@elyx-code/project-logic-tree 0.0.6109 → 0.0.6110

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.
@@ -64,7 +64,7 @@ All built-in 'action-descriptor' entity ids are:
64
64
  `;a.push(new b({id:`${r.id}--${h.InvalidReference}`,code:h.InvalidReference,severity:T.Error,message:`Entity of type "${n.Operation}" with id "${r.id}", has an invalid reference at the 'declaration' property. The 'declaration' property must be a valid reference to an 'action-descriptor' entity.
65
65
  References can either be an ID string or an object with exacly four properties: 'id', 'entityId', 'entityType', 'type'.${l}`,issue:null}))}return{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
66
66
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
67
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addOperation(this),(a=this.process)==null||a.writesValues.forEach(s=>{s.setValueWriter(this.process),e.push(s)}),this.successCalls.forEach(s=>{s.addSuccessCaller(this),e.push(s)}),this.errorCalls.forEach(s=>{s.addErrorCaller(this),e.push(s)}),this.calledBySuccess.forEach(s=>{s.addSuccessCall(this),e.push(s)}),this.calledByError.forEach(s=>{s.addErrorCall(this),e.push(s)}),this.calledByEntry.forEach(s=>{s.addCall(this),e.push(s)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addValueReader(e){var t;return(t=this.process)==null||t.addValueReader(e),this}removeValueReader(e){var t;return(t=this.process)==null||t.removeValueReader(e),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?t.setParent(this.parent.parent):t.type!==n.InternalCall&&t.setParent(this.parent),t.initChildren(),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.syncMissingFixedInputs(),this.syncMissingFixedOutputs(),this.declaration.syncOperationInstance(this),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s;const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:o,removed:l}=(s=this.process)==null?void 0:s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}if(this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.outputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.error){const{affected:o,removed:l}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}return this.successCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),this.errorCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),e||this.calledBy.forEach(o=>{r.push(o),o.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.process){const{affected:r}=this.process.restore({seenEntities:e});t.push(...r)}return this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.error?this.error.toFlatIds(e):[]])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:(e=this.process)==null?void 0:e.toJSON(),declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),parent:this.parent.toReference(),error:(t=this.error)==null?void 0:t.toJSON()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference():null,inputs:this.inputs.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),declaration:this.declaration.toReference(),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.process?this.process.toFlatJSON(e):[],...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.process?this.process.toFlatGenerationTarget(e):[],...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=N2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new de(this.toJSON(),this.project)}removeUnrecognizedInputs(){const e=[],t=[],r=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}removeUnrecognizedOutputs(){const e=[],t=[],r=[];return this.outputs.forEach(a=>{if(!this.declaration.outputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedInputs(){const e=[],t=[],r=[],a=this.declaration.inputs.filter(p=>p.parentRelationType===O.FixedArguments&&!this.inputs.find(y=>y.declaration.id===p.id));this.inputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.inputs.forEach(m=>{m.index>=p.index&&m.sync({index:m.index+1})});const y={id:_.UUID.uuid(),version:1,type:n.InputMap,declaration:p.toJSON(),readsValue:null,defaultValue:null,index:p.index,name:null,description:null,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject()}),this.inputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedInputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedOutputs(){const e=[],t=[],r=[],a=this.declaration.outputs.filter(p=>p.parentRelationType===O.FixedReturns&&!this.outputs.find(y=>y.declaration.id===p.id));this.outputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.outputs.forEach(m=>{m.index>=p.index&&m.index++});const y={id:_.UUID.uuid(),version:1,type:n.OutputMap,declaration:p.toJSON(),writesValues:[],index:p.index,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject()}),this.outputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedOutputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(de,"MUTABLE_BASE_PROPERTIES",[]),c(de,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(de,"BASE_PROPERTIES",[...de.MUTABLE_BASE_PROPERTIES,...de.INMUTABLE_BASE_PROPERTIES]),c(de,"MUTABLE_META_PROPERTIES",[...de.MUTABLE_BASE_PROPERTIES,"x","y"]),c(de,"INMUTABLE_META_PROPERTIES",[...de.INMUTABLE_BASE_PROPERTIES]),c(de,"META_PROPERTIES",[...de.MUTABLE_META_PROPERTIES,...de.INMUTABLE_META_PROPERTIES]),c(de,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(de,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),c(de,"UPSTREAM_PROPERTIES",[...de.MUTABLE_UPSTREAM_PROPERTIES,...de.INMUTABLE_UPSTREAM_PROPERTIES]),c(de,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","outputs","writesValues","successCalls","errorCalls","error"]),c(de,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(de,"DOWNSTREAM_PROPERTIES",[...de.MUTABLE_DOWNSTREAM_PROPERTIES,...de.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(de,"PROPERTIES",[...de.META_PROPERTIES,...de.UPSTREAM_PROPERTIES,...de.DOWNSTREAM_PROPERTIES]);let Nr=de;function V2(i){const e=M3(),t=i.toJSON();e.safeParse(t).success;const a=St(i);i.inputs.forEach(o=>o.validate()),a.forEach(o=>o.validate());const s=[];return ie(i.errors,s)}const ue=class ue{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"collapsed");c(this,"type",n.GlobalEvent);c(this,"inputs",[]);c(this,"calls",[]);c(this,"returnStatements",[]);c(this,"parent");c(this,"implements");c(this,"detachedChildren",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.x=e.x,this.y=e.y,this.collapsed=e.collapsed}static fromGenerationTarget(e,t){let r=t;if(e.parent){const l=N(e.parent);r=t.get(l)}let a;e.implements&&(a=t.getBuiltIn(e.implements));const s={id:e.id,version:1,name:e.name,type:n.GlobalEvent,collapsed:!1,returnStatements:[],calls:[],inputs:[],implements:a,x:0,y:0,parent:r},o=g(s,t);return o.setParent(r),o.initChildren(),o}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{},t);if(r=s.modifiedData,a.push(...s.errors,...Le(r)),!e.implements)a.push(new b({id:`${e.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'implements' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for 'global-event' entities.
67
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addOperation(this),(a=this.process)==null||a.writesValues.forEach(s=>{s.setValueWriter(this.process),e.push(s)}),this.successCalls.forEach(s=>{s.addSuccessCaller(this),e.push(s)}),this.errorCalls.forEach(s=>{s.addErrorCaller(this),e.push(s)}),this.calledBySuccess.forEach(s=>{s.addSuccessCall(this),e.push(s)}),this.calledByError.forEach(s=>{s.addErrorCall(this),e.push(s)}),this.calledByEntry.forEach(s=>{s.addCall(this),e.push(s)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addValueReader(e){var t;return(t=this.process)==null||t.addValueReader(e),this}removeValueReader(e){var t;return(t=this.process)==null||t.removeValueReader(e),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?t.setParent(this.parent.parent):t.type!==n.InternalCall&&t.setParent(this.parent),t.initChildren(),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.syncMissingFixedInputs(),this.syncMissingFixedOutputs(),this.declaration.syncOperationInstance(this),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s;const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:o,removed:l}=(s=this.process)==null?void 0:s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}if(this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.outputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.error){const{affected:o,removed:l}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}return this.successCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),this.errorCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),e||this.calledBy.forEach(o=>{r.push(o),o.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.process){const{affected:r}=this.process.restore({seenEntities:e});t.push(...r)}return this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.error?this.error.toFlatIds(e):[]])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:(e=this.process)==null?void 0:e.toJSON(),declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),parent:this.parent.toReference(),error:(t=this.error)==null?void 0:t.toJSON()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference():null,inputs:this.inputs.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),declaration:this.declaration.toReference(),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.process?this.process.toFlatJSON(e):[],...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.process?this.process.toFlatGenerationTarget(e):[],...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=N2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new de(this.toJSON(),this.project)}removeUnrecognizedInputs(){const e=[],t=[],r=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}removeUnrecognizedOutputs(){const e=[],t=[],r=[];return this.outputs.forEach(a=>{if(!this.declaration.outputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedInputs(){const e=[],t=[],r=[],a=this.declaration.inputs.filter(p=>p.parentRelationType===O.FixedArguments&&!this.inputs.find(y=>y.declaration.id===p.id));this.inputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.inputs.forEach(m=>{m.index>=p.index&&m.sync({index:m.index+1})});const y={id:_.UUID.uuid(),version:1,type:n.InputMap,declaration:p.toJSON(),readsValue:null,defaultValue:null,index:p.index,name:null,description:null,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject()}),this.inputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedInputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedOutputs(){const e=[],t=[],r=[],a=this.declaration.outputs.filter(p=>p.parentRelationType===O.FixedReturns&&!this.outputs.find(y=>y.declaration.id===p.id));this.outputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.outputs.forEach(m=>{m.index>=p.index&&m.index++});const y={id:_.UUID.uuid(),version:1,type:n.OutputMap,declaration:p.toJSON(),writesValues:[],index:p.index,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject()}),this.outputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedOutputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(de,"MUTABLE_BASE_PROPERTIES",[]),c(de,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(de,"BASE_PROPERTIES",[...de.MUTABLE_BASE_PROPERTIES,...de.INMUTABLE_BASE_PROPERTIES]),c(de,"MUTABLE_META_PROPERTIES",[...de.MUTABLE_BASE_PROPERTIES,"x","y"]),c(de,"INMUTABLE_META_PROPERTIES",[...de.INMUTABLE_BASE_PROPERTIES]),c(de,"META_PROPERTIES",[...de.MUTABLE_META_PROPERTIES,...de.INMUTABLE_META_PROPERTIES]),c(de,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(de,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),c(de,"UPSTREAM_PROPERTIES",[...de.MUTABLE_UPSTREAM_PROPERTIES,...de.INMUTABLE_UPSTREAM_PROPERTIES]),c(de,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","outputs","writesValues","successCalls","errorCalls","error"]),c(de,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(de,"DOWNSTREAM_PROPERTIES",[...de.MUTABLE_DOWNSTREAM_PROPERTIES,...de.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(de,"PROPERTIES",[...de.META_PROPERTIES,...de.UPSTREAM_PROPERTIES,...de.DOWNSTREAM_PROPERTIES]);let Nr=de;function V2(i){const e=M3(),t=i.toJSON();e.safeParse(t).success;const a=St(i);i.inputs.forEach(o=>o.validate()),a.forEach(o=>o.validate());const s=[];return ie(i.errors,s)}const ue=class ue{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"collapsed");c(this,"type",n.GlobalEvent);c(this,"inputs",[]);c(this,"calls",[]);c(this,"returnStatements",[]);c(this,"parent");c(this,"implements");c(this,"detachedChildren",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.x=e.x,this.y=e.y,this.collapsed=e.collapsed}static fromGenerationTarget(e,t){let r=t;if(e.parent){const l=N(e.parent);r=t.get(l)}let a;e.implements&&(a=t.getBuiltIn(e.implements));const s={id:e.id,version:1,name:e.name,type:n.GlobalEvent,collapsed:!1,returnStatements:[],calls:[],inputs:[],implements:a,x:0,y:0,parent:r},o=g(s,t);return o.setParent(r),o.initChildren(),o}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{},t);if(r=s.modifiedData,a.push(...s.errors,...Le(r)),!e.implements)a.push(new b({id:`${e.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'implements' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for 'global-event' entities.
68
68
  ${jo(t)}`,issue:null}));else if(!t.get(e.implements))a.push(new b({id:`${e.id}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'implements' property that isn't found in the project. The 'implements' property must point to one of the built-in action descriptors reserved for 'global-event' entities.
69
69
  ${jo(t)}`,issue:null}));else if(!t.globalEventActionDescriptors.find(p=>p.id===e.implements))a.push(new b({id:`${e.id}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'implements' property that isn't pointing to an action descriptor reserved for 'global-event' entities.
70
70
  ${jo(t)}`,issue:null}));else{const p=t.events.find(y=>y.implements.id===e.implements);p&&a.push(new b({id:`${e.id}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'implements' property that points to an action descriptor that is already implemented by another global event with id '${p.id}' in the project. Each global event must implement a unique action descriptor.
@@ -73,17 +73,17 @@ ${ko(t)}`,issue:null})):a.push(new b({id:`${e.id}--${h.ReferencedEntityNotFound}
73
73
  ${ko(t)}`,issue:null})):a.push(new b({id:`${e.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'declaration' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
74
74
  ${ko(t)}`,issue:null})),{errors:a,modifiedData:r}}static fromReturnDeclarationToBodyArgumentDeclarationName(e){return`Previous iteration results of '${C(e,e.project)}'`}static fromBodyArgumentDeclarationToReturnDeclarationName(e){const t=e.name.replace("Previous iteration results of '","");return t.slice(0,t.length-1)}static fromReturnDeclarationToLoopOutputDeclarationName(e){return`Result list of '${C(e,e.project)}'`}static fromLoopOutputDeclarationToReturnDeclarationName(e){const t=e.name.replace("Result list of '","");return t.slice(0,t.length-1)}static fromLoopOutputDeclarationToBodyArgumentDeclarationName(e){return e.name.replace("Result list of '","Previous iteration results of '")}static fromBodyArgumentDeclarationToLoopOutputDeclarationName(e){return e.name.replace("Previous iteration results of '","Result list of '")}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
75
75
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
76
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addLoop(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(r=>r.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),this}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}setBody(e){return this.body=e,this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}replaceDetachedChild(e,t){const r=this.detachedChildren.indexOf(e);return r!==-1&&(this.detachedChildren[r]=t),this}subscribeDetachedChild(e){return this.detachedChildren.includes(e)||this.detachedChildren.push(e),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.body&&(this.body=g(this.initialData.body,this.project),this.body.setParent(this),this.body.initChildren()),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncChildren(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.body.remove({ignoreUpstream:!0,seenEntities:t}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.body.restore({seenEntities:e}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.error?this.error.toFlat(e):[],...this.body?this.body.toFlat(e):[],...this.continueStatements.flatMap(r=>r.toFlat(e)),...this.breakStatements.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[],...this.body?this.body.toFlatIds(e):[],...this.continueStatements.flatMap(r=>r.toFlatIds(e)),...this.breakStatements.flatMap(r=>r.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:((e=this.process)==null?void 0:e.toJSON())||null,declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),outputsDeclarations:this.outputsDeclarations.map(r=>r.toJSON()),successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),error:((t=this.error)==null?void 0:t.toJSON())||null,body:this.body.toJSON(),parent:this.parent.toReference(),breakStatements:this.breakStatements.map(r=>r.toJSON()),continueStatements:this.continueStatements.map(r=>r.toJSON())}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:((e=this.declaration)==null?void 0:e.toReference())||null,body:((t=this.body)==null?void 0:t.toReference())||null,inputs:this.inputs.map(s=>s.toReference()),outputs:this.outputs.map(s=>s.toReference()),outputsDeclarations:this.outputsDeclarations.map(s=>s.toReference()),successCalls:this.successCalls.map(s=>s.toReference()),errorCalls:this.errorCalls.map(s=>s.toReference()),process:((r=this.process)==null?void 0:r.toReference())||null,calledBySuccess:this.calledBySuccess.map(s=>s.toReference()),calledByError:this.calledByError.map(s=>s.toReference()),calledByEntry:this.calledByEntry.map(s=>s.toReference()),continueStatements:this.continueStatements.map(s=>s.toReference()),breakStatements:this.breakStatements.map(s=>s.toReference()),error:((a=this.error)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.body)==null?void 0:r.toFlatJSON(e))||[],...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.continueStatements.flatMap(a=>a.toFlatJSON(e)),...this.breakStatements.flatMap(a=>a.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[],...this.process?this.process.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.body)==null?void 0:r.toFlatGenerationTarget(e))||[],...this.successCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.inputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.outputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.continueStatements.flatMap(a=>a.toFlatGenerationTarget(e)),...this.breakStatements.flatMap(a=>a.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[],...this.process?this.process.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),this.continueStatements.forEach(r=>r.clearErrors()),this.breakStatements.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=L2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.body?this.body.getErrors():[],...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new z(this.toJSON(),this.project)}getVariableInstances(){return this.body?re(this.body).filter(r=>r.type===n.VariableInstance):[]}addReturnStatement(e){return xe.includes(this.parent.type)&&this.parent.addReturnStatement(e),this}removeReturnStatement(e){return xe.includes(this.parent.type)&&this.parent.removeReturnStatement(e),this}addBreakStatement(e){return this.breakStatements.includes(e)||this.breakStatements.push(e),this}removeBreakStatement(e){const t=this.breakStatements.indexOf(e);return t!==-1&&this.breakStatements.splice(t,1),this}addContinueStatement(e){return this.continueStatements.includes(e)||this.continueStatements.push(e),this}removeContinueStatement(e){const t=this.continueStatements.indexOf(e);return t!==-1&&this.continueStatements.splice(t,1),this}getUniqueReturnDeclarations(){const e=[];return[...this.breakStatements,...this.continueStatements].forEach(r=>{r.outputs.forEach(s=>{e.find(l=>l===s||C(l,this.project)===C(s,this.project)&&jt(l.dataType,s.dataType))||e.push(s)})}),E(e)}syncTerminationStatements(){const e=[],t=[],r=[],a=this.getUniqueReturnDeclarations();return[...this.breakStatements,...this.continueStatements].forEach(o=>{const l=o.outputs,p=a.filter(y=>!l.find(f=>C(y,this.project)===C(f,this.project)&&jt(y.dataType,f.dataType)));p.length&&e.push(o),p.forEach(y=>{const f=y.clone(o);f.addSelfToProject(),t.push(f)})}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncBodyInputIndexes(){const e=[],t=[],r=[];return this.body.inputs.sort((s,o)=>s.index-o.index),this.body.inputs.forEach((s,o)=>{s.index!==o&&(s.sync({index:o}),e.push(s))}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncBodyArgumentsDeclarations(){const e=[],t=[],r=[],{updated:a,added:s,removed:o}=this.syncFixedBodyArgumentDeclarations();e.push(...a),t.push(...s),r.push(...o);const l=this.getUniqueReturnDeclarations(),p=this.body.inputs;l.sort((R,v)=>R.index-v.index),l.forEach(R=>{const v=R.getDataType();let A=p.find(ae=>C(ae,this.project)===z.fromReturnDeclarationToBodyArgumentDeclarationName(R)&&jt(ae.dataType,R.dataType));if(!A){const ae=z.fromReturnDeclarationToBodyArgumentDeclarationName(R),Je={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:ae,description:`Aggretated list of all previously outputted values from each iteration by the output '${C(R,this.project)}'`,dataType:null,implements:null,index:R.index,required:R.required,parent:this.body.toReference(),writesValues:[]},vt=g(Je,this.project);vt.setParent(this.body),vt.initChildren(),vt.addSelfToProject(),t.push(vt),A=vt}const D=this.body.inputs.find(ae=>ae.index===A.index&&ae!==A),F=this.body.inputs.filter(ae=>ae!==A);let k=A.index;D&&(k=Math.max(...F.map(ae=>ae.index))+1),A.index!==k&&(A.sync({index:k}),e.push(A));const oe=A.getDataType();let me=oe;if(v)if(!oe||!jt(oe,v)){if(!me){const ae=v.clone(A);ae.addSelfToProject(),me=ae,t.push(ae),e.push(A)}me.merge(v),me.sync({isList:!0})}else me.isList||(me.sync({isList:!0}),e.push(me));if(!v&&!me){const ae={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!0,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},Je=g(ae,this.project);Je.sync({isList:!0}),Je.setParent(A),Je.initChildren(),Je.addSelfToProject(),t.push(Je)}});const{updated:y,added:f,removed:m}=this.removeExtraBodyArgumentDeclarations();return e.push(...y),t.push(...f),r.push(...m),{updated:E(e),added:E(t),removed:E(r),self:this}}syncOutputsDeclarations(){const e=[],t=[],r=[],a=this.getUniqueReturnDeclarations(),s=this.outputsDeclarations;return a.forEach((l,p)=>{l.index!==p&&(l.sync({index:p}),e.push(l))}),a.forEach(l=>{const p=l.getDataType();let f=s.find(v=>C(v,this.project)===z.fromReturnDeclarationToLoopOutputDeclarationName(l)&&jt(v.dataType,l.dataType));if(!f){const v=z.fromReturnDeclarationToLoopOutputDeclarationName(l),P={id:_.UUID.uuid(),version:1,type:n.ValueDescriptor,name:v,description:`Aggretated list of all previously outputted values from each iteration by the output '${C(l,this.project)}'`,dataType:null,index:l.index,required:l.required,parent:this.toReference()},A=g(P,this.project);A.setParent(this),A.initChildren(),A.addSelfToProject(),t.push(A),f=A}f.index!==l.index&&(f.sync({index:l.index}),e.push(f));let R=f.getDataType();if(p)if(!R||!jt(R,p)){if(!R){const v=p.clone(f);v.addSelfToProject(),R=v,t.push(v),e.push(f)}R.merge(p),R.sync({isList:!0})}else R.isList||(R.sync({isList:!0}),e.push(R));if(!p&&!R){const v={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!0,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:f.toReference()},P=g(v,this.project);P.sync({isList:!0}),P.setParent(f),P.initChildren(),P.addSelfToProject(),t.push(P)}}),s.filter(l=>!a.find(y=>C(l,this.project)===z.fromReturnDeclarationToLoopOutputDeclarationName(y))).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),r.push(...y)}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncOutputMaps(){const e=[],t=[],r=[],a=this.outputsDeclarations,s=this.outputs;return a.forEach(l=>{var f;let y=s.find(m=>{var R,v;return((R=m.declaration)==null?void 0:R.id)===l.id&&jt((v=m.declaration)==null?void 0:v.dataType,l.dataType)});if(y)((f=y.declaration)==null?void 0:f.id)!==l.id&&(y.setDeclaration(l),e.push(y));else{const m={id:_.UUID.uuid(),version:1,type:n.OutputMap,index:l.index,declaration:l.toJSON(),writesValues:[],parent:this.toReference()},R=g(m,this.project);R.setParent(this),R.initChildren(),R.addSelfToProject(),t.push(R),y=R}y.index!==l.index&&(y.sync({index:l.index}),e.push(y))}),s.filter(l=>!a.find(y=>{var f;return((f=l.declaration)==null?void 0:f.id)===y.id})).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),r.push(...y)}),{updated:E(e),added:E(t),removed:E(r),self:this}}createCurrentIterationNumberArgumentDeclaration(){const e=[],t=[],r=[];let s=this.body.inputs.find(y=>{var f;return y.name===z.CURRENT_ITERATION_NUMBER_ARG_NAME||y.id===((f=this.currentIterationNumberArgumentDeclaration)==null?void 0:f.id)});const o=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!s){const y={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_ITERATION_NUMBER_ARG_NAME,description:"The number of the current iteration",dataType:null,implements:o==null?void 0:o.toJSON(),index:this.body.inputs.length,required:!0,parent:this.body.toReference(),writesValues:[]},f=g(y,this.project);f.setParent(this.body),f.initChildren(),f.addSelfToProject(),t.push(f),s=f}!s.index&&s.index!==0&&(s.sync({index:0}),e.push(s)),(!s.implements||s.implements.id!==o.id)&&(s.setImplements(o),e.push(s));let p=s.getDataType();if(!p){const y={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:s.toReference()},f=g(y,this.project);f.setParent(s),f.initChildren(),f.addSelfToProject(),t.push(f),p=f}if(!p.entity||p.entity.type!==n.PrimitiveEntity||p.entity.name!==I.Number||p.entity.id!==B["primitive-entity"].number.id){const y=this.project.getBuiltIn(B["primitive-entity"].number.id);p.setEntity(y),e.push(p)}return this.currentIterationNumberArgumentDeclaration=s,{updated:E(e),added:E(t),removed:E(r),self:this}}removeExtraBodyArgumentDeclarations(){const e=[],t=[],r=[],a=this.body.inputs,s=this.getUniqueReturnDeclarations();return a.filter(l=>l===this.currentIterationNumberArgumentDeclaration||l===this.currentValueArgumentDeclaration?!1:!s.find(y=>C(l,this.project)===z.fromReturnDeclarationToBodyArgumentDeclarationName(y))).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),r.push(...y)}),{updated:E(e),added:E(t),removed:E(r),self:this}}createCurrentValueInputBasedOnInputMap(){var l,p,y,f,m;const e=[],t=[],r=[];switch(this.declaration.id){case $.List:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.List].body.inputs.currentValue.id}),v=this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.List].inputs.list.id});if(!v)break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.List].inputs.list.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(!F){const oe={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},me=g(oe,this.project);me.setParent(A),me.initChildren(),me.addSelfToProject(),t.push(me),F=me}const k=v.getDataType();F.merge(k),F.sync({isList:!1})}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}case $.ManualFlow:{this.currentValueArgumentDeclaration=null;break}case $.Counted:{this.currentValueArgumentDeclaration=null;break}case $.ObjectKeys:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.ObjectKeys].body.inputs.currentValue.id});if(!this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.ObjectKeys].inputs.object.id}))break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.ObjectKeys].inputs.object.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(F){const k=this.project.getBuiltIn(B["primitive-entity"].string.id);((l=F.entity)==null?void 0:l.id)!==k.id&&(F.setEntity(k),e.push(F))}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=g(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),F=oe}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}case $.ObjectValues:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.ObjectValues].body.inputs.currentValue.id}),v=this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.ObjectValues].inputs.object.id});if(!v)break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.ObjectValues].inputs.object.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(F){const k=v.getDataType(),oe=((y=k==null?void 0:k.entity)==null?void 0:y.properties)||[];(f=F.orChildrenGroup)==null||f.forEach(me=>{const{affected:ae,removed:Je}=me.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...ae),r.push(...Je)}),oe.forEach(me=>{const ae=me.getDataType();if(ae){const Je=ae.clone(F);Je.sync({parentRelationType:We.OrDataTypeGroup}),Je.addSelfToProject(),t.push(Je)}else{const Je={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:We.OrDataTypeGroup,parent:F.toReference()},vt=g(Je,this.project);vt.setParent(F),vt.initChildren(),vt.addSelfToProject(),t.push(vt)}})}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=g(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),F=oe;const me=v.getDataType();(((p=me==null?void 0:me.entity)==null?void 0:p.properties)||[]).forEach(Je=>{const vt=Je.getDataType();if(vt){const Hr=vt.clone(oe);Hr.sync({parentRelationType:We.OrDataTypeGroup}),Hr.addSelfToProject(),t.push(Hr)}else{const Hr={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:We.OrDataTypeGroup,parent:oe.toReference()},tl=g(Hr,this.project);tl.setParent(oe),tl.initChildren(),tl.addSelfToProject(),t.push(tl)}})}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}case $.String:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.String].body.inputs.currentValue.id});if(!this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.String].inputs.string.id}))break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop]["string-loop"].inputs.string.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(F){const k=this.project.getBuiltIn(B["primitive-entity"].string.id);((m=F.entity)==null?void 0:m.id)!==k.id&&(F.setEntity(k),e.push(F))}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=g(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),t.push(oe),F=oe}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}}const{updated:a,added:s,removed:o}=this.removeExtraBodyArgumentDeclarations();return e.push(...a),t.push(...s),r.push(...o),{updated:E(e),added:E(t),removed:E(r),self:this}}syncFixedBodyArgumentDeclarations(){const e=[],t=[],r=[],{updated:a,added:s,removed:o}=this.createCurrentIterationNumberArgumentDeclaration();e.push(...a),t.push(...s),r.push(...o);const{updated:l,added:p,removed:y}=this.createCurrentValueInputBasedOnInputMap();return e.push(...l),t.push(...p),r.push(...y),{updated:E(e),added:E(t),removed:E(r),self:this}}syncInputMaps(){const e=[],t=[],r=[];switch(this.declaration.id){case $.List:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["list-loop"].inputs.list.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["list-loop"].inputs.list.id){const s=this.project.get(B[n.Loop]["list-loop"].inputs.list.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["list-loop"].inputs.list.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ManualFlow:{this.inputs.forEach(a=>{a.remove(),r.push(a)});break}case $.Counted:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["counted-loop"].inputs.number.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["counted-loop"].inputs.number.id){const s=this.project.get(B[n.Loop]["counted-loop"].inputs.number.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["counted-loop"].inputs.number.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ObjectKeys:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["object-keys-loop"].inputs.object.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["object-keys-loop"].inputs.object.id){const s=this.project.get(B[n.Loop]["object-keys-loop"].inputs.object.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["object-keys-loop"].inputs.object.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ObjectValues:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["object-values-loop"].inputs.object.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["object-values-loop"].inputs.object.id){const s=this.project.get(B[n.Loop]["object-values-loop"].inputs.object.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["object-values-loop"].inputs.object.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.String:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["string-loop"].inputs.string.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["string-loop"].inputs.string.id){const s=this.project.get(B[n.Loop]["string-loop"].inputs.string.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["string-loop"].inputs.string.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}}return{updated:E(e),added:E(t),removed:E(r),self:this}}getCurrentValueBuiltInValueDescriptor(){var t;const e=(t=B[n.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:t.id;return e?this.project.get(e):null}getCurrentIterationNumberBuiltInValueDescriptor(){const e=B[n.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(e)}syncBody(){var o;const e=[],t=[],r=[],a=B[n.Loop][this.declaration.id].body.id,s=this.project.getBuiltIn(a);if(this.body)((o=this.body.implements)==null?void 0:o.id)!==s.id&&(this.body.setImplements(s),this.body.setParent(this),e.push(this.body));else{const l={id:_.UUID.uuid(),version:1,type:n.FunctionDeclaration,name:s.name,description:null,inputs:[],index:null,returnStatements:[],calls:[],collapsed:!1,private:!1,implements:s.toJSON(),x:0,y:0,parent:this.toReference()},p=g(l,this.project);p.initChildren(),p.setParent(this),p.addSelfToProject(),t.push(p)}return{self:this,updated:E(e),added:E(t),removed:E(r)}}syncChildren(){const e=[],t=[],r=[],{updated:a,added:s,removed:o}=this.syncBody();e.push(...a),t.push(...s),r.push(...o);const{updated:l,added:p,removed:y}=this.syncInputMaps();e.push(...l),t.push(...p),r.push(...y);const{updated:f,added:m,removed:R}=this.syncTerminationStatements();e.push(...f),t.push(...m),r.push(...R);const{updated:v,added:P,removed:A}=this.syncBodyArgumentsDeclarations();e.push(...v),t.push(...P),r.push(...A);const{updated:D,added:F,removed:k}=this.syncBodyInputIndexes();e.push(...D),t.push(...F),r.push(...k);const{updated:oe,added:me,removed:ae}=this.syncOutputsDeclarations();e.push(...oe),t.push(...me),r.push(...ae);const{updated:Je,added:vt,removed:Hr}=this.syncOutputMaps();return e.push(...Je),t.push(...vt),r.push(...Hr),{self:this,updated:E(e),added:E(t),removed:E(r)}}};c(z,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),c(z,"CURRENT_VALUE_ARG_NAME","Current value"),c(z,"MUTABLE_BASE_PROPERTIES",[]),c(z,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(z,"BASE_PROPERTIES",[...z.MUTABLE_BASE_PROPERTIES,...z.INMUTABLE_BASE_PROPERTIES]),c(z,"MUTABLE_META_PROPERTIES",[...z.MUTABLE_BASE_PROPERTIES,"x","y"]),c(z,"INMUTABLE_META_PROPERTIES",[...z.INMUTABLE_BASE_PROPERTIES]),c(z,"META_PROPERTIES",[...z.MUTABLE_META_PROPERTIES,...z.INMUTABLE_META_PROPERTIES]),c(z,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(z,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),c(z,"UPSTREAM_PROPERTIES",[...z.MUTABLE_UPSTREAM_PROPERTIES,...z.INMUTABLE_UPSTREAM_PROPERTIES]),c(z,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","outputsDeclarations","successCalls","errorCalls","error","breakStatements","continueStatements"]),c(z,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(z,"DOWNSTREAM_PROPERTIES",[...z.MUTABLE_DOWNSTREAM_PROPERTIES,...z.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(z,"PROPERTIES",[...z.META_PROPERTIES,...z.UPSTREAM_PROPERTIES,...z.DOWNSTREAM_PROPERTIES]);let Mr=z;function G2(i){const e=N6(),t=i.toJSON();e.safeParse(t).success,i.inputs.forEach(o=>o.validate());const s=[..._n(i)];return ie(i.errors,s)}const ve=class ve{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Condition);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"declaration");c(this,"inputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const f=N(e.parent);r=t.get(f)}const a=e.calledByEntry.map(f=>{const m=N(f);return t.get(m)}),s=e.calledBySuccess.map(f=>{const m=N(f);return t.get(m)}),o=e.calledByError.map(f=>{const m=N(f);return t.get(m)});let l;if(e.declaration){const f=N(e.declaration);l=t.get(f)}const p={id:e.id,version:1,type:n.Condition,declaration:l,calledByEntry:a,calledBySuccess:s,calledByError:o,errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:r},y=g(p,t);return y.setParent(r),y.initChildren(),y}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);return r=s.modifiedData,a.push(...s.errors,...Le(r)),e.declaration?t.get(e.declaration)?t.conditionDeclarations.find(p=>p.id===e.declaration)||a.push(new b({id:`${e.id}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't pointing to an action descriptor reserved for '${n.Condition}' entities.
76
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addLoop(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(r=>r.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),this}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}setBody(e){return this.body=e,this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}replaceDetachedChild(e,t){const r=this.detachedChildren.indexOf(e);return r!==-1&&(this.detachedChildren[r]=t),this}subscribeDetachedChild(e){return this.detachedChildren.includes(e)||this.detachedChildren.push(e),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.body&&(this.body=g(this.initialData.body,this.project),this.body.setParent(this),this.body.initChildren()),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncChildren(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.body.remove({ignoreUpstream:!0,seenEntities:t}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.body.restore({seenEntities:e}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.error?this.error.toFlat(e):[],...this.body?this.body.toFlat(e):[],...this.continueStatements.flatMap(r=>r.toFlat(e)),...this.breakStatements.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[],...this.body?this.body.toFlatIds(e):[],...this.continueStatements.flatMap(r=>r.toFlatIds(e)),...this.breakStatements.flatMap(r=>r.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:((e=this.process)==null?void 0:e.toJSON())||null,declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),outputsDeclarations:this.outputsDeclarations.map(r=>r.toJSON()),successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),error:((t=this.error)==null?void 0:t.toJSON())||null,body:this.body.toJSON(),parent:this.parent.toReference(),breakStatements:this.breakStatements.map(r=>r.toJSON()),continueStatements:this.continueStatements.map(r=>r.toJSON())}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:((e=this.declaration)==null?void 0:e.toReference())||null,body:((t=this.body)==null?void 0:t.toReference())||null,inputs:this.inputs.map(s=>s.toReference()),outputs:this.outputs.map(s=>s.toReference()),outputsDeclarations:this.outputsDeclarations.map(s=>s.toReference()),successCalls:this.successCalls.map(s=>s.toReference()),errorCalls:this.errorCalls.map(s=>s.toReference()),process:((r=this.process)==null?void 0:r.toReference())||null,calledBySuccess:this.calledBySuccess.map(s=>s.toReference()),calledByError:this.calledByError.map(s=>s.toReference()),calledByEntry:this.calledByEntry.map(s=>s.toReference()),continueStatements:this.continueStatements.map(s=>s.toReference()),breakStatements:this.breakStatements.map(s=>s.toReference()),error:((a=this.error)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.body)==null?void 0:r.toFlatJSON(e))||[],...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.continueStatements.flatMap(a=>a.toFlatJSON(e)),...this.breakStatements.flatMap(a=>a.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[],...this.process?this.process.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.body)==null?void 0:r.toFlatGenerationTarget(e))||[],...this.successCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.inputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.outputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.continueStatements.flatMap(a=>a.toFlatGenerationTarget(e)),...this.breakStatements.flatMap(a=>a.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[],...this.process?this.process.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),this.continueStatements.forEach(r=>r.clearErrors()),this.breakStatements.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=L2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.body?this.body.getErrors():[],...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new z(this.toJSON(),this.project)}getVariableInstances(){return this.body?re(this.body).filter(r=>r.type===n.VariableInstance):[]}addReturnStatement(e){return xe.includes(this.parent.type)&&this.parent.addReturnStatement(e),this}removeReturnStatement(e){return xe.includes(this.parent.type)&&this.parent.removeReturnStatement(e),this}addBreakStatement(e){return this.breakStatements.includes(e)||this.breakStatements.push(e),this}removeBreakStatement(e){const t=this.breakStatements.indexOf(e);return t!==-1&&this.breakStatements.splice(t,1),this}addContinueStatement(e){return this.continueStatements.includes(e)||this.continueStatements.push(e),this}removeContinueStatement(e){const t=this.continueStatements.indexOf(e);return t!==-1&&this.continueStatements.splice(t,1),this}getUniqueReturnDeclarations(){const e=[];return[...this.breakStatements,...this.continueStatements].forEach(r=>{r.outputs.forEach(s=>{e.find(l=>l===s||C(l,this.project)===C(s,this.project)&&jt(l.dataType,s.dataType))||e.push(s)})}),E(e)}syncTerminationStatements(){const e=[],t=[],r=[],a=this.getUniqueReturnDeclarations();return[...this.breakStatements,...this.continueStatements].forEach(o=>{const l=o.outputs,p=a.filter(y=>!l.find(f=>C(y,this.project)===C(f,this.project)&&jt(y.dataType,f.dataType)));p.length&&e.push(o),p.forEach(y=>{const f=y.clone(o);f.addSelfToProject(),t.push(f)})}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncBodyInputIndexes(){const e=[],t=[],r=[];return this.body.inputs.sort((s,o)=>s.index-o.index),this.body.inputs.forEach((s,o)=>{s.index!==o&&(s.sync({index:o}),e.push(s))}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncBodyArgumentsDeclarations(){const e=[],t=[],r=[],{updated:a,added:s,removed:o}=this.syncFixedBodyArgumentDeclarations();e.push(...a),t.push(...s),r.push(...o);const l=this.getUniqueReturnDeclarations(),p=this.body.inputs;l.sort((R,v)=>R.index-v.index),l.forEach(R=>{const v=R.getDataType();let A=p.find(ae=>C(ae,this.project)===z.fromReturnDeclarationToBodyArgumentDeclarationName(R)&&jt(ae.dataType,R.dataType));if(!A){const ae=z.fromReturnDeclarationToBodyArgumentDeclarationName(R),Je={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:ae,description:`Aggretated list of all previously outputted values from each iteration by the output '${C(R,this.project)}'`,dataType:null,implements:null,index:R.index,required:R.required,parent:this.body.toReference(),writesValues:[]},vt=g(Je,this.project);vt.setParent(this.body),vt.initChildren(),vt.addSelfToProject(),t.push(vt),A=vt}const D=this.body.inputs.find(ae=>ae.index===A.index&&ae!==A),F=this.body.inputs.filter(ae=>ae!==A);let k=A.index;D&&(k=Math.max(...F.map(ae=>ae.index))+1),A.index!==k&&(A.sync({index:k}),e.push(A));const oe=A.getDataType();let me=oe;if(v)if(!oe||!jt(oe,v)){if(!me){const ae=v.clone(A);ae.addSelfToProject(),me=ae,t.push(ae),e.push(A)}me.merge(v),me.sync({isList:!0})}else me.isList||(me.sync({isList:!0}),e.push(me));if(!v&&!me){const ae={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!0,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},Je=g(ae,this.project);Je.sync({isList:!0}),Je.setParent(A),Je.initChildren(),Je.addSelfToProject(),t.push(Je)}});const{updated:y,added:f,removed:m}=this.removeExtraBodyArgumentDeclarations();return e.push(...y),t.push(...f),r.push(...m),{updated:E(e),added:E(t),removed:E(r),self:this}}syncOutputsDeclarations(){const e=[],t=[],r=[],a=this.getUniqueReturnDeclarations(),s=this.outputsDeclarations;return a.forEach((l,p)=>{l.index!==p&&(l.sync({index:p}),e.push(l))}),a.forEach(l=>{const p=l.getDataType();let f=s.find(v=>C(v,this.project)===z.fromReturnDeclarationToLoopOutputDeclarationName(l)&&jt(v.dataType,l.dataType));if(!f){const v=z.fromReturnDeclarationToLoopOutputDeclarationName(l),P={id:_.UUID.uuid(),version:1,type:n.ValueDescriptor,name:v,description:`Aggretated list of all previously outputted values from each iteration by the output '${C(l,this.project)}'`,dataType:null,index:l.index,required:l.required,parent:this.toReference()},A=g(P,this.project);A.setParent(this),A.initChildren(),A.addSelfToProject(),t.push(A),f=A}f.index!==l.index&&(f.sync({index:l.index}),e.push(f));let R=f.getDataType();if(p)if(!R||!jt(R,p)){if(!R){const v=p.clone(f);v.addSelfToProject(),R=v,t.push(v),e.push(f)}R.merge(p),R.sync({isList:!0})}else R.isList||(R.sync({isList:!0}),e.push(R));if(!p&&!R){const v={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!0,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:f.toReference()},P=g(v,this.project);P.sync({isList:!0}),P.setParent(f),P.initChildren(),P.addSelfToProject(),t.push(P)}}),s.filter(l=>!a.find(y=>C(l,this.project)===z.fromReturnDeclarationToLoopOutputDeclarationName(y))).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),r.push(...y)}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncOutputMaps(){const e=[],t=[],r=[],a=this.outputsDeclarations,s=this.outputs;return a.forEach(l=>{var f;let y=s.find(m=>{var R,v;return((R=m.declaration)==null?void 0:R.id)===l.id&&jt((v=m.declaration)==null?void 0:v.dataType,l.dataType)});if(y)((f=y.declaration)==null?void 0:f.id)!==l.id&&(y.setDeclaration(l),e.push(y));else{const m={id:_.UUID.uuid(),version:1,type:n.OutputMap,index:l.index,declaration:l.toJSON(),writesValues:[],parent:this.toReference()},R=g(m,this.project);R.setParent(this),R.initChildren(),R.addSelfToProject(),t.push(R),y=R}y.index!==l.index&&(y.sync({index:l.index}),e.push(y))}),s.filter(l=>!a.find(y=>{var f;return((f=l.declaration)==null?void 0:f.id)===y.id})).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),r.push(...y)}),{updated:E(e),added:E(t),removed:E(r),self:this}}createCurrentIterationNumberArgumentDeclaration(){const e=[],t=[],r=[];let s=this.body.inputs.find(y=>{var f;return y.name===z.CURRENT_ITERATION_NUMBER_ARG_NAME||y.id===((f=this.currentIterationNumberArgumentDeclaration)==null?void 0:f.id)});const o=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!s){const y={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_ITERATION_NUMBER_ARG_NAME,description:"The number of the current iteration",dataType:null,implements:o==null?void 0:o.toJSON(),index:this.body.inputs.length,required:!0,parent:this.body.toReference(),writesValues:[]},f=g(y,this.project);f.setParent(this.body),f.initChildren(),f.addSelfToProject(),t.push(f),s=f}!s.index&&s.index!==0&&(s.sync({index:0}),e.push(s)),(!s.implements||s.implements.id!==o.id)&&(s.setImplements(o),e.push(s));let p=s.getDataType();if(!p){const y={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:s.toReference()},f=g(y,this.project);f.setParent(s),f.initChildren(),f.addSelfToProject(),t.push(f),p=f}if(!p.entity||p.entity.type!==n.PrimitiveEntity||p.entity.name!==I.Number||p.entity.id!==B["primitive-entity"].number.id){const y=this.project.getBuiltIn(B["primitive-entity"].number.id);p.setEntity(y),e.push(p)}return this.currentIterationNumberArgumentDeclaration=s,{updated:E(e),added:E(t),removed:E(r),self:this}}removeExtraBodyArgumentDeclarations(){const e=[],t=[],r=[],a=this.body.inputs,s=this.getUniqueReturnDeclarations();return a.filter(l=>l===this.currentIterationNumberArgumentDeclaration||l===this.currentValueArgumentDeclaration?!1:!s.find(y=>C(l,this.project)===z.fromReturnDeclarationToBodyArgumentDeclarationName(y))).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),r.push(...y)}),{updated:E(e),added:E(t),removed:E(r),self:this}}createCurrentValueInputBasedOnInputMap(){var l,p,y,f,m;const e=[],t=[],r=[];switch(this.declaration.id){case $.List:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.List].body.inputs.currentValue.id}),v=this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.List].inputs.list.id});if(!v)break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.List].inputs.list.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(!F){const oe={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},me=g(oe,this.project);me.setParent(A),me.initChildren(),me.addSelfToProject(),t.push(me),F=me}const k=v.getDataType();F.merge(k),F.sync({isList:!1})}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}case $.ManualFlow:{this.currentValueArgumentDeclaration=null;break}case $.Counted:{this.currentValueArgumentDeclaration=null;break}case $.ObjectKeys:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.ObjectKeys].body.inputs.currentValue.id});if(!this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.ObjectKeys].inputs.object.id}))break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.ObjectKeys].inputs.object.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(F){const k=this.project.getBuiltIn(B["primitive-entity"].string.id);((l=F.entity)==null?void 0:l.id)!==k.id&&(F.setEntity(k),e.push(F))}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=g(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),F=oe}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}case $.ObjectValues:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.ObjectValues].body.inputs.currentValue.id}),v=this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.ObjectValues].inputs.object.id});if(!v)break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.ObjectValues].inputs.object.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(F){const k=v.getDataType(),oe=((y=k==null?void 0:k.entity)==null?void 0:y.properties)||[];(f=F.orChildrenGroup)==null||f.forEach(me=>{const{affected:ae,removed:Je}=me.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...ae),r.push(...Je)}),oe.forEach(me=>{const ae=me.getDataType();if(ae){const Je=ae.clone(F);Je.sync({parentRelationType:We.OrDataTypeGroup}),Je.addSelfToProject(),t.push(Je)}else{const Je={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:We.OrDataTypeGroup,parent:F.toReference()},vt=g(Je,this.project);vt.setParent(F),vt.initChildren(),vt.addSelfToProject(),t.push(vt)}})}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=g(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),F=oe;const me=v.getDataType();(((p=me==null?void 0:me.entity)==null?void 0:p.properties)||[]).forEach(Je=>{const vt=Je.getDataType();if(vt){const Hr=vt.clone(oe);Hr.sync({parentRelationType:We.OrDataTypeGroup}),Hr.addSelfToProject(),t.push(Hr)}else{const Hr={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:We.OrDataTypeGroup,parent:oe.toReference()},tl=g(Hr,this.project);tl.setParent(oe),tl.initChildren(),tl.addSelfToProject(),t.push(tl)}})}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}case $.String:{const R=this.body.inputs.find(A=>{var D;return((D=A.implements)==null?void 0:D.id)===B[n.Loop][$.String].body.inputs.currentValue.id});if(!this.inputs.find(A=>{var D;return((D=A.declaration)==null?void 0:D.id)===B[n.Loop][$.String].inputs.string.id}))break;const P=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop]["string-loop"].inputs.string.id);P&&(!R.implements||R.implements.id!==P.id)&&(R.setImplements(P),e.push(R));let F=R.getDataType();if(F){const k=this.project.getBuiltIn(B["primitive-entity"].string.id);((m=F.entity)==null?void 0:m.id)!==k.id&&(F.setEntity(k),e.push(F))}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=g(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),t.push(oe),F=oe}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:P,writesValues:[],dataType:null,parent:this.body.toReference()},D=g(A,this.project);D.initChildren(),D.setParent(this.body),D.addSelfToProject(),P&&(!D.implements||D.implements.id!==P.id)&&(D.setImplements(P),e.push(D)),t.push(D),this.currentValueArgumentDeclaration=D}break}}const{updated:a,added:s,removed:o}=this.removeExtraBodyArgumentDeclarations();return e.push(...a),t.push(...s),r.push(...o),{updated:E(e),added:E(t),removed:E(r),self:this}}syncFixedBodyArgumentDeclarations(){const e=[],t=[],r=[],{updated:a,added:s,removed:o}=this.createCurrentIterationNumberArgumentDeclaration();e.push(...a),t.push(...s),r.push(...o);const{updated:l,added:p,removed:y}=this.createCurrentValueInputBasedOnInputMap();return e.push(...l),t.push(...p),r.push(...y),{updated:E(e),added:E(t),removed:E(r),self:this}}syncInputMaps(){const e=[],t=[],r=[];switch(this.declaration.id){case $.List:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["list-loop"].inputs.list.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["list-loop"].inputs.list.id){const s=this.project.get(B[n.Loop]["list-loop"].inputs.list.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["list-loop"].inputs.list.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ManualFlow:{this.inputs.forEach(a=>{a.remove(),r.push(a)});break}case $.Counted:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["counted-loop"].inputs.number.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["counted-loop"].inputs.number.id){const s=this.project.get(B[n.Loop]["counted-loop"].inputs.number.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["counted-loop"].inputs.number.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ObjectKeys:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["object-keys-loop"].inputs.object.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["object-keys-loop"].inputs.object.id){const s=this.project.get(B[n.Loop]["object-keys-loop"].inputs.object.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["object-keys-loop"].inputs.object.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ObjectValues:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["object-values-loop"].inputs.object.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["object-values-loop"].inputs.object.id){const s=this.project.get(B[n.Loop]["object-values-loop"].inputs.object.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["object-values-loop"].inputs.object.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.String:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["string-loop"].inputs.string.id?a=s:(s.remove(),r.push(s))}),a){if(a.declaration.id!==B[n.Loop]["string-loop"].inputs.string.id){const s=this.project.get(B[n.Loop]["string-loop"].inputs.string.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["string-loop"].inputs.string.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=g(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}}return{updated:E(e),added:E(t),removed:E(r),self:this}}getCurrentValueBuiltInValueDescriptor(){var t;const e=(t=B[n.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:t.id;return e?this.project.get(e):null}getCurrentIterationNumberBuiltInValueDescriptor(){const e=B[n.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(e)}syncBody(){var o;const e=[],t=[],r=[],a=B[n.Loop][this.declaration.id].body.id,s=this.project.getBuiltIn(a);if(this.body)((o=this.body.implements)==null?void 0:o.id)!==s.id&&(this.body.setImplements(s),this.body.setParent(this),e.push(this.body));else{const l={id:_.UUID.uuid(),version:1,type:n.FunctionDeclaration,name:s.name,description:null,inputs:[],index:null,returnStatements:[],calls:[],collapsed:!1,private:!1,implements:s.toJSON(),x:0,y:0,parent:this.toReference()},p=g(l,this.project);p.initChildren(),p.setParent(this),p.addSelfToProject(),t.push(p)}return{self:this,updated:E(e),added:E(t),removed:E(r)}}syncChildren(){const e=[],t=[],r=[],{updated:a,added:s,removed:o}=this.syncBody();e.push(...a),t.push(...s),r.push(...o);const{updated:l,added:p,removed:y}=this.syncInputMaps();e.push(...l),t.push(...p),r.push(...y);const{updated:f,added:m,removed:R}=this.syncTerminationStatements();e.push(...f),t.push(...m),r.push(...R);const{updated:v,added:P,removed:A}=this.syncBodyArgumentsDeclarations();e.push(...v),t.push(...P),r.push(...A);const{updated:D,added:F,removed:k}=this.syncBodyInputIndexes();e.push(...D),t.push(...F),r.push(...k);const{updated:oe,added:me,removed:ae}=this.syncOutputsDeclarations();e.push(...oe),t.push(...me),r.push(...ae);const{updated:Je,added:vt,removed:Hr}=this.syncOutputMaps();return e.push(...Je),t.push(...vt),r.push(...Hr),{self:this,updated:E(e),added:E(t),removed:E(r)}}};c(z,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),c(z,"CURRENT_VALUE_ARG_NAME","Current value"),c(z,"MUTABLE_BASE_PROPERTIES",[]),c(z,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(z,"BASE_PROPERTIES",[...z.MUTABLE_BASE_PROPERTIES,...z.INMUTABLE_BASE_PROPERTIES]),c(z,"MUTABLE_META_PROPERTIES",[...z.MUTABLE_BASE_PROPERTIES,"x","y"]),c(z,"INMUTABLE_META_PROPERTIES",[...z.INMUTABLE_BASE_PROPERTIES]),c(z,"META_PROPERTIES",[...z.MUTABLE_META_PROPERTIES,...z.INMUTABLE_META_PROPERTIES]),c(z,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(z,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),c(z,"UPSTREAM_PROPERTIES",[...z.MUTABLE_UPSTREAM_PROPERTIES,...z.INMUTABLE_UPSTREAM_PROPERTIES]),c(z,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","outputsDeclarations","successCalls","errorCalls","error","breakStatements","continueStatements"]),c(z,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(z,"DOWNSTREAM_PROPERTIES",[...z.MUTABLE_DOWNSTREAM_PROPERTIES,...z.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(z,"PROPERTIES",[...z.META_PROPERTIES,...z.UPSTREAM_PROPERTIES,...z.DOWNSTREAM_PROPERTIES]);let Mr=z;function G2(i){const e=N6(),t=i.toJSON();e.safeParse(t).success,i.inputs.forEach(o=>o.validate());const s=[..._n(i)];return ie(i.errors,s)}const ve=class ve{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Condition);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"declaration");c(this,"inputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const f=N(e.parent);r=t.get(f)}const a=e.calledByEntry.map(f=>{const m=N(f);return t.get(m)}),s=e.calledBySuccess.map(f=>{const m=N(f);return t.get(m)}),o=e.calledByError.map(f=>{const m=N(f);return t.get(m)});let l;if(e.declaration){const f=N(e.declaration);l=t.get(f)}const p={id:e.id,version:1,type:n.Condition,declaration:l,calledByEntry:a,calledBySuccess:s,calledByError:o,errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:r},y=g(p,t);return y.setParent(r),y.initChildren(),y}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);return r=s.modifiedData,a.push(...s.errors,...Le(r)),e.declaration?t.get(e.declaration)?t.conditionDeclarations.find(p=>p.id===e.declaration)||a.push(new b({id:`${e.id}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't pointing to an action descriptor reserved for '${n.Condition}' entities.
77
77
  ${qo(t)}`,issue:null})):a.push(new b({id:`${e.id}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't found in the project. The 'declaration' property must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
78
78
  ${qo(t)}`,issue:null})):a.push(new b({id:`${e.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'declaration' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
79
79
  ${qo(t)}`,issue:null})),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
80
- If an entity is called by another, they must be in the same scope, which means they have the same parent.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addCondition(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this}removeOutput(e){return this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.syncMissingFixedInputs(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)})}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:t,self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(r=>r.toFlat(e)),...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.calledBy.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.calledBy.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:this.declaration.toJSON(),successCalls:this.successCalls.map(e=>e.toJSON()),errorCalls:this.errorCalls.map(e=>e.toJSON()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),inputs:this.inputs.map(e=>e.toJSON()),parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:this.declaration.toReference(),inputs:this.inputs.map(e=>e.toReference()),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.successCalls.forEach(e=>e.clearErrors()),this.errorCalls.forEach(e=>e.clearErrors()),this}validate(){const e=G2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(e){return new ve(this.toJSON(),this.project)}removeUnrecognizedInputs(){const e=[],t=[],r=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedInputs(){const e=[],t=[],r=[],a=this.declaration.inputs.filter(p=>p.parentRelationType===O.FixedArguments&&!this.inputs.find(y=>y.declaration.id===p.id));this.inputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.inputs.forEach(m=>{m.index>=p.index&&m.sync({index:m.index+1})});const y={id:_.UUID.uuid(),version:1,type:n.InputMap,declaration:p.toJSON(),readsValue:null,defaultValue:null,index:p.index,name:null,description:null,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject()}),this.inputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedInputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(ve,"MUTABLE_BASE_PROPERTIES",["operator"]),c(ve,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(ve,"BASE_PROPERTIES",[...ve.MUTABLE_BASE_PROPERTIES,...ve.INMUTABLE_BASE_PROPERTIES]),c(ve,"MUTABLE_META_PROPERTIES",["x","y"]),c(ve,"INMUTABLE_META_PROPERTIES",[...ve.INMUTABLE_BASE_PROPERTIES]),c(ve,"META_PROPERTIES",[...ve.MUTABLE_META_PROPERTIES,...ve.INMUTABLE_META_PROPERTIES]),c(ve,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","parent"]),c(ve,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(ve,"UPSTREAM_PROPERTIES",[...ve.MUTABLE_UPSTREAM_PROPERTIES,...ve.INMUTABLE_UPSTREAM_PROPERTIES]),c(ve,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","inputsDeclarations","inputs"]),c(ve,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ve,"DOWNSTREAM_PROPERTIES",[...ve.MUTABLE_DOWNSTREAM_PROPERTIES,...ve.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ve,"PROPERTIES",[...ve.META_PROPERTIES,...ve.UPSTREAM_PROPERTIES,...ve.DOWNSTREAM_PROPERTIES]);let Vr=ve;class CP{constructor(){c(this,"initialData")}}class $2{}class F2 extends CP{}class U2{}class x2{}class j2{}class vu{}class k2 extends vu{}class q2 extends vu{}class J2{}class qa{static initReadsValue(e){if(e.initialData.readsValue&&e.initialData.readsValue.type!==n.GenericReference)e.readsValue=g(e.initialData.readsValue,e.project);else if(e.initialData.readsValue&&e.initialData.readsValue.type===n.GenericReference){const t=Mt(e.initialData.readsValue,e.project);t&&(e.readsValue=t)}if(e.readsValue){if(Fe.includes(e.readsValue.type)){let t=e.parent;ut.includes(t.type)||(t=t.parent);const r=e.type===n.InputMap&&e.parent.type===n.Loop;r&&(t=e.parent.parent),e.readsValue.setParent(t),e.readsValue.initChildren(),!r&&t.detachedChildren.includes(e)?t.replaceDetachedChild(e,e.readsValue):r||t.subscribeDetachedChild(e.readsValue)}e.readsValue.addValueReader(e)}return e.readsValue}}class Ja{static initWritesValues(e,t){const r=e.initialData.writesValues.reduce((s,o)=>{if(o.type===n.GenericReference||e.writesValues.some(p=>p.id===o.id))return s;const l=g(o,e.project);return l.setValueWriter(e),Fe.includes(l.type)&&(l.setParent(t),l.initChildren()),[...s,l]},[]),a=[...e.writesValues];return e.writesValues=E([...a,...r]),e.writesValues}}class W2{}function H2(i){var l;const e=b3(),t=i.toJSON();e.safeParse(t).success,(l=i.dataType)==null||l.validate(),i.inputs.forEach(p=>p.validate()),i.outputs.forEach(p=>p.validate()),i.internalCalls.forEach(p=>p.validate());const s=[..._n(i)];if(i.id==="random-company-employee-test-variable-id"){const p=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(p.error)}if(i.id==="company-dto-variable-one-id"){const p=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(p.error)}const o=_u(i);return s.push(...o),ie(i.errors,s)}const pe=class pe{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"dataType",null);c(this,"x");c(this,"y");c(this,"type",n.VariableDeclaration);c(this,"writesValues",[]);c(this,"readsValue",null);c(this,"inputs",[]);c(this,"outputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"internalCalls",[]);c(this,"parent");c(this,"variableInstances",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const f=N(e.parent);r=t.get(f)}const a=e.calledByEntry.map(f=>{const m=N(f);return t.get(m)}),s=e.calledBySuccess.map(f=>{const m=N(f);return t.get(m)}),o=e.calledByError.map(f=>{const m=N(f);return t.get(m)});let l=null;if(e.readsValue){const f=N(e.readsValue);l=t.get(f)}const p={id:e.id,version:1,type:n.VariableDeclaration,name:e.name,description:e.description,calledByEntry:a,calledBySuccess:s,calledByError:o,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:l,inputs:[],outputs:[],writesValues:[],x:0,y:0,parent:r},y=g(p,t);return y.setParent(r),y.initChildren(),y}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);r=s.modifiedData;const o=Tu(r,t);return a.push(...s.errors,...o,...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];let r=JSON.parse(JSON.stringify(e));const a=Ha(r,this);return r=a.modifiedData,t.push(...a.errors),e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
80
+ If an entity is called by another, they must be in the same scope, which means they have the same parent.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addCondition(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this}removeOutput(e){return this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.syncMissingFixedInputs(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)})}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:t,self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(r=>r.toFlat(e)),...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.calledBy.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.calledBy.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:this.declaration.toJSON(),successCalls:this.successCalls.map(e=>e.toJSON()),errorCalls:this.errorCalls.map(e=>e.toJSON()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),inputs:this.inputs.map(e=>e.toJSON()),parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:this.declaration.toReference(),inputs:this.inputs.map(e=>e.toReference()),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.successCalls.forEach(e=>e.clearErrors()),this.errorCalls.forEach(e=>e.clearErrors()),this}validate(){const e=G2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(e){return new ve(this.toJSON(),this.project)}removeUnrecognizedInputs(){const e=[],t=[],r=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedInputs(){const e=[],t=[],r=[],a=this.declaration.inputs.filter(p=>p.parentRelationType===O.FixedArguments&&!this.inputs.find(y=>y.declaration.id===p.id));this.inputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.inputs.forEach(m=>{m.index>=p.index&&m.sync({index:m.index+1})});const y={id:_.UUID.uuid(),version:1,type:n.InputMap,declaration:p.toJSON(),readsValue:null,defaultValue:null,index:p.index,name:null,description:null,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject()}),this.inputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedInputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(ve,"MUTABLE_BASE_PROPERTIES",["operator"]),c(ve,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(ve,"BASE_PROPERTIES",[...ve.MUTABLE_BASE_PROPERTIES,...ve.INMUTABLE_BASE_PROPERTIES]),c(ve,"MUTABLE_META_PROPERTIES",["x","y"]),c(ve,"INMUTABLE_META_PROPERTIES",[...ve.INMUTABLE_BASE_PROPERTIES]),c(ve,"META_PROPERTIES",[...ve.MUTABLE_META_PROPERTIES,...ve.INMUTABLE_META_PROPERTIES]),c(ve,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","parent"]),c(ve,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(ve,"UPSTREAM_PROPERTIES",[...ve.MUTABLE_UPSTREAM_PROPERTIES,...ve.INMUTABLE_UPSTREAM_PROPERTIES]),c(ve,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","inputsDeclarations","inputs"]),c(ve,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ve,"DOWNSTREAM_PROPERTIES",[...ve.MUTABLE_DOWNSTREAM_PROPERTIES,...ve.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ve,"PROPERTIES",[...ve.META_PROPERTIES,...ve.UPSTREAM_PROPERTIES,...ve.DOWNSTREAM_PROPERTIES]);let Vr=ve;class CP{constructor(){c(this,"initialData")}}class $2{}class F2 extends CP{}class U2{}class x2{}class j2{}class vu{}class k2 extends vu{}class q2 extends vu{}class J2{}class qa{static initReadsValue(e){if(e.initialData.readsValue&&e.initialData.readsValue.type!==n.GenericReference)e.readsValue=g(e.initialData.readsValue,e.project);else if(e.initialData.readsValue&&e.initialData.readsValue.type===n.GenericReference){const t=Mt(e.initialData.readsValue,e.project);t&&(e.readsValue=t)}if(e.readsValue){if(Fe.includes(e.readsValue.type)){let t=e.parent;ut.includes(t.type)||(t=t.parent);const r=e.type===n.InputMap&&e.parent.type===n.Loop;r&&(t=e.parent.parent),e.readsValue.setParent(t),e.readsValue.initChildren(),!r&&t.detachedChildren.includes(e)?t.replaceDetachedChild(e,e.readsValue):r||t.subscribeDetachedChild(e.readsValue)}e.readsValue.addValueReader(e)}return e.readsValue}}class Ja{static initWritesValues(e,t){const r=e.initialData.writesValues.reduce((s,o)=>{if(o.type===n.GenericReference||e.writesValues.some(p=>p.id===o.id))return s;const l=g(o,e.project);return l.setValueWriter(e),Fe.includes(l.type)&&(l.setParent(t),l.initChildren()),[...s,l]},[]),a=[...e.writesValues];return e.writesValues=E([...a,...r]),e.writesValues}}class W2{}function H2(i){var l;const e=b3(),t=i.toJSON();e.safeParse(t).success,(l=i.dataType)==null||l.validate(),i.inputs.forEach(p=>p.validate()),i.outputs.forEach(p=>p.validate()),i.internalCalls.forEach(p=>p.validate());const s=[..._n(i)];if(i.id==="random-company-employee-test-variable-id"){const p=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(p.error)}if(i.id==="company-dto-variable-one-id"){const p=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(p.error)}const o=_u(i);return s.push(...o),ie(i.errors,s)}const pe=class pe{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"dataType",null);c(this,"x");c(this,"y");c(this,"type",n.VariableDeclaration);c(this,"writesValues",[]);c(this,"readsValue",null);c(this,"inputs",[]);c(this,"outputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"internalCalls",[]);c(this,"parent");c(this,"variableInstances",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const f=N(e.parent);r=t.get(f)}const a=e.calledByEntry.map(f=>{const m=N(f);return t.get(m)}),s=e.calledBySuccess.map(f=>{const m=N(f);return t.get(m)}),o=e.calledByError.map(f=>{const m=N(f);return t.get(m)});let l=null;if(e.readsValue){const f=N(e.readsValue);l=t.get(f)}const p={id:e.id,version:1,type:n.VariableDeclaration,name:e.name,description:e.description,calledByEntry:a,calledBySuccess:s,calledByError:o,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:l,inputs:[],outputs:[],writesValues:[],x:0,y:0,parent:r},y=g(p,t);return y.setParent(r),y.initChildren(),y}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);r=s.modifiedData;const o=Tu(r,t);return a.push(...s.errors,...o,...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];let r=JSON.parse(JSON.stringify(e));const a=Ha(r,this);return r=a.modifiedData,t.push(...a.errors),e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
81
81
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
82
82
  Specifically for variables, their scope is also calculated from their value readers and value writters.
83
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:r}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&(this.readsValue.addValueReader(this),e.push(this.readsValue)),this.writesValues.forEach(a=>{a.setValueWriter(this),e.push(a)}),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(e=>!e.calledBy.length)}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.initialData.dataType&&(this.dataType=g(this.initialData.dataType,this.project),this.dataType.setParent(this),this.dataType.initChildren()),Ja.initWritesValues(this,this.parent),qa.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.initialData.inputs.forEach(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),this.addInput(t),t}),this.initialData.outputs.forEach(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),this.addOutput(t),t}),this.initialData.internalCalls.forEach(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),this.addInternalCall(t),t}),this.generateUnusedInputs(),this.generateUnusedOutputs(),this.generateUnusedInternalCalls(),(!this.dataType||this.dataType.inferred)&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(),this)}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}subscribeInstance(e){return this.variableInstances.includes(e)?this:(this.variableInstances.push(e),this)}removeInstance(e){return this.variableInstances=this.variableInstances.filter(t=>t.id!==e.id),this}getMasterInputWithValueWritterFromAllInstances(e){return E([...this.inputs,...this.variableInstances.flatMap(a=>a.inputs)]).find(a=>C(a,this.project)===C(e,this.project)&&!!a.readsValue)||e}inferDataTypeAndSyncInstancesInputsAndOutputs(){var r,a;if(!this.dataType){const s=g({id:this.id+"--infered-data-type",version:1,type:n.DataType,isList:!1,isNullable:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:null,constant:!1,like:!0,inferred:!0,defaultValue:null,parent:this.toReference()},this.project);s.sync({inferred:!0,like:!0}),s.setParent(this),s.initChildren(),this.setDataType(s)}if(this.readsValue){const s=(r=this.readsValue.getDataType())==null?void 0:r.clone(this);return s&&(s.sync({inferred:!0,like:!0}),this.setDataType(s)),this}const e=E([...this.inputs,...this.variableInstances.flatMap(s=>s.inputs)]),t=[];return e.forEach(s=>{t.find(l=>C(l,this.project)===C(s,this.project))||t.push(s)}),t.length?((a=this.dataType)==null||a.inferFromInputs(t),this.dataType?(this.generateUnusedInputs(),this.generateUnusedOutputs(),this.variableInstances.forEach(s=>{s.generateUnusedInputs(),s.generateUnusedOutputs()}),this):this):this}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.description=e.description||this.description,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),Za(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(r.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{r.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.dataType){const{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];if(this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(r=>{t.push(r),r.setValueWriter(this)}),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.internalCalls.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.dataType){const{affected:r}=this.dataType.restore({seenEntities:e});t.push(...r)}return this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.dataType)==null?void 0:r.toFlat(e))||[],...this.writesValues.flatMap(a=>a.toFlat(e)),...this.successCalls.flatMap(a=>a.toFlat(e)),...this.errorCalls.flatMap(a=>a.toFlat(e)),...this.inputs.flatMap(a=>a.toFlat(e)),...this.outputs.flatMap(a=>a.toFlat(e)),...this.internalCalls.flatMap(a=>a.toFlat(e))])}toFlatIds(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.dataType)==null?void 0:r.toFlatIds(e))||[],...this.writesValues.flatMap(a=>a.toFlatIds(e)),...this.successCalls.flatMap(a=>a.toFlatIds(e)),...this.errorCalls.flatMap(a=>a.toFlatIds(e)),...this.inputs.flatMap(a=>a.toFlatIds(e)),...this.outputs.flatMap(a=>a.toFlatIds(e)),...this.internalCalls.flatMap(a=>a.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,dataType:((e=this.dataType)==null?void 0:e.toJSON())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(r=>r.toJSON()),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),internalCalls:this.internalCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,dataType:((e=this.dataType)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(r=>r.toReference()),inputs:this.inputs.map(r=>r.toReference()),outputs:this.outputs.map(r=>r.toReference()),successCalls:this.successCalls.map(r=>r.toReference()),errorCalls:this.errorCalls.map(r=>r.toReference()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),internalCalls:this.internalCalls.map(r=>r.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.dataType)==null?void 0:r.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.dataType)==null?void 0:r.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(a=>a.toFlatGenerationTarget(e)),...this.successCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.inputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.outputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(a=>a.toFlatGenerationTarget(e))])}clearErrors(){var e;return this.errors=[],this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),this.internalCalls.forEach(t=>t.clearErrors()),(e=this.dataType)==null||e.clearErrors(),this}validate(){const e=H2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t,r;return[...this.errors,...((t=this.dataType)==null?void 0:t.getErrors())||[],...this.inputs.flatMap(a=>a.getErrors()),...this.internalCalls.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...((r=this.readsValue)==null?void 0:r.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return((e=this.dataType)==null?void 0:e.defaultValue)||null}clone(e){return new pe(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}createInstance(e=this.project,t={}){const r={id:t.id||_.UUID.uuid(),version:t.version||1,type:n.VariableInstance,parent:e.toReference(),successCalls:t.successCalls||[],errorCalls:t.errorCalls||[],inputs:t.inputs||[],outputs:t.outputs||[],writesValues:t.writesValues||[],internalCalls:t.internalCalls||[],readsValue:t.readsValue||null,calledByEntry:t.calledByEntry||[],calledBySuccess:t.calledBySuccess||[],calledByError:t.calledByError||[],declaration:this.toJSON(),x:0,y:0},a=g(r,this.project);return a.setParent(e),a.initChildren(),e===this.project&&this.project.addVariableInstance(a),a}generateUnusedInputs(){if(this.dataType)if(this.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.dataType.entity.type)){const e=[...this.dataType.entity.properties];e.filter(s=>!s.getDataType()).forEach(s=>{const o=this.inputs.find(y=>C(y,this.project)===C(s,this.project));if(!o)return;const l=this.getMasterInputWithValueWritterFromAllInstances(o);if(!l)return;const p=un(l);s.setDataType(p),o.setDeclaration(s)}),e.filter(s=>!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===s.id})).forEach(s=>{const o={id:_.UUID.uuid(),version:1,type:n.InputMap,parent:this.toReference(),name:null,description:null,declaration:s,defaultValue:null,index:s.index,readsValue:null},l=g(o,this.project);return l.setParent(this),l.initChildren(),l.suggestion=!0,this.addInput(l),l}),this.inputs.filter(s=>!s.declaration).forEach(s=>{const o=e.find(l=>C(l,this.project)===C(s,this.project));o&&s.setDeclaration(o)})}}else return[];else return[];return[]}generateUnusedOutputs(){if(this.dataType)if(this.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.properties].filter(r=>!this.outputs.find(a=>a.declaration===r)).map(r=>{const a={id:_.UUID.uuid(),version:1,type:n.OutputMap,parent:this.toReference(),declaration:r,index:r.index,writesValues:[]},s=g(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,this.addOutput(s),s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.dataType)if(this.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.getAllInteractiveMethods()].filter(r=>!this.internalCalls.find(s=>{var l,p,y,f,m;return(((l=s.declaration)==null?void 0:l.id)||((y=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:y.entityId)||((m=(f=s.initialData)==null?void 0:f.declaration)==null?void 0:m.id))===r.id})).map(r=>{const a=r.createInternalCall(this);return a.suggestion=!0,this.addInternalCall(a),a})}else return[];else return[];return[]}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return(!this.dataType||this.dataType.inferred)&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(),this.dataType||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};c(pe,"MUTABLE_BASE_PROPERTIES",["name","description"]),c(pe,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(pe,"BASE_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"MUTABLE_META_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,"x","y"]),c(pe,"INMUTABLE_META_PROPERTIES",[...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"META_PROPERTIES",[...pe.MUTABLE_META_PROPERTIES,...pe.INMUTABLE_META_PROPERTIES]),c(pe,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),c(pe,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","dataType"]),c(pe,"UPSTREAM_PROPERTIES",[...pe.MUTABLE_UPSTREAM_PROPERTIES,...pe.INMUTABLE_UPSTREAM_PROPERTIES]),c(pe,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),c(pe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(pe,"DOWNSTREAM_PROPERTIES",[...pe.MUTABLE_DOWNSTREAM_PROPERTIES,...pe.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(pe,"PROPERTIES",[...pe.META_PROPERTIES,...pe.UPSTREAM_PROPERTIES,...pe.DOWNSTREAM_PROPERTIES]);let Lr=pe;function Y2(i){const e=D3(),t=i.toJSON();e.safeParse(t).success,i.inputs.forEach(l=>l.validate()),i.outputs.forEach(l=>l.validate()),i.internalCalls.forEach(l=>l.validate());const s=[..._n(i)];if(i.id==="exec-sequentially-result-variable-id"){const l=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(l.error)}const o=_u(i);return s.push(...o),ie(i.errors,s)}const ye=class ye{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.VariableInstance);c(this,"writesValues",[]);c(this,"readsValue",null);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"internalCalls",[]);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const R=N(e.parent);r=t.get(R)}const a=N(e.declaration),s=t.get(a),o=e.calledByEntry.map(R=>{const v=N(R);return t.get(v)}),l=e.calledBySuccess.map(R=>{const v=N(R);return t.get(v)}),p=e.calledByError.map(R=>{const v=N(R);return t.get(v)});let y=null;if(e.readsValue){const R=N(e.readsValue);y=t.get(R)}const f={id:e.id,version:1,type:n.VariableInstance,declaration:s.toReference(),calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],internalCalls:[],readsValue:y,inputs:[],outputs:[],writesValues:[],x:0,y:0,parent:r},m=g(f,t);return m.setParent(r),m.initChildren(),m}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0},declaration:{list:!1,types:[n.VariableDeclaration]}},t);return r=s.modifiedData,a.push(...s.errors,...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];let r=JSON.parse(JSON.stringify(e));const a=Ha(r,this);return r=a.modifiedData,t.push(...a.errors),e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
83
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:r}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&(this.readsValue.addValueReader(this),e.push(this.readsValue)),this.writesValues.forEach(a=>{a.setValueWriter(this),e.push(a)}),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(e=>!e.calledBy.length)}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.initialData.dataType&&(this.dataType=g(this.initialData.dataType,this.project),this.dataType.setParent(this),this.dataType.initChildren()),Ja.initWritesValues(this,this.parent),qa.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.initialData.inputs.forEach(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),this.addInput(t),t}),this.initialData.outputs.forEach(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),this.addOutput(t),t}),this.initialData.internalCalls.forEach(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),this.addInternalCall(t),t}),this.generateUnusedInputs(),this.generateUnusedOutputs(),this.generateUnusedInternalCalls(),(!this.dataType||this.dataType.inferred)&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(),this)}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}subscribeInstance(e){return this.variableInstances.includes(e)?this:(this.variableInstances.push(e),this)}removeInstance(e){return this.variableInstances=this.variableInstances.filter(t=>t.id!==e.id),this}getMasterInputWithValueWritterFromAllInstances(e){return E([...this.inputs,...this.variableInstances.flatMap(a=>a.inputs)]).find(a=>C(a,this.project)===C(e,this.project)&&!!a.readsValue)||e}inferDataTypeAndSyncInstancesInputsAndOutputs(){var r,a;if(!this.dataType){const s=g({id:this.id+"--infered-data-type",version:1,type:n.DataType,isList:!1,isNullable:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:null,constant:!1,like:!0,inferred:!0,defaultValue:null,parent:this.toReference()},this.project);s.sync({inferred:!0,like:!0}),s.setParent(this),s.initChildren(),this.setDataType(s)}if(this.readsValue){const s=(r=this.readsValue.getDataType())==null?void 0:r.clone(this);return s&&(s.sync({inferred:!0,like:!0}),this.setDataType(s)),this}const e=E([...this.inputs,...this.variableInstances.flatMap(s=>s.inputs)]),t=[];return e.forEach(s=>{t.find(l=>C(l,this.project)===C(s,this.project))||t.push(s)}),t.length?((a=this.dataType)==null||a.inferFromInputs(t),this.dataType?(this.generateUnusedInputs(),this.generateUnusedOutputs(),this.variableInstances.forEach(s=>{s.generateUnusedInputs(),s.generateUnusedOutputs()}),this):this):this}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.description=e.description||this.description,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),Za(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(r.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{r.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.dataType){const{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];if(this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(r=>{t.push(r),r.setValueWriter(this)}),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.internalCalls.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.dataType){const{affected:r}=this.dataType.restore({seenEntities:e});t.push(...r)}return this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.dataType)==null?void 0:r.toFlat(e))||[],...this.writesValues.flatMap(a=>a.toFlat(e)),...this.successCalls.flatMap(a=>a.toFlat(e)),...this.errorCalls.flatMap(a=>a.toFlat(e)),...this.inputs.flatMap(a=>a.toFlat(e)),...this.outputs.flatMap(a=>a.toFlat(e)),...this.internalCalls.flatMap(a=>a.toFlat(e))])}toFlatIds(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.dataType)==null?void 0:r.toFlatIds(e))||[],...this.writesValues.flatMap(a=>a.toFlatIds(e)),...this.successCalls.flatMap(a=>a.toFlatIds(e)),...this.errorCalls.flatMap(a=>a.toFlatIds(e)),...this.inputs.flatMap(a=>a.toFlatIds(e)),...this.outputs.flatMap(a=>a.toFlatIds(e)),...this.internalCalls.flatMap(a=>a.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,dataType:((e=this.dataType)==null?void 0:e.toJSON())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(r=>r.toJSON()),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),internalCalls:this.internalCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,dataType:((e=this.dataType)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(r=>r.toReference()),inputs:this.inputs.map(r=>r.toReference()),outputs:this.outputs.map(r=>r.toReference()),successCalls:this.successCalls.map(r=>r.toReference()),errorCalls:this.errorCalls.map(r=>r.toReference()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),internalCalls:this.internalCalls.map(r=>r.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.dataType)==null?void 0:r.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.dataType)==null?void 0:r.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(a=>a.toFlatGenerationTarget(e)),...this.successCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.inputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.outputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(a=>a.toFlatGenerationTarget(e))])}clearErrors(){var e;return this.errors=[],this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),this.internalCalls.forEach(t=>t.clearErrors()),(e=this.dataType)==null||e.clearErrors(),this}validate(){const e=H2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t,r;return[...this.errors,...((t=this.dataType)==null?void 0:t.getErrors())||[],...this.inputs.flatMap(a=>a.getErrors()),...this.internalCalls.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...((r=this.readsValue)==null?void 0:r.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return((e=this.dataType)==null?void 0:e.defaultValue)||null}clone(e){return new pe(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}createInstance(e=this.project,t={}){const r={id:t.id||_.UUID.uuid(),version:t.version||1,type:n.VariableInstance,parent:e.toReference(),successCalls:t.successCalls||[],errorCalls:t.errorCalls||[],inputs:t.inputs||[],outputs:t.outputs||[],writesValues:t.writesValues||[],internalCalls:t.internalCalls||[],readsValue:t.readsValue||null,calledByEntry:t.calledByEntry||[],calledBySuccess:t.calledBySuccess||[],calledByError:t.calledByError||[],declaration:this.toJSON(),x:0,y:0},a=g(r,this.project);return a.setParent(e),a.initChildren(),e===this.project&&this.project.addVariableInstance(a),a}generateUnusedInputs(){if(this.dataType)if(this.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.dataType.entity.type)){const e=[...this.dataType.entity.properties];e.filter(s=>!s.getDataType()).forEach(s=>{const o=this.inputs.find(y=>C(y,this.project)===C(s,this.project));if(!o)return;const l=this.getMasterInputWithValueWritterFromAllInstances(o);if(!l)return;const p=un(l);s.setDataType(p),o.setDeclaration(s)}),e.filter(s=>!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===s.id})).forEach(s=>{const o={id:_.UUID.uuid(),version:1,type:n.InputMap,parent:this.toReference(),name:null,description:null,declaration:s,defaultValue:null,index:s.index,readsValue:null},l=g(o,this.project);return l.setParent(this),l.initChildren(),l.suggestion=!0,this.addInput(l),l}),this.inputs.filter(s=>!s.declaration).forEach(s=>{const o=e.find(l=>C(l,this.project)===C(s,this.project));o&&s.setDeclaration(o)})}}else return[];else return[];return[]}generateUnusedOutputs(){if(this.dataType)if(this.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.properties].filter(r=>!this.outputs.find(a=>a.declaration===r)).map(r=>{const a={id:_.UUID.uuid(),version:1,type:n.OutputMap,parent:this.toReference(),declaration:r,index:r.index,writesValues:[]},s=g(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,this.addOutput(s),s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.dataType)if(this.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.getAllInteractiveMethods()].filter(r=>!this.internalCalls.find(s=>{var l,p,y,f,m;return(((l=s.declaration)==null?void 0:l.id)||((y=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:y.entityId)||((m=(f=s.initialData)==null?void 0:f.declaration)==null?void 0:m.id))===r.id})).map(r=>{const a=r.createInternalCall(this);return a.suggestion=!0,this.addInternalCall(a),a})}else return[];else return[];return[]}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return(!this.dataType||this.dataType.inferred)&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(),this.dataType||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};c(pe,"MUTABLE_BASE_PROPERTIES",["name","description"]),c(pe,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(pe,"BASE_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"MUTABLE_META_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,"x","y"]),c(pe,"INMUTABLE_META_PROPERTIES",[...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"META_PROPERTIES",[...pe.MUTABLE_META_PROPERTIES,...pe.INMUTABLE_META_PROPERTIES]),c(pe,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),c(pe,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","dataType"]),c(pe,"UPSTREAM_PROPERTIES",[...pe.MUTABLE_UPSTREAM_PROPERTIES,...pe.INMUTABLE_UPSTREAM_PROPERTIES]),c(pe,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),c(pe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(pe,"DOWNSTREAM_PROPERTIES",[...pe.MUTABLE_DOWNSTREAM_PROPERTIES,...pe.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(pe,"PROPERTIES",[...pe.META_PROPERTIES,...pe.UPSTREAM_PROPERTIES,...pe.DOWNSTREAM_PROPERTIES]);let Lr=pe;function Y2(i){const e=D3(),t=i.toJSON();e.safeParse(t).success,i.inputs.forEach(l=>l.validate()),i.outputs.forEach(l=>l.validate()),i.internalCalls.forEach(l=>l.validate());const s=[..._n(i)];if(i.id==="exec-sequentially-result-variable-id"){const l=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(l.error)}const o=_u(i);return s.push(...o),ie(i.errors,s)}const ye=class ye{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.VariableInstance);c(this,"writesValues",[]);c(this,"readsValue",null);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"internalCalls",[]);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const R=N(e.parent);r=t.get(R)}const a=N(e.declaration),s=t.get(a),o=e.calledByEntry.map(R=>{const v=N(R);return t.get(v)}),l=e.calledBySuccess.map(R=>{const v=N(R);return t.get(v)}),p=e.calledByError.map(R=>{const v=N(R);return t.get(v)});let y=null;if(e.readsValue){const R=N(e.readsValue);y=t.get(R)}const f={id:e.id,version:1,type:n.VariableInstance,declaration:s.toReference(),calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],internalCalls:[],readsValue:y,inputs:[],outputs:[],writesValues:[],x:0,y:0,parent:r},m=g(f,t);return m.setParent(r),m.initChildren(),m}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0},declaration:{list:!1,types:[n.VariableDeclaration]}},t);return r=s.modifiedData,a.push(...s.errors,...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];let r=JSON.parse(JSON.stringify(e));const a=Ha(r,this);return r=a.modifiedData,t.push(...a.errors),e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
84
84
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
85
85
  Specifically for variables, their scope is also calculated from their value readers and value writters.
86
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:r}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this),e.push(this.readsValue)),this.writesValues.forEach(a=>{a.setValueWriter(this),e.push(a)}),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){const e=this.usedInternalCalls;return this.internalCalls.filter(r=>!(e.find(o=>o.id===r.id)||e.find(o=>o.declaration===r.declaration)))}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}setParent(e){return this.parent=e,this}initChildren(){var e;if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===n.GenericReference){const t=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!t)return this;this.declaration=t}else this.declaration=g(this.initialData.declaration,this.project),this.declaration.setParent(this.parent),this.declaration.initChildren();return Ja.initWritesValues(this,this.parent),qa.initReadsValue(this),this.initialData.inputs.forEach(t=>{const r=g(t,this.project);return r.setParent(this),r.initChildren(),this.addInput(r),r}),this.initialData.outputs.forEach(t=>{const r=g(t,this.project);return r.setParent(this),r.initChildren(),this.addOutput(r),r}),this.successCalls=this.initialData.successCalls.map(t=>{const r=g(t,this.project);return r.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(r.type)?(r.setParent(this.parent.parent),r.initChildren()):r.type!==n.InternalCall&&(r.setParent(this.parent),r.initChildren()),r}),this.errorCalls=this.initialData.errorCalls.map(t=>{const r=g(t,this.project);return r.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(r.type)?(r.setParent(this.parent.parent),r.initChildren()):r.type!==n.InternalCall&&(r.setParent(this.parent),r.initChildren()),r}),this.internalCalls=this.initialData.internalCalls.reduce((t,r)=>{if(r.type===n.GenericReference){const a=this.project.findSubscribedInstanceFromReference(r);if(!a)return t;const s=a;return s.setParent(this),[...t,s]}else{const a=g(r,this.project);return a.setParent(this),a.initChildren(),[...t,a]}},[]),this.generateUnusedInputs(),this.generateUnusedOutputs(),this.generateUnusedInternalCalls(),this.declaration.subscribeInstance(this),(!this.declaration.dataType||(e=this.declaration.dataType)!=null&&e.inferred)&&this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(),this}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),Za(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(r.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{r.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),this.declaration.removeInstance(this),{affected:E(r),removed:E(a)})}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];return this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(r=>{t.push(r),r.setValueWriter(this)}),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.internalCalls.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),this.declaration.subscribeInstance(this),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.writesValues.flatMap(r=>r.toFlat(e)),...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.internalCalls.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.writesValues.flatMap(r=>r.toFlatIds(e)),...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.internalCalls.flatMap(r=>r.toFlatIds(e))])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,declaration:this.declaration.toReference(),readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,writesValues:this.writesValues.map(t=>t.toJSON()),inputs:this.inputs.map(t=>t.toJSON()),outputs:this.outputs.map(t=>t.toJSON()),successCalls:this.successCalls.map(t=>t.toJSON()),errorCalls:this.errorCalls.map(t=>t.toJSON()),internalCalls:this.internalCalls.map(t=>t.toJSON()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:((e=this.declaration)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(r=>r.toReference()),inputs:this.inputs.map(r=>r.toReference()),outputs:this.outputs.map(r=>r.toReference()),successCalls:this.successCalls.map(r=>r.toReference()),errorCalls:this.errorCalls.map(r=>r.toReference()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),internalCalls:this.internalCalls.map(r=>r.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.declaration)==null?void 0:r.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e)),...this.calledBy.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.declaration)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.readsValue)==null?void 0:a.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(s=>s.toFlatGenerationTarget(e)),...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(s=>s.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.outputs.forEach(e=>e.clearErrors()),this.successCalls.forEach(e=>e.clearErrors()),this.errorCalls.forEach(e=>e.clearErrors()),this.internalCalls.forEach(e=>e.clearErrors()),this}validate(){const e=Y2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...this.inputs.flatMap(r=>r.getErrors()),...this.internalCalls.flatMap(r=>r.getErrors()),...this.outputs.flatMap(r=>r.getErrors()),...((t=this.readsValue)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e,t;return((t=(e=this.declaration)==null?void 0:e.dataType)==null?void 0:t.defaultValue)||null}clone(e){return new ye(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}setDeclaration(e){return this.declaration!==e&&(this.declaration=e),this}generateUnusedInputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const e=[...this.declaration.dataType.entity.properties];e.filter(s=>!s.getDataType()).forEach(s=>{const o=this.inputs.find(y=>C(y,this.project)===C(s,this.project));if(!o)return;const l=this.declaration.getMasterInputWithValueWritterFromAllInstances(o);if(!l)return;const p=un(l);s.setDataType(p),o.setDeclaration(s)}),e.filter(s=>!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===s.id})).forEach(s=>{const o={id:_.UUID.uuid(),version:1,type:n.InputMap,parent:this.toReference(),name:null,description:null,declaration:s,defaultValue:null,index:s.index,readsValue:null},l=g(o,this.project);return l.setParent(this),l.initChildren(),l.suggestion=!0,this.addInput(l),l}),this.inputs.filter(s=>!s.declaration).forEach(s=>{const o=e.find(l=>C(l,this.project)===C(s,this.project));o&&s.setDeclaration(o)})}}else return[];else return[];return[]}generateUnusedOutputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.properties].filter(r=>!this.outputs.find(a=>a.declaration===r)).map(r=>{const a={id:_.UUID.uuid(),version:1,type:n.OutputMap,parent:this.toReference(),declaration:r,index:r.index,writesValues:[]},s=g(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,this.addOutput(s),s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.getAllInteractiveMethods()].filter(r=>!this.internalCalls.find(s=>{var l,p,y,f,m;return(((l=s.declaration)==null?void 0:l.id)||((y=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:y.entityId)||((m=(f=s.initialData)==null?void 0:f.declaration)==null?void 0:m.id))===r.id})).map(r=>{const a=r.createInternalCall(this);return a.suggestion=!0,this.addInternalCall(a),a})}else return[];else return[];return[]}getDataType(){var e;return((e=this.declaration)==null?void 0:e.getDataType())||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};c(ye,"MUTABLE_BASE_PROPERTIES",[]),c(ye,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(ye,"BASE_PROPERTIES",[...ye.MUTABLE_BASE_PROPERTIES,...ye.INMUTABLE_BASE_PROPERTIES]),c(ye,"MUTABLE_META_PROPERTIES",[...ye.MUTABLE_BASE_PROPERTIES,"x","y"]),c(ye,"INMUTABLE_META_PROPERTIES",[...ye.INMUTABLE_BASE_PROPERTIES]),c(ye,"META_PROPERTIES",[...ye.MUTABLE_META_PROPERTIES,...ye.INMUTABLE_META_PROPERTIES]),c(ye,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),c(ye,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),c(ye,"UPSTREAM_PROPERTIES",[...ye.MUTABLE_UPSTREAM_PROPERTIES,...ye.INMUTABLE_UPSTREAM_PROPERTIES]),c(ye,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),c(ye,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ye,"DOWNSTREAM_PROPERTIES",[...ye.MUTABLE_DOWNSTREAM_PROPERTIES,...ye.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ye,"PROPERTIES",[...ye.META_PROPERTIES,...ye.UPSTREAM_PROPERTIES,...ye.DOWNSTREAM_PROPERTIES]);let Gr=ye;function z2(i){var s;const e=m6(),t=i.toJSON();e.safeParse(t).success,(s=i.dataType)==null||s.validate();const a=[];if(i.id==="iterate-over-employee-list-continue-statement-employee-dto-output-decl-id"){const o=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});a.push(o.error)}return ie(i.errors,a)}const Ie=class Ie{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"index");c(this,"required");c(this,"isError");c(this,"type",n.ReturnDeclaration);c(this,"dataType",null);c(this,"readsValue",null);c(this,"implements",null);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.index=e.index,this.name=e.name,this.description=e.description,this.required=e.required,this.isError=e.isError}static fromGenerationTarget(e,t){const r=N(e.parent),a=t.get(r);let s=null;if(e.readsValue){const p=N(e.readsValue);s=t.get(p)}const o={id:e.id,version:1,name:e.name,type:n.ReturnDeclaration,index:a.outputs.length,isError:!1,description:e.description,implements:null,required:e.required,readsValue:s,dataType:null,parent:a},l=g(o,t);return l.setParent(a),l.initChildren(),l}static validateGenerationTarget(e,t){var l,p;let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[n.ReturnStatement,n.Search,n.BreakStatement,n.ContinueStatement]}},t),o=Ru(r,t);if(r=s.modifiedData,r.parent){const y=t.get(N(r.parent));if(y&&[n.BreakStatement,n.ContinueStatement].includes(y.type)){const f=y,m=f.parent,R=[...m.breakStatements.filter(P=>P.id!==y.id),...m.continueStatements.filter(P=>P.id!==y.id)];if(f.outputs.length)a.push(new b({id:`${r.id}--${S.NoOverlapWithImplementedSignature}`,code:S.NoOverlapWithImplementedSignature,severity:T.Error,message:`Entity of type '${n.ReturnDeclaration}' with id '${r.id}' cannot be added to the parent entity of type '${f.type}' with id '${f.id}'. This '${f.type}' already has return declarations.
86
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:r}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this),e.push(this.readsValue)),this.writesValues.forEach(a=>{a.setValueWriter(this),e.push(a)}),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){const e=this.usedInternalCalls;return this.internalCalls.filter(r=>!(e.find(o=>o.id===r.id)||e.find(o=>o.declaration===r.declaration)))}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}setParent(e){return this.parent=e,this}initChildren(){var e;if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===n.GenericReference){const t=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!t)return this;this.declaration=t}else this.declaration=g(this.initialData.declaration,this.project),this.declaration.setParent(this.parent),this.declaration.initChildren();return Ja.initWritesValues(this,this.parent),qa.initReadsValue(this),this.initialData.inputs.forEach(t=>{const r=g(t,this.project);return r.setParent(this),r.initChildren(),this.addInput(r),r}),this.initialData.outputs.forEach(t=>{const r=g(t,this.project);return r.setParent(this),r.initChildren(),this.addOutput(r),r}),this.successCalls=this.initialData.successCalls.map(t=>{const r=g(t,this.project);return r.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(r.type)?(r.setParent(this.parent.parent),r.initChildren()):r.type!==n.InternalCall&&(r.setParent(this.parent),r.initChildren()),r}),this.errorCalls=this.initialData.errorCalls.map(t=>{const r=g(t,this.project);return r.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(r.type)?(r.setParent(this.parent.parent),r.initChildren()):r.type!==n.InternalCall&&(r.setParent(this.parent),r.initChildren()),r}),this.internalCalls=this.initialData.internalCalls.reduce((t,r)=>{if(r.type===n.GenericReference){const a=this.project.findSubscribedInstanceFromReference(r);if(!a)return t;const s=a;return s.setParent(this),[...t,s]}else{const a=g(r,this.project);return a.setParent(this),a.initChildren(),[...t,a]}},[]),this.generateUnusedInputs(),this.generateUnusedOutputs(),this.generateUnusedInternalCalls(),this.declaration.subscribeInstance(this),(!this.declaration.dataType||(e=this.declaration.dataType)!=null&&e.inferred)&&this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(),this}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),Za(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(r.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{r.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),this.declaration.removeInstance(this),{affected:E(r),removed:E(a)})}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];return this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(r=>{t.push(r),r.setValueWriter(this)}),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.internalCalls.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),this.declaration.subscribeInstance(this),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.writesValues.flatMap(r=>r.toFlat(e)),...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.internalCalls.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.writesValues.flatMap(r=>r.toFlatIds(e)),...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.internalCalls.flatMap(r=>r.toFlatIds(e))])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,declaration:this.declaration.toReference(),readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,writesValues:this.writesValues.map(t=>t.toJSON()),inputs:this.inputs.map(t=>t.toJSON()),outputs:this.outputs.map(t=>t.toJSON()),successCalls:this.successCalls.map(t=>t.toJSON()),errorCalls:this.errorCalls.map(t=>t.toJSON()),internalCalls:this.internalCalls.map(t=>t.toJSON()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:((e=this.declaration)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(r=>r.toReference()),inputs:this.inputs.map(r=>r.toReference()),outputs:this.outputs.map(r=>r.toReference()),successCalls:this.successCalls.map(r=>r.toReference()),errorCalls:this.errorCalls.map(r=>r.toReference()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),internalCalls:this.internalCalls.map(r=>r.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.declaration)==null?void 0:r.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e)),...this.calledBy.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.declaration)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.readsValue)==null?void 0:a.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(s=>s.toFlatGenerationTarget(e)),...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(s=>s.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.outputs.forEach(e=>e.clearErrors()),this.successCalls.forEach(e=>e.clearErrors()),this.errorCalls.forEach(e=>e.clearErrors()),this.internalCalls.forEach(e=>e.clearErrors()),this}validate(){const e=Y2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...this.inputs.flatMap(r=>r.getErrors()),...this.internalCalls.flatMap(r=>r.getErrors()),...this.outputs.flatMap(r=>r.getErrors()),...((t=this.readsValue)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e,t;return((t=(e=this.declaration)==null?void 0:e.dataType)==null?void 0:t.defaultValue)||null}clone(e){return new ye(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}setDeclaration(e){return this.declaration!==e&&(this.declaration=e),this}generateUnusedInputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const e=[...this.declaration.dataType.entity.properties];e.filter(s=>!s.getDataType()).forEach(s=>{const o=this.inputs.find(y=>C(y,this.project)===C(s,this.project));if(!o)return;const l=this.declaration.getMasterInputWithValueWritterFromAllInstances(o);if(!l)return;const p=un(l);s.setDataType(p),o.setDeclaration(s)}),e.filter(s=>!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===s.id})).forEach(s=>{const o={id:_.UUID.uuid(),version:1,type:n.InputMap,parent:this.toReference(),name:null,description:null,declaration:s,defaultValue:null,index:s.index,readsValue:null},l=g(o,this.project);return l.setParent(this),l.initChildren(),l.suggestion=!0,this.addInput(l),l}),this.inputs.filter(s=>!s.declaration).forEach(s=>{const o=e.find(l=>C(l,this.project)===C(s,this.project));o&&s.setDeclaration(o)})}}else return[];else return[];return[]}generateUnusedOutputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.properties].filter(r=>!this.outputs.find(a=>a.declaration===r)).map(r=>{const a={id:_.UUID.uuid(),version:1,type:n.OutputMap,parent:this.toReference(),declaration:r,index:r.index,writesValues:[]},s=g(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,this.addOutput(s),s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([n.CustomEntity,n.PrimitiveEntity,n.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.getAllInteractiveMethods()].filter(r=>!this.internalCalls.find(s=>{var l,p,y,f,m;return(((l=s.declaration)==null?void 0:l.id)||((y=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:y.entityId)||((m=(f=s.initialData)==null?void 0:f.declaration)==null?void 0:m.id))===r.id})).map(r=>{const a=r.createInternalCall(this);return a.suggestion=!0,this.addInternalCall(a),a})}else return[];else return[];return[]}getDataType(){var e;return((e=this.declaration)==null?void 0:e.getDataType())||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};c(ye,"MUTABLE_BASE_PROPERTIES",[]),c(ye,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(ye,"BASE_PROPERTIES",[...ye.MUTABLE_BASE_PROPERTIES,...ye.INMUTABLE_BASE_PROPERTIES]),c(ye,"MUTABLE_META_PROPERTIES",[...ye.MUTABLE_BASE_PROPERTIES,"x","y"]),c(ye,"INMUTABLE_META_PROPERTIES",[...ye.INMUTABLE_BASE_PROPERTIES]),c(ye,"META_PROPERTIES",[...ye.MUTABLE_META_PROPERTIES,...ye.INMUTABLE_META_PROPERTIES]),c(ye,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),c(ye,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),c(ye,"UPSTREAM_PROPERTIES",[...ye.MUTABLE_UPSTREAM_PROPERTIES,...ye.INMUTABLE_UPSTREAM_PROPERTIES]),c(ye,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),c(ye,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ye,"DOWNSTREAM_PROPERTIES",[...ye.MUTABLE_DOWNSTREAM_PROPERTIES,...ye.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ye,"PROPERTIES",[...ye.META_PROPERTIES,...ye.UPSTREAM_PROPERTIES,...ye.DOWNSTREAM_PROPERTIES]);let Gr=ye;function z2(i){var s;const e=m6(),t=i.toJSON();e.safeParse(t).success,(s=i.dataType)==null||s.validate();const a=[];if(i.id==="iterate-over-employee-list-continue-statement-employee-dto-output-decl-id"){const o=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});a.push(o.error)}return ie(i.errors,a)}const Ie=class Ie{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"index");c(this,"required");c(this,"isError");c(this,"type",n.ReturnDeclaration);c(this,"dataType",null);c(this,"readsValue",null);c(this,"implements",null);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.index=e.index,this.name=e.name,this.description=e.description,this.required=e.required,this.isError=e.isError}static fromGenerationTarget(e,t){const r=N(e.parent),a=t.get(r);let s=null;if(e.readsValue){const p=N(e.readsValue);s=t.get(p)}const o={id:e.id,version:1,name:e.name,type:n.ReturnDeclaration,index:a.outputs.length,isError:!1,description:e.description,implements:null,required:e.required,readsValue:s,dataType:null,parent:a},l=g(o,t);return l.setParent(a),l.initChildren(),l}static validateGenerationTarget(e,t){var l,p;let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[n.ReturnStatement,n.Search,n.BreakStatement,n.ContinueStatement]}},t),o=Ru(r,t);if(r=s.modifiedData,r.parent){const y=t.get(N(r.parent));if(y&&[n.BreakStatement,n.ContinueStatement].includes(y.type)){const f=y,m=f.parent,R=[...m.breakStatements.filter(P=>P.id!==y.id),...m.continueStatements.filter(P=>P.id!==y.id)];if(f.outputs.length)a.push(new b({id:`${r.id}--${S.NoOverlapWithImplementedSignature}`,code:S.NoOverlapWithImplementedSignature,severity:T.Error,message:`Entity of type '${n.ReturnDeclaration}' with id '${r.id}' cannot be added to the parent entity of type '${f.type}' with id '${f.id}'. This '${f.type}' already has return declarations.
87
87
  ${Au}`,issue:null}));else{const P=(p=(l=R[0])==null?void 0:l.outputs[0])==null?void 0:p.name;P!==r.name&&a.push(new b({id:`${r.id}--${S.NoOverlapWithImplementedSignature}`,code:S.NoOverlapWithImplementedSignature,severity:T.Error,message:`Entity of type '${n.ReturnDeclaration}' with id '${r.id}' cannot be added to the parent entity of type '${f.type}' with id '${f.id}'. This new 'return-declaration' doesn't have the same name "${P}" as the return declarations on the other statements in the same scope.
88
88
  ${Au}`,issue:null}))}}else if(y&&y.type===n.ReturnStatement){const f=y.parent;if(f&&xe.includes(f.type)){const m=f.implements;if(m){const R=m.outputs.find(k=>k.name===r.name),v=m.outputs.filter(k=>!y.outputs.find(me=>me.type===n.ReturnDeclaration&&me.name===k.name)),P=y.outputs.filter(k=>k.type===n.ReturnDeclaration),A=P.find(k=>k.name===r.name),D=P.length?`The parent entity already implements the following return declarations: ${U(P.map(k=>`'${k.id}' (${k.name})`),", "," and ")}.`:"The parent entity does not yet have any implemented return declarations.",F=v.length?`The parent entity is still missing the following returns in the implementation: ${U(v.map(k=>`'${k.id}' (${k.name})`),", "," and ")}.`:"The parent entity has all the returns it needs implemented.";R?A&&a.push(new b({id:`${r.id}--${S.NoOverlapWithImplementedSignature}`,code:S.NoOverlapWithImplementedSignature,severity:T.Error,message:`Entity of type '${n.ReturnDeclaration}' with id '${r.id}' should not exist in a parent entity of type '${y.type}' with id '${y.id}' that implements a ${n.ActionDescriptor} with fixed outputs.
89
89
  Adding a new return would make the implementation invalid. An return with the same name already exists in the parent entity.
@@ -94,7 +94,7 @@ ${D}
94
94
  ${F}`,issue:null}))}}}}return a.push(...s.errors,...o,...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];let r=JSON.parse(JSON.stringify(e));const a=Ha(r,this);return r=a.modifiedData,t.push(...a.errors),r.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
95
95
  This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),{errors:t,modifiedData:r}}addSelfToProject(){var a;const e=[this],t=[],r=[];if(this.parent.addOutputDeclaration(this),e.push(this.parent),(a=this.readsValue)==null||a.addValueReader(this),this.readsValue&&e.push(this.readsValue),this.parent&&[n.BreakStatement,n.ContinueStatement].includes(this.parent.type)){const s=this.parent.parent,{updated:o,added:l,removed:p}=s.syncChildren();e.push(...o),t.push(...l),r.push(...p)}return{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}setImplements(e){return this.implements=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.dataType&&(this.dataType=g(this.initialData.dataType,this.project),this.dataType.setParent(this),this.dataType.initChildren()),this.initialData.implements){const e=g(this.initialData.implements,this.project);this.implements=e}return qa.initReadsValue(this),this}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.index=e.index||(e.index!==0?this.index:0),this.name=e.name||this.name,this.description=e.description||this.description,this.required=e.required||this.required,this.isError=e.isError||this.isError,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),Za(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.dataType){const s=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s.affected),a.push(...s.removed)}return{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.dataType){const r=this.dataType.restore({seenEntities:e});t.push(...r.affected)}return{affected:[],self:this}}toFlat(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.dataType)==null?void 0:r.toFlat(e))||[]])}toFlatIds(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.dataType)==null?void 0:r.toFlatIds(e))||[]])}toJSON(){var e,t,r;return{id:this.id,version:this.version,name:this.name,description:this.description,type:this.type,index:this.index,required:this.required,isError:this.isError,dataType:((e=this.dataType)==null?void 0:e.toJSON())||null,implements:((t=this.implements)==null?void 0:t.toJSON())||null,readsValue:((r=this.readsValue)==null?void 0:r.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r;return{id:this.id,version:this.version,name:this.name,description:this.description,type:this.type,index:this.index,required:this.required,isError:this.isError,readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,implements:((t=this.implements)==null?void 0:t.toReference())||null,dataType:((r=this.dataType)==null?void 0:r.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.dataType)==null?void 0:r.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,isError:this.isError,readsValue:(e=this.readsValue)==null?void 0:e.id,required:this.required,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.readsValue)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.dataType)==null?void 0:a.toFlatGenerationTarget(e))||[]])}clearErrors(){var e;return this.errors=[],(e=this.dataType)==null||e.clearErrors(),this}validate(){const e=z2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...((t=this.dataType)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return((e=this.dataType)==null?void 0:e.defaultValue)||null}clone(e=null,t=null,r=!0){var f;const a=this.toJSON(),s=t||Ze(C(this,this.project),n.ReturnDeclaration,this.project);a.dataType=null;const o=s.split("-id"),l=o[o.length-1||0]||s;a.id=s;const p=qt(a,this.project);e?p.setParent(e):p.setParent(this.parent),r&&p.subscribe(),p.initChildren();const y=(f=this.dataType)==null?void 0:f.clone(p,l+"--data-type-id",r);return p.dataType=y||null,p}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}inferDataType(){const e=yu(this);if(e){const t=e.clone(this);t&&(t.inferred=!0,this.setDataType(t))}return this}getCounterparts(){let e=[];if([n.BreakStatement,n.ContinueStatement].includes(this.parent.type)){const t=this.parent.parent;e=[...t.breakStatements,...t.continueStatements].flatMap(s=>s.outputs).filter(s=>C(s,this.project)===C(this,this.project)&&s.id!==this.id)}else if(this.parent.type===n.ReturnStatement&&[n.FunctionDeclaration,n.GlobalEvent].includes(this.parent.parent.type)&&this.parent.parent.implements){const r=this.parent.parent.returnStatements.flatMap(a=>a.outputs);this.implements?e=r.filter(s=>{var o;return this.implements.id===((o=s.implements)==null?void 0:o.id)}):e=r.filter(s=>C(s,this.project)===C(this,this.project)&&s.id!==this.id)}return e}inferDataTypeFromCounterparts(){var r,a;const e=this.getCounterparts(),t=e.find(s=>{var o;return(o=s.dataType)==null?void 0:o.isResolved});if(t)this.setDataType(t.dataType);else for(let s=0;s<e.length;s++){const o=e[s];if((!o.dataType||!o.dataType.isResolved||(r=o.dataType)!=null&&r.inferred)&&o.readsValue&&o.inferDataType(),(a=o.dataType)!=null&&a.isResolved){this.setDataType(o.dataType);break}}return this}getDataType(){var e;return(!this.dataType||!this.dataType.isResolved||(e=this.dataType)!=null&&e.inferred)&&this.readsValue?this.inferDataType():this.inferDataTypeFromCounterparts(),this.dataType}};c(Ie,"MUTABLE_BASE_PROPERTIES",["name","description","required","isError"]),c(Ie,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(Ie,"BASE_PROPERTIES",[...Ie.MUTABLE_BASE_PROPERTIES,...Ie.INMUTABLE_BASE_PROPERTIES]),c(Ie,"MUTABLE_META_PROPERTIES",[...Ie.MUTABLE_BASE_PROPERTIES,"index"]),c(Ie,"INMUTABLE_META_PROPERTIES",[...Ie.INMUTABLE_BASE_PROPERTIES]),c(Ie,"META_PROPERTIES",[...Ie.MUTABLE_META_PROPERTIES,...Ie.INMUTABLE_META_PROPERTIES]),c(Ie,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),c(Ie,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","dataType"]),c(Ie,"UPSTREAM_PROPERTIES",[...Ie.MUTABLE_UPSTREAM_PROPERTIES,...Ie.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ie,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ie,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ie,"DOWNSTREAM_PROPERTIES",[...Ie.MUTABLE_DOWNSTREAM_PROPERTIES,...Ie.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ie,"PROPERTIES",[...Ie.META_PROPERTIES,...Ie.UPSTREAM_PROPERTIES,...Ie.DOWNSTREAM_PROPERTIES]);let Nt=Ie;function Z2(i){var o;const e=G6(),t=i.toJSON();e.safeParse(t).success,i.inputsDeclarations.forEach(l=>l.validate()),i.inputs.forEach(l=>l.validate()),i.outputsDeclarations.forEach(l=>l.validate()),i.outputs.forEach(l=>l.validate()),(o=i.error)==null||o.validate();const s=[..._n(i)];if(i.id==="search-person-by-id-id"){const l=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(l.error)}return ie(i.errors,s)}const Ge=class Ge{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"query","");c(this,"type",n.Search);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"inputsDeclarations",[]);c(this,"inputs",[]);c(this,"outputsDeclarations",[]);c(this,"outputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"error",null);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y,this.name=e.name,this.query=e.query,this.description=e.description}static fromGenerationTarget(e,t){let r=t;if(e.parent){const y=N(e.parent);r=t.get(y)}const a=e.calledByEntry.map(y=>{const f=N(y);return t.get(f)}),s=e.calledBySuccess.map(y=>{const f=N(y);return t.get(f)}),o=e.calledByError.map(y=>{const f=N(y);return t.get(f)}),l={id:e.id,version:1,type:n.Search,name:e.name,description:e.description,query:e.query,calledByEntry:a,calledBySuccess:s,calledByError:o,errorCalls:[],successCalls:[],inputsDeclarations:[],inputs:[],outputsDeclarations:[],outputs:[],error:null,x:0,y:0,parent:r},p=g(l,t);return p.setParent(r),p.initChildren(),p}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);return r=s.modifiedData,a.push(...s.errors,...Le(r)),{errors:a,modifiedData:r}}get resultsAsList(){const e=this.outputsDeclarations[0];if(e){const t=e.getDataType();return t?t.isList===!0:!0}return!0}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
96
96
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
97
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addSearch(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(a=>a.id===e.id);t>-1&&this.inputs.splice(t,1);const r=this.inputsDeclarations.findIndex(a=>{var s;return a.id===((s=e.declaration)==null?void 0:s.id)});return r>-1&&this.inputsDeclarations.splice(r,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addInputDeclaration(e){return this.inputsDeclarations.includes(e)?this:(this.inputsDeclarations.push(e),this.syncInputMaps(),this)}removeInputDeclaration(e){const t=this.inputsDeclarations.findIndex(r=>r.id===e.id);return t>-1&&this.inputsDeclarations.splice(t,1),this}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(r=>r.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),this}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputsDeclarations=this.initialData.inputsDeclarations.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputsDeclarations=this.initialData.outputsDeclarations.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncInputMaps(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this.name=e.name||this.name,this.description=e.description||this.description,e.query!==void 0&&(this.query=e.query),this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.inputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputsDeclarations.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputsDeclarations.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.inputsDeclarations.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.outputsDeclarations.flatMap(r=>r.toFlat(e)),...this.calledBy.flatMap(r=>r.toFlat(e)),...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.inputsDeclarations.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.outputsDeclarations.flatMap(r=>r.toFlatIds(e)),...this.calledBy.flatMap(r=>r.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[]])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,name:this.name,query:this.query,description:this.description,x:this.x,y:this.y,successCalls:this.successCalls.map(t=>t.toJSON()),errorCalls:this.errorCalls.map(t=>t.toJSON()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),inputsDeclarations:this.inputsDeclarations.map(t=>t.toJSON()),inputs:this.inputs.map(t=>t.toJSON()),outputsDeclarations:this.outputsDeclarations.map(t=>t.toJSON()),outputs:this.outputs.map(t=>t.toJSON()),parent:this.parent.toReference(),error:((e=this.error)==null?void 0:e.toJSON())||null}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,query:this.query,x:this.x,y:this.y,inputs:this.inputs.map(e=>e.toReference()),inputsDeclarations:this.inputsDeclarations.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),outputsDeclarations:this.outputsDeclarations.map(e=>e.toReference()),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.inputsDeclarations.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.outputsDeclarations.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,query:this.query,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputsDeclarations.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputsDeclarations.flatMap(r=>r.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],this.inputsDeclarations.forEach(t=>t.clearErrors()),this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),(e=this.error)==null||e.clearErrors(),this}validate(){const e=Z2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputsDeclarations.flatMap(t=>t.getErrors()),...this.inputs.flatMap(t=>t.getErrors()),...this.outputsDeclarations.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new Ge(this.toJSON(),this.project)}syncInputMaps(){const e=[],t=[],r=[];return this.inputsDeclarations.forEach(a=>{if(!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===a.id})){const o={id:this.id+"--"+_.UUID.uuid(),version:1,type:n.InputMap,declaration:a.toJSON(),readsValue:null,defaultValue:null,index:this.inputs.length,name:null,description:null,parent:this.toReference()},l=g(o,this.project);l.setParent(this),l.initChildren(),l.addSelfToProject(),e.push(this),t.push(l)}}),this.inputs.forEach(a=>{if(!this.inputsDeclarations.find(o=>{var l;return o.id===((l=a.declaration)==null?void 0:l.id)})){const{affected:o,removed:l}=a.remove();e.push(...o),r.push(...l)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(Ge,"MUTABLE_BASE_PROPERTIES",["name","description","query"]),c(Ge,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(Ge,"BASE_PROPERTIES",[...Ge.MUTABLE_BASE_PROPERTIES,...Ge.INMUTABLE_BASE_PROPERTIES]),c(Ge,"MUTABLE_META_PROPERTIES",[...Ge.MUTABLE_BASE_PROPERTIES,"x","y"]),c(Ge,"INMUTABLE_META_PROPERTIES",[...Ge.INMUTABLE_BASE_PROPERTIES]),c(Ge,"META_PROPERTIES",[...Ge.MUTABLE_META_PROPERTIES,...Ge.INMUTABLE_META_PROPERTIES]),c(Ge,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(Ge,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(Ge,"UPSTREAM_PROPERTIES",[...Ge.MUTABLE_UPSTREAM_PROPERTIES,...Ge.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","inputsDeclarations","inputs","outputsDeclarations","outputs","error"]),c(Ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ge,"DOWNSTREAM_PROPERTIES",[...Ge.MUTABLE_DOWNSTREAM_PROPERTIES,...Ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ge,"PROPERTIES",[...Nt.META_PROPERTIES,...Nt.UPSTREAM_PROPERTIES,...Nt.DOWNSTREAM_PROPERTIES]);let $r=Ge;function K2(i){const e=C3(),t=i.toJSON();e.safeParse(t).success,i.functions.forEach(s=>s.validate()),i.events.forEach(s=>s.validate());const a=[];return ie(i.errors,a)}const De=class De{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"type",n.InstalledProject);c(this,"implements");c(this,"functions",[]);c(this,"events",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y,this.implements=e.implements}static fromGenerationTarget(e,t){const r=t,a={id:e.id,version:1,name:e.name,type:n.InstalledProject,description:e.description,functions:[],events:[],implements:{entityId:e.implements,entityType:n.Project,type:n.GenericReference,id:_.UUID.uuid()},x:0,y:0,parent:r},s=g(a,t);return s.setParent(r),s.initChildren(),s}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[];return a.push(...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an installed project, must be the root project as it is a globally declared entity.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.functions=this.initialData.functions.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.events=this.initialData.events.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.functions.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});r.push(...o),a.push(...l)}),this.events.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});r.push(...o),a.push(...l)}),{affected:[],removed:[]})}restore({seenEntities:e}={seenEntities:new Set}){return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.functions.forEach(t=>{t.restore({seenEntities:e})}),this.events.forEach(t=>{t.restore({seenEntities:e})}),{affected:[],self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.functions.flatMap(r=>r.toFlat(e)),...this.events.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.functions.flatMap(r=>r.toFlatIds(e)),...this.events.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,implements:this.implements,functions:this.functions.map(e=>e.toJSON()),events:this.events.map(e=>e.toJSON()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,implements:this.implements,functions:this.functions.map(e=>e.toReference()),events:this.events.map(e=>e.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.functions.flatMap(r=>r.toFlatJSON(e)),...this.events.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,name:this.name,description:this.description,type:this.type,implements:this.implements.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.functions.flatMap(r=>r.toFlatGenerationTarget(e)),...this.events.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.functions.forEach(e=>e.clearErrors()),this.events.forEach(e=>e.clearErrors()),this}validate(){const e=K2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.functions.flatMap(t=>t.getErrors()),...this.events.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(){return new De(this.toJSON(),this.project)}};c(De,"MUTABLE_BASE_PROPERTIES",[]),c(De,"INMUTABLE_BASE_PROPERTIES",["id","version","name","description","type"]),c(De,"BASE_PROPERTIES",[...De.MUTABLE_BASE_PROPERTIES,...De.INMUTABLE_BASE_PROPERTIES]),c(De,"MUTABLE_META_PROPERTIES",["x","y"]),c(De,"INMUTABLE_META_PROPERTIES",[...De.INMUTABLE_BASE_PROPERTIES]),c(De,"META_PROPERTIES",[...De.MUTABLE_META_PROPERTIES,...De.INMUTABLE_META_PROPERTIES]),c(De,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(De,"INMUTABLE_UPSTREAM_PROPERTIES",["implements","parent"]),c(De,"UPSTREAM_PROPERTIES",[...De.MUTABLE_UPSTREAM_PROPERTIES,...De.INMUTABLE_UPSTREAM_PROPERTIES]),c(De,"MUTABLE_DOWNSTREAM_PROPERTIES",["functions","events"]),c(De,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(De,"DOWNSTREAM_PROPERTIES",[...De.MUTABLE_DOWNSTREAM_PROPERTIES,...De.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(De,"PROPERTIES",[...De.META_PROPERTIES,...De.UPSTREAM_PROPERTIES,...De.DOWNSTREAM_PROPERTIES]);let Fr=De;function X2(i){var l;const e=x6(),t=i.toJSON();e.safeParse(t).success,i.inputs.forEach(p=>p.validate()),i.outputs.forEach(p=>p.validate()),(l=i.error)==null||l.validate();const a=_n(i),s=Q2(i),o=[...a,...s];return ie(i.errors,o)}function Q2(i){const e=[],t=No(i.parent),r=t==null?void 0:t.entity;if(!r)e.push(Y({id:`${i.id}--${S.InternalCallParentMissingDataType}`,code:S.InternalCallParentMissingDataType,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) its id "${i.declaration}".`,issue:null,entity:i}).error);else if(![n.CustomEntity,n.BuiltInBaseEntity,n.PrimitiveEntity].includes(r.type))e.push(Y({id:`${i.id}--${S.InternalCallParentDeclarationEntityInvalidType}`,code:S.InternalCallParentDeclarationEntityInvalidType,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", belongs to a variable whose data type 'entity' is not a custom entity, built-in base entity or primitive entity.
97
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addSearch(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(a=>a.id===e.id);t>-1&&this.inputs.splice(t,1);const r=this.inputsDeclarations.findIndex(a=>{var s;return a.id===((s=e.declaration)==null?void 0:s.id)});return r>-1&&this.inputsDeclarations.splice(r,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addInputDeclaration(e){return this.inputsDeclarations.includes(e)?this:(this.inputsDeclarations.push(e),this.syncInputMaps(),this)}removeInputDeclaration(e){const t=this.inputsDeclarations.findIndex(r=>r.id===e.id);return t>-1&&this.inputsDeclarations.splice(t,1),this}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(r=>r.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),this}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputsDeclarations=this.initialData.inputsDeclarations.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputsDeclarations=this.initialData.outputsDeclarations.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncInputMaps(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this.name=e.name||this.name,this.description=e.description||this.description,e.query!==void 0&&(this.query=e.query),this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.inputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.outputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{r.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{r.push(s),s.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputsDeclarations.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputsDeclarations.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.inputsDeclarations.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.outputsDeclarations.flatMap(r=>r.toFlat(e)),...this.calledBy.flatMap(r=>r.toFlat(e)),...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.inputsDeclarations.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.outputsDeclarations.flatMap(r=>r.toFlatIds(e)),...this.calledBy.flatMap(r=>r.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[]])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,name:this.name,query:this.query,description:this.description,x:this.x,y:this.y,successCalls:this.successCalls.map(t=>t.toJSON()),errorCalls:this.errorCalls.map(t=>t.toJSON()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),inputsDeclarations:this.inputsDeclarations.map(t=>t.toJSON()),inputs:this.inputs.map(t=>t.toJSON()),outputsDeclarations:this.outputsDeclarations.map(t=>t.toJSON()),outputs:this.outputs.map(t=>t.toJSON()),parent:this.parent.toReference(),error:((e=this.error)==null?void 0:e.toJSON())||null}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,query:this.query,x:this.x,y:this.y,inputs:this.inputs.map(e=>e.toReference()),inputsDeclarations:this.inputsDeclarations.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),outputsDeclarations:this.outputsDeclarations.map(e=>e.toReference()),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.inputsDeclarations.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.outputsDeclarations.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,query:this.query,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputsDeclarations.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputsDeclarations.flatMap(r=>r.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],this.inputsDeclarations.forEach(t=>t.clearErrors()),this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),(e=this.error)==null||e.clearErrors(),this}validate(){const e=Z2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputsDeclarations.flatMap(t=>t.getErrors()),...this.inputs.flatMap(t=>t.getErrors()),...this.outputsDeclarations.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new Ge(this.toJSON(),this.project)}syncInputMaps(){const e=[],t=[],r=[];return this.inputsDeclarations.forEach(a=>{if(!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===a.id})){const o={id:this.id+"--"+_.UUID.uuid(),version:1,type:n.InputMap,declaration:a.toJSON(),readsValue:null,defaultValue:null,index:this.inputs.length,name:null,description:null,parent:this.toReference()},l=g(o,this.project);l.setParent(this),l.initChildren(),l.addSelfToProject(),e.push(this),t.push(l)}}),this.inputs.forEach(a=>{if(!this.inputsDeclarations.find(o=>{var l;return o.id===((l=a.declaration)==null?void 0:l.id)})){const{affected:o,removed:l}=a.remove();e.push(...o),r.push(...l)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(Ge,"MUTABLE_BASE_PROPERTIES",["name","description","query"]),c(Ge,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(Ge,"BASE_PROPERTIES",[...Ge.MUTABLE_BASE_PROPERTIES,...Ge.INMUTABLE_BASE_PROPERTIES]),c(Ge,"MUTABLE_META_PROPERTIES",[...Ge.MUTABLE_BASE_PROPERTIES,"x","y"]),c(Ge,"INMUTABLE_META_PROPERTIES",[...Ge.INMUTABLE_BASE_PROPERTIES]),c(Ge,"META_PROPERTIES",[...Ge.MUTABLE_META_PROPERTIES,...Ge.INMUTABLE_META_PROPERTIES]),c(Ge,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(Ge,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(Ge,"UPSTREAM_PROPERTIES",[...Ge.MUTABLE_UPSTREAM_PROPERTIES,...Ge.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","inputsDeclarations","inputs","outputsDeclarations","outputs","error"]),c(Ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ge,"DOWNSTREAM_PROPERTIES",[...Ge.MUTABLE_DOWNSTREAM_PROPERTIES,...Ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ge,"PROPERTIES",[...Nt.META_PROPERTIES,...Nt.UPSTREAM_PROPERTIES,...Nt.DOWNSTREAM_PROPERTIES]);let $r=Ge;function K2(i){const e=C3(),t=i.toJSON();e.safeParse(t).success,i.functions.forEach(s=>s.validate()),i.events.forEach(s=>s.validate());const a=[];return ie(i.errors,a)}const De=class De{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"type",n.InstalledProject);c(this,"implements");c(this,"functions",[]);c(this,"events",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y,this.implements=e.implements}static fromGenerationTarget(e,t){const r=t,a={id:e.id,version:1,name:e.name,type:n.InstalledProject,description:e.description,functions:[],events:[],implements:{entityId:e.implements,entityType:n.Project,type:n.GenericReference,id:_.UUID.uuid()},x:0,y:0,parent:r},s=g(a,t);return s.setParent(r),s.initChildren(),s}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[];return a.push(...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an installed project, must be the root project as it is a globally declared entity.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.functions=this.initialData.functions.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.events=this.initialData.events.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.functions.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});r.push(...o),a.push(...l)}),this.events.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});r.push(...o),a.push(...l)}),{affected:[],removed:[]})}restore({seenEntities:e}={seenEntities:new Set}){return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.functions.forEach(t=>{t.restore({seenEntities:e})}),this.events.forEach(t=>{t.restore({seenEntities:e})}),{affected:[],self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.functions.flatMap(r=>r.toFlat(e)),...this.events.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.functions.flatMap(r=>r.toFlatIds(e)),...this.events.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,implements:this.implements,functions:this.functions.map(e=>e.toJSON()),events:this.events.map(e=>e.toJSON()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,implements:this.implements,functions:this.functions.map(e=>e.toReference()),events:this.events.map(e=>e.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.functions.flatMap(r=>r.toFlatJSON(e)),...this.events.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,name:this.name,description:this.description,type:this.type,implements:this.implements.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.functions.flatMap(r=>r.toFlatGenerationTarget(e)),...this.events.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.functions.forEach(e=>e.clearErrors()),this.events.forEach(e=>e.clearErrors()),this}validate(){const e=K2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.functions.flatMap(t=>t.getErrors()),...this.events.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(){return new De(this.toJSON(),this.project)}};c(De,"MUTABLE_BASE_PROPERTIES",[]),c(De,"INMUTABLE_BASE_PROPERTIES",["id","version","name","description","type"]),c(De,"BASE_PROPERTIES",[...De.MUTABLE_BASE_PROPERTIES,...De.INMUTABLE_BASE_PROPERTIES]),c(De,"MUTABLE_META_PROPERTIES",["x","y"]),c(De,"INMUTABLE_META_PROPERTIES",[...De.INMUTABLE_BASE_PROPERTIES]),c(De,"META_PROPERTIES",[...De.MUTABLE_META_PROPERTIES,...De.INMUTABLE_META_PROPERTIES]),c(De,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(De,"INMUTABLE_UPSTREAM_PROPERTIES",["implements","parent"]),c(De,"UPSTREAM_PROPERTIES",[...De.MUTABLE_UPSTREAM_PROPERTIES,...De.INMUTABLE_UPSTREAM_PROPERTIES]),c(De,"MUTABLE_DOWNSTREAM_PROPERTIES",["functions","events"]),c(De,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(De,"DOWNSTREAM_PROPERTIES",[...De.MUTABLE_DOWNSTREAM_PROPERTIES,...De.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(De,"PROPERTIES",[...De.META_PROPERTIES,...De.UPSTREAM_PROPERTIES,...De.DOWNSTREAM_PROPERTIES]);let Fr=De;function X2(i){var l;const e=x6(),t=i.toJSON();e.safeParse(t).success,i.inputs.forEach(p=>p.validate()),i.outputs.forEach(p=>p.validate()),(l=i.error)==null||l.validate();const a=_n(i),s=Q2(i),o=[...a,...s];return ie(i.errors,o)}function Q2(i){const e=[],t=No(i.parent),r=t==null?void 0:t.entity;if(!r)e.push(Y({id:`${i.id}--${S.InternalCallParentMissingDataType}`,code:S.InternalCallParentMissingDataType,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) its id "${i.declaration}".`,issue:null,entity:i}).error);else if(![n.CustomEntity,n.BuiltInBaseEntity,n.PrimitiveEntity].includes(r.type))e.push(Y({id:`${i.id}--${S.InternalCallParentDeclarationEntityInvalidType}`,code:S.InternalCallParentDeclarationEntityInvalidType,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", belongs to a variable whose data type 'entity' is not a custom entity, built-in base entity or primitive entity.
98
98
  This variable's data-type has an 'entity' field that references an entity with id '${r.id}' and of type '${r.type}'.`,issue:null,entity:i}).error);else{const a=qu(r),s=[];[n.CustomEntity,n.BuiltInBaseEntity,n.PrimitiveEntity].includes(r.type)&&s.push(...r.getAllInteractiveMethods());let o="";a?r.methods.length?o=`
99
99
  All 'function-declaration' entities attached as methods to the parent data-type 'entity' field, available to be called as 'internal-calls' in this variable are:
100
100
  - ${r.methods.map(y=>y.id).join(`
@@ -123,7 +123,7 @@ ${Qn}`);const R=r.declaration;if(!t.get(R))a.push(new b({id:`${r.id}--${h.Refere
123
123
  The declaration of the internal-call must be a 'function-declaration' entity which exists as a method in the entity of the data-type of the parent variable.${m}`,issue:null})):a.push(new b({id:`${r.id}--${S.InternalCallDeclarationNotFoundInParentDatatypeEntity}`,code:S.InternalCallDeclarationNotFoundInParentDatatypeEntity,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) with id "${r.declaration}".${m}`,issue:null}))}}(l.inputs.length||l.outputs.length||l.internalCalls.length)&&a.push(new b({id:`${r.id}--${h.InvalidInternalCallParentRelation}`,code:h.InvalidInternalCallParentRelation,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}", can only be added to a variable declaration or variable instance parent if the parent doesn't already have inputs, outputs or other internal calls.
124
124
  If you need a new variable-instance for this, consider using the 'implement_variable_instance' generation action to create one and give it a caller.
125
125
  The you can attach the new internal-call to it.`,issue:null}))}return a.push(...s.errors,...Le(r)),{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
126
- This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],r=[];return this.parent.addInternalCall(this),e.push(this.parent),(a=this.process)==null||a.writesValues.forEach(s=>{s.setValueWriter(this.process),e.push(s)}),this.successCalls.forEach(s=>{s.addSuccessCaller(this),e.push(s)}),this.errorCalls.forEach(s=>{s.addErrorCaller(this),e.push(s)}),this.calledBySuccess.forEach(s=>{s.addSuccessCall(this),e.push(s)}),this.calledByError.forEach(s=>{s.addErrorCall(this),e.push(s)}),this.calledByEntry.forEach(s=>{s.addCall(this),e.push(s)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addValueReader(e){var t;return(t=this.process)==null||t.addValueReader(e),this}removeValueReader(e){var t;return(t=this.process)==null||t.removeValueReader(e),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.parent.type!==n.GenericReference){const e=g(this.initialData.parent,this.project);this.setParent(e),this.parent.initChildren(),this.parent.addInternalCall(this);const t=this.calledBy.find(r=>!!r.parent&&ut.includes(r.parent.type));if(t){const r=g(t.parent,this.project);this.parent.setParent(r)}else if(!t&&!this.parent.calledBy.length)throw new Error("Parent of internal call parent could not be resolved")}return this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.index=e.index||(e.index!==0?this.index:0),this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s;const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:o,removed:l}=(s=this.process)==null?void 0:s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}if(this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.outputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.error){const{affected:o,removed:l}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}return this.successCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),this.errorCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),e||this.calledBy.forEach(o=>{r.push(o),o.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.process){const{affected:r}=this.process.restore({seenEntities:e});t.push(...r)}return this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.calledBy.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.calledBy.flatMap(r=>r.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.error?this.error.toFlatIds(e):[]])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,index:this.index,successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:(e=this.process)==null?void 0:e.toJSON(),declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),parent:this.parent.toReference(),error:(t=this.error)==null?void 0:t.toJSON()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,index:this.index,process:this.process?this.process.toReference():null,inputs:this.inputs.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),declaration:this.declaration.toReference(),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.process?this.process.toFlatJSON(e):[],...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(e=>e.id),calledBySuccess:this.calledBySuccess.map(e=>e.id),calledByError:this.calledByError.map(e=>e.id),declaration:this.declaration.id,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.process?this.process.toFlatGenerationTarget(e):[],...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=X2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new fe(this.toJSON(),this.project)}};c(fe,"MUTABLE_BASE_PROPERTIES",[]),c(fe,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(fe,"BASE_PROPERTIES",[...fe.MUTABLE_BASE_PROPERTIES,...fe.INMUTABLE_BASE_PROPERTIES]),c(fe,"MUTABLE_META_PROPERTIES",[...fe.MUTABLE_BASE_PROPERTIES,"index"]),c(fe,"INMUTABLE_META_PROPERTIES",[...fe.INMUTABLE_BASE_PROPERTIES]),c(fe,"META_PROPERTIES",[...fe.MUTABLE_META_PROPERTIES,...fe.INMUTABLE_META_PROPERTIES]),c(fe,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(fe,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),c(fe,"UPSTREAM_PROPERTIES",[...fe.MUTABLE_UPSTREAM_PROPERTIES,...fe.INMUTABLE_UPSTREAM_PROPERTIES]),c(fe,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","outputs","writesValues","successCalls","errorCalls","error"]),c(fe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(fe,"DOWNSTREAM_PROPERTIES",[...fe.MUTABLE_DOWNSTREAM_PROPERTIES,...fe.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(fe,"PROPERTIES",[...fe.META_PROPERTIES,...fe.UPSTREAM_PROPERTIES,...fe.DOWNSTREAM_PROPERTIES]);let Ni=fe;function e7(i){const e=J6(),t=i.toJSON();e.safeParse(t).success;const a=[];if(i.id==="exec-sequentially-argument-map-id"){const s=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});a.push(s.error)}return ie(i.errors,a)}const Pe=class Pe{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"index");c(this,"name",null);c(this,"description",null);c(this,"declaration",null);c(this,"type",n.InputMap);c(this,"defaultValue",null);c(this,"readsValue",null);c(this,"dataType",null);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.index=e.index,this.name=e.name||null,this.description=e.description||null}static fromGenerationTarget(e,t){const r=N(e.parent),a=t.get(r);let s=null;if(e.declaration){const y=N(e.declaration);s=t.get(y)}let o=null;if(e.readsValue){const y=N(e.readsValue);o=t.get(y)}const l={id:e.id,version:1,name:e.name||null,type:n.InputMap,index:(a.inputs||[]).length,description:e.description||null,declaration:s,readsValue:o,defaultValue:null,parent:a},p=g(l,t);return p.setParent(a),p.initChildren(),p}static validateGenerationTarget(e,t){var y;let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...Ue,n.InputMap]}},t);r=s.modifiedData;const o=t.get(r.parent),l=r.declaration&&(t.get(r.declaration)||t.getBuiltIn(r.declaration)),p=((o==null?void 0:o.inputs)||[]).find(f=>{var m;return r.declaration&&((m=f.declaration)==null?void 0:m.id)===r.declaration});if(r.declaration?l?[n.Property,n.ArgumentDeclaration,n.ValueDescriptor].includes(l.type)?o&&l.type===n.ArgumentDeclaration&&![n.FunctionCall,n.Search,n.InternalCall].includes(o.type)?a.push(new b({id:`${r.id}--${h.InvalidInputMapDeclaration}`,code:h.InvalidInputMapDeclaration,severity:T.Error,message:`Entity of type '${n.InputMap}' with id '${r.id}' has a 'declaration' property pointing to an entity with type '${n.ArgumentDeclaration}' with id '${r.declaration}'.
126
+ This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],r=[];return this.parent.addInternalCall(this),e.push(this.parent),(a=this.process)==null||a.writesValues.forEach(s=>{s.setValueWriter(this.process),e.push(s)}),this.successCalls.forEach(s=>{s.addSuccessCaller(this),e.push(s)}),this.errorCalls.forEach(s=>{s.addErrorCaller(this),e.push(s)}),this.calledBySuccess.forEach(s=>{s.addSuccessCall(this),e.push(s)}),this.calledByError.forEach(s=>{s.addErrorCall(this),e.push(s)}),this.calledByEntry.forEach(s=>{s.addCall(this),e.push(s)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addValueReader(e){var t;return(t=this.process)==null||t.addValueReader(e),this}removeValueReader(e){var t;return(t=this.process)==null||t.removeValueReader(e),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.parent.type!==n.GenericReference){const e=g(this.initialData.parent,this.project);this.setParent(e),this.parent.initChildren(),this.parent.addInternalCall(this);const t=this.calledBy.find(r=>!!r.parent&&ut.includes(r.parent.type));if(t){const r=g(t.parent,this.project);this.parent.setParent(r)}else if(!t&&!this.parent.calledBy.length)throw new Error("Parent of internal call parent could not be resolved")}return this.declaration=g(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.index=e.index||(e.index!==0?this.index:0),this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s;const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:o,removed:l}=(s=this.process)==null?void 0:s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}if(this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.outputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.error){const{affected:o,removed:l}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}return this.successCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),this.errorCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),e||this.calledBy.forEach(o=>{r.push(o),o.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.process){const{affected:r}=this.process.restore({seenEntities:e});t.push(...r)}return this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.calledBy.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e)),...this.calledBy.flatMap(r=>r.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.error?this.error.toFlatIds(e):[]])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,index:this.index,successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:(e=this.process)==null?void 0:e.toJSON(),declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),parent:this.parent.toReference(),error:(t=this.error)==null?void 0:t.toJSON()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,index:this.index,process:this.process?this.process.toReference():null,inputs:this.inputs.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),declaration:this.declaration.toReference(),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.process?this.process.toFlatJSON(e):[],...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.calledBy.flatMap(r=>r.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(e=>e.id),calledBySuccess:this.calledBySuccess.map(e=>e.id),calledByError:this.calledByError.map(e=>e.id),declaration:this.declaration.id,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.process?this.process.toFlatGenerationTarget(e):[],...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=X2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new fe(this.toJSON(),this.project)}};c(fe,"MUTABLE_BASE_PROPERTIES",[]),c(fe,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(fe,"BASE_PROPERTIES",[...fe.MUTABLE_BASE_PROPERTIES,...fe.INMUTABLE_BASE_PROPERTIES]),c(fe,"MUTABLE_META_PROPERTIES",[...fe.MUTABLE_BASE_PROPERTIES,"index"]),c(fe,"INMUTABLE_META_PROPERTIES",[...fe.INMUTABLE_BASE_PROPERTIES]),c(fe,"META_PROPERTIES",[...fe.MUTABLE_META_PROPERTIES,...fe.INMUTABLE_META_PROPERTIES]),c(fe,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(fe,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),c(fe,"UPSTREAM_PROPERTIES",[...fe.MUTABLE_UPSTREAM_PROPERTIES,...fe.INMUTABLE_UPSTREAM_PROPERTIES]),c(fe,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","outputs","writesValues","successCalls","errorCalls","error"]),c(fe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(fe,"DOWNSTREAM_PROPERTIES",[...fe.MUTABLE_DOWNSTREAM_PROPERTIES,...fe.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(fe,"PROPERTIES",[...fe.META_PROPERTIES,...fe.UPSTREAM_PROPERTIES,...fe.DOWNSTREAM_PROPERTIES]);let Ni=fe;function e7(i){const e=J6(),t=i.toJSON();e.safeParse(t).success;const a=[];if(i.id==="exec-sequentially-argument-map-id"){const s=Y({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});a.push(s.error)}return ie(i.errors,a)}const Pe=class Pe{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"index");c(this,"name",null);c(this,"description",null);c(this,"declaration",null);c(this,"type",n.InputMap);c(this,"defaultValue",null);c(this,"readsValue",null);c(this,"dataType",null);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.index=e.index,this.name=e.name||null,this.description=e.description||null}static fromGenerationTarget(e,t){const r=N(e.parent),a=t.get(r);let s=null;if(e.declaration){const y=N(e.declaration);s=t.get(y)}let o=null;if(e.readsValue){const y=N(e.readsValue);o=t.get(y)}const l={id:e.id,version:1,name:e.name||null,type:n.InputMap,index:(a.inputs||[]).length,description:e.description||null,declaration:s,readsValue:o,defaultValue:null,parent:a},p=g(l,t);return p.setParent(a),p.initChildren(),p}static validateGenerationTarget(e,t){var y;let r=JSON.parse(JSON.stringify(e));const a=[],s=He(r,{parent:{list:!1,types:[...Ue,n.InputMap]}},t);r=s.modifiedData;const o=t.get(r.parent),l=r.declaration&&(t.get(r.declaration)||t.getBuiltIn(r.declaration)),p=((o==null?void 0:o.inputs)||[]).find(f=>{var m;return r.declaration&&((m=f.declaration)==null?void 0:m.id)===r.declaration});if(r.declaration?l?[n.Property,n.ArgumentDeclaration,n.ValueDescriptor].includes(l.type)?o&&l.type===n.ArgumentDeclaration&&![n.FunctionCall,n.Search,n.InternalCall].includes(o.type)?a.push(new b({id:`${r.id}--${h.InvalidInputMapDeclaration}`,code:h.InvalidInputMapDeclaration,severity:T.Error,message:`Entity of type '${n.InputMap}' with id '${r.id}' has a 'declaration' property pointing to an entity with type '${n.ArgumentDeclaration}' with id '${r.declaration}'.
127
127
  The parent entity of type '${o.type}' with id '${o.id}' is not compatible with this type of declaration.
128
128
  Only 'function-call', 'search' and 'internal-call' entities can have input-maps whose 'declaration' points to 'argument-declaration' entities.`,issue:null})):o&&l.type===n.Property&&!Fe.includes(o.type)?a.push(new b({id:`${r.id}--${h.InvalidInputMapDeclaration}`,code:h.InvalidInputMapDeclaration,severity:T.Error,message:`Entity of type '${n.InputMap}' with id '${r.id}' has a 'declaration' property pointing to an entity with type '${n.Property}' with id '${r.declaration}'.
129
129
  The parent entity of type '${o.type}' with id '${o.id}' is not compatible with this type of declaration.
@@ -388,7 +388,7 @@ All global 'function-declaration' entity ids are:
388
388
  The project currently has no global 'function-declaration' entities that can be called as 'function-call' entities.`;a.push(new b({id:`${r.id}--${h.InvalidReference}`,code:h.InvalidReference,severity:T.Error,message:`Entity of type "${n.FunctionCall}" with id "${r.id}", has an invalid reference at the 'declaration' property. The 'declaration' property must be a valid reference to an 'function-declaration' entity.
389
389
  References can either be an ID string or an object with exacly four properties: 'id', 'entityId', 'entityType', 'type'.${l}`,issue:null}))}return{errors:a,modifiedData:r}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
390
390
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
391
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addFunctionCall(this),(a=this.process)==null||a.writesValues.forEach(s=>{s.setValueWriter(this.process),e.push(s)}),this.successCalls.forEach(s=>{s.addSuccessCaller(this),e.push(s)}),this.errorCalls.forEach(s=>{s.addErrorCaller(this),e.push(s)}),this.calledBySuccess.forEach(s=>{s.addSuccessCall(this),e.push(s)}),this.calledByError.forEach(s=>{s.addErrorCall(this),e.push(s)}),this.calledByEntry.forEach(s=>{s.addCall(this),e.push(s)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addValueReader(e){var t;return(t=this.process)==null||t.addValueReader(e),this}removeValueReader(e){var t;return(t=this.process)==null||t.removeValueReader(e),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===n.FunctionDeclaration){const e=g(this.initialData.declaration,this.project);this.declaration=e}else{const e=N(this.initialData.declaration),t=this.project.get(e);this.declaration=t}return this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncMissingFixedInputs(),this.syncMissingFixedOutputs(),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s;const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:o,removed:l}=(s=this.process)==null?void 0:s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}if(this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.outputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.error){const{affected:o,removed:l}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}return this.successCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),this.errorCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),e||this.calledBy.forEach(o=>{r.push(o),o.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.process){const{affected:r}=this.process.restore({seenEntities:e});t.push(...r)}return this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:(e=this.process)==null?void 0:e.toJSON(),declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),parent:this.parent.toReference(),error:(t=this.error)==null?void 0:t.toJSON()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference():null,inputs:this.inputs.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),declaration:this.declaration.toReference(),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.process?this.process.toFlatJSON(e):[],...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,version:this.version,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.process?this.process.toFlatGenerationTarget(e):[],...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=A7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new _e(this.toJSON(),this.project)}removeUnrecognizedInputs(){const e=[],t=[],r=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}removeUnrecognizedOutputs(){const e=[],t=[],r=[];return this.outputs.forEach(a=>{if(!this.declaration.getUniqueReturnDeclarations().find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedInputs(){const e=[],t=[],r=[],a=this.declaration.inputs.filter(p=>!this.inputs.find(y=>y.declaration.id===p.id));this.inputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.inputs.forEach(m=>{m.index>=p.index&&m.sync({index:m.index+1})});const y={id:_.UUID.uuid(),version:1,type:n.InputMap,declaration:p.toJSON(),readsValue:null,defaultValue:null,index:p.index,name:null,description:null,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject(),t.push(f)}),this.inputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedInputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedOutputs(){const e=[],t=[],r=[],a=[];this.outputs=this.initialData.outputs.map(y=>{const f=g(y,this.project);return a.push(f.index),f.setParent(this),f.initChildren(),f});const s=this.declaration.getUniqueReturnDeclarations().filter(y=>!this.outputs.find(f=>f.declaration.id===y.id));this.outputs.sort((y,f)=>y.index-f.index),s.forEach((y,f)=>{this.outputs.forEach(P=>{P.index>=y.index&&P.index++});const m=a.includes(y.index)?this.outputs.length-1+f:y.index,R={id:_.UUID.uuid(),version:1,type:n.OutputMap,declaration:y.toJSON(),writesValues:[],index:m,parent:this.toReference()},v=g(R,this.project);v.setParent(this),v.initChildren(),v.addSelfToProject()}),this.outputs.sort((y,f)=>y.index-f.index);const{updated:o,added:l,removed:p}=this.removeUnrecognizedOutputs();return e.push(...o),t.push(...l),r.push(...p),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(_e,"MUTABLE_BASE_PROPERTIES",[]),c(_e,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(_e,"BASE_PROPERTIES",[..._e.MUTABLE_BASE_PROPERTIES,..._e.INMUTABLE_BASE_PROPERTIES]),c(_e,"MUTABLE_META_PROPERTIES",["x","y"]),c(_e,"INMUTABLE_META_PROPERTIES",[..._e.INMUTABLE_BASE_PROPERTIES]),c(_e,"META_PROPERTIES",[..._e.MUTABLE_META_PROPERTIES,..._e.INMUTABLE_META_PROPERTIES]),c(_e,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(_e,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),c(_e,"UPSTREAM_PROPERTIES",[..._e.MUTABLE_UPSTREAM_PROPERTIES,..._e.INMUTABLE_UPSTREAM_PROPERTIES]),c(_e,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),c(_e,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(_e,"DOWNSTREAM_PROPERTIES",[..._e.MUTABLE_DOWNSTREAM_PROPERTIES,..._e.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(_e,"PROPERTIES",[..._e.META_PROPERTIES,..._e.UPSTREAM_PROPERTIES,..._e.DOWNSTREAM_PROPERTIES]);let kr=_e;function kP(i){var e,t,r;switch(i.id){case B["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const a=i.project.entities.filter(f=>!!f.implements.find(m=>m.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));if(a.find(f=>!!f.properties.find(m=>{var R;return m.implements&&m.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((R=m.getDefaultValue())==null?void 0:R.value)===!0}))){const m=a[0].properties.find(v=>v.implements&&v.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),R=(e=m==null?void 0:m.dataType)==null?void 0:e.defaultValue;if(R)R.value=!0;else if(m!=null&&m.dataType){const v=(t=m==null?void 0:m.dataType)==null?void 0:t.id.split("-id")[0],P=g({id:v+"-default-value-id",version:1,type:n.PrimitiveValue,name:I.EntityTemplate,parentRelationType:null,autogeneration:null,value:!0,valueAsType:null,parent:m==null?void 0:m.dataType.toReference()},i.project);return P.setParent(m==null?void 0:m.dataType),P.initChildren(),P.addSelfToProject(),{newEntities:[P]}}return{newEntities:[]}}const o=i.project.get(B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),l=Jo(o,"Main database");if(l.errors.length>0)return{newEntities:[]};const p=l.implemented.properties.find(f=>f.implements&&f.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=(r=p==null?void 0:p.dataType)==null?void 0:r.defaultValue;if(y)y.value=!0;else if(p!=null&&p.dataType){const f=p==null?void 0:p.dataType.id.split("-id")[0],m=g({id:f+"-default-value-id",version:1,type:n.PrimitiveValue,name:I.EntityTemplate,parentRelationType:null,autogeneration:null,value:!0,valueAsType:null,parent:p==null?void 0:p.dataType.toReference()},i.project);m.setParent(p==null?void 0:p.dataType),m.initChildren(),m.addSelfToProject()}return{newEntities:[l.implemented]}}}return{newEntities:[]}}function qP(i){return i.implements.filter(t=>t.type===n.BuiltInBaseEntity).map(t=>{var r;switch(t.id){case B["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const s=i.project.entities.filter(p=>p.implements.find(y=>y.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)).find(p=>!!p.properties.find(y=>{var f;return y.implements&&y.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((f=y.getDefaultValue())==null?void 0:f.value)===!0}));if(!s)return{newEntities:[]};const o=i.properties.find(p=>p.implements&&p.implements.id===B["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),l=(r=o==null?void 0:o.dataType)==null?void 0:r.defaultValue;if(o&&(o!=null&&o.dataType)&&!l){const p=o==null?void 0:o.dataType.id.split("-id")[0],y=g({id:p+"-default-value-id",version:1,type:n.PrimitiveValue,name:I.EntityTemplate,parentRelationType:null,autogeneration:null,value:null,valueAsType:s,parent:o==null?void 0:o.dataType.toReference()},i.project);return y.setParent(o==null?void 0:o.dataType),y.initChildren(),y.addSelfToProject(),{newEntities:[y]}}return{newEntities:[]}}}}),{newEntities:[]}}function Jo(i,e,t){const r=t||Ze(e,n.CustomEntity,i.project),a=r.split("-id"),s=a[a.length-1||0]||r,o={id:r,version:1,name:e,type:n.CustomEntity,description:null,static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[i],x:0,y:0,parent:i.project},l=Lo(o,i.project);if(l.length>0)return{errors:l,implemented:null,entitiesChanges:{new:[],updated:[],deleted:[]}};const p=kP(i),y=g(o,i.project);y.setParent(i.project),y.initChildren();const f=i.properties.map(v=>{const P=s+"-"+Ze(C(v,i.project),n.Property,i.project),A=v.clone(y,P);return A.abstract=!1,A.implements=v,A.setParent(y),y.addProperty(A),A}),m=i.abstractMethods.map(v=>{const P=s+Ze(v.name,n.FunctionDeclaration,i.project),A=v.implementAsFunctionDeclaration(P),D={id:P+"-parent-ref-id",type:n.GenericReference,entityId:r,entityType:n.CustomEntity},F={...A,implements:v,parent:D},k=g(F,i.project);return y.addMethod(k),k.setParent(y),k.initChildren(),k.implements=v,k});o.properties=f,o.methods=m;const R=qP(y);return{implemented:y,errors:[],entitiesChanges:{new:[y,...p.newEntities,...R.newEntities],updated:[y],deleted:[]}}}function Nu(i,e){return e.entities.find(a=>{const s=a.properties,o=s.map(m=>m.name),l=i.every(m=>o.includes(m)),p=o.filter(m=>!i.includes(m)),y=s.every(m=>!p.includes(m.name)||!m.required);return l&&y})||null}function JP(i,e,t=We.OrDataTypeGroup){const r=[],a=[],s=[],l={id:e.id+"--nested-data-type-id-"+i.id,version:1,type:n.DataType,entity:i.toJSON(),isList:!1,isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parentRelationType:t,parent:e.toReference()},p=g(l,i.project);return a.push(p),p.setParent(e),p.initChildren(),p.setEntity(i),p.addSelfToProject(),{updated:E(r),added:E(a),removed:E(s),self:p}}function Mu(i,e,t,r){const a=[],s=[],o=[];switch(typeof i){case"string":let l=!1;const p=new Date(i);if(p instanceof Date&&!isNaN(p.valueOf())&&(l=!0),l){const y=e.project.getBuiltIn(B[n.PrimitiveEntity][I.Date].id);e.setEntity(y);break}else{const y=e.project.getBuiltIn(B[n.PrimitiveEntity][I.String].id);e.setEntity(y);break}case"number":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Number].id));break;case"boolean":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Boolean].id));break;case"object":if(i===null){e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Null].id));break}else if(Array.isArray(i))if(e.sync({isList:!0}),i.length>0){const y=i.slice(0,5).filter(m=>m!==void 0);if(y.every(m=>typeof m==typeof y[0])&&(typeof y[0]!="object"||y[0]===null))switch(typeof y[0]){case"string":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.String].id));break;case"number":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Number].id));break;case"boolean":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Boolean].id));break;case"object":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Null].id));break}else{const m=[];let R=!1;y.forEach((P,A)=>{if(Array.isArray(P)&&(R=!0),typeof P=="object"&&!Array.isArray(P)&&P!==null){const D=Wo(P,e.project,{...t,id:e.id+"--or-child-data-type-entity-id-"+A},r);D.hasCreated&&m.push(D.changeSet.self),a.push(...D.changeSet.updated),s.push(...D.changeSet.added),o.push(...D.changeSet.removed)}});const v=E(m);if(!v.length&&!R){y.forEach(P=>{const A={id:_.UUID.uuid(),version:1,type:n.DataType,entity:null,isList:!1,isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parentRelationType:We.OrDataTypeGroup,parent:e.toReference()},D=g(A,e.project);switch(D.setParent(e),D.initChildren(),D.addSelfToProject(),typeof P){case"string":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.String].id));break;case"number":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.Number].id));break;case"boolean":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.Boolean].id));break;case"object":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.Null].id));break}});break}else v.length===1&&!R?e.setEntity(v[0]):y.forEach((P,A)=>{if(typeof P=="object"&&!Array.isArray(P)&&P!==null){const D=Nu(Object.keys(P),e.project);if(D){const F=JP(D||v[0],e,We.OrDataTypeGroup);a.push(...F.updated),s.push(...F.added),o.push(...F.removed)}}else{const D={id:e.id+"--or-child-data-type-id--"+A,version:1,type:n.DataType,entity:null,isList:Array.isArray(P),isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parentRelationType:We.OrDataTypeGroup,parent:e.toReference()},F=g(D,e.project);F.setParent(e),F.initChildren(),F.addSelfToProject();const k=Mu(P,F,{...t,id:e.id+"--or-child-data-type-entity-id-"+A},r);a.push(...k.updated),s.push(...k.added),o.push(...k.removed)}})}}else{const y=Wo(i[0],e.project,{...t},r);e.setEntity(y.changeSet.self),a.push(...y.changeSet.updated),s.push(...y.changeSet.added),o.push(...y.changeSet.removed);break}else{const y=Wo(i,e.project,{...t},r);e.setEntity(y.changeSet.self),a.push(...y.changeSet.updated),s.push(...y.changeSet.added),o.push(...y.changeSet.removed);break}}return{updated:E(a),added:E(s),removed:E(o),self:e}}function Wo(i,e,t,r){const a=[],s=[],o=[],l=Object.keys(i),p=Nu(l,e);if(p)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],self:p}};const y=r?t.name+" of "+r.name:t.name,m={id:t.id||Ze(y,n.CustomEntity,e),version:1,name:y,type:n.CustomEntity,description:t.description||null,static:t.static||!1,abstract:t.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:e.toReference()},R=g(m,e);return R.setParent(e),R.initChildren(),R.addSelfToProject(),s.push(R),l.forEach((v,P)=>{const A=Ze(y+" "+v,n.Property,e),D={id:A,version:1,name:v,type:n.Property,description:null,static:!1,abstract:!1,dataType:null,implements:null,index:P,hidden:!1,private:!1,required:!0,parent:R.toReference()},F=g(D,e);F.setParent(R),F.initChildren(),F.addSelfToProject(),s.push(F);const k=i[v],me={id:A+"--data-type-id",version:1,type:n.DataType,entity:null,isList:!1,isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parent:F.toReference()},ae=g(me,e);ae.setParent(F),ae.initChildren(),ae.addSelfToProject(),s.push(ae);const Je=Mu(k,ae,{...t,name:v,id:A+"--data-type-entity-id"},r||R);a.push(...Je.updated),s.push(...Je.added),o.push(...Je.removed)}),{hasCreated:!0,changeSet:{updated:E(a),added:E(s),removed:E(o),self:R}}}function Ho(i,e){const t=qr(i);if(t.length===0)return{list:[],last:null};let r=null;return{list:t.flatMap(s=>{if(s===e)return r=s,[s];const o=Ho(s,e);return o.last&&(r=o.last),[s,...o.list]}),last:r}}function WP(i,e,t=new Set){const r=er(i),a=er(e),s=r.filter(p=>!a.includes(p)),o=r.filter(p=>a.includes(p)),l=s.reduce((p,y)=>t.has(y.id)?p:(t.add(y.id),E([...p,...WP(y,e,t)])),[]);return E([...o,...l])}function Ya(i,e){const t=Ho(i,e);return t.last===e&&t.list.length>0&&t.list[0]!==e}function O7(i,e){return!!Ho(i,e).last}function S7(i){if(xe.includes(i.type))return i;if([...hn,n.VariableDeclaration].includes(i.type)){const e=i.parent;return xe.includes(e.type)?e:null}return null}function Vu(i,e){if(!i||!e)throw new Error("Both entities must be defined to find a common ancestor");if(i===e)return i;const t=i.parent;if(t){if(t===e)return e;if(t.type===n.Project)return null}else return null;const r=e.parent;if(r){if(r===i)return i;if(r.type===n.Project)return null}else return null;return Vu(t,r)}function et(i){if(al.includes(i.type)){if(i.type===n.FunctionDeclaration){const e=i.parent;if(e.type===n.CustomEntity)return e;if(e.type===n.Loop)return e}return i}else{const e=i.parent;return e?et(e):null}}function HP(i){if(!i)return null;if(hn.includes(i.type))return i;const e=i.parent;return e?HP(e):null}function YP(i){if(!i)return null;if(Ue.includes(i.type))return i;const e=i.parent;return e?YP(e):null}function zP(i){if(!i)return null;if(Qt.includes(i.type))return i;const e=i.parent;return e?zP(e):null}function C7(i){return i.type===n.VariableDeclaration?[i]:Ue.includes(i.type)?[...i.inputs,...i.outputs||[]]:Ve.includes(i.type)?i.outputs:zr.includes(i.type)||i.type===n.FunctionDeclaration?i.inputs:[]}function B7(i){const e=er(i),t=[],r=[];zu.includes(i.type)&&t.push(...Lu(i));const a=e.filter(s=>{const o=t.includes(s);return o?!1:hn.includes(s.type)&&!o?(r.push(s),!1):!0});return t.sort((s,o)=>Ya(o,s)?-1:0),r.sort((s,o)=>Ya(o,s)?-1:0),[...t,...r,...a]}function ZP(i){return[...i].sort((e,t)=>Ya(t,e)?-1:0)}function w7(i){const e=ZP(i),t=[];return e.forEach(r=>{const a=t[t.length-1];if(a){const s=a[a.length-1];Ya(r,s)?t.push([r]):a.push(r)}else t.push([r])}),t}function Rt(i){const e=i.map(t=>et(t));return E(e)}function Lu(i){return Ue.includes(i.type)?[...Rt(i.successCalls),...Rt(i.errorCalls)]:xe.includes(i.type)?Rt(i.calls):[]}function _7(i,e){return Lu(i).includes(e)}function Gu(i){return i.writesValues||[]}function N7(i,e){return Gu(i).includes(e)}function KP(i){var e;return Fe.includes((e=i==null?void 0:i.readsValue)==null?void 0:e.type)?i.readsValue:null}function M7(i){return i.writesValues}function XP(i=[]){return i.map(KP).filter(e=>!!e)}function Yo(i=[]){return i.map(e=>e.writesValues).flat().filter(e=>Fe.includes(e.type))}function QP(i=[]){return i.map(e=>e.readsValue).filter(e=>!!e&&Fe.includes(e.type))}function eA(i){return Fe.includes(i.type)?i:null}function tA(i){return i.writesValues.map(eA).filter(e=>!!e)}function nA(i=[]){return i.reduce((e,t)=>t.type===n.OutputMap?[...e,...tA(t)]:e,[])}function Me(i){return Ue.includes(i.type)?[...yn(Rt(i.successCalls)),...yn(Rt(i.errorCalls))]:xe.includes(i.type)?yn(Rt(i.calls)):[]}function V7(i){return Ue.includes(i.type)?[...yn(Rt(i.successCalls)),...yn(Rt(i.errorCalls))]:xe.includes(i.type)?yn(Rt(i.calls)):[]}function rA(i,e=new Set){return i.writesValues.filter(r=>Fe.includes(r.type)&&!e.has(r.id)).reduce((r,a)=>e.has(a.id)?r:[...r,...re(a,e)],[])}function iA(i,e=new Set){var r;return(((r=i.readsValue)==null?void 0:r.writesValues)||[]).filter(a=>Fe.includes(a.type)&&!e.has(a.id)).reduce((a,s)=>e.has(s.id)?a:[...a,...re(s,e)],[])}function re(i,e=new Set){if(e.has(i.id))return[];if(i.type===n.ReturnStatement)return QP(i.outputs).reduce((r,a)=>[...r,...re(a,e)],[]);if(i.type===n.FunctionCall||i.type===n.Operation||i.type===n.Condition)return[...Me(i).reduce((s,o)=>{const l=et(o);return[...s,...re(l||o,e)]},[]),...XP(i.inputs),...nA(i.outputs)].reduce((s,o)=>[...s,...re(o,e)],[]);if(zr.includes(i.type)){const t=Yo(i.inputs),a=Me(i).reduce((s,o)=>{const l=et(o);return[...s,...re(l||o,e)]},[]);return t.push(...a),t.reduce((s,o)=>[...s,...re(o,e)],[])}if(i.type===n.FunctionDeclaration){const t=[...Yo(i.inputs)],a=Me(i).reduce((s,o)=>{const l=et(o);return[...s,...re(l||o,e)]},[]);return t.push(...a),t.reduce((s,o)=>[...s,...re(o)],[])}if(Fe.includes(i.type)){e.add(i.id);const r=Me(i).reduce((a,s)=>{const o=et(s);return[...a,...re(o||s,e)]},[]);return[i,...r,...iA(i,e),...rA(i,e)]}return[]}function St(i,e=new Set){return e.has(i.id)?[]:(e.add(i.id),[...er(i).reduce((a,s)=>[...a,s,...St(s,e)],[])])}function yn(i){return i.reduce((e,t)=>t.type===n.ReturnStatement||t.type===n.ContinueStatement||t.type===n.BreakStatement?[...e,t]:[...e,t,...Me(t)],[])}function aA(i){const e=i.entities||[],t=[...e,...i.functions||[],...i.events||[],...i.projects||[]],r=e.reduce((p,y)=>[...p,...y.properties],[]),a=e.reduce((p,y)=>[...p,...y.methods],[]),s=a.reduce((p,y)=>[...p,...Yo(y.inputs),...yn(Rt(y.calls)),...y.returnStatements],[]),o=i.functions.reduce((p,y)=>[...p,...yn(Rt(y.calls)),...y.returnStatements],[]),l=i.events.reduce((p,y)=>[...p,...yn(Rt(y.calls)),...y.returnStatements],[]);return[...t,...r,...a,...s,...o,...l]}function sA(i,e){return e.filter(r=>{if(!r)return!1;switch(r.type){case n.FunctionCall:return r.inputs.find(a=>a.id===i.id)!==void 0||r.outputs.find(a=>a.id===i.id)!==void 0;case n.Condition:return r.successCalls.find(a=>a.id===i.id)!==void 0||r.errorCalls.find(a=>a.id===i.id)!==void 0||r.inputs.find(a=>a.id===i.id)!==void 0;case n.Operation:return r.outputs.find(a=>a.id===i.id)!==void 0;case n.VariableDeclaration:return Ue.includes(i.type)?oA(i).find(s=>{var o;return((o=s.readsValue)==null?void 0:o.id)===r.id})!==void 0:!1;case n.CustomEntity:return r.properties.find(a=>a.id===i.id)!==void 0||r.methods.find(a=>a.id===i.id)!==void 0;case n.FunctionDeclaration:return r.inputs.find(a=>a.id===i.id)!==void 0||(r.returnStatements.map(a=>a.outputs).flat()||[]).find(a=>a.id===i.id)!==void 0;default:return!1}})}function L7(i){const e=aA(i.project);return sA(i,e)}function qr(i){const e=[];if(hn.includes(i.type)){i.calledBy.forEach(a=>{const s=et(a);s&&e.push(s)});const r=[...i.inputs||[],...i.outputs||[]].map(a=>Fu(a)).filter(a=>a!==null);e.push(...E(r))}if(Fe.includes(i.type)){const t=Fu(i);t&&e.push(t)}return E(e)}function $u(i){return i.type===n.FunctionCall||i.type===n.InternalCall||[n.Operation,n.Condition,n.Loop].includes(i.type)?i.declaration.inputs:i.type===n.FunctionDeclaration||zr.includes(i.type)?i.inputs:i.type===n.Search?i.inputsDeclarations:[]}function G7(i,e){return e.type===n.Condition?e.inputs.find(t=>t.declaration.id===i.id):e.type===n.FunctionCall||e.type===n.Operation?e.inputs.find(t=>t.declaration.id===i.id):null}function oA(i){return Ue.includes(i.type)?i.inputs:[]}function lA(i){var e;return i.type===n.FunctionCall?((e=i.declaration.returnStatements[0])==null?void 0:e.outputs)||[]:[n.Operation,n.Condition,n.Loop].includes(i.type)?i.declaration.outputs:i.type===n.Search?i.outputsDeclarations:Ve.includes(i.type)?i.outputs:[]}function $7(i,e){return e.type===n.Condition?null:e.type===n.FunctionCall||e.type===n.Operation?e.outputs.find(t=>t.declaration.id===i.id):null}function F7(i){return i.type===n.Condition?[]:Ue.includes(i.type)?i.outputs:[]}function Fu(i){const e=i.readsValue;return e?et(e):null}function cA(i){const e=i.internalCalls||[];return E(Rt(E(e.flatMap(t=>[...t.successCalls,...t.errorCalls]))))}function Li(i){const e=Gu(i),t=[];return e.forEach(r=>{if(Fe.includes(r.type))t.push(r);else if(Nn.includes(r.type)){const a=r.parent;t.push(a)}}),t}function E(i){const e=new Set;return i.filter(t=>!t||e.has(t.id)?!1:(e.add(t.id),!0))}function er(i,e=!1){const t=[];if(i.type===n.Project&&t.push(...(i==null?void 0:i.entities)||[],...(i==null?void 0:i.functions)||[],...(i==null?void 0:i.variableDeclarations)||[],...(i==null?void 0:i.variableInstances)||[],...(i==null?void 0:i.searches)||[],...(i==null?void 0:i.loops)||[],...(i==null?void 0:i.operations)||[],...(i==null?void 0:i.conditions)||[],...(i==null?void 0:i.functionCalls)||[],...(i==null?void 0:i.events)||[],...(i==null?void 0:i.projects)||[]),ut.includes(i.type)&&t.push(...(i==null?void 0:i.detachedChildren)||[]),i.type===n.CustomEntity){const r=[...i.suggestedMethods,...i.methods].flatMap(a=>a.collapsed&&e?[]:er(a));t.push(...r)}if(i.type===n.Condition){const r=i.successCalls.map(s=>et(s)),a=i.errorCalls.map(s=>et(s));t.push(...r,...a)}if(zr.includes(i.type)){if(i.collapsed&&e)return[];const r=i.inputs.map(s=>Li(s)).flat(),a=i.calls.map(s=>et(s));t.push(...E(r),...a)}if(Ue.includes(i.type)&&i.type!==n.Condition&&i.type!==n.Loop){const r=i==null?void 0:i.outputs.map(o=>Li(o)).flat(),a=i.successCalls.map(o=>et(o)),s=i.errorCalls.map(o=>et(o));t.push(...E(r),...a,...s)}if(Fe.includes(i.type)){const r=Li(i),a=cA(i);t.push(...r,...a)}if(i.type===n.Loop){const r=i.outputs.map(o=>Li(o)).flat();if(i.body){const o=er(i.body,e);t.push(...o)}const a=i.errorCalls.map(o=>et(o)),s=i.successCalls.map(o=>et(o));t.push(...E(r),...s,...a)}if(i.type===n.FunctionDeclaration){if(i.collapsed&&e)return[];const r=i.inputs.map(s=>Li(s)).flat(),a=i.calls.map(s=>et(s));t.push(...E(r),...a)}return E(t)}function dA(i,e=!1){const t=er(i,e),r=[...t,...t.reduce((a,s)=>[...a,...dA(s,e)],[])];return E(r)}function uA(i){const e=qr(i),t=[...e,...e.reduce((r,a)=>[...r,...uA(a)],[])];return E(t)}function zo(i){return i.implements.reduce((e,t)=>t.type===n.CustomEntity?[...e,n.CustomEntity,...zo(t),...Zo(t)]:[...e,t.name],[])}function Zo(i){return i.extends.reduce((e,t)=>t.type===n.CustomEntity?[...e,n.CustomEntity,...Zo(t),...zo(t)]:[...e,t.name],[])}function Uu(i){return i.extends.reduce((e,t)=>t.type===n.CustomEntity?[...e,t,...Uu(t),...xu(t)]:[...e,t],[])}function xu(i){return i.implements.reduce((e,t)=>t.type===n.CustomEntity?[...e,t,...xu(t),...Uu(t)]:[...e,t],[])}function ju(i){return[...Zo(i),...zo(i)].filter((t,r,a)=>a.indexOf(t)===r)}function pA(i){return i.implements.length===0&&i.extends.length===0?null:i.implements.find(r=>r.type===n.BuiltInBaseEntity&&r.name===V.PERSISTED_ENTITY)?i:[...i.implements,...i.extends].reduce((r,a)=>{if(a.type===n.CustomEntity){const s=pA(a);if(s)return s}return r},null)}function U7(i){const e=i.extends.find(t=>t.type===n.BuiltInBaseEntity);return e&&e.type===n.BuiltInBaseEntity?e:null}function x7(i){const e=i.implements.find(t=>t.type===n.BuiltInBaseEntity);return e&&e.type===n.BuiltInBaseEntity?e:null}function ku(i){const e=i.extends.find(t=>t.type===n.CustomEntity);return e&&e.type===n.CustomEntity?e:null}function tr(i){const e=[...i.implements,...i.extends].reduce((t,r)=>r.type===n.BuiltInBaseEntity?[...t,r]:r.type===n.CustomEntity?[...t,...tr(r)]:t,[]);return E(e)}function qu(i){return i.type===n.PrimitiveEntity?!0:i.type===n.BuiltInBaseEntity?i.interactive:!tr(i).find(r=>!r.interactive)}function j7(i){return i.parent===i.project&&i.project.variableDeclarations.includes(i)}function Ju(i){return i.parent!==i.project?!1:n.VariableDeclaration===i.type?i.project.variableDeclarations.includes(i):n.VariableInstance===i.type?i.project.variableInstances.includes(i):n.FunctionCall===i.type?i.project.functionCalls.includes(i):n.Condition===i.type?i.project.conditions.includes(i):n.Operation===i.type?i.project.operations.includes(i):n.Loop===i.type?i.project.loops.includes(i):n.Search===i.type?i.project.searches.includes(i):!1}function yA(i){if([...xe,n.CustomEntity,n.InstalledProject,n.Project].includes(i.type)||Ju(i))return!1;const e=qr(i);return e.length===0?!0:e.some(t=>yA(t))}function Wu(i){return[...xe,n.CustomEntity,n.InstalledProject,n.Project].includes(i.type)||Ju(i)?!1:qr(i).length===0}function fA(i,e=0){if(Wu(i)){const t=qr(i);return t.length===0?i:t.map(a=>fA(a,e+1)).reduce((a,s)=>a?s&&s.x<a.x?s:a:s,null)}return null}function hA(i){const e=[];if(Wu(i))e.push(i);else return[];return qr(i).forEach(r=>{e.push(...hA(r))}),e}function mA(i){return i.type===n.FunctionDeclaration&&i.parent!==i.project&&!![n.CustomEntity,n.Loop,n.InstalledProject].includes(i.parent.type)}function k7(i,e){const t=new Map;return i.forEach(r=>{t.set(r.id,r)}),e.forEach(r=>{t.set(r.id,r)}),Array.from(t.values())}function Ko(i){switch(i){case n.CustomEntity:return Jr;case n.FunctionDeclaration:return _r;case n.VariableDeclaration:return Lr;case n.VariableInstance:return Gr;case n.FunctionCall:return kr;case n.Operation:return Nr;case n.Condition:return Vr;case n.ReturnStatement:return xr;case n.Loop:return Mr;case n.Search:return $r;case n.InputMap:return Bn;case n.OutputMap:return wn;case n.ArgumentDeclaration:return Ur;case n.ReturnDeclaration:return Nt;case n.Property:return wr;case n.InstalledProject:return Fr;case n.Project:return _;case n.BuiltInBaseEntity:return Xt;default:return null}}function gt(i,e){if(ut.includes(i.type))return i;if(Zr.includes(i.type))return null;const t=i.parent;if(!t)return null;if(t.type===n.GenericReference){const r=N(t);if(!r)return null;const a=e.get(r);return a?gt(a,e):null}else return t===e?e:gt(t,e)}function Hu(i,e){if(Zr.includes(i.type)||e.getBuiltIn(i.id))return null;const t=Mt(i.parent,e);return t?t===e?ut.includes(i.type)?i:null:t.type===n.CustomEntity?i:Hu(t,e):null}function Xo(i,e,t){if(i===e||e===t||i===t)return!1;const r=gt(e.parent,t);return r===i?!0:Xo(r,e,t)}var Qo=(i=>(i.SameBothLocal="same-both-local",i.AInB="a-in-b",i.BInA="b-in-a",i.ParallelInCommonParent="parallel-in-common-parent",i.ParallelInProject="parallel-in-project",i.AIsGlobalBIsNot="a-is-global-b-is-not",i.BIsGlobalAIsNot="b-is-global-a-is-not",i.SameBothGlobal="same-both-global",i))(Qo||{});function za(i,e,t){const r=gt(i,t),a=gt(e,t);if(!r)throw new Error("Could not find scope owner for the entity: "+i.id);if(!a)throw new Error("Could not find scope owner for the entity: "+e.id);if(r===a&&r.type!==n.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:r};if(r===a&&r.type===n.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:r};if(r.type===n.Project&&a.type!==n.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:r};if(r.type!==n.Project&&a.type===n.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:a};if(Xo(r,a,t))return{compatible:!0,type:"b-in-a",commonAncestorScope:r};if(Xo(a,r,t))return{compatible:!0,type:"a-in-b",commonAncestorScope:a};const l=Vu(r,a);return l===t?{compatible:!1,type:"parallel-in-project",commonAncestorScope:l}:l?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:gt(l,t)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:t}}function TA(i,e,t){const r=za(i,e,t);if(!r.compatible||r.type!=="same-both-local")return null;if(i===e)return i;let a=gt(i.parent,t);if(a){if(a===e)return e;if(a.type===n.Project)return i}else return i;for(;a;){if(a){if(a===e)return e;if(a.type===n.Project)return i}else return i;a=gt(a.parent,t)}let s=gt(e.parent,t);if(s){if(s===i)return i;if(s.type===n.Project)return e}else return e;for(;s;){if(s){if(s===i)return i;if(s.type===n.Project)return e}else return e;s=gt(s.parent,t)}return null}function EA(i){return i.length===0?null:i.length===1?i[0]:i.reduce((t,r)=>{const a=TA(t,r,r.project);return!a||a===r?t:r},i[0])}function Mt(i,e){let t;return typeof i=="string"?t=i:i.type===n.GenericReference?t=N(i):t=i.id,t===e.id?e:e.get(t)}function nr(i){if(!i)return null;if(Zr.includes(i.type))return i;if(i.type===n.Project)return null;if(i.project.getBuiltIn(i.id))return i;const e=i.parent;return!e||e.type===n.Project?null:nr(e)}function Za(i,e){var t;if(i.readsValue){const r=Mt(i.readsValue,e.project);e.setValueWriter(r),r.addValueReader(e)}else i.readsValue===null&&((t=e.readsValue)==null||t.removeValueReader(e),e.readsValue=null);return e}function Ka(i){const e=[];function t(s,o){return e.some(l=>l.blockedByCaller===s&&l.blockedByCalling===o)}function r(s,o){t(s,o)||e.push({blockedByCaller:s,blockedByCalling:o})}const a=Hu(i,i.project);return i.calledBySuccess.forEach(s=>{[...s.successCalls||[]].forEach(p=>{Ve.includes(p.type)&&p!==i&&(Me(i).find(m=>m===p)||r(s,p))});let l;if(Ue.includes(s.type)&&(l=s),l){const p=Ka(l);p.reachable||Me(i).find(m=>m===s)||p.blocks.forEach(m=>{r(s,m.blockedByCalling)})}}),i.calledByError.forEach(s=>{[...s.errorCalls||[]].forEach(p=>{Ve.includes(p.type)&&p!==i&&(Me(i).find(m=>m===p)||r(s,p))});let l;if(Ue.includes(s.type)&&(l=s),l){const p=Ka(l);p.reachable||Me(i).find(m=>m===s)||p.blocks.forEach(m=>{r(s,m.blockedByCalling)})}}),i.calledByEntry.forEach(s=>{if([...s.calls||[]].forEach(p=>{Ve.includes(p.type)&&p!==i&&(Me(i).find(m=>m===p)||r(s,p))}),s===a)return;let l;if(s.type===n.FunctionDeclaration){const p=et(s);if(p.type===n.CustomEntity)return;p.type===n.Loop&&(l=p)}if(l){const p=Ka(l);p.reachable||p.blocks.forEach(y=>{r(s,y.blockedByCalling)})}}),{reachable:e.length===0,entryPoint:a,blocks:e}}function q7(i){return al.includes(i.type)?i.type===n.FunctionDeclaration?!mA(i):!0:!1}function J7(i){if(n.ActionDescriptor===i.type){if(i.project.operationDeclarations.find(s=>s.id===i.id))return n.Operation;if(i.project.globalEventActionDescriptors.find(s=>s.id===i.id))return n.GlobalEvent;if(i.project.loopDeclarations.find(s=>s.id===i.id))return n.Loop;if(i.project.conditionDeclarations.find(s=>s.id===i.id))return n.Condition}return i.type}function Gi(i,e){if(i.type!==n.CustomEntity||i.abstract)return!1;const t=ku(i)||i;return!!ju(t).includes(e)}function W7(i){const e=[];return i.entities.forEach(t=>{if(Gi(t,V.PERSISTED_ENTITY)){e.push(t);return}}),E(e)}function H7(i){const e=[];return i.entities.forEach(t=>{if(Gi(t,V.RELATIONAL_DATABASE)){e.push(t);return}}),E(e)}function Y7(i){return i.type!==n.CustomEntity||i.abstract||!Gi(i,V.PERSISTED_ENTITY)?null:(i==null?void 0:i.properties.find(t=>{var r;return((r=t.implements)==null?void 0:r.id)===B[n.BuiltInBaseEntity][V.PERSISTED_ENTITY].properties.primaryKey.id&&!t.abstract}))||null}function z7(i){if(i.type!==n.CustomEntity)return[];if(i.abstract)return[];if(!Gi(i,V.PERSISTED_ENTITY))return[];const e=[],t=i.properties.filter(r=>{var a;return((a=r.implements)==null?void 0:a.id)!==B[n.BuiltInBaseEntity][V.PERSISTED_ENTITY].properties.database.id&&!r.abstract});return e.push(...t),e}function Z7(i){var t;if(!i||i.type!==n.CustomEntity||!Gi(i,V.PERSISTED_ENTITY))return null;const e=i.properties.find(r=>{var a;return((a=r.implements)==null?void 0:a.id)===B[n.BuiltInBaseEntity][V.PERSISTED_ENTITY].properties.database.id});return(t=e==null?void 0:e.getDefaultValue())==null?void 0:t.valueAsType}function K7(i,e){const t=[];if(i.parent)if(i.id===i.parent)t.push(new b({id:`${i.id}--${i.parent}--${h.SelfReference}`,code:h.SelfReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.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 r=e.get(i.parent);r?[n.Project,n.DataType].includes(r.type)||t.push(new b({id:`${i.id}--${i.parent}--${h.InvalidParentReference}`,code:h.InvalidParentReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):t.push(new b({id:`${i.id}--${i.parent}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return i.implements&&Array.isArray(i.implements)?i.implements.forEach(r=>{if(i.id===r){t.push(new b({id:`${i.id}--${r}--${h.SelfReference}`,code:h.SelfReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.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 a=e.get(r);a?[n.CustomEntity,n.BuiltInBaseEntity].includes(a.type)?a.abstract||t.push(new b({id:`${i.id}--${r}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):t.push(new b({id:`${i.id}--${r}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an entity of type 'custom-entity' or 'built-in-base-entity'.`,issue:null})):t.push(new b({id:`${i.id}--${r}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${r}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):t.push(new b({id:`${i.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' property that isn't an array.`,issue:null})),i.extends&&Array.isArray(i.extends)&&i.extends.forEach(r=>{const a=e.get(r);a?[n.CustomEntity,n.BuiltInBaseEntity].includes(a.type)?a.abstract&&t.push(new b({id:`${i.id}--${r}--${h.InvalidExtendsReference}`,code:h.InvalidExtendsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.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})):t.push(new b({id:`${i.id}--${r}--${h.InvalidExtendsReference}`,code:h.InvalidExtendsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'extends' reference that isn't pointing to an entity of type 'custom-entity' or 'built-in-base-entity'.`,issue:null})):t.push(new b({id:`${i.id}--${r}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${r}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),t}const Ne=class Ne{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"static");c(this,"abstract");c(this,"type",n.CustomEntity);c(this,"properties",[]);c(this,"methods",[]);c(this,"abstractMethods",[]);c(this,"extends",[]);c(this,"implements",[]);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestedProperties",[]);c(this,"suggestedMethods",[]);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y,this.static=e.static,this.abstract=e.abstract}static fromGenerationTarget(e,t){let r=t;if(e.parent){const p=N(e.parent);r=t.get(p)}const a=[];e.implements&&e.implements.forEach(p=>{a.push(t.get(p)||t.getBuiltIn(p))});const s=[];e.extends&&e.extends.forEach(p=>{s.push(t.get(p)||t.getBuiltIn(p))});const o={id:e.id,version:1,name:e.name,type:n.CustomEntity,description:e.description,static:e.static,abstract:e.abstract,properties:[],methods:[],abstractMethods:[],extends:s,implements:a,x:0,y:0,parent:r},l=g(o,t);return l.setParent(r),l.initChildren(),l}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=K7(r,t),o=Lo(r,t);a.push(...s,...o,...Le(r));const l=r.parent?t.get(r.parent):null;if(l&&l.type===n.DataType){const p=l;p.entity&&a.push(new b({id:`${e.id}--${h.NewEntityWouldOverriteExisting}`,code:h.NewEntityWouldOverriteExisting,severity:T.Error,message:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${p.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
391
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],r=[];return this.parent===this.project&&this.project.addFunctionCall(this),(a=this.process)==null||a.writesValues.forEach(s=>{s.setValueWriter(this.process),e.push(s)}),this.successCalls.forEach(s=>{s.addSuccessCaller(this),e.push(s)}),this.errorCalls.forEach(s=>{s.addErrorCaller(this),e.push(s)}),this.calledBySuccess.forEach(s=>{s.addSuccessCall(this),e.push(s)}),this.calledByError.forEach(s=>{s.addErrorCall(this),e.push(s)}),this.calledByEntry.forEach(s=>{s.addCall(this),e.push(s)}),{updated:E(e),added:E(t),removed:E(r),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(r=>r.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(r=>r.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addValueReader(e){var t;return(t=this.process)==null||t.addValueReader(e),this}removeValueReader(e){var t;return(t=this.process)==null||t.removeValueReader(e),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const r=this.errorCalls.findIndex(a=>a.id===e.id);return r>-1&&this.errorCalls.splice(r,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===n.FunctionDeclaration){const e=g(this.initialData.declaration,this.project);this.declaration=e}else{const e=N(this.initialData.declaration),t=this.project.get(e);this.declaration=t}return this.successCalls=this.initialData.successCalls.map(e=>{const t=g(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=g(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=g(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.error&&(this.error=g(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncMissingFixedInputs(),this.syncMissingFixedOutputs(),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s;const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:o,removed:l}=(s=this.process)==null?void 0:s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}if(this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.outputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});r.push(...l),a.push(...p)}),this.error){const{affected:o,removed:l}=this.error.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}return this.successCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),this.errorCalls.forEach(o=>{r.push(o),o.removeCaller(this)}),e||this.calledBy.forEach(o=>{r.push(o),o.removeCall(this)}),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.process){const{affected:r}=this.process.restore({seenEntities:e});t.push(...r)}return this.inputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(r=>{t.push(r),r.addSuccessCaller(this)}),this.errorCalls.forEach(r=>{t.push(r),r.addErrorCaller(this)}),this.calledBySuccess.forEach(r=>{t.push(r),r.addSuccessCall(this)}),this.calledByError.forEach(r=>{t.push(r),r.addErrorCall(this)}),this.calledByEntry.forEach(r=>{t.push(r),r.addCall(this)}),{affected:E(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(r=>r.toFlat(e)),...this.errorCalls.flatMap(r=>r.toFlat(e)),...this.inputs.flatMap(r=>r.toFlat(e)),...this.outputs.flatMap(r=>r.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(r=>r.toFlatIds(e)),...this.errorCalls.flatMap(r=>r.toFlatIds(e)),...this.inputs.flatMap(r=>r.toFlatIds(e)),...this.outputs.flatMap(r=>r.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(r=>r.toJSON()),errorCalls:this.errorCalls.map(r=>r.toJSON()),calledBySuccess:this.calledBySuccess.map(r=>r.toReference()),calledByError:this.calledByError.map(r=>r.toReference()),calledByEntry:this.calledByEntry.map(r=>r.toReference()),process:(e=this.process)==null?void 0:e.toJSON(),declaration:this.declaration.toJSON(),inputs:this.inputs.map(r=>r.toJSON()),outputs:this.outputs.map(r=>r.toJSON()),parent:this.parent.toReference(),error:(t=this.error)==null?void 0:t.toJSON()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference():null,inputs:this.inputs.map(e=>e.toReference()),outputs:this.outputs.map(e=>e.toReference()),declaration:this.declaration.toReference(),successCalls:this.successCalls.map(e=>e.toReference()),errorCalls:this.errorCalls.map(e=>e.toReference()),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),error:this.error?this.error.toReference():null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(r=>r.toFlatJSON(e)),...this.errorCalls.flatMap(r=>r.toFlatJSON(e)),...this.inputs.flatMap(r=>r.toFlatJSON(e)),...this.outputs.flatMap(r=>r.toFlatJSON(e)),...this.process?this.process.toFlatJSON(e):[],...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,version:this.version,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.inputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.outputs.flatMap(r=>r.toFlatGenerationTarget(e)),...this.process?this.process.toFlatGenerationTarget(e):[],...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(r=>r.clearErrors()),this.outputs.forEach(r=>r.clearErrors()),this.successCalls.forEach(r=>r.clearErrors()),this.errorCalls.forEach(r=>r.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=A7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new _e(this.toJSON(),this.project)}removeUnrecognizedInputs(){const e=[],t=[],r=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}removeUnrecognizedOutputs(){const e=[],t=[],r=[];return this.outputs.forEach(a=>{if(!this.declaration.getUniqueReturnDeclarations().find(o=>o.id===a.declaration.id)){const o=a.remove();r.push(...o.removed),e.push(...o.affected)}}),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedInputs(){const e=[],t=[],r=[],a=this.declaration.inputs.filter(p=>!this.inputs.find(y=>y.declaration.id===p.id));this.inputs.sort((p,y)=>p.index-y.index),a.forEach(p=>{this.inputs.forEach(m=>{m.index>=p.index&&m.sync({index:m.index+1})});const y={id:_.UUID.uuid(),version:1,type:n.InputMap,declaration:p.toJSON(),readsValue:null,defaultValue:null,index:p.index,name:null,description:null,parent:this.toReference()},f=g(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject(),t.push(f)}),this.inputs.sort((p,y)=>p.index-y.index);const{updated:s,added:o,removed:l}=this.removeUnrecognizedInputs();return e.push(...s),t.push(...o),r.push(...l),{updated:E(e),added:E(t),removed:E(r),self:this}}syncMissingFixedOutputs(){const e=[],t=[],r=[],a=[];this.outputs=this.initialData.outputs.map(y=>{const f=g(y,this.project);return a.push(f.index),f.setParent(this),f.initChildren(),f});const s=this.declaration.getUniqueReturnDeclarations().filter(y=>!this.outputs.find(f=>f.declaration.id===y.id));this.outputs.sort((y,f)=>y.index-f.index),s.forEach((y,f)=>{this.outputs.forEach(P=>{P.index>=y.index&&P.index++});const m=a.includes(y.index)?this.outputs.length-1+f:y.index,R={id:_.UUID.uuid(),version:1,type:n.OutputMap,declaration:y.toJSON(),writesValues:[],index:m,parent:this.toReference()},v=g(R,this.project);v.setParent(this),v.initChildren(),v.addSelfToProject()}),this.outputs.sort((y,f)=>y.index-f.index);const{updated:o,added:l,removed:p}=this.removeUnrecognizedOutputs();return e.push(...o),t.push(...l),r.push(...p),{updated:E(e),added:E(t),removed:E(r),self:this}}};c(_e,"MUTABLE_BASE_PROPERTIES",[]),c(_e,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(_e,"BASE_PROPERTIES",[..._e.MUTABLE_BASE_PROPERTIES,..._e.INMUTABLE_BASE_PROPERTIES]),c(_e,"MUTABLE_META_PROPERTIES",["x","y"]),c(_e,"INMUTABLE_META_PROPERTIES",[..._e.INMUTABLE_BASE_PROPERTIES]),c(_e,"META_PROPERTIES",[..._e.MUTABLE_META_PROPERTIES,..._e.INMUTABLE_META_PROPERTIES]),c(_e,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(_e,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),c(_e,"UPSTREAM_PROPERTIES",[..._e.MUTABLE_UPSTREAM_PROPERTIES,..._e.INMUTABLE_UPSTREAM_PROPERTIES]),c(_e,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),c(_e,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(_e,"DOWNSTREAM_PROPERTIES",[..._e.MUTABLE_DOWNSTREAM_PROPERTIES,..._e.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(_e,"PROPERTIES",[..._e.META_PROPERTIES,..._e.UPSTREAM_PROPERTIES,..._e.DOWNSTREAM_PROPERTIES]);let kr=_e;function kP(i){var e,t,r;switch(i.id){case B["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const a=i.project.entities.filter(f=>!!f.implements.find(m=>m.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));if(a.find(f=>!!f.properties.find(m=>{var R;return m.implements&&m.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((R=m.getDefaultValue())==null?void 0:R.value)===!0}))){const m=a[0].properties.find(v=>v.implements&&v.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),R=(e=m==null?void 0:m.dataType)==null?void 0:e.defaultValue;if(R)R.value=!0;else if(m!=null&&m.dataType){const v=(t=m==null?void 0:m.dataType)==null?void 0:t.id.split("-id")[0],P=g({id:v+"-default-value-id",version:1,type:n.PrimitiveValue,name:I.EntityTemplate,parentRelationType:null,autogeneration:null,value:!0,valueAsType:null,parent:m==null?void 0:m.dataType.toReference()},i.project);return P.setParent(m==null?void 0:m.dataType),P.initChildren(),P.addSelfToProject(),{newEntities:[P]}}return{newEntities:[]}}const o=i.project.get(B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),l=Jo(o,"Main database");if(l.errors.length>0)return{newEntities:[]};const p=l.implemented.properties.find(f=>f.implements&&f.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=(r=p==null?void 0:p.dataType)==null?void 0:r.defaultValue;if(y)y.value=!0;else if(p!=null&&p.dataType){const f=p==null?void 0:p.dataType.id.split("-id")[0],m=g({id:f+"-default-value-id",version:1,type:n.PrimitiveValue,name:I.EntityTemplate,parentRelationType:null,autogeneration:null,value:!0,valueAsType:null,parent:p==null?void 0:p.dataType.toReference()},i.project);m.setParent(p==null?void 0:p.dataType),m.initChildren(),m.addSelfToProject()}return{newEntities:[l.implemented]}}}return{newEntities:[]}}function qP(i){return i.implements.filter(t=>t.type===n.BuiltInBaseEntity).map(t=>{var r;switch(t.id){case B["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const s=i.project.entities.filter(p=>p.implements.find(y=>y.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)).find(p=>!!p.properties.find(y=>{var f;return y.implements&&y.implements.id===B["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((f=y.getDefaultValue())==null?void 0:f.value)===!0}));if(!s)return{newEntities:[]};const o=i.properties.find(p=>p.implements&&p.implements.id===B["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),l=(r=o==null?void 0:o.dataType)==null?void 0:r.defaultValue;if(o&&(o!=null&&o.dataType)&&!l){const p=o==null?void 0:o.dataType.id.split("-id")[0],y=g({id:p+"-default-value-id",version:1,type:n.PrimitiveValue,name:I.EntityTemplate,parentRelationType:null,autogeneration:null,value:null,valueAsType:s,parent:o==null?void 0:o.dataType.toReference()},i.project);return y.setParent(o==null?void 0:o.dataType),y.initChildren(),y.addSelfToProject(),{newEntities:[y]}}return{newEntities:[]}}}}),{newEntities:[]}}function Jo(i,e,t){const r=t||Ze(e,n.CustomEntity,i.project),a=r.split("-id"),s=a[a.length-1||0]||r,o={id:r,version:1,name:e,type:n.CustomEntity,description:null,static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[i],x:0,y:0,parent:i.project},l=Lo(o,i.project);if(l.length>0)return{errors:l,implemented:null,entitiesChanges:{new:[],updated:[],deleted:[]}};const p=kP(i),y=g(o,i.project);y.setParent(i.project),y.initChildren();const f=i.properties.map(v=>{const P=s+"-"+Ze(C(v,i.project),n.Property,i.project),A=v.clone(y,P);return A.abstract=!1,A.implements=v,A.setParent(y),y.addProperty(A),A}),m=i.abstractMethods.map(v=>{const P=s+Ze(v.name,n.FunctionDeclaration,i.project),A=v.implementAsFunctionDeclaration(P),D={id:P+"-parent-ref-id",type:n.GenericReference,entityId:r,entityType:n.CustomEntity},F={...A,implements:v,parent:D},k=g(F,i.project);return y.addMethod(k),k.setParent(y),k.initChildren(),k.implements=v,k});o.properties=f,o.methods=m;const R=qP(y);return{implemented:y,errors:[],entitiesChanges:{new:[y,...p.newEntities,...R.newEntities],updated:[y],deleted:[]}}}function Nu(i,e){return e.entities.find(a=>{const s=a.properties,o=s.map(m=>m.name),l=i.every(m=>o.includes(m)),p=o.filter(m=>!i.includes(m)),y=s.every(m=>!p.includes(m.name)||!m.required);return l&&y})||null}function JP(i,e,t=We.OrDataTypeGroup){const r=[],a=[],s=[],l={id:e.id+"--nested-data-type-id-"+i.id,version:1,type:n.DataType,entity:i.toJSON(),isList:!1,isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parentRelationType:t,parent:e.toReference()},p=g(l,i.project);return a.push(p),p.setParent(e),p.initChildren(),p.setEntity(i),p.addSelfToProject(),{updated:E(r),added:E(a),removed:E(s),self:p}}function Mu(i,e,t,r){const a=[],s=[],o=[];switch(typeof i){case"string":let l=!1;const p=new Date(i);if(p instanceof Date&&!isNaN(p.valueOf())&&(l=!0),l){const y=e.project.getBuiltIn(B[n.PrimitiveEntity][I.Date].id);e.setEntity(y);break}else{const y=e.project.getBuiltIn(B[n.PrimitiveEntity][I.String].id);e.setEntity(y);break}case"number":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Number].id));break;case"boolean":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Boolean].id));break;case"object":if(i===null){e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Null].id));break}else if(Array.isArray(i))if(e.sync({isList:!0}),i.length>0){const y=i.slice(0,5).filter(m=>m!==void 0);if(y.every(m=>typeof m==typeof y[0])&&(typeof y[0]!="object"||y[0]===null))switch(typeof y[0]){case"string":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.String].id));break;case"number":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Number].id));break;case"boolean":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Boolean].id));break;case"object":e.setEntity(e.project.getBuiltIn(B[n.PrimitiveEntity][I.Null].id));break}else{const m=[];let R=!1;y.forEach((P,A)=>{if(Array.isArray(P)&&(R=!0),typeof P=="object"&&!Array.isArray(P)&&P!==null){const D=Wo(P,e.project,{...t,id:e.id+"--or-child-data-type-entity-id-"+A},r);D.hasCreated&&m.push(D.changeSet.self),a.push(...D.changeSet.updated),s.push(...D.changeSet.added),o.push(...D.changeSet.removed)}});const v=E(m);if(!v.length&&!R){y.forEach(P=>{const A={id:_.UUID.uuid(),version:1,type:n.DataType,entity:null,isList:!1,isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parentRelationType:We.OrDataTypeGroup,parent:e.toReference()},D=g(A,e.project);switch(D.setParent(e),D.initChildren(),D.addSelfToProject(),typeof P){case"string":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.String].id));break;case"number":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.Number].id));break;case"boolean":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.Boolean].id));break;case"object":D.setEntity(D.project.getBuiltIn(B[n.PrimitiveEntity][I.Null].id));break}});break}else v.length===1&&!R?e.setEntity(v[0]):y.forEach((P,A)=>{if(typeof P=="object"&&!Array.isArray(P)&&P!==null){const D=Nu(Object.keys(P),e.project);if(D){const F=JP(D||v[0],e,We.OrDataTypeGroup);a.push(...F.updated),s.push(...F.added),o.push(...F.removed)}}else{const D={id:e.id+"--or-child-data-type-id--"+A,version:1,type:n.DataType,entity:null,isList:Array.isArray(P),isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parentRelationType:We.OrDataTypeGroup,parent:e.toReference()},F=g(D,e.project);F.setParent(e),F.initChildren(),F.addSelfToProject();const k=Mu(P,F,{...t,id:e.id+"--or-child-data-type-entity-id-"+A},r);a.push(...k.updated),s.push(...k.added),o.push(...k.removed)}})}}else{const y=Wo(i[0],e.project,{...t},r);e.setEntity(y.changeSet.self),a.push(...y.changeSet.updated),s.push(...y.changeSet.added),o.push(...y.changeSet.removed);break}else{const y=Wo(i,e.project,{...t},r);e.setEntity(y.changeSet.self),a.push(...y.changeSet.updated),s.push(...y.changeSet.added),o.push(...y.changeSet.removed);break}}return{updated:E(a),added:E(s),removed:E(o),self:e}}function Wo(i,e,t,r){const a=[],s=[],o=[],l=Object.keys(i),p=Nu(l,e);if(p)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],self:p}};const y=r?t.name+" of "+r.name:t.name,m={id:t.id||Ze(y,n.CustomEntity,e),version:1,name:y,type:n.CustomEntity,description:t.description||null,static:t.static||!1,abstract:t.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:e.toReference()},R=g(m,e);return R.setParent(e),R.initChildren(),R.addSelfToProject(),s.push(R),l.forEach((v,P)=>{const A=Ze(y+" "+v,n.Property,e),D={id:A,version:1,name:v,type:n.Property,description:null,static:!1,abstract:!1,dataType:null,implements:null,index:P,hidden:!1,private:!1,required:!0,parent:R.toReference()},F=g(D,e);F.setParent(R),F.initChildren(),F.addSelfToProject(),s.push(F);const k=i[v],me={id:A+"--data-type-id",version:1,type:n.DataType,entity:null,isList:!1,isNullable:!1,defaultValue:null,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,constant:!1,parent:F.toReference()},ae=g(me,e);ae.setParent(F),ae.initChildren(),ae.addSelfToProject(),s.push(ae);const Je=Mu(k,ae,{...t,name:v,id:A+"--data-type-entity-id"},r||R);a.push(...Je.updated),s.push(...Je.added),o.push(...Je.removed)}),{hasCreated:!0,changeSet:{updated:E(a),added:E(s),removed:E(o),self:R}}}function Ho(i,e){const t=qr(i);if(t.length===0)return{list:[],last:null};let r=null;return{list:t.flatMap(s=>{if(s===e)return r=s,[s];const o=Ho(s,e);return o.last&&(r=o.last),[s,...o.list]}),last:r}}function WP(i,e,t=new Set){const r=er(i),a=er(e),s=r.filter(p=>!a.includes(p)),o=r.filter(p=>a.includes(p)),l=s.reduce((p,y)=>t.has(y.id)?p:(t.add(y.id),E([...p,...WP(y,e,t)])),[]);return E([...o,...l])}function Ya(i,e){const t=Ho(i,e);return t.last===e&&t.list.length>0&&t.list[0]!==e}function O7(i,e){return!!Ho(i,e).last}function S7(i){if(xe.includes(i.type))return i;if([...hn,n.VariableDeclaration].includes(i.type)){const e=i.parent;return xe.includes(e.type)?e:null}return null}function Vu(i,e){if(!i||!e)throw new Error("Both entities must be defined to find a common ancestor");if(i===e)return i;const t=i.parent;if(t){if(t===e)return e;if(t.type===n.Project)return null}else return null;const r=e.parent;if(r){if(r===i)return i;if(r.type===n.Project)return null}else return null;return Vu(t,r)}function et(i){if(al.includes(i.type)){if(i.type===n.FunctionDeclaration){const e=i.parent;if(e.type===n.CustomEntity)return e;if(e.type===n.Loop)return e}return i}else{const e=i.parent;return e?et(e):null}}function HP(i){if(!i)return null;if(hn.includes(i.type))return i;const e=i.parent;return e?HP(e):null}function YP(i){if(!i)return null;if(Ue.includes(i.type))return i;const e=i.parent;return e?YP(e):null}function zP(i){if(!i)return null;if(Qt.includes(i.type))return i;const e=i.parent;return e?zP(e):null}function C7(i){return i.type===n.VariableDeclaration?[i]:Ue.includes(i.type)?[...i.inputs,...i.outputs||[]]:Ve.includes(i.type)?i.outputs:zr.includes(i.type)||i.type===n.FunctionDeclaration?i.inputs:[]}function B7(i){const e=er(i),t=[],r=[];zu.includes(i.type)&&t.push(...Lu(i));const a=e.filter(s=>{const o=t.includes(s);return o?!1:hn.includes(s.type)&&!o?(r.push(s),!1):!0});return t.sort((s,o)=>Ya(o,s)?-1:0),r.sort((s,o)=>Ya(o,s)?-1:0),[...t,...r,...a]}function ZP(i){return[...i].sort((e,t)=>Ya(t,e)?-1:0)}function w7(i){const e=ZP(i),t=[];return e.forEach(r=>{const a=t[t.length-1];if(a){const s=a[a.length-1];Ya(r,s)?t.push([r]):a.push(r)}else t.push([r])}),t}function Rt(i){const e=i.map(t=>et(t));return E(e)}function Lu(i){return Ue.includes(i.type)?[...Rt(i.successCalls),...Rt(i.errorCalls)]:xe.includes(i.type)?Rt(i.calls):[]}function _7(i,e){return Lu(i).includes(e)}function Gu(i){return i.writesValues||[]}function N7(i,e){return Gu(i).includes(e)}function KP(i){var e;return Fe.includes((e=i==null?void 0:i.readsValue)==null?void 0:e.type)?i.readsValue:null}function M7(i){return i.writesValues}function XP(i=[]){return i.map(KP).filter(e=>!!e)}function Yo(i=[]){return i.map(e=>e.writesValues).flat().filter(e=>Fe.includes(e.type))}function QP(i=[]){return i.map(e=>e.readsValue).filter(e=>!!e&&Fe.includes(e.type))}function eA(i){return Fe.includes(i.type)?i:null}function tA(i){return i.writesValues.map(eA).filter(e=>!!e)}function nA(i=[]){return i.reduce((e,t)=>t.type===n.OutputMap?[...e,...tA(t)]:e,[])}function Me(i){return Ue.includes(i.type)?[...yn(Rt(i.successCalls)),...yn(Rt(i.errorCalls))]:xe.includes(i.type)?yn(Rt(i.calls)):[]}function V7(i){return Ue.includes(i.type)?[...yn(Rt(i.successCalls)),...yn(Rt(i.errorCalls))]:xe.includes(i.type)?yn(Rt(i.calls)):[]}function rA(i,e=new Set){return i.writesValues.filter(r=>Fe.includes(r.type)&&!e.has(r.id)).reduce((r,a)=>e.has(a.id)?r:[...r,...re(a,e)],[])}function iA(i,e=new Set){var r;return(((r=i.readsValue)==null?void 0:r.writesValues)||[]).filter(a=>Fe.includes(a.type)&&!e.has(a.id)).reduce((a,s)=>e.has(s.id)?a:[...a,...re(s,e)],[])}function re(i,e=new Set){if(e.has(i.id))return[];if(i.type===n.ReturnStatement)return QP(i.outputs).reduce((r,a)=>[...r,...re(a,e)],[]);if(i.type===n.FunctionCall||i.type===n.Operation||i.type===n.Condition)return[...Me(i).reduce((s,o)=>{const l=et(o);return[...s,...re(l||o,e)]},[]),...XP(i.inputs),...nA(i.outputs)].reduce((s,o)=>[...s,...re(o,e)],[]);if(zr.includes(i.type)){const t=Yo(i.inputs),a=Me(i).reduce((s,o)=>{const l=et(o);return[...s,...re(l||o,e)]},[]);return t.push(...a),t.reduce((s,o)=>[...s,...re(o,e)],[])}if(i.type===n.FunctionDeclaration){const t=[...Yo(i.inputs)],a=Me(i).reduce((s,o)=>{const l=et(o);return[...s,...re(l||o,e)]},[]);return t.push(...a),t.reduce((s,o)=>[...s,...re(o)],[])}if(Fe.includes(i.type)){e.add(i.id);const r=Me(i).reduce((a,s)=>{const o=et(s);return[...a,...re(o||s,e)]},[]);return[i,...r,...iA(i,e),...rA(i,e)]}return[]}function St(i,e=new Set){return e.has(i.id)?[]:(e.add(i.id),[...er(i).reduce((a,s)=>[...a,s,...St(s,e)],[])])}function yn(i){return i.reduce((e,t)=>t.type===n.ReturnStatement||t.type===n.ContinueStatement||t.type===n.BreakStatement?[...e,t]:[...e,t,...Me(t)],[])}function aA(i){const e=i.entities||[],t=[...e,...i.functions||[],...i.events||[],...i.projects||[]],r=e.reduce((p,y)=>[...p,...y.properties],[]),a=e.reduce((p,y)=>[...p,...y.methods],[]),s=a.reduce((p,y)=>[...p,...Yo(y.inputs),...yn(Rt(y.calls)),...y.returnStatements],[]),o=i.functions.reduce((p,y)=>[...p,...yn(Rt(y.calls)),...y.returnStatements],[]),l=i.events.reduce((p,y)=>[...p,...yn(Rt(y.calls)),...y.returnStatements],[]);return[...t,...r,...a,...s,...o,...l]}function sA(i,e){return e.filter(r=>{if(!r)return!1;switch(r.type){case n.FunctionCall:return r.inputs.find(a=>a.id===i.id)!==void 0||r.outputs.find(a=>a.id===i.id)!==void 0;case n.Condition:return r.successCalls.find(a=>a.id===i.id)!==void 0||r.errorCalls.find(a=>a.id===i.id)!==void 0||r.inputs.find(a=>a.id===i.id)!==void 0;case n.Operation:return r.outputs.find(a=>a.id===i.id)!==void 0;case n.VariableDeclaration:return Ue.includes(i.type)?oA(i).find(s=>{var o;return((o=s.readsValue)==null?void 0:o.id)===r.id})!==void 0:!1;case n.CustomEntity:return r.properties.find(a=>a.id===i.id)!==void 0||r.methods.find(a=>a.id===i.id)!==void 0;case n.FunctionDeclaration:return r.inputs.find(a=>a.id===i.id)!==void 0||(r.returnStatements.map(a=>a.outputs).flat()||[]).find(a=>a.id===i.id)!==void 0;default:return!1}})}function L7(i){const e=aA(i.project);return sA(i,e)}function qr(i){const e=[];if(hn.includes(i.type)){i.calledBy.forEach(a=>{const s=et(a);s&&e.push(s)});const r=[...i.inputs||[],...i.outputs||[]].map(a=>Fu(a)).filter(a=>a!==null);e.push(...E(r))}if(Fe.includes(i.type)){const t=Fu(i);t&&e.push(t)}return E(e)}function $u(i){return i.type===n.FunctionCall||i.type===n.InternalCall||[n.Operation,n.Condition,n.Loop].includes(i.type)?i.declaration.inputs:i.type===n.FunctionDeclaration||zr.includes(i.type)?i.inputs:i.type===n.Search?i.inputsDeclarations:[]}function G7(i,e){return e.type===n.Condition?e.inputs.find(t=>t.declaration.id===i.id):e.type===n.FunctionCall||e.type===n.Operation?e.inputs.find(t=>t.declaration.id===i.id):null}function oA(i){return Ue.includes(i.type)?i.inputs:[]}function lA(i){var e;return i.type===n.FunctionCall?((e=i.declaration.returnStatements[0])==null?void 0:e.outputs)||[]:[n.Operation,n.Condition,n.Loop].includes(i.type)?i.declaration.outputs:i.type===n.Search?i.outputsDeclarations:Ve.includes(i.type)?i.outputs:[]}function $7(i,e){return e.type===n.Condition?null:e.type===n.FunctionCall||e.type===n.Operation?e.outputs.find(t=>t.declaration.id===i.id):null}function F7(i){return i.type===n.Condition?[]:Ue.includes(i.type)?i.outputs:[]}function Fu(i){const e=i.readsValue;return e?et(e):null}function cA(i){const e=i.internalCalls||[];return E(Rt(E(e.flatMap(t=>[...t.successCalls,...t.errorCalls]))))}function Li(i){const e=Gu(i),t=[];return e.forEach(r=>{if(Fe.includes(r.type))t.push(r);else if(Nn.includes(r.type)){const a=r.parent;t.push(a)}}),t}function E(i){const e=new Set;return i.filter(t=>!t||e.has(t.id)?!1:(e.add(t.id),!0))}function er(i,e=!1){const t=[];if(i.type===n.Project&&t.push(...(i==null?void 0:i.entities)||[],...(i==null?void 0:i.functions)||[],...(i==null?void 0:i.variableDeclarations)||[],...(i==null?void 0:i.variableInstances)||[],...(i==null?void 0:i.searches)||[],...(i==null?void 0:i.loops)||[],...(i==null?void 0:i.operations)||[],...(i==null?void 0:i.conditions)||[],...(i==null?void 0:i.functionCalls)||[],...(i==null?void 0:i.events)||[],...(i==null?void 0:i.projects)||[]),ut.includes(i.type)&&t.push(...(i==null?void 0:i.detachedChildren)||[]),i.type===n.CustomEntity){const r=[...i.suggestedMethods,...i.methods].flatMap(a=>a.collapsed&&e?[]:er(a));t.push(...r)}if(i.type===n.Condition){const r=i.successCalls.map(s=>et(s)),a=i.errorCalls.map(s=>et(s));t.push(...r,...a)}if(zr.includes(i.type)){if(i.collapsed&&e)return[];const r=i.inputs.map(s=>Li(s)).flat(),a=i.calls.map(s=>et(s));t.push(...E(r),...a)}if(Ue.includes(i.type)&&i.type!==n.Condition&&i.type!==n.Loop){const r=i==null?void 0:i.outputs.map(o=>Li(o)).flat(),a=i.successCalls.map(o=>et(o)),s=i.errorCalls.map(o=>et(o));t.push(...E(r),...a,...s)}if(Fe.includes(i.type)){const r=Li(i),a=cA(i);t.push(...r,...a)}if(i.type===n.Loop){const r=i.outputs.map(o=>Li(o)).flat();if(i.body){const o=er(i.body,e);t.push(...o)}const a=i.errorCalls.map(o=>et(o)),s=i.successCalls.map(o=>et(o));t.push(...E(r),...s,...a)}if(i.type===n.FunctionDeclaration){if(i.collapsed&&e)return[];const r=i.inputs.map(s=>Li(s)).flat(),a=i.calls.map(s=>et(s));t.push(...E(r),...a)}return E(t)}function dA(i,e=!1){const t=er(i,e),r=[...t,...t.reduce((a,s)=>[...a,...dA(s,e)],[])];return E(r)}function uA(i){const e=qr(i),t=[...e,...e.reduce((r,a)=>[...r,...uA(a)],[])];return E(t)}function zo(i){return i.implements.reduce((e,t)=>t.type===n.CustomEntity?[...e,n.CustomEntity,...zo(t),...Zo(t)]:[...e,t.name],[])}function Zo(i){return i.extends.reduce((e,t)=>t.type===n.CustomEntity?[...e,n.CustomEntity,...Zo(t),...zo(t)]:[...e,t.name],[])}function Uu(i){return i.extends.reduce((e,t)=>t.type===n.CustomEntity?[...e,t,...Uu(t),...xu(t)]:[...e,t],[])}function xu(i){return i.implements.reduce((e,t)=>t.type===n.CustomEntity?[...e,t,...xu(t),...Uu(t)]:[...e,t],[])}function ju(i){return[...Zo(i),...zo(i)].filter((t,r,a)=>a.indexOf(t)===r)}function pA(i){return i.implements.length===0&&i.extends.length===0?null:i.implements.find(r=>r.type===n.BuiltInBaseEntity&&r.name===V.PERSISTED_ENTITY)?i:[...i.implements,...i.extends].reduce((r,a)=>{if(a.type===n.CustomEntity){const s=pA(a);if(s)return s}return r},null)}function U7(i){const e=i.extends.find(t=>t.type===n.BuiltInBaseEntity);return e&&e.type===n.BuiltInBaseEntity?e:null}function x7(i){const e=i.implements.find(t=>t.type===n.BuiltInBaseEntity);return e&&e.type===n.BuiltInBaseEntity?e:null}function ku(i){const e=i.extends.find(t=>t.type===n.CustomEntity);return e&&e.type===n.CustomEntity?e:null}function tr(i){const e=[...i.implements,...i.extends].reduce((t,r)=>r.type===n.BuiltInBaseEntity?[...t,r]:r.type===n.CustomEntity?[...t,...tr(r)]:t,[]);return E(e)}function qu(i){return i.type===n.PrimitiveEntity?!0:i.type===n.BuiltInBaseEntity?i.interactive:!tr(i).find(r=>!r.interactive)}function j7(i){return i.parent===i.project&&i.project.variableDeclarations.includes(i)}function Ju(i){return i.parent!==i.project?!1:n.VariableDeclaration===i.type?i.project.variableDeclarations.includes(i):n.VariableInstance===i.type?i.project.variableInstances.includes(i):n.FunctionCall===i.type?i.project.functionCalls.includes(i):n.Condition===i.type?i.project.conditions.includes(i):n.Operation===i.type?i.project.operations.includes(i):n.Loop===i.type?i.project.loops.includes(i):n.Search===i.type?i.project.searches.includes(i):!1}function yA(i){if([...xe,n.CustomEntity,n.InstalledProject,n.Project].includes(i.type)||Ju(i))return!1;const e=qr(i);return e.length===0?!0:e.some(t=>yA(t))}function Wu(i){return[...xe,n.CustomEntity,n.InstalledProject,n.Project].includes(i.type)||Ju(i)?!1:qr(i).length===0}function fA(i,e=0){if(Wu(i)){const t=qr(i);return t.length===0?i:t.map(a=>fA(a,e+1)).reduce((a,s)=>a?s&&s.x<a.x?s:a:s,null)}return null}function hA(i){const e=[];if(Wu(i))e.push(i);else return[];return qr(i).forEach(r=>{e.push(...hA(r))}),e}function mA(i){return i.type===n.FunctionDeclaration&&i.parent!==i.project&&!![n.CustomEntity,n.Loop,n.InstalledProject].includes(i.parent.type)}function k7(i,e){const t=new Map;return i.forEach(r=>{t.set(r.id,r)}),e.forEach(r=>{t.set(r.id,r)}),Array.from(t.values())}function Ko(i){switch(i){case n.CustomEntity:return Jr;case n.FunctionDeclaration:return _r;case n.VariableDeclaration:return Lr;case n.VariableInstance:return Gr;case n.FunctionCall:return kr;case n.Operation:return Nr;case n.Condition:return Vr;case n.ReturnStatement:return xr;case n.Loop:return Mr;case n.Search:return $r;case n.InputMap:return Bn;case n.OutputMap:return wn;case n.ArgumentDeclaration:return Ur;case n.ReturnDeclaration:return Nt;case n.Property:return wr;case n.InstalledProject:return Fr;case n.Project:return _;case n.BuiltInBaseEntity:return Xt;default:return null}}function gt(i,e){if(ut.includes(i.type))return i;if(Zr.includes(i.type))return null;const t=i.parent;if(!t)return null;if(t.type===n.GenericReference){const r=N(t);if(!r)return null;const a=e.get(r);return a?gt(a,e):null}else return t===e?e:gt(t,e)}function Hu(i,e){if(Zr.includes(i.type)||e.getBuiltIn(i.id))return null;const t=Mt(i.parent,e);return t?t===e?ut.includes(i.type)?i:null:t.type===n.CustomEntity?i:Hu(t,e):null}function Xo(i,e,t){if(i===e||e===t||i===t)return!1;const r=gt(e.parent,t);return r===i?!0:Xo(r,e,t)}var Qo=(i=>(i.SameBothLocal="same-both-local",i.AInB="a-in-b",i.BInA="b-in-a",i.ParallelInCommonParent="parallel-in-common-parent",i.ParallelInProject="parallel-in-project",i.AIsGlobalBIsNot="a-is-global-b-is-not",i.BIsGlobalAIsNot="b-is-global-a-is-not",i.SameBothGlobal="same-both-global",i))(Qo||{});function za(i,e,t){const r=gt(i,t),a=gt(e,t);if(!r)throw new Error("Could not find scope owner for the entity: "+i.id);if(!a)throw new Error("Could not find scope owner for the entity: "+e.id);if(r===a&&r.type!==n.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:r};if(r===a&&r.type===n.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:r};if(r.type===n.Project&&a.type!==n.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:r};if(r.type!==n.Project&&a.type===n.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:a};if(Xo(r,a,t))return{compatible:!0,type:"b-in-a",commonAncestorScope:r};if(Xo(a,r,t))return{compatible:!0,type:"a-in-b",commonAncestorScope:a};const l=Vu(r,a);return l===t?{compatible:!1,type:"parallel-in-project",commonAncestorScope:l}:l?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:gt(l,t)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:t}}function TA(i,e,t){const r=za(i,e,t);if(!r.compatible||r.type!=="same-both-local")return null;if(i===e)return i;let a=gt(i.parent,t);if(a){if(a===e)return e;if(a.type===n.Project)return i}else return i;for(;a;){if(a){if(a===e)return e;if(a.type===n.Project)return i}else return i;a=gt(a.parent,t)}let s=gt(e.parent,t);if(s){if(s===i)return i;if(s.type===n.Project)return e}else return e;for(;s;){if(s){if(s===i)return i;if(s.type===n.Project)return e}else return e;s=gt(s.parent,t)}return null}function EA(i){return i.length===0?null:i.length===1?i[0]:i.reduce((t,r)=>{const a=TA(t,r,r.project);return!a||a===r?t:r},i[0])}function Mt(i,e){let t;return typeof i=="string"?t=i:i.type===n.GenericReference?t=N(i):t=i.id,t===e.id?e:e.get(t)}function nr(i){if(!i)return null;if(Zr.includes(i.type))return i;if(i.type===n.Project)return null;if(i.project.getBuiltIn(i.id))return i;const e=i.parent;return!e||e.type===n.Project?null:nr(e)}function Za(i,e){var t;if(i.readsValue){const r=Mt(i.readsValue,e.project);e.setValueWriter(r),r.addValueReader(e)}else i.readsValue===null&&((t=e.readsValue)==null||t.removeValueReader(e),e.readsValue=null);return e}function Ka(i){const e=[];function t(s,o){return e.some(l=>l.blockedByCaller===s&&l.blockedByCalling===o)}function r(s,o){t(s,o)||e.push({blockedByCaller:s,blockedByCalling:o})}const a=Hu(i,i.project);return i.calledBySuccess.forEach(s=>{[...s.successCalls||[]].forEach(p=>{Ve.includes(p.type)&&p!==i&&(Me(i).find(m=>m===p)||r(s,p))});let l;if(Ue.includes(s.type)&&(l=s),l){const p=Ka(l);p.reachable||Me(i).find(m=>m===s)||p.blocks.forEach(m=>{r(s,m.blockedByCalling)})}}),i.calledByError.forEach(s=>{[...s.errorCalls||[]].forEach(p=>{Ve.includes(p.type)&&p!==i&&(Me(i).find(m=>m===p)||r(s,p))});let l;if(Ue.includes(s.type)&&(l=s),l){const p=Ka(l);p.reachable||Me(i).find(m=>m===s)||p.blocks.forEach(m=>{r(s,m.blockedByCalling)})}}),i.calledByEntry.forEach(s=>{if([...s.calls||[]].forEach(p=>{Ve.includes(p.type)&&p!==i&&(Me(i).find(m=>m===p)||r(s,p))}),s===a)return;let l;if(s.type===n.FunctionDeclaration){const p=et(s);if(p.type===n.CustomEntity)return;p.type===n.Loop&&(l=p)}if(l){const p=Ka(l);p.reachable||p.blocks.forEach(y=>{r(s,y.blockedByCalling)})}}),{reachable:e.length===0,entryPoint:a,blocks:e}}function q7(i){return al.includes(i.type)?i.type===n.FunctionDeclaration?!mA(i):!0:!1}function J7(i){if(n.ActionDescriptor===i.type){if(i.project.operationDeclarations.find(s=>s.id===i.id))return n.Operation;if(i.project.globalEventActionDescriptors.find(s=>s.id===i.id))return n.GlobalEvent;if(i.project.loopDeclarations.find(s=>s.id===i.id))return n.Loop;if(i.project.conditionDeclarations.find(s=>s.id===i.id))return n.Condition}return i.type}function Gi(i,e){if(i.type!==n.CustomEntity||i.abstract)return!1;const t=ku(i)||i;return!!ju(t).includes(e)}function W7(i){const e=[];return i.entities.forEach(t=>{if(Gi(t,V.PERSISTED_ENTITY)){e.push(t);return}}),E(e)}function H7(i){const e=[];return i.entities.forEach(t=>{if(Gi(t,V.RELATIONAL_DATABASE)){e.push(t);return}}),E(e)}function Y7(i){return i.type!==n.CustomEntity||i.abstract||!Gi(i,V.PERSISTED_ENTITY)?null:(i==null?void 0:i.properties.find(t=>{var r;return((r=t.implements)==null?void 0:r.id)===B[n.BuiltInBaseEntity][V.PERSISTED_ENTITY].properties.primaryKey.id&&!t.abstract}))||null}function z7(i){if(i.type!==n.CustomEntity)return[];if(i.abstract)return[];if(!Gi(i,V.PERSISTED_ENTITY))return[];const e=[],t=i.properties.filter(r=>{var a;return((a=r.implements)==null?void 0:a.id)!==B[n.BuiltInBaseEntity][V.PERSISTED_ENTITY].properties.database.id&&!r.abstract});return e.push(...t),e}function Z7(i){var t;if(!i||i.type!==n.CustomEntity||!Gi(i,V.PERSISTED_ENTITY))return null;const e=i.properties.find(r=>{var a;return((a=r.implements)==null?void 0:a.id)===B[n.BuiltInBaseEntity][V.PERSISTED_ENTITY].properties.database.id});return(t=e==null?void 0:e.getDefaultValue())==null?void 0:t.valueAsType}function K7(i,e){const t=[];if(i.parent)if(i.id===i.parent)t.push(new b({id:`${i.id}--${i.parent}--${h.SelfReference}`,code:h.SelfReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.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 r=e.get(i.parent);r?[n.Project,n.DataType].includes(r.type)||t.push(new b({id:`${i.id}--${i.parent}--${h.InvalidParentReference}`,code:h.InvalidParentReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):t.push(new b({id:`${i.id}--${i.parent}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return i.implements&&Array.isArray(i.implements)?i.implements.forEach(r=>{if(i.id===r){t.push(new b({id:`${i.id}--${r}--${h.SelfReference}`,code:h.SelfReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.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 a=e.get(r);a?[n.CustomEntity,n.BuiltInBaseEntity].includes(a.type)?a.abstract||t.push(new b({id:`${i.id}--${r}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):t.push(new b({id:`${i.id}--${r}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an entity of type 'custom-entity' or 'built-in-base-entity'.`,issue:null})):t.push(new b({id:`${i.id}--${r}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${r}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):t.push(new b({id:`${i.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' property that isn't an array.`,issue:null})),i.extends&&Array.isArray(i.extends)&&i.extends.forEach(r=>{const a=e.get(r);a?[n.CustomEntity,n.BuiltInBaseEntity].includes(a.type)?a.abstract&&t.push(new b({id:`${i.id}--${r}--${h.InvalidExtendsReference}`,code:h.InvalidExtendsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.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})):t.push(new b({id:`${i.id}--${r}--${h.InvalidExtendsReference}`,code:h.InvalidExtendsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'extends' reference that isn't pointing to an entity of type 'custom-entity' or 'built-in-base-entity'.`,issue:null})):t.push(new b({id:`${i.id}--${r}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${r}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),t}const Ne=class Ne{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"static");c(this,"abstract");c(this,"type",n.CustomEntity);c(this,"properties",[]);c(this,"methods",[]);c(this,"abstractMethods",[]);c(this,"extends",[]);c(this,"implements",[]);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestedProperties",[]);c(this,"suggestedMethods",[]);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y,this.static=e.static,this.abstract=e.abstract}static fromGenerationTarget(e,t){let r=t;if(e.parent){const p=N(e.parent);r=t.get(p)}const a=[];e.implements&&e.implements.forEach(p=>{a.push(t.get(p)||t.getBuiltIn(p))});const s=[];e.extends&&e.extends.forEach(p=>{s.push(t.get(p)||t.getBuiltIn(p))});const o={id:e.id,version:1,name:e.name,type:n.CustomEntity,description:e.description,static:e.static,abstract:e.abstract,properties:[],methods:[],abstractMethods:[],extends:s,implements:a,x:0,y:0,parent:r},l=g(o,t);return l.setParent(r),l.initChildren(),l}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=K7(r,t),o=Lo(r,t);a.push(...s,...o,...Le(r));const l=r.parent?t.get(r.parent):null;if(l&&l.type===n.DataType){const p=l;p.entity&&a.push(new b({id:`${e.id}--${h.NewEntityWouldOverriteExisting}`,code:h.NewEntityWouldOverriteExisting,severity:T.Error,message:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${p.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
392
392
  You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
393
393
  ${pn({describe_entity:p.entity.id})}
394
394
  Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:a,modifiedData:r}}get allBasePropertiesFromExtendedAndImplementedEntities(){return E([...this.extends.reduce((e,t)=>[...[...t.ownDeclaredProperties,...t.allBasePropertiesFromExtendedAndImplementedEntities].filter(a=>!a.abstract),...e],[]),...this.implements.reduce((e,t)=>[...[...t.ownDeclaredProperties,...t.allBasePropertiesFromExtendedAndImplementedEntities].filter(a=>!a.abstract),...e],[])])}get extendedPropertiesFromOriginalParents(){return E(this.extends.reduce((e,t)=>{const r=[...t.ownDeclaredProperties,...t.extendedPropertiesFromOriginalParents].filter(a=>!a.abstract);return[...e,...r]},[]))}get implementedPropertiesFromOriginalParents(){return E([...this.extends.reduce((e,t)=>{const r=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(s=>!!s.abstract&&!r.find(o=>o.name===s.name));return[...r,...a,...e]},[]),...this.implements.reduce((e,t)=>{const r=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(s=>!!s.abstract&&!r.find(o=>o.name===s.name));return[...r,...a,...e]},[])].filter(e=>!!e.abstract))}get extendedProperties(){return this.properties.filter(e=>e.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(e=>!e.isExtendedProperty)}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.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:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];if(this.parent.type===n.DataType){const a=this.parent;a.entity=this,e.push(a)}else this.project.addCustomEntity(this);return{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}removeProperty(e){return this.properties=this.properties.filter(t=>t.id!==e.id),this}addMethod(e){return this.methods.includes(e)||(this.methods.push(e),this.suggestedMethods=this.suggestedMethods.filter(t=>t.name!==e.name)),this}removeMethod(e){return this.methods=this.methods.filter(t=>t.id!==e.id),this}addProperty(e){return this.properties.includes(e)||(this.properties.push(e),this.suggestedProperties=this.suggestedProperties.filter(t=>t.name!==e.name)),this}addSuggestedProperty(e){return this.suggestedProperties.includes(e)||this.suggestedProperties.push(e),this}addSuggestedMethod(e){return this.suggestedMethods.includes(e)||this.suggestedMethods.push(e),this}removeSuggestedProperty(e){return this.suggestedProperties=this.suggestedProperties.filter(t=>t.id!==e.id),this}removeSuggestedMethod(e){return this.suggestedMethods=this.suggestedMethods.filter(t=>t.id!==e.id),this}addAbstractMethod(e){return this.abstractMethods.includes(e)||this.abstractMethods.push(e),this}removeAbstractMethod(e){return this.abstractMethods=this.abstractMethods.filter(t=>t.id!==e.id),this}initChildren(){return this.initialized?this:(this.initialized=!0,this.properties=this.initialData.properties.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.methods=this.initialData.methods.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.abstractMethods=this.initialData.abstractMethods.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t}),this.extends=this.initialData.extends.map(e=>g(e,this.project)),this.implements=this.initialData.implements.map(e=>g(e,this.project)),this.syncImplementationProperties(),this.addExtendedProperties(),this.addSuggestions(),this)}syncImplementationProperties(){return this.implementedPropertiesFromOriginalParents.filter(r=>!!!this.allBasePropertiesFromExtendedAndImplementedEntities.find(o=>{var l;return((l=o.implements)==null?void 0:l.id)===r.id})).forEach(r=>{if(this.properties.find(l=>{var p;return((p=l.implements)==null?void 0:p.id)===r.id}))return;const s=this.properties.find(l=>l.name===r.name&&!!l.abstract&&!l.implements);if(s){s.implements=r,s.abstract=!1;return}const o=r.clone(this,_.UUID.uuid());o.initChildren(),o.implements=r,o.abstract=!1,this.addProperty(o)}),this}addExtendedProperties(){const e=this.properties,t=this.extendedPropertiesFromOriginalParents,r=t.filter(s=>s.abstract?!!!t.find(l=>{var p;return((p=l.implements)==null?void 0:p.id)===s.id}):!0),a=new Set(e.map(s=>s.name));return r.forEach(s=>{a.add(s.name);const o=s.clone(this,_.UUID.uuid());o.initChildren(),this.addProperty(o)}),this}addSuggestions(){return this.implements.forEach(e=>{gk(this,e).forEach(a=>{const s=a.toJSON();s.id=`_suggestion--parent--${this.id}--${a.id}`;const o=g(s,this.project);o.suggestion=!0,o.setParent(this),o.initChildren(),this.addSuggestedProperty(o)}),vk(this,e).forEach(a=>{const s=`_suggestion--parent--${this.id}--${a.id}`,o=a.implementAsFunctionDeclaration(s),l=g(o,this.project);if(l.suggestion=!0,l.setParent(this),l.initChildren(),l.inputs.forEach(p=>{p.suggestion=!0}),l.returnStatements.length){const p=l.returnStatements[0];p.suggestion=!0,p.outputs.forEach(y=>{y.suggestion=!0})}this.addSuggestedMethod(l)})}),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.x=e.x||this.x,this.y=e.y||this.y,this.static=e.static||this.static,this.abstract=e.abstract||this.abstract,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.properties.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.methods.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.abstractMethods.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.suggestedProperties.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),this.suggestedMethods.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});r.push(...o),a.push(...l)}),{affected:E(r),removed:E(a)})}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.properties.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.methods.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.abstractMethods.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.suggestedProperties.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),this.suggestedMethods.forEach(r=>{const{affected:a}=r.restore({seenEntities:e});t.push(...a)}),{affected:E(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.extends.flatMap(r=>r.toFlat(e)),...this.implements.flatMap(r=>r.toFlat(e)),...this.properties.flatMap(r=>r.toFlat(e)),...this.methods.flatMap(r=>r.toFlat(e)),...this.abstractMethods.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.extends.flatMap(r=>r.toFlatIds(e)),...this.implements.flatMap(r=>r.toFlatIds(e)),...this.properties.flatMap(r=>r.toFlatIds(e)),...this.methods.flatMap(r=>r.toFlatIds(e)),...this.abstractMethods.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(e=>e.toJSON()),methods:this.methods.map(e=>e.toJSON()),abstractMethods:this.abstractMethods.map(e=>e.toJSON()),implements:this.implements.map(e=>e.toJSON()),extends:this.extends.map(e=>e.toJSON()),parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,name:this.name,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),implements:this.implements.map(e=>e.toReference()),extends:this.extends.map(e=>e.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(r=>r.toFlatJSON(e)),...this.methods.flatMap(r=>r.toFlatJSON(e)),...this.abstractMethods.flatMap(r=>r.toFlatJSON(e)),...this.implements.flatMap(r=>r.toFlatJSON(e)),...this.extends.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===n.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(t=>t.id),implements:this.implements.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(r=>r.toFlatGenerationTarget(e)),...this.methods.flatMap(r=>r.toFlatGenerationTarget(e)),...this.abstractMethods.flatMap(r=>r.toFlatGenerationTarget(e)),...this.implements.filter(r=>r.type===n.CustomEntity).flatMap(r=>r.toFlatGenerationTarget(e)),...this.implements.filter(r=>r.type===n.CustomEntity).flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.properties.forEach(e=>e.clearErrors()),this.methods.forEach(e=>e.clearErrors()),this.abstractMethods.forEach(e=>e.clearErrors()),this}validate(){return this.errors=Rk(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(t=>t.getErrors()),...this.methods.flatMap(t=>t.getErrors()),...this.abstractMethods.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(e=null,t=null,r=!0){var R,v,P;const a=this.toJSON(),s=t||Ze(C(this,this.project),n.CustomEntity,this.project);a.properties=[],a.methods=[],a.abstractMethods=[];const o=s.split("-id"),l=o[o.length-1||0]||s;a.id=s;const p=qt(a,this.project);e&&p.setParent(e),r&&p.subscribe(),p.initChildren();const y=(R=this.properties)==null?void 0:R.map((A,D)=>A.clone(p,l+"-property-"+D+"-id",r));p.properties=y;const f=(v=this.methods)==null?void 0:v.map((A,D)=>A.clone(p,l+"-method-"+D+"-id",r));p.methods=f;const m=(P=this.abstractMethods)==null?void 0:P.map((A,D)=>A.clone(p,l+"-abstract-method-"+D+"-id",r));return p.abstractMethods=m,p}getFunctionDeclaration(e){return this.methods.find(t=>t.id===e)}implement(e,t){return Jo(this,e,t)}getAllInteractiveMethods(){const e=this.implements.filter(r=>r.type===n.CustomEntity||r.type===n.BuiltInBaseEntity&&r.interactive);return E([...this.methods,...this.extends.flatMap(r=>r.getAllInteractiveMethods()),...e.flatMap(r=>r.getAllInteractiveMethods())])}inferFromInputs(e){if(this.parent.type!==n.DataType||!this.parent.inferred)return this;const t=[];e.forEach(s=>{t.find(l=>C(l,this.project)===C(s,this.project))||t.push(s)});const r=this.properties.filter(s=>!s.getDataType());t.forEach(s=>{const o=r.find(m=>C(m,this.project)===C(s,this.project));if(!o)return;const p=Br(s.parent).getMasterInputWithValueWritterFromAllInstances(s),y=un(p),f=y==null?void 0:y.clone(o,o.id+"--data-type",!0);f&&o.setDataType(f),s.setDeclaration(o)});const a=[];return t.forEach(s=>{if(!s.declaration){a.push(s);return}}),a.length===0?this:(a.forEach(s=>{const o=this.properties.find(v=>C(v,this.project)===C(s,this.project));if(o){if(s.setDeclaration(o),!o.getDataType()){const P=Br(s.parent).getMasterInputWithValueWritterFromAllInstances(s),A=un(P),D=A==null?void 0:A.clone(o,o.id+"--data-type",!0);D&&o.setDataType(D)}return}const l={id:s.id+"--inferred-property",type:n.Property,version:1,name:C(s,this.project),description:s.description,static:!0,abstract:!1,private:!1,hidden:!1,required:!1,index:s.index,implements:null,dataType:null,parent:this.toReference()},p=g(l,this.project);p.setParent(this),p.initChildren();const f=Br(s.parent).getMasterInputWithValueWritterFromAllInstances(s),m=un(f),R=m==null?void 0:m.clone(p,l.id+"--data-type",!0);return R&&p.setDataType(R),this.addProperty(p),s.setDeclaration(p),p}),this)}};c(Ne,"MUTABLE_BASE_PROPERTIES",["name","description","static","abstract"]),c(Ne,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(Ne,"BASE_PROPERTIES",[...Ne.MUTABLE_BASE_PROPERTIES,...Ne.INMUTABLE_BASE_PROPERTIES]),c(Ne,"MUTABLE_META_PROPERTIES",[...Ne.MUTABLE_BASE_PROPERTIES,"x","y"]),c(Ne,"INMUTABLE_META_PROPERTIES",[...Ne.INMUTABLE_BASE_PROPERTIES]),c(Ne,"META_PROPERTIES",[...Ne.MUTABLE_META_PROPERTIES,...Ne.INMUTABLE_META_PROPERTIES]),c(Ne,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),c(Ne,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(Ne,"UPSTREAM_PROPERTIES",[...Ne.MUTABLE_UPSTREAM_PROPERTIES,...Ne.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ne,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),c(Ne,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ne,"DOWNSTREAM_PROPERTIES",[...Ne.MUTABLE_DOWNSTREAM_PROPERTIES,...Ne.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ne,"PROPERTIES",[...Ne.META_PROPERTIES,...Ne.UPSTREAM_PROPERTIES,...Ne.DOWNSTREAM_PROPERTIES]);let Jr=Ne;function X7(i){const e=K9(),t=i.toJSON();e.safeParse(t).success;const a=[];return ie(i.errors,a)}class Xt{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"type",n.BuiltInBaseEntity);c(this,"abstract",!1);c(this,"static");c(this,"properties",[]);c(this,"methods",[]);c(this,"abstractMethods",[]);c(this,"extends",[]);c(this,"interactive",!1);c(this,"errors",[]);c(this,"project");this.initialData=this.initialData||e,this.project=this.project||t,this.id=this.id||e.id,this.version=this.version||e.version,this.name=this.name||e.name,this.static=this.static||e.static,this.interactive=this.interactive||e.interactive,this.abstract=e.abstract,this.properties=this.initialData.properties.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.methods=this.initialData.methods.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.extends=this.initialData.extends.map(r=>g(r,this.project))}get allBasePropertiesFromExtendedAndImplementedEntities(){return E(this.extends.reduce((e,t)=>{const r=[...t.ownDeclaredProperties,...t.allBasePropertiesFromExtendedAndImplementedEntities].filter(a=>!a.abstract);return[...e,...r]},[]))}get extendedPropertiesFromOriginalParents(){return E(this.extends.reduce((e,t)=>{const r=[...t.ownDeclaredProperties,...t.extendedPropertiesFromOriginalParents].filter(a=>!a.abstract);return[...e,...r]},[]))}get implementedPropertiesFromOriginalParents(){return E([...this.extends.reduce((e,t)=>{const r=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(s=>!!s.abstract&&!r.find(o=>o.name===s.name));return[...r,...a,...e]},[])])}get extendedProperties(){return this.properties.filter(e=>e.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(e=>!e.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async load(){return this}remove(e={ignoreUpstream:!1,seenEntities:new Set}){return{affected:[],removed:[]}}restore({seenEntities:e}={seenEntities:new Set}){return{affected:[],self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.properties.flatMap(r=>r.toFlat(e)),...this.methods.flatMap(r=>r.toFlat(e)),...this.abstractMethods.flatMap(r=>r.toFlat(e)),...this.extends.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.properties.flatMap(r=>r.toFlatIds(e)),...this.methods.flatMap(r=>r.toFlatIds(e)),...this.abstractMethods.flatMap(r=>r.toFlatIds(e)),...this.extends.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(e=>e.toJSON()),methods:this.methods.map(e=>e.toJSON()),abstractMethods:this.abstractMethods.map(e=>e.toJSON()),extends:this.extends.map(e=>e.toJSON())}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),extends:this.extends.map(e=>e.toReference())}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(r=>r.toFlatJSON(e)),...this.methods.flatMap(r=>r.toFlatJSON(e)),...this.abstractMethods.flatMap(r=>r.toFlatJSON(e))])}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(e=>e.id)}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(r=>r.toFlatGenerationTarget(e)),...this.methods.flatMap(r=>r.toFlatGenerationTarget(e)),...this.abstractMethods.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.properties.forEach(e=>e.clearErrors()),this.methods.forEach(e=>e.clearErrors()),this.abstractMethods.forEach(e=>e.clearErrors()),this}validate(){const e=X7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(t=>t.getErrors()),...this.methods.flatMap(t=>t.getErrors()),...this.abstractMethods.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(){return new Xt(this.toJSON(),this.project)}implement(e,t){return Jo(this,e,t)}getAllInteractiveMethods(){const e=[];return this.interactive&&(e.push(...this.methods),this.extends.filter(r=>r.type===n.BuiltInBaseEntity&&r.interactive||r.type===n.PrimitiveEntity).forEach(r=>{r instanceof Xt&&e.push(...r.getAllInteractiveMethods())})),E(e)}}function Q7(i){const e=j9(),t=i.toJSON();e.safeParse(t).success;const a=[];return ie(i.errors,a)}class kt{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"type",n.PrimitiveEntity);c(this,"static");c(this,"abstract");c(this,"properties",[]);c(this,"methods",[]);c(this,"abstractMethods",[]);c(this,"extends",[]);c(this,"errors",[]);c(this,"project");this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.static=e.static,this.abstract=e.abstract,this.properties=this.initialData.properties.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.methods=this.initialData.methods.map(r=>{const a=g(r,this.project);return a.parent=this,a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=g(r,this.project);return a.parent=this,a})}get allBasePropertiesFromExtendedAndImplementedEntities(){return E(this.extends.reduce((e,t)=>{const r=[...t.ownDeclaredProperties,...t.allBasePropertiesFromExtendedAndImplementedEntities].filter(a=>!a.abstract);return[...e,...r]},[]))}get extendedPropertiesFromOriginalParents(){return E(this.extends.reduce((e,t)=>{const r=[...t.ownDeclaredProperties,...t.extendedPropertiesFromOriginalParents].filter(a=>!a.abstract);return[...e,...r]},[]))}get implementedPropertiesFromOriginalParents(){return E([...this.extends.reduce((e,t)=>{const r=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(s=>!!s.abstract&&!r.find(o=>o.name===s.name));return[...r,...a,...e]},[])])}get extendedProperties(){return this.properties.filter(e=>e.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(e=>!e.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async load(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){return{affected:[],removed:[]}}restore({seenEntities:e}={seenEntities:new Set}){return{affected:[],self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.properties.flatMap(r=>r.toFlat(e)),...this.methods.flatMap(r=>r.toFlat(e)),...this.abstractMethods.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.properties.flatMap(r=>r.toFlatIds(e)),...this.methods.flatMap(r=>r.toFlatIds(e)),...this.abstractMethods.flatMap(r=>r.toFlatIds(e))])}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(e=>e.toJSON()),methods:this.methods.map(e=>e.toJSON()),abstractMethods:this.abstractMethods.map(e=>e.toJSON()),extends:this.extends.map(e=>e.toJSON())}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),extends:this.extends.map(e=>e.toReference())}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(r=>r.toFlatJSON(e)),...this.methods.flatMap(r=>r.toFlatJSON(e)),...this.abstractMethods.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(e=>e.id)}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(r=>r.toFlatGenerationTarget(e)),...this.methods.flatMap(r=>r.toFlatGenerationTarget(e)),...this.abstractMethods.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.properties.forEach(e=>e.clearErrors()),this.methods.forEach(e=>e.clearErrors()),this.abstractMethods.forEach(e=>e.clearErrors()),this}validate(){const e=Q7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(t=>t.getErrors()),...this.methods.flatMap(t=>t.getErrors()),...this.abstractMethods.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(){return new kt(this.toJSON(),this.project)}getAllInteractiveMethods(){const e=[];return e.push(...this.methods),this.extends.filter(r=>r.type===n.BuiltInBaseEntity&&r.interactive||r.type===n.PrimitiveEntity).forEach(r=>{r instanceof Xt&&e.push(...r.getAllInteractiveMethods())}),E(e)}}function qt(i,e){if(!i)throw new Error("Entity is null");const t=e.get(i.id);switch(i.type){case n.PrimitiveValue:return t||new Mi(i,e);case n.CustomEntity:return t||new Jr(i,e);case n.PrimitiveEntity:return t||new kt(i,e);case n.FunctionDeclaration:return t||new _r(i,e);case n.GlobalEvent:return t||new _i(i,e);case n.DataType:return t||new wi(i,e);case n.Property:return t||new wr(i,e);case n.FunctionCall:return t||new kr(i,e);case n.Condition:return t||new Vr(i,e);case n.Operation:return t||new Nr(i,e);case n.VariableDeclaration:return t||new Lr(i,e);case n.VariableInstance:return t||new Gr(i,e);case n.OutputMap:return t||new wn(i,e);case n.ReturnDeclaration:return t||new Nt(i,e);case n.ArgumentDeclaration:return t||new Ur(i,e);case n.InputMap:return t||new Bn(i,e);case n.Project:return t||new _(i);case n.InstalledProject:return t||new Fr(i,e);case n.ActionDescriptor:return t||new te(i,e);case n.ReturnStatement:return t||new xr(i,e);case n.Loop:return t||new Mr(i,e);case n.Search:return t||new $r(i,e);case n.ValueDescriptor:return t||new jr(i,e);case n.BuiltInBaseEntity:return t||new Xt(i,e);case n.InternalCall:return t||new Ni(i,e);case n.ContinueStatement:return t||new bt(i,e);case n.BreakStatement:return t||new Vi(i,e);default:throw new Error("Invalid entity type: "+i.type)}}function g(i,e){if(!i)throw new Error("Entity is null");const t=qt(i,e);return t.subscribe(),t}function eq(i,e){if(!i)throw new Error("Entity is null");switch(i.type){case n.PrimitiveValue:return Mi.fromGenerationTarget(i,e);case n.CustomEntity:return Jr.fromGenerationTarget(i,e);case n.FunctionDeclaration:return _r.fromGenerationTarget(i,e);case n.GlobalEvent:return _i.fromGenerationTarget(i,e);case n.DataType:return wi.fromGenerationTarget(i,e);case n.Property:return wr.fromGenerationTarget(i,e);case n.FunctionCall:return kr.fromGenerationTarget(i,e);case n.Condition:return Vr.fromGenerationTarget(i,e);case n.Operation:return Nr.fromGenerationTarget(i,e);case n.VariableDeclaration:return Lr.fromGenerationTarget(i,e);case n.VariableInstance:return Gr.fromGenerationTarget(i,e);case n.OutputMap:return wn.fromGenerationTarget(i,e);case n.ReturnDeclaration:return Nt.fromGenerationTarget(i,e);case n.ArgumentDeclaration:return Ur.fromGenerationTarget(i,e);case n.InputMap:return Bn.fromGenerationTarget(i,e);case n.InstalledProject:return Fr.fromGenerationTarget(i,e);case n.ReturnStatement:return xr.fromGenerationTarget(i,e);case n.Loop:return Mr.fromGenerationTarget(i,e);case n.Search:return $r.fromGenerationTarget(i,e);case n.ActionDescriptor:return te.fromGenerationTarget(i,e);case n.ValueDescriptor:return jr.fromGenerationTarget(i,e);case n.InternalCall:return Ni.fromGenerationTarget(i,e);case n.ContinueStatement:return bt.fromGenerationTarget(i,e);case n.BreakStatement:return Vi.fromGenerationTarget(i,e);default:throw new Error("Invalid entity type: "+i.type)}}const ee=class ee{constructor(e){c(this,"initialData");c(this,"id");c(this,"version");c(this,"type",n.Project);c(this,"name",null);c(this,"description",null);c(this,"x");c(this,"y");c(this,"entities",[]);c(this,"projects",[]);c(this,"functions",[]);c(this,"events",[]);c(this,"variableDeclarations",[]);c(this,"variableInstances",[]);c(this,"conditions",[]);c(this,"operations",[]);c(this,"functionCalls",[]);c(this,"loops",[]);c(this,"searches",[]);c(this,"primitives",[]);c(this,"builtInBaseEntities",[]);c(this,"operationDeclarations",[]);c(this,"globalEventActionDescriptors",[]);c(this,"loopDeclarations",[]);c(this,"loopDeclarationsBodies",[]);c(this,"conditionDeclarations",[]);c(this,"valueDescriptors",[]);c(this,"dataTypes",[]);c(this,"project");c(this,"instances",{});c(this,"builtInInstances",{});c(this,"errors",[]);c(this,"references",[]);this.initialData=e,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.x=0,this.y=0;try{(!ee.UUID||ee.UUID.isBackup)&&(ee.UUID=ks==null?void 0:ks()),ee.UUID||(ee.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:t=>t})}catch(t){console.error("Error initializing UUID module",t),ee.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:r=>r}}}static injectUUIDModule(e){ee.UUID=e}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[];return a.push(...Le(r)),{errors:a,modifiedData:r}}async inject(...e){return await Promise.all(e.map(t=>new Promise(async r=>{await t.init(this),r(null)}))),this}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return{updated:E(e),added:E(t),removed:E(r),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(e){return this.operationDeclarations.includes(e)}isGlobalEventActionDescriptor(e){return this.globalEventActionDescriptors.includes(e)}isLoopDeclaration(e){return this.loopDeclarations.includes(e)}isConditionDeclaration(e){return this.conditionDeclarations.includes(e)}initChildren(){return this.entities=this.initialData.entities.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.projects=this.initialData.projects.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.functions=this.initialData.functions.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.events=this.initialData.events.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.variableDeclarations=this.initialData.variableDeclarations.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.variableInstances=this.initialData.variableInstances.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.conditions=this.initialData.conditions.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.operations=this.initialData.operations.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.functionCalls=this.initialData.functionCalls.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.loops=this.initialData.loops.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.searches=this.initialData.searches.map(e=>{const t=g(e,this);return t.setParent(this),t.initChildren(),t}),this.attachOrphanReferences(),this.validate(),this}subscribeInstance(e){return(!this.instances[e.id]||this.instances[e.id]!==e)&&(this.instances[e.id]=e),this}subscribeBuiltInInstance(e){return(!this.builtInInstances[e.id]||this.builtInInstances[e.id]!==e)&&(this.builtInInstances[e.id]=e),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(e){return delete this.instances[e.id],this}findSubscribedInstance(e){return this.instances[e.id]||null}findSubscribedBuiltInInstance(e){return this.builtInInstances[e.id]||null}get(e){return this.instances[e]||this.builtInInstances[e]||null}getManaged(e){return this.instances[e]||null}getBuiltIn(e){return this.builtInInstances[e]||null}findSubscribedInstanceFromReference(e){return this.instances[e.entityId]||null}findSubscribedBuiltInInstanceFromReference(e){return this.builtInInstances[e.entityId]||null}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.description=e.description||this.description,this.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e}={ignoreUpstream:!1}){return{affected:[],removed:[]}}restore({seenEntities:e}={seenEntities:new Set}){return{affected:[],self:this}}getAllBuiltInIds(){const e=new Set;return[...this.primitives.flatMap(t=>t.toFlatIds(e)),...this.builtInBaseEntities.flatMap(t=>t.toFlatIds(e)),...this.operationDeclarations.flatMap(t=>t.toFlatIds(e)),...this.globalEventActionDescriptors.flatMap(t=>t.toFlatIds(e)),...this.loopDeclarations.flatMap(t=>t.toFlatIds(e)),...this.conditionDeclarations.flatMap(t=>t.toFlatIds(e)),...this.valueDescriptors.flatMap(t=>t.toFlatIds(e)),...this.dataTypes.flatMap(t=>t.toFlatIds(e))]}getAllBuiltIn(){const e=new Set;return[...this.primitives.flatMap(t=>t.toFlat(e)),...this.builtInBaseEntities.flatMap(t=>t.toFlat(e)),...this.operationDeclarations.flatMap(t=>t.toFlat(e)),...this.globalEventActionDescriptors.flatMap(t=>t.toFlat(e)),...this.loopDeclarations.flatMap(t=>t.toFlat(e)),...this.conditionDeclarations.flatMap(t=>t.toFlat(e)),...this.valueDescriptors.flatMap(t=>t.toFlat(e)),...this.dataTypes.flatMap(t=>t.toFlat(e))]}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[...this.entities.flatMap(r=>r.toFlat(e)),...this.functions.flatMap(r=>r.toFlat(e)),...this.events.flatMap(r=>r.toFlat(e)),...this.projects.flatMap(r=>r.toFlat(e)),...this.variableDeclarations.flatMap(r=>r.toFlat(e)),...this.variableInstances.flatMap(r=>r.toFlat(e)),...this.conditions.flatMap(r=>r.toFlat(e)),...this.operations.flatMap(r=>r.toFlat(e)),...this.functionCalls.flatMap(r=>r.toFlat(e)),...this.loops.flatMap(r=>r.toFlat(e)),...this.searches.flatMap(r=>r.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),Array.from(e))}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,entities:this.entities.map(e=>e.toJSON()),functions:this.functions.map(e=>e.toJSON()),events:this.events.map(e=>e.toJSON()),projects:this.projects.map(e=>e.toJSON()),variableDeclarations:this.variableDeclarations.map(e=>e.toJSON()),variableInstances:this.variableInstances.map(e=>e.toJSON()),conditions:this.conditions.map(e=>e.toJSON()),operations:this.operations.map(e=>e.toJSON()),functionCalls:this.functionCalls.map(e=>e.toJSON()),loops:this.loops.map(e=>e.toJSON()),searches:this.searches.map(e=>e.toJSON())}}toReference(){return{id:this.id+"--"+ee.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,entities:this.entities.map(e=>e.toReference()),functions:this.functions.map(e=>e.toReference()),events:this.events.map(e=>e.toReference()),projects:this.projects.map(e=>e.toReference()),variableDeclarations:this.variableDeclarations.map(e=>e.toReference()),variableInstances:this.variableInstances.map(e=>e.toReference()),conditions:this.conditions.map(e=>e.toReference()),operations:this.operations.map(e=>e.toReference()),functionCalls:this.functionCalls.map(e=>e.toReference()),loops:this.loops.map(e=>e.toReference()),searches:this.searches.map(e=>e.toReference())}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[...this.entities.flatMap(r=>r.toFlatJSON(e)),...this.functions.flatMap(r=>r.toFlatJSON(e)),...this.events.flatMap(r=>r.toFlatJSON(e)),...this.projects.flatMap(r=>r.toFlatJSON(e)),...this.variableDeclarations.flatMap(r=>r.toFlatJSON(e)),...this.variableInstances.flatMap(r=>r.toFlatJSON(e)),...this.conditions.flatMap(r=>r.toFlatJSON(e)),...this.operations.flatMap(r=>r.toFlatJSON(e)),...this.functionCalls.flatMap(r=>r.toFlatJSON(e)),...this.loops.flatMap(r=>r.toFlatJSON(e)),...this.searches.flatMap(r=>r.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[...this.entities.flatMap(r=>r.toFlatGenerationTarget(e)),...this.functions.flatMap(r=>r.toFlatGenerationTarget(e)),...this.events.flatMap(r=>r.toFlatGenerationTarget(e)),...this.projects.flatMap(r=>r.toFlatGenerationTarget(e)),...this.variableDeclarations.flatMap(r=>r.toFlatGenerationTarget(e)),...this.variableInstances.flatMap(r=>r.toFlatGenerationTarget(e)),...this.conditions.flatMap(r=>r.toFlatGenerationTarget(e)),...this.operations.flatMap(r=>r.toFlatGenerationTarget(e)),...this.functionCalls.flatMap(r=>r.toFlatGenerationTarget(e)),...this.loops.flatMap(r=>r.toFlatGenerationTarget(e)),...this.searches.flatMap(r=>r.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.entities.forEach(e=>e.clearErrors()),this.projects.forEach(e=>e.clearErrors()),this.functions.forEach(e=>e.clearErrors()),this.events.forEach(e=>e.clearErrors()),this.variableDeclarations.forEach(e=>e.clearErrors()),this.variableInstances.forEach(e=>e.clearErrors()),this.conditions.forEach(e=>e.clearErrors()),this.operations.forEach(e=>e.clearErrors()),this.functionCalls.forEach(e=>e.clearErrors()),this.loops.forEach(e=>e.clearErrors()),this.searches.forEach(e=>e.clearErrors()),this}validate(){const e=fk(),t=this.toJSON();return e.safeParse(t),this.validateChildren(),{success:!0,error:null,data:t}}validateChildren(){this.entities.forEach(e=>e.validate()),this.projects.forEach(e=>e.validate()),this.functions.forEach(e=>e.validate()),this.events.forEach(e=>e.validate()),this.variableDeclarations.forEach(e=>e.validate()),this.variableInstances.forEach(e=>e.validate()),this.conditions.forEach(e=>e.validate()),this.operations.forEach(e=>e.validate()),this.functionCalls.forEach(e=>e.validate()),this.loops.forEach(e=>e.validate()),this.searches.forEach(e=>e.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(t=>t.getErrors()),...this.projects.flatMap(t=>t.getErrors()),...this.functions.flatMap(t=>t.getErrors()),...this.events.flatMap(t=>t.getErrors()),...this.variableDeclarations.flatMap(t=>t.getErrors()),...this.variableInstances.flatMap(t=>t.getErrors()),...this.conditions.flatMap(t=>t.getErrors()),...this.operations.flatMap(t=>t.getErrors()),...this.functionCalls.flatMap(t=>t.getErrors()),...this.loops.flatMap(t=>t.getErrors()),...this.searches.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(){return new ee(this.toJSON())}getCustomEntity(e){return this.entities.find(t=>t.id===e)||null}addCustomEntityFromTransfer(e){const t=g(e,this);return this.addCustomEntity(t),t}addCustomEntity(e){return this.entities.includes(e)||this.entities.push(e),e}addFunctionDeclarationFromTransfer(e){const t=g(e,this);return this.addFunctionDeclaration(t),t}addFunctionDeclaration(e){return this.functions.includes(e)||this.functions.push(e),e}addFunctionCallFromTransfer(e){const t=g(e,this);return this.addFunctionCall(t),t}addFunctionCall(e){return this.functionCalls.includes(e)||this.functionCalls.push(e),e}addVariableDeclarationFromTransfer(e){const t=g(e,this);return this.addVariableDeclaration(t),t}addVariableDeclaration(e){return this.variableDeclarations.includes(e)||this.variableDeclarations.push(e),e}addVariableInstanceFromTransfer(e){const t=g(e,this);return this.addVariableInstance(t),t}addVariableInstance(e){return this.variableInstances.includes(e)||this.variableInstances.push(e),e}addInstalledProjectFromTransfer(e){const t=g(e,this);return this.addInstalledProject(t),this}addInstalledProject(e){return this.projects.includes(e)||this.projects.push(e),this}addGlobalEventFromTransfer(e){const t=g(e,this);return this.addGlobalEvent(t),this}addGlobalEvent(e){return this.events.includes(e)||this.events.push(e),this}addConditionFromTransfer(e){const t=g(e,this);return this.addCondition(t),this}addCondition(e){return this.conditions.includes(e)||this.conditions.push(e),this}addOperationFromTransfer(e){const t=g(e,this);return this.addOperation(t),this}addOperation(e){return this.operations.includes(e)||this.operations.push(e),this}addLoopFromTransfer(e){const t=g(e,this);return this.addLoop(t),this}addLoop(e){return this.loops.includes(e)||this.loops.push(e),this}addSearchFromTransfer(e){const t=g(e,this);return this.addSearch(t),this}addSearch(e){return this.searches.includes(e)||this.searches.push(e),this}removeCustomEntity(e){const t=this.entities.findIndex(r=>r.id===e.id);if(t>-1){const r=this.entities[t];return this.entities.splice(t,1),r}return null}removeFunctionDeclaration(e){const t=this.functions.findIndex(r=>r.id===e.id);if(t>-1){const r=this.functions[t];return this.functions.splice(t,1),r}return null}removeExternalProject(e){const t=this.projects.findIndex(r=>r.id===e.id);if(t>-1){const r=this.projects[t];return this.projects.splice(t,1),r}return null}removeGlobalEvent(e){const t=this.events.findIndex(r=>r.id===e.id);if(t>-1){const r=this.events[t];return this.events.splice(t,1),r}return null}removeTopLevelVariableDeclaration(e){if(e.type!==n.VariableDeclaration)return null;const t=this.variableDeclarations.findIndex(r=>r.id===e.id);if(t>-1){const r=this.variableDeclarations[t];return this.variableDeclarations.splice(t,1),r}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(t=>t.methods)]}getFunctionDeclaration(e){return this.functions.find(t=>t.id===e)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Condition)]},[]),...this.functionCalls.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Condition)]},[]),...this.operations.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Condition)]},[]),...this.loops.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Condition)]},[]),...this.searches.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Operation)]},[]),...this.functionCalls.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Operation)]},[]),...this.conditions.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Operation)]},[]),...this.loops.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Operation)]},[]),...this.searches.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.FunctionCall)]},[]),...this.conditions.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.FunctionCall)]},[]),...this.operations.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.FunctionCall)]},[]),...this.loops.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.FunctionCall)]},[]),...this.searches.reduce((t,r)=>{const a=Me(r);return[...t,...a.filter(s=>s.type===n.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((t,r)=>{const a=re(r);return[...t,...a]},[]),...this.functionCalls.reduce((t,r)=>{const a=re(r);return[...t,...a]},[]),...this.conditions.reduce((t,r)=>{const a=re(r);return[...t,...a]},[]),...this.operations.reduce((t,r)=>{const a=re(r);return[...t,...a]},[]),...this.loops.reduce((t,r)=>{const a=re(r);return[...t,...a]},[]),...this.searches.reduce((t,r)=>{const a=re(r);return[...t,...a]},[])]}getVariableInstances(){return[...this.variableInstances,...this.getEntryPoints().reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableInstance);return[...t,...s]},[]),...this.functionCalls.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableInstance);return[...t,...s]},[]),...this.conditions.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableInstance);return[...t,...s]},[]),...this.operations.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableInstance);return[...t,...s]},[]),...this.loops.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableInstance);return[...t,...s]},[]),...this.searches.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableInstance);return[...t,...s]},[])]}getVariableDeclarations(){return E([...this.variableDeclarations,...this.getEntryPoints().reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableDeclaration);return[...t,...s]},[]),...this.functionCalls.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableDeclaration);return[...t,...s]},[]),...this.conditions.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableDeclaration);return[...t,...s]},[]),...this.operations.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableDeclaration);return[...t,...s]},[]),...this.loops.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableDeclaration);return[...t,...s]},[]),...this.searches.reduce((t,r)=>{const s=re(r).filter(o=>o.type===n.VariableDeclaration);return[...t,...s]},[])])}attachOrphanReferences(){const e=this.getVariableInstances(),t=this.getVariableDeclarations();return e.forEach(r=>{if(!r.declaration){const a=r.initialData,s=a.declaration.entityId||a.declaration.id,o=t.find(l=>l.id===s);o&&r.setDeclaration(o)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(e=>e.name===V.PERSISTED_ENTITY)||null}};c(ee,"UUID",{isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:e=>e}),c(ee,"MUTABLE_BASE_PROPERTIES",["name","description"]),c(ee,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(ee,"BASE_PROPERTIES",[...ee.MUTABLE_BASE_PROPERTIES,...ee.INMUTABLE_BASE_PROPERTIES]),c(ee,"MUTABLE_META_PROPERTIES",[...ee.MUTABLE_BASE_PROPERTIES,"x","y"]),c(ee,"INMUTABLE_META_PROPERTIES",[...ee.INMUTABLE_BASE_PROPERTIES]),c(ee,"META_PROPERTIES",[...ee.MUTABLE_META_PROPERTIES,...ee.INMUTABLE_META_PROPERTIES]),c(ee,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(ee,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),c(ee,"UPSTREAM_PROPERTIES",[...ee.MUTABLE_UPSTREAM_PROPERTIES,...ee.INMUTABLE_UPSTREAM_PROPERTIES]),c(ee,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),c(ee,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ee,"DOWNSTREAM_PROPERTIES",[...ee.MUTABLE_DOWNSTREAM_PROPERTIES,...ee.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ee,"PROPERTIES",[...ee.META_PROPERTIES,...ee.UPSTREAM_PROPERTIES,...ee.DOWNSTREAM_PROPERTIES]);let _=ee;class bA extends te{constructor(t){super(Wt,t);c(this,"id",le.Parallel);c(this,"name",le.Parallel);c(this,"description","Execute a list of actions one after the other");c(this,"version",1);c(this,"autoexecutable",!0);c(this,"initialData",Wt);c(this,"type",n.ActionDescriptor);c(this,"inputs",[]);c(this,"outputs",[]);c(this,"error",null);c(this,"project");this.project=t,this.inputs=Wt.inputs.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.outputs=Wt.outputs.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.error=Wt.error?g(Wt.error,this.project):null}}class RA extends te{constructor(t){super(pt,t);c(this,"id",pt.id);c(this,"name",pt.name);c(this,"description",pt.description);c(this,"version",pt.version);c(this,"autoexecutable",!1);c(this,"initialData",pt);c(this,"type",n.ActionDescriptor);c(this,"inputs",[]);c(this,"outputs",[]);c(this,"error",null);c(this,"project");this.project=t,this.inputs=pt.inputs.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.outputs=pt.outputs.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.error=pt.error?g(pt.error,this.project):null}}class gA extends te{constructor(t){super(En,t);c(this,"id",le.Sequential);c(this,"name",le.Sequential);c(this,"description","Execute a list of actions one after the other");c(this,"version",1);c(this,"autoexecutable",!0);c(this,"initialData",En);c(this,"type",n.ActionDescriptor);c(this,"inputs",[]);c(this,"outputs",[]);c(this,"error",null);c(this,"project");this.project=t,this.inputs=En.inputs.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.outputs=En.outputs.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.error=En.error?g(En.error,this.project):null}}class tq extends te{constructor(e){super(xi,e)}}class nq extends te{constructor(e){super(ir,e)}}class rq extends te{constructor(t){super(ar,t);c(this,"autoexecutable",!0)}getEntityToMatchInputMap(t){return t.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===B.operation[ce.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(t){return t.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===B.operation[ce.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(t){return t.outputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===B.operation[ce.Validate].outputs.outputEntity.id})||null}getEntityToMatch(t){let r=null;if(t.readsValue){const s=t.readsValue.getDataType();s&&s.entity&&s.entity.type===n.CustomEntity&&(r=s.entity)}const a=t.getDefaultValue();return!r&&a&&a.valueAsType&&!Array.isArray(a.valueAsType)&&a.valueAsType.type===n.CustomEntity&&(r=a.valueAsType),r}syncOperationInstance(t){const r=this.getEntityToMatchInputMap(t);r&&this.syncEntityToMatchInputMapDataType(r);const a=this.getDataToValidateInputMap(t);a&&this.syncDataToValidateInputMapDataType(a);const s=this.getOutputDataOutputMap(t);return s&&this.syncOutputDataOutputMapDataType(s),t}syncEntityToMatchInputMapDataType(t){var a,s,o;if(((a=t.declaration)==null?void 0:a.id)!==B.operation[ce.Validate].inputs.entityToMatch.id)return null;if(!t.dataType){const l={id:t.id+"--infered-data-type",version:1,type:n.DataType,isList:!1,isNullable:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!0,entity:null,constant:!1,like:!0,inferred:!0,defaultValue:null,parent:t.toReference()},p=g(l,t.project);p.setParent(t),p.initChildren(),t.setDataType(p)}(s=t.dataType)==null||s.sync({inferred:!0,like:!1,asType:!0});const r=this.getEntityToMatch(t);return(o=t.dataType)==null||o.setEntity(r),t.dataType}syncDataToValidateInputMapDataType(t){var o,l,p;if(((o=t.declaration)==null?void 0:o.id)!==B.operation[ce.Validate].inputs.dataToValidate.id)return null;const r=this.getEntityToMatchInputMap(t.parent);if(!r||!this.getEntityToMatch(r))return null;if(!t.dataType){const y={id:t.id+"--infered-data-type",version:1,type:n.DataType,isList:!1,isNullable:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:null,constant:!1,like:!0,inferred:!0,defaultValue:null,parent:t.toReference()},f=g(y,t.project);f.setParent(t),f.initChildren(),t.setDataType(f)}(l=t.dataType)==null||l.sync({inferred:!0,like:!0,asType:!1});const s=this.getEntityToMatch(r);return(p=t.dataType)==null||p.setEntity(s),t.dataType}syncOutputDataOutputMapDataType(t){var o,l,p;if(((o=t.declaration)==null?void 0:o.id)!==B.operation[ce.Validate].outputs.outputEntity.id)return null;const r=this.getEntityToMatchInputMap(t.parent);if(!r||!this.getEntityToMatch(r))return null;if(!t.dataType){const y={id:t.id+"--infered-data-type",version:1,type:n.DataType,isList:!1,isNullable:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:null,constant:!1,like:!0,inferred:!0,defaultValue:null,parent:t.toReference()},f=g(y,t.project);f.setParent(t),f.initChildren(),t.setDataType(f)}(l=t.dataType)==null||l.sync({inferred:!0,like:!0,asType:!1});const s=this.getEntityToMatch(r);return(p=t.dataType)==null||p.setEntity(s),t.dataType}inferInputMapDataType(t){var r,a;return((r=t.declaration)==null?void 0:r.id)===B.operation[ce.Validate].inputs.entityToMatch.id?this.syncEntityToMatchInputMapDataType(t):((a=t.declaration)==null?void 0:a.id)===B.operation[ce.Validate].inputs.dataToValidate.id?this.syncDataToValidateInputMapDataType(t):null}inferOutputMapDataType(t){var r;return((r=t.declaration)==null?void 0:r.id)===B.operation[ce.Validate].outputs.outputEntity.id?this.syncOutputDataOutputMapDataType(t):null}}class iq extends te{constructor(e){super(fl,e)}}class aq extends te{constructor(e){super(ml,e)}}class sq extends te{constructor(e){super(Tl,e)}}class oq extends te{constructor(e){super(ts,e)}}class lq extends te{constructor(e){super(Xa,e)}}class cq extends te{constructor(e){super(Ui,e)}}function dq(i){const e=[new gA(i),new bA(i),new RA(i),new tq(i),new nq(i),new rq(i),new oq(i),new iq(i),new sq(i),new aq(i),new lq(i),new cq(i),new te(yl,i),new te(pl,i)];return e.forEach(t=>{t.initChildren(),i.subscribeBuiltInInstance(t)}),i.operationDeclarations=e,e}class vA extends Xt{constructor(t){super(nt,t);c(this,"initialData");c(this,"id",V.PERSISTED_ENTITY);c(this,"version",1);c(this,"name",V.PERSISTED_ENTITY);c(this,"description",nt.description);c(this,"type",n.BuiltInBaseEntity);c(this,"abstract",nt.abstract);c(this,"static",nt.static);c(this,"properties",[]);c(this,"methods",[]);c(this,"abstractMethods",[]);c(this,"extends",[]);c(this,"errors",[]);c(this,"project");this.initialData=nt,this.project=t,this.id=nt.id,this.version=nt.version,this.name=nt.name,this.static=nt.static,this.abstract=nt.abstract,this.properties=this.initialData.properties.map(r=>{const a=g(r,this.project);return a.setParent(this),a.initChildren(),a}),this.methods=this.initialData.methods.map(r=>{const a=g(r,this.project);return a.parent=this,a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=g(r,this.project);return a.parent=this,a}),this.extends=this.initialData.extends.map(r=>g(r,this.project))}}function uq(i){const e=[new vA(i),new Xt(ys,i),new Xt(bn,i),new Xt(Zl,i)];return e.forEach(t=>{i.subscribeBuiltInInstance(t)}),i.builtInBaseEntities=e,e}function pq(i){const e=[new kt(x,i),new kt(Mn,i),new kt(Z,i),new kt(Ke,i),new kt(Vn,i),new kt(mn,i),new kt(Ln,i),new kt($i,i)];return e.forEach(t=>{i.subscribeBuiltInInstance(t)}),i.primitives=e,e}function yq(i){const e=[new te(Es,i)];return e.forEach(t=>{t.initChildren(),i.subscribeBuiltInInstance(t)}),i.globalEventActionDescriptors=e,e}function fq(i){const e=[new te(ps,i),new te(sr,i),new te(us,i),new te(ki,i),new te(qi,i),new te(Al,i)];e.forEach(r=>{r.initChildren(),i.subscribeBuiltInInstance(r)}),i.loopDeclarations=e;const t=[new te(Vl,i),new te(ds,i),new te(wl,i),new te(ET,i),new te(GT,i),new te(Sl,i)];return t.forEach(r=>{r.initChildren(),i.subscribeBuiltInInstance(r)}),i.loopDeclarationsBodies=t,e}function hq(i){const e=[new jr(ec,i)];return e.forEach(t=>{t.initChildren(),i.subscribeBuiltInInstance(t)}),i.valueDescriptors=e,e}function mq(i){const e=[new te(ur,i),new te(ri,i)];return e.forEach(t=>{t.initChildren(),i.subscribeBuiltInInstance(t)}),i.operationDeclarations=e,e}const Wr={},el={};async function Tq(i,e={}){const t={...MI};return t.id=i.id,e.empty?{data:{id:i.id,type:n.Project,version:1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]}}:{data:t}}function IA(i){const e=new _(i);return pq(e),uq(e),dq(e),yq(e),fq(e),hq(e),mq(e),e.getAllBuiltIn().forEach(r=>{e.builtInInstances[r.id]||(e.builtInInstances[r.id]=r,delete e.instances[r.id])}),e.initChildren(),e}async function Eq(i,e={}){if(i.id&&Wr[i.id])return Wr[i.id];if(i.id&&el[i.id])return await el[i.id],Wr[i.id];const t=Tq(i,e);i.id&&(el[i.id]=t);const r=await t;if(r.data){const a=IA(r.data);return Wr[i.id]=a,i.id&&delete el[i.id],a}return null}function bq(i){return Wr[i.id]&&delete Wr[i.id],null}const Rq="test_primitive_entities_export";d.AI_VALUE_CONNECTION_GENERATION_ACTION_EXPLANATION=Bu,d.ActionDescriptorState=te,d.ActionInputMapState=n7,d.ActionOutputMapState=a7,d.AppendToListOperationInputIds=df,d.AppendToListOperationOutputIds=uf,d.ArgumentDeclarationState=Ur,d.BREAK_AND_CONTINUE_STATEMENTS_RETURN_DECLARATIONS_EXPLANATION=Au,d.BUILT_IN_BASE_ENTITY_IDS=B,d.BUILT_IN_ENTITY_TYPES=Zr,d.BaseCanvasDraggableState=U2,d.BaseEntityNames=V,d.BaseState=F2,d.BaseValueDescriptorIds=sl,d.BreakStatementState=Vi,d.BuiltInBaseEntityState=Xt,d.CACHED_PROJECTS_BY_ID=Wr,d.CALLABLE_ENTITIES_EXPLANATION=T7,d.CALLABLE_TYPES=hn,d.CALLER_ENTITIES_EXPLANATION=NP,d.CALLER_TYPES=Qt,d.CALLS_UPDATE_EXPLANATION=Xn,d.COMPARISON_CONDITIONS=Ob,d.CONDITIONS=WA,d.CUSTOM_ENTITY_OPERATIONS=Ch,d.CallableEntityClass=j2,d.CallerEntityClass=vu,d.ChildEntityState=x2,d.ComparisonOperatorTypes=$e,d.ConditionState=Vr,d.ContinueStatementState=bt,d.CreateNewInputIds=rh,d.CreateNewOutputIds=ih,d.CustomEntityState=Jr,d.DRAGGABLE_CALLABLE_TYPES=il,d.DRAGGABLE_CALLER_TYPES=zu,d.DRAGGABLE_ELEMENT_TYPES=al,d.DRAGGABLE_EXECUTABLE_TYPES=PA,d.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES=rl,d.DataTypeCompatibilityTypes=xt,d.DataTypeParentChildRelation=We,d.DataTypeState=wi,d.ENTITIES_WITH_VALLUES_EXPLANATION=Uo,d.ENTITY_TYPES=AA,d.ENTITY_WITH_LOGIC_SCOPE_TYPES=ut,d.ENTITY_WITH_NAMES_TYPES=Zu,d.ENTITY_WITH_VALUE_TYPES=Yu,d.ENTRY_POINT_ENTITIES_EXPLANATION=Wa,d.ENTRY_POINT_TYPES=xe,d.EVENT_TYPES=zr,d.EXECUTABLE_TYPES=DA,d.EXECUTION_OPERATIONS=nh,d.EntityError=br,d.EntityErrorSeverity=T,d.EntityGenerationError=b,d.EntityGenerationErrorCode=h,d.EntityInstanceErrorCode=M,d.EntityOperations=ce,d.EntityType=n,d.EntityWithLogicScopeClass=W2,d.EntityWithValueClass=J2,d.EntryPointEntityClass=k2,d.ExecutionOperations=le,d.ExecutionTerminationType=BP,d.FunctionCallState=kr,d.FunctionDeclarationState=_r,d.GLOBAL_EVENT_DECLARATIONS=HA,d.GetLastInListOperationInputIds=Ky,d.GetLastInListOperationOutputIds=Xy,d.GlobalEventNames=fn,d.GlobalEventState=_i,d.HTTPOperations=tt,d.HTTP_OPERATIONS=cm,d.InputMapState=Bn,d.InstalledProjectState=Fr,d.InternalCallState=Ni,d.JoinListOperationInputIds=Ty,d.JoinListOperationOutputIds=Ey,d.LIST_OPERATIONS=Df,d.ListOperations=H,d.LoopState=Mr,d.LoopTypes=$,d.NON_INTERACTIVE_BASE_ENTITIES_EXPLANATION=Qn,d.NUMBER_OPERATIONS=wp,d.NumberOperations=Te,d.OPERATION_DECLARATIONS=BA,d.OperationState=Nr,d.OutputMapParentChildRelation=Yr,d.OutputMapState=wn,d.PARENT_AUTO_CALCULATION_FROM_CALLER_EXPLANATION=xo,d.PASS_THROUGH_CALLABLE_ENTITIES_EXPLANATION=Kn,d.PASS_THROUGH_CALLABLE_TYPES=Ue,d.PROPERTY_NOT_VALUE_READER_WRITTER_EXPLANATION=Cu,d.ParallelExecutionOperation=bA,d.PassThroughCallableEntityClass=q2,d.PersistedEntity=vA,d.PersistedEntityMethods=Ct,d.PrimitiveEntityState=kt,d.PrimitiveTypes=I,d.PrimitiveValueParentChildRelation=nl,d.PrimitiveValueState=Mi,d.ProjectState=_,d.PropertyState=wr,d.RETURN_STATEMENT_RETURN_DECLARATIONS_EXPLANATION=E7,d.ReturnDeclarationState=Nt,d.ReturnStatementState=xr,d.STANDALONE_CONDITIONS=Eb,d.STRING_OPERATIONS=my,d.ScopeCompatibilityType=Qo,d.SearchState=$r,d.SequentialExecutionOperation=gA,d.SequentialExecutionOperationInputIds=kf,d.SequentialExecutionOperationOutputIds=qf,d.SharedEntityErrorCode=S,d.SharedStateFunctionality=CP,d.SplitListOperationInputIds=Ny,d.SplitListOperationOutputIds=My,d.StandaloneOperatorTypes=Vt,d.StringOperations=X,d.TERMINATION_TYPES=Ve,d.USER_MANAGED_ENTITY_TYPES=OA,d.UserManagedEntityStateFunctionality=$2,d.VALUE_READING_ENTITIES_EXPLANATION=Su,d.VALUE_READING_TYPES=Nn,d.VALUE_WRITING_ENTITIES_EXPLANATION=MP,d.VALUE_WRITING_TYPES=ke,d.VARIABLE_DATA_TYPE_INFERRANCE_EXPLANATION=Ou,d.VARIABLE_TYPES=Fe,d.ValueAutogenerationType=je,d.ValueDescriptorParentChildRelation=O,d.ValueDescriptorState=jr,d.ValueReadingEntityClass=qa,d.ValueWritingEntityClass=Ja,d.VariableDeclarationState=Lr,d.VariableInputMapState=t7,d.VariableInstanceState=Gr,d.VariableOutputMapState=i7,d.WaitOperation=RA,d.WaitOperationInputIds=Lf,d.WaitOperationOutputIds=Gf,d.appendToListOperation=ts,d.appendToListOperationElementToAppendArgument=bl,d.appendToListOperationElementToAppendArgumentParentRef=bf,d.appendToListOperationElementToAppendArgumentRef=ff,d.appendToListOperationError=If,d.appendToListOperationErrorParentRef=vf,d.appendToListOperationListArgument=El,d.appendToListOperationListArgumentParentRef=Ef,d.appendToListOperationListArgumentRef=pf,d.appendToListOperationListDataType=yf,d.appendToListOperationResultListDataType=Tf,d.appendToListOperationResultListReturn=gf,d.appendToListOperationResultListReturnParentRef=Rf,d.appendToListOperationResultListReturnRef=mf,d.appendToListOperationSecondListDataType=hf,d.asGenerationActionExample=pn,d.booleanPrototype=Mn,d.capitalizeFirstLetter=wo,d.checkAreCustomEntitiesCompatibleAsDataType=TP,d.checkAreDataTypesCompatible=jt,d.checkArePropertiesCompatibleAsDataType=mP,d.checkIsBranchDependentButNotDirectlyOnBranch=Ya,d.checkIsBranchDependentOnBranch=O7,d.checkIsCallableEntityReachable=Ka,d.checkIsCanvasEntity=q7,d.checkIsDetachedBranch=yA,d.checkIsDetachedBranchShallow=Wu,d.checkIsGlobalVariable=j7,d.checkIsGloballyDeclared=Ju,d.checkIsMethod=mA,d.checkIsNestedScope=Xo,d.checkScopeCompatibility=za,d.countedLoopActionDescriptor=ps,d.countedLoopActionDescriptorDynamicReturnDeclaration=WT,d.countedLoopActionDescriptorDynamicReturnDeclarationParentRef=JT,d.countedLoopActionDescriptorStringArgumentDeclaration=qT,d.countedLoopActionDescriptorStringArgumentDeclarationDataType=jT,d.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValue=UT,d.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValueParentRef=FT,d.countedLoopActionDescriptorStringArgumentDeclarationDataTypeParentRef=xT,d.countedLoopActionDescriptorStringArgumentDeclarationParentRef=kT,d.countedLoopBodyActionDescriptor=Vl,d.countedLoopBodyActionDescriptorAnyDynamicArgument=KT,d.countedLoopBodyActionDescriptorAnyDynamicArgumentParentRef=ZT,d.countedLoopBodyActionDescriptorAnyDynamicReturn=QT,d.countedLoopBodyActionDescriptorAnyDynamicReturnParentRef=XT,d.countedLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Ml,d.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=YT,d.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=HT,d.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=zT,d.createCustomEntityFromJSONObject=Wo,d.createEntityError=Y,d.createNestedDataTypeForEntity=JP,d.createNewInstanceOperation=ir,d.createNewInstanceOperationEntityToInstanciateArgument=ph,d.createNewInstanceOperationEntityToInstanciateArgumentRef=ch,d.createNewInstanceOperationEntityToInstanciateDataType=dh,d.createNewInstanceOperationError=mh,d.createNewInstanceOperationErrorParentRef=hh,d.createNewInstanceOperationNewEntityDataArgument=lh,d.createNewInstanceOperationNewEntityDataArgumentDataType=oh,d.createNewInstanceOperationNewEntityDataArgumentDataTypeParentRef=sh,d.createNewInstanceOperationNewEntityDataArgumentParentRef=ah,d.createNewInstanceOperationOutputEntityDeclaration=fh,d.createNewInstanceOperationOutputEntityDeclarationParentRef=yh,d.createNewInstanceOperationRef=uh,d.createSemanticId=Ze,d.createStateFromGenerationTargetType=eq,d.createStateFromType=qt,d.createStateFromTypeAndSubscribe=g,d.cronJobBuiltInBaseEntity=Zl,d.cronJobBuiltInBaseEntityExpressionProperty=fb,d.cronJobBuiltInBaseEntityExpressionPropertyDataTypeRef=kA,d.cronJobBuiltInBaseEntityExpressionPropertyRef=pb,d.cronJobBuiltInBaseEntityRef=yb,d.cronJobTriggeredFunctionDeclarationBlueprint=zl,d.cronJobTriggeredFunctionDeclarationBlueprintParentRef=db,d.customEntityToZodSchema=Jb,d.dataTypeCompatibilityToErrorExplanation=jP,d.datePrototype=mn,d.dateValueAutogenerationSchema=dd,d.deletePersistedEntityMethod=Yl,d.deletePersistedEntityMethodParentRef=ZE,d.deleteRootProject=bq,d.endpointBuiltInBaseEntity=ys,d.endpointBuiltInBaseEntityRef=rE,d.endpointBuiltInBaseEntityRefFour=$E,d.endpointBuiltInBaseEntityRefThree=pE,d.endpointBuiltInBaseEntityRefTwo=lE,d.endpointBuiltInCorsProperty=iE,d.endpointBuiltInCorsPropertyDataType=nE,d.endpointBuiltInCorsPropertyDataTypeRef=eE,d.endpointBuiltInCorsPropertyRef=tE,d.endpointBuiltInMethodProperty=Gl,d.endpointBuiltInMethodPropertyDataType=uE,d.endpointBuiltInMethodPropertyDataTypeRef=cE,d.endpointBuiltInMethodPropertyRef=dE,d.endpointBuiltInPathProperty=Ll,d.endpointBuiltInPathPropertyDataType=oE,d.endpointBuiltInPathPropertyDataTypeRef=aE,d.endpointBuiltInPathPropertyRef=sE,d.endpointPathParamsArgumentDeclaration=Fl,d.endpointPathParamsArgumentDeclarationRef=vE,d.endpointPathParamsVariableDataType=IE,d.endpointPathParamsVariableDataTypeRef=gE,d.endpointReachedTriggerActionDescriptor=Jl,d.endpointReachedTriggerActionDescriptorRef=DE,d.endpointReachedTriggerActionDescriptorRefFour=OE,d.endpointReachedTriggerActionDescriptorRefThree=AE,d.endpointReachedTriggerActionDescriptorRefTwo=PE,d.endpointRequestBodyArgumentDeclaration=xl,d.endpointRequestBodyArgumentDeclarationRef=mE,d.endpointRequestBodyVariableDataType=TE,d.endpointRequestHeadersArgumentDeclaration=$l,d.endpointRequestHeadersArgumentDeclarationRef=fE,d.endpointRequestHeadersVariableDataType=hE,d.endpointRequestHeadersVariableDataTypeRef=yE,d.endpointRequestQueryParamsArgumentDeclaration=Ul,d.endpointRequestQueryParamsArgumentDeclarationRef=bE,d.endpointRequestQueryParamsVariableDataType=RE,d.endpointRequestQueryParamsVariableDataTypeRef=EE,d.endpointResponseBodyDataType=LE,d.endpointResponseBodyReturnDeclaration=ql,d.endpointResponseBodyReturnDeclarationRef=VE,d.endpointResponseCodeDataType=CE,d.endpointResponseCodeReturnDeclaration=jl,d.endpointResponseCodeReturnDeclarationRef=SE,d.endpointResponseHeadersDataType=NE,d.endpointResponseHeadersDataTypeRef=wE,d.endpointResponseHeadersReturnDeclaration=kl,d.endpointResponseHeadersReturnDeclarationRef=_E,d.endpointReturnStatementRef=BE,d.endpointReturnStatementRefThree=GE,d.endpointReturnStatementRefTwo=ME,d.enumOptionsProperty=tp,d.enumOptionsPropertyDataType=Qu,d.enumOptionsPropertyDataTypeRef=Ku,d.enumOptionsPropertyRef=Xu,d.enumPrototype=Vn,d.enumPrototypeRef=ep,d.executionBuiltInEntity=Xl,d.executionBuiltInEntityAbortMethod=Kl,d.executionBuiltInEntityAbortMethodParentRef=hb,d.filterOutDuplicateEntities=E,d.filterOutDuplicateErrors=N9,d.findEntityFromKeys=Nu,d.findReferenceToSelfInList=sA,d.findReferencesToSelfInProject=L7,d.flattenCalls=yn,d.flattenCanvasAncestorsUntil=Ho,d.flattenCustomEntityExtensionAndImplementationTypes=ju,d.flattenCustomEntityExtensionTypes=Zo,d.flattenCustomEntityExtensions=Uu,d.flattenCustomEntityImplementations=xu,d.flattenCustomEntityImplementionTypes=zo,d.flattenDerivedCanvasEntities=St,d.flattenDetachedBranch=hA,d.flattenElementCalls=Me,d.flattenElementCallsOnTheSameScope=V7,d.flattenProjectElements=aA,d.flattenRelatedCanvasElementsOnTheLeft=uA,d.flattenRelatedCanvasElementsOnTheRight=dA,d.flattenVariableReads=iA,d.flattenVariableWrites=rA,d.flattenVariables=re,d.fromZodParseToEntityGenerationErrors=Iu,d.generate=kS,d.generateActionExample=b7,d.generateExecutionDataType=E2,d.generateMutablePropertiesExplanation=Go,d.generateRandomBoolean=TR,d.generateRandomDate=zb,d.generateRandomDateAfter=Wb,d.generateRandomDateBefore=Hb,d.generateRandomDateBetweenRange=Yb,d.generateRandomNumber=pR,d.generateRandomNumberAfter=cR,d.generateRandomNumberBefore=dR,d.generateRandomNumberBetweenRange=uR,d.generateRandomText=mR,d.generateRandomTextAfter=yR,d.generateRandomTextBefore=fR,d.generateRandomTextBetweenRange=hR,d.generateUniqueUUID=lR,d.getAllActionDescriptorsForConditions=qo,d.getAllActionDescriptorsForGlobalEvents=jo,d.getAllActionDescriptorsForLoops=ko,d.getAllActionDescriptorsForOperations=I7,d.getAllGloballyDeclaredFunctionDeclarationsExplanation=FP,d.getBaseBuiltInEntities=tr,d.getBaseSchemaBasedOnType=wP,d.getBuiltInEntityOwner=nr,d.getCallableEntityReferenceSchema=ze,d.getCallableEntityTypeSchema=iD,d.getCallerEntityReferenceSchema=$3,d.getCallerEntityTypeSchema=G3,d.getCalls=Lu,d.getCanvasEntitiesDerivedFromInternalCalls=cA,d.getCanvasEntitiesDerivedFromWrites=Li,d.getCanvasEntityDerivedFromValueReadingEntity=Fu,d.getCanvasEntityReferenceSchema=tk,d.getCanvasEntityTypeSchema=ek,d.getChildrenEntityWithValues=C7,d.getColumnProperties=z7,d.getCommonAncestor=Vu,d.getCommonChildren=WP,d.getCustomEntityExtends=Gi,d.getDatabaseEntities=H7,d.getDatabaseEntity=Z7,d.getDeclaration=Br,d.getDeepestScope=EA,d.getDraggableCallableEntityReferenceSchema=sD,d.getDraggableCallableEntityTypeSchema=aD,d.getDraggableCallerEntityReferenceSchema=U3,d.getDraggableCallerEntityTypeSchema=F3,d.getDraggableExecutableEntityReferenceSchema=q3,d.getDraggableExecutableEntityTypeSchema=k3,d.getDraggablePassThroughCallableEntityReferenceSchema=Io,d.getDraggablePassThroughCallableEntityTypeSchema=vo,d.getDraggablePlayableEntityReferenceSchema=z3,d.getDraggablePlayableEntityTypeSchema=Y3,d.getEntityArgumentDeclarations=$u,d.getEntityInputMaps=oA,d.getEntityOutputMaps=F7,d.getEntityReferenceSchema=Q3,d.getEntityReturnDeclarations=lA,d.getEntityTypeSchema=X3,d.getEntityWithLogicScopeReferenceSchema=On,d.getEntityWithLogicScopeTypeSchema=J3,d.getEntityWithValueReferenceSchema=rD,d.getEntityWithValueTypeSchema=L3,d.getEntryPointEntityReferenceSchema=Ye,d.getEntryPointEntityTypeSchema=Yn,d.getEventEntityReferenceSchema=Ro,d.getEventEntityTypeSchema=bo,d.getExecutableEntityReferenceSchema=j3,d.getExecutableEntityTypeSchema=x3,d.getExtendedBuiltInEntity=U7,d.getExtendedCustomEntity=ku,d.getGenerationTargetSchemaBasedOnType=_P,d.getHeadIfPartOfDetachedBranch=fA,d.getHighestScope=TA,d.getImplementedBuiltInEntity=x7,d.getIsInteractive=qu,d.getLastInListOperation=Tl,d.getLastInListOperationError=cf,d.getLastInListOperationErrorParentRef=lf,d.getLastInListOperationInputListArgument=af,d.getLastInListOperationInputListArgumentParentRef=rf,d.getLastInListOperationInputListArgumentRef=Qy,d.getLastInListOperationInputListDataType=ef,d.getLastInListOperationOutputElementDataType=nf,d.getLastInListOperationOutputElementReturn=of,d.getLastInListOperationOutputElementReturnParentRef=sf,d.getLastInListOperationOutputElementReturnRef=tf,d.getLinkedEntitiesFromArgumentDeclaration=M7,d.getLowestPersistedEntityImplementation=pA,d.getParentCallableEntity=HP,d.getParentCallerEntity=zP,d.getParentCanvasEntities=Rt,d.getParentCanvasEntity=et,d.getParentEntryPoint=S7,d.getParentPassthroughCallableEntity=YP,d.getPassThroughCallableEntityReferenceSchema=Ee,d.getPassThroughCallableEntityTypeSchema=go,d.getPeristedEntities=W7,d.getPlayableEntityReferenceSchema=H3,d.getPlayableEntityTypeSchema=W3,d.getProject=Eq,d.getPrototypeByType=Ko,d.getReferenceEntityId=N,d.getReferencedEntitiesStateOrErrors=Fo,d.getReferencedEntityStateOrErrors=Du,d.getRelatedCanvasElementsOnTheLeft=qr,d.getRelatedCanvasElementsOnTheRight=er,d.getRootEntryPointScopeOwner=Hu,d.getScopeOwner=gt,d.getTerminationReferenceSchema=K3,d.getTerminationTypeSchema=Z3,d.getUsedArgFromDeclaration=G7,d.getUsedReturnFromDeclaration=$7,d.getValueReadingEntityReferenceSchema=nD,d.getValueReadingEntityTypeSchema=An,d.getValueWritingEntityReferenceSchema=V3,d.getValueWritingEntityTypeSchema=Na,d.getVariableFromInputMapping=KP,d.getVariableFromReturnVariablePointer=eA,d.getVariableReferenceSchema=Hn,d.getVariableTypeSchema=Dr,d.getVariablesFromArgumentDeclarations=Yo,d.getVariablesFromInputMaps=XP,d.getVariablesFromOutputMapping=tA,d.getVariablesFromOutputMaps=nA,d.getVariablesFromReturnDeclarations=QP,d.getVariablesInSameOrHigherScope=hu,d.getWrites=Gu,d.groupCallsBasedOnParallelizableExecution=w7,d.handleAfterEntityImplementationSideEffects=qP,d.handleBeforeEntityImplementationSideEffects=kP,d.httpRequestBodyArgument=as,d.httpRequestBodyArgumentRef=jh,d.httpRequestBodyDataType=kh,d.httpRequestHeadersArgument=is,d.httpRequestHeadersArgumentRef=Uh,d.httpRequestHeadersDataType=xh,d.httpRequestMethodArgument=ns,d.httpRequestMethodArgumentRef=$h,d.httpRequestMethodDataType=Fh,d.httpRequestMethodDataTypeRef=Lh,d.httpRequestOperation=xi,d.httpRequestOperationErrorValueDescriptor=Pl,d.httpRequestOperationErrorValueDescriptorDatatype=lm,d.httpRequestOperationErrorValueDescriptorRef=om,d.httpRequestOperationRef=rm,d.httpRequestOperationRefEight=am,d.httpRequestOperationRefFive=tm,d.httpRequestOperationRefFour=em,d.httpRequestOperationRefNine=sm,d.httpRequestOperationRefSeven=im,d.httpRequestOperationRefSix=nm,d.httpRequestOperationRefThree=Qh,d.httpRequestOperationRefTwo=Xh,d.httpRequestQueryParamsArgument=Dl,d.httpRequestQueryParamsArgumentRef=Mh,d.httpRequestQueryParamsDataType=Vh,d.httpRequestVariableURLArgument=rs,d.httpRequestVariableURLArgumentRef=_h,d.httpRequestVariableURLDataType=Nh,d.httpRequestVariableURLDataTypeRef=Bh,d.httpResponseBodyReturnDataType=Kh,d.httpResponseBodyReturnDataTypeRef=zh,d.httpResponseBodyReturnReturn=ls,d.httpResponseBodyReturnReturnRef=Zh,d.httpResponseCodeDataType=Jh,d.httpResponseCodeReturn=ss,d.httpResponseCodeReturnRef=qh,d.httpResponseHeadersDataType=Yh,d.httpResponseHeadersDataTypeRef=Wh,d.httpResponseHeadersReturn=os,d.httpResponseHeadersReturnRef=Hh,d.implement=Jo,d.inferArgumentDeclarationDataType=EP,d.inferDataType=un,d.inferInputMapDataType=pu,d.inferOutputMapDataType=fu,d.inferPropertyDataType=gP,d.inferReturnDeclarationDataType=yu,d.inferValueDescriptorDataType=vP,d.inferVariableDeclarationDataType=RP,d.inferVariableInstanceDataType=bP,d.initProject=IA,d.iterateOverListActionDescriptorListArgumentDeclaration=Im,d.iterateOverListActionDescriptorListArgumentDeclarationDataType=gm,d.iterateOverListActionDescriptorListArgumentDeclarationDataTypeParentRef=Rm,d.iterateOverListActionDescriptorListArgumentDeclarationParentRef=vm,d.iterateOverListLoopActionDescriptor=sr,d.iterateOverListLoopActionDescriptorDynamicReturnDeclaration=Pm,d.iterateOverListLoopActionDescriptorDynamicReturnDeclarationParentRef=Dm,d.iterateOverListLoopBodyActionDescriptor=ds,d.iterateOverListLoopBodyActionDescriptorAnyDynamicArgument=Mm,d.iterateOverListLoopBodyActionDescriptorAnyDynamicArgumentParentRef=Nm,d.iterateOverListLoopBodyActionDescriptorAnyDynamicReturn=Lm,d.iterateOverListLoopBodyActionDescriptorAnyDynamicReturnParentRef=Vm,d.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclaration=cs,d.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=Om,d.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=Am,d.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=Sm,d.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclaration=_m,d.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=Bm,d.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=Cm,d.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=wm,d.iterateOverObjectKeysActionDescriptorObjectArgumentDeclaration=iT,d.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataType=nT,d.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataTypeParentRef=tT,d.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationParentRef=rT,d.iterateOverObjectKeysLoopActionDescriptor=ki,d.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclaration=sT,d.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclarationParentRef=aT,d.iterateOverObjectKeysLoopBodyActionDescriptor=ET,d.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgument=hT,d.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgumentParentRef=fT,d.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturn=TT,d.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturnParentRef=mT,d.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclaration=_l,d.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=lT,d.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=oT,d.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=cT,d.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclaration=yT,d.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=uT,d.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=dT,d.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=pT,d.iterateOverObjectValuesActionDescriptorObjectArgumentDeclaration=IT,d.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataType=gT,d.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataTypeParentRef=RT,d.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationParentRef=vT,d.iterateOverObjectValuesLoopActionDescriptor=qi,d.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclaration=PT,d.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclarationParentRef=DT,d.iterateOverObjectValuesLoopBodyActionDescriptor=GT,d.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgument=MT,d.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgumentParentRef=NT,d.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturn=LT,d.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturnParentRef=VT,d.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Nl,d.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=OT,d.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=AT,d.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=ST,d.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclaration=_T,d.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=BT,d.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=CT,d.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=wT,d.iterateOverStringActionDescriptorDynamicReturnDeclaration=km,d.iterateOverStringActionDescriptorDynamicReturnDeclarationParentRef=jm,d.iterateOverStringActionDescriptorStringArgumentDeclaration=xm,d.iterateOverStringActionDescriptorStringArgumentDeclarationDataType=Fm,d.iterateOverStringActionDescriptorStringArgumentDeclarationDataTypeParentRef=$m,d.iterateOverStringActionDescriptorStringArgumentDeclarationParentRef=Um,d.iterateOverStringLoopActionDescriptor=us,d.iterateOverStringLoopBodyActionDescriptor=wl,d.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgument=Km,d.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgumentParentRef=Zm,d.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturn=Qm,d.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturnParentRef=Xm,d.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Cl,d.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=Jm,d.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=qm,d.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=Wm,d.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Bl,d.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=Ym,d.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=Hm,d.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=zm,d.joinListOperation=fl,d.joinListOperationError=_y,d.joinListOperationErrorParentRef=wy,d.joinListOperationFirstListArgument=Ay,d.joinListOperationFirstListArgumentParentRef=Py,d.joinListOperationFirstListArgumentRef=by,d.joinListOperationFirstListDataType=Ry,d.joinListOperationResultListDataType=Dy,d.joinListOperationResultListReturn=By,d.joinListOperationResultListReturnParentRef=Cy,d.joinListOperationResultListReturnRef=Iy,d.joinListOperationSecondListArgument=Sy,d.joinListOperationSecondListArgumentParentRef=Oy,d.joinListOperationSecondListArgumentRef=gy,d.joinListOperationSecondListDataType=vy,d.joinListWithLastSeparator=U,d.joinStringsOperation=Ui,d.joinStringsOperationDynamicStringArgument=Xp,d.joinStringsOperationDynamicStringArgumentParentRef=Kp,d.joinStringsOperationDynamicStringArgumentRef=zp,d.joinStringsOperationDynamicStringDataType=Zp,d.joinStringsOperationError=Yp,d.joinStringsOperationErrorParentRef=Hp,d.joinStringsOperationFirstStringArgument=Qa,d.joinStringsOperationFirstStringArgumentParentRef=$p,d.joinStringsOperationFirstStringArgumentRef=_p,d.joinStringsOperationFirstStringDataType=Np,d.joinStringsOperationResultStringDataType=Gp,d.joinStringsOperationResultStringReturn=Fi,d.joinStringsOperationResultStringReturnParentRef=Wp,d.joinStringsOperationResultStringReturnRef=Lp,d.joinStringsOperationSecondStringArgument=es,d.joinStringsOperationSecondStringArgumentParentRef=Jp,d.joinStringsOperationSecondStringArgumentRef=Mp,d.joinStringsOperationSecondStringDataType=Vp,d.joinStringsOperationSeparatorStringArgument=qp,d.joinStringsOperationSeparatorStringArgumentParentRef=kp,d.joinStringsOperationSeparatorStringArgumentRef=Fp,d.joinStringsOperationSeparatorStringDataType=jp,d.joinStringsOperationSeparatorStringDataTypeDefaultValue=xp,d.joinStringsOperationSeparatorStringDataTypeDefaultValueParentRef=Up,d.keyValuePrototype=$i,d.lowercaseFirstLetter=_o,d.manualFlowActionDescriptorDeclarationArgumentDeclaration=Ol,d.manualFlowActionDescriptorDeclarationArgumentDeclarationDataType=ym,d.manualFlowActionDescriptorDeclarationArgumentDeclarationDataTypeParentRef=pm,d.manualFlowActionDescriptorDeclarationArgumentDeclarationParentRef=fm,d.manualFlowLoopActionDescriptor=Al,d.manualFlowLoopActionDescriptorDynamicReturnDeclaration=um,d.manualFlowLoopActionDescriptorDynamicReturnDeclarationParentRef=dm,d.manualFlowLoopBodyActionDescriptor=Sl,d.manualFlowLoopBodyActionDescriptorAnyDynamicArgument=mm,d.manualFlowLoopBodyActionDescriptorAnyDynamicArgumentParentRef=hm,d.manualFlowLoopBodyActionDescriptorAnyDynamicReturn=Em,d.manualFlowLoopBodyActionDescriptorAnyDynamicReturnParentRef=Tm,d.mapActionDescriptorToTypeItRepresents=J7,d.mergeEntityErrorsList=M9,d.mergeListOfEntities=k7,d.methodDefaultValue=Gh,d.mockClientProject=MI,d.moreThanOrEqualCondition=ri,d.moreThanOrEqualConditionLeftHandArgument=vb,d.moreThanOrEqualConditionLeftHandArgumentDataType=Rb,d.moreThanOrEqualConditionLeftHandArgumentDataTypeParentRef=bb,d.moreThanOrEqualConditionLeftHandArgumentParentRef=gb,d.moreThanOrEqualConditionRightHandArgument=Ab,d.moreThanOrEqualConditionRightHandArgumentDataType=Db,d.moreThanOrEqualConditionRightHandArgumentDataTypeParentRef=Ib,d.moreThanOrEqualConditionRightHandArgumentParentRef=Pb,d.notEmptyCondition=ur,d.notEmptyConditionArgument=Tb,d.notEmptyConditionRef=mb,d.nullPrototype=SA,d.numberAdditionOperation=Xa,d.numberAdditionOperationDynamicSummandArgument=fp,d.numberAdditionOperationDynamicSummandArgumentType=yp,d.numberAdditionOperationDynamicSummandArgumentTypeParentRef=pp,d.numberAdditionOperationError=up,d.numberAdditionOperationErrorParentRef=dp,d.numberAdditionOperationFirstNumberArgument=ol,d.numberAdditionOperationFirstNumberArgumentRef=np,d.numberAdditionOperationFirstNumberDataType=rp,d.numberAdditionOperationRef=lp,d.numberAdditionOperationRefThree=cl,d.numberAdditionOperationRefTwo=cp,d.numberAdditionOperationResultNumberDataType=op,d.numberAdditionOperationResultNumberReturn=dl,d.numberAdditionOperationResultNumberReturnRef=sp,d.numberAdditionOperationSecondNumberArgument=ll,d.numberAdditionOperationSecondNumberArgumentRef=ip,d.numberAdditionOperationSecondNumberDataType=ap,d.numberPrototype=Z,d.numberSubtractionOperation=pl,d.numberSubtractionOperationDynamicSubtrahendArgument=Bp,d.numberSubtractionOperationDynamicSubtrahendArgumentType=Cp,d.numberSubtractionOperationDynamicSubtrahendArgumentTypeParentRef=Sp,d.numberSubtractionOperationError=Op,d.numberSubtractionOperationErrorParentRef=Ap,d.numberSubtractionOperationFirstNumberArgument=gp,d.numberSubtractionOperationFirstNumberArgumentRef=hp,d.numberSubtractionOperationFirstNumberDataType=mp,d.numberSubtractionOperationRef=ul,d.numberSubtractionOperationRefThree=Dp,d.numberSubtractionOperationRefTwo=vp,d.numberSubtractionOperationResultNumberDataType=Rp,d.numberSubtractionOperationResultNumberReturn=Pp,d.numberSubtractionOperationResultNumberReturnRef=bp,d.numberSubtractionOperationSecondNumberArgument=Ip,d.numberSubtractionOperationSecondNumberArgumentRef=Tp,d.numberSubtractionOperationSecondNumberDataType=Ep,d.numberValueAutogenerationSchema=cd,d.parallelExecutionOperation=Wt,d.parallelExecutionOperationError=Vf,d.parallelExecutionOperationErrorParentRef=Mf,d.parallelExecutionOperationListOfExecutionResultsDataType=wf,d.parallelExecutionOperationListOfExecutionResultsReturn=gl,d.parallelExecutionOperationListOfExecutionResultsReturnRef=Bf,d.parallelExecutionOperationListOfFunctionsArgument=Rl,d.parallelExecutionOperationListOfFunctionsArgumentDatatype=Cf,d.parallelExecutionOperationListOfFunctionsArgumentRef=Sf,d.parallelExecutionOperationListOfFunctionsBlueprint=Of,d.parallelExecutionOperationListOfFunctionsBlueprintDynamicInput=Af,d.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutput=Pf,d.parallelExecutionOperationRef=_f,d.parallelExecutionOperationRefThree=Nf,d.persistedBuiltInBaseEntity=nt,d.persistedBuiltInBaseEntityDatabaseProperty=ei,d.persistedBuiltInBaseEntityDatabasePropertyDataTypeRef=UA,d.persistedBuiltInBaseEntityDatabasePropertyParentRef=QE,d.persistedBuiltInBaseEntityDatabasePropertyRef=XE,d.persistedBuiltInBaseEntityPrimaryKeyProperty=ti,d.persistedBuiltInBaseEntityPrimaryKeyPropertyDataType=ob,d.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOption=tb,d.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOptionParentRef=eb,d.persistedBuiltInBaseEntityPrimaryKeyPropertyParentRef=lb,d.persistedBuiltInBaseEntityPrimaryKeyPropertyRef=sb,d.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOption=rb,d.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOptionParentRef=nb,d.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOption=ab,d.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOptionParentRef=ib,d.processOutputGlobalValueDescriptorDataType=Cb,d.processOutputGlobalValueDescriptorReturn=ec,d.processOutputGlobalValueDescriptorReturnRef=Sb,d.projectPublicationCompletedGlobalEvent=Es,d.propertyToZodSchema=qb,d.relationalDatabaseBuiltInBaseEntity=bn,d.relationalDatabaseBuiltInBaseEntityAutoscalingProperty=Hl,d.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataTypeRef=YE,d.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyParentRef=zE,d.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyRef=HE,d.relationalDatabaseBuiltInBaseEntityDefaultProperty=Wl,d.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataTypeRef=JE,d.relationalDatabaseBuiltInBaseEntityDefaultPropertyRef=WE,d.relationalDatabaseBuiltInBaseEntityIdentifierProperty=fs,d.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataTypeRef=FE,d.relationalDatabaseBuiltInBaseEntityIdentifierPropertyRef=UE,d.relationalDatabaseBuiltInBaseEntityMinSizeProperty=Ts,d.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataTypeRef=kE,d.relationalDatabaseBuiltInBaseEntityMinSizePropertyRef=qE,d.relationalDatabaseBuiltInBaseEntityPasswordProperty=ms,d.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataTypeRef=VA,d.relationalDatabaseBuiltInBaseEntityPasswordPropertyRef=jE,d.relationalDatabaseBuiltInBaseEntityRef=Qr,d.relationalDatabaseBuiltInBaseEntityUsernameProperty=hs,d.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataTypeRef=NA,d.relationalDatabaseBuiltInBaseEntityUsernamePropertyRef=xE,d.resolveActionDescriptorName=SP,d.resolveBaseEntityName=DP,d.resolveBuiltInBaseEntityDataTypeLabel=PP,d.resolveConditionOperatorLabel=Vo,d.resolveCustomEntityDataTypeLabel=I2,d.resolveDataType=No,d.resolveDataTypeEntityOrNestedChildrenFromLiteralValue=Mu,d.resolveDataTypeLabel=ka,d.resolveEntityDataTypeLabel=v2,d.resolveEntityName=C,d.resolveFirstCallsSecond=_7,d.resolveFirstWritesSecond=N7,d.resolvePrimaryKeyProperty=Y7,d.resolvePrimitiveEntityName=OP,d.resolveSearchName=AP,d.resolveVariableScope=b2,d.sequentialExecutionOperation=En,d.sequentialExecutionOperationError=th,d.sequentialExecutionOperationErrorParentRef=eh,d.sequentialExecutionOperationListOfExecutionResultsDataType=Kf,d.sequentialExecutionOperationListOfExecutionResultsReturn=Il,d.sequentialExecutionOperationListOfExecutionResultsReturnParentRef=Qf,d.sequentialExecutionOperationListOfExecutionResultsReturnRef=Zf,d.sequentialExecutionOperationListOfFunctionsArgument=vl,d.sequentialExecutionOperationListOfFunctionsArgumentDatatype=zf,d.sequentialExecutionOperationListOfFunctionsArgumentParentRef=Xf,d.sequentialExecutionOperationListOfFunctionsArgumentRef=Yf,d.sequentialExecutionOperationListOfFunctionsBlueprint=Hf,d.sequentialExecutionOperationListOfFunctionsBlueprintDynamicInput=Wf,d.sequentialExecutionOperationListOfFunctionsBlueprintDynamicOutput=Jf,d.softDeletePersistedEntityMethod=jA,d.softDeletePersistedEntityMethodParentRef=cb,d.sortCallsBasedOnExecutionDependencies=ZP,d.sortChildrenEntitiesBasedOnExecutionDependencies=B7,d.splitListOperation=ml,d.splitListOperationError=Zy,d.splitListOperationErrorParentRef=zy,d.splitListOperationFirstOutputListDataType=Fy,d.splitListOperationFirstOutputListReturn=Jy,d.splitListOperationFirstOutputListReturnParentRef=qy,d.splitListOperationFirstOutputListReturnRef=hl,d.splitListOperationInputListArgument=xy,d.splitListOperationInputListArgumentParentRef=Uy,d.splitListOperationInputListArgumentRef=Vy,d.splitListOperationInputListDataType=Ly,d.splitListOperationSecondOutputListDataType=Wy,d.splitListOperationSecondOutputListReturn=Yy,d.splitListOperationSecondOutputListReturnParentRef=Hy,d.splitListOperationSplitIndexArgument=ky,d.splitListOperationSplitIndexArgumentParentRef=jy,d.splitListOperationSplitIndexArgumentRef=Gy,d.splitListOperationSplitIndexDataType=$y,d.splitStringOperation=yl,d.splitStringOperationError=hy,d.splitStringOperationErrorParentRef=fy,d.splitStringOperationFirstPartResultStringDataType=iy,d.splitStringOperationFirstPartResultStringReturn=yy,d.splitStringOperationFirstPartResultStringReturnParentRef=py,d.splitStringOperationFirstPartResultStringReturnRef=ry,d.splitStringOperationIndexArgument=dy,d.splitStringOperationIndexArgumentParentRef=cy,d.splitStringOperationIndexArgumentRef=ty,d.splitStringOperationIndexDataType=ny,d.splitStringOperationSecondPartResultStringDataType=sy,d.splitStringOperationSecondPartResultStringReturn=CA,d.splitStringOperationSecondPartResultStringReturnParentRef=uy,d.splitStringOperationSecondPartResultStringReturnRef=ay,d.splitStringOperationStringArgument=ly,d.splitStringOperationStringArgumentParentRef=oy,d.splitStringOperationStringArgumentRef=Qp,d.splitStringOperationStringDataType=ey,d.stringPrototype=x,d.stringValueAutogenerationSchema=ld,d.suggestNewIdForEntity=gu,d.test_primitive_entities_export=Rq,d.toCamelCase=R2,d.toEntityState=Mt,d.toKebabCase=IP,d.toLowerCaseKebabCase=Mo,d.toPascalCase=g2,d.untypedDataPrototype=Ke,d.updateErrorsList=ie,d.updateValueReader=Za,d.urlDefaultValue=wh,d.uuidPrototype=Ln,d.validateArgumentDeclarationName=bu,d.validateCalledByErrorIdInAction=g7,d.validateCalledByIdInAction=R7,d.validateCallers=$P,d.validateConditionEntityDeclaration=D7,d.validateCustomEntityName=Lo,d.validateDataOperation=ar,d.validateDataOperationDataToValidateArgument=Rh,d.validateDataOperationDataToValidateArgumentParentRef=bh,d.validateDataOperationDataToValidateArgumentRef=Th,d.validateDataOperationDataToValidateDataType=Eh,d.validateDataOperationEntityToMatchTypeArgument=Dh,d.validateDataOperationEntityToMatchTypeArgumentParentRef=Ih,d.validateDataOperationEntityToMatchTypeArgumentRef=gh,d.validateDataOperationEntityToMatchTypeDataType=vh,d.validateDataOperationError=Sh,d.validateDataOperationErrorParentRef=Oh,d.validateDataOperationOutputEntityDeclaration=Ah,d.validateDataOperationOutputEntityDeclarationParentRef=Ph,d.validateEntryCaller=GP,d.validateErrorCaller=LP,d.validateFunctionCallDeclaration=UP,d.validateFunctionDeclarationName=mu,d.validateGeneratedEntityParentIsNotBuiltInEntity=m7,d.validateGeneration=f7,d.validateGenerationTarget=Le,d.validateGenerationUpdate=h7,d.validateLoopEntityDeclaration=P7,d.validateName=D2,d.validateOperationEntityDeclaration=xP,d.validatePropertyName=Eu,d.validateReachability=_n,d.validateReadsValueInActionPayload=v7,d.validateReferenceObject=$o,d.validateReferenceToOne=Pu,d.validateReferences=He,d.validateReturnDeclarationName=Ru,d.validateSuccessCaller=VP,d.validateValueReaderGenerationUpdate=Ha,d.validateValueWritter=wu,d.validateVariableDeclarationName=Tu,d.validateVariableInternalCallUse=_u,d.valueAutogenerationCurrentDateAndTimeSchema=LI,d.valueAutogenerationGenericSchema=ro,d.valueAutogenerationOptions=ud,d.valueAutogenerationOptionsSchema=VI,d.valueAutogenerationRandomBooleanSchema=od,d.valueAutogenerationRandomDateBetweenSchema=JI,d.valueAutogenerationRandomDateFromSchema=kI,d.valueAutogenerationRandomDateSchema=so,d.valueAutogenerationRandomDateUntilSchema=qI,d.valueAutogenerationRandomNumberBetweenSchema=FI,d.valueAutogenerationRandomNumberFromSchema=GI,d.valueAutogenerationRandomNumberSchema=io,d.valueAutogenerationRandomNumberUntilSchema=$I,d.valueAutogenerationRandomSchema=Aa,d.valueAutogenerationRandomTextBetweenSchema=jI,d.valueAutogenerationRandomTextFromSchema=UI,d.valueAutogenerationRandomTextSchema=ao,d.valueAutogenerationRandomTextUntilSchema=xI,d.valueAutogenerationRangeValueTypesSchema=Pa,d.valueAutogenerationUniqueSchema=sd,d.waitOperation=pt,d.waitOperationMillisecondsNumberArgument=rr,d.waitOperationMillisecondsNumberArgumentRef=$f,d.waitOperationMillisecondsNumberDataType=Ff,d.waitOperationOperationError=jf,d.waitOperationOperationErrorParentRef=xf,d.waitOperationRef=Uf,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});