@elyx-code/project-logic-tree 0.0.6349 → 0.0.6350

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
@@ -97389,9 +97389,7 @@ const Ge = class Ge extends hr {
97389
97389
  undo() {
97390
97390
  console.log("Undoing, from: ", this.undoableStackValueIndex), this.undoableStackValueIndex = this.undoableStackValueIndex - 1, console.log("To: ", this.undoableStackValueIndex);
97391
97391
  const i = this.history[this.undoableStackValueIndex + 1], a = this.history[this.undoableStackValueIndex];
97392
- return console.log("Current change set: ", i), console.log("Change set to restore: ", a.toJSON()), // @ts-ignore
97393
- O$(
97394
- // @ts-ignore
97392
+ return console.log("Current change set: ", i), console.log("Change set to restore: ", a == null ? void 0 : a.toJSON()), O$(
97395
97393
  i || "initial",
97396
97394
  a || "initial",
97397
97395
  this
@@ -97402,7 +97400,6 @@ const Ge = class Ge extends hr {
97402
97400
  console.log("Undoing, from: ", this.undoableStackValueIndex), this.undoableStackValueIndex = this.undoableStackValueIndex + 1, console.log("To: ", this.undoableStackValueIndex);
97403
97401
  const i = this.history[this.undoableStackValueIndex - 1], a = this.history[this.undoableStackValueIndex];
97404
97402
  return console.log("Current change set: ", i), console.log("Change set to restore: ", a.toJSON()), O$(
97405
- // @ts-ignore
97406
97403
  i || "initial",
97407
97404
  a || "initial",
97408
97405
  this
@@ -400,5 +400,5 @@ If an entity is called by another, they must be in the same scope, which means t
400
400
  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:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];if(a==="declaration"){const{updated:T,added:w,removed:A}=this.remove({ignoreUpstream:!1},l);p.push(...T),t.push(...w),y.push(...A)}if(a==="parent"){const{updated:T,added:w,removed:A}=this.remove({ignoreUpstream:!1},l);p.push(...T),t.push(...w),y.push(...A)}return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];if(a==="declaration"){const{updated:T,added:w,removed:A}=this.restore({},l);p.push(...T),t.push(...w),y.push(...A)}if(a==="parent"){const{updated:T,added:w,removed:A}=this.restore({},l);p.push(...T),t.push(...w),y.push(...A)}return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){var i;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"parent"}]),this.declaration.unsubscribeDependents([{entity:this,field:"declaration"}]),this}subscribeToDependencies(){var i;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),this.declaration.subscribeDependents([{entity:this,field:"declaration"}]),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Mt(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.error=this.error,i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.process=this.process,i.declaration=this.declaration,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const T=new Map;for(const[w,A]of this.knownVersions||new Map){if(T.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,N]of A.knownVersions)T.set(V,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Mt(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.error=y.error,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.process=y.process,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=W(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.declaration){const l=W(i.declaration),p=this.project.get(l);p&&this.setDeclaration(p)}return i.calledByEntry.forEach(l=>{const p=W(l),t=this.project.get(p);t&&(this.addEntryCaller(t,a),t.addCall(this,a))}),[...this.calledByEntry].forEach(l=>{i.calledByEntry.find(t=>W(t)===l.id)||(this.removeCaller(l,a),l.removeCall(this,a))}),i.calledBySuccess.forEach(l=>{const p=W(l),t=this.project.get(p);t&&(this.addSuccessCaller(t,a),t.addSuccessCall(this,a))}),[...this.calledBySuccess].forEach(l=>{i.calledBySuccess.find(t=>W(t)===l.id)||(this.removeCaller(l,a),l.removeCall(this,a))}),i.calledByError.forEach(l=>{const p=W(l),t=this.project.get(p);t&&(this.addErrorCaller(t,a),t.addErrorCall(this,a))}),[...this.calledBySuccess].forEach(l=>{i.calledBySuccess.find(t=>W(t)===l.id)||(this.removeCaller(l,a),l.removeCall(this,a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' 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 t=W(this.initialData.declaration),y=this.project.get(t);y&&(this.setDeclaration(y),i.push(y))}return this.initialData.calledByEntry.forEach(t=>{const y=W(t),v=this.project.get(y);v&&this.addEntryCaller(v,null)}),this.initialData.calledBySuccess.forEach(t=>{const y=W(t),v=this.project.get(y);v&&this.addSuccessCaller(v,null)}),this.initialData.calledByError.forEach(t=>{const y=W(t),v=this.project.get(y);v&&this.addErrorCaller(v,null)}),{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:T}=this.syncInputs(i),{updated:w,added:A,removed:V}=this.syncOutputs(i);return a.push(...y,...w),l.push(...v,...A),p.push(...T,...V),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){var y;const a=[this],l=[],p=[],t=[];return this.parent===this.project&&this.project.addFunctionCall(this),(y=this.process)==null||y.writesValues.forEach(v=>{v.setValueWriter(this.process,i),a.push(v)}),this.successCalls.forEach(v=>{v.addSuccessCaller(this,i),a.push(v)}),this.errorCalls.forEach(v=>{v.addErrorCaller(this,i),a.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,i),a.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,i),a.push(v)}),this.calledByEntry.forEach(v=>{v.addCall(this,i),a.push(v)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-input"))){const l=this.inputs.findIndex(p=>p.id===i.id);return l>-1&&(this.inputs.splice(l,1),a&&(a==null||a.add(this,K.Affected))),a==null||a.attemptAutoclose("remove-input",this.id),this}addInput(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-input"))){return this.inputs.includes(i)?(a==null||a.attemptAutoclose("add-input",this.id),this):(this.inputs.push(i),a==null||a.add(this,K.Affected),a==null||a.attemptAutoclose("add-input",this.id),this)}addOutput(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-output"))){return this.outputs.includes(i)?(a==null||a.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),a==null||a.add(this,K.Affected),a==null||a.attemptAutoclose("add-output",this.id),this)}removeOutput(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-output"))){const l=this.outputs.findIndex(p=>p.id===i.id);return l>-1&&(this.outputs.splice(l,1),a&&(a==null||a.add(this,K.Affected))),a==null||a.attemptAutoclose("remove-output",this.id),this}addValueReader(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-value-reader"))){var l;return this.process&&!this.process.writesValues.includes(i)&&((l=this.process)==null||l.addValueReader(i,a),a==null||a.add(this,K.Affected)),a==null||a.attemptAutoclose("add-value-reader",this.id),this}removeValueReader(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-value-reader"))){var l;return this.process&&this.process.writesValues.includes(i)&&((l=this.process)==null||l.removeValueReader(i,a),a==null||a.add(this,K.Affected)),a==null||a.attemptAutoclose("remove-value-reader",this.id),this}addSuccessCaller(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-success-caller")),l=!1){return this.calledBySuccess.find(p=>p.id===i.id)||(this.calledBySuccess.push(i),a==null||a.add(this,K.Updated),l&&je(this,a)),a==null||a.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-error-caller")),l=!1){return this.calledByError.find(p=>p.id===i.id)||(this.calledByError.push(i),a==null||a.add(this,K.Updated),l&&je(this,a)),a==null||a.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-entry-caller")),l=!1){return this.calledByEntry.find(p=>p.id===i.id)||(this.calledByEntry.push(i),a==null||a.add(this,K.Updated),l&&je(this,a)),a==null||a.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-error-call")),l=!1){return this.errorCalls.find(p=>p.id===i.id)||(this.errorCalls.push(i),l&&je(this,a),a==null||a.add(this,K.Affected)),a==null||a.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-success-call")),l=!1){return this.successCalls.find(p=>p.id===i.id)||(this.successCalls.push(i),l&&je(this,a),a==null||a.add(this,K.Affected)),a==null||a.attemptAutoclose("add-success-call",this.id),this}removeCall(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-call")),l=!1){const p=this.successCalls.findIndex(y=>y.id===i.id);p>-1&&(this.successCalls.splice(p,1),a==null||a.add(this,K.Affected));const t=this.errorCalls.findIndex(y=>y.id===i.id);return t>-1&&(this.errorCalls.splice(t,1),a==null||a.add(this,K.Affected)),l&&je(this,a),a==null||a.attemptAutoclose("remove-call",this.id),this}removeCaller(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-caller")),l=!1){return this.calledBySuccess=this.calledBySuccess.filter(p=>p.id!==i.id?!0:(a==null||a.add(this,K.Updated),a==null||a.add(p,K.Affected),!1)),this.calledByError=this.calledByError.filter(p=>p.id!==i.id?!0:(a==null||a.add(this,K.Updated),a==null||a.add(p,K.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(p=>p.id!==i.id?!0:(a==null||a.add(this,K.Updated),a==null||a.add(p,K.Affected),!1)),l&&je(this,a),a==null||a.attemptAutoclose("remove-caller",this.id),this}setParent(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setDeclaration(i){return this.declaration=i,this}initChildren(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.declaration.type===f.FunctionDeclaration){const a=ee(this.initialData.declaration,this.project);this.declaration=a}else{const a=W(this.initialData.declaration),l=this.project.get(a);this.declaration=l}return this.successCalls=this.initialData.successCalls.map(a=>{const l=ee(a,this.project);if(l.addSuccessCaller(this),[f.BreakStatement,f.ContinueStatement].includes(l.type))l.setParent(this.parent.parent,null),l.initChildren(i);else if(l.type===f.ReturnStatement){const p=$r(this,this.project);l.setParent(p,null),l.initChildren(i)}else l.type!==f.InternalCall&&(l.setParent(this.parent,null),l.initChildren(i));return l}),this.errorCalls=this.initialData.errorCalls.map(a=>{const l=ee(a,this.project);if(l.addErrorCaller(this),[f.BreakStatement,f.ContinueStatement].includes(l.type))l.setParent(this.parent.parent,null),l.initChildren(i);else if(l.type===f.ReturnStatement){const p=$r(this,this.project);l.setParent(p,null),l.initChildren(i)}else l.type!==f.InternalCall&&(l.setParent(this.parent,null),l.initChildren(i));return l}),this.inputs=this.initialData.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.initialData.process&&(this.process=ee(this.initialData.process,this.project),this.process.setParent(this,null),this.process.initChildren(i)),this.initialData.error&&(this.error=ee(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Er(this,i),p=this.toMeta();return this.x=i.x||p.x,this.y=i.y||p.y,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Mt.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Mt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Mt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Mt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Mt.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Mt.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];return this.parent.type===f.Project?(this.parent.removeFunctionCall(this),t.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(l),affected:R(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){var v;const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(T=>{const{updated:w,removed:A,added:V}=T.entity.onDetachedDependencyRemoved(this,T.field,a);l.push(...w),p.push(...A),t.push(...V)}),this.process){const{updated:T,removed:w}=(v=this.process)==null?void 0:v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}if(this.inputs.forEach(T=>{const{updated:w,removed:A}=T.remove({ignoreUpstream:!0},a);l.push(...w),p.push(...A)}),this.outputs.forEach(T=>{const{updated:w,removed:A}=T.remove({ignoreUpstream:!0},a);l.push(...w),p.push(...A)}),this.error){const{updated:T,removed:w}=this.error.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}if(this.successCalls.forEach(T=>{l.push(T),T.removeCaller(this,a)}),this.errorCalls.forEach(T=>{l.push(T),T.removeCaller(this,a)}),!i){const T=this.removeFromParent(a);t.push(...T.added),l.push(...T.updated),p.push(...T.removed),y.push(...T.affected),this.calledBy.forEach(w=>{l.push(w),w.removeCall(this,a)})}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(p),affected:R(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:T,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...T),a.push(...w)}),this.process){const{updated:y}=this.process.restore({},i);l.push(...y)}return this.inputs.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.outputs.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.successCalls.forEach(y=>{l.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{l.push(y),y.addErrorCaller(this,i)}),this.calledBySuccess.forEach(y=>{l.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{l.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{l.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(l),removed:R(p),affected:R(t),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.successCalls.flatMap(l=>l.toFlat(i)),...this.errorCalls.flatMap(l=>l.toFlat(i)),...this.inputs.flatMap(l=>l.toFlat(i)),...this.outputs.flatMap(l=>l.toFlat(i)),...this.process?this.process.toFlat(i):[],...this.error?this.error.toFlat(i):[],...this.calledBy.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.successCalls.flatMap(l=>l.toFlatIds(i)),...this.errorCalls.flatMap(l=>l.toFlatIds(i)),...this.inputs.flatMap(l=>l.toFlatIds(i)),...this.outputs.flatMap(l=>l.toFlatIds(i))])}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(i=new Set){var a,l;return i.has(this.id)?this.toReference():(i.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,successCalls:this.successCalls.map(p=>p.toJSON(i)),errorCalls:this.errorCalls.map(p=>p.toJSON(i)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference()),calledByError:this.calledByError.map(p=>p.toReference()),calledByEntry:this.calledByEntry.map(p=>p.toReference()),process:(a=this.process)==null?void 0:a.toJSON(i),declaration:this.declaration.toJSON(i),inputs:this.inputs.map(p=>p.toJSON(i)),outputs:this.outputs.map(p=>p.toJSON(i)),parent:this.parent.toReference(),error:(l=this.error)==null?void 0:l.toJSON(i)})}toJSONClone(i=Ne){var l,p,t,y,v,T,w;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Ar(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(A=>A.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(A=>A.toJSONClone({...i,newId:null})),calledBySuccess:this.calledBySuccess.map(A=>A.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(A=>A.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(A=>A.toReference({seenEntityMaps:i.seenEntityMaps})),process:(T=this.process)==null?void 0:T.toJSONClone({...i,newId:null}),declaration:this.declaration.toJSONClone({...i,newId:null}),inputs:this.inputs.map(A=>A.toJSONClone({...i,newId:null})),outputs:this.outputs.map(A=>A.toJSONClone({...i,newId:null})),error:(w=this.error)==null?void 0:w.toJSONClone({...i,newId:null}),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference(i):null,inputs:this.inputs.map(p=>p.toReference(i)),outputs:this.outputs.map(p=>p.toReference(i)),declaration:this.declaration.toReference(i),successCalls:this.successCalls.map(p=>p.toReference(i)),errorCalls:this.errorCalls.map(p=>p.toReference(i)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference(i)),calledByError:this.calledByError.map(p=>p.toReference(i)),calledByEntry:this.calledByEntry.map(p=>p.toReference(i)),error:this.error?this.error.toReference(i):null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(l=>l.toFlatJSON(i)),...this.errorCalls.flatMap(l=>l.toFlatJSON(i)),...this.inputs.flatMap(l=>l.toFlatJSON(i)),...this.outputs.flatMap(l=>l.toFlatJSON(i)),...this.process?this.process.toFlatJSON(i):[],...this.error?this.error.toFlatJSON(i):[]])}toGenerationTarget(){const i=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,calledByEntry:this.calledByEntry.map(a=>a.id),calledBySuccess:this.calledBySuccess.map(a=>a.id),calledByError:this.calledByError.map(a=>a.id),declaration:this.declaration.id,parent:i}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(l=>l.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(l=>l.toFlatGenerationTarget(i)),...this.inputs.flatMap(l=>l.toFlatGenerationTarget(i)),...this.outputs.flatMap(l=>l.toFlatGenerationTarget(i)),...this.process?this.process.toFlatGenerationTarget(i):[],...this.error?this.error.toFlatGenerationTarget(i):[]])}clearErrors(){var i,a;return this.errors=[],this.inputs.forEach(l=>l.clearErrors()),this.outputs.forEach(l=>l.clearErrors()),this.successCalls.forEach(l=>l.clearErrors()),this.errorCalls.forEach(l=>l.clearErrors()),(i=this.process)==null||i.clearErrors(),(a=this.error)==null||a.clearErrors(),this}validate(){const i=hj(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var j,k;let t=Ir(a,this);const y=this.toJSON(),v=l||P.UUID.uuid();y.inputs=[];const T=v.split("-id"),w=T[T.length-1||0]||v;y.id=v,y.version=P.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const A=Kt(y,t);a?A.setParent(a,null):A.setParent(this.parent,null),p&&A.subscribe(),A.initChildren(i),i==null||i.add(A,K.Added);const V=(j=this.inputs)==null?void 0:j.map((q,Y)=>q.clone(i,A,w+"-input-map-"+Y+"-id",p));A.inputs=V;const N=(k=this.outputs)==null?void 0:k.map((q,Y)=>q.clone(i,A,w+"-output-map-"+Y+"-id",p));return A.outputs=N,this.error&&(A.error=this.error.clone(i,A,w+"-error-map-id",p)),this.process&&(A.process=this.process.clone(i,A,w+"-process-id",p)),i==null||i.attemptAutoclose("clone-entity",this.id),A}removeUnrecognizedInputs(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-inputs"))){const a=[],l=[],p=[],t=[];return this.inputs.forEach(v=>{if(!this.declaration.inputs.find(w=>{var A;return w.id===((A=v.declaration)==null?void 0:A.id)})){const w=v.remove({ignoreUpstream:!1},i);p.push(...w.removed),a.push(...w.updated)}}),this.inputs.filter((v,T)=>{const w=this.inputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(w===-1)return!1;const A=this.inputs[w];return L(A==null?void 0:A.createdAt).isSame(L(v.createdAt))?T>w:!!L(A==null?void 0:A.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);p.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-inputs",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-outputs"))){const a=[],l=[],p=[],t=[];return this.outputs.forEach(v=>{if(!this.declaration.getUniqueReturnDeclarations().find(w=>{var A;return w.id===((A=v.declaration)==null?void 0:A.id)})){const w=v.remove({ignoreUpstream:!1},i);p.push(...w.removed),a.push(...w.updated)}}),this.outputs.filter((v,T)=>{const w=this.outputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(w===-1)return!1;const A=this.outputs[w];return L(A==null?void 0:A.createdAt).isSame(L(v.createdAt))?T>w:!!L(A==null?void 0:A.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);p.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-outputs",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}syncInputs(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-missing-fixed-inputs"))){const a=[],l=[],p=[],t=[],y=this.declaration.inputs.filter(A=>!this.inputs.find(V=>V.declaration.id===A.id));this.inputs.sort((A,V)=>A.index-V.index),y.forEach(A=>{this.inputs.forEach(j=>{j.index>=A.index&&j.metaSync({index:j.index+1},i)});const V={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.InputMap,declaration:A.toJSON(),readsValue:null,defaultValue:null,index:A.index,name:null,codeName:null,description:null,parent:this.toReference()},N=ee(V,this.project);N.setParent(this,i),N.initChildren(i),i==null||i.add(N,K.Added),N.addSelfToProject(i),l.push(N)}),this.inputs.sort((A,V)=>A.index-V.index);const{updated:v,added:T,removed:w}=this.removeUnrecognizedInputs(i);return a.push(...v),l.push(...T),p.push(...w),i==null||i.attemptAutoclose("sync-missing-fixed-inputs",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}syncOutputs(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-missing-fixed-outputs"))){const a=[],l=[],p=[],t=[],y=[];this.outputs=this.initialData.outputs.reduce((V,N)=>{if(N.type===f.GenericReference){const k=_i(N,this.project);return k?[...V,k]:V}const j=ee(N,this.project);return y.push(j.index),j.setParent(this,null),j.initChildren(i),[...V,j]},[]);const v=this.declaration.getUniqueReturnDeclarations().filter(V=>!this.outputs.find(N=>N.declaration.id===V.id));this.outputs.sort((V,N)=>V.index-N.index),v.forEach((V,N)=>{this.outputs.forEach(Y=>{Y.index>=V.index&&Y.index++});const j=y.includes(V.index)?this.outputs.length-1+N:V.index,k={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.OutputMap,declaration:V.toJSON(),defaultValue:null,writesValues:[],index:j,parent:this.toReference()},q=ee(k,this.project);q.setParent(this,i),q.initChildren(i),i==null||i.add(q,K.Added),q.addSelfToProject(i)}),this.outputs.sort((V,N)=>V.index-N.index);const{updated:T,added:w,removed:A}=this.removeUnrecognizedOutputs(i);return a.push(...T),l.push(...w),p.push(...A),i==null||i.attemptAutoclose("sync-missing-fixed-outputs",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}};D(Mt,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(Mt,"type",f.FunctionCall),D(Mt,"USER_MANAGED_PARENT_TYPES",[...br,f.Project]),D(Mt,"PARENT_TYPES",[...Mt.USER_MANAGED_PARENT_TYPES]),D(Mt,"MUTABLE_BASE_PROPERTIES",[]),D(Mt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(Mt,"BASE_PROPERTIES",[...Mt.MUTABLE_BASE_PROPERTIES,...Mt.INMUTABLE_BASE_PROPERTIES]),D(Mt,"MUTABLE_META_PROPERTIES",["x","y"]),D(Mt,"INMUTABLE_META_PROPERTIES",[...Mt.INMUTABLE_BASE_PROPERTIES]),D(Mt,"META_PROPERTIES",[...Mt.MUTABLE_META_PROPERTIES,...Mt.INMUTABLE_META_PROPERTIES]),D(Mt,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),D(Mt,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),D(Mt,"UPSTREAM_PROPERTIES",[...Mt.MUTABLE_UPSTREAM_PROPERTIES,...Mt.INMUTABLE_UPSTREAM_PROPERTIES]),D(Mt,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),D(Mt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(Mt,"DOWNSTREAM_PROPERTIES",[...Mt.MUTABLE_DOWNSTREAM_PROPERTIES,...Mt.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(Mt,"PROPERTIES",[...Mt.META_PROPERTIES,...Mt.UPSTREAM_PROPERTIES,...Mt.DOWNSTREAM_PROPERTIES]);let za=Mt;function sA(d){return d&&typeof d.then=="function"}function cme(d){const u=new ha(d[0]),i=d.map(l=>l.id),a={};return d.forEach(l=>{a[l.id]=l}),u.order=i,u.flatRecord=a,u.orderEntities(),u.order.map(l=>u.flatRecord[l])}class ha{constructor(u){D(this,"order",[]);D(this,"flatRecord",{});D(this,"allBuiltInEntityIds",Ps());D(this,"onGoingVisits",{});u&&(this.flatten(u),this.orderEntities())}flatten(u){const i=new Set(Ps()),a=R(he(u,i,{ignoreBuiltInBaseEntities:!0})),l=new Set;for(const p of a)this.flatRecord[p.id]=p,l.add(p.id);this.order=Array.from(l)}moveEntityAfterDependencies(u){const{upstream:i}=Rd(u,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});for(const a of Object.keys(i)){const l=this.order.indexOf(a),p=this.order.indexOf(u.id);if(l>p)return this.order.splice(p,1),this.order.splice(l,0,u.id),!0}return!1}orderEntities(){let u=!1;for(let i=0;i<this.order.length;i++){const a=this.order[i],l=this.flatRecord[a];if(l||console.warn(`Entity with id ${a} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(l)){u=!0;break}}u&&this.orderEntities()}getUpstreamOngoingDependenciesVisits(u,i){const{upstream:a}=Rd(this.flatRecord[u],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}),l={};return Object.entries(this.onGoingVisits[i]||{}).forEach(([p,t])=>{Object.keys(a).includes(p)&&(l[p]=t)}),l}getDownstreamOngoingDependenciesVisits(u,i){const a=Object.keys(this.onGoingVisits[i]||{}),l=new Set(a.flatMap(t=>Object.keys(Rd(this.flatRecord[t],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}).downstream))),p={};return Array.from(l).forEach(t=>{t===u&&(p[t]=this.onGoingVisits[i][t])}),p}async settlePromises(u,i){const a=Object.values(u);a.length&&await Promise.all(a),Object.keys(u).forEach(l=>{delete this.onGoingVisits[i][l]})}visit(u){const i=this.order;for(const a of i)u(this.flatRecord[a],this.flatRecord);return this}reverseVisit(u){const i=this.order.slice().reverse();for(const a of i)u(this.flatRecord[a],this.flatRecord);return this}async visitAsync(u){const i=this.order,a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const l of i){const p=this.getUpstreamOngoingDependenciesVisits(l,a);Object.keys(p).length&&await this.settlePromises(p,a);const t=u(this.flatRecord[l],this.flatRecord);sA(t)&&(this.onGoingVisits[a][l]=t)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}async reverseVisitAsync(u){const i=this.order.slice().reverse(),a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const l of i){const p=this.getDownstreamOngoingDependenciesVisits(l,a);Object.keys(p).length&&await this.settlePromises(p,a);const t=u(this.flatRecord[l],this.flatRecord);sA(t)&&(this.onGoingVisits[a][l]=t)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}}function mj(d,u){switch(d.id){case Ee["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=d.project.entities.filter(v=>!!v.implements.find(T=>T.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),a=i.find(v=>{const T=v.properties.find(V=>V.implements&&V.implements.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),w=T==null?void 0:T.getDefaultValue();return(w==null?void 0:w.value)===!0});if(!a&&i.length){const T=i[0].properties.find(A=>A.implements&&A.implements.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),w=T==null?void 0:T.defaultValue;if(w)w.metaSync({value:!0},u);else if(T!=null&&T.dataType){const A={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:X.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:T==null?void 0:T.toReference()},V=ee(A,d.project);return V.setParent(T,u),V.initChildren(u),u==null||u.add(V,K.Added),V.addSelfToProject(u),{newEntities:[V]}}return{newEntities:[]}}else if(a)return{newEntities:[]};const l=d.project.get(Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),p=Fy(l,"Main database",u);if(p.errors.length>0)return{newEntities:[]};const t=p.properties.find(v=>v.implements&&v.implements.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=t==null?void 0:t.defaultValue;if(y)y.metaSync({value:!0},u);else if(t!=null&&t.dataType){const v={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:X.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:t==null?void 0:t.toReference()},T=ee(v,d.project);T.setParent(t,u),T.initChildren(u),u==null||u.add(T,K.Added),T.addSelfToProject(u)}return{newEntities:[p]}}}return{newEntities:[]}}function vj(d,u){const i=[],a=[],l=[],p=[];return d.implements.filter(y=>y.type===f.BuiltInBaseEntity).forEach(y=>{var v;switch(y.id){case Ee["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const T=d.project.entities.filter(N=>N.implements.find(j=>j.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let w=T.find(N=>!!N.properties.find(j=>{var k;return j.implements&&j.implements.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((k=j.getDefaultValue())==null?void 0:k.value)===!0}));if(!w&&T.length)w=T[0];else if(!w&&!T.length){w=d.project.getBuiltIn(Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",u);const j=w.properties.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id});(v=j==null?void 0:j.defaultValue)==null||v.metaSync({value:!0},u),a.push(w)}const A=d.properties.find(N=>N.implements&&N.implements.id===Ee["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),V=A==null?void 0:A.defaultValue;if(A&&!V){const N={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(u==null?void 0:u.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:X.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:(w==null?void 0:w.toJSON())||null,valueAsTypeList:null,parent:A==null?void 0:A.toReference()},j=ee(N,d.project);j.hydrateAncestors(),j.setParent(A,u),j.addSelfToProject(u),j.initChildren(u),u==null||u.add(j,K.Added),a.push(j);return}else V&&!V.valueAsTypeSingle&&V.setValueAsTypeSingle(w||null,u);return}}}),{self:d,updated:R(i),added:R(a),removed:R(l),affected:R(p)}}function Fy(d,u,i,a){const l=a||P.UUID.uuid(),p=P.UUID.uuid(),t={id:l,version:p,createdAt:(i==null?void 0:i.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:u,type:f.DefinitionEntity,codeName:null,description:null,static:d.static,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[d.toJSON()],x:0,y:0,parent:d.project.toReference()};mj(d,i);const y=ee(t,d.project);return y.hydrateAncestors(),i==null||i.add(y,K.Added),y.addSelfToProject(i),y.addImplementation(d),y.setParent(d.project,i),y.initChildren(i),vj(y,i),y}function nA(d,u){return u.entities.find(l=>{const p=l.properties,t=p.map(A=>A.name),y=d.every(A=>t.includes(A)),v=t.filter(A=>!d.includes(A)),T=p.every(A=>!v.includes(A.name)||!A.required);return y&&T})||null}function Ej(d,u,i,a=Zr.OrDataTypeGroup){const l=[],p=[],t=[],y=[],T={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:d.toJSON(),isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,like:!0,inferred:!1,parentRelationType:a,parent:u.toReference()},w=ee(T,d.project);return p.push(w),w.setParent(u,i),w.initChildren(i),i==null||i.add(w,K.Added),w.setEntity(d,i),w.addSelfToProject(i),{updated:R(l),added:R(p),removed:R(t),affected:R(y),self:w}}function aA(d,u,i,a,l){var T,w,A,V,N,j,k,q;const p=[],t=[],y=[],v=[];switch(typeof d){case"string":let Y=!1;const ie=new Date(d);if(ie instanceof Date&&!isNaN(ie.valueOf())&&(Y=!0),Y){const te=u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Date].id);u.setEntity(te,a);break}else{const te=u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.String].id);u.setEntity(te,a);break}case"number":u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Number].id),a);break;case"boolean":u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Boolean].id),a);break;case"object":if(d===null){u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Null].id),a);break}else if(Array.isArray(d))if(u.metaSync({isList:!0},a),d.length>0){const te=d.slice(0,5).filter(ne=>ne!==void 0);if(te.every(ne=>typeof ne==typeof te[0])&&(typeof te[0]!="object"||te[0]===null))switch(typeof te[0]){case"string":u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.String].id),a);break;case"number":u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Number].id),a);break;case"boolean":u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Boolean].id),a);break;case"object":u.setEntity(u.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Null].id),a);break}else{const ne=[];let me=!1;te.forEach(ae=>{var ce,H,de,ve;if(Array.isArray(ae)&&(me=!0),typeof ae=="object"&&!Array.isArray(ae)&&ae!==null){const Pe=Gy(ae,u.project,{...i,id:P.UUID.uuid()},a,l);Pe.hasCreated&&ne.push((ce=Pe.changeSet)==null?void 0:ce.self),p.push(...(H=Pe.changeSet)==null?void 0:H.updated),t.push(...(de=Pe.changeSet)==null?void 0:de.added),y.push(...(ve=Pe.changeSet)==null?void 0:ve.removed)}});const J=R(ne);if(!J.length&&!me){te.forEach(ae=>{const ce={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:Zr.OrDataTypeGroup,parent:u.toReference()},H=ee(ce,u.project);switch(H.setParent(u,a),H.initChildren(a),a==null||a.add(H,K.Added),H.addSelfToProject(a),typeof ae){case"string":H.setEntity(H.project.getBuiltIn(Ee[f.PrimitiveEntity][X.String].id),a);break;case"number":H.setEntity(H.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Number].id),a);break;case"boolean":H.setEntity(H.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Boolean].id),a);break;case"object":H.setEntity(H.project.getBuiltIn(Ee[f.PrimitiveEntity][X.Null].id),a);break}});break}else J.length===1&&!me?u.setEntity(J[0],a):te.forEach(ae=>{if(typeof ae=="object"&&!Array.isArray(ae)&&ae!==null){const ce=nA(Object.keys(ae),u.project);if(ce){const H=Ej(ce||J[0],u,a,Zr.OrDataTypeGroup);p.push(...H.updated),t.push(...H.added),y.push(...H.removed)}}else{const ce={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:Array.isArray(ae),asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:Zr.OrDataTypeGroup,parent:u.toReference()},H=ee(ce,u.project);H.setParent(u,a),H.initChildren(a),a==null||a.add(H,K.Added),H.addSelfToProject(a);const de=aA(ae,H,{...i,id:P.UUID.uuid()},a,l);p.push(...de.updated),t.push(...de.added),y.push(...de.removed)}})}}else{const te=Gy(d[0],u.project,{...i},a,l);u.setEntity((T=te.changeSet)==null?void 0:T.self,a),p.push(...(w=te.changeSet)==null?void 0:w.updated),t.push(...(A=te.changeSet)==null?void 0:A.added),y.push(...(V=te.changeSet)==null?void 0:V.removed);break}else{const te=Gy(d,u.project,{...i},a,l);u.setEntity((N=te.changeSet)==null?void 0:N.self,a),p.push(...(j=te.changeSet)==null?void 0:j.updated),t.push(...(k=te.changeSet)==null?void 0:k.added),y.push(...(q=te.changeSet)==null?void 0:q.removed);break}}return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:u}}function Gy(d,u,i,a,l){const p=[],t=[],y=[],v=[],T=Object.keys(d),w=nA(T,u);if(w)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:w}};const A=l?i.name+" of "+l.name:i.name,N={id:i.id||P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:A,codeName:null,type:f.DefinitionEntity,description:i.description||null,static:i.static||!1,abstract:i.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:u.toReference()},j=ee(N,u);return j.setParent(u,a),j.initChildren(a),a==null||a.add(j,K.Added),j.addSelfToProject(a),t.push(j),T.forEach((k,q)=>{const ie={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:k,type:f.Property,codeName:k,description:null,static:!1,abstract:!1,defaultValue:null,constant:!1,dataType:null,implements:null,extends:null,index:q,hidden:!1,private:!1,required:!0,parent:j.toReference()},te=ee(ie,u);te.setParent(j,a),te.initChildren(a),a==null||a.add(te,K.Added),te.addSelfToProject(a),t.push(te);const pe=d[k],me={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parent:te.toReference()},J=ee(me,u);J.setParent(te,a),J.initChildren(a),a==null||a.add(J,K.Added),J.addSelfToProject(a),t.push(J);const ae=aA(pe,J,{...i,name:k,id:P.UUID.uuid()},a,l||j);p.push(...ae.updated),t.push(...ae.added),y.push(...ae.removed)}),{hasCreated:!0,changeSet:{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:j}}}function ya(d,u,i,a){const l=[];return!d.length||!u.length?{errors:l,overlap:!1}:(d.length>u.length?d.forEach(p=>{const t=u.find(v=>v.name===p.name),y=u.find(v=>{var T,w;return!!p.implements&&((T=v.implements)==null?void 0:T.id)===((w=p.implements)==null?void 0:w.id)});if(t){const v=new qt({id:p.id+"--"+t.id+"--"+a,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${t.type} ${t.name} with id "${t.id}" that has the same name`,issue:null,severity:Z.Error,code:a,entity:p,firstRelationship:t});l.push(v)}if(y){const v=new qt({id:p.id+"--"+y.id+"--"+i,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${y.type} ${y.name} with id "${y.id}" that implements the same base descriptor`,issue:null,severity:Z.Error,code:i,entity:p,firstRelationship:y});l.push(v)}}):u.forEach(p=>{var v;const t=d.find(T=>T.name===p.name),y=d.find(T=>{var w,A;return!!T.implements&&((w=T.implements)==null?void 0:w.id)===((A=p.implements)==null?void 0:A.id)});if(t){const T=new qt({id:t.id+"--"+p.id+"--"+a,message:`Entity of type ${t.type} named "${t.name}" with id "${t.id}" overrides a base entity ${p.name} with id "${p.id}" that has the same name`,issue:null,severity:Z.Error,code:a,entity:t,firstRelationship:p});l.push(T)}if(y){const T=new qt({id:y.id+"--"+p.id+"--"+i,message:`Entity of type ${y.type} named "${y.name}" with id "${y.id}" overrides a base entity ${p.name} with id "${p.id}" that implements the same base ${(v=y==null?void 0:y.implements)==null?void 0:v.type}`,issue:null,severity:Z.Error,code:i,entity:y,firstRelationship:p});l.push(T)}}),{errors:l,overlap:!!l.length})}function pme(d,u){return d.abstract||(d.properties.forEach(a=>{a.abstract||a.metaSync({abstract:!0},u)}),Object.values(d.detachedDependents).forEach(a=>{a.field===gb.Entity&&a.entity.remove({ignoreUpstream:!1},u)}),d.metaSync({abstract:!0},u)),d}function fme(d,u){return d.abstract&&(d.properties.forEach(a=>{a.abstract&&a.metaSync({abstract:!1},u)}),Object.values(d.detachedDependents).forEach(a=>{(a.field===Qy.Implements||a.field===Qy.Extends)&&a.entity.onDetachedDependencyRemoved(d,a.field,u)}),d.metaSync({abstract:!1},u)),d}function hme(d,u){return d.static||(d.properties.forEach(a=>{a.static||a.metaSync({static:!0},u)}),d.metaSync({static:!0},u)),d}function yme(d,u){return d.static&&d.metaSync({static:!1},u),d}var Tj=(d=>(d.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",d.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",d))(Tj||{});function bj(d,u){const i=[],a=u;if(!a)return{errors:i,override:u};if(typeof a!="string")return{errors:[],override:u};if(a.includes(" ")){const l=new qt({id:d.id+"--string-value-must-not-have-spaces",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces.`,issue:null,severity:Z.Error,code:"string-value-must-not-have-spaces",entity:d});i.push(l)}return{errors:i,override:a.replace(/\s/g,"-")}}function Aj(d,u){const i=[],a=u;if(!a)return{errors:i,override:u};if(typeof a!="string")return{errors:[],override:u};if(a.includes(" ")){const l=new qt({id:d.id+"--string-value-must-not-have-spaces",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces or dashes.`,issue:null,severity:Z.Error,code:"string-value-must-not-have-spaces",entity:d});i.push(l)}if(a.includes("-")){const l=new qt({id:d.id+"--string-value-must-not-have-dashes",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value cannot contain spaces or dashes.`,issue:null,severity:Z.Error,code:"string-value-must-not-have-dashes",entity:d});i.push(l)}return{errors:i,override:a.replace(/\s|-/g,"_")}}function oA(d,u){var i;if(d.type===f.LiteralValue){let a=(i=d.value)==null?void 0:i.toString();try{a=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${re(d,u)}) = ${a}`}if(d.type===f.DataType){if(d instanceof Hi||d.increaseVersion)return`${d.type}: ${d.id} (${yd(d)})`;try{const a=yd(d);return`${d.type}: ${d.id} (${a})`}catch{}}return`${d.type}: ${d.id} (${re(d,u)})`}function wd(d,u){const i=Xa(d);if(i.length===0)return{list:[],last:null};let a=null;return{list:i.flatMap(p=>{if(p===u)return a=p,[p];const t=wd(p,u);return t.last&&(a=t.last),[p,...t.list]}),last:a}}function lA(d){const u=d.calledBy;if(u.length===0)return d.project;const i=u.reduce((a,l)=>{const p=Ri(l,d.project);return!p||p.type===f.Project?a:a.type===f.Project||wd(p,a).last?p:(wd(a,p).last,a)},d.project);return i.type===f.FunctionDeclaration&&i.parent.type===f.Loop?i.parent:i}function je(d,u){var l,p;let i=lA(d);if(d.type===f.InternalCall)(l=d.parent)==null||l.setParent(i,u),(p=d.parent)==null||p.addSelfToProject(u);else if((d.type===f.ContinueStatement||d.type===f.BreakStatement)&&i.type!==f.Loop){d.remove({ignoreUpstream:!1},u);return}else if(d.type===f.ReturnStatement&&!br.includes(i.type)){d.remove({ignoreUpstream:!1},u);return}else d.setParent(i,u),d.addSelfToProject(u);if(rr.includes(d.type))return;ut(d).forEach(t=>{var v,T;const y=lA(t);if(t.type===f.InternalCall)(v=t.parent)==null||v.setParent(y,u),(T=t.parent)==null||T.addSelfToProject(u);else if((t.type===f.ContinueStatement||t.type===f.BreakStatement)&&y.type!==f.Loop){t.remove({ignoreUpstream:!1},u);return}else if(t.type===f.ReturnStatement&&!br.includes(y.type)){t.remove({ignoreUpstream:!1},u);return}else t.setParent(y,u),t.addSelfToProject(u)})}function Ky(d,u,i=new Set){const a=tn(d),l=tn(u),p=a.filter(v=>!l.includes(v)),t=a.filter(v=>l.includes(v)),y=p.reduce((v,T)=>i.has(T.id)?v:(i.add(T.id),R([...v,...Ky(T,u,i)])),[]);return R([...t,...y])}function Wo(d,u){const i=wd(d,u);return i.last===u&&i.list.length>0&&i.list[0]!==u}function dA(d,u){return!!wd(d,u).last}function mme(d){if(Wt.includes(d.type))return d;if([...ks,f.VariableDeclaration].includes(d.type)){const u=d.parent;return Wt.includes(u.type)?u:null}return null}function uA(d,u){if(!d||!u)throw new Error("Both entities must be defined to find a common ancestor");if(d===u)return d;const i=d.parent;if(i){if(i===u)return u;if(i.type===f.Project)return null}else return null;const a=u.parent;if(a){if(a===d)return d;if(a.type===f.Project)return null}else return null;return uA(i,a)}function ur(d){if($f.includes(d.type)){if(d.type===f.FunctionDeclaration){const u=d.parent;if(u.type===f.DefinitionEntity)return ur(u);if(u.type===f.Loop)return u}return d.type===f.DefinitionEntity&&d.parent.type===f.DataType?ur(d.parent):d}else{const u=d.parent;return u?ur(u):null}}function ky(d,u){const i=Ap(d,u);if(!i)return null;if($f.includes(i.type)){if(i.type===f.FunctionDeclaration){const a=Ap(i.parent,u);if(a){if(a.type===f.DefinitionEntity)return a;if(a.type===f.Loop)return a}}return i}else{const a=i.parent?Ap(i.parent,u):null;return a?ky(a,u):null}}function Ij(d){if(!d)return null;if(ks.includes(d.type))return d;const u=d.parent;return u?Ij(u):null}function wj(d){if(!d)return null;if(Xt.includes(d.type))return d;const u=d.parent;return u?wj(u):null}function Rj(d){if(!d)return null;if(qs.includes(d.type))return d;const u=d.parent;return u?Rj(u):null}function _j(d){return d.type===f.VariableDeclaration?[d]:Xt.includes(d.type)?[...d.inputs,...d.outputs||[]]:rr.includes(d.type)?d.outputs:Dl.includes(d.type)||d.type===f.FunctionDeclaration?d.inputs:[]}function vme(d){const u=tn(d),i=[],a=[];lR.includes(d.type)&&i.push(...qy(d));const l=u.filter(p=>{const t=i.includes(p);return t?!1:ks.includes(p.type)&&!t?(a.push(p),!1):!0});return i.sort((p,t)=>Wo(t,p)?-1:0),a.sort((p,t)=>Wo(t,p)?-1:0),[...i,...a,...l]}function gj(d){return[...d].sort((u,i)=>Wo(i,u)?-1:0)}function cA(d){const u=gj(d),i=[];return u.forEach(a=>{const l=i[i.length-1];if(l){const p=l[l.length-1];Wo(a,p)?i.push([a]):l.push(a)}else i.push([a])}),i}function zr(d){const u=d.map(i=>ur(i));return R(u)}function qy(d){return Xt.includes(d.type)?[...zr(d.successCalls),...zr(d.errorCalls)]:Wt.includes(d.type)?zr(d.calls):[]}function Eme(d,u){return qy(d).includes(u)}function pA(d){return d.writesValues||[]}function Tme(d,u){return pA(d).includes(u)}function Dj(d){var u;return rt.includes((u=d==null?void 0:d.readsValue)==null?void 0:u.type)?d.readsValue:null}function bme(d){return d.writesValues}function Oj(d=[]){return d.map(Dj).filter(u=>!!u)}function Sy(d=[]){return d.map(u=>u.writesValues).flat().filter(u=>rt.includes(u.type))}function Cj(d=[]){return d.map(u=>u.readsValue).filter(u=>!!u&&rt.includes(u.type))}function $j(d){return rt.includes(d.type)?d:null}function Pj(d){return d.writesValues.map($j).filter(u=>!!u)}function Vj(d=[]){return d.reduce((u,i)=>i.type===f.OutputMap?[...u,...Pj(i)]:u,[])}function ut(d){return d.type===f.Loop?R([...$s(zr(d.successCalls)),...$s(zr(d.errorCalls)),...d.body?ut(d.body):[]]):Xt.includes(d.type)?R([...$s(zr(d.successCalls)),...$s(zr(d.errorCalls))]):Wt.includes(d.type)?R($s(zr(d.calls))):[]}function Ame(d){return Xt.includes(d.type)?[...$s(zr(d.successCalls)),...$s(zr(d.errorCalls))]:Wt.includes(d.type)?$s(zr(d.calls)):[]}function Nj(d,u=new Set){return d.writesValues.filter(a=>rt.includes(a.type)&&!u.has(a.id)).reduce((a,l)=>u.has(l.id)?a:[...a,...Ht(l,u)],[])}function Lj(d,u=new Set){var a;return(((a=d.readsValue)==null?void 0:a.writesValues)||[]).filter(l=>rt.includes(l.type)&&!u.has(l.id)).reduce((l,p)=>u.has(p.id)?l:[...l,...Ht(p,u)],[])}function Ht(d,u=new Set){if(u.has(d.id))return[];if(d.type===f.ReturnStatement)return Cj(d.outputs).reduce((a,l)=>[...a,...Ht(l,u)],[]);if(d.type===f.FunctionCall||d.type===f.Operation||d.type===f.Condition)return[...ut(d).reduce((p,t)=>{const y=ur(t);return[...p,...Ht(y||t,u)]},[]),...Oj(d.inputs),...Vj(d.outputs)].reduce((p,t)=>[...p,...Ht(t,u)],[]);if(Dl.includes(d.type)){const i=Sy(d.inputs),l=ut(d).reduce((p,t)=>{const y=ur(t);return[...p,...Ht(y||t,u)]},[]);return i.push(...l),i.reduce((p,t)=>[...p,...Ht(t,u)],[])}if(d.type===f.FunctionDeclaration){const i=[...Sy(d.inputs)],l=ut(d).reduce((p,t)=>{const y=ur(t);return[...p,...Ht(y||t,u)]},[]);return i.push(...l),i.reduce((p,t)=>[...p,...Ht(t)],[])}if(rt.includes(d.type)){u.add(d.id);const a=ut(d).reduce((l,p)=>{const t=ur(p);return[...l,...Ht(t||p,u)]},[]);return[d,...a,...Lj(d,u),...Nj(d,u)]}return[]}function Xi(d,u=new Set){return u.has(d.id)?[]:(u.add(d.id),[...tn(d).reduce((l,p)=>[...l,p,...Xi(p,u)],[])])}function $s(d){return d.reduce((u,i)=>i.type===f.ReturnStatement||i.type===f.ContinueStatement||i.type===f.BreakStatement?[...u,i]:[...u,i,...ut(i)],[])}function Bj(d){const u=d.entities||[],i=[...u,...d.functions||[],...d.events||[],...d.projects||[]],a=u.reduce((v,T)=>[...v,...T.properties],[]),l=u.reduce((v,T)=>[...v,...T.methods],[]),p=l.reduce((v,T)=>[...v,...Sy(T.inputs),...$s(zr(T.calls)),...T.returnStatements],[]),t=d.functions.reduce((v,T)=>[...v,...$s(zr(T.calls)),...T.returnStatements],[]),y=d.events.reduce((v,T)=>[...v,...$s(zr(T.calls)),...T.returnStatements],[]);return[...i,...a,...l,...p,...t,...y]}function Mj(d,u){return u.filter(a=>{if(!a)return!1;switch(a.type){case f.FunctionCall:return a.inputs.find(l=>l.id===d.id)!==void 0||a.outputs.find(l=>l.id===d.id)!==void 0;case f.Condition:return a.successCalls.find(l=>l.id===d.id)!==void 0||a.errorCalls.find(l=>l.id===d.id)!==void 0||a.inputs.find(l=>l.id===d.id)!==void 0;case f.Operation:return a.outputs.find(l=>l.id===d.id)!==void 0;case f.VariableDeclaration:return Xt.includes(d.type)?cx(d).find(p=>{var t;return((t=p.readsValue)==null?void 0:t.id)===a.id})!==void 0:!1;case f.DefinitionEntity:return a.properties.find(l=>l.id===d.id)!==void 0||a.methods.find(l=>l.id===d.id)!==void 0;case f.FunctionDeclaration:return a.inputs.find(l=>l.id===d.id)!==void 0||(a.returnStatements.map(l=>l.outputs).flat()||[]).find(l=>l.id===d.id)!==void 0;default:return!1}})}function Ime(d){const u=Bj(d.project);return Mj(d,u)}function Ap(d,u){return d?typeof d=="string"?u[d]:d.type===f.GenericReference?u[d.entityId]:u[d.id]?u[d.id]:null:null}function Uj(d={},u){const i={};return Object.keys(d).forEach(a=>{const l=u.get(a)||a,p=d[a];i[l]=p}),i}function Rd(d,u={},i={}){const a={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...i};if(a.ignoreBuiltInBaseEntities&&(ki.includes(d.type)||(a.allBuiltInEntityIds||[]).includes(d.id)))return{upstream:{},downstream:{}};const l=d,p=d,t=d,y=d,v=d,T=d,w=d,A=d,V=d,N=d,j=d,k=d,q=d,Y=[...q.readsValue?[q.readsValue]:[],...q.declaration?[q.declaration]:[],...(k.calledByEntry||[]).flatMap(ne=>ne),...(k.calledBySuccess||[]).flatMap(ne=>ne),...(k.calledByError||[]).flatMap(ne=>ne),...N.parent?[N.parent]:[]];Array.isArray(t.implements)?Y.push(...t.implements.flatMap(ne=>ne)):V.implements&&Y.push(V.implements),Array.isArray(t.extends)?Y.push(...t.extends.flatMap(ne=>ne)):V.extends&&Y.push(V.extends),v.valueAsTypeList&&Array.isArray(v.valueAsTypeList)&&Y.push(...v.valueAsTypeList.flatMap(ne=>ne)),v.valueAsTypeSingle&&Y.push(v.valueAsTypeSingle);const ie=[...(l.inputs||[]).flatMap(ne=>ne),...(j.inputsDeclarations||[]).flatMap(ne=>ne),...(l.outputs||[]).flatMap(ne=>ne),...(j.outputsDeclarations||[]).flatMap(ne=>ne),...(q.internalCalls||[]).flatMap(ne=>ne),...q.writesValues||[],...k.dataType?[k.dataType]:[],...T.body?[T.body]:[],...k.defaultValue?[k.defaultValue]:[],...(k.successCalls||[]).flatMap(ne=>ne),...(k.errorCalls||[]).flatMap(ne=>ne),...(t.properties||[]).flatMap(ne=>ne),...(t.methods||[]).flatMap(ne=>ne),...(t.abstractMethods||[]).flatMap(ne=>ne),...w.error?[w.error]:[],...w.process?[w.process]:[],...N.throws?[N.throws]:[],...(p.andChildrenGroup||[]).flatMap(ne=>ne),...(p.orChildrenGroup||[]).flatMap(ne=>ne),...(A.entities||[]).flatMap(ne=>ne),...(A.functions||[]).flatMap(ne=>ne),...(A.functionCalls||[]).flatMap(ne=>ne),...(A.events||[]).flatMap(ne=>ne),...(A.conditions||[]).flatMap(ne=>ne),...(A.operations||[]).flatMap(ne=>ne),...(A.loops||[]).flatMap(ne=>ne),...(A.variableDeclarations||[]).flatMap(ne=>ne),...(A.variableInstances||[]).flatMap(ne=>ne),...(A.searches||[]).flatMap(ne=>ne),...(A.projects||[]).flatMap(ne=>ne),...(y.calls||[]).flatMap(ne=>ne)];d.type===f.DataType&&(p.entity&&u[W(p.entity)]&&u[W(p.entity)].parent&&W(u[W(p.entity)].parent)===d.id?ie.push(p.entity):p.entity&&Y.push(p.entity));const te={},pe={};return Y.forEach(ne=>{var ae;const me=W(ne);if(me&&a.ignoreBuiltInBaseEntities&&(ki.includes(ne.type)||(a.allBuiltInEntityIds||[]).includes(me)))return;const J=ne.version;if(me){const ce=((ae=a.entityMaps)==null?void 0:ae.get(me))||me;te[ce]=J}}),ie.forEach(ne=>{var ae;const me=W(ne);if(me&&a.ignoreBuiltInBaseEntities&&(ki.includes(ne.type)||(a.allBuiltInEntityIds||[]).includes(me)))return;const J=ne.version;if(me){const ce=((ae=a.entityMaps)==null?void 0:ae.get(me))||me;pe[ce]=J}}),{upstream:te,downstream:pe}}function wme(d,u){const i=[];if(ks.includes(d.type)){ys(d).forEach(p=>{const t=ky(p,u);t&&i.push(t)});const l=[...d.inputs||[],...d.outputs||[]].map(p=>{const t=Ap(p,u);return t?fx(t,u):null}).filter(p=>p!==null);i.push(...R(l))}if(rt.includes(d.type)){const a=Zy(d);a&&i.push(a)}return R(i)}function Xa(d){const u=[];if(ks.includes(d.type)){d.calledBy.forEach(l=>{const p=ur(l);p&&u.push(p)});const a=[...d.inputs||[],...d.outputs||[]].map(l=>Zy(l)).filter(l=>l!==null);u.push(...R(a))}if(rt.includes(d.type)){const i=Zy(d);i&&u.push(i)}return R(u)}function ys(d){return[...d.calledByEntry||[],...d.calledByError||[],...d.calledBySuccess||[]].filter(u=>u.type!==f.GenericReference)}function jj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[d,...d.inputs.flatMap(a=>he(a,u,i)),...d.outputs.flatMap(a=>he(a,u,i)),...d.error?he(d.error,u,i):[],...d.parent?he(d.parent,u,i):[]]}function xj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[d,...d.defaultValue?he(d.defaultValue,u):[],...d.writesValues.flatMap(a=>he(a,u,i)),...d.dataType?he(d.dataType,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Fj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[d,...d.outputs.flatMap(a=>he(a,u,i)),...d.throws?he(d.throws,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function Gj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[d,...(d.properties||[]).flatMap(a=>he(a,u,i)),...(d.methods||[]).flatMap(a=>he(a,u,i)),...(d.abstractMethods||[]).flatMap(a=>he(a,u,i)),...(d.extends||[]).flatMap(a=>he(a,u,i))]}function Kj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Condition)throw new Error("Entity must be a condition to be flattened");return[d,...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function kj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[d,...d.outputs.flatMap(a=>he(a,u,i)),...d.throws?he(d.throws,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function qj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[d,...(d.extends||[]).flatMap(a=>he(a,u,i)),...(d.implements||[]).flatMap(a=>he(a,u,i)),...(d.properties||[]).flatMap(a=>he(a,u,i)),...(d.methods||[]).flatMap(a=>he(a,u,i)),...(d.abstractMethods||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function Sj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.DataType)throw new Error("Entity must be a data type to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(a=>he(a,u,i)),...(d.orChildrenGroup||[]).flatMap(a=>he(a,u,i)),...d.entity?he(d.entity,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Zj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[d,...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...d.error?he(d.error,u,i):[],...d.process?he(d.process,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function Jj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[d,...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.calls||[]).flatMap(a=>he(a,u,i)),...d.implements?he(d.implements,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Wj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[d,...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.calls||[]).flatMap(a=>he(a,u,i)),...d.implements?he(d.implements,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Yj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InputMap)throw new Error("Entity must be an input map to be flattened");return[d,...d.readsValue?he(d.readsValue,u,i):[],...d.declaration?he(d.declaration,u,i):[],...d.defaultValue?he(d.defaultValue,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Hj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[d,...(d.functions||[]).flatMap(a=>he(a,u,i)),...(d.events||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function zj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.error?he(d.error,u,i):[],...d.process?he(d.process,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Xj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[d,...d.valueAsTypeSingle?he(d.valueAsTypeSingle,u,i):[],...d.valueAsTypeList&&Array.isArray(d.valueAsTypeList)?d.valueAsTypeList.flatMap(a=>he(a,u,i)):[],...d.parent?he(d.parent,u,i):[]]}function Qj(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Loop)throw new Error("Entity must be a loop to be flattened");return[d,...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...d.error?he(d.error,u,i):[],...d.process?he(d.process,u,i):[],...d.body?he(d.body,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function ex(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Operation)throw new Error("Entity must be an operation to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...d.error?he(d.error,u,i):[],...d.process?he(d.process,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function tx(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.OutputMap)throw new Error("Entity must be an output map to be flattened");return[d,...(d.writesValues||[]).flatMap(a=>he(a,u,i)),...d.declaration?he(d.declaration,u,i):[],...d.defaultValue?he(d.defaultValue,u,i):[],...d.parent?he(d.parent,u,i):[]]}function rx(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[d,...(d.properties||[]).flatMap(a=>he(a,u,i)),...(d.methods||[]).flatMap(a=>he(a,u,i)),...(d.abstractMethods||[]).flatMap(a=>he(a,u,i))]}function ix(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Project)throw new Error("Entity must be a project to be flattened");return[d,...(d.entities||[]).flatMap(a=>he(a,u,i)),...(d.functions||[]).flatMap(a=>he(a,u,i)),...(d.events||[]).flatMap(a=>he(a,u,i)),...(d.projects||[]).flatMap(a=>he(a,u,i)),...(d.variableDeclarations||[]).flatMap(a=>he(a,u,i)),...(d.variableInstances||[]).flatMap(a=>he(a,u,i)),...(d.operations||[]).flatMap(a=>he(a,u,i)),...(d.conditions||[]).flatMap(a=>he(a,u,i)),...(d.functionCalls||[]).flatMap(a=>he(a,u,i)),...(d.projects||[]).flatMap(a=>he(a,u,i)),...(d.loops||[]).flatMap(a=>he(a,u,i)),...(d.searches||[]).flatMap(a=>he(a,u,i))]}function sx(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Property)throw new Error("Entity must be a property to be flattened");return[d,...d.defaultValue?he(d.defaultValue,u,i):[],...d.dataType?he(d.dataType,u,i):[],...d.parent?he(d.parent,u,i):[]]}function nx(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ReturnDeclaration)throw new Error("Entity must be a return declaration to be flattened");return[d,...d.readsValue?he(d.readsValue,u,i):[],...d.defaultValue?he(d.defaultValue,u,i):[],...d.dataType?he(d.dataType,u,i):[],...d.parent?he(d.parent,u,i):[]]}function ax(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[d,...(d.outputs||[]).flatMap(a=>he(a,u,i)),...d.throws?he(d.throws,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function ox(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.Search)throw new Error("Entity must be a search to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...(d.inputsDeclarations||[]).flatMap(a=>he(a,u,i)),...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputsDeclarations||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...d.error?he(d.error,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.parent?he(d.parent,u,i):[]]}function lx(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[d,...d.defaultValue?he(d.defaultValue,u,i):[],...d.dataType?he(d.dataType,u,i):[],...d.parent?he(d.parent,u,i):[]]}function dx(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...(d.internalCalls||[]).flatMap(a=>he(a,u,i)),...(d.writesValues||[]).flatMap(a=>he(a,u,i)),...d.readsValue?he(d.readsValue,u,i):[],...d.defaultValue?he(d.defaultValue,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.dataType?he(d.dataType,u,i):[],...d.parent?he(d.parent,u,i):[]]}function ux(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(u.has(d.id))return[];if(u.add(d.id),d.type!==f.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[d,...(d.successCalls||[]).flatMap(a=>he(a,u,i)),...(d.errorCalls||[]).flatMap(a=>he(a,u,i)),...(d.inputs||[]).flatMap(a=>he(a,u,i)),...(d.outputs||[]).flatMap(a=>he(a,u,i)),...(d.internalCalls||[]).flatMap(a=>he(a,u,i)),...(d.writesValues||[]).flatMap(a=>he(a,u,i)),...d.readsValue?he(d.readsValue,u,i):[],...d.defaultValue?he(d.defaultValue,u,i):[],...(ys(d)||[]).flatMap(a=>he(a,u,i)),...d.declaration?he(d.declaration,u,i):[],...d.parent?he(d.parent,u,i):[]]}function Ps(){const d=new Set,u=pV.flatMap(i=>he(i,d)).map(i=>i.id);if(!u.includes("http-request-error-return-delaration-id"))throw new Error("Built-in base entities must be included in the list");return u}function he(d,u=new Set,i={ignoreBuiltInBaseEntities:!1}){if(!d)throw new Error("Entity must be defined to be flattened");if(d.type===f.GenericReference)return[];if(i.ignoreBuiltInBaseEntities&&(ki.includes(d.type)||Ps().includes(d.id)))return[];if(u.has(d.id))return[];switch(d.type){case f.FunctionCall:return Zj(d,u,i);case f.Operation:return ex(d,u,i);case f.Condition:return Kj(d,u,i);case f.Loop:return Qj(d,u,i);case f.Search:return ox(d,u,i);case f.GlobalEvent:return Wj(d,u,i);case f.ReturnStatement:return ax(d,u,i);case f.ContinueStatement:return kj(d,u,i);case f.BreakStatement:return Fj(d,u,i);case f.VariableDeclaration:return dx(d,u,i);case f.DefinitionEntity:return qj(d,u,i);case f.FunctionDeclaration:return Jj(d,u,i);case f.Project:return ix(d,u,i);case f.ActionDescriptor:return jj(d,u,i);case f.ArgumentDeclaration:return xj(d,u,i);case f.ReturnDeclaration:return nx(d,u,i);case f.ValueDescriptor:return lx(d,u,i);case f.InputMap:return Yj(d,u,i);case f.OutputMap:return tx(d,u,i);case f.DataType:return Sj(d,u,i);case f.InstalledProject:return Hj(d,u,i);case f.InternalCall:return zj(d,u,i);case f.LiteralValue:return Xj(d,u,i);case f.Property:return sx(d,u,i);case f.VariableInstance:return ux(d,u,i);case f.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:Gj(d,u,i);case f.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:rx(d,u,i)}return[]}function fA(d){return d.type===f.FunctionCall||d.type===f.InternalCall||[f.Operation,f.Condition,f.Loop].includes(d.type)?d.declaration.inputs:d.type===f.FunctionDeclaration||Dl.includes(d.type)?d.inputs:d.type===f.Search?d.inputsDeclarations:[]}function Rme(d,u){return u.type===f.Condition?u.inputs.find(i=>i.declaration.id===d.id):u.type===f.FunctionCall||u.type===f.Operation?u.inputs.find(i=>i.declaration.id===d.id):null}function cx(d){return Xt.includes(d.type)?d.inputs:[]}function px(d){var u;return d.type===f.FunctionCall?((u=d.declaration.returnStatements[0])==null?void 0:u.outputs)||[]:[f.Operation,f.Condition,f.Loop].includes(d.type)?d.declaration.outputs:d.type===f.Search?d.outputsDeclarations:rr.includes(d.type)?d.outputs:[]}function _me(d,u){return u.type===f.Condition?null:u.type===f.FunctionCall||u.type===f.Operation?u.outputs.find(i=>i.declaration.id===d.id):null}function gme(d){return d.type===f.Condition?[]:Xt.includes(d.type)?d.outputs:[]}function Zy(d){const u=d.readsValue;return u?ur(u):null}function fx(d,u){const i=d.readsValue;return i?ky(i,u):null}function hx(d){const u=d.internalCalls||[];return R(zr(R(u.flatMap(i=>[...i.successCalls,...i.errorCalls]))))}function _d(d){const u=pA(d),i=[];return u.forEach(a=>{if(rt.includes(a.type))i.push(a);else if(Jn.includes(a.type)){const l=a.parent;i.push(l)}}),i}function R(d){const u=new Set;return d.filter(i=>!i||u.has(i.id)?!1:(u.add(i.id),!0))}function tn(d,u=!1){const i=[];if(d.type===f.Project&&i.push(...(d==null?void 0:d.entities)||[],...(d==null?void 0:d.functions)||[],...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[],...(d==null?void 0:d.events)||[],...(d==null?void 0:d.projects)||[]),br.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===f.DefinitionEntity){const a=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&u?[]:tn(l));i.push(...a)}if(d.type===f.Condition){const a=d.successCalls.map(p=>ur(p)),l=d.errorCalls.map(p=>ur(p));i.push(...a,...l)}if(Dl.includes(d.type)){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>_d(p)).flat(),l=d.calls.map(p=>ur(p));i.push(...R(a),...l)}if(Xt.includes(d.type)&&d.type!==f.Condition&&d.type!==f.Loop){const a=d==null?void 0:d.outputs.map(t=>_d(t)).flat(),l=d.successCalls.map(t=>ur(t)),p=d.errorCalls.map(t=>ur(t));i.push(...R(a),...l,...p)}if(rt.includes(d.type)){const a=_d(d),l=hx(d);i.push(...a,...l)}if(d.type===f.Loop){const a=d.outputs.map(t=>_d(t)).flat();if(d.body){const t=tn(d.body,u);i.push(...t)}const l=d.errorCalls.map(t=>ur(t)),p=d.successCalls.map(t=>ur(t));i.push(...R(a),...p,...l)}if(d.type===f.FunctionDeclaration){if(d.collapsed&&u)return[];const a=d.inputs.map(p=>_d(p)).flat(),l=d.calls.map(p=>ur(p));i.push(...R(a),...l)}return R(i)}function Jy(d,u=!1){const i=tn(d,u),a=[...i,...i.reduce((l,p)=>[...l,...Jy(p,u)],[])];return R(a)}function yx(d){const u=Xa(d),i=[...u,...u.reduce((a,l)=>[...a,...yx(l)],[])];return R(i)}function Ip(d){return d.implements.reduce((u,i)=>i.type===f.DefinitionEntity?[...u,f.DefinitionEntity,...Ip(i),...wp(i)]:[...u,i.name],[])}function wp(d){return d.extends.reduce((u,i)=>i.type===f.DefinitionEntity?[...u,f.DefinitionEntity,...wp(i),...Ip(i)]:[...u,i.name],[])}function hA(d){return d.extends.reduce((u,i)=>i.type===f.DefinitionEntity?[...u,i,...hA(i),...yA(i)]:[...u,i],[])}function yA(d){return d.implements.reduce((u,i)=>i.type===f.DefinitionEntity?[...u,i,...yA(i),...hA(i)]:[...u,i],[])}function gd(d){return[...wp(d),...Ip(d)].filter((i,a,l)=>l.indexOf(i)===a)}function mA(d){return d.implements.length===0&&d.extends.length===0?null:d.implements.find(a=>a.type===f.BuiltInBaseEntity&&a.name===$e.PERSISTED_ENTITY)?d:[...d.implements,...d.extends].reduce((a,l)=>{if(l.type===f.DefinitionEntity){const p=mA(l);if(p)return p}return a},null)}function Dme(d){const u=d.extends.find(i=>i.type===f.BuiltInBaseEntity);return u&&u.type===f.BuiltInBaseEntity?u:null}function Ome(d){const u=d.implements.find(i=>i.type===f.BuiltInBaseEntity);return u&&u.type===f.BuiltInBaseEntity?u:null}function Wy(d){const u=d.extends.find(i=>i.type===f.DefinitionEntity);return u&&u.type===f.DefinitionEntity?u:null}function wi(d){if(d.type===f.BuiltInBaseEntity)return[d];const u=[...d.implements,...d.extends].reduce((i,a)=>a.type===f.BuiltInBaseEntity?[...i,a]:a.type===f.DefinitionEntity?[...i,...wi(a)]:i,[]);return R(u)}function Rp(d){return d.type===f.PrimitiveEntity?!0:d.type===f.BuiltInBaseEntity?d.interactive:!wi(d).find(a=>!a.interactive)}function Cme(d){return d.parent===d.project&&d.project.variableDeclarations.includes(d)}function vA(d){return d.parent!==d.project?!1:f.VariableDeclaration===d.type?d.project.variableDeclarations.includes(d):f.VariableInstance===d.type?d.project.variableInstances.includes(d):f.FunctionCall===d.type?d.project.functionCalls.includes(d):f.Condition===d.type?d.project.conditions.includes(d):f.Operation===d.type?d.project.operations.includes(d):f.Loop===d.type?d.project.loops.includes(d):f.Search===d.type?d.project.searches.includes(d):!1}function mx(d){if([...Wt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(d.type)||vA(d))return!1;const u=Xa(d);return u.length===0?!0:u.some(i=>mx(i))}function EA(d){return[...Wt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(d.type)||vA(d)?!1:Xa(d).length===0}function vx(d,u=0){if(EA(d)){const i=Xa(d);return i.length===0?d:i.map(l=>vx(l,u+1)).reduce((l,p)=>l?p&&p.x<l.x?p:l:p,null)}return null}function Ex(d){const u=[];if(EA(d))u.push(d);else return[];return Xa(d).forEach(a=>{u.push(...Ex(a))}),u}function TA(d){return d.type===f.FunctionDeclaration&&d.parent!==d.project&&!![f.DefinitionEntity,f.Loop,f.InstalledProject].includes(d.parent.type)}function $me(d,u){const i=new Map;return d.forEach(a=>{i.set(a.id,a)}),u.forEach(a=>{i.set(a.id,a)}),Array.from(i.values())}function _p(d){switch(d){case f.DefinitionEntity:return ma;case f.FunctionDeclaration:return Ua;case f.VariableDeclaration:return ka;case f.VariableInstance:return Ka;case f.FunctionCall:return za;case f.Operation:return ja;case f.Condition:return Ga;case f.ReturnStatement:return xa;case f.Loop:return Ai;case f.Search:return qa;case f.InputMap:return Cs;case f.OutputMap:return Qs;case f.ArgumentDeclaration:return pa;case f.ReturnDeclaration:return Ni;case f.Property:return ua;case f.InstalledProject:return Sa;case f.Project:return P;case f.DataType:return Hi;case f.GlobalEvent:return Fa;case f.InternalCall:return Za;case f.ValueDescriptor:return en;case f.BuiltInBaseEntity:return Cn;case f.PrimitiveEntity:return Li;case f.ActionDescriptor:return jt;case f.LiteralValue:return bi;case f.ContinueStatement:return li;case f.BreakStatement:return Ja;default:return null}}function Ri(d,u,i=null){const a=d!=null&&d.parent?W(d==null?void 0:d.parent):null;let l=a?u.get(a):null,p=i||d;if(d.type===f.ReturnStatement)return $r(d,u,p);if(d.type===f.FunctionDeclaration&&(l==null?void 0:l.type)===f.Loop)return l;if(Wt.includes(d.type))return d;if(d.type===f.Loop)return p.id===d.id?l:d;if(ki.includes(d.type))return null;const t=d.parent;if(!t)return null;if(t.type===f.GenericReference){const y=W(t);if(!y)return null;const v=u.get(y);return v?Ri(v,u,p):null}else return t===u?u:Ri(t,u,p)}function $r(d,u,i=null){const a=d!=null&&d.parent?W(d==null?void 0:d.parent):null;let l=a?u.get(a):null,p=i||d;if(d.type===f.FunctionDeclaration&&(l==null?void 0:l.type)===f.Loop)return $r(l.parent,u,p);if(Wt.includes(d.type))return d;if(ki.includes(d.type))return null;const t=d.parent;if(!t)return null;if(t.type===f.GenericReference){const y=W(t);if(!y)return null;const v=u.get(y);return v?$r(v,u,p):null}else return t===u?u:$r(t,u,p)}function bA(d,u){if(ki.includes(d.type)||u.getBuiltIn(d.id))return null;const i=_i(d.parent,u);return i?i===u?br.includes(d.type)?d:null:i.type===f.DefinitionEntity?d:bA(i,u):null}function Yy(d,u,i){if(d===u||u===i||d===i)return!1;const a=Ri(u.parent,i);return a===d?!0:Yy(a,u,i)}var Hy=(d=>(d.SameBothLocal="same-both-local",d.AInB="a-in-b",d.BInA="b-in-a",d.ParallelInCommonParent="parallel-in-common-parent",d.ParallelInProject="parallel-in-project",d.AIsGlobalBIsNot="a-is-global-b-is-not",d.BIsGlobalAIsNot="b-is-global-a-is-not",d.SameBothGlobal="same-both-global",d))(Hy||{});function gp(d,u,i){const a=Ri(d,i),l=Ri(u,i);if(!a)throw new Error("Could not find scope owner for the entity: "+d.id);if(!l)throw new Error("Could not find scope owner for the entity: "+u.id);if(a===l&&a.type!==f.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:a};if(a===l&&a.type===f.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:a};if(a.type===f.Project&&l.type!==f.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:a};if(a.type!==f.Project&&l.type===f.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:l};if(Yy(a,l,i))return{compatible:!0,type:"b-in-a",commonAncestorScope:a};if(Yy(l,a,i))return{compatible:!0,type:"a-in-b",commonAncestorScope:l};const y=uA(a,l);return y===i?{compatible:!1,type:"parallel-in-project",commonAncestorScope:y}:y?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:Ri(y,i)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:i}}function Tx(d,u,i){const a=gp(d,u,i);if(!a.compatible||a.type!=="same-both-local")return null;if(d===u)return d;let l=Ri(d.parent,i);if(l){if(l===u)return u;if(l.type===f.Project)return d}else return d;for(;l;){if(l){if(l===u)return u;if(l.type===f.Project)return d}else return d;l=Ri(l.parent,i)}let p=Ri(u.parent,i);if(p){if(p===d)return d;if(p.type===f.Project)return u}else return u;for(;p;){if(p){if(p===d)return d;if(p.type===f.Project)return u}else return u;p=Ri(p.parent,i)}return null}function bx(d){return d.length===0?null:d.length===1?d[0]:d.reduce((i,a)=>{const l=Tx(i,a,a.project);return!l||l===a?i:a},d[0])}function _i(d,u){if(!d)return null;let i;return typeof d=="string"?i=d:d.type===f.GenericReference?i=W(d):i=d.id,i===u.id?u:u.get(i)}function Qa(d){if(!d)return null;if(ki.includes(d.type))return d;if(d.type===f.Project)return null;if(d.project.getBuiltIn(d.id))return d;const u=d.parent;return!u||u.type===f.Project?null:Qa(u)}function Dp(d){const u=[];function i(p,t){return u.some(y=>y.blockedByCaller===p&&y.blockedByCalling===t)}function a(p,t){i(p,t)||u.push({blockedByCaller:p,blockedByCalling:t})}const l=bA(d,d.project);return d.calledBySuccess.forEach(p=>{[...p.successCalls||[]].forEach(v=>{rr.includes(v.type)&&v!==d&&(ut(d).find(A=>A===v)||a(p,v))});let y;if(Xt.includes(p.type)&&(y=p),y){const v=Dp(y);v.reachable||ut(d).find(A=>A===p)||v.blocks.forEach(A=>{a(p,A.blockedByCalling)})}}),d.calledByError.forEach(p=>{[...p.errorCalls||[]].forEach(v=>{rr.includes(v.type)&&v!==d&&(ut(d).find(A=>A===v)||a(p,v))});let y;if(Xt.includes(p.type)&&(y=p),y){const v=Dp(y);v.reachable||ut(d).find(A=>A===p)||v.blocks.forEach(A=>{a(p,A.blockedByCalling)})}}),d.calledByEntry.forEach(p=>{if([...p.calls||[]].forEach(v=>{rr.includes(v.type)&&v!==d&&(ut(d).find(A=>A===v)||a(p,v))}),p===l)return;let y;if(p.type===f.FunctionDeclaration){const v=ur(p);if(v.type===f.DefinitionEntity)return;v.type===f.Loop&&(y=v)}if(y){const v=Dp(y);v.reachable||v.blocks.forEach(T=>{a(p,T.blockedByCalling)})}}),{reachable:u.length===0,entryPoint:l,blocks:u}}function Pme(d){return $f.includes(d.type)?d.type===f.FunctionDeclaration?!TA(d):!0:!1}function Vme(d){if(f.ActionDescriptor===d.type){if(d.project.operationDeclarations.find(p=>p.id===d.id))return f.Operation;if(d.project.globalEventActionDescriptors.find(p=>p.id===d.id))return f.GlobalEvent;if(d.project.loopDeclarations.find(p=>p.id===d.id))return f.Loop;if(d.project.conditionDeclarations.find(p=>p.id===d.id))return f.Condition}return d.type}function zy(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!wp(d).includes(u)}function Nme(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!Ip(d).includes(u)}function Vs(d,u){return d.type===f.BuiltInBaseEntity?d.name===u:!!gd(d).includes(u)}function Lme(d){const u=[];return d.entities.forEach(i=>{if(zy(i,$e.PERSISTED_ENTITY)){u.push(i);return}}),R(u)}function Bme(d){const u=[];return d.entities.forEach(i=>{if(zy(i,$e.RELATIONAL_DATABASE)){u.push(i);return}}),R(u)}function Mme(d){return d.type!==f.DefinitionEntity||d.abstract||!zy(d,$e.PERSISTED_ENTITY)?null:(d==null?void 0:d.properties.find(i=>{var a;return((a=i.implements)==null?void 0:a.id)===Ee[f.BuiltInBaseEntity][$e.PERSISTED_ENTITY].properties.primaryKey.id&&!i.abstract}))||null}function Ax(d){var a;const u=mA(d);if(!u)return null;const i=u.properties.find(l=>{var p;return((p=l.implements)==null?void 0:p.id)===Ee[f.BuiltInBaseEntity][$e.PERSISTED_ENTITY].properties.database.id});return i?(a=i.getDefaultValue())==null?void 0:a.valueAsType:null}function Dd(d){if(d.type!==f.DefinitionEntity)return[];if(d.abstract)return[];if(!Vs(d,$e.PERSISTED_ENTITY))return[];const u=[],i=d.properties.filter(a=>{var l;return((l=a.implements)==null?void 0:l.id)!==Ee[f.BuiltInBaseEntity][$e.PERSISTED_ENTITY].properties.database.id&&!a.abstract});return u.push(...i),u}function Ume(d){var i;if(!d||d.type!==f.DefinitionEntity||!Vs(d,$e.PERSISTED_ENTITY))return null;const u=d.properties.find(a=>{var l;return((l=a.implements)==null?void 0:l.id)===Ee[f.BuiltInBaseEntity][$e.PERSISTED_ENTITY].properties.database.id});return(i=u==null?void 0:u.getDefaultValue())==null?void 0:i.valueAsTypeSingle}function Ir(d,u){var a;if(!cR.includes(u.type)||!d)return u.project||null;let i=u.project;return d.type===f.Project?i=d:((a=u.project)==null?void 0:a.id)!==d.project.id&&(i=d.project),i}function jme(d){switch(d){case f.Project:return P;case f.InstalledProject:return Sa;case f.DefinitionEntity:return ma;case f.FunctionDeclaration:return Ua;case f.GlobalEvent:return Fa;case f.VariableInstance:return Ka;case f.VariableDeclaration:return ka;case f.InputMap:return Cs;case f.OutputMap:return Qs;case f.Condition:return Ga;case f.Operation:return ja;case f.FunctionCall:return za;case f.ReturnDeclaration:return Ni;case f.ArgumentDeclaration:return pa;case f.PrimitiveEntity:return Li;case f.DataType:return Hi;case f.Property:return ua;case f.ActionDescriptor:return jt;case f.ReturnStatement:return xa;case f.ContinueStatement:return li;case f.BreakStatement:return Ja;case f.Loop:return Ai;case f.Search:return qa;case f.ValueDescriptor:return en;case f.InternalCall:return Za;case f.LiteralValue:return bi}return null}function xme(d){const u={added:{},updated:{},removed:{},affected:[],seenEntities:[],self:d==null?void 0:d.self};return d==null||d.added.forEach(i=>{u.added[i.id]=i}),d==null||d.updated.forEach(i=>{u.updated[i.id]=i}),d==null||d.removed.forEach(i=>{u.removed[i.id]=i}),u.affected=Array.from(new Set(d==null?void 0:d.affected.map(i=>i.id))),u}function Er(d,u){const i=_p(d.type);return i?!i.MUTABLE_META_PROPERTIES.every(l=>{const p=d[l],t=u[l];return t===void 0||p===t?!0:Array.isArray(p)&&Array.isArray(t)?p.length!==t.length?!1:p.every((y,v)=>y===t[v]):!1}):!1}function Xy(d,u={}){if(d.type===f.Project)return[];if(!d.parent)return[];const i=W(d.parent);if(!i)return[];const a=u[i];return a?[a.id,...Xy(a,u)]:[]}function Fme(d){const u=[],i=new Set;return[...d.listAdded,...d.listUpdated,...d.listAffected].forEach(a=>{const l=ur(a);!l||i.has(l.id)||(i.add(l.id),u.push(l))}),R(u)}function Gme(d){if(d.type===f.Condition)return null;if(d.type===f.Search)return d.project.getBuiltIn(Ee["value-descriptor"][Ol.SearchErrorOutputDescriptor].id)||null;if(d.type===f.Operation)return d.declaration.error;if(d.type===f.FunctionCall){const i=d.declaration.returnStatements.find(a=>!!a.throws);return(i==null?void 0:i.throws)||null}return null}function Ix(d){const u=d.entities.filter(l=>!!l.implements.find(p=>p.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),i=u.find(l=>{const p=l.properties.find(v=>v.implements&&v.implements.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),t=p==null?void 0:p.getDefaultValue();return(t==null?void 0:t.value)===!0});return i||u[0]||null}function AA(d,u){const i=Array.from(new Set([...u.getAllBuiltInIds(),...Ps()]));return!!(i.includes(d.id)||!Xy(d,{...u.instances,...u.builtInInstances}).every(p=>!i.includes(p)))}function wx(d){if(!d)return null;if(d.type===f.Project)return d.id;const u=d.parent;return u?wx(u):d.id}function Rx(d){const u=Pce(),i=d.toJSON();u.safeParse(i).success;const l=d.implements.flatMap(w=>Kme(d,w)),p=d.extends.flatMap(w=>kme(d,w)),t=Sme(d),y=qme(d);d.methods.flatMap(w=>w.validate());const v=[...l,...p,...t,...y];return zt(d.errors,v)}function _x(d,u){const i=u.properties.filter(p=>p.abstract),a=[];let l=[...d.properties];return i.forEach(p=>{const t=l.find(y=>{var v;return((v=y.implements)==null?void 0:v.id)===p.id});t?l=l.filter(y=>y.id!==t.id):a.push(p)}),a}function gx(d,u){const i=u.abstractMethods,a=[];let l=[...d.methods];return i.forEach(p=>{const t=l.find(y=>{var v;return((v=y.implements)==null?void 0:v.id)===p.id});t?l=l.filter(y=>y.id!==t.id):a.push(p)}),a}function Kme(d,u){const i=[];if(!u.abstract){const w=nt({id:d.id+"--"+se.ImplementingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is implementing a non-abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.ImplementingNonAbstractEntity,entity:d});return i.push(w.error),i}const a=u.properties.filter(w=>w.abstract),l=[];let p=[...d.properties];a.forEach(w=>{const A=p.find(V=>{var N;return((N=V.implements)==null?void 0:N.id)===w.id});A?p=p.filter(V=>V.id!==A.id):l.push(w)}),l.length&&l.forEach(w=>{const A=nt({id:d.id+"--"+se.MissingPropertyImplementation+"--"+w.id,message:`Property "${w.name}" with id "${w.id}" of entity "${u.name}" with id "${u.id}" is not implemented when entity "${d.name}" with id "${d.id}" implements it`,issue:null,severity:Z.Error,code:se.MissingPropertyImplementation,entity:d});i.push(A.error)});const t=[];let y=[...d.methods];u.abstractMethods.forEach(w=>{const A=y.find(V=>{var N;return((N=V.implements)==null?void 0:N.id)===w.id});A?y=y.filter(V=>V.id!==A.id):t.push(w)}),t.length&&t.forEach(w=>{const A=nt({id:d.id+"--"+se.MissingMethodImplementation+"--"+w.id,message:`Method "${w.name}" with id "${w.id}" of entity "${u.name}" with id "${u.id}" is not implemented when entity "${d.name}" with id "${d.id}" implements it`,issue:null,severity:Z.Error,code:se.MissingMethodImplementation,entity:d});i.push(A.error)});const v=[];u.properties.forEach(w=>{const A=p.find(V=>V.name===w.name);A&&v.push([A,w])}),v.length&&v.forEach(([w])=>{const A=nt({id:d.id+"--"+oe.PropertyOverwritesOtherSiblingWithSameName+"--"+w.id,message:`Property "${w.name}" with id "${w.id}" of entity "${d.name}" with id "${d.id}" overwrites the property with the same name from the base entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:oe.PropertyOverwritesOtherSiblingWithSameName,entity:d});i.push(A.error)});const T=[];return u.methods.forEach(w=>{const A=y.find(V=>V.name===w.name);A&&T.push([A,w])}),T.length&&T.forEach(([w])=>{const A=nt({id:d.id+"--"+oe.MethodOverwritesOtherSiblingWithSameName+"--"+w.id,message:`Method "${w.name}" with id "${w.id}" of entity "${d.name}" with id "${d.id}" overwrites the method with the same name from the base entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:oe.MethodOverwritesOtherSiblingWithSameName,entity:d});i.push(A.error)}),i}function kme(d,u){const i=[],a=[];if(!d.abstract&&u.abstract){const p=nt({id:d.id+"--"+u.id+"--"+se.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not-abstract but is extending an abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:u});return i.push(p.error),i}if(d.abstract&&!u.abstract){const p=nt({id:d.id+"--"+u.id+"--"+se.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but is extending an non-abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:u});return i.push(p.error),i}d.properties.forEach(p=>{var y;const t=u.properties.find(v=>{var T;return v.name===p.name&&((T=p.extends)==null?void 0:T.id)!==v.id});((y=p.implements)==null?void 0:y.id)!==(t==null?void 0:t.id)&&t&&a.push(p)}),a.length&&a.forEach(p=>{const t=nt({id:d.id+"--"+oe.PropertyOverwritesOtherSiblingWithSameName,message:`Property "${p.name}" with id "${p.id}" of entity "${d.name}" with id "${d.id}" overwrites the property with the same name from the extended entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:oe.PropertyOverwritesOtherSiblingWithSameName,entity:d});i.push(t.error)});const l=[];return d.methods.forEach(p=>{var y;const t=u.methods.find(v=>{var T;return v.name===p.name&&((T=p.extends)==null?void 0:T.id)!==v.id});((y=p.implements)==null?void 0:y.id)!==(t==null?void 0:t.id)&&t&&l.push(p)}),l.length&&l.forEach(p=>{const t=nt({id:d.id+"--"+oe.MethodOverwritesOtherSiblingWithSameName,message:`Method "${p.name}" with id "${p.id}" of entity "${d.name}" with id "${d.id}" overwrites the method with the same name from the extended entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:oe.MethodOverwritesOtherSiblingWithSameName,entity:d});i.push(t.error)}),i}function qme(d){const u=[];if(!d.properties.length){const i=nt({id:d.id+"--"+se.NoProperties,message:"No properties implemented",issue:null,severity:Z.Warning,code:se.NoProperties,entity:d});u.push(i.error)}return d.properties.forEach(i=>{i.validate()}),u}function Sme(d){const u=[];if(d.abstract){if(d.methods.length){const i=nt({id:d.id+"--"+se.AbstractEntityWithNonAbstractMethods,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract but has non-abstract methods`,issue:null,severity:Z.Error,code:se.AbstractEntityWithNonAbstractMethods,entity:d});u.push(i.error)}if(d.properties.some(i=>!i.abstract)){const i=nt({id:d.id+"--"+se.AbstractEntityWithNonAbstractProperties,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract but has non-abstract properties`,issue:null,severity:Z.Error,code:se.AbstractEntityWithNonAbstractProperties,entity:d});u.push(i.error),d.properties.forEach(a=>{if(!a.abstract){const l=nt({id:d.id+"--"+se.StaticEntityWithNonStaticProperties+"--"+a.id,message:`Property "${a.name}" with id "${a.id}" of entity "${d.name}" with id "${d.id}" is not marked as abstract but the entity is marked as abstract`,issue:null,severity:Z.Error,code:se.StaticEntityWithNonStaticProperties,entity:d});u.push(l.error)}})}}else{if(d.abstractMethods.length){const i=nt({id:d.id+"--"+se.AbstractPropertyInNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not marked as abstract but has abstract methods`,issue:null,severity:Z.Error,code:se.AbstractPropertyInNonAbstractEntity,entity:d});u.push(i.error)}d.properties.some(i=>i.abstract)&&d.properties.forEach(i=>{if(i.abstract){const a=nt({id:d.id+"--"+se.AbstractPropertyInNonAbstractEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${d.name}" with id "${d.id}" is marked as abstract but the entity is not marked as abstract`,issue:null,severity:Z.Error,code:se.AbstractPropertyInNonAbstractEntity,entity:d,firstRelationship:i});u.push(a.error)}})}return d.static&&d.properties.some(i=>!i.static)&&d.properties.forEach(i=>{if(!i.static){const a=nt({id:d.id+"--"+se.NonStaticPropertyInStaticEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${d.name}" with id "${d.id}" is not marked as static but the entity is marked as static`,issue:null,severity:Z.Error,code:se.NonStaticPropertyInStaticEntity,entity:d,firstRelationship:i});u.push(a.error)}}),u}function Zme(d,u){const i=[],a=wi(u);if(!u.abstract){const t=new qt({id:d.id+"--"+u.id+"--"+se.ImplementingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is implementing a non-abstract built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.ImplementingNonAbstractEntity,entity:d,firstRelationship:u});i.push(t)}const l=d.implements.filter(t=>t.id!==u.id);if(d.abstract){const t=new qt({id:d.id+"--"+u.id+"--"+se.AbstractEntityImplements,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract and cannot implement built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.AbstractEntityImplements,entity:d,firstRelationship:u});i.push(t)}if(d.static&&!u.static){const t=new qt({id:d.id+"--"+u.id+"--"+se.StaticImplementingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is marked as static and cannot implement non-static built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.StaticImplementingNonStaticEntity,entity:d,firstRelationship:u});i.push(t)}if(!d.static&&u.static){const t=new qt({id:d.id+"--"+u.id+"--"+se.NonStaticImplementingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is not marked as static and cannot implement static built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.NonStaticImplementingStaticEntity,entity:d,firstRelationship:u});i.push(t)}return l.length&&l.forEach(t=>{if(t.type===f.BuiltInBaseEntity){const y=a.filter(v=>v.id!==t.id);y.length&&y.forEach(v=>{if(v.id!==t.id){const T=new qt({id:d.id+"--"+v.id+"--"+t.id+"--"+se.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${v.name}" with id "${v.id}" but also implements entity "${t.name}" with id "${t.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ImplementsIncompatibleEntities,entity:d,firstRelationship:v,secondRelationship:t});i.push(T)}})}else{wi(t).forEach(w=>{const A=a.filter(V=>V.id!==w.id);A.length&&A.forEach(V=>{if(V.id!==w.id){const N=new qt({id:d.id+"--"+V.id+"--"+w.id+"--"+se.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${V.name}" with id "${V.id}" but also implements entity "${w.name}" with id "${w.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ImplementsIncompatibleEntities,entity:d,firstRelationship:V,secondRelationship:w});i.push(N)}})});const v=ya(u.ownDeclaredProperties,t.ownDeclaredProperties,oe.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,oe.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);i.push(...v.errors);const T=ya(u.abstractMethods,[...t.abstractMethods,...t.methods],oe.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,oe.MethodOverwritesOtherImplementedEntitysMethodWithSameName);i.push(...T.errors)}}),R(d.extends.flatMap(t=>wi(t))).forEach(t=>{if(!a.find(y=>y.id===t.id)){const y=new qt({id:d.id+"--"+u.id+"--"+t.id+"--"+se.ExtendsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${u.name}" with id "${u.id}" but also extends entity "${t.name}" with id "${t.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ExtendsIncompatibleEntities,entity:d,firstRelationship:u,secondRelationship:t});i.push(y)}}),i}function Jme(d,u,i=!1){const a=[],l=wi(u);if(!d.abstract&&u.abstract){const w=nt({id:d.id+"--"+u.id+"--"+se.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not-abstract but is extending an abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:u});a.push(w.error)}if(d.abstract&&!u.abstract){const w=nt({id:d.id+"--"+u.id+"--"+se.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but is extending an non-abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:u});a.push(w.error)}if(!d.static&&u.static){const w=nt({id:d.id+"--"+u.id+"--"+se.NonStaticExtendingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is not static but is extending a static entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.NonStaticExtendingStaticEntity,entity:d,firstRelationship:u});a.push(w.error)}if(d.static&&!u.static){const w=nt({id:d.id+"--"+u.id+"--"+se.StaticExtendingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but is extending an non-static entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.StaticExtendingNonStaticEntity,entity:d,firstRelationship:u});a.push(w.error)}if(!Rp(u)){const w=nt({id:d.id+"--"+u.id+"--"+se.ExtendingNonInteractiveEntity,message:`Entity "${d.name}" with id "${d.id}" is extending an non-interactive entity "${u.name}" with id "${u.id}"`,issue:null,severity:Z.Error,code:se.ExtendingNonInteractiveEntity,entity:d,firstRelationship:u});a.push(w.error)}const t=d.extends.filter(w=>w.id!==u.id);t.length&&t.forEach(w=>{if(w.type===f.BuiltInBaseEntity){const A=l.filter(V=>V.id!==w.id);A.length&&A.forEach(V=>{if(V.id!==w.id){const N=nt({id:d.id+"--"+V.id+"--"+w.id+"--"+se.ExtendsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${V.name}" with id "${V.id}" but also extends entity "${w.name}" with id "${w.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ExtendsIncompatibleEntities,entity:d,firstRelationship:V,secondRelationship:w});a.push(N.error)}})}else{wi(w).forEach(Y=>{const ie=l.filter(te=>te.id!==Y.id);ie.length&&ie.forEach(te=>{if(te.id!==Y.id){const pe=new qt({id:d.id+"--"+te.id+"--"+Y.id+"--"+se.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${te.name}" with id "${te.id}" but also extends or implements entity "${Y.name}" with id "${Y.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ImplementsIncompatibleEntities,entity:d,firstRelationship:te,secondRelationship:Y});a.push(pe)}})});const V=!!wi(w).find(Y=>Y.id===u.id);let N=[...w.properties];V&&(N=N.filter(Y=>!u.properties.find(ie=>{var te;return ie.id===Y.id||ie.name===Y.name||ie.id===((te=Y.implements)==null?void 0:te.id)})));let j=[...w.methods];V&&(j=j.filter(Y=>!u.methods.find(ie=>{var te;return ie.id===Y.id||ie.name===Y.name||ie.id===((te=Y.implements)==null?void 0:te.id)})));const k=ya(u.ownDeclaredProperties,N,oe.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation,oe.PropertyOverwritesOtherExtendedEntitysPropertyWithSameName);a.push(...k.errors);const q=ya(u.abstractMethods,j,oe.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation,oe.MethodOverwritesOtherExtendedEntitysMethodWithSameName);a.push(...q.errors)}}),i&&console.log("self.implements.length",d.implements.length),d.implements.length&&d.implements.forEach(w=>{if(w.type===f.BuiltInBaseEntity){const A=l.filter(V=>V.id!==w.id);A.length&&A.forEach(V=>{if(V.id!==w.id){const N=new qt({id:d.id+"--"+V.id+"--"+w.id+"--"+se.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${V.name}" with id "${V.id}" but also implements entity "${w.name}" with id "${w.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ImplementsIncompatibleEntities,entity:d,firstRelationship:V,secondRelationship:w});a.push(N)}})}else{wi(w).forEach(j=>{const k=l.filter(q=>q.id!==j.id);k.length&&k.forEach(q=>{if(q.id!==j.id){const Y=new qt({id:d.id+"--"+q.id+"--"+j.id+"--"+se.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${q.name}" with id "${q.id}" but also implements entity "${j.name}" with id "${j.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ImplementsIncompatibleEntities,entity:d,firstRelationship:q,secondRelationship:j});a.push(Y)}})});const V=ya(u.ownDeclaredProperties,w.ownDeclaredProperties,oe.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,oe.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);a.push(...V.errors);const N=ya(u.abstractMethods,[...w.abstractMethods,...w.methods],oe.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,oe.MethodOverwritesOtherImplementedEntitysMethodWithSameName);a.push(...N.errors)}});const y=ya(d.ownDeclaredProperties,u.ownDeclaredProperties,oe.PropertyOverwritesOtherSiblingWithSameImplementation,oe.PropertyOverwritesOtherSiblingWithSameName);a.push(...y.errors);const v=ya(u.methods,u.abstractMethods,oe.MethodOverwritesOtherSiblingWithSameImplementation,oe.MethodOverwritesOtherSiblingWithSameName);return a.push(...v.errors),R(d.extends.flatMap(w=>wi(w))).forEach(w=>{if(!l.find(A=>A.id===w.id)){const A=new qt({id:d.id+"--"+u.id+"--"+w.id+"--"+se.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${u.name}" with id "${u.id}" but also extends entity "${w.name}" with id "${w.id}" which is incompatible`,issue:null,severity:Z.Error,code:se.ImplementsIncompatibleEntities,entity:d,firstRelationship:u,secondRelationship:w});a.push(A)}}),a}function Wme(d){const u=[];return d.implements.forEach(i=>{if(!i.static){const a=new qt({id:d.id+"--"+i.id+"--"+se.StaticImplementingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but implements entity "${i.name}" with id "${i.id}" which is non-static`,issue:null,severity:Z.Error,code:se.StaticImplementingNonStaticEntity,entity:d,firstRelationship:i});u.push(a)}}),d.extends.forEach(i=>{if(!i.static){const a=new qt({id:d.id+"--"+i.id+"--"+se.StaticExtendingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but extends entity "${i.name}" with id "${i.id}" which is non-static`,issue:null,severity:Z.Error,code:se.StaticExtendingNonStaticEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function Yme(d){const u=[];if(d.implements.length){const i=new qt({id:d.id+"--"+se.AbstractEntityImplements,message:`Entity "${d.name}" with id "${d.id}" cannot be marked as abstract because it implements other entities`,issue:null,severity:Z.Error,code:se.AbstractEntityImplements,entity:d});u.push(i)}return d.extends.forEach(i=>{if(!i.abstract){const a=new qt({id:d.id+"--"+i.id+"--"+se.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but extends entity "${i.name}" with id "${i.id}" which is non-abstract`,issue:null,severity:Z.Error,code:se.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function Hme(d){const u=[];return d.extends.forEach(i=>{if(i.static){const a=new qt({id:d.id+"--"+i.id+"--"+se.NonStaticExtendingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is non-static but extends entity "${i.name}" with id "${i.id}" which is static`,issue:null,severity:Z.Error,code:se.NonStaticExtendingStaticEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function zme(d){const u=[];return d.extends.forEach(i=>{if(i.abstract){const a=new qt({id:d.id+"--"+i.id+"--"+se.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is non-abstract but extends entity "${i.name}" with id "${i.id}" which is abstract`,issue:null,severity:Z.Error,code:se.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:i});u.push(a)}}),u}const Xme=Object.freeze(Object.defineProperty({__proto__:null,getBaseMethodsNotImplemented:gx,getBasePropertiesNotImplemented:_x,validate:Rx,validateCanBecomeAbstract:Yme,validateCanBecomeNonAbstract:zme,validateCanBecomeNonStatic:Hme,validateCanBecomeStatic:Wme,validateCanExtendEntity:Jme,validateCanImplementEntity:Zme},Symbol.toStringTag,{value:"Module"}));function Qme(d,u){const i=[];if(d.parent)if(d.id===d.parent)i.push(new Q({id:`${d.id}--${d.parent}--${S.SelfReference}`,code:S.SelfReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at 'parent'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null}));else{const a=u.get(d.parent);a?[f.Project,f.DataType].includes(a.type)||i.push(new Q({id:`${d.id}--${d.parent}--${S.InvalidParentReference}`,code:S.InvalidParentReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):i.push(new Q({id:`${d.id}--${d.parent}--${S.ReferencedEntityNotFound}`,code:S.ReferencedEntityNotFound,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return d.implements&&Array.isArray(d.implements)?d.implements.forEach(a=>{if(d.id===a){i.push(new Q({id:`${d.id}--${a}--${S.SelfReference}`,code:S.SelfReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at one of the 'implements' references. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null}));return}const l=u.get(a);l?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(l.type)?l.abstract||i.push(new Q({id:`${d.id}--${a}--${S.InvalidImplementsReference}`,code:S.InvalidImplementsReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.InvalidImplementsReference}`,code:S.InvalidImplementsReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.ReferencedEntityNotFound}`,code:S.ReferencedEntityNotFound,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${a}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):i.push(new Q({id:`${d.id}--${oe.InvalidObjectStructure}`,code:oe.InvalidObjectStructure,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' property that isn't an array.`,issue:null})),d.extends&&Array.isArray(d.extends)&&d.extends.forEach(a=>{const l=u.get(a);l?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(l.type)?l.abstract&&i.push(new Q({id:`${d.id}--${a}--${S.InvalidExtendsReference}`,code:S.InvalidExtendsReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'extends' reference that isn't pointing to a non-abstract entity. Did you want to use the property 'implements', which holds a list of references to absract entities, instead?`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.InvalidExtendsReference}`,code:S.InvalidExtendsReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'extends' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.ReferencedEntityNotFound}`,code:S.ReferencedEntityNotFound,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${a}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),i}var Qy=(d=>(d.Extends="extends",d.Implements="implements",d))(Qy||{});const Ct=class Ct extends hr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"name");D(this,"codeName",null);D(this,"description",null);D(this,"x");D(this,"y");D(this,"static");D(this,"abstract");D(this,"type",f.DefinitionEntity);D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"implements",[]);D(this,"project");D(this,"errors",[]);D(this,"parent");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"suggestedProperties",[]);D(this,"suggestedMethods",[]);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.static=i.static,this.abstract=i.abstract}static new(i=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DefinitionEntity,name:"",codeName:null,description:"",static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:null}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const T=W(i.parent);l=a.get(T)}const p=[];i.implements&&i.implements.forEach(T=>{p.push(a.get(T)||a.getBuiltIn(T))});const t=[];i.extends&&i.extends.forEach(T=>{t.push(a.get(T)||a.getBuiltIn(T))});const y={id:i.id,version:P.UUID.uuid(),createdAt:L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,type:f.DefinitionEntity,codeName:i.codeName||null,description:i.description,static:i.static,abstract:i.abstract,properties:[],methods:[],abstractMethods:[],extends:t,implements:p,x:0,y:0,parent:l},v=ee(y,a);return v.setParent(l,null),v}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[],t=Qme(l,a),y=hb(l,a);p.push(...t,...y,...vr(l));const v=l.parent?a.get(l.parent):null;if(v&&v.type===f.DataType){const T=v;T.entity&&p.push(new Q({id:`${i.id}--${S.NewEntityWouldOverriteExisting}`,code:S.NewEntityWouldOverriteExisting,severity:Z.Error,message:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${T.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
401
401
  You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
402
402
  ${On({describe_entity:T.entity.id})}
403
- Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:p,modifiedData:l}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return R([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return R([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allMethods,[]),...this.implements.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allProperties,[]),...this.implements.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return R([...this.extends.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[]),...this.implements.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[])])}get allBaseMethodsFromExtendedAndImplementedEntities(){return R([...this.extends.reduce((i,a)=>a.type!==f.DefinitionEntity?[]:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[]),...this.implements.reduce((i,a)=>a.type!==f.DefinitionEntity?a.abstractMethods:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return R(this.extends.reduce((i,a)=>{if(a.type!==f.DefinitionEntity)return[];const l=[...a.ownDeclaredMethods,...a.extendedMethodsFromOriginalParents].filter(p=>p.type!==f.ActionDescriptor);return[...i,...l]},[]))}get implementedMethodsFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.type===f.DefinitionEntity?a.methods:[],p=[...a.abstractMethods].filter(t=>!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>[...a.abstractMethods,...i],[])].filter(i=>i.type===f.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${S.InvalidParentUpdate}`,code:S.InvalidParentUpdate,severity:Z.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.removeImplementation(i),a==="extends"&&this.removeExtension(i),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.addImplementation(i),a==="extends"&&this.addExtension(i),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{ki.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this}subscribeToDependencies(){return this.implements.forEach(i=>{ki.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends.forEach(i=>{ki.includes(i.type)||i.subscribeDependents([{entity:this,field:"extends"}])}),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ct(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=[...this.extends],i.implements=[...this.implements],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const T=new Map;for(const[w,A]of this.knownVersions||new Map){if(T.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,N]of A.knownVersions)T.set(V,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ct(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.properties=y.properties,this.methods=y.methods,this.abstractMethods=y.abstractMethods,this.extends=y.extends,this.implements=y.implements,this.parent=y.parent,{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=W(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return i.extends.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addExtension(t)}),i.implements.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addImplementation(t)}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return this.initialData.extends.forEach(t=>{const y=W(t),v=this.project.get(y);v&&(this.addExtension(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),this.initialData.implements.forEach(t=>{const y=W(t),v=this.project.get(y);v&&(this.addImplementation(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:T,affected:w}=this.syncImplementationProperties(i);a.push(...y),l.push(...v),p.push(...T),t.push(...w);const{updated:A,added:V,removed:N,affected:j}=this.addExtendedProperties(i);a.push(...A),l.push(...V),p.push(...N),t.push(...j);const{updated:k,added:q,removed:Y}=this.removeUnrecognizedProperties(i);a.push(...k),l.push(...q),p.push(...Y);const{updated:ie,added:te,removed:pe,affected:ne}=this.syncImplementationMethods(i);a.push(...ie),l.push(...te),p.push(...pe),t.push(...ne);const{updated:me,added:J,removed:ae,affected:ce}=this.addExtendedMethods(i);a.push(...me),l.push(...J),p.push(...ae),t.push(...ce);const{updated:H,added:de,removed:ve}=this.removeUnrecognizedMethods(i);return a.push(...H),l.push(...de),p.push(...ve),this.addSuggestions(),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];if(this.parent.type===f.DataType){const y=this.parent;y.entity=this,a.push(y)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}addExtension(i){return this.extends.includes(i)||this.extends.push(i),this}removeExtension(i){return this.extends=this.extends.filter(a=>a.id!==i.id),this}addImplementation(i){return this.implements.includes(i)||this.implements.push(i),this}removeImplementation(i){return this.implements=this.implements.filter(a=>a.id!==i.id),this}removeProperty(i){return this.properties=this.properties.filter(a=>a.id!==i.id),this}addMethod(i){return this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name)),this}removeMethod(i){return this.methods=this.methods.filter(a=>a.id!==i.id),this}addProperty(i){return this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name)),this}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(a=>a.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(a=>a.id!==i.id),this}addAbstractMethod(i){return this.abstractMethods.includes(i)||this.abstractMethods.push(i),this}removeAbstractMethod(i){return this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),this}initChildren(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.properties=this.initialData.properties.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.methods=this.initialData.methods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.extends=this.initialData.extends.map(a=>ee(a,this.project)),this.implements=this.initialData.implements.map(a=>ee(a,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}removeUnrecognizedProperties(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-properties"))){const a=[],l=[],p=[],t=[];let y=[...this.properties];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedProperty);const v=this.implementedPropertiesFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(w=>{var A;return w.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const w=T.remove({ignoreUpstream:!1},i);p.push(...w.removed),a.push(...w.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-methods"))){const a=[],l=[],p=[],t=[];let y=[...this.methods];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedMethod);const v=this.implementedMethodsFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(w=>{var A;return w.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const w=T.remove({ignoreUpstream:!1},i);p.push(...w.removed),a.push(...w.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,v=this.implementedMethodsFromOriginalParents,T=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var j;return((j=N.implements)==null?void 0:j.id)===A.id})).forEach(A=>{if(this.methods.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===A.id}))return;const N=this.methods.find(k=>{var pe,ne;if(k.name===A.name&&!k.implements)return!0;const q=Vs(this,$e.CRON_JOB),Y=Vs(this,$e.HTTP_ENDPOINT),ie=((pe=k.implements)==null?void 0:pe.id)===Ee["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,te=((ne=k.implements)==null?void 0:ne.id)===Ee["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(q&&!te&&!Y&&ie||Y&&!ie&&!q&&te)});if(N&&N.type===f.FunctionDeclaration){N.setImplements(A),N.metaSync({name:A.name},i),i==null||i.add(N,K.Updated),i==null||i.add(this,K.Updated);return}const j=A.implementAsFunctionDeclaration(i,this);l.push(j),i==null||i.add(j,K.Added),this.addMethod(j)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.implementedPropertiesFromOriginalParents,T=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var j;return((j=N.implements)==null?void 0:j.id)===A.id})).forEach(A=>{if(this.properties.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===A.id}))return;const N=this.properties.find(k=>k.name===A.name&&!!k.abstract&&!k.implements);if(N){N.setImplements(A,i),N.metaSync({abstract:!1},i),N.afterAllChildrenInitialized(i);return}const j=A.implement(this,i,P.UUID.uuid());l.push(j),i==null||i.add(j,K.Added)}),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addExtendedMethods(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-extended-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,T=this.extendedMethodsFromOriginalParents.filter(A=>A.type===f.FunctionDeclaration),w=new Set(y.filter(A=>{var V;return!!((V=A.extends)!=null&&V.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(w.has(A.id))return;w.add(A.id);const V=A.clone(i,this,P.UUID.uuid());V.setExtends(A,i),V.initChildren(i),l.push(V),i==null||i.add(V,K.Added),this.addMethod(V)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addExtendedProperties(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-extended-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.extendedPropertiesFromOriginalParents,T=v.filter(A=>v.find(N=>{var j;return((j=N.implements)==null?void 0:j.id)===A.id})?!1:!A.abstract),w=new Set(y.filter(A=>{var V;return!!((V=A.extends)!=null&&V.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(w.has(A.id))return;w.add(A.id);const V=A.clone(i,this,P.UUID.uuid());V.setExtends(A,i),V.initChildren(i),l.push(V),i==null||i.add(V,K.Added),this.addProperty(V)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSuggestions(){return this.implements.forEach(i=>{_x(this,i).forEach(p=>{const t=p.toJSON();t.id=`_suggestion--parent--${this.id}--${p.id}`;const y=ee(t,this.project);y.suggestion=!0,y.setParent(this,null),y.initChildren(null),this.addSuggestedProperty(y)}),gx(this,i).forEach(p=>{const t=`_suggestion--parent--${this.id}--${p.id}`,y=p.implementAsFunctionDeclaration(null,this,t),v=ee(y,this.project);if(v.suggestion=!0,v.setParent(this,null),v.initChildren(null),this.methods=this.methods.filter(T=>T.id!==t),v.inputs.forEach(T=>{T.suggestion=!0}),v.returnStatements.length){const T=v.returnStatements[0];T.suggestion=!0,T.outputs.forEach(w=>{w.suggestion=!0})}this.addSuggestedMethod(v)})}),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Er(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,this.static=i.static!==void 0?i.static:this.static,this.abstract=i.abstract!==void 0?i.abstract:this.abstract,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Ct.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Ct.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Ct.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Ct.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Ct.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Ct.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];if(this.parent.type===f.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===f.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const y=this.parent.setEntity(null,i);a.push(y)}return i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(l),affected:R(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:w,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),p.push(...w),t.push(...A)}),this.properties.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.methods.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.abstractMethods.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.suggestedProperties.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.suggestedMethods.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(p),affected:R(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:T,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...T),a.push(...w)}),this.properties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.methods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.abstractMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedProperties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(l),removed:R(p),affected:R(t),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.extends.flatMap(l=>l.toFlat(i)),...this.implements.flatMap(l=>l.toFlat(i)),...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.extends.flatMap(l=>l.toFlatIds(i)),...this.implements.flatMap(l=>l.toFlatIds(i)),...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),implements:this.implements.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i)),parent:this.parent.toReference()})}toJSONClone(i=Ne){var l,p,t,y,v;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Ar(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(T=>T.toJSONClone({...i,newId:null})),methods:this.methods.map(T=>T.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(T=>T.toJSONClone({...i,newId:null})),implements:this.implements.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),extends:this.extends.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(p=>p.toReference(i)),methods:this.methods.map(p=>p.toReference(i)),abstractMethods:this.abstractMethods.map(p=>p.toReference(i)),implements:this.implements.map(p=>p.toReference(i)),extends:this.extends.map(p=>p.toReference(i)),parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i)),...this.implements.flatMap(l=>l.toFlatJSON(i)),...this.extends.flatMap(l=>l.toFlatJSON(i)),...this.parent.toFlatJSON(i)])}toGenerationTarget(){const i=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:this.extends.map(a=>a.id),implements:this.implements.map(a=>a.id),parent:i}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.parent.toFlatGenerationTarget(i)])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=Rx(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var k,q,Y;let t=Ir(a,this);const y=this.toJSON(),v=l||P.UUID.uuid();y.properties=[],y.methods=[],y.abstractMethods=[];const T=v.split("-id"),w=T[T.length-1||0]||v;y.id=v,y.version=P.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const A=Kt(y,t);a&&A.setParent(a,null),p&&A.subscribe(),A.initChildren(i),i==null||i.add(A,K.Added);const V=(k=this.properties)==null?void 0:k.map(ie=>ie.clone(i,A,P.UUID.uuid(),p));A.properties=V;const N=(q=this.methods)==null?void 0:q.map((ie,te)=>ie.clone(i,A,w+"-method-"+te+"-id",p));A.methods=N;const j=(Y=this.abstractMethods)==null?void 0:Y.map((ie,te)=>ie.clone(i,A,w+"-abstract-method-"+te+"-id",p));return A.abstractMethods=j,i==null||i.attemptAutoclose("clone-entity",this.id),A}getFunctionDeclaration(i){return this.methods.find(a=>a.id===i)}implement(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"implement-definition-entity")),l){const p=Fy(this,i,a,l);return a==null||a.attemptAutoclose("implement-definition-entity",this.id),p}getAllInteractiveMethods(){const i=this.implements.filter(l=>l.type===f.DefinitionEntity||l.type===f.BuiltInBaseEntity&&l.interactive);return R([...this.methods,...this.extends.flatMap(l=>l.getAllInteractiveMethods()),...i.flatMap(l=>l.getAllInteractiveMethods())])}inferFromInputs(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const l=[],p=[],t=[],y=[];if(this.parent.type!==f.DataType||!this.parent.inferred)return a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const v=[];i.forEach(A=>{v.find(N=>re(N,this.project)===re(A,this.project))||v.push(A)});const T=this.properties.filter(A=>!A.dataType);v.forEach(A=>{var Y,ie;const V=T.find(te=>re(te,this.project)===re(A,this.project));if(!V)return;const j=oi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),k=zs(j,a),q=k==null?void 0:k.clone(a,V,P.UUID.uuid(),!0);q&&((Y=V.dataType)==null||Y.merge(q,a),q.id!==((ie=V.dataType)==null?void 0:ie.id)&&q.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,K.Affected))),A.setDeclaration(V),a==null||a.add(A,K.Updated)});const w=[];return v.forEach(A=>{if(!A.declaration){w.push(A);return}}),w.length===0?(a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(w.forEach(A=>{var te,pe,ne,me;const V=this.properties.find(J=>re(J,this.project)===re(A,this.project));if(V){if(A.setDeclaration(V),!V.getDataType(a)){const ae=oi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),ce=zs(ae),H=ce==null?void 0:ce.clone(a,V,P.UUID.uuid(),!0);H&&((te=V.dataType)==null||te.merge(H,a),H.id!==((pe=V.dataType)==null?void 0:pe.id)&&H.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,K.Affected)))}return}const N={id:P.UUID.uuid(),type:f.Property,version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:re(A,this.project),codeName:A.codeName,description:A.description,defaultValue:null,static:!0,abstract:!1,private:!1,hidden:!1,required:!1,constant:!0,index:A.index,implements:null,extends:null,dataType:null,parent:this.toReference()},j=ee(N,this.project);j.setParent(this,a),j.initChildren(a),a==null||a.add(j,K.Added);const q=oi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),Y=zs(q),ie=Y==null?void 0:Y.clone(a,j,P.UUID.uuid(),!0);return ie&&((ne=j.dataType)==null||ne.merge(ie,a),ie.id!==((me=j.dataType)==null?void 0:me.id)&&ie.remove({ignoreUpstream:!1},a),j.dataType&&(j.dataType.metaSync({inferred:!0,like:!0},a),j.setDataType(j.dataType,a),a==null||a.add(j,K.Affected))),this.addProperty(j),A.setDeclaration(j),a==null||a.add(A,K.Updated),j}),a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:R(l),updated:R(p),removed:R(t),affected:R(y),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(a=>{var p;const l=kr(a.name);i[l]=((p=a.getDefaultValue())==null?void 0:p.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(a=>{const l=kr(a.name),p=this.project.requestActiveValue(a);i[l]=(p==null?void 0:p.value)||null}),i}};D(Ct,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(Ct,"type",f.DefinitionEntity),D(Ct,"USER_MANAGED_PARENT_TYPES",[f.Project,f.DataType]),D(Ct,"PARENT_TYPES",[...Ct.USER_MANAGED_PARENT_TYPES]),D(Ct,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract"]),D(Ct,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(Ct,"BASE_PROPERTIES",[...Ct.MUTABLE_BASE_PROPERTIES,...Ct.INMUTABLE_BASE_PROPERTIES]),D(Ct,"MUTABLE_META_PROPERTIES",[...Ct.MUTABLE_BASE_PROPERTIES,"x","y"]),D(Ct,"INMUTABLE_META_PROPERTIES",[...Ct.INMUTABLE_BASE_PROPERTIES]),D(Ct,"META_PROPERTIES",[...Ct.MUTABLE_META_PROPERTIES,...Ct.INMUTABLE_META_PROPERTIES]),D(Ct,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),D(Ct,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),D(Ct,"UPSTREAM_PROPERTIES",[...Ct.MUTABLE_UPSTREAM_PROPERTIES,...Ct.INMUTABLE_UPSTREAM_PROPERTIES]),D(Ct,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),D(Ct,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(Ct,"DOWNSTREAM_PROPERTIES",[...Ct.MUTABLE_DOWNSTREAM_PROPERTIES,...Ct.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(Ct,"PROPERTIES",[...Ct.META_PROPERTIES,...Ct.UPSTREAM_PROPERTIES,...Ct.DOWNSTREAM_PROPERTIES]);let ma=Ct;function e0e(d){const u=ude(),i=d.toJSON();u.safeParse(i).success;const l=[];return zt(d.errors,l)}const jp=class jp extends hr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"version");D(this,"name");D(this,"description",null);D(this,"type",f.BuiltInBaseEntity);D(this,"abstract",!1);D(this,"static");D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"interactive",!1);D(this,"errors",[]);D(this,"project");this.initialData=this.initialData||i,this.project=this.project||a,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.extends=this.initialData.extends.map(l=>ee(l,this.project))}get allMethods(){return R([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return R([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=ye,...a){return await jp.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.extends.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.extends.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,interactive:this.interactive,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=Ne){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=e0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}implement(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),null,!0,"implement-built-in-base-entity")),l){const p=Fy(this,i,a,l);return a==null||a.attemptAutoclose("implement-built-in-base-entity",this.id),p}getAllInteractiveMethods(){const i=[];return this.interactive&&(i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof jp&&i.push(...l.getAllInteractiveMethods())})),R(i)}};D(jp,"repository",{APILoad:async(i,...a)=>null});let Cn=jp;function t0e(d){const u=tde(),i=d.toJSON();u.safeParse(i).success;const l=[];return zt(d.errors,l)}const cm=class cm extends hr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"name");D(this,"description",null);D(this,"type",f.PrimitiveEntity);D(this,"static");D(this,"abstract");D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"errors",[]);D(this,"project");this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.parent=this,p})}get allMethods(){return R([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return R([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=ye,...a){return await cm.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=Ne){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=t0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof Cn&&i.push(...l.getAllInteractiveMethods())}),R(i)}};D(cm,"repository",{APILoad:async(i,...a)=>null});let Li=cm;function Kt(d,u){if(!d)throw new Error("Entity is null");const i=u.get(d.id);switch(d.type){case f.LiteralValue:return i||new bi(d,u);case f.DefinitionEntity:return i||new ma(d,u);case f.PrimitiveEntity:return i||new Li(d,u);case f.FunctionDeclaration:return i||new Ua(d,u);case f.GlobalEvent:return i||new Fa(d,u);case f.DataType:return i||new Hi(d,u);case f.Property:return i||new ua(d,u);case f.FunctionCall:return i||new za(d,u);case f.Condition:return i||new Ga(d,u);case f.Operation:return i||new ja(d,u);case f.VariableDeclaration:return i||new ka(d,u);case f.VariableInstance:return i||new Ka(d,u);case f.OutputMap:return i||new Qs(d,u);case f.ReturnDeclaration:return i||new Ni(d,u);case f.ArgumentDeclaration:return i||new pa(d,u);case f.InputMap:return i||new Cs(d,u);case f.Project:return i||new P(d);case f.InstalledProject:return i||new Sa(d,u);case f.ActionDescriptor:return i||new jt(d,u);case f.ReturnStatement:return i||new xa(d,u);case f.Loop:return i||new Ai(d,u);case f.Search:return i||new qa(d,u);case f.ValueDescriptor:return i||new en(d,u);case f.BuiltInBaseEntity:return i||new Cn(d,u);case f.InternalCall:return i||new Za(d,u);case f.ContinueStatement:return i||new li(d,u);case f.BreakStatement:return i||new Ja(d,u);case f.GenericReference:return u.get(d.entityId);default:throw new Error("Invalid entity type: "+d.type)}}function ee(d,u){if(!d)throw new Error("Entity is null");const i=Kt(d,u);return i.subscribe(),i}function r0e(d,u){if(!d)throw new Error("Entity is null");switch(d.type){case f.LiteralValue:return bi.fromGenerationTarget(d,u);case f.DefinitionEntity:return ma.fromGenerationTarget(d,u);case f.FunctionDeclaration:return Ua.fromGenerationTarget(d,u);case f.GlobalEvent:return Fa.fromGenerationTarget(d,u);case f.DataType:return Hi.fromGenerationTarget(d,u);case f.Property:return ua.fromGenerationTarget(d,u);case f.FunctionCall:return za.fromGenerationTarget(d,u);case f.Condition:return Ga.fromGenerationTarget(d,u);case f.Operation:return ja.fromGenerationTarget(d,u);case f.VariableDeclaration:return ka.fromGenerationTarget(d,u);case f.VariableInstance:return Ka.fromGenerationTarget(d,u);case f.OutputMap:return Qs.fromGenerationTarget(d,u);case f.ReturnDeclaration:return Ni.fromGenerationTarget(d,u);case f.ArgumentDeclaration:return pa.fromGenerationTarget(d,u);case f.InputMap:return Cs.fromGenerationTarget(d,u);case f.InstalledProject:return Sa.fromGenerationTarget(d,u);case f.ReturnStatement:return xa.fromGenerationTarget(d,u);case f.Loop:return Ai.fromGenerationTarget(d,u);case f.Search:return qa.fromGenerationTarget(d,u);case f.ActionDescriptor:return jt.fromGenerationTarget(d,u);case f.ValueDescriptor:return en.fromGenerationTarget(d,u);case f.InternalCall:return Za.fromGenerationTarget(d,u);case f.ContinueStatement:return li.fromGenerationTarget(d,u);case f.BreakStatement:return Ja.fromGenerationTarget(d,u);default:throw new Error("Invalid entity type: "+d.type)}}const Ne={seenEntityMaps:new Map,seenEntities:new Set,timestamp:L().toISOString()};class Dx{constructor(){D(this,"initialData")}}const ye={cascade:!1},Ox={APILoad:async(d,...u)=>null},i0e={APICreate:async(d,...u)=>d,APIUpdate:async(d,...u)=>d,APIDelete:async(d,...u)=>d,APIClone:async(d,...u)=>{},APILoadVersion:async(d,u,...i)=>null,...Ox};class s0e{}class n0e extends Dx{}class a0e{}class o0e{}class l0e{}class IA{}class d0e extends IA{}class u0e extends IA{}class c0e{}class Op{static initReadsValue(u){if(u.initialData.readsValue&&u.initialData.readsValue.type!==f.GenericReference)u.readsValue=ee(u.initialData.readsValue,u.project);else if(u.initialData.readsValue&&u.initialData.readsValue.type===f.GenericReference){const i=_i(u.initialData.readsValue,u.project);i&&(u.readsValue=i)}if(u.readsValue){if(rt.includes(u.readsValue.type)){let i=u.parent;br.includes(i.type)||(i=i.parent);const a=u.type===f.InputMap&&u.parent.type===f.Loop;a&&(i=u.parent.parent),u.readsValue.setParent(i,null),u.readsValue.initChildren(null),i&&i.type!==f.Project&&!a&&i.detachedChildren.includes(u)?i.replaceDetachedChild(u,u.readsValue):i&&i.type!==f.Project&&!a&&i.subscribeDetachedChild(u.readsValue)}u.readsValue.addValueReader(u,null)}return u.readsValue}}class Cp{static initWritesValues(u,i){const a=u.initialData.writesValues.reduce((p,t)=>{if(t.type===f.GenericReference||u.writesValues.some(v=>v.id===t.id))return p;const y=ee(t,u.project);return y.setValueWriter(u,null),rt.includes(y.type)&&(y.setParent(i,null),y.initChildren(null)),[...p,y]},[]),l=[...u.writesValues];return u.writesValues=R([...l,...a]),u.writesValues}}class p0e{}var f0e=Object.defineProperty,h0e=(d,u,i)=>u in d?f0e(d,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[u]=i,Yo=(d,u,i)=>(h0e(d,typeof u!="symbol"?u+"":u,i),i);class y0e{constructor(u){Yo(this,"eventName"),Yo(this,"callbacks",[]),this.eventName=u,this.on=this.on.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}on(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks.includes(u)||this.callbacks.push(u)}off(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(i=>i!==u)}destroy(){this.callbacks=[]}}class wA{constructor(){Yo(this,"subscribedEvents",{}),Yo(this,"on",this._on),Yo(this,"emit",this._emit),Yo(this,"off",this._off),Yo(this,"destroy",this._destroy),this.getEvent=this.getEvent.bind(this),this._on=this._on.bind(this),this._emit=this._emit.bind(this),this._off=this._off.bind(this),this._destroy=this._destroy.bind(this),this.on=this.on.bind(this),this.emit=this.emit.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}getEvent(u){return this.subscribedEvents[u]||(this.subscribedEvents[u]=new y0e(u)),this.subscribedEvents[u]}_on(u,i){this.getEvent(u).on(i)}_emit(u,...i){const a=this.getEvent(u);a&&a.callbacks.forEach(l=>{l.apply(null,i)})}_off(u,i){const a=this.getEvent(u);a&&(i?a.off(i):(a.destroy(),delete this.subscribedEvents[u]))}_destroy(){Object.keys(this.subscribedEvents).forEach(u=>{this._off(u)}),this.subscribedEvents={}}}var yr=(d=>(d.PROJECT_INITIALIZED="project-initialized",d.CHANGE_SET_CLOSED="change-set-closed",d.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",d.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",d.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",d.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",d.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",d.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",d))(yr||{});const Ke=class Ke extends hr{constructor(i){super(i);D(this,"initialData");D(this,"id");D(this,"type",f.Project);D(this,"name",null);D(this,"description",null);D(this,"x");D(this,"y");D(this,"entities",[]);D(this,"projects",[]);D(this,"functions",[]);D(this,"events",[]);D(this,"variableDeclarations",[]);D(this,"variableInstances",[]);D(this,"conditions",[]);D(this,"operations",[]);D(this,"functionCalls",[]);D(this,"loops",[]);D(this,"searches",[]);D(this,"primitives",[]);D(this,"builtInBaseEntities",[]);D(this,"operationDeclarations",[]);D(this,"globalEventActionDescriptors",[]);D(this,"loopDeclarations",[]);D(this,"loopDeclarationsBodies",[]);D(this,"conditionDeclarations",[]);D(this,"valueDescriptors",[]);D(this,"dataTypes",[]);D(this,"project");D(this,"instances",{});D(this,"builtInInstances",{});D(this,"deletedInstances",{});D(this,"errors",[]);D(this,"references",[]);D(this,"history",[]);D(this,"undoableStackValueIndex",-1);D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"_eventsHub",new wA);D(this,"onCloseChangeSetCallback",null);D(this,"onAddChangeSetCallback",null);D(this,"onDiscardChangeSetCallback",null);D(this,"onRequestActiveValueCallback",null);this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this;try{(!Ke.UUID||Ke.UUID.isBackup)&&(Ke.UUID=_h==null?void 0:_h()),Ke.UUID||(Ke.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:a=>a})}catch(a){console.error("Error initializing UUID module",a),Ke.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:l=>l}}}static injectUUIDModule(i){Ke.UUID=i}static new(i=null){return{id:Ke.UUID.uuid(),version:Ke.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||Ke.sessionAuthor,previousVersion:null,deleted:!1,type:f.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[];return p.push(...vr(l)),{errors:p,modifiedData:l}}get off(){return this._eventsHub.off}get on(){return this._eventsHub.on}get emit(){return this._eventsHub.emit}async closePendingChangeSets(){const i=this.history.find(a=>a.dirty&&!a.open);i&&await this.closeChangeSet(i)}onRequestActiveValue(i){this.onRequestActiveValueCallback=i}async onCloseChangeSet(i){this.onCloseChangeSetCallback=i,await this.closePendingChangeSets()}onAddChangeSet(i){this.onAddChangeSetCallback=i}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}async closeChangeSet(i){const a=this.history.findIndex(t=>t.id===i.id),l=this.history.slice(0,a),p=l[l.length-1];if(!(p!=null&&p.dirty)&&this.onCloseChangeSetCallback){(await this.onCloseChangeSetCallback(i)).success&&(i.dirty=!1,this.emit("change-set-closed",i),this.closePendingChangeSets());return}}toLatestChangeSet(i,a,l,p=!1,t="here-this"){if(!this.history.length)return new G(this,i,a,l,p,t);const y=this.history[this.history.length-1];return y.open?y:this.addChangeSet(new G(this,i,a,l,p,t))}addChangeSet(i){var p,t;if(!this.history.length)return this.undoableStackValueIndex=_b(this.undoableStackValueIndex,this.history,i),(p=this.onAddChangeSetCallback)==null||p.call(this,i,this.undoableStackValueIndex),i;const a=this.history.find(y=>y.id===(i==null?void 0:i.id));if(a)return a;const l=this.history.find(y=>y.open);if(l)throw console.warn("Previous still open: ",l),console.warn("New change set: ",i),new Error(`There is already an open change-set with id '${l.id}'.`);return this.undoableStackValueIndex=_b(this.undoableStackValueIndex,this.history,i),(t=this.onAddChangeSetCallback)==null||t.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var l;const a=this.history.findIndex(p=>p.id===(i==null?void 0:i.id));return a!==-1&&(this.history.splice(a,1),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(l=this.onDiscardChangeSetCallback)==null||l.call(this,i)),this}async inject(...i){return await Promise.all(i.map(a=>new Promise(async l=>{await a.init(this),l(null)}))),this}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=Ke.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ke(this);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const T=new Map;for(const[w,A]of this.knownVersions||new Map){if(T.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,N]of A.knownVersions)T.set(V,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ke(T)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.entities=y.entities,this.projects=y.projects,this.functions=y.functions,this.events=y.events,this.variableDeclarations=y.variableDeclarations,this.variableInstances=y.variableInstances,this.conditions=y.conditions,this.operations=y.operations,this.functionCalls=y.functionCalls,this.loops=y.loops,this.searches=y.searches,{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){return this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=null){const a=[],l=[],p=[],t=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),this.captureVersion(),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i){const a=[],l=[],p=[],t=[];return this.subscribe(),this.subscribeToDependencies(),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.projects=this.initialData.projects.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableDeclarations=this.initialData.variableDeclarations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableInstances=this.initialData.variableInstances.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.conditions=this.initialData.conditions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.operations=this.initialData.operations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functions=this.initialData.functions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.events=this.initialData.events.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functionCalls=this.initialData.functionCalls.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.loops=this.initialData.loops.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.searches=this.initialData.searches.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,a=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Er(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Ke.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Ke.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Ke.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Ke.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Ke.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Ke.repository.APILoadVersion(this.id,a,...l)}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlatIds(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlatIds(i)),...this.operationDeclarations.flatMap(a=>a.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlatIds(i)),...this.loopDeclarations.flatMap(a=>a.toFlatIds(i)),...this.conditionDeclarations.flatMap(a=>a.toFlatIds(i)),...this.valueDescriptors.flatMap(a=>a.toFlatIds(i)),...this.dataTypes.flatMap(a=>a.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlat(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlat(i)),...this.operationDeclarations.flatMap(a=>a.toFlat(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlat(i)),...this.loopDeclarations.flatMap(a=>a.toFlat(i)),...this.conditionDeclarations.flatMap(a=>a.toFlat(i)),...this.valueDescriptors.flatMap(a=>a.toFlat(i)),...this.dataTypes.flatMap(a=>a.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(l=>l.toFlat(i)),...this.functions.flatMap(l=>l.toFlat(i)),...this.events.flatMap(l=>l.toFlat(i)),...this.projects.flatMap(l=>l.toFlat(i)),...this.variableDeclarations.flatMap(l=>l.toFlat(i)),...this.variableInstances.flatMap(l=>l.toFlat(i)),...this.conditions.flatMap(l=>l.toFlat(i)),...this.operations.flatMap(l=>l.toFlat(i)),...this.functionCalls.flatMap(l=>l.toFlat(i)),...this.loops.flatMap(l=>l.toFlat(i)),...this.searches.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(l=>l.toFlatIds(i)),...this.functions.flatMap(l=>l.toFlatIds(i)),...this.events.flatMap(l=>l.toFlatIds(i)),...this.projects.flatMap(l=>l.toFlatIds(i)),...this.variableDeclarations.flatMap(l=>l.toFlatIds(i)),...this.variableInstances.flatMap(l=>l.toFlatIds(i)),...this.conditions.flatMap(l=>l.toFlatIds(i)),...this.operations.flatMap(l=>l.toFlatIds(i)),...this.functionCalls.flatMap(l=>l.toFlatIds(i)),...this.loops.flatMap(l=>l.toFlatIds(i)),...this.searches.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(a=>a.toJSON(i)),variableDeclarations:this.variableDeclarations.map(a=>a.toJSON(i)),variableInstances:this.variableInstances.map(a=>a.toJSON(i)),conditions:this.conditions.map(a=>a.toJSON(i)),operations:this.operations.map(a=>a.toJSON(i)),loops:this.loops.map(a=>a.toJSON(i)),searches:this.searches.map(a=>a.toJSON(i)),functions:this.functions.map(a=>a.toJSON(i)),events:this.events.map(a=>a.toJSON(i)),projects:this.projects.map(a=>a.toJSON(i)),functionCalls:this.functionCalls.map(a=>a.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const a=new Map,l=new Set,p=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(t=>{if(p.includes(t)){a.set(t,t);return}a.set(t,Ke.UUID.uuid())}),l.add(this.id),{id:a.get(this.id),version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),projects:this.projects.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableDeclarations:this.variableDeclarations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableInstances:this.variableInstances.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),conditions:this.conditions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),operations:this.operations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functions:this.functions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),events:this.events.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functionCalls:this.functionCalls.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),loops:this.loops.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),searches:this.searches.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null}))}}toReference(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+Ke.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(p=>p.toReference(i)),functions:this.functions.map(p=>p.toReference(i)),events:this.events.map(p=>p.toReference(i)),projects:this.projects.map(p=>p.toReference(i)),variableDeclarations:this.variableDeclarations.map(p=>p.toReference(i)),variableInstances:this.variableInstances.map(p=>p.toReference(i)),conditions:this.conditions.map(p=>p.toReference(i)),operations:this.operations.map(p=>p.toReference(i)),functionCalls:this.functionCalls.map(p=>p.toReference(i)),loops:this.loops.map(p=>p.toReference(i)),searches:this.searches.map(p=>p.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(l=>l.toFlatJSON(i)),...this.functions.flatMap(l=>l.toFlatJSON(i)),...this.events.flatMap(l=>l.toFlatJSON(i)),...this.projects.flatMap(l=>l.toFlatJSON(i)),...this.variableDeclarations.flatMap(l=>l.toFlatJSON(i)),...this.variableInstances.flatMap(l=>l.toFlatJSON(i)),...this.conditions.flatMap(l=>l.toFlatJSON(i)),...this.operations.flatMap(l=>l.toFlatJSON(i)),...this.functionCalls.flatMap(l=>l.toFlatJSON(i)),...this.loops.flatMap(l=>l.toFlatJSON(i)),...this.searches.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.events.flatMap(l=>l.toFlatGenerationTarget(i)),...this.projects.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(l=>l.toFlatGenerationTarget(i)),...this.conditions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.operations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(l=>l.toFlatGenerationTarget(i)),...this.loops.flatMap(l=>l.toFlatGenerationTarget(i)),...this.searches.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){const i=gce(),a=this.toJSON();return i.safeParse(a),this.validateChildren(),{success:!0,error:null,data:a}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(a=>a.getErrors()),...this.projects.flatMap(a=>a.getErrors()),...this.functions.flatMap(a=>a.getErrors()),...this.events.flatMap(a=>a.getErrors()),...this.variableDeclarations.flatMap(a=>a.getErrors()),...this.variableInstances.flatMap(a=>a.getErrors()),...this.conditions.flatMap(a=>a.getErrors()),...this.operations.flatMap(a=>a.getErrors()),...this.functionCalls.flatMap(a=>a.getErrors()),...this.loops.flatMap(a=>a.getErrors()),...this.searches.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(){return this}getDefinitionEntity(i){return this.entities.find(a=>a.id===i)||null}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const a=this.entities.findIndex(l=>l.id===i.id);if(a>-1){const l=this.entities[a];return this.entities.splice(a,1),l}return null}removeCondition(i){const a=this.conditions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.conditions[a];return this.conditions.splice(a,1),l}return null}removeOperation(i){const a=this.operations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.operations[a];return this.operations.splice(a,1),l}return null}removeLoop(i){const a=this.loops.findIndex(l=>l.id===i.id);if(a>-1){const l=this.loops[a];return this.loops.splice(a,1),l}return null}removeSearch(i){const a=this.searches.findIndex(l=>l.id===i.id);if(a>-1){const l=this.searches[a];return this.searches.splice(a,1),l}return null}removeFunctionCall(i){const a=this.functionCalls.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functionCalls[a];return this.functionCalls.splice(a,1),l}return null}removeVariableInstance(i){const a=this.variableInstances.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableInstances[a];return this.variableInstances.splice(a,1),l}return null}removeVariableDeclaration(i){const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}removeFunctionDeclaration(i){const a=this.functions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functions[a];return this.functions.splice(a,1),l}return null}removeInstalledProject(i){const a=this.projects.findIndex(l=>l.id===i.id);if(a>-1){const l=this.projects[a];return this.projects.splice(a,1),l}return null}removeGlobalEvent(i){const a=this.events.findIndex(l=>l.id===i.id);if(a>-1){const l=this.events[a];return this.events.splice(a,1),l}return null}removeTopLevelVariableDeclaration(i){if(i.type!==f.VariableDeclaration)return null;const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(a=>a.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.ReturnStatement||t.type===f.ContinueStatement||t.type===f.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(a=>a.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.functionCalls.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.conditions.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.operations.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.loops.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.searches.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[])]}getVariableInstances(){return[...this.variableInstances,...this.getEntryPoints().reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[])]}getVariableDeclarations(){return R([...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),a=this.getVariableDeclarations();return i.forEach(l=>{if(!l.declaration){const p=l.initialData,t=p.declaration.entityId||p.declaration.id,y=a.find(v=>v.id===t);y&&l.setDeclaration(y)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===$e.PERSISTED_ENTITY)||null}requestActiveValue(i){var l;const a=(l=this.onRequestActiveValueCallback)==null?void 0:l.call(this,i);return a?a||null:i.getDefaultValue()}undo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,console.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],a=this.history[this.undoableStackValueIndex];return console.log("Current change set: ",i),console.log("Change set to restore: ",a.toJSON()),wb(i||"initial",a||"initial",this)}redo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,console.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],a=this.history[this.undoableStackValueIndex];return console.log("Current change set: ",i),console.log("Change set to restore: ",a.toJSON()),wb(i||"initial",a||"initial",this)}applyExternalChangeSet(i){const a=i.payload,l=this.addChangeSet(new G(this,i.userAuthor,i.emittedAt,this)),p=a.updated[this.id];if(!p)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const t={...a.added,...a.updated,...a.removed},y=[...Object.keys(a.added),...Object.keys(a.updated),...Object.keys(a.removed)];y.forEach(T=>{var w;if(!t[T]){console.warn(`Entity '${T}' not found in change set transfer. Cannot apply changes.`);const A=(w=this.get(T))==null?void 0:w.toShallowJSON();throw A?console.warn("Entity in project: ",A):console.warn("Entity not in project"),new Error(`Entity '${T}' not found in change set transfer. Cannot apply changes.`)}});const v=new ha(p);return v.flatRecord=t,v.order=y,v.orderEntities(),console.log("All entities: ",v.order.map((T,w)=>`${w+1}: ${t[T].type} - ${T}`).join(`,
403
+ Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:p,modifiedData:l}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return R([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return R([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allMethods,[]),...this.implements.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allProperties,[]),...this.implements.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return R([...this.extends.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[]),...this.implements.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[])])}get allBaseMethodsFromExtendedAndImplementedEntities(){return R([...this.extends.reduce((i,a)=>a.type!==f.DefinitionEntity?[]:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[]),...this.implements.reduce((i,a)=>a.type!==f.DefinitionEntity?a.abstractMethods:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return R(this.extends.reduce((i,a)=>{if(a.type!==f.DefinitionEntity)return[];const l=[...a.ownDeclaredMethods,...a.extendedMethodsFromOriginalParents].filter(p=>p.type!==f.ActionDescriptor);return[...i,...l]},[]))}get implementedMethodsFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.type===f.DefinitionEntity?a.methods:[],p=[...a.abstractMethods].filter(t=>!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>[...a.abstractMethods,...i],[])].filter(i=>i.type===f.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${S.InvalidParentUpdate}`,code:S.InvalidParentUpdate,severity:Z.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.removeImplementation(i),a==="extends"&&this.removeExtension(i),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.addImplementation(i),a==="extends"&&this.addExtension(i),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{ki.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this}subscribeToDependencies(){return this.implements.forEach(i=>{ki.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends.forEach(i=>{ki.includes(i.type)||i.subscribeDependents([{entity:this,field:"extends"}])}),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ct(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=[...this.extends],i.implements=[...this.implements],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const T=new Map;for(const[w,A]of this.knownVersions||new Map){if(T.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,N]of A.knownVersions)T.set(V,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ct(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.properties=y.properties,this.methods=y.methods,this.abstractMethods=y.abstractMethods,this.extends=y.extends,this.implements=y.implements,this.parent=y.parent,{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=W(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return i.extends.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addExtension(t)}),i.implements.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addImplementation(t)}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return this.initialData.extends.forEach(t=>{const y=W(t),v=this.project.get(y);v&&(this.addExtension(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),this.initialData.implements.forEach(t=>{const y=W(t),v=this.project.get(y);v&&(this.addImplementation(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:T,affected:w}=this.syncImplementationProperties(i);a.push(...y),l.push(...v),p.push(...T),t.push(...w);const{updated:A,added:V,removed:N,affected:j}=this.addExtendedProperties(i);a.push(...A),l.push(...V),p.push(...N),t.push(...j);const{updated:k,added:q,removed:Y}=this.removeUnrecognizedProperties(i);a.push(...k),l.push(...q),p.push(...Y);const{updated:ie,added:te,removed:pe,affected:ne}=this.syncImplementationMethods(i);a.push(...ie),l.push(...te),p.push(...pe),t.push(...ne);const{updated:me,added:J,removed:ae,affected:ce}=this.addExtendedMethods(i);a.push(...me),l.push(...J),p.push(...ae),t.push(...ce);const{updated:H,added:de,removed:ve}=this.removeUnrecognizedMethods(i);return a.push(...H),l.push(...de),p.push(...ve),this.addSuggestions(),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];if(this.parent.type===f.DataType){const y=this.parent;y.entity=this,a.push(y)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}addExtension(i){return this.extends.includes(i)||this.extends.push(i),this}removeExtension(i){return this.extends=this.extends.filter(a=>a.id!==i.id),this}addImplementation(i){return this.implements.includes(i)||this.implements.push(i),this}removeImplementation(i){return this.implements=this.implements.filter(a=>a.id!==i.id),this}removeProperty(i){return this.properties=this.properties.filter(a=>a.id!==i.id),this}addMethod(i){return this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name)),this}removeMethod(i){return this.methods=this.methods.filter(a=>a.id!==i.id),this}addProperty(i){return this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name)),this}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(a=>a.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(a=>a.id!==i.id),this}addAbstractMethod(i){return this.abstractMethods.includes(i)||this.abstractMethods.push(i),this}removeAbstractMethod(i){return this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),this}initChildren(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.properties=this.initialData.properties.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.methods=this.initialData.methods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.extends=this.initialData.extends.map(a=>ee(a,this.project)),this.implements=this.initialData.implements.map(a=>ee(a,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}removeUnrecognizedProperties(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-properties"))){const a=[],l=[],p=[],t=[];let y=[...this.properties];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedProperty);const v=this.implementedPropertiesFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(w=>{var A;return w.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const w=T.remove({ignoreUpstream:!1},i);p.push(...w.removed),a.push(...w.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-methods"))){const a=[],l=[],p=[],t=[];let y=[...this.methods];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedMethod);const v=this.implementedMethodsFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(w=>{var A;return w.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const w=T.remove({ignoreUpstream:!1},i);p.push(...w.removed),a.push(...w.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,v=this.implementedMethodsFromOriginalParents,T=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var j;return((j=N.implements)==null?void 0:j.id)===A.id})).forEach(A=>{if(this.methods.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===A.id}))return;const N=this.methods.find(k=>{var pe,ne;if(k.name===A.name&&!k.implements)return!0;const q=Vs(this,$e.CRON_JOB),Y=Vs(this,$e.HTTP_ENDPOINT),ie=((pe=k.implements)==null?void 0:pe.id)===Ee["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,te=((ne=k.implements)==null?void 0:ne.id)===Ee["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(q&&!te&&!Y&&ie||Y&&!ie&&!q&&te)});if(N&&N.type===f.FunctionDeclaration){N.setImplements(A),N.metaSync({name:A.name},i),i==null||i.add(N,K.Updated),i==null||i.add(this,K.Updated);return}const j=A.implementAsFunctionDeclaration(i,this);l.push(j),i==null||i.add(j,K.Added),this.addMethod(j)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.implementedPropertiesFromOriginalParents,T=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var j;return((j=N.implements)==null?void 0:j.id)===A.id})).forEach(A=>{if(this.properties.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===A.id}))return;const N=this.properties.find(k=>k.name===A.name&&!!k.abstract&&!k.implements);if(N){N.setImplements(A,i),N.metaSync({abstract:!1},i),N.afterAllChildrenInitialized(i);return}const j=A.implement(this,i,P.UUID.uuid());l.push(j),i==null||i.add(j,K.Added)}),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addExtendedMethods(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-extended-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,T=this.extendedMethodsFromOriginalParents.filter(A=>A.type===f.FunctionDeclaration),w=new Set(y.filter(A=>{var V;return!!((V=A.extends)!=null&&V.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(w.has(A.id))return;w.add(A.id);const V=A.clone(i,this,P.UUID.uuid());V.setExtends(A,i),V.initChildren(i),l.push(V),i==null||i.add(V,K.Added),this.addMethod(V)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addExtendedProperties(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"add-extended-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.extendedPropertiesFromOriginalParents,T=v.filter(A=>v.find(N=>{var j;return((j=N.implements)==null?void 0:j.id)===A.id})?!1:!A.abstract),w=new Set(y.filter(A=>{var V;return!!((V=A.extends)!=null&&V.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(w.has(A.id))return;w.add(A.id);const V=A.clone(i,this,P.UUID.uuid());V.setExtends(A,i),V.initChildren(i),l.push(V),i==null||i.add(V,K.Added),this.addProperty(V)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSuggestions(){return this.implements.forEach(i=>{_x(this,i).forEach(p=>{const t=p.toJSON();t.id=`_suggestion--parent--${this.id}--${p.id}`;const y=ee(t,this.project);y.suggestion=!0,y.setParent(this,null),y.initChildren(null),this.addSuggestedProperty(y)}),gx(this,i).forEach(p=>{const t=`_suggestion--parent--${this.id}--${p.id}`,y=p.implementAsFunctionDeclaration(null,this,t),v=ee(y,this.project);if(v.suggestion=!0,v.setParent(this,null),v.initChildren(null),this.methods=this.methods.filter(T=>T.id!==t),v.inputs.forEach(T=>{T.suggestion=!0}),v.returnStatements.length){const T=v.returnStatements[0];T.suggestion=!0,T.outputs.forEach(w=>{w.suggestion=!0})}this.addSuggestedMethod(v)})}),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Er(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,this.static=i.static!==void 0?i.static:this.static,this.abstract=i.abstract!==void 0?i.abstract:this.abstract,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Ct.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Ct.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Ct.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Ct.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Ct.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Ct.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];if(this.parent.type===f.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===f.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const y=this.parent.setEntity(null,i);a.push(y)}return i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(l),affected:R(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:w,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),p.push(...w),t.push(...A)}),this.properties.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.methods.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.abstractMethods.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.suggestedProperties.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),this.suggestedMethods.forEach(v=>{const{updated:T,removed:w}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...w)}),!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(p),affected:R(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:T,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...T),a.push(...w)}),this.properties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.methods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.abstractMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedProperties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(l),removed:R(p),affected:R(t),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.extends.flatMap(l=>l.toFlat(i)),...this.implements.flatMap(l=>l.toFlat(i)),...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.extends.flatMap(l=>l.toFlatIds(i)),...this.implements.flatMap(l=>l.toFlatIds(i)),...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),implements:this.implements.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i)),parent:this.parent.toReference()})}toJSONClone(i=Ne){var l,p,t,y,v;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Ar(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(T=>T.toJSONClone({...i,newId:null})),methods:this.methods.map(T=>T.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(T=>T.toJSONClone({...i,newId:null})),implements:this.implements.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),extends:this.extends.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(p=>p.toReference(i)),methods:this.methods.map(p=>p.toReference(i)),abstractMethods:this.abstractMethods.map(p=>p.toReference(i)),implements:this.implements.map(p=>p.toReference(i)),extends:this.extends.map(p=>p.toReference(i)),parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i)),...this.implements.flatMap(l=>l.toFlatJSON(i)),...this.extends.flatMap(l=>l.toFlatJSON(i)),...this.parent.toFlatJSON(i)])}toGenerationTarget(){const i=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:this.extends.map(a=>a.id),implements:this.implements.map(a=>a.id),parent:i}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.parent.toFlatGenerationTarget(i)])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=Rx(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var k,q,Y;let t=Ir(a,this);const y=this.toJSON(),v=l||P.UUID.uuid();y.properties=[],y.methods=[],y.abstractMethods=[];const T=v.split("-id"),w=T[T.length-1||0]||v;y.id=v,y.version=P.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const A=Kt(y,t);a&&A.setParent(a,null),p&&A.subscribe(),A.initChildren(i),i==null||i.add(A,K.Added);const V=(k=this.properties)==null?void 0:k.map(ie=>ie.clone(i,A,P.UUID.uuid(),p));A.properties=V;const N=(q=this.methods)==null?void 0:q.map((ie,te)=>ie.clone(i,A,w+"-method-"+te+"-id",p));A.methods=N;const j=(Y=this.abstractMethods)==null?void 0:Y.map((ie,te)=>ie.clone(i,A,w+"-abstract-method-"+te+"-id",p));return A.abstractMethods=j,i==null||i.attemptAutoclose("clone-entity",this.id),A}getFunctionDeclaration(i){return this.methods.find(a=>a.id===i)}implement(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"implement-definition-entity")),l){const p=Fy(this,i,a,l);return a==null||a.attemptAutoclose("implement-definition-entity",this.id),p}getAllInteractiveMethods(){const i=this.implements.filter(l=>l.type===f.DefinitionEntity||l.type===f.BuiltInBaseEntity&&l.interactive);return R([...this.methods,...this.extends.flatMap(l=>l.getAllInteractiveMethods()),...i.flatMap(l=>l.getAllInteractiveMethods())])}inferFromInputs(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const l=[],p=[],t=[],y=[];if(this.parent.type!==f.DataType||!this.parent.inferred)return a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const v=[];i.forEach(A=>{v.find(N=>re(N,this.project)===re(A,this.project))||v.push(A)});const T=this.properties.filter(A=>!A.dataType);v.forEach(A=>{var Y,ie;const V=T.find(te=>re(te,this.project)===re(A,this.project));if(!V)return;const j=oi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),k=zs(j,a),q=k==null?void 0:k.clone(a,V,P.UUID.uuid(),!0);q&&((Y=V.dataType)==null||Y.merge(q,a),q.id!==((ie=V.dataType)==null?void 0:ie.id)&&q.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,K.Affected))),A.setDeclaration(V),a==null||a.add(A,K.Updated)});const w=[];return v.forEach(A=>{if(!A.declaration){w.push(A);return}}),w.length===0?(a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(w.forEach(A=>{var te,pe,ne,me;const V=this.properties.find(J=>re(J,this.project)===re(A,this.project));if(V){if(A.setDeclaration(V),!V.getDataType(a)){const ae=oi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),ce=zs(ae),H=ce==null?void 0:ce.clone(a,V,P.UUID.uuid(),!0);H&&((te=V.dataType)==null||te.merge(H,a),H.id!==((pe=V.dataType)==null?void 0:pe.id)&&H.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,K.Affected)))}return}const N={id:P.UUID.uuid(),type:f.Property,version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:re(A,this.project),codeName:A.codeName,description:A.description,defaultValue:null,static:!0,abstract:!1,private:!1,hidden:!1,required:!1,constant:!0,index:A.index,implements:null,extends:null,dataType:null,parent:this.toReference()},j=ee(N,this.project);j.setParent(this,a),j.initChildren(a),a==null||a.add(j,K.Added);const q=oi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),Y=zs(q),ie=Y==null?void 0:Y.clone(a,j,P.UUID.uuid(),!0);return ie&&((ne=j.dataType)==null||ne.merge(ie,a),ie.id!==((me=j.dataType)==null?void 0:me.id)&&ie.remove({ignoreUpstream:!1},a),j.dataType&&(j.dataType.metaSync({inferred:!0,like:!0},a),j.setDataType(j.dataType,a),a==null||a.add(j,K.Affected))),this.addProperty(j),A.setDeclaration(j),a==null||a.add(A,K.Updated),j}),a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:R(l),updated:R(p),removed:R(t),affected:R(y),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(a=>{var p;const l=kr(a.name);i[l]=((p=a.getDefaultValue())==null?void 0:p.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(a=>{const l=kr(a.name),p=this.project.requestActiveValue(a);i[l]=(p==null?void 0:p.value)||null}),i}};D(Ct,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(Ct,"type",f.DefinitionEntity),D(Ct,"USER_MANAGED_PARENT_TYPES",[f.Project,f.DataType]),D(Ct,"PARENT_TYPES",[...Ct.USER_MANAGED_PARENT_TYPES]),D(Ct,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract"]),D(Ct,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(Ct,"BASE_PROPERTIES",[...Ct.MUTABLE_BASE_PROPERTIES,...Ct.INMUTABLE_BASE_PROPERTIES]),D(Ct,"MUTABLE_META_PROPERTIES",[...Ct.MUTABLE_BASE_PROPERTIES,"x","y"]),D(Ct,"INMUTABLE_META_PROPERTIES",[...Ct.INMUTABLE_BASE_PROPERTIES]),D(Ct,"META_PROPERTIES",[...Ct.MUTABLE_META_PROPERTIES,...Ct.INMUTABLE_META_PROPERTIES]),D(Ct,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),D(Ct,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),D(Ct,"UPSTREAM_PROPERTIES",[...Ct.MUTABLE_UPSTREAM_PROPERTIES,...Ct.INMUTABLE_UPSTREAM_PROPERTIES]),D(Ct,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),D(Ct,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(Ct,"DOWNSTREAM_PROPERTIES",[...Ct.MUTABLE_DOWNSTREAM_PROPERTIES,...Ct.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(Ct,"PROPERTIES",[...Ct.META_PROPERTIES,...Ct.UPSTREAM_PROPERTIES,...Ct.DOWNSTREAM_PROPERTIES]);let ma=Ct;function e0e(d){const u=ude(),i=d.toJSON();u.safeParse(i).success;const l=[];return zt(d.errors,l)}const jp=class jp extends hr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"version");D(this,"name");D(this,"description",null);D(this,"type",f.BuiltInBaseEntity);D(this,"abstract",!1);D(this,"static");D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"interactive",!1);D(this,"errors",[]);D(this,"project");this.initialData=this.initialData||i,this.project=this.project||a,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.extends=this.initialData.extends.map(l=>ee(l,this.project))}get allMethods(){return R([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return R([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=ye,...a){return await jp.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.extends.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.extends.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,interactive:this.interactive,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=Ne){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=e0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}implement(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),null,!0,"implement-built-in-base-entity")),l){const p=Fy(this,i,a,l);return a==null||a.attemptAutoclose("implement-built-in-base-entity",this.id),p}getAllInteractiveMethods(){const i=[];return this.interactive&&(i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof jp&&i.push(...l.getAllInteractiveMethods())})),R(i)}};D(jp,"repository",{APILoad:async(i,...a)=>null});let Cn=jp;function t0e(d){const u=tde(),i=d.toJSON();u.safeParse(i).success;const l=[];return zt(d.errors,l)}const cm=class cm extends hr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"name");D(this,"description",null);D(this,"type",f.PrimitiveEntity);D(this,"static");D(this,"abstract");D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"errors",[]);D(this,"project");this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.parent=this,p})}get allMethods(){return R([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return R([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return R([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return R(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return R([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=ye,...a){return await cm.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=Ne){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=t0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof Cn&&i.push(...l.getAllInteractiveMethods())}),R(i)}};D(cm,"repository",{APILoad:async(i,...a)=>null});let Li=cm;function Kt(d,u){if(!d)throw new Error("Entity is null");const i=u.get(d.id);switch(d.type){case f.LiteralValue:return i||new bi(d,u);case f.DefinitionEntity:return i||new ma(d,u);case f.PrimitiveEntity:return i||new Li(d,u);case f.FunctionDeclaration:return i||new Ua(d,u);case f.GlobalEvent:return i||new Fa(d,u);case f.DataType:return i||new Hi(d,u);case f.Property:return i||new ua(d,u);case f.FunctionCall:return i||new za(d,u);case f.Condition:return i||new Ga(d,u);case f.Operation:return i||new ja(d,u);case f.VariableDeclaration:return i||new ka(d,u);case f.VariableInstance:return i||new Ka(d,u);case f.OutputMap:return i||new Qs(d,u);case f.ReturnDeclaration:return i||new Ni(d,u);case f.ArgumentDeclaration:return i||new pa(d,u);case f.InputMap:return i||new Cs(d,u);case f.Project:return i||new P(d);case f.InstalledProject:return i||new Sa(d,u);case f.ActionDescriptor:return i||new jt(d,u);case f.ReturnStatement:return i||new xa(d,u);case f.Loop:return i||new Ai(d,u);case f.Search:return i||new qa(d,u);case f.ValueDescriptor:return i||new en(d,u);case f.BuiltInBaseEntity:return i||new Cn(d,u);case f.InternalCall:return i||new Za(d,u);case f.ContinueStatement:return i||new li(d,u);case f.BreakStatement:return i||new Ja(d,u);case f.GenericReference:return u.get(d.entityId);default:throw new Error("Invalid entity type: "+d.type)}}function ee(d,u){if(!d)throw new Error("Entity is null");const i=Kt(d,u);return i.subscribe(),i}function r0e(d,u){if(!d)throw new Error("Entity is null");switch(d.type){case f.LiteralValue:return bi.fromGenerationTarget(d,u);case f.DefinitionEntity:return ma.fromGenerationTarget(d,u);case f.FunctionDeclaration:return Ua.fromGenerationTarget(d,u);case f.GlobalEvent:return Fa.fromGenerationTarget(d,u);case f.DataType:return Hi.fromGenerationTarget(d,u);case f.Property:return ua.fromGenerationTarget(d,u);case f.FunctionCall:return za.fromGenerationTarget(d,u);case f.Condition:return Ga.fromGenerationTarget(d,u);case f.Operation:return ja.fromGenerationTarget(d,u);case f.VariableDeclaration:return ka.fromGenerationTarget(d,u);case f.VariableInstance:return Ka.fromGenerationTarget(d,u);case f.OutputMap:return Qs.fromGenerationTarget(d,u);case f.ReturnDeclaration:return Ni.fromGenerationTarget(d,u);case f.ArgumentDeclaration:return pa.fromGenerationTarget(d,u);case f.InputMap:return Cs.fromGenerationTarget(d,u);case f.InstalledProject:return Sa.fromGenerationTarget(d,u);case f.ReturnStatement:return xa.fromGenerationTarget(d,u);case f.Loop:return Ai.fromGenerationTarget(d,u);case f.Search:return qa.fromGenerationTarget(d,u);case f.ActionDescriptor:return jt.fromGenerationTarget(d,u);case f.ValueDescriptor:return en.fromGenerationTarget(d,u);case f.InternalCall:return Za.fromGenerationTarget(d,u);case f.ContinueStatement:return li.fromGenerationTarget(d,u);case f.BreakStatement:return Ja.fromGenerationTarget(d,u);default:throw new Error("Invalid entity type: "+d.type)}}const Ne={seenEntityMaps:new Map,seenEntities:new Set,timestamp:L().toISOString()};class Dx{constructor(){D(this,"initialData")}}const ye={cascade:!1},Ox={APILoad:async(d,...u)=>null},i0e={APICreate:async(d,...u)=>d,APIUpdate:async(d,...u)=>d,APIDelete:async(d,...u)=>d,APIClone:async(d,...u)=>{},APILoadVersion:async(d,u,...i)=>null,...Ox};class s0e{}class n0e extends Dx{}class a0e{}class o0e{}class l0e{}class IA{}class d0e extends IA{}class u0e extends IA{}class c0e{}class Op{static initReadsValue(u){if(u.initialData.readsValue&&u.initialData.readsValue.type!==f.GenericReference)u.readsValue=ee(u.initialData.readsValue,u.project);else if(u.initialData.readsValue&&u.initialData.readsValue.type===f.GenericReference){const i=_i(u.initialData.readsValue,u.project);i&&(u.readsValue=i)}if(u.readsValue){if(rt.includes(u.readsValue.type)){let i=u.parent;br.includes(i.type)||(i=i.parent);const a=u.type===f.InputMap&&u.parent.type===f.Loop;a&&(i=u.parent.parent),u.readsValue.setParent(i,null),u.readsValue.initChildren(null),i&&i.type!==f.Project&&!a&&i.detachedChildren.includes(u)?i.replaceDetachedChild(u,u.readsValue):i&&i.type!==f.Project&&!a&&i.subscribeDetachedChild(u.readsValue)}u.readsValue.addValueReader(u,null)}return u.readsValue}}class Cp{static initWritesValues(u,i){const a=u.initialData.writesValues.reduce((p,t)=>{if(t.type===f.GenericReference||u.writesValues.some(v=>v.id===t.id))return p;const y=ee(t,u.project);return y.setValueWriter(u,null),rt.includes(y.type)&&(y.setParent(i,null),y.initChildren(null)),[...p,y]},[]),l=[...u.writesValues];return u.writesValues=R([...l,...a]),u.writesValues}}class p0e{}var f0e=Object.defineProperty,h0e=(d,u,i)=>u in d?f0e(d,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[u]=i,Yo=(d,u,i)=>(h0e(d,typeof u!="symbol"?u+"":u,i),i);class y0e{constructor(u){Yo(this,"eventName"),Yo(this,"callbacks",[]),this.eventName=u,this.on=this.on.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}on(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks.includes(u)||this.callbacks.push(u)}off(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(i=>i!==u)}destroy(){this.callbacks=[]}}class wA{constructor(){Yo(this,"subscribedEvents",{}),Yo(this,"on",this._on),Yo(this,"emit",this._emit),Yo(this,"off",this._off),Yo(this,"destroy",this._destroy),this.getEvent=this.getEvent.bind(this),this._on=this._on.bind(this),this._emit=this._emit.bind(this),this._off=this._off.bind(this),this._destroy=this._destroy.bind(this),this.on=this.on.bind(this),this.emit=this.emit.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}getEvent(u){return this.subscribedEvents[u]||(this.subscribedEvents[u]=new y0e(u)),this.subscribedEvents[u]}_on(u,i){this.getEvent(u).on(i)}_emit(u,...i){const a=this.getEvent(u);a&&a.callbacks.forEach(l=>{l.apply(null,i)})}_off(u,i){const a=this.getEvent(u);a&&(i?a.off(i):(a.destroy(),delete this.subscribedEvents[u]))}_destroy(){Object.keys(this.subscribedEvents).forEach(u=>{this._off(u)}),this.subscribedEvents={}}}var yr=(d=>(d.PROJECT_INITIALIZED="project-initialized",d.CHANGE_SET_CLOSED="change-set-closed",d.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",d.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",d.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",d.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",d.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",d.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",d))(yr||{});const Ke=class Ke extends hr{constructor(i){super(i);D(this,"initialData");D(this,"id");D(this,"type",f.Project);D(this,"name",null);D(this,"description",null);D(this,"x");D(this,"y");D(this,"entities",[]);D(this,"projects",[]);D(this,"functions",[]);D(this,"events",[]);D(this,"variableDeclarations",[]);D(this,"variableInstances",[]);D(this,"conditions",[]);D(this,"operations",[]);D(this,"functionCalls",[]);D(this,"loops",[]);D(this,"searches",[]);D(this,"primitives",[]);D(this,"builtInBaseEntities",[]);D(this,"operationDeclarations",[]);D(this,"globalEventActionDescriptors",[]);D(this,"loopDeclarations",[]);D(this,"loopDeclarationsBodies",[]);D(this,"conditionDeclarations",[]);D(this,"valueDescriptors",[]);D(this,"dataTypes",[]);D(this,"project");D(this,"instances",{});D(this,"builtInInstances",{});D(this,"deletedInstances",{});D(this,"errors",[]);D(this,"references",[]);D(this,"history",[]);D(this,"undoableStackValueIndex",-1);D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"_eventsHub",new wA);D(this,"onCloseChangeSetCallback",null);D(this,"onAddChangeSetCallback",null);D(this,"onDiscardChangeSetCallback",null);D(this,"onRequestActiveValueCallback",null);this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this;try{(!Ke.UUID||Ke.UUID.isBackup)&&(Ke.UUID=_h==null?void 0:_h()),Ke.UUID||(Ke.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:a=>a})}catch(a){console.error("Error initializing UUID module",a),Ke.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:l=>l}}}static injectUUIDModule(i){Ke.UUID=i}static new(i=null){return{id:Ke.UUID.uuid(),version:Ke.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||Ke.sessionAuthor,previousVersion:null,deleted:!1,type:f.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[];return p.push(...vr(l)),{errors:p,modifiedData:l}}get off(){return this._eventsHub.off}get on(){return this._eventsHub.on}get emit(){return this._eventsHub.emit}async closePendingChangeSets(){const i=this.history.find(a=>a.dirty&&!a.open);i&&await this.closeChangeSet(i)}onRequestActiveValue(i){this.onRequestActiveValueCallback=i}async onCloseChangeSet(i){this.onCloseChangeSetCallback=i,await this.closePendingChangeSets()}onAddChangeSet(i){this.onAddChangeSetCallback=i}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}async closeChangeSet(i){const a=this.history.findIndex(t=>t.id===i.id),l=this.history.slice(0,a),p=l[l.length-1];if(!(p!=null&&p.dirty)&&this.onCloseChangeSetCallback){(await this.onCloseChangeSetCallback(i)).success&&(i.dirty=!1,this.emit("change-set-closed",i),this.closePendingChangeSets());return}}toLatestChangeSet(i,a,l,p=!1,t="here-this"){if(!this.history.length)return new G(this,i,a,l,p,t);const y=this.history[this.history.length-1];return y.open?y:this.addChangeSet(new G(this,i,a,l,p,t))}addChangeSet(i){var p,t;if(!this.history.length)return this.undoableStackValueIndex=_b(this.undoableStackValueIndex,this.history,i),(p=this.onAddChangeSetCallback)==null||p.call(this,i,this.undoableStackValueIndex),i;const a=this.history.find(y=>y.id===(i==null?void 0:i.id));if(a)return a;const l=this.history.find(y=>y.open);if(l)throw console.warn("Previous still open: ",l),console.warn("New change set: ",i),new Error(`There is already an open change-set with id '${l.id}'.`);return this.undoableStackValueIndex=_b(this.undoableStackValueIndex,this.history,i),(t=this.onAddChangeSetCallback)==null||t.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var l;const a=this.history.findIndex(p=>p.id===(i==null?void 0:i.id));return a!==-1&&(this.history.splice(a,1),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(l=this.onDiscardChangeSetCallback)==null||l.call(this,i)),this}async inject(...i){return await Promise.all(i.map(a=>new Promise(async l=>{await a.init(this),l(null)}))),this}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=Ke.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ke(this);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const T=new Map;for(const[w,A]of this.knownVersions||new Map){if(T.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,N]of A.knownVersions)T.set(V,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ke(T)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.entities=y.entities,this.projects=y.projects,this.functions=y.functions,this.events=y.events,this.variableDeclarations=y.variableDeclarations,this.variableInstances=y.variableInstances,this.conditions=y.conditions,this.operations=y.operations,this.functionCalls=y.functionCalls,this.loops=y.loops,this.searches=y.searches,{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){return this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=null){const a=[],l=[],p=[],t=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),this.captureVersion(),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i){const a=[],l=[],p=[],t=[];return this.subscribe(),this.subscribeToDependencies(),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.projects=this.initialData.projects.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableDeclarations=this.initialData.variableDeclarations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableInstances=this.initialData.variableInstances.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.conditions=this.initialData.conditions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.operations=this.initialData.operations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functions=this.initialData.functions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.events=this.initialData.events.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functionCalls=this.initialData.functionCalls.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.loops=this.initialData.loops.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.searches=this.initialData.searches.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,a=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Er(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Ke.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Ke.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Ke.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Ke.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Ke.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Ke.repository.APILoadVersion(this.id,a,...l)}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,Ke.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlatIds(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlatIds(i)),...this.operationDeclarations.flatMap(a=>a.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlatIds(i)),...this.loopDeclarations.flatMap(a=>a.toFlatIds(i)),...this.conditionDeclarations.flatMap(a=>a.toFlatIds(i)),...this.valueDescriptors.flatMap(a=>a.toFlatIds(i)),...this.dataTypes.flatMap(a=>a.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlat(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlat(i)),...this.operationDeclarations.flatMap(a=>a.toFlat(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlat(i)),...this.loopDeclarations.flatMap(a=>a.toFlat(i)),...this.conditionDeclarations.flatMap(a=>a.toFlat(i)),...this.valueDescriptors.flatMap(a=>a.toFlat(i)),...this.dataTypes.flatMap(a=>a.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(l=>l.toFlat(i)),...this.functions.flatMap(l=>l.toFlat(i)),...this.events.flatMap(l=>l.toFlat(i)),...this.projects.flatMap(l=>l.toFlat(i)),...this.variableDeclarations.flatMap(l=>l.toFlat(i)),...this.variableInstances.flatMap(l=>l.toFlat(i)),...this.conditions.flatMap(l=>l.toFlat(i)),...this.operations.flatMap(l=>l.toFlat(i)),...this.functionCalls.flatMap(l=>l.toFlat(i)),...this.loops.flatMap(l=>l.toFlat(i)),...this.searches.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(l=>l.toFlatIds(i)),...this.functions.flatMap(l=>l.toFlatIds(i)),...this.events.flatMap(l=>l.toFlatIds(i)),...this.projects.flatMap(l=>l.toFlatIds(i)),...this.variableDeclarations.flatMap(l=>l.toFlatIds(i)),...this.variableInstances.flatMap(l=>l.toFlatIds(i)),...this.conditions.flatMap(l=>l.toFlatIds(i)),...this.operations.flatMap(l=>l.toFlatIds(i)),...this.functionCalls.flatMap(l=>l.toFlatIds(i)),...this.loops.flatMap(l=>l.toFlatIds(i)),...this.searches.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(a=>a.toJSON(i)),variableDeclarations:this.variableDeclarations.map(a=>a.toJSON(i)),variableInstances:this.variableInstances.map(a=>a.toJSON(i)),conditions:this.conditions.map(a=>a.toJSON(i)),operations:this.operations.map(a=>a.toJSON(i)),loops:this.loops.map(a=>a.toJSON(i)),searches:this.searches.map(a=>a.toJSON(i)),functions:this.functions.map(a=>a.toJSON(i)),events:this.events.map(a=>a.toJSON(i)),projects:this.projects.map(a=>a.toJSON(i)),functionCalls:this.functionCalls.map(a=>a.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const a=new Map,l=new Set,p=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(t=>{if(p.includes(t)){a.set(t,t);return}a.set(t,Ke.UUID.uuid())}),l.add(this.id),{id:a.get(this.id),version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),projects:this.projects.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableDeclarations:this.variableDeclarations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableInstances:this.variableInstances.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),conditions:this.conditions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),operations:this.operations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functions:this.functions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),events:this.events.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functionCalls:this.functionCalls.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),loops:this.loops.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),searches:this.searches.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null}))}}toReference(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+Ke.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ne){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(p=>p.toReference(i)),functions:this.functions.map(p=>p.toReference(i)),events:this.events.map(p=>p.toReference(i)),projects:this.projects.map(p=>p.toReference(i)),variableDeclarations:this.variableDeclarations.map(p=>p.toReference(i)),variableInstances:this.variableInstances.map(p=>p.toReference(i)),conditions:this.conditions.map(p=>p.toReference(i)),operations:this.operations.map(p=>p.toReference(i)),functionCalls:this.functionCalls.map(p=>p.toReference(i)),loops:this.loops.map(p=>p.toReference(i)),searches:this.searches.map(p=>p.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(l=>l.toFlatJSON(i)),...this.functions.flatMap(l=>l.toFlatJSON(i)),...this.events.flatMap(l=>l.toFlatJSON(i)),...this.projects.flatMap(l=>l.toFlatJSON(i)),...this.variableDeclarations.flatMap(l=>l.toFlatJSON(i)),...this.variableInstances.flatMap(l=>l.toFlatJSON(i)),...this.conditions.flatMap(l=>l.toFlatJSON(i)),...this.operations.flatMap(l=>l.toFlatJSON(i)),...this.functionCalls.flatMap(l=>l.toFlatJSON(i)),...this.loops.flatMap(l=>l.toFlatJSON(i)),...this.searches.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.events.flatMap(l=>l.toFlatGenerationTarget(i)),...this.projects.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(l=>l.toFlatGenerationTarget(i)),...this.conditions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.operations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(l=>l.toFlatGenerationTarget(i)),...this.loops.flatMap(l=>l.toFlatGenerationTarget(i)),...this.searches.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){const i=gce(),a=this.toJSON();return i.safeParse(a),this.validateChildren(),{success:!0,error:null,data:a}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(a=>a.getErrors()),...this.projects.flatMap(a=>a.getErrors()),...this.functions.flatMap(a=>a.getErrors()),...this.events.flatMap(a=>a.getErrors()),...this.variableDeclarations.flatMap(a=>a.getErrors()),...this.variableInstances.flatMap(a=>a.getErrors()),...this.conditions.flatMap(a=>a.getErrors()),...this.operations.flatMap(a=>a.getErrors()),...this.functionCalls.flatMap(a=>a.getErrors()),...this.loops.flatMap(a=>a.getErrors()),...this.searches.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(){return this}getDefinitionEntity(i){return this.entities.find(a=>a.id===i)||null}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const a=this.entities.findIndex(l=>l.id===i.id);if(a>-1){const l=this.entities[a];return this.entities.splice(a,1),l}return null}removeCondition(i){const a=this.conditions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.conditions[a];return this.conditions.splice(a,1),l}return null}removeOperation(i){const a=this.operations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.operations[a];return this.operations.splice(a,1),l}return null}removeLoop(i){const a=this.loops.findIndex(l=>l.id===i.id);if(a>-1){const l=this.loops[a];return this.loops.splice(a,1),l}return null}removeSearch(i){const a=this.searches.findIndex(l=>l.id===i.id);if(a>-1){const l=this.searches[a];return this.searches.splice(a,1),l}return null}removeFunctionCall(i){const a=this.functionCalls.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functionCalls[a];return this.functionCalls.splice(a,1),l}return null}removeVariableInstance(i){const a=this.variableInstances.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableInstances[a];return this.variableInstances.splice(a,1),l}return null}removeVariableDeclaration(i){const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}removeFunctionDeclaration(i){const a=this.functions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functions[a];return this.functions.splice(a,1),l}return null}removeInstalledProject(i){const a=this.projects.findIndex(l=>l.id===i.id);if(a>-1){const l=this.projects[a];return this.projects.splice(a,1),l}return null}removeGlobalEvent(i){const a=this.events.findIndex(l=>l.id===i.id);if(a>-1){const l=this.events[a];return this.events.splice(a,1),l}return null}removeTopLevelVariableDeclaration(i){if(i.type!==f.VariableDeclaration)return null;const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(a=>a.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.ReturnStatement||t.type===f.ContinueStatement||t.type===f.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(a=>a.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.functionCalls.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.conditions.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.operations.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.loops.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[]),...this.searches.reduce((a,l)=>{const p=Ht(l);return[...a,...p]},[])]}getVariableInstances(){return[...this.variableInstances,...this.getEntryPoints().reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[])]}getVariableDeclarations(){return R([...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=Ht(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.searches.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.functionCalls.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.conditions.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.operations.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.loops.reduce((a,l)=>{const p=ut(l);return[...a,...p.filter(t=>t.type===f.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),a=this.getVariableDeclarations();return i.forEach(l=>{if(!l.declaration){const p=l.initialData,t=p.declaration.entityId||p.declaration.id,y=a.find(v=>v.id===t);y&&l.setDeclaration(y)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===$e.PERSISTED_ENTITY)||null}requestActiveValue(i){var l;const a=(l=this.onRequestActiveValueCallback)==null?void 0:l.call(this,i);return a?a||null:i.getDefaultValue()}undo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,console.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],a=this.history[this.undoableStackValueIndex];return console.log("Current change set: ",i),console.log("Change set to restore: ",a==null?void 0:a.toJSON()),wb(i||"initial",a||"initial",this)}redo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,console.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],a=this.history[this.undoableStackValueIndex];return console.log("Current change set: ",i),console.log("Change set to restore: ",a.toJSON()),wb(i||"initial",a||"initial",this)}applyExternalChangeSet(i){const a=i.payload,l=this.addChangeSet(new G(this,i.userAuthor,i.emittedAt,this)),p=a.updated[this.id];if(!p)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const t={...a.added,...a.updated,...a.removed},y=[...Object.keys(a.added),...Object.keys(a.updated),...Object.keys(a.removed)];y.forEach(T=>{var w;if(!t[T]){console.warn(`Entity '${T}' not found in change set transfer. Cannot apply changes.`);const A=(w=this.get(T))==null?void 0:w.toShallowJSON();throw A?console.warn("Entity in project: ",A):console.warn("Entity not in project"),new Error(`Entity '${T}' not found in change set transfer. Cannot apply changes.`)}});const v=new ha(p);return v.flatRecord=t,v.order=y,v.orderEntities(),console.log("All entities: ",v.order.map((T,w)=>`${w+1}: ${t[T].type} - ${T}`).join(`,
404
404
  `)),console.log("Persisting new additions"),v.visit(async(T,w)=>{if(a.added[T.id]){console.log("Adding: ",T.id);try{const A=ee(T,this);if(A.hydrateAncestors(),A.addSelfToProject(l),l.add(A,K.Added),!this.get(T.id))throw new Error(`Entity ${T.id} was not added to the project`)}catch(A){console.error("Error: ",A),console.error("Errored entity: ",T)}}}),console.log("Persisting updates"),v.visit(async(T,w)=>{if(a.updated[T.id]){console.log("Updating: ",T.id);try{const A=this.get(T.id);A?(A.updateWithShallowTransfer(T,l),l.add(A,K.Updated)):console.warn(`Active version of ${T.id} not found when applying external changes`)}catch(A){console.error("Error: ",A),console.error("Errored entity: ",T)}}}),console.log("Persisting removals"),v.visit(async(T,w)=>{if(a.removed[T.id]){console.log("Removing: ",T.id);try{const A=this.get(T.id);A&&A.remove({ignoreUpstream:!1},l)}catch(A){console.error("Error: ",A),console.error("Errored entity: ",T)}}}),l}toFullProjectTransfer(){const i=new ha(this),a={};return i.visit(l=>{const p=l.toShallowJSON();a[l.id]=p}),{order:i.order,size:i.order.length,record:a}}};D(Ke,"sessionAuthor","1"),D(Ke,"UUID",{isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:i=>i}),D(Ke,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(Ke,"type",f.Project),D(Ke,"USER_MANAGED_PARENT_TYPES",[]),D(Ke,"PARENT_TYPES",[...Ke.USER_MANAGED_PARENT_TYPES]),D(Ke,"MUTABLE_BASE_PROPERTIES",["name","description"]),D(Ke,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(Ke,"BASE_PROPERTIES",[...Ke.MUTABLE_BASE_PROPERTIES,...Ke.INMUTABLE_BASE_PROPERTIES]),D(Ke,"MUTABLE_META_PROPERTIES",[...Ke.MUTABLE_BASE_PROPERTIES,"x","y"]),D(Ke,"INMUTABLE_META_PROPERTIES",[...Ke.INMUTABLE_BASE_PROPERTIES]),D(Ke,"META_PROPERTIES",[...Ke.MUTABLE_META_PROPERTIES,...Ke.INMUTABLE_META_PROPERTIES]),D(Ke,"MUTABLE_UPSTREAM_PROPERTIES",[]),D(Ke,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),D(Ke,"UPSTREAM_PROPERTIES",[...Ke.MUTABLE_UPSTREAM_PROPERTIES,...Ke.INMUTABLE_UPSTREAM_PROPERTIES]),D(Ke,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),D(Ke,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(Ke,"DOWNSTREAM_PROPERTIES",[...Ke.MUTABLE_DOWNSTREAM_PROPERTIES,...Ke.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(Ke,"PROPERTIES",[...Ke.META_PROPERTIES,...Ke.UPSTREAM_PROPERTIES,...Ke.DOWNSTREAM_PROPERTIES]);let P=Ke;class Cx extends jt{constructor(i){super(Ss,i);D(this,"id",er.Parallel);D(this,"name",er.Parallel);D(this,"description","Programmatically execute a list of actions one after the other");D(this,"version","1");D(this,"autoexecutable",!0);D(this,"initialData",Ss);D(this,"type",f.ActionDescriptor);D(this,"inputs",[]);D(this,"outputs",[]);D(this,"error",null);D(this,"project");this.project=i,this.inputs=Ss.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=Ss.outputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=Ss.error?ee(Ss.error,this.project):null}}class $x extends jt{constructor(i){super(gi,i);D(this,"id",gi.id);D(this,"name",gi.name);D(this,"description",gi.description);D(this,"version",gi.version);D(this,"autoexecutable",!1);D(this,"initialData",gi);D(this,"type",f.ActionDescriptor);D(this,"inputs",[]);D(this,"outputs",[]);D(this,"error",null);D(this,"project");this.project=i,this.inputs=gi.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=gi.outputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=gi.error?ee(gi.error,this.project):null}}class Px extends jt{constructor(i){super(Xn,i);D(this,"id",er.Sequential);D(this,"name",er.Sequential);D(this,"description","Programmatically execute a list of actions one after the other");D(this,"version","1");D(this,"autoexecutable",!0);D(this,"initialData",Xn);D(this,"type",f.ActionDescriptor);D(this,"inputs",[]);D(this,"outputs",[]);D(this,"error",null);D(this,"project");this.project=i,this.inputs=Xn.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=Xn.outputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=Xn.error?ee(Xn.error,this.project):null}}class m0e extends jt{constructor(u){super(Iu,u)}}class v0e extends jt{constructor(u){super(bo,u)}}class E0e extends jt{constructor(i){super(Ao,i);D(this,"autoexecutable",!0)}getEntityToMatchInputMap(i){return i.inputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===Ee.operation[tr.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(i){return i.inputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===Ee.operation[tr.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(i){return i.outputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===Ee.operation[tr.Validate].outputs.outputEntity.id})||null}getEntityToMatch(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"get-entity-to-match-validate-data"))){const l=this.project.requestActiveValue(i),p=l==null?void 0:l.valueAsTypeSingle;return a==null||a.attemptAutoclose("get-entity-to-match-validate-data",this.id),p}syncOperationInstance(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-operation-instance-validate-data"))){const l=[],p=[],t=[],y=[],v=this.getEntityToMatchInputMap(i);if(v){const{added:A,updated:V,removed:N,affected:j}=this.syncEntityToMatchInputMapDataType(v,a);l.push(...V),p.push(...A),t.push(...N),y.push(...j)}const T=this.getDataToValidateInputMap(i);if(T){const{added:A,updated:V,removed:N,affected:j}=this.syncDataToValidateInputMapDataType(T,a);l.push(...V),p.push(...A),t.push(...N),y.push(...j)}const w=this.getOutputDataOutputMap(i);if(w){const{added:A,updated:V,removed:N,affected:j}=this.syncOutputDataOutputMapDataType(w,a);l.push(...V),p.push(...A),t.push(...N),y.push(...j)}return a==null||a.attemptAutoclose("sync-operation-instance-validate-data",this.id),{updated:R(l),added:R(p),removed:R(t),affected:R(y),self:i}}syncEntityToMatchInputMapDataType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-entity-to-match-input-map-data-type"))){var w,A,V,N,j,k,q,Y,ie,te,pe,ne,me,J,ae;const l=[],p=[],t=[],y=[];if(((w=i.declaration)==null?void 0:w.id)!==Ee.operation[tr.Validate].inputs.entityToMatch.id)return a==null||a.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const v=this.project.requestActiveValue(i),T=v==null?void 0:v.valueAsTypeSingle;if(!i.dataType){const ce={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:((A=i.declaration.dataType)==null?void 0:A.options)||null,implementationChooseOne:((V=i.declaration.dataType)==null?void 0:V.implementationChooseOne)||!1,staticEntities:((N=i.declaration.dataType)==null?void 0:N.staticEntities)??null,interactiveEntities:((j=i.declaration.dataType)==null?void 0:j.interactiveEntities)??null,actionEntities:((k=i.declaration.dataType)==null?void 0:k.actionEntities)??null,isList:((q=i.declaration.dataType)==null?void 0:q.isList)||!1,andChildrenGroup:null,orChildrenGroup:null,asType:!0,entity:(T==null?void 0:T.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},H=ee(ce,i.project);H.hydrateAncestors(),H.setParent(i,a),H.initChildren(a),H.setEntity(T,a),a==null||a.add(H,K.Added),l.push(H),i.setDataType(H,a)}return(J=i.dataType)==null||J.metaSync({inferred:!0,like:!1,asType:!0,options:((Y=i.declaration.dataType)==null?void 0:Y.options)||null,implementationChooseOne:((ie=i.declaration.dataType)==null?void 0:ie.implementationChooseOne)||!1,staticEntities:((te=i.declaration.dataType)==null?void 0:te.staticEntities)??null,interactiveEntities:((pe=i.declaration.dataType)==null?void 0:pe.interactiveEntities)??null,actionEntities:((ne=i.declaration.dataType)==null?void 0:ne.actionEntities)??null,isList:((me=i.declaration.dataType)==null?void 0:me.isList)||!1},a),(ae=i.dataType)==null||ae.setEntity(T,a),i.dataType&&p.push(i.dataType),a==null||a.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:R(p),added:R(l),removed:R(t),affected:R(y),self:i.dataType}}syncDataToValidateInputMapDataType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-data-to-validate-input-map-data-type"))){var A,V,N;const l=[],p=[],t=[],y=[];if(((A=i.declaration)==null?void 0:A.id)!==Ee.operation[tr.Validate].inputs.dataToValidate.id)return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const v=this.getEntityToMatchInputMap(i.parent);if(!v)return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(v,a))return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!i.dataType){const j={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,isList:!1,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,asType:!1,entity:null,like:!0,inferred:!0,parent:i.toReference()},k=ee(j,i.project);k.setParent(i,a),k.initChildren(a),a==null||a.add(k,K.Added),l.push(k),i.setDataType(k,a)}(V=i.dataType)==null||V.metaSync({inferred:!0,like:!0,asType:!1},a);const w=this.getEntityToMatch(v,a);return(N=i.dataType)==null||N.setEntity(w,a),i.dataType&&p.push(i.dataType),a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:R(p),added:R(l),removed:R(t),affected:R(y),self:i.dataType}}syncOutputDataOutputMapDataType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"sync-output-data-output-map-data-type"))){var V,N,j;const l=[],p=[],t=[],y=[];if(((V=i.declaration)==null?void 0:V.id)!==Ee.operation[tr.Validate].outputs.outputEntity.id)return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const v=this.getEntityToMatchInputMap(i.parent);if(!v)return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(v,a))return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const w=this.project.requestActiveValue(v),A=(w==null?void 0:w.valueAsTypeSingle)||null;if(!i.dataType){const k={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:(A==null?void 0:A.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},q=ee(k,i.project);q.hydrateAncestors(),q.setParent(i,a),q.initChildren(a),q.setEntity(A,a),a==null||a.add(q,K.Added),l.push(q),i.setDataType(q,a)}return(N=i.dataType)==null||N.metaSync({inferred:!0,like:!0,asType:!1},a),(j=i.dataType)==null||j.setEntity(A,a),i.dataType&&p.push(i.dataType),a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:R(p),added:R(l),removed:R(t),affected:R(y),self:i.dataType}}inferInputMapDataType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"infer-input-map-data-type-validate-data"))){var p,t,y;if(((p=i.declaration)==null?void 0:p.id)===Ee.operation[tr.Validate].inputs.entityToMatch.id){const{added:v,updated:T,removed:w,affected:A}=this.syncEntityToMatchInputMapDataType(i,a);return a==null||a.attemptAutoclose("infer-input-map-data-type",this.id),{updated:R(T),added:R(v),removed:R(w),affected:R(A),self:i.dataType}}if(((t=i.declaration)==null?void 0:t.id)===Ee.operation[tr.Validate].inputs.dataToValidate.id){const{added:v,updated:T,removed:w,affected:A}=this.syncDataToValidateInputMapDataType(i,a);return a==null||a.attemptAutoclose("infer-input-map-data-type",this.id),{updated:R(T),added:R(v),removed:R(w),affected:R(A),self:i.dataType}}const l=(y=i.declaration)==null?void 0:y.getDataType(a);if(l&&l.isResolved)return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:l};if(i.readsValue){const v=zs(i.readsValue,a);return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:v}}return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:null}}inferOutputMapDataType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,L().toISOString(),this,!0,"infer-output-map-data-type-validate-data"))){var l;if(((l=i.declaration)==null?void 0:l.id)===Ee.operation[tr.Validate].outputs.outputEntity.id){const{added:p,updated:t,removed:y,affected:v}=this.syncOutputDataOutputMapDataType(i,a);return a==null||a.attemptAutoclose("infer-output-map-data-type-validate-data",this.id),{updated:R(t),added:R(p),removed:R(y),affected:R(v),self:i.dataType}}return{updated:[],added:[],removed:[],affected:[],self:null}}}class T0e extends jt{constructor(u){super(cv,u)}}class b0e extends jt{constructor(u){super(fv,u)}}class A0e extends jt{constructor(u){super(hv,u)}}class I0e extends jt{constructor(u){super(Lf,u)}}class w0e extends jt{constructor(u){super(Pf,u)}}class R0e extends jt{constructor(u){super(Au,u)}}function _0e(d){const u=[new Px(d),new Cx(d),new $x(d),new m0e(d),new v0e(d),new E0e(d),new I0e(d),new T0e(d),new A0e(d),new b0e(d),new w0e(d),new R0e(d),new jt(uv,d),new jt(dv,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.operationDeclarations=u,u}class Vx extends Cn{constructor(i){super(ti,i);D(this,"initialData");D(this,"id",$e.PERSISTED_ENTITY);D(this,"version","1");D(this,"name",$e.PERSISTED_ENTITY);D(this,"description",ti.description);D(this,"type",f.BuiltInBaseEntity);D(this,"abstract",ti.abstract);D(this,"static",ti.static);D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"errors",[]);D(this,"project");this.initialData=ti,this.project=i,this.id=ti.id,this.version=ti.version,this.name=ti.name,this.static=ti.static,this.abstract=ti.abstract,this.properties=this.initialData.properties.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.methods=this.initialData.methods.map(a=>{const l=ee(a,this.project);return l.parent=this,l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=ee(a,this.project);return l.parent=this,l}),this.extends=this.initialData.extends.map(a=>ee(a,this.project))}}var Nx=(d=>(d.StatusCodeMustBeNumber="status-code-must-be-number",d.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",d))(Nx||{});function Lx(d,u){const i=[];if(typeof u!="number"){const a=new qt({id:d.id+"--status-code-must-be-number",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value must be a number.`,issue:null,severity:Z.Error,code:"status-code-must-be-number",entity:d});return i.push(a),{errors:i,override:u}}if(u<100){const a=new qt({id:d.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value must be a number between 100 and 599.`,issue:null,severity:Z.Error,code:"status-code-must-be-between-100-and-599",entity:d});i.push(a)}if(u>599){const a=new qt({id:d.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value must be a number between 100 and 599.`,issue:null,severity:Z.Error,code:"status-code-must-be-between-100-and-599",entity:d});i.push(a)}return{errors:i,override:u}}class Bx extends Cn{constructor(i){super(qi,i);D(this,"initialData");D(this,"id",$e.PERSISTED_ENTITY);D(this,"version","1");D(this,"name",$e.PERSISTED_ENTITY);D(this,"description",qi.description);D(this,"type",f.BuiltInBaseEntity);D(this,"abstract",qi.abstract);D(this,"static",qi.static);D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"errors",[]);D(this,"project");this.initialData=qi,this.project=i,this.id=qi.id,this.version=qi.version,this.name=qi.name,this.static=qi.static,this.abstract=qi.abstract,this.properties=this.initialData.properties.map(t=>{const y=ee(t,this.project);return y.setParent(this,null),y.initChildren(null),y}),this.methods=this.initialData.methods.map(t=>{const y=ee(t,this.project);return y.parent=this,y}),this.abstractMethods=this.initialData.abstractMethods.map(t=>{const y=ee(t,this.project);return y.parent=this,y}),this.extends=this.initialData.extends.map(t=>ee(t,this.project));const a=this.properties.find(t=>t.id===Ee["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!a)throw new Error("Path property not found in endpoint entity");a._codeNativeValueValidation=(t,y)=>bj(t,y);const l=this.abstractMethods.find(t=>t.id===Ee["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!l)throw new Error("Handler method not found in endpoint entity");const p=l.outputs.find(t=>t.id===Ee["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.outputs.statusCode.id);if(!p)throw new Error("Status code output not found in handler method");p.codeNativeValueValidation=(t,y)=>Lx(t,y)}}const g0e="test_primitive_entities_export";class D0e extends Cn{constructor(i){super(Wr,i);D(this,"initialData");D(this,"id",$e.PERSISTED_ENTITY);D(this,"version","1");D(this,"name",$e.PERSISTED_ENTITY);D(this,"description",Wr.description);D(this,"type",f.BuiltInBaseEntity);D(this,"abstract",Wr.abstract);D(this,"static",Wr.static);D(this,"properties",[]);D(this,"methods",[]);D(this,"abstractMethods",[]);D(this,"extends",[]);D(this,"errors",[]);D(this,"project");this.initialData=Wr,this.project=i,this.id=Wr.id,this.version=Wr.version,this.name=Wr.name,this.static=Wr.static,this.abstract=Wr.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.extends=this.initialData.extends.map(l=>ee(l,this.project));const a=this.properties.find(l=>l.id===Ee["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id);if(!a)throw new Error("Path property not found in endpoint entity");a._codeNativeValueValidation=(l,p)=>Aj(l,p)}}function O0e(d){const u=[new Vx(d),new Bx(d),new D0e(d),new Cn(zf,d)];return u.forEach(i=>{d.subscribeBuiltInInstance(i)}),d.builtInBaseEntities=u,u}function C0e(d){const u=[new Li(Se,d),new Li(Wn,d),new Li(dt,d),new Li(iv,d),new Li(Jr,d),new Li(Yn,d),new Li(yn,d),new Li(Hn,d),new Li(Cl,d)];return u.forEach(i=>{d.subscribeBuiltInInstance(i)}),d.primitives=u,u}function $0e(d){const u=[new jt(Qf,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.globalEventActionDescriptors=u,u}function P0e(d){const u=[new jt(gu,d),new jt(Ra,d),new jt(Ru,d),new jt(Vl,d),new jt(Nl,d),new jt(Kf,d)];u.forEach(a=>{a.initChildren(null),d.subscribeBuiltInInstance(a)}),d.loopDeclarations=u;const i=[new jt(Zf,d),new jt(_u,d),new jt(qf,d),new jt(Dv,d),new jt(Cv,d),new jt(kf,d)];return i.forEach(a=>{a.initChildren(null),d.subscribeBuiltInInstance(a)}),d.loopDeclarationsBodies=i,u}function V0e(d){const u=[new en(eh,d),new en(Yv,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.valueDescriptors=u,u}function N0e(d){const u=[new jt(go,d),new jt(jl,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.conditionDeclarations=u,u}const Ho={},em={},$p={empty:!1,enrich:!0,mock:!1,ignoreCache:!1,onFetch:async()=>null,manuallyInit:!1};function Mx(d,u={enrich:!0,shallowErrors:!1}){const i={enrich:!0,shallowErrors:!1,...u},{enrich:a,shallowErrors:l}=i,p=d.project,t=d.record,y=new ha(p),v=new Set;t[p.id]=p,v.add(p.id);const T=L().toISOString();Object.values(t).forEach(V=>{!V||y.allBuiltInEntityIds.includes(V.id)||v.add(V.id)}),y.order=Array.from(v),y.flatRecord=t,y.orderEntities();const w=tm(d.project);w.instances[p.id]=w;const A=a?w.addChangeSet(new G(w,P.sessionAuthor,T,w,!0,"project-init-from-fetch-result")):null;return y.visit(V=>{if(V.id===w.id)return;const N=ee(V,w);try{N.hydrateAncestors(),N.addSelfToProject(null);const j=Rd(V);Object.keys(j.downstream).forEach(k=>{const q=w.get(k);q&&q.hydrateAncestors()})}catch(j){if(l)console.error("Error hydrating ancestors: ",j);else throw j}}),a?(y.visit(V=>{if(V.id===w.id)return;const N=w.get(V.id);N&&N.afterAllChildrenInitialized(A)}),w.afterAllChildrenInitialized(A)):rm(w,T).forEach(N=>{N.remove({ignoreUpstream:!0},null)}),w.instancesList.forEach(V=>{V.previousVersion=null}),A==null||A.attemptAutoclose("project-init-from-fetch-result",w.id),w}async function L0e(d,u=$p){const i={...$p,...u};if(i.empty)return{data:{project:{id:d.id,type:f.Project,version:P.UUID.uuid(),createdAt:L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]},record:{}}};if(i.mock){const l={...iT};return l.id=d.id,{data:{project:l,record:{}}}}return console.log("Fetching project from external API"),new Promise(async l=>{try{if(i.onFetch){const p=await i.onFetch(d.id);if(p){l({data:p});return}}else l({data:null})}catch(p){console.error("Error fetching project: ",p),l({data:null})}})}function tm(d){const u=new P(d);return C0e(u),O0e(u),_0e(u),$0e(u),P0e(u),V0e(u),N0e(u),Array.from(new Set([...u.getAllBuiltInIds(),...Ps()])).forEach(a=>{if(!u.builtInInstances[a]&&u.instances[a])u.builtInInstances[a]=u.instances[a],delete u.instances[a];else if(!u.builtInInstances[a])throw new Error(`Built in entity was not properly initialized: ${a}`)}),u.instances[u.id]=u,u}function rm(d,u){return d.instancesList.filter(a=>L(a.createdAt).isAfter(L(u)||!!a.previousVersion))}function B0e(d,{enrich:u}={enrich:!0}){const i=new Map,a=new Map,l=Array.from(new Set([...d.getAllBuiltInIds(),...Ps()]));Object.keys(d.instances).forEach(w=>{if(l.includes(w)){i.set(w,w),a.set(w,w);return}const A=d.get(w);if(!Xy(A,{...d.instances,...d.builtInInstances}).every(k=>!l.includes(k))){i.set(w,w),a.set(w,w);return}const j=P.UUID.uuid();i.set(w,j),a.set(j,w)});const p=L().toISOString(),t=d.toShallowJSON({seenEntityMaps:i});t.previousVersion=null,t.createdAt=p,t.version=P.UUID.uuid();const y=tm(t);y.instances[y.id]=y;const v=u?y.addChangeSet(new G(y,P.sessionAuthor,p,y,!0,"project-clone")):null,T=new ha(d);return T.visit(w=>{const A=w.toShallowJSON({seenEntityMaps:i});A.previousVersion=null,A.createdAt=p,A.version=P.UUID.uuid();const V=Rd(A,Uj(T.flatRecord,i));if(Object.keys(V.upstream).length){let j=!1;if(Object.keys(V.upstream).forEach(k=>{if(!j&&(!y.get(k)||y.getDeleted(k))){j=!0;return}}),j)return}const N=ee(A,y);N.hydrateAncestors(),N.addSelfToProject(v),v==null||v.add(N,K.Added)}),u?(T.visit(w=>{if(w.id===y.id)return;const A=y.get(i.get(w.id));A&&A.afterAllChildrenInitialized(v)}),y.afterAllChildrenInitialized(v)):rm(y,p).forEach(A=>{A.remove({ignoreUpstream:!0},null)}),y.instancesList.forEach(w=>{w.previousVersion=null}),v==null||v.attemptAutoclose("project-clone",y.id),y}function Ux(d,{enrich:u}={enrich:!0}){const i=tm(d),a=L().toISOString(),l=u?i.addChangeSet(new G(i,P.sessionAuthor,a,i,!0,"project-init")):null;l&&(l.type=Ib.Automatic);const p=new ha(d);return p.visit(t=>{const y=ee(t,i);y.hydrateAncestors(),y.addSelfToProject(l)}),u?(p.visit(t=>{if(t.id===i.id)return;const y=i.get(t.id);y&&y.afterAllChildrenInitialized(l)}),i.afterAllChildrenInitialized(l)):(rm(i,a).forEach(v=>{v.remove({ignoreUpstream:!0},null)}),new ha(i).visit(v=>{v.initialized=!0,v.captureVersion()})),i.initialized=!0,l==null||l.attemptAutoclose("project-init",i.id),i}async function M0e(d,u=$p){const i={...$p,...u};if(d.id&&Ho[d.id]&&!i.ignoreCache)return Ho[d.id];if(d.id&&em[d.id]&&!i.ignoreCache)return await em[d.id],Ho[d.id];const a=L0e(d,i);d.id&&(em[d.id]=a);const l=await a;if(l.data){let p;return i.mock?p=Ux(iT,{enrich:!!i.enrich}):l.data instanceof P?p=l.data:p=Mx(l.data,{enrich:!!i.enrich}),Ho[d.id]=p,d.id&&delete em[d.id],p}return null}function U0e(d){return Ho[d.id]&&delete Ho[d.id],null}var Ae=(d=>(d.Inherited="inherited",d.DefaultValue="default-value",d.Missing="missing",d.Empty="empty",d.AutoCalculated="auto-calculated",d.QueuedAutocalculation="queued-autocalculation",d.External="external",d.Testing="testing",d.ExecutionResult="execution-result",d))(Ae||{});const jx={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function j0e(d,u){return{...jx,id:d,project:u}}class Pp{constructor(u,i){D(this,"initialized",!1);D(this,"id");D(this,"project");D(this,"values",{});D(this,"onWriteCallback",()=>{});D(this,"onRemoveCallback",()=>{});this.id=u,this.project=i,this.init()}onWrite(u){this.onWriteCallback=u}onRemove(u){this.onRemoveCallback=u}init(){if(!this.project.id||this.initialized)return;const u={},i={};Object.keys(u).forEach(a=>{const l=u[a],p=new bi(l,this.project);try{if(l.parent){const v=this.project.findSubscribedInstanceFromReference(l.parent);if(!v)return;p.setParent(v,null),p.hydrateAncestors(),p.initChildren(null)}else if(l.standaloneParent){const v=this.project.findSubscribedInstanceFromReference(l.standaloneParent);if(!v)return;p.standalone=!0,p.setStandaloneParent(v),p.hydrateAncestors(),p.initChildren(null)}i[a]=p;const t=p.parent||p.standaloneParent,y=Fx(p,t,this.project);y?i[a]=y:delete u[a]}catch(t){console.error("Error hydrating ancestors: ",t),delete u[a]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const u={};return Object.keys(this.values).forEach(i=>{u[i]=this.values[i].toJSON()}),u}writeValue(u,i){if(!u)throw new Error("The value owner entity is required when writing a value to a value store");let l=this.values[u.id];if(!l)if(i instanceof bi)l=i;else if(i)l=Kt(i,this.project);else{const p={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:new Date().toISOString(),author:P.sessionAuthor,deleted:!1,previousVersion:null,value:null,type:f.LiteralValue,standaloneParent:u.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:Zo(u.getDataType(null))};l=Kt(p,this.project)}l.standalone=!0,l.initialData.standaloneParent||console.warn("instance.initialData: ",l.initialData),l.setStandaloneParent(u),l.hydrateAncestors(),l.initChildren(null),i&&(l.metaSync({...i},null),l.setValueAsType(i.valueAsType,null)),this.values[u.id]=l,this.onWriteCallback(u,l)}readValue(u){return this.values[u]||null}removeValue(u){if(!this.values[u])return;delete this.values[u];const i=this.project.get(u);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function zo(d){var u;return!!(d.required||(u=d.declaration)!=null&&u.required)}function xx(d){return q4(d)||d===void 0||d===""}function RA(d){return d?d.valueAsType?!1:xx(d.value):!0}function rn(d,u,i,a){var y;let l;if(((y=d==null?void 0:d.entity)==null?void 0:y.type)===f.PrimitiveEntity)switch(d.entity.name){case X.EntityTemplate:l=X.EntityTemplate;break;case X.String:l=X.String;break;case X.Number:l=X.Number;break;case X.Boolean:l=X.Boolean;break;case X.Null:l=X.Null;break;case X.Enum:l=X.Enum;break;case X.KeyValue:l=X.KeyValue;break;case X.Untyped:l=X.Untyped;break;case X.KeyValue:l=X.KeyValue;break;case X.Date:l=X.Date;break;case X.UUID:l=X.UUID;break;case X.File:l=X.File;break;default:throw new Error(`Primitive type ${re(d.entity,i)} is not supported`)}else l=X.Untyped;const p=bi.new();p.name=l,p.parent=u.toReference();const t=ee(p,i);return t.hydrateAncestors(),a==null||a.add(t,K.Added),t.addSelfToProject(a),t.initChildren(a),t}function sn(d,u,i=new Set){var a;if(i.has(d.id))return[];if(i.add(d.id),d.type===f.ReturnDeclaration){const l=[d,...d.getCounterparts()];return console.log("Resolved counterparts for return declaration: ",`${d.name} ${d.id}`),console.log("equivalentReturnDeclarations: ",l.map(p=>`${p.name} ${p.id}`)),R([...l,...l.flatMap(p=>sn(p,u,i))])}else if(rt.includes(d.type)){const l=oi(d);return R([l,...[l].flatMap(p=>sn(p,u,i))])}else if(d.type===f.OutputMap){if(rt.includes(d.parent.type)&&d.declaration.type===f.Property&&d.declaration.static)return R([d,d.declaration,...[d,d.declaration].flatMap(l=>sn(l,u,i))])}else if(d.type===f.InputMap&&rt.includes(d.parent.type)&&((a=d.declaration)==null?void 0:a.type)===f.Property&&d.declaration.static)return R([d.declaration,...[d.declaration].flatMap(l=>sn(l,u,i))]);return[d]}function Fx(d,u,i){return d}function Od(d,u){const i=d.readsValue;let a=null;if((i==null?void 0:i.type)===f.VariableDeclaration){const p=Np(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Ae.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.VariableInstance){const p=sm(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Ae.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.OutputMap){const p=OA(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Ae.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.ArgumentDeclaration){const p=gA(i,u);if(p){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Ae.Inherited,inheritanceLink:t}}}return a}function He(d,u,i){var t;if(!u)return null;let a;if(((t=d==null?void 0:d.entity)==null?void 0:t.type)===f.PrimitiveEntity)switch(d.entity.name){case X.EntityTemplate:a=X.EntityTemplate;break;case X.String:a=X.String;break;case X.Number:a=X.Number;break;case X.Boolean:a=X.Boolean;break;case X.Null:a=X.Null;break;case X.Enum:a=X.Enum;break;case X.KeyValue:a=X.KeyValue;break;case X.Untyped:a=X.Untyped;break;case X.KeyValue:a=X.KeyValue;break;case X.Date:a=X.Date;break;case X.UUID:a=X.UUID;break;case X.File:a=X.File;break;default:throw new Error(`Primitive type ${re(d.entity,i)} is not supported`)}else a=X.Untyped;const l=bi.new();l.name=a,l.standaloneParent=u.toReference();let p=new bi(l,i);return p.hydrateAncestors(),p.standalone=!0,p.setStandaloneParent(u),p.initChildren(null),p}function im(d,u,i){var p;const a={...d},l=u.inputs;if(!l)return a;for(const t of l){const y=$A(t,i);if(y&&y.value){const v=re(t,i.project),T=kr(v);a[T]=(p=y==null?void 0:y.value)==null?void 0:p.value}}return a}function Vp(d,u,i){var p;const a={...d},l=u.inputs;if(!l)return a;for(const t of l){const y=CA(t,i);if(y&&y.value){const v=re(t,i.project),T=kr(v);a[T]=(p=y==null?void 0:y.value)==null?void 0:p.value}}return a}function Gx(d,u){var y,v,T,w,A,V,N;let i={};if(((v=(y=d.dataType)==null?void 0:y.entity)==null?void 0:v.type)===f.DefinitionEntity&&(i={...i,...d.dataType.entity.getActiveRawDefaultValue()}),u.execution&&u.execution.hasEntity(d)){const j=(T=u.lastExecutionResults)==null?void 0:T.readValue(d.id);if(j){if(ir(j.value)){const q={...i,...j.value},Y={...Vp(q,d,u)};d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("1- newRawValue",Y),j.metaSync({value:Y},null)}return{value:j,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}}const a=!!((w=u.execution)!=null&&w.entities.length),l=(A=u.execution)==null?void 0:A.hasEntity(d),p=d.readsValue;let t=null;if(p){const j=(V=u.execution)==null?void 0:V.hasEntity(p);if((!a||a&&j&&l||a&&!j&&!l)&&(t=Od(d,u),t&&t.value&&ir(t.value.value))){const q={...i,...t.value.value},Y={...Vp(q,d,u)};d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("2- newRawValue",Y),t.value.metaSync({value:Y},null)}}if(!t&&d.defaultValue){const j=d.defaultValue;if(j.value===null&&j.autogeneration){const k=gh(j);if(j.metaSync({value:k},null),ir(k)){const q={...Vp(k,d,u)};d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("3- newRawValue",q),j.metaSync({value:q},null)}}t={value:j,valueOwner:d,type:j.value===null?Ae.Empty:Ae.DefaultValue,inheritanceLink:null}}if(!t||t.type===Ae.DefaultValue){const j=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(j){if(ir(j.value)){const k={...i,...j.value},q={...Vp(k,d,u)};d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("4- newRawValue",q),j.metaSync({value:q},null)}return{value:j,valueOwner:d,type:Ae.Testing,inheritanceLink:null}}}return t||{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}}function Kx(d,u){var l,p,t,y,v;let i={};if(((p=(l=d.dataType)==null?void 0:l.entity)==null?void 0:p.type)===f.DefinitionEntity&&(i={...i,...d.dataType.entity.getActiveRawDefaultValue()},d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("initialDefaultValue",i)),u.execution&&u.execution.hasEntity(d)){const T=(t=u.lastExecutionResults)==null?void 0:t.readValue(d.id);if(T){if(ir(T.value)){const A={...i,...T.value};T.metaSync({value:{...im(A,d,u)}},null)}return{value:T,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}}const a=(y=u.localTestValues)==null?void 0:y.readValue(d.id);if(d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("testValue",a),a){if(ir(a.value)){const w={...i,...a.value};a.metaSync({value:{...im(w,d,u)}},null)}return{value:a,valueOwner:d,type:Ae.Testing,inheritanceLink:null}}if((v=d.dataType)!=null&&v.entity&&d.dataType.entity.type===f.DefinitionEntity&&d.dataType.isObject()){const T=He(d.dataType,d,u.project);return T==null||T.metaSync({value:im(i,d,u)},null),{value:T,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null}}return null}function Np(d,u){var y,v,T,w,A,V;if((y=d.dataType)!=null&&y.isObject())return Gx(d,u);const i=ur(d),a=!!((v=u.execution)!=null&&v.entities.length),l=(T=u.execution)==null?void 0:T.hasEntity(i),p=d.readsValue;let t=null;if(p){const N=(w=u.execution)==null?void 0:w.hasEntity(p);(!a||a&&N&&l||a&&!N&&!l)&&(t=Od(d,u))}if(!t&&d.defaultValue){const N=d.defaultValue;if(N.value===null&&N.autogeneration){const j=gh(N);N.metaSync({value:j},null)}t={value:N,valueOwner:d,type:N.value===null?Ae.Empty:Ae.DefaultValue,inheritanceLink:null}}return(!t||t.type===Ae.DefaultValue)&&(A=u.localTestValues)!=null&&A.values[d.id]?{value:(V=u.localTestValues)==null?void 0:V.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null}:t||{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}}function _A(d,u){var a,l,p,t;if(d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("resolveVarDeclarationValue",d),(a=d.dataType)!=null&&a.isObject())return d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("current value is object"),Kx(d,u);if(u.execution&&u.execution.hasEntity(d)){const y=(l=u.lastExecutionResults)==null?void 0:l.readValue(d.id);if(y)return{value:y,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}const i=(p=u.localTestValues)==null?void 0:p.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Ae.Testing,inheritanceLink:null};if((t=d.dataType)!=null&&t.entity&&d.dataType.entity.type===f.DefinitionEntity&&d.dataType.isObject()){const y=He(d.dataType,d,u.project),v=d.dataType.entity.getActiveRawDefaultValue();return d.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("resolvedRawValue",v),y==null||y.metaSync({value:v},null),{value:y,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null}}return null}function sm(d,u){var T,w,A,V,N;d.id==="e749df9b-6b68-4baf-a3c5-59ca15c2492f"&&console.log("resolveVarInstanceNextValue");const i=!!((T=u.execution)!=null&&T.entities.length),a=(w=u.execution)==null?void 0:w.hasEntity(d);let l=null;const p=d.readsValue;if(p){const j=(A=u.execution)==null?void 0:A.hasEntity(p);(!i||i&&j&&a||i&&!j&&!a)&&(l=Od(d,u))}const t=d.declaration;if(!l&&t){d.id==="e749df9b-6b68-4baf-a3c5-59ca15c2492f"&&console.log("resolveVarInstanceNextValue resolveVarDeclarationNextValue");const j=Np(t,u);j&&j.value&&(l=j)}if((!l||l.type===Ae.DefaultValue)&&(V=u.localTestValues)!=null&&V.values[d.id])return{value:(N=u.localTestValues)==null?void 0:N.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null};const y=zo(d);return y&&a&&!l?{value:null,valueOwner:d,type:Ae.Missing,inheritanceLink:null}:a&&!y&&!l?{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}:l||{value:null,valueOwner:d,type:Ae.External,inheritanceLink:null}}function kx(d,u){return _A(d.declaration,u)}function gA(d,u){var v,T,w,A,V;if(u.execution&&u.execution.hasEntity(d)){const N=(v=u.lastExecutionResults)==null?void 0:v.readValue(d.id);if(N)return{value:N,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}const i=ur(d),a=d.parent.type===f.FunctionDeclaration&&d.parent.parent.type===f.Loop?d.parent:null,l=!!((T=u.execution)!=null&&T.hasEntity(i))||!!a&&!!((w=u.execution)!=null&&w.hasEntity(a));let p=null;if(d.defaultValue){const N=d.defaultValue;if(N.value===null&&N.autogeneration){const j=gh(N);N.metaSync({value:j},null)}p={value:N,valueOwner:d,type:N.value===null?Ae.Empty:Ae.DefaultValue,inheritanceLink:null}}if((!p||p.type===Ae.DefaultValue)&&(A=u.localTestValues)!=null&&A.values[d.id])return{value:(V=u.localTestValues)==null?void 0:V.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null};const t=zo(d);let y=t&&l&&!p;return i.type===f.Loop&&l&&(y=!1),y?{value:null,valueOwner:d,type:Ae.Missing,inheritanceLink:null}:l&&!t&&!p?{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}:p||{value:null,valueOwner:d,type:Ae.External,inheritanceLink:null}}function DA(d,u){var T,w,A,V,N,j;if(u.execution&&u.execution.hasEntity(d)){const k=(T=u.lastExecutionResults)==null?void 0:T.readValue(d.id);if(k)return{value:k,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}const i=ur(d),a=!!((w=u.execution)!=null&&w.entities.length),l=(A=u.execution)==null?void 0:A.hasEntity(i),p=d.readsValue;let t=null;if(p){const k=(V=u.execution)==null?void 0:V.hasEntity(p);(!a||a&&k&&l||a&&!k&&!l)&&(t=Od(d,u))}if(!t&&d.defaultValue&&(t={value:d.defaultValue,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null}),(!t||t.type===Ae.DefaultValue)&&(N=u.localTestValues)!=null&&N.values[d.id])return{value:(j=u.localTestValues)==null?void 0:j.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null};const y=zo(d);return y&&!t?{value:null,valueOwner:d,type:Ae.Missing,inheritanceLink:null}:!y&&!t?{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}:t}function OA(d,u){var y,v,T,w,A;if(u.execution&&u.execution.hasEntity(d)){const V=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(V)return{value:V,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}const i=ur(d);if(rt.includes(i.type)){const V=eo(i,u),N=kr(re(d,u.project));if(V!=null&&V.value&&ir(V.value.value)){const j=V.value.value[N],k=He(d.getDataType(null),d,u.project);return k==null||k.metaSync({value:j},null),{value:k,valueOwner:d,type:V.type,inheritanceLink:{sources:[V],target:d}}}return null}const a=(v=u.execution)==null?void 0:v.hasEntity(i),l=((T=u.execution)==null?void 0:T.state)===PA.Running;if((w=u.persistedExecutionResults)!=null&&w.values[d.id]&&!a&&!l){const V=(A=u.persistedExecutionResults)==null?void 0:A.readValue(d.id);if((V==null?void 0:V.value)!==null||V.valueAsType!==null)return{value:V,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}const p=d.getDefaultValue();if(p&&(p.value!==null||p.valueAsType!==null))return{value:p,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null};const t=d.parent;if(!t)throw new Error(`Couldn't find the parent that generates the output ${d.id}`);switch(t.type){case f.VariableInstance:{const N=sm(t,u);if(N&&N.value){const k=d.declaration;if(ir(N.value.value)){const q=N.value.value[k.name],Y=He(d.declaration.dataType,d,u.project);return Y==null||Y.metaSync({value:q},null),{value:Y,valueOwner:d,type:Ae.Inherited,inheritanceLink:{sources:[N],target:d}}}}const j=He(d.declaration.dataType,d,u.project);return j==null||j.metaSync({value:null},null),{value:j,valueOwner:d,type:Ae.Inherited,inheritanceLink:{sources:N?[N]:[],target:d}}}case f.VariableDeclaration:{const N=Np(t,u);if(N&&N.value){const k=d.declaration;if(ir(N.value.value)){const q=N.value.value[k.name],Y=He(d.declaration.dataType,d,u.project);return Y==null||Y.metaSync({value:q},null),{value:Y,valueOwner:d,type:Ae.Inherited,inheritanceLink:{sources:[N],target:d}}}}const j=He(d.declaration.dataType,d,u.project);return j==null||j.metaSync({value:null},null),{value:j,valueOwner:d,type:Ae.Inherited,inheritanceLink:{sources:N?[N]:[],target:d}}}case f.Operation:{const V=t.outputs.map(j=>{var q,Y;if((q=u.persistedExecutionResults)!=null&&q.values[j.id]){const ie=(Y=u.persistedExecutionResults)==null?void 0:Y.values[j.id];if(ie.value!==null||ie.valueAsType!==null)return{value:ie,valueOwner:j,type:Ae.ExecutionResult,inheritanceLink:null}}const k=j.getDefaultValue();if(k&&(k.value!==null||k.valueAsType!==null))return{value:k,valueOwner:j,type:Ae.DefaultValue,inheritanceLink:null}}).filter(j=>!!j),N=He(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Ae.QueuedAutocalculation,inheritanceLink:V.length?{sources:V,target:d}:null}}case f.FunctionCall:{const V=t.inputs.map(j=>Lp(j,u)).filter(j=>!!j),N=He(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Ae.QueuedAutocalculation,inheritanceLink:V.length?{sources:V,target:d}:null}}case f.Loop:{const V=t.inputs.map(j=>Lp(j,u)).filter(j=>!!j),N=He(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Ae.QueuedAutocalculation,inheritanceLink:V.length?{sources:V,target:d}:null}}}return null}function qx(d,u){var y,v;if(!rt.includes(d.parent.type))return null;if(((y=d.declaration)==null?void 0:y.type)===f.Property&&d.declaration.static)return eo(d.declaration,u);const i=oi(d.parent),a=nm(i,u),l=kr(re(d,u.project)),p=He(d.getDataType(null),d,u.project),t=(v=a==null?void 0:a.value)==null?void 0:v.value;return t&&ir(t)?(p==null||p.metaSync({value:t[l]||null},null),{value:p,valueOwner:d,type:a.type,inheritanceLink:{sources:a?[a]:[],target:d}}):null}function Sx(d,u){var y,v;if(!rt.includes(d.parent.type))return null;if(((y=d.declaration)==null?void 0:y.type)===f.Property&&d.declaration.static)return eo(d.declaration,u);const i=oi(d.parent),a=eo(i,u),l=kr(re(d,u.project)),p=He(d.getDataType(null),d,u.project),t=(v=a==null?void 0:a.value)==null?void 0:v.value;return t&&ir(t)?(p==null||p.metaSync({value:t[l]||null},null),{value:p,valueOwner:d,type:a.type,inheritanceLink:{sources:[a],target:d}}):null}function CA(d,u){var T,w,A,V,N;const i=ur(d),a=!!((T=u.execution)!=null&&T.entities.length),l=(w=u.execution)==null?void 0:w.hasEntity(i),p=d.readsValue;let t=null;if(p){const j=(A=u.execution)==null?void 0:A.hasEntity(p);(!a||a&&j&&l||a&&!j&&!l)&&(d.id==="c1b53d2e-0916-48c6-a2fa-0d488af73a93"&&console.log("Here input-map is property of object -- resolving from writter"),t=Od(d,u),d.id==="c1b53d2e-0916-48c6-a2fa-0d488af73a93"&&console.log("Here input-map is property of object -- resolved from writter: ",t))}if(!t&&d.defaultValue){const j=d.defaultValue;j&&(t={value:j,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null})}if(!t&&d.declaration){const j=eo(d.declaration,u);j&&j.value&&(t={...j,valueOwner:d,type:Ae.DefaultValue})}if((!t||t.type===Ae.DefaultValue||(t==null?void 0:t.type)===Ae.Empty)&&(V=u.localTestValues)!=null&&V.values[d.id])return{value:(N=u.localTestValues)==null?void 0:N.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null};const y=zo(d);return y&&!t||(t==null?void 0:t.type)===Ae.Empty?{value:null,valueOwner:d,type:Ae.Missing,inheritanceLink:(t==null?void 0:t.inheritanceLink)||null}:!y&&(!t||t.type===Ae.Inherited)&&!(t!=null&&t.inheritanceLink)?{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}:t}function $A(d,u){var a;if(u.execution&&u.execution.hasEntity(d)){const l=(a=u.lastExecutionResults)==null?void 0:a.readValue(d.id);if(l)return{value:l,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}return Lp(d,u)}function Lp(d,u){var i;return rt.includes(d.parent.type)&&(i=oi(d.parent).dataType)!=null&&i.isObject()?qx(d,u):CA(d,u)}function Zx(d,u){var i;return rt.includes(d.parent.type)&&(i=oi(d.parent).dataType)!=null&&i.isObject()?Sx(d,u):$A(d,u)}function Jx(d,u){var t,y,v;if(!d.static)return null;if(u.execution){const T=(t=u.lastExecutionResults)==null?void 0:t.readValue(d.id);if(T)return{value:T,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}if((y=u.localTestValues)!=null&&y.values[d.id])return{value:(v=u.localTestValues)==null?void 0:v.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null};const i=d.getDefaultValue();let a=null;return i&&(a={value:i,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null}),zo(d)&&RA(a==null?void 0:a.value)?{value:null,valueOwner:d,type:Ae.Missing,inheritanceLink:null}:RA(a==null?void 0:a.value)?{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}:a}function Wx(d,u){var t,y,v,T,w,A,V;if(u.execution&&u.execution.hasEntity(d)){const N=(t=u.lastExecutionResults)==null?void 0:t.readValue(d.id);if(N)return{value:N,valueOwner:d,type:Ae.ExecutionResult,inheritanceLink:null}}if((y=u.localTestValues)!=null&&y.values[d.id])return{value:(v=u.localTestValues)==null?void 0:v.values[d.id],valueOwner:d,type:Ae.Testing,inheritanceLink:null};const i=d.getDefaultValue();let a=null;return i&&(a={value:i,valueOwner:d,type:Ae.DefaultValue,inheritanceLink:null}),zo(d)&&!((T=a==null?void 0:a.value)!=null&&T.value)&&!((w=a==null?void 0:a.value)!=null&&w.valueAsType)?{value:null,valueOwner:d,type:Ae.Missing,inheritanceLink:null}:!((A=a==null?void 0:a.value)!=null&&A.value)&&!((V=a==null?void 0:a.value)!=null&&V.valueAsType)?{value:null,valueOwner:d,type:Ae.Empty,inheritanceLink:null}:a}function eo(d,u){switch(d.type){case f.ArgumentDeclaration:return gA(d,u);case f.InputMap:return Zx(d,u);case f.VariableDeclaration:return _A(d,u);case f.VariableInstance:return kx(d,u);case f.OutputMap:return OA(d,u);case f.ReturnDeclaration:return DA(d,u);case f.Property:return Jx(d,u);case f.ValueDescriptor:return Wx(d,u);default:return null}}function nm(d,u){switch(d.type){case f.InputMap:return Lp(d,u);case f.VariableDeclaration:return Np(d,u);case f.VariableInstance:return sm(d,u);case f.ReturnDeclaration:return DA(d,u);default:return null}}function x0e(d){var u;if(d&&d.type===Ae.DefaultValue&&d.value&&d.valueOwner&&((u=d.valueOwner.defaultValue)==null?void 0:u.id)===d.value.id){const i=He(d.valueOwner.getDataType(null),d.valueOwner,d.valueOwner.project);return{type:Ae.DefaultValue,value:i,valueOwner:d.valueOwner,inheritanceLink:null}}return d}function Xo(d,u,i,a){let l=!1,p=null,t=null;a instanceof G?(l=!0,p=a,t=null):(p=null,t=a);const y=d.parent;return u.getVariableDeclarations().forEach(T=>{var A,V,N,j;const w=T.getDataType(null);if(((A=w==null?void 0:w.entity)==null?void 0:A.id)===y.id){let k=l?T.defaultValue:t==null?void 0:t.readValue(T.id);k?!l&&k&&k.id===((V=T.defaultValue)==null?void 0:V.id)&&(k=He(T.getDataType(null),T,u)):l?k=rn(T.getDataType(null),T,u,p):k=He(T.getDataType(null),T,u);const q=re(d,u),Y=kr(q);let ie={};((j=(N=T.dataType)==null?void 0:N.entity)==null?void 0:j.type)===f.DefinitionEntity&&(ie={...ie,...T.dataType.entity.getActiveRawDefaultValue()}),ir(k==null?void 0:k.value)&&(ie={...ie,...k.value}),ie[Y]=i,k==null||k.metaSync({value:ie},p),l||t==null||t.writeValue(T,k);return}}),p}function Bp(d,u,i,a){var N,j,k;let l=!1,p=null,t=null;a instanceof G?(l=!0,p=a,t=null):(p=null,t=a);const y=oi(d.parent),v=y.getDataType(null);if(!(v!=null&&v.isObject()))return p;let T=l?y.defaultValue:t==null?void 0:t.readValue(y.id);T?!l&&T&&T.id===((N=y.defaultValue)==null?void 0:N.id)&&(T=He(y.getDataType(null),y,u)):l?T=rn(y.getDataType(null),y,u,p):T=He(y.getDataType(null),y,u);const w=re(d,u),A=kr(w);let V={};if(((k=(j=y.dataType)==null?void 0:j.entity)==null?void 0:k.type)===f.DefinitionEntity&&(V={...V,...y.dataType.entity.getActiveRawDefaultValue()}),ir(T==null?void 0:T.value)&&(V={...V,...T==null?void 0:T.value}),V[A]=i,T==null||T.metaSync({value:V},p),l||t==null||t.writeValue(y,T),(i===""||i===null||i===void 0)&&d.type===f.OutputMap){const q=y.inputs.find(Y=>{var ie;return((ie=Y.declaration)==null?void 0:ie.id)===d.declaration.id||re(Y,u)===w});if(q){let Y=l?q.defaultValue:t==null?void 0:t.readValue(q.id);Y&&Y.metaSync({value:null},p),l||t==null||t.removeValue(q.id)}}return p}function Yx(d,u,i){var t,y,v,T;let a=!1,l=null,p=null;if(i instanceof G?(a=!0,l=i,p=null):(l=null,p=i),rt.includes(d.type)){const w=oi(d);(t=w.dataType)!=null&&t.isObject()&&w.inputs.forEach(A=>{var V,N,j,k;if(((V=A.declaration)==null?void 0:V.type)===f.Property&&A.declaration.static){let q=a?d.defaultValue:p==null?void 0:p.readValue(A.declaration.id);q?!a&&q&&q.id===((N=A.declaration.defaultValue)==null?void 0:N.id)&&(q=He(A.declaration.getDataType(null),A.declaration,u)):a?q=rn(A.declaration.getDataType(null),A.declaration,u,l):q=He(A.declaration.getDataType(null),A.declaration,u),q==null||q.metaSync({value:null},l),a||p==null||p.removeValue((j=A.declaration)==null?void 0:j.id)}else if(((k=A.declaration)==null?void 0:k.type)===f.Property){let q=a?d.defaultValue:p==null?void 0:p.readValue(A.id);q&&q.metaSync({value:null},l),a||p==null||p.removeValue(A.id)}})}else d.type===f.InputMap?((y=d.declaration)==null?void 0:y.type)===f.Property&&d.declaration.static?Xo(d.declaration,u,null,i):rt.includes(d.parent.type)&&((v=d.declaration)==null?void 0:v.type)===f.Property&&Bp(d,u,null,i):d.type===f.OutputMap?((T=d.declaration)==null?void 0:T.type)===f.Property&&d.declaration.static?Xo(d.declaration,u,null,i):rt.includes(d.parent.type)&&d.declaration.type===f.Property&&Bp(d,u,null,i):d.type===f.Property&&d.static&&Xo(d,u,null,i);return l}function Hx(d,u,i,a){var y,v,T,w,A,V;let l=!1,p=null,t=null;if(a instanceof G?(l=!0,p=a,t=null):(p=null,t=a),rt.includes(u.type)){const N=oi(u);if((y=N.dataType)!=null&&y.isObject()){let j={};((T=(v=N.dataType)==null?void 0:v.entity)==null?void 0:T.type)===f.DefinitionEntity&&(j={...j,...N.dataType.entity.getActiveRawDefaultValue()});const k=ir(d)?d:j;N.inputs.forEach(q=>{var Y,ie,te;if(((Y=q.declaration)==null?void 0:Y.type)===f.Property&&q.declaration.static){let pe=l?u.defaultValue:t==null?void 0:t.readValue(q.declaration.id);pe?!l&&pe&&pe.id===((ie=q.declaration.defaultValue)==null?void 0:ie.id)&&(pe=He(q.declaration.getDataType(null),q.declaration,i)):l?pe=rn(q.declaration.getDataType(null),q.declaration,i,p):pe=He(q.declaration.getDataType(null),q.declaration,i);const ne=re(q,i),me=kr(ne),J=k[me];pe==null||pe.metaSync({value:J},p),l||t==null||t.writeValue(q.declaration,pe)}else if(((te=q.declaration)==null?void 0:te.type)===f.Property){let pe=l?u.defaultValue:t==null?void 0:t.readValue(q.id);pe&&pe.metaSync({value:null},p),l||t==null||t.removeValue(q.id)}})}}else u.type===f.InputMap?((w=u.declaration)==null?void 0:w.type)===f.Property&&u.declaration.static?Xo(u.declaration,i,d,a):rt.includes(u.parent.type)&&((A=u.declaration)==null?void 0:A.type)===f.Property&&Bp(u,i,d,a):u.type===f.OutputMap?((V=u.declaration)==null?void 0:V.type)===f.Property&&u.declaration.static?Xo(u.declaration,i,null,a):rt.includes(u.parent.type)&&u.declaration.type===f.Property&&Bp(u,i,null,a):u.type===f.Property&&u.static&&Xo(u,i,d,a);return p}function zx(d,u,i){const a=sn(d,u);let l=!1,p=null,t=null;return i instanceof G?(l=!0,p=i,t=null):(p=null,t=i),a.forEach(y=>{var T;let v=l?y.defaultValue:t==null?void 0:t.readValue(y.id);v?!l&&v&&v.id===((T=y.defaultValue)==null?void 0:T.id)&&(v=He(d.getDataType(null),d,d.project)):l?v=rn(y.getDataType(null),y,u,p):v=He(y.getDataType(null),y,u),v==null||v.metaSync({value:null},p),l||t==null||t.removeValue(y.id),Yx(y,u,i)}),p}function F0e(d,u,i,a){if(d===""||d===null||d===void 0)return zx(u,i,a);const l=sn(u,i);let p=!1,t=null,y=null;return a instanceof G?(p=!0,t=a,y=null):(t=null,y=a),l.forEach(v=>{var w;let T=p?u.defaultValue:y==null?void 0:y.readValue(u.id);T?!p&&T&&T.id===((w=v.defaultValue)==null?void 0:w.id)&&(T=He(v.getDataType(null),v,i)):p?T=rn(v.getDataType(null),v,i,t):T=He(v.getDataType(null),v,i),T==null||T.metaSync({value:d},t),p||y==null||y.writeValue(v,T),Hx(d,v,i,a)}),t}function Qo(d,u,i,a){let l=!1,p=null,t=null;a instanceof G?(l=!0,p=a,t=null):(p=null,t=a);const y=d.parent;return u.getVariableDeclarations().forEach(T=>{var A,V,N,j;const w=T.getDataType(null);if(((A=w==null?void 0:w.entity)==null?void 0:A.id)===y.id){let k=l?T.defaultValue:t==null?void 0:t.readValue(T.id);k?!l&&k&&k.id===((V=T.defaultValue)==null?void 0:V.id)&&(k=He(T.getDataType(null),T,u)):l?k=rn(T.getDataType(null),T,u,p):k=He(T.getDataType(null),T,u);const q=re(d,u),Y=kr(q);let ie={};((j=(N=T.dataType)==null?void 0:N.entity)==null?void 0:j.type)===f.DefinitionEntity&&(ie={...ie,...T.dataType.entity.getActiveRawDefaultValue()}),ir(k==null?void 0:k.value)&&(ie={...ie,...k.value}),Array.isArray(i)?ie[Y]=(i==null?void 0:i.map(te=>te.toShallowJSON()))||null:ie[Y]=(i==null?void 0:i.toShallowJSON())||null,k==null||k.metaSync({value:ie},p),l||t==null||t.writeValue(T,k);return}}),p}function Mp(d,u,i,a){var N,j,k;let l=!1,p=null,t=null;a instanceof G?(l=!0,p=a,t=null):(p=null,t=a);const y=oi(d.parent),v=y.getDataType(null);if(!(v!=null&&v.isObject()))return p;let T=l?y.defaultValue:t==null?void 0:t.readValue(y.id);T?!l&&T&&T.id===((N=y.defaultValue)==null?void 0:N.id)&&(T=He(y.getDataType(null),y,u)):l?T=rn(y.getDataType(null),y,u,p):T=He(y.getDataType(null),y,u);const w=re(d,u),A=kr(w);let V={};if(((k=(j=y.dataType)==null?void 0:j.entity)==null?void 0:k.type)===f.DefinitionEntity&&(V={...V,...y.dataType.entity.getActiveRawDefaultValue()}),ir(T==null?void 0:T.value)&&(V={...V,...T.value}),Array.isArray(i)?V[A]=(i==null?void 0:i.map(q=>q.toShallowJSON()))||null:V[A]=(i==null?void 0:i.toShallowJSON())||null,T==null||T.metaSync({value:V},p),l||t==null||t.writeValue(y,T),i==null&&d.type===f.OutputMap){const q=y.inputs.find(Y=>{var ie;return((ie=Y.declaration)==null?void 0:ie.id)===d.declaration.id||re(Y,u)===w});if(q){let Y=l?q.defaultValue:t==null?void 0:t.readValue(q.id);Y&&(Array.isArray(i)?Y==null||Y.setValueAsTypeList(i,p):Y==null||Y.setValueAsTypeSingle(i,p)),l||t==null||t.removeValue(q.id)}}return p}function Xx(d,u,i){var a,l,p;return d.type===f.InputMap?((a=d.declaration)==null?void 0:a.type)===f.Property&&d.declaration.static?Qo(d.declaration,u,null,i):rt.includes(d.parent.type)&&((l=d.declaration)==null?void 0:l.type)===f.Property&&Mp(d,u,null,i):d.type===f.OutputMap?((p=d.declaration)==null?void 0:p.type)===f.Property&&d.declaration.static?Qo(d.declaration,u,null,i):rt.includes(d.parent.type)&&d.declaration.type===f.Property&&Mp(d,u,null,i):d.type===f.Property&&d.static&&Qo(d,u,null,i),i}function Qx(d,u,i,a){var l,p,t;return u.type===f.InputMap?((l=u.declaration)==null?void 0:l.type)===f.Property&&u.declaration.static?Qo(u.declaration,i,d,a):rt.includes(u.parent.type)&&((p=u.declaration)==null?void 0:p.type)===f.Property&&Mp(u,i,d,a):u.type===f.OutputMap?((t=u.declaration)==null?void 0:t.type)===f.Property&&u.declaration.static?Qo(u.declaration,i,null,a):rt.includes(u.parent.type)&&u.declaration.type===f.Property&&Mp(u,i,null,a):u.type===f.Property&&u.static&&Qo(u,i,d,a),a}function e5(d,u,i){const a=sn(d,u);let l=!1,p=null,t=null;return i instanceof G?(l=!0,p=i,t=null):(p=null,t=i),a.forEach(y=>{var T;let v=l?y.defaultValue:t==null?void 0:t.readValue(y.id);v?!l&&v&&v.id===((T=y.defaultValue)==null?void 0:T.id)&&(v=He(y.getDataType(null),y,y.project)):l?v=rn(y.getDataType(null),y,u,p):v=He(y.getDataType(null),y,u),v==null||v.setValueAsTypeSingle(null,p),v==null||v.setValueAsTypeList(null,p),l||t==null||t.removeValue(y.id),Xx(y,u,i)}),p}function G0e(d,u,i,a){if(d==null)return e5(u,i,a);const l=sn(u,i);let p=!1,t=null,y=null;return a instanceof G?(p=!0,t=a,y=null):(t=null,y=a),l.forEach(v=>{var w;let T=p?v.defaultValue:y==null?void 0:y.readValue(v.id);T?!p&&T&&T.id===((w=v.defaultValue)==null?void 0:w.id)&&(T=He(v.getDataType(null),v,v.project)):p?T=rn(v.getDataType(null),v,i,t):T=He(v.getDataType(null),v,i),Array.isArray(d)?T==null||T.setValueAsTypeList(d,t):T==null||T.setValueAsTypeSingle(d,t),p||y==null||y.writeValue(v,T),Qx(d,v,i,a)}),t}function t5(d,u){return _j(d).map(a=>eo(a,u))}function K0e(d,u){return d.reduce((a,l)=>{const p=t5(l,u);return[...a,...p.filter(t=>(t==null?void 0:t.type)===Ae.Missing)]},[])}const el={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var PA=(d=>(d.FinishedSuccess="finished-success",d.FinishedError="finished-error",d.Running="running",d.Paused="paused",d.Stopped="stopped",d.NotStarted="not-started",d))(PA||{});const ms=class ms extends wA{constructor(i,a,l,p=null){super();D(this,"project");D(this,"entryPoint");D(this,"state","not-started");D(this,"events",new wA);D(this,"entities",[]);D(this,"parentExecution",null);D(this,"executing",[]);D(this,"executed",[]);D(this,"skipped",[]);D(this,"localTestValues");D(this,"resolvedValues");D(this,"persistedExecutionResults");D(this,"lastExecutionResults");D(this,"onAddToSkippedListCallback",null);D(this,"onRemoveFromSkippedListCallback",null);D(this,"onAddEntityCallback",null);D(this,"onRemoveEntityCallback",null);this.entities=a,this.entryPoint=l,this.project=i,this.parentExecution=p,this.localTestValues=new Pp(P.UUID.uuid(),this.project),this.resolvedValues=new Pp(P.UUID.uuid(),this.project),this.persistedExecutionResults=new Pp(P.UUID.uuid(),this.project),this.lastExecutionResults=new Pp(P.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults}}static injectSearchImplementation(i){ms.searchImplementation=i}mergeExernalValuesWithInternalInputs(i,a){const l=[];return[...Xt,...Wt].includes(a.type)?l.push(...a.inputs):rr.includes(a.type)&&l.push(...a.outputs),l.map(t=>{var v;let y=i.find(T=>T.valueOwner.id===t.id);if(y)return y;if(!y&&Wt.includes(a.type)&&(y=i.find(T=>{var w;return((w=T.valueOwner.declaration)==null?void 0:w.id)===t.id})),y){const T=(v=y.value)==null?void 0:v.clone(null);return T==null||T.setStandaloneParent(t),{...y,valueOwner:t,value:T||null,inheritanceLink:{sources:[y],target:t}}}return Jn.includes(t.type)?nm(t,this.valueResolutionContext):eo(t,this.valueResolutionContext)}).reduce((t,y)=>{const v=sn(y==null?void 0:y.valueOwner,this.project),T=y?[y]:[];return v.forEach(w=>{var N,j,k;if(w.id===(y==null?void 0:y.valueOwner.id))return;const A=He(w.getDataType(null),w,this.project);A==null||A.metaSync({value:(N=y==null?void 0:y.value)==null?void 0:N.value},null),A==null||A.setValueAsTypeList(((j=y==null?void 0:y.value)==null?void 0:j.valueAsTypeList)||null),A==null||A.setValueAsTypeSingle(((k=y==null?void 0:y.value)==null?void 0:k.valueAsTypeSingle)||null);const V={...y,valueOwner:w,value:A};T.push(V)}),[...t,...T]},[])}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}static async executeOperation(i,a,l){var p,t;try{let y={value:Ze.Success,error:null,results:[]};a.sort((w,A)=>w.valueOwner.index-A.valueOwner.index),i.declaration.implementation&&(y=await i.declaration.implementation(...a.map(w=>{var A,V;return((A=w==null?void 0:w.value)==null?void 0:A.valueAsType)||((V=w==null?void 0:w.value)==null?void 0:V.value)})));const v=i.outputs.map((w,A)=>{const V=w==null?void 0:w.getDataType(null),N=He(V,w,l);return V!=null&&V.asType?N==null||N.setValueAsTypeSingle(y.results[A]):N==null||N.metaSync({value:y.results[A]},null),{valueOwner:w,type:Ae.ExecutionResult,inheritanceLink:null,value:N}});let T=null;if(y.error&&i.error){console.warn("Raw error executing entity: ",y.error);const w=((p=i.error)==null?void 0:p.getDataType(null))||null,A=He(w,i.error,l);w!=null&&w.asType?A==null||A.setValueAsTypeSingle(y.error):A==null||A.metaSync({value:y.error},null),T={valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A}}return{value:y.value,entity:i,error:T,results:v}}catch(y){console.warn("Operation execution error: ",y);let v=null;if(i.error){const T=(t=i.error)==null?void 0:t.getDataType(null),w=He(T,i.error,l);T!=null&&T.asType?w==null||w.setValueAsTypeSingle(y):w==null||w.metaSync({value:y},null),v={valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:w}}return{value:Ze.Error,entity:i,error:v,results:[]}}}async executeSearch(i,a,l){var p;console.log("executeSearch");try{let t={value:Ze.Success,error:null,results:[]};const y=i.outputs[0];if(!y)return{value:Ze.Success,entity:i,error:null,results:[]};let v={value:null,valueOwner:y,type:Ae.ExecutionResult,inheritanceLink:null};const T=await ms.searchImplementation(i,a),w=y==null?void 0:y.getDataType(null),A=He(w,y,l);return A==null||A.metaSync({value:T.data},null),v.value=A,{value:t.value,entity:i,error:null,results:[v]}}catch(t){if(console.warn(`Search node execution error: ${t}`),!i.error)return{value:Ze.Error,entity:i,error:null,results:[]};const y=(p=i.error)==null?void 0:p.getDataType(null),v=He(y,i.error,l);return v==null||v.metaSync({value:t},null),{value:Ze.Error,entity:i,error:{valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:v},results:[]}}}async executeLoop(i,a,l,p={}){var y,v;const t={...el,...p};try{let T={value:Ze.Success,error:null,results:[]};const w=a.map(q=>{var Y,ie;return((Y=q==null?void 0:q.value)==null?void 0:Y.valueAsType)||((ie=q==null?void 0:q.value)==null?void 0:ie.value)});let A={};i.getUniqueReturnDeclarations().forEach(q=>{const Y=i.body.inputs.find(ne=>re(ne,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(q)),ie=q==null?void 0:q.getDataType(null),te=He(ie,Y,l);ie!=null&&ie.asType?te==null||te.setValueAsTypeList([]):te==null||te.metaSync({value:[]},null),this.lastExecutionResults.writeValue(Y,te);const pe={value:te,valueOwner:Y,type:Ae.ExecutionResult,inheritanceLink:null};A[Y.id]=pe});let N={value:Ze.Success,entity:i.body,error:null,results:[]};switch(console.log("aggregateListResults: ",A),i.declaration.id){case Ee.loop["counted-loop"].id:{const q=w[0];console.log("maxCount",q);let Y=1;for(console.log("currentIteration",Y);Y<=q&&Y<=50;){console.log("iterating",Y);const ie=i.body.inputs.map(pe=>{if(pe===i.currentIterationNumberArgumentDeclaration){console.log("Argument is body iteration number");const ne=i.currentIterationNumberArgumentDeclaration.getDataType(null),me=Zo(ne),J=this.lastExecutionResults.readValue(pe.id);if(J){J.metaSync({value:Y},null),console.log("existingValue",Y),this.lastExecutionResults.writeValue(pe,J);const de={value:J,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null};return A[pe.id]=de,de}const ae={id:P.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:P.UUID.uuid(),createdAt:new Date().toISOString(),author:P.sessionAuthor,deleted:!1,previousVersion:null,value:Y,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:me,standaloneParent:pe.toReference()},ce=Kt(ae,l);this.lastExecutionResults.writeValue(pe,ce);const H={value:ce,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null};return console.log("newDynamicValue",Y),A[pe.id]=H,H}else return A[pe.id]}).filter(pe=>!!pe);console.log("Loop executes body with inputs: ",ie);const te=await this.executeFullFunctionDeclarationLogic(i.body,ie,t);if(N=te,N.results.forEach(pe=>{var ae,ce,H,de;if(pe.valueOwner.type!==f.ReturnDeclaration)return;const ne=i.body.inputs.find(ve=>re(ve,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(pe.valueOwner)),J=[...((ce=(ae=A==null?void 0:A[ne.id])==null?void 0:ae.value)==null?void 0:ce.value)||[],((H=pe==null?void 0:pe.value)==null?void 0:H.value)||null];(de=A[ne.id].value)==null||de.metaSync({value:J},null),this.lastExecutionResults.writeValue(ne,A[ne.id].value)}),[Ze.Error,Ze.Break,Ze.Return].includes(te.value))break;console.log("Loop iteration finished"),Y++}break}case Ee.loop["manual-flow-loop"].id:{let q=1;for(;q<=50;){const Y=i.body.inputs.map(te=>{if(te===i.currentIterationNumberArgumentDeclaration){const pe=this.lastExecutionResults.readValue(te.id);if(pe){pe.metaSync({value:q},null),this.lastExecutionResults.writeValue(te,pe);const ae={value:pe,valueOwner:te,type:Ae.ExecutionResult,inheritanceLink:null};return A[te.id]=ae,ae}const ne=i.currentIterationNumberArgumentDeclaration.getDataType(null),me=He(ne,te,l);me==null||me.metaSync({value:q},null),this.lastExecutionResults.writeValue(te,me);const J={value:me,valueOwner:te,type:Ae.ExecutionResult,inheritanceLink:null};return console.log("newDynamicValue",q),J}else return A[te.id]}).filter(te=>!!te);console.log("Loop executes body");const ie=await this.executeFullFunctionDeclarationLogic(i.body,Y,t);if(N=ie,N.results.forEach(te=>{var J,ae,ce;if(te.valueOwner.type!==f.ReturnDeclaration)return;const pe=i.body.inputs.find(H=>re(H,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(te.valueOwner)),me=[...(J=A[pe.id].value)==null?void 0:J.value,((ae=te.value)==null?void 0:ae.value)||null];(ce=A[pe.id].value)==null||ce.metaSync({value:me},null),this.lastExecutionResults.writeValue(pe,A[pe.id].value)}),[Ze.Error,Ze.Break,Ze.Return].includes(ie.value))break;q++}break}case Ee.loop["list-loop"].id:{const q=w[0];let Y=1;const ie=q;for(let te=0;te<ie.length;te++){const pe=ie[te],ne=i.body.inputs.map(J=>{if(J===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(J.id);if(ae)return ae.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,ae),{value:ae,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=He(ce,J,l);return H==null||H.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(J===i.currentValueArgumentDeclaration){const ae=i.currentValueArgumentDeclaration.getDataType(null),ce=Zo(ae),H=this.lastExecutionResults.readValue(J.id);if(H)return H.metaSync({value:pe},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const de={id:P.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:P.UUID.uuid(),createdAt:new Date().toISOString(),author:P.sessionAuthor,deleted:!1,previousVersion:null,value:pe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:J.toReference()},ve=Kt(de,l);return this.lastExecutionResults.writeValue(J,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[J.id]}).filter(J=>!!J);console.log("Loop executes body");const me=await this.executeFullFunctionDeclarationLogic(i.body,ne,t);if(N=me,N.results.forEach(J=>{var de,ve,Pe;if(J.valueOwner.type!==f.ReturnDeclaration)return;const ae=i.body.inputs.find(Oe=>re(Oe,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(J.valueOwner)),H=[...(de=A[ae.id].value)==null?void 0:de.value,((ve=J.value)==null?void 0:ve.value)||null];(Pe=A[ae.id].value)==null||Pe.metaSync({value:H},null),this.lastExecutionResults.writeValue(ae,A[ae.id].value)}),[Ze.Error,Ze.Break,Ze.Return].includes(me.value))break;Y++}break}case Ee.loop["object-keys-loop"].id:{const q=w[0];let Y=1;const ie=q?Object.keys(q):[];console.log("iterableListOfValues: ",ie);for(let te=0;te<ie.length;te++){const pe=ie[te],ne=i.body.inputs.map(J=>{if(J===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(J.id);if(ae)return ae.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,ae),{value:ae,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=He(ce,J,l);return H==null||H.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(J===i.currentValueArgumentDeclaration){const ae=i.currentValueArgumentDeclaration.getDataType(null),ce=Zo(ae),H=this.lastExecutionResults.readValue(J.id);if(H)return H.metaSync({value:pe},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const de={id:P.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:P.UUID.uuid(),createdAt:new Date().toISOString(),author:P.sessionAuthor,deleted:!1,previousVersion:null,value:pe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:J.toReference()},ve=Kt(de,l);return this.lastExecutionResults.writeValue(J,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[J.id]}).filter(J=>!!J);console.log("Loop executes body");const me=await this.executeFullFunctionDeclarationLogic(i.body,ne,t);if(N=me,N.results.forEach(J=>{var de,ve,Pe;if(J.valueOwner.type!==f.ReturnDeclaration)return;const ae=i.body.inputs.find(Oe=>re(Oe,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(J.valueOwner)),H=[...(de=A[ae.id].value)==null?void 0:de.value,((ve=J.value)==null?void 0:ve.value)||null];(Pe=A[ae.id].value)==null||Pe.metaSync({value:H},null),this.lastExecutionResults.writeValue(ae,A[ae.id].value)}),[Ze.Error,Ze.Break,Ze.Return].includes(me.value))break;Y++}break}case Ee.loop["object-values-loop"].id:{const q=w[0];let Y=1;const ie=q?Object.values(q):[];for(let te=0;te<ie.length;te++){const pe=ie[te],ne=i.body.inputs.map(J=>{if(J===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(J.id);if(ae)return ae.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,ae),{value:ae,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=He(ce,J,l);return H==null||H.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(J===i.currentValueArgumentDeclaration){const ae=i.currentValueArgumentDeclaration.getDataType(null),ce=Zo(ae),H=this.lastExecutionResults.readValue(J.id);if(H)return H.metaSync({value:pe},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const de={id:P.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:P.UUID.uuid(),createdAt:new Date().toISOString(),author:P.sessionAuthor,deleted:!1,previousVersion:null,value:pe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:J.toReference()},ve=Kt(de,l);return this.lastExecutionResults.writeValue(J,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[J.id]}).filter(J=>!!J);console.log("Loop executes body"),console.log("HEREEE Object.values() resolvedBodyInputsForCurrentIteration",ne);const me=await this.executeFullFunctionDeclarationLogic(i.body,ne,t);if(N=me,N.results.forEach(J=>{var de,ve,Pe;if(J.valueOwner.type!==f.ReturnDeclaration)return;const ae=i.body.inputs.find(Oe=>re(Oe,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(J.valueOwner)),H=[...(de=A[ae.id].value)==null?void 0:de.value,((ve=J.value)==null?void 0:ve.value)||null];(Pe=A[ae.id].value)==null||Pe.metaSync({value:H},null),this.lastExecutionResults.writeValue(ae,A[ae.id].value)}),[Ze.Error,Ze.Break,Ze.Return].includes(me.value))break;Y++}break}case Ee.loop["string-loop"].id:{const q=w[0];let Y=1;const ie=q.split("");for(let te=0;te<ie.length;te++){const pe=ie[te],ne=i.body.inputs.map(J=>{if(J===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(J.id);if(ae)return ae.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,ae),{value:ae,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=He(ce,J,l);return H==null||H.metaSync({value:Y},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else if(J===i.currentValueArgumentDeclaration){const ae=i.currentValueArgumentDeclaration.getDataType(null),ce=Zo(ae),H=this.lastExecutionResults.readValue(J.id);if(H)return H.metaSync({value:pe},null),this.lastExecutionResults.writeValue(J,H),{value:H,valueOwner:J,type:Ae.ExecutionResult,inheritanceLink:null};const de={id:P.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:P.UUID.uuid(),createdAt:new Date().toISOString(),author:P.sessionAuthor,deleted:!1,previousVersion:null,value:pe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:J.toReference()},ve=Kt(de,l);return this.lastExecutionResults.writeValue(J,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Ae.ExecutionResult,inheritanceLink:null}}else return A[J.id]}).filter(J=>!!J);console.log("Loop executes body");const me=await this.executeFullFunctionDeclarationLogic(i.body,ne,t);if(N=me,N.results.forEach(J=>{var de,ve,Pe;if(J.valueOwner.type!==f.ReturnDeclaration)return;const ae=i.body.inputs.find(Oe=>re(Oe,l)===Ai.fromReturnDeclarationToBodyArgumentDeclarationName(J.valueOwner)),H=[...(de=A[ae.id].value)==null?void 0:de.value,((ve=J.value)==null?void 0:ve.value)||null];(Pe=A[ae.id].value)==null||Pe.metaSync({value:H},null),this.lastExecutionResults.writeValue(ae,A[ae.id].value)}),[Ze.Error,Ze.Break,Ze.Return].includes(me.value))break;Y++}break}}let j=[];i.body.inputs.forEach(q=>{var ie;const Y=A[q.id];if(Y){const te=(ie=Y.value)==null?void 0:ie.clone(null),pe=i.outputs.find(ne=>ne.declaration&&Ai.fromLoopOutputDeclarationToBodyArgumentDeclarationName(ne.declaration)===re(q,l));if(!pe)return;j.push({valueOwner:pe,type:Ae.ExecutionResult,inheritanceLink:null,value:te})}}),T={value:[Ze.Error,Ze.Return].includes(N.value)?N.value:Ze.Success,error:null,results:j};let k=null;if(T.error&&i.error){console.warn("Raw error executing entity: ",T.error);const q=(y=i.error)==null?void 0:y.getDataType(null),Y=He(q||null,i.error,l);q!=null&&q.asType?Y==null||Y.setValueAsTypeSingle(T.error):Y==null||Y.metaSync({value:T.error},null),k={valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:Y}}return{value:T.value,entity:i,error:k,results:T.results}}catch(T){if(console.warn("Error executing loop: ",T),i.error){const w=(v=i.error)==null?void 0:v.getDataType(null),A=He(w,i.error,l);return w!=null&&w.asType?A==null||A.setValueAsTypeSingle(T):A==null||A.metaSync({value:T},null),{value:Ze.Error,entity:i,error:{valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A},results:[]}}else return{value:Ze.Error,entity:i,error:null,results:[]}}}async executeFunctionCall(i,a,l,p={}){var y,v;const t={...el,...p};try{let T={value:Ze.Success,error:null,results:[]};console.log("executeFunctionCall",a),T=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,a,l,t);const w=i.outputs.map(V=>{var Y,ie,te,pe;const N=[...V.declaration.getCounterparts(),V.declaration];console.log("declarations",N);const j=T.results.find(ne=>N.some(J=>ne.valueOwner.id===J.id));console.log("resultValue",j);const k=V==null?void 0:V.getDataType(null),q=He(k,V,l);return k!=null&&k.asType?Array.isArray((Y=j==null?void 0:j.value)==null?void 0:Y.valueAsType)?q==null||q.setValueAsTypeList((ie=j==null?void 0:j.value)==null?void 0:ie.valueAsTypeList):q==null||q.setValueAsTypeSingle(((te=j==null?void 0:j.value)==null?void 0:te.valueAsType)||null):q==null||q.metaSync({value:(pe=j==null?void 0:j.value)==null?void 0:pe.value},null),{valueOwner:V,type:Ae.ExecutionResult,inheritanceLink:null,value:q}});let A=null;if(T.error&&i.error){console.warn("Raw error executing entity: ",T.error);const V=(y=i.error)==null?void 0:y.getDataType(null),N=He(V||null,i.error,l);V!=null&&V.asType?N==null||N.setValueAsTypeSingle(T.error):N==null||N.metaSync({value:T.error},null),A={valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:N}}return{value:T.value,entity:i,error:A,results:w}}catch(T){if(console.log("error: ",T),!i.error)return{value:Ze.Error,entity:i,error:null,results:[]};const w=(v=i.error)==null?void 0:v.getDataType(null),A=He(w,i.error,l);return w!=null&&w.asType?A==null||A.setValueAsTypeSingle(T):A==null||A.metaSync({value:T},null),{value:Ze.Error,entity:i,error:{valueOwner:i.error,type:Ae.ExecutionResult,inheritanceLink:null,value:A},results:[]}}}static async executeCondition(i,a){var p,t,y,v,T,w,A,V,N,j,k,q,Y,ie,te,pe,ne,me,J,ae,ce,H,de,ve,Pe,Oe,Ie,_e,Me,Ce,ze,at,St,sr,Tr,Nr;let l=!1;switch(i.declaration.id){case Ki.Empty:{l=!!((t=(p=a[0])==null?void 0:p.value)!=null&&t.value);break}case Ki.NotEmpty:{l=!((v=(y=a[0])==null?void 0:y.value)!=null&&v.value);break}case lr.Equal:{if([X.String,X.Number,X.Boolean,X.Null,X.Enum,X.Date,X.UUID].includes((w=(T=a[0])==null?void 0:T.value)==null?void 0:w.name)){l=((V=(A=a[0])==null?void 0:A.value)==null?void 0:V.value)===((j=(N=a[1])==null?void 0:N.value)==null?void 0:j.value);break}if(((q=(k=a[0])==null?void 0:k.value)==null?void 0:q.name)===X.KeyValue||((ie=(Y=a[0])==null?void 0:Y.value)==null?void 0:ie.name)===X.Untyped){const Ur=(pe=(te=a[0])==null?void 0:te.value)==null?void 0:pe.value,Bi=(me=(ne=a[1])==null?void 0:ne.value)==null?void 0:me.value;l=JSON.stringify(Ur)===JSON.stringify(Bi);break}break}case lr.NotEqual:{if([X.String,X.Number,X.Boolean,X.Null,X.Enum,X.Date,X.UUID].includes((ae=(J=a[0])==null?void 0:J.value)==null?void 0:ae.name)){l=((H=(ce=a[0])==null?void 0:ce.value)==null?void 0:H.value)!==((ve=(de=a[1])==null?void 0:de.value)==null?void 0:ve.value);break}if(((Oe=(Pe=a[0])==null?void 0:Pe.value)==null?void 0:Oe.name)===X.Untyped||((_e=(Ie=a[0])==null?void 0:Ie.value)==null?void 0:_e.name)===X.KeyValue){const Ur=(Ce=(Me=a[0])==null?void 0:Me.value)==null?void 0:Ce.value,Bi=(at=(ze=a[1])==null?void 0:ze.value)==null?void 0:at.value;l=JSON.stringify(Ur)!==JSON.stringify(Bi);break}break}case lr.MoreThanOrEqual:{l=((sr=(St=a[0])==null?void 0:St.value)==null?void 0:sr.value)>=((Nr=(Tr=a[1])==null?void 0:Tr.value)==null?void 0:Nr.value);break}}return{value:l?Ze.Success:Ze.Error,entity:i,error:null,results:[]}}async executeDetachedFullFunctionDeclarationLogic(i,a,l,p={}){const t={...el,...p,onBeforeEntityExecution:(T,w,A)=>{var V;return((V=p==null?void 0:p.onBeforeEntityExecution)==null?void 0:V.call(p,T,w,{...A,detached:!0}))||Promise.resolve()},onEntityExecuted:(T,w,A)=>{var V;return((V=p==null?void 0:p.onEntityExecuted)==null?void 0:V.call(p,T,w,{...A,detached:!0}))||Promise.resolve()}},y=new ms(l,[i,...Jy(i)],i,this);y.inheritValuesFromContext(this),console.log("functionBodyExecution",a);const v=await y.execute(t,a);return console.log("executeDetachedFullFunctionDeclarationLogic result: ",v),v}async executeFullFunctionDeclarationLogic(i,a,l={}){const p={...el,...l},t=Jy(i);t.forEach(A=>{this.addEntity(A)}),t.reduce((A,V)=>rr.includes(V.type)?[...A,...V.outputs]:Xt.includes(V.type)&&V.type!==f.Condition?[...A,...V.outputs,...V.inputs]:V.type===f.Condition?[...A,...V.inputs]:A,[]).forEach(A=>{this.lastExecutionResults.removeValue(A.id)});const v=await this.executeBranch(i,p,a),w=i.getUniqueReturnDeclarations().reduce((A,V)=>{const N=v==null?void 0:v.results.find(j=>j.valueOwner.id===V.id);return N?[...A,N]:A},[]);return{...v,results:w}}static async executeEntryPointEntity(i,a){return{value:Ze.Success,entity:i,error:null,results:a}}static async executeVariable(i,a){return{value:Ze.Success,entity:i,error:null,results:[a]}}static async executeReturnStatement(i,a){return{value:i.throws?Ze.Error:Ze.Return,entity:i,error:null,results:a}}static async executeContinueStatement(i,a){return{value:Ze.Continue,entity:i,error:null,results:a}}static async executeBreakStatement(i,a){return{value:Ze.Break,entity:i,error:null,results:a}}mergeValues(i,a){const l=[];for(let p=0;p<a.length;p++)i!=null&&i[p]?l.push(i[p]):l.push(a[p]);return l}async executeEntity(i,a=[],l={}){var y,v,T,w,A,V,N,j,k,q,Y,ie,te,pe,ne,me;const p={...el,...l},t={detached:!1};switch(console.log("Executing entity: ",i),console.log("Exec ent with inputs: ",a),i.type){case f.Condition:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((y=p.onBeforeEntityExecution)==null?void 0:y.call(p,i,J,t)),ms.executeCondition(i,J)}case f.Operation:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((v=p.onBeforeEntityExecution)==null?void 0:v.call(p,i,J,t)),ms.executeOperation(i,J,this.project)}case f.VariableInstance:case f.VariableDeclaration:{i.id==="ad7eae6d-c691-40a5-943b-f72008cdc3b0"&&console.log("Execute variable declaration resolveNextValue");let J=nm(i,this.valueResolutionContext);const ae=oi(i),ce=ae.getDataType(null);if(ce!=null&&ce.isObject()){let ve={};if(((T=ce==null?void 0:ce.entity)==null?void 0:T.type)===f.DefinitionEntity&&(ve={...ve,...ce.entity.getActiveRawDefaultValue()}),J!=null&&J.value)ir((w=J==null?void 0:J.value)==null?void 0:w.value)&&(ve={...ve,...(A=J==null?void 0:J.value)==null?void 0:A.value}),J==null||J.value.metaSync({value:ve},null);else{const Pe=He(ce,i,this.project);Pe==null||Pe.metaSync({value:ve},null),J={valueOwner:ae,type:Ae.ExecutionResult,inheritanceLink:null,value:Pe}}this.lastExecutionResults.writeValue(ae,J.value),console.log("Propagating value to inputs: ",ae.inputs.map(Pe=>re(Pe,this.project))),ae.inputs.forEach(Pe=>{var Oe;if(((Oe=Pe.declaration)==null?void 0:Oe.type)===f.Property&&Pe.declaration.static){const Ie=this.lastExecutionResults.readValue(Pe.declaration.id),_e=re(Pe,this.project),Me=kr(_e);if(Ie)Ie.metaSync({value:ve[Me]},null),this.lastExecutionResults.writeValue(Pe.declaration,Ie);else{const Ce=He(Pe.getDataType(null),Pe,this.project);Ce==null||Ce.metaSync({value:ve[Me]},null),console.log(`Created new value for static property ${_e}: `,ve[Me]),this.lastExecutionResults.writeValue(Pe.declaration,Ce)}}})}else this.lastExecutionResults.writeValue(ae,J==null?void 0:J.value);const H=[],de=(V=J==null?void 0:J.value)!=null&&V.value&&ir((N=J.value)==null?void 0:N.value)?((j=J.value)==null?void 0:j.value)||{}:{};return i.outputs.map(ve=>{const Pe=kr(re(ve,this.project)),Oe=de[Pe],Ie=He(ve.getDataType(null),ve,this.project);Ie==null||Ie.metaSync({value:Oe},null);const _e={value:Ie,valueOwner:ve,type:Ae.ExecutionResult,inheritanceLink:J?{sources:[J],target:i}:null};H.push(_e)}),J.type=Ae.ExecutionResult,{value:Ze.Success,entity:i,error:null,results:[J,...H]}}case f.FunctionCall:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((k=p.onBeforeEntityExecution)==null?void 0:k.call(p,i,J,t)),this.executeFunctionCall(i,J,this.project)}case f.FunctionDeclaration:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((q=p.onBeforeEntityExecution)==null?void 0:q.call(p,i,J,t)),ms.executeEntryPointEntity(i,J)}case f.Search:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((Y=p.onBeforeEntityExecution)==null?void 0:Y.call(p,i,J,t)),this.executeSearch(i,J,this.project)}case f.Loop:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((ie=p.onBeforeEntityExecution)==null?void 0:ie.call(p,i,J,t)),this.executeLoop(i,J,this.project,p)}case f.ReturnStatement:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((te=p.onBeforeEntityExecution)==null?void 0:te.call(p,i,J,t)),ms.executeReturnStatement(i,J)}case f.ContinueStatement:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((pe=p.onBeforeEntityExecution)==null?void 0:pe.call(p,i,J,t)),ms.executeContinueStatement(i,J)}case f.BreakStatement:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((ne=p.onBeforeEntityExecution)==null?void 0:ne.call(p,i,J,t)),ms.executeBreakStatement(i,J)}case f.GlobalEvent:{const J=this.mergeExernalValuesWithInternalInputs(a,i);return await((me=p.onBeforeEntityExecution)==null?void 0:me.call(p,i,J,t)),ms.executeEntryPointEntity(i,J)}default:return{value:Ze.Error,entity:i,error:null,results:[]}}}storeLastExecutionValues(i){i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),console.log("result.results: ",i.results),i.results.forEach(a=>{const l=sn(a.valueOwner,this.project);a.value?l.forEach(p=>{this.lastExecutionResults.writeValue(p,a.value)}):l.forEach(p=>{this.lastExecutionResults.removeValue(p.id)})})}async executeBranch(i,a={},l=[]){var T;const p={...el,...a},t={detached:!1};if(console.log("executeBranch: ",l),!this.hasEntity(i))return console.log("Skipping entity (not part of test): ",i),null;this.addToExecutingList(i),console.log("Executing branch: ",i);const v=await this.executeEntity(i,l,p);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(v),await((T=p.onEntityExecuted)==null?void 0:T.call(p,i,v,t)),v.value===Ze.Success){const w=(i.successCalls||i.calls||[]).filter(N=>this.hasEntity(N));(i.errorCalls||[]).filter(N=>this.hasEntity(N)).forEach(N=>{this.addToSkippedList(N)});const V=cA(zr(w));for(let N=0;N<V.length;N++){const j=V[N];let k=[];const q=await Promise.all(j.map(ie=>this.executeBranch(ie,p,v.results))),Y=q.find(ie=>ie.value===Ze.Error||ie.value===Ze.Return||ie.value===Ze.Break||ie.value===Ze.Continue);if(Y)return Y;k=[...k,...q]}return v}else if(v.value===Ze.Error){const w=(i.errorCalls||[]).filter(j=>this.hasEntity(j));(i.successCalls||i.calls||[]).filter(j=>this.hasEntity(j)).forEach(j=>{this.addToSkippedList(j)});const V=cA(zr(w));let N=[];for(let j=0;j<V.length;j++){const k=V[j],q=await Promise.all(k.map(ie=>this.executeBranch(ie,p,v.results))),Y=q.find(ie=>ie.value===Ze.Error||ie.value===Ze.Return||ie.value===Ze.Break||ie.value===Ze.Continue);if(Y)return Y;N=[...N,...q]}return v}else{if(v.value===Ze.Return)return v;if(v.value===Ze.Break)return v;if(v.value===Ze.Continue)return v}return v}async execute(i={},a=[]){const l={...el,...i};this.state="running";const p=await this.executeBranch(this.entryPoint,l,a);return this.state="finished-success",p}addEntity(i){var a;this.entities.includes(i)||(this.entities.push(i),(a=this.onAddEntityCallback)==null||a.call(this,i))}addEntities(i){i.forEach(a=>this.addEntity(a))}removeEntity(i){var a;if(i!==this.entryPoint){const l=this.entities.indexOf(i);l>-1&&(this.entities.splice(l,1),(a=this.onRemoveEntityCallback)==null||a.call(this,i))}}hasEntity(i){if(this.entities.includes(i))return!0;const a=ur(i);if(!a)return!1;const l=a.type===f.Loop&&i.parent===a.body?a.body:null;return l?this.entities.includes(l)||this.entities.includes(a):this.entities.includes(a)}hasEntityWithId(i){const a=this.project.get(i);return a?this.hasEntity(a):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}removeFromExecutingList(i){const a=this.executing.indexOf(i);a>-1&&this.executing.splice(a,1)}removeFromAlreadyExecutedList(i){const a=this.executed.indexOf(i);a>-1&&this.executed.splice(a,1)}removeFromSkippedList(i){var l;const a=this.skipped.indexOf(i);a>-1&&(this.skipped.splice(a,1),(l=this.onRemoveFromSkippedListCallback)==null||l.call(this,i))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var a;this.skipped.includes(i)||(this.skipped.push(i),(a=this.onAddToSkippedListCallback)==null||a.call(this,i))}};D(ms,"searchImplementation",async()=>({data:null,error:"Search module not implemented"}));let VA=ms;function k0e(d){var u,i;if(d.isList)return"list";if(((u=d.entity)==null?void 0:u.type)===f.DefinitionEntity)return"definition-entity";switch((i=d.entity)==null?void 0:i.name){case X.Number:return"number";case X.String:return"text";case X.Boolean:return"boolean";case X.UUID:return"uuid";case X.Date:return"date-time";default:return"definition-entity"}}const NA={[f.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[f.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[f.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[f.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[f.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[f.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[f.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[f.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[f.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[f.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[f.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[f.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[f.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[f.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[f.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[f.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[f.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[f.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[f.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[f.ReturnDeclaration]:{singular:"Output definition",plural:"Output definitions",shortSingular:"Output",shortPlural:"Outputs"},[f.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"}};function LA(d){const u=Wy(d);if(!u){const a=gd(d);if(a.includes($e.HTTP_ENDPOINT))return"HTTP endpoint";if(a.includes($e.PERSISTED_ENTITY))return"Persisted entity";if(a.includes($e.CRON_JOB))return"Scheduled execution";if(a.includes($e.RELATIONAL_DATABASE))return"Relational database"}if(u){let a="Extension of "+re(u,u.project)+" entity",l=fd(a);const p=gd(d);return p.includes($e.HTTP_ENDPOINT)?"HTTP endpoint"+(l?", "+l:""):p.includes($e.PERSISTED_ENTITY)?"Persisted entity"+(l?", "+l:""):p.includes($e.CRON_JOB)?"Scheduled execution"+(l?", "+l:""):p.includes($e.RELATIONAL_DATABASE)?"Relational database"+(l?", "+l:""):a}let i="";return d.abstract&&(i="Template "),d.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function r5(d){return d.parent.type===f.DefinitionEntity||d.parent.type===f.InstalledProject?"Internal action of "+re(d.parent,d.project):d.parent.type===f.Loop?"Action repeated on every iteration":"Internal action of entity"}function BA(d){return TA(d)?r5(d):"Custom trigger"}function q0e(d){var u;switch(d.type){case f.DefinitionEntity:return LA(d);case f.FunctionDeclaration:return BA(d)}return(u=NA[d.type])==null?void 0:u.singular}function S0e(d){var u;switch(d.type){case f.DefinitionEntity:return LA(d);case f.FunctionDeclaration:return BA(d)}return(u=NA[d.type])==null?void 0:u.singular}const MA=4e4,i5=280,Z0e=300,UA=65,Cd=32,am=39,s5=26,n5=49,om=44,J0e=35,lm=52,jA=10,va=jA*2,dm=38,um=90,xA=270,a5=MA/2+120,o5=MA/2+180;function l5(d){let i=Cd+om+dm+jA;const a=[...d.inputs];return a.length&&(i+=va,a.forEach(()=>{i+=s5})),{height:i,width:280}}function d5(d){let i=UA;const a=[];if([f.DefinitionEntity].includes(d.type)){const v=[...d.suggestedProperties||[],...d.properties||[]];v.length&&(i+=va,v.forEach(T=>{i+=T.static?n5:am}))}if([f.DefinitionEntity,f.InstalledProject,f.Loop].includes(d.type)){const v=[...(d==null?void 0:d.suggestedMethods)||[],...d.methods||[],...d.functions||[],...d.body?[d.body]:[]];v.length&&(i+=va,v.forEach(T=>{const w=l5(T);i+=w.height}))}Xt.includes(d.type)?(rt.includes(d.type)?a.push(...(d.usedInputs||[]).flatMap(v=>[v])||[]):a.push(...(d.inputs||[]).flatMap(v=>[v])||[]),d.error&&(i+=lm)):[f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)?(a.push(...d.outputs||[]),d.throws&&(i+=lm)):d.type===f.Condition&&(a.push(d.inputs[0]),d.inputs[1]&&a.push(d.inputs[1]));const l=a.length;l&&(i+=l*am,i+=va);const p=[];if(d.type===f.FunctionDeclaration||d.type===f.GlobalEvent?p.push(...d.inputs||[]):Xt.includes(d.type)&&(rt.includes(d.type)?p.push(...d.usedOutputs||[]):p.push(...d.outputs||[])),rt.includes(d.type)){d.readsValue&&(i+=va,i+=om),d.writesValues.length&&(i+=va,i+=om),d.internalCalls.length&&d.usedInternalCalls.forEach(()=>i+=lm+va);const v=d.getDataType(null);(!v||v.inferred)&&(i+=dm)}const t=p.length;return t&&(i+=t*am,i+=va),[f.DefinitionEntity,f.FunctionDeclaration,f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)&&(i+=dm),{height:i,width:280}}function Up(d){return`${d.split("-").map((a,l)=>l===0?a.charAt(0).toUpperCase()+a.slice(1):a.toLowerCase()).join(" ")}.`}function W0e(d){switch(d.code){case se.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case se.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case se.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case se.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case se.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case se.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case se.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case oe.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case oe.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case se.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case se.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case oe.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case se.NoProperties:return"This entity has no properties, so it doesn't do anything";case se.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case se.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case se.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case se.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case se.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case se.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case se.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case se.PropertyImplementsNonAbstact:return"This property implements a non-template property";case se.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case se.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case se.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case se.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case se.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case oe.InternalCallDeclarationIsNotFunctionDeclaration:return"This internal call is not an action";case oe.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case oe.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case oe.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case oe.UnreachableEntity:return"This entity is unreachable";case se.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";default:return Up(d.code)}}function Y0e(d){switch(d.code){case se.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case se.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case se.IncorrectEntityImplementation:return"Incorrect implementation";case se.IncorrectMethodImplementation:return"Incorrect action implementation";case se.IncorrectPropertyImplementation:return"Incorrect property implementation";case se.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case se.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case oe.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case oe.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case se.MissingMethodImplementation:return"Missing action";case se.MissingPropertyImplementation:return"Missing property";case oe.NameNotUniqueInScope:return"Duplicate name";case se.NoProperties:return"No properties";case se.NonStaticPropertyInStaticEntity:return"Non-static property";case se.StaticEntityWithNonStaticProperties:return"Non-static properties";case se.ReadingFromIncompatibleType:return"Read from different type";case se.WritingToIncompatibleType:return"Write to different type";case se.ScopeWithoutLogic:return"No logic";case se.NonStaticPropertyImplementsStatic:return"Invalid static property";case se.PropertyImplementsIncompatibleType:return"Incompatible data type";case se.PropertyImplementsNonAbstact:return"Non-template property";case se.StaticPropertyImplementsNonStatic:return"Non-static property";case se.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case se.VariableHasInputsAndInternalCall:return"Bad internal call";case se.VariableHasOutputsAndInternalCall:return"Bad internal call";case se.VariableIsCalledAndHasInternalCall:return"Bad internal call";case oe.InternalCallDeclarationIsNotFunctionDeclaration:return"Declaration not an action";case oe.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case oe.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case oe.InternalCallParentMissingDataType:return"Parent has no data type";case oe.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case oe.UnreachableEntity:return"Unreachable entity";case se.DisconnectedCallableEntity:return"Disconnected entity";default:return Up(d.code)}}function H0e(d){switch(d.code){case se.AbstractEntityWithNonAbstractMethods:return`${re(d.entity,d.entity.project)} has non-template actions`;case se.AbstractEntityWithNonAbstractProperties:return`${re(d.entity,d.entity.project)} has non-template properties`;case se.IncorrectEntityImplementation:return`${re(d.entity,d.entity.project)} incorrectly implements template`;case se.IncorrectMethodImplementation:return`${re(d.entity,d.entity.project)} incorrectly implements the template`;case se.IncorrectPropertyImplementation:return`${re(d.entity,d.entity.project)} incorrectly implements the template`;case se.AbstractMethodInNonAbstractEntity:return`${re(d.entity,d.entity.project)} can't be a template`;case se.AbstractPropertyInNonAbstractEntity:return`${re(d.entity,d.entity.project)} can't be a template`;case oe.MethodOverwritesOtherSiblingWithSameName:return`${re(d.entity,d.entity.project)} overwrites action`;case oe.PropertyOverwritesOtherSiblingWithSameName:return`${re(d.entity,d.entity.project)} overwrites property`;case se.MissingMethodImplementation:return`${re(d.entity,d.entity.project)} is missing action`;case se.MissingPropertyImplementation:return`${re(d.entity,d.entity.project)} is missing property`;case oe.NameNotUniqueInScope:return`${re(d.entity,d.entity.project)} name is not unique`;case se.NoProperties:return`${re(d.entity,d.entity.project)} has no properties`;case se.NonStaticPropertyInStaticEntity:return`${re(d.entity,d.entity.project)} has non-static property`;case se.StaticEntityWithNonStaticProperties:return`${re(d.entity,d.entity.project)} has non-static properties`;case se.ReadingFromIncompatibleType:return`${re(d.entity,d.entity.project)} reads from different type`;case se.WritingToIncompatibleType:return`${re(d.entity,d.entity.project)} writes to different type`;case se.ScopeWithoutLogic:return`${re(d.entity,d.entity.project)} has no logic`;case se.NonStaticPropertyImplementsStatic:return`${re(d.entity,d.entity.project)} has invalid static property`;case se.PropertyImplementsIncompatibleType:return`${re(d.entity,d.entity.project)} has incompatible data type`;case se.PropertyImplementsNonAbstact:return`${re(d.entity,d.entity.project)} has non-template property`;case se.StaticPropertyImplementsNonStatic:return`${re(d.entity,d.entity.project)} has non-static property`;case se.VariableCallsOthersAndHasInternalCall:return`${re(d.entity,d.entity.project)} has bad internal call`;case se.VariableHasInputsAndInternalCall:return`${re(d.entity,d.entity.project)} has bad internal call`;case se.VariableHasOutputsAndInternalCall:return`${re(d.entity,d.entity.project)} has bad internal call`;case se.VariableIsCalledAndHasInternalCall:return`${re(d.entity,d.entity.project)} has bad internal call`;case oe.InternalCallDeclarationIsNotFunctionDeclaration:return`${re(d.entity,d.entity.project)} has declaration that is not an action`;case oe.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${re(d.entity,d.entity.project)} has declaration that is not found in parent`;case oe.InternalCallParentDeclarationEntityInvalidType:return`${re(d.entity,d.entity.project)} has invalid parent declaration type`;case oe.InternalCallParentMissingDataType:return`${re(d.entity,d.entity.project)}'s parent has no data type`;case oe.InternalCallDeclarationNotInParentDatatypeEntity:return`${re(d.entity,d.entity.project)} has declaration that is not in parent`;case oe.UnreachableEntity:return`${re(d.entity,d.entity.project)} is unreachable`;case se.DisconnectedCallableEntity:return`${re(d.entity,d.entity.project)} is not executed by any entity`;default:return`${re(d.entity,d.entity.project)} Error: ${Up(d.code)}`}}function z0e(d){var u,i,a,l;switch(d.code){case se.AbstractEntityWithNonAbstractMethods:return`${re(d.entity,d.entity.project)} has non-template actions`;case se.AbstractEntityWithNonAbstractProperties:return`${re(d.entity,d.entity.project)} has non-template properties`;case se.IncorrectEntityImplementation:return`${re(d.entity,d.entity.project)} incorrectly implements the template entity`;case se.IncorrectMethodImplementation:return`${re(d.entity,d.entity.project)} incorrectly implements the template action it's based on`;case se.IncorrectPropertyImplementation:return`${re(d.entity,d.entity.project)} incorrectly implements the template property it's based on`;case se.AbstractMethodInNonAbstractEntity:return`${re(d.entity,d.entity.project)} is a template action in a non-template entity`;case se.AbstractPropertyInNonAbstractEntity:return`${re(d.entity,d.entity.project)} is a template property in a non-template entity`;case oe.MethodOverwritesOtherSiblingWithSameName:return`${re(d.entity,d.entity.project)} overwrites an action in the template entity`;case oe.PropertyOverwritesOtherSiblingWithSameName:return`${re(d.entity,d.entity.project)} overwrites a property in the template entity`;case se.MissingMethodImplementation:return`${re(d.entity,d.entity.project)} is missing an action implementation from the template entity`;case se.MissingPropertyImplementation:return`${re(d.entity,d.entity.project)} is missing a property implementation from the template entity`;case oe.NameNotUniqueInScope:return`${re(d.entity,d.entity.project)} has a duplicate name in the same scope`;case se.NoProperties:return`${re(d.entity,d.entity.project)} has no properties, so it doesn't do anything`;case se.NonStaticPropertyInStaticEntity:return`${re(d.entity,d.entity.project)} has a non-static property in a static entity`;case se.StaticEntityWithNonStaticProperties:return`${re(d.entity,d.entity.project)} has non-static properties in a static entity`;case se.ReadingFromIncompatibleType:return`${re(d.entity,d.entity.project)} reads data from a value of a different data type`;case se.WritingToIncompatibleType:return`${re(d.entity,d.entity.project)} writes data to a value of a different data type`;case se.ScopeWithoutLogic:return`${re(d.entity,d.entity.project)} has no logic`;case se.NonStaticPropertyImplementsStatic:return`${re(d.entity,d.entity.project)} has a static property in a non-static entity`;case se.PropertyImplementsIncompatibleType:return`${re(d.entity,d.entity.project)} implements a property of a different data type`;case se.PropertyImplementsNonAbstact:return`${re(d.entity,d.entity.project)} implements a non-template property`;case se.StaticPropertyImplementsNonStatic:return`${re(d.entity,d.entity.project)} has a static property in a non-static entity`;case se.VariableCallsOthersAndHasInternalCall:return`${re(d.entity,d.entity.project)} calls other entities while being used to execute internal logic`;case se.VariableHasInputsAndInternalCall:return`${re(d.entity,d.entity.project)} has inputs while being used to execute internal logic`;case se.VariableHasOutputsAndInternalCall:return`${re(d.entity,d.entity.project)} has outputs while being used to execute internal logic`;case se.VariableIsCalledAndHasInternalCall:return`${re(d.entity,d.entity.project)} is called while being used to execute internal logic`;case oe.InternalCallDeclarationIsNotFunctionDeclaration:return`${re(d.entity,d.entity.project)} has a declaration that is not an action`;case oe.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${re(d.entity,d.entity.project)} has a declaration that is not found in ${(u=d.entity.parent.getDataType(null))!=null&&u.entity?re((i=d.entity.parent.getDataType(null))==null?void 0:i.entity,d.entity.project):"the variable's data-type entity"}`;case oe.InternalCallParentDeclarationEntityInvalidType:return`${re(d.entity,d.entity.project)} is part of a variable whos data-type entity can't have actions`;case oe.InternalCallParentMissingDataType:return`${re(d.entity,d.entity.project)} is part of a variable with no data-type entity`;case oe.InternalCallDeclarationNotInParentDatatypeEntity:return`${re(d.entity,d.entity.project)} has a declaration doesn't belong to ${(a=d.entity.parent.getDataType(null))!=null&&a.entity?re((l=d.entity.parent.getDataType(null))==null?void 0:l.entity,d.entity.project):"the variable's data-type entity"}`;case oe.UnreachableEntity:return`${re(d.entity,d.entity.project)} is unreachable`;case se.DisconnectedCallableEntity:return`${re(d.entity,d.entity.project)} is disconnected and won't be executed by anything after publishing`;default:return`${re(d.entity,d.entity.project)} Error: ${Up(d.code)}`}}var FA=(d=>(d.ValuesAlreadyConnected="values-already-connected",d.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",d.CannotReadValueFromChildren="cannot-read-value-from-children",d.CannotWriteValueToChildren="cannot-write-value-to-children",d.CannotBeCalledByChildren="cannot-be-called-by-children",d.ExecutionsAlreadyConnected="executions-already-connected",d.DataTypesNotCompatible="data-types-not-compatible",d.CannotCallAncestor="cannot-call-ancestor",d.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",d.NotInScope="not-in-scope",d.IsNotValueWrittingEntity="is-not-value-writting-entity",d.IsNotValueReadingEntity="is-not-value-reading-entity",d.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",d.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",d.CallerIsInHigherScope="caller-is-in-higher-scope",d.CallerIsInLowerScope="caller-is-in-lower-scope",d.CallIsInHigherScope="call-is-in-higher-scope",d.CallIsInLowerScope="call-is-in-lower-scope",d.OtherIncompatibleScopeReason="other-incompatible-scope-reason",d))(FA||{});const X0e=Object.values(FA);var GA=(d=>(d.NotPartOfOngoingTest="not-part-of-ongoing-test",d.CannotBeAddedToTest="cannot-be-added-to-test",d))(GA||{});const Q0e=Object.values(GA);var KA=(d=>(d.Suggestion="suggestion",d.CanvasGloballyDisabled="canvas-globally-disabled",d))(KA||{});const eve=Object.values(KA);function tve(d,u){const i=[...d,...u];return Array.from(new Set(i))}function rve(d,u){const i=[...d,...u],a=Array.from(new Set(i));return{hasChanged:a.length!==d.length,reasons:a}}function ive(d,u){const i=d.filter(l=>!u.includes(l));return{hasChanged:i.length!==d.length,reasons:i}}function sve(d,u){return d.find(i=>i.entity.id===u)||null}function u5(d){return d.filter((u,i)=>d.indexOf(u)===i)}class Xr{constructor(u,i,a=null,l){D(this,"ids",[]);D(this,"entity");D(this,"entityCardHeight");D(this,"entityCardWidth");D(this,"index");D(this,"childEntities",[]);D(this,"children",[]);D(this,"parents",[]);D(this,"calculationEntryPoint");D(this,"_onlyEntities",null);D(this,"_changeSet",null);if(this.index=i,this.entity=u,this.calculationEntryPoint=a||this,this===this.calculationEntryPoint&&!l)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(u,i,a){const l=a5-xA-i5,p=o5-um-UA;u.metaSync({x:u.x||l,y:u.y||p},i);const t=new Xr(u,0,null,i);t._onlyEntities=a||[],t.ids=["0"];const y=[];t.next(T=>{y.push(...T)}),Xr.recursivelyAssembleChildrenAreas(y),t.resolveChildrenOverlaps();const v=t.flattenChildEntities();return t._onlyEntities?v.filter(T=>(t._onlyEntities||[]).includes(T)):v}static recursivelyAssembleChildrenAreas(u){const i=[];u.forEach(a=>{a.next(l=>{i.push(...l)})}),i.length>0&&Xr.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(u){this.calculationEntryPoint._changeSet=u}findAreaInChildrenFromEntity(u){if(this.entity===u)return this;const i=this.children.find(l=>l.entity===u);return i||this.children.reduce((l,p)=>l||p.findAreaInChildrenFromEntity(u),null)}findAreaFromEntity(u){if(this.entity===u)return this;const i=this.calculationEntryPoint.children,a=i.find(p=>p.entity===u);return a||i.reduce((p,t)=>p||t.findAreaInChildrenFromEntity(u),null)}addParent(u){if(!this.parents.includes(u)){const i=Xr.resolveIds(u,this.index);this.ids.push(...i),this.parents.push(u)}}static resolveIds(u,i){return u?u.ids.map(a=>`${a}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const u=tn(this.entity,!0);if(this.entity.type===f.Project){const i=[],a=[],l=[];u.forEach(t=>{if(f.DefinitionEntity===t.type){a.push(t);return}else if(Wt.includes(t.type)){l.push(t);return}i.push(t)});const p=i.sort((t,y)=>{const v=!!Ky(t,y).length,T=tn(t),w=tn(y);return v?0:T.length&&!w.length?-1:!T.length&&w.length?1:0}).filter(t=>!Xa(t).length);this.childEntities=[...a,...l,...p]}else{const i=[],a=[],l=[],p=[],t=[];qs.includes(this.entity.type)&&qy(this.entity).forEach(T=>{if(rt.includes(T.type)){l.push(T);return}const w=ur(T);i.push(w)}),br.includes(this.entity.type)&&a.push(...this.entity.detachedChildren);const y=u.filter(v=>{const T=i.includes(v);return T||l.includes(v)||a.includes(v)?!1:rt.includes(v.type)?(l.push(v),!1):ks.includes(v.type)&&!T?(p.push(v),!1):v.type===f.DefinitionEntity?(t.push(v),!1):!0});i.sort((v,T)=>Wo(v,T)?-1:0),p.sort((v,T)=>Wo(v,T)?-1:0),l.sort((v,T)=>dA(v,T)?1:dA(T,v)?-1:0),this.childEntities=[...t,...i,...p,...y,...l,...a]}}calculateCardSize(){const u=d5(this.entity);this.entityCardWidth=u.width,this.entityCardHeight=u.height}static getBoundriesOfTwoAreas(u,i){return{top:Math.min(u.top,i.top),left:Math.min(u.left,i.left),bottom:Math.max(u.bottom,i.bottom),right:Math.max(u.right,i.right)}}static getBoundriedOfCombinedAreas(u,i){const a=u.filter(p=>!i.includes(p));return a.reduce((p,t)=>i.includes(t)?p:Xr.getBoundriesOfTwoAreas(p,t.fullBranchArea),a[0].fullBranchArea)}getFullAreaUntilAny(u){const i=this.ownEntityPlusBufferArea;return this.children.filter(t=>!u.includes(t)).map(t=>t.getFullAreaUntilAny(u)).reduce((t,y)=>Xr.getBoundriesOfTwoAreas(t,y),i)}getFullAreaUntilAreaOrAnyChildren(u){const i=[u,...u.flattenChildren()],a=this.ownEntityPlusBufferArea;return this.children.filter(t=>i.includes(t)).map(t=>t.getFullAreaUntil(u)).reduce((t,y)=>Xr.getBoundriesOfTwoAreas(t,y),a)}getFullAreaUntil(u){const i=this.ownEntityPlusBufferArea;return this.children.filter(p=>p!==u).map(p=>p.getFullAreaUntil(u)).reduce((p,t)=>Xr.getBoundriesOfTwoAreas(p,t),i)}get fullBranchArea(){const u=this.ownEntityPlusBufferArea;return this.children.map(l=>l.fullBranchArea).reduce((l,p)=>Xr.getBoundriesOfTwoAreas(l,p),u)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const u=this.ownEntityArea;return{top:u.top,left:u.left,bottom:u.bottom+um,right:u.right+xA}}static filterOutRepeatedAreas(u){return u.filter((i,a)=>u.indexOf(i)===a)}getEarliestId(u,i){const a=u.split("-"),l=i.split("-");return a.length<l.length?u:a.length>l.length?i:a.reduce((t,y,v)=>y<l[v]?u:i,u)}getEarliestLevel(){return this.ids.reduce((a,l)=>this.getEarliestId(a,l),this.ids[0]).split("-").length}countColumns(){let u=0;if(this!==this.calculationEntryPoint)u++;else return u;if(!this.parents.length)return u;const a=this.parents.reduce((l,p)=>p.getEarliestLevel()>l.getEarliestLevel()?p:l,this.parents[0]).countColumns();return u+=a,u}getLatestId(u,i){if(u===i)return u;const a=u.split("-"),l=i.split("-");return a.length<l.length?i:a.length>l.length?u:a.reduce((t,y,v)=>y>l[v]?u:i,u)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((a,l)=>this.getLatestId(a,l),this.ids[0]).split("-").length}smoothPosition(){const u=this.flattenSiblings();if(!u.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(a=>{a!==this.calculationEntryPoint&&a.shiftDownAlone(i)})}else if([...Wt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=u.filter(a=>!this.parents.includes(a));i.length?i.every(l=>{const p=this.countColumns(),t=l.countColumns();return p>t})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(u,i){if(u.includes(this))return u;this.move(this.entity,{y:this.entity.y+i});let a=[...u,this];return this.children.forEach(l=>{if(Xr.getEarliestParentInChain(l)!==this)return;const t=sve(a,l.entity.id);a=Xr.filterOutRepeatedAreas([...a]),t||(a=a.filter(v=>v!==l));const y=l.shiftDownUntilAny(a,i);a.push(...y)}),a}shiftRightUntilAny(u,i){u.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(a=>{const l=Xr.filterOutRepeatedAreas([...this.flattenSiblings(),...u]);Xr.getEarliestParentInChain(a)===this&&a.shiftRightUntilAny(l,i)}))}shiftRight(u){this.move(this.entity,{x:this.entity.x+u}),this.children.forEach(i=>{const l=i.flattenSiblings().filter(p=>p!==i);i.shiftRightUntilAny(l,u)})}shiftDownAlone(u){this.move(this.entity,{y:this.entity.y+u})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const u=this.parents.reduce((l,p)=>{const t=p.ownEntityArea,y=t.top+Cd,v={top:y,left:t.left,bottom:y,right:t.right};return Xr.getBoundriesOfTwoAreas(l,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Cd;this.shiftDownAlone(a)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const u=this.children.reduce((l,p)=>{const t=p.ownEntityArea,y=t.top+Cd,v={top:y,left:t.left,bottom:y,right:t.right};return Xr.getBoundriesOfTwoAreas(l,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Cd;return this.shiftDownAlone(a),a}resolveChildrenOverlaps(){const u=this.flattenChildren();let i=[];u.forEach(a=>{const l=a.adjustVerticallyToAvoidOverlaps();i.push(...l)}),u.forEach(a=>{a.smoothPosition()})}static getEarliestParentInChain(u){let i=u.parents[0];return u.parents.length&&(i=u.parents.sort((a,l)=>{if(!a.ids.length)return-1;if(!l.ids.length)return 1;const p=a.ids.sort((y,v)=>y.length<v.length?-1:0),t=l.ids.sort((y,v)=>y.length<v.length?-1:0);return p[0].length-t[0].length})[0]),i}flattenEarlierSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,l)=>{if(u.has(l.entity.id))return a;u.add(l.entity.id);const t=l.children.slice(0,l.children.indexOf(this)).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...t]},[])}flattenSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,l)=>{if(u.has(l.entity.id))return a;u.add(l.entity.id);const t=l.children.filter(y=>y!==this).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...t]},[])}flattenChildren(u=new Set){return this.children.reduce((i,a)=>u.has(a.entity.id)?i:(u.add(a.entity.id),[...i,a,...a.flattenChildren(u)]),[])}flattenParents(u=new Set){return this.parents.reduce((a,l)=>u.has(l.entity.id)?a:(u.add(l.entity.id),[...a,l,...l.flattenParents(u)]),[])}getAreaIfRendered(u){return this.calculationEntryPoint.flattenChildren().find(l=>l.entity.id===u.id)||null}getLowerSiblings(){const u=this.parents.reduce((i,a)=>{const l=a.children.indexOf(this),p=a.children.slice(l+1);return[...i,...p]},[]);return u5(u)}getLowerAreas(){const u=this.getLowerSiblings(),i=this.parents.reduce((a,l)=>[...a,...l.getLowerAreas()],[]);return u5([...u,...i])}adjustVerticallyToAvoidOverlaps(u=[]){const a=Xr.getEarliestParentInChain(this).children[this.index-1];if(!a)return u;const l=this.flattenEarlierSiblings(),p=this.flattenParents(),t=[...l,...p,a],T=R(t.flatMap(N=>Ky(this.entity,N.entity))).filter(N=>N.id!==this.entity.id).map(N=>this.findAreaFromEntity(N)).filter(N=>!!N),w=this.getFullAreaUntilAny(T),A=a.getFullAreaUntilAny(T),V=t.reduce((N,j)=>j===this||j.fullBranchArea.left!==w.left?N:Math.max(N,j.fullBranchArea.bottom),A.bottom);if(w.top<V){const N=V-w.top+um;return this.shiftDownUntilAny(u,N)}return u}move(u,i){(this.onlyEntities||[]).includes(u)&&u.metaSync(i,this.changeSet)}addChild(u){const i=this.childEntities[u];let a=null;i.x&&i.y?a=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),a||(a=new Xr(i,u,this.calculationEntryPoint));const l=this.ownEntityPlusBufferArea;this.children.includes(a)||(this.children.push(a),a.addParent(this));const p=a.fullBranchArea;if(p.left<l.right){const t=l.right-p.left;a.shiftRight(t)}return a}flattenChildEntities(u=new Set){return this.children.reduce((i,a)=>u.has(a.entity.id)?i:(u.add(a.entity.id),[...i,a.entity,...a.flattenChildEntities(u)]),[])}next(u){const i=[];this.childEntities.forEach((a,l)=>{const p=this.addChild(l);p&&i.push(p)}),u(i)}}$.AI_VALUE_CONNECTION_GENERATION_ACTION_EXPLANATION=tA,$.ALL_BUILT_IN_BASE_ENTITIES=qP,$.ALL_BUILT_IN_CONDITION_ENTITIES=sV,$.ALL_BUILT_IN_GLOBAL_EVENT_ENTITIES=aV,$.ALL_BUILT_IN_LOOP_BODY_ENTITIES=E$,$.ALL_BUILT_IN_LOOP_ENTITIES=v$,$.ALL_BUILT_IN_OPERATION_ENTITIES=CO,$.ALL_BUILT_IN_PRIMITIVE_ENTITIES=vR,$.ALL_BUILT_IN_TOP_LEVEL_ENTITIES=pV,$.ALL_BUILT_IN_VALUE_DESCRIPTORS=cV,$.ALL_CONNECTION_DISABLED_REASONS=X0e,$.ALL_OTHER_DISABLED_REASONS=eve,$.ALL_TESTING_DISABLED_REASONS=Q0e,$.ActionDescriptorState=jt,$.ActionInputMapState=Sye,$.ActionOutputMapState=Wye,$.AppendToListOperationInputIds=_g,$.AppendToListOperationOutputIds=gg,$.Area=Xr,$.ArgumentDeclarationDependencyField=zU,$.ArgumentDeclarationState=pa,$.BREAK_AND_CONTINUE_STATEMENTS_RETURN_DECLARATIONS_EXPLANATION=zb,$.BUILT_IN_BASE_ENTITY_IDS=Ee,$.BUILT_IN_ENTITY_TYPES=ki,$.BaseCanvasDraggableState=a0e,$.BaseEntityNames=$e,$.BaseState=n0e,$.BaseValueDescriptorIds=Ol,$.BreakStatementDependencyField=QU,$.BreakStatementState=Ja,$.BuiltInBaseEntityState=Cn,$.CACHED_PROJECTS_BY_ID=Ho,$.CALLABLE_ENTITIES_EXPLANATION=tme,$.CALLABLE_TYPES=ks,$.CALLER_ENTITIES_EXPLANATION=sj,$.CALLER_TYPES=qs,$.CALLS_UPDATE_EXPLANATION=Ya,$.CANVAS_BASE_X=a5,$.CANVAS_BASE_Y=o5,$.CANVAS_CARD_HEADER_CENTER_HEIGHT=Cd,$.CANVAS_CARD_WIDTH=i5,$.CANVAS_COMPLEX_CARD_HEIGHT=Z0e,$.CANVAS_HORIZONTAL_BUFFER_BETWEEN_CARDS=xA,$.CANVAS_SIMPLE_CARD_HEIGHT=UA,$.CANVAS_SIZE=MA,$.CANVAS_VERTICAL_BUFFER_BETWEEN_CARDS=um,$.CARD_FOOTER_HEIGHT=dm,$.CARD_PROPERTIES_SECTION_PADDING=va,$.CARD_PROPERTIES_SECTION_SINGLE_PADDING=jA,$.CHILDREN_TYPES=M9,$.COMPARISON_CONDITIONS=rV,$.CONDITIONS=iV,$.CUSTOM_ENTITY_OPERATIONS=JD,$.CallableEntityClass=l0e,$.CallerEntityClass=IA,$.CanvasEntityConnectionDisabledReason=FA,$.CanvasEntityOtherDisabledReason=KA,$.CanvasEntityTestingDisabledReason=GA,$.ChangeSet=G,$.ChangeSetChangeCaptureType=Ib,$.ChangeSetEntityChangeType=K,$.ChildEntityBaseClass=o0e,$.CommonStringValidationErrorCodes=Tj,$.ComparisonOperatorTypes=lr,$.ConditionDependencyField=gM,$.ConditionState=Ga,$.ContinueStatementDependencyField=AM,$.ContinueStatementState=li,$.CreateNewInputIds=AD,$.CreateNewOutputIds=ID,$.DRAGGABLE_CALLABLE_TYPES=rv,$.DRAGGABLE_CALLER_TYPES=lR,$.DRAGGABLE_ELEMENT_TYPES=$f,$.DRAGGABLE_EXECUTABLE_TYPES=L9,$.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES=Cf,$.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=tv,$.DataTypeCompatibilityTypes=Ds,$.DataTypeDependencyField=gb,$.DataTypeParentChildRelation=Zr,$.DataTypeState=Hi,$.DefinitionEntityDependencyField=Qy,$.DefinitionEntityState=ma,$.DynamicValueTypes=Ae,$.EDITABLE_PERSISTANCE_REPOSITORY_DEFAULTS=i0e,$.ENTITIES_WITH_VALLUES_EXPLANATION=By,$.ENTITY_PERSISTANCE_OPTIONS_DEFAULTS=ye,$.ENTITY_RECUSION_OPTIONS_DEFAULTS=Ne,$.ENTITY_TYPES=B9,$.ENTITY_WITH_CODE_NAMES_TYPES=uR,$.ENTITY_WITH_DECLARATION_TYPES=V9,$.ENTITY_WITH_LOGIC_SCOPE_TYPES=br,$.ENTITY_WITH_NAMES_TYPES=dR,$.ENTITY_WITH_PARENT_TYPES=$9,$.ENTITY_WITH_USER_MANAGED_DECLARATION_TYPES=aR,$.ENTITY_WITH_USER_MANAGED_SINGLE_IMPLEMENTS_TYPES=P9,$.ENTITY_WITH_VALUE_TYPES=ev,$.ENTRY_POINT_ENTITIES_EXPLANATION=Tp,$.ENTRY_POINT_TYPES=Wt,$.ERROR_PROPERTY_HEIGHT=lm,$.EVENT_TYPES=Dl,$.EXECUTABLE_TYPES=N9,$.EXECUTION_OPERATIONS=bD,$.EfimeralValueStore=Pp,$.EndpointEntity=Bx,$.EntityError=qt,$.EntityErrorSeverity=Z,$.EntityGenerationError=Q,$.EntityGenerationErrorCode=S,$.EntityInstanceErrorCode=se,$.EntityOperations=tr,$.EntityType=f,$.EntityWithLogicScopeClass=p0e,$.EntityWithValueClass=c0e,$.EntryPointEntityClass=d0e,$.Execution=VA,$.ExecutionOperations=er,$.ExecutionState=PA,$.ExecutionTerminationType=Ze,$.FunctionCallDependencyField=yj,$.FunctionCallState=za,$.FunctionDeclarationDependencyField=fM,$.FunctionDeclarationState=Ua,$.GET_PROJECT_OPTIONS_DEFAULTS=$p,$.GLOBAL_EVENT_DECLARATIONS=nV,$.GetLastInListOperationInputIds=fg,$.GetLastInListOperationOutputIds=hg,$.GlobalEventNames=Zn,$.GlobalEventState=Fa,$.HTTPOperations=ni,$.HTTPStatucCodeValidationErrorCodes=Nx,$.HTTP_OPERATIONS=DO,$.InputMapDependencyField=JU,$.InputMapState=Cs,$.InstalledProjectState=Sa,$.InternalCallDependencyField=SU,$.InternalCallState=Za,$.JoinListOperationInputIds=N_,$.JoinListOperationOutputIds=L_,$.LIST_OPERATIONS=xg,$.ListOperations=lt,$.LiteralValueDependencyField=dM,$.LiteralValueState=bi,$.LoopDependencyField=RM,$.LoopState=Ai,$.LoopTypes=xe,$.MAIN_VALUE_PROPERTY_HEADER_HEIGHT=om,$.MAIN_VALUE_SUB_PROPERTY_HEIGHT=J0e,$.NESTED_PROPERTY_HEIGHT=s5,$.NON_INTERACTIVE_BASE_ENTITIES_EXPLANATION=Ha,$.NUMBER_OPERATIONS=JR,$.NumberOperations=or,$.OPERATION_DECLARATIONS=OO,$.OperationDependencyField=mM,$.OperationState=ja,$.OutputMapDependencyField=YU,$.OutputMapParentChildRelation=gl,$.OutputMapState=Qs,$.PARENT_AUTO_CALCULATION_FROM_CALLER_EXPLANATION=My,$.PASS_THROUGH_CALLABLE_ENTITIES_EXPLANATION=Wa,$.PASS_THROUGH_CALLABLE_TYPES=Xt,$.PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=oR,$.PLACEHOLDER_VALUE_STORE_CLIENT=jx,$.PROPERTY_HEIGHT=am,$.PROPERTY_NOT_VALUE_READER_WRITTER_EXPLANATION=eA,$.ParallelExecutionOperation=Cx,$.PassThroughCallableEntityClass=u0e,$.PersistedEntity=Vx,$.PersistedEntityMethods=as,$.PrimitiveEntityState=Li,$.PrimitiveTypes=X,$.ProjectState=P,$.ProjectStateEvents=yr,$.PropertyDependencyField=cM,$.PropertyState=ua,$.READABLE_ENTITY_TYPES=NA,$.READ_ONLY_ENTITY_PERSISTANCE_REPOSITORY=Ox,$.RETURN_STATEMENT_RETURN_DECLARATIONS_EXPLANATION=rme,$.ReturnDeclarationDependencyField=EM,$.ReturnDeclarationState=Ni,$.ReturnStatementDependencyField=Db,$.ReturnStatementState=xa,$.SQLAST=Uye,$.STANDALONE_CONDITIONS=JP,$.STATIC_PROPERTY_HEIGHT=n5,$.STRING_OPERATIONS=V_,$.ScopeCompatibilityType=Hy,$.SearchDependencyField=GU,$.SearchState=qa,$.SequentialExecutionOperation=Px,$.SequentialExecutionOperationInputIds=oD,$.SequentialExecutionOperationOutputIds=lD,$.SharedEntityErrorCode=oe,$.SharedStateFunctionality=Dx,$.SplitListOperationInputIds=Y_,$.SplitListOperationOutputIds=H_,$.StandaloneOperatorTypes=Ki,$.StringOperations=ht,$.TERMINATION_TYPES=rr,$.Traverser=ha,$.USER_MANAGED_ENTITY_TYPES=cR,$.UserManagedEntityStateTemplate=s0e,$.VALUE_READING_ENTITIES_EXPLANATION=Qb,$.VALUE_READING_TYPES=Jn,$.VALUE_WRITING_ENTITIES_EXPLANATION=nj,$.VALUE_WRITING_TYPES=gr,$.VARIABLE_DATA_TYPE_INFERRANCE_EXPLANATION=Xb,$.VARIABLE_TYPES=rt,$.ValueAutogenerationType=_r,$.ValueDescriptorDependencyField=tj,$.ValueDescriptorParentChildRelation=ue,$.ValueDescriptorState=en,$.ValueReadingEntityClass=Op,$.ValueWritingEntityClass=Cp,$.VariableDeclarationDependencyField=CM,$.VariableDeclarationState=ka,$.VariableInputMapState=qye,$.VariableInstanceDependencyField=Cb,$.VariableInstanceState=Ka,$.VariableOutputMapState=Jye,$.WaitOperation=$x,$.WaitOperationInputIds=eD,$.WaitOperationOutputIds=tD,$.actionDescriptorValidation=Zfe,$.addDisabledReasons=rve,$.afterLiteralValueAsTypeChangeSideEffects=Qx,$.afterLiteralValueAsTypeDeleteSideEffects=Xx,$.afterLiteralValueChangeSideEffects=Hx,$.afterLiteralValueDeleteSideEffects=Yx,$.aggregateVariableInputsNextValues=Vp,$.aggregateVariableInputsValues=im,$.appendToListOperation=Lf,$.appendToListOperationElementToAppendArgument=mv,$.appendToListOperationElementToAppendArgumentParentRef=Lg,$.appendToListOperationElementToAppendArgumentRef=Cg,$.appendToListOperationError=jg,$.appendToListOperationErrorParentRef=Ug,$.appendToListOperationListArgument=yv,$.appendToListOperationListArgumentParentRef=Ng,$.appendToListOperationListArgumentRef=Dg,$.appendToListOperationListDataType=Og,$.appendToListOperationResultListDataType=Vg,$.appendToListOperationResultListReturn=Mg,$.appendToListOperationResultListReturnParentRef=Bg,$.appendToListOperationResultListReturnRef=Pg,$.appendToListOperationSecondListDataType=$g,$.applyNewScope=je,$.argumentDeclarationValidation=Yye,$.asGenerationActionExample=On,$.assembleAndAddLiteralValueFromDataType=rn,$.assembleStandaloneLiteralValueFromDataType=He,$.booleanPrototype=Wn,$.breakStatementValidation=Hye,$.calculateCardSize=d5,$.calculateMethodCardSize=l5,$.calculateNewParentBasedOnCallers=lA,$.capitalizeFirstLetter=Hr,$.changeSetJSONRecordToUniqueIds=$fe,$.checkAreDataTypesCompatible=Os,$.checkAreDefinitionEntitiesCompatibleAsDataType=SB,$.checkArePropertiesCompatibleAsDataType=qB,$.checkExtendsBaseEntity=zy,$.checkHasBaseEntity=Vs,$.checkHasMetadataChanged=Er,$.checkImplementationsOverlap=ya,$.checkImplementsBaseEntity=Nme,$.checkIsBranchDependentButNotDirectlyOnBranch=Wo,$.checkIsBranchDependentOnBranch=dA,$.checkIsBuiltIn=AA,$.checkIsCallableEntityReachable=Dp,$.checkIsCanvasEntity=Pme,$.checkIsDefEntityInlineDeclaredForSearchOutputType=Zb,$.checkIsDetachedBranch=mx,$.checkIsDetachedBranchShallow=EA,$.checkIsEmptyValue=xx,$.checkIsGlobalVariable=Cme,$.checkIsGloballyDeclared=vA,$.checkIsLiteralValueEmpty=RA,$.checkIsMethod=TA,$.checkIsNestedScope=Yy,$.checkIsRequiredValue=zo,$.checkScopeCompatibility=gp,$.cloneProject=B0e,$.conditionValidation=Jfe,$.continueStatementValidation=Kfe,$.convertToAbstract=pme,$.convertToNonAbstract=fme,$.convertToNonStatic=yme,$.convertToStatic=hme,$.countedLoopActionDescriptor=gu,$.countedLoopActionDescriptorDynamicReturnDeclaration=d$,$.countedLoopActionDescriptorDynamicReturnDeclarationParentRef=l$,$.countedLoopActionDescriptorStringArgumentDeclaration=o$,$.countedLoopActionDescriptorStringArgumentDeclarationDataType=n$,$.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValue=i$,$.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValueParentRef=r$,$.countedLoopActionDescriptorStringArgumentDeclarationDataTypeParentRef=s$,$.countedLoopActionDescriptorStringArgumentDeclarationParentRef=a$,$.countedLoopBodyActionDescriptor=Zf,$.countedLoopBodyActionDescriptorAnyDynamicArgument=h$,$.countedLoopBodyActionDescriptorAnyDynamicArgumentParentRef=f$,$.countedLoopBodyActionDescriptorAnyDynamicReturn=m$,$.countedLoopBodyActionDescriptorAnyDynamicReturnParentRef=y$,$.countedLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Pv,$.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=c$,$.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=u$,$.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=p$,$.createDefinitionEntityFromJSONObject=Gy,$.createEntityError=nt,$.createNestedDataTypeForEntity=Ej,$.createNewInstanceOperation=bo,$.createNewInstanceOperationEntityToInstanciateArgument=$D,$.createNewInstanceOperationEntityToInstanciateArgumentRef=DD,$.createNewInstanceOperationEntityToInstanciateDataType=OD,$.createNewInstanceOperationError=LD,$.createNewInstanceOperationErrorParentRef=ND,$.createNewInstanceOperationNewEntityDataArgument=gD,$.createNewInstanceOperationNewEntityDataArgumentDataType=_D,$.createNewInstanceOperationNewEntityDataArgumentDataTypeParentRef=RD,$.createNewInstanceOperationNewEntityDataArgumentParentRef=wD,$.createNewInstanceOperationOutputEntityDeclaration=VD,$.createNewInstanceOperationOutputEntityDeclarationParentRef=PD,$.createNewInstanceOperationRef=CD,$.createSemanticId=iM,$.createStateFromGenerationTargetType=r0e,$.createStateFromType=Kt,$.createStateFromTypeAndSubscribe=ee,$.cronJobBuiltInBaseEntity=zf,$.cronJobBuiltInBaseEntityExpressionProperty=KP,$.cronJobBuiltInBaseEntityExpressionPropertyDataTypeRef=q9,$.cronJobBuiltInBaseEntityExpressionPropertyRef=FP,$.cronJobBuiltInBaseEntityRef=GP,$.cronJobTriggeredFunctionDeclarationBlueprint=Sv,$.cronJobTriggeredFunctionDeclarationBlueprintParentRef=jP,$.dataTypeCompatibilityToErrorExplanation=fj,$.dataTypeValidation=Mfe,$.datePrototype=yn,$.dateValueAutogenerationSchema=lT,$.definitionEntityToZodSchema=OV,$.definitionEntityValidation=Xme,$.deletePersistedEntityMethod=qv,$.deletePersistedEntityMethodParentRef=wP,$.deleteRootProject=U0e,$.emitSideEffects=oM,$.endpointBuiltInBaseEntity=qi,$.endpointBuiltInBaseEntityRef=I$,$.endpointBuiltInBaseEntityRefFour=sP,$.endpointBuiltInBaseEntityRefThree=P$,$.endpointBuiltInBaseEntityRefTwo=D$,$.endpointBuiltInCorsProperty=w$,$.endpointBuiltInCorsPropertyDataType=A$,$.endpointBuiltInCorsPropertyDataTypeRef=T$,$.endpointBuiltInCorsPropertyRef=b$,$.endpointBuiltInMethodProperty=Nv,$.endpointBuiltInMethodPropertyDataType=$$,$.endpointBuiltInMethodPropertyDataTypeRef=O$,$.endpointBuiltInMethodPropertyRef=C$,$.endpointBuiltInPathProperty=Vv,$.endpointBuiltInPathPropertyDataType=g$,$.endpointBuiltInPathPropertyDataTypeRef=R$,$.endpointBuiltInPathPropertyRef=_$,$.endpointPathParamsArgumentDeclaration=Bv,$.endpointPathParamsArgumentDeclarationRef=G$,$.endpointPathParamsVariableDataType=K$,$.endpointPathParamsVariableDataTypeRef=F$,$.endpointReachedTriggerActionDescriptor=Gv,$.endpointReachedTriggerActionDescriptorRef=k$,$.endpointReachedTriggerActionDescriptorRefFour=Z$,$.endpointReachedTriggerActionDescriptorRefThree=S$,$.endpointReachedTriggerActionDescriptorRefTwo=q$,$.endpointRequestBodyArgumentDeclaration=Uv,$.endpointRequestBodyArgumentDeclarationRef=B$,$.endpointRequestBodyVariableDataType=M$,$.endpointRequestHeadersArgumentDeclaration=Lv,$.endpointRequestHeadersArgumentDeclarationRef=N$,$.endpointRequestHeadersVariableDataType=L$,$.endpointRequestHeadersVariableDataTypeRef=V$,$.endpointRequestQueryParamsArgumentDeclaration=Mv,$.endpointRequestQueryParamsArgumentDeclarationRef=j$,$.endpointRequestQueryParamsVariableDataType=x$,$.endpointRequestQueryParamsVariableDataTypeRef=U$,$.endpointResponseBodyDataType=rP,$.endpointResponseBodyReturnDeclaration=Fv,$.endpointResponseBodyReturnDeclarationRef=tP,$.endpointResponseCodeDataType=W$,$.endpointResponseCodeReturnDeclaration=jv,$.endpointResponseCodeReturnDeclarationDefaultValueParentRef=H$,$.endpointResponseCodeReturnDeclarationRef=J$,$.endpointResponseHeadersDataType=Q$,$.endpointResponseHeadersDataTypeRef=z$,$.endpointResponseHeadersReturnDeclaration=xv,$.endpointResponseHeadersReturnDeclarationRef=X$,$.endpointReturnStatementRef=Y$,$.endpointReturnStatementRefThree=iP,$.endpointReturnStatementRefTwo=eP,$.enrichFromKnownEntities=Ap,$.enumOptionsProperty=mR,$.enumOptionsPropertyDataType=hR,$.enumOptionsPropertyDataTypeRef=pR,$.enumOptionsPropertyRef=fR,$.enumPrototype=Yn,$.enumPrototypeRef=yR,$.errorCodeToMessage=Up,$.executionBuiltInBaseEntity=Xf,$.executionBuiltInEntityAbortMethod=Zv,$.executionBuiltInEntityAbortMethodParentRef=kP,$.filterOutDuplicateEntities=R,$.filterOutDuplicateErrors=Zle,$.findEntityFromKeys=nA,$.findReferenceToSelfInList=Mj,$.findReferencesToSelfInProject=Ime,$.flattenActionDescriptor=jj,$.flattenArgumentDeclaration=xj,$.flattenBreakStatement=Fj,$.flattenBuiltInBaseEntity=Gj,$.flattenCalls=$s,$.flattenCanvasAncestorsUntil=wd,$.flattenCondition=Kj,$.flattenContinueStatement=kj,$.flattenDataType=Sj,$.flattenDefinitionEntity=qj,$.flattenDefinitionEntityExtensionAndImplementationTypes=gd,$.flattenDefinitionEntityExtensionTypes=wp,$.flattenDefinitionEntityExtensions=hA,$.flattenDefinitionEntityImplementations=yA,$.flattenDefinitionEntityImplementionTypes=Ip,$.flattenDerivedCanvasEntities=Xi,$.flattenDetachedBranch=Ex,$.flattenElementCalls=ut,$.flattenElementCallsOnTheSameScope=Ame,$.flattenEntity=he,$.flattenFunctionCall=Zj,$.flattenFunctionDeclaration=Jj,$.flattenGlobalEvent=Wj,$.flattenInputMap=Yj,$.flattenInstalledProject=Hj,$.flattenInternalCall=zj,$.flattenLiteralValue=Xj,$.flattenLoop=Qj,$.flattenOperation=ex,$.flattenOutputMap=tx,$.flattenPrimitiveEntity=rx,$.flattenProject=ix,$.flattenProjectElements=Bj,$.flattenProperty=sx,$.flattenRelatedCanvasElementsOnTheLeft=yx,$.flattenRelatedCanvasElementsOnTheRight=Jy,$.flattenReturnDeclaration=nx,$.flattenReturnStatement=ax,$.flattenSearch=ox,$.flattenValueDescriptor=lx,$.flattenVariableDeclaration=dx,$.flattenVariableInstance=ux,$.flattenVariableReads=Lj,$.flattenVariableWrites=Nj,$.flattenVariables=Ht,$.fromChangeSetToRecordChangeSet=xme,$.fromLiteralValueTypeToPrimitiveType=qb,$.fromZodParseToEntityGenerationErrors=Wb,$.functionCallValidation=ume,$.functionDeclarationValidation=Bfe,$.generate=gh,$.generateActionExample=ime,$.generateExecutionDataType=Ife,$.generateIdFromStrategy=Ar,$.generateMutablePropertiesExplanation=Vy,$.generatePlaceholderValueStore=j0e,$.generateRandomBoolean=eN,$.generateRandomDate=VV,$.generateRandomDateAfter=CV,$.generateRandomDateBefore=$V,$.generateRandomDateBetweenRange=PV,$.generateRandomNumber=YV,$.generateRandomNumberAfter=ZV,$.generateRandomNumberBefore=JV,$.generateRandomNumberBetweenRange=WV,$.generateRandomText=QV,$.generateRandomTextAfter=HV,$.generateRandomTextBefore=zV,$.generateRandomTextBetweenRange=XV,$.generateStandaloneIfDefault=x0e,$.generateUniqueUUID=SV,$.getAllActionDescriptorsForConditions=xy,$.getAllActionDescriptorsForGlobalEvents=Uy,$.getAllActionDescriptorsForLoops=jy,$.getAllActionDescriptorsForOperations=ome,$.getAllBuiltInEntityIds=Ps,$.getAllGloballyDeclaredFunctionDeclarationsExplanation=uj,$.getBaseBuiltInEntities=wi,$.getBaseSchemaBasedOnType=rj,$.getBuiltInEntityOwner=Qa,$.getCallableEntityReferenceSchema=Yr,$.getCallableEntityTypeSchema=P4,$.getCalledBy=ys,$.getCallerEntityReferenceSchema=Hue,$.getCallerEntityTypeSchema=Yue,$.getCalls=qy,$.getCanvasEntitiesDerivedFromInternalCalls=hx,$.getCanvasEntitiesDerivedFromWrites=_d,$.getCanvasEntityDerivedFromValueReadingEntity=Zy,$.getCanvasEntityDerivedFromValueReadingEntityFromTransfer=fx,$.getCanvasEntityReferenceSchema=fce,$.getCanvasEntityTypeSchema=pce,$.getChildrenEntityWithValues=_j,$.getColumnProperties=Dd,$.getCommonAncestor=uA,$.getCommonChildren=Ky,$.getDatabaseEntities=Bme,$.getDatabaseEntity=Ume,$.getDeclaration=oi,$.getDeclarationOutputedError=Gme,$.getDeepestScope=bx,$.getDefaultRelationalDatabaseEntityOrFirst=Ix,$.getDraggableCallableEntityReferenceSchema=N4,$.getDraggableCallableEntityTypeSchema=V4,$.getDraggableCallerEntityReferenceSchema=Xue,$.getDraggableCallerEntityTypeSchema=zue,$.getDraggableExecutableEntityReferenceSchema=rce,$.getDraggableExecutableEntityTypeSchema=tce,$.getDraggablePassThroughCallableEntityReferenceSchema=ly,$.getDraggablePassThroughCallableEntityTypeSchema=oy,$.getDraggablePlayableEntityReferenceSchema=oce,$.getDraggablePlayableEntityTypeSchema=ace,$.getEntitiesCreatedSinceInitialization=rm,$.getEntitiesToPropagateValuesTo=sn,$.getEntityArgumentDeclarations=fA,$.getEntityInputMaps=cx,$.getEntityOutputMaps=gme,$.getEntityReferenceSchema=cce,$.getEntityReturnDeclarations=px,$.getEntityTypeSchema=uce,$.getEntityWithLogicScopeReferenceSchema=oa,$.getEntityWithLogicScopeTypeSchema=ice,$.getEntityWithValueReferenceSchema=$4,$.getEntityWithValueTypeSchema=Wue,$.getEntryPointEntityReferenceSchema=Kr,$.getEntryPointEntityTypeSchema=Ba,$.getEventEntityReferenceSchema=ny,$.getEventEntityTypeSchema=sy,$.getExecutableEntityReferenceSchema=ece,$.getExecutableEntityTypeSchema=Que,$.getExtendedBuiltInEntity=Dme,$.getExtendedDefinitionEntity=Wy,$.getFirstNonLoopScopeOwner=$r,$.getGenerationTargetSchemaBasedOnType=ij,$.getHeadIfPartOfDetachedBranch=vx,$.getHighestScope=Tx,$.getImplementedBuiltInEntity=Ome,$.getIsInteractive=Rp,$.getLastInListOperation=hv,$.getLastInListOperationError=Rg,$.getLastInListOperationErrorParentRef=wg,$.getLastInListOperationInputListArgument=bg,$.getLastInListOperationInputListArgumentParentRef=Tg,$.getLastInListOperationInputListArgumentRef=yg,$.getLastInListOperationInputListDataType=mg,$.getLastInListOperationOutputElementDataType=Eg,$.getLastInListOperationOutputElementReturn=Ig,$.getLastInListOperationOutputElementReturnParentRef=Ag,$.getLastInListOperationOutputElementReturnRef=vg,$.getLinkedEntitiesFromArgumentDeclaration=bme,$.getLiteralValueNameFromDataType=Zo,$.getLowestPersistedEntityImplementation=mA,$.getParentCallableEntity=Ij,$.getParentCallerEntity=Rj,$.getParentCanvasEntities=zr,$.getParentCanvasEntity=ur,$.getParentCanvasEntityFromTransfer=ky,$.getParentEntryPoint=mme,$.getParentPassthroughCallableEntity=wj,$.getPassThroughCallableEntityReferenceSchema=dr,$.getPassThroughCallableEntityTypeSchema=ay,$.getPeristedEntities=Lme,$.getPlayableEntityReferenceSchema=nce,$.getPlayableEntityTypeSchema=sce,$.getProject=M0e,$.getPrototypeByType=_p,$.getRecusriveParentsIds=Xy,$.getReferenceEntityId=W,$.getReferencedEntitiesStateOrErrors=Ly,$.getReferencedEntityStateOrErrors=Yb,$.getReferencedIds=Rd,$.getRelatedCanvasElementsOnTheLeft=Xa,$.getRelatedCanvasElementsOnTheLeftFromTransfer=wme,$.getRelatedCanvasElementsOnTheRight=tn,$.getRootEntryPointScopeOwner=bA,$.getScopeOwner=Ri,$.getStateClassFromType=jme,$.getTerminationReferenceSchema=dce,$.getTerminationTypeSchema=lce,$.getTopLevelParentEntityId=wx,$.getTouchedCanvasEntitiesFromChangeSet=Fme,$.getUsedArgFromDeclaration=Rme,$.getUsedReturnFromDeclaration=_me,$.getValueReadingEntityReferenceSchema=C4,$.getValueReadingEntityTypeSchema=aa,$.getValueWritingEntityReferenceSchema=Jue,$.getValueWritingEntityTypeSchema=uc,$.getVariableFromInputMapping=Dj,$.getVariableFromReturnVariablePointer=$j,$.getVariableReferenceSchema=La,$.getVariableTypeSchema=Fo,$.getVariablesFromArgumentDeclarations=Sy,$.getVariablesFromInputMaps=Oj,$.getVariablesFromOutputMapping=Pj,$.getVariablesFromOutputMaps=Vj,$.getVariablesFromReturnDeclarations=Cj,$.getVariablesInSameOrHigherScope=fb,$.getWrites=pA,$.globalEventValidation=kfe,$.groupCallsBasedOnParallelizableExecution=cA,$.handleAfterEntityImplementationSideEffects=vj,$.handleBeforeEntityImplementationSideEffects=mj,$.handleLiteralValueChange=F0e,$.handleLiteralValueDelete=zx,$.handleValueAsTypeChange=G0e,$.handleValueAsTypeDelete=e5,$.httpRequestBodyArgument=jf,$.httpRequestBodyArgumentRef=aO,$.httpRequestBodyDataType=oO,$.httpRequestHeadersArgument=Uf,$.httpRequestHeadersArgumentRef=sO,$.httpRequestHeadersDataType=nO,$.httpRequestMethodArgument=Bf,$.httpRequestMethodArgumentRef=rO,$.httpRequestMethodDataType=iO,$.httpRequestMethodDataTypeRef=eO,$.httpRequestOperation=Iu,$.httpRequestOperationErrorValueDescriptor=Iv,$.httpRequestOperationErrorValueDescriptorDatatype=gO,$.httpRequestOperationErrorValueDescriptorRef=_O,$.httpRequestOperationRef=AO,$.httpRequestOperationRefEight=wO,$.httpRequestOperationRefFive=TO,$.httpRequestOperationRefFour=EO,$.httpRequestOperationRefNine=RO,$.httpRequestOperationRefSeven=IO,$.httpRequestOperationRefSix=bO,$.httpRequestOperationRefThree=vO,$.httpRequestOperationRefTwo=mO,$.httpRequestQueryParamsArgument=Av,$.httpRequestQueryParamsArgumentRef=XD,$.httpRequestQueryParamsDataType=QD,$.httpRequestVariableURLArgument=Mf,$.httpRequestVariableURLArgumentRef=HD,$.httpRequestVariableURLDataType=zD,$.httpRequestVariableURLDataTypeRef=WD,$.httpResponseBodyReturnDataType=yO,$.httpResponseBodyReturnDataTypeRef=fO,$.httpResponseBodyReturnReturn=Gf,$.httpResponseBodyReturnReturnRef=hO,$.httpResponseCodeDataType=dO,$.httpResponseCodeReturn=xf,$.httpResponseCodeReturnRef=lO,$.httpResponseHeadersDataType=pO,$.httpResponseHeadersDataTypeRef=uO,$.httpResponseHeadersReturn=Ff,$.httpResponseHeadersReturnRef=cO,$.httpStatusCodeValueValidation=Lx,$.hydrateOrDiscardLiteralValue=Fx,$.implement=Fy,$.inferArgumentDeclarationDataType=ZB,$.inferDataType=zs,$.inferInputMapDataType=ub,$.inferOutputMapDataType=pb,$.inferPropertyDataType=YB,$.inferReturnDeclarationDataType=cb,$.inferValueDescriptorDataType=HB,$.inferVariableDeclarationDataType=WB,$.inferVariableInstanceDataType=JB,$.initBaseProjectEntity=tm,$.initProject=Ux,$.initProjectFromFetchResult=Mx,$.inputMapValidation=kye,$.installedProjectValidation=Gye,$.internalCallValidation=Kye,$.isPromise=sA,$.isUUID=sM,$.iterateOverListActionDescriptorListArgumentDeclaration=aC,$.iterateOverListActionDescriptorListArgumentDeclarationDataType=sC,$.iterateOverListActionDescriptorListArgumentDeclarationDataTypeParentRef=iC,$.iterateOverListActionDescriptorListArgumentDeclarationParentRef=nC,$.iterateOverListLoopActionDescriptor=Ra,$.iterateOverListLoopActionDescriptorDynamicReturnDeclaration=lC,$.iterateOverListLoopActionDescriptorDynamicReturnDeclarationParentRef=oC,$.iterateOverListLoopBodyActionDescriptor=_u,$.iterateOverListLoopBodyActionDescriptorAnyDynamicArgument=vC,$.iterateOverListLoopBodyActionDescriptorAnyDynamicArgumentParentRef=mC,$.iterateOverListLoopBodyActionDescriptorAnyDynamicReturn=TC,$.iterateOverListLoopBodyActionDescriptorAnyDynamicReturnParentRef=EC,$.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Sf,$.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=uC,$.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=dC,$.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=cC,$.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclaration=yC,$.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=fC,$.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=pC,$.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=hC,$.iterateOverObjectKeysActionDescriptorObjectArgumentDeclaration=RC,$.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataType=IC,$.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataTypeParentRef=AC,$.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationParentRef=wC,$.iterateOverObjectKeysLoopActionDescriptor=Vl,$.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclaration=gC,$.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclarationParentRef=_C,$.iterateOverObjectKeysLoopBodyActionDescriptor=Dv,$.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgument=BC,$.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgumentParentRef=LC,$.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturn=UC,$.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturnParentRef=MC,$.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclaration=gv,$.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=OC,$.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=DC,$.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=CC,$.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclaration=NC,$.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=PC,$.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=$C,$.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=VC,$.iterateOverObjectValuesActionDescriptorObjectArgumentDeclaration=KC,$.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataType=FC,$.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataTypeParentRef=xC,$.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationParentRef=GC,$.iterateOverObjectValuesLoopActionDescriptor=Nl,$.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclaration=qC,$.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclarationParentRef=kC,$.iterateOverObjectValuesLoopBodyActionDescriptor=Cv,$.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgument=QC,$.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgumentParentRef=XC,$.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturn=t$,$.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturnParentRef=e$,$.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Ov,$.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=ZC,$.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=SC,$.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=JC,$.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclaration=zC,$.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=YC,$.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=WC,$.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=HC,$.iterateOverStringActionDescriptorDynamicReturnDeclaration=SO,$.iterateOverStringActionDescriptorDynamicReturnDeclarationParentRef=qO,$.iterateOverStringActionDescriptorStringArgumentDeclaration=kO,$.iterateOverStringActionDescriptorStringArgumentDeclarationDataType=GO,$.iterateOverStringActionDescriptorStringArgumentDeclarationDataTypeParentRef=FO,$.iterateOverStringActionDescriptorStringArgumentDeclarationParentRef=KO,$.iterateOverStringLoopActionDescriptor=Ru,$.iterateOverStringLoopBodyActionDescriptor=qf,$.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgument=QO,$.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgumentParentRef=XO,$.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturn=tC,$.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturnParentRef=eC,$.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Rv,$.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=JO,$.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=ZO,$.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=WO,$.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclaration=_v,$.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=HO,$.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=YO,$.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=zO,$.joinListOperation=cv,$.joinListOperationError=W_,$.joinListOperationErrorParentRef=J_,$.joinListOperationFirstListArgument=K_,$.joinListOperationFirstListArgumentParentRef=G_,$.joinListOperationFirstListArgumentRef=B_,$.joinListOperationFirstListDataType=M_,$.joinListOperationResultListDataType=F_,$.joinListOperationResultListReturn=Z_,$.joinListOperationResultListReturnParentRef=S_,$.joinListOperationResultListReturnRef=x_,$.joinListOperationSecondListArgument=q_,$.joinListOperationSecondListArgumentParentRef=k_,$.joinListOperationSecondListArgumentRef=U_,$.joinListOperationSecondListDataType=j_,$.joinListWithLastSeparator=qe,$.joinStringsOperation=Au,$.joinStringsOperationDynamicStringArgument=h_,$.joinStringsOperationDynamicStringArgumentParentRef=f_,$.joinStringsOperationDynamicStringArgumentRef=c_,$.joinStringsOperationDynamicStringDataType=p_,$.joinStringsOperationError=u_,$.joinStringsOperationErrorParentRef=d_,$.joinStringsOperationFirstStringArgument=Vf,$.joinStringsOperationFirstStringArgumentParentRef=e_,$.joinStringsOperationFirstStringArgumentRef=WR,$.joinStringsOperationFirstStringDataType=YR,$.joinStringsOperationResultStringDataType=QR,$.joinStringsOperationResultStringReturn=bu,$.joinStringsOperationResultStringReturnParentRef=l_,$.joinStringsOperationResultStringReturnRef=XR,$.joinStringsOperationSecondStringArgument=Nf,$.joinStringsOperationSecondStringArgumentParentRef=o_,$.joinStringsOperationSecondStringArgumentRef=HR,$.joinStringsOperationSecondStringDataType=zR,$.joinStringsOperationSeparatorStringArgument=a_,$.joinStringsOperationSeparatorStringArgumentParentRef=n_,$.joinStringsOperationSeparatorStringArgumentRef=t_,$.joinStringsOperationSeparatorStringDataType=s_,$.joinStringsOperationSeparatorStringDataTypeDefaultValue=i_,$.joinStringsOperationSeparatorStringDataTypeDefaultValueParentRef=r_,$.keyValuePrototype=Cl,$.literalValueValidation=Pfe,$.loopValidation=Sfe,$.lowercaseFirstLetter=fd,$.manualFlowActionDescriptorDeclarationArgumentDeclaration=wv,$.manualFlowActionDescriptorDeclarationArgumentDeclarationDataType=NO,$.manualFlowActionDescriptorDeclarationArgumentDeclarationDataTypeParentRef=VO,$.manualFlowActionDescriptorDeclarationArgumentDeclarationParentRef=LO,$.manualFlowLoopActionDescriptor=Kf,$.manualFlowLoopActionDescriptorDynamicReturnDeclaration=PO,$.manualFlowLoopActionDescriptorDynamicReturnDeclarationParentRef=$O,$.manualFlowLoopBodyActionDescriptor=kf,$.manualFlowLoopBodyActionDescriptorAnyDynamicArgument=MO,$.manualFlowLoopBodyActionDescriptorAnyDynamicArgumentParentRef=BO,$.manualFlowLoopBodyActionDescriptorAnyDynamicReturn=jO,$.manualFlowLoopBodyActionDescriptorAnyDynamicReturnParentRef=UO,$.mapActionDescriptorToTypeItRepresents=Vme,$.mapRecord=Uj,$.mergeArraysOfStringsWithoutDuplicates=tve,$.mergeEntityErrorsList=Jle,$.mergeListOfEntities=$me,$.methodDefaultValue=tO,$.mockClientProject=iT,$.moreThanOrEqualCondition=jl,$.moreThanOrEqualConditionLeftHandArgument=zP,$.moreThanOrEqualConditionLeftHandArgumentDataType=YP,$.moreThanOrEqualConditionLeftHandArgumentDataTypeParentRef=WP,$.moreThanOrEqualConditionLeftHandArgumentParentRef=HP,$.moreThanOrEqualConditionRightHandArgument=tV,$.moreThanOrEqualConditionRightHandArgumentDataType=QP,$.moreThanOrEqualConditionRightHandArgumentDataTypeParentRef=XP,$.moreThanOrEqualConditionRightHandArgumentParentRef=eV,$.noSpacesOrDashesValueValidation=Aj,$.noSpacesValueValidation=bj,$.notEmptyCondition=go,$.notEmptyConditionArgument=ZP,$.notEmptyConditionRef=SP,$.nullPrototype=iv,$.numberAdditionOperation=Pf,$.numberAdditionOperationDynamicSummandArgument=$R,$.numberAdditionOperationDynamicSummandArgumentType=CR,$.numberAdditionOperationDynamicSummandArgumentTypeParentRef=OR,$.numberAdditionOperationError=DR,$.numberAdditionOperationErrorParentRef=gR,$.numberAdditionOperationFirstNumberArgument=sv,$.numberAdditionOperationFirstNumberArgumentRef=ER,$.numberAdditionOperationFirstNumberDataType=TR,$.numberAdditionOperationRef=RR,$.numberAdditionOperationRefThree=av,$.numberAdditionOperationRefTwo=_R,$.numberAdditionOperationResultNumberDataType=wR,$.numberAdditionOperationResultNumberReturn=ov,$.numberAdditionOperationResultNumberReturnRef=IR,$.numberAdditionOperationSecondNumberArgument=nv,$.numberAdditionOperationSecondNumberArgumentRef=bR,$.numberAdditionOperationSecondNumberDataType=AR,$.numberPrototype=dt,$.numberSubtractionOperation=dv,$.numberSubtractionOperationDynamicSubtrahendArgument=ZR,$.numberSubtractionOperationDynamicSubtrahendArgumentType=SR,$.numberSubtractionOperationDynamicSubtrahendArgumentTypeParentRef=qR,$.numberSubtractionOperationError=kR,$.numberSubtractionOperationErrorParentRef=KR,$.numberSubtractionOperationFirstNumberArgument=UR,$.numberSubtractionOperationFirstNumberArgumentRef=PR,$.numberSubtractionOperationFirstNumberDataType=VR,$.numberSubtractionOperationRef=lv,$.numberSubtractionOperationRefThree=FR,$.numberSubtractionOperationRefTwo=jR,$.numberSubtractionOperationResultNumberDataType=MR,$.numberSubtractionOperationResultNumberReturn=GR,$.numberSubtractionOperationResultNumberReturnRef=BR,$.numberSubtractionOperationSecondNumberArgument=xR,$.numberSubtractionOperationSecondNumberArgumentRef=NR,$.numberSubtractionOperationSecondNumberDataType=LR,$.numberValueAutogenerationSchema=oT,$.operationValidation=xfe,$.orderEntitiesForTraversal=cme,$.outputMapValidation=Zye,$.parallelExecutionOperation=Ss,$.parallelExecutionOperationError=Qg,$.parallelExecutionOperationErrorParentRef=Xg,$.parallelExecutionOperationListOfExecutionResultsDataType=Yg,$.parallelExecutionOperationListOfExecutionResultsReturn=Ev,$.parallelExecutionOperationListOfExecutionResultsReturnRef=Wg,$.parallelExecutionOperationListOfFunctionsArgument=vv,$.parallelExecutionOperationListOfFunctionsArgumentDatatype=Jg,$.parallelExecutionOperationListOfFunctionsArgumentRef=Zg,$.parallelExecutionOperationListOfFunctionsBlueprint=Sg,$.parallelExecutionOperationListOfFunctionsBlueprintDynamicInput=kg,$.parallelExecutionOperationListOfFunctionsBlueprintDynamicInputParentRef=Kg,$.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutput=Gg,$.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutputParentRef=Fg,$.parallelExecutionOperationListOfFunctionsBlueprintParentRef=qg,$.parallelExecutionOperationRef=Hg,$.parallelExecutionOperationRefThree=zg,$.persistedBuiltInBaseEntity=ti,$.persistedBuiltInBaseEntityDatabaseProperty=Bl,$.persistedBuiltInBaseEntityDatabasePropertyDataType=gP,$.persistedBuiltInBaseEntityDatabasePropertyDataTypeRef=G9,$.persistedBuiltInBaseEntityDatabasePropertyParentRef=DP,$.persistedBuiltInBaseEntityDatabasePropertyRef=_P,$.persistedBuiltInBaseEntityPrimaryKeyProperty=Ml,$.persistedBuiltInBaseEntityPrimaryKeyPropertyDataType=BP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOption=CP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOptionParentRef=OP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyParentRef=MP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyRef=LP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOption=PP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOptionParentRef=$P,$.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOption=NP,$.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOptionParentRef=VP,$.printEntity=oA,$.processOutputGlobalValueDescriptorDataType=lV,$.processOutputGlobalValueDescriptorReturn=eh,$.processOutputGlobalValueDescriptorReturnRef=oV,$.projectPublicationCompletedGlobalEvent=Qf,$.propagateNewInputOrOutputMapValueAsTypeToParentVariable=Mp,$.propagateNewInputOrOutputMapValueToParentVariable=Bp,$.propagateNewStaticPropertyValueAsTypeToVariables=Qo,$.propagateNewStaticPropertyValueToVariables=Xo,$.propertyToZodSchema=DV,$.propertyValidation=Ofe,$.readValueFromWritter=Od,$.rebaseStack=_b,$.relationalDatabaseBuiltInBaseEntity=Wr,$.relationalDatabaseBuiltInBaseEntityAutoscalingProperty=kv,$.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataType=AP,$.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataTypeRef=bP,$.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyParentRef=IP,$.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyRef=TP,$.relationalDatabaseBuiltInBaseEntityDefaultProperty=Kv,$.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataType=EP,$.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataTypeRef=mP,$.relationalDatabaseBuiltInBaseEntityDefaultPropertyRef=vP,$.relationalDatabaseBuiltInBaseEntityIdentifierProperty=Jf,$.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataType=oP,$.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataTypeRef=nP,$.relationalDatabaseBuiltInBaseEntityIdentifierPropertyRef=aP,$.relationalDatabaseBuiltInBaseEntityMinSizeProperty=Hf,$.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataType=yP,$.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataTypeRef=fP,$.relationalDatabaseBuiltInBaseEntityMinSizePropertyRef=hP,$.relationalDatabaseBuiltInBaseEntityPasswordProperty=Yf,$.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataType=cP,$.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataTypeRef=F9,$.relationalDatabaseBuiltInBaseEntityPasswordPropertyDefaultValueParentRef=pP,$.relationalDatabaseBuiltInBaseEntityPasswordPropertyRef=uP,$.relationalDatabaseBuiltInBaseEntityRef=Ll,$.relationalDatabaseBuiltInBaseEntityUsernameProperty=Wf,$.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataType=dP,$.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataTypeRef=x9,$.relationalDatabaseBuiltInBaseEntityUsernamePropertyRef=lP,$.removeDisabledReasons=ive,$.resolveActionDescriptorName=rM,$.resolveArgumentDeclarationValue=gA,$.resolveBaseEntityName=XB,$.resolveBuiltInBaseEntityDataTypeLabel=QB,$.resolveCardSubheader=q0e,$.resolveClonedEntityProject=Ir,$.resolveConditionOperatorLabel=Ey,$.resolveDataType=my,$.resolveDataTypeEntityOrNestedChildrenFromLiteralValue=aA,$.resolveDataTypeLabel=yd,$.resolveDatatypeIconName=k0e,$.resolveDefinitionEntityDataTypeLabel=_fe,$.resolveDefinitionEntitySubheader=LA,$.resolveEntityCodeName=bb,$.resolveEntityDataTypeLabel=Rfe,$.resolveEntityName=re,$.resolveEntitySubheader=S0e,$.resolveFirstCallsSecond=Eme,$.resolveFirstWritesSecond=Tme,$.resolveFunctionDeclarationCardSubheader=BA,$.resolveInputMapNextStandaloneValue=CA,$.resolveInputMapNextValue=Lp,$.resolveInputMapNextValueAsPropertyOfAnObject=qx,$.resolveInputMapStandaloneValue=$A,$.resolveInputMapValue=Zx,$.resolveInputMapValueAsPropertyOfAnObject=Sx,$.resolveMethodCardSubheader=r5,$.resolveNextValue=nm,$.resolveOutputMapValue=OA,$.resolvePersistedDefinitionEntityDatabaseEntity=Ax,$.resolvePrimaryKeyProperty=Mme,$.resolvePrimitiveEntityForSearchLiteralValueType=Sb,$.resolvePrimitiveEntityName=tM,$.resolvePropertyValue=Jx,$.resolveReturnDeclarationValue=DA,$.resolveSearchName=eM,$.resolveValue=eo,$.resolveValueDescriptorValue=Wx,$.resolveVarDeclarationAggregateObjectValue=Kx,$.resolveVarDeclarationNextAggregateObjectValue=Gx,$.resolveVarDeclarationNextValue=Np,$.resolveVarDeclarationValue=_A,$.resolveVarInstanceNextValue=sm,$.resolveVarInstanceValue=kx,$.resolveVariableScope=wfe,$.returnDeclarationValidation=Ffe,$.returnStatementValidation=Gfe,$.searchStatementErrorGlobalValueDescriptor=Yv,$.searchStatementErrorGlobalValueDescriptorDataType=uV,$.searchStatementErrorGlobalValueDescriptorRef=dV,$.searchStatementState=jye,$.searchStatementUtils=Fye,$.searchValidation=Hfe,$.sequentialExecutionOperation=Xn,$.sequentialExecutionOperationError=TD,$.sequentialExecutionOperationErrorParentRef=ED,$.sequentialExecutionOperationListOfExecutionResultsDataType=yD,$.sequentialExecutionOperationListOfExecutionResultsReturn=bv,$.sequentialExecutionOperationListOfExecutionResultsReturnParentRef=vD,$.sequentialExecutionOperationListOfExecutionResultsReturnRef=hD,$.sequentialExecutionOperationListOfFunctionsArgument=Tv,$.sequentialExecutionOperationListOfFunctionsArgumentDatatype=fD,$.sequentialExecutionOperationListOfFunctionsArgumentParentRef=mD,$.sequentialExecutionOperationListOfFunctionsArgumentRef=pD,$.sequentialExecutionOperationListOfFunctionsBlueprint=cD,$.sequentialExecutionOperationListOfFunctionsBlueprintDynamicInput=uD,$.sequentialExecutionOperationListOfFunctionsBlueprintDynamicOutput=dD,$.softDeletePersistedEntityMethod=K9,$.softDeletePersistedEntityMethodParentRef=UP,$.sortCallsBasedOnExecutionDependencies=gj,$.sortChildrenEntitiesBasedOnExecutionDependencies=vme,$.splitListOperation=fv,$.splitListOperationError=pg,$.splitListOperationErrorParentRef=cg,$.splitListOperationFirstOutputListDataType=tg,$.splitListOperationFirstOutputListReturn=og,$.splitListOperationFirstOutputListReturnParentRef=ag,$.splitListOperationFirstOutputListReturnRef=pv,$.splitListOperationInputListArgument=ig,$.splitListOperationInputListArgumentParentRef=rg,$.splitListOperationInputListArgumentRef=z_,$.splitListOperationInputListDataType=X_,$.splitListOperationSecondOutputListDataType=lg,$.splitListOperationSecondOutputListReturn=ug,$.splitListOperationSecondOutputListReturnParentRef=dg,$.splitListOperationSplitIndexArgument=ng,$.splitListOperationSplitIndexArgumentParentRef=sg,$.splitListOperationSplitIndexArgumentRef=Q_,$.splitListOperationSplitIndexDataType=eg,$.splitStringOperation=uv,$.splitStringOperationError=P_,$.splitStringOperationErrorParentRef=$_,$.splitStringOperationFirstPartResultStringDataType=b_,$.splitStringOperationFirstPartResultStringReturn=C_,$.splitStringOperationFirstPartResultStringReturnParentRef=O_,$.splitStringOperationFirstPartResultStringReturnRef=T_,$.splitStringOperationIndexArgument=g_,$.splitStringOperationIndexArgumentParentRef=__,$.splitStringOperationIndexArgumentRef=v_,$.splitStringOperationIndexDataType=E_,$.splitStringOperationSecondPartResultStringDataType=I_,$.splitStringOperationSecondPartResultStringReturn=U9,$.splitStringOperationSecondPartResultStringReturnParentRef=D_,$.splitStringOperationSecondPartResultStringReturnRef=A_,$.splitStringOperationStringArgument=R_,$.splitStringOperationStringArgumentParentRef=w_,$.splitStringOperationStringArgumentRef=y_,$.splitStringOperationStringDataType=m_,$.stringPrototype=Se,$.stringValueAutogenerationSchema=aT,$.suggestNewIdForEntity=Ab,$.syncSearchEntityOutput=Jb,$.test_primitive_entities_export=g0e,$.toCamelCase=kr,$.toEntityState=_i,$.toKebabCase=zB,$.toLowerCaseKebabCase=vy,$.toPascalCase=hd,$.transitionProjectVersion=wb,$.translateLogicErrorCode=W0e,$.translateLogicErrorCodeShort=Y0e,$.translateLogicErrorCodeShortWithEntityName=H0e,$.translateLogicErrorCodeWithEntityName=z0e,$.traverseChangeSet=Rb,$.untypedDataPrototype=Jr,$.updateErrorsList=zt,$.urlDefaultValue=YD,$.uuidPrototype=Hn,$.validateArgumentDeclarationName=Eb,$.validateCalledByErrorIdInAction=nme,$.validateCalledByIdInAction=sme,$.validateCallers=dj,$.validateConditionEntityDeclaration=lme,$.validateDataOperation=Ao,$.validateDataOperationDataToValidateArgument=jD,$.validateDataOperationDataToValidateArgumentParentRef=UD,$.validateDataOperationDataToValidateArgumentRef=BD,$.validateDataOperationDataToValidateDataType=MD,$.validateDataOperationEntityToMatchTypeArgument=KD,$.validateDataOperationEntityToMatchTypeArgumentParentRef=GD,$.validateDataOperationEntityToMatchTypeArgumentRef=xD,$.validateDataOperationEntityToMatchTypeDataType=FD,$.validateDataOperationError=ZD,$.validateDataOperationErrorParentRef=SD,$.validateDataOperationOutputEntityDeclaration=qD,$.validateDataOperationOutputEntityDeclarationParentRef=kD,$.validateDefinitionEntityName=hb,$.validateEntityValues=t5,$.validateEntryCaller=lj,$.validateErrorCaller=oj,$.validateFunctionCallDeclaration=cj,$.validateFunctionDeclarationName=yb,$.validateGeneratedEntityParentIsNotBuiltInEntity=eme,$.validateGeneration=Xye,$.validateGenerationTarget=vr,$.validateGenerationUpdate=Qye,$.validateLogic=K0e,$.validateLoopEntityDeclaration=dme,$.validateName=gfe,$.validateOperationEntityDeclaration=pj,$.validatePropertyName=vb,$.validateReachability=fa,$.validateReadsValueInActionPayload=ame,$.validateReferenceObject=Ny,$.validateReferenceToOne=Hb,$.validateReferences=Mr,$.validateReturnDeclarationName=Tb,$.validateSuccessCaller=aj,$.validateValueReaderGenerationUpdate=bp,$.validateValueWritter=rA,$.validateVariableDeclarationName=mb,$.validateVariableInternalCallUse=iA,$.valueAutogenerationCurrentDateAndTimeSchema=l4,$.valueAutogenerationGenericSchema=kh,$.valueAutogenerationOptions=dT,$.valueAutogenerationOptionsSchema=o4,$.valueAutogenerationRandomBooleanSchema=nT,$.valueAutogenerationRandomDateBetweenSchema=v4,$.valueAutogenerationRandomDateFromSchema=y4,$.valueAutogenerationRandomDateSchema=Zh,$.valueAutogenerationRandomDateUntilSchema=m4,$.valueAutogenerationRandomNumberBetweenSchema=c4,$.valueAutogenerationRandomNumberFromSchema=d4,$.valueAutogenerationRandomNumberSchema=qh,$.valueAutogenerationRandomNumberUntilSchema=u4,$.valueAutogenerationRandomSchema=ic,$.valueAutogenerationRandomTextBetweenSchema=h4,$.valueAutogenerationRandomTextFromSchema=p4,$.valueAutogenerationRandomTextSchema=Sh,$.valueAutogenerationRandomTextUntilSchema=f4,$.valueAutogenerationRangeValueTypesSchema=rc,$.valueAutogenerationUniqueSchema=sT,$.valueDescriptorValidation=zye,$.variableDeclarationValidation=Wfe,$.variableInstanceValidation=Yfe,$.waitOperation=gi,$.waitOperationMillisecondsNumberArgument=To,$.waitOperationMillisecondsNumberArgumentRef=rD,$.waitOperationMillisecondsNumberDataType=iD,$.waitOperationOperationError=aD,$.waitOperationOperationErrorParentRef=nD,$.waitOperationRef=sD,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6349",
3
+ "version": "0.0.6350",
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",