@elyx-code/project-logic-tree 0.0.6143 → 0.0.6144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -51476,7 +51476,8 @@ function cr(n) {
51476
51476
  ...n.calledByEntry || [],
51477
51477
  ...n.calledByError || [],
51478
51478
  ...n.calledBySuccess || []
51479
- ];
51479
+ // Filter out references
51480
+ ].filter((s) => s.type !== r.GenericReference);
51480
51481
  }
51481
51482
  function vZ(n, s = /* @__PURE__ */ new Set(), e = {
51482
51483
  ignoreBuiltInBaseEntities: !1
@@ -400,7 +400,7 @@ All global 'function-declaration' entity ids are:
400
400
  The project currently has no global 'function-declaration' entities that can be called as 'function-call' entities.`;a.push(new b({id:`${i.id}--${T.InvalidReference}`,code:T.InvalidReference,severity:E.Error,message:`Entity of type "${n.FunctionCall}" with id "${i.id}", has an invalid reference at the 'declaration' property. The 'declaration' property must be a valid reference to an 'function-declaration' entity.
401
401
  References can either be an ID string or an object with exacly four properties: 'id', 'entityId', 'entityType', 'type'.${d}`,issue:null}))}return{errors:a,modifiedData:i}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${T.InvalidParentUpdate}`,code:T.InvalidParentUpdate,severity:E.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.
402
402
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
403
- 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}}hydrateAncestors(){const e=[],t=[],i=[];if(this.initialData.parent){const a=P(this.initialData.parent),o=this.project.get(a);o&&(this.setParent(o),e.push(o))}if(this.initialData.declaration){const a=P(this.initialData.declaration),o=this.project.get(a);o&&(this.setDeclaration(o),e.push(o))}return this.initialData.calledByEntry.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addEntryCaller(l),e.push(l))}),this.initialData.calledBySuccess.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addSuccessCaller(l),e.push(l))}),this.initialData.calledByError.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addErrorCaller(l),e.push(l))}),{updated:m(e),added:m(t),removed:m(i),self:this}}afterAllChildrenInitialized(){const e=[],t=[],i=[];this.initialized=!0;const{updated:a,added:o,removed:l}=this.syncMissingFixedInputs(),{updated:d,added:h,removed:y}=this.syncMissingFixedOutputs();return e.push(...a,...d),t.push(...o,...h),i.push(...l,...y),{updated:m(e),added:m(t),removed:m(i),self:this}}addSelfToProject(){var a;const e=[this],t=[],i=[];return this.parent===this.project&&this.project.addFunctionCall(this),(a=this.process)==null||a.writesValues.forEach(o=>{o.setValueWriter(this.process),e.push(o)}),this.successCalls.forEach(o=>{o.addSuccessCaller(this),e.push(o)}),this.errorCalls.forEach(o=>{o.addErrorCaller(this),e.push(o)}),this.calledBySuccess.forEach(o=>{o.addSuccessCall(this),e.push(o)}),this.calledByError.forEach(o=>{o.addErrorCall(this),e.push(o)}),this.calledByEntry.forEach(o=>{o.addCall(this),e.push(o)}),{updated:m(e),added:m(t),removed:m(i),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(i=>i.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(i=>i.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 i=this.errorCalls.findIndex(a=>a.id===e.id);return i>-1&&this.errorCalls.splice(i,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}setDeclaration(e){return this.declaration=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===n.FunctionDeclaration){const e=I(this.initialData.declaration,this.project);this.declaration=e}else{const e=P(this.initialData.declaration),t=this.project.get(e);this.declaration=t}return this.successCalls=this.initialData.successCalls.map(e=>{const t=I(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=I(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=I(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=I(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.error&&(this.error=I(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.afterAllChildrenInitialized(),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return super.sync(e),this.x=e.x||this.x,this.y=e.y||this.y,this}async load(e=N,...t){return await Ge.repository.load(this.id,...t),this}async create(e=N,...t){return await Ge.repository.create(this.toShallowJSON(),...t),this}async update(e=N,...t){return await Ge.repository.update(this.toShallowJSON(),...t),this}async delete(e=N,...t){return await Ge.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var o;const i=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:l,removed:d}=(o=this.process)==null?void 0:o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}if(this.inputs.forEach(l=>{const{affected:d,removed:h}=l.remove({ignoreUpstream:!0,seenEntities:t});i.push(...d),a.push(...h)}),this.outputs.forEach(l=>{const{affected:d,removed:h}=l.remove({ignoreUpstream:!0,seenEntities:t});i.push(...d),a.push(...h)}),this.error){const{affected:l,removed:d}=this.error.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}return this.successCalls.forEach(l=>{i.push(l),l.removeCaller(this)}),this.errorCalls.forEach(l=>{i.push(l),l.removeCaller(this)}),e||this.calledBy.forEach(l=>{i.push(l),l.removeCall(this)}),{affected:m(i),removed:m(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:i}=this.process.restore({seenEntities:e});t.push(...i)}return this.inputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(i=>{t.push(i),i.addSuccessCaller(this)}),this.errorCalls.forEach(i=>{t.push(i),i.addErrorCaller(this)}),this.calledBySuccess.forEach(i=>{t.push(i),i.addSuccessCall(this)}),this.calledByError.forEach(i=>{t.push(i),i.addErrorCall(this)}),this.calledByEntry.forEach(i=>{t.push(i),i.addCall(this)}),{affected:m(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[],...this.calledBy.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e))])}toJSON(e=new Set){var t,i;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(a=>a.toJSON(e)),errorCalls:this.errorCalls.map(a=>a.toJSON(e)),calledBySuccess:this.calledBySuccess.map(a=>a.toReference()),calledByError:this.calledByError.map(a=>a.toReference()),calledByEntry:this.calledByEntry.map(a=>a.toReference()),process:(t=this.process)==null?void 0:t.toJSON(e),declaration:this.declaration.toJSON(e),inputs:this.inputs.map(a=>a.toJSON(e)),outputs:this.outputs.map(a=>a.toJSON(e)),parent:this.parent.toReference(),error:(i=this.error)==null?void 0:i.toJSON(e)})}toJSONClone(e=$){var i,a,o,l,d,h,y;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||at(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(a=e.seenEntities)!=null&&a.has(t)||(o=e.seenEntities)!=null&&o.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((l=e.seenEntities)==null||l.add(t),(d=e.seenEntities)==null||d.add(this.id),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(f=>f.toJSONClone({...e,newId:null})),errorCalls:this.errorCalls.map(f=>f.toJSONClone({...e,newId:null})),calledBySuccess:this.calledBySuccess.map(f=>f.toReference({seenEntityMaps:e.seenEntityMaps})),calledByError:this.calledByError.map(f=>f.toReference({seenEntityMaps:e.seenEntityMaps})),calledByEntry:this.calledByEntry.map(f=>f.toReference({seenEntityMaps:e.seenEntityMaps})),process:(h=this.process)==null?void 0:h.toJSONClone({...e,newId:null}),declaration:this.declaration.toJSONClone({...e,newId:null}),inputs:this.inputs.map(f=>f.toJSONClone({...e,newId:null})),outputs:this.outputs.map(f=>f.toJSONClone({...e,newId:null})),error:(y=this.error)==null?void 0:y.toJSONClone({...e,newId:null}),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+B.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference(e):null,inputs:this.inputs.map(a=>a.toReference(e)),outputs:this.outputs.map(a=>a.toReference(e)),declaration:this.declaration.toReference(e),successCalls:this.successCalls.map(a=>a.toReference(e)),errorCalls:this.errorCalls.map(a=>a.toReference(e)),calledBySuccess:this.calledBySuccess.map(a=>a.toReference(e)),calledByError:this.calledByError.map(a=>a.toReference(e)),calledByEntry:this.calledByEntry.map(a=>a.toReference(e)),error:this.error?this.error.toReference(e):null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(i=>i.toFlatJSON(e)),...this.errorCalls.flatMap(i=>i.toFlatJSON(e)),...this.inputs.flatMap(i=>i.toFlatJSON(e)),...this.outputs.flatMap(i=>i.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,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,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(i=>i.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(i=>i.toFlatGenerationTarget(e)),...this.inputs.flatMap(i=>i.toFlatGenerationTarget(e)),...this.outputs.flatMap(i=>i.toFlatGenerationTarget(e)),...this.process?this.process.toFlatGenerationTarget(e):[],...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(i=>i.clearErrors()),this.outputs.forEach(i=>i.clearErrors()),this.successCalls.forEach(i=>i.clearErrors()),this.errorCalls.forEach(i=>i.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=nq(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=null,t=null,i=!0){var R,A;let a=st(e,this);const o=this.toJSON(),l=t||Fe(C(this,this.project),n.FunctionCall,a);o.inputs=[];const d=l.split("-id"),h=d[d.length-1||0]||l;o.id=l;const y=nt(o,a);e?y.setParent(e):y.setParent(this.parent),i&&y.subscribe(),y.initChildren();const f=(R=this.inputs)==null?void 0:R.map((D,g)=>D.clone(y,h+"-input-map-"+g+"-id",i));y.inputs=f;const v=(A=this.outputs)==null?void 0:A.map((D,g)=>D.clone(y,h+"-output-map-"+g+"-id",i));return y.outputs=v,this.error&&(y.error=this.error.clone(y,h+"-error-map-id",i)),this.process&&(y.process=this.process.clone(y,h+"-process-id",i)),y}removeUnrecognizedInputs(){const e=[],t=[],i=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(l=>{var d;return l.id===((d=a.declaration)==null?void 0:d.id)})){const l=a.remove();i.push(...l.removed),e.push(...l.affected)}}),{updated:m(e),added:m(t),removed:m(i),self:this}}removeUnrecognizedOutputs(){const e=[],t=[],i=[];return this.outputs.forEach(a=>{if(!this.declaration.getUniqueReturnDeclarations().find(l=>{var d;return l.id===((d=a.declaration)==null?void 0:d.id)})){const l=a.remove();i.push(...l.removed),e.push(...l.affected)}}),{updated:m(e),added:m(t),removed:m(i),self:this}}syncMissingFixedInputs(){const e=[],t=[],i=[],a=this.declaration.inputs.filter(h=>!this.inputs.find(y=>y.declaration.id===h.id));this.inputs.sort((h,y)=>h.index-y.index),a.forEach(h=>{this.inputs.forEach(v=>{v.index>=h.index&&v.sync({index:v.index+1})});const y={id:B.UUID.uuid(),version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,type:n.InputMap,declaration:h.toJSON(),readsValue:null,defaultValue:null,index:h.index,name:null,description:null,parent:this.toReference()},f=I(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject(),t.push(f)}),this.inputs.sort((h,y)=>h.index-y.index);const{updated:o,added:l,removed:d}=this.removeUnrecognizedInputs();return e.push(...o),t.push(...l),i.push(...d),{updated:m(e),added:m(t),removed:m(i),self:this}}syncMissingFixedOutputs(){const e=[],t=[],i=[],a=[];this.outputs=this.initialData.outputs.map(y=>{const f=I(y,this.project);return a.push(f.index),f.setParent(this),f.initChildren(),f});const o=this.declaration.getUniqueReturnDeclarations().filter(y=>!this.outputs.find(f=>f.declaration.id===y.id));this.outputs.sort((y,f)=>y.index-f.index),o.forEach((y,f)=>{this.outputs.forEach(D=>{D.index>=y.index&&D.index++});const v=a.includes(y.index)?this.outputs.length-1+f:y.index,R={id:B.UUID.uuid(),version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,type:n.OutputMap,declaration:y.toJSON(),defaultValue:null,writesValues:[],index:v,parent:this.toReference()},A=I(R,this.project);A.setParent(this),A.initChildren(),A.addSelfToProject()}),this.outputs.sort((y,f)=>y.index-f.index);const{updated:l,added:d,removed:h}=this.removeUnrecognizedOutputs();return e.push(...l),t.push(...d),i.push(...h),{updated:m(e),added:m(t),removed:m(i),self:this}}};u(Ge,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),u(Ge,"type",n.FunctionCall),u(Ge,"USER_MANAGED_PARENT_TYPES",[...ut,n.Project]),u(Ge,"PARENT_TYPES",[...Ge.USER_MANAGED_PARENT_TYPES]),u(Ge,"MUTABLE_BASE_PROPERTIES",[]),u(Ge,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),u(Ge,"BASE_PROPERTIES",[...Ge.MUTABLE_BASE_PROPERTIES,...Ge.INMUTABLE_BASE_PROPERTIES]),u(Ge,"MUTABLE_META_PROPERTIES",["x","y"]),u(Ge,"INMUTABLE_META_PROPERTIES",[...Ge.INMUTABLE_BASE_PROPERTIES]),u(Ge,"META_PROPERTIES",[...Ge.MUTABLE_META_PROPERTIES,...Ge.INMUTABLE_META_PROPERTIES]),u(Ge,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),u(Ge,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),u(Ge,"UPSTREAM_PROPERTIES",[...Ge.MUTABLE_UPSTREAM_PROPERTIES,...Ge.INMUTABLE_UPSTREAM_PROPERTIES]),u(Ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),u(Ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),u(Ge,"DOWNSTREAM_PROPERTIES",[...Ge.MUTABLE_DOWNSTREAM_PROPERTIES,...Ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),u(Ge,"PROPERTIES",[...Ge.META_PROPERTIES,...Ge.UPSTREAM_PROPERTIES,...Ge.DOWNSTREAM_PROPERTIES]);let Ei=Ge;function Ip(r){return r&&typeof r.then=="function"}class Ap{constructor(s){u(this,"order",[]);u(this,"flatRecord",{});u(this,"onGoingVisits",{});this.flatten(s),this.orderEntities()}flatten(s){const e=new Set(Cp()),t=m(S(s,e,{ignoreBuiltInBaseEntities:!0})),i=new Set;for(const a of t)this.flatRecord[a.id]=a,i.add(a.id);this.order=Array.from(i)}moveEntityAfterDependencies(s){const e=$l(s,this.flatRecord);for(const t of e){const i=this.order.indexOf(t),a=this.order.indexOf(s.id);if(i>a)return this.order.splice(a,1),this.order.splice(i,0,s.id),!0}return!1}orderEntities(){let s=!1;for(let e=0;e<this.order.length;e++){const t=this.order[e],i=this.flatRecord[t];if(this.moveEntityAfterDependencies(i)){s=!0;break}}s&&this.orderEntities()}getUpstreamOngoingDependenciesVisits(s,e){const t=$l(this.flatRecord[s],this.flatRecord),i={};return Object.entries(this.onGoingVisits[e]||{}).forEach(([a,o])=>{Array.from(t).includes(a)&&(i[a]=o)}),i}getDownstreamOngoingDependenciesVisits(s,e){const t=Object.keys(this.onGoingVisits[e]||{}),i=new Set(t.flatMap(o=>Array.from($l(this.flatRecord[o],this.flatRecord)))),a={};return Array.from(i).forEach(o=>{o===s&&(a[o]=this.onGoingVisits[e][o])}),a}async settlePromises(s,e){const t=Object.values(s);t.length&&await Promise.all(t),Object.keys(s).forEach(i=>{delete this.onGoingVisits[e][i]})}visit(s){const e=this.order;for(const t of e)s(this.flatRecord[t],this.flatRecord);return this}reverseVisit(s){const e=this.order.slice().reverse();for(const t of e)s(this.flatRecord[t],this.flatRecord);return this}async visitAsync(s){const e=this.order,t=Math.random().toString(36).substring(7);this.onGoingVisits[t]={};for(const i of e){const a=this.getUpstreamOngoingDependenciesVisits(i,t);Object.keys(a).length&&await this.settlePromises(a,t);const o=s(this.flatRecord[i],this.flatRecord);Ip(o)&&(this.onGoingVisits[t][i]=o)}return await this.settlePromises(this.onGoingVisits[t],t),this.onGoingVisits[t]={},this}async reverseVisitAsync(s){const e=this.order.slice().reverse(),t=Math.random().toString(36).substring(7);this.onGoingVisits[t]={};for(const i of e){const a=this.getDownstreamOngoingDependenciesVisits(i,t);Object.keys(a).length&&await this.settlePromises(a,t);const o=s(this.flatRecord[i],this.flatRecord);Ip(o)&&(this.onGoingVisits[t][i]=o)}return await this.settlePromises(this.onGoingVisits[t],t),this.onGoingVisits[t]={},this}}function rD(r){var s;switch(r.id){case _["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const e=r.project.entities.filter(d=>!!d.implements.find(h=>h.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));if(e.find(d=>!!d.properties.find(h=>{var y;return h.implements&&h.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((y=h.getDefaultValue())==null?void 0:y.value)===!0}))){const h=e[0].properties.find(f=>f.implements&&f.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=h==null?void 0:h.defaultValue;if(y)y.value=!0;else if(h!=null&&h.dataType){const f=(s=h==null?void 0:h.dataType)==null?void 0:s.id.split("-id")[0],v=I({id:f+"-default-value-id",version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.LiteralValue,name:V.EntityTemplate,autogeneration:null,value:!0,valueAsType:null,parent:h==null?void 0:h.dataType.toReference()},r.project);return v.setParent(h==null?void 0:h.dataType),v.initChildren(),v.addSelfToProject(),{newEntities:[v]}}return{newEntities:[]}}const i=r.project.get(_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),a=Ml(i,"Main database");if(a.errors.length>0)return{newEntities:[]};const o=a.implemented.properties.find(d=>d.implements&&d.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),l=o==null?void 0:o.defaultValue;if(l)l.value=!0;else if(o!=null&&o.dataType){const d=o==null?void 0:o.dataType.id.split("-id")[0],h=I({id:d+"-default-value-id",version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.LiteralValue,name:V.EntityTemplate,autogeneration:null,value:!0,valueAsType:null,parent:o==null?void 0:o.dataType.toReference()},r.project);h.setParent(o==null?void 0:o.dataType),h.initChildren(),h.addSelfToProject()}return{newEntities:[a.implemented]}}}return{newEntities:[]}}function iD(r){return r.implements.filter(e=>e.type===n.BuiltInBaseEntity).map(e=>{switch(e.id){case _["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=r.project.entities.filter(l=>l.implements.find(d=>d.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)).find(l=>!!l.properties.find(d=>{var h;return d.implements&&d.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((h=d.getDefaultValue())==null?void 0:h.value)===!0}));if(!i)return{newEntities:[]};const a=r.properties.find(l=>l.implements&&l.implements.id===_["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),o=a==null?void 0:a.defaultValue;if(a&&(a!=null&&a.dataType)&&!o){const l=a==null?void 0:a.dataType.id.split("-id")[0],d=I({id:l+"-default-value-id",version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.LiteralValue,name:V.EntityTemplate,autogeneration:null,value:null,valueAsType:i,parent:a==null?void 0:a.dataType.toReference()},r.project);return d.setParent(a==null?void 0:a.dataType),d.initChildren(),d.addSelfToProject(),{newEntities:[d]}}return{newEntities:[]}}}}),{newEntities:[]}}function Ml(r,s,e){const t=e||Fe(s,n.DefinitionEntity,r.project),i=t.split("-id"),a=i[i.length-1||0]||t,o={id:t,version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,name:s,type:n.DefinitionEntity,description:null,static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[r],x:0,y:0,parent:r.project},l=Al(o,r.project);if(l.length>0)return{errors:l,implemented:null,entitiesChanges:{new:[],updated:[],deleted:[]}};const d=rD(r),h=I(o,r.project);h.setParent(r.project),h.initChildren();const y=r.properties.map(R=>{const A=a+"-"+Fe(C(R,r.project),n.Property,r.project),D=R.clone(h,A);return D.abstract=!1,D.implements=R,D.setParent(h),h.addProperty(D),D}),f=r.abstractMethods.map(R=>{const A=a+Fe(R.name,n.FunctionDeclaration,r.project),D=R.implementAsFunctionDeclaration(A),g={id:A+"-parent-ref-id",type:n.GenericReference,entityId:t,version:"1",entityType:n.DefinitionEntity},M={...D,implements:R,parent:g},Z=I(M,r.project);return h.addMethod(Z),Z.setParent(h),Z.initChildren(),Z.implements=R,Z});o.properties=y,o.methods=f;const v=iD(h);return{implemented:h,errors:[],entitiesChanges:{new:[h,...d.newEntities,...v.newEntities],updated:[h],deleted:[]}}}function Dp(r,s){return s.entities.find(i=>{const a=i.properties,o=a.map(f=>f.name),l=r.every(f=>o.includes(f)),d=o.filter(f=>!r.includes(f)),h=a.every(f=>!d.includes(f.name)||!f.required);return l&&h})||null}function aD(r,s,e=ft.OrDataTypeGroup){const t=[],i=[],a=[],l={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:r.toJSON(),isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parentRelationType:e,parent:s.toReference()},d=I(l,r.project);return i.push(d),d.setParent(s),d.initChildren(),d.setEntity(r),d.addSelfToProject(),{updated:m(t),added:m(i),removed:m(a),self:d}}function Pp(r,s,e,t){const i=[],a=[],o=[];switch(typeof r){case"string":let l=!1;const d=new Date(r);if(d instanceof Date&&!isNaN(d.valueOf())&&(l=!0),l){const h=s.project.getBuiltIn(_[n.PrimitiveEntity][V.Date].id);s.setEntity(h);break}else{const h=s.project.getBuiltIn(_[n.PrimitiveEntity][V.String].id);s.setEntity(h);break}case"number":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Number].id));break;case"boolean":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Boolean].id));break;case"object":if(r===null){s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Null].id));break}else if(Array.isArray(r))if(s.sync({isList:!0}),r.length>0){const h=r.slice(0,5).filter(f=>f!==void 0);if(h.every(f=>typeof f==typeof h[0])&&(typeof h[0]!="object"||h[0]===null))switch(typeof h[0]){case"string":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.String].id));break;case"number":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Number].id));break;case"boolean":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Boolean].id));break;case"object":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Null].id));break}else{const f=[];let v=!1;h.forEach(A=>{if(Array.isArray(A)&&(v=!0),typeof A=="object"&&!Array.isArray(A)&&A!==null){const D=_l(A,s.project,{...e,id:B.UUID.uuid()},t);D.hasCreated&&f.push(D.changeSet.self),i.push(...D.changeSet.updated),a.push(...D.changeSet.added),o.push(...D.changeSet.removed)}});const R=m(f);if(!R.length&&!v){h.forEach(A=>{const D={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parentRelationType:ft.OrDataTypeGroup,parent:s.toReference()},g=I(D,s.project);switch(g.setParent(s),g.initChildren(),g.addSelfToProject(),typeof A){case"string":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.String].id));break;case"number":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.Number].id));break;case"boolean":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.Boolean].id));break;case"object":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.Null].id));break}});break}else R.length===1&&!v?s.setEntity(R[0]):h.forEach(A=>{if(typeof A=="object"&&!Array.isArray(A)&&A!==null){const D=Dp(Object.keys(A),s.project);if(D){const g=aD(D||R[0],s,ft.OrDataTypeGroup);i.push(...g.updated),a.push(...g.added),o.push(...g.removed)}}else{const D={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:null,isList:Array.isArray(A),asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parentRelationType:ft.OrDataTypeGroup,parent:s.toReference()},g=I(D,s.project);g.setParent(s),g.initChildren(),g.addSelfToProject();const M=Pp(A,g,{...e,id:B.UUID.uuid()},t);i.push(...M.updated),a.push(...M.added),o.push(...M.removed)}})}}else{const h=_l(r[0],s.project,{...e},t);s.setEntity(h.changeSet.self),i.push(...h.changeSet.updated),a.push(...h.changeSet.added),o.push(...h.changeSet.removed);break}else{const h=_l(r,s.project,{...e},t);s.setEntity(h.changeSet.self),i.push(...h.changeSet.updated),a.push(...h.changeSet.added),o.push(...h.changeSet.removed);break}}return{updated:m(i),added:m(a),removed:m(o),self:s}}function _l(r,s,e,t){const i=[],a=[],o=[],l=Object.keys(r),d=Dp(l,s);if(d)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],self:d}};const h=t?e.name+" of "+t.name:e.name,f={id:e.id||Fe(h,n.DefinitionEntity,s),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,name:h,type:n.DefinitionEntity,description:e.description||null,static:e.static||!1,abstract:e.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:s.toReference()},v=I(f,s);return v.setParent(s),v.initChildren(),v.addSelfToProject(),a.push(v),l.forEach((R,A)=>{const g={id:Fe(h+" "+R,n.Property,s),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,name:R,type:n.Property,description:null,static:!1,abstract:!1,defaultValue:null,constant:!1,dataType:null,implements:null,index:A,hidden:!1,private:!1,required:!0,parent:v.toReference()},M=I(g,s);M.setParent(v),M.initChildren(),M.addSelfToProject(),a.push(M);const Z=r[R],ee={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parent:M.toReference()},oe=I(ee,s);oe.setParent(M),oe.initChildren(),oe.addSelfToProject(),a.push(oe);const ue=Pp(Z,oe,{...e,name:R,id:B.UUID.uuid()},t||v);i.push(...ue.updated),a.push(...ue.added),o.push(...ue.removed)}),{hasCreated:!0,changeSet:{updated:m(i),added:m(a),removed:m(o),self:v}}}function Nl(r,s){const e=Ri(r);if(e.length===0)return{list:[],last:null};let t=null;return{list:e.flatMap(a=>{if(a===s)return t=a,[a];const o=Nl(a,s);return o.last&&(t=o.last),[a,...o.list]}),last:t}}function sD(r,s,e=new Set){const t=Or(r),i=Or(s),a=t.filter(d=>!i.includes(d)),o=t.filter(d=>i.includes(d)),l=a.reduce((d,h)=>e.has(h.id)?d:(e.add(h.id),m([...d,...sD(h,s,e)])),[]);return m([...o,...l])}function Is(r,s){const e=Nl(r,s);return e.last===s&&e.list.length>0&&e.list[0]!==s}function rq(r,s){return!!Nl(r,s).last}function iq(r){if(ze.includes(r.type))return r;if([...vn,n.VariableDeclaration].includes(r.type)){const s=r.parent;return ze.includes(s.type)?s:null}return null}function Sp(r,s){if(!r||!s)throw new Error("Both entities must be defined to find a common ancestor");if(r===s)return r;const e=r.parent;if(e){if(e===s)return s;if(e.type===n.Project)return null}else return null;const t=s.parent;if(t){if(t===r)return r;if(t.type===n.Project)return null}else return null;return Sp(e,t)}function At(r){if(Bs.includes(r.type)){if(r.type===n.FunctionDeclaration){const s=r.parent;if(s.type===n.DefinitionEntity)return s;if(s.type===n.Loop)return s}return r}else{const s=r.parent;return s?At(s):null}}function Ll(r,s){const e=As(r,s);if(!e)return null;if(Bs.includes(e.type)){if(e.type===n.FunctionDeclaration){const t=As(e.parent,s);if(t){if(t.type===n.DefinitionEntity)return t;if(t.type===n.Loop)return t}}return e}else{const t=e.parent?As(e.parent,s):null;return t?Ll(t,s):null}}function oD(r){if(!r)return null;if(vn.includes(r.type))return r;const s=r.parent;return s?oD(s):null}function lD(r){if(!r)return null;if(Qe.includes(r.type))return r;const s=r.parent;return s?lD(s):null}function dD(r){if(!r)return null;if(Dn.includes(r.type))return r;const s=r.parent;return s?dD(s):null}function aq(r){return r.type===n.VariableDeclaration?[r]:Qe.includes(r.type)?[...r.inputs,...r.outputs||[]]:et.includes(r.type)?r.outputs:Pi.includes(r.type)||r.type===n.FunctionDeclaration?r.inputs:[]}function sq(r){const s=Or(r),e=[],t=[];Jp.includes(r.type)&&e.push(...Op(r));const i=s.filter(a=>{const o=e.includes(a);return o?!1:vn.includes(a.type)&&!o?(t.push(a),!1):!0});return e.sort((a,o)=>Is(o,a)?-1:0),t.sort((a,o)=>Is(o,a)?-1:0),[...e,...t,...i]}function uD(r){return[...r].sort((s,e)=>Is(e,s)?-1:0)}function oq(r){const s=uD(r),e=[];return s.forEach(t=>{const i=e[e.length-1];if(i){const a=i[i.length-1];Is(t,a)?e.push([t]):i.push(t)}else e.push([t])}),e}function Zt(r){const s=r.map(e=>At(e));return m(s)}function Op(r){return Qe.includes(r.type)?[...Zt(r.successCalls),...Zt(r.errorCalls)]:ze.includes(r.type)?Zt(r.calls):[]}function lq(r,s){return Op(r).includes(s)}function Vp(r){return r.writesValues||[]}function dq(r,s){return Vp(r).includes(s)}function cD(r){var s;return We.includes((s=r==null?void 0:r.readsValue)==null?void 0:s.type)?r.readsValue:null}function uq(r){return r.writesValues}function pD(r=[]){return r.map(cD).filter(s=>!!s)}function Gl(r=[]){return r.map(s=>s.writesValues).flat().filter(s=>We.includes(s.type))}function hD(r=[]){return r.map(s=>s.readsValue).filter(s=>!!s&&We.includes(s.type))}function yD(r){return We.includes(r.type)?r:null}function fD(r){return r.writesValues.map(yD).filter(s=>!!s)}function mD(r=[]){return r.reduce((s,e)=>e.type===n.OutputMap?[...s,...fD(e)]:s,[])}function Xe(r){return Qe.includes(r.type)?[...Un(Zt(r.successCalls)),...Un(Zt(r.errorCalls))]:ze.includes(r.type)?Un(Zt(r.calls)):[]}function cq(r){return Qe.includes(r.type)?[...Un(Zt(r.successCalls)),...Un(Zt(r.errorCalls))]:ze.includes(r.type)?Un(Zt(r.calls)):[]}function TD(r,s=new Set){return r.writesValues.filter(t=>We.includes(t.type)&&!s.has(t.id)).reduce((t,i)=>s.has(i.id)?t:[...t,...xe(i,s)],[])}function vD(r,s=new Set){var t;return(((t=r.readsValue)==null?void 0:t.writesValues)||[]).filter(i=>We.includes(i.type)&&!s.has(i.id)).reduce((i,a)=>s.has(a.id)?i:[...i,...xe(a,s)],[])}function xe(r,s=new Set){if(s.has(r.id))return[];if(r.type===n.ReturnStatement)return hD(r.outputs).reduce((t,i)=>[...t,...xe(i,s)],[]);if(r.type===n.FunctionCall||r.type===n.Operation||r.type===n.Condition)return[...Xe(r).reduce((a,o)=>{const l=At(o);return[...a,...xe(l||o,s)]},[]),...pD(r.inputs),...mD(r.outputs)].reduce((a,o)=>[...a,...xe(o,s)],[]);if(Pi.includes(r.type)){const e=Gl(r.inputs),i=Xe(r).reduce((a,o)=>{const l=At(o);return[...a,...xe(l||o,s)]},[]);return e.push(...i),e.reduce((a,o)=>[...a,...xe(o,s)],[])}if(r.type===n.FunctionDeclaration){const e=[...Gl(r.inputs)],i=Xe(r).reduce((a,o)=>{const l=At(o);return[...a,...xe(l||o,s)]},[]);return e.push(...i),e.reduce((a,o)=>[...a,...xe(o)],[])}if(We.includes(r.type)){s.add(r.id);const t=Xe(r).reduce((i,a)=>{const o=At(a);return[...i,...xe(o||a,s)]},[]);return[r,...t,...vD(r,s),...TD(r,s)]}return[]}function Kt(r,s=new Set){return s.has(r.id)?[]:(s.add(r.id),[...Or(r).reduce((i,a)=>[...i,a,...Kt(a,s)],[])])}function Un(r){return r.reduce((s,e)=>e.type===n.ReturnStatement||e.type===n.ContinueStatement||e.type===n.BreakStatement?[...s,e]:[...s,e,...Xe(e)],[])}function ED(r){const s=r.entities||[],e=[...s,...r.functions||[],...r.events||[],...r.projects||[]],t=s.reduce((d,h)=>[...d,...h.properties],[]),i=s.reduce((d,h)=>[...d,...h.methods],[]),a=i.reduce((d,h)=>[...d,...Gl(h.inputs),...Un(Zt(h.calls)),...h.returnStatements],[]),o=r.functions.reduce((d,h)=>[...d,...Un(Zt(h.calls)),...h.returnStatements],[]),l=r.events.reduce((d,h)=>[...d,...Un(Zt(h.calls)),...h.returnStatements],[]);return[...e,...t,...i,...a,...o,...l]}function RD(r,s){return s.filter(t=>{if(!t)return!1;switch(t.type){case n.FunctionCall:return t.inputs.find(i=>i.id===r.id)!==void 0||t.outputs.find(i=>i.id===r.id)!==void 0;case n.Condition:return t.successCalls.find(i=>i.id===r.id)!==void 0||t.errorCalls.find(i=>i.id===r.id)!==void 0||t.inputs.find(i=>i.id===r.id)!==void 0;case n.Operation:return t.outputs.find(i=>i.id===r.id)!==void 0;case n.VariableDeclaration:return Qe.includes(r.type)?HD(r).find(a=>{var o;return((o=a.readsValue)==null?void 0:o.id)===t.id})!==void 0:!1;case n.DefinitionEntity:return t.properties.find(i=>i.id===r.id)!==void 0||t.methods.find(i=>i.id===r.id)!==void 0;case n.FunctionDeclaration:return t.inputs.find(i=>i.id===r.id)!==void 0||(t.returnStatements.map(i=>i.outputs).flat()||[]).find(i=>i.id===r.id)!==void 0;default:return!1}})}function pq(r){const s=ED(r.project);return RD(r,s)}function As(r,s){return r?typeof r=="string"?s[r]:r.type===n.GenericReference?s[r.entityId]:s[r.id]?s[r.id]:null:null}function hq(r){const s=r,e=r,t=r,i=r,a=r,o=r,l=r,d=r,h=r,y=r,f=r,v=r,R=r,A=[...(s.inputs||[]).flatMap(g=>g),...(f.inputsDeclarations||[]).flatMap(g=>g),...(s.outputs||[]).flatMap(g=>g),...(f.outputsDeclarations||[]).flatMap(g=>g),...(R.internalCalls||[]).flatMap(g=>g),...R.writesValues||[],...R.readsValue?[R.readsValue]:[],...R.declaration?[R.declaration]:[],...v.dataType?[v.dataType]:[],...o.body?[o.body]:[],...v.defaultValue?[v.defaultValue]:[],...(v.calledByEntry||[]).flatMap(g=>g),...(v.calledBySuccess||[]).flatMap(g=>g),...(v.calledByError||[]).flatMap(g=>g),...(v.successCalls||[]).flatMap(g=>g),...(v.errorCalls||[]).flatMap(g=>g),...(t.properties||[]).flatMap(g=>g),...(t.extends||[]).flatMap(g=>g),...(t.methods||[]).flatMap(g=>g),...(t.abstractMethods||[]).flatMap(g=>g),...l.error?[l.error]:[],...l.process?[l.process]:[],...y.throws?[y.throws]:[],...y.parent?[y.parent]:[],...e.entity?[e.entity]:[],...(e.andChildrenGroup||[]).flatMap(g=>g),...(e.orChildrenGroup||[]).flatMap(g=>g),...(d.entities||[]).flatMap(g=>g),...(d.functions||[]).flatMap(g=>g),...(d.functionCalls||[]).flatMap(g=>g),...(d.events||[]).flatMap(g=>g),...(d.conditions||[]).flatMap(g=>g),...(d.operations||[]).flatMap(g=>g),...(d.loops||[]).flatMap(g=>g),...(d.variableDeclarations||[]).flatMap(g=>g),...(d.variableInstances||[]).flatMap(g=>g),...(d.searches||[]).flatMap(g=>g),...(d.projects||[]).flatMap(g=>g),...(i.calls||[]).flatMap(g=>g)];Array.isArray(t.implements)?A.push(...t.implements.flatMap(g=>g)):h.implements&&A.push(h.implements),Array.isArray(a.valueAsType)?A.push(...a.valueAsType.flatMap(g=>g)):a.valueAsType&&A.push(a.valueAsType);const D={};return A.forEach(g=>{const M=g.version,Z=P(g);Z&&(D[Z]=M)}),D}function gD(r,s){const e=[];if(vn.includes(r.type)){ln(r).forEach(a=>{const o=Ll(a,s);o&&e.push(o)});const i=[...r.inputs||[],...r.outputs||[]].map(a=>{const o=As(a,s);return o?KD(o,s):null}).filter(a=>a!==null);e.push(...m(i))}if(We.includes(r.type)){const t=Fl(r);t&&e.push(t)}return m(e)}function Ri(r){const s=[];if(vn.includes(r.type)){r.calledBy.forEach(i=>{const a=At(i);a&&s.push(a)});const t=[...r.inputs||[],...r.outputs||[]].map(i=>Fl(i)).filter(i=>i!==null);s.push(...m(t))}if(We.includes(r.type)){const e=Fl(r);e&&s.push(e)}return m(s)}function ln(r){return[...r.calledByEntry||[],...r.calledByError||[],...r.calledBySuccess||[]]}function bD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[r,...r.inputs.flatMap(t=>S(t,s,e)),...r.outputs.flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.parent?S(r.parent,s,e):[]]}function ID(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[r,...r.defaultValue?S(r.defaultValue,s):[],...r.writesValues.flatMap(t=>S(t,s,e)),...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function AD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[r,...r.outputs.flatMap(t=>S(t,s,e)),...r.throws?S(r.throws,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function DD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[r,...(r.properties||[]).flatMap(t=>S(t,s,e)),...(r.methods||[]).flatMap(t=>S(t,s,e)),...(r.abstractMethods||[]).flatMap(t=>S(t,s,e)),...(r.extends||[]).flatMap(t=>S(t,s,e))]}function PD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Condition)throw new Error("Entity must be a condition to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function SD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[r,...r.outputs.flatMap(t=>S(t,s,e)),...r.throws?S(r.throws,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function OD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[r,...(r.extends||[]).flatMap(t=>S(t,s,e)),...(r.implements||[]).flatMap(t=>S(t,s,e)),...(r.properties||[]).flatMap(t=>S(t,s,e)),...(r.methods||[]).flatMap(t=>S(t,s,e)),...(r.abstractMethods||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function VD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.DataType)throw new Error("Entity must be a data type to be flattened");return[r,...(r.andChildrenGroup||[]).flatMap(t=>S(t,s,e)),...(r.orChildrenGroup||[]).flatMap(t=>S(t,s,e)),...r.entity?S(r.entity,s,e):[],...r.parent?S(r.parent,s,e):[]]}function CD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function wD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.returnStatements||[]).flatMap(t=>S(t,s,e)),...(r.calls||[]).flatMap(t=>S(t,s,e)),...r.implements?S(r.implements,s,e):[],...r.parent?S(r.parent,s,e):[]]}function BD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.calls||[]).flatMap(t=>S(t,s,e)),...(r.returnStatements||[]).flatMap(t=>S(t,s,e)),...r.implements?S(r.implements,s,e):[],...r.parent?S(r.parent,s,e):[]]}function MD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.InputMap)throw new Error("Entity must be an input map to be flattened");return[r,...r.readsValue?S(r.readsValue,s,e):[],...r.declaration?S(r.declaration,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...r.parent?S(r.parent,s,e):[]]}function _D(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[r,...(r.functions||[]).flatMap(t=>S(t,s,e)),...(r.events||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function ND(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...r.parent?S(r.parent,s,e):[]]}function LD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[r,...r.valueAsType?Array.isArray(r.valueAsType)?r.valueAsType.flatMap(t=>S(t,s,e)):S(r.valueAsType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function GD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Loop)throw new Error("Entity must be a loop to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...r.body?S(r.body,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...(r.breakStatements||[]).flatMap(t=>S(t,s,e)),...(r.continueStatements||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function $D(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Operation)throw new Error("Entity must be an operation to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function FD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.OutputMap)throw new Error("Entity must be an output map to be flattened");return[r,...(r.writesValues||[]).flatMap(t=>S(t,s,e)),...r.declaration?S(r.declaration,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...r.parent?S(r.parent,s,e):[]]}function UD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[r,...(r.properties||[]).flatMap(t=>S(t,s,e)),...(r.methods||[]).flatMap(t=>S(t,s,e)),...(r.abstractMethods||[]).flatMap(t=>S(t,s,e))]}function xD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Project)throw new Error("Entity must be a project to be flattened");return[r,...(r.entities||[]).flatMap(t=>S(t,s,e)),...(r.functions||[]).flatMap(t=>S(t,s,e)),...(r.events||[]).flatMap(t=>S(t,s,e)),...(r.projects||[]).flatMap(t=>S(t,s,e)),...(r.variableDeclarations||[]).flatMap(t=>S(t,s,e)),...(r.variableInstances||[]).flatMap(t=>S(t,s,e)),...(r.operations||[]).flatMap(t=>S(t,s,e)),...(r.conditions||[]).flatMap(t=>S(t,s,e)),...(r.functionCalls||[]).flatMap(t=>S(t,s,e)),...(r.projects||[]).flatMap(t=>S(t,s,e)),...(r.loops||[]).flatMap(t=>S(t,s,e)),...(r.searches||[]).flatMap(t=>S(t,s,e))]}function jD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Property)throw new Error("Entity must be a property to be flattened");return[r,...r.defaultValue?S(r.defaultValue,s,e):[],...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function kD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ReturnDeclaration)throw new Error("Entity must be a return declaration to be flattened");return[r,...r.readsValue?S(r.readsValue,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function ZD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[r,...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.throws?S(r.throws,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function qD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Search)throw new Error("Entity must be a search to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputsDeclarations||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputsDeclarations||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function JD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[r,...r.defaultValue?S(r.defaultValue,s,e):[],...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function WD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(r.internalCalls||[]).flatMap(t=>S(t,s,e)),...(r.writesValues||[]).flatMap(t=>S(t,s,e)),...r.readsValue?S(r.readsValue,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function YD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(r.internalCalls||[]).flatMap(t=>S(t,s,e)),...(r.writesValues||[]).flatMap(t=>S(t,s,e)),...r.readsValue?S(r.readsValue,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.declaration?S(r.declaration,s,e):[],...r.parent?S(r.parent,s,e):[]]}function Cp(){const r=new Set;return ZE.flatMap(e=>S(e,r)).map(e=>e.id)}function S(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(!r)throw new Error("Entity must be defined to be flattened");if(r.type===n.GenericReference)return[];if(e.ignoreBuiltInBaseEntities&&(ur.includes(r.type)||Cp().includes(r.id)))return[];if(s.has(r.id))return[];switch(r.type){case n.FunctionCall:return CD(r,s,e);case n.Operation:return $D(r,s,e);case n.Condition:return PD(r,s,e);case n.Loop:return GD(r,s,e);case n.Search:return qD(r,s,e);case n.GlobalEvent:return BD(r,s,e);case n.ReturnStatement:return ZD(r,s,e);case n.ContinueStatement:return SD(r,s,e);case n.BreakStatement:return AD(r,s,e);case n.VariableDeclaration:return WD(r,s,e);case n.DefinitionEntity:return OD(r,s,e);case n.FunctionDeclaration:return wD(r,s,e);case n.Project:return xD(r,s,e);case n.ActionDescriptor:return bD(r,s,e);case n.ArgumentDeclaration:return ID(r,s,e);case n.ReturnDeclaration:return kD(r,s,e);case n.ValueDescriptor:return JD(r,s,e);case n.InputMap:return MD(r,s,e);case n.OutputMap:return FD(r,s,e);case n.DataType:return VD(r,s,e);case n.InstalledProject:return _D(r,s,e);case n.InternalCall:return ND(r,s,e);case n.LiteralValue:return LD(r,s,e);case n.Property:return jD(r,s,e);case n.VariableInstance:return YD(r,s,e);case n.BuiltInBaseEntity:return e.ignoreBuiltInBaseEntities?[]:DD(r,s,e);case n.PrimitiveEntity:return e.ignoreBuiltInBaseEntities?[]:UD(r,s,e)}return[]}function $l(r,s){if(ur.includes(r.type))return new Set;const e=gD(r,s),t=new Set(e.map(i=>i.id));if(r.type===n.LiteralValue&&r.valueAsType&&(Array.isArray(r.valueAsType)?r.valueAsType.forEach(i=>{t.add(i.id)}):t.add(r.valueAsType.id)),r.type===n.DataType&&r.entity&&(r.entity.type===n.DefinitionEntity?(r.entity.parent.entityId||r.entity.parent.id)!==r.id&&t.add(r.entity.id):t.add(r.entity.id)),kp.includes(r.type)){const i=r.parent;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(Zp.includes(r.type)){const i=r.implements;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(Hl.includes(r.type)){const i=r.declaration;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(kn.includes(r.type)){const i=r.readsValue;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(vn.includes(r.type)){const i=[...r.calledBySuccess||[],...r.calledByEntry||[],...r.calledByError||[]];i.length&&i.forEach(a=>{a.type===n.GenericReference?t.add(a.entityId):t.add(a.id)})}return t}function wp(r){return r.type===n.FunctionCall||r.type===n.InternalCall||[n.Operation,n.Condition,n.Loop].includes(r.type)?r.declaration.inputs:r.type===n.FunctionDeclaration||Pi.includes(r.type)?r.inputs:r.type===n.Search?r.inputsDeclarations:[]}function yq(r,s){return s.type===n.Condition?s.inputs.find(e=>e.declaration.id===r.id):s.type===n.FunctionCall||s.type===n.Operation?s.inputs.find(e=>e.declaration.id===r.id):null}function HD(r){return Qe.includes(r.type)?r.inputs:[]}function zD(r){var s;return r.type===n.FunctionCall?((s=r.declaration.returnStatements[0])==null?void 0:s.outputs)||[]:[n.Operation,n.Condition,n.Loop].includes(r.type)?r.declaration.outputs:r.type===n.Search?r.outputsDeclarations:et.includes(r.type)?r.outputs:[]}function fq(r,s){return s.type===n.Condition?null:s.type===n.FunctionCall||s.type===n.Operation?s.outputs.find(e=>e.declaration.id===r.id):null}function mq(r){return r.type===n.Condition?[]:Qe.includes(r.type)?r.outputs:[]}function Fl(r){const s=r.readsValue;return s?At(s):null}function KD(r,s){const e=r.readsValue;return e?Ll(e,s):null}function XD(r){const s=r.internalCalls||[];return m(Zt(m(s.flatMap(e=>[...e.successCalls,...e.errorCalls]))))}function ma(r){const s=Vp(r),e=[];return s.forEach(t=>{if(We.includes(t.type))e.push(t);else if(kn.includes(t.type)){const i=t.parent;e.push(i)}}),e}function m(r){const s=new Set;return r.filter(e=>!e||s.has(e.id)?!1:(s.add(e.id),!0))}function Or(r,s=!1){const e=[];if(r.type===n.Project&&e.push(...(r==null?void 0:r.entities)||[],...(r==null?void 0:r.functions)||[],...(r==null?void 0:r.variableDeclarations)||[],...(r==null?void 0:r.variableInstances)||[],...(r==null?void 0:r.searches)||[],...(r==null?void 0:r.loops)||[],...(r==null?void 0:r.operations)||[],...(r==null?void 0:r.conditions)||[],...(r==null?void 0:r.functionCalls)||[],...(r==null?void 0:r.events)||[],...(r==null?void 0:r.projects)||[]),ut.includes(r.type)&&e.push(...(r==null?void 0:r.detachedChildren)||[]),r.type===n.DefinitionEntity){const t=[...r.suggestedMethods,...r.methods].flatMap(i=>i.collapsed&&s?[]:Or(i));e.push(...t)}if(r.type===n.Condition){const t=r.successCalls.map(a=>At(a)),i=r.errorCalls.map(a=>At(a));e.push(...t,...i)}if(Pi.includes(r.type)){if(r.collapsed&&s)return[];const t=r.inputs.map(a=>ma(a)).flat(),i=r.calls.map(a=>At(a));e.push(...m(t),...i)}if(Qe.includes(r.type)&&r.type!==n.Condition&&r.type!==n.Loop){const t=r==null?void 0:r.outputs.map(o=>ma(o)).flat(),i=r.successCalls.map(o=>At(o)),a=r.errorCalls.map(o=>At(o));e.push(...m(t),...i,...a)}if(We.includes(r.type)){const t=ma(r),i=XD(r);e.push(...t,...i)}if(r.type===n.Loop){const t=r.outputs.map(o=>ma(o)).flat();if(r.body){const o=Or(r.body,s);e.push(...o)}const i=r.errorCalls.map(o=>At(o)),a=r.successCalls.map(o=>At(o));e.push(...m(t),...a,...i)}if(r.type===n.FunctionDeclaration){if(r.collapsed&&s)return[];const t=r.inputs.map(a=>ma(a)).flat(),i=r.calls.map(a=>At(a));e.push(...m(t),...i)}return m(e)}function QD(r,s=!1){const e=Or(r,s),t=[...e,...e.reduce((i,a)=>[...i,...QD(a,s)],[])];return m(t)}function eP(r){const s=Ri(r),e=[...s,...s.reduce((t,i)=>[...t,...eP(i)],[])];return m(e)}function Ul(r){return r.implements.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,n.DefinitionEntity,...Ul(e),...xl(e)]:[...s,e.name],[])}function xl(r){return r.extends.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,n.DefinitionEntity,...xl(e),...Ul(e)]:[...s,e.name],[])}function Bp(r){return r.extends.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,e,...Bp(e),...Mp(e)]:[...s,e],[])}function Mp(r){return r.implements.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,e,...Mp(e),...Bp(e)]:[...s,e],[])}function _p(r){return[...xl(r),...Ul(r)].filter((e,t,i)=>i.indexOf(e)===t)}function tP(r){return r.implements.length===0&&r.extends.length===0?null:r.implements.find(t=>t.type===n.BuiltInBaseEntity&&t.name===j.PERSISTED_ENTITY)?r:[...r.implements,...r.extends].reduce((t,i)=>{if(i.type===n.DefinitionEntity){const a=tP(i);if(a)return a}return t},null)}function Tq(r){const s=r.extends.find(e=>e.type===n.BuiltInBaseEntity);return s&&s.type===n.BuiltInBaseEntity?s:null}function vq(r){const s=r.implements.find(e=>e.type===n.BuiltInBaseEntity);return s&&s.type===n.BuiltInBaseEntity?s:null}function Np(r){const s=r.extends.find(e=>e.type===n.DefinitionEntity);return s&&s.type===n.DefinitionEntity?s:null}function Vr(r){const s=[...r.implements,...r.extends].reduce((e,t)=>t.type===n.BuiltInBaseEntity?[...e,t]:t.type===n.DefinitionEntity?[...e,...Vr(t)]:e,[]);return m(s)}function Lp(r){return r.type===n.PrimitiveEntity?!0:r.type===n.BuiltInBaseEntity?r.interactive:!Vr(r).find(t=>!t.interactive)}function Eq(r){return r.parent===r.project&&r.project.variableDeclarations.includes(r)}function Gp(r){return r.parent!==r.project?!1:n.VariableDeclaration===r.type?r.project.variableDeclarations.includes(r):n.VariableInstance===r.type?r.project.variableInstances.includes(r):n.FunctionCall===r.type?r.project.functionCalls.includes(r):n.Condition===r.type?r.project.conditions.includes(r):n.Operation===r.type?r.project.operations.includes(r):n.Loop===r.type?r.project.loops.includes(r):n.Search===r.type?r.project.searches.includes(r):!1}function nP(r){if([...ze,n.DefinitionEntity,n.InstalledProject,n.Project].includes(r.type)||Gp(r))return!1;const s=Ri(r);return s.length===0?!0:s.some(e=>nP(e))}function $p(r){return[...ze,n.DefinitionEntity,n.InstalledProject,n.Project].includes(r.type)||Gp(r)?!1:Ri(r).length===0}function rP(r,s=0){if($p(r)){const e=Ri(r);return e.length===0?r:e.map(i=>rP(i,s+1)).reduce((i,a)=>i?a&&a.x<i.x?a:i:a,null)}return null}function iP(r){const s=[];if($p(r))s.push(r);else return[];return Ri(r).forEach(t=>{s.push(...iP(t))}),s}function aP(r){return r.type===n.FunctionDeclaration&&r.parent!==r.project&&!![n.DefinitionEntity,n.Loop,n.InstalledProject].includes(r.parent.type)}function Rq(r,s){const e=new Map;return r.forEach(t=>{e.set(t.id,t)}),s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())}function jl(r){switch(r){case n.DefinitionEntity:return gi;case n.FunctionDeclaration:return li;case n.VariableDeclaration:return pi;case n.VariableInstance:return hi;case n.FunctionCall:return Ei;case n.Operation:return di;case n.Condition:return ci;case n.ReturnStatement:return Ti;case n.Loop:return ui;case n.Search:return yi;case n.InputMap:return sr;case n.OutputMap:return or;case n.ArgumentDeclaration:return mi;case n.ReturnDeclaration:return on;case n.Property:return oi;case n.InstalledProject:return fi;case n.Project:return B;case n.BuiltInBaseEntity:return xn;default:return null}}function qt(r,s){if(ut.includes(r.type))return r;if(ur.includes(r.type))return null;const e=r.parent;if(!e)return null;if(e.type===n.GenericReference){const t=P(e);if(!t)return null;const i=s.get(t);return i?qt(i,s):null}else return e===s?s:qt(e,s)}function Fp(r,s){if(ur.includes(r.type)||s.getBuiltIn(r.id))return null;const e=Xt(r.parent,s);return e?e===s?ut.includes(r.type)?r:null:e.type===n.DefinitionEntity?r:Fp(e,s):null}function kl(r,s,e){if(r===s||s===e||r===e)return!1;const t=qt(s.parent,e);return t===r?!0:kl(t,s,e)}var Zl=(r=>(r.SameBothLocal="same-both-local",r.AInB="a-in-b",r.BInA="b-in-a",r.ParallelInCommonParent="parallel-in-common-parent",r.ParallelInProject="parallel-in-project",r.AIsGlobalBIsNot="a-is-global-b-is-not",r.BIsGlobalAIsNot="b-is-global-a-is-not",r.SameBothGlobal="same-both-global",r))(Zl||{});function Ds(r,s,e){const t=qt(r,e),i=qt(s,e);if(!t)throw new Error("Could not find scope owner for the entity: "+r.id);if(!i)throw new Error("Could not find scope owner for the entity: "+s.id);if(t===i&&t.type!==n.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:t};if(t===i&&t.type===n.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:t};if(t.type===n.Project&&i.type!==n.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:t};if(t.type!==n.Project&&i.type===n.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:i};if(kl(t,i,e))return{compatible:!0,type:"b-in-a",commonAncestorScope:t};if(kl(i,t,e))return{compatible:!0,type:"a-in-b",commonAncestorScope:i};const l=Sp(t,i);return l===e?{compatible:!1,type:"parallel-in-project",commonAncestorScope:l}:l?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:qt(l,e)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:e}}function sP(r,s,e){const t=Ds(r,s,e);if(!t.compatible||t.type!=="same-both-local")return null;if(r===s)return r;let i=qt(r.parent,e);if(i){if(i===s)return s;if(i.type===n.Project)return r}else return r;for(;i;){if(i){if(i===s)return s;if(i.type===n.Project)return r}else return r;i=qt(i.parent,e)}let a=qt(s.parent,e);if(a){if(a===r)return r;if(a.type===n.Project)return s}else return s;for(;a;){if(a){if(a===r)return r;if(a.type===n.Project)return s}else return s;a=qt(a.parent,e)}return null}function oP(r){return r.length===0?null:r.length===1?r[0]:r.reduce((e,t)=>{const i=sP(e,t,t.project);return!i||i===t?e:t},r[0])}function Xt(r,s){if(!r)return null;let e;return typeof r=="string"?e=r:r.type===n.GenericReference?e=P(r):e=r.id,e===s.id?s:s.get(e)}function Cr(r){if(!r)return null;if(ur.includes(r.type))return r;if(r.type===n.Project)return null;if(r.project.getBuiltIn(r.id))return r;const s=r.parent;return!s||s.type===n.Project?null:Cr(s)}function gq(r,s){var e;if(r.readsValue){const t=Xt(r.readsValue,s.project);s.setValueWriter(t),t.addValueReader(s)}else r.readsValue===null&&((e=s.readsValue)==null||e.removeValueReader(s),s.readsValue=null);return s}function Ps(r){const s=[];function e(a,o){return s.some(l=>l.blockedByCaller===a&&l.blockedByCalling===o)}function t(a,o){e(a,o)||s.push({blockedByCaller:a,blockedByCalling:o})}const i=Fp(r,r.project);return r.calledBySuccess.forEach(a=>{[...a.successCalls||[]].forEach(d=>{et.includes(d.type)&&d!==r&&(Xe(r).find(f=>f===d)||t(a,d))});let l;if(Qe.includes(a.type)&&(l=a),l){const d=Ps(l);d.reachable||Xe(r).find(f=>f===a)||d.blocks.forEach(f=>{t(a,f.blockedByCalling)})}}),r.calledByError.forEach(a=>{[...a.errorCalls||[]].forEach(d=>{et.includes(d.type)&&d!==r&&(Xe(r).find(f=>f===d)||t(a,d))});let l;if(Qe.includes(a.type)&&(l=a),l){const d=Ps(l);d.reachable||Xe(r).find(f=>f===a)||d.blocks.forEach(f=>{t(a,f.blockedByCalling)})}}),r.calledByEntry.forEach(a=>{if([...a.calls||[]].forEach(d=>{et.includes(d.type)&&d!==r&&(Xe(r).find(f=>f===d)||t(a,d))}),a===i)return;let l;if(a.type===n.FunctionDeclaration){const d=At(a);if(d.type===n.DefinitionEntity)return;d.type===n.Loop&&(l=d)}if(l){const d=Ps(l);d.reachable||d.blocks.forEach(h=>{t(a,h.blockedByCalling)})}}),{reachable:s.length===0,entryPoint:i,blocks:s}}function bq(r){return Bs.includes(r.type)?r.type===n.FunctionDeclaration?!aP(r):!0:!1}function Iq(r){if(n.ActionDescriptor===r.type){if(r.project.operationDeclarations.find(a=>a.id===r.id))return n.Operation;if(r.project.globalEventActionDescriptors.find(a=>a.id===r.id))return n.GlobalEvent;if(r.project.loopDeclarations.find(a=>a.id===r.id))return n.Loop;if(r.project.conditionDeclarations.find(a=>a.id===r.id))return n.Condition}return r.type}function Ta(r,s){if(r.type!==n.DefinitionEntity||r.abstract)return!1;const e=Np(r)||r;return!!_p(e).includes(s)}function Aq(r){const s=[];return r.entities.forEach(e=>{if(Ta(e,j.PERSISTED_ENTITY)){s.push(e);return}}),m(s)}function Dq(r){const s=[];return r.entities.forEach(e=>{if(Ta(e,j.RELATIONAL_DATABASE)){s.push(e);return}}),m(s)}function Pq(r){return r.type!==n.DefinitionEntity||r.abstract||!Ta(r,j.PERSISTED_ENTITY)?null:(r==null?void 0:r.properties.find(e=>{var t;return((t=e.implements)==null?void 0:t.id)===_[n.BuiltInBaseEntity][j.PERSISTED_ENTITY].properties.primaryKey.id&&!e.abstract}))||null}function Sq(r){if(r.type!==n.DefinitionEntity)return[];if(r.abstract)return[];if(!Ta(r,j.PERSISTED_ENTITY))return[];const s=[],e=r.properties.filter(t=>{var i;return((i=t.implements)==null?void 0:i.id)!==_[n.BuiltInBaseEntity][j.PERSISTED_ENTITY].properties.database.id&&!t.abstract});return s.push(...e),s}function Oq(r){var e;if(!r||r.type!==n.DefinitionEntity||!Ta(r,j.PERSISTED_ENTITY))return null;const s=r.properties.find(t=>{var i;return((i=t.implements)==null?void 0:i.id)===_[n.BuiltInBaseEntity][j.PERSISTED_ENTITY].properties.database.id});return(e=s==null?void 0:s.getDefaultValue())==null?void 0:e.valueAsType}function st(r,s){var t;if(!Yp.includes(s.type)||!r)return s.project||null;let e=s.project;return r.type===n.Project?e=r:((t=s.project)==null?void 0:t.id)!==r.project.id&&(e=r.project),e}function Vq(r,s){const e=[];if(r.parent)if(r.id===r.parent)e.push(new b({id:`${r.id}--${r.parent}--${T.SelfReference}`,code:T.SelfReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.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 t=s.get(r.parent);t?[n.Project,n.DataType].includes(t.type)||e.push(new b({id:`${r.id}--${r.parent}--${T.InvalidParentReference}`,code:T.InvalidParentReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):e.push(new b({id:`${r.id}--${r.parent}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${r.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return r.implements&&Array.isArray(r.implements)?r.implements.forEach(t=>{if(r.id===t){e.push(new b({id:`${r.id}--${t}--${T.SelfReference}`,code:T.SelfReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.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 i=s.get(t);i?[n.DefinitionEntity,n.BuiltInBaseEntity].includes(i.type)?i.abstract||e.push(new b({id:`${r.id}--${t}--${T.InvalidImplementsReference}`,code:T.InvalidImplementsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):e.push(new b({id:`${r.id}--${t}--${T.InvalidImplementsReference}`,code:T.InvalidImplementsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):e.push(new b({id:`${r.id}--${t}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${t}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):e.push(new b({id:`${r.id}--${w.InvalidObjectStructure}`,code:w.InvalidObjectStructure,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' property that isn't an array.`,issue:null})),r.extends&&Array.isArray(r.extends)&&r.extends.forEach(t=>{const i=s.get(t);i?[n.DefinitionEntity,n.BuiltInBaseEntity].includes(i.type)?i.abstract&&e.push(new b({id:`${r.id}--${t}--${T.InvalidExtendsReference}`,code:T.InvalidExtendsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.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})):e.push(new b({id:`${r.id}--${t}--${T.InvalidExtendsReference}`,code:T.InvalidExtendsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'extends' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):e.push(new b({id:`${r.id}--${t}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${t}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),e}const we=class we extends Ke{constructor(e,t){super(e);u(this,"initialData");u(this,"id");u(this,"name");u(this,"description",null);u(this,"x");u(this,"y");u(this,"static");u(this,"abstract");u(this,"type",n.DefinitionEntity);u(this,"properties",[]);u(this,"methods",[]);u(this,"abstractMethods",[]);u(this,"extends",[]);u(this,"implements",[]);u(this,"project");u(this,"errors",[]);u(this,"parent");u(this,"initialized",!1);u(this,"suggestedProperties",[]);u(this,"suggestedMethods",[]);this.initialData=e,this.project=t,this.id=e.id,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 i=t;if(e.parent){const h=P(e.parent);i=t.get(h)}const a=[];e.implements&&e.implements.forEach(h=>{a.push(t.get(h)||t.getBuiltIn(h))});const o=[];e.extends&&e.extends.forEach(h=>{o.push(t.get(h)||t.getBuiltIn(h))});const l={id:e.id,version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,name:e.name,type:n.DefinitionEntity,description:e.description,static:e.static,abstract:e.abstract,properties:[],methods:[],abstractMethods:[],extends:o,implements:a,x:0,y:0,parent:i},d=I(l,t);return d.setParent(i),d.initChildren(),d}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],o=Vq(i,t),l=Al(i,t);a.push(...o,...l,...tt(i));const d=i.parent?t.get(i.parent):null;if(d&&d.type===n.DataType){const h=d;h.entity&&a.push(new b({id:`${e.id}--${T.NewEntityWouldOverriteExisting}`,code:T.NewEntityWouldOverriteExisting,severity:E.Error,message:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${h.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
403
+ 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}}hydrateAncestors(){const e=[],t=[],i=[];if(this.initialData.parent){const a=P(this.initialData.parent),o=this.project.get(a);o&&(this.setParent(o),e.push(o))}if(this.initialData.declaration){const a=P(this.initialData.declaration),o=this.project.get(a);o&&(this.setDeclaration(o),e.push(o))}return this.initialData.calledByEntry.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addEntryCaller(l),e.push(l))}),this.initialData.calledBySuccess.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addSuccessCaller(l),e.push(l))}),this.initialData.calledByError.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addErrorCaller(l),e.push(l))}),{updated:m(e),added:m(t),removed:m(i),self:this}}afterAllChildrenInitialized(){const e=[],t=[],i=[];this.initialized=!0;const{updated:a,added:o,removed:l}=this.syncMissingFixedInputs(),{updated:d,added:h,removed:y}=this.syncMissingFixedOutputs();return e.push(...a,...d),t.push(...o,...h),i.push(...l,...y),{updated:m(e),added:m(t),removed:m(i),self:this}}addSelfToProject(){var a;const e=[this],t=[],i=[];return this.parent===this.project&&this.project.addFunctionCall(this),(a=this.process)==null||a.writesValues.forEach(o=>{o.setValueWriter(this.process),e.push(o)}),this.successCalls.forEach(o=>{o.addSuccessCaller(this),e.push(o)}),this.errorCalls.forEach(o=>{o.addErrorCaller(this),e.push(o)}),this.calledBySuccess.forEach(o=>{o.addSuccessCall(this),e.push(o)}),this.calledByError.forEach(o=>{o.addErrorCall(this),e.push(o)}),this.calledByEntry.forEach(o=>{o.addCall(this),e.push(o)}),{updated:m(e),added:m(t),removed:m(i),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(i=>i.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(i=>i.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 i=this.errorCalls.findIndex(a=>a.id===e.id);return i>-1&&this.errorCalls.splice(i,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}setDeclaration(e){return this.declaration=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===n.FunctionDeclaration){const e=I(this.initialData.declaration,this.project);this.declaration=e}else{const e=P(this.initialData.declaration),t=this.project.get(e);this.declaration=t}return this.successCalls=this.initialData.successCalls.map(e=>{const t=I(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=I(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=I(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=I(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.error&&(this.error=I(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.afterAllChildrenInitialized(),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return super.sync(e),this.x=e.x||this.x,this.y=e.y||this.y,this}async load(e=N,...t){return await Ge.repository.load(this.id,...t),this}async create(e=N,...t){return await Ge.repository.create(this.toShallowJSON(),...t),this}async update(e=N,...t){return await Ge.repository.update(this.toShallowJSON(),...t),this}async delete(e=N,...t){return await Ge.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var o;const i=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.process){const{affected:l,removed:d}=(o=this.process)==null?void 0:o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}if(this.inputs.forEach(l=>{const{affected:d,removed:h}=l.remove({ignoreUpstream:!0,seenEntities:t});i.push(...d),a.push(...h)}),this.outputs.forEach(l=>{const{affected:d,removed:h}=l.remove({ignoreUpstream:!0,seenEntities:t});i.push(...d),a.push(...h)}),this.error){const{affected:l,removed:d}=this.error.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}return this.successCalls.forEach(l=>{i.push(l),l.removeCaller(this)}),this.errorCalls.forEach(l=>{i.push(l),l.removeCaller(this)}),e||this.calledBy.forEach(l=>{i.push(l),l.removeCall(this)}),{affected:m(i),removed:m(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:i}=this.process.restore({seenEntities:e});t.push(...i)}return this.inputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(i=>{t.push(i),i.addSuccessCaller(this)}),this.errorCalls.forEach(i=>{t.push(i),i.addErrorCaller(this)}),this.calledBySuccess.forEach(i=>{t.push(i),i.addSuccessCall(this)}),this.calledByError.forEach(i=>{t.push(i),i.addErrorCall(this)}),this.calledByEntry.forEach(i=>{t.push(i),i.addCall(this)}),{affected:m(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.error?this.error.toFlat(e):[],...this.calledBy.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e))])}toJSON(e=new Set){var t,i;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(a=>a.toJSON(e)),errorCalls:this.errorCalls.map(a=>a.toJSON(e)),calledBySuccess:this.calledBySuccess.map(a=>a.toReference()),calledByError:this.calledByError.map(a=>a.toReference()),calledByEntry:this.calledByEntry.map(a=>a.toReference()),process:(t=this.process)==null?void 0:t.toJSON(e),declaration:this.declaration.toJSON(e),inputs:this.inputs.map(a=>a.toJSON(e)),outputs:this.outputs.map(a=>a.toJSON(e)),parent:this.parent.toReference(),error:(i=this.error)==null?void 0:i.toJSON(e)})}toJSONClone(e=$){var i,a,o,l,d,h,y;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||at(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(a=e.seenEntities)!=null&&a.has(t)||(o=e.seenEntities)!=null&&o.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((l=e.seenEntities)==null||l.add(t),(d=e.seenEntities)==null||d.add(this.id),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(f=>f.toJSONClone({...e,newId:null})),errorCalls:this.errorCalls.map(f=>f.toJSONClone({...e,newId:null})),calledBySuccess:this.calledBySuccess.map(f=>f.toReference({seenEntityMaps:e.seenEntityMaps})),calledByError:this.calledByError.map(f=>f.toReference({seenEntityMaps:e.seenEntityMaps})),calledByEntry:this.calledByEntry.map(f=>f.toReference({seenEntityMaps:e.seenEntityMaps})),process:(h=this.process)==null?void 0:h.toJSONClone({...e,newId:null}),declaration:this.declaration.toJSONClone({...e,newId:null}),inputs:this.inputs.map(f=>f.toJSONClone({...e,newId:null})),outputs:this.outputs.map(f=>f.toJSONClone({...e,newId:null})),error:(y=this.error)==null?void 0:y.toJSONClone({...e,newId:null}),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+B.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference(e):null,inputs:this.inputs.map(a=>a.toReference(e)),outputs:this.outputs.map(a=>a.toReference(e)),declaration:this.declaration.toReference(e),successCalls:this.successCalls.map(a=>a.toReference(e)),errorCalls:this.errorCalls.map(a=>a.toReference(e)),calledBySuccess:this.calledBySuccess.map(a=>a.toReference(e)),calledByError:this.calledByError.map(a=>a.toReference(e)),calledByEntry:this.calledByEntry.map(a=>a.toReference(e)),error:this.error?this.error.toReference(e):null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(i=>i.toFlatJSON(e)),...this.errorCalls.flatMap(i=>i.toFlatJSON(e)),...this.inputs.flatMap(i=>i.toFlatJSON(e)),...this.outputs.flatMap(i=>i.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,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,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(i=>i.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(i=>i.toFlatGenerationTarget(e)),...this.inputs.flatMap(i=>i.toFlatGenerationTarget(e)),...this.outputs.flatMap(i=>i.toFlatGenerationTarget(e)),...this.process?this.process.toFlatGenerationTarget(e):[],...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(i=>i.clearErrors()),this.outputs.forEach(i=>i.clearErrors()),this.successCalls.forEach(i=>i.clearErrors()),this.errorCalls.forEach(i=>i.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=nq(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=null,t=null,i=!0){var R,A;let a=st(e,this);const o=this.toJSON(),l=t||Fe(C(this,this.project),n.FunctionCall,a);o.inputs=[];const d=l.split("-id"),h=d[d.length-1||0]||l;o.id=l;const y=nt(o,a);e?y.setParent(e):y.setParent(this.parent),i&&y.subscribe(),y.initChildren();const f=(R=this.inputs)==null?void 0:R.map((D,g)=>D.clone(y,h+"-input-map-"+g+"-id",i));y.inputs=f;const v=(A=this.outputs)==null?void 0:A.map((D,g)=>D.clone(y,h+"-output-map-"+g+"-id",i));return y.outputs=v,this.error&&(y.error=this.error.clone(y,h+"-error-map-id",i)),this.process&&(y.process=this.process.clone(y,h+"-process-id",i)),y}removeUnrecognizedInputs(){const e=[],t=[],i=[];return this.inputs.forEach(a=>{if(!this.declaration.inputs.find(l=>{var d;return l.id===((d=a.declaration)==null?void 0:d.id)})){const l=a.remove();i.push(...l.removed),e.push(...l.affected)}}),{updated:m(e),added:m(t),removed:m(i),self:this}}removeUnrecognizedOutputs(){const e=[],t=[],i=[];return this.outputs.forEach(a=>{if(!this.declaration.getUniqueReturnDeclarations().find(l=>{var d;return l.id===((d=a.declaration)==null?void 0:d.id)})){const l=a.remove();i.push(...l.removed),e.push(...l.affected)}}),{updated:m(e),added:m(t),removed:m(i),self:this}}syncMissingFixedInputs(){const e=[],t=[],i=[],a=this.declaration.inputs.filter(h=>!this.inputs.find(y=>y.declaration.id===h.id));this.inputs.sort((h,y)=>h.index-y.index),a.forEach(h=>{this.inputs.forEach(v=>{v.index>=h.index&&v.sync({index:v.index+1})});const y={id:B.UUID.uuid(),version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,type:n.InputMap,declaration:h.toJSON(),readsValue:null,defaultValue:null,index:h.index,name:null,description:null,parent:this.toReference()},f=I(y,this.project);f.setParent(this),f.initChildren(),f.addSelfToProject(),t.push(f)}),this.inputs.sort((h,y)=>h.index-y.index);const{updated:o,added:l,removed:d}=this.removeUnrecognizedInputs();return e.push(...o),t.push(...l),i.push(...d),{updated:m(e),added:m(t),removed:m(i),self:this}}syncMissingFixedOutputs(){const e=[],t=[],i=[],a=[];this.outputs=this.initialData.outputs.map(y=>{const f=I(y,this.project);return a.push(f.index),f.setParent(this),f.initChildren(),f});const o=this.declaration.getUniqueReturnDeclarations().filter(y=>!this.outputs.find(f=>f.declaration.id===y.id));this.outputs.sort((y,f)=>y.index-f.index),o.forEach((y,f)=>{this.outputs.forEach(D=>{D.index>=y.index&&D.index++});const v=a.includes(y.index)?this.outputs.length-1+f:y.index,R={id:B.UUID.uuid(),version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,type:n.OutputMap,declaration:y.toJSON(),defaultValue:null,writesValues:[],index:v,parent:this.toReference()},A=I(R,this.project);A.setParent(this),A.initChildren(),A.addSelfToProject()}),this.outputs.sort((y,f)=>y.index-f.index);const{updated:l,added:d,removed:h}=this.removeUnrecognizedOutputs();return e.push(...l),t.push(...d),i.push(...h),{updated:m(e),added:m(t),removed:m(i),self:this}}};u(Ge,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),u(Ge,"type",n.FunctionCall),u(Ge,"USER_MANAGED_PARENT_TYPES",[...ut,n.Project]),u(Ge,"PARENT_TYPES",[...Ge.USER_MANAGED_PARENT_TYPES]),u(Ge,"MUTABLE_BASE_PROPERTIES",[]),u(Ge,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),u(Ge,"BASE_PROPERTIES",[...Ge.MUTABLE_BASE_PROPERTIES,...Ge.INMUTABLE_BASE_PROPERTIES]),u(Ge,"MUTABLE_META_PROPERTIES",["x","y"]),u(Ge,"INMUTABLE_META_PROPERTIES",[...Ge.INMUTABLE_BASE_PROPERTIES]),u(Ge,"META_PROPERTIES",[...Ge.MUTABLE_META_PROPERTIES,...Ge.INMUTABLE_META_PROPERTIES]),u(Ge,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),u(Ge,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),u(Ge,"UPSTREAM_PROPERTIES",[...Ge.MUTABLE_UPSTREAM_PROPERTIES,...Ge.INMUTABLE_UPSTREAM_PROPERTIES]),u(Ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),u(Ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),u(Ge,"DOWNSTREAM_PROPERTIES",[...Ge.MUTABLE_DOWNSTREAM_PROPERTIES,...Ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),u(Ge,"PROPERTIES",[...Ge.META_PROPERTIES,...Ge.UPSTREAM_PROPERTIES,...Ge.DOWNSTREAM_PROPERTIES]);let Ei=Ge;function Ip(r){return r&&typeof r.then=="function"}class Ap{constructor(s){u(this,"order",[]);u(this,"flatRecord",{});u(this,"onGoingVisits",{});this.flatten(s),this.orderEntities()}flatten(s){const e=new Set(Cp()),t=m(S(s,e,{ignoreBuiltInBaseEntities:!0})),i=new Set;for(const a of t)this.flatRecord[a.id]=a,i.add(a.id);this.order=Array.from(i)}moveEntityAfterDependencies(s){const e=$l(s,this.flatRecord);for(const t of e){const i=this.order.indexOf(t),a=this.order.indexOf(s.id);if(i>a)return this.order.splice(a,1),this.order.splice(i,0,s.id),!0}return!1}orderEntities(){let s=!1;for(let e=0;e<this.order.length;e++){const t=this.order[e],i=this.flatRecord[t];if(this.moveEntityAfterDependencies(i)){s=!0;break}}s&&this.orderEntities()}getUpstreamOngoingDependenciesVisits(s,e){const t=$l(this.flatRecord[s],this.flatRecord),i={};return Object.entries(this.onGoingVisits[e]||{}).forEach(([a,o])=>{Array.from(t).includes(a)&&(i[a]=o)}),i}getDownstreamOngoingDependenciesVisits(s,e){const t=Object.keys(this.onGoingVisits[e]||{}),i=new Set(t.flatMap(o=>Array.from($l(this.flatRecord[o],this.flatRecord)))),a={};return Array.from(i).forEach(o=>{o===s&&(a[o]=this.onGoingVisits[e][o])}),a}async settlePromises(s,e){const t=Object.values(s);t.length&&await Promise.all(t),Object.keys(s).forEach(i=>{delete this.onGoingVisits[e][i]})}visit(s){const e=this.order;for(const t of e)s(this.flatRecord[t],this.flatRecord);return this}reverseVisit(s){const e=this.order.slice().reverse();for(const t of e)s(this.flatRecord[t],this.flatRecord);return this}async visitAsync(s){const e=this.order,t=Math.random().toString(36).substring(7);this.onGoingVisits[t]={};for(const i of e){const a=this.getUpstreamOngoingDependenciesVisits(i,t);Object.keys(a).length&&await this.settlePromises(a,t);const o=s(this.flatRecord[i],this.flatRecord);Ip(o)&&(this.onGoingVisits[t][i]=o)}return await this.settlePromises(this.onGoingVisits[t],t),this.onGoingVisits[t]={},this}async reverseVisitAsync(s){const e=this.order.slice().reverse(),t=Math.random().toString(36).substring(7);this.onGoingVisits[t]={};for(const i of e){const a=this.getDownstreamOngoingDependenciesVisits(i,t);Object.keys(a).length&&await this.settlePromises(a,t);const o=s(this.flatRecord[i],this.flatRecord);Ip(o)&&(this.onGoingVisits[t][i]=o)}return await this.settlePromises(this.onGoingVisits[t],t),this.onGoingVisits[t]={},this}}function rD(r){var s;switch(r.id){case _["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const e=r.project.entities.filter(d=>!!d.implements.find(h=>h.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));if(e.find(d=>!!d.properties.find(h=>{var y;return h.implements&&h.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((y=h.getDefaultValue())==null?void 0:y.value)===!0}))){const h=e[0].properties.find(f=>f.implements&&f.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),y=h==null?void 0:h.defaultValue;if(y)y.value=!0;else if(h!=null&&h.dataType){const f=(s=h==null?void 0:h.dataType)==null?void 0:s.id.split("-id")[0],v=I({id:f+"-default-value-id",version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.LiteralValue,name:V.EntityTemplate,autogeneration:null,value:!0,valueAsType:null,parent:h==null?void 0:h.dataType.toReference()},r.project);return v.setParent(h==null?void 0:h.dataType),v.initChildren(),v.addSelfToProject(),{newEntities:[v]}}return{newEntities:[]}}const i=r.project.get(_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),a=Ml(i,"Main database");if(a.errors.length>0)return{newEntities:[]};const o=a.implemented.properties.find(d=>d.implements&&d.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),l=o==null?void 0:o.defaultValue;if(l)l.value=!0;else if(o!=null&&o.dataType){const d=o==null?void 0:o.dataType.id.split("-id")[0],h=I({id:d+"-default-value-id",version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.LiteralValue,name:V.EntityTemplate,autogeneration:null,value:!0,valueAsType:null,parent:o==null?void 0:o.dataType.toReference()},r.project);h.setParent(o==null?void 0:o.dataType),h.initChildren(),h.addSelfToProject()}return{newEntities:[a.implemented]}}}return{newEntities:[]}}function iD(r){return r.implements.filter(e=>e.type===n.BuiltInBaseEntity).map(e=>{switch(e.id){case _["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=r.project.entities.filter(l=>l.implements.find(d=>d.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)).find(l=>!!l.properties.find(d=>{var h;return d.implements&&d.implements.id===_["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((h=d.getDefaultValue())==null?void 0:h.value)===!0}));if(!i)return{newEntities:[]};const a=r.properties.find(l=>l.implements&&l.implements.id===_["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),o=a==null?void 0:a.defaultValue;if(a&&(a!=null&&a.dataType)&&!o){const l=a==null?void 0:a.dataType.id.split("-id")[0],d=I({id:l+"-default-value-id",version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.LiteralValue,name:V.EntityTemplate,autogeneration:null,value:null,valueAsType:i,parent:a==null?void 0:a.dataType.toReference()},r.project);return d.setParent(a==null?void 0:a.dataType),d.initChildren(),d.addSelfToProject(),{newEntities:[d]}}return{newEntities:[]}}}}),{newEntities:[]}}function Ml(r,s,e){const t=e||Fe(s,n.DefinitionEntity,r.project),i=t.split("-id"),a=i[i.length-1||0]||t,o={id:t,version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,name:s,type:n.DefinitionEntity,description:null,static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[r],x:0,y:0,parent:r.project},l=Al(o,r.project);if(l.length>0)return{errors:l,implemented:null,entitiesChanges:{new:[],updated:[],deleted:[]}};const d=rD(r),h=I(o,r.project);h.setParent(r.project),h.initChildren();const y=r.properties.map(R=>{const A=a+"-"+Fe(C(R,r.project),n.Property,r.project),D=R.clone(h,A);return D.abstract=!1,D.implements=R,D.setParent(h),h.addProperty(D),D}),f=r.abstractMethods.map(R=>{const A=a+Fe(R.name,n.FunctionDeclaration,r.project),D=R.implementAsFunctionDeclaration(A),g={id:A+"-parent-ref-id",type:n.GenericReference,entityId:t,version:"1",entityType:n.DefinitionEntity},M={...D,implements:R,parent:g},Z=I(M,r.project);return h.addMethod(Z),Z.setParent(h),Z.initChildren(),Z.implements=R,Z});o.properties=y,o.methods=f;const v=iD(h);return{implemented:h,errors:[],entitiesChanges:{new:[h,...d.newEntities,...v.newEntities],updated:[h],deleted:[]}}}function Dp(r,s){return s.entities.find(i=>{const a=i.properties,o=a.map(f=>f.name),l=r.every(f=>o.includes(f)),d=o.filter(f=>!r.includes(f)),h=a.every(f=>!d.includes(f.name)||!f.required);return l&&h})||null}function aD(r,s,e=ft.OrDataTypeGroup){const t=[],i=[],a=[],l={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:r.toJSON(),isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parentRelationType:e,parent:s.toReference()},d=I(l,r.project);return i.push(d),d.setParent(s),d.initChildren(),d.setEntity(r),d.addSelfToProject(),{updated:m(t),added:m(i),removed:m(a),self:d}}function Pp(r,s,e,t){const i=[],a=[],o=[];switch(typeof r){case"string":let l=!1;const d=new Date(r);if(d instanceof Date&&!isNaN(d.valueOf())&&(l=!0),l){const h=s.project.getBuiltIn(_[n.PrimitiveEntity][V.Date].id);s.setEntity(h);break}else{const h=s.project.getBuiltIn(_[n.PrimitiveEntity][V.String].id);s.setEntity(h);break}case"number":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Number].id));break;case"boolean":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Boolean].id));break;case"object":if(r===null){s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Null].id));break}else if(Array.isArray(r))if(s.sync({isList:!0}),r.length>0){const h=r.slice(0,5).filter(f=>f!==void 0);if(h.every(f=>typeof f==typeof h[0])&&(typeof h[0]!="object"||h[0]===null))switch(typeof h[0]){case"string":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.String].id));break;case"number":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Number].id));break;case"boolean":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Boolean].id));break;case"object":s.setEntity(s.project.getBuiltIn(_[n.PrimitiveEntity][V.Null].id));break}else{const f=[];let v=!1;h.forEach(A=>{if(Array.isArray(A)&&(v=!0),typeof A=="object"&&!Array.isArray(A)&&A!==null){const D=_l(A,s.project,{...e,id:B.UUID.uuid()},t);D.hasCreated&&f.push(D.changeSet.self),i.push(...D.changeSet.updated),a.push(...D.changeSet.added),o.push(...D.changeSet.removed)}});const R=m(f);if(!R.length&&!v){h.forEach(A=>{const D={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parentRelationType:ft.OrDataTypeGroup,parent:s.toReference()},g=I(D,s.project);switch(g.setParent(s),g.initChildren(),g.addSelfToProject(),typeof A){case"string":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.String].id));break;case"number":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.Number].id));break;case"boolean":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.Boolean].id));break;case"object":g.setEntity(g.project.getBuiltIn(_[n.PrimitiveEntity][V.Null].id));break}});break}else R.length===1&&!v?s.setEntity(R[0]):h.forEach(A=>{if(typeof A=="object"&&!Array.isArray(A)&&A!==null){const D=Dp(Object.keys(A),s.project);if(D){const g=aD(D||R[0],s,ft.OrDataTypeGroup);i.push(...g.updated),a.push(...g.added),o.push(...g.removed)}}else{const D={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:null,isList:Array.isArray(A),asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parentRelationType:ft.OrDataTypeGroup,parent:s.toReference()},g=I(D,s.project);g.setParent(s),g.initChildren(),g.addSelfToProject();const M=Pp(A,g,{...e,id:B.UUID.uuid()},t);i.push(...M.updated),a.push(...M.added),o.push(...M.removed)}})}}else{const h=_l(r[0],s.project,{...e},t);s.setEntity(h.changeSet.self),i.push(...h.changeSet.updated),a.push(...h.changeSet.added),o.push(...h.changeSet.removed);break}else{const h=_l(r,s.project,{...e},t);s.setEntity(h.changeSet.self),i.push(...h.changeSet.updated),a.push(...h.changeSet.added),o.push(...h.changeSet.removed);break}}return{updated:m(i),added:m(a),removed:m(o),self:s}}function _l(r,s,e,t){const i=[],a=[],o=[],l=Object.keys(r),d=Dp(l,s);if(d)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],self:d}};const h=t?e.name+" of "+t.name:e.name,f={id:e.id||Fe(h,n.DefinitionEntity,s),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,name:h,type:n.DefinitionEntity,description:e.description||null,static:e.static||!1,abstract:e.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:s.toReference()},v=I(f,s);return v.setParent(s),v.initChildren(),v.addSelfToProject(),a.push(v),l.forEach((R,A)=>{const g={id:Fe(h+" "+R,n.Property,s),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,name:R,type:n.Property,description:null,static:!1,abstract:!1,defaultValue:null,constant:!1,dataType:null,implements:null,index:A,hidden:!1,private:!1,required:!0,parent:v.toReference()},M=I(g,s);M.setParent(v),M.initChildren(),M.addSelfToProject(),a.push(M);const Z=r[R],ee={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,like:!0,inferred:!1,parent:M.toReference()},oe=I(ee,s);oe.setParent(M),oe.initChildren(),oe.addSelfToProject(),a.push(oe);const ue=Pp(Z,oe,{...e,name:R,id:B.UUID.uuid()},t||v);i.push(...ue.updated),a.push(...ue.added),o.push(...ue.removed)}),{hasCreated:!0,changeSet:{updated:m(i),added:m(a),removed:m(o),self:v}}}function Nl(r,s){const e=Ri(r);if(e.length===0)return{list:[],last:null};let t=null;return{list:e.flatMap(a=>{if(a===s)return t=a,[a];const o=Nl(a,s);return o.last&&(t=o.last),[a,...o.list]}),last:t}}function sD(r,s,e=new Set){const t=Or(r),i=Or(s),a=t.filter(d=>!i.includes(d)),o=t.filter(d=>i.includes(d)),l=a.reduce((d,h)=>e.has(h.id)?d:(e.add(h.id),m([...d,...sD(h,s,e)])),[]);return m([...o,...l])}function Is(r,s){const e=Nl(r,s);return e.last===s&&e.list.length>0&&e.list[0]!==s}function rq(r,s){return!!Nl(r,s).last}function iq(r){if(ze.includes(r.type))return r;if([...vn,n.VariableDeclaration].includes(r.type)){const s=r.parent;return ze.includes(s.type)?s:null}return null}function Sp(r,s){if(!r||!s)throw new Error("Both entities must be defined to find a common ancestor");if(r===s)return r;const e=r.parent;if(e){if(e===s)return s;if(e.type===n.Project)return null}else return null;const t=s.parent;if(t){if(t===r)return r;if(t.type===n.Project)return null}else return null;return Sp(e,t)}function At(r){if(Bs.includes(r.type)){if(r.type===n.FunctionDeclaration){const s=r.parent;if(s.type===n.DefinitionEntity)return s;if(s.type===n.Loop)return s}return r}else{const s=r.parent;return s?At(s):null}}function Ll(r,s){const e=As(r,s);if(!e)return null;if(Bs.includes(e.type)){if(e.type===n.FunctionDeclaration){const t=As(e.parent,s);if(t){if(t.type===n.DefinitionEntity)return t;if(t.type===n.Loop)return t}}return e}else{const t=e.parent?As(e.parent,s):null;return t?Ll(t,s):null}}function oD(r){if(!r)return null;if(vn.includes(r.type))return r;const s=r.parent;return s?oD(s):null}function lD(r){if(!r)return null;if(Qe.includes(r.type))return r;const s=r.parent;return s?lD(s):null}function dD(r){if(!r)return null;if(Dn.includes(r.type))return r;const s=r.parent;return s?dD(s):null}function aq(r){return r.type===n.VariableDeclaration?[r]:Qe.includes(r.type)?[...r.inputs,...r.outputs||[]]:et.includes(r.type)?r.outputs:Pi.includes(r.type)||r.type===n.FunctionDeclaration?r.inputs:[]}function sq(r){const s=Or(r),e=[],t=[];Jp.includes(r.type)&&e.push(...Op(r));const i=s.filter(a=>{const o=e.includes(a);return o?!1:vn.includes(a.type)&&!o?(t.push(a),!1):!0});return e.sort((a,o)=>Is(o,a)?-1:0),t.sort((a,o)=>Is(o,a)?-1:0),[...e,...t,...i]}function uD(r){return[...r].sort((s,e)=>Is(e,s)?-1:0)}function oq(r){const s=uD(r),e=[];return s.forEach(t=>{const i=e[e.length-1];if(i){const a=i[i.length-1];Is(t,a)?e.push([t]):i.push(t)}else e.push([t])}),e}function Zt(r){const s=r.map(e=>At(e));return m(s)}function Op(r){return Qe.includes(r.type)?[...Zt(r.successCalls),...Zt(r.errorCalls)]:ze.includes(r.type)?Zt(r.calls):[]}function lq(r,s){return Op(r).includes(s)}function Vp(r){return r.writesValues||[]}function dq(r,s){return Vp(r).includes(s)}function cD(r){var s;return We.includes((s=r==null?void 0:r.readsValue)==null?void 0:s.type)?r.readsValue:null}function uq(r){return r.writesValues}function pD(r=[]){return r.map(cD).filter(s=>!!s)}function Gl(r=[]){return r.map(s=>s.writesValues).flat().filter(s=>We.includes(s.type))}function hD(r=[]){return r.map(s=>s.readsValue).filter(s=>!!s&&We.includes(s.type))}function yD(r){return We.includes(r.type)?r:null}function fD(r){return r.writesValues.map(yD).filter(s=>!!s)}function mD(r=[]){return r.reduce((s,e)=>e.type===n.OutputMap?[...s,...fD(e)]:s,[])}function Xe(r){return Qe.includes(r.type)?[...Un(Zt(r.successCalls)),...Un(Zt(r.errorCalls))]:ze.includes(r.type)?Un(Zt(r.calls)):[]}function cq(r){return Qe.includes(r.type)?[...Un(Zt(r.successCalls)),...Un(Zt(r.errorCalls))]:ze.includes(r.type)?Un(Zt(r.calls)):[]}function TD(r,s=new Set){return r.writesValues.filter(t=>We.includes(t.type)&&!s.has(t.id)).reduce((t,i)=>s.has(i.id)?t:[...t,...xe(i,s)],[])}function vD(r,s=new Set){var t;return(((t=r.readsValue)==null?void 0:t.writesValues)||[]).filter(i=>We.includes(i.type)&&!s.has(i.id)).reduce((i,a)=>s.has(a.id)?i:[...i,...xe(a,s)],[])}function xe(r,s=new Set){if(s.has(r.id))return[];if(r.type===n.ReturnStatement)return hD(r.outputs).reduce((t,i)=>[...t,...xe(i,s)],[]);if(r.type===n.FunctionCall||r.type===n.Operation||r.type===n.Condition)return[...Xe(r).reduce((a,o)=>{const l=At(o);return[...a,...xe(l||o,s)]},[]),...pD(r.inputs),...mD(r.outputs)].reduce((a,o)=>[...a,...xe(o,s)],[]);if(Pi.includes(r.type)){const e=Gl(r.inputs),i=Xe(r).reduce((a,o)=>{const l=At(o);return[...a,...xe(l||o,s)]},[]);return e.push(...i),e.reduce((a,o)=>[...a,...xe(o,s)],[])}if(r.type===n.FunctionDeclaration){const e=[...Gl(r.inputs)],i=Xe(r).reduce((a,o)=>{const l=At(o);return[...a,...xe(l||o,s)]},[]);return e.push(...i),e.reduce((a,o)=>[...a,...xe(o)],[])}if(We.includes(r.type)){s.add(r.id);const t=Xe(r).reduce((i,a)=>{const o=At(a);return[...i,...xe(o||a,s)]},[]);return[r,...t,...vD(r,s),...TD(r,s)]}return[]}function Kt(r,s=new Set){return s.has(r.id)?[]:(s.add(r.id),[...Or(r).reduce((i,a)=>[...i,a,...Kt(a,s)],[])])}function Un(r){return r.reduce((s,e)=>e.type===n.ReturnStatement||e.type===n.ContinueStatement||e.type===n.BreakStatement?[...s,e]:[...s,e,...Xe(e)],[])}function ED(r){const s=r.entities||[],e=[...s,...r.functions||[],...r.events||[],...r.projects||[]],t=s.reduce((d,h)=>[...d,...h.properties],[]),i=s.reduce((d,h)=>[...d,...h.methods],[]),a=i.reduce((d,h)=>[...d,...Gl(h.inputs),...Un(Zt(h.calls)),...h.returnStatements],[]),o=r.functions.reduce((d,h)=>[...d,...Un(Zt(h.calls)),...h.returnStatements],[]),l=r.events.reduce((d,h)=>[...d,...Un(Zt(h.calls)),...h.returnStatements],[]);return[...e,...t,...i,...a,...o,...l]}function RD(r,s){return s.filter(t=>{if(!t)return!1;switch(t.type){case n.FunctionCall:return t.inputs.find(i=>i.id===r.id)!==void 0||t.outputs.find(i=>i.id===r.id)!==void 0;case n.Condition:return t.successCalls.find(i=>i.id===r.id)!==void 0||t.errorCalls.find(i=>i.id===r.id)!==void 0||t.inputs.find(i=>i.id===r.id)!==void 0;case n.Operation:return t.outputs.find(i=>i.id===r.id)!==void 0;case n.VariableDeclaration:return Qe.includes(r.type)?HD(r).find(a=>{var o;return((o=a.readsValue)==null?void 0:o.id)===t.id})!==void 0:!1;case n.DefinitionEntity:return t.properties.find(i=>i.id===r.id)!==void 0||t.methods.find(i=>i.id===r.id)!==void 0;case n.FunctionDeclaration:return t.inputs.find(i=>i.id===r.id)!==void 0||(t.returnStatements.map(i=>i.outputs).flat()||[]).find(i=>i.id===r.id)!==void 0;default:return!1}})}function pq(r){const s=ED(r.project);return RD(r,s)}function As(r,s){return r?typeof r=="string"?s[r]:r.type===n.GenericReference?s[r.entityId]:s[r.id]?s[r.id]:null:null}function hq(r){const s=r,e=r,t=r,i=r,a=r,o=r,l=r,d=r,h=r,y=r,f=r,v=r,R=r,A=[...(s.inputs||[]).flatMap(g=>g),...(f.inputsDeclarations||[]).flatMap(g=>g),...(s.outputs||[]).flatMap(g=>g),...(f.outputsDeclarations||[]).flatMap(g=>g),...(R.internalCalls||[]).flatMap(g=>g),...R.writesValues||[],...R.readsValue?[R.readsValue]:[],...R.declaration?[R.declaration]:[],...v.dataType?[v.dataType]:[],...o.body?[o.body]:[],...v.defaultValue?[v.defaultValue]:[],...(v.calledByEntry||[]).flatMap(g=>g),...(v.calledBySuccess||[]).flatMap(g=>g),...(v.calledByError||[]).flatMap(g=>g),...(v.successCalls||[]).flatMap(g=>g),...(v.errorCalls||[]).flatMap(g=>g),...(t.properties||[]).flatMap(g=>g),...(t.extends||[]).flatMap(g=>g),...(t.methods||[]).flatMap(g=>g),...(t.abstractMethods||[]).flatMap(g=>g),...l.error?[l.error]:[],...l.process?[l.process]:[],...y.throws?[y.throws]:[],...y.parent?[y.parent]:[],...e.entity?[e.entity]:[],...(e.andChildrenGroup||[]).flatMap(g=>g),...(e.orChildrenGroup||[]).flatMap(g=>g),...(d.entities||[]).flatMap(g=>g),...(d.functions||[]).flatMap(g=>g),...(d.functionCalls||[]).flatMap(g=>g),...(d.events||[]).flatMap(g=>g),...(d.conditions||[]).flatMap(g=>g),...(d.operations||[]).flatMap(g=>g),...(d.loops||[]).flatMap(g=>g),...(d.variableDeclarations||[]).flatMap(g=>g),...(d.variableInstances||[]).flatMap(g=>g),...(d.searches||[]).flatMap(g=>g),...(d.projects||[]).flatMap(g=>g),...(i.calls||[]).flatMap(g=>g)];Array.isArray(t.implements)?A.push(...t.implements.flatMap(g=>g)):h.implements&&A.push(h.implements),Array.isArray(a.valueAsType)?A.push(...a.valueAsType.flatMap(g=>g)):a.valueAsType&&A.push(a.valueAsType);const D={};return A.forEach(g=>{const M=g.version,Z=P(g);Z&&(D[Z]=M)}),D}function gD(r,s){const e=[];if(vn.includes(r.type)){ln(r).forEach(a=>{const o=Ll(a,s);o&&e.push(o)});const i=[...r.inputs||[],...r.outputs||[]].map(a=>{const o=As(a,s);return o?KD(o,s):null}).filter(a=>a!==null);e.push(...m(i))}if(We.includes(r.type)){const t=Fl(r);t&&e.push(t)}return m(e)}function Ri(r){const s=[];if(vn.includes(r.type)){r.calledBy.forEach(i=>{const a=At(i);a&&s.push(a)});const t=[...r.inputs||[],...r.outputs||[]].map(i=>Fl(i)).filter(i=>i!==null);s.push(...m(t))}if(We.includes(r.type)){const e=Fl(r);e&&s.push(e)}return m(s)}function ln(r){return[...r.calledByEntry||[],...r.calledByError||[],...r.calledBySuccess||[]].filter(s=>s.type!==n.GenericReference)}function bD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[r,...r.inputs.flatMap(t=>S(t,s,e)),...r.outputs.flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.parent?S(r.parent,s,e):[]]}function ID(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[r,...r.defaultValue?S(r.defaultValue,s):[],...r.writesValues.flatMap(t=>S(t,s,e)),...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function AD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[r,...r.outputs.flatMap(t=>S(t,s,e)),...r.throws?S(r.throws,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function DD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[r,...(r.properties||[]).flatMap(t=>S(t,s,e)),...(r.methods||[]).flatMap(t=>S(t,s,e)),...(r.abstractMethods||[]).flatMap(t=>S(t,s,e)),...(r.extends||[]).flatMap(t=>S(t,s,e))]}function PD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Condition)throw new Error("Entity must be a condition to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function SD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[r,...r.outputs.flatMap(t=>S(t,s,e)),...r.throws?S(r.throws,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function OD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[r,...(r.extends||[]).flatMap(t=>S(t,s,e)),...(r.implements||[]).flatMap(t=>S(t,s,e)),...(r.properties||[]).flatMap(t=>S(t,s,e)),...(r.methods||[]).flatMap(t=>S(t,s,e)),...(r.abstractMethods||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function VD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.DataType)throw new Error("Entity must be a data type to be flattened");return[r,...(r.andChildrenGroup||[]).flatMap(t=>S(t,s,e)),...(r.orChildrenGroup||[]).flatMap(t=>S(t,s,e)),...r.entity?S(r.entity,s,e):[],...r.parent?S(r.parent,s,e):[]]}function CD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function wD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.returnStatements||[]).flatMap(t=>S(t,s,e)),...(r.calls||[]).flatMap(t=>S(t,s,e)),...r.implements?S(r.implements,s,e):[],...r.parent?S(r.parent,s,e):[]]}function BD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.calls||[]).flatMap(t=>S(t,s,e)),...(r.returnStatements||[]).flatMap(t=>S(t,s,e)),...r.implements?S(r.implements,s,e):[],...r.parent?S(r.parent,s,e):[]]}function MD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.InputMap)throw new Error("Entity must be an input map to be flattened");return[r,...r.readsValue?S(r.readsValue,s,e):[],...r.declaration?S(r.declaration,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...r.parent?S(r.parent,s,e):[]]}function _D(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[r,...(r.functions||[]).flatMap(t=>S(t,s,e)),...(r.events||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function ND(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...r.parent?S(r.parent,s,e):[]]}function LD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[r,...r.valueAsType?Array.isArray(r.valueAsType)?r.valueAsType.flatMap(t=>S(t,s,e)):S(r.valueAsType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function GD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Loop)throw new Error("Entity must be a loop to be flattened");return[r,...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...r.body?S(r.body,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...(r.breakStatements||[]).flatMap(t=>S(t,s,e)),...(r.continueStatements||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function $D(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Operation)throw new Error("Entity must be an operation to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...r.process?S(r.process,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function FD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.OutputMap)throw new Error("Entity must be an output map to be flattened");return[r,...(r.writesValues||[]).flatMap(t=>S(t,s,e)),...r.declaration?S(r.declaration,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...r.parent?S(r.parent,s,e):[]]}function UD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[r,...(r.properties||[]).flatMap(t=>S(t,s,e)),...(r.methods||[]).flatMap(t=>S(t,s,e)),...(r.abstractMethods||[]).flatMap(t=>S(t,s,e))]}function xD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Project)throw new Error("Entity must be a project to be flattened");return[r,...(r.entities||[]).flatMap(t=>S(t,s,e)),...(r.functions||[]).flatMap(t=>S(t,s,e)),...(r.events||[]).flatMap(t=>S(t,s,e)),...(r.projects||[]).flatMap(t=>S(t,s,e)),...(r.variableDeclarations||[]).flatMap(t=>S(t,s,e)),...(r.variableInstances||[]).flatMap(t=>S(t,s,e)),...(r.operations||[]).flatMap(t=>S(t,s,e)),...(r.conditions||[]).flatMap(t=>S(t,s,e)),...(r.functionCalls||[]).flatMap(t=>S(t,s,e)),...(r.projects||[]).flatMap(t=>S(t,s,e)),...(r.loops||[]).flatMap(t=>S(t,s,e)),...(r.searches||[]).flatMap(t=>S(t,s,e))]}function jD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Property)throw new Error("Entity must be a property to be flattened");return[r,...r.defaultValue?S(r.defaultValue,s,e):[],...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function kD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ReturnDeclaration)throw new Error("Entity must be a return declaration to be flattened");return[r,...r.readsValue?S(r.readsValue,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function ZD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[r,...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.throws?S(r.throws,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function qD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.Search)throw new Error("Entity must be a search to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputsDeclarations||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputsDeclarations||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...r.error?S(r.error,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.parent?S(r.parent,s,e):[]]}function JD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[r,...r.defaultValue?S(r.defaultValue,s,e):[],...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function WD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(r.internalCalls||[]).flatMap(t=>S(t,s,e)),...(r.writesValues||[]).flatMap(t=>S(t,s,e)),...r.readsValue?S(r.readsValue,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.dataType?S(r.dataType,s,e):[],...r.parent?S(r.parent,s,e):[]]}function YD(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(s.has(r.id))return[];if(s.add(r.id),r.type!==n.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[r,...(r.successCalls||[]).flatMap(t=>S(t,s,e)),...(r.errorCalls||[]).flatMap(t=>S(t,s,e)),...(r.inputs||[]).flatMap(t=>S(t,s,e)),...(r.outputs||[]).flatMap(t=>S(t,s,e)),...(r.internalCalls||[]).flatMap(t=>S(t,s,e)),...(r.writesValues||[]).flatMap(t=>S(t,s,e)),...r.readsValue?S(r.readsValue,s,e):[],...r.defaultValue?S(r.defaultValue,s,e):[],...(ln(r)||[]).flatMap(t=>S(t,s,e)),...r.declaration?S(r.declaration,s,e):[],...r.parent?S(r.parent,s,e):[]]}function Cp(){const r=new Set;return ZE.flatMap(e=>S(e,r)).map(e=>e.id)}function S(r,s=new Set,e={ignoreBuiltInBaseEntities:!1}){if(!r)throw new Error("Entity must be defined to be flattened");if(r.type===n.GenericReference)return[];if(e.ignoreBuiltInBaseEntities&&(ur.includes(r.type)||Cp().includes(r.id)))return[];if(s.has(r.id))return[];switch(r.type){case n.FunctionCall:return CD(r,s,e);case n.Operation:return $D(r,s,e);case n.Condition:return PD(r,s,e);case n.Loop:return GD(r,s,e);case n.Search:return qD(r,s,e);case n.GlobalEvent:return BD(r,s,e);case n.ReturnStatement:return ZD(r,s,e);case n.ContinueStatement:return SD(r,s,e);case n.BreakStatement:return AD(r,s,e);case n.VariableDeclaration:return WD(r,s,e);case n.DefinitionEntity:return OD(r,s,e);case n.FunctionDeclaration:return wD(r,s,e);case n.Project:return xD(r,s,e);case n.ActionDescriptor:return bD(r,s,e);case n.ArgumentDeclaration:return ID(r,s,e);case n.ReturnDeclaration:return kD(r,s,e);case n.ValueDescriptor:return JD(r,s,e);case n.InputMap:return MD(r,s,e);case n.OutputMap:return FD(r,s,e);case n.DataType:return VD(r,s,e);case n.InstalledProject:return _D(r,s,e);case n.InternalCall:return ND(r,s,e);case n.LiteralValue:return LD(r,s,e);case n.Property:return jD(r,s,e);case n.VariableInstance:return YD(r,s,e);case n.BuiltInBaseEntity:return e.ignoreBuiltInBaseEntities?[]:DD(r,s,e);case n.PrimitiveEntity:return e.ignoreBuiltInBaseEntities?[]:UD(r,s,e)}return[]}function $l(r,s){if(ur.includes(r.type))return new Set;const e=gD(r,s),t=new Set(e.map(i=>i.id));if(r.type===n.LiteralValue&&r.valueAsType&&(Array.isArray(r.valueAsType)?r.valueAsType.forEach(i=>{t.add(i.id)}):t.add(r.valueAsType.id)),r.type===n.DataType&&r.entity&&(r.entity.type===n.DefinitionEntity?(r.entity.parent.entityId||r.entity.parent.id)!==r.id&&t.add(r.entity.id):t.add(r.entity.id)),kp.includes(r.type)){const i=r.parent;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(Zp.includes(r.type)){const i=r.implements;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(Hl.includes(r.type)){const i=r.declaration;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(kn.includes(r.type)){const i=r.readsValue;i&&(i.type===n.GenericReference?t.add(i.entityId):t.add(i.id))}if(vn.includes(r.type)){const i=[...r.calledBySuccess||[],...r.calledByEntry||[],...r.calledByError||[]];i.length&&i.forEach(a=>{a.type===n.GenericReference?t.add(a.entityId):t.add(a.id)})}return t}function wp(r){return r.type===n.FunctionCall||r.type===n.InternalCall||[n.Operation,n.Condition,n.Loop].includes(r.type)?r.declaration.inputs:r.type===n.FunctionDeclaration||Pi.includes(r.type)?r.inputs:r.type===n.Search?r.inputsDeclarations:[]}function yq(r,s){return s.type===n.Condition?s.inputs.find(e=>e.declaration.id===r.id):s.type===n.FunctionCall||s.type===n.Operation?s.inputs.find(e=>e.declaration.id===r.id):null}function HD(r){return Qe.includes(r.type)?r.inputs:[]}function zD(r){var s;return r.type===n.FunctionCall?((s=r.declaration.returnStatements[0])==null?void 0:s.outputs)||[]:[n.Operation,n.Condition,n.Loop].includes(r.type)?r.declaration.outputs:r.type===n.Search?r.outputsDeclarations:et.includes(r.type)?r.outputs:[]}function fq(r,s){return s.type===n.Condition?null:s.type===n.FunctionCall||s.type===n.Operation?s.outputs.find(e=>e.declaration.id===r.id):null}function mq(r){return r.type===n.Condition?[]:Qe.includes(r.type)?r.outputs:[]}function Fl(r){const s=r.readsValue;return s?At(s):null}function KD(r,s){const e=r.readsValue;return e?Ll(e,s):null}function XD(r){const s=r.internalCalls||[];return m(Zt(m(s.flatMap(e=>[...e.successCalls,...e.errorCalls]))))}function ma(r){const s=Vp(r),e=[];return s.forEach(t=>{if(We.includes(t.type))e.push(t);else if(kn.includes(t.type)){const i=t.parent;e.push(i)}}),e}function m(r){const s=new Set;return r.filter(e=>!e||s.has(e.id)?!1:(s.add(e.id),!0))}function Or(r,s=!1){const e=[];if(r.type===n.Project&&e.push(...(r==null?void 0:r.entities)||[],...(r==null?void 0:r.functions)||[],...(r==null?void 0:r.variableDeclarations)||[],...(r==null?void 0:r.variableInstances)||[],...(r==null?void 0:r.searches)||[],...(r==null?void 0:r.loops)||[],...(r==null?void 0:r.operations)||[],...(r==null?void 0:r.conditions)||[],...(r==null?void 0:r.functionCalls)||[],...(r==null?void 0:r.events)||[],...(r==null?void 0:r.projects)||[]),ut.includes(r.type)&&e.push(...(r==null?void 0:r.detachedChildren)||[]),r.type===n.DefinitionEntity){const t=[...r.suggestedMethods,...r.methods].flatMap(i=>i.collapsed&&s?[]:Or(i));e.push(...t)}if(r.type===n.Condition){const t=r.successCalls.map(a=>At(a)),i=r.errorCalls.map(a=>At(a));e.push(...t,...i)}if(Pi.includes(r.type)){if(r.collapsed&&s)return[];const t=r.inputs.map(a=>ma(a)).flat(),i=r.calls.map(a=>At(a));e.push(...m(t),...i)}if(Qe.includes(r.type)&&r.type!==n.Condition&&r.type!==n.Loop){const t=r==null?void 0:r.outputs.map(o=>ma(o)).flat(),i=r.successCalls.map(o=>At(o)),a=r.errorCalls.map(o=>At(o));e.push(...m(t),...i,...a)}if(We.includes(r.type)){const t=ma(r),i=XD(r);e.push(...t,...i)}if(r.type===n.Loop){const t=r.outputs.map(o=>ma(o)).flat();if(r.body){const o=Or(r.body,s);e.push(...o)}const i=r.errorCalls.map(o=>At(o)),a=r.successCalls.map(o=>At(o));e.push(...m(t),...a,...i)}if(r.type===n.FunctionDeclaration){if(r.collapsed&&s)return[];const t=r.inputs.map(a=>ma(a)).flat(),i=r.calls.map(a=>At(a));e.push(...m(t),...i)}return m(e)}function QD(r,s=!1){const e=Or(r,s),t=[...e,...e.reduce((i,a)=>[...i,...QD(a,s)],[])];return m(t)}function eP(r){const s=Ri(r),e=[...s,...s.reduce((t,i)=>[...t,...eP(i)],[])];return m(e)}function Ul(r){return r.implements.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,n.DefinitionEntity,...Ul(e),...xl(e)]:[...s,e.name],[])}function xl(r){return r.extends.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,n.DefinitionEntity,...xl(e),...Ul(e)]:[...s,e.name],[])}function Bp(r){return r.extends.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,e,...Bp(e),...Mp(e)]:[...s,e],[])}function Mp(r){return r.implements.reduce((s,e)=>e.type===n.DefinitionEntity?[...s,e,...Mp(e),...Bp(e)]:[...s,e],[])}function _p(r){return[...xl(r),...Ul(r)].filter((e,t,i)=>i.indexOf(e)===t)}function tP(r){return r.implements.length===0&&r.extends.length===0?null:r.implements.find(t=>t.type===n.BuiltInBaseEntity&&t.name===j.PERSISTED_ENTITY)?r:[...r.implements,...r.extends].reduce((t,i)=>{if(i.type===n.DefinitionEntity){const a=tP(i);if(a)return a}return t},null)}function Tq(r){const s=r.extends.find(e=>e.type===n.BuiltInBaseEntity);return s&&s.type===n.BuiltInBaseEntity?s:null}function vq(r){const s=r.implements.find(e=>e.type===n.BuiltInBaseEntity);return s&&s.type===n.BuiltInBaseEntity?s:null}function Np(r){const s=r.extends.find(e=>e.type===n.DefinitionEntity);return s&&s.type===n.DefinitionEntity?s:null}function Vr(r){const s=[...r.implements,...r.extends].reduce((e,t)=>t.type===n.BuiltInBaseEntity?[...e,t]:t.type===n.DefinitionEntity?[...e,...Vr(t)]:e,[]);return m(s)}function Lp(r){return r.type===n.PrimitiveEntity?!0:r.type===n.BuiltInBaseEntity?r.interactive:!Vr(r).find(t=>!t.interactive)}function Eq(r){return r.parent===r.project&&r.project.variableDeclarations.includes(r)}function Gp(r){return r.parent!==r.project?!1:n.VariableDeclaration===r.type?r.project.variableDeclarations.includes(r):n.VariableInstance===r.type?r.project.variableInstances.includes(r):n.FunctionCall===r.type?r.project.functionCalls.includes(r):n.Condition===r.type?r.project.conditions.includes(r):n.Operation===r.type?r.project.operations.includes(r):n.Loop===r.type?r.project.loops.includes(r):n.Search===r.type?r.project.searches.includes(r):!1}function nP(r){if([...ze,n.DefinitionEntity,n.InstalledProject,n.Project].includes(r.type)||Gp(r))return!1;const s=Ri(r);return s.length===0?!0:s.some(e=>nP(e))}function $p(r){return[...ze,n.DefinitionEntity,n.InstalledProject,n.Project].includes(r.type)||Gp(r)?!1:Ri(r).length===0}function rP(r,s=0){if($p(r)){const e=Ri(r);return e.length===0?r:e.map(i=>rP(i,s+1)).reduce((i,a)=>i?a&&a.x<i.x?a:i:a,null)}return null}function iP(r){const s=[];if($p(r))s.push(r);else return[];return Ri(r).forEach(t=>{s.push(...iP(t))}),s}function aP(r){return r.type===n.FunctionDeclaration&&r.parent!==r.project&&!![n.DefinitionEntity,n.Loop,n.InstalledProject].includes(r.parent.type)}function Rq(r,s){const e=new Map;return r.forEach(t=>{e.set(t.id,t)}),s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())}function jl(r){switch(r){case n.DefinitionEntity:return gi;case n.FunctionDeclaration:return li;case n.VariableDeclaration:return pi;case n.VariableInstance:return hi;case n.FunctionCall:return Ei;case n.Operation:return di;case n.Condition:return ci;case n.ReturnStatement:return Ti;case n.Loop:return ui;case n.Search:return yi;case n.InputMap:return sr;case n.OutputMap:return or;case n.ArgumentDeclaration:return mi;case n.ReturnDeclaration:return on;case n.Property:return oi;case n.InstalledProject:return fi;case n.Project:return B;case n.BuiltInBaseEntity:return xn;default:return null}}function qt(r,s){if(ut.includes(r.type))return r;if(ur.includes(r.type))return null;const e=r.parent;if(!e)return null;if(e.type===n.GenericReference){const t=P(e);if(!t)return null;const i=s.get(t);return i?qt(i,s):null}else return e===s?s:qt(e,s)}function Fp(r,s){if(ur.includes(r.type)||s.getBuiltIn(r.id))return null;const e=Xt(r.parent,s);return e?e===s?ut.includes(r.type)?r:null:e.type===n.DefinitionEntity?r:Fp(e,s):null}function kl(r,s,e){if(r===s||s===e||r===e)return!1;const t=qt(s.parent,e);return t===r?!0:kl(t,s,e)}var Zl=(r=>(r.SameBothLocal="same-both-local",r.AInB="a-in-b",r.BInA="b-in-a",r.ParallelInCommonParent="parallel-in-common-parent",r.ParallelInProject="parallel-in-project",r.AIsGlobalBIsNot="a-is-global-b-is-not",r.BIsGlobalAIsNot="b-is-global-a-is-not",r.SameBothGlobal="same-both-global",r))(Zl||{});function Ds(r,s,e){const t=qt(r,e),i=qt(s,e);if(!t)throw new Error("Could not find scope owner for the entity: "+r.id);if(!i)throw new Error("Could not find scope owner for the entity: "+s.id);if(t===i&&t.type!==n.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:t};if(t===i&&t.type===n.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:t};if(t.type===n.Project&&i.type!==n.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:t};if(t.type!==n.Project&&i.type===n.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:i};if(kl(t,i,e))return{compatible:!0,type:"b-in-a",commonAncestorScope:t};if(kl(i,t,e))return{compatible:!0,type:"a-in-b",commonAncestorScope:i};const l=Sp(t,i);return l===e?{compatible:!1,type:"parallel-in-project",commonAncestorScope:l}:l?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:qt(l,e)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:e}}function sP(r,s,e){const t=Ds(r,s,e);if(!t.compatible||t.type!=="same-both-local")return null;if(r===s)return r;let i=qt(r.parent,e);if(i){if(i===s)return s;if(i.type===n.Project)return r}else return r;for(;i;){if(i){if(i===s)return s;if(i.type===n.Project)return r}else return r;i=qt(i.parent,e)}let a=qt(s.parent,e);if(a){if(a===r)return r;if(a.type===n.Project)return s}else return s;for(;a;){if(a){if(a===r)return r;if(a.type===n.Project)return s}else return s;a=qt(a.parent,e)}return null}function oP(r){return r.length===0?null:r.length===1?r[0]:r.reduce((e,t)=>{const i=sP(e,t,t.project);return!i||i===t?e:t},r[0])}function Xt(r,s){if(!r)return null;let e;return typeof r=="string"?e=r:r.type===n.GenericReference?e=P(r):e=r.id,e===s.id?s:s.get(e)}function Cr(r){if(!r)return null;if(ur.includes(r.type))return r;if(r.type===n.Project)return null;if(r.project.getBuiltIn(r.id))return r;const s=r.parent;return!s||s.type===n.Project?null:Cr(s)}function gq(r,s){var e;if(r.readsValue){const t=Xt(r.readsValue,s.project);s.setValueWriter(t),t.addValueReader(s)}else r.readsValue===null&&((e=s.readsValue)==null||e.removeValueReader(s),s.readsValue=null);return s}function Ps(r){const s=[];function e(a,o){return s.some(l=>l.blockedByCaller===a&&l.blockedByCalling===o)}function t(a,o){e(a,o)||s.push({blockedByCaller:a,blockedByCalling:o})}const i=Fp(r,r.project);return r.calledBySuccess.forEach(a=>{[...a.successCalls||[]].forEach(d=>{et.includes(d.type)&&d!==r&&(Xe(r).find(f=>f===d)||t(a,d))});let l;if(Qe.includes(a.type)&&(l=a),l){const d=Ps(l);d.reachable||Xe(r).find(f=>f===a)||d.blocks.forEach(f=>{t(a,f.blockedByCalling)})}}),r.calledByError.forEach(a=>{[...a.errorCalls||[]].forEach(d=>{et.includes(d.type)&&d!==r&&(Xe(r).find(f=>f===d)||t(a,d))});let l;if(Qe.includes(a.type)&&(l=a),l){const d=Ps(l);d.reachable||Xe(r).find(f=>f===a)||d.blocks.forEach(f=>{t(a,f.blockedByCalling)})}}),r.calledByEntry.forEach(a=>{if([...a.calls||[]].forEach(d=>{et.includes(d.type)&&d!==r&&(Xe(r).find(f=>f===d)||t(a,d))}),a===i)return;let l;if(a.type===n.FunctionDeclaration){const d=At(a);if(d.type===n.DefinitionEntity)return;d.type===n.Loop&&(l=d)}if(l){const d=Ps(l);d.reachable||d.blocks.forEach(h=>{t(a,h.blockedByCalling)})}}),{reachable:s.length===0,entryPoint:i,blocks:s}}function bq(r){return Bs.includes(r.type)?r.type===n.FunctionDeclaration?!aP(r):!0:!1}function Iq(r){if(n.ActionDescriptor===r.type){if(r.project.operationDeclarations.find(a=>a.id===r.id))return n.Operation;if(r.project.globalEventActionDescriptors.find(a=>a.id===r.id))return n.GlobalEvent;if(r.project.loopDeclarations.find(a=>a.id===r.id))return n.Loop;if(r.project.conditionDeclarations.find(a=>a.id===r.id))return n.Condition}return r.type}function Ta(r,s){if(r.type!==n.DefinitionEntity||r.abstract)return!1;const e=Np(r)||r;return!!_p(e).includes(s)}function Aq(r){const s=[];return r.entities.forEach(e=>{if(Ta(e,j.PERSISTED_ENTITY)){s.push(e);return}}),m(s)}function Dq(r){const s=[];return r.entities.forEach(e=>{if(Ta(e,j.RELATIONAL_DATABASE)){s.push(e);return}}),m(s)}function Pq(r){return r.type!==n.DefinitionEntity||r.abstract||!Ta(r,j.PERSISTED_ENTITY)?null:(r==null?void 0:r.properties.find(e=>{var t;return((t=e.implements)==null?void 0:t.id)===_[n.BuiltInBaseEntity][j.PERSISTED_ENTITY].properties.primaryKey.id&&!e.abstract}))||null}function Sq(r){if(r.type!==n.DefinitionEntity)return[];if(r.abstract)return[];if(!Ta(r,j.PERSISTED_ENTITY))return[];const s=[],e=r.properties.filter(t=>{var i;return((i=t.implements)==null?void 0:i.id)!==_[n.BuiltInBaseEntity][j.PERSISTED_ENTITY].properties.database.id&&!t.abstract});return s.push(...e),s}function Oq(r){var e;if(!r||r.type!==n.DefinitionEntity||!Ta(r,j.PERSISTED_ENTITY))return null;const s=r.properties.find(t=>{var i;return((i=t.implements)==null?void 0:i.id)===_[n.BuiltInBaseEntity][j.PERSISTED_ENTITY].properties.database.id});return(e=s==null?void 0:s.getDefaultValue())==null?void 0:e.valueAsType}function st(r,s){var t;if(!Yp.includes(s.type)||!r)return s.project||null;let e=s.project;return r.type===n.Project?e=r:((t=s.project)==null?void 0:t.id)!==r.project.id&&(e=r.project),e}function Vq(r,s){const e=[];if(r.parent)if(r.id===r.parent)e.push(new b({id:`${r.id}--${r.parent}--${T.SelfReference}`,code:T.SelfReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.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 t=s.get(r.parent);t?[n.Project,n.DataType].includes(t.type)||e.push(new b({id:`${r.id}--${r.parent}--${T.InvalidParentReference}`,code:T.InvalidParentReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):e.push(new b({id:`${r.id}--${r.parent}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${r.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return r.implements&&Array.isArray(r.implements)?r.implements.forEach(t=>{if(r.id===t){e.push(new b({id:`${r.id}--${t}--${T.SelfReference}`,code:T.SelfReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.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 i=s.get(t);i?[n.DefinitionEntity,n.BuiltInBaseEntity].includes(i.type)?i.abstract||e.push(new b({id:`${r.id}--${t}--${T.InvalidImplementsReference}`,code:T.InvalidImplementsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):e.push(new b({id:`${r.id}--${t}--${T.InvalidImplementsReference}`,code:T.InvalidImplementsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):e.push(new b({id:`${r.id}--${t}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${t}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):e.push(new b({id:`${r.id}--${w.InvalidObjectStructure}`,code:w.InvalidObjectStructure,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' property that isn't an array.`,issue:null})),r.extends&&Array.isArray(r.extends)&&r.extends.forEach(t=>{const i=s.get(t);i?[n.DefinitionEntity,n.BuiltInBaseEntity].includes(i.type)?i.abstract&&e.push(new b({id:`${r.id}--${t}--${T.InvalidExtendsReference}`,code:T.InvalidExtendsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.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})):e.push(new b({id:`${r.id}--${t}--${T.InvalidExtendsReference}`,code:T.InvalidExtendsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'extends' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):e.push(new b({id:`${r.id}--${t}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${t}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),e}const we=class we extends Ke{constructor(e,t){super(e);u(this,"initialData");u(this,"id");u(this,"name");u(this,"description",null);u(this,"x");u(this,"y");u(this,"static");u(this,"abstract");u(this,"type",n.DefinitionEntity);u(this,"properties",[]);u(this,"methods",[]);u(this,"abstractMethods",[]);u(this,"extends",[]);u(this,"implements",[]);u(this,"project");u(this,"errors",[]);u(this,"parent");u(this,"initialized",!1);u(this,"suggestedProperties",[]);u(this,"suggestedMethods",[]);this.initialData=e,this.project=t,this.id=e.id,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 i=t;if(e.parent){const h=P(e.parent);i=t.get(h)}const a=[];e.implements&&e.implements.forEach(h=>{a.push(t.get(h)||t.getBuiltIn(h))});const o=[];e.extends&&e.extends.forEach(h=>{o.push(t.get(h)||t.getBuiltIn(h))});const l={id:e.id,version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,name:e.name,type:n.DefinitionEntity,description:e.description,static:e.static,abstract:e.abstract,properties:[],methods:[],abstractMethods:[],extends:o,implements:a,x:0,y:0,parent:i},d=I(l,t);return d.setParent(i),d.initChildren(),d}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],o=Vq(i,t),l=Al(i,t);a.push(...o,...l,...tt(i));const d=i.parent?t.get(i.parent):null;if(d&&d.type===n.DataType){const h=d;h.entity&&a.push(new b({id:`${e.id}--${T.NewEntityWouldOverriteExisting}`,code:T.NewEntityWouldOverriteExisting,severity:E.Error,message:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${h.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
404
404
  You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
405
405
  ${Fn({describe_entity:h.entity.id})}
406
406
  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:i}}get allBasePropertiesFromExtendedAndImplementedEntities(){return m([...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 m(this.extends.reduce((e,t)=>{const i=[...t.ownDeclaredProperties,...t.extendedPropertiesFromOriginalParents].filter(a=>!a.abstract);return[...e,...i]},[]))}get implementedPropertiesFromOriginalParents(){return m([...this.extends.reduce((e,t)=>{const i=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(o=>!!o.abstract&&!i.find(l=>l.name===o.name));return[...i,...a,...e]},[]),...this.implements.reduce((e,t)=>{const i=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(o=>!!o.abstract&&!i.find(l=>l.name===o.name));return[...i,...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}--${T.InvalidParentUpdate}`,code:T.InvalidParentUpdate,severity:E.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}}hydrateAncestors(){const e=[],t=[],i=[];if(this.initialData.parent){const a=P(this.initialData.parent),o=this.project.get(a);o&&(this.setParent(o),e.push(o))}return this.initialData.extends.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addExtension(l),e.push(l))}),this.initialData.implements.forEach(a=>{const o=P(a),l=this.project.get(o);l&&(this.addImplementation(l),e.push(l))}),{updated:m(e),added:m(t),removed:m(i),self:this}}afterAllChildrenInitialized(){const e=[],t=[],i=[];return this.initialized=!0,this.syncImplementationProperties(),this.addExtendedProperties(),this.addSuggestions(),{updated:m(e),added:m(t),removed:m(i),self:this}}addSelfToProject(){const e=[this],t=[],i=[];if(this.parent.type===n.DataType){const a=this.parent;a.entity=this,e.push(a)}else this.project.addDefinitionEntity(this);return{updated:m(e),added:m(t),removed:m(i),self:this}}setParent(e){return this.parent=e,this}addExtension(e){return this.extends.includes(e)||this.extends.push(e),this}removeExtension(e){return this.extends=this.extends.filter(t=>t.id!==e.id),this}addImplementation(e){return this.implements.includes(e)||this.implements.push(e),this}removeImplementation(e){return this.implements=this.implements.filter(t=>t.id!==e.id),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=I(e,this.project);return t.setParent(this),t.initChildren(),t}),this.methods=this.initialData.methods.map(e=>{const t=I(e,this.project);return t.setParent(this),t.initChildren(),t}),this.abstractMethods=this.initialData.abstractMethods.map(e=>{const t=I(e,this.project);return t.setParent(this),t.initChildren(),t}),this.extends=this.initialData.extends.map(e=>I(e,this.project)),this.implements=this.initialData.implements.map(e=>I(e,this.project)),this.afterAllChildrenInitialized(),this)}syncImplementationProperties(){const e=this.properties,t=this.implementedPropertiesFromOriginalParents,i=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...e];return t.filter(o=>!i.find(d=>{var h;return((h=d.implements)==null?void 0:h.id)===o.id})).forEach(o=>{if(this.properties.find(y=>{var f;return((f=y.implements)==null?void 0:f.id)===o.id}))return;const d=this.properties.find(y=>y.name===o.name&&!!y.abstract&&!y.implements);if(d){d.implements=o,d.abstract=!1;return}const h=o.clone(this,B.UUID.uuid());h.initChildren(),h.implements=o,h.abstract=!1,this.addProperty(h)}),this}addExtendedProperties(){const e=this.properties,t=this.extendedPropertiesFromOriginalParents,i=t.filter(o=>t.find(d=>{var h;return((h=d.implements)==null?void 0:h.id)===o.id})?!1:!o.abstract),a=new Set(e.map(o=>o.name));return i.forEach(o=>{if(a.has(o.name))return;a.add(o.name);const l=o.clone(this,B.UUID.uuid());l.initChildren(),this.addProperty(l)}),this}addSuggestions(){return this.implements.forEach(e=>{s5(this,e).forEach(a=>{const o=a.toJSON();o.id=`_suggestion--parent--${this.id}--${a.id}`;const l=I(o,this.project);l.suggestion=!0,l.setParent(this),l.initChildren(),this.addSuggestedProperty(l)}),o5(this,e).forEach(a=>{const o=`_suggestion--parent--${this.id}--${a.id}`,l=a.implementAsFunctionDeclaration(o),d=I(l,this.project);if(d.suggestion=!0,d.setParent(this),d.initChildren(),d.inputs.forEach(h=>{h.suggestion=!0}),d.returnStatements.length){const h=d.returnStatements[0];h.suggestion=!0,h.outputs.forEach(y=>{y.suggestion=!0})}this.addSuggestedMethod(d)})}),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return super.sync(e),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(e=N,...t){return await we.repository.load(this.id,...t),this}async create(e=N,...t){return await we.repository.create(this.toShallowJSON(),...t),this}async update(e=N,...t){return await we.repository.update(this.toShallowJSON(),...t),this}async delete(e=N,...t){return await we.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const i=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.properties.forEach(o=>{const{affected:l,removed:d}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}),this.methods.forEach(o=>{const{affected:l,removed:d}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}),this.abstractMethods.forEach(o=>{const{affected:l,removed:d}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}),this.suggestedProperties.forEach(o=>{const{affected:l,removed:d}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}),this.suggestedMethods.forEach(o=>{const{affected:l,removed:d}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...d)}),{affected:m(i),removed:m(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(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.methods.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.abstractMethods.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.suggestedProperties.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.suggestedMethods.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),{affected:m(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.extends.flatMap(i=>i.toFlat(e)),...this.implements.flatMap(i=>i.toFlat(e)),...this.properties.flatMap(i=>i.toFlat(e)),...this.methods.flatMap(i=>i.toFlat(e)),...this.abstractMethods.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.extends.flatMap(i=>i.toFlatIds(e)),...this.implements.flatMap(i=>i.toFlatIds(e)),...this.properties.flatMap(i=>i.toFlatIds(e)),...this.methods.flatMap(i=>i.toFlatIds(e)),...this.abstractMethods.flatMap(i=>i.toFlatIds(e))])}toJSON(e=new Set){return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(t=>t.toJSON(e)),methods:this.methods.map(t=>t.toJSON(e)),abstractMethods:this.abstractMethods.map(t=>t.toJSON(e)),implements:this.implements.map(t=>t.toJSON(e)),extends:this.extends.map(t=>t.toJSON(e)),parent:this.parent.toReference()})}toJSONClone(e=$){var i,a,o,l,d;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||at(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(a=e.seenEntities)!=null&&a.has(t)||(o=e.seenEntities)!=null&&o.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((l=e.seenEntities)==null||l.add(t),(d=e.seenEntities)==null||d.add(this.id),{id:t,version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,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(h=>h.toJSONClone({...e,newId:null})),methods:this.methods.map(h=>h.toJSONClone({...e,newId:null})),abstractMethods:this.abstractMethods.map(h=>h.toJSONClone({...e,newId:null})),implements:this.implements.map(h=>h.type===n.BuiltInBaseEntity?h.toJSON():h.toJSONClone({...e,newId:null})),extends:this.extends.map(h=>h.type===n.BuiltInBaseEntity?h.toJSON():h.toJSONClone({...e,newId:null})),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+B.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,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(a=>a.toReference(e)),methods:this.methods.map(a=>a.toReference(e)),abstractMethods:this.abstractMethods.map(a=>a.toReference(e)),implements:this.implements.map(a=>a.toReference(e)),extends:this.extends.map(a=>a.toReference(e)),parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(i=>i.toFlatJSON(e)),...this.methods.flatMap(i=>i.toFlatJSON(e)),...this.abstractMethods.flatMap(i=>i.toFlatJSON(e)),...this.implements.flatMap(i=>i.toFlatJSON(e)),...this.extends.flatMap(i=>i.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(i=>i.toFlatGenerationTarget(e)),...this.methods.flatMap(i=>i.toFlatGenerationTarget(e)),...this.abstractMethods.flatMap(i=>i.toFlatGenerationTarget(e)),...this.implements.filter(i=>i.type===n.DefinitionEntity).flatMap(i=>i.toFlatGenerationTarget(e)),...this.implements.filter(i=>i.type===n.DefinitionEntity).flatMap(i=>i.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=a5(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,i=!0){var A,D,g;let a=st(e,this);const o=this.toJSON(),l=t||Fe(C(this,this.project),n.DefinitionEntity,a);o.properties=[],o.methods=[],o.abstractMethods=[];const d=l.split("-id"),h=d[d.length-1||0]||l;o.id=l;const y=nt(o,a);e&&y.setParent(e),i&&y.subscribe(),y.initChildren();const f=(A=this.properties)==null?void 0:A.map(M=>M.clone(y,B.UUID.uuid(),i));y.properties=f;const v=(D=this.methods)==null?void 0:D.map((M,Z)=>M.clone(y,h+"-method-"+Z+"-id",i));y.methods=v;const R=(g=this.abstractMethods)==null?void 0:g.map((M,Z)=>M.clone(y,h+"-abstract-method-"+Z+"-id",i));return y.abstractMethods=R,y}getFunctionDeclaration(e){return this.methods.find(t=>t.id===e)}implement(e,t){return Ml(this,e,t)}getAllInteractiveMethods(){const e=this.implements.filter(i=>i.type===n.DefinitionEntity||i.type===n.BuiltInBaseEntity&&i.interactive);return m([...this.methods,...this.extends.flatMap(i=>i.getAllInteractiveMethods()),...e.flatMap(i=>i.getAllInteractiveMethods())])}inferFromInputs(e){if(this.parent.type!==n.DataType||!this.parent.inferred)return this;const t=[];e.forEach(o=>{t.find(d=>C(d,this.project)===C(o,this.project))||t.push(o)});const i=this.properties.filter(o=>!o.getDataType());t.forEach(o=>{const l=i.find(v=>C(v,this.project)===C(o,this.project));if(!l)return;const h=si(o.parent).getMasterInputWithValueWritterFromAllInstances(o),y=$n(h),f=y==null?void 0:y.clone(l,B.UUID.uuid(),!0);f&&l.setDataType(f),o.setDeclaration(l)});const a=[];return t.forEach(o=>{if(!o.declaration){a.push(o);return}}),a.length===0?this:(a.forEach(o=>{const l=this.properties.find(A=>C(A,this.project)===C(o,this.project));if(l){if(o.setDeclaration(l),!l.getDataType()){const D=si(o.parent).getMasterInputWithValueWritterFromAllInstances(o),g=$n(D),M=g==null?void 0:g.clone(l,B.UUID.uuid(),!0);M&&l.setDataType(M)}return}const d={id:B.UUID.uuid(),type:n.Property,version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,name:C(o,this.project),description:o.description,defaultValue:null,static:!0,abstract:!1,private:!1,hidden:!1,required:!1,constant:!0,index:o.index,implements:null,dataType:null,parent:this.toReference()},h=I(d,this.project);h.setParent(this),h.initChildren();const f=si(o.parent).getMasterInputWithValueWritterFromAllInstances(o),v=$n(f),R=v==null?void 0:v.clone(h,B.UUID.uuid(),!0);return R&&h.setDataType(R),this.addProperty(h),o.setDeclaration(h),h}),this)}};u(we,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),u(we,"type",n.DefinitionEntity),u(we,"USER_MANAGED_PARENT_TYPES",[n.Project,n.DataType]),u(we,"PARENT_TYPES",[...we.USER_MANAGED_PARENT_TYPES]),u(we,"MUTABLE_BASE_PROPERTIES",["name","description","static","abstract"]),u(we,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),u(we,"BASE_PROPERTIES",[...we.MUTABLE_BASE_PROPERTIES,...we.INMUTABLE_BASE_PROPERTIES]),u(we,"MUTABLE_META_PROPERTIES",[...we.MUTABLE_BASE_PROPERTIES,"x","y"]),u(we,"INMUTABLE_META_PROPERTIES",[...we.INMUTABLE_BASE_PROPERTIES]),u(we,"META_PROPERTIES",[...we.MUTABLE_META_PROPERTIES,...we.INMUTABLE_META_PROPERTIES]),u(we,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),u(we,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),u(we,"UPSTREAM_PROPERTIES",[...we.MUTABLE_UPSTREAM_PROPERTIES,...we.INMUTABLE_UPSTREAM_PROPERTIES]),u(we,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),u(we,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),u(we,"DOWNSTREAM_PROPERTIES",[...we.MUTABLE_DOWNSTREAM_PROPERTIES,...we.INMUTABLE_DOWNSTREAM_PROPERTIES]),u(we,"PROPERTIES",[...we.META_PROPERTIES,...we.UPSTREAM_PROPERTIES,...we.DOWNSTREAM_PROPERTIES]);let gi=we;function Cq(r){const s=Lk(),e=r.toJSON();s.safeParse(e).success;const i=[];return je(r.errors,i)}const Os=class Os extends Ke{constructor(e,t){super(e);u(this,"initialData");u(this,"id");u(this,"version");u(this,"name");u(this,"description",null);u(this,"type",n.BuiltInBaseEntity);u(this,"abstract",!1);u(this,"static");u(this,"properties",[]);u(this,"methods",[]);u(this,"abstractMethods",[]);u(this,"extends",[]);u(this,"interactive",!1);u(this,"errors",[]);u(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(i=>{const a=I(i,this.project);return a.setParent(this),a.initChildren(),a}),this.methods=this.initialData.methods.map(i=>{const a=I(i,this.project);return a.setParent(this),a.initChildren(),a}),this.abstractMethods=this.initialData.abstractMethods.map(i=>{const a=I(i,this.project);return a.setParent(this),a.initChildren(),a}),this.extends=this.initialData.extends.map(i=>I(i,this.project))}get allBasePropertiesFromExtendedAndImplementedEntities(){return m(this.extends.reduce((e,t)=>{const i=[...t.ownDeclaredProperties,...t.allBasePropertiesFromExtendedAndImplementedEntities].filter(a=>!a.abstract);return[...e,...i]},[]))}get extendedPropertiesFromOriginalParents(){return m(this.extends.reduce((e,t)=>{const i=[...t.ownDeclaredProperties,...t.extendedPropertiesFromOriginalParents].filter(a=>!a.abstract);return[...e,...i]},[]))}get implementedPropertiesFromOriginalParents(){return m([...this.extends.reduce((e,t)=>{const i=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(o=>!!o.abstract&&!i.find(l=>l.name===o.name));return[...i,...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(e=N,...t){return await Os.repository.load(this.id,...t),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(i=>i.toFlat(e)),...this.methods.flatMap(i=>i.toFlat(e)),...this.abstractMethods.flatMap(i=>i.toFlat(e)),...this.extends.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.properties.flatMap(i=>i.toFlatIds(e)),...this.methods.flatMap(i=>i.toFlatIds(e)),...this.abstractMethods.flatMap(i=>i.toFlatIds(e)),...this.extends.flatMap(i=>i.toFlatIds(e))])}toJSON(e=new Set){return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(t=>t.toJSON(e)),methods:this.methods.map(t=>t.toJSON(e)),abstractMethods:this.abstractMethods.map(t=>t.toJSON(e)),extends:this.extends.map(t=>t.toJSON(e))})}toReference(e=$){return{id:this.id+"--"+B.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(e=$){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(t=>t.toReference()),methods:this.methods.map(t=>t.toReference()),abstractMethods:this.abstractMethods.map(t=>t.toReference()),extends:this.extends.map(t=>t.toReference())}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(i=>i.toFlatJSON(e)),...this.methods.flatMap(i=>i.toFlatJSON(e)),...this.abstractMethods.flatMap(i=>i.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(i=>i.toFlatGenerationTarget(e)),...this.methods.flatMap(i=>i.toFlatGenerationTarget(e)),...this.abstractMethods.flatMap(i=>i.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=Cq(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}implement(e,t){return Ml(this,e,t)}getAllInteractiveMethods(){const e=[];return this.interactive&&(e.push(...this.methods),this.extends.filter(i=>i.type===n.BuiltInBaseEntity&&i.interactive||i.type===n.PrimitiveEntity).forEach(i=>{i instanceof Os&&e.push(...i.getAllInteractiveMethods())})),m(e)}};u(Os,"repository",{load:async(e,...t)=>null});let xn=Os;function wq(r){const s=Sk(),e=r.toJSON();s.safeParse(e).success;const i=[];return je(r.errors,i)}const Jl=class Jl extends Ke{constructor(e,t){super(e);u(this,"initialData");u(this,"id");u(this,"name");u(this,"description",null);u(this,"type",n.PrimitiveEntity);u(this,"static");u(this,"abstract");u(this,"properties",[]);u(this,"methods",[]);u(this,"abstractMethods",[]);u(this,"extends",[]);u(this,"errors",[]);u(this,"project");this.initialData=e,this.project=t,this.id=e.id,this.name=e.name,this.static=e.static,this.abstract=e.abstract,this.properties=this.initialData.properties.map(i=>{const a=I(i,this.project);return a.setParent(this),a.initChildren(),a}),this.methods=this.initialData.methods.map(i=>{const a=I(i,this.project);return a.parent=this,a}),this.abstractMethods=this.initialData.abstractMethods.map(i=>{const a=I(i,this.project);return a.parent=this,a})}get allBasePropertiesFromExtendedAndImplementedEntities(){return m(this.extends.reduce((e,t)=>{const i=[...t.ownDeclaredProperties,...t.allBasePropertiesFromExtendedAndImplementedEntities].filter(a=>!a.abstract);return[...e,...i]},[]))}get extendedPropertiesFromOriginalParents(){return m(this.extends.reduce((e,t)=>{const i=[...t.ownDeclaredProperties,...t.extendedPropertiesFromOriginalParents].filter(a=>!a.abstract);return[...e,...i]},[]))}get implementedPropertiesFromOriginalParents(){return m([...this.extends.reduce((e,t)=>{const i=t.implementedPropertiesFromOriginalParents,a=[...t.ownDeclaredProperties].filter(o=>!!o.abstract&&!i.find(l=>l.name===o.name));return[...i,...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(e=N,...t){return await Jl.repository.load(this.id,...t),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(i=>i.toFlat(e)),...this.methods.flatMap(i=>i.toFlat(e)),...this.abstractMethods.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.properties.flatMap(i=>i.toFlatIds(e)),...this.methods.flatMap(i=>i.toFlatIds(e)),...this.abstractMethods.flatMap(i=>i.toFlatIds(e))])}toJSON(e=new Set){return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(t=>t.toJSON(e)),methods:this.methods.map(t=>t.toJSON(e)),abstractMethods:this.abstractMethods.map(t=>t.toJSON(e)),extends:this.extends.map(t=>t.toJSON(e))})}toReference(e=$){return{id:this.id+"--"+B.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(e=$){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(t=>t.toReference()),methods:this.methods.map(t=>t.toReference()),abstractMethods:this.abstractMethods.map(t=>t.toReference()),extends:this.extends.map(t=>t.toReference())}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(i=>i.toFlatJSON(e)),...this.methods.flatMap(i=>i.toFlatJSON(e)),...this.abstractMethods.flatMap(i=>i.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(i=>i.toFlatGenerationTarget(e)),...this.methods.flatMap(i=>i.toFlatGenerationTarget(e)),...this.abstractMethods.flatMap(i=>i.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=wq(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}getAllInteractiveMethods(){const e=[];return e.push(...this.methods),this.extends.filter(i=>i.type===n.BuiltInBaseEntity&&i.interactive||i.type===n.PrimitiveEntity).forEach(i=>{i instanceof xn&&e.push(...i.getAllInteractiveMethods())}),m(e)}};u(Jl,"repository",{load:async(e,...t)=>null});let fn=Jl;function nt(r,s){if(!r)throw new Error("Entity is null");const e=s.get(r.id);switch(r.type){case n.LiteralValue:return e||new ya(r,s);case n.DefinitionEntity:return e||new gi(r,s);case n.PrimitiveEntity:return e||new fn(r,s);case n.FunctionDeclaration:return e||new li(r,s);case n.GlobalEvent:return e||new pa(r,s);case n.DataType:return e||new ca(r,s);case n.Property:return e||new oi(r,s);case n.FunctionCall:return e||new Ei(r,s);case n.Condition:return e||new ci(r,s);case n.Operation:return e||new di(r,s);case n.VariableDeclaration:return e||new pi(r,s);case n.VariableInstance:return e||new hi(r,s);case n.OutputMap:return e||new or(r,s);case n.ReturnDeclaration:return e||new on(r,s);case n.ArgumentDeclaration:return e||new mi(r,s);case n.InputMap:return e||new sr(r,s);case n.Project:return e||new B(r);case n.InstalledProject:return e||new fi(r,s);case n.ActionDescriptor:return e||new Be(r,s);case n.ReturnStatement:return e||new Ti(r,s);case n.Loop:return e||new ui(r,s);case n.Search:return e||new yi(r,s);case n.ValueDescriptor:return e||new vi(r,s);case n.BuiltInBaseEntity:return e||new xn(r,s);case n.InternalCall:return e||new ha(r,s);case n.ContinueStatement:return e||new kt(r,s);case n.BreakStatement:return e||new fa(r,s);case n.GenericReference:return s.get(r.entityId);default:throw new Error("Invalid entity type: "+r.type)}}function I(r,s){if(!r)throw new Error("Entity is null");const e=nt(r,s);return e.subscribe(),e}function Bq(r,s){if(!r)throw new Error("Entity is null");switch(r.type){case n.LiteralValue:return ya.fromGenerationTarget(r,s);case n.DefinitionEntity:return gi.fromGenerationTarget(r,s);case n.FunctionDeclaration:return li.fromGenerationTarget(r,s);case n.GlobalEvent:return pa.fromGenerationTarget(r,s);case n.DataType:return ca.fromGenerationTarget(r,s);case n.Property:return oi.fromGenerationTarget(r,s);case n.FunctionCall:return Ei.fromGenerationTarget(r,s);case n.Condition:return ci.fromGenerationTarget(r,s);case n.Operation:return di.fromGenerationTarget(r,s);case n.VariableDeclaration:return pi.fromGenerationTarget(r,s);case n.VariableInstance:return hi.fromGenerationTarget(r,s);case n.OutputMap:return or.fromGenerationTarget(r,s);case n.ReturnDeclaration:return on.fromGenerationTarget(r,s);case n.ArgumentDeclaration:return mi.fromGenerationTarget(r,s);case n.InputMap:return sr.fromGenerationTarget(r,s);case n.InstalledProject:return fi.fromGenerationTarget(r,s);case n.ReturnStatement:return Ti.fromGenerationTarget(r,s);case n.Loop:return ui.fromGenerationTarget(r,s);case n.Search:return yi.fromGenerationTarget(r,s);case n.ActionDescriptor:return Be.fromGenerationTarget(r,s);case n.ValueDescriptor:return vi.fromGenerationTarget(r,s);case n.InternalCall:return ha.fromGenerationTarget(r,s);case n.ContinueStatement:return kt.fromGenerationTarget(r,s);case n.BreakStatement:return fa.fromGenerationTarget(r,s);default:throw new Error("Invalid entity type: "+r.type)}}const $={seenEntityMaps:new Map,seenEntities:new Set};class lP{constructor(){u(this,"initialData")}}const N={cascade:!1},dP={load:async(r,...s)=>null},Mq={create:async(r,...s)=>r,update:async(r,...s)=>r,delete:async(r,...s)=>{},...dP};class _q{}class Nq extends lP{}class Lq{}class Gq{}class $q{}class Up{}class Fq extends Up{}class Uq extends Up{}class xq{}class dr{static initReadsValue(s){if(s.initialData.readsValue&&s.initialData.readsValue.type!==n.GenericReference)s.readsValue=I(s.initialData.readsValue,s.project);else if(s.initialData.readsValue&&s.initialData.readsValue.type===n.GenericReference){const e=Xt(s.initialData.readsValue,s.project);e&&(s.readsValue=e)}if(s.readsValue){if(We.includes(s.readsValue.type)){let e=s.parent;ut.includes(e.type)||(e=e.parent);const t=s.type===n.InputMap&&s.parent.type===n.Loop;t&&(e=s.parent.parent),s.readsValue.setParent(e),s.readsValue.initChildren(),!t&&e.detachedChildren.includes(s)?e.replaceDetachedChild(s,s.readsValue):t||e.subscribeDetachedChild(s.readsValue)}s.readsValue.addValueReader(s)}return s.readsValue}static hydrateReadsValue(s){if(s.initialData.readsValue&&s.initialData.readsValue.type!==n.GenericReference)s.readsValue=I(s.initialData.readsValue,s.project);else if(s.initialData.readsValue&&s.initialData.readsValue.type===n.GenericReference){const e=Xt(s.initialData.readsValue,s.project);e&&(s.readsValue=e)}if(s.readsValue){if(We.includes(s.readsValue.type)){let e=s.parent;ut.includes(e.type)||(e=e.parent);const t=s.type===n.InputMap&&s.parent.type===n.Loop;t&&(e=s.parent.parent),s.readsValue.setParent(e),!t&&e.detachedChildren.includes(s)?e.replaceDetachedChild(s,s.readsValue):t||e.subscribeDetachedChild(s.readsValue)}s.readsValue.addValueReader(s)}return s.readsValue}}class Ss{static initWritesValues(s,e){const t=s.initialData.writesValues.reduce((a,o)=>{if(o.type===n.GenericReference||s.writesValues.some(d=>d.id===o.id))return a;const l=I(o,s.project);return l.setValueWriter(s),We.includes(l.type)&&(l.setParent(e),l.initChildren()),[...a,l]},[]),i=[...s.writesValues];return s.writesValues=m([...i,...t]),s.writesValues}}class jq{}const ie=class ie extends Ke{constructor(e){super(e);u(this,"initialData");u(this,"id");u(this,"type",n.Project);u(this,"name",null);u(this,"description",null);u(this,"x");u(this,"y");u(this,"entities",[]);u(this,"projects",[]);u(this,"functions",[]);u(this,"events",[]);u(this,"variableDeclarations",[]);u(this,"variableInstances",[]);u(this,"conditions",[]);u(this,"operations",[]);u(this,"functionCalls",[]);u(this,"loops",[]);u(this,"searches",[]);u(this,"primitives",[]);u(this,"builtInBaseEntities",[]);u(this,"operationDeclarations",[]);u(this,"globalEventActionDescriptors",[]);u(this,"loopDeclarations",[]);u(this,"loopDeclarationsBodies",[]);u(this,"conditionDeclarations",[]);u(this,"valueDescriptors",[]);u(this,"dataTypes",[]);u(this,"project");u(this,"instances",{});u(this,"builtInInstances",{});u(this,"errors",[]);u(this,"references",[]);u(this,"initialized",!1);this.initialData=e,this.id=e.id,this.name=e.name,this.description=e.description,this.x=0,this.y=0,this.instances[this.id]=this;try{(!ie.UUID||ie.UUID.isBackup)&&(ie.UUID=Vo==null?void 0:Vo()),ie.UUID||(ie.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),ie.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:i=>i}}}static injectUUIDModule(e){ie.UUID=e}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[];return a.push(...tt(i)),{errors:a,modifiedData:i}}async inject(...e){return await Promise.all(e.map(t=>new Promise(async i=>{await t.init(this),i(null)}))),this}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}hydrateAncestors(){const e=[],t=[],i=[];return{updated:m(e),added:m(t),removed:m(i),self:this}}afterAllChildrenInitialized(){const e=[],t=[],i=[];return this.initialized=!0,this.validate(),{updated:m(e),added:m(t),removed:m(i),self:this}}addSelfToProject(){const e=[],t=[],i=[];return{updated:m(e),added:m(t),removed:m(i),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.initialized?this:(this.initialized=!0,this.entities=this.initialData.entities.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.projects=this.initialData.projects.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.variableDeclarations=this.initialData.variableDeclarations.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.variableInstances=this.initialData.variableInstances.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.conditions=this.initialData.conditions.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.operations=this.initialData.operations.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.functions=this.initialData.functions.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.events=this.initialData.events.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.functionCalls=this.initialData.functionCalls.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.loops=this.initialData.loops.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.searches=this.initialData.searches.map(e=>{const t=I(e,this);return t.setParent(this),t.initChildren(),t}),this.attachOrphanReferences(),this.afterAllChildrenInitialized(),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 super.sync(e),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(e=N,...t){return await ie.repository.load(this.id,...t),this}async create(e=N,...t){return await ie.repository.create(this.toShallowJSON(),...t),this}async update(e=N,...t){return await ie.repository.update(this.toShallowJSON(),...t),this}async delete(e=N,...t){return await ie.repository.delete(this.id,...t),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(i=>i.toFlat(e)),...this.functions.flatMap(i=>i.toFlat(e)),...this.events.flatMap(i=>i.toFlat(e)),...this.projects.flatMap(i=>i.toFlat(e)),...this.variableDeclarations.flatMap(i=>i.toFlat(e)),...this.variableInstances.flatMap(i=>i.toFlat(e)),...this.conditions.flatMap(i=>i.toFlat(e)),...this.operations.flatMap(i=>i.toFlat(e)),...this.functionCalls.flatMap(i=>i.toFlat(e)),...this.loops.flatMap(i=>i.toFlat(e)),...this.searches.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),Array.from(e))}toJSON(e=new Set){return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(t=>t.toJSON(e)),variableDeclarations:this.variableDeclarations.map(t=>t.toJSON(e)),variableInstances:this.variableInstances.map(t=>t.toJSON(e)),conditions:this.conditions.map(t=>t.toJSON(e)),operations:this.operations.map(t=>t.toJSON(e)),loops:this.loops.map(t=>t.toJSON(e)),searches:this.searches.map(t=>t.toJSON(e)),functions:this.functions.map(t=>t.toJSON(e)),events:this.events.map(t=>t.toJSON(e)),projects:this.projects.map(t=>t.toJSON(e)),functionCalls:this.functionCalls.map(t=>t.toJSON(e))})}toJSONClone(e={uuidStrategy:"uuid"}){const t=new Map,i=new Set,a=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(o=>{if(a.includes(o)){t.set(o,o);return}t.set(o,ie.UUID.uuid())}),i.add(this.id),{id:t.get(this.id),version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),projects:this.projects.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),variableDeclarations:this.variableDeclarations.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),variableInstances:this.variableInstances.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),conditions:this.conditions.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),operations:this.operations.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),functions:this.functions.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),events:this.events.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),functionCalls:this.functionCalls.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),loops:this.loops.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null})),searches:this.searches.map(o=>o.toJSONClone({...e,seenEntityMaps:t,seenEntities:i,newId:null}))}}toReference(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+ie.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=$){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(a=>a.toReference(e)),functions:this.functions.map(a=>a.toReference(e)),events:this.events.map(a=>a.toReference(e)),projects:this.projects.map(a=>a.toReference(e)),variableDeclarations:this.variableDeclarations.map(a=>a.toReference(e)),variableInstances:this.variableInstances.map(a=>a.toReference(e)),conditions:this.conditions.map(a=>a.toReference(e)),operations:this.operations.map(a=>a.toReference(e)),functionCalls:this.functionCalls.map(a=>a.toReference(e)),loops:this.loops.map(a=>a.toReference(e)),searches:this.searches.map(a=>a.toReference(e))}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[...this.entities.flatMap(i=>i.toFlatJSON(e)),...this.functions.flatMap(i=>i.toFlatJSON(e)),...this.events.flatMap(i=>i.toFlatJSON(e)),...this.projects.flatMap(i=>i.toFlatJSON(e)),...this.variableDeclarations.flatMap(i=>i.toFlatJSON(e)),...this.variableInstances.flatMap(i=>i.toFlatJSON(e)),...this.conditions.flatMap(i=>i.toFlatJSON(e)),...this.operations.flatMap(i=>i.toFlatJSON(e)),...this.functionCalls.flatMap(i=>i.toFlatJSON(e)),...this.loops.flatMap(i=>i.toFlatJSON(e)),...this.searches.flatMap(i=>i.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(i=>i.toFlatGenerationTarget(e)),...this.functions.flatMap(i=>i.toFlatGenerationTarget(e)),...this.events.flatMap(i=>i.toFlatGenerationTarget(e)),...this.projects.flatMap(i=>i.toFlatGenerationTarget(e)),...this.variableDeclarations.flatMap(i=>i.toFlatGenerationTarget(e)),...this.variableInstances.flatMap(i=>i.toFlatGenerationTarget(e)),...this.conditions.flatMap(i=>i.toFlatGenerationTarget(e)),...this.operations.flatMap(i=>i.toFlatGenerationTarget(e)),...this.functionCalls.flatMap(i=>i.toFlatGenerationTarget(e)),...this.loops.flatMap(i=>i.toFlatGenerationTarget(e)),...this.searches.flatMap(i=>i.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=Q3(),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 this}getDefinitionEntity(e){return this.entities.find(t=>t.id===e)||null}addDefinitionEntityFromTransfer(e){const t=I(e,this);return this.addDefinitionEntity(t),t}addDefinitionEntity(e){return this.entities.includes(e)||this.entities.push(e),e}addFunctionDeclarationFromTransfer(e){const t=I(e,this);return this.addFunctionDeclaration(t),t}addFunctionDeclaration(e){return this.functions.includes(e)||this.functions.push(e),e}addFunctionCallFromTransfer(e){const t=I(e,this);return this.addFunctionCall(t),t}addFunctionCall(e){return this.functionCalls.includes(e)||this.functionCalls.push(e),e}addVariableDeclarationFromTransfer(e){const t=I(e,this);return this.addVariableDeclaration(t),t}addVariableDeclaration(e){return this.variableDeclarations.includes(e)||this.variableDeclarations.push(e),e}addVariableInstanceFromTransfer(e){const t=I(e,this);return this.addVariableInstance(t),t}addVariableInstance(e){return this.variableInstances.includes(e)||this.variableInstances.push(e),e}addInstalledProjectFromTransfer(e){const t=I(e,this);return this.addInstalledProject(t),this}addInstalledProject(e){return this.projects.includes(e)||this.projects.push(e),this}addGlobalEventFromTransfer(e){const t=I(e,this);return this.addGlobalEvent(t),this}addGlobalEvent(e){return this.events.includes(e)||this.events.push(e),this}addConditionFromTransfer(e){const t=I(e,this);return this.addCondition(t),this}addCondition(e){return this.conditions.includes(e)||this.conditions.push(e),this}addOperationFromTransfer(e){const t=I(e,this);return this.addOperation(t),this}addOperation(e){return this.operations.includes(e)||this.operations.push(e),this}addLoopFromTransfer(e){const t=I(e,this);return this.addLoop(t),this}addLoop(e){return this.loops.includes(e)||this.loops.push(e),this}addSearchFromTransfer(e){const t=I(e,this);return this.addSearch(t),this}addSearch(e){return this.searches.includes(e)||this.searches.push(e),this}removeDefinitionEntity(e){const t=this.entities.findIndex(i=>i.id===e.id);if(t>-1){const i=this.entities[t];return this.entities.splice(t,1),i}return null}removeFunctionDeclaration(e){const t=this.functions.findIndex(i=>i.id===e.id);if(t>-1){const i=this.functions[t];return this.functions.splice(t,1),i}return null}removeExternalProject(e){const t=this.projects.findIndex(i=>i.id===e.id);if(t>-1){const i=this.projects[t];return this.projects.splice(t,1),i}return null}removeGlobalEvent(e){const t=this.events.findIndex(i=>i.id===e.id);if(t>-1){const i=this.events[t];return this.events.splice(t,1),i}return null}removeTopLevelVariableDeclaration(e){if(e.type!==n.VariableDeclaration)return null;const t=this.variableDeclarations.findIndex(i=>i.id===e.id);if(t>-1){const i=this.variableDeclarations[t];return this.variableDeclarations.splice(t,1),i}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,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Condition)]},[]),...this.functionCalls.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Condition)]},[]),...this.operations.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Condition)]},[]),...this.loops.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Condition)]},[]),...this.searches.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Operation)]},[]),...this.functionCalls.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Operation)]},[]),...this.conditions.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Operation)]},[]),...this.loops.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Operation)]},[]),...this.searches.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.FunctionCall)]},[]),...this.conditions.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.FunctionCall)]},[]),...this.operations.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.FunctionCall)]},[]),...this.loops.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.FunctionCall)]},[]),...this.searches.reduce((t,i)=>{const a=Xe(i);return[...t,...a.filter(o=>o.type===n.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((t,i)=>{const a=xe(i);return[...t,...a]},[]),...this.functionCalls.reduce((t,i)=>{const a=xe(i);return[...t,...a]},[]),...this.conditions.reduce((t,i)=>{const a=xe(i);return[...t,...a]},[]),...this.operations.reduce((t,i)=>{const a=xe(i);return[...t,...a]},[]),...this.loops.reduce((t,i)=>{const a=xe(i);return[...t,...a]},[]),...this.searches.reduce((t,i)=>{const a=xe(i);return[...t,...a]},[])]}getVariableInstances(){return[...this.variableInstances,...this.getEntryPoints().reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableInstance);return[...t,...o]},[]),...this.functionCalls.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableInstance);return[...t,...o]},[]),...this.conditions.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableInstance);return[...t,...o]},[]),...this.operations.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableInstance);return[...t,...o]},[]),...this.loops.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableInstance);return[...t,...o]},[]),...this.searches.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableInstance);return[...t,...o]},[])]}getVariableDeclarations(){return m([...this.variableDeclarations,...this.getEntryPoints().reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableDeclaration);return[...t,...o]},[]),...this.functionCalls.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableDeclaration);return[...t,...o]},[]),...this.conditions.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableDeclaration);return[...t,...o]},[]),...this.operations.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableDeclaration);return[...t,...o]},[]),...this.loops.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableDeclaration);return[...t,...o]},[]),...this.searches.reduce((t,i)=>{const o=xe(i).filter(l=>l.type===n.VariableDeclaration);return[...t,...o]},[])])}attachOrphanReferences(){const e=this.getVariableInstances(),t=this.getVariableDeclarations();return e.forEach(i=>{if(!i.declaration){const a=i.initialData,o=a.declaration.entityId||a.declaration.id,l=t.find(d=>d.id===o);l&&i.setDeclaration(l)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(e=>e.name===j.PERSISTED_ENTITY)||null}};u(ie,"UUID",{isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:e=>e}),u(ie,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),u(ie,"type",n.Project),u(ie,"USER_MANAGED_PARENT_TYPES",[]),u(ie,"PARENT_TYPES",[...ie.USER_MANAGED_PARENT_TYPES]),u(ie,"MUTABLE_BASE_PROPERTIES",["name","description"]),u(ie,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),u(ie,"BASE_PROPERTIES",[...ie.MUTABLE_BASE_PROPERTIES,...ie.INMUTABLE_BASE_PROPERTIES]),u(ie,"MUTABLE_META_PROPERTIES",[...ie.MUTABLE_BASE_PROPERTIES,"x","y"]),u(ie,"INMUTABLE_META_PROPERTIES",[...ie.INMUTABLE_BASE_PROPERTIES]),u(ie,"META_PROPERTIES",[...ie.MUTABLE_META_PROPERTIES,...ie.INMUTABLE_META_PROPERTIES]),u(ie,"MUTABLE_UPSTREAM_PROPERTIES",[]),u(ie,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),u(ie,"UPSTREAM_PROPERTIES",[...ie.MUTABLE_UPSTREAM_PROPERTIES,...ie.INMUTABLE_UPSTREAM_PROPERTIES]),u(ie,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),u(ie,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),u(ie,"DOWNSTREAM_PROPERTIES",[...ie.MUTABLE_DOWNSTREAM_PROPERTIES,...ie.INMUTABLE_DOWNSTREAM_PROPERTIES]),u(ie,"PROPERTIES",[...ie.META_PROPERTIES,...ie.UPSTREAM_PROPERTIES,...ie.DOWNSTREAM_PROPERTIES]);let B=ie;class uP extends Be{constructor(e){super(En,e);u(this,"id",Ze.Parallel);u(this,"name",Ze.Parallel);u(this,"description","Execute a list of actions one after the other");u(this,"version","1");u(this,"autoexecutable",!0);u(this,"initialData",En);u(this,"type",n.ActionDescriptor);u(this,"inputs",[]);u(this,"outputs",[]);u(this,"error",null);u(this,"project");this.project=e,this.inputs=En.inputs.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.outputs=En.outputs.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.error=En.error?I(En.error,this.project):null}}class cP extends Be{constructor(e){super(Lt,e);u(this,"id",Lt.id);u(this,"name",Lt.name);u(this,"description",Lt.description);u(this,"version",Lt.version);u(this,"autoexecutable",!1);u(this,"initialData",Lt);u(this,"type",n.ActionDescriptor);u(this,"inputs",[]);u(this,"outputs",[]);u(this,"error",null);u(this,"project");this.project=e,this.inputs=Lt.inputs.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.outputs=Lt.outputs.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.error=Lt.error?I(Lt.error,this.project):null}}class pP extends Be{constructor(e){super(Yn,e);u(this,"id",Ze.Sequential);u(this,"name",Ze.Sequential);u(this,"description","Execute a list of actions one after the other");u(this,"version","1");u(this,"autoexecutable",!0);u(this,"initialData",Yn);u(this,"type",n.ActionDescriptor);u(this,"inputs",[]);u(this,"outputs",[]);u(this,"error",null);u(this,"project");this.project=e,this.inputs=Yn.inputs.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.outputs=Yn.outputs.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.error=Yn.error?I(Yn.error,this.project):null}}class kq extends Be{constructor(s){super(ga,s)}}class Zq extends Be{constructor(s){super(Mr,s)}}class qq extends Be{constructor(e){super(_r,e);u(this,"autoexecutable",!0)}getEntityToMatchInputMap(e){return e.inputs.find(t=>{var i;return((i=t.declaration)==null?void 0:i.id)===_.operation[qe.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(e){return e.inputs.find(t=>{var i;return((i=t.declaration)==null?void 0:i.id)===_.operation[qe.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(e){return e.outputs.find(t=>{var i;return((i=t.declaration)==null?void 0:i.id)===_.operation[qe.Validate].outputs.outputEntity.id})||null}getEntityToMatch(e){let t=null;if(e.readsValue){const a=e.readsValue.getDataType();a&&a.entity&&a.entity.type===n.DefinitionEntity&&(t=a.entity)}const i=e.getDefaultValue();return!t&&i&&i.valueAsType&&!Array.isArray(i.valueAsType)&&i.valueAsType.type===n.DefinitionEntity&&(t=i.valueAsType),t}syncOperationInstance(e){const t=this.getEntityToMatchInputMap(e);t&&this.syncEntityToMatchInputMapDataType(t);const i=this.getDataToValidateInputMap(e);i&&this.syncDataToValidateInputMapDataType(i);const a=this.getOutputDataOutputMap(e);return a&&this.syncOutputDataOutputMapDataType(a),e}syncEntityToMatchInputMapDataType(e){var i,a,o;if(((i=e.declaration)==null?void 0:i.id)!==_.operation[qe.Validate].inputs.entityToMatch.id)return null;if(!e.dataType){const l={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!0,entity:null,like:!0,inferred:!0,parent:e.toReference()},d=I(l,e.project);d.setParent(e),d.initChildren(),e.setDataType(d)}(a=e.dataType)==null||a.sync({inferred:!0,like:!1,asType:!0});const t=this.getEntityToMatch(e);return(o=e.dataType)==null||o.setEntity(t),e.dataType}syncDataToValidateInputMapDataType(e){var o,l,d;if(((o=e.declaration)==null?void 0:o.id)!==_.operation[qe.Validate].inputs.dataToValidate.id)return null;const t=this.getEntityToMatchInputMap(e.parent);if(!t||!this.getEntityToMatch(t))return null;if(!e.dataType){const h={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:null,like:!0,inferred:!0,parent:e.toReference()},y=I(h,e.project);y.setParent(e),y.initChildren(),e.setDataType(y)}(l=e.dataType)==null||l.sync({inferred:!0,like:!0,asType:!1});const a=this.getEntityToMatch(t);return(d=e.dataType)==null||d.setEntity(a),e.dataType}syncOutputDataOutputMapDataType(e){var o,l,d;if(((o=e.declaration)==null?void 0:o.id)!==_.operation[qe.Validate].outputs.outputEntity.id)return null;const t=this.getEntityToMatchInputMap(e.parent);if(!t||!this.getEntityToMatch(t))return null;if(!e.dataType){const h={id:B.UUID.uuid(),version:"1",createdAt:"2024-01-01T00:00:00.000Z",author:"1",previousVersion:null,deleted:!1,type:n.DataType,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:null,like:!0,inferred:!0,parent:e.toReference()},y=I(h,e.project);y.setParent(e),y.initChildren(),e.setDataType(y)}(l=e.dataType)==null||l.sync({inferred:!0,like:!0,asType:!1});const a=this.getEntityToMatch(t);return(d=e.dataType)==null||d.setEntity(a),e.dataType}inferInputMapDataType(e){var t,i;return((t=e.declaration)==null?void 0:t.id)===_.operation[qe.Validate].inputs.entityToMatch.id?this.syncEntityToMatchInputMapDataType(e):((i=e.declaration)==null?void 0:i.id)===_.operation[qe.Validate].inputs.dataToValidate.id?this.syncDataToValidateInputMapDataType(e):null}inferOutputMapDataType(e){var t;return((t=e.declaration)==null?void 0:t.id)===_.operation[qe.Validate].outputs.outputEntity.id?this.syncOutputDataOutputMapDataType(e):null}}class Jq extends Be{constructor(s){super(ad,s)}}class Wq extends Be{constructor(s){super(od,s)}}class Yq extends Be{constructor(s){super(ld,s)}}class Hq extends Be{constructor(s){super(Gs,s)}}class zq extends Be{constructor(s){super(_s,s)}}class Kq extends Be{constructor(s){super(Ra,s)}}function Xq(r){const s=[new pP(r),new uP(r),new cP(r),new kq(r),new Zq(r),new qq(r),new Hq(r),new Jq(r),new Yq(r),new Wq(r),new zq(r),new Kq(r),new Be(id,r),new Be(rd,r)];return s.forEach(e=>{e.initChildren(),r.subscribeBuiltInInstance(e)}),r.operationDeclarations=s,s}class hP extends xn{constructor(e){super(bt,e);u(this,"initialData");u(this,"id",j.PERSISTED_ENTITY);u(this,"version","1");u(this,"name",j.PERSISTED_ENTITY);u(this,"description",bt.description);u(this,"type",n.BuiltInBaseEntity);u(this,"abstract",bt.abstract);u(this,"static",bt.static);u(this,"properties",[]);u(this,"methods",[]);u(this,"abstractMethods",[]);u(this,"extends",[]);u(this,"errors",[]);u(this,"project");this.initialData=bt,this.project=e,this.id=bt.id,this.version=bt.version,this.name=bt.name,this.static=bt.static,this.abstract=bt.abstract,this.properties=this.initialData.properties.map(t=>{const i=I(t,this.project);return i.setParent(this),i.initChildren(),i}),this.methods=this.initialData.methods.map(t=>{const i=I(t,this.project);return i.parent=this,i}),this.abstractMethods=this.initialData.abstractMethods.map(t=>{const i=I(t,this.project);return i.parent=this,i}),this.extends=this.initialData.extends.map(t=>I(t,this.project))}}function Qq(r){const s=[new hP(r),new xn(Sa,r),new xn(Vn,r),new xn(eo,r)];return s.forEach(e=>{r.subscribeBuiltInInstance(e)}),r.builtInBaseEntities=s,s}function eJ(r){const s=[new fn(K,r),new fn(Zn,r),new fn(de,r),new fn(Et,r),new fn(qn,r),new fn(Pn,r),new fn(Jn,r),new fn(Si,r)];return s.forEach(e=>{r.subscribeBuiltInInstance(e)}),r.primitives=s,s}function tJ(r){const s=[new Be(no,r)];return s.forEach(e=>{e.initChildren(),r.subscribeBuiltInInstance(e)}),r.globalEventActionDescriptors=s,s}function nJ(r){const s=[new Be(Da,r),new Be(cr,r),new Be(Ia,r),new Be(Ci,r),new Be(wi,r),new Be(qs,r)];s.forEach(t=>{t.initChildren(),r.subscribeBuiltInInstance(t)}),r.loopDeclarations=s;const e=[new Be(Hs,r),new Be(Aa,r),new Be(Ws,r),new Be(gd,r),new Be(Id,r),new Be(Js,r)];return e.forEach(t=>{t.initChildren(),r.subscribeBuiltInInstance(t)}),r.loopDeclarationsBodies=e,s}function rJ(r){const s=[new vi(ro,r)];return s.forEach(e=>{e.initChildren(),r.subscribeBuiltInInstance(e)}),r.valueDescriptors=s,s}function iJ(r){const s=[new Be(Fr,r),new Be(Li,r)];return s.forEach(e=>{e.initChildren(),r.subscribeBuiltInInstance(e)}),r.operationDeclarations=s,s}const bi={},ql={};async function aJ(r,s={}){const e={...YI};return e.id=r.id,s.empty?{data:{id:r.id,type:n.Project,version:"1",createdAt:G().toDate(),author:"1",previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]}}:{data:e}}function xp(r){const s=new B(r);return eJ(s),Qq(s),Xq(s),tJ(s),nJ(s),rJ(s),iJ(s),s.getAllBuiltIn().forEach(t=>{s.builtInInstances[t.id]||(s.builtInInstances[t.id]=t,delete s.instances[t.id])}),s}function sJ(r){const s=new Map,e=r.getAllBuiltInIds();Object.keys(r.instances).forEach(i=>{if(e.includes(i)){s.set(i,i);return}s.set(i,B.UUID.uuid())});const t=xp(r.toShallowJSON({seenEntityMaps:s}));return new Ap(r).visit(i=>{const a=I(i.toShallowJSON({seenEntityMaps:s}),t);a.hydrateAncestors(),a.addSelfToProject()}).visit(i=>{const a=t.get(s.get(i.id));a&&a.afterAllChildrenInitialized()}),t.afterAllChildrenInitialized(),t}function yP(r){const s=xp(r);return new Ap(r).visit(e=>{const t=I(e,s);t.hydrateAncestors(),t.addSelfToProject()}).visit(e=>{const t=s.get(e.id);t&&t.afterAllChildrenInitialized()}),s.afterAllChildrenInitialized(),s}async function oJ(r,s={}){if(r.id&&bi[r.id])return bi[r.id];if(r.id&&ql[r.id])return await ql[r.id],bi[r.id];const e=aJ(r,s);r.id&&(ql[r.id]=e);const t=await e;if(t.data){const i=yP(t.data);return bi[r.id]=i,r.id&&delete ql[r.id],i}return null}function lJ(r){return bi[r.id]&&delete bi[r.id],null}const dJ="test_primitive_entities_export";c.AI_VALUE_CONNECTION_GENERATION_ACTION_EXPLANATION=Rp,c.ALL_BUILT_IN_BASE_ENTITIES=AE,c.ALL_BUILT_IN_CONDITION_ENTITIES=$E,c.ALL_BUILT_IN_GLOBAL_EVENT_ENTITIES=UE,c.ALL_BUILT_IN_LOOP_BODY_ENTITIES=ev,c.ALL_BUILT_IN_LOOP_ENTITIES=QT,c.ALL_BUILT_IN_OPERATION_ENTITIES=c0,c.ALL_BUILT_IN_PRIMITIVE_ENTITIES=th,c.ALL_BUILT_IN_TOP_LEVEL_ENTITIES=ZE,c.ALL_BUILT_IN_VALUE_DESCRIPTORS=kE,c.ActionDescriptorState=Be,c.ActionInputMapState=M7,c.ActionOutputMapState=L7,c.AppendToListOperationInputIds=uf,c.AppendToListOperationOutputIds=cf,c.ArgumentDeclarationState=mi,c.BREAK_AND_CONTINUE_STATEMENTS_RETURN_DECLARATIONS_EXPLANATION=mp,c.BUILT_IN_BASE_ENTITY_IDS=_,c.BUILT_IN_ENTITY_TYPES=ur,c.BaseCanvasDraggableState=Lq,c.BaseEntityNames=j,c.BaseState=Nq,c.BaseValueDescriptorIds=Ms,c.BreakStatementState=fa,c.BuiltInBaseEntityState=xn,c.CACHED_PROJECTS_BY_ID=bi,c.CALLABLE_ENTITIES_EXPLANATION=W7,c.CALLABLE_TYPES=vn,c.CALLER_ENTITIES_EXPLANATION=W1,c.CALLER_TYPES=Dn,c.CALLS_UPDATE_EXPLANATION=Pr,c.COMPARISON_CONDITIONS=LE,c.CONDITIONS=GE,c.CUSTOM_ENTITY_OPERATIONS=Vm,c.CallableEntityClass=$q,c.CallerEntityClass=Up,c.ChildEntityState=Gq,c.ComparisonOperatorTypes=it,c.ConditionState=ci,c.ContinueStatementState=kt,c.CreateNewInputIds=rm,c.CreateNewOutputIds=im,c.DRAGGABLE_CALLABLE_TYPES=Kl,c.DRAGGABLE_CALLER_TYPES=Jp,c.DRAGGABLE_ELEMENT_TYPES=Bs,c.DRAGGABLE_EXECUTABLE_TYPES=vP,c.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES=ws,c.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=zl,c.DataTypeCompatibilityTypes=hn,c.DataTypeParentChildRelation=ft,c.DataTypeState=ca,c.DefinitionEntityState=gi,c.EDITABLE_PERSISTANCE_REPOSITORY_DEFAULTS=Mq,c.ENTITIES_WITH_VALLUES_EXPLANATION=Ol,c.ENTITY_PERSISTANCE_OPTIONS_DEFAULTS=N,c.ENTITY_RECUSION_OPTIONS_DEFAULTS=$,c.ENTITY_TYPES=EP,c.ENTITY_WITH_DECLARATION_TYPES=mP,c.ENTITY_WITH_LOGIC_SCOPE_TYPES=ut,c.ENTITY_WITH_NAMES_TYPES=Wp,c.ENTITY_WITH_PARENT_TYPES=kp,c.ENTITY_WITH_USER_MANAGED_DECLARATION_TYPES=Hl,c.ENTITY_WITH_USER_MANAGED_SINGLE_IMPLEMENTS_TYPES=Zp,c.ENTITY_WITH_VALUE_TYPES=jp,c.ENTRY_POINT_ENTITIES_EXPLANATION=gs,c.ENTRY_POINT_TYPES=ze,c.EVENT_TYPES=Pi,c.EXECUTABLE_TYPES=TP,c.EXECUTION_OPERATIONS=nm,c.EntityError=Hr,c.EntityErrorSeverity=E,c.EntityGenerationError=b,c.EntityGenerationErrorCode=T,c.EntityInstanceErrorCode=F,c.EntityOperations=qe,c.EntityType=n,c.EntityWithLogicScopeClass=jq,c.EntityWithValueClass=xq,c.EntryPointEntityClass=Fq,c.ExecutionOperations=Ze,c.ExecutionTerminationType=Z1,c.FunctionCallState=Ei,c.FunctionDeclarationState=li,c.GLOBAL_EVENT_DECLARATIONS=FE,c.GetLastInListOperationInputIds=Ky,c.GetLastInListOperationOutputIds=Xy,c.GlobalEventNames=jn,c.GlobalEventState=pa,c.HTTPOperations=Pt,c.HTTP_OPERATIONS=d0,c.InputMapState=sr,c.InstalledProjectState=fi,c.InternalCallState=ha,c.JoinListOperationInputIds=Ty,c.JoinListOperationOutputIds=vy,c.LIST_OPERATIONS=Af,c.ListOperations=ae,c.LiteralValueState=ya,c.LoopState=ui,c.LoopTypes=q,c.NON_INTERACTIVE_BASE_ENTITIES_EXPLANATION=Sr,c.NUMBER_OPERATIONS=wh,c.NumberOperations=Je,c.OPERATION_DECLARATIONS=u0,c.OperationState=di,c.OutputMapParentChildRelation=Di,c.OutputMapState=or,c.PARENT_AUTO_CALCULATION_FROM_CALLER_EXPLANATION=Vl,c.PASS_THROUGH_CALLABLE_ENTITIES_EXPLANATION=Dr,c.PASS_THROUGH_CALLABLE_TYPES=Qe,c.PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=qp,c.PROPERTY_NOT_VALUE_READER_WRITTER_EXPLANATION=Ep,c.ParallelExecutionOperation=uP,c.PassThroughCallableEntityClass=Uq,c.PersistedEntity=hP,c.PersistedEntityMethods=en,c.PrimitiveEntityState=fn,c.PrimitiveTypes=V,c.ProjectState=B,c.PropertyState=oi,c.READ_ONLY_ENTITY_PERSISTANCE_REPOSITORY=dP,c.RETURN_STATEMENT_RETURN_DECLARATIONS_EXPLANATION=Y7,c.ReturnDeclarationState=on,c.ReturnStatementState=Ti,c.STANDALONE_CONDITIONS=SE,c.STRING_OPERATIONS=my,c.ScopeCompatibilityType=Zl,c.SearchState=yi,c.SequentialExecutionOperation=pP,c.SequentialExecutionOperationInputIds=kf,c.SequentialExecutionOperationOutputIds=Zf,c.SharedEntityErrorCode=w,c.SharedStateFunctionality=lP,c.SplitListOperationInputIds=My,c.SplitListOperationOutputIds=_y,c.StandaloneOperatorTypes=dn,c.StringOperations=pe,c.TERMINATION_TYPES=et,c.Traverser=Ap,c.USER_MANAGED_ENTITY_TYPES=Yp,c.UserManagedEntityStateFunctionality=_q,c.VALUE_READING_ENTITIES_EXPLANATION=vp,c.VALUE_READING_TYPES=kn,c.VALUE_WRITING_ENTITIES_EXPLANATION=Y1,c.VALUE_WRITING_TYPES=lt,c.VARIABLE_DATA_TYPE_INFERRANCE_EXPLANATION=Tp,c.VARIABLE_TYPES=We,c.ValueAutogenerationType=ot,c.ValueDescriptorParentChildRelation=O,c.ValueDescriptorState=vi,c.ValueReadingEntityClass=dr,c.ValueWritingEntityClass=Ss,c.VariableDeclarationState=pi,c.VariableInputMapState=B7,c.VariableInstanceState=hi,c.VariableOutputMapState=N7,c.WaitOperation=cP,c.WaitOperationInputIds=Lf,c.WaitOperationOutputIds=Gf,c.appendToListOperation=Gs,c.appendToListOperationElementToAppendArgument=ud,c.appendToListOperationElementToAppendArgumentParentRef=Ef,c.appendToListOperationElementToAppendArgumentRef=yf,c.appendToListOperationError=If,c.appendToListOperationErrorParentRef=bf,c.appendToListOperationListArgument=dd,c.appendToListOperationListArgumentParentRef=vf,c.appendToListOperationListArgumentRef=pf,c.appendToListOperationListDataType=hf,c.appendToListOperationResultListDataType=Tf,c.appendToListOperationResultListReturn=gf,c.appendToListOperationResultListReturnParentRef=Rf,c.appendToListOperationResultListReturnRef=mf,c.appendToListOperationSecondListDataType=ff,c.asGenerationActionExample=Fn,c.booleanPrototype=Zn,c.capitalizeFirstLetter=El,c.checkAreDataTypesCompatible=yn,c.checkAreDefinitionEntitiesCompatibleAsDataType=B1,c.checkArePropertiesCompatibleAsDataType=w1,c.checkIsBranchDependentButNotDirectlyOnBranch=Is,c.checkIsBranchDependentOnBranch=rq,c.checkIsCallableEntityReachable=Ps,c.checkIsCanvasEntity=bq,c.checkIsDetachedBranch=nP,c.checkIsDetachedBranchShallow=$p,c.checkIsGlobalVariable=Eq,c.checkIsGloballyDeclared=Gp,c.checkIsMethod=aP,c.checkIsNestedScope=kl,c.checkScopeCompatibility=Ds,c.cloneProject=sJ,c.countedLoopActionDescriptor=Da,c.countedLoopActionDescriptorDynamicReturnDeclaration=qT,c.countedLoopActionDescriptorDynamicReturnDeclarationParentRef=ZT,c.countedLoopActionDescriptorStringArgumentDeclaration=kT,c.countedLoopActionDescriptorStringArgumentDeclarationDataType=xT,c.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValue=FT,c.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValueParentRef=$T,c.countedLoopActionDescriptorStringArgumentDeclarationDataTypeParentRef=UT,c.countedLoopActionDescriptorStringArgumentDeclarationParentRef=jT,c.countedLoopBodyActionDescriptor=Hs,c.countedLoopBodyActionDescriptorAnyDynamicArgument=zT,c.countedLoopBodyActionDescriptorAnyDynamicArgumentParentRef=HT,c.countedLoopBodyActionDescriptorAnyDynamicReturn=XT,c.countedLoopBodyActionDescriptorAnyDynamicReturnParentRef=KT,c.countedLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Dd,c.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=WT,c.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=JT,c.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=YT,c.createDefinitionEntityFromJSONObject=_l,c.createEntityError=se,c.createNestedDataTypeForEntity=aD,c.createNewInstanceOperation=Mr,c.createNewInstanceOperationEntityToInstanciateArgument=pm,c.createNewInstanceOperationEntityToInstanciateArgumentRef=dm,c.createNewInstanceOperationEntityToInstanciateDataType=um,c.createNewInstanceOperationError=mm,c.createNewInstanceOperationErrorParentRef=fm,c.createNewInstanceOperationNewEntityDataArgument=lm,c.createNewInstanceOperationNewEntityDataArgumentDataType=om,c.createNewInstanceOperationNewEntityDataArgumentDataTypeParentRef=sm,c.createNewInstanceOperationNewEntityDataArgumentParentRef=am,c.createNewInstanceOperationOutputEntityDeclaration=ym,c.createNewInstanceOperationOutputEntityDeclarationParentRef=hm,c.createNewInstanceOperationRef=cm,c.createSemanticId=Fe,c.createStateFromGenerationTargetType=Bq,c.createStateFromType=nt,c.createStateFromTypeAndSubscribe=I,c.cronJobBuiltInBaseEntity=eo,c.cronJobBuiltInBaseEntityExpressionProperty=bE,c.cronJobBuiltInBaseEntityExpressionPropertyDataTypeRef=PP,c.cronJobBuiltInBaseEntityExpressionPropertyRef=RE,c.cronJobBuiltInBaseEntityRef=gE,c.cronJobTriggeredFunctionDeclarationBlueprint=Fd,c.cronJobTriggeredFunctionDeclarationBlueprintParentRef=vE,c.dataTypeCompatibilityToErrorExplanation=nD,c.datePrototype=Pn,c.dateValueAutogenerationSchema=tc,c.definitionEntityToZodSchema=sR,c.deletePersistedEntityMethod=$d,c.deletePersistedEntityMethodParentRef=rE,c.deleteRootProject=lJ,c.endpointBuiltInBaseEntity=Sa,c.endpointBuiltInBaseEntityRef=iv,c.endpointBuiltInBaseEntityRefFour=Fv,c.endpointBuiltInBaseEntityRefThree=hv,c.endpointBuiltInBaseEntityRefTwo=dv,c.endpointBuiltInCorsProperty=av,c.endpointBuiltInCorsPropertyDataType=rv,c.endpointBuiltInCorsPropertyDataTypeRef=tv,c.endpointBuiltInCorsPropertyRef=nv,c.endpointBuiltInMethodProperty=Sd,c.endpointBuiltInMethodPropertyDataType=pv,c.endpointBuiltInMethodPropertyDataTypeRef=uv,c.endpointBuiltInMethodPropertyRef=cv,c.endpointBuiltInPathProperty=Pd,c.endpointBuiltInPathPropertyDataType=lv,c.endpointBuiltInPathPropertyDataTypeRef=sv,c.endpointBuiltInPathPropertyRef=ov,c.endpointPathParamsArgumentDeclaration=Vd,c.endpointPathParamsArgumentDeclarationRef=Iv,c.endpointPathParamsVariableDataType=Av,c.endpointPathParamsVariableDataTypeRef=bv,c.endpointReachedTriggerActionDescriptor=Nd,c.endpointReachedTriggerActionDescriptorRef=Dv,c.endpointReachedTriggerActionDescriptorRefFour=Ov,c.endpointReachedTriggerActionDescriptorRefThree=Sv,c.endpointReachedTriggerActionDescriptorRefTwo=Pv,c.endpointRequestBodyArgumentDeclaration=wd,c.endpointRequestBodyArgumentDeclarationRef=Tv,c.endpointRequestBodyVariableDataType=vv,c.endpointRequestHeadersArgumentDeclaration=Od,c.endpointRequestHeadersArgumentDeclarationRef=fv,c.endpointRequestHeadersVariableDataType=mv,c.endpointRequestHeadersVariableDataTypeRef=yv,c.endpointRequestQueryParamsArgumentDeclaration=Cd,c.endpointRequestQueryParamsArgumentDeclarationRef=Rv,c.endpointRequestQueryParamsVariableDataType=gv,c.endpointRequestQueryParamsVariableDataTypeRef=Ev,c.endpointResponseBodyDataType=Gv,c.endpointResponseBodyReturnDeclaration=_d,c.endpointResponseBodyReturnDeclarationRef=Lv,c.endpointResponseCodeDataType=Cv,c.endpointResponseCodeReturnDeclaration=Bd,c.endpointResponseCodeReturnDeclarationRef=Vv,c.endpointResponseHeadersDataType=_v,c.endpointResponseHeadersDataTypeRef=Bv,c.endpointResponseHeadersReturnDeclaration=Md,c.endpointResponseHeadersReturnDeclarationRef=Mv,c.endpointReturnStatementRef=wv,c.endpointReturnStatementRefThree=$v,c.endpointReturnStatementRefTwo=Nv,c.enrichFromKnownEntities=As,c.enumOptionsProperty=eh,c.enumOptionsPropertyDataType=Xp,c.enumOptionsPropertyDataTypeRef=zp,c.enumOptionsPropertyRef=Kp,c.enumPrototype=qn,c.enumPrototypeRef=Qp,c.executionBuiltInBaseEntity=to,c.executionBuiltInEntityAbortMethod=Ud,c.executionBuiltInEntityAbortMethodParentRef=IE,c.filterOutDuplicateEntities=m,c.filterOutDuplicateErrors=vk,c.findEntityFromKeys=Dp,c.findReferenceToSelfInList=RD,c.findReferencesToSelfInProject=pq,c.flattenActionDescriptor=bD,c.flattenArgumentDeclaration=ID,c.flattenBreakStatement=AD,c.flattenBuiltInBaseEntity=DD,c.flattenCalls=Un,c.flattenCanvasAncestorsUntil=Nl,c.flattenCondition=PD,c.flattenContinueStatement=SD,c.flattenDataType=VD,c.flattenDefinitionEntity=OD,c.flattenDefinitionEntityExtensionAndImplementationTypes=_p,c.flattenDefinitionEntityExtensionTypes=xl,c.flattenDefinitionEntityExtensions=Bp,c.flattenDefinitionEntityImplementations=Mp,c.flattenDefinitionEntityImplementionTypes=Ul,c.flattenDerivedCanvasEntities=Kt,c.flattenDetachedBranch=iP,c.flattenElementCalls=Xe,c.flattenElementCallsOnTheSameScope=cq,c.flattenEntity=S,c.flattenFunctionCall=CD,c.flattenFunctionDeclaration=wD,c.flattenGlobalEvent=BD,c.flattenInputMap=MD,c.flattenInstalledProject=_D,c.flattenInternalCall=ND,c.flattenLiteralValue=LD,c.flattenLoop=GD,c.flattenOperation=$D,c.flattenOutputMap=FD,c.flattenPrimitiveEntity=UD,c.flattenProject=xD,c.flattenProjectElements=ED,c.flattenProperty=jD,c.flattenRelatedCanvasElementsOnTheLeft=eP,c.flattenRelatedCanvasElementsOnTheRight=QD,c.flattenReturnDeclaration=kD,c.flattenReturnStatement=ZD,c.flattenSearch=qD,c.flattenValueDescriptor=JD,c.flattenVariableDeclaration=WD,c.flattenVariableInstance=YD,c.flattenVariableReads=vD,c.flattenVariableWrites=TD,c.flattenVariables=xe,c.fromZodParseToEntityGenerationErrors=hp,c.generate=CO,c.generateActionExample=H7,c.generateExecutionDataType=r7,c.generateIdFromStrategy=at,c.generateMutablePropertiesExplanation=Dl,c.generateRandomBoolean=MR,c.generateRandomDate=uR,c.generateRandomDateAfter=oR,c.generateRandomDateBefore=lR,c.generateRandomDateBetweenRange=dR,c.generateRandomNumber=OR,c.generateRandomNumberAfter=DR,c.generateRandomNumberBefore=PR,c.generateRandomNumberBetweenRange=SR,c.generateRandomText=BR,c.generateRandomTextAfter=VR,c.generateRandomTextBefore=CR,c.generateRandomTextBetweenRange=wR,c.generateUniqueUUID=AR,c.getAllActionDescriptorsForConditions=Bl,c.getAllActionDescriptorsForGlobalEvents=Cl,c.getAllActionDescriptorsForLoops=wl,c.getAllActionDescriptorsForOperations=Q7,c.getAllBuiltInEntityIds=Cp,c.getAllGloballyDeclaredFunctionDeclarationsExplanation=Q1,c.getBaseBuiltInEntities=Vr,c.getBaseSchemaBasedOnType=q1,c.getBuiltInEntityOwner=Cr,c.getCallableEntityReferenceSchema=Rt,c.getCallableEntityTypeSchema=EA,c.getCalledBy=ln,c.getCallerEntityReferenceSchema=I3,c.getCallerEntityTypeSchema=b3,c.getCalls=Op,c.getCanvasEntitiesDerivedFromInternalCalls=XD,c.getCanvasEntitiesDerivedFromWrites=ma,c.getCanvasEntityDerivedFromValueReadingEntity=Fl,c.getCanvasEntityDerivedFromValueReadingEntityFromTransfer=KD,c.getCanvasEntityReferenceSchema=U3,c.getCanvasEntityTypeSchema=F3,c.getChildrenEntityWithValues=aq,c.getColumnProperties=Sq,c.getCommonAncestor=Sp,c.getCommonChildren=sD,c.getDatabaseEntities=Dq,c.getDatabaseEntity=Oq,c.getDeclaration=si,c.getDeepestScope=oP,c.getDefinitionEntityExtends=Ta,c.getDraggableCallableEntityReferenceSchema=gA,c.getDraggableCallableEntityTypeSchema=RA,c.getDraggableCallerEntityReferenceSchema=D3,c.getDraggableCallerEntityTypeSchema=A3,c.getDraggableExecutableEntityReferenceSchema=V3,c.getDraggableExecutableEntityTypeSchema=O3,c.getDraggablePassThroughCallableEntityReferenceSchema=cl,c.getDraggablePassThroughCallableEntityTypeSchema=ul,c.getDraggablePlayableEntityReferenceSchema=_3,c.getDraggablePlayableEntityTypeSchema=M3,c.getEntityArgumentDeclarations=wp,c.getEntityInputMaps=HD,c.getEntityOutputMaps=mq,c.getEntityReferenceSchema=$3,c.getEntityReturnDeclarations=zD,c.getEntityTypeSchema=G3,c.getEntityWithLogicScopeReferenceSchema=rr,c.getEntityWithLogicScopeTypeSchema=C3,c.getEntityWithValueReferenceSchema=vA,c.getEntityWithValueTypeSchema=g3,c.getEntryPointEntityReferenceSchema=vt,c.getEntryPointEntityTypeSchema=br,c.getEventEntityReferenceSchema=ll,c.getEventEntityTypeSchema=ol,c.getExecutableEntityReferenceSchema=S3,c.getExecutableEntityTypeSchema=P3,c.getExtendedBuiltInEntity=Tq,c.getExtendedDefinitionEntity=Np,c.getGenerationTargetSchemaBasedOnType=J1,c.getHeadIfPartOfDetachedBranch=rP,c.getHighestScope=sP,c.getImplementedBuiltInEntity=vq,c.getIsInteractive=Lp,c.getLastInListOperation=ld,c.getLastInListOperationError=df,c.getLastInListOperationErrorParentRef=lf,c.getLastInListOperationInputListArgument=af,c.getLastInListOperationInputListArgumentParentRef=rf,c.getLastInListOperationInputListArgumentRef=Qy,c.getLastInListOperationInputListDataType=ef,c.getLastInListOperationOutputElementDataType=nf,c.getLastInListOperationOutputElementReturn=of,c.getLastInListOperationOutputElementReturnParentRef=sf,c.getLastInListOperationOutputElementReturnRef=tf,c.getLinkedEntitiesFromArgumentDeclaration=uq,c.getLowestPersistedEntityImplementation=tP,c.getParentCallableEntity=oD,c.getParentCallerEntity=dD,c.getParentCanvasEntities=Zt,c.getParentCanvasEntity=At,c.getParentCanvasEntityFromTransfer=Ll,c.getParentEntryPoint=iq,c.getParentPassthroughCallableEntity=lD,c.getPassThroughCallableEntityReferenceSchema=Ye,c.getPassThroughCallableEntityTypeSchema=dl,c.getPeristedEntities=Aq,c.getPlayableEntityReferenceSchema=B3,c.getPlayableEntityTypeSchema=w3,c.getProject=oJ,c.getPrototypeByType=jl,c.getReferenceEntityId=P,c.getReferencedEntitiesStateOrErrors=Sl,c.getReferencedEntityStateOrErrors=yp,c.getReferencedIds=hq,c.getRelatedCanvasElementsOnTheLeft=Ri,c.getRelatedCanvasElementsOnTheLeftFromTransfer=gD,c.getRelatedCanvasElementsOnTheRight=Or,c.getRootEntryPointScopeOwner=Fp,c.getScopeOwner=qt,c.getTerminationReferenceSchema=L3,c.getTerminationTypeSchema=N3,c.getUpstreamDependencyIds=$l,c.getUsedArgFromDeclaration=yq,c.getUsedReturnFromDeclaration=fq,c.getValueReadingEntityReferenceSchema=TA,c.getValueReadingEntityTypeSchema=nr,c.getValueWritingEntityReferenceSchema=R3,c.getValueWritingEntityTypeSchema=us,c.getVariableFromInputMapping=cD,c.getVariableFromReturnVariablePointer=yD,c.getVariableReferenceSchema=gr,c.getVariableTypeSchema=ei,c.getVariablesFromArgumentDeclarations=Gl,c.getVariablesFromInputMaps=pD,c.getVariablesFromOutputMapping=fD,c.getVariablesFromOutputMaps=mD,c.getVariablesFromReturnDeclarations=hD,c.getVariablesInSameOrHigherScope=sp,c.getWrites=Vp,c.groupCallsBasedOnParallelizableExecution=oq,c.handleAfterEntityImplementationSideEffects=iD,c.handleBeforeEntityImplementationSideEffects=rD,c.httpRequestBodyArgument=xs,c.httpRequestBodyArgumentRef=jm,c.httpRequestBodyDataType=km,c.httpRequestHeadersArgument=Us,c.httpRequestHeadersArgumentRef=Um,c.httpRequestHeadersDataType=xm,c.httpRequestMethodArgument=$s,c.httpRequestMethodArgumentRef=$m,c.httpRequestMethodDataType=Fm,c.httpRequestMethodDataTypeRef=Lm,c.httpRequestOperation=ga,c.httpRequestOperationErrorValueDescriptor=md,c.httpRequestOperationErrorValueDescriptorDatatype=l0,c.httpRequestOperationErrorValueDescriptorRef=o0,c.httpRequestOperationRef=r0,c.httpRequestOperationRefEight=a0,c.httpRequestOperationRefFive=t0,c.httpRequestOperationRefFour=e0,c.httpRequestOperationRefNine=s0,c.httpRequestOperationRefSeven=i0,c.httpRequestOperationRefSix=n0,c.httpRequestOperationRefThree=Qm,c.httpRequestOperationRefTwo=Xm,c.httpRequestQueryParamsArgument=fd,c.httpRequestQueryParamsArgumentRef=_m,c.httpRequestQueryParamsDataType=Nm,c.httpRequestVariableURLArgument=Fs,c.httpRequestVariableURLArgumentRef=Bm,c.httpRequestVariableURLDataType=Mm,c.httpRequestVariableURLDataTypeRef=Cm,c.httpResponseBodyReturnDataType=Km,c.httpResponseBodyReturnDataTypeRef=Hm,c.httpResponseBodyReturnReturn=Zs,c.httpResponseBodyReturnReturnRef=zm,c.httpResponseCodeDataType=qm,c.httpResponseCodeReturn=js,c.httpResponseCodeReturnRef=Zm,c.httpResponseHeadersDataType=Ym,c.httpResponseHeadersDataTypeRef=Jm,c.httpResponseHeadersReturn=ks,c.httpResponseHeadersReturnRef=Wm,c.implement=Ml,c.inferArgumentDeclarationDataType=M1,c.inferDataType=$n,c.inferInputMapDataType=rp,c.inferOutputMapDataType=ap,c.inferPropertyDataType=L1,c.inferReturnDeclarationDataType=ip,c.inferValueDescriptorDataType=G1,c.inferVariableDeclarationDataType=N1,c.inferVariableInstanceDataType=_1,c.initBaseProjectEntity=xp,c.initProject=yP,c.isPromise=Ip,c.iterateOverListActionDescriptorListArgumentDeclaration=j0,c.iterateOverListActionDescriptorListArgumentDeclarationDataType=U0,c.iterateOverListActionDescriptorListArgumentDeclarationDataTypeParentRef=F0,c.iterateOverListActionDescriptorListArgumentDeclarationParentRef=x0,c.iterateOverListLoopActionDescriptor=cr,c.iterateOverListLoopActionDescriptorDynamicReturnDeclaration=Z0,c.iterateOverListLoopActionDescriptorDynamicReturnDeclarationParentRef=k0,c.iterateOverListLoopBodyActionDescriptor=Aa,c.iterateOverListLoopBodyActionDescriptorAnyDynamicArgument=Q0,c.iterateOverListLoopBodyActionDescriptorAnyDynamicArgumentParentRef=X0,c.iterateOverListLoopBodyActionDescriptorAnyDynamicReturn=tT,c.iterateOverListLoopBodyActionDescriptorAnyDynamicReturnParentRef=eT,c.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Ys,c.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=J0,c.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=q0,c.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=W0,c.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclaration=K0,c.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=H0,c.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=Y0,c.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=z0,c.iterateOverObjectKeysActionDescriptorObjectArgumentDeclaration=sT,c.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataType=iT,c.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataTypeParentRef=rT,c.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationParentRef=aT,c.iterateOverObjectKeysLoopActionDescriptor=Ci,c.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclaration=lT,c.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclarationParentRef=oT,c.iterateOverObjectKeysLoopBodyActionDescriptor=gd,c.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgument=TT,c.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgumentParentRef=mT,c.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturn=ET,c.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturnParentRef=vT,c.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Rd,c.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=uT,c.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=dT,c.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=cT,c.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclaration=fT,c.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=hT,c.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=pT,c.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=yT,c.iterateOverObjectValuesActionDescriptorObjectArgumentDeclaration=AT,c.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataType=bT,c.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataTypeParentRef=gT,c.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationParentRef=IT,c.iterateOverObjectValuesLoopActionDescriptor=wi,c.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclaration=PT,c.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclarationParentRef=DT,c.iterateOverObjectValuesLoopBodyActionDescriptor=Id,c.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgument=NT,c.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgumentParentRef=_T,c.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturn=GT,c.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturnParentRef=LT,c.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclaration=bd,c.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=OT,c.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=ST,c.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=VT,c.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclaration=MT,c.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=wT,c.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=CT,c.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=BT,c.iterateOverStringActionDescriptorDynamicReturnDeclaration=S0,c.iterateOverStringActionDescriptorDynamicReturnDeclarationParentRef=P0,c.iterateOverStringActionDescriptorStringArgumentDeclaration=D0,c.iterateOverStringActionDescriptorStringArgumentDeclarationDataType=I0,c.iterateOverStringActionDescriptorStringArgumentDeclarationDataTypeParentRef=b0,c.iterateOverStringActionDescriptorStringArgumentDeclarationParentRef=A0,c.iterateOverStringLoopActionDescriptor=Ia,c.iterateOverStringLoopBodyActionDescriptor=Ws,c.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgument=N0,c.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgumentParentRef=_0,c.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturn=G0,c.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturnParentRef=L0,c.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclaration=vd,c.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=V0,c.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=O0,c.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=C0,c.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Ed,c.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=B0,c.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=w0,c.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=M0,c.joinListOperation=ad,c.joinListOperationError=By,c.joinListOperationErrorParentRef=wy,c.joinListOperationFirstListArgument=Py,c.joinListOperationFirstListArgumentParentRef=Dy,c.joinListOperationFirstListArgumentRef=Ey,c.joinListOperationFirstListDataType=Ry,c.joinListOperationResultListDataType=Ay,c.joinListOperationResultListReturn=Cy,c.joinListOperationResultListReturnParentRef=Vy,c.joinListOperationResultListReturnRef=Iy,c.joinListOperationSecondListArgument=Oy,c.joinListOperationSecondListArgumentParentRef=Sy,c.joinListOperationSecondListArgumentRef=gy,c.joinListOperationSecondListDataType=by,c.joinListWithLastSeparator=z,c.joinStringsOperation=Ra,c.joinStringsOperationDynamicStringArgument=Xh,c.joinStringsOperationDynamicStringArgumentParentRef=Kh,c.joinStringsOperationDynamicStringArgumentRef=Hh,c.joinStringsOperationDynamicStringDataType=zh,c.joinStringsOperationError=Yh,c.joinStringsOperationErrorParentRef=Wh,c.joinStringsOperationFirstStringArgument=Ns,c.joinStringsOperationFirstStringArgumentParentRef=$h,c.joinStringsOperationFirstStringArgumentRef=Bh,c.joinStringsOperationFirstStringDataType=Mh,c.joinStringsOperationResultStringDataType=Gh,c.joinStringsOperationResultStringReturn=Ea,c.joinStringsOperationResultStringReturnParentRef=Jh,c.joinStringsOperationResultStringReturnRef=Lh,c.joinStringsOperationSecondStringArgument=Ls,c.joinStringsOperationSecondStringArgumentParentRef=qh,c.joinStringsOperationSecondStringArgumentRef=_h,c.joinStringsOperationSecondStringDataType=Nh,c.joinStringsOperationSeparatorStringArgument=Zh,c.joinStringsOperationSeparatorStringArgumentParentRef=kh,c.joinStringsOperationSeparatorStringArgumentRef=Fh,c.joinStringsOperationSeparatorStringDataType=jh,c.joinStringsOperationSeparatorStringDataTypeDefaultValue=xh,c.joinStringsOperationSeparatorStringDataTypeDefaultValueParentRef=Uh,c.keyValuePrototype=Si,c.lowercaseFirstLetter=Rl,c.manualFlowActionDescriptorDeclarationArgumentDeclaration=Td,c.manualFlowActionDescriptorDeclarationArgumentDeclarationDataType=f0,c.manualFlowActionDescriptorDeclarationArgumentDeclarationDataTypeParentRef=y0,c.manualFlowActionDescriptorDeclarationArgumentDeclarationParentRef=m0,c.manualFlowLoopActionDescriptor=qs,c.manualFlowLoopActionDescriptorDynamicReturnDeclaration=h0,c.manualFlowLoopActionDescriptorDynamicReturnDeclarationParentRef=p0,c.manualFlowLoopBodyActionDescriptor=Js,c.manualFlowLoopBodyActionDescriptorAnyDynamicArgument=v0,c.manualFlowLoopBodyActionDescriptorAnyDynamicArgumentParentRef=T0,c.manualFlowLoopBodyActionDescriptorAnyDynamicReturn=R0,c.manualFlowLoopBodyActionDescriptorAnyDynamicReturnParentRef=E0,c.mapActionDescriptorToTypeItRepresents=Iq,c.mergeEntityErrorsList=Ek,c.mergeListOfEntities=Rq,c.methodDefaultValue=Gm,c.mockClientProject=YI,c.moreThanOrEqualCondition=Li,c.moreThanOrEqualConditionLeftHandArgument=wE,c.moreThanOrEqualConditionLeftHandArgumentDataType=VE,c.moreThanOrEqualConditionLeftHandArgumentDataTypeParentRef=OE,c.moreThanOrEqualConditionLeftHandArgumentParentRef=CE,c.moreThanOrEqualConditionRightHandArgument=NE,c.moreThanOrEqualConditionRightHandArgumentDataType=ME,c.moreThanOrEqualConditionRightHandArgumentDataTypeParentRef=BE,c.moreThanOrEqualConditionRightHandArgumentParentRef=_E,c.notEmptyCondition=Fr,c.notEmptyConditionArgument=PE,c.notEmptyConditionRef=DE,c.nullPrototype=Hp,c.numberAdditionOperation=_s,c.numberAdditionOperationDynamicSummandArgument=yh,c.numberAdditionOperationDynamicSummandArgumentType=hh,c.numberAdditionOperationDynamicSummandArgumentTypeParentRef=ph,c.numberAdditionOperationError=ch,c.numberAdditionOperationErrorParentRef=uh,c.numberAdditionOperationFirstNumberArgument=Xl,c.numberAdditionOperationFirstNumberArgumentRef=nh,c.numberAdditionOperationFirstNumberDataType=rh,c.numberAdditionOperationRef=lh,c.numberAdditionOperationRefThree=ed,c.numberAdditionOperationRefTwo=dh,c.numberAdditionOperationResultNumberDataType=oh,c.numberAdditionOperationResultNumberReturn=td,c.numberAdditionOperationResultNumberReturnRef=sh,c.numberAdditionOperationSecondNumberArgument=Ql,c.numberAdditionOperationSecondNumberArgumentRef=ih,c.numberAdditionOperationSecondNumberDataType=ah,c.numberPrototype=de,c.numberSubtractionOperation=rd,c.numberSubtractionOperationDynamicSubtrahendArgument=Ch,c.numberSubtractionOperationDynamicSubtrahendArgumentType=Vh,c.numberSubtractionOperationDynamicSubtrahendArgumentTypeParentRef=Oh,c.numberSubtractionOperationError=Sh,c.numberSubtractionOperationErrorParentRef=Ph,c.numberSubtractionOperationFirstNumberArgument=gh,c.numberSubtractionOperationFirstNumberArgumentRef=fh,c.numberSubtractionOperationFirstNumberDataType=mh,c.numberSubtractionOperationRef=nd,c.numberSubtractionOperationRefThree=Ah,c.numberSubtractionOperationRefTwo=bh,c.numberSubtractionOperationResultNumberDataType=Rh,c.numberSubtractionOperationResultNumberReturn=Dh,c.numberSubtractionOperationResultNumberReturnRef=Eh,c.numberSubtractionOperationSecondNumberArgument=Ih,c.numberSubtractionOperationSecondNumberArgumentRef=Th,c.numberSubtractionOperationSecondNumberDataType=vh,c.numberValueAutogenerationSchema=ec,c.parallelExecutionOperation=En,c.parallelExecutionOperationError=Nf,c.parallelExecutionOperationErrorParentRef=_f,c.parallelExecutionOperationListOfExecutionResultsDataType=wf,c.parallelExecutionOperationListOfExecutionResultsReturn=pd,c.parallelExecutionOperationListOfExecutionResultsReturnRef=Cf,c.parallelExecutionOperationListOfFunctionsArgument=cd,c.parallelExecutionOperationListOfFunctionsArgumentDatatype=Vf,c.parallelExecutionOperationListOfFunctionsArgumentRef=Of,c.parallelExecutionOperationListOfFunctionsBlueprint=Sf,c.parallelExecutionOperationListOfFunctionsBlueprintDynamicInput=Pf,c.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutput=Df,c.parallelExecutionOperationRef=Bf,c.parallelExecutionOperationRefThree=Mf,c.persistedBuiltInBaseEntity=bt,c.persistedBuiltInBaseEntityDatabaseProperty=Mi,c.persistedBuiltInBaseEntityDatabasePropertyDataType=sE,c.persistedBuiltInBaseEntityDatabasePropertyDataTypeRef=AP,c.persistedBuiltInBaseEntityDatabasePropertyParentRef=oE,c.persistedBuiltInBaseEntityDatabasePropertyRef=aE,c.persistedBuiltInBaseEntityPrimaryKeyProperty=_i,c.persistedBuiltInBaseEntityPrimaryKeyPropertyDataType=fE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOption=dE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOptionParentRef=lE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyParentRef=mE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyRef=yE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOption=cE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOptionParentRef=uE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOption=hE,c.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOptionParentRef=pE,c.processOutputGlobalValueDescriptorDataType=jE,c.processOutputGlobalValueDescriptorReturn=ro,c.processOutputGlobalValueDescriptorReturnRef=xE,c.projectPublicationCompletedGlobalEvent=no,c.propertyToZodSchema=aR,c.relationalDatabaseBuiltInBaseEntity=Vn,c.relationalDatabaseBuiltInBaseEntityAutoscalingProperty=Gd,c.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataType=tE,c.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataTypeRef=eE,c.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyParentRef=nE,c.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyRef=Qv,c.relationalDatabaseBuiltInBaseEntityDefaultProperty=Ld,c.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataType=Xv,c.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataTypeRef=zv,c.relationalDatabaseBuiltInBaseEntityDefaultPropertyRef=Kv,c.relationalDatabaseBuiltInBaseEntityIdentifierProperty=zs,c.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataType=jv,c.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataTypeRef=Uv,c.relationalDatabaseBuiltInBaseEntityIdentifierPropertyRef=xv,c.relationalDatabaseBuiltInBaseEntityMinSizeProperty=Qs,c.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataType=Hv,c.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataTypeRef=Wv,c.relationalDatabaseBuiltInBaseEntityMinSizePropertyRef=Yv,c.relationalDatabaseBuiltInBaseEntityPasswordProperty=Xs,c.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataType=Jv,c.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataTypeRef=IP,c.relationalDatabaseBuiltInBaseEntityPasswordPropertyRef=qv,c.relationalDatabaseBuiltInBaseEntityRef=Bi,c.relationalDatabaseBuiltInBaseEntityUsernameProperty=Ks,c.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataType=Zv,c.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataTypeRef=bP,c.relationalDatabaseBuiltInBaseEntityUsernamePropertyRef=kv,c.resolveActionDescriptorName=k1,c.resolveBaseEntityName=F1,c.resolveBuiltInBaseEntityDataTypeLabel=U1,c.resolveClonedEntityProject=st,c.resolveConditionOperatorLabel=Il,c.resolveDataType=gl,c.resolveDataTypeEntityOrNestedChildrenFromLiteralValue=Pp,c.resolveDataTypeLabel=Rs,c.resolveDefinitionEntityDataTypeLabel=l7,c.resolveEntityDataTypeLabel=o7,c.resolveEntityName=C,c.resolveFirstCallsSecond=lq,c.resolveFirstWritesSecond=dq,c.resolvePrimaryKeyProperty=Pq,c.resolvePrimitiveEntityName=j1,c.resolveSearchName=x1,c.resolveVariableScope=i7,c.sequentialExecutionOperation=Yn,c.sequentialExecutionOperationError=tm,c.sequentialExecutionOperationErrorParentRef=em,c.sequentialExecutionOperationListOfExecutionResultsDataType=Kf,c.sequentialExecutionOperationListOfExecutionResultsReturn=yd,c.sequentialExecutionOperationListOfExecutionResultsReturnParentRef=Qf,c.sequentialExecutionOperationListOfExecutionResultsReturnRef=zf,c.sequentialExecutionOperationListOfFunctionsArgument=hd,c.sequentialExecutionOperationListOfFunctionsArgumentDatatype=Hf,c.sequentialExecutionOperationListOfFunctionsArgumentParentRef=Xf,c.sequentialExecutionOperationListOfFunctionsArgumentRef=Yf,c.sequentialExecutionOperationListOfFunctionsBlueprint=Wf,c.sequentialExecutionOperationListOfFunctionsBlueprintDynamicInput=Jf,c.sequentialExecutionOperationListOfFunctionsBlueprintDynamicOutput=qf,c.softDeletePersistedEntityMethod=DP,c.softDeletePersistedEntityMethodParentRef=TE,c.sortCallsBasedOnExecutionDependencies=uD,c.sortChildrenEntitiesBasedOnExecutionDependencies=sq,c.splitListOperation=od,c.splitListOperationError=zy,c.splitListOperationErrorParentRef=Hy,c.splitListOperationFirstOutputListDataType=Fy,c.splitListOperationFirstOutputListReturn=qy,c.splitListOperationFirstOutputListReturnParentRef=Zy,c.splitListOperationFirstOutputListReturnRef=sd,c.splitListOperationInputListArgument=xy,c.splitListOperationInputListArgumentParentRef=Uy,c.splitListOperationInputListArgumentRef=Ny,c.splitListOperationInputListDataType=Ly,c.splitListOperationSecondOutputListDataType=Jy,c.splitListOperationSecondOutputListReturn=Yy,c.splitListOperationSecondOutputListReturnParentRef=Wy,c.splitListOperationSplitIndexArgument=ky,c.splitListOperationSplitIndexArgumentParentRef=jy,c.splitListOperationSplitIndexArgumentRef=Gy,c.splitListOperationSplitIndexDataType=$y,c.splitStringOperation=id,c.splitStringOperationError=fy,c.splitStringOperationErrorParentRef=yy,c.splitStringOperationFirstPartResultStringDataType=iy,c.splitStringOperationFirstPartResultStringReturn=hy,c.splitStringOperationFirstPartResultStringReturnParentRef=py,c.splitStringOperationFirstPartResultStringReturnRef=ry,c.splitStringOperationIndexArgument=uy,c.splitStringOperationIndexArgumentParentRef=dy,c.splitStringOperationIndexArgumentRef=ty,c.splitStringOperationIndexDataType=ny,c.splitStringOperationSecondPartResultStringDataType=sy,c.splitStringOperationSecondPartResultStringReturn=RP,c.splitStringOperationSecondPartResultStringReturnParentRef=cy,c.splitStringOperationSecondPartResultStringReturnRef=ay,c.splitStringOperationStringArgument=ly,c.splitStringOperationStringArgumentParentRef=oy,c.splitStringOperationStringArgumentRef=Qh,c.splitStringOperationStringDataType=ey,c.stringPrototype=K,c.stringValueAutogenerationSchema=Qu,c.suggestNewIdForEntity=pp,c.test_primitive_entities_export=dJ,c.toCamelCase=a7,c.toEntityState=Xt,c.toKebabCase=$1,c.toLowerCaseKebabCase=bl,c.toPascalCase=s7,c.untypedDataPrototype=Et,c.updateErrorsList=je,c.updateValueReader=gq,c.urlDefaultValue=wm,c.uuidPrototype=Jn,c.validateArgumentDeclarationName=up,c.validateCalledByErrorIdInAction=K7,c.validateCalledByIdInAction=z7,c.validateCallers=X1,c.validateConditionEntityDeclaration=eq,c.validateDataOperation=_r,c.validateDataOperationDataToValidateArgument=Rm,c.validateDataOperationDataToValidateArgumentParentRef=Em,c.validateDataOperationDataToValidateArgumentRef=Tm,c.validateDataOperationDataToValidateDataType=vm,c.validateDataOperationEntityToMatchTypeArgument=Am,c.validateDataOperationEntityToMatchTypeArgumentParentRef=Im,c.validateDataOperationEntityToMatchTypeArgumentRef=gm,c.validateDataOperationEntityToMatchTypeDataType=bm,c.validateDataOperationError=Om,c.validateDataOperationErrorParentRef=Sm,c.validateDataOperationOutputEntityDeclaration=Pm,c.validateDataOperationOutputEntityDeclarationParentRef=Dm,c.validateDefinitionEntityName=Al,c.validateEntryCaller=K1,c.validateErrorCaller=z1,c.validateFunctionCallDeclaration=eD,c.validateFunctionDeclarationName=op,c.validateGeneratedEntityParentIsNotBuiltInEntity=J7,c.validateGeneration=Z7,c.validateGenerationTarget=tt,c.validateGenerationUpdate=q7,c.validateLoopEntityDeclaration=tq,c.validateName=d7,c.validateOperationEntityDeclaration=tD,c.validatePropertyName=dp,c.validateReachability=lr,c.validateReadsValueInActionPayload=X7,c.validateReferenceObject=Pl,c.validateReferenceToOne=fp,c.validateReferences=mt,c.validateReturnDeclarationName=cp,c.validateSuccessCaller=H1,c.validateValueReaderGenerationUpdate=bs,c.validateValueWritter=gp,c.validateVariableDeclarationName=lp,c.validateVariableInternalCallUse=bp,c.valueAutogenerationCurrentDateAndTimeSchema=KI,c.valueAutogenerationGenericSchema=Jo,c.valueAutogenerationOptions=nc,c.valueAutogenerationOptionsSchema=zI,c.valueAutogenerationRandomBooleanSchema=Xu,c.valueAutogenerationRandomDateBetweenSchema=sA,c.valueAutogenerationRandomDateFromSchema=iA,c.valueAutogenerationRandomDateSchema=Ho,c.valueAutogenerationRandomDateUntilSchema=aA,c.valueAutogenerationRandomNumberBetweenSchema=eA,c.valueAutogenerationRandomNumberFromSchema=XI,c.valueAutogenerationRandomNumberSchema=Wo,c.valueAutogenerationRandomNumberUntilSchema=QI,c.valueAutogenerationRandomSchema=rs,c.valueAutogenerationRandomTextBetweenSchema=rA,c.valueAutogenerationRandomTextFromSchema=tA,c.valueAutogenerationRandomTextSchema=Yo,c.valueAutogenerationRandomTextUntilSchema=nA,c.valueAutogenerationRangeValueTypesSchema=ns,c.valueAutogenerationUniqueSchema=Ku,c.waitOperation=Lt,c.waitOperationMillisecondsNumberArgument=Br,c.waitOperationMillisecondsNumberArgumentRef=$f,c.waitOperationMillisecondsNumberDataType=Ff,c.waitOperationOperationError=jf,c.waitOperationOperationErrorParentRef=xf,c.waitOperationRef=Uf,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,4 @@
1
- import { BaseEntityNames, ElementGenerationTarget, ElementShallowTransfer, ElementTransfer, EntityType, Element, IGenericReference, EntityId, ValueReadingEntityTypesUnion, ValueReadingEntity, IActionDescriptor, IActionDescriptorTransfer, IArgumentDeclaration, IArgumentDeclarationTransfer, DraggableElement, Reference, IBreakStatement, IBreakStatementTransfer, IBuiltInBaseEntity, IBuiltInBaseEntityTransfer, ICondition, IConditionTransfer, IContinueStatement, IContinueStatementTransfer, CallableEntity, CallableEntityTransfer, CallerEntity, CallerEntityTransfer, IDefinitionEntity, IDefinitionEntityTransfer, IDataType, IDataTypeTransfer, IFunctionCall, IFunctionCallTransfer, IFunctionDeclaration, IFunctionDeclarationTransfer, IGlobalEvent, IGlobalEventTransfer, IInputMap, IInputMapTransfer, IInstalledProject, IInstalledProjectTransfer, IInternalCall, IInternalCallTransfer, ILiteralValue, ILiteralValueTransfer, ILoop, ILoopTransfer, IOperation, IOperationTransfer, IOutputMap, IOutputMapTransfer, IPrimitiveEntity, IPrimitiveEntityTransfer, IProject, IProjectTransfer, IProperty, IPropertyTransfer, IReturnDeclaration, IReturnDeclarationTransfer, IReturnStatement, IReturnStatementTransfer, ISearch, ISearchTransfer, IValueDescriptor, IValueDescriptorTransfer, IVariableDeclarationTransfer, IVariableDeclaration, IVariableInstance, IVariableInstanceTransfer, DraggableElementTransfer, ValueReadingEntityTransfer } from '../../definitions';
1
+ import { BaseEntityNames, ElementGenerationTarget, ElementShallowTransfer, ElementTransfer, EntityType, Element, IGenericReference, EntityId, ValueReadingEntityTypesUnion, ValueReadingEntity, IActionDescriptor, IActionDescriptorTransfer, IArgumentDeclaration, IArgumentDeclarationTransfer, DraggableElement, Reference, IBreakStatement, IBreakStatementTransfer, IBuiltInBaseEntity, IBuiltInBaseEntityTransfer, ICondition, IConditionTransfer, IContinueStatement, IContinueStatementTransfer, CallableEntity, CallableEntityTransfer, CallerEntity, CallerEntityTransfer, IDefinitionEntity, IDefinitionEntityTransfer, IDataType, IDataTypeTransfer, IFunctionCall, IFunctionCallTransfer, IFunctionDeclaration, IFunctionDeclarationTransfer, IGlobalEvent, IGlobalEventTransfer, IInputMap, IInputMapTransfer, IInstalledProject, IInstalledProjectTransfer, IInternalCall, IInternalCallTransfer, ILiteralValue, ILiteralValueTransfer, ILoop, ILoopTransfer, IOperation, IOperationTransfer, IOutputMap, IOutputMapTransfer, IPrimitiveEntity, IPrimitiveEntityTransfer, IProject, IProjectTransfer, IProperty, IPropertyTransfer, IReturnDeclaration, IReturnDeclarationTransfer, IReturnStatement, IReturnStatementTransfer, ISearch, ISearchTransfer, IValueDescriptor, IValueDescriptorTransfer, IVariableDeclarationTransfer, IVariableDeclaration, IVariableInstance, IVariableInstanceTransfer, DraggableElementTransfer, ValueReadingEntityTransfer, IActionDescriptorShallowTransfer, IDataTypeShallowTransfer, IDefinitionEntityShallowTransfer, IFunctionDeclarationShallowTransfer, IInstalledProjectShallowTransfer, ILoopShallowTransfer, IOperationShallowTransfer, ILiteralValueShallowTransfer, IPrimitiveEntityShallowTransfer, IProjectShallowTransfer, IPropertyShallowTransfer, IReturnDeclarationShallowTransfer, IReturnStatementShallowTransfer, ISearchShallowTransfer, IValueDescriptorShallowTransfer, IVariableDeclarationShallowTransfer, IVariableInstanceShallowTransfer, IFunctionCallShallowTransfer, IGlobalEventShallowTransfer, IInputMapShallowTransfer, IInternalCallShallowTransfer, CallableEntityShallowTransfer, IOutputMapShallowTransfer, IConditionShallowTransfer, IContinueStatementShallowTransfer, IBreakStatementShallowTransfer, IArgumentDeclarationShallowTransfer, IBuiltInBaseEntityShallowTransfer, DraggableElementShallowTransfer } from '../../definitions';
2
2
  import { DraggableCallableEntityState, CanvasEntityState, EntityState, EntityWithLogicScopeState, EntryPointEntityState, DraggableExecutableEntityState, DraggablePassThroughCallableEntityState, ValueReadingEntityState, ValueWritingEntityState, EntityWithValueState, VariableState, BuiltInBaseEntityState, TerminationState, InstalledProjectState, ExecutableEntityState, ValueDescriptorState, CallableEntityState, CallerEntityState, PassThroughCallableEntityState, PrimitiveEntityState, InternalCallState } from '../state';
3
3
  import { FunctionCallState } from '../state/function-call';
4
4
  import { InputMapState } from '../state/input-map';
@@ -35,7 +35,7 @@ export declare function checkIsBranchDependentOnBranch(branchA: CanvasEntityStat
35
35
  export declare function getParentEntryPoint(entity: EntityState): EntryPointEntityState | null;
36
36
  export declare function getCommonAncestor(entityA: EntityState, entityB: EntityState): EntityState | null;
37
37
  export declare function getParentCanvasEntity(entity: EntityState): CanvasEntityState | null;
38
- export declare function getParentCanvasEntityFromTransfer(entity: Element | ElementTransfer | IGenericReference, allKnownEntities: Record<EntityId, Element | ElementTransfer>): DraggableElement | DraggableElementTransfer | null;
38
+ export declare function getParentCanvasEntityFromTransfer(entity: Element | ElementTransfer | ElementShallowTransfer | IGenericReference, allKnownEntities: Record<EntityId, Element | ElementTransfer | ElementShallowTransfer>): DraggableElement | DraggableElementTransfer | DraggableElementShallowTransfer | null;
39
39
  export declare function getParentCallableEntity(entity: EntityState): CallableEntityState | null;
40
40
  export declare function getParentPassthroughCallableEntity(entity: EntityState): PassThroughCallableEntityState | null;
41
41
  export declare function getParentCallerEntity(entity: EntityState): CallerEntityState | null;
@@ -66,97 +66,97 @@ export declare function flattenCalls(entities: CallableEntityState[]): CallableE
66
66
  export declare function flattenProjectElements(project: ProjectState): EntityState[];
67
67
  export declare function findReferenceToSelfInList(element: EntityState, elements: EntityState[]): EntityState[];
68
68
  export declare function findReferencesToSelfInProject(element: EntityState): EntityState[];
69
- export declare function enrichFromKnownEntities(entity: ElementTransfer | Element | IGenericReference | EntityId, allKnownEntities: Record<EntityId, Element | ElementTransfer>): Element | ElementTransfer | null;
69
+ export declare function enrichFromKnownEntities(entity: ElementTransfer | Element | ElementShallowTransfer | IGenericReference | EntityId, allKnownEntities: Record<EntityId, Element | ElementTransfer | ElementShallowTransfer>): Element | ElementTransfer | ElementShallowTransfer | null;
70
70
  export declare function getReferencedIds(entity: ElementTransfer | Element | ElementShallowTransfer | EntityState): Record<EntityId, EntityId>;
71
- export declare function getRelatedCanvasElementsOnTheLeftFromTransfer(entity: DraggableElement | DraggableElementTransfer, allKnownEntities: Record<EntityId, Element | ElementTransfer>): (DraggableElement | DraggableElementTransfer)[];
71
+ export declare function getRelatedCanvasElementsOnTheLeftFromTransfer(entity: DraggableElement | DraggableElementTransfer | DraggableElementShallowTransfer, allKnownEntities: Record<EntityId, Element | ElementTransfer | ElementShallowTransfer>): (DraggableElement | DraggableElementTransfer | DraggableElementShallowTransfer)[];
72
72
  export declare function getRelatedCanvasElementsOnTheLeft(entity: CanvasEntityState): CanvasEntityState[];
73
- export declare function getCalledBy(entity: CallableEntityState | CallableEntity | CallableEntityTransfer): (CallerEntityState | CallerEntity | CallerEntityTransfer)[];
74
- export declare function flattenActionDescriptor(entity: IActionDescriptor | IActionDescriptorTransfer, seenEntities?: Set<EntityId>, options?: {
73
+ export declare function getCalledBy(entity: CallableEntityState | CallableEntity | CallableEntityTransfer | CallableEntityShallowTransfer): (CallerEntityState | CallerEntity | CallerEntityTransfer)[];
74
+ export declare function flattenActionDescriptor(entity: IActionDescriptor | IActionDescriptorTransfer | IActionDescriptorShallowTransfer, seenEntities?: Set<EntityId>, options?: {
75
75
  ignoreBuiltInBaseEntities?: boolean;
76
- }): (Element | ElementTransfer)[];
77
- export declare function flattenArgumentDeclaration(entity: IArgumentDeclaration | IArgumentDeclarationTransfer, seenEntities?: Set<EntityId>, options?: {
76
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
77
+ export declare function flattenArgumentDeclaration(entity: IArgumentDeclaration | IArgumentDeclarationTransfer | IArgumentDeclarationShallowTransfer, seenEntities?: Set<EntityId>, options?: {
78
78
  ignoreBuiltInBaseEntities?: boolean;
79
- }): (Element | ElementTransfer)[];
80
- export declare function flattenBreakStatement(entity: IBreakStatement | IBreakStatementTransfer, seenEntities?: Set<EntityId>, options?: {
79
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
80
+ export declare function flattenBreakStatement(entity: IBreakStatement | IBreakStatementTransfer | IBreakStatementShallowTransfer, seenEntities?: Set<EntityId>, options?: {
81
81
  ignoreBuiltInBaseEntities?: boolean;
82
- }): (Element | ElementTransfer)[];
83
- export declare function flattenBuiltInBaseEntity(entity: IBuiltInBaseEntity | IBuiltInBaseEntityTransfer, seenEntities?: Set<EntityId>, options?: {
82
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
83
+ export declare function flattenBuiltInBaseEntity(entity: IBuiltInBaseEntity | IBuiltInBaseEntityTransfer | IBuiltInBaseEntityShallowTransfer, seenEntities?: Set<EntityId>, options?: {
84
84
  ignoreBuiltInBaseEntities?: boolean;
85
- }): (Element | ElementTransfer)[];
86
- export declare function flattenCondition(entity: ICondition | IConditionTransfer, seenEntities?: Set<EntityId>, options?: {
85
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
86
+ export declare function flattenCondition(entity: ICondition | IConditionTransfer | IConditionShallowTransfer, seenEntities?: Set<EntityId>, options?: {
87
87
  ignoreBuiltInBaseEntities?: boolean;
88
- }): (Element | ElementTransfer)[];
89
- export declare function flattenContinueStatement(entity: IContinueStatement | IContinueStatementTransfer, seenEntities?: Set<EntityId>, options?: {
88
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
89
+ export declare function flattenContinueStatement(entity: IContinueStatement | IContinueStatementTransfer | IContinueStatementShallowTransfer, seenEntities?: Set<EntityId>, options?: {
90
90
  ignoreBuiltInBaseEntities?: boolean;
91
- }): (Element | ElementTransfer)[];
92
- export declare function flattenDefinitionEntity(entity: IDefinitionEntity | IDefinitionEntityTransfer, seenEntities?: Set<EntityId>, options?: {
91
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
92
+ export declare function flattenDefinitionEntity(entity: IDefinitionEntity | IDefinitionEntityTransfer | IDefinitionEntityShallowTransfer, seenEntities?: Set<EntityId>, options?: {
93
93
  ignoreBuiltInBaseEntities?: boolean;
94
- }): (Element | ElementTransfer)[];
95
- export declare function flattenDataType(entity: IDataType | IDataTypeTransfer, seenEntities?: Set<EntityId>, options?: {
94
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
95
+ export declare function flattenDataType(entity: IDataType | IDataTypeTransfer | IDataTypeShallowTransfer, seenEntities?: Set<EntityId>, options?: {
96
96
  ignoreBuiltInBaseEntities?: boolean;
97
- }): (Element | ElementTransfer)[];
98
- export declare function flattenFunctionCall(entity: IFunctionCall | IFunctionCallTransfer, seenEntities?: Set<EntityId>, options?: {
97
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
98
+ export declare function flattenFunctionCall(entity: IFunctionCall | IFunctionCallTransfer | IFunctionCallShallowTransfer, seenEntities?: Set<EntityId>, options?: {
99
99
  ignoreBuiltInBaseEntities?: boolean;
100
- }): (Element | ElementTransfer)[];
101
- export declare function flattenFunctionDeclaration(entity: IFunctionDeclaration | IFunctionDeclarationTransfer, seenEntities?: Set<EntityId>, options?: {
100
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
101
+ export declare function flattenFunctionDeclaration(entity: IFunctionDeclaration | IFunctionDeclarationTransfer | IFunctionDeclarationShallowTransfer, seenEntities?: Set<EntityId>, options?: {
102
102
  ignoreBuiltInBaseEntities?: boolean;
103
- }): (Element | ElementTransfer)[];
104
- export declare function flattenGlobalEvent(entity: IGlobalEvent | IGlobalEventTransfer, seenEntities?: Set<EntityId>, options?: {
103
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
104
+ export declare function flattenGlobalEvent(entity: IGlobalEvent | IGlobalEventTransfer | IGlobalEventShallowTransfer, seenEntities?: Set<EntityId>, options?: {
105
105
  ignoreBuiltInBaseEntities?: boolean;
106
- }): (Element | ElementTransfer)[];
107
- export declare function flattenInputMap(entity: IInputMap | IInputMapTransfer, seenEntities?: Set<EntityId>, options?: {
106
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
107
+ export declare function flattenInputMap(entity: IInputMap | IInputMapTransfer | IInputMapShallowTransfer, seenEntities?: Set<EntityId>, options?: {
108
108
  ignoreBuiltInBaseEntities?: boolean;
109
- }): (Element | ElementTransfer)[];
110
- export declare function flattenInstalledProject(entity: IInstalledProject | IInstalledProjectTransfer, seenEntities?: Set<EntityId>, options?: {
109
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
110
+ export declare function flattenInstalledProject(entity: IInstalledProject | IInstalledProjectTransfer | IInstalledProjectShallowTransfer, seenEntities?: Set<EntityId>, options?: {
111
111
  ignoreBuiltInBaseEntities?: boolean;
112
- }): (Element | ElementTransfer)[];
113
- export declare function flattenInternalCall(entity: IInternalCall | IInternalCallTransfer, seenEntities?: Set<EntityId>, options?: {
112
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
113
+ export declare function flattenInternalCall(entity: IInternalCall | IInternalCallTransfer | IInternalCallShallowTransfer, seenEntities?: Set<EntityId>, options?: {
114
114
  ignoreBuiltInBaseEntities?: boolean;
115
- }): (Element | ElementTransfer)[];
116
- export declare function flattenLiteralValue(entity: ILiteralValue | ILiteralValueTransfer, seenEntities?: Set<EntityId>, options?: {
115
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
116
+ export declare function flattenLiteralValue(entity: ILiteralValue | ILiteralValueTransfer | ILiteralValueShallowTransfer, seenEntities?: Set<EntityId>, options?: {
117
117
  ignoreBuiltInBaseEntities?: boolean;
118
- }): (Element | ElementTransfer)[];
119
- export declare function flattenLoop(entity: ILoop | ILoopTransfer, seenEntities?: Set<EntityId>, options?: {
118
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
119
+ export declare function flattenLoop(entity: ILoop | ILoopTransfer | ILoopShallowTransfer, seenEntities?: Set<EntityId>, options?: {
120
120
  ignoreBuiltInBaseEntities?: boolean;
121
- }): (Element | ElementTransfer)[];
122
- export declare function flattenOperation(entity: IOperation | IOperationTransfer, seenEntities?: Set<EntityId>, options?: {
121
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
122
+ export declare function flattenOperation(entity: IOperation | IOperationTransfer | IOperationShallowTransfer, seenEntities?: Set<EntityId>, options?: {
123
123
  ignoreBuiltInBaseEntities?: boolean;
124
- }): (Element | ElementTransfer)[];
125
- export declare function flattenOutputMap(entity: IOutputMap | IOutputMapTransfer, seenEntities?: Set<EntityId>, options?: {
124
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
125
+ export declare function flattenOutputMap(entity: IOutputMap | IOutputMapTransfer | IOutputMapShallowTransfer, seenEntities?: Set<EntityId>, options?: {
126
126
  ignoreBuiltInBaseEntities?: boolean;
127
- }): (Element | ElementTransfer)[];
128
- export declare function flattenPrimitiveEntity(entity: IPrimitiveEntity | IPrimitiveEntityTransfer, seenEntities?: Set<EntityId>, options?: {
127
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
128
+ export declare function flattenPrimitiveEntity(entity: IPrimitiveEntity | IPrimitiveEntityTransfer | IPrimitiveEntityShallowTransfer, seenEntities?: Set<EntityId>, options?: {
129
129
  ignoreBuiltInBaseEntities?: boolean;
130
- }): (Element | ElementTransfer)[];
131
- export declare function flattenProject(entity: IProject | IProjectTransfer, seenEntities?: Set<EntityId>, options?: {
130
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
131
+ export declare function flattenProject(entity: IProject | IProjectTransfer | IProjectShallowTransfer, seenEntities?: Set<EntityId>, options?: {
132
132
  ignoreBuiltInBaseEntities?: boolean;
133
- }): (Element | ElementTransfer)[];
134
- export declare function flattenProperty(entity: IProperty | IPropertyTransfer, seenEntities?: Set<EntityId>, options?: {
133
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
134
+ export declare function flattenProperty(entity: IProperty | IPropertyTransfer | IPropertyShallowTransfer, seenEntities?: Set<EntityId>, options?: {
135
135
  ignoreBuiltInBaseEntities?: boolean;
136
- }): (Element | ElementTransfer)[];
137
- export declare function flattenReturnDeclaration(entity: IReturnDeclaration | IReturnDeclarationTransfer, seenEntities?: Set<EntityId>, options?: {
136
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
137
+ export declare function flattenReturnDeclaration(entity: IReturnDeclaration | IReturnDeclarationTransfer | IReturnDeclarationShallowTransfer, seenEntities?: Set<EntityId>, options?: {
138
138
  ignoreBuiltInBaseEntities?: boolean;
139
- }): (Element | ElementTransfer)[];
140
- export declare function flattenReturnStatement(entity: IReturnStatement | IReturnStatementTransfer, seenEntities?: Set<EntityId>, options?: {
139
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
140
+ export declare function flattenReturnStatement(entity: IReturnStatement | IReturnStatementTransfer | IReturnStatementShallowTransfer, seenEntities?: Set<EntityId>, options?: {
141
141
  ignoreBuiltInBaseEntities?: boolean;
142
- }): (Element | ElementTransfer)[];
143
- export declare function flattenSearch(entity: ISearch | ISearchTransfer, seenEntities?: Set<EntityId>, options?: {
142
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
143
+ export declare function flattenSearch(entity: ISearch | ISearchTransfer | ISearchShallowTransfer, seenEntities?: Set<EntityId>, options?: {
144
144
  ignoreBuiltInBaseEntities?: boolean;
145
- }): (Element | ElementTransfer)[];
146
- export declare function flattenValueDescriptor(entity: IValueDescriptor | IValueDescriptorTransfer, seenEntities?: Set<EntityId>, options?: {
145
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
146
+ export declare function flattenValueDescriptor(entity: IValueDescriptor | IValueDescriptorTransfer | IValueDescriptorShallowTransfer, seenEntities?: Set<EntityId>, options?: {
147
147
  ignoreBuiltInBaseEntities?: boolean;
148
- }): (Element | ElementTransfer)[];
149
- export declare function flattenVariableDeclaration(entity: IVariableDeclaration | IVariableDeclarationTransfer, seenEntities?: Set<EntityId>, options?: {
148
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
149
+ export declare function flattenVariableDeclaration(entity: IVariableDeclaration | IVariableDeclarationTransfer | IVariableDeclarationShallowTransfer, seenEntities?: Set<EntityId>, options?: {
150
150
  ignoreBuiltInBaseEntities?: boolean;
151
- }): (Element | ElementTransfer)[];
152
- export declare function flattenVariableInstance(entity: IVariableInstance | IVariableInstanceTransfer, seenEntities?: Set<EntityId>, options?: {
151
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
152
+ export declare function flattenVariableInstance(entity: IVariableInstance | IVariableInstanceTransfer | IVariableInstanceShallowTransfer, seenEntities?: Set<EntityId>, options?: {
153
153
  ignoreBuiltInBaseEntities?: boolean;
154
- }): (Element | ElementTransfer)[];
154
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
155
155
  export declare function getAllBuiltInEntityIds(): EntityId[];
156
- export declare function flattenEntity(entity: Element | ElementTransfer | Reference, seenEntities?: Set<EntityId>, options?: {
156
+ export declare function flattenEntity(entity: Element | ElementTransfer | ElementShallowTransfer | Reference, seenEntities?: Set<EntityId>, options?: {
157
157
  ignoreBuiltInBaseEntities?: boolean;
158
- }): (Element | ElementTransfer)[];
159
- export declare function getUpstreamDependencyIds(element: ElementTransfer, allKnownEntities: Record<EntityId, ElementTransfer>): Set<EntityId>;
158
+ }): (Element | ElementTransfer | ElementShallowTransfer)[];
159
+ export declare function getUpstreamDependencyIds(element: Element | ElementTransfer | ElementShallowTransfer, allKnownEntities: Record<EntityId, Element | ElementTransfer | ElementShallowTransfer>): Set<EntityId>;
160
160
  export declare function getEntityArgumentDeclarations(entity: ExecutableEntityState): (ArgumentDeclarationState | ValueDescriptorState)[];
161
161
  export declare function getUsedArgFromDeclaration(argumentDeclaration: ArgumentDeclarationState, entity: ConditionState | FunctionCallState | OperationState): InputMapState | null;
162
162
  export declare function getEntityInputMaps(entity: DraggablePassThroughCallableEntityState): InputMapState[];
@@ -164,7 +164,7 @@ export declare function getEntityReturnDeclarations(entity: TerminationState | F
164
164
  export declare function getUsedReturnFromDeclaration(returnDeclaration: ReturnDeclarationState, entity: ConditionState | FunctionCallState | OperationState): OutputMapState | null;
165
165
  export declare function getEntityOutputMaps(entity: DraggablePassThroughCallableEntityState): OutputMapState[];
166
166
  export declare function getCanvasEntityDerivedFromValueReadingEntity(valueReadingEntity: ValueReadingEntityState): CanvasEntityState | null;
167
- export declare function getCanvasEntityDerivedFromValueReadingEntityFromTransfer(valueReadingEntity: ValueReadingEntity | ValueReadingEntityTransfer, allKnownEntities: Record<EntityId, ElementTransfer>): DraggableElement | DraggableElementTransfer | null;
167
+ export declare function getCanvasEntityDerivedFromValueReadingEntityFromTransfer(valueReadingEntity: ValueReadingEntity | ValueReadingEntityTransfer, allKnownEntities: Record<EntityId, ElementTransfer | ElementShallowTransfer>): DraggableElement | DraggableElementTransfer | DraggableElementShallowTransfer | null;
168
168
  export declare function getCanvasEntitiesDerivedFromInternalCalls(entity: VariableState): CanvasEntityState[];
169
169
  export declare function getCanvasEntitiesDerivedFromWrites(valueWrittingEntity: ValueWritingEntityState): CanvasEntityState[];
170
170
  export declare function filterOutDuplicateEntities(entities: (EntityState | Element | ElementTransfer | ElementShallowTransfer | ElementGenerationTarget)[]): (Element | ElementTransfer | ElementShallowTransfer | ElementGenerationTarget | EntityState)[];
@@ -1,20 +1,20 @@
1
- import { ElementTransfer, Element, EntityId } from '../../definitions';
1
+ import { ElementTransfer, Element, EntityId, ElementShallowTransfer } from '../../definitions';
2
2
  import { EntityState } from '../state';
3
3
 
4
4
  export declare function isPromise(obj: any): obj is Promise<any>;
5
5
  export declare class Traverser {
6
6
  order: EntityId[];
7
- flatRecord: Record<EntityId, Element | ElementTransfer | EntityState>;
7
+ flatRecord: Record<EntityId, Element | ElementTransfer | EntityState | ElementShallowTransfer>;
8
8
  private onGoingVisits;
9
- constructor(root: Element | ElementTransfer | EntityState);
10
- private flatten;
9
+ constructor(root: Element | ElementTransfer | EntityState | ElementShallowTransfer);
10
+ flatten(entity: Element | ElementTransfer | EntityState | ElementShallowTransfer): void;
11
11
  private moveEntityAfterDependencies;
12
- private orderEntities;
12
+ orderEntities(): void;
13
13
  getUpstreamOngoingDependenciesVisits(entityId: EntityId, taskId: string): Record<EntityId, Promise<any>>;
14
14
  getDownstreamOngoingDependenciesVisits(entityId: EntityId, taskId: string): Record<EntityId, Promise<any>>;
15
15
  settlePromises(promises: Record<EntityId, Promise<any>>, taskId: string): Promise<void>;
16
- visit(callback: (entity: Element | ElementTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState>) => any): Traverser;
17
- reverseVisit(callback: (entity: Element | ElementTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState>) => any): Traverser;
18
- visitAsync(callback: (entity: Element | ElementTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState>) => Promise<any>): Promise<Traverser>;
19
- reverseVisitAsync(callback: (entity: Element | ElementTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState>) => Promise<any>): Promise<Traverser>;
16
+ visit(callback: (entity: Element | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState | ElementShallowTransfer>) => any): Traverser;
17
+ reverseVisit(callback: (entity: Element | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState | ElementShallowTransfer>) => any): Traverser;
18
+ visitAsync(callback: (entity: Element | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState | ElementShallowTransfer>) => Promise<any>): Promise<Traverser>;
19
+ reverseVisitAsync(callback: (entity: Element | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element | ElementTransfer | EntityState | ElementShallowTransfer>) => Promise<any>): Promise<Traverser>;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6143",
3
+ "version": "0.0.6144",
4
4
  "author": "Sergio Herrero",
5
5
  "license": "UNLICENSED",
6
6
  "description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",