@elyx-code/project-logic-tree 0.0.6387 → 0.0.6388
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.d.ts +4 -4
- package/dist/index.js +8 -89
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -191,7 +191,7 @@ You can't modify system entities that are built-in.`,issue:null})),y&&y.type===f
|
|
|
191
191
|
An action descriptor can only have one error value descriptor child.
|
|
192
192
|
Either remove the existing error value descriptor or update it with the 'update' action.
|
|
193
193
|
You can use the 'describe_entity' action to get more information about the existing error value descriptor like so:
|
|
194
|
-
${Mn({describe_entity:y.error.id})}`,issue:null}))),{errors:p,modifiedData:l}}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){var i,a,l;return(l=(a=(i=this.dataType)==null?void 0:i.entity)==null?void 0:a.unsubscribeDependents)==null||l.call(a,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var i,a,l;return(l=(a=(i=this.dataType)==null?void 0:i.entity)==null?void 0:a.subscribeDependents)==null||l.call(a,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Mt(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Mt(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.parent=y.parent,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=Z(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&(this.removeFromParent(a),this.parent=null),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=Z(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){var y,v,T,R,A,P,N,U;const a=[this],l=[],p=[],t=[];return this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument?((y=this.parent)==null?void 0:y.type)===f.Search||((v=this.parent)==null?void 0:v.type)===f.Loop?(this.parent.addInputDeclaration(this,i),t.push(this.parent)):((R=(T=this.parent)==null?void 0:T.addInput)==null||R.call(T,this,i),a.push(this.parent)):this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((A=this.parent)==null?void 0:A.type)===f.Search||((P=this.parent)==null?void 0:P.type)===f.Loop?(this.parent.addOutputDeclaration(this,i),t.push(this.parent)):((U=(N=this.parent)==null?void 0:N.addOutput)==null||U.call(N,this,i),a.push(this.parent)):this.parentRelationType===le.ReturnedError&&this.parent&&(this.parent.error=this,t.push(this.parent)),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}setParent(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}initChildren(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=ee(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=ee(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.index=i.index||(i.index!==0?p.index:0),this.required=i.required!==void 0?i.required:this.required,this.parentRelationType=i.parentRelationType!==void 0?i.parentRelationType:this.parentRelationType,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await Mt.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await Mt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await Mt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await Mt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await Mt.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await Mt.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){var y,v,T,R,A,P,N;const a=[],l=[],p=[],t=[];return this.parent&&(((y=this.parent)==null?void 0:y.type)===f.Search?this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((v=this.parent)==null||v.removeOutputDeclaration(this,i),t.push(this.parent)):this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument?((T=this.parent)==null||T.removeInputDeclaration(this,i),t.push(this.parent)):this.parentRelationType===le.ReturnedError&&(this.parent.error=null,t.push(this.parent)):((R=this.parent)==null?void 0:R.type)===f.Loop?this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((A=this.parent)==null||A.removeOutputDeclaration(this,i),t.push(this.parent)):this.parentRelationType===le.ReturnedError&&(this.parent.error=null,t.push(this.parent)):this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((P=this.parent)==null||P.removeOutput(this,i),t.push(this.parent)):(this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument)&&((N=this.parent)==null||N.removeInput(this,i),t.push(this.parent))),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:w(p),updated:w(a),removed:w(l),affected:w(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(Array.from(new Set([...xs(),...this.project.getAllBuiltInIds()])).includes(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(T=>{const{updated:R,removed:A,added:P}=T.entity.onDetachedDependencyRemoved(this,T.field,a);l.push(...R),p.push(...A),t.push(...P)}),this.defaultValue){const{updated:T,removed:R}=this.defaultValue.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}if(this.dataType){const{updated:T,removed:R}=this.dataType.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}if(!i){const T=this.removeFromParent(a);t.push(...T.added),l.push(...T.updated),p.push(...T.removed),y.push(...T.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:w(t),updated:w(l),removed:w(p),affected:w(y),self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){var y,v,T,R,A,P,N;const a=[],l=[],p=[],t=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(U=>{const{updated:K,removed:k,added:J}=U.entity.onDetachedDependencyRestored(this,U.field,i);l.push(...K),p.push(...k),a.push(...J)}),this.defaultValue){const{updated:U}=this.defaultValue.restore({},i);l.push(...U)}if(this.dataType){const{updated:U}=this.dataType.restore({},i);l.push(...U)}return((y=this.parent)==null?void 0:y.type)===f.Search?this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?(v=this.parent)==null||v.addOutputDeclaration(this,i):(this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument)&&((T=this.parent)==null||T.addInputDeclaration(this,i)):((R=this.parent)==null?void 0:R.type)===f.Loop?(this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn)&&((A=this.parent)==null||A.addOutputDeclaration(this,i)):this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?(P=this.parent)==null||P.addOutput(this,i):(this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument)&&((N=this.parent)==null||N.addInput(this,i)),i==null||i.attemptAutoclose("restore-entity",this.id),{added:w(a),updated:w(l),removed:w(p),affected:w(t),self:this}}toFlat(i=new Set){var l;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.defaultValue)==null?void 0:l.toFlat(i))||[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){var l;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.defaultValue)==null?void 0:l.toFlatIds(i))||[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,index:this.index,required:this.required,parentRelationType:this.parentRelationType,type:this.type,name:this.name}}toJSON(i=new Set){var a,l,p;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,required:this.required,defaultValue:((a=this.defaultValue)==null?void 0:a.toJSON(i))||null,parentRelationType:this.parentRelationType,dataType:((l=this.dataType)==null?void 0:l.toJSON(i))||null,parent:((p=this.parent)==null?void 0:p.toReference())||null})}toJSONClone(i=xe){var l,p,t,y,v,T,R,A;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Nr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,required:this.required,defaultValue:((T=this.defaultValue)==null?void 0:T.toJSONClone({...i,newId:null}))||null,parentRelationType:this.parentRelationType,dataType:((R=this.dataType)==null?void 0:R.toJSONClone({...i,newId:null}))||null,parent:((A=this.parent)==null?void 0:A.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l,p,t,y;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,required:this.required,parentRelationType:this.parentRelationType,defaultValue:((p=this.defaultValue)==null?void 0:p.toReference(i))||null,dataType:((t=this.dataType)==null?void 0:t.toReference(i))||null,parent:((y=this.parent)==null?void 0:y.toReference(i))||null}}toFlatJSON(i=new Set){var l;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.defaultValue)==null?void 0:l.toFlatJSON(i))||[],...this.dataType?this.dataType.toFlatJSON(i):[]])}toGenerationTarget(){var i;return{id:this.id,name:this.name,codeName:this.codeName,description:this.description,type:this.type,required:this.required,parentRelationType:this.parentRelationType,parent:(i=this.parent)==null?void 0:i.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(i):[],...this.dataType?this.dataType.toFlatGenerationTarget(i):[]])}clearErrors(){var i,a;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),(a=this.dataType)==null||a.clearErrors(),this}validate(){const i=Ax(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.dataType?this.dataType.getErrors():[]]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var N,U;if(Array.from(new Set([...xs(),...this.project.getAllBuiltInIds()])).includes(this.id))return this;let y=Vr(a,this);const v=l||V.UUID.uuid(),T=this.toJSON();T.id=v,T.version=V.UUID.uuid(),T.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),T.author=(i==null?void 0:i.author)||"1",T.previousVersion=null,T.deleted=!1;const R=zt(T,y);a&&R.setParent(a,null),i==null||i.add(R,G.Added),p&&R.subscribe();const A=((N=this.dataType)==null?void 0:N.clone(i,R,V.UUID.uuid(),p))||null;A&&R.setDataType(A,i);const P=(U=this.defaultValue)==null?void 0:U.clone(i,R,V.UUID.uuid(),p);return R.defaultValue=P||null,i==null||i.attemptAutoclose("clone-entity",this.id),R}getDataType(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}setDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-data-type"))){const l=this.dataType;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.dataType=i,this.subscribeToDependencies(),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("set-data-type",this.id),this}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-default-value"))){const l=this.defaultValue;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.defaultValue=i,a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("set-default-value",this.id),this}removeDataType(){return this.dataType=null,this}implementAsReturnDeclaration(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-as-return-declaration")),a,l){const p=Ki.new(i);p.id=l||p.id,p.name=this.name,p.description=this.description,p.parent=a.toReference(),p.implements=this.toJSON(),p.isError=this.parentRelationType===le.ReturnedError;const t=zt(p,this.project);if(t.hydrateAncestors(),t.addSelfToProject(i),i==null||i.add(t,G.Added),t.initChildren(i),this.dataType){const y=this.dataType.clone(i,t);t.setDataType(y,i)}if(this.defaultValue){const y=this.defaultValue.clone(i,t);t.setDefaultValue(y,i)}return i==null||i.attemptAutoclose("implement-as-return-declaration",this.id),t}implementAsArgumentDeclaration(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-as-return-declaration")),a,l){const p=Ea.new(i);p.id=l||p.id,p.name=this.name,p.description=this.description,p.parent=a.toReference(),p.implements=this.toJSON();const t=zt(p,this.project);if(t.hydrateAncestors(),t.addSelfToProject(i),i==null||i.add(t,G.Added),t.initChildren(i),this.dataType){const y=this.dataType.clone(i,t);t.setDataType(y,i)}if(this.defaultValue){const y=this.defaultValue.clone(i,t);t.setDefaultValue(y,i)}return i==null||i.attemptAutoclose("implement-as-return-declaration",this.id),t}};O(Mt,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),O(Mt,"type",f.ValueDescriptor),O(Mt,"USER_MANAGED_PARENT_TYPES",[f.ActionDescriptor,f.Loop,f.Search]),O(Mt,"PARENT_TYPES",[...Mt.USER_MANAGED_PARENT_TYPES]),O(Mt,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","required"]),O(Mt,"INMUTABLE_BASE_PROPERTIES",["id","version","type","parentRelationType","createdAt","author","previousVersion"]),O(Mt,"BASE_PROPERTIES",[...Mt.MUTABLE_BASE_PROPERTIES,...Mt.INMUTABLE_BASE_PROPERTIES]),O(Mt,"MUTABLE_META_PROPERTIES",[...Mt.MUTABLE_BASE_PROPERTIES,"index"]),O(Mt,"INMUTABLE_META_PROPERTIES",[...Mt.INMUTABLE_BASE_PROPERTIES]),O(Mt,"META_PROPERTIES",[...Mt.MUTABLE_META_PROPERTIES,...Mt.INMUTABLE_META_PROPERTIES]),O(Mt,"MUTABLE_UPSTREAM_PROPERTIES",[]),O(Mt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),O(Mt,"UPSTREAM_PROPERTIES",[...Mt.MUTABLE_UPSTREAM_PROPERTIES,...Mt.INMUTABLE_UPSTREAM_PROPERTIES]),O(Mt,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),O(Mt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),O(Mt,"DOWNSTREAM_PROPERTIES",[...Mt.MUTABLE_DOWNSTREAM_PROPERTIES,...Mt.INMUTABLE_DOWNSTREAM_PROPERTIES]),O(Mt,"PROPERTIES",[...Mt.META_PROPERTIES,...Mt.UPSTREAM_PROPERTIES,...Mt.DOWNSTREAM_PROPERTIES]);let sn=Mt;var Te=(d=>(d.Inherited="inherited",d.DefaultValue="default-value",d.Missing="missing",d.Empty="empty",d.AutoCalculated="auto-calculated",d.QueuedAutocalculation="queued-autocalculation",d.External="external",d.Testing="testing",d.ExecutionResult="execution-result",d))(Te||{});const wx={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function lme(d,u){return{...wx,id:d,project:u}}class mp{constructor(u,i){O(this,"initialized",!1);O(this,"id");O(this,"project");O(this,"values",{});O(this,"onWriteCallback",()=>{});O(this,"onRemoveCallback",()=>{});this.id=u,this.project=i,this.init()}onWrite(u){this.onWriteCallback=u}onRemove(u){this.onRemoveCallback=u}init(){if(!this.project.id||this.initialized)return;const u={},i={};Object.keys(u).forEach(a=>{const l=u[a],p=new $i(l,this.project);try{if(l.parent){const v=this.project.findSubscribedInstanceFromReference(l.parent);if(!v)return;p.setParent(v,null),p.hydrateAncestors(),p.initChildren(null)}else if(l.standaloneParent){const v=this.project.findSubscribedInstanceFromReference(l.standaloneParent);if(!v)return;p.standalone=!0,p.setStandaloneParent(v),p.hydrateAncestors(),p.initChildren(null)}i[a]=p;const t=p.parent||p.standaloneParent,y=Rx(p,t,this.project);y?i[a]=y:delete u[a]}catch(t){Fe.error("Error hydrating ancestors: ",t),delete u[a]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const u={};return Object.keys(this.values).forEach(i=>{u[i]=this.values[i].toJSON()}),u}writeValue(u,i){if(!u)throw new Error("The value owner entity is required when writing a value to a value store");let l=this.values[u.id];if(!l)if(i instanceof $i)l=i;else if(i)l=zt(i,this.project);else{const p={id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:null,type:f.LiteralValue,standaloneParent:u.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:rl(u.getDataType(null))};l=zt(p,this.project)}l.standalone=!0,l.initialData.standaloneParent||Fe.warn("instance.initialData: ",l.initialData),l.setStandaloneParent(u),l.hydrateAncestors(),l.initChildren(null),i&&(l.metaSync({...i},null),l.setValueAsType(i.valueAsType,null)),this.values[u.id]=l,this.onWriteCallback(u,l)}readValue(u){return this.values[u]||null}removeValue(u){if(!this.values[u])return;delete this.values[u];const i=this.project.get(u);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function Ta(d){var u;return!!(d.required||(u=d.declaration)!=null&&u.required)}function my(d){return W4(d)||d===void 0||d===""}function qb(d){return d?d.valueAsType?!1:my(d.value):!0}function nn(d,u,i,a){var y;let l;if(((y=d==null?void 0:d.entity)==null?void 0:y.type)===f.PrimitiveEntity)switch(d.entity.name){case X.EntityTemplate:l=X.EntityTemplate;break;case X.String:l=X.String;break;case X.Number:l=X.Number;break;case X.Boolean:l=X.Boolean;break;case X.Null:l=X.Null;break;case X.Enum:l=X.Enum;break;case X.KeyValue:l=X.KeyValue;break;case X.Untyped:l=X.Untyped;break;case X.KeyValue:l=X.KeyValue;break;case X.Date:l=X.Date;break;case X.UUID:l=X.UUID;break;case X.File:l=X.File;break;default:throw new Error(`Primitive type ${ie(d.entity,i)} is not supported`)}else l=X.Untyped;const p=$i.new();p.name=l,p.parent=u.toReference();const t=ee(p,i);return t.hydrateAncestors(),a==null||a.add(t,G.Added),t.addSelfToProject(a),t.initChildren(a),t}function an(d,u,i=new Set){var a,l;if(i.has(d.id))return[];if(i.add(d.id),d.type===f.ReturnDeclaration){const p=[d,...d.getCounterparts()];return Fe.log("Resolved counterparts for return declaration: ",`${d.name} ${d.id}`),Fe.log("equivalentReturnDeclarations: ",p.map(t=>`${t.name} ${t.id}`)),w([...p,...p.flatMap(t=>an(t,u,i))])}else if(ot.includes(d.type)){const p=bi(d);return w([p,...[p].flatMap(t=>an(t,u,i))])}else if(d.type===f.OutputMap){if(ot.includes(d.parent.type)&&d.declaration.type===f.Property&&d.declaration.static)return w([d,d.declaration,...[d,d.declaration].flatMap(p=>an(p,u,i))])}else if(d.type===f.InputMap&&ot.includes(d.parent.type)&&((a=d.declaration)==null?void 0:a.type)===f.Property&&(l=d.declaration)!=null&&l.static)return w([d.declaration,...[d.declaration].flatMap(p=>an(p,u,i))]);return[d]}function Rx(d,u,i){return d}function $d(d,u){const i=d.readsValue;let a=null;if((i==null?void 0:i.type)===f.VariableDeclaration){const p=Ep(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.VariableInstance){const p=Ey(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.OutputMap){const p=Hb(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.ArgumentDeclaration){const p=Jb(i,u);if(p){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}return a}function et(d,u,i){var y;if(!u)return null;let a;if(((y=d==null?void 0:d.entity)==null?void 0:y.type)===f.PrimitiveEntity)switch(d.entity.name){case X.EntityTemplate:a=X.EntityTemplate;break;case X.String:a=X.String;break;case X.Number:a=X.Number;break;case X.Boolean:a=X.Boolean;break;case X.Null:a=X.Null;break;case X.Enum:a=X.Enum;break;case X.KeyValue:a=X.KeyValue;break;case X.Untyped:a=X.Untyped;break;case X.KeyValue:a=X.KeyValue;break;case X.Date:a=X.Date;break;case X.UUID:a=X.UUID;break;case X.File:a=X.File;break;default:throw new Error(`Primitive type ${ie(d.entity,i)} is not supported`)}else a=X.Untyped;if(!i.get(u.id))return null;const p=$i.new();p.name=a,p.standaloneParent=u.toReference();let t=new $i(p,i);return t.hydrateAncestors(),t.standalone=!0,t.setStandaloneParent(u),t.initChildren(null),t}function vy(d,u,i){var p;const a={...d},l=u.inputs;if(!l)return a;for(const t of l){if(!Mp(t))continue;const y=bp(t,i);if(y&&y.value){const v=ie(t,i.project),T=$r(v);a[T]=((p=y==null?void 0:y.value)==null?void 0:p.value)||a[T]}}return a}function vp(d,u,i){var p;const a={...d},l=u.inputs;if(!l)return a;for(const t of l){if(!Mp(t))continue;const y=Tp(t,i);if(y&&y.value){const v=ie(t,i.project),T=$r(v);a[T]=(p=y==null?void 0:y.value)==null?void 0:p.value}}return a}function gx(d,u){var y,v,T,R,A,P,N;let i={};if(((v=(y=d.dataType)==null?void 0:y.entity)==null?void 0:v.type)===f.DefinitionEntity&&(i={...i,...d.dataType.entity.getActiveRawDefaultValue()}),u.execution&&u.execution.hasEntity(d)){const U=(T=u.lastExecutionResults)==null?void 0:T.readValue(d.id);if(U){if(lr(U.value)){const k={...i,...U.value},J={...vp(k,d,u)};U.metaSync({value:J},null)}return{value:U,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}}const a=!!((R=u.execution)!=null&&R.entities.length),l=(A=u.execution)==null?void 0:A.hasEntity(d),p=d.readsValue;let t=null;if(p){const U=(P=u.execution)==null?void 0:P.hasEntity(p);if((!a||a&&U&&l||a&&!U&&!l)&&(t=$d(d,u),t&&t.value&&lr(t.value.value))){const k={...i,...t.value.value},J={...vp(k,d,u)};t.value.metaSync({value:J},null)}}if(!t&&d.defaultValue){const U=d.defaultValue;if(U.value===null&&U.autogeneration){const K=ph(U);if(U.metaSync({value:K},null),lr(K)){const k={...vp(K,d,u)};U.metaSync({value:k},null)}}t={value:U,valueOwner:d,type:U.value===null?Te.Empty:Te.DefaultValue,inheritanceLink:null}}if(!t||t.type===Te.DefaultValue){const U=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(U){if(lr(U.value)){const K={...i,...U.value},k={...vp(K,d,u)};U.metaSync({value:k},null)}return{value:U,valueOwner:d,type:Te.Testing,inheritanceLink:null}}}return t||{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}}function _x(d,u){var l,p,t,y,v;let i={};if(((p=(l=d.dataType)==null?void 0:l.entity)==null?void 0:p.type)===f.DefinitionEntity&&(i={...i,...d.dataType.entity.getActiveRawDefaultValue()}),u.execution&&u.execution.hasEntity(d)){const T=(t=u.lastExecutionResults)==null?void 0:t.readValue(d.id);if(T){if(lr(T.value)){const A={...i,...T.value},P=vy(A,d,u);T==null||T.metaSync({value:P},null)}return{value:T,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}}const a=(y=u.localTestValues)==null?void 0:y.readValue(d.id);if(a){if(lr(a.value)){const R={...i,...a.value},A=vy(R,d,u);a.metaSync({value:A},null)}return{value:a,valueOwner:d,type:Te.Testing,inheritanceLink:null}}if((v=d.dataType)!=null&&v.entity&&d.dataType.entity.type===f.DefinitionEntity&&d.dataType.isObject()){const T=et(d.dataType,d,u.project);return T==null||T.metaSync({value:vy(i,d,u)},null),{value:T,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}}return null}function Ep(d,u){var y,v,T,R,A;if((y=d.dataType)!=null&&y.isObject())return gx(d,u);const i=or(d),a=!!((v=u.execution)!=null&&v.entities.length),l=(T=u.execution)==null?void 0:T.hasEntity(i),p=d.readsValue;let t=null;if(p){const P=(R=u.execution)==null?void 0:R.hasEntity(p);(!a||a&&P&&l||a&&!P&&!l)&&(t=$d(d,u))}if(!t&&d.defaultValue){const P=d.defaultValue;if(P.value===null&&P.autogeneration){const N=ph(P);P.metaSync({value:N},null)}t={value:P,valueOwner:d,type:P.value===null?Te.Empty:Te.DefaultValue,inheritanceLink:null}}if(!t||t.type===Te.DefaultValue){const P=(A=u.localTestValues)==null?void 0:A.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.Testing,inheritanceLink:null}}return t||{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}}function Zb(d,u){var a,l,p,t;if((a=d.dataType)!=null&&a.isObject())return _x(d,u);if(u.execution&&u.execution.hasEntity(d)){const y=(l=u.lastExecutionResults)==null?void 0:l.readValue(d.id);if(y)return{value:y,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(p=u.localTestValues)==null?void 0:p.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null};if((t=d.dataType)!=null&&t.entity&&d.dataType.entity.type===f.DefinitionEntity&&d.dataType.isObject()){const y=et(d.dataType,d,u.project),v=d.dataType.entity.getActiveRawDefaultValue();return y==null||y.metaSync({value:v},null),{value:y,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}}return null}function Ey(d,u){var T,R,A,P;const i=!!((T=u.execution)!=null&&T.entities.length),a=(R=u.execution)==null?void 0:R.hasEntity(d);let l=null;const p=d.readsValue;if(p){const N=(A=u.execution)==null?void 0:A.hasEntity(p);(!i||i&&N&&a||i&&!N&&!a)&&(l=$d(d,u))}const t=d.declaration;if(!l&&t){const N=Ep(t,u);N&&N.value&&(l=N)}if(!l||l.type===Te.DefaultValue){const N=(P=u.localTestValues)==null?void 0:P.readValue(d.id);if(N)return{value:N,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const y=Ta(d);return y&&a&&!l?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:a&&!y&&!l?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:l||{value:null,valueOwner:d,type:Te.External,inheritanceLink:null}}function Dx(d,u){return Zb(d.declaration,u)}function Jb(d,u){var v,T,R,A;if(u.execution&&u.execution.hasEntity(d)){const P=(v=u.lastExecutionResults)==null?void 0:v.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=or(d),a=d.parent.type===f.FunctionDeclaration&&d.parent.parent.type===f.Loop?d.parent:null,l=!!((T=u.execution)!=null&&T.hasEntity(i))||!!a&&!!((R=u.execution)!=null&&R.hasEntity(a));let p=null;if(d.defaultValue){const P=d.defaultValue;if(P.value===null&&P.autogeneration){const N=ph(P);P.metaSync({value:N},null)}p={value:P,valueOwner:d,type:P.value===null?Te.Empty:Te.DefaultValue,inheritanceLink:null}}if(!p||p.type===Te.DefaultValue){const P=(A=u.localTestValues)==null?void 0:A.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const t=Ta(d);let y=t&&l&&!p;return i.type===f.Loop&&l&&(y=!1),y?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:l&&!t&&!p?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:p||{value:null,valueOwner:d,type:Te.External,inheritanceLink:null}}function Wb(d,u){var T,R,A,P,N;if(u.execution&&u.execution.hasEntity(d)){const U=(T=u.lastExecutionResults)==null?void 0:T.readValue(d.id);if(U)return{value:U,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=or(d),a=!!((R=u.execution)!=null&&R.entities.length),l=(A=u.execution)==null?void 0:A.hasEntity(i),p=d.readsValue;let t=null;if(p){const U=(P=u.execution)==null?void 0:P.hasEntity(p);(!a||a&&U&&l||a&&!U&&!l)&&(t=$d(d,u))}if(!t&&d.defaultValue&&(t={value:d.defaultValue,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}),!t||t.type===Te.DefaultValue){const U=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(U)return{value:U,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const y=Ta(d);return y&&!t?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:!y&&!t?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:t}function Hb(d,u){var y,v,T,R,A;if(u.execution&&u.execution.hasEntity(d)){const P=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=or(d);if(ot.includes(i.type)){const P=il(i,u),N=$r(ie(d,u.project));if(P!=null&&P.value&&lr(P.value.value)){const U=P.value.value[N],K=et(d.getDataType(null),d,u.project);return K==null||K.metaSync({value:U},null),{value:K,valueOwner:d,type:P.type,inheritanceLink:{sources:[P],target:d}}}return null}const a=(v=u.execution)==null?void 0:v.hasEntity(i),l=((T=u.execution)==null?void 0:T.state)===Xb.Running;if((R=u.persistedExecutionResults)!=null&&R.values[d.id]&&!a&&!l){const P=(A=u.persistedExecutionResults)==null?void 0:A.readValue(d.id);if((P==null?void 0:P.value)!==null||(P==null?void 0:P.valueAsType)!==null)return{value:P,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const p=d.getDefaultValue();if(p&&(p.value!==null||p.valueAsType!==null))return{value:p,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null};const t=d.parent;if(!t)throw new Error(`Couldn't find the parent that generates the output ${d.id}`);switch(t.type){case f.VariableInstance:{const N=Ey(t,u);if(N&&N.value){const K=d.declaration;if(lr(N.value.value)){const k=N.value.value[K.name],J=et(d.declaration.dataType,d,u.project);return J==null||J.metaSync({value:k},null),{value:J,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:[N],target:d}}}}const U=et(d.declaration.dataType,d,u.project);return U==null||U.metaSync({value:null},null),{value:U,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:N?[N]:[],target:d}}}case f.VariableDeclaration:{const N=Ep(t,u);if(N&&N.value){const K=d.declaration;if(lr(N.value.value)){const k=N.value.value[K.name],J=et(d.declaration.dataType,d,u.project);return J==null||J.metaSync({value:k},null),{value:J,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:[N],target:d}}}}const U=et(d.declaration.dataType,d,u.project);return U==null||U.metaSync({value:null},null),{value:U,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:N?[N]:[],target:d}}}case f.Operation:{const P=t.outputs.map(U=>{var k,J;if((k=u.persistedExecutionResults)!=null&&k.values[U.id]){const se=(J=u.persistedExecutionResults)==null?void 0:J.values[U.id];if(se.value!==null||se.valueAsType!==null)return{value:se,valueOwner:U,type:Te.ExecutionResult,inheritanceLink:null}}const K=U.getDefaultValue();if(K&&(K.value!==null||K.valueAsType!==null))return{value:K,valueOwner:U,type:Te.DefaultValue,inheritanceLink:null}}).filter(U=>!!U),N=et(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:P.length?{sources:P,target:d}:null}}case f.FunctionCall:{const P=t.inputs.map(U=>Ty(U,u)).filter(U=>!!U),N=et(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:P.length?{sources:P,target:d}:null}}case f.Loop:{const P=t.inputs.map(U=>Ty(U,u)).filter(U=>!!U),N=et(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:P.length?{sources:P,target:d}:null}}case f.Search:return{value:null,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:null}}return null}function Ox(d,u){var R,A;if(!ot.includes(d.parent.type)||!Mp(d))return null;if(((R=d.declaration)==null?void 0:R.type)===f.Property&&d.declaration.static)return il(d.declaration,u);const i=Tp(d,u);if(i&&i.type!==Te.Empty&&i.type!==Te.Missing)return i;const a=bi(d.parent),l=by(a,u),p=$r(ie(d,u.project)),t=et(d.getDataType(null),d,u.project),y=Ta(d),v=(A=l==null?void 0:l.value)==null?void 0:A.value;if(v&&lr(v)){let P=v[p];return v[p]===void 0&&(P=null),t==null||t.metaSync({value:P},null),y&&my(P)?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:{value:t,valueOwner:d,type:l.type,inheritanceLink:{sources:l?[l]:[],target:d}}}return y?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}}function Cx(d,u){var R,A,P,N,U;if(!ot.includes(d.parent.type)||!Mp(d))return null;if(((R=d.declaration)==null?void 0:R.type)===f.Property&&d.declaration.static)return il(d.declaration,u);const i=bi(d.parent),a=il(i,u),l=d.parent===i?d:i.inputs.find(K=>{var k,J;return((k=K.declaration)==null?void 0:k.id)===((J=d.declaration)==null?void 0:J.id)}),p=bp(l,u),t=$r(ie(d,u.project)),y=et(d.getDataType(null),d,u.project),v=Ta(d),T=(A=a==null?void 0:a.value)==null?void 0:A.value;if(((a==null?void 0:a.type)===Te.ExecutionResult||(a==null?void 0:a.type)===Te.Testing)&&T&&lr(T)){let K=T[t];return T[t]===void 0&&(K=null),y==null||y.metaSync({value:K},null),{value:y,valueOwner:d,type:a.type,inheritanceLink:{sources:a?[a]:[],target:d}}}if(p&&p.type!==Te.Empty&&p.type!==Te.Missing)return p;if(T&&lr(T)){let K=T[t];T[t]===void 0&&(K=null),y==null||y.metaSync({value:K},null);const k=v&&my(K),J=!!((P=u.execution)!=null&&P.entities.length),se=(N=u.execution)==null?void 0:N.hasEntity(i),te=i.readsValue;if(te){const ce=(U=u.execution)==null?void 0:U.hasEntity(te);if(k&&(!J||J&&ce&&se||J&&!ce&&!se))return{value:null,valueOwner:d,type:Te.Inherited,inheritanceLink:null}}return k?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:{value:y,valueOwner:d,type:a.type,inheritanceLink:{sources:a?[a]:[],target:d}}}return bp(d,u)}function Tp(d,u){var T,R,A,P,N;const i=or(d),a=!!((T=u.execution)!=null&&T.entities.length),l=(R=u.execution)==null?void 0:R.hasEntity(i),p=d.readsValue;let t=null;if(p){const U=(A=u.execution)==null?void 0:A.hasEntity(p);(!a||a&&U&&l||a&&!U&&!l)&&(t=$d(d,u))}if(!t&&d.defaultValue){const U=d.defaultValue;U&&(t={value:U,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null})}if(!t&&d.declaration){const U=il(d.declaration,u);U&&U.value&&(t={...U,valueOwner:d,type:Te.DefaultValue})}if(!t||t.type===Te.DefaultValue||(t==null?void 0:t.type)===Te.Empty){const U=(P=u.persistedExecutionResults)==null?void 0:P.readValue(d.id);if(U)return{value:U,valueOwner:d,type:Te.Testing,inheritanceLink:null};const K=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(K)return{value:K,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const y=Ta(d);return y&&!t||(t==null?void 0:t.type)===Te.Empty?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:(t==null?void 0:t.inheritanceLink)||null}:!y&&(!t||t.type===Te.Inherited)&&!(t!=null&&t.inheritanceLink)?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:t}function bp(d,u){var l,p;if(u.execution&&u.execution.hasEntity(d)){const t=(l=u.lastExecutionResults)==null?void 0:l.readValue(d.id);if(t)return{value:t,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(p=u.localTestValues)==null?void 0:p.readValue(d.id);return i?{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null}:Tp(d,u)}function Ty(d,u){var i;return ot.includes(d.parent.type)&&(i=bi(d.parent).dataType)!=null&&i.isObject()?Ox(d,u):Tp(d,u)}function $x(d,u){var i;return ot.includes(d.parent.type)&&(i=bi(d.parent).dataType)!=null&&i.isObject()?Cx(d,u):bp(d,u)}function Px(d,u){var y,v;if(!d.static)return null;if(u.execution){const T=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(T)return{value:T,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(v=u.localTestValues)==null?void 0:v.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null};const a=d.getDefaultValue();let l=null;return a&&(l={value:a,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}),Ta(d)&&qb(l==null?void 0:l.value)?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:qb(l==null?void 0:l.value)?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:l}function Vx(d,u){var y,v,T,R,A,P;if(u.execution&&u.execution.hasEntity(d)){const N=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(N)return{value:N,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(v=u.localTestValues)==null?void 0:v.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null};const a=d.getDefaultValue();let l=null;return a&&(l={value:a,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}),Ta(d)&&!((T=l==null?void 0:l.value)!=null&&T.value)&&!((R=l==null?void 0:l.value)!=null&&R.valueAsType)?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:!((A=l==null?void 0:l.value)!=null&&A.value)&&!((P=l==null?void 0:l.value)!=null&&P.valueAsType)?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:l}function il(d,u){switch(d.type){case f.ArgumentDeclaration:return Jb(d,u);case f.InputMap:return $x(d,u);case f.VariableDeclaration:return Zb(d,u);case f.VariableInstance:return Dx(d,u);case f.OutputMap:return Hb(d,u);case f.ReturnDeclaration:return Wb(d,u);case f.Property:return Px(d,u);case f.ValueDescriptor:return Vx(d,u);default:return null}}function by(d,u){switch(d.type){case f.InputMap:return Ty(d,u);case f.VariableDeclaration:return Ep(d,u);case f.VariableInstance:return Ey(d,u);case f.ReturnDeclaration:return Wb(d,u);default:return null}}function dme(d){var u;if(d&&d.type===Te.DefaultValue&&d.value&&d.valueOwner&&((u=d.valueOwner.defaultValue)==null?void 0:u.id)===d.value.id){const i=et(d.valueOwner.getDataType(null),d.valueOwner,d.valueOwner.project);return{type:Te.DefaultValue,value:i,valueOwner:d.valueOwner,inheritanceLink:null}}return d}function sl(d,u,i,a){let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=d.parent;return u.getVariableDeclarations().forEach(T=>{var A,P,N,U;const R=T.getDataType(null);if(((A=R==null?void 0:R.entity)==null?void 0:A.id)===y.id){let K=l?T.defaultValue:t==null?void 0:t.readValue(T.id);K?!l&&K&&K.id===((P=T.defaultValue)==null?void 0:P.id)&&(K=et(T.getDataType(null),T,u)):l?K=nn(T.getDataType(null),T,u,p):K=et(T.getDataType(null),T,u);const k=ie(d,u),J=$r(k);let se={};((U=(N=T.dataType)==null?void 0:N.entity)==null?void 0:U.type)===f.DefinitionEntity&&(se={...se,...T.dataType.entity.getActiveRawDefaultValue()}),lr(K==null?void 0:K.value)&&(se={...se,...K.value}),se[J]=i,K==null||K.metaSync({value:se},p),l||t==null||t.writeValue(T,K);return}}),p}function Ap(d,u,i,a){var N,U,K;let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=bi(d.parent),v=y.getDataType(null);if(!(v!=null&&v.isObject()))return p;let T=l?y.defaultValue:t==null?void 0:t.readValue(y.id);T?!l&&T&&T.id===((N=y.defaultValue)==null?void 0:N.id)&&(T=et(y.getDataType(null),y,u)):l?T=nn(y.getDataType(null),y,u,p):T=et(y.getDataType(null),y,u);const R=ie(d,u),A=$r(R);let P={};if(((K=(U=y.dataType)==null?void 0:U.entity)==null?void 0:K.type)===f.DefinitionEntity&&(P={...P,...y.dataType.entity.getActiveRawDefaultValue()}),lr(T==null?void 0:T.value)&&(P={...P,...T.value}),P[A]=i,T==null||T.metaSync({value:P},p),l||t==null||t.writeValue(y,T),(i===""||i===null||i===void 0)&&d.type===f.OutputMap){const k=y.inputs.find(J=>{var se;return((se=J.declaration)==null?void 0:se.id)===d.declaration.id||ie(J,u)===R});if(k){let J=l?k.defaultValue:t==null?void 0:t.readValue(k.id);J&&J.metaSync({value:null},p),l||t==null||t.removeValue(k.id)}}return p}function Nx(d,u,i){var t,y,v,T;let a=!1,l=null,p=null;if(i instanceof F?(a=!0,l=i,p=null):(l=null,p=i),ot.includes(d.type)){const R=bi(d);(t=R.dataType)!=null&&t.isObject()&&R.inputs.forEach(A=>{var P,N,U,K;if(((P=A.declaration)==null?void 0:P.type)===f.Property&&A.declaration.static){let k=a?d.defaultValue:p==null?void 0:p.readValue(A.declaration.id);k?!a&&k&&k.id===((N=A.declaration.defaultValue)==null?void 0:N.id)&&(k=et(A.declaration.getDataType(null),A.declaration,u)):a?k=nn(A.declaration.getDataType(null),A.declaration,u,l):k=et(A.declaration.getDataType(null),A.declaration,u),k==null||k.metaSync({value:null},l),a||p==null||p.removeValue((U=A.declaration)==null?void 0:U.id)}else if(((K=A.declaration)==null?void 0:K.type)===f.Property){let k=a?d.defaultValue:p==null?void 0:p.readValue(A.id);k&&k.metaSync({value:null},l),a||p==null||p.removeValue(A.id)}})}else d.type===f.InputMap?((y=d.declaration)==null?void 0:y.type)===f.Property&&d.declaration.static?sl(d.declaration,u,null,i):ot.includes(d.parent.type)&&((v=d.declaration)==null?void 0:v.type)===f.Property&&Ap(d,u,null,i):d.type===f.OutputMap?((T=d.declaration)==null?void 0:T.type)===f.Property&&d.declaration.static?sl(d.declaration,u,null,i):ot.includes(d.parent.type)&&d.declaration.type===f.Property&&Ap(d,u,null,i):d.type===f.Property&&d.static&&sl(d,u,null,i);return l}function Lx(d,u,i,a){var y,v,T,R,A,P;let l=!1,p=null,t=null;if(a instanceof F?(l=!0,p=a,t=null):(p=null,t=a),ot.includes(u.type)){const N=bi(u);if((y=N.dataType)!=null&&y.isObject()){let U={};((T=(v=N.dataType)==null?void 0:v.entity)==null?void 0:T.type)===f.DefinitionEntity&&(U={...U,...N.dataType.entity.getActiveRawDefaultValue()});const K=lr(d)?d:U;N.inputs.forEach(k=>{var J,se,te;if(((J=k.declaration)==null?void 0:J.type)===f.Property&&k.declaration.static){let ce=l?u.defaultValue:t==null?void 0:t.readValue(k.declaration.id);ce?!l&&ce&&ce.id===((se=k.declaration.defaultValue)==null?void 0:se.id)&&(ce=et(k.declaration.getDataType(null),k.declaration,i)):l?ce=nn(k.declaration.getDataType(null),k.declaration,i,p):ce=et(k.declaration.getDataType(null),k.declaration,i);const re=ie(k,i),fe=$r(re),z=K[fe];ce==null||ce.metaSync({value:z},p),l||t==null||t.writeValue(k.declaration,ce)}else if(((te=k.declaration)==null?void 0:te.type)===f.Property){let ce=l?u.defaultValue:t==null?void 0:t.readValue(k.id);ce&&ce.metaSync({value:null},p),l||t==null||t.removeValue(k.id)}})}}else u.type===f.InputMap?((R=u.declaration)==null?void 0:R.type)===f.Property&&u.declaration.static?sl(u.declaration,i,d,a):ot.includes(u.parent.type)&&((A=u.declaration)==null?void 0:A.type)===f.Property&&Ap(u,i,d,a):u.type===f.OutputMap?((P=u.declaration)==null?void 0:P.type)===f.Property&&u.declaration.static?sl(u.declaration,i,null,a):ot.includes(u.parent.type)&&u.declaration.type===f.Property&&Ap(u,i,null,a):u.type===f.Property&&u.static&&sl(u,i,d,a);return p}function Bx(d,u,i){const a=an(d,u);let l=!1,p=null,t=null;return i instanceof F?(l=!0,p=i,t=null):(p=null,t=i),a.forEach(y=>{var T;let v=l?y.defaultValue:t==null?void 0:t.readValue(y.id);v?!l&&v&&v.id===((T=y.defaultValue)==null?void 0:T.id)&&(v=et(d.getDataType(null),d,d.project)):l?v=nn(y.getDataType(null),y,u,p):v=et(y.getDataType(null),y,u),v==null||v.metaSync({value:null},p),l||t==null||t.removeValue(y.id),Nx(y,u,i)}),p}function ume(d,u,i,a){if(d===""||d===null||d===void 0)return Bx(u,i,a);const l=an(u,i);let p=!1,t=null,y=null;return a instanceof F?(p=!0,t=a,y=null):(t=null,y=a),l.forEach(v=>{var R;let T=p?u.defaultValue:y==null?void 0:y.readValue(u.id);T?!p&&T&&T.id===((R=v.defaultValue)==null?void 0:R.id)&&(T=et(v.getDataType(null),v,i)):p?T=nn(v.getDataType(null),v,i,t):T=et(v.getDataType(null),v,i),T==null||T.metaSync({value:d},t),p||y==null||y.writeValue(v,T),Lx(d,v,i,a)}),t}function nl(d,u,i,a){let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=d.parent;return u.getVariableDeclarations().forEach(T=>{var A,P,N,U;const R=T.getDataType(null);if(((A=R==null?void 0:R.entity)==null?void 0:A.id)===y.id){let K=l?T.defaultValue:t==null?void 0:t.readValue(T.id);K?!l&&K&&K.id===((P=T.defaultValue)==null?void 0:P.id)&&(K=et(T.getDataType(null),T,u)):l?K=nn(T.getDataType(null),T,u,p):K=et(T.getDataType(null),T,u);const k=ie(d,u),J=$r(k);let se={};((U=(N=T.dataType)==null?void 0:N.entity)==null?void 0:U.type)===f.DefinitionEntity&&(se={...se,...T.dataType.entity.getActiveRawDefaultValue()}),lr(K==null?void 0:K.value)&&(se={...se,...K.value}),Array.isArray(i)?se[J]=(i==null?void 0:i.map(te=>te.toShallowJSON()))||null:se[J]=(i==null?void 0:i.toShallowJSON())||null,K==null||K.metaSync({value:se},p),l||t==null||t.writeValue(T,K);return}}),p}function Ip(d,u,i,a){var N,U,K;let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=bi(d.parent),v=y.getDataType(null);if(!(v!=null&&v.isObject()))return p;let T=l?y.defaultValue:t==null?void 0:t.readValue(y.id);T?!l&&T&&T.id===((N=y.defaultValue)==null?void 0:N.id)&&(T=et(y.getDataType(null),y,u)):l?T=nn(y.getDataType(null),y,u,p):T=et(y.getDataType(null),y,u);const R=ie(d,u),A=$r(R);let P={};if(((K=(U=y.dataType)==null?void 0:U.entity)==null?void 0:K.type)===f.DefinitionEntity&&(P={...P,...y.dataType.entity.getActiveRawDefaultValue()}),lr(T==null?void 0:T.value)&&(P={...P,...T.value}),Array.isArray(i)?P[A]=(i==null?void 0:i.map(k=>k.toShallowJSON()))||null:P[A]=(i==null?void 0:i.toShallowJSON())||null,T==null||T.metaSync({value:P},p),l||t==null||t.writeValue(y,T),i==null&&d.type===f.OutputMap){const k=y.inputs.find(J=>{var se;return((se=J.declaration)==null?void 0:se.id)===d.declaration.id||ie(J,u)===R});if(k){let J=l?k.defaultValue:t==null?void 0:t.readValue(k.id);J&&(Array.isArray(i)?J==null||J.setValueAsTypeList(i,p):J==null||J.setValueAsTypeSingle(i,p)),l||t==null||t.removeValue(k.id)}}return p}function Mx(d,u,i){var a,l,p;return d.type===f.InputMap?((a=d.declaration)==null?void 0:a.type)===f.Property&&d.declaration.static?nl(d.declaration,u,null,i):ot.includes(d.parent.type)&&((l=d.declaration)==null?void 0:l.type)===f.Property&&Ip(d,u,null,i):d.type===f.OutputMap?((p=d.declaration)==null?void 0:p.type)===f.Property&&d.declaration.static?nl(d.declaration,u,null,i):ot.includes(d.parent.type)&&d.declaration.type===f.Property&&Ip(d,u,null,i):d.type===f.Property&&d.static&&nl(d,u,null,i),i}function Ux(d,u,i,a){var l,p,t;return u.type===f.InputMap?((l=u.declaration)==null?void 0:l.type)===f.Property&&u.declaration.static?nl(u.declaration,i,d,a):ot.includes(u.parent.type)&&((p=u.declaration)==null?void 0:p.type)===f.Property&&Ip(u,i,d,a):u.type===f.OutputMap?((t=u.declaration)==null?void 0:t.type)===f.Property&&u.declaration.static?nl(u.declaration,i,null,a):ot.includes(u.parent.type)&&u.declaration.type===f.Property&&Ip(u,i,null,a):u.type===f.Property&&u.static&&nl(u,i,d,a),a}function jx(d,u,i){const a=an(d,u);let l=!1,p=null,t=null;return i instanceof F?(l=!0,p=i,t=null):(p=null,t=i),a.forEach(y=>{var T;let v=l?y.defaultValue:t==null?void 0:t.readValue(y.id);v?!l&&v&&v.id===((T=y.defaultValue)==null?void 0:T.id)&&(v=et(y.getDataType(null),y,y.project)):l?v=nn(y.getDataType(null),y,u,p):v=et(y.getDataType(null),y,u),v==null||v.setValueAsTypeSingle(null,p),v==null||v.setValueAsTypeList(null,p),l||t==null||t.removeValue(y.id),Mx(y,u,i)}),p}function cme(d,u,i,a){if(d==null)return jx(u,i,a);const l=an(u,i);let p=!1,t=null,y=null;return a instanceof F?(p=!0,t=a,y=null):(t=null,y=a),l.forEach(v=>{var R;let T=p?v.defaultValue:y==null?void 0:y.readValue(v.id);T?!p&&T&&T.id===((R=v.defaultValue)==null?void 0:R.id)&&(T=et(v.getDataType(null),v,v.project)):p?T=nn(v.getDataType(null),v,i,t):T=et(v.getDataType(null),v,i),Array.isArray(d)?T==null||T.setValueAsTypeList(d,t):T==null||T.setValueAsTypeSingle(d,t),p||y==null||y.writeValue(v,T),Ux(d,v,i,a)}),t}var pme=Object.defineProperty,fme=(d,u,i)=>u in d?pme(d,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[u]=i,al=(d,u,i)=>(fme(d,typeof u!="symbol"?u+"":u,i),i);let hme=class{constructor(u){al(this,"eventName"),al(this,"callbacks",[]),this.eventName=u,this.on=this.on.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}on(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks.includes(u)||this.callbacks.push(u)}off(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(i=>i!==u)}destroy(){this.callbacks=[]}},wp=class{constructor(){al(this,"subscribedEvents",{}),al(this,"on",this._on),al(this,"emit",this._emit),al(this,"off",this._off),al(this,"destroy",this._destroy),this.getEvent=this.getEvent.bind(this),this._on=this._on.bind(this),this._emit=this._emit.bind(this),this._off=this._off.bind(this),this._destroy=this._destroy.bind(this),this.on=this.on.bind(this),this.emit=this.emit.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}getEvent(u){return this.subscribedEvents[u]||(this.subscribedEvents[u]=new hme(u)),this.subscribedEvents[u]}_on(u,i){this.getEvent(u).on(i)}_emit(u,...i){const a=this.getEvent(u);a&&a.callbacks.forEach(l=>{l.apply(null,i)})}_off(u,i){const a=this.getEvent(u);a&&(i?a.off(i):(a.destroy(),delete this.subscribedEvents[u]))}_destroy(){Object.keys(this.subscribedEvents).forEach(u=>{this._off(u)}),this.subscribedEvents={}}};var Ay=(d=>(d[d.High=1]="High",d[d.Normal=5]="Normal",d[d.Low=10]="Low",d))(Ay||{}),xx=(d=>(d.Logic="logic",d.GUI="gui",d.Editor="editor",d.Compile="compile",d))(xx||{}),Fx=(d=>(d.OnCompileBefore="on:compile:before:DefinitionEntity",d.OnCompileDefault="on:compile:default:DefinitionEntity",d.OnCompileAfter="on:compile:after:DefinitionEntity",d.EmitCompile="emit:compile:DefinitionEntity",d.DoEditorPublish="do:editor:publish",d.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",d.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",d.UpdateGUIGlobalTheme="update:gui:global:theme",d))(Fx||{}),Yb=(d=>(d.UUID="uuid",d.BuiltInFunctionImplementations="built-in-function-implementations",d.SearchNodeImplementation="search-node-implementation",d))(Yb||{});function yme(d){switch(d){case"uuid":return $u;case"built-in-function-implementations":return{[Li.AbortExecution]:async(u,i)=>({value:Je.Error,entity:u,error:null,results:[]}),[Li.SavePersistedEntity]:async(u,i)=>({value:Je.Error,entity:u,error:null,results:[]}),[Li.DeletePersistedEntity]:async(u,i)=>({value:Je.Error,entity:u,error:null,results:[]})};case"search-node-implementation":return{searchImplementation:async(u,i)=>({data:null,error:"Search module not implemented"})}}return null}const zb={onRequestModule:d=>{const u=yme(d);if(u)return u;throw new Error(`Module '${d}' is not available. Please register it before using.`)}};class mme{constructor(u=new wp){O(this,"extensions",new Map);this.events=u}get extensionInOrder(){return Array.from(this.extensions.values()).sort((u,i)=>(u.manifest.initPriority||Ay.Normal)-(i.manifest.initPriority||Ay.Normal))}requestContext(u){return null}requestModule(u){const i=this.extensions.get(u);if(i){if(i.module)return i.module;throw new Error(`Module ${u} is not registered properly.`)}throw new Error(`Unknown module: ${u}`)}register(u,i){this.extensions.set(u.id,{manifest:u,module:i})}async initAll(){for(const u of this.extensionInOrder)if(u.module.init){const i=u.manifest.contexts.map(a=>this.requestContext(a)).filter(a=>a!==null);i.length&&await u.module.init(i)}}async destroyAll(){for(const u of[...this.extensionInOrder].reverse())u.module.destroy&&await u.module.destroy();this.events.destroy()}on(u,i){this.events.on(u,i)}emit(u,...i){this.events.emit(u,...i)}off(u,i){this.events.off(u,i)}}const Qa={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var Xb=(d=>(d.FinishedSuccess="finished-success",d.FinishedError="finished-error",d.Running="running",d.Paused="paused",d.Stopped="stopped",d.NotStarted="not-started",d))(Xb||{});const Gx={...zb};class Bn extends wp{constructor(i,a,l,p=null,t=Gx){super();O(this,"project");O(this,"entryPoint");O(this,"state","not-started");O(this,"events",new wp);O(this,"entities",[]);O(this,"parentExecution",null);O(this,"executing",[]);O(this,"executed",[]);O(this,"skipped",[]);O(this,"scheduled",[]);O(this,"localTestValues");O(this,"resolvedValues");O(this,"persistedExecutionResults");O(this,"lastExecutionResults");O(this,"onAddToSkippedListCallback",null);O(this,"onRemoveFromSkippedListCallback",null);O(this,"onAddEntityCallback",null);O(this,"onRemoveEntityCallback",null);this.parentContext=t,this.entities=a,this.entryPoint=l,this.project=i,this.parentExecution=p,this.localTestValues=new mp(V.UUID.uuid(),this.project),this.resolvedValues=new mp(V.UUID.uuid(),this.project),this.persistedExecutionResults=new mp(V.UUID.uuid(),this.project),this.lastExecutionResults=new mp(V.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults}}skip(i){this.hasEntity(i)&&(this.skipped.includes(i)||(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Ps.includes(i.type)&&[...i.successCalls||[],...i.errorCalls||[],...i.calls||[]].forEach(a=>this.skip(a))))}async schedule(i,a,l){if(this.hasExecuted(i))return null;if(tr.includes(i.type))return this.executeBranch(i,l,a);if($s.includes(i.type)){if(i.calledBy.every(t=>this.hasExecuted(t)||!this.hasEntity(t)))return this.executeBranch(i,l,a);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,a){const l=[];return[...nr,...tr].includes(a.type)?l.push(...a.inputs):pr.includes(a.type)&&l.push(...a.outputs),l.map(t=>{var v;let y=i.find(T=>T.valueOwner.id===t.id);if(y)return y;if(!y&&tr.includes(a.type)&&(y=i.find(T=>{var R;return((R=T.valueOwner.declaration)==null?void 0:R.id)===t.id})),y){const T=(v=y.value)==null?void 0:v.clone(null);return T==null||T.setStandaloneParent(t),{...y,valueOwner:t,value:T||null,inheritanceLink:{sources:[y],target:t}}}return Tn.includes(t.type)?by(t,this.valueResolutionContext):il(t,this.valueResolutionContext)}).reduce((t,y)=>{const v=an(y==null?void 0:y.valueOwner,this.project),T=y?[y]:[];return v.forEach(R=>{var N,U,K;if(R.id===(y==null?void 0:y.valueOwner.id))return;const A=et(R.getDataType(null),R,this.project);A==null||A.metaSync({value:(N=y==null?void 0:y.value)==null?void 0:N.value},null),A==null||A.setValueAsTypeList(((U=y==null?void 0:y.value)==null?void 0:U.valueAsTypeList)||null),A==null||A.setValueAsTypeSingle(((K=y==null?void 0:y.value)==null?void 0:K.valueAsTypeSingle)||null);const P={...y,valueOwner:R,value:A};T.push(P)}),[...t,...T]},[]).sort((t,y)=>t.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,a,l,p={}){var y,v;const t={...Qa,...p};try{let T={value:Je.Success,error:null,results:[]};if(a.sort((R,A)=>R.valueOwner.index-A.valueOwner.index),Object.values(Li).includes(i.declaration.id)){const R=this.parentContext.onRequestModule(Yb.BuiltInFunctionImplementations)[i.declaration.id];R?T=await R(i,a):Fe.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{T=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,a,l,t);const R=i.outputs.map(P=>{var J,se,te,ce;const N=[...P.declaration.getCounterparts(),P.declaration],U=T.results.find(re=>N.some(z=>re.valueOwner.id===z.id)),K=P==null?void 0:P.getDataType(null),k=et(K,P,l);return K!=null&&K.asType?Array.isArray((J=U==null?void 0:U.value)==null?void 0:J.valueAsType)?k==null||k.setValueAsTypeList((se=U==null?void 0:U.value)==null?void 0:se.valueAsTypeList):k==null||k.setValueAsTypeSingle(((te=U==null?void 0:U.value)==null?void 0:te.valueAsType)||null):k==null||k.metaSync({value:(ce=U==null?void 0:U.value)==null?void 0:ce.value},null),{valueOwner:P,type:Te.ExecutionResult,inheritanceLink:null,value:k}});let A=null;if(T.error){Fe.warn("Raw error executing entity: ",T.error);const P=(y=i.error)==null?void 0:y.getDataType(null),N=et(P||null,i.error,l);P!=null&&P.asType?N==null||N.setValueAsTypeSingle(T.error):N==null||N.metaSync({value:T.error},null),A={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:N}}return{value:T.value,entity:i,error:A,results:R}}return{...T,entity:i}}catch(T){Fe.warn("Operation execution error: ",T);let R=null;if(i.error){const A=(v=i.error)==null?void 0:v.getDataType(null),P=et(A,i.error,l);A!=null&&A.asType?P==null||P.setValueAsTypeSingle(T):P==null||P.metaSync({value:T},null),R={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:P}}return{value:Je.Error,entity:i,error:R,results:[]}}}static async executeOperation(i,a,l){var p,t;try{let y={value:Je.Success,error:null,results:[]};a.sort((R,A)=>R.valueOwner.index-A.valueOwner.index),i.declaration.implementation&&(y=await i.declaration.implementation(i,a));const v=i.outputs.map((R,A)=>{const P=R==null?void 0:R.getDataType(null),N=et(P,R,l);return P!=null&&P.asType?N==null||N.setValueAsTypeSingle(y.results[A]):N==null||N.metaSync({value:y.results[A]},null),{valueOwner:R,type:Te.ExecutionResult,inheritanceLink:null,value:N}});let T=null;if(y.error&&i.error){Fe.warn("Raw error executing entity: ",y.error);const R=((p=i.error)==null?void 0:p.getDataType(null))||null,A=et(R,i.error,l);R!=null&&R.asType?A==null||A.setValueAsTypeSingle(y.error):A==null||A.metaSync({value:y.error},null),T={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:A}}return{value:y.value,entity:i,error:T,results:v}}catch(y){Fe.warn("Operation execution error: ",y);let v=null;if(i.error){const T=(t=i.error)==null?void 0:t.getDataType(null),R=et(T,i.error,l);T!=null&&T.asType?R==null||R.setValueAsTypeSingle(y):R==null||R.metaSync({value:y},null),v={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:R}}return{value:Je.Error,entity:i,error:v,results:[]}}}async executeSearch(i,a,l){var p;try{let t={value:Je.Success,error:null,results:[]};const y=i.outputs[0];if(!y)return{value:Je.Success,entity:i,error:null,results:[]};let v={value:null,valueOwner:y,type:Te.ExecutionResult,inheritanceLink:null};const T=await this.parentContext.onRequestModule(Yb.SearchNodeImplementation).searchImplementation(i,a),R=y==null?void 0:y.getDataType(null),A=et(R,y,l);return A==null||A.metaSync({value:T.data},null),v.value=A,{value:t.value,entity:i,error:null,results:[v]}}catch(t){if(Fe.warn(`Search node execution error: ${t}`),!i.error)return{value:Je.Error,entity:i,error:null,results:[]};const y=(p=i.error)==null?void 0:p.getDataType(null),v=et(y,i.error,l);return v==null||v.metaSync({value:t},null),{value:Je.Error,entity:i,error:{valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:v},results:[]}}}async executeLoop(i,a,l,p={}){var y,v;const t={...Qa,...p};try{let T={value:Je.Success,error:null,results:[]};const R=a.map(k=>{var J,se;return((J=k==null?void 0:k.value)==null?void 0:J.valueAsType)||((se=k==null?void 0:k.value)==null?void 0:se.value)});let A={};i.getUniqueReturnDeclarations().forEach(k=>{const J=i.body.inputs.find(re=>ie(re,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(k)),se=k==null?void 0:k.getDataType(null),te=et(se,J,l);se!=null&&se.asType?te==null||te.setValueAsTypeList([]):te==null||te.metaSync({value:[]},null),this.lastExecutionResults.writeValue(J,te);const ce={value:te,valueOwner:J,type:Te.ExecutionResult,inheritanceLink:null};A[J.id]=ce});let N={value:Je.Success,entity:i.body,error:null,results:[]};switch(i.declaration.id){case ve.loop["counted-loop"].id:{const k=R[0];let J=1;for(;J<=k&&J<=50;){const se=i.body.inputs.map(ce=>{if(ce===i.currentIterationNumberArgumentDeclaration){const re=i.currentIterationNumberArgumentDeclaration.getDataType(null),fe=rl(re),z=this.lastExecutionResults.readValue(ce.id);if(z){z.metaSync({value:J},null),this.lastExecutionResults.writeValue(ce,z);const ae={value:z,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null};return A[ce.id]=ae,ae}const Y={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:J,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:fe,standaloneParent:ce.toReference()},ue=zt(Y,l);this.lastExecutionResults.writeValue(ce,ue);const H={value:ue,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null};return A[ce.id]=H,H}else return A[ce.id]}).filter(ce=>!!ce),te=await this.executeFullFunctionDeclarationLogic(i.body,se,t);if(N=te,N.results.forEach(ce=>{var Y,ue,H,ae;if(ce.valueOwner.type!==f.ReturnDeclaration)return;const re=i.body.inputs.find(be=>ie(be,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(ce.valueOwner)),z=[...((ue=(Y=A==null?void 0:A[re.id])==null?void 0:Y.value)==null?void 0:ue.value)||[],((H=ce==null?void 0:ce.value)==null?void 0:H.value)||null];(ae=A[re.id].value)==null||ae.metaSync({value:z},null),this.lastExecutionResults.writeValue(re,A[re.id].value)}),[Je.Error,Je.Break,Je.Return].includes(te.value))break;J++}break}case ve.loop["manual-flow-loop"].id:{let k=1;for(;k<=50;){const J=i.body.inputs.map(te=>{if(te===i.currentIterationNumberArgumentDeclaration){const ce=this.lastExecutionResults.readValue(te.id);if(ce){ce.metaSync({value:k},null),this.lastExecutionResults.writeValue(te,ce);const Y={value:ce,valueOwner:te,type:Te.ExecutionResult,inheritanceLink:null};return A[te.id]=Y,Y}const re=i.currentIterationNumberArgumentDeclaration.getDataType(null),fe=et(re,te,l);return fe==null||fe.metaSync({value:k},null),this.lastExecutionResults.writeValue(te,fe),{value:fe,valueOwner:te,type:Te.ExecutionResult,inheritanceLink:null}}else return A[te.id]}).filter(te=>!!te),se=await this.executeFullFunctionDeclarationLogic(i.body,J,t);if(N=se,N.results.forEach(te=>{var z,Y,ue;if(te.valueOwner.type!==f.ReturnDeclaration)return;const ce=i.body.inputs.find(H=>ie(H,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(te.valueOwner)),fe=[...(z=A[ce.id].value)==null?void 0:z.value,((Y=te.value)==null?void 0:Y.value)||null];(ue=A[ce.id].value)==null||ue.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ce,A[ce.id].value)}),[Je.Error,Je.Break,Je.Return].includes(se.value))break;k++}break}case ve.loop["list-loop"].id:{const k=R[0];let J=1;const se=k;for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}case ve.loop["object-keys-loop"].id:{const k=R[0];let J=1;const se=k?Object.keys(k):[];for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}case ve.loop["object-values-loop"].id:{const k=R[0];let J=1;const se=k?Object.values(k):[];for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}case ve.loop["string-loop"].id:{const k=R[0];let J=1;const se=k.split("");for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}}let U=[];i.body.inputs.forEach(k=>{var se;const J=A[k.id];if(J){const te=(se=J.value)==null?void 0:se.clone(null),ce=i.outputs.find(re=>re.declaration&&Oi.fromLoopOutputDeclarationToBodyArgumentDeclarationName(re.declaration)===ie(k,l));if(!ce)return;U.push({valueOwner:ce,type:Te.ExecutionResult,inheritanceLink:null,value:te})}}),T={value:[Je.Error,Je.Return].includes(N.value)?N.value:Je.Success,error:null,results:U};let K=null;if(T.error&&i.error){Fe.warn("Raw error executing entity: ",T.error);const k=(y=i.error)==null?void 0:y.getDataType(null),J=et(k||null,i.error,l);k!=null&&k.asType?J==null||J.setValueAsTypeSingle(T.error):J==null||J.metaSync({value:T.error},null),K={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:J}}return{value:T.value,entity:i,error:K,results:T.results}}catch(T){if(Fe.warn("Error executing loop: ",T),i.error){const R=(v=i.error)==null?void 0:v.getDataType(null),A=et(R,i.error,l);return R!=null&&R.asType?A==null||A.setValueAsTypeSingle(T):A==null||A.metaSync({value:T},null),{value:Je.Error,entity:i,error:{valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:A},results:[]}}else return{value:Je.Error,entity:i,error:null,results:[]}}}async executeFunctionCall(i,a,l,p={}){var y,v;const t={...Qa,...p};try{let T={value:Je.Success,error:null,results:[]};T=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,a,l,t);const R=i.outputs.map(P=>{var J,se,te,ce;const N=[...P.declaration.getCounterparts(),P.declaration],U=T.results.find(re=>N.some(z=>re.valueOwner.id===z.id)),K=P==null?void 0:P.getDataType(null),k=et(K,P,l);return K!=null&&K.asType?Array.isArray((J=U==null?void 0:U.value)==null?void 0:J.valueAsType)?k==null||k.setValueAsTypeList((se=U==null?void 0:U.value)==null?void 0:se.valueAsTypeList):k==null||k.setValueAsTypeSingle(((te=U==null?void 0:U.value)==null?void 0:te.valueAsType)||null):k==null||k.metaSync({value:(ce=U==null?void 0:U.value)==null?void 0:ce.value},null),{valueOwner:P,type:Te.ExecutionResult,inheritanceLink:null,value:k}});let A=null;if(T.error&&i.error){Fe.warn("Raw error executing entity: ",T.error);const P=(y=i.error)==null?void 0:y.getDataType(null),N=et(P||null,i.error,l);P!=null&&P.asType?N==null||N.setValueAsTypeSingle(T.error):N==null||N.metaSync({value:T.error},null),A={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:N}}return{value:T.value,entity:i,error:A,results:R}}catch(T){if(!i.error)return{value:Je.Error,entity:i,error:null,results:[]};const R=(v=i.error)==null?void 0:v.getDataType(null),A=et(R,i.error,l);return R!=null&&R.asType?A==null||A.setValueAsTypeSingle(T):A==null||A.metaSync({value:T},null),{value:Je.Error,entity:i,error:{valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:A},results:[]}}}static async executeCondition(i,a){var p,t,y,v,T,R,A,P,N,U,K,k,J,se,te,ce,re,fe,z,Y,ue,H,ae,be,Be,Oe,_e,De,Ke,Me,Qe,yt,Qt,fr,Pr,Zr;let l=!1;switch(i.declaration.id){case kr.Empty:{l=!((t=(p=a[0])==null?void 0:p.value)!=null&&t.value);break}case kr.NotEmpty:{l=!!((v=(y=a[0])==null?void 0:y.value)!=null&&v.value);break}case vr.Equal:{if([X.String,X.Number,X.Boolean,X.Null,X.Enum,X.Date,X.UUID].includes((R=(T=a[0])==null?void 0:T.value)==null?void 0:R.name)){l=((P=(A=a[0])==null?void 0:A.value)==null?void 0:P.value)===((U=(N=a[1])==null?void 0:N.value)==null?void 0:U.value);break}if(((k=(K=a[0])==null?void 0:K.value)==null?void 0:k.name)===X.KeyValue||((se=(J=a[0])==null?void 0:J.value)==null?void 0:se.name)===X.Untyped){const Xr=(ce=(te=a[0])==null?void 0:te.value)==null?void 0:ce.value,Si=(fe=(re=a[1])==null?void 0:re.value)==null?void 0:fe.value;l=JSON.stringify(Xr)===JSON.stringify(Si);break}break}case vr.NotEqual:{if([X.String,X.Number,X.Boolean,X.Null,X.Enum,X.Date,X.UUID].includes((Y=(z=a[0])==null?void 0:z.value)==null?void 0:Y.name)){l=((H=(ue=a[0])==null?void 0:ue.value)==null?void 0:H.value)!==((be=(ae=a[1])==null?void 0:ae.value)==null?void 0:be.value);break}if(((Oe=(Be=a[0])==null?void 0:Be.value)==null?void 0:Oe.name)===X.Untyped||((De=(_e=a[0])==null?void 0:_e.value)==null?void 0:De.name)===X.KeyValue){const Xr=(Me=(Ke=a[0])==null?void 0:Ke.value)==null?void 0:Me.value,Si=(yt=(Qe=a[1])==null?void 0:Qe.value)==null?void 0:yt.value;l=JSON.stringify(Xr)!==JSON.stringify(Si);break}break}case vr.MoreThanOrEqual:{l=((fr=(Qt=a[0])==null?void 0:Qt.value)==null?void 0:fr.value)>=((Zr=(Pr=a[1])==null?void 0:Pr.value)==null?void 0:Zr.value);break}}return{value:l?Je.Success:Je.Error,entity:i,error:null,results:[]}}async executeDetachedFullFunctionDeclarationLogic(i,a,l,p={}){const t={...Qa,...p,onBeforeEntityExecution:(T,R,A)=>{var P;return((P=p==null?void 0:p.onBeforeEntityExecution)==null?void 0:P.call(p,T,R,{...A,detached:!0}))||Promise.resolve()},onEntityExecuted:(T,R,A)=>{var P;return((P=p==null?void 0:p.onEntityExecuted)==null?void 0:P.call(p,T,R,{...A,detached:!0}))||Promise.resolve()}},y=new Bn(l,[i,...Sy(i)],i,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(t,a)}async executeFullFunctionDeclarationLogic(i,a,l={}){const p={...Qa,...l},t=Sy(i);t.forEach(A=>{this.addEntity(A)}),t.reduce((A,P)=>pr.includes(P.type)?[...A,...P.outputs]:nr.includes(P.type)&&P.type!==f.Condition?[...A,...P.outputs,...P.inputs]:P.type===f.Condition?[...A,...P.inputs]:A,[]).forEach(A=>{this.lastExecutionResults.removeValue(A.id)});const v=await this.executeBranch(i,p,a),R=i.getUniqueReturnDeclarations().reduce((A,P)=>{const N=v==null?void 0:v.results.find(U=>U.valueOwner.id===P.id);return N?[...A,N]:A},[]);return{...v||{},value:(v==null?void 0:v.value)||Je.Success,entity:i,error:(v==null?void 0:v.error)||null,results:R}}static async executeEntryPointEntity(i,a){return{value:Je.Success,entity:i,error:null,results:a}}static async executeVariable(i,a){return{value:Je.Success,entity:i,error:null,results:[a]}}static async executeReturnStatement(i,a){return{value:i.throws?Je.Error:Je.Return,entity:i,error:null,results:a}}static async executeContinueStatement(i,a){return{value:Je.Continue,entity:i,error:null,results:a}}static async executeBreakStatement(i,a){return{value:Je.Break,entity:i,error:null,results:a}}mergeValues(i,a){const l=[];for(let p=0;p<a.length;p++)i!=null&&i[p]?l.push(i[p]):l.push(a[p]);return l}async executeEntity(i,a=[],l={}){var y,v,T,R,A,P,N,U,K,k,J,se,te,ce,re,fe,z;const p={...Qa,...l},t={detached:!1};switch(i.type){case f.Condition:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((y=p.onBeforeEntityExecution)==null?void 0:y.call(p,i,Y,t)),Bn.executeCondition(i,Y)}case f.InternalCall:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((v=p.onBeforeEntityExecution)==null?void 0:v.call(p,i,Y,t)),this.executeInternalCall(i,Y,this.project)}case f.Operation:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((T=p.onBeforeEntityExecution)==null?void 0:T.call(p,i,Y,t)),Bn.executeOperation(i,Y,this.project)}case f.VariableInstance:case f.VariableDeclaration:{let Y=by(i,this.valueResolutionContext);const ue=bi(i),H=ue.getDataType(null);if(H!=null&&H.isObject()){let Be={};if(((R=H==null?void 0:H.entity)==null?void 0:R.type)===f.DefinitionEntity&&(Be={...Be,...H.entity.getActiveRawDefaultValue()}),Y!=null&&Y.value)lr((A=Y==null?void 0:Y.value)==null?void 0:A.value)&&(Be={...Be,...(P=Y==null?void 0:Y.value)==null?void 0:P.value}),Y==null||Y.value.metaSync({value:Be},null);else{const Oe=et(H,i,this.project);Oe==null||Oe.metaSync({value:Be},null),Y={valueOwner:ue,type:Te.ExecutionResult,inheritanceLink:null,value:Oe}}this.lastExecutionResults.writeValue(ue,Y.value),ue.inputs.forEach(Oe=>{var _e;if(((_e=Oe.declaration)==null?void 0:_e.type)===f.Property&&Oe.declaration.static){const De=this.lastExecutionResults.readValue(Oe.declaration.id),Ke=ie(Oe,this.project),Me=$r(Ke);if(De)De.metaSync({value:Be[Me]},null),this.lastExecutionResults.writeValue(Oe.declaration,De);else{const Qe=et(Oe.getDataType(null),Oe,this.project);Qe==null||Qe.metaSync({value:Be[Me]},null),this.lastExecutionResults.writeValue(Oe.declaration,Qe)}}})}else this.lastExecutionResults.writeValue(ue,Y==null?void 0:Y.value);const ae=[],be=(N=Y==null?void 0:Y.value)!=null&&N.value&&lr((U=Y.value)==null?void 0:U.value)?((K=Y.value)==null?void 0:K.value)||{}:{};return i.outputs.map(Be=>{const Oe=$r(ie(Be,this.project)),_e=be[Oe],De=et(Be.getDataType(null),Be,this.project);De==null||De.metaSync({value:_e},null);const Ke={value:De,valueOwner:Be,type:Te.ExecutionResult,inheritanceLink:Y?{sources:[Y],target:i}:null};ae.push(Ke)}),Y.type=Te.ExecutionResult,{value:Je.Success,entity:i,error:null,results:[Y,...ae]}}case f.FunctionCall:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((k=p.onBeforeEntityExecution)==null?void 0:k.call(p,i,Y,t)),this.executeFunctionCall(i,Y,this.project)}case f.FunctionDeclaration:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((J=p.onBeforeEntityExecution)==null?void 0:J.call(p,i,Y,t)),Bn.executeEntryPointEntity(i,Y)}case f.Search:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((se=p.onBeforeEntityExecution)==null?void 0:se.call(p,i,Y,t)),this.executeSearch(i,Y,this.project)}case f.Loop:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((te=p.onBeforeEntityExecution)==null?void 0:te.call(p,i,Y,t)),this.executeLoop(i,Y,this.project,p)}case f.ReturnStatement:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((ce=p.onBeforeEntityExecution)==null?void 0:ce.call(p,i,Y,t)),Bn.executeReturnStatement(i,Y)}case f.ContinueStatement:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((re=p.onBeforeEntityExecution)==null?void 0:re.call(p,i,Y,t)),Bn.executeContinueStatement(i,Y)}case f.BreakStatement:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((fe=p.onBeforeEntityExecution)==null?void 0:fe.call(p,i,Y,t)),Bn.executeBreakStatement(i,Y)}case f.GlobalEvent:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((z=p.onBeforeEntityExecution)==null?void 0:z.call(p,i,Y,t)),Bn.executeEntryPointEntity(i,Y)}default:return{value:Je.Error,entity:i,error:null,results:[]}}}storeLastExecutionValues(i){i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),i.results.forEach(a=>{const l=an(a.valueOwner,this.project);a.value?l.forEach(p=>{this.lastExecutionResults.writeValue(p,a.value)}):l.forEach(p=>{this.lastExecutionResults.removeValue(p.id)})})}async executeBranch(i,a={},l=[]){var T;const p={...Qa,...a},t={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const v=await this.executeEntity(i,l,p);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(v),await((T=p.onEntityExecuted)==null?void 0:T.call(p,i,v,t)),v.value===Je.Success){const R=(i.successCalls||i.calls||[]).filter(K=>this.hasEntity(K));(i.errorCalls||[]).forEach(K=>{this.skip(K)});let P=[];const N=(await Promise.all(R.map(K=>this.schedule(K,v.results,p)))).filter(K=>!!K),U=N.filter(K=>!!K).find(K=>K.value===Je.Error||K.value===Je.Return||K.value===Je.Break||K.value===Je.Continue);return U||(P=[...P,...N],v)}else if(v.value===Je.Error){const R=(i.errorCalls||[]).filter(K=>this.hasEntity(K));(i.successCalls||i.calls||[]).forEach(K=>{this.skip(K)});let P=[];const N=(await Promise.all(R.map(K=>this.schedule(K,v.results,p)))).filter(K=>!!K),U=N.filter(K=>!!K).find(K=>K.value===Je.Error||K.value===Je.Return||K.value===Je.Break||K.value===Je.Continue);return U||(P=[...P,...N],v)}else{if(v.value===Je.Return)return v;if(v.value===Je.Break)return v;if(v.value===Je.Continue)return v}return v}async execute(i={},a=[]){const l={...Qa,...i};this.state="running";const p=await this.executeBranch(this.entryPoint,l,a);return this.state="finished-success",p}addEntity(i){var a;this.entities.includes(i)||(this.entities.push(i),(a=this.onAddEntityCallback)==null||a.call(this,i))}addEntities(i){i.forEach(a=>this.addEntity(a))}removeEntity(i){var a;if(i!==this.entryPoint){const l=this.entities.indexOf(i);l>-1&&(this.entities.splice(l,1),(a=this.onRemoveEntityCallback)==null||a.call(this,i))}}hasEntity(i){var p,t,y;if(this.entities.includes(i))return!0;if(((p=i.parent)==null?void 0:p.type)===f.FunctionDeclaration&&((y=(t=i.parent)==null?void 0:t.parent)==null?void 0:y.type)===f.DefinitionEntity)return this.entities.includes(i.parent);const a=or(i);if(!a)return!1;const l=a.type===f.Loop&&i.parent===a.body?a.body:null;return l?this.entities.includes(l)||this.entities.includes(a):this.entities.includes(a)}removeScheduled(i){const a=this.scheduled.indexOf(i);a>-1&&this.scheduled.splice(a,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const a=this.project.get(i);return a?this.hasEntity(a):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}removeFromExecutingList(i){const a=this.executing.indexOf(i);a>-1&&this.executing.splice(a,1)}removeFromAlreadyExecutedList(i){const a=this.executed.indexOf(i);a>-1&&this.executed.splice(a,1)}removeFromSkippedList(i){var l;const a=this.skipped.indexOf(i);a>-1&&(this.skipped.splice(a,1),(l=this.onRemoveFromSkippedListCallback)==null||l.call(this,i))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var a;this.skipped.includes(i)||(this.skipped.push(i),(a=this.onAddToSkippedListCallback)==null||a.call(this,i))}}function vme(d){var u,i;if(d.isList)return"list";if(((u=d.entity)==null?void 0:u.type)===f.DefinitionEntity)return"definition-entity";switch((i=d.entity)==null?void 0:i.name){case X.Number:return"number";case X.String:return"text";case X.Boolean:return"boolean";case X.UUID:return"uuid";case X.Date:return"date-time";default:return"definition-entity"}}const Qb={[f.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[f.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[f.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[f.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[f.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[f.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[f.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[f.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[f.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[f.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[f.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[f.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[f.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[f.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[f.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[f.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[f.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[f.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[f.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[f.ReturnDeclaration]:{singular:"Output definition",plural:"Output definitions",shortSingular:"Output",shortPlural:"Outputs"},[f.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"}};function eA(d){const u=qy(d);if(!u){const a=Md(d);if(a.includes(Ve.HTTP_ENDPOINT))return"HTTP endpoint";if(a.includes(Ve.PERSISTED_ENTITY))return"Persisted entity";if(a.includes(Ve.CRON_JOB))return"Scheduled execution";if(a.includes(Ve.RELATIONAL_DATABASE))return"Relational database"}if(u){let a="Extension of "+ie(u,u.project)+" entity",l=dd(a);const p=Md(d);return p.includes(Ve.HTTP_ENDPOINT)?"HTTP endpoint"+(l?", "+l:""):p.includes(Ve.PERSISTED_ENTITY)?"Persisted entity"+(l?", "+l:""):p.includes(Ve.CRON_JOB)?"Scheduled execution"+(l?", "+l:""):p.includes(Ve.RELATIONAL_DATABASE)?"Relational database"+(l?", "+l:""):a}let i="";return d.abstract&&(i="Template "),d.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function Kx(d){return d.parent.type===f.DefinitionEntity||d.parent.type===f.InstalledProject?"Internal action of "+ie(d.parent,d.project):d.parent.type===f.Loop?"Action repeated on every iteration":"Internal action of entity"}function tA(d){return MA(d)?Kx(d):"Custom trigger"}function Eme(d){var u;switch(d.type){case f.DefinitionEntity:return eA(d);case f.FunctionDeclaration:return tA(d)}return(u=Qb[d.type])==null?void 0:u.singular}function Tme(d){var u;switch(d.type){case f.DefinitionEntity:return eA(d);case f.FunctionDeclaration:return tA(d)}return(u=Qb[d.type])==null?void 0:u.singular}const rA=4e4,kx=280,bme=300,iA=65,Pd=32,Iy=39,Sx=26,qx=49,wy=44,Ame=35,Ry=52,sA=10,ba=sA*2,gy=38,_y=90,nA=270,Zx=rA/2+120,Jx=rA/2+180;function Wx(d){let i=Pd+wy+gy+sA;const a=[...d.inputs];return a.length&&(i+=ba,a.forEach(()=>{i+=Sx})),{height:i,width:280}}function Hx(d){let i=iA;const a=[];if([f.DefinitionEntity].includes(d.type)){const v=[...d.suggestedProperties||[],...d.properties||[]];v.length&&(i+=ba,v.forEach(T=>{i+=T.static?qx:Iy}))}if([f.DefinitionEntity,f.InstalledProject,f.Loop].includes(d.type)){const v=[...(d==null?void 0:d.suggestedMethods)||[],...d.methods||[],...d.functions||[],...d.body?[d.body]:[]];v.length&&(i+=ba,v.forEach(T=>{const R=Wx(T);i+=R.height}))}nr.includes(d.type)?(ot.includes(d.type)?a.push(...(d.usedInputs||[]).flatMap(v=>[v])||[]):a.push(...(d.inputs||[]).flatMap(v=>[v])||[]),d.error&&(i+=Ry)):[f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)?(a.push(...d.outputs||[]),d.throws&&(i+=Ry)):d.type===f.Condition&&(a.push(d.inputs[0]),d.inputs[1]&&a.push(d.inputs[1]));const l=a.length;l&&(i+=l*Iy,i+=ba);const p=[];if(d.type===f.FunctionDeclaration||d.type===f.GlobalEvent?p.push(...d.inputs||[]):nr.includes(d.type)&&(ot.includes(d.type)?p.push(...d.usedOutputs||[]):p.push(...d.outputs||[])),ot.includes(d.type)){d.readsValue&&(i+=ba,i+=wy),d.writesValues.length&&(i+=ba,i+=wy),d.internalCalls.length&&d.usedInternalCalls.forEach(()=>i+=Ry+ba);const v=d.getDataType(null);(!v||v.inferred)&&(i+=gy)}const t=p.length;return t&&(i+=t*Iy,i+=ba),[f.DefinitionEntity,f.FunctionDeclaration,f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)&&(i+=gy),{height:i,width:280}}function Rp(d){return`${d.split("-").map((a,l)=>l===0?a.charAt(0).toUpperCase()+a.slice(1):a.toLowerCase()).join(" ")}.`}function Ime(d){switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case oe.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case oe.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case oe.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case oe.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case oe.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case oe.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case ne.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case ne.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case oe.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case oe.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case ne.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case oe.NoProperties:return"This entity has no properties, so it doesn't do anything";case oe.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case oe.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case oe.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case oe.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case oe.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case oe.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case oe.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case oe.PropertyImplementsNonAbstact:return"This property implements a non-template property";case oe.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case oe.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case oe.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case oe.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case oe.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case ne.InternalCallDeclarationIsNotFunctionDeclaration:return"This internal call is not an action";case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case ne.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case ne.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case ne.UnreachableEntity:return"This entity is unreachable";case oe.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";default:return Rp(d.code)}}function wme(d){switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case oe.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case oe.IncorrectEntityImplementation:return"Incorrect implementation";case oe.IncorrectMethodImplementation:return"Incorrect action implementation";case oe.IncorrectPropertyImplementation:return"Incorrect property implementation";case oe.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case oe.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case ne.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case ne.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case oe.MissingMethodImplementation:return"Missing action";case oe.MissingPropertyImplementation:return"Missing property";case ne.NameNotUniqueInScope:return"Duplicate name";case oe.NoProperties:return"No properties";case oe.NonStaticPropertyInStaticEntity:return"Non-static property";case oe.StaticEntityWithNonStaticProperties:return"Non-static properties";case oe.ReadingFromIncompatibleType:return"Read from different type";case oe.WritingToIncompatibleType:return"Write to different type";case oe.ScopeWithoutLogic:return"No logic";case oe.NonStaticPropertyImplementsStatic:return"Invalid static property";case oe.PropertyImplementsIncompatibleType:return"Incompatible data type";case oe.PropertyImplementsNonAbstact:return"Non-template property";case oe.StaticPropertyImplementsNonStatic:return"Non-static property";case oe.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case oe.VariableHasInputsAndInternalCall:return"Bad internal call";case oe.VariableHasOutputsAndInternalCall:return"Bad internal call";case oe.VariableIsCalledAndHasInternalCall:return"Bad internal call";case ne.InternalCallDeclarationIsNotFunctionDeclaration:return"Declaration not an action";case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case ne.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case ne.InternalCallParentMissingDataType:return"Parent has no data type";case ne.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case ne.UnreachableEntity:return"Unreachable entity";case oe.DisconnectedCallableEntity:return"Disconnected entity";default:return Rp(d.code)}}function Rme(d){switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return`${ie(d.entity,d.entity.project)} has non-template actions`;case oe.AbstractEntityWithNonAbstractProperties:return`${ie(d.entity,d.entity.project)} has non-template properties`;case oe.IncorrectEntityImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements template`;case oe.IncorrectMethodImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template`;case oe.IncorrectPropertyImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template`;case oe.AbstractMethodInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} can't be a template`;case oe.AbstractPropertyInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} can't be a template`;case ne.MethodOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites action`;case ne.PropertyOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites property`;case oe.MissingMethodImplementation:return`${ie(d.entity,d.entity.project)} is missing action`;case oe.MissingPropertyImplementation:return`${ie(d.entity,d.entity.project)} is missing property`;case ne.NameNotUniqueInScope:return`${ie(d.entity,d.entity.project)} name is not unique`;case oe.NoProperties:return`${ie(d.entity,d.entity.project)} has no properties`;case oe.NonStaticPropertyInStaticEntity:return`${ie(d.entity,d.entity.project)} has non-static property`;case oe.StaticEntityWithNonStaticProperties:return`${ie(d.entity,d.entity.project)} has non-static properties`;case oe.ReadingFromIncompatibleType:return`${ie(d.entity,d.entity.project)} reads from different type`;case oe.WritingToIncompatibleType:return`${ie(d.entity,d.entity.project)} writes to different type`;case oe.ScopeWithoutLogic:return`${ie(d.entity,d.entity.project)} has no logic`;case oe.NonStaticPropertyImplementsStatic:return`${ie(d.entity,d.entity.project)} has invalid static property`;case oe.PropertyImplementsIncompatibleType:return`${ie(d.entity,d.entity.project)} has incompatible data type`;case oe.PropertyImplementsNonAbstact:return`${ie(d.entity,d.entity.project)} has non-template property`;case oe.StaticPropertyImplementsNonStatic:return`${ie(d.entity,d.entity.project)} has non-static property`;case oe.VariableCallsOthersAndHasInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case oe.VariableHasInputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case oe.VariableHasOutputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case oe.VariableIsCalledAndHasInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case ne.InternalCallDeclarationIsNotFunctionDeclaration:return`${ie(d.entity,d.entity.project)} has declaration that is not an action`;case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has declaration that is not found in parent`;case ne.InternalCallParentDeclarationEntityInvalidType:return`${ie(d.entity,d.entity.project)} has invalid parent declaration type`;case ne.InternalCallParentMissingDataType:return`${ie(d.entity,d.entity.project)}'s parent has no data type`;case ne.InternalCallDeclarationNotInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has declaration that is not in parent`;case ne.UnreachableEntity:return`${ie(d.entity,d.entity.project)} is unreachable`;case oe.DisconnectedCallableEntity:return`${ie(d.entity,d.entity.project)} is not executed by any entity`;default:return`${ie(d.entity,d.entity.project)} Error: ${Rp(d.code)}`}}function gme(d){var u,i,a,l;switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return`${ie(d.entity,d.entity.project)} has non-template actions`;case oe.AbstractEntityWithNonAbstractProperties:return`${ie(d.entity,d.entity.project)} has non-template properties`;case oe.IncorrectEntityImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template entity`;case oe.IncorrectMethodImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template action it's based on`;case oe.IncorrectPropertyImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template property it's based on`;case oe.AbstractMethodInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} is a template action in a non-template entity`;case oe.AbstractPropertyInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} is a template property in a non-template entity`;case ne.MethodOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites an action in the template entity`;case ne.PropertyOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites a property in the template entity`;case oe.MissingMethodImplementation:return`${ie(d.entity,d.entity.project)} is missing an action implementation from the template entity`;case oe.MissingPropertyImplementation:return`${ie(d.entity,d.entity.project)} is missing a property implementation from the template entity`;case ne.NameNotUniqueInScope:return`${ie(d.entity,d.entity.project)} has a duplicate name in the same scope`;case oe.NoProperties:return`${ie(d.entity,d.entity.project)} has no properties, so it doesn't do anything`;case oe.NonStaticPropertyInStaticEntity:return`${ie(d.entity,d.entity.project)} has a non-static property in a static entity`;case oe.StaticEntityWithNonStaticProperties:return`${ie(d.entity,d.entity.project)} has non-static properties in a static entity`;case oe.ReadingFromIncompatibleType:return`${ie(d.entity,d.entity.project)} reads data from a value of a different data type`;case oe.WritingToIncompatibleType:return`${ie(d.entity,d.entity.project)} writes data to a value of a different data type`;case oe.ScopeWithoutLogic:return`${ie(d.entity,d.entity.project)} has no logic`;case oe.NonStaticPropertyImplementsStatic:return`${ie(d.entity,d.entity.project)} has a static property in a non-static entity`;case oe.PropertyImplementsIncompatibleType:return`${ie(d.entity,d.entity.project)} implements a property of a different data type`;case oe.PropertyImplementsNonAbstact:return`${ie(d.entity,d.entity.project)} implements a non-template property`;case oe.StaticPropertyImplementsNonStatic:return`${ie(d.entity,d.entity.project)} has a static property in a non-static entity`;case oe.VariableCallsOthersAndHasInternalCall:return`${ie(d.entity,d.entity.project)} calls other entities while being used to execute internal logic`;case oe.VariableHasInputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has inputs while being used to execute internal logic`;case oe.VariableHasOutputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has outputs while being used to execute internal logic`;case oe.VariableIsCalledAndHasInternalCall:return`${ie(d.entity,d.entity.project)} is called while being used to execute internal logic`;case ne.InternalCallDeclarationIsNotFunctionDeclaration:return`${ie(d.entity,d.entity.project)} has a declaration that is not an action`;case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has a declaration that is not found in ${(u=d.entity.parent.getDataType(null))!=null&&u.entity?ie((i=d.entity.parent.getDataType(null))==null?void 0:i.entity,d.entity.project):"the variable's data-type entity"}`;case ne.InternalCallParentDeclarationEntityInvalidType:return`${ie(d.entity,d.entity.project)} is part of a variable whos data-type entity can't have actions`;case ne.InternalCallParentMissingDataType:return`${ie(d.entity,d.entity.project)} is part of a variable with no data-type entity`;case ne.InternalCallDeclarationNotInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has a declaration doesn't belong to ${(a=d.entity.parent.getDataType(null))!=null&&a.entity?ie((l=d.entity.parent.getDataType(null))==null?void 0:l.entity,d.entity.project):"the variable's data-type entity"}`;case ne.UnreachableEntity:return`${ie(d.entity,d.entity.project)} is unreachable`;case oe.DisconnectedCallableEntity:return`${ie(d.entity,d.entity.project)} is disconnected and won't be executed by anything after publishing`;default:return`${ie(d.entity,d.entity.project)} Error: ${Rp(d.code)}`}}var aA=(d=>(d.ValuesAlreadyConnected="values-already-connected",d.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",d.CannotReadValueFromChildren="cannot-read-value-from-children",d.CannotWriteValueToChildren="cannot-write-value-to-children",d.CannotBeCalledByChildren="cannot-be-called-by-children",d.ExecutionsAlreadyConnected="executions-already-connected",d.DataTypesNotCompatible="data-types-not-compatible",d.CannotCallAncestor="cannot-call-ancestor",d.CannotConnectToItself="cannot-connect-to-itself",d.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",d.NotInScope="not-in-scope",d.IsNotValueWrittingEntity="is-not-value-writting-entity",d.IsNotValueReadingEntity="is-not-value-reading-entity",d.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",d.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",d.CallerIsInHigherScope="caller-is-in-higher-scope",d.CallerIsInLowerScope="caller-is-in-lower-scope",d.CallIsInHigherScope="call-is-in-higher-scope",d.CallIsInLowerScope="call-is-in-lower-scope",d.OtherIncompatibleScopeReason="other-incompatible-scope-reason",d.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",d))(aA||{});const _me=Object.values(aA);var oA=(d=>(d.NotPartOfOngoingTest="not-part-of-ongoing-test",d.CannotBeAddedToTest="cannot-be-added-to-test",d))(oA||{});const Dme=Object.values(oA);var lA=(d=>(d.Suggestion="suggestion",d.CanvasGloballyDisabled="canvas-globally-disabled",d.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",d.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",d))(lA||{});const Ome=Object.values(lA);function Cme(d,u){const i=[...d,...u];return Array.from(new Set(i))}function $me(d,u){const i=[...d,...u],a=Array.from(new Set(i));return{hasChanged:a.length!==d.length,reasons:a}}function Pme(d,u){const i=d.filter(l=>!u.includes(l));return{hasChanged:i.length!==d.length,reasons:i}}function Vme(d,u){return d.find(i=>i.entity.id===u)||null}function Yx(d){return d.filter((u,i)=>d.indexOf(u)===i)}class ci{constructor(u,i,a=null,l){O(this,"ids",[]);O(this,"entity");O(this,"entityCardHeight");O(this,"entityCardWidth");O(this,"index");O(this,"childEntities",[]);O(this,"children",[]);O(this,"parents",[]);O(this,"calculationEntryPoint");O(this,"_onlyEntities",null);O(this,"_changeSet",null);if(this.index=i,this.entity=u,this.calculationEntryPoint=a||this,this===this.calculationEntryPoint&&!l)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(u,i,a){const l=Zx-nA-kx,p=Jx-_y-iA;u.metaSync({x:u.x||l,y:u.y||p},i);const t=new ci(u,0,null,i);t._onlyEntities=a||[],t.ids=["0"];const y=[];t.next(T=>{y.push(...T)}),ci.recursivelyAssembleChildrenAreas(y),t.resolveChildrenOverlaps();const v=t.flattenChildEntities();return t._onlyEntities?v.filter(T=>(t._onlyEntities||[]).includes(T)):v}static recursivelyAssembleChildrenAreas(u){const i=[];u.forEach(a=>{a.next(l=>{i.push(...l)})}),i.length>0&&ci.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(u){this.calculationEntryPoint._changeSet=u}findAreaInChildrenFromEntity(u){if(this.entity===u)return this;const i=this.children.find(l=>l.entity===u);return i||this.children.reduce((l,p)=>l||p.findAreaInChildrenFromEntity(u),null)}findAreaFromEntity(u){if(this.entity===u)return this;const i=this.calculationEntryPoint.children,a=i.find(p=>p.entity===u);return a||i.reduce((p,t)=>p||t.findAreaInChildrenFromEntity(u),null)}addParent(u){if(!this.parents.includes(u)){const i=ci.resolveIds(u,this.index);this.ids.push(...i),this.parents.push(u)}}static resolveIds(u,i){return u?u.ids.map(a=>`${a}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const u=ln(this.entity,!0);if(this.entity.type===f.Project){const i=[],a=[],l=[];u.forEach(t=>{if(f.DefinitionEntity===t.type){a.push(t);return}else if(tr.includes(t.type)){l.push(t);return}i.push(t)});const p=i.sort((t,y)=>{const v=!!Uy(t,y).length,T=ln(t),R=ln(y);return v?0:T.length&&!R.length?-1:!T.length&&R.length?1:0}).filter(t=>!no(t).length);this.childEntities=[...a,...l,...p]}else{const i=[],a=[],l=[],p=[],t=[];Ps.includes(this.entity.type)&&xy(this.entity).forEach(T=>{if(ot.includes(T.type)){l.push(T);return}const R=or(T);i.push(R)}),Dr.includes(this.entity.type)&&a.push(...this.entity.detachedChildren);const y=u.filter(v=>{const T=i.includes(v);return T||l.includes(v)||a.includes(v)?!1:ot.includes(v.type)?(l.push(v),!1):$s.includes(v.type)&&!T?(p.push(v),!1):v.type===f.DefinitionEntity?(t.push(v),!1):!0});i.sort((v,T)=>ll(v,T)?-1:0),p.sort((v,T)=>ll(v,T)?-1:0),l.sort((v,T)=>OA(v,T)?1:OA(T,v)?-1:0),this.childEntities=[...t,...i,...p,...y,...l,...a]}}calculateCardSize(){const u=Hx(this.entity);this.entityCardWidth=u.width,this.entityCardHeight=u.height}static getBoundriesOfTwoAreas(u,i){return{top:Math.min(u.top,i.top),left:Math.min(u.left,i.left),bottom:Math.max(u.bottom,i.bottom),right:Math.max(u.right,i.right)}}static getBoundriedOfCombinedAreas(u,i){const a=u.filter(p=>!i.includes(p));return a.reduce((p,t)=>i.includes(t)?p:ci.getBoundriesOfTwoAreas(p,t.fullBranchArea),a[0].fullBranchArea)}getFullAreaUntilAny(u){const i=this.ownEntityPlusBufferArea;return this.children.filter(t=>!u.includes(t)).map(t=>t.getFullAreaUntilAny(u)).reduce((t,y)=>ci.getBoundriesOfTwoAreas(t,y),i)}getFullAreaUntilAreaOrAnyChildren(u){const i=[u,...u.flattenChildren()],a=this.ownEntityPlusBufferArea;return this.children.filter(t=>i.includes(t)).map(t=>t.getFullAreaUntil(u)).reduce((t,y)=>ci.getBoundriesOfTwoAreas(t,y),a)}getFullAreaUntil(u){const i=this.ownEntityPlusBufferArea;return this.children.filter(p=>p!==u).map(p=>p.getFullAreaUntil(u)).reduce((p,t)=>ci.getBoundriesOfTwoAreas(p,t),i)}get fullBranchArea(){const u=this.ownEntityPlusBufferArea;return this.children.map(l=>l.fullBranchArea).reduce((l,p)=>ci.getBoundriesOfTwoAreas(l,p),u)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const u=this.ownEntityArea;return{top:u.top,left:u.left,bottom:u.bottom+_y,right:u.right+nA}}static filterOutRepeatedAreas(u){return u.filter((i,a)=>u.indexOf(i)===a)}getEarliestId(u,i){const a=u.split("-"),l=i.split("-");return a.length<l.length?u:a.length>l.length?i:a.reduce((t,y,v)=>y<l[v]?u:i,u)}getEarliestLevel(){return this.ids.reduce((a,l)=>this.getEarliestId(a,l),this.ids[0]).split("-").length}countColumns(){let u=0;if(this!==this.calculationEntryPoint)u++;else return u;if(!this.parents.length)return u;const a=this.parents.reduce((l,p)=>p.getEarliestLevel()>l.getEarliestLevel()?p:l,this.parents[0]).countColumns();return u+=a,u}getLatestId(u,i){if(u===i)return u;const a=u.split("-"),l=i.split("-");return a.length<l.length?i:a.length>l.length?u:a.reduce((t,y,v)=>y>l[v]?u:i,u)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((a,l)=>this.getLatestId(a,l),this.ids[0]).split("-").length}smoothPosition(){const u=this.flattenSiblings();if(!u.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(a=>{a!==this.calculationEntryPoint&&a.shiftDownAlone(i)})}else if([...tr].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=u.filter(a=>!this.parents.includes(a));i.length?i.every(l=>{const p=this.countColumns(),t=l.countColumns();return p>t})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(u,i){if(u.includes(this))return u;this.move(this.entity,{y:this.entity.y+i});let a=[...u,this];return this.children.forEach(l=>{if(ci.getEarliestParentInChain(l)!==this)return;const t=Vme(a,l.entity.id);a=ci.filterOutRepeatedAreas([...a]),t||(a=a.filter(v=>v!==l));const y=l.shiftDownUntilAny(a,i);a.push(...y)}),a}shiftRightUntilAny(u,i){u.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(a=>{const l=ci.filterOutRepeatedAreas([...this.flattenSiblings(),...u]);ci.getEarliestParentInChain(a)===this&&a.shiftRightUntilAny(l,i)}))}shiftRight(u){this.move(this.entity,{x:this.entity.x+u}),this.children.forEach(i=>{const l=i.flattenSiblings().filter(p=>p!==i);i.shiftRightUntilAny(l,u)})}shiftDownAlone(u){this.move(this.entity,{y:this.entity.y+u})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const u=this.parents.reduce((l,p)=>{const t=p.ownEntityArea,y=t.top+Pd,v={top:y,left:t.left,bottom:y,right:t.right};return ci.getBoundriesOfTwoAreas(l,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Pd;this.shiftDownAlone(a)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const u=this.children.reduce((l,p)=>{const t=p.ownEntityArea,y=t.top+Pd,v={top:y,left:t.left,bottom:y,right:t.right};return ci.getBoundriesOfTwoAreas(l,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Pd;return this.shiftDownAlone(a),a}resolveChildrenOverlaps(){const u=this.flattenChildren();let i=[];u.forEach(a=>{const l=a.adjustVerticallyToAvoidOverlaps();i.push(...l)}),u.forEach(a=>{a.smoothPosition()})}static getEarliestParentInChain(u){let i=u.parents[0];return u.parents.length&&(i=u.parents.sort((a,l)=>{if(!a.ids.length)return-1;if(!l.ids.length)return 1;const p=a.ids.sort((y,v)=>y.length<v.length?-1:0),t=l.ids.sort((y,v)=>y.length<v.length?-1:0);return p[0].length-t[0].length})[0]),i}flattenEarlierSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,l)=>{if(u.has(l.entity.id))return a;u.add(l.entity.id);const t=l.children.slice(0,l.children.indexOf(this)).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...t]},[])}flattenSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,l)=>{if(u.has(l.entity.id))return a;u.add(l.entity.id);const t=l.children.filter(y=>y!==this).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...t]},[])}flattenChildren(u=new Set){return this.children.reduce((i,a)=>u.has(a.entity.id)?i:(u.add(a.entity.id),[...i,a,...a.flattenChildren(u)]),[])}flattenParents(u=new Set){return this.parents.reduce((a,l)=>u.has(l.entity.id)?a:(u.add(l.entity.id),[...a,l,...l.flattenParents(u)]),[])}getAreaIfRendered(u){return this.calculationEntryPoint.flattenChildren().find(l=>l.entity.id===u.id)||null}getLowerSiblings(){const u=this.parents.reduce((i,a)=>{const l=a.children.indexOf(this),p=a.children.slice(l+1);return[...i,...p]},[]);return Yx(u)}getLowerAreas(){const u=this.getLowerSiblings(),i=this.parents.reduce((a,l)=>[...a,...l.getLowerAreas()],[]);return Yx([...u,...i])}adjustVerticallyToAvoidOverlaps(u=[]){const a=ci.getEarliestParentInChain(this).children[this.index-1];if(!a)return u;const l=this.flattenEarlierSiblings(),p=this.flattenParents(),t=[...l,...p,a],T=w(t.flatMap(N=>Uy(this.entity,N.entity))).filter(N=>N.id!==this.entity.id).map(N=>this.findAreaFromEntity(N)).filter(N=>!!N),R=this.getFullAreaUntilAny(T),A=a.getFullAreaUntilAny(T),P=t.reduce((N,U)=>U===this||U.fullBranchArea.left!==R.left?N:Math.max(N,U.fullBranchArea.bottom),A.bottom);if(R.top<P){const N=P-R.top+_y;return this.shiftDownUntilAny(u,N)}return u}move(u,i){(this.onlyEntities||[]).includes(u)&&u.metaSync(i,this.changeSet)}addChild(u){const i=this.childEntities[u];let a=null;i.x&&i.y?a=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),a||(a=new ci(i,u,this.calculationEntryPoint));const l=this.ownEntityPlusBufferArea;this.children.includes(a)||(this.children.push(a),a.addParent(this));const p=a.fullBranchArea;if(p.left<l.right){const t=l.right-p.left;a.shiftRight(t)}return a}flattenChildEntities(u=new Set){return this.children.reduce((i,a)=>u.has(a.entity.id)?i:(u.add(a.entity.id),[...i,a.entity,...a.flattenChildEntities(u)]),[])}next(u){const i=[];this.childEntities.forEach((a,l)=>{const p=this.addChild(l);p&&i.push(p)}),u(i)}}var gp=(d=>(d.Amazon="amazon",d.Google="google",d.Microsoft="microsoft",d))(gp||{}),jr=(d=>(d.RelationalDatabase="relational-database",d.CompiledLocalCodebase="compiled-local-codebase",d.CloudHostedCodebase="cloud-hosted-codebase",d.HttpApi="http-api",d.HttpEndpoint="http-endpoint",d.ServerlessFunction="serverless-function",d))(jr||{}),dA=(d=>(d.Post="post",d.Get="get",d.Acknowledgement="acknowledgment",d.Progress="progress",d.Error="error",d.Complete="complete",d))(dA||{}),ol=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.Skipped="skipped",d.AbortedByUser="aborted-by-user",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(ol||{}),uA=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(uA||{}),nt=(d=>(d.ProjectNotFound="project-not-found",d.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",d.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",d.DeploymentCompleted="deployment-completed",d.DeploymentStarted="deployment-started",d.DeploymentFailed="deployment-failed",d.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",d.RequestPayloadValidationFailed="request-payload-validation-failed",d.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",d.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",d.ProjectAlreadyBeingPublished="project-already-being-published",d.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",d.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",d.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",d.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",d.CreatingNewRelationalDatabase="creating-new-relational-database",d.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",d.RelationalDatabaseAlreadyExists="relational-database-already-exists",d.RelationalDatabaseDeletionStarted="relational-database-deletion-started",d.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",d.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",d.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",d.HttpApiDeploymentStarted="http-api-deployment-started",d.HttpApiDeploymentCompleted="http-api-deployment-completed",d.HttpApiDeploymentFailed="http-api-deployment-failed",d.CreatingNewHttpApi="creating-new-http-api",d.HttpApiAlreadyExists="http-api-already-exists",d.HttpApiDeletionStarted="http-api-deletion-started",d.HttpApiDeletionCompleted="http-api-deletion-completed",d.HttpApiDeletionFailed="http-api-deletion-failed",d.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",d.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",d.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",d.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",d.BundlingCodebaseForDownload="bundling-codebase-for-download",d.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",d.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",d.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",d.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",d.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",d.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",d.CodeCompilationStarted="code-compilation-started",d.CodeCompilationCompleted="code-compilation-completed",d.CodeCompilationFailed="code-compilation-failed",d.BundleCodebaseStarted="bundle-codebase-started",d.BundleCodebaseCompleted="bundle-codebase-completed",d.BundleCodebaseFailed="bundle-codebase-failed",d.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",d.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",d.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",d.MigrateRelationalDatabaseStarted="migrate-relational-database-started",d.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",d.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",d))(nt||{}),on=(d=>(d.CodeCompilation="code-compilation",d.RelationalDatabaseDeployment="relational-database-deployment",d.RelationalDatabaseDeletion="relational-database-deletion",d.HttpApiDeployment="http-api-deployment",d.HttpApiDeletion="http-api-deletion",d.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",d.BundleCodebase="bundle-codebase",d.MigrateRelationalDatabase="migrate-relational-database",d.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",d.CodebaseCleanup="codebase-cleanup",d))(on||{});jr.CloudHostedCodebase,jr.HttpApi,jr.RelationalDatabase,jr.CloudHostedCodebase,jr.CloudHostedCodebase,jr.RelationalDatabase,jr.CloudHostedCodebase,jr.CloudHostedCodebase;function zx(d){return`project-${d}-http-api`}function Xx(d){return`entity-${d}-database`}class Qx{constructor(u,i,a,l,p,t,y,v,T){O(this,"stepType");O(this,"id");O(this,"resourceType");O(this,"index");O(this,"dependency",[]);O(this,"lastEvent",null);O(this,"lasEventTimestamp",null);O(this,"status",ol.Queued);O(this,"publicationRun");O(this,"resource");this.stepType=u,this.id=i,this.resourceType=a,this.status=l,this.dependency=p,this.index=t,this.lasEventTimestamp=y,this.publicationRun=v,this.resource=T}toJSON(){return{stepType:this.stepType,id:this.id,resourceType:this.resourceType,index:this.index,status:this.status,dependency:this.dependency,lastEvent:this.lastEvent,resource:{resourceId:this.resource.resourceId,resourceType:this.resource.resourceType,provider:this.resource.provider,details:this.resource.details,status:this.resource.status,name:this.resource.name}}}async update(u){var i,a;this.status=u.status,this.dependency=u.dependency,this.index=u.index,this.stepType=u.stepType,this.resourceType=u.resourceType,this.lastEvent=u.lastEvent,this.id=u.id,(a=this.resource)==null||a.setDetails((i=u.resource)==null?void 0:i.details)}}var eF=(d=>(d.Ready="ready",d.Provisioning="provisioning",d.Queued="queued",d.ProvisioningFailed="provisioning-failed",d.Deleting="deleting",d.DeletingFailed="deleting-failed",d.Deleted="deleted",d))(eF||{});class cA{constructor(u,i,a){O(this,"provisionedBy");O(this,"publicationRun");O(this,"resourceType");O(this,"provider");O(this,"resourceId");O(this,"details",null);O(this,"name",null);O(this,"status","queued");this.publicationRun=u,this.resourceType=i,this.provider=a}setDetails(u){this.details=u}setStatus(u){this.status=u}setProvisionedBy(u){this.provisionedBy=u}}class pA extends cA{constructor(i,a,l,p){super(i,l,p);O(this,"resourceType");O(this,"owners",new Map);O(this,"details",null);O(this,"status","queued");a.forEach(t=>{this.owners.set(t.id,t)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,a;return this.resourceType===jr.HttpApi?this.resourceId=zx(this.publicationRun.project.id):this.resourceType===jr.RelationalDatabase&&(this.resourceId=Xx((a=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:a.id)),this.resourceId}}class fA extends cA{constructor(i,a,l){super(i,a,l);O(this,"resourceType");O(this,"details",null);O(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceType===jr.CompiledLocalCodebase?this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`:this.resourceType===jr.CloudHostedCodebase&&(this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`),this.resourceId}}class Nme{constructor(u,i){O(this,"id");O(this,"projectAutoIncrementPublicationCount");O(this,"projectPublishedSemanticVersion");O(this,"projectVersion");O(this,"projectId");O(this,"cloudProvider");O(this,"triggeredBy");O(this,"createdAt");O(this,"updatedAt");O(this,"status");O(this,"steps",[]);O(this,"editor");O(this,"explicitResources",new Map);O(this,"implicitGlobalResources",new Map);O(this,"finalGlobalEvent",null);O(this,"finalStatus",null);this.id=u.id,this.projectAutoIncrementPublicationCount=u.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=u.projectPublishedSemanticVersion,this.projectVersion=u.projectVersion,this.projectId=u.projectId,this.cloudProvider=u.cloudProvider,this.triggeredBy=u.triggeredBy,this.createdAt=u.createdAt,this.updatedAt=u.updatedAt,this.status=u.status,this.editor=i}get project(){return this.editor.project}getInfraTypes(u){return this.steps.filter(i=>u.includes(i.resourceType))}getStepsTypes(u){return this.steps.filter(i=>u.includes(i.stepType))}toIds(u){return u.map(i=>i.id)}getResourceForEntity(u){const i=Array.from(this.explicitResources.values()).find(a=>a.owners.has(u.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(jr.CompiledLocalCodebase,new fA(this,jr.CompiledLocalCodebase,gp.Amazon)),this.implicitGlobalResources.set(jr.CloudHostedCodebase,new fA(this,jr.CloudHostedCodebase,gp.Amazon));const u=this.project.entities.filter(a=>as(a,Ve.HTTP_ENDPOINT)),i=this.project.entities.filter(a=>as(a,Ve.RELATIONAL_DATABASE));if(i.length&&i.forEach(a=>{const l=new pA(this,[a],jr.RelationalDatabase,gp.Amazon);this.explicitResources.set(l.resourceId,l)}),u.length){const a=new pA(this,u,jr.HttpApi,gp.Amazon);this.explicitResources.set(a.resourceId,a)}}setSteps(u,i){u.forEach(a=>{this.addStep(a,i)}),this.editor.events.emit(nt.ProjectPublishRequestAcknowledged,{})}addStep(u,i){const a=u.dependency||[];if(a.length){const p=a.filter(t=>!this.steps.find(y=>y.id===t));if(p.length)throw new Error(`Missing dependencies: ${p.join(", ")}`)}if(!u.resource)throw new Error(`Resource not found for step ${u.stepType} (${u.id})`);if(!this.steps.find(p=>p.id===u.id)){const p=this.implicitGlobalResources.get(u.resourceType)||this.explicitResources.get(u.resource.resourceId),t=new Qx(u.stepType,u.id,u.resourceType,u.status,a,u.index,i,this,p);this.steps.push(t)}}onUpdate(u){var i;if(Fe.log("onUpdate",u),(i=u.payload)!=null&&i.stepType){const a=this.steps.find(l=>{var p;return l.id===((p=u.payload)==null?void 0:p.id)});a&&L(u.emittedAt).isAfter(L(a.lasEventTimestamp))&&a.update(u.payload)}this.editor.events.emit("publication-updated",{}),u.type===dA.Error?(this.finalStatus=uA.Failed,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-error",u)):u.type===dA.Complete&&(this.finalStatus=uA.Success,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-completed",u))}}function Lme(d){switch(d){case on.CodeCompilation:return"Code generation";case on.RelationalDatabaseDeployment:return"Database creation";case on.HttpApiDeployment:return"HTTP gateway creation";case on.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case on.BundleCodebase:return"Bundle code";case on.MigrateRelationalDatabase:return"Database structure migration";case on.BusinessLogicCodebaseDeployment:return"Update servers with new code";case on.CodebaseCleanup:return"Code cleanup";case on.HttpApiDeletion:return"HTTP gateway deletion";case on.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function Bme(d){switch(d){case nt.DeploymentCompleted:return"Successfully published";case nt.DeploymentStarted:return"Publication started";case nt.DeploymentFailed:return"Publication failed";case nt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case nt.RequestPayloadValidationFailed:return"Request payload validation failed";case nt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case nt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case nt.RelationalDatabaseDeploymentStarted:return"Database creation started";case nt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case nt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case nt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case nt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case nt.RelationalDatabaseAlreadyExists:return"Database already exists";case nt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case nt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case nt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case nt.CreatingNewHttpApi:return"Creating new HTTP gateway";case nt.HttpApiAlreadyExists:return"HTTP gateway already exists";case nt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case nt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case nt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case nt.BundlingCodebaseForDownload:return"Bundling code for download";case nt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case nt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case nt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case nt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case nt.CodeCompilationStarted:return"Code generation started";case nt.CodeCompilationCompleted:return"Code generation completed";case nt.CodeCompilationFailed:return"Code generation failed";case nt.BundleCodebaseStarted:return"Code bundling started";case nt.BundleCodebaseCompleted:return"Code bundling completed";case nt.BundleCodebaseFailed:return"Code bundling failed";case nt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case nt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case nt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case nt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case nt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case nt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case nt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case nt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case nt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case nt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case nt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case nt.ProjectNotFound:return"Project not found";case nt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case nt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case nt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case nt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case nt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case nt.RelationalDatabaseDeletionStarted:return"Database deletion started";case nt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case nt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case nt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var tF=(d=>(d.NO_LOGIC="NO_LOGIC",d.NO_NAME="NO_NAME",d.NO_CHANGES="NO_CHANGES",d.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",d))(tF||{});function Mme(d){switch(d){case"NO_LOGIC":return"This project has no logic";case"NO_NAME":return"This project has no name";case"NO_CHANGES":return"This version has already been published";case"PROJECT_PUBLICATION_ALREADY_ONGOING":return"This project is already being published";default:return"Publishing is currently not available. Try again later"}}function Ume(d){switch(d){case jr.RelationalDatabase:return"Relational database";case jr.HttpEndpoint:case jr.HttpApi:return"HTTP endpoints";case jr.ServerlessFunction:case jr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function jme(d){switch(d){case ol.Running:return"In progress";case ol.Failed:return"Failed";case ol.Success:return"Succeeded";case ol.Skipped:return"Skipped";case ol.Queued:default:return"Queued"}}function xme(d,u){let i=null;const a=[];if(!d.id)i={...d,id:V.UUID.uuid()};else if(!VG(d.id)){const y=V.UUID.uuid();i={...d,id:y},a.push(new Q({id:`${d.id}--${S.InvalidUUIDStringFormat}`,message:`Entity with id "${d.id}" has an invalid UUID string format. The 'id' property must be a valid UUID string.
|
|
194
|
+
${Mn({describe_entity:y.error.id})}`,issue:null}))),{errors:p,modifiedData:l}}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){var i,a,l;return(l=(a=(i=this.dataType)==null?void 0:i.entity)==null?void 0:a.unsubscribeDependents)==null||l.call(a,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var i,a,l;return(l=(a=(i=this.dataType)==null?void 0:i.entity)==null?void 0:a.subscribeDependents)==null||l.call(a,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Mt(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Mt(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.parent=y.parent,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=Z(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&(this.removeFromParent(a),this.parent=null),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=Z(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){var y,v,T,R,A,P,N,U;const a=[this],l=[],p=[],t=[];return this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument?((y=this.parent)==null?void 0:y.type)===f.Search||((v=this.parent)==null?void 0:v.type)===f.Loop?(this.parent.addInputDeclaration(this,i),t.push(this.parent)):((R=(T=this.parent)==null?void 0:T.addInput)==null||R.call(T,this,i),a.push(this.parent)):this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((A=this.parent)==null?void 0:A.type)===f.Search||((P=this.parent)==null?void 0:P.type)===f.Loop?(this.parent.addOutputDeclaration(this,i),t.push(this.parent)):((U=(N=this.parent)==null?void 0:N.addOutput)==null||U.call(N,this,i),a.push(this.parent)):this.parentRelationType===le.ReturnedError&&this.parent&&(this.parent.error=this,t.push(this.parent)),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}setParent(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}initChildren(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=ee(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=ee(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.index=i.index||(i.index!==0?p.index:0),this.required=i.required!==void 0?i.required:this.required,this.parentRelationType=i.parentRelationType!==void 0?i.parentRelationType:this.parentRelationType,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await Mt.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await Mt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await Mt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await Mt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await Mt.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await Mt.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){var y,v,T,R,A,P,N;const a=[],l=[],p=[],t=[];return this.parent&&(((y=this.parent)==null?void 0:y.type)===f.Search?this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((v=this.parent)==null||v.removeOutputDeclaration(this,i),t.push(this.parent)):this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument?((T=this.parent)==null||T.removeInputDeclaration(this,i),t.push(this.parent)):this.parentRelationType===le.ReturnedError&&(this.parent.error=null,t.push(this.parent)):((R=this.parent)==null?void 0:R.type)===f.Loop?this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((A=this.parent)==null||A.removeOutputDeclaration(this,i),t.push(this.parent)):this.parentRelationType===le.ReturnedError&&(this.parent.error=null,t.push(this.parent)):this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?((P=this.parent)==null||P.removeOutput(this,i),t.push(this.parent)):(this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument)&&((N=this.parent)==null||N.removeInput(this,i),t.push(this.parent))),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:w(p),updated:w(a),removed:w(l),affected:w(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(Array.from(new Set([...xs(),...this.project.getAllBuiltInIds()])).includes(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(T=>{const{updated:R,removed:A,added:P}=T.entity.onDetachedDependencyRemoved(this,T.field,a);l.push(...R),p.push(...A),t.push(...P)}),this.defaultValue){const{updated:T,removed:R}=this.defaultValue.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}if(this.dataType){const{updated:T,removed:R}=this.dataType.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}if(!i){const T=this.removeFromParent(a);t.push(...T.added),l.push(...T.updated),p.push(...T.removed),y.push(...T.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:w(t),updated:w(l),removed:w(p),affected:w(y),self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){var y,v,T,R,A,P,N;const a=[],l=[],p=[],t=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(U=>{const{updated:K,removed:k,added:J}=U.entity.onDetachedDependencyRestored(this,U.field,i);l.push(...K),p.push(...k),a.push(...J)}),this.defaultValue){const{updated:U}=this.defaultValue.restore({},i);l.push(...U)}if(this.dataType){const{updated:U}=this.dataType.restore({},i);l.push(...U)}return((y=this.parent)==null?void 0:y.type)===f.Search?this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?(v=this.parent)==null||v.addOutputDeclaration(this,i):(this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument)&&((T=this.parent)==null||T.addInputDeclaration(this,i)):((R=this.parent)==null?void 0:R.type)===f.Loop?(this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn)&&((A=this.parent)==null||A.addOutputDeclaration(this,i)):this.parentRelationType===le.FixedReturns||this.parentRelationType===le.DynamicReturn?(P=this.parent)==null||P.addOutput(this,i):(this.parentRelationType===le.FixedArguments||this.parentRelationType===le.DynamicArgument)&&((N=this.parent)==null||N.addInput(this,i)),i==null||i.attemptAutoclose("restore-entity",this.id),{added:w(a),updated:w(l),removed:w(p),affected:w(t),self:this}}toFlat(i=new Set){var l;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.defaultValue)==null?void 0:l.toFlat(i))||[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){var l;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.defaultValue)==null?void 0:l.toFlatIds(i))||[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,index:this.index,required:this.required,parentRelationType:this.parentRelationType,type:this.type,name:this.name}}toJSON(i=new Set){var a,l,p;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,required:this.required,defaultValue:((a=this.defaultValue)==null?void 0:a.toJSON(i))||null,parentRelationType:this.parentRelationType,dataType:((l=this.dataType)==null?void 0:l.toJSON(i))||null,parent:((p=this.parent)==null?void 0:p.toReference())||null})}toJSONClone(i=xe){var l,p,t,y,v,T,R,A;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Nr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,required:this.required,defaultValue:((T=this.defaultValue)==null?void 0:T.toJSONClone({...i,newId:null}))||null,parentRelationType:this.parentRelationType,dataType:((R=this.dataType)==null?void 0:R.toJSONClone({...i,newId:null}))||null,parent:((A=this.parent)==null?void 0:A.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l,p,t,y;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,required:this.required,parentRelationType:this.parentRelationType,defaultValue:((p=this.defaultValue)==null?void 0:p.toReference(i))||null,dataType:((t=this.dataType)==null?void 0:t.toReference(i))||null,parent:((y=this.parent)==null?void 0:y.toReference(i))||null}}toFlatJSON(i=new Set){var l;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.defaultValue)==null?void 0:l.toFlatJSON(i))||[],...this.dataType?this.dataType.toFlatJSON(i):[]])}toGenerationTarget(){var i;return{id:this.id,name:this.name,codeName:this.codeName,description:this.description,type:this.type,required:this.required,parentRelationType:this.parentRelationType,parent:(i=this.parent)==null?void 0:i.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(i):[],...this.dataType?this.dataType.toFlatGenerationTarget(i):[]])}clearErrors(){var i,a;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),(a=this.dataType)==null||a.clearErrors(),this}validate(){const i=Ax(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.dataType?this.dataType.getErrors():[]]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var N,U;if(Array.from(new Set([...xs(),...this.project.getAllBuiltInIds()])).includes(this.id))return this;let y=Vr(a,this);const v=l||V.UUID.uuid(),T=this.toJSON();T.id=v,T.version=V.UUID.uuid(),T.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),T.author=(i==null?void 0:i.author)||"1",T.previousVersion=null,T.deleted=!1;const R=zt(T,y);a&&R.setParent(a,null),i==null||i.add(R,G.Added),p&&R.subscribe();const A=((N=this.dataType)==null?void 0:N.clone(i,R,V.UUID.uuid(),p))||null;A&&R.setDataType(A,i);const P=(U=this.defaultValue)==null?void 0:U.clone(i,R,V.UUID.uuid(),p);return R.defaultValue=P||null,i==null||i.attemptAutoclose("clone-entity",this.id),R}getDataType(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}setDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-data-type"))){const l=this.dataType;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.dataType=i,this.subscribeToDependencies(),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("set-data-type",this.id),this}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-default-value"))){const l=this.defaultValue;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.defaultValue=i,a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("set-default-value",this.id),this}removeDataType(){return this.dataType=null,this}implementAsReturnDeclaration(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-as-return-declaration")),a,l){const p=Ki.new(i);p.id=l||p.id,p.name=this.name,p.description=this.description,p.parent=a.toReference(),p.implements=this.toJSON(),p.isError=this.parentRelationType===le.ReturnedError;const t=zt(p,this.project);if(t.hydrateAncestors(),t.addSelfToProject(i),i==null||i.add(t,G.Added),t.initChildren(i),this.dataType){const y=this.dataType.clone(i,t);t.setDataType(y,i)}if(this.defaultValue){const y=this.defaultValue.clone(i,t);t.setDefaultValue(y,i)}return i==null||i.attemptAutoclose("implement-as-return-declaration",this.id),t}implementAsArgumentDeclaration(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-as-return-declaration")),a,l){const p=Ea.new(i);p.id=l||p.id,p.name=this.name,p.description=this.description,p.parent=a.toReference(),p.implements=this.toJSON();const t=zt(p,this.project);if(t.hydrateAncestors(),t.addSelfToProject(i),i==null||i.add(t,G.Added),t.initChildren(i),this.dataType){const y=this.dataType.clone(i,t);t.setDataType(y,i)}if(this.defaultValue){const y=this.defaultValue.clone(i,t);t.setDefaultValue(y,i)}return i==null||i.attemptAutoclose("implement-as-return-declaration",this.id),t}};O(Mt,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),O(Mt,"type",f.ValueDescriptor),O(Mt,"USER_MANAGED_PARENT_TYPES",[f.ActionDescriptor,f.Loop,f.Search]),O(Mt,"PARENT_TYPES",[...Mt.USER_MANAGED_PARENT_TYPES]),O(Mt,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","required"]),O(Mt,"INMUTABLE_BASE_PROPERTIES",["id","version","type","parentRelationType","createdAt","author","previousVersion"]),O(Mt,"BASE_PROPERTIES",[...Mt.MUTABLE_BASE_PROPERTIES,...Mt.INMUTABLE_BASE_PROPERTIES]),O(Mt,"MUTABLE_META_PROPERTIES",[...Mt.MUTABLE_BASE_PROPERTIES,"index"]),O(Mt,"INMUTABLE_META_PROPERTIES",[...Mt.INMUTABLE_BASE_PROPERTIES]),O(Mt,"META_PROPERTIES",[...Mt.MUTABLE_META_PROPERTIES,...Mt.INMUTABLE_META_PROPERTIES]),O(Mt,"MUTABLE_UPSTREAM_PROPERTIES",[]),O(Mt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),O(Mt,"UPSTREAM_PROPERTIES",[...Mt.MUTABLE_UPSTREAM_PROPERTIES,...Mt.INMUTABLE_UPSTREAM_PROPERTIES]),O(Mt,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),O(Mt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),O(Mt,"DOWNSTREAM_PROPERTIES",[...Mt.MUTABLE_DOWNSTREAM_PROPERTIES,...Mt.INMUTABLE_DOWNSTREAM_PROPERTIES]),O(Mt,"PROPERTIES",[...Mt.META_PROPERTIES,...Mt.UPSTREAM_PROPERTIES,...Mt.DOWNSTREAM_PROPERTIES]);let sn=Mt;var Te=(d=>(d.Inherited="inherited",d.DefaultValue="default-value",d.Missing="missing",d.Empty="empty",d.AutoCalculated="auto-calculated",d.QueuedAutocalculation="queued-autocalculation",d.External="external",d.Testing="testing",d.ExecutionResult="execution-result",d))(Te||{});const wx={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function lme(d,u){return{...wx,id:d,project:u}}class mp{constructor(u,i){O(this,"initialized",!1);O(this,"id");O(this,"project");O(this,"values",{});O(this,"onWriteCallback",()=>{});O(this,"onRemoveCallback",()=>{});this.id=u,this.project=i,this.init()}onWrite(u){this.onWriteCallback=u}onRemove(u){this.onRemoveCallback=u}init(){if(!this.project.id||this.initialized)return;const u={},i={};Object.keys(u).forEach(a=>{const l=u[a],p=new $i(l,this.project);try{if(l.parent){const v=this.project.findSubscribedInstanceFromReference(l.parent);if(!v)return;p.setParent(v,null),p.hydrateAncestors(),p.initChildren(null)}else if(l.standaloneParent){const v=this.project.findSubscribedInstanceFromReference(l.standaloneParent);if(!v)return;p.standalone=!0,p.setStandaloneParent(v),p.hydrateAncestors(),p.initChildren(null)}i[a]=p;const t=p.parent||p.standaloneParent,y=Rx(p,t,this.project);y?i[a]=y:delete u[a]}catch(t){Fe.error("Error hydrating ancestors: ",t),delete u[a]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const u={};return Object.keys(this.values).forEach(i=>{u[i]=this.values[i].toJSON()}),u}writeValue(u,i){if(!u)throw new Error("The value owner entity is required when writing a value to a value store");let l=this.values[u.id];if(!l)if(i instanceof $i)l=i;else if(i)l=zt(i,this.project);else{const p={id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:null,type:f.LiteralValue,standaloneParent:u.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:rl(u.getDataType(null))};l=zt(p,this.project)}l.standalone=!0,l.initialData.standaloneParent||Fe.warn("instance.initialData: ",l.initialData),l.setStandaloneParent(u),l.hydrateAncestors(),l.initChildren(null),i&&(l.metaSync({...i},null),l.setValueAsType(i.valueAsType,null)),this.values[u.id]=l,this.onWriteCallback(u,l)}readValue(u){return this.values[u]||null}removeValue(u){if(!this.values[u])return;delete this.values[u];const i=this.project.get(u);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function Ta(d){var u;return!!(d.required||(u=d.declaration)!=null&&u.required)}function my(d){return W4(d)||d===void 0||d===""}function qb(d){return d?d.valueAsType?!1:my(d.value):!0}function nn(d,u,i,a){var y;let l;if(((y=d==null?void 0:d.entity)==null?void 0:y.type)===f.PrimitiveEntity)switch(d.entity.name){case X.EntityTemplate:l=X.EntityTemplate;break;case X.String:l=X.String;break;case X.Number:l=X.Number;break;case X.Boolean:l=X.Boolean;break;case X.Null:l=X.Null;break;case X.Enum:l=X.Enum;break;case X.KeyValue:l=X.KeyValue;break;case X.Untyped:l=X.Untyped;break;case X.KeyValue:l=X.KeyValue;break;case X.Date:l=X.Date;break;case X.UUID:l=X.UUID;break;case X.File:l=X.File;break;default:throw new Error(`Primitive type ${ie(d.entity,i)} is not supported`)}else l=X.Untyped;const p=$i.new();p.name=l,p.parent=u.toReference();const t=ee(p,i);return t.hydrateAncestors(),a==null||a.add(t,G.Added),t.addSelfToProject(a),t.initChildren(a),t}function an(d,u,i=new Set){var a,l;if(i.has(d.id))return[];if(i.add(d.id),d.type===f.ReturnDeclaration){const p=[d,...d.getCounterparts()];return Fe.log("Resolved counterparts for return declaration: ",`${d.name} ${d.id}`),Fe.log("equivalentReturnDeclarations: ",p.map(t=>`${t.name} ${t.id}`)),w([...p,...p.flatMap(t=>an(t,u,i))])}else if(ot.includes(d.type)){const p=bi(d);return w([p,...[p].flatMap(t=>an(t,u,i))])}else if(d.type===f.OutputMap){if(ot.includes(d.parent.type)&&d.declaration.type===f.Property&&d.declaration.static)return w([d,d.declaration,...[d,d.declaration].flatMap(p=>an(p,u,i))])}else if(d.type===f.InputMap&&ot.includes(d.parent.type)&&((a=d.declaration)==null?void 0:a.type)===f.Property&&(l=d.declaration)!=null&&l.static)return w([d.declaration,...[d.declaration].flatMap(p=>an(p,u,i))]);return[d]}function Rx(d,u,i){return d}function $d(d,u){const i=d.readsValue;let a=null;if((i==null?void 0:i.type)===f.VariableDeclaration){const p=Ep(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.VariableInstance){const p=Ey(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.OutputMap){const p=Hb(i,u);if(p&&p.value){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}else if((i==null?void 0:i.type)===f.ArgumentDeclaration){const p=Jb(i,u);if(p){const t={sources:[p],target:d};a={value:p.value,valueOwner:d,type:Te.Inherited,inheritanceLink:t}}}return a}function et(d,u,i){var y;if(!u)return null;let a;if(((y=d==null?void 0:d.entity)==null?void 0:y.type)===f.PrimitiveEntity)switch(d.entity.name){case X.EntityTemplate:a=X.EntityTemplate;break;case X.String:a=X.String;break;case X.Number:a=X.Number;break;case X.Boolean:a=X.Boolean;break;case X.Null:a=X.Null;break;case X.Enum:a=X.Enum;break;case X.KeyValue:a=X.KeyValue;break;case X.Untyped:a=X.Untyped;break;case X.KeyValue:a=X.KeyValue;break;case X.Date:a=X.Date;break;case X.UUID:a=X.UUID;break;case X.File:a=X.File;break;default:throw new Error(`Primitive type ${ie(d.entity,i)} is not supported`)}else a=X.Untyped;if(!i.get(u.id))return null;const p=$i.new();p.name=a,p.standaloneParent=u.toReference();let t=new $i(p,i);return t.hydrateAncestors(),t.standalone=!0,t.setStandaloneParent(u),t.initChildren(null),t}function vy(d,u,i){var p;const a={...d},l=u.inputs;if(!l)return a;for(const t of l){if(!Mp(t))continue;const y=bp(t,i);if(y&&y.value){const v=ie(t,i.project),T=$r(v);a[T]=((p=y==null?void 0:y.value)==null?void 0:p.value)||a[T]}}return a}function vp(d,u,i){var p;const a={...d},l=u.inputs;if(!l)return a;for(const t of l){if(!Mp(t))continue;const y=Tp(t,i);if(y&&y.value){const v=ie(t,i.project),T=$r(v);a[T]=(p=y==null?void 0:y.value)==null?void 0:p.value}}return a}function gx(d,u){var y,v,T,R,A,P,N;let i={};if(((v=(y=d.dataType)==null?void 0:y.entity)==null?void 0:v.type)===f.DefinitionEntity&&(i={...i,...d.dataType.entity.getActiveRawDefaultValue()}),u.execution&&u.execution.hasEntity(d)){const U=(T=u.lastExecutionResults)==null?void 0:T.readValue(d.id);if(U){if(lr(U.value)){const k={...i,...U.value},J={...vp(k,d,u)};U.metaSync({value:J},null)}return{value:U,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}}const a=!!((R=u.execution)!=null&&R.entities.length),l=(A=u.execution)==null?void 0:A.hasEntity(d),p=d.readsValue;let t=null;if(p){const U=(P=u.execution)==null?void 0:P.hasEntity(p);if((!a||a&&U&&l||a&&!U&&!l)&&(t=$d(d,u),t&&t.value&&lr(t.value.value))){const k={...i,...t.value.value},J={...vp(k,d,u)};t.value.metaSync({value:J},null)}}if(!t&&d.defaultValue){const U=d.defaultValue;if(U.value===null&&U.autogeneration){const K=ph(U);if(U.metaSync({value:K},null),lr(K)){const k={...vp(K,d,u)};U.metaSync({value:k},null)}}t={value:U,valueOwner:d,type:U.value===null?Te.Empty:Te.DefaultValue,inheritanceLink:null}}if(!t||t.type===Te.DefaultValue){const U=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(U){if(lr(U.value)){const K={...i,...U.value},k={...vp(K,d,u)};U.metaSync({value:k},null)}return{value:U,valueOwner:d,type:Te.Testing,inheritanceLink:null}}}return t||{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}}function _x(d,u){var l,p,t,y,v;let i={};if(((p=(l=d.dataType)==null?void 0:l.entity)==null?void 0:p.type)===f.DefinitionEntity&&(i={...i,...d.dataType.entity.getActiveRawDefaultValue()}),u.execution&&u.execution.hasEntity(d)){const T=(t=u.lastExecutionResults)==null?void 0:t.readValue(d.id);if(T){if(lr(T.value)){const A={...i,...T.value},P=vy(A,d,u);T==null||T.metaSync({value:P},null)}return{value:T,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}}const a=(y=u.localTestValues)==null?void 0:y.readValue(d.id);if(a){if(lr(a.value)){const R={...i,...a.value},A=vy(R,d,u);a.metaSync({value:A},null)}return{value:a,valueOwner:d,type:Te.Testing,inheritanceLink:null}}if((v=d.dataType)!=null&&v.entity&&d.dataType.entity.type===f.DefinitionEntity&&d.dataType.isObject()){const T=et(d.dataType,d,u.project);return T==null||T.metaSync({value:vy(i,d,u)},null),{value:T,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}}return null}function Ep(d,u){var y,v,T,R,A;if((y=d.dataType)!=null&&y.isObject())return gx(d,u);const i=or(d),a=!!((v=u.execution)!=null&&v.entities.length),l=(T=u.execution)==null?void 0:T.hasEntity(i),p=d.readsValue;let t=null;if(p){const P=(R=u.execution)==null?void 0:R.hasEntity(p);(!a||a&&P&&l||a&&!P&&!l)&&(t=$d(d,u))}if(!t&&d.defaultValue){const P=d.defaultValue;if(P.value===null&&P.autogeneration){const N=ph(P);P.metaSync({value:N},null)}t={value:P,valueOwner:d,type:P.value===null?Te.Empty:Te.DefaultValue,inheritanceLink:null}}if(!t||t.type===Te.DefaultValue){const P=(A=u.localTestValues)==null?void 0:A.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.Testing,inheritanceLink:null}}return t||{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}}function Zb(d,u){var a,l,p,t;if((a=d.dataType)!=null&&a.isObject())return _x(d,u);if(u.execution&&u.execution.hasEntity(d)){const y=(l=u.lastExecutionResults)==null?void 0:l.readValue(d.id);if(y)return{value:y,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(p=u.localTestValues)==null?void 0:p.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null};if((t=d.dataType)!=null&&t.entity&&d.dataType.entity.type===f.DefinitionEntity&&d.dataType.isObject()){const y=et(d.dataType,d,u.project),v=d.dataType.entity.getActiveRawDefaultValue();return y==null||y.metaSync({value:v},null),{value:y,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}}return null}function Ey(d,u){var T,R,A,P;const i=!!((T=u.execution)!=null&&T.entities.length),a=(R=u.execution)==null?void 0:R.hasEntity(d);let l=null;const p=d.readsValue;if(p){const N=(A=u.execution)==null?void 0:A.hasEntity(p);(!i||i&&N&&a||i&&!N&&!a)&&(l=$d(d,u))}const t=d.declaration;if(!l&&t){const N=Ep(t,u);N&&N.value&&(l=N)}if(!l||l.type===Te.DefaultValue){const N=(P=u.localTestValues)==null?void 0:P.readValue(d.id);if(N)return{value:N,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const y=Ta(d);return y&&a&&!l?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:a&&!y&&!l?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:l||{value:null,valueOwner:d,type:Te.External,inheritanceLink:null}}function Dx(d,u){return Zb(d.declaration,u)}function Jb(d,u){var v,T,R,A;if(u.execution&&u.execution.hasEntity(d)){const P=(v=u.lastExecutionResults)==null?void 0:v.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=or(d),a=d.parent.type===f.FunctionDeclaration&&d.parent.parent.type===f.Loop?d.parent:null,l=!!((T=u.execution)!=null&&T.hasEntity(i))||!!a&&!!((R=u.execution)!=null&&R.hasEntity(a));let p=null;if(d.defaultValue){const P=d.defaultValue;if(P.value===null&&P.autogeneration){const N=ph(P);P.metaSync({value:N},null)}p={value:P,valueOwner:d,type:P.value===null?Te.Empty:Te.DefaultValue,inheritanceLink:null}}if(!p||p.type===Te.DefaultValue){const P=(A=u.localTestValues)==null?void 0:A.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const t=Ta(d);let y=t&&l&&!p;return i.type===f.Loop&&l&&(y=!1),y?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:l&&!t&&!p?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:p||{value:null,valueOwner:d,type:Te.External,inheritanceLink:null}}function Wb(d,u){var T,R,A,P,N;if(u.execution&&u.execution.hasEntity(d)){const U=(T=u.lastExecutionResults)==null?void 0:T.readValue(d.id);if(U)return{value:U,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=or(d),a=!!((R=u.execution)!=null&&R.entities.length),l=(A=u.execution)==null?void 0:A.hasEntity(i),p=d.readsValue;let t=null;if(p){const U=(P=u.execution)==null?void 0:P.hasEntity(p);(!a||a&&U&&l||a&&!U&&!l)&&(t=$d(d,u))}if(!t&&d.defaultValue&&(t={value:d.defaultValue,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}),!t||t.type===Te.DefaultValue){const U=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(U)return{value:U,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const y=Ta(d);return y&&!t?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:!y&&!t?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:t}function Hb(d,u){var y,v,T,R,A;if(u.execution&&u.execution.hasEntity(d)){const P=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(P)return{value:P,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=or(d);if(ot.includes(i.type)){const P=il(i,u),N=$r(ie(d,u.project));if(P!=null&&P.value&&lr(P.value.value)){const U=P.value.value[N],K=et(d.getDataType(null),d,u.project);return K==null||K.metaSync({value:U},null),{value:K,valueOwner:d,type:P.type,inheritanceLink:{sources:[P],target:d}}}return null}const a=(v=u.execution)==null?void 0:v.hasEntity(i),l=((T=u.execution)==null?void 0:T.state)===Xb.Running;if((R=u.persistedExecutionResults)!=null&&R.values[d.id]&&!a&&!l){const P=(A=u.persistedExecutionResults)==null?void 0:A.readValue(d.id);if((P==null?void 0:P.value)!==null||(P==null?void 0:P.valueAsType)!==null)return{value:P,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const p=d.getDefaultValue();if(p&&(p.value!==null||p.valueAsType!==null))return{value:p,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null};const t=d.parent;if(!t)throw new Error(`Couldn't find the parent that generates the output ${d.id}`);switch(t.type){case f.VariableInstance:{const N=Ey(t,u);if(N&&N.value){const K=d.declaration;if(lr(N.value.value)){const k=N.value.value[K.name],J=et(d.declaration.dataType,d,u.project);return J==null||J.metaSync({value:k},null),{value:J,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:[N],target:d}}}}const U=et(d.declaration.dataType,d,u.project);return U==null||U.metaSync({value:null},null),{value:U,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:N?[N]:[],target:d}}}case f.VariableDeclaration:{const N=Ep(t,u);if(N&&N.value){const K=d.declaration;if(lr(N.value.value)){const k=N.value.value[K.name],J=et(d.declaration.dataType,d,u.project);return J==null||J.metaSync({value:k},null),{value:J,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:[N],target:d}}}}const U=et(d.declaration.dataType,d,u.project);return U==null||U.metaSync({value:null},null),{value:U,valueOwner:d,type:Te.Inherited,inheritanceLink:{sources:N?[N]:[],target:d}}}case f.Operation:{const P=t.outputs.map(U=>{var k,J;if((k=u.persistedExecutionResults)!=null&&k.values[U.id]){const se=(J=u.persistedExecutionResults)==null?void 0:J.values[U.id];if(se.value!==null||se.valueAsType!==null)return{value:se,valueOwner:U,type:Te.ExecutionResult,inheritanceLink:null}}const K=U.getDefaultValue();if(K&&(K.value!==null||K.valueAsType!==null))return{value:K,valueOwner:U,type:Te.DefaultValue,inheritanceLink:null}}).filter(U=>!!U),N=et(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:P.length?{sources:P,target:d}:null}}case f.FunctionCall:{const P=t.inputs.map(U=>Ty(U,u)).filter(U=>!!U),N=et(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:P.length?{sources:P,target:d}:null}}case f.Loop:{const P=t.inputs.map(U=>Ty(U,u)).filter(U=>!!U),N=et(d.declaration.dataType,d,u.project);return N==null||N.metaSync({value:null},null),{value:N,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:P.length?{sources:P,target:d}:null}}case f.Search:return{value:null,valueOwner:d,type:Te.QueuedAutocalculation,inheritanceLink:null}}return null}function Ox(d,u){var R,A;if(!ot.includes(d.parent.type)||!Mp(d))return null;if(((R=d.declaration)==null?void 0:R.type)===f.Property&&d.declaration.static)return il(d.declaration,u);const i=Tp(d,u);if(i&&i.type!==Te.Empty&&i.type!==Te.Missing)return i;const a=bi(d.parent),l=by(a,u),p=$r(ie(d,u.project)),t=et(d.getDataType(null),d,u.project),y=Ta(d),v=(A=l==null?void 0:l.value)==null?void 0:A.value;if(v&&lr(v)){let P=v[p];return v[p]===void 0&&(P=null),t==null||t.metaSync({value:P},null),y&&my(P)?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:{value:t,valueOwner:d,type:l.type,inheritanceLink:{sources:l?[l]:[],target:d}}}return y?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}}function Cx(d,u){var R,A,P,N,U;if(!ot.includes(d.parent.type)||!Mp(d))return null;if(((R=d.declaration)==null?void 0:R.type)===f.Property&&d.declaration.static)return il(d.declaration,u);const i=bi(d.parent),a=il(i,u),l=d.parent===i?d:i.inputs.find(K=>{var k,J;return((k=K.declaration)==null?void 0:k.id)===((J=d.declaration)==null?void 0:J.id)}),p=bp(l,u),t=$r(ie(d,u.project)),y=et(d.getDataType(null),d,u.project),v=Ta(d),T=(A=a==null?void 0:a.value)==null?void 0:A.value;if(((a==null?void 0:a.type)===Te.ExecutionResult||(a==null?void 0:a.type)===Te.Testing)&&T&&lr(T)){let K=T[t];return T[t]===void 0&&(K=null),y==null||y.metaSync({value:K},null),{value:y,valueOwner:d,type:a.type,inheritanceLink:{sources:a?[a]:[],target:d}}}if(p&&p.type!==Te.Empty&&p.type!==Te.Missing)return p;if(T&&lr(T)){let K=T[t];T[t]===void 0&&(K=null),y==null||y.metaSync({value:K},null);const k=v&&my(K),J=!!((P=u.execution)!=null&&P.entities.length),se=(N=u.execution)==null?void 0:N.hasEntity(i),te=i.readsValue;if(te){const ce=(U=u.execution)==null?void 0:U.hasEntity(te);if(k&&(!J||J&&ce&&se||J&&!ce&&!se))return{value:null,valueOwner:d,type:Te.Inherited,inheritanceLink:null}}return k?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:{value:y,valueOwner:d,type:a.type,inheritanceLink:{sources:a?[a]:[],target:d}}}return bp(d,u)}function Tp(d,u){var T,R,A,P,N;const i=or(d),a=!!((T=u.execution)!=null&&T.entities.length),l=(R=u.execution)==null?void 0:R.hasEntity(i),p=d.readsValue;let t=null;if(p){const U=(A=u.execution)==null?void 0:A.hasEntity(p);(!a||a&&U&&l||a&&!U&&!l)&&(t=$d(d,u))}if(!t&&d.defaultValue){const U=d.defaultValue;U&&(t={value:U,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null})}if(!t&&d.declaration){const U=il(d.declaration,u);U&&U.value&&(t={...U,valueOwner:d,type:Te.DefaultValue})}if(!t||t.type===Te.DefaultValue||(t==null?void 0:t.type)===Te.Empty){const U=(P=u.persistedExecutionResults)==null?void 0:P.readValue(d.id);if(U)return{value:U,valueOwner:d,type:Te.Testing,inheritanceLink:null};const K=(N=u.localTestValues)==null?void 0:N.readValue(d.id);if(K)return{value:K,valueOwner:d,type:Te.Testing,inheritanceLink:null}}const y=Ta(d);return y&&!t||(t==null?void 0:t.type)===Te.Empty?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:(t==null?void 0:t.inheritanceLink)||null}:!y&&(!t||t.type===Te.Inherited)&&!(t!=null&&t.inheritanceLink)?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:t}function bp(d,u){var l,p;if(u.execution&&u.execution.hasEntity(d)){const t=(l=u.lastExecutionResults)==null?void 0:l.readValue(d.id);if(t)return{value:t,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(p=u.localTestValues)==null?void 0:p.readValue(d.id);return i?{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null}:Tp(d,u)}function Ty(d,u){var i;return ot.includes(d.parent.type)&&(i=bi(d.parent).dataType)!=null&&i.isObject()?Ox(d,u):Tp(d,u)}function $x(d,u){var i;return ot.includes(d.parent.type)&&(i=bi(d.parent).dataType)!=null&&i.isObject()?Cx(d,u):bp(d,u)}function Px(d,u){var y,v;if(!d.static)return null;if(u.execution){const T=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(T)return{value:T,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(v=u.localTestValues)==null?void 0:v.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null};const a=d.getDefaultValue();let l=null;return a&&(l={value:a,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}),Ta(d)&&qb(l==null?void 0:l.value)?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:qb(l==null?void 0:l.value)?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:l}function Vx(d,u){var y,v,T,R,A,P;if(u.execution&&u.execution.hasEntity(d)){const N=(y=u.lastExecutionResults)==null?void 0:y.readValue(d.id);if(N)return{value:N,valueOwner:d,type:Te.ExecutionResult,inheritanceLink:null}}const i=(v=u.localTestValues)==null?void 0:v.readValue(d.id);if(i)return{value:i,valueOwner:d,type:Te.Testing,inheritanceLink:null};const a=d.getDefaultValue();let l=null;return a&&(l={value:a,valueOwner:d,type:Te.DefaultValue,inheritanceLink:null}),Ta(d)&&!((T=l==null?void 0:l.value)!=null&&T.value)&&!((R=l==null?void 0:l.value)!=null&&R.valueAsType)?{value:null,valueOwner:d,type:Te.Missing,inheritanceLink:null}:!((A=l==null?void 0:l.value)!=null&&A.value)&&!((P=l==null?void 0:l.value)!=null&&P.valueAsType)?{value:null,valueOwner:d,type:Te.Empty,inheritanceLink:null}:l}function il(d,u){switch(d.type){case f.ArgumentDeclaration:return Jb(d,u);case f.InputMap:return $x(d,u);case f.VariableDeclaration:return Zb(d,u);case f.VariableInstance:return Dx(d,u);case f.OutputMap:return Hb(d,u);case f.ReturnDeclaration:return Wb(d,u);case f.Property:return Px(d,u);case f.ValueDescriptor:return Vx(d,u);default:return null}}function by(d,u){switch(d.type){case f.InputMap:return Ty(d,u);case f.VariableDeclaration:return Ep(d,u);case f.VariableInstance:return Ey(d,u);case f.ReturnDeclaration:return Wb(d,u);default:return null}}function dme(d){var u;if(d&&d.type===Te.DefaultValue&&d.value&&d.valueOwner&&((u=d.valueOwner.defaultValue)==null?void 0:u.id)===d.value.id){const i=et(d.valueOwner.getDataType(null),d.valueOwner,d.valueOwner.project);return{type:Te.DefaultValue,value:i,valueOwner:d.valueOwner,inheritanceLink:null}}return d}function sl(d,u,i,a){let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=d.parent;return u.getVariableDeclarations().forEach(T=>{var A,P,N,U;const R=T.getDataType(null);if(((A=R==null?void 0:R.entity)==null?void 0:A.id)===y.id){let K=l?T.defaultValue:t==null?void 0:t.readValue(T.id);K?!l&&K&&K.id===((P=T.defaultValue)==null?void 0:P.id)&&(K=et(T.getDataType(null),T,u)):l?K=nn(T.getDataType(null),T,u,p):K=et(T.getDataType(null),T,u);const k=ie(d,u),J=$r(k);let se={};((U=(N=T.dataType)==null?void 0:N.entity)==null?void 0:U.type)===f.DefinitionEntity&&(se={...se,...T.dataType.entity.getActiveRawDefaultValue()}),lr(K==null?void 0:K.value)&&(se={...se,...K.value}),se[J]=i,K==null||K.metaSync({value:se},p),l||t==null||t.writeValue(T,K);return}}),p}function Ap(d,u,i,a){var N,U,K;let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=bi(d.parent),v=y.getDataType(null);if(!(v!=null&&v.isObject()))return p;let T=l?y.defaultValue:t==null?void 0:t.readValue(y.id);T?!l&&T&&T.id===((N=y.defaultValue)==null?void 0:N.id)&&(T=et(y.getDataType(null),y,u)):l?T=nn(y.getDataType(null),y,u,p):T=et(y.getDataType(null),y,u);const R=ie(d,u),A=$r(R);let P={};if(((K=(U=y.dataType)==null?void 0:U.entity)==null?void 0:K.type)===f.DefinitionEntity&&(P={...P,...y.dataType.entity.getActiveRawDefaultValue()}),lr(T==null?void 0:T.value)&&(P={...P,...T.value}),P[A]=i,T==null||T.metaSync({value:P},p),l||t==null||t.writeValue(y,T),(i===""||i===null||i===void 0)&&d.type===f.OutputMap){const k=y.inputs.find(J=>{var se;return((se=J.declaration)==null?void 0:se.id)===d.declaration.id||ie(J,u)===R});if(k){let J=l?k.defaultValue:t==null?void 0:t.readValue(k.id);J&&J.metaSync({value:null},p),l||t==null||t.removeValue(k.id)}}return p}function Nx(d,u,i){var t,y,v,T;let a=!1,l=null,p=null;if(i instanceof F?(a=!0,l=i,p=null):(l=null,p=i),ot.includes(d.type)){const R=bi(d);(t=R.dataType)!=null&&t.isObject()&&R.inputs.forEach(A=>{var P,N,U,K;if(((P=A.declaration)==null?void 0:P.type)===f.Property&&A.declaration.static){let k=a?d.defaultValue:p==null?void 0:p.readValue(A.declaration.id);k?!a&&k&&k.id===((N=A.declaration.defaultValue)==null?void 0:N.id)&&(k=et(A.declaration.getDataType(null),A.declaration,u)):a?k=nn(A.declaration.getDataType(null),A.declaration,u,l):k=et(A.declaration.getDataType(null),A.declaration,u),k==null||k.metaSync({value:null},l),a||p==null||p.removeValue((U=A.declaration)==null?void 0:U.id)}else if(((K=A.declaration)==null?void 0:K.type)===f.Property){let k=a?d.defaultValue:p==null?void 0:p.readValue(A.id);k&&k.metaSync({value:null},l),a||p==null||p.removeValue(A.id)}})}else d.type===f.InputMap?((y=d.declaration)==null?void 0:y.type)===f.Property&&d.declaration.static?sl(d.declaration,u,null,i):ot.includes(d.parent.type)&&((v=d.declaration)==null?void 0:v.type)===f.Property&&Ap(d,u,null,i):d.type===f.OutputMap?((T=d.declaration)==null?void 0:T.type)===f.Property&&d.declaration.static?sl(d.declaration,u,null,i):ot.includes(d.parent.type)&&d.declaration.type===f.Property&&Ap(d,u,null,i):d.type===f.Property&&d.static&&sl(d,u,null,i);return l}function Lx(d,u,i,a){var y,v,T,R,A,P;let l=!1,p=null,t=null;if(a instanceof F?(l=!0,p=a,t=null):(p=null,t=a),ot.includes(u.type)){const N=bi(u);if((y=N.dataType)!=null&&y.isObject()){let U={};((T=(v=N.dataType)==null?void 0:v.entity)==null?void 0:T.type)===f.DefinitionEntity&&(U={...U,...N.dataType.entity.getActiveRawDefaultValue()});const K=lr(d)?d:U;N.inputs.forEach(k=>{var J,se,te;if(((J=k.declaration)==null?void 0:J.type)===f.Property&&k.declaration.static){let ce=l?u.defaultValue:t==null?void 0:t.readValue(k.declaration.id);ce?!l&&ce&&ce.id===((se=k.declaration.defaultValue)==null?void 0:se.id)&&(ce=et(k.declaration.getDataType(null),k.declaration,i)):l?ce=nn(k.declaration.getDataType(null),k.declaration,i,p):ce=et(k.declaration.getDataType(null),k.declaration,i);const re=ie(k,i),fe=$r(re),z=K[fe];ce==null||ce.metaSync({value:z},p),l||t==null||t.writeValue(k.declaration,ce)}else if(((te=k.declaration)==null?void 0:te.type)===f.Property){let ce=l?u.defaultValue:t==null?void 0:t.readValue(k.id);ce&&ce.metaSync({value:null},p),l||t==null||t.removeValue(k.id)}})}}else u.type===f.InputMap?((R=u.declaration)==null?void 0:R.type)===f.Property&&u.declaration.static?sl(u.declaration,i,d,a):ot.includes(u.parent.type)&&((A=u.declaration)==null?void 0:A.type)===f.Property&&Ap(u,i,d,a):u.type===f.OutputMap?((P=u.declaration)==null?void 0:P.type)===f.Property&&u.declaration.static?sl(u.declaration,i,null,a):ot.includes(u.parent.type)&&u.declaration.type===f.Property&&Ap(u,i,null,a):u.type===f.Property&&u.static&&sl(u,i,d,a);return p}function Bx(d,u,i){const a=an(d,u);let l=!1,p=null,t=null;return i instanceof F?(l=!0,p=i,t=null):(p=null,t=i),a.forEach(y=>{var T;let v=l?y.defaultValue:t==null?void 0:t.readValue(y.id);v?!l&&v&&v.id===((T=y.defaultValue)==null?void 0:T.id)&&(v=et(d.getDataType(null),d,d.project)):l?v=nn(y.getDataType(null),y,u,p):v=et(y.getDataType(null),y,u),v==null||v.metaSync({value:null},p),l||t==null||t.removeValue(y.id),Nx(y,u,i)}),p}function ume(d,u,i,a){if(d===""||d===null||d===void 0)return Bx(u,i,a);const l=an(u,i);let p=!1,t=null,y=null;return a instanceof F?(p=!0,t=a,y=null):(t=null,y=a),l.forEach(v=>{var R;let T=p?u.defaultValue:y==null?void 0:y.readValue(u.id);T?!p&&T&&T.id===((R=v.defaultValue)==null?void 0:R.id)&&(T=et(v.getDataType(null),v,i)):p?T=nn(v.getDataType(null),v,i,t):T=et(v.getDataType(null),v,i),T==null||T.metaSync({value:d},t),p||y==null||y.writeValue(v,T),Lx(d,v,i,a)}),t}function nl(d,u,i,a){let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=d.parent;return u.getVariableDeclarations().forEach(T=>{var A,P,N,U;const R=T.getDataType(null);if(((A=R==null?void 0:R.entity)==null?void 0:A.id)===y.id){let K=l?T.defaultValue:t==null?void 0:t.readValue(T.id);K?!l&&K&&K.id===((P=T.defaultValue)==null?void 0:P.id)&&(K=et(T.getDataType(null),T,u)):l?K=nn(T.getDataType(null),T,u,p):K=et(T.getDataType(null),T,u);const k=ie(d,u),J=$r(k);let se={};((U=(N=T.dataType)==null?void 0:N.entity)==null?void 0:U.type)===f.DefinitionEntity&&(se={...se,...T.dataType.entity.getActiveRawDefaultValue()}),lr(K==null?void 0:K.value)&&(se={...se,...K.value}),Array.isArray(i)?se[J]=(i==null?void 0:i.map(te=>te.toShallowJSON()))||null:se[J]=(i==null?void 0:i.toShallowJSON())||null,K==null||K.metaSync({value:se},p),l||t==null||t.writeValue(T,K);return}}),p}function Ip(d,u,i,a){var N,U,K;let l=!1,p=null,t=null;a instanceof F?(l=!0,p=a,t=null):(p=null,t=a);const y=bi(d.parent),v=y.getDataType(null);if(!(v!=null&&v.isObject()))return p;let T=l?y.defaultValue:t==null?void 0:t.readValue(y.id);T?!l&&T&&T.id===((N=y.defaultValue)==null?void 0:N.id)&&(T=et(y.getDataType(null),y,u)):l?T=nn(y.getDataType(null),y,u,p):T=et(y.getDataType(null),y,u);const R=ie(d,u),A=$r(R);let P={};if(((K=(U=y.dataType)==null?void 0:U.entity)==null?void 0:K.type)===f.DefinitionEntity&&(P={...P,...y.dataType.entity.getActiveRawDefaultValue()}),lr(T==null?void 0:T.value)&&(P={...P,...T.value}),Array.isArray(i)?P[A]=(i==null?void 0:i.map(k=>k.toShallowJSON()))||null:P[A]=(i==null?void 0:i.toShallowJSON())||null,T==null||T.metaSync({value:P},p),l||t==null||t.writeValue(y,T),i==null&&d.type===f.OutputMap){const k=y.inputs.find(J=>{var se;return((se=J.declaration)==null?void 0:se.id)===d.declaration.id||ie(J,u)===R});if(k){let J=l?k.defaultValue:t==null?void 0:t.readValue(k.id);J&&(Array.isArray(i)?J==null||J.setValueAsTypeList(i,p):J==null||J.setValueAsTypeSingle(i,p)),l||t==null||t.removeValue(k.id)}}return p}function Mx(d,u,i){var a,l,p;return d.type===f.InputMap?((a=d.declaration)==null?void 0:a.type)===f.Property&&d.declaration.static?nl(d.declaration,u,null,i):ot.includes(d.parent.type)&&((l=d.declaration)==null?void 0:l.type)===f.Property&&Ip(d,u,null,i):d.type===f.OutputMap?((p=d.declaration)==null?void 0:p.type)===f.Property&&d.declaration.static?nl(d.declaration,u,null,i):ot.includes(d.parent.type)&&d.declaration.type===f.Property&&Ip(d,u,null,i):d.type===f.Property&&d.static&&nl(d,u,null,i),i}function Ux(d,u,i,a){var l,p,t;return u.type===f.InputMap?((l=u.declaration)==null?void 0:l.type)===f.Property&&u.declaration.static?nl(u.declaration,i,d,a):ot.includes(u.parent.type)&&((p=u.declaration)==null?void 0:p.type)===f.Property&&Ip(u,i,d,a):u.type===f.OutputMap?((t=u.declaration)==null?void 0:t.type)===f.Property&&u.declaration.static?nl(u.declaration,i,null,a):ot.includes(u.parent.type)&&u.declaration.type===f.Property&&Ip(u,i,null,a):u.type===f.Property&&u.static&&nl(u,i,d,a),a}function jx(d,u,i){const a=an(d,u);let l=!1,p=null,t=null;return i instanceof F?(l=!0,p=i,t=null):(p=null,t=i),a.forEach(y=>{var T;let v=l?y.defaultValue:t==null?void 0:t.readValue(y.id);v?!l&&v&&v.id===((T=y.defaultValue)==null?void 0:T.id)&&(v=et(y.getDataType(null),y,y.project)):l?v=nn(y.getDataType(null),y,u,p):v=et(y.getDataType(null),y,u),v==null||v.setValueAsTypeSingle(null,p),v==null||v.setValueAsTypeList(null,p),l||t==null||t.removeValue(y.id),Mx(y,u,i)}),p}function cme(d,u,i,a){if(d==null)return jx(u,i,a);const l=an(u,i);let p=!1,t=null,y=null;return a instanceof F?(p=!0,t=a,y=null):(t=null,y=a),l.forEach(v=>{var R;let T=p?v.defaultValue:y==null?void 0:y.readValue(v.id);T?!p&&T&&T.id===((R=v.defaultValue)==null?void 0:R.id)&&(T=et(v.getDataType(null),v,v.project)):p?T=nn(v.getDataType(null),v,i,t):T=et(v.getDataType(null),v,i),Array.isArray(d)?T==null||T.setValueAsTypeList(d,t):T==null||T.setValueAsTypeSingle(d,t),p||y==null||y.writeValue(v,T),Ux(d,v,i,a)}),t}var pme=Object.defineProperty,fme=(d,u,i)=>u in d?pme(d,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[u]=i,al=(d,u,i)=>(fme(d,typeof u!="symbol"?u+"":u,i),i);let hme=class{constructor(u){al(this,"eventName"),al(this,"callbacks",[]),this.eventName=u,this.on=this.on.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}on(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks.includes(u)||this.callbacks.push(u)}off(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(i=>i!==u)}destroy(){this.callbacks=[]}},wp=class{constructor(){al(this,"subscribedEvents",{}),al(this,"on",this._on),al(this,"emit",this._emit),al(this,"off",this._off),al(this,"destroy",this._destroy),this.getEvent=this.getEvent.bind(this),this._on=this._on.bind(this),this._emit=this._emit.bind(this),this._off=this._off.bind(this),this._destroy=this._destroy.bind(this),this.on=this.on.bind(this),this.emit=this.emit.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}getEvent(u){return this.subscribedEvents[u]||(this.subscribedEvents[u]=new hme(u)),this.subscribedEvents[u]}_on(u,i){this.getEvent(u).on(i)}_emit(u,...i){const a=this.getEvent(u);a&&a.callbacks.forEach(l=>{l.apply(null,i)})}_off(u,i){const a=this.getEvent(u);a&&(i?a.off(i):(a.destroy(),delete this.subscribedEvents[u]))}_destroy(){Object.keys(this.subscribedEvents).forEach(u=>{this._off(u)}),this.subscribedEvents={}}};var Ay=(d=>(d[d.High=1]="High",d[d.Normal=5]="Normal",d[d.Low=10]="Low",d))(Ay||{}),xx=(d=>(d.Logic="logic",d.GUI="gui",d.Editor="editor",d.Compile="compile",d))(xx||{}),Fx=(d=>(d.OnCompileBefore="on:compile:before:DefinitionEntity",d.OnCompileDefault="on:compile:default:DefinitionEntity",d.OnCompileAfter="on:compile:after:DefinitionEntity",d.EmitCompile="emit:compile:DefinitionEntity",d.DoEditorPublish="do:editor:publish",d.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",d.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",d.UpdateGUIGlobalTheme="update:gui:global:theme",d))(Fx||{}),Yb=(d=>(d.UUID="uuid",d.BuiltInFunctionImplementations="built-in-function-implementations",d.SearchNodeImplementation="search-node-implementation",d))(Yb||{});function yme(d){switch(d){case"uuid":return $u;case"built-in-function-implementations":return{[Li.AbortExecution]:async(u,i)=>({value:Je.Error,entity:u,error:null,results:[]}),[Li.SavePersistedEntity]:async(u,i)=>({value:Je.Error,entity:u,error:null,results:[]}),[Li.DeletePersistedEntity]:async(u,i)=>({value:Je.Error,entity:u,error:null,results:[]})};case"search-node-implementation":return{searchImplementation:async(u,i)=>({data:null,error:"Search module not implemented"})}}return null}const zb={requestModule:d=>{const u=yme(d);if(u)return u;throw new Error(`Module '${d}' is not available. Please register it before using.`)}};class mme{constructor(u=new wp){O(this,"extensions",new Map);this.events=u}get extensionInOrder(){return Array.from(this.extensions.values()).sort((u,i)=>(u.manifest.initPriority||Ay.Normal)-(i.manifest.initPriority||Ay.Normal))}requestContext(u){return null}requestModule(u){const i=this.extensions.get(u);if(i){if(i.module)return i.module;throw new Error(`Module ${u} is not registered properly.`)}throw new Error(`Unknown module: ${u}`)}register(u,i){this.extensions.set(u.id,{manifest:u,module:i})}async initAll(){for(const u of this.extensionInOrder)if(u.module.init){const i=u.manifest.contexts.map(a=>this.requestContext(a)).filter(a=>a!==null);i.length&&await u.module.init(i)}}async destroyAll(){for(const u of[...this.extensionInOrder].reverse())u.module.destroy&&await u.module.destroy();this.events.destroy()}on(u,i){this.events.on(u,i)}emit(u,...i){this.events.emit(u,...i)}off(u,i){this.events.off(u,i)}}const Qa={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var Xb=(d=>(d.FinishedSuccess="finished-success",d.FinishedError="finished-error",d.Running="running",d.Paused="paused",d.Stopped="stopped",d.NotStarted="not-started",d))(Xb||{});const Gx={...zb};class Bn extends wp{constructor(i,a,l,p=null,t=Gx){super();O(this,"project");O(this,"entryPoint");O(this,"state","not-started");O(this,"events",new wp);O(this,"entities",[]);O(this,"parentExecution",null);O(this,"executing",[]);O(this,"executed",[]);O(this,"skipped",[]);O(this,"scheduled",[]);O(this,"localTestValues");O(this,"resolvedValues");O(this,"persistedExecutionResults");O(this,"lastExecutionResults");O(this,"onAddToSkippedListCallback",null);O(this,"onRemoveFromSkippedListCallback",null);O(this,"onAddEntityCallback",null);O(this,"onRemoveEntityCallback",null);this.parentContext=t,this.entities=a,this.entryPoint=l,this.project=i,this.parentExecution=p,this.localTestValues=new mp(V.UUID.uuid(),this.project),this.resolvedValues=new mp(V.UUID.uuid(),this.project),this.persistedExecutionResults=new mp(V.UUID.uuid(),this.project),this.lastExecutionResults=new mp(V.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults}}skip(i){this.hasEntity(i)&&(this.skipped.includes(i)||(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Ps.includes(i.type)&&[...i.successCalls||[],...i.errorCalls||[],...i.calls||[]].forEach(a=>this.skip(a))))}async schedule(i,a,l){if(this.hasExecuted(i))return null;if(tr.includes(i.type))return this.executeBranch(i,l,a);if($s.includes(i.type)){if(i.calledBy.every(t=>this.hasExecuted(t)||!this.hasEntity(t)))return this.executeBranch(i,l,a);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,a){const l=[];return[...nr,...tr].includes(a.type)?l.push(...a.inputs):pr.includes(a.type)&&l.push(...a.outputs),l.map(t=>{var v;let y=i.find(T=>T.valueOwner.id===t.id);if(y)return y;if(!y&&tr.includes(a.type)&&(y=i.find(T=>{var R;return((R=T.valueOwner.declaration)==null?void 0:R.id)===t.id})),y){const T=(v=y.value)==null?void 0:v.clone(null);return T==null||T.setStandaloneParent(t),{...y,valueOwner:t,value:T||null,inheritanceLink:{sources:[y],target:t}}}return Tn.includes(t.type)?by(t,this.valueResolutionContext):il(t,this.valueResolutionContext)}).reduce((t,y)=>{const v=an(y==null?void 0:y.valueOwner,this.project),T=y?[y]:[];return v.forEach(R=>{var N,U,K;if(R.id===(y==null?void 0:y.valueOwner.id))return;const A=et(R.getDataType(null),R,this.project);A==null||A.metaSync({value:(N=y==null?void 0:y.value)==null?void 0:N.value},null),A==null||A.setValueAsTypeList(((U=y==null?void 0:y.value)==null?void 0:U.valueAsTypeList)||null),A==null||A.setValueAsTypeSingle(((K=y==null?void 0:y.value)==null?void 0:K.valueAsTypeSingle)||null);const P={...y,valueOwner:R,value:A};T.push(P)}),[...t,...T]},[]).sort((t,y)=>t.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,a,l,p={}){var y,v;const t={...Qa,...p};try{let T={value:Je.Success,error:null,results:[]};if(a.sort((R,A)=>R.valueOwner.index-A.valueOwner.index),Object.values(Li).includes(i.declaration.id)){const R=this.parentContext.requestModule(Yb.BuiltInFunctionImplementations)[i.declaration.id];R?T=await R(i,a):Fe.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{T=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,a,l,t);const R=i.outputs.map(P=>{var J,se,te,ce;const N=[...P.declaration.getCounterparts(),P.declaration],U=T.results.find(re=>N.some(z=>re.valueOwner.id===z.id)),K=P==null?void 0:P.getDataType(null),k=et(K,P,l);return K!=null&&K.asType?Array.isArray((J=U==null?void 0:U.value)==null?void 0:J.valueAsType)?k==null||k.setValueAsTypeList((se=U==null?void 0:U.value)==null?void 0:se.valueAsTypeList):k==null||k.setValueAsTypeSingle(((te=U==null?void 0:U.value)==null?void 0:te.valueAsType)||null):k==null||k.metaSync({value:(ce=U==null?void 0:U.value)==null?void 0:ce.value},null),{valueOwner:P,type:Te.ExecutionResult,inheritanceLink:null,value:k}});let A=null;if(T.error){Fe.warn("Raw error executing entity: ",T.error);const P=(y=i.error)==null?void 0:y.getDataType(null),N=et(P||null,i.error,l);P!=null&&P.asType?N==null||N.setValueAsTypeSingle(T.error):N==null||N.metaSync({value:T.error},null),A={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:N}}return{value:T.value,entity:i,error:A,results:R}}return{...T,entity:i}}catch(T){Fe.warn("Operation execution error: ",T);let R=null;if(i.error){const A=(v=i.error)==null?void 0:v.getDataType(null),P=et(A,i.error,l);A!=null&&A.asType?P==null||P.setValueAsTypeSingle(T):P==null||P.metaSync({value:T},null),R={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:P}}return{value:Je.Error,entity:i,error:R,results:[]}}}static async executeOperation(i,a,l){var p,t;try{let y={value:Je.Success,error:null,results:[]};a.sort((R,A)=>R.valueOwner.index-A.valueOwner.index),i.declaration.implementation&&(y=await i.declaration.implementation(i,a));const v=i.outputs.map((R,A)=>{const P=R==null?void 0:R.getDataType(null),N=et(P,R,l);return P!=null&&P.asType?N==null||N.setValueAsTypeSingle(y.results[A]):N==null||N.metaSync({value:y.results[A]},null),{valueOwner:R,type:Te.ExecutionResult,inheritanceLink:null,value:N}});let T=null;if(y.error&&i.error){Fe.warn("Raw error executing entity: ",y.error);const R=((p=i.error)==null?void 0:p.getDataType(null))||null,A=et(R,i.error,l);R!=null&&R.asType?A==null||A.setValueAsTypeSingle(y.error):A==null||A.metaSync({value:y.error},null),T={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:A}}return{value:y.value,entity:i,error:T,results:v}}catch(y){Fe.warn("Operation execution error: ",y);let v=null;if(i.error){const T=(t=i.error)==null?void 0:t.getDataType(null),R=et(T,i.error,l);T!=null&&T.asType?R==null||R.setValueAsTypeSingle(y):R==null||R.metaSync({value:y},null),v={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:R}}return{value:Je.Error,entity:i,error:v,results:[]}}}async executeSearch(i,a,l){var p;try{let t={value:Je.Success,error:null,results:[]};const y=i.outputs[0];if(!y)return{value:Je.Success,entity:i,error:null,results:[]};let v={value:null,valueOwner:y,type:Te.ExecutionResult,inheritanceLink:null};const T=await this.parentContext.requestModule(Yb.SearchNodeImplementation).searchImplementation(i,a),R=y==null?void 0:y.getDataType(null),A=et(R,y,l);return A==null||A.metaSync({value:T.data},null),v.value=A,{value:t.value,entity:i,error:null,results:[v]}}catch(t){if(Fe.warn(`Search node execution error: ${t}`),!i.error)return{value:Je.Error,entity:i,error:null,results:[]};const y=(p=i.error)==null?void 0:p.getDataType(null),v=et(y,i.error,l);return v==null||v.metaSync({value:t},null),{value:Je.Error,entity:i,error:{valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:v},results:[]}}}async executeLoop(i,a,l,p={}){var y,v;const t={...Qa,...p};try{let T={value:Je.Success,error:null,results:[]};const R=a.map(k=>{var J,se;return((J=k==null?void 0:k.value)==null?void 0:J.valueAsType)||((se=k==null?void 0:k.value)==null?void 0:se.value)});let A={};i.getUniqueReturnDeclarations().forEach(k=>{const J=i.body.inputs.find(re=>ie(re,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(k)),se=k==null?void 0:k.getDataType(null),te=et(se,J,l);se!=null&&se.asType?te==null||te.setValueAsTypeList([]):te==null||te.metaSync({value:[]},null),this.lastExecutionResults.writeValue(J,te);const ce={value:te,valueOwner:J,type:Te.ExecutionResult,inheritanceLink:null};A[J.id]=ce});let N={value:Je.Success,entity:i.body,error:null,results:[]};switch(i.declaration.id){case ve.loop["counted-loop"].id:{const k=R[0];let J=1;for(;J<=k&&J<=50;){const se=i.body.inputs.map(ce=>{if(ce===i.currentIterationNumberArgumentDeclaration){const re=i.currentIterationNumberArgumentDeclaration.getDataType(null),fe=rl(re),z=this.lastExecutionResults.readValue(ce.id);if(z){z.metaSync({value:J},null),this.lastExecutionResults.writeValue(ce,z);const ae={value:z,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null};return A[ce.id]=ae,ae}const Y={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:J,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:fe,standaloneParent:ce.toReference()},ue=zt(Y,l);this.lastExecutionResults.writeValue(ce,ue);const H={value:ue,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null};return A[ce.id]=H,H}else return A[ce.id]}).filter(ce=>!!ce),te=await this.executeFullFunctionDeclarationLogic(i.body,se,t);if(N=te,N.results.forEach(ce=>{var Y,ue,H,ae;if(ce.valueOwner.type!==f.ReturnDeclaration)return;const re=i.body.inputs.find(be=>ie(be,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(ce.valueOwner)),z=[...((ue=(Y=A==null?void 0:A[re.id])==null?void 0:Y.value)==null?void 0:ue.value)||[],((H=ce==null?void 0:ce.value)==null?void 0:H.value)||null];(ae=A[re.id].value)==null||ae.metaSync({value:z},null),this.lastExecutionResults.writeValue(re,A[re.id].value)}),[Je.Error,Je.Break,Je.Return].includes(te.value))break;J++}break}case ve.loop["manual-flow-loop"].id:{let k=1;for(;k<=50;){const J=i.body.inputs.map(te=>{if(te===i.currentIterationNumberArgumentDeclaration){const ce=this.lastExecutionResults.readValue(te.id);if(ce){ce.metaSync({value:k},null),this.lastExecutionResults.writeValue(te,ce);const Y={value:ce,valueOwner:te,type:Te.ExecutionResult,inheritanceLink:null};return A[te.id]=Y,Y}const re=i.currentIterationNumberArgumentDeclaration.getDataType(null),fe=et(re,te,l);return fe==null||fe.metaSync({value:k},null),this.lastExecutionResults.writeValue(te,fe),{value:fe,valueOwner:te,type:Te.ExecutionResult,inheritanceLink:null}}else return A[te.id]}).filter(te=>!!te),se=await this.executeFullFunctionDeclarationLogic(i.body,J,t);if(N=se,N.results.forEach(te=>{var z,Y,ue;if(te.valueOwner.type!==f.ReturnDeclaration)return;const ce=i.body.inputs.find(H=>ie(H,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(te.valueOwner)),fe=[...(z=A[ce.id].value)==null?void 0:z.value,((Y=te.value)==null?void 0:Y.value)||null];(ue=A[ce.id].value)==null||ue.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ce,A[ce.id].value)}),[Je.Error,Je.Break,Je.Return].includes(se.value))break;k++}break}case ve.loop["list-loop"].id:{const k=R[0];let J=1;const se=k;for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}case ve.loop["object-keys-loop"].id:{const k=R[0];let J=1;const se=k?Object.keys(k):[];for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}case ve.loop["object-values-loop"].id:{const k=R[0];let J=1;const se=k?Object.values(k):[];for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}case ve.loop["string-loop"].id:{const k=R[0];let J=1;const se=k.split("");for(let te=0;te<se.length;te++){const ce=se[te],re=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const Y=this.lastExecutionResults.readValue(z.id);if(Y)return Y.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,Y),{value:Y,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ue=i.currentIterationNumberArgumentDeclaration.getDataType(null),H=et(ue,z,l);return H==null||H.metaSync({value:J},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const Y=i.currentValueArgumentDeclaration.getDataType(null),ue=rl(Y),H=this.lastExecutionResults.readValue(z.id);if(H)return H.metaSync({value:ce},null),this.lastExecutionResults.writeValue(z,H),{value:H,valueOwner:z,type:Te.ExecutionResult,inheritanceLink:null};const ae={id:V.UUID.uuid(),type:f.LiteralValue,autogeneration:null,version:V.UUID.uuid(),createdAt:new Date().toISOString(),author:V.sessionAuthor,deleted:!1,previousVersion:null,value:ce,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:z.toReference()},be=zt(ae,l);return this.lastExecutionResults.writeValue(z,be),{value:be,valueOwner:i.currentValueArgumentDeclaration,type:Te.ExecutionResult,inheritanceLink:null}}else return A[z.id]}).filter(z=>!!z),fe=await this.executeFullFunctionDeclarationLogic(i.body,re,t);if(N=fe,N.results.forEach(z=>{var ae,be,Be;if(z.valueOwner.type!==f.ReturnDeclaration)return;const Y=i.body.inputs.find(Oe=>ie(Oe,l)===Oi.fromReturnDeclarationToBodyArgumentDeclarationName(z.valueOwner)),H=[...(ae=A[Y.id].value)==null?void 0:ae.value,((be=z.value)==null?void 0:be.value)||null];(Be=A[Y.id].value)==null||Be.metaSync({value:H},null),this.lastExecutionResults.writeValue(Y,A[Y.id].value)}),[Je.Error,Je.Break,Je.Return].includes(fe.value))break;J++}break}}let U=[];i.body.inputs.forEach(k=>{var se;const J=A[k.id];if(J){const te=(se=J.value)==null?void 0:se.clone(null),ce=i.outputs.find(re=>re.declaration&&Oi.fromLoopOutputDeclarationToBodyArgumentDeclarationName(re.declaration)===ie(k,l));if(!ce)return;U.push({valueOwner:ce,type:Te.ExecutionResult,inheritanceLink:null,value:te})}}),T={value:[Je.Error,Je.Return].includes(N.value)?N.value:Je.Success,error:null,results:U};let K=null;if(T.error&&i.error){Fe.warn("Raw error executing entity: ",T.error);const k=(y=i.error)==null?void 0:y.getDataType(null),J=et(k||null,i.error,l);k!=null&&k.asType?J==null||J.setValueAsTypeSingle(T.error):J==null||J.metaSync({value:T.error},null),K={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:J}}return{value:T.value,entity:i,error:K,results:T.results}}catch(T){if(Fe.warn("Error executing loop: ",T),i.error){const R=(v=i.error)==null?void 0:v.getDataType(null),A=et(R,i.error,l);return R!=null&&R.asType?A==null||A.setValueAsTypeSingle(T):A==null||A.metaSync({value:T},null),{value:Je.Error,entity:i,error:{valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:A},results:[]}}else return{value:Je.Error,entity:i,error:null,results:[]}}}async executeFunctionCall(i,a,l,p={}){var y,v;const t={...Qa,...p};try{let T={value:Je.Success,error:null,results:[]};T=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,a,l,t);const R=i.outputs.map(P=>{var J,se,te,ce;const N=[...P.declaration.getCounterparts(),P.declaration],U=T.results.find(re=>N.some(z=>re.valueOwner.id===z.id)),K=P==null?void 0:P.getDataType(null),k=et(K,P,l);return K!=null&&K.asType?Array.isArray((J=U==null?void 0:U.value)==null?void 0:J.valueAsType)?k==null||k.setValueAsTypeList((se=U==null?void 0:U.value)==null?void 0:se.valueAsTypeList):k==null||k.setValueAsTypeSingle(((te=U==null?void 0:U.value)==null?void 0:te.valueAsType)||null):k==null||k.metaSync({value:(ce=U==null?void 0:U.value)==null?void 0:ce.value},null),{valueOwner:P,type:Te.ExecutionResult,inheritanceLink:null,value:k}});let A=null;if(T.error&&i.error){Fe.warn("Raw error executing entity: ",T.error);const P=(y=i.error)==null?void 0:y.getDataType(null),N=et(P||null,i.error,l);P!=null&&P.asType?N==null||N.setValueAsTypeSingle(T.error):N==null||N.metaSync({value:T.error},null),A={valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:N}}return{value:T.value,entity:i,error:A,results:R}}catch(T){if(!i.error)return{value:Je.Error,entity:i,error:null,results:[]};const R=(v=i.error)==null?void 0:v.getDataType(null),A=et(R,i.error,l);return R!=null&&R.asType?A==null||A.setValueAsTypeSingle(T):A==null||A.metaSync({value:T},null),{value:Je.Error,entity:i,error:{valueOwner:i.error,type:Te.ExecutionResult,inheritanceLink:null,value:A},results:[]}}}static async executeCondition(i,a){var p,t,y,v,T,R,A,P,N,U,K,k,J,se,te,ce,re,fe,z,Y,ue,H,ae,be,Be,Oe,_e,De,Ke,Me,Qe,yt,Qt,fr,Pr,Zr;let l=!1;switch(i.declaration.id){case kr.Empty:{l=!((t=(p=a[0])==null?void 0:p.value)!=null&&t.value);break}case kr.NotEmpty:{l=!!((v=(y=a[0])==null?void 0:y.value)!=null&&v.value);break}case vr.Equal:{if([X.String,X.Number,X.Boolean,X.Null,X.Enum,X.Date,X.UUID].includes((R=(T=a[0])==null?void 0:T.value)==null?void 0:R.name)){l=((P=(A=a[0])==null?void 0:A.value)==null?void 0:P.value)===((U=(N=a[1])==null?void 0:N.value)==null?void 0:U.value);break}if(((k=(K=a[0])==null?void 0:K.value)==null?void 0:k.name)===X.KeyValue||((se=(J=a[0])==null?void 0:J.value)==null?void 0:se.name)===X.Untyped){const Xr=(ce=(te=a[0])==null?void 0:te.value)==null?void 0:ce.value,Si=(fe=(re=a[1])==null?void 0:re.value)==null?void 0:fe.value;l=JSON.stringify(Xr)===JSON.stringify(Si);break}break}case vr.NotEqual:{if([X.String,X.Number,X.Boolean,X.Null,X.Enum,X.Date,X.UUID].includes((Y=(z=a[0])==null?void 0:z.value)==null?void 0:Y.name)){l=((H=(ue=a[0])==null?void 0:ue.value)==null?void 0:H.value)!==((be=(ae=a[1])==null?void 0:ae.value)==null?void 0:be.value);break}if(((Oe=(Be=a[0])==null?void 0:Be.value)==null?void 0:Oe.name)===X.Untyped||((De=(_e=a[0])==null?void 0:_e.value)==null?void 0:De.name)===X.KeyValue){const Xr=(Me=(Ke=a[0])==null?void 0:Ke.value)==null?void 0:Me.value,Si=(yt=(Qe=a[1])==null?void 0:Qe.value)==null?void 0:yt.value;l=JSON.stringify(Xr)!==JSON.stringify(Si);break}break}case vr.MoreThanOrEqual:{l=((fr=(Qt=a[0])==null?void 0:Qt.value)==null?void 0:fr.value)>=((Zr=(Pr=a[1])==null?void 0:Pr.value)==null?void 0:Zr.value);break}}return{value:l?Je.Success:Je.Error,entity:i,error:null,results:[]}}async executeDetachedFullFunctionDeclarationLogic(i,a,l,p={}){const t={...Qa,...p,onBeforeEntityExecution:(T,R,A)=>{var P;return((P=p==null?void 0:p.onBeforeEntityExecution)==null?void 0:P.call(p,T,R,{...A,detached:!0}))||Promise.resolve()},onEntityExecuted:(T,R,A)=>{var P;return((P=p==null?void 0:p.onEntityExecuted)==null?void 0:P.call(p,T,R,{...A,detached:!0}))||Promise.resolve()}},y=new Bn(l,[i,...Sy(i)],i,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(t,a)}async executeFullFunctionDeclarationLogic(i,a,l={}){const p={...Qa,...l},t=Sy(i);t.forEach(A=>{this.addEntity(A)}),t.reduce((A,P)=>pr.includes(P.type)?[...A,...P.outputs]:nr.includes(P.type)&&P.type!==f.Condition?[...A,...P.outputs,...P.inputs]:P.type===f.Condition?[...A,...P.inputs]:A,[]).forEach(A=>{this.lastExecutionResults.removeValue(A.id)});const v=await this.executeBranch(i,p,a),R=i.getUniqueReturnDeclarations().reduce((A,P)=>{const N=v==null?void 0:v.results.find(U=>U.valueOwner.id===P.id);return N?[...A,N]:A},[]);return{...v||{},value:(v==null?void 0:v.value)||Je.Success,entity:i,error:(v==null?void 0:v.error)||null,results:R}}static async executeEntryPointEntity(i,a){return{value:Je.Success,entity:i,error:null,results:a}}static async executeVariable(i,a){return{value:Je.Success,entity:i,error:null,results:[a]}}static async executeReturnStatement(i,a){return{value:i.throws?Je.Error:Je.Return,entity:i,error:null,results:a}}static async executeContinueStatement(i,a){return{value:Je.Continue,entity:i,error:null,results:a}}static async executeBreakStatement(i,a){return{value:Je.Break,entity:i,error:null,results:a}}mergeValues(i,a){const l=[];for(let p=0;p<a.length;p++)i!=null&&i[p]?l.push(i[p]):l.push(a[p]);return l}async executeEntity(i,a=[],l={}){var y,v,T,R,A,P,N,U,K,k,J,se,te,ce,re,fe,z;const p={...Qa,...l},t={detached:!1};switch(i.type){case f.Condition:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((y=p.onBeforeEntityExecution)==null?void 0:y.call(p,i,Y,t)),Bn.executeCondition(i,Y)}case f.InternalCall:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((v=p.onBeforeEntityExecution)==null?void 0:v.call(p,i,Y,t)),this.executeInternalCall(i,Y,this.project)}case f.Operation:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((T=p.onBeforeEntityExecution)==null?void 0:T.call(p,i,Y,t)),Bn.executeOperation(i,Y,this.project)}case f.VariableInstance:case f.VariableDeclaration:{let Y=by(i,this.valueResolutionContext);const ue=bi(i),H=ue.getDataType(null);if(H!=null&&H.isObject()){let Be={};if(((R=H==null?void 0:H.entity)==null?void 0:R.type)===f.DefinitionEntity&&(Be={...Be,...H.entity.getActiveRawDefaultValue()}),Y!=null&&Y.value)lr((A=Y==null?void 0:Y.value)==null?void 0:A.value)&&(Be={...Be,...(P=Y==null?void 0:Y.value)==null?void 0:P.value}),Y==null||Y.value.metaSync({value:Be},null);else{const Oe=et(H,i,this.project);Oe==null||Oe.metaSync({value:Be},null),Y={valueOwner:ue,type:Te.ExecutionResult,inheritanceLink:null,value:Oe}}this.lastExecutionResults.writeValue(ue,Y.value),ue.inputs.forEach(Oe=>{var _e;if(((_e=Oe.declaration)==null?void 0:_e.type)===f.Property&&Oe.declaration.static){const De=this.lastExecutionResults.readValue(Oe.declaration.id),Ke=ie(Oe,this.project),Me=$r(Ke);if(De)De.metaSync({value:Be[Me]},null),this.lastExecutionResults.writeValue(Oe.declaration,De);else{const Qe=et(Oe.getDataType(null),Oe,this.project);Qe==null||Qe.metaSync({value:Be[Me]},null),this.lastExecutionResults.writeValue(Oe.declaration,Qe)}}})}else this.lastExecutionResults.writeValue(ue,Y==null?void 0:Y.value);const ae=[],be=(N=Y==null?void 0:Y.value)!=null&&N.value&&lr((U=Y.value)==null?void 0:U.value)?((K=Y.value)==null?void 0:K.value)||{}:{};return i.outputs.map(Be=>{const Oe=$r(ie(Be,this.project)),_e=be[Oe],De=et(Be.getDataType(null),Be,this.project);De==null||De.metaSync({value:_e},null);const Ke={value:De,valueOwner:Be,type:Te.ExecutionResult,inheritanceLink:Y?{sources:[Y],target:i}:null};ae.push(Ke)}),Y.type=Te.ExecutionResult,{value:Je.Success,entity:i,error:null,results:[Y,...ae]}}case f.FunctionCall:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((k=p.onBeforeEntityExecution)==null?void 0:k.call(p,i,Y,t)),this.executeFunctionCall(i,Y,this.project)}case f.FunctionDeclaration:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((J=p.onBeforeEntityExecution)==null?void 0:J.call(p,i,Y,t)),Bn.executeEntryPointEntity(i,Y)}case f.Search:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((se=p.onBeforeEntityExecution)==null?void 0:se.call(p,i,Y,t)),this.executeSearch(i,Y,this.project)}case f.Loop:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((te=p.onBeforeEntityExecution)==null?void 0:te.call(p,i,Y,t)),this.executeLoop(i,Y,this.project,p)}case f.ReturnStatement:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((ce=p.onBeforeEntityExecution)==null?void 0:ce.call(p,i,Y,t)),Bn.executeReturnStatement(i,Y)}case f.ContinueStatement:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((re=p.onBeforeEntityExecution)==null?void 0:re.call(p,i,Y,t)),Bn.executeContinueStatement(i,Y)}case f.BreakStatement:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((fe=p.onBeforeEntityExecution)==null?void 0:fe.call(p,i,Y,t)),Bn.executeBreakStatement(i,Y)}case f.GlobalEvent:{const Y=this.mergeExernalValuesWithInternalInputs(a,i);return await((z=p.onBeforeEntityExecution)==null?void 0:z.call(p,i,Y,t)),Bn.executeEntryPointEntity(i,Y)}default:return{value:Je.Error,entity:i,error:null,results:[]}}}storeLastExecutionValues(i){i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),i.results.forEach(a=>{const l=an(a.valueOwner,this.project);a.value?l.forEach(p=>{this.lastExecutionResults.writeValue(p,a.value)}):l.forEach(p=>{this.lastExecutionResults.removeValue(p.id)})})}async executeBranch(i,a={},l=[]){var T;const p={...Qa,...a},t={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const v=await this.executeEntity(i,l,p);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(v),await((T=p.onEntityExecuted)==null?void 0:T.call(p,i,v,t)),v.value===Je.Success){const R=(i.successCalls||i.calls||[]).filter(K=>this.hasEntity(K));(i.errorCalls||[]).forEach(K=>{this.skip(K)});let P=[];const N=(await Promise.all(R.map(K=>this.schedule(K,v.results,p)))).filter(K=>!!K),U=N.filter(K=>!!K).find(K=>K.value===Je.Error||K.value===Je.Return||K.value===Je.Break||K.value===Je.Continue);return U||(P=[...P,...N],v)}else if(v.value===Je.Error){const R=(i.errorCalls||[]).filter(K=>this.hasEntity(K));(i.successCalls||i.calls||[]).forEach(K=>{this.skip(K)});let P=[];const N=(await Promise.all(R.map(K=>this.schedule(K,v.results,p)))).filter(K=>!!K),U=N.filter(K=>!!K).find(K=>K.value===Je.Error||K.value===Je.Return||K.value===Je.Break||K.value===Je.Continue);return U||(P=[...P,...N],v)}else{if(v.value===Je.Return)return v;if(v.value===Je.Break)return v;if(v.value===Je.Continue)return v}return v}async execute(i={},a=[]){const l={...Qa,...i};this.state="running";const p=await this.executeBranch(this.entryPoint,l,a);return this.state="finished-success",p}addEntity(i){var a;this.entities.includes(i)||(this.entities.push(i),(a=this.onAddEntityCallback)==null||a.call(this,i))}addEntities(i){i.forEach(a=>this.addEntity(a))}removeEntity(i){var a;if(i!==this.entryPoint){const l=this.entities.indexOf(i);l>-1&&(this.entities.splice(l,1),(a=this.onRemoveEntityCallback)==null||a.call(this,i))}}hasEntity(i){var p,t,y;if(this.entities.includes(i))return!0;if(((p=i.parent)==null?void 0:p.type)===f.FunctionDeclaration&&((y=(t=i.parent)==null?void 0:t.parent)==null?void 0:y.type)===f.DefinitionEntity)return this.entities.includes(i.parent);const a=or(i);if(!a)return!1;const l=a.type===f.Loop&&i.parent===a.body?a.body:null;return l?this.entities.includes(l)||this.entities.includes(a):this.entities.includes(a)}removeScheduled(i){const a=this.scheduled.indexOf(i);a>-1&&this.scheduled.splice(a,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const a=this.project.get(i);return a?this.hasEntity(a):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}removeFromExecutingList(i){const a=this.executing.indexOf(i);a>-1&&this.executing.splice(a,1)}removeFromAlreadyExecutedList(i){const a=this.executed.indexOf(i);a>-1&&this.executed.splice(a,1)}removeFromSkippedList(i){var l;const a=this.skipped.indexOf(i);a>-1&&(this.skipped.splice(a,1),(l=this.onRemoveFromSkippedListCallback)==null||l.call(this,i))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var a;this.skipped.includes(i)||(this.skipped.push(i),(a=this.onAddToSkippedListCallback)==null||a.call(this,i))}}function vme(d){var u,i;if(d.isList)return"list";if(((u=d.entity)==null?void 0:u.type)===f.DefinitionEntity)return"definition-entity";switch((i=d.entity)==null?void 0:i.name){case X.Number:return"number";case X.String:return"text";case X.Boolean:return"boolean";case X.UUID:return"uuid";case X.Date:return"date-time";default:return"definition-entity"}}const Qb={[f.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[f.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[f.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[f.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[f.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[f.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[f.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[f.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[f.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[f.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[f.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[f.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[f.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[f.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[f.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[f.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[f.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[f.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[f.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[f.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[f.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[f.ReturnDeclaration]:{singular:"Output definition",plural:"Output definitions",shortSingular:"Output",shortPlural:"Outputs"},[f.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"}};function eA(d){const u=qy(d);if(!u){const a=Md(d);if(a.includes(Ve.HTTP_ENDPOINT))return"HTTP endpoint";if(a.includes(Ve.PERSISTED_ENTITY))return"Persisted entity";if(a.includes(Ve.CRON_JOB))return"Scheduled execution";if(a.includes(Ve.RELATIONAL_DATABASE))return"Relational database"}if(u){let a="Extension of "+ie(u,u.project)+" entity",l=dd(a);const p=Md(d);return p.includes(Ve.HTTP_ENDPOINT)?"HTTP endpoint"+(l?", "+l:""):p.includes(Ve.PERSISTED_ENTITY)?"Persisted entity"+(l?", "+l:""):p.includes(Ve.CRON_JOB)?"Scheduled execution"+(l?", "+l:""):p.includes(Ve.RELATIONAL_DATABASE)?"Relational database"+(l?", "+l:""):a}let i="";return d.abstract&&(i="Template "),d.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function Kx(d){return d.parent.type===f.DefinitionEntity||d.parent.type===f.InstalledProject?"Internal action of "+ie(d.parent,d.project):d.parent.type===f.Loop?"Action repeated on every iteration":"Internal action of entity"}function tA(d){return MA(d)?Kx(d):"Custom trigger"}function Eme(d){var u;switch(d.type){case f.DefinitionEntity:return eA(d);case f.FunctionDeclaration:return tA(d)}return(u=Qb[d.type])==null?void 0:u.singular}function Tme(d){var u;switch(d.type){case f.DefinitionEntity:return eA(d);case f.FunctionDeclaration:return tA(d)}return(u=Qb[d.type])==null?void 0:u.singular}const rA=4e4,kx=280,bme=300,iA=65,Pd=32,Iy=39,Sx=26,qx=49,wy=44,Ame=35,Ry=52,sA=10,ba=sA*2,gy=38,_y=90,nA=270,Zx=rA/2+120,Jx=rA/2+180;function Wx(d){let i=Pd+wy+gy+sA;const a=[...d.inputs];return a.length&&(i+=ba,a.forEach(()=>{i+=Sx})),{height:i,width:280}}function Hx(d){let i=iA;const a=[];if([f.DefinitionEntity].includes(d.type)){const v=[...d.suggestedProperties||[],...d.properties||[]];v.length&&(i+=ba,v.forEach(T=>{i+=T.static?qx:Iy}))}if([f.DefinitionEntity,f.InstalledProject,f.Loop].includes(d.type)){const v=[...(d==null?void 0:d.suggestedMethods)||[],...d.methods||[],...d.functions||[],...d.body?[d.body]:[]];v.length&&(i+=ba,v.forEach(T=>{const R=Wx(T);i+=R.height}))}nr.includes(d.type)?(ot.includes(d.type)?a.push(...(d.usedInputs||[]).flatMap(v=>[v])||[]):a.push(...(d.inputs||[]).flatMap(v=>[v])||[]),d.error&&(i+=Ry)):[f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)?(a.push(...d.outputs||[]),d.throws&&(i+=Ry)):d.type===f.Condition&&(a.push(d.inputs[0]),d.inputs[1]&&a.push(d.inputs[1]));const l=a.length;l&&(i+=l*Iy,i+=ba);const p=[];if(d.type===f.FunctionDeclaration||d.type===f.GlobalEvent?p.push(...d.inputs||[]):nr.includes(d.type)&&(ot.includes(d.type)?p.push(...d.usedOutputs||[]):p.push(...d.outputs||[])),ot.includes(d.type)){d.readsValue&&(i+=ba,i+=wy),d.writesValues.length&&(i+=ba,i+=wy),d.internalCalls.length&&d.usedInternalCalls.forEach(()=>i+=Ry+ba);const v=d.getDataType(null);(!v||v.inferred)&&(i+=gy)}const t=p.length;return t&&(i+=t*Iy,i+=ba),[f.DefinitionEntity,f.FunctionDeclaration,f.ReturnStatement,f.BreakStatement,f.ContinueStatement].includes(d.type)&&(i+=gy),{height:i,width:280}}function Rp(d){return`${d.split("-").map((a,l)=>l===0?a.charAt(0).toUpperCase()+a.slice(1):a.toLowerCase()).join(" ")}.`}function Ime(d){switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case oe.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case oe.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case oe.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case oe.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case oe.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case oe.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case ne.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case ne.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case oe.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case oe.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case ne.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case oe.NoProperties:return"This entity has no properties, so it doesn't do anything";case oe.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case oe.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case oe.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case oe.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case oe.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case oe.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case oe.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case oe.PropertyImplementsNonAbstact:return"This property implements a non-template property";case oe.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case oe.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case oe.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case oe.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case oe.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case ne.InternalCallDeclarationIsNotFunctionDeclaration:return"This internal call is not an action";case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case ne.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case ne.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case ne.UnreachableEntity:return"This entity is unreachable";case oe.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";default:return Rp(d.code)}}function wme(d){switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case oe.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case oe.IncorrectEntityImplementation:return"Incorrect implementation";case oe.IncorrectMethodImplementation:return"Incorrect action implementation";case oe.IncorrectPropertyImplementation:return"Incorrect property implementation";case oe.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case oe.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case ne.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case ne.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case oe.MissingMethodImplementation:return"Missing action";case oe.MissingPropertyImplementation:return"Missing property";case ne.NameNotUniqueInScope:return"Duplicate name";case oe.NoProperties:return"No properties";case oe.NonStaticPropertyInStaticEntity:return"Non-static property";case oe.StaticEntityWithNonStaticProperties:return"Non-static properties";case oe.ReadingFromIncompatibleType:return"Read from different type";case oe.WritingToIncompatibleType:return"Write to different type";case oe.ScopeWithoutLogic:return"No logic";case oe.NonStaticPropertyImplementsStatic:return"Invalid static property";case oe.PropertyImplementsIncompatibleType:return"Incompatible data type";case oe.PropertyImplementsNonAbstact:return"Non-template property";case oe.StaticPropertyImplementsNonStatic:return"Non-static property";case oe.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case oe.VariableHasInputsAndInternalCall:return"Bad internal call";case oe.VariableHasOutputsAndInternalCall:return"Bad internal call";case oe.VariableIsCalledAndHasInternalCall:return"Bad internal call";case ne.InternalCallDeclarationIsNotFunctionDeclaration:return"Declaration not an action";case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case ne.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case ne.InternalCallParentMissingDataType:return"Parent has no data type";case ne.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case ne.UnreachableEntity:return"Unreachable entity";case oe.DisconnectedCallableEntity:return"Disconnected entity";default:return Rp(d.code)}}function Rme(d){switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return`${ie(d.entity,d.entity.project)} has non-template actions`;case oe.AbstractEntityWithNonAbstractProperties:return`${ie(d.entity,d.entity.project)} has non-template properties`;case oe.IncorrectEntityImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements template`;case oe.IncorrectMethodImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template`;case oe.IncorrectPropertyImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template`;case oe.AbstractMethodInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} can't be a template`;case oe.AbstractPropertyInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} can't be a template`;case ne.MethodOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites action`;case ne.PropertyOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites property`;case oe.MissingMethodImplementation:return`${ie(d.entity,d.entity.project)} is missing action`;case oe.MissingPropertyImplementation:return`${ie(d.entity,d.entity.project)} is missing property`;case ne.NameNotUniqueInScope:return`${ie(d.entity,d.entity.project)} name is not unique`;case oe.NoProperties:return`${ie(d.entity,d.entity.project)} has no properties`;case oe.NonStaticPropertyInStaticEntity:return`${ie(d.entity,d.entity.project)} has non-static property`;case oe.StaticEntityWithNonStaticProperties:return`${ie(d.entity,d.entity.project)} has non-static properties`;case oe.ReadingFromIncompatibleType:return`${ie(d.entity,d.entity.project)} reads from different type`;case oe.WritingToIncompatibleType:return`${ie(d.entity,d.entity.project)} writes to different type`;case oe.ScopeWithoutLogic:return`${ie(d.entity,d.entity.project)} has no logic`;case oe.NonStaticPropertyImplementsStatic:return`${ie(d.entity,d.entity.project)} has invalid static property`;case oe.PropertyImplementsIncompatibleType:return`${ie(d.entity,d.entity.project)} has incompatible data type`;case oe.PropertyImplementsNonAbstact:return`${ie(d.entity,d.entity.project)} has non-template property`;case oe.StaticPropertyImplementsNonStatic:return`${ie(d.entity,d.entity.project)} has non-static property`;case oe.VariableCallsOthersAndHasInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case oe.VariableHasInputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case oe.VariableHasOutputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case oe.VariableIsCalledAndHasInternalCall:return`${ie(d.entity,d.entity.project)} has bad internal call`;case ne.InternalCallDeclarationIsNotFunctionDeclaration:return`${ie(d.entity,d.entity.project)} has declaration that is not an action`;case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has declaration that is not found in parent`;case ne.InternalCallParentDeclarationEntityInvalidType:return`${ie(d.entity,d.entity.project)} has invalid parent declaration type`;case ne.InternalCallParentMissingDataType:return`${ie(d.entity,d.entity.project)}'s parent has no data type`;case ne.InternalCallDeclarationNotInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has declaration that is not in parent`;case ne.UnreachableEntity:return`${ie(d.entity,d.entity.project)} is unreachable`;case oe.DisconnectedCallableEntity:return`${ie(d.entity,d.entity.project)} is not executed by any entity`;default:return`${ie(d.entity,d.entity.project)} Error: ${Rp(d.code)}`}}function gme(d){var u,i,a,l;switch(d.code){case oe.AbstractEntityWithNonAbstractMethods:return`${ie(d.entity,d.entity.project)} has non-template actions`;case oe.AbstractEntityWithNonAbstractProperties:return`${ie(d.entity,d.entity.project)} has non-template properties`;case oe.IncorrectEntityImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template entity`;case oe.IncorrectMethodImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template action it's based on`;case oe.IncorrectPropertyImplementation:return`${ie(d.entity,d.entity.project)} incorrectly implements the template property it's based on`;case oe.AbstractMethodInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} is a template action in a non-template entity`;case oe.AbstractPropertyInNonAbstractEntity:return`${ie(d.entity,d.entity.project)} is a template property in a non-template entity`;case ne.MethodOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites an action in the template entity`;case ne.PropertyOverwritesOtherSiblingWithSameName:return`${ie(d.entity,d.entity.project)} overwrites a property in the template entity`;case oe.MissingMethodImplementation:return`${ie(d.entity,d.entity.project)} is missing an action implementation from the template entity`;case oe.MissingPropertyImplementation:return`${ie(d.entity,d.entity.project)} is missing a property implementation from the template entity`;case ne.NameNotUniqueInScope:return`${ie(d.entity,d.entity.project)} has a duplicate name in the same scope`;case oe.NoProperties:return`${ie(d.entity,d.entity.project)} has no properties, so it doesn't do anything`;case oe.NonStaticPropertyInStaticEntity:return`${ie(d.entity,d.entity.project)} has a non-static property in a static entity`;case oe.StaticEntityWithNonStaticProperties:return`${ie(d.entity,d.entity.project)} has non-static properties in a static entity`;case oe.ReadingFromIncompatibleType:return`${ie(d.entity,d.entity.project)} reads data from a value of a different data type`;case oe.WritingToIncompatibleType:return`${ie(d.entity,d.entity.project)} writes data to a value of a different data type`;case oe.ScopeWithoutLogic:return`${ie(d.entity,d.entity.project)} has no logic`;case oe.NonStaticPropertyImplementsStatic:return`${ie(d.entity,d.entity.project)} has a static property in a non-static entity`;case oe.PropertyImplementsIncompatibleType:return`${ie(d.entity,d.entity.project)} implements a property of a different data type`;case oe.PropertyImplementsNonAbstact:return`${ie(d.entity,d.entity.project)} implements a non-template property`;case oe.StaticPropertyImplementsNonStatic:return`${ie(d.entity,d.entity.project)} has a static property in a non-static entity`;case oe.VariableCallsOthersAndHasInternalCall:return`${ie(d.entity,d.entity.project)} calls other entities while being used to execute internal logic`;case oe.VariableHasInputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has inputs while being used to execute internal logic`;case oe.VariableHasOutputsAndInternalCall:return`${ie(d.entity,d.entity.project)} has outputs while being used to execute internal logic`;case oe.VariableIsCalledAndHasInternalCall:return`${ie(d.entity,d.entity.project)} is called while being used to execute internal logic`;case ne.InternalCallDeclarationIsNotFunctionDeclaration:return`${ie(d.entity,d.entity.project)} has a declaration that is not an action`;case ne.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has a declaration that is not found in ${(u=d.entity.parent.getDataType(null))!=null&&u.entity?ie((i=d.entity.parent.getDataType(null))==null?void 0:i.entity,d.entity.project):"the variable's data-type entity"}`;case ne.InternalCallParentDeclarationEntityInvalidType:return`${ie(d.entity,d.entity.project)} is part of a variable whos data-type entity can't have actions`;case ne.InternalCallParentMissingDataType:return`${ie(d.entity,d.entity.project)} is part of a variable with no data-type entity`;case ne.InternalCallDeclarationNotInParentDatatypeEntity:return`${ie(d.entity,d.entity.project)} has a declaration doesn't belong to ${(a=d.entity.parent.getDataType(null))!=null&&a.entity?ie((l=d.entity.parent.getDataType(null))==null?void 0:l.entity,d.entity.project):"the variable's data-type entity"}`;case ne.UnreachableEntity:return`${ie(d.entity,d.entity.project)} is unreachable`;case oe.DisconnectedCallableEntity:return`${ie(d.entity,d.entity.project)} is disconnected and won't be executed by anything after publishing`;default:return`${ie(d.entity,d.entity.project)} Error: ${Rp(d.code)}`}}var aA=(d=>(d.ValuesAlreadyConnected="values-already-connected",d.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",d.CannotReadValueFromChildren="cannot-read-value-from-children",d.CannotWriteValueToChildren="cannot-write-value-to-children",d.CannotBeCalledByChildren="cannot-be-called-by-children",d.ExecutionsAlreadyConnected="executions-already-connected",d.DataTypesNotCompatible="data-types-not-compatible",d.CannotCallAncestor="cannot-call-ancestor",d.CannotConnectToItself="cannot-connect-to-itself",d.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",d.NotInScope="not-in-scope",d.IsNotValueWrittingEntity="is-not-value-writting-entity",d.IsNotValueReadingEntity="is-not-value-reading-entity",d.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",d.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",d.CallerIsInHigherScope="caller-is-in-higher-scope",d.CallerIsInLowerScope="caller-is-in-lower-scope",d.CallIsInHigherScope="call-is-in-higher-scope",d.CallIsInLowerScope="call-is-in-lower-scope",d.OtherIncompatibleScopeReason="other-incompatible-scope-reason",d.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",d))(aA||{});const _me=Object.values(aA);var oA=(d=>(d.NotPartOfOngoingTest="not-part-of-ongoing-test",d.CannotBeAddedToTest="cannot-be-added-to-test",d))(oA||{});const Dme=Object.values(oA);var lA=(d=>(d.Suggestion="suggestion",d.CanvasGloballyDisabled="canvas-globally-disabled",d.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",d.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",d))(lA||{});const Ome=Object.values(lA);function Cme(d,u){const i=[...d,...u];return Array.from(new Set(i))}function $me(d,u){const i=[...d,...u],a=Array.from(new Set(i));return{hasChanged:a.length!==d.length,reasons:a}}function Pme(d,u){const i=d.filter(l=>!u.includes(l));return{hasChanged:i.length!==d.length,reasons:i}}function Vme(d,u){return d.find(i=>i.entity.id===u)||null}function Yx(d){return d.filter((u,i)=>d.indexOf(u)===i)}class ci{constructor(u,i,a=null,l){O(this,"ids",[]);O(this,"entity");O(this,"entityCardHeight");O(this,"entityCardWidth");O(this,"index");O(this,"childEntities",[]);O(this,"children",[]);O(this,"parents",[]);O(this,"calculationEntryPoint");O(this,"_onlyEntities",null);O(this,"_changeSet",null);if(this.index=i,this.entity=u,this.calculationEntryPoint=a||this,this===this.calculationEntryPoint&&!l)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(u,i,a){const l=Zx-nA-kx,p=Jx-_y-iA;u.metaSync({x:u.x||l,y:u.y||p},i);const t=new ci(u,0,null,i);t._onlyEntities=a||[],t.ids=["0"];const y=[];t.next(T=>{y.push(...T)}),ci.recursivelyAssembleChildrenAreas(y),t.resolveChildrenOverlaps();const v=t.flattenChildEntities();return t._onlyEntities?v.filter(T=>(t._onlyEntities||[]).includes(T)):v}static recursivelyAssembleChildrenAreas(u){const i=[];u.forEach(a=>{a.next(l=>{i.push(...l)})}),i.length>0&&ci.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(u){this.calculationEntryPoint._changeSet=u}findAreaInChildrenFromEntity(u){if(this.entity===u)return this;const i=this.children.find(l=>l.entity===u);return i||this.children.reduce((l,p)=>l||p.findAreaInChildrenFromEntity(u),null)}findAreaFromEntity(u){if(this.entity===u)return this;const i=this.calculationEntryPoint.children,a=i.find(p=>p.entity===u);return a||i.reduce((p,t)=>p||t.findAreaInChildrenFromEntity(u),null)}addParent(u){if(!this.parents.includes(u)){const i=ci.resolveIds(u,this.index);this.ids.push(...i),this.parents.push(u)}}static resolveIds(u,i){return u?u.ids.map(a=>`${a}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const u=ln(this.entity,!0);if(this.entity.type===f.Project){const i=[],a=[],l=[];u.forEach(t=>{if(f.DefinitionEntity===t.type){a.push(t);return}else if(tr.includes(t.type)){l.push(t);return}i.push(t)});const p=i.sort((t,y)=>{const v=!!Uy(t,y).length,T=ln(t),R=ln(y);return v?0:T.length&&!R.length?-1:!T.length&&R.length?1:0}).filter(t=>!no(t).length);this.childEntities=[...a,...l,...p]}else{const i=[],a=[],l=[],p=[],t=[];Ps.includes(this.entity.type)&&xy(this.entity).forEach(T=>{if(ot.includes(T.type)){l.push(T);return}const R=or(T);i.push(R)}),Dr.includes(this.entity.type)&&a.push(...this.entity.detachedChildren);const y=u.filter(v=>{const T=i.includes(v);return T||l.includes(v)||a.includes(v)?!1:ot.includes(v.type)?(l.push(v),!1):$s.includes(v.type)&&!T?(p.push(v),!1):v.type===f.DefinitionEntity?(t.push(v),!1):!0});i.sort((v,T)=>ll(v,T)?-1:0),p.sort((v,T)=>ll(v,T)?-1:0),l.sort((v,T)=>OA(v,T)?1:OA(T,v)?-1:0),this.childEntities=[...t,...i,...p,...y,...l,...a]}}calculateCardSize(){const u=Hx(this.entity);this.entityCardWidth=u.width,this.entityCardHeight=u.height}static getBoundriesOfTwoAreas(u,i){return{top:Math.min(u.top,i.top),left:Math.min(u.left,i.left),bottom:Math.max(u.bottom,i.bottom),right:Math.max(u.right,i.right)}}static getBoundriedOfCombinedAreas(u,i){const a=u.filter(p=>!i.includes(p));return a.reduce((p,t)=>i.includes(t)?p:ci.getBoundriesOfTwoAreas(p,t.fullBranchArea),a[0].fullBranchArea)}getFullAreaUntilAny(u){const i=this.ownEntityPlusBufferArea;return this.children.filter(t=>!u.includes(t)).map(t=>t.getFullAreaUntilAny(u)).reduce((t,y)=>ci.getBoundriesOfTwoAreas(t,y),i)}getFullAreaUntilAreaOrAnyChildren(u){const i=[u,...u.flattenChildren()],a=this.ownEntityPlusBufferArea;return this.children.filter(t=>i.includes(t)).map(t=>t.getFullAreaUntil(u)).reduce((t,y)=>ci.getBoundriesOfTwoAreas(t,y),a)}getFullAreaUntil(u){const i=this.ownEntityPlusBufferArea;return this.children.filter(p=>p!==u).map(p=>p.getFullAreaUntil(u)).reduce((p,t)=>ci.getBoundriesOfTwoAreas(p,t),i)}get fullBranchArea(){const u=this.ownEntityPlusBufferArea;return this.children.map(l=>l.fullBranchArea).reduce((l,p)=>ci.getBoundriesOfTwoAreas(l,p),u)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const u=this.ownEntityArea;return{top:u.top,left:u.left,bottom:u.bottom+_y,right:u.right+nA}}static filterOutRepeatedAreas(u){return u.filter((i,a)=>u.indexOf(i)===a)}getEarliestId(u,i){const a=u.split("-"),l=i.split("-");return a.length<l.length?u:a.length>l.length?i:a.reduce((t,y,v)=>y<l[v]?u:i,u)}getEarliestLevel(){return this.ids.reduce((a,l)=>this.getEarliestId(a,l),this.ids[0]).split("-").length}countColumns(){let u=0;if(this!==this.calculationEntryPoint)u++;else return u;if(!this.parents.length)return u;const a=this.parents.reduce((l,p)=>p.getEarliestLevel()>l.getEarliestLevel()?p:l,this.parents[0]).countColumns();return u+=a,u}getLatestId(u,i){if(u===i)return u;const a=u.split("-"),l=i.split("-");return a.length<l.length?i:a.length>l.length?u:a.reduce((t,y,v)=>y>l[v]?u:i,u)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((a,l)=>this.getLatestId(a,l),this.ids[0]).split("-").length}smoothPosition(){const u=this.flattenSiblings();if(!u.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(a=>{a!==this.calculationEntryPoint&&a.shiftDownAlone(i)})}else if([...tr].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=u.filter(a=>!this.parents.includes(a));i.length?i.every(l=>{const p=this.countColumns(),t=l.countColumns();return p>t})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(u,i){if(u.includes(this))return u;this.move(this.entity,{y:this.entity.y+i});let a=[...u,this];return this.children.forEach(l=>{if(ci.getEarliestParentInChain(l)!==this)return;const t=Vme(a,l.entity.id);a=ci.filterOutRepeatedAreas([...a]),t||(a=a.filter(v=>v!==l));const y=l.shiftDownUntilAny(a,i);a.push(...y)}),a}shiftRightUntilAny(u,i){u.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(a=>{const l=ci.filterOutRepeatedAreas([...this.flattenSiblings(),...u]);ci.getEarliestParentInChain(a)===this&&a.shiftRightUntilAny(l,i)}))}shiftRight(u){this.move(this.entity,{x:this.entity.x+u}),this.children.forEach(i=>{const l=i.flattenSiblings().filter(p=>p!==i);i.shiftRightUntilAny(l,u)})}shiftDownAlone(u){this.move(this.entity,{y:this.entity.y+u})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const u=this.parents.reduce((l,p)=>{const t=p.ownEntityArea,y=t.top+Pd,v={top:y,left:t.left,bottom:y,right:t.right};return ci.getBoundriesOfTwoAreas(l,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Pd;this.shiftDownAlone(a)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const u=this.children.reduce((l,p)=>{const t=p.ownEntityArea,y=t.top+Pd,v={top:y,left:t.left,bottom:y,right:t.right};return ci.getBoundriesOfTwoAreas(l,v)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),a=(u.bottom-u.top)/2-Pd;return this.shiftDownAlone(a),a}resolveChildrenOverlaps(){const u=this.flattenChildren();let i=[];u.forEach(a=>{const l=a.adjustVerticallyToAvoidOverlaps();i.push(...l)}),u.forEach(a=>{a.smoothPosition()})}static getEarliestParentInChain(u){let i=u.parents[0];return u.parents.length&&(i=u.parents.sort((a,l)=>{if(!a.ids.length)return-1;if(!l.ids.length)return 1;const p=a.ids.sort((y,v)=>y.length<v.length?-1:0),t=l.ids.sort((y,v)=>y.length<v.length?-1:0);return p[0].length-t[0].length})[0]),i}flattenEarlierSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,l)=>{if(u.has(l.entity.id))return a;u.add(l.entity.id);const t=l.children.slice(0,l.children.indexOf(this)).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...t]},[])}flattenSiblings(u=new Set){return u.add(this.entity.id),this.parents.reduce((a,l)=>{if(u.has(l.entity.id))return a;u.add(l.entity.id);const t=l.children.filter(y=>y!==this).reduce((y,v)=>[...y,v,...v.flattenChildren(u)],[]);return[...a,...t]},[])}flattenChildren(u=new Set){return this.children.reduce((i,a)=>u.has(a.entity.id)?i:(u.add(a.entity.id),[...i,a,...a.flattenChildren(u)]),[])}flattenParents(u=new Set){return this.parents.reduce((a,l)=>u.has(l.entity.id)?a:(u.add(l.entity.id),[...a,l,...l.flattenParents(u)]),[])}getAreaIfRendered(u){return this.calculationEntryPoint.flattenChildren().find(l=>l.entity.id===u.id)||null}getLowerSiblings(){const u=this.parents.reduce((i,a)=>{const l=a.children.indexOf(this),p=a.children.slice(l+1);return[...i,...p]},[]);return Yx(u)}getLowerAreas(){const u=this.getLowerSiblings(),i=this.parents.reduce((a,l)=>[...a,...l.getLowerAreas()],[]);return Yx([...u,...i])}adjustVerticallyToAvoidOverlaps(u=[]){const a=ci.getEarliestParentInChain(this).children[this.index-1];if(!a)return u;const l=this.flattenEarlierSiblings(),p=this.flattenParents(),t=[...l,...p,a],T=w(t.flatMap(N=>Uy(this.entity,N.entity))).filter(N=>N.id!==this.entity.id).map(N=>this.findAreaFromEntity(N)).filter(N=>!!N),R=this.getFullAreaUntilAny(T),A=a.getFullAreaUntilAny(T),P=t.reduce((N,U)=>U===this||U.fullBranchArea.left!==R.left?N:Math.max(N,U.fullBranchArea.bottom),A.bottom);if(R.top<P){const N=P-R.top+_y;return this.shiftDownUntilAny(u,N)}return u}move(u,i){(this.onlyEntities||[]).includes(u)&&u.metaSync(i,this.changeSet)}addChild(u){const i=this.childEntities[u];let a=null;i.x&&i.y?a=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),a||(a=new ci(i,u,this.calculationEntryPoint));const l=this.ownEntityPlusBufferArea;this.children.includes(a)||(this.children.push(a),a.addParent(this));const p=a.fullBranchArea;if(p.left<l.right){const t=l.right-p.left;a.shiftRight(t)}return a}flattenChildEntities(u=new Set){return this.children.reduce((i,a)=>u.has(a.entity.id)?i:(u.add(a.entity.id),[...i,a.entity,...a.flattenChildEntities(u)]),[])}next(u){const i=[];this.childEntities.forEach((a,l)=>{const p=this.addChild(l);p&&i.push(p)}),u(i)}}var gp=(d=>(d.Amazon="amazon",d.Google="google",d.Microsoft="microsoft",d))(gp||{}),jr=(d=>(d.RelationalDatabase="relational-database",d.CompiledLocalCodebase="compiled-local-codebase",d.CloudHostedCodebase="cloud-hosted-codebase",d.HttpApi="http-api",d.HttpEndpoint="http-endpoint",d.ServerlessFunction="serverless-function",d))(jr||{}),dA=(d=>(d.Post="post",d.Get="get",d.Acknowledgement="acknowledgment",d.Progress="progress",d.Error="error",d.Complete="complete",d))(dA||{}),ol=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.Skipped="skipped",d.AbortedByUser="aborted-by-user",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(ol||{}),uA=(d=>(d.Queued="queued",d.Running="running",d.Success="success",d.Failed="failed",d.CleanedUp="cleaned-up",d.UnrecoverableFailure="unrecoverable-failure",d.Reverted="reverted",d.UnpublishingStarted="unpublishing-started",d.Unpublished="unpublished",d))(uA||{}),nt=(d=>(d.ProjectNotFound="project-not-found",d.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",d.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",d.DeploymentCompleted="deployment-completed",d.DeploymentStarted="deployment-started",d.DeploymentFailed="deployment-failed",d.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",d.RequestPayloadValidationFailed="request-payload-validation-failed",d.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",d.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",d.ProjectAlreadyBeingPublished="project-already-being-published",d.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",d.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",d.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",d.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",d.CreatingNewRelationalDatabase="creating-new-relational-database",d.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",d.RelationalDatabaseAlreadyExists="relational-database-already-exists",d.RelationalDatabaseDeletionStarted="relational-database-deletion-started",d.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",d.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",d.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",d.HttpApiDeploymentStarted="http-api-deployment-started",d.HttpApiDeploymentCompleted="http-api-deployment-completed",d.HttpApiDeploymentFailed="http-api-deployment-failed",d.CreatingNewHttpApi="creating-new-http-api",d.HttpApiAlreadyExists="http-api-already-exists",d.HttpApiDeletionStarted="http-api-deletion-started",d.HttpApiDeletionCompleted="http-api-deletion-completed",d.HttpApiDeletionFailed="http-api-deletion-failed",d.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",d.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",d.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",d.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",d.BundlingCodebaseForDownload="bundling-codebase-for-download",d.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",d.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",d.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",d.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",d.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",d.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",d.CodeCompilationStarted="code-compilation-started",d.CodeCompilationCompleted="code-compilation-completed",d.CodeCompilationFailed="code-compilation-failed",d.BundleCodebaseStarted="bundle-codebase-started",d.BundleCodebaseCompleted="bundle-codebase-completed",d.BundleCodebaseFailed="bundle-codebase-failed",d.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",d.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",d.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",d.MigrateRelationalDatabaseStarted="migrate-relational-database-started",d.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",d.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",d))(nt||{}),on=(d=>(d.CodeCompilation="code-compilation",d.RelationalDatabaseDeployment="relational-database-deployment",d.RelationalDatabaseDeletion="relational-database-deletion",d.HttpApiDeployment="http-api-deployment",d.HttpApiDeletion="http-api-deletion",d.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",d.BundleCodebase="bundle-codebase",d.MigrateRelationalDatabase="migrate-relational-database",d.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",d.CodebaseCleanup="codebase-cleanup",d))(on||{});jr.CloudHostedCodebase,jr.HttpApi,jr.RelationalDatabase,jr.CloudHostedCodebase,jr.CloudHostedCodebase,jr.RelationalDatabase,jr.CloudHostedCodebase,jr.CloudHostedCodebase;function zx(d){return`project-${d}-http-api`}function Xx(d){return`entity-${d}-database`}class Qx{constructor(u,i,a,l,p,t,y,v,T){O(this,"stepType");O(this,"id");O(this,"resourceType");O(this,"index");O(this,"dependency",[]);O(this,"lastEvent",null);O(this,"lasEventTimestamp",null);O(this,"status",ol.Queued);O(this,"publicationRun");O(this,"resource");this.stepType=u,this.id=i,this.resourceType=a,this.status=l,this.dependency=p,this.index=t,this.lasEventTimestamp=y,this.publicationRun=v,this.resource=T}toJSON(){return{stepType:this.stepType,id:this.id,resourceType:this.resourceType,index:this.index,status:this.status,dependency:this.dependency,lastEvent:this.lastEvent,resource:{resourceId:this.resource.resourceId,resourceType:this.resource.resourceType,provider:this.resource.provider,details:this.resource.details,status:this.resource.status,name:this.resource.name}}}async update(u){var i,a;this.status=u.status,this.dependency=u.dependency,this.index=u.index,this.stepType=u.stepType,this.resourceType=u.resourceType,this.lastEvent=u.lastEvent,this.id=u.id,(a=this.resource)==null||a.setDetails((i=u.resource)==null?void 0:i.details)}}var eF=(d=>(d.Ready="ready",d.Provisioning="provisioning",d.Queued="queued",d.ProvisioningFailed="provisioning-failed",d.Deleting="deleting",d.DeletingFailed="deleting-failed",d.Deleted="deleted",d))(eF||{});class cA{constructor(u,i,a){O(this,"provisionedBy");O(this,"publicationRun");O(this,"resourceType");O(this,"provider");O(this,"resourceId");O(this,"details",null);O(this,"name",null);O(this,"status","queued");this.publicationRun=u,this.resourceType=i,this.provider=a}setDetails(u){this.details=u}setStatus(u){this.status=u}setProvisionedBy(u){this.provisionedBy=u}}class pA extends cA{constructor(i,a,l,p){super(i,l,p);O(this,"resourceType");O(this,"owners",new Map);O(this,"details",null);O(this,"status","queued");a.forEach(t=>{this.owners.set(t.id,t)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,a;return this.resourceType===jr.HttpApi?this.resourceId=zx(this.publicationRun.project.id):this.resourceType===jr.RelationalDatabase&&(this.resourceId=Xx((a=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:a.id)),this.resourceId}}class fA extends cA{constructor(i,a,l){super(i,a,l);O(this,"resourceType");O(this,"details",null);O(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceType===jr.CompiledLocalCodebase?this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`:this.resourceType===jr.CloudHostedCodebase&&(this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`),this.resourceId}}class Nme{constructor(u,i){O(this,"id");O(this,"projectAutoIncrementPublicationCount");O(this,"projectPublishedSemanticVersion");O(this,"projectVersion");O(this,"projectId");O(this,"cloudProvider");O(this,"triggeredBy");O(this,"createdAt");O(this,"updatedAt");O(this,"status");O(this,"steps",[]);O(this,"editor");O(this,"explicitResources",new Map);O(this,"implicitGlobalResources",new Map);O(this,"finalGlobalEvent",null);O(this,"finalStatus",null);this.id=u.id,this.projectAutoIncrementPublicationCount=u.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=u.projectPublishedSemanticVersion,this.projectVersion=u.projectVersion,this.projectId=u.projectId,this.cloudProvider=u.cloudProvider,this.triggeredBy=u.triggeredBy,this.createdAt=u.createdAt,this.updatedAt=u.updatedAt,this.status=u.status,this.editor=i}get project(){return this.editor.project}getInfraTypes(u){return this.steps.filter(i=>u.includes(i.resourceType))}getStepsTypes(u){return this.steps.filter(i=>u.includes(i.stepType))}toIds(u){return u.map(i=>i.id)}getResourceForEntity(u){const i=Array.from(this.explicitResources.values()).find(a=>a.owners.has(u.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(jr.CompiledLocalCodebase,new fA(this,jr.CompiledLocalCodebase,gp.Amazon)),this.implicitGlobalResources.set(jr.CloudHostedCodebase,new fA(this,jr.CloudHostedCodebase,gp.Amazon));const u=this.project.entities.filter(a=>as(a,Ve.HTTP_ENDPOINT)),i=this.project.entities.filter(a=>as(a,Ve.RELATIONAL_DATABASE));if(i.length&&i.forEach(a=>{const l=new pA(this,[a],jr.RelationalDatabase,gp.Amazon);this.explicitResources.set(l.resourceId,l)}),u.length){const a=new pA(this,u,jr.HttpApi,gp.Amazon);this.explicitResources.set(a.resourceId,a)}}setSteps(u,i){u.forEach(a=>{this.addStep(a,i)}),this.editor.events.emit(nt.ProjectPublishRequestAcknowledged,{})}addStep(u,i){const a=u.dependency||[];if(a.length){const p=a.filter(t=>!this.steps.find(y=>y.id===t));if(p.length)throw new Error(`Missing dependencies: ${p.join(", ")}`)}if(!u.resource)throw new Error(`Resource not found for step ${u.stepType} (${u.id})`);if(!this.steps.find(p=>p.id===u.id)){const p=this.implicitGlobalResources.get(u.resourceType)||this.explicitResources.get(u.resource.resourceId),t=new Qx(u.stepType,u.id,u.resourceType,u.status,a,u.index,i,this,p);this.steps.push(t)}}onUpdate(u){var i;if(Fe.log("onUpdate",u),(i=u.payload)!=null&&i.stepType){const a=this.steps.find(l=>{var p;return l.id===((p=u.payload)==null?void 0:p.id)});a&&L(u.emittedAt).isAfter(L(a.lasEventTimestamp))&&a.update(u.payload)}this.editor.events.emit("publication-updated",{}),u.type===dA.Error?(this.finalStatus=uA.Failed,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-error",u)):u.type===dA.Complete&&(this.finalStatus=uA.Success,this.finalGlobalEvent=u.event,this.editor.events.emit("project-publication-completed",u))}}function Lme(d){switch(d){case on.CodeCompilation:return"Code generation";case on.RelationalDatabaseDeployment:return"Database creation";case on.HttpApiDeployment:return"HTTP gateway creation";case on.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case on.BundleCodebase:return"Bundle code";case on.MigrateRelationalDatabase:return"Database structure migration";case on.BusinessLogicCodebaseDeployment:return"Update servers with new code";case on.CodebaseCleanup:return"Code cleanup";case on.HttpApiDeletion:return"HTTP gateway deletion";case on.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function Bme(d){switch(d){case nt.DeploymentCompleted:return"Successfully published";case nt.DeploymentStarted:return"Publication started";case nt.DeploymentFailed:return"Publication failed";case nt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case nt.RequestPayloadValidationFailed:return"Request payload validation failed";case nt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case nt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case nt.RelationalDatabaseDeploymentStarted:return"Database creation started";case nt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case nt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case nt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case nt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case nt.RelationalDatabaseAlreadyExists:return"Database already exists";case nt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case nt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case nt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case nt.CreatingNewHttpApi:return"Creating new HTTP gateway";case nt.HttpApiAlreadyExists:return"HTTP gateway already exists";case nt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case nt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case nt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case nt.BundlingCodebaseForDownload:return"Bundling code for download";case nt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case nt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case nt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case nt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case nt.CodeCompilationStarted:return"Code generation started";case nt.CodeCompilationCompleted:return"Code generation completed";case nt.CodeCompilationFailed:return"Code generation failed";case nt.BundleCodebaseStarted:return"Code bundling started";case nt.BundleCodebaseCompleted:return"Code bundling completed";case nt.BundleCodebaseFailed:return"Code bundling failed";case nt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case nt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case nt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case nt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case nt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case nt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case nt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case nt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case nt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case nt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case nt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case nt.ProjectNotFound:return"Project not found";case nt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case nt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case nt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case nt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case nt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case nt.RelationalDatabaseDeletionStarted:return"Database deletion started";case nt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case nt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case nt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var tF=(d=>(d.NO_LOGIC="NO_LOGIC",d.NO_NAME="NO_NAME",d.NO_CHANGES="NO_CHANGES",d.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",d))(tF||{});function Mme(d){switch(d){case"NO_LOGIC":return"This project has no logic";case"NO_NAME":return"This project has no name";case"NO_CHANGES":return"This version has already been published";case"PROJECT_PUBLICATION_ALREADY_ONGOING":return"This project is already being published";default:return"Publishing is currently not available. Try again later"}}function Ume(d){switch(d){case jr.RelationalDatabase:return"Relational database";case jr.HttpEndpoint:case jr.HttpApi:return"HTTP endpoints";case jr.ServerlessFunction:case jr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function jme(d){switch(d){case ol.Running:return"In progress";case ol.Failed:return"Failed";case ol.Success:return"Succeeded";case ol.Skipped:return"Skipped";case ol.Queued:default:return"Queued"}}function xme(d,u){let i=null;const a=[];if(!d.id)i={...d,id:V.UUID.uuid()};else if(!VG(d.id)){const y=V.UUID.uuid();i={...d,id:y},a.push(new Q({id:`${d.id}--${S.InvalidUUIDStringFormat}`,message:`Entity with id "${d.id}" has an invalid UUID string format. The 'id' property must be a valid UUID string.
|
|
195
195
|
The 'id' has been changed to "${y}".`,severity:q.Warning,code:S.InvalidUUIDStringFormat,issue:null}))}if(i={...d,id:(i==null?void 0:i.id)||d.id||""},!d.type)return{errors:[...a,new Q({id:`${i.id}--${S.MissingTypeProperty}`,message:`Entity with id "${i.id}" is missing a 'type' property.`,severity:q.Error,code:S.MissingTypeProperty,issue:null})],modifiedData:i};if(d.type===f.GenericReference)return{errors:[...a,new Q({id:`${i.id}--${S.RootReference}`,message:`Generic reference entity with id "${i.id}". A generic reference cannot be generated as a standalone entity. Only in the body of another entity.`,severity:q.Error,code:S.RootReference,issue:null})],modifiedData:i};const l=i,p=u.instances[l.id],t=u.builtInInstances[l.id];if(p&&!t&&l.type!==f.GenericReference){let y=`A previously generated entity with id "${l.id}" already exists in the project state.
|
|
196
196
|
Are you trying to update that entity?
|
|
197
197
|
If so, you should use the 'update' action for core mutable metadata properties, or 'delete' and then 'post' again to replace it.
|
|
@@ -400,5 +400,5 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
400
400
|
${$y}`,issue:null})),{errors:a,modifiedData:i}}onProjectInitialized(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,new Date().toISOString(),this,!0,"on-property-received-project-initialized"))){return BG(this,a),a==null||a.attemptAutoclose("on-property-received-project-initialized",this.id),this}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];if(a==="property-implements"&&(this.setImplements(null,l),p.push(this)),a==="property-extends"){const{updated:T,added:R,removed:A,affected:P}=this.remove({ignoreUpstream:!1},l);p.push(...T),t.push(...R),y.push(...A),v.push(...P)}return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];if(a==="property-implements"&&(this.setImplements(i,l),p.push(this)),a==="property-extends"){const{updated:T,added:R,removed:A,affected:P}=this.restore({},l);p.push(...T),t.push(...R),y.push(...A),v.push(...P)}return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){var i,a,l,p,t,y,v;return(a=(i=this.implements)==null?void 0:i.unsubscribeDependents)==null||a.call(i,[{entity:this,field:"property-implements"}]),(p=(l=this.extends)==null?void 0:l.unsubscribeDependents)==null||p.call(l,[{entity:this,field:"property-extends"}]),(v=(y=(t=this.dataType)==null?void 0:t.entity)==null?void 0:y.unsubscribeDependents)==null||v.call(y,[{entity:this,field:"data-type-entity"}]),this.project.off(gr.PROJECT_INITIALIZED,this.onProjectInitialized),this}subscribeToDependencies(){var i,a,l,p,t,y,v;return(a=(i=this.implements)==null?void 0:i.subscribeDependents)==null||a.call(i,[{entity:this,field:"property-implements"}]),(p=(l=this.extends)==null?void 0:l.subscribeDependents)==null||p.call(l,[{entity:this,field:"property-extends"}]),(v=(y=(t=this.dataType)==null?void 0:t.entity)==null?void 0:y.subscribeDependents)==null||v.call(y,[{entity:this,field:"data-type-entity"}]),this.project.on(gr.PROJECT_INITIALIZED,this.onProjectInitialized),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new bt(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.implements=this.implements,i.extends=this.extends,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent&&this.parent.type!==f.PrimitiveEntity&&this.parent.type!==f.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new bt(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.implements=y.implements,this.parent=y.parent,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=Z(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,null);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.implements){const l=Z(i.implements),p=this.project.get(l);if(p)this.setImplements(p,a);else if(l)throw new Error(`${di(this.type)} with id '${this.id}' has a 'implements' reference "${l}" which is missing in the project`)}if(i.extends){const l=Z(i.extends),p=this.project.get(l);if(p)this.setExtends(p,a);else if(l)throw new Error(`${di(this.type)} with id '${this.id}' has a 'extends' reference "${l}" which is missing in the project`)}return this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=Z(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.implements){const t=Z(this.initialData.implements),y=this.project.get(t);if(y)this.setImplements(y,null),i.push(y);else if(t)throw new Error(`${di(this.type)} with id '${this.id}' has a 'implements' reference "${t}" which is missing in the project`)}if(this.initialData.extends){const t=Z(this.initialData.extends),y=this.project.get(t);if(y)this.setExtends(y,null),i.push(y);else if(t)throw new Error(`${di(this.type)} with id '${this.id}' has a 'extends' reference "${t}" which is missing in the project`)}return{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:T,affected:R}=this.syncWithImplementation(i);a.push(...y),l.push(...v),p.push(...T),t.push(...R);const{updated:A,added:P,removed:N,affected:U}=BG(this,i);return a.push(...A),l.push(...P),p.push(...N),t.push(...U),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];return this.parent.addProperty(this),a.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}setParent(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setImplements(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-implements"))){var l;return((l=this.implements)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.implements=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-implements",this.id),this}setExtends(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-extends"))){var l;return((l=this.extends)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.extends=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-extends",this.id),this}initChildren(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=ee(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const a=ee(this.initialData.dataType,this.project);a.setParent(this,null),a.initChildren(i),this.dataType=a}if(this.initialData.implements){const a=ee(this.initialData.implements,this.project);this.setImplements(a,null)}if(this.initialData.extends){const a=ee(this.initialData.extends,this.project);this.setExtends(a,null)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.abstract=i.abstract!==void 0?i.abstract:p.abstract,this.private=i.private!==void 0?i.private:p.private,this.index=i.index||(i.index!==0?p.index:0),this.static=i.static!==void 0?i.static:p.static,this.hidden=i.hidden!==void 0?i.hidden:p.hidden,this.constant=i.constant!==void 0?i.constant:p.constant,this.interactive=i.interactive!==void 0?i.interactive:p.interactive,this.required=i.required!==void 0?i.required:p.required,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await bt.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await bt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await bt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await bt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await bt.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await bt.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];return this.parent.type===f.DefinitionEntity&&(this.parent.removeProperty(this),t.push(this.parent)),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:w(p),updated:w(a),removed:w(l),affected:w(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:R,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),p.push(...R),t.push(...A)}),this.defaultValue){const{updated:v,removed:T}=this.defaultValue.remove({ignoreUpstream:!0},a);l.push(...v),p.push(...T)}if(this.dataType){const{updated:v,removed:T}=this.dataType.remove({ignoreUpstream:!0},a);l.push(...v),p.push(...T)}if(!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:w(t),updated:w(l),removed:w(p),affected:w(y),self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:T,added:R}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...T),a.push(...R)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);l.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);l.push(...y)}return this.parent.type===f.DefinitionEntity&&(this.parent.addProperty(this),t.push(this.parent)),i==null||i.attemptAutoclose("restore-entity",this.id),{added:w(a),updated:w(l),removed:w(p),affected:w(t),self:this}}toFlat(i=new Set){var l,p;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.defaultValue)==null?void 0:l.toFlat(i))||[],...((p=this.dataType)==null?void 0:p.toFlat(i))||[],...this.parent.toFlat(i)])}toFlatIds(i=new Set){var l,p;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.defaultValue)==null?void 0:l.toFlatIds(i))||[],...((p=this.dataType)==null?void 0:p.toFlatIds(i))||[],...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,index:this.index,hidden:this.hidden,private:this.private,abstract:this.abstract,required:this.required,constant:this.constant,interactive:this.interactive,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){var a,l,p,t;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,defaultValue:((a=this.defaultValue)==null?void 0:a.toJSON(i))||null,dataType:((l=this.dataType)==null?void 0:l.toJSON(i))||null,implements:((p=this.implements)==null?void 0:p.toJSON(i))||null,extends:((t=this.extends)==null?void 0:t.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=xe){var l,p,t,y,v,T,R;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Nr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,defaultValue:((T=this.defaultValue)==null?void 0:T.toJSONClone({...i,newId:null}))||null,dataType:((R=this.dataType)==null?void 0:R.toJSONClone({...i,newId:null}))||null,implements:(()=>{var A;return this.implements&&this.project.getBuiltIn(this.implements.id)?this.implements.toJSON():((A=this.implements)==null?void 0:A.toJSONClone({...i,newId:null}))||null})(),extends:(()=>{var A;return this.extends&&this.project.getBuiltIn(this.extends.id)?this.extends.toJSON():((A=this.extends)==null?void 0:A.toJSONClone({...i,newId:null}))||null})(),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l,p,t,y,v;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,constant:this.constant,interactive:this.interactive,hidden:this.hidden,defaultValue:((p=this.defaultValue)==null?void 0:p.toReference(i))||null,dataType:((t=this.dataType)==null?void 0:t.toReference(i))||null,implements:((y=this.implements)==null?void 0:y.toReference(i))||null,extends:((v=this.extends)==null?void 0:v.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,p,t;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.defaultValue)==null?void 0:l.toFlatJSON(i))||[],...((p=this.dataType)==null?void 0:p.toFlatJSON(i))||[],...((t=this.implements)==null?void 0:t.toFlatJSON(i))||[],...this.parent.toFlatJSON(i)])}toGenerationTarget(){var i,a;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:(i=this.implements)==null?void 0:i.id,extends:(a=this.extends)==null?void 0:a.id,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,p;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.defaultValue)==null?void 0:l.toFlatGenerationTarget(i))||[],...((p=this.dataType)==null?void 0:p.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,a;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),(a=this.dataType)==null||a.clearErrors(),this}validate(){return this.errors=NG(this),this.errors.length,{success:!0,error:null,data:null}}getErrors(){var a,l;return[...this.errors,...((a=this.defaultValue)==null?void 0:a.getErrors())||[],...((l=this.dataType)==null?void 0:l.getErrors())||[]]}getShallowErrors(){return this.errors}implement(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-self-as-property")),l=null){const p=l||V.UUID.uuid(),t=bt.new(a);t.id=p,t.name=this.name,t.description=this.description,t.index=this.index,t.private=this.private,t.required=this.required,t.static=this.static,t.constant=this.constant,t.hidden=this.hidden,t.parent=i.toReference(),t.implements=this.toJSON();const y=ee(t,this.project);return y.hydrateAncestors(),y.addSelfToProject(a),y.initChildren(a),y}clone(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var N,U;let t=Vr(a,this);const y=l||V.UUID.uuid();let v=a||this.parent;const T={hidden:!1,id:y,version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||"1",previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,constant:this.constant,interactive:this.interactive,required:this.required,abstract:this.abstract,static:this.static,defaultValue:null,dataType:null,implements:this.implements,extends:this.extends,parent:v},R=zt(T,t);p&&R.subscribe(),R.hydrateAncestors(),p&&R.addSelfToProject(i),R.setParent(v,null),R.initChildren(i),i==null||i.add(R,G.Added);const A=((N=this.dataType)==null?void 0:N.clone(i,R,V.UUID.uuid(),p))||null;A&&R.setDataType(A,i);const P=(U=this.defaultValue)==null?void 0:U.clone(i,R,V.UUID.uuid(),p);return R.setDefaultValue(P||null,i),this.implements&&R.setImplements(this.implements,i),R.addSelfToProject(null),i==null||i.attemptAutoclose("clone-entity",this.id),R}setDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-data-type"))){const l=this.dataType;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.dataType=i,this.subscribeToDependencies(),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("set-data-type",this.id),this}removeDataType(){return this.dataType=null,this}getDataType(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType}getDefaultValue(){return this.defaultValue}setDefaultValue(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-default-value"))){const l=this.defaultValue;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.defaultValue=i,a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("set-default-value",this.id),this}syncWithImplementation(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-with-implementation"))){var y;const a=[],l=[],p=[],t=[];if(this.implements){const v=this.implements;if(!this.dataType&&v.dataType){const T=v.dataType.clone(i,this,V.UUID.uuid(),!0);this.setDataType(T,i),l.push(T)}if(this.implements.defaultValue&&!this.defaultValue){const T=(y=this.implements.defaultValue)==null?void 0:y.clone(i,this,V.UUID.uuid(),!0);this.setDefaultValue(T||null,i),l.push(T)}}return i==null||i.attemptAutoclose("sync-with-implementation",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}};O(bt,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),O(bt,"type",f.Property),O(bt,"USER_MANAGED_PARENT_TYPES",[f.DefinitionEntity]),O(bt,"PARENT_TYPES",[...bt.USER_MANAGED_PARENT_TYPES,f.PrimitiveEntity,f.BuiltInBaseEntity]),O(bt,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","private","abstract","static","required","constant","interactive"]),O(bt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),O(bt,"BASE_PROPERTIES",[...bt.MUTABLE_BASE_PROPERTIES,...bt.INMUTABLE_BASE_PROPERTIES]),O(bt,"MUTABLE_META_PROPERTIES",[...bt.MUTABLE_BASE_PROPERTIES,"index"]),O(bt,"INMUTABLE_META_PROPERTIES",[...bt.INMUTABLE_BASE_PROPERTIES]),O(bt,"META_PROPERTIES",[...bt.MUTABLE_META_PROPERTIES,...bt.INMUTABLE_META_PROPERTIES]),O(bt,"MUTABLE_UPSTREAM_PROPERTIES",[]),O(bt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements","extends"]),O(bt,"UPSTREAM_PROPERTIES",[...bt.MUTABLE_UPSTREAM_PROPERTIES,...bt.INMUTABLE_UPSTREAM_PROPERTIES]),O(bt,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),O(bt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),O(bt,"DOWNSTREAM_PROPERTIES",[...bt.MUTABLE_DOWNSTREAM_PROPERTIES,...bt.INMUTABLE_DOWNSTREAM_PROPERTIES]),O(bt,"PROPERTIES",[...bt.META_PROPERTIES,...bt.UPSTREAM_PROPERTIES,...bt.DOWNSTREAM_PROPERTIES]);let jn=bt;function UG(d){const u=Ofe(),i=d.toJSON();u.safeParse(i).success;const l=d.implements.flatMap(R=>F0e(d,R)),p=d.extends.flatMap(R=>G0e(d,R)),t=k0e(d),y=K0e(d);d.methods.flatMap(R=>R.validate());const v=[...l,...p,...t,...y,...FG(d)];return ar(d.errors,v)}function jG(d,u){const i=u.properties.filter(p=>p.abstract),a=[];let l=[...d.properties];return i.forEach(p=>{const t=l.find(y=>{var v;return((v=y.implements)==null?void 0:v.id)===p.id});t?l=l.filter(y=>y.id!==t.id):a.push(p)}),a}function xG(d,u){const i=u.abstractMethods,a=[];let l=[...d.methods];return i.forEach(p=>{const t=l.find(y=>{var v;return((v=y.implements)==null?void 0:v.id)===p.id});t?l=l.filter(y=>y.id!==t.id):a.push(p)}),a}function F0e(d,u){const i=[];if(!u.abstract){const R=st({id:d.id+"--"+oe.ImplementingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is implementing a non-abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.ImplementingNonAbstractEntity,entity:d});return i.push(R.error),i}const a=u.properties.filter(R=>R.abstract),l=[];let p=[...d.properties];a.forEach(R=>{const A=p.find(P=>{var N;return((N=P.implements)==null?void 0:N.id)===R.id});A?p=p.filter(P=>P.id!==A.id):l.push(R)}),l.length&&l.forEach(R=>{const A=st({id:d.id+"--"+oe.MissingPropertyImplementation+"--"+R.id,message:`Property "${R.name}" with id "${R.id}" of entity "${u.name}" with id "${u.id}" is not implemented when entity "${d.name}" with id "${d.id}" implements it`,issue:null,severity:q.Error,code:oe.MissingPropertyImplementation,entity:d});i.push(A.error)});const t=[];let y=[...d.methods];u.abstractMethods.forEach(R=>{const A=y.find(P=>{var N;return((N=P.implements)==null?void 0:N.id)===R.id});A?y=y.filter(P=>P.id!==A.id):t.push(R)}),t.length&&t.forEach(R=>{const A=st({id:d.id+"--"+oe.MissingMethodImplementation+"--"+R.id,message:`Method "${R.name}" with id "${R.id}" of entity "${u.name}" with id "${u.id}" is not implemented when entity "${d.name}" with id "${d.id}" implements it`,issue:null,severity:q.Error,code:oe.MissingMethodImplementation,entity:d});i.push(A.error)});const v=[];u.properties.forEach(R=>{const A=p.find(P=>P.name===R.name);A&&v.push([A,R])}),v.length&&v.forEach(([R])=>{const A=st({id:d.id+"--"+ne.PropertyOverwritesOtherSiblingWithSameName+"--"+R.id,message:`Property "${R.name}" with id "${R.id}" of entity "${d.name}" with id "${d.id}" overwrites the property with the same name from the base entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:ne.PropertyOverwritesOtherSiblingWithSameName,entity:d});i.push(A.error)});const T=[];return u.methods.forEach(R=>{const A=y.find(P=>P.name===R.name);A&&T.push([A,R])}),T.length&&T.forEach(([R])=>{const A=st({id:d.id+"--"+ne.MethodOverwritesOtherSiblingWithSameName+"--"+R.id,message:`Method "${R.name}" with id "${R.id}" of entity "${d.name}" with id "${d.id}" overwrites the method with the same name from the base entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:ne.MethodOverwritesOtherSiblingWithSameName,entity:d});i.push(A.error)}),i}function G0e(d,u){const i=[],a=[];if(!d.abstract&&u.abstract){const p=st({id:d.id+"--"+u.id+"--"+oe.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not-abstract but is extending an abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:u});return i.push(p.error),i}if(d.abstract&&!u.abstract){const p=st({id:d.id+"--"+u.id+"--"+oe.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but is extending an non-abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:u});return i.push(p.error),i}d.properties.forEach(p=>{var y;const t=u.properties.find(v=>{var T;return v.name===p.name&&((T=p.extends)==null?void 0:T.id)!==v.id});((y=p.implements)==null?void 0:y.id)!==(t==null?void 0:t.id)&&t&&a.push(p)}),a.length&&a.forEach(p=>{const t=st({id:d.id+"--"+ne.PropertyOverwritesOtherSiblingWithSameName,message:`Property "${p.name}" with id "${p.id}" of entity "${d.name}" with id "${d.id}" overwrites the property with the same name from the extended entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:ne.PropertyOverwritesOtherSiblingWithSameName,entity:d});i.push(t.error)});const l=[];return d.methods.forEach(p=>{var y;const t=u.methods.find(v=>{var T;return v.name===p.name&&((T=p.extends)==null?void 0:T.id)!==v.id});((y=p.implements)==null?void 0:y.id)!==(t==null?void 0:t.id)&&t&&l.push(p)}),l.length&&l.forEach(p=>{const t=st({id:d.id+"--"+ne.MethodOverwritesOtherSiblingWithSameName,message:`Method "${p.name}" with id "${p.id}" of entity "${d.name}" with id "${d.id}" overwrites the method with the same name from the extended entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:ne.MethodOverwritesOtherSiblingWithSameName,entity:d});i.push(t.error)}),i}function K0e(d){const u=[];if(!d.properties.length){const i=st({id:d.id+"--"+oe.NoProperties,message:"No properties implemented",issue:null,severity:q.Warning,code:oe.NoProperties,entity:d});u.push(i.error)}return d.properties.forEach(i=>{i.validate()}),u}function k0e(d){const u=[];if(d.abstract){if(d.methods.length){const i=st({id:d.id+"--"+oe.AbstractEntityWithNonAbstractMethods,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract but has non-abstract methods`,issue:null,severity:q.Error,code:oe.AbstractEntityWithNonAbstractMethods,entity:d});u.push(i.error)}if(d.properties.some(i=>!i.abstract)){const i=st({id:d.id+"--"+oe.AbstractEntityWithNonAbstractProperties,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract but has non-abstract properties`,issue:null,severity:q.Error,code:oe.AbstractEntityWithNonAbstractProperties,entity:d});u.push(i.error),d.properties.forEach(a=>{if(!a.abstract){const l=st({id:d.id+"--"+oe.StaticEntityWithNonStaticProperties+"--"+a.id,message:`Property "${a.name}" with id "${a.id}" of entity "${d.name}" with id "${d.id}" is not marked as abstract but the entity is marked as abstract`,issue:null,severity:q.Error,code:oe.StaticEntityWithNonStaticProperties,entity:d});u.push(l.error)}})}}else{if(d.abstractMethods.length){const i=st({id:d.id+"--"+oe.AbstractPropertyInNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not marked as abstract but has abstract methods`,issue:null,severity:q.Error,code:oe.AbstractPropertyInNonAbstractEntity,entity:d});u.push(i.error)}d.properties.some(i=>i.abstract)&&d.properties.forEach(i=>{if(i.abstract){const a=st({id:d.id+"--"+oe.AbstractPropertyInNonAbstractEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${d.name}" with id "${d.id}" is marked as abstract but the entity is not marked as abstract`,issue:null,severity:q.Error,code:oe.AbstractPropertyInNonAbstractEntity,entity:d,firstRelationship:i});u.push(a.error)}})}return d.static&&d.properties.some(i=>!i.static)&&d.properties.forEach(i=>{if(!i.static){const a=st({id:d.id+"--"+oe.NonStaticPropertyInStaticEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${d.name}" with id "${d.id}" is not marked as static but the entity is marked as static`,issue:null,severity:q.Error,code:oe.NonStaticPropertyInStaticEntity,entity:d,firstRelationship:i});u.push(a.error)}}),u}function S0e(d,u){const i=[],a=Pi(u);if(!u.abstract){const t=new Xt({id:d.id+"--"+u.id+"--"+oe.ImplementingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is implementing a non-abstract built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.ImplementingNonAbstractEntity,entity:d,firstRelationship:u});i.push(t)}const l=d.implements.filter(t=>t.id!==u.id);if(d.abstract){const t=new Xt({id:d.id+"--"+u.id+"--"+oe.AbstractEntityImplements,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract and cannot implement built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.AbstractEntityImplements,entity:d,firstRelationship:u});i.push(t)}if(d.static&&!u.static){const t=new Xt({id:d.id+"--"+u.id+"--"+oe.StaticImplementingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is marked as static and cannot implement non-static built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.StaticImplementingNonStaticEntity,entity:d,firstRelationship:u});i.push(t)}if(!d.static&&u.static){const t=new Xt({id:d.id+"--"+u.id+"--"+oe.NonStaticImplementingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is not marked as static and cannot implement static built-in entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.NonStaticImplementingStaticEntity,entity:d,firstRelationship:u});i.push(t)}return l.length&&l.forEach(t=>{if(t.type===f.BuiltInBaseEntity){const y=a.filter(v=>v.id!==t.id);y.length&&y.forEach(v=>{if(v.id!==t.id){const T=new Xt({id:d.id+"--"+v.id+"--"+t.id+"--"+oe.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${v.name}" with id "${v.id}" but also implements entity "${t.name}" with id "${t.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ImplementsIncompatibleEntities,entity:d,firstRelationship:v,secondRelationship:t});i.push(T)}})}else{Pi(t).forEach(R=>{const A=a.filter(P=>P.id!==R.id);A.length&&A.forEach(P=>{if(P.id!==R.id){const N=new Xt({id:d.id+"--"+P.id+"--"+R.id+"--"+oe.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${P.name}" with id "${P.id}" but also implements entity "${R.name}" with id "${R.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ImplementsIncompatibleEntities,entity:d,firstRelationship:P,secondRelationship:R});i.push(N)}})});const v=Ia(u.ownDeclaredProperties,t.ownDeclaredProperties,ne.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,ne.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);i.push(...v.errors);const T=Ia(u.abstractMethods,[...t.abstractMethods,...t.methods],ne.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,ne.MethodOverwritesOtherImplementedEntitysMethodWithSameName);i.push(...T.errors)}}),w(d.extends.flatMap(t=>Pi(t))).forEach(t=>{if(!a.find(y=>y.id===t.id)){const y=new Xt({id:d.id+"--"+u.id+"--"+t.id+"--"+oe.ExtendsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${u.name}" with id "${u.id}" but also extends entity "${t.name}" with id "${t.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ExtendsIncompatibleEntities,entity:d,firstRelationship:u,secondRelationship:t});i.push(y)}}),i}function q0e(d,u,i=!1){const a=[],l=Pi(u);if(!d.abstract&&u.abstract){const R=st({id:d.id+"--"+u.id+"--"+oe.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not-abstract but is extending an abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:u});a.push(R.error)}if(d.abstract&&!u.abstract){const R=st({id:d.id+"--"+u.id+"--"+oe.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but is extending an non-abstract entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:u});a.push(R.error)}if(!d.static&&u.static){const R=st({id:d.id+"--"+u.id+"--"+oe.NonStaticExtendingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is not static but is extending a static entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.NonStaticExtendingStaticEntity,entity:d,firstRelationship:u});a.push(R.error)}if(d.static&&!u.static){const R=st({id:d.id+"--"+u.id+"--"+oe.StaticExtendingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but is extending an non-static entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.StaticExtendingNonStaticEntity,entity:d,firstRelationship:u});a.push(R.error)}if(!Vp(u)){const R=st({id:d.id+"--"+u.id+"--"+oe.ExtendingNonInteractiveEntity,message:`Entity "${d.name}" with id "${d.id}" is extending an non-interactive entity "${u.name}" with id "${u.id}"`,issue:null,severity:q.Error,code:oe.ExtendingNonInteractiveEntity,entity:d,firstRelationship:u});a.push(R.error)}const t=d.extends.filter(R=>R.id!==u.id);t.length&&t.forEach(R=>{if(R.type===f.BuiltInBaseEntity){const A=l.filter(P=>P.id!==R.id);A.length&&A.forEach(P=>{if(P.id!==R.id){const N=st({id:d.id+"--"+P.id+"--"+R.id+"--"+oe.ExtendsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${P.name}" with id "${P.id}" but also extends entity "${R.name}" with id "${R.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ExtendsIncompatibleEntities,entity:d,firstRelationship:P,secondRelationship:R});a.push(N.error)}})}else{Pi(R).forEach(J=>{const se=l.filter(te=>te.id!==J.id);se.length&&se.forEach(te=>{if(te.id!==J.id){const ce=new Xt({id:d.id+"--"+te.id+"--"+J.id+"--"+oe.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${te.name}" with id "${te.id}" but also extends or implements entity "${J.name}" with id "${J.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ImplementsIncompatibleEntities,entity:d,firstRelationship:te,secondRelationship:J});a.push(ce)}})});const P=!!Pi(R).find(J=>J.id===u.id);let N=[...R.properties];P&&(N=N.filter(J=>!u.properties.find(se=>{var te;return se.id===J.id||se.name===J.name||se.id===((te=J.implements)==null?void 0:te.id)})));let U=[...R.methods];P&&(U=U.filter(J=>!u.methods.find(se=>{var te;return se.id===J.id||se.name===J.name||se.id===((te=J.implements)==null?void 0:te.id)})));const K=Ia(u.ownDeclaredProperties,N,ne.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation,ne.PropertyOverwritesOtherExtendedEntitysPropertyWithSameName);a.push(...K.errors);const k=Ia(u.abstractMethods,U,ne.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation,ne.MethodOverwritesOtherExtendedEntitysMethodWithSameName);a.push(...k.errors)}}),i&&Fe.log("self.implements.length",d.implements.length),d.implements.length&&d.implements.forEach(R=>{if(R.type===f.BuiltInBaseEntity){const A=l.filter(P=>P.id!==R.id);A.length&&A.forEach(P=>{if(P.id!==R.id){const N=new Xt({id:d.id+"--"+P.id+"--"+R.id+"--"+oe.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${P.name}" with id "${P.id}" but also implements entity "${R.name}" with id "${R.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ImplementsIncompatibleEntities,entity:d,firstRelationship:P,secondRelationship:R});a.push(N)}})}else{Pi(R).forEach(U=>{const K=l.filter(k=>k.id!==U.id);K.length&&K.forEach(k=>{if(k.id!==U.id){const J=new Xt({id:d.id+"--"+k.id+"--"+U.id+"--"+oe.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${k.name}" with id "${k.id}" but also implements entity "${U.name}" with id "${U.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ImplementsIncompatibleEntities,entity:d,firstRelationship:k,secondRelationship:U});a.push(J)}})});const P=Ia(u.ownDeclaredProperties,R.ownDeclaredProperties,ne.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,ne.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);a.push(...P.errors);const N=Ia(u.abstractMethods,[...R.abstractMethods,...R.methods],ne.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,ne.MethodOverwritesOtherImplementedEntitysMethodWithSameName);a.push(...N.errors)}});const y=Ia(d.ownDeclaredProperties,u.ownDeclaredProperties,ne.PropertyOverwritesOtherSiblingWithSameImplementation,ne.PropertyOverwritesOtherSiblingWithSameName);a.push(...y.errors);const v=Ia(u.methods,u.abstractMethods,ne.MethodOverwritesOtherSiblingWithSameImplementation,ne.MethodOverwritesOtherSiblingWithSameName);return a.push(...v.errors),w(d.extends.flatMap(R=>Pi(R))).forEach(R=>{if(!l.find(A=>A.id===R.id)){const A=new Xt({id:d.id+"--"+u.id+"--"+R.id+"--"+oe.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${u.name}" with id "${u.id}" but also extends entity "${R.name}" with id "${R.id}" which is incompatible`,issue:null,severity:q.Error,code:oe.ImplementsIncompatibleEntities,entity:d,firstRelationship:u,secondRelationship:R});a.push(A)}}),a}function Z0e(d){const u=[];return d.implements.forEach(i=>{if(!i.static){const a=new Xt({id:d.id+"--"+i.id+"--"+oe.StaticImplementingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but implements entity "${i.name}" with id "${i.id}" which is non-static`,issue:null,severity:q.Error,code:oe.StaticImplementingNonStaticEntity,entity:d,firstRelationship:i});u.push(a)}}),d.extends.forEach(i=>{if(!i.static){const a=new Xt({id:d.id+"--"+i.id+"--"+oe.StaticExtendingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but extends entity "${i.name}" with id "${i.id}" which is non-static`,issue:null,severity:q.Error,code:oe.StaticExtendingNonStaticEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function J0e(d){const u=[];if(d.implements.length){const i=new Xt({id:d.id+"--"+oe.AbstractEntityImplements,message:`Entity "${d.name}" with id "${d.id}" cannot be marked as abstract because it implements other entities`,issue:null,severity:q.Error,code:oe.AbstractEntityImplements,entity:d});u.push(i)}return d.extends.forEach(i=>{if(!i.abstract){const a=new Xt({id:d.id+"--"+i.id+"--"+oe.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but extends entity "${i.name}" with id "${i.id}" which is non-abstract`,issue:null,severity:q.Error,code:oe.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function W0e(d){const u=[];return d.extends.forEach(i=>{if(i.static){const a=new Xt({id:d.id+"--"+i.id+"--"+oe.NonStaticExtendingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is non-static but extends entity "${i.name}" with id "${i.id}" which is static`,issue:null,severity:q.Error,code:oe.NonStaticExtendingStaticEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function H0e(d){const u=[];return d.extends.forEach(i=>{if(i.abstract){const a=new Xt({id:d.id+"--"+i.id+"--"+oe.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is non-abstract but extends entity "${i.name}" with id "${i.id}" which is abstract`,issue:null,severity:q.Error,code:oe.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:i});u.push(a)}}),u}function FG(d){const u=[],i=d.name;if(!i){const P=st({id:`${d.id}--${ne.EmptyName}`,message:`Definition entity "${ie(d,d.project)}" with id "${d.id}" does not have a name. Entities of type ${d.type} must have valid names.`,issue:null,severity:q.Error,code:ne.EmptyName,entity:d});return u.push(P.error),u}const l=[...d.project.functions,...d.project.entities.flatMap(P=>P.methods)].filter(P=>P.id!==d.id),p=i.trim(),t=!l.some(P=>P.name===i||P.name===p);if(!t){const P=st({id:`${d.id}--${ne.NameNotUniqueInScope}`,message:`Definition entity "${ie(d,d.project)}" with id "${d.id}" does not have a unique name. Entities of type ${d.type} must have valid names among all other entities of its type.`,issue:null,severity:q.Error,code:ne.NameNotUniqueInScope,entity:d});u.push(P.error)}const y=$r(i);if(!!l.some(P=>$r(P.name)===y)&&t){const P=st({id:`${d.id}--${ne.NameAsResolvedCodeNameNotUniqueInScope}`,message:`Definition entity "${ie(d,d.project)}" with id "${d.id}" does not have a unique name once it is resolved as it will appear in code: "${y}". Entities of type ${d.type} must have valid names including their code name form.`,issue:null,severity:q.Error,code:ne.NameAsResolvedCodeNameNotUniqueInScope,entity:d});u.push(P.error)}if(!/^[a-zA-Z_]/.test(i)){const P=st({id:`${d.id}--${ne.NameMustStartWithLetterOrUnderscore}`,message:`Definition entity "${ie(d,d.project)}" with id "${d.id}" has a name that does not start with a letter or underscore.`,issue:null,severity:q.Error,code:ne.NameMustStartWithLetterOrUnderscore,entity:d});u.push(P.error)}const R=i.substring(1);if(!/^[a-zA-Z0-9_ ]*$/.test(R)){const P=st({id:`${d.id}--${ne.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces}`,message:`Definition entity "${ie(d,d.project)}" with id "${d.id}" has a name that contains invalid characters. It can only contain letters, numbers, underscores and spaces.`,issue:null,severity:q.Error,code:ne.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces,entity:d});u.push(P.error)}return u}const Y0e=Object.freeze(Object.defineProperty({__proto__:null,getBaseMethodsNotImplemented:xG,getBasePropertiesNotImplemented:jG,validate:UG,validateCanBecomeAbstract:J0e,validateCanBecomeNonAbstract:H0e,validateCanBecomeNonStatic:W0e,validateCanBecomeStatic:Z0e,validateCanExtendEntity:q0e,validateCanImplementEntity:S0e,validateDefinitionEntityName:FG},Symbol.toStringTag,{value:"Module"}));function z0e(d,u){const i=[];if(d.parent)if(d.id===d.parent)i.push(new Q({id:`${d.id}--${d.parent}--${S.SelfReference}`,code:S.SelfReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at 'parent'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null}));else{const a=u.get(d.parent);a?[f.Project,f.DataType].includes(a.type)||i.push(new Q({id:`${d.id}--${d.parent}--${S.InvalidParentReference}`,code:S.InvalidParentReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):i.push(new Q({id:`${d.id}--${d.parent}--${S.ReferencedEntityNotFound}`,code:S.ReferencedEntityNotFound,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return d.implements&&Array.isArray(d.implements)?d.implements.forEach(a=>{if(d.id===a){i.push(new Q({id:`${d.id}--${a}--${S.SelfReference}`,code:S.SelfReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at one of the 'implements' references. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null}));return}const l=u.get(a);l?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(l.type)?l.abstract||i.push(new Q({id:`${d.id}--${a}--${S.InvalidImplementsReference}`,code:S.InvalidImplementsReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.InvalidImplementsReference}`,code:S.InvalidImplementsReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.ReferencedEntityNotFound}`,code:S.ReferencedEntityNotFound,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${a}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):i.push(new Q({id:`${d.id}--${ne.InvalidObjectStructure}`,code:ne.InvalidObjectStructure,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' property that isn't an array.`,issue:null})),d.extends&&Array.isArray(d.extends)&&d.extends.forEach(a=>{const l=u.get(a);l?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(l.type)?l.abstract&&i.push(new Q({id:`${d.id}--${a}--${S.InvalidExtendsReference}`,code:S.InvalidExtendsReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'extends' reference that isn't pointing to a non-abstract entity. Did you want to use the property 'implements', which holds a list of references to absract entities, instead?`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.InvalidExtendsReference}`,code:S.InvalidExtendsReference,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'extends' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):i.push(new Q({id:`${d.id}--${a}--${S.ReferencedEntityNotFound}`,code:S.ReferencedEntityNotFound,severity:q.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${a}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),i}var Xy=(d=>(d.Extends="extends",d.Implements="implements",d))(Xy||{});const Ut=class Ut extends Rr{constructor(i,a){super(i);O(this,"initialData");O(this,"id");O(this,"name");O(this,"codeName",null);O(this,"description",null);O(this,"x");O(this,"y");O(this,"static");O(this,"abstract");O(this,"type",f.DefinitionEntity);O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"implements",[]);O(this,"project");O(this,"errors",[]);O(this,"parent");O(this,"detachedDependents",{});O(this,"knownVersions",null);O(this,"activeVersion",!1);O(this,"initialized",!1);O(this,"startedInitialization",!1);O(this,"suggestedProperties",[]);O(this,"suggestedMethods",[]);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.static=i.static,this.abstract=i.abstract}static new(i=null){return{id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,type:f.DefinitionEntity,name:"",codeName:null,description:"",static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:null}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const T=Z(i.parent);l=a.get(T)}const p=[];i.implements&&i.implements.forEach(T=>{p.push(a.get(T)||a.getBuiltIn(T))});const t=[];i.extends&&i.extends.forEach(T=>{t.push(a.get(T)||a.getBuiltIn(T))});const y={id:i.id,version:V.UUID.uuid(),createdAt:L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,type:f.DefinitionEntity,codeName:i.codeName||null,description:i.description,static:i.static,abstract:i.abstract,properties:[],methods:[],abstractMethods:[],extends:t,implements:p,x:0,y:0,parent:l},v=ee(y,a);return v.setParent(l,null),v}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[],t=z0e(l,a),y=xA(l,a);p.push(...t,...y,...Or(l));const v=l.parent?a.get(l.parent):null;if(v&&v.type===f.DataType){const T=v;T.entity&&p.push(new Q({id:`${i.id}--${S.NewEntityWouldOverriteExisting}`,code:S.NewEntityWouldOverriteExisting,severity:q.Error,message:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${T.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
|
|
401
401
|
You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
|
|
402
402
|
${Mn({describe_entity:T.entity.id})}
|
|
403
|
-
Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:p,modifiedData:l}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return w([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return w([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allMethods,[]),...this.implements.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allProperties,[]),...this.implements.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return w([...this.extends.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[]),...this.implements.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[])])}get allBaseMethodsFromExtendedAndImplementedEntities(){return w([...this.extends.reduce((i,a)=>a.type!==f.DefinitionEntity?[]:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[]),...this.implements.reduce((i,a)=>a.type!==f.DefinitionEntity?a.abstractMethods:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return w(this.extends.reduce((i,a)=>{if(a.type!==f.DefinitionEntity)return[];const l=[...a.ownDeclaredMethods,...a.extendedMethodsFromOriginalParents].filter(p=>p.type!==f.ActionDescriptor);return[...i,...l]},[]))}get implementedMethodsFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.type===f.DefinitionEntity?a.methods:[],p=[...a.abstractMethods].filter(t=>!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>[...a.abstractMethods,...i],[])].filter(i=>i.type===f.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${S.InvalidParentUpdate}`,code:S.InvalidParentUpdate,severity:q.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.removeImplementation(i),a==="extends"&&this.removeExtension(i),{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.addImplementation(i),a==="extends"&&this.addExtension(i),{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{zi.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this}subscribeToDependencies(){return this.implements.forEach(i=>{zi.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends.forEach(i=>{zi.includes(i.type)||i.subscribeDependents([{entity:this,field:"extends"}])}),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ut(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=[...this.extends],i.implements=[...this.implements],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ut(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.properties=y.properties,this.methods=y.methods,this.abstractMethods=y.abstractMethods,this.extends=y.extends,this.implements=y.implements,this.parent=y.parent,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=Z(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return i.extends.forEach(l=>{const p=Z(l),t=this.project.get(p);t&&this.addExtension(t)}),i.implements.forEach(l=>{const p=Z(l),t=this.project.get(p);t&&this.addImplementation(t)}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=Z(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return this.initialData.extends.forEach(t=>{const y=Z(t),v=this.project.get(y);v&&(this.addExtension(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),this.initialData.implements.forEach(t=>{const y=Z(t),v=this.project.get(y);v&&(this.addImplementation(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:T,affected:R}=this.syncImplementationProperties(i);a.push(...y),l.push(...v),p.push(...T),t.push(...R);const{updated:A,added:P,removed:N,affected:U}=this.addExtendedProperties(i);a.push(...A),l.push(...P),p.push(...N),t.push(...U);const{updated:K,added:k,removed:J}=this.removeUnrecognizedProperties(i);a.push(...K),l.push(...k),p.push(...J);const{updated:se,added:te,removed:ce,affected:re}=this.syncImplementationMethods(i);a.push(...se),l.push(...te),p.push(...ce),t.push(...re);const{updated:fe,added:z,removed:Y,affected:ue}=this.addExtendedMethods(i);a.push(...fe),l.push(...z),p.push(...Y),t.push(...ue);const{updated:H,added:ae,removed:be}=this.removeUnrecognizedMethods(i);return a.push(...H),l.push(...ae),p.push(...be),this.addSuggestions(),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];if(this.parent.type===f.DataType){const y=this.parent;y.entity=this,a.push(y)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}setParent(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}addExtension(i){return this.extends.includes(i)||this.extends.push(i),this}removeExtension(i){return this.extends=this.extends.filter(a=>a.id!==i.id),this}addImplementation(i){return this.implements.includes(i)||this.implements.push(i),this}removeImplementation(i){return this.implements=this.implements.filter(a=>a.id!==i.id),this}removeProperty(i){return this.properties=this.properties.filter(a=>a.id!==i.id),this}addMethod(i){return this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name)),this}removeMethod(i){return this.methods=this.methods.filter(a=>a.id!==i.id),this}addProperty(i){return this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name)),this}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(a=>a.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(a=>a.id!==i.id),this}addAbstractMethod(i){return this.abstractMethods.includes(i)||this.abstractMethods.push(i),this}removeAbstractMethod(i){return this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),this}initChildren(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.properties=this.initialData.properties.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.methods=this.initialData.methods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.extends=this.initialData.extends.map(a=>ee(a,this.project)),this.implements=this.initialData.implements.map(a=>ee(a,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}removeUnrecognizedProperties(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-properties"))){const a=[],l=[],p=[],t=[];let y=[...this.properties];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedProperty);const v=this.implementedPropertiesFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(R=>{var A;return R.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const R=T.remove({ignoreUpstream:!1},i);p.push(...R.removed),a.push(...R.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-methods"))){const a=[],l=[],p=[],t=[];let y=[...this.methods];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedMethod);const v=this.implementedMethodsFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(R=>{var A;return R.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const R=T.remove({ignoreUpstream:!1},i);p.push(...R.removed),a.push(...R.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,v=this.implementedMethodsFromOriginalParents,T=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var U;return((U=N.implements)==null?void 0:U.id)===A.id})).forEach(A=>{if(this.methods.find(K=>{var k;return((k=K.implements)==null?void 0:k.id)===A.id}))return;const N=this.methods.find(K=>{var ce,re;if(K.name===A.name&&!K.implements)return!0;const k=as(this,Ve.CRON_JOB),J=as(this,Ve.HTTP_ENDPOINT),se=((ce=K.implements)==null?void 0:ce.id)===ve["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,te=((re=K.implements)==null?void 0:re.id)===ve["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(k&&!te&&!J&&se||J&&!se&&!k&&te)});if(N&&N.type===f.FunctionDeclaration){N.setImplements(A,i),N.metaSync({name:A.name},i),i==null||i.add(N,G.Updated),i==null||i.add(this,G.Updated);return}const U=A.implementAsFunctionDeclaration(i,this);l.push(U),i==null||i.add(U,G.Added),this.addMethod(U)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.implementedPropertiesFromOriginalParents,T=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var U;return((U=N.implements)==null?void 0:U.id)===A.id})).forEach(A=>{if(this.properties.find(K=>{var k;return((k=K.implements)==null?void 0:k.id)===A.id}))return;const N=this.properties.find(K=>K.name===A.name&&!!K.abstract&&!K.implements);if(N){N.setImplements(A,i),N.metaSync({abstract:!1},i),N.afterAllChildrenInitialized(i);return}const U=A.implement(this,i,V.UUID.uuid());l.push(U),i==null||i.add(U,G.Added)}),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addExtendedMethods(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-extended-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,T=this.extendedMethodsFromOriginalParents.filter(A=>A.type===f.FunctionDeclaration),R=new Set(y.filter(A=>{var P;return!!((P=A.extends)!=null&&P.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(R.has(A.id))return;R.add(A.id);const P=A.clone(i,this,V.UUID.uuid());P.setExtends(A,i),P.initChildren(i),l.push(P),i==null||i.add(P,G.Added),this.addMethod(P)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addExtendedProperties(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-extended-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.extendedPropertiesFromOriginalParents,T=v.filter(A=>v.find(N=>{var U;return((U=N.implements)==null?void 0:U.id)===A.id})?!1:!A.abstract),R=new Set(y.filter(A=>{var P;return!!((P=A.extends)!=null&&P.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(R.has(A.id))return;R.add(A.id);const P=A.clone(i,this,V.UUID.uuid());P.setExtends(A,i),P.initChildren(i),l.push(P),i==null||i.add(P,G.Added),this.addProperty(P)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSuggestions(){return this.implements.forEach(i=>{jG(this,i).forEach(p=>{const t=p.toJSON();t.id=`_suggestion--parent--${this.id}--${p.id}`;const y=ee(t,this.project);y.suggestion=!0,y.setParent(this,null),y.initChildren(null),this.addSuggestedProperty(y)}),xG(this,i).forEach(p=>{const t=`_suggestion--parent--${this.id}--${p.id}`,y=p.implementAsFunctionDeclaration(null,this,t),v=ee(y,this.project);if(v.suggestion=!0,v.setParent(this,null),v.initChildren(null),this.methods=this.methods.filter(T=>T.id!==t),v.inputs.forEach(T=>{T.suggestion=!0}),v.returnStatements.length){const T=v.returnStatements[0];T.suggestion=!0,T.outputs.forEach(R=>{R.suggestion=!0})}this.addSuggestedMethod(v)})}),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,this.static=i.static!==void 0?i.static:this.static,this.abstract=i.abstract!==void 0?i.abstract:this.abstract,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await Ut.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await Ut.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await Ut.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await Ut.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await Ut.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await Ut.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];if(this.parent.type===f.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===f.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const y=this.parent.setEntity(null,i);a.push(y)}return i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:w(p),updated:w(a),removed:w(l),affected:w(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:R,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),p.push(...R),t.push(...A)}),this.properties.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.methods.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.abstractMethods.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.suggestedProperties.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.suggestedMethods.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:w(t),updated:w(l),removed:w(p),affected:w(y),self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:T,added:R}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...T),a.push(...R)}),this.properties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.methods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.abstractMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedProperties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:w(a),updated:w(l),removed:w(p),affected:w(t),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.extends.flatMap(l=>l.toFlat(i)),...this.implements.flatMap(l=>l.toFlat(i)),...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.extends.flatMap(l=>l.toFlatIds(i)),...this.implements.flatMap(l=>l.toFlatIds(i)),...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),implements:this.implements.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i)),parent:this.parent.toReference()})}toJSONClone(i=xe){var l,p,t,y,v;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Nr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(T=>T.toJSONClone({...i,newId:null})),methods:this.methods.map(T=>T.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(T=>T.toJSONClone({...i,newId:null})),implements:this.implements.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),extends:this.extends.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(p=>p.toReference(i)),methods:this.methods.map(p=>p.toReference(i)),abstractMethods:this.abstractMethods.map(p=>p.toReference(i)),implements:this.implements.map(p=>p.toReference(i)),extends:this.extends.map(p=>p.toReference(i)),parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i)),...this.implements.flatMap(l=>l.toFlatJSON(i)),...this.extends.flatMap(l=>l.toFlatJSON(i)),...this.parent.toFlatJSON(i)])}toGenerationTarget(){const i=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:this.extends.map(a=>a.id),implements:this.implements.map(a=>a.id),parent:i}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.parent.toFlatGenerationTarget(i)])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=UG(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var K,k,J;let t=Vr(a,this);const y=this.toJSON(),v=l||V.UUID.uuid();y.properties=[],y.methods=[],y.abstractMethods=[];const T=v.split("-id"),R=T[T.length-1||0]||v;y.id=v,y.version=V.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const A=zt(y,t);a&&A.setParent(a,null),p&&A.subscribe(),A.initChildren(i),i==null||i.add(A,G.Added);const P=(K=this.properties)==null?void 0:K.map(se=>se.clone(i,A,V.UUID.uuid(),p));A.properties=P;const N=(k=this.methods)==null?void 0:k.map((se,te)=>se.clone(i,A,R+"-method-"+te+"-id",p));A.methods=N;const U=(J=this.abstractMethods)==null?void 0:J.map((se,te)=>se.clone(i,A,R+"-abstract-method-"+te+"-id",p));return A.abstractMethods=U,i==null||i.attemptAutoclose("clone-entity",this.id),A}getFunctionDeclaration(i){return this.methods.find(a=>a.id===i)}implement(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-definition-entity")),l){const p=By(this,i,a,l);return a==null||a.attemptAutoclose("implement-definition-entity",this.id),p}getAllInteractiveMethods(){const i=this.implements.filter(l=>l.type===f.DefinitionEntity||l.type===f.BuiltInBaseEntity&&l.interactive);return w([...this.methods,...this.extends.flatMap(l=>l.getAllInteractiveMethods()),...i.flatMap(l=>l.getAllInteractiveMethods())])}inferFromInputs(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const l=[],p=[],t=[],y=[];if(this.parent.type!==f.DataType||!this.parent.inferred)return a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const v=[];i.forEach(A=>{v.find(N=>ie(N,this.project)===ie(A,this.project))||v.push(A)});const T=this.properties.filter(A=>!A.dataType);v.forEach(A=>{var se,te,ce;const P=T.find(re=>ie(re,this.project)===ie(A,this.project));if(!P)return;const U=bi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),K=tn(U,a),k=K==null?void 0:K.clone(a,P,V.UUID.uuid(),!0);k&&((se=P.dataType)==null||se.merge(k,a),k.id!==((te=P.dataType)==null?void 0:te.id)&&k.remove({ignoreUpstream:!1},a),P.dataType&&(P.dataType.metaSync({inferred:!0,like:!0},a),P.setDataType(P.dataType,a),a==null||a.add(P,G.Affected)));let J=null;if(A.declaration&&P.id!==((ce=A.declaration)==null?void 0:ce.id)&&(J=A.declaration),A.setDeclaration(P,a),a==null||a.add(A,G.Updated),J){const{updated:re,removed:fe}=J.remove({ignoreUpstream:!1},a);p.push(...re),t.push(...fe)}});const R=[];return v.forEach(A=>{if(!A.declaration){R.push(A);return}}),R.length===0?(a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(R.forEach(A=>{var te,ce,re,fe;const P=this.properties.find(z=>ie(z,this.project)===ie(A,this.project));if(P){if(A.setDeclaration(P,a),!P.getDataType(a)){const Y=bi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),ue=tn(Y),H=ue==null?void 0:ue.clone(a,P,V.UUID.uuid(),!0);H&&((te=P.dataType)==null||te.merge(H,a),H.id!==((ce=P.dataType)==null?void 0:ce.id)&&H.remove({ignoreUpstream:!1},a),P.dataType&&(P.dataType.metaSync({inferred:!0,like:!0},a),P.setDataType(P.dataType,a),a==null||a.add(P,G.Affected)))}return}const N=jn.new(a);N.parent=this.toReference(),N.index=A.index,N.name=ie(A,this.project),N.codeName=A.codeName,N.description=A.description;const U=ee(N,this.project);U.hydrateAncestors(),a==null||a.add(U,G.Added),U.setParent(this,a),U.initChildren(a);const k=bi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),J=tn(k),se=J==null?void 0:J.clone(a,U,V.UUID.uuid(),!0);return se&&((re=U.dataType)==null||re.merge(se,a),se.id!==((fe=U.dataType)==null?void 0:fe.id)&&se.remove({ignoreUpstream:!1},a),U.dataType&&(U.dataType.metaSync({inferred:!0,like:!0},a),U.setDataType(U.dataType,a),a==null||a.add(U,G.Affected))),this.addProperty(U),A.setDeclaration(U,a),a==null||a.add(A,G.Updated),U}),a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:w(l),updated:w(p),removed:w(t),affected:w(y),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(a=>{var p;if(!jA(a))return;const l=$r(a.name);i[l]=((p=a.getDefaultValue())==null?void 0:p.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(a=>{var t;if(!jA(a))return;const l=$r(a.name),p=(t=this.project.requestActiveDynamicValue(a))==null?void 0:t.value;i[l]=(p==null?void 0:p.value)||null}),i}};O(Ut,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),O(Ut,"type",f.DefinitionEntity),O(Ut,"USER_MANAGED_PARENT_TYPES",[f.Project,f.DataType]),O(Ut,"PARENT_TYPES",[...Ut.USER_MANAGED_PARENT_TYPES]),O(Ut,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract"]),O(Ut,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),O(Ut,"BASE_PROPERTIES",[...Ut.MUTABLE_BASE_PROPERTIES,...Ut.INMUTABLE_BASE_PROPERTIES]),O(Ut,"MUTABLE_META_PROPERTIES",[...Ut.MUTABLE_BASE_PROPERTIES,"x","y"]),O(Ut,"INMUTABLE_META_PROPERTIES",[...Ut.INMUTABLE_BASE_PROPERTIES]),O(Ut,"META_PROPERTIES",[...Ut.MUTABLE_META_PROPERTIES,...Ut.INMUTABLE_META_PROPERTIES]),O(Ut,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),O(Ut,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),O(Ut,"UPSTREAM_PROPERTIES",[...Ut.MUTABLE_UPSTREAM_PROPERTIES,...Ut.INMUTABLE_UPSTREAM_PROPERTIES]),O(Ut,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),O(Ut,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),O(Ut,"DOWNSTREAM_PROPERTIES",[...Ut.MUTABLE_DOWNSTREAM_PROPERTIES,...Ut.INMUTABLE_DOWNSTREAM_PROPERTIES]),O(Ut,"PROPERTIES",[...Ut.META_PROPERTIES,...Ut.UPSTREAM_PROPERTIES,...Ut.DOWNSTREAM_PROPERTIES]);let wa=Ut;function X0e(d){const u=pce(),i=d.toJSON();u.safeParse(i).success;const l=[];return ar(d.errors,l)}const Fp=class Fp extends Rr{constructor(i,a){super(i);O(this,"initialData");O(this,"id");O(this,"version");O(this,"name");O(this,"description",null);O(this,"type",f.BuiltInBaseEntity);O(this,"abstract",!1);O(this,"static");O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"interactive",!1);O(this,"errors",[]);O(this,"project");this.initialData=this.initialData||i,this.project=this.project||a,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.extends=this.initialData.extends.map(l=>ee(l,this.project))}get allMethods(){return w([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return w([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=me,...a){return await Fp.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.extends.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.extends.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,interactive:this.interactive,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=xe){return{id:this.id+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=xe){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=X0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}implement(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),null,!0,"implement-built-in-base-entity")),l){const p=By(this,i,a,l);return a==null||a.attemptAutoclose("implement-built-in-base-entity",this.id),p}getAllInteractiveMethods(){const i=[];return this.interactive&&(i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof Fp&&i.push(...l.getAllInteractiveMethods())})),w(i)}};O(Fp,"repository",{APILoad:async(i,...a)=>null});let xn=Fp;function Q0e(d){const u=oce(),i=d.toJSON();u.safeParse(i).success;const l=[];return ar(d.errors,l)}const rm=class rm extends Rr{constructor(i,a){super(i);O(this,"initialData");O(this,"id");O(this,"name");O(this,"description",null);O(this,"type",f.PrimitiveEntity);O(this,"static");O(this,"abstract");O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"errors",[]);O(this,"project");this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.parent=this,p})}get allMethods(){return w([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return w([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=me,...a){return await rm.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=xe){return{id:this.id+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=xe){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=Q0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof xn&&i.push(...l.getAllInteractiveMethods())}),w(i)}};O(rm,"repository",{APILoad:async(i,...a)=>null});let ki=rm;function zt(d,u){if(!d)throw new Error("Entity is null");const i=u.get(d.id);switch(d.type){case f.LiteralValue:return i||new $i(d,u);case f.DefinitionEntity:return i||new wa(d,u);case f.PrimitiveEntity:return i||new ki(d,u);case f.FunctionDeclaration:return i||new Ka(d,u);case f.GlobalEvent:return i||new qa(d,u);case f.DataType:return i||new is(d,u);case f.Property:return i||new jn(d,u);case f.FunctionCall:return i||new so(d,u);case f.Condition:return i||new Za(d,u);case f.Operation:return i||new ka(d,u);case f.VariableDeclaration:return i||new Wa(d,u);case f.VariableInstance:return i||new Ja(d,u);case f.OutputMap:return i||new rn(d,u);case f.ReturnDeclaration:return i||new Ki(d,u);case f.ArgumentDeclaration:return i||new Ea(d,u);case f.InputMap:return i||new Ln(d,u);case f.Project:return i||new V(d);case f.InstalledProject:return i||new Ya(d,u);case f.ActionDescriptor:return i||new ht(d,u);case f.ReturnStatement:return i||new Sa(d,u);case f.Loop:return i||new Oi(d,u);case f.Search:return i||new Ha(d,u);case f.ValueDescriptor:return i||new sn(d,u);case f.BuiltInBaseEntity:return i||new xn(d,u);case f.InternalCall:return i||new za(d,u);case f.ContinueStatement:return i||new Ti(d,u);case f.BreakStatement:return i||new Xa(d,u);case f.GenericReference:return u.get(d.entityId);default:throw new Error("Invalid entity type: "+d.type)}}function ee(d,u){if(!d)throw new Error("Entity is null");const i=zt(d,u);return i.subscribe(),i}function eve(d,u){if(!d)throw new Error("Entity is null");switch(d.type){case f.LiteralValue:return $i.fromGenerationTarget(d,u);case f.DefinitionEntity:return wa.fromGenerationTarget(d,u);case f.FunctionDeclaration:return Ka.fromGenerationTarget(d,u);case f.GlobalEvent:return qa.fromGenerationTarget(d,u);case f.DataType:return is.fromGenerationTarget(d,u);case f.Property:return jn.fromGenerationTarget(d,u);case f.FunctionCall:return so.fromGenerationTarget(d,u);case f.Condition:return Za.fromGenerationTarget(d,u);case f.Operation:return ka.fromGenerationTarget(d,u);case f.VariableDeclaration:return Wa.fromGenerationTarget(d,u);case f.VariableInstance:return Ja.fromGenerationTarget(d,u);case f.OutputMap:return rn.fromGenerationTarget(d,u);case f.ReturnDeclaration:return Ki.fromGenerationTarget(d,u);case f.ArgumentDeclaration:return Ea.fromGenerationTarget(d,u);case f.InputMap:return Ln.fromGenerationTarget(d,u);case f.InstalledProject:return Ya.fromGenerationTarget(d,u);case f.ReturnStatement:return Sa.fromGenerationTarget(d,u);case f.Loop:return Oi.fromGenerationTarget(d,u);case f.Search:return Ha.fromGenerationTarget(d,u);case f.ActionDescriptor:return ht.fromGenerationTarget(d,u);case f.ValueDescriptor:return sn.fromGenerationTarget(d,u);case f.InternalCall:return za.fromGenerationTarget(d,u);case f.ContinueStatement:return Ti.fromGenerationTarget(d,u);case f.BreakStatement:return Xa.fromGenerationTarget(d,u);default:throw new Error("Invalid entity type: "+d.type)}}const xe={seenEntityMaps:new Map,seenEntities:new Set,timestamp:L().toISOString()};class GG{constructor(){O(this,"initialData")}}const me={cascade:!1},KG={APILoad:async(d,...u)=>null},tve={APICreate:async(d,...u)=>d,APIUpdate:async(d,...u)=>d,APIDelete:async(d,...u)=>d,APIClone:async(d,...u)=>{},APILoadVersion:async(d,u,...i)=>null,...KG};class rve{}class ive extends GG{}class sve{}class nve{}class ave{}class JA{}class ove extends JA{}class lve extends JA{}class dve{}class Up{static initReadsValue(u){if(u.initialData.readsValue&&u.initialData.readsValue.type!==f.GenericReference)u.readsValue=ee(u.initialData.readsValue,u.project);else if(u.initialData.readsValue&&u.initialData.readsValue.type===f.GenericReference){const i=Ni(u.initialData.readsValue,u.project);i&&(u.readsValue=i)}if(u.readsValue){if(ot.includes(u.readsValue.type)){let i=u.parent;Dr.includes(i.type)||(i=i.parent);const a=u.type===f.InputMap&&u.parent.type===f.Loop;a&&(i=u.parent.parent),u.readsValue.setParent(i,null),u.readsValue.initChildren(null),i&&i.type!==f.Project&&!a&&i.detachedChildren.includes(u)?i.replaceDetachedChild(u,u.readsValue):i&&i.type!==f.Project&&!a&&i.subscribeDetachedChild(u.readsValue)}u.readsValue.addValueReader(u,null)}return u.readsValue}}class jp{static initWritesValues(u,i){const a=u.initialData.writesValues.reduce((p,t)=>{if(t.type===f.GenericReference||u.writesValues.some(v=>v.id===t.id))return p;const y=ee(t,u.project);return y.setValueWriter(u,null),ot.includes(y.type)&&(y.setParent(i,null),y.initChildren(null)),[...p,y]},[]),l=[...u.writesValues];return u.writesValues=w([...l,...a]),u.writesValues}}class uve{}var gr=(d=>(d.PROJECT_INITIALIZED="project-initialized",d.CHANGE_SET_CLOSED="change-set-closed",d.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",d.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",d.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",d.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",d.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",d.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",d))(gr||{});const WA={...zb,events:new wp},kG={onRequestActiveDynamicValue:d=>null,...WA},it=class it extends Rr{constructor(i,a={...kG,events:new wp}){super(i);O(this,"initialData");O(this,"id");O(this,"type",f.Project);O(this,"name",null);O(this,"description",null);O(this,"x");O(this,"y");O(this,"entities",[]);O(this,"projects",[]);O(this,"functions",[]);O(this,"events",[]);O(this,"variableDeclarations",[]);O(this,"variableInstances",[]);O(this,"conditions",[]);O(this,"operations",[]);O(this,"functionCalls",[]);O(this,"loops",[]);O(this,"searches",[]);O(this,"primitives",[]);O(this,"builtInBaseEntities",[]);O(this,"operationDeclarations",[]);O(this,"globalEventActionDescriptors",[]);O(this,"loopDeclarations",[]);O(this,"loopDeclarationsBodies",[]);O(this,"conditionDeclarations",[]);O(this,"valueDescriptors",[]);O(this,"dataTypes",[]);O(this,"project");O(this,"instances",{});O(this,"builtInInstances",{});O(this,"deletedInstances",{});O(this,"errors",[]);O(this,"references",[]);O(this,"history",[]);O(this,"undoableStackValueIndex",-1);O(this,"detachedDependents",{});O(this,"knownVersions",null);O(this,"activeVersion",!1);O(this,"initialized",!1);O(this,"startedInitialization",!1);O(this,"onCloseChangeSetCallback",null);O(this,"onAddChangeSetCallback",null);O(this,"onDiscardChangeSetCallback",null);if(this.parentContext=a,this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this,!it.UUID)throw new Error("UUID module is already initialized. Please inject a valid UUID module.")}static get UUID(){return this.parentContext.onRequestModule("uuid")}static new(i=null){return{id:it.UUID.uuid(),version:it.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||it.sessionAuthor,previousVersion:null,deleted:!1,type:f.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[];return p.push(...Or(l)),{errors:p,modifiedData:l}}get off(){return this.parentContext.events.off}get on(){return this.parentContext.events.on}get emit(){return this.parentContext.events.emit}async closePendingChangeSets(){const i=this.history.find(a=>a.dirty&&!a.open);i&&await this.closeChangeSet(i)}async onCloseChangeSet(i){this.onCloseChangeSetCallback=i,await this.closePendingChangeSets()}onAddChangeSet(i){this.onAddChangeSetCallback=i}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}async closeChangeSet(i){const a=this.history.findIndex(t=>t.id===i.id),l=this.history.slice(0,a),p=l[l.length-1];if(!(p!=null&&p.dirty)&&this.onCloseChangeSetCallback){(await this.onCloseChangeSetCallback(i)).success&&(i.dirty=!1,this.emit("change-set-closed",i),this.closePendingChangeSets());return}}toLatestChangeSet(i,a,l,p=!1,t="here-this"){if(!this.history.length)return new F(this,i,a,l,p,t);const y=this.history[this.history.length-1];return y.open?y:this.addChangeSet(new F(this,i,a,l,p,t))}addChangeSet(i){var p,t;if(!this.history.length)return this.undoableStackValueIndex=Eb(this.undoableStackValueIndex,this.history,i),(p=this.onAddChangeSetCallback)==null||p.call(this,i,this.undoableStackValueIndex),i;const a=this.history.find(y=>y.id===(i==null?void 0:i.id));if(a)return a;const l=this.history.find(y=>y.open);if(l)throw Fe.warn("Previous still open: ",l),Fe.warn("New change set: ",i),new Error(`There is already an open change-set with id '${l.id}'.`);return this.undoableStackValueIndex=Eb(this.undoableStackValueIndex,this.history,i),(t=this.onAddChangeSetCallback)==null||t.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var l;const a=this.history.findIndex(p=>p.id===(i==null?void 0:i.id));return a!==-1&&(this.history.splice(a,1),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(l=this.onDiscardChangeSetCallback)==null||l.call(this,i)),this}async inject(...i){return await Promise.all(i.map(a=>new Promise(async l=>{await a.init(this),l(null)}))),this}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=it.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new it(this);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new it(T)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.entities=y.entities,this.projects=y.projects,this.functions=y.functions,this.events=y.events,this.variableDeclarations=y.variableDeclarations,this.variableInstances=y.variableInstances,this.conditions=y.conditions,this.operations=y.operations,this.functionCalls=y.functionCalls,this.loops=y.loops,this.searches=y.searches,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){return this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];return{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=null){const a=[],l=[],p=[],t=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),this.captureVersion(),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i){const a=[],l=[],p=[],t=[];return this.subscribe(),this.subscribeToDependencies(),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.projects=this.initialData.projects.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableDeclarations=this.initialData.variableDeclarations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableInstances=this.initialData.variableInstances.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.conditions=this.initialData.conditions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.operations=this.initialData.operations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functions=this.initialData.functions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.events=this.initialData.events.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functionCalls=this.initialData.functionCalls.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.loops=this.initialData.loops.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.searches=this.initialData.searches.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,a=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await it.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await it.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await it.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await it.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await it.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await it.repository.APILoadVersion(this.id,a,...l)}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlatIds(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlatIds(i)),...this.operationDeclarations.flatMap(a=>a.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlatIds(i)),...this.loopDeclarations.flatMap(a=>a.toFlatIds(i)),...this.conditionDeclarations.flatMap(a=>a.toFlatIds(i)),...this.valueDescriptors.flatMap(a=>a.toFlatIds(i)),...this.dataTypes.flatMap(a=>a.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlat(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlat(i)),...this.operationDeclarations.flatMap(a=>a.toFlat(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlat(i)),...this.loopDeclarations.flatMap(a=>a.toFlat(i)),...this.conditionDeclarations.flatMap(a=>a.toFlat(i)),...this.valueDescriptors.flatMap(a=>a.toFlat(i)),...this.dataTypes.flatMap(a=>a.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(l=>l.toFlat(i)),...this.functions.flatMap(l=>l.toFlat(i)),...this.events.flatMap(l=>l.toFlat(i)),...this.projects.flatMap(l=>l.toFlat(i)),...this.variableDeclarations.flatMap(l=>l.toFlat(i)),...this.variableInstances.flatMap(l=>l.toFlat(i)),...this.conditions.flatMap(l=>l.toFlat(i)),...this.operations.flatMap(l=>l.toFlat(i)),...this.functionCalls.flatMap(l=>l.toFlat(i)),...this.loops.flatMap(l=>l.toFlat(i)),...this.searches.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(l=>l.toFlatIds(i)),...this.functions.flatMap(l=>l.toFlatIds(i)),...this.events.flatMap(l=>l.toFlatIds(i)),...this.projects.flatMap(l=>l.toFlatIds(i)),...this.variableDeclarations.flatMap(l=>l.toFlatIds(i)),...this.variableInstances.flatMap(l=>l.toFlatIds(i)),...this.conditions.flatMap(l=>l.toFlatIds(i)),...this.operations.flatMap(l=>l.toFlatIds(i)),...this.functionCalls.flatMap(l=>l.toFlatIds(i)),...this.loops.flatMap(l=>l.toFlatIds(i)),...this.searches.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(a=>a.toJSON(i)),variableDeclarations:this.variableDeclarations.map(a=>a.toJSON(i)),variableInstances:this.variableInstances.map(a=>a.toJSON(i)),conditions:this.conditions.map(a=>a.toJSON(i)),operations:this.operations.map(a=>a.toJSON(i)),loops:this.loops.map(a=>a.toJSON(i)),searches:this.searches.map(a=>a.toJSON(i)),functions:this.functions.map(a=>a.toJSON(i)),events:this.events.map(a=>a.toJSON(i)),projects:this.projects.map(a=>a.toJSON(i)),functionCalls:this.functionCalls.map(a=>a.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const a=new Map,l=new Set,p=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(t=>{if(p.includes(t)){a.set(t,t);return}a.set(t,it.UUID.uuid())}),l.add(this.id),{id:a.get(this.id),version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),projects:this.projects.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableDeclarations:this.variableDeclarations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableInstances:this.variableInstances.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),conditions:this.conditions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),operations:this.operations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functions:this.functions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),events:this.events.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functionCalls:this.functionCalls.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),loops:this.loops.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),searches:this.searches.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null}))}}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+it.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(p=>p.toReference(i)),functions:this.functions.map(p=>p.toReference(i)),events:this.events.map(p=>p.toReference(i)),projects:this.projects.map(p=>p.toReference(i)),variableDeclarations:this.variableDeclarations.map(p=>p.toReference(i)),variableInstances:this.variableInstances.map(p=>p.toReference(i)),conditions:this.conditions.map(p=>p.toReference(i)),operations:this.operations.map(p=>p.toReference(i)),functionCalls:this.functionCalls.map(p=>p.toReference(i)),loops:this.loops.map(p=>p.toReference(i)),searches:this.searches.map(p=>p.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(l=>l.toFlatJSON(i)),...this.functions.flatMap(l=>l.toFlatJSON(i)),...this.events.flatMap(l=>l.toFlatJSON(i)),...this.projects.flatMap(l=>l.toFlatJSON(i)),...this.variableDeclarations.flatMap(l=>l.toFlatJSON(i)),...this.variableInstances.flatMap(l=>l.toFlatJSON(i)),...this.conditions.flatMap(l=>l.toFlatJSON(i)),...this.operations.flatMap(l=>l.toFlatJSON(i)),...this.functionCalls.flatMap(l=>l.toFlatJSON(i)),...this.loops.flatMap(l=>l.toFlatJSON(i)),...this.searches.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.events.flatMap(l=>l.toFlatGenerationTarget(i)),...this.projects.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(l=>l.toFlatGenerationTarget(i)),...this.conditions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.operations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(l=>l.toFlatGenerationTarget(i)),...this.loops.flatMap(l=>l.toFlatGenerationTarget(i)),...this.searches.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){const i=Nfe(),a=this.toJSON();return i.safeParse(a),this.validateChildren(),{success:!0,error:null,data:a}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(a=>a.getErrors()),...this.projects.flatMap(a=>a.getErrors()),...this.functions.flatMap(a=>a.getErrors()),...this.events.flatMap(a=>a.getErrors()),...this.variableDeclarations.flatMap(a=>a.getErrors()),...this.variableInstances.flatMap(a=>a.getErrors()),...this.conditions.flatMap(a=>a.getErrors()),...this.operations.flatMap(a=>a.getErrors()),...this.functionCalls.flatMap(a=>a.getErrors()),...this.loops.flatMap(a=>a.getErrors()),...this.searches.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(){return this}getDefinitionEntity(i){return this.entities.find(a=>a.id===i)||null}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const a=this.entities.findIndex(l=>l.id===i.id);if(a>-1){const l=this.entities[a];return this.entities.splice(a,1),l}return null}removeCondition(i){const a=this.conditions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.conditions[a];return this.conditions.splice(a,1),l}return null}removeOperation(i){const a=this.operations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.operations[a];return this.operations.splice(a,1),l}return null}removeLoop(i){const a=this.loops.findIndex(l=>l.id===i.id);if(a>-1){const l=this.loops[a];return this.loops.splice(a,1),l}return null}removeSearch(i){const a=this.searches.findIndex(l=>l.id===i.id);if(a>-1){const l=this.searches[a];return this.searches.splice(a,1),l}return null}removeFunctionCall(i){const a=this.functionCalls.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functionCalls[a];return this.functionCalls.splice(a,1),l}return null}removeVariableInstance(i){const a=this.variableInstances.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableInstances[a];return this.variableInstances.splice(a,1),l}return null}removeVariableDeclaration(i){const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}removeFunctionDeclaration(i){const a=this.functions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functions[a];return this.functions.splice(a,1),l}return null}removeInstalledProject(i){const a=this.projects.findIndex(l=>l.id===i.id);if(a>-1){const l=this.projects[a];return this.projects.splice(a,1),l}return null}removeGlobalEvent(i){const a=this.events.findIndex(l=>l.id===i.id);if(a>-1){const l=this.events[a];return this.events.splice(a,1),l}return null}removeTopLevelVariableDeclaration(i){if(i.type!==f.VariableDeclaration)return null;const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(a=>a.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.ReturnStatement||t.type===f.ContinueStatement||t.type===f.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(a=>a.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.functionCalls.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.conditions.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.operations.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.loops.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.searches.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[])]}getVariableInstances(){return[...this.variableInstances,...this.entities.reduce((a,l)=>[...a,...l.methods.flatMap(p=>{const y=mt(p).filter(v=>v.type===f.VariableInstance);return[...a,...y]})],[]),...this.getEntryPoints().reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[])]}getVariableDeclarations(){return w([...this.variableDeclarations,...this.entities.reduce((a,l)=>[...a,...l.methods.flatMap(p=>{const y=mt(p).filter(v=>v.type===f.VariableDeclaration);return[...a,...y]})],[]),...this.getEntryPoints().reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),a=this.getVariableDeclarations();return i.forEach(l=>{if(!l.declaration){const p=l.initialData,t=p.declaration.entityId||p.declaration.id,y=a.find(v=>v.id===t);y&&l.setDeclaration(y)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===Ve.PERSISTED_ENTITY)||null}requestActiveDynamicValue(i){var l,p;const a=(p=(l=this.parentContext).onRequestActiveDynamicValue)==null?void 0:p.call(l,i);if(!a){const t=i.getDefaultValue();return t?{value:t,type:Te.DefaultValue,inheritanceLink:null,valueOwner:i}:null}return a||null}requestModule(i){if(this.parentContext.onRequestModule){const a=this.parentContext.onRequestModule(i);return!a&&i==="uuid"?$u:a||null}return i==="uuid"?$u:null}undo(){Fe.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,Fe.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],a=this.history[this.undoableStackValueIndex];return Fe.log("Current change set: ",i==null?void 0:i.toJSON()),Fe.log("Change set to restore: ",a==null?void 0:a.toJSON()),mb(i||"initial",a||"initial",this)}redo(){Fe.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,Fe.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],a=this.history[this.undoableStackValueIndex];return Fe.log("Current change set: ",i==null?void 0:i.toJSON()),Fe.log("Change set to restore: ",a.toJSON()),mb(i||"initial",a||"initial",this)}applyExternalChangeSet(i){const a=i.payload,l=this.addChangeSet(new F(this,i.userAuthor,i.emittedAt,this)),p=a.updated[this.id];if(!p)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const t={...a.added,...a.updated,...a.removed},y=[...Object.keys(a.added),...Object.keys(a.updated),...Object.keys(a.removed)];y.forEach(T=>{var R;if(!t[T]){Fe.warn(`Entity '${T}' not found in change set transfer. Cannot apply changes.`);const A=(R=this.get(T))==null?void 0:R.toShallowJSON();throw A?Fe.warn("Entity in project: ",A):Fe.warn("Entity not in project"),new Error(`Entity '${T}' not found in change set transfer. Cannot apply changes.`)}});const v=new Un(p);return v.flatRecord=t,v.order=y,v.orderEntities(),Fe.log("All entities: ",v.order.map((T,R)=>`${R+1}: ${t[T].type} - ${T}`).join(`,
|
|
403
|
+
Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:p,modifiedData:l}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return w([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return w([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allMethods,[]),...this.implements.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allProperties,[]),...this.implements.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return w([...this.extends.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[]),...this.implements.reduce((i,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...i],[])])}get allBaseMethodsFromExtendedAndImplementedEntities(){return w([...this.extends.reduce((i,a)=>a.type!==f.DefinitionEntity?[]:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[]),...this.implements.reduce((i,a)=>a.type!==f.DefinitionEntity?a.abstractMethods:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return w(this.extends.reduce((i,a)=>{if(a.type!==f.DefinitionEntity)return[];const l=[...a.ownDeclaredMethods,...a.extendedMethodsFromOriginalParents].filter(p=>p.type!==f.ActionDescriptor);return[...i,...l]},[]))}get implementedMethodsFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.type===f.DefinitionEntity?a.methods:[],p=[...a.abstractMethods].filter(t=>!l.find(y=>y.name===t.name));return[...l,...p,...i]},[]),...this.implements.reduce((i,a)=>[...a.abstractMethods,...i],[])].filter(i=>i.type===f.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${S.InvalidParentUpdate}`,code:S.InvalidParentUpdate,severity:q.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.removeImplementation(i),a==="extends"&&this.removeExtension(i),{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return a==="implements"&&this.addImplementation(i),a==="extends"&&this.addExtension(i),{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{zi.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this}subscribeToDependencies(){return this.implements.forEach(i=>{zi.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends.forEach(i=>{zi.includes(i.type)||i.subscribeDependents([{entity:this,field:"extends"}])}),this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ut(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=[...this.extends],i.implements=[...this.implements],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ut(T,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.properties=y.properties,this.methods=y.methods,this.abstractMethods=y.abstractMethods,this.extends=y.extends,this.implements=y.implements,this.parent=y.parent,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=Z(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,a);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return i.extends.forEach(l=>{const p=Z(l),t=this.project.get(p);t&&this.addExtension(t)}),i.implements.forEach(l=>{const p=Z(l),t=this.project.get(p);t&&this.addImplementation(t)}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=Z(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);return this.initialData.extends.forEach(t=>{const y=Z(t),v=this.project.get(y);v&&(this.addExtension(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),this.initialData.implements.forEach(t=>{const y=Z(t),v=this.project.get(y);v&&(this.addImplementation(v),v.type!==f.BuiltInBaseEntity&&i.push(v))}),{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:T,affected:R}=this.syncImplementationProperties(i);a.push(...y),l.push(...v),p.push(...T),t.push(...R);const{updated:A,added:P,removed:N,affected:U}=this.addExtendedProperties(i);a.push(...A),l.push(...P),p.push(...N),t.push(...U);const{updated:K,added:k,removed:J}=this.removeUnrecognizedProperties(i);a.push(...K),l.push(...k),p.push(...J);const{updated:se,added:te,removed:ce,affected:re}=this.syncImplementationMethods(i);a.push(...se),l.push(...te),p.push(...ce),t.push(...re);const{updated:fe,added:z,removed:Y,affected:ue}=this.addExtendedMethods(i);a.push(...fe),l.push(...z),p.push(...Y),t.push(...ue);const{updated:H,added:ae,removed:be}=this.removeUnrecognizedMethods(i);return a.push(...H),l.push(...ae),p.push(...be),this.addSuggestions(),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];if(this.parent.type===f.DataType){const y=this.parent;y.entity=this,a.push(y)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}setParent(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}addExtension(i){return this.extends.includes(i)||this.extends.push(i),this}removeExtension(i){return this.extends=this.extends.filter(a=>a.id!==i.id),this}addImplementation(i){return this.implements.includes(i)||this.implements.push(i),this}removeImplementation(i){return this.implements=this.implements.filter(a=>a.id!==i.id),this}removeProperty(i){return this.properties=this.properties.filter(a=>a.id!==i.id),this}addMethod(i){return this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name)),this}removeMethod(i){return this.methods=this.methods.filter(a=>a.id!==i.id),this}addProperty(i){return this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name)),this}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(a=>a.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(a=>a.id!==i.id),this}addAbstractMethod(i){return this.abstractMethods.includes(i)||this.abstractMethods.push(i),this}removeAbstractMethod(i){return this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),this}initChildren(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.properties=this.initialData.properties.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.methods=this.initialData.methods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(i),l}),this.extends=this.initialData.extends.map(a=>ee(a,this.project)),this.implements=this.initialData.implements.map(a=>ee(a,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}removeUnrecognizedProperties(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-properties"))){const a=[],l=[],p=[],t=[];let y=[...this.properties];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedProperty);const v=this.implementedPropertiesFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(R=>{var A;return R.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const R=T.remove({ignoreUpstream:!1},i);p.push(...R.removed),a.push(...R.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-unrecognized-methods"))){const a=[],l=[],p=[],t=[];let y=[...this.methods];y=y.filter(T=>T.parent.id===this.id),y=y.filter(T=>!T.isExtendedMethod);const v=this.implementedMethodsFromOriginalParents;return y=y.filter(T=>this.interactive&&!T.implements?!1:!v.find(R=>{var A;return R.id===((A=T.implements)==null?void 0:A.id)})),y.forEach(T=>{const R=T.remove({ignoreUpstream:!1},i);p.push(...R.removed),a.push(...R.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,v=this.implementedMethodsFromOriginalParents,T=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var U;return((U=N.implements)==null?void 0:U.id)===A.id})).forEach(A=>{if(this.methods.find(K=>{var k;return((k=K.implements)==null?void 0:k.id)===A.id}))return;const N=this.methods.find(K=>{var ce,re;if(K.name===A.name&&!K.implements)return!0;const k=as(this,Ve.CRON_JOB),J=as(this,Ve.HTTP_ENDPOINT),se=((ce=K.implements)==null?void 0:ce.id)===ve["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,te=((re=K.implements)==null?void 0:re.id)===ve["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(k&&!te&&!J&&se||J&&!se&&!k&&te)});if(N&&N.type===f.FunctionDeclaration){N.setImplements(A,i),N.metaSync({name:A.name},i),i==null||i.add(N,G.Updated),i==null||i.add(this,G.Updated);return}const U=A.implementAsFunctionDeclaration(i,this);l.push(U),i==null||i.add(U,G.Added),this.addMethod(U)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-implementation-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.implementedPropertiesFromOriginalParents,T=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...y];return v.filter(A=>!T.find(N=>{var U;return((U=N.implements)==null?void 0:U.id)===A.id})).forEach(A=>{if(this.properties.find(K=>{var k;return((k=K.implements)==null?void 0:k.id)===A.id}))return;const N=this.properties.find(K=>K.name===A.name&&!!K.abstract&&!K.implements);if(N){N.setImplements(A,i),N.metaSync({abstract:!1},i),N.afterAllChildrenInitialized(i);return}const U=A.implement(this,i,V.UUID.uuid());l.push(U),i==null||i.add(U,G.Added)}),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addExtendedMethods(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-extended-methods"))){const a=[],l=[],p=[],t=[],y=this.methods,T=this.extendedMethodsFromOriginalParents.filter(A=>A.type===f.FunctionDeclaration),R=new Set(y.filter(A=>{var P;return!!((P=A.extends)!=null&&P.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(R.has(A.id))return;R.add(A.id);const P=A.clone(i,this,V.UUID.uuid());P.setExtends(A,i),P.initChildren(i),l.push(P),i==null||i.add(P,G.Added),this.addMethod(P)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addExtendedProperties(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"add-extended-properties"))){const a=[],l=[],p=[],t=[],y=this.properties,v=this.extendedPropertiesFromOriginalParents,T=v.filter(A=>v.find(N=>{var U;return((U=N.implements)==null?void 0:U.id)===A.id})?!1:!A.abstract),R=new Set(y.filter(A=>{var P;return!!((P=A.extends)!=null&&P.id)}).map(A=>A.extends.id));return T.forEach(A=>{if(R.has(A.id))return;R.add(A.id);const P=A.clone(i,this,V.UUID.uuid());P.setExtends(A,i),P.initChildren(i),l.push(P),i==null||i.add(P,G.Added),this.addProperty(P)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSuggestions(){return this.implements.forEach(i=>{jG(this,i).forEach(p=>{const t=p.toJSON();t.id=`_suggestion--parent--${this.id}--${p.id}`;const y=ee(t,this.project);y.suggestion=!0,y.setParent(this,null),y.initChildren(null),this.addSuggestedProperty(y)}),xG(this,i).forEach(p=>{const t=`_suggestion--parent--${this.id}--${p.id}`,y=p.implementAsFunctionDeclaration(null,this,t),v=ee(y,this.project);if(v.suggestion=!0,v.setParent(this,null),v.initChildren(null),this.methods=this.methods.filter(T=>T.id!==t),v.inputs.forEach(T=>{T.suggestion=!0}),v.returnStatements.length){const T=v.returnStatements[0];T.suggestion=!0,T.outputs.forEach(R=>{R.suggestion=!0})}this.addSuggestedMethod(v)})}),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,this.static=i.static!==void 0?i.static:this.static,this.abstract=i.abstract!==void 0?i.abstract:this.abstract,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await Ut.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await Ut.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await Ut.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await Ut.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await Ut.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await Ut.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];if(this.parent.type===f.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===f.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const y=this.parent.setEntity(null,i);a.push(y)}return i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:w(p),updated:w(a),removed:w(l),affected:w(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:R,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),p.push(...R),t.push(...A)}),this.properties.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.methods.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.abstractMethods.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.suggestedProperties.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),this.suggestedMethods.forEach(v=>{const{updated:T,removed:R}=v.remove({ignoreUpstream:!0},a);l.push(...T),p.push(...R)}),!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:w(t),updated:w(l),removed:w(p),affected:w(y),self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:T,added:R}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...T),a.push(...R)}),this.properties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.methods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.abstractMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedProperties.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),this.suggestedMethods.forEach(y=>{const{updated:v}=y.restore({},i);l.push(...v)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:w(a),updated:w(l),removed:w(p),affected:w(t),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.extends.flatMap(l=>l.toFlat(i)),...this.implements.flatMap(l=>l.toFlat(i)),...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.extends.flatMap(l=>l.toFlatIds(i)),...this.implements.flatMap(l=>l.toFlatIds(i)),...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),implements:this.implements.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i)),parent:this.parent.toReference()})}toJSONClone(i=xe){var l,p,t,y,v;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||Nr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.UUID.uuid(),createdAt:i.timestamp||L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(T=>T.toJSONClone({...i,newId:null})),methods:this.methods.map(T=>T.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(T=>T.toJSONClone({...i,newId:null})),implements:this.implements.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),extends:this.extends.map(T=>T.type===f.BuiltInBaseEntity?T.toJSON():T.toJSONClone({...i,newId:null})),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(p=>p.toReference(i)),methods:this.methods.map(p=>p.toReference(i)),abstractMethods:this.abstractMethods.map(p=>p.toReference(i)),implements:this.implements.map(p=>p.toReference(i)),extends:this.extends.map(p=>p.toReference(i)),parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i)),...this.implements.flatMap(l=>l.toFlatJSON(i)),...this.extends.flatMap(l=>l.toFlatJSON(i)),...this.parent.toFlatJSON(i)])}toGenerationTarget(){const i=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:this.extends.map(a=>a.id),implements:this.implements.map(a=>a.id),parent:i}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(i)),...this.parent.toFlatGenerationTarget(i)])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=UG(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var K,k,J;let t=Vr(a,this);const y=this.toJSON(),v=l||V.UUID.uuid();y.properties=[],y.methods=[],y.abstractMethods=[];const T=v.split("-id"),R=T[T.length-1||0]||v;y.id=v,y.version=V.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||L().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const A=zt(y,t);a&&A.setParent(a,null),p&&A.subscribe(),A.initChildren(i),i==null||i.add(A,G.Added);const P=(K=this.properties)==null?void 0:K.map(se=>se.clone(i,A,V.UUID.uuid(),p));A.properties=P;const N=(k=this.methods)==null?void 0:k.map((se,te)=>se.clone(i,A,R+"-method-"+te+"-id",p));A.methods=N;const U=(J=this.abstractMethods)==null?void 0:J.map((se,te)=>se.clone(i,A,R+"-abstract-method-"+te+"-id",p));return A.abstractMethods=U,i==null||i.attemptAutoclose("clone-entity",this.id),A}getFunctionDeclaration(i){return this.methods.find(a=>a.id===i)}implement(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"implement-definition-entity")),l){const p=By(this,i,a,l);return a==null||a.attemptAutoclose("implement-definition-entity",this.id),p}getAllInteractiveMethods(){const i=this.implements.filter(l=>l.type===f.DefinitionEntity||l.type===f.BuiltInBaseEntity&&l.interactive);return w([...this.methods,...this.extends.flatMap(l=>l.getAllInteractiveMethods()),...i.flatMap(l=>l.getAllInteractiveMethods())])}inferFromInputs(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const l=[],p=[],t=[],y=[];if(this.parent.type!==f.DataType||!this.parent.inferred)return a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const v=[];i.forEach(A=>{v.find(N=>ie(N,this.project)===ie(A,this.project))||v.push(A)});const T=this.properties.filter(A=>!A.dataType);v.forEach(A=>{var se,te,ce;const P=T.find(re=>ie(re,this.project)===ie(A,this.project));if(!P)return;const U=bi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),K=tn(U,a),k=K==null?void 0:K.clone(a,P,V.UUID.uuid(),!0);k&&((se=P.dataType)==null||se.merge(k,a),k.id!==((te=P.dataType)==null?void 0:te.id)&&k.remove({ignoreUpstream:!1},a),P.dataType&&(P.dataType.metaSync({inferred:!0,like:!0},a),P.setDataType(P.dataType,a),a==null||a.add(P,G.Affected)));let J=null;if(A.declaration&&P.id!==((ce=A.declaration)==null?void 0:ce.id)&&(J=A.declaration),A.setDeclaration(P,a),a==null||a.add(A,G.Updated),J){const{updated:re,removed:fe}=J.remove({ignoreUpstream:!1},a);p.push(...re),t.push(...fe)}});const R=[];return v.forEach(A=>{if(!A.declaration){R.push(A);return}}),R.length===0?(a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(R.forEach(A=>{var te,ce,re,fe;const P=this.properties.find(z=>ie(z,this.project)===ie(A,this.project));if(P){if(A.setDeclaration(P,a),!P.getDataType(a)){const Y=bi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),ue=tn(Y),H=ue==null?void 0:ue.clone(a,P,V.UUID.uuid(),!0);H&&((te=P.dataType)==null||te.merge(H,a),H.id!==((ce=P.dataType)==null?void 0:ce.id)&&H.remove({ignoreUpstream:!1},a),P.dataType&&(P.dataType.metaSync({inferred:!0,like:!0},a),P.setDataType(P.dataType,a),a==null||a.add(P,G.Affected)))}return}const N=jn.new(a);N.parent=this.toReference(),N.index=A.index,N.name=ie(A,this.project),N.codeName=A.codeName,N.description=A.description;const U=ee(N,this.project);U.hydrateAncestors(),a==null||a.add(U,G.Added),U.setParent(this,a),U.initChildren(a);const k=bi(A.parent).getMasterInputWithValueWritterFromAllInstances(A),J=tn(k),se=J==null?void 0:J.clone(a,U,V.UUID.uuid(),!0);return se&&((re=U.dataType)==null||re.merge(se,a),se.id!==((fe=U.dataType)==null?void 0:fe.id)&&se.remove({ignoreUpstream:!1},a),U.dataType&&(U.dataType.metaSync({inferred:!0,like:!0},a),U.setDataType(U.dataType,a),a==null||a.add(U,G.Affected))),this.addProperty(U),A.setDeclaration(U,a),a==null||a.add(A,G.Updated),U}),a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:w(l),updated:w(p),removed:w(t),affected:w(y),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(a=>{var p;if(!jA(a))return;const l=$r(a.name);i[l]=((p=a.getDefaultValue())==null?void 0:p.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(a=>{var t;if(!jA(a))return;const l=$r(a.name),p=(t=this.project.requestActiveDynamicValue(a))==null?void 0:t.value;i[l]=(p==null?void 0:p.value)||null}),i}};O(Ut,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),O(Ut,"type",f.DefinitionEntity),O(Ut,"USER_MANAGED_PARENT_TYPES",[f.Project,f.DataType]),O(Ut,"PARENT_TYPES",[...Ut.USER_MANAGED_PARENT_TYPES]),O(Ut,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract"]),O(Ut,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),O(Ut,"BASE_PROPERTIES",[...Ut.MUTABLE_BASE_PROPERTIES,...Ut.INMUTABLE_BASE_PROPERTIES]),O(Ut,"MUTABLE_META_PROPERTIES",[...Ut.MUTABLE_BASE_PROPERTIES,"x","y"]),O(Ut,"INMUTABLE_META_PROPERTIES",[...Ut.INMUTABLE_BASE_PROPERTIES]),O(Ut,"META_PROPERTIES",[...Ut.MUTABLE_META_PROPERTIES,...Ut.INMUTABLE_META_PROPERTIES]),O(Ut,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),O(Ut,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),O(Ut,"UPSTREAM_PROPERTIES",[...Ut.MUTABLE_UPSTREAM_PROPERTIES,...Ut.INMUTABLE_UPSTREAM_PROPERTIES]),O(Ut,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),O(Ut,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),O(Ut,"DOWNSTREAM_PROPERTIES",[...Ut.MUTABLE_DOWNSTREAM_PROPERTIES,...Ut.INMUTABLE_DOWNSTREAM_PROPERTIES]),O(Ut,"PROPERTIES",[...Ut.META_PROPERTIES,...Ut.UPSTREAM_PROPERTIES,...Ut.DOWNSTREAM_PROPERTIES]);let wa=Ut;function X0e(d){const u=pce(),i=d.toJSON();u.safeParse(i).success;const l=[];return ar(d.errors,l)}const Fp=class Fp extends Rr{constructor(i,a){super(i);O(this,"initialData");O(this,"id");O(this,"version");O(this,"name");O(this,"description",null);O(this,"type",f.BuiltInBaseEntity);O(this,"abstract",!1);O(this,"static");O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"interactive",!1);O(this,"errors",[]);O(this,"project");this.initialData=this.initialData||i,this.project=this.project||a,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.extends=this.initialData.extends.map(l=>ee(l,this.project))}get allMethods(){return w([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return w([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=me,...a){return await Fp.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i)),...this.extends.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i)),...this.extends.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,interactive:this.interactive,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=xe){return{id:this.id+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=xe){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=X0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}implement(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),null,!0,"implement-built-in-base-entity")),l){const p=By(this,i,a,l);return a==null||a.attemptAutoclose("implement-built-in-base-entity",this.id),p}getAllInteractiveMethods(){const i=[];return this.interactive&&(i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof Fp&&i.push(...l.getAllInteractiveMethods())})),w(i)}};O(Fp,"repository",{APILoad:async(i,...a)=>null});let xn=Fp;function Q0e(d){const u=oce(),i=d.toJSON();u.safeParse(i).success;const l=[];return ar(d.errors,l)}const rm=class rm extends Rr{constructor(i,a){super(i);O(this,"initialData");O(this,"id");O(this,"name");O(this,"description",null);O(this,"type",f.PrimitiveEntity);O(this,"static");O(this,"abstract");O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"errors",[]);O(this,"project");this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.parent=this,p})}get allMethods(){return w([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return w([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return w([...this.extends.flatMap(i=>i.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...i,...l]},[]))}get extendedPropertiesFromOriginalParents(){return w(this.extends.reduce((i,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...i,...l]},[]))}get implementedPropertiesFromOriginalParents(){return w([...this.extends.reduce((i,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(y=>y.name===t.name));return[...l,...p,...i]},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=me,...a){return await rm.repository.APILoad(this.id,...a),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(i)),...this.methods.flatMap(l=>l.toFlat(i)),...this.abstractMethods.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(i)),...this.methods.flatMap(l=>l.toFlatIds(i)),...this.abstractMethods.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:this.extends.map(a=>a.toJSON(i))})}toReference(i=xe){return{id:this.id+"--"+V.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=xe){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(i)),...this.methods.flatMap(l=>l.toFlatJSON(i)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(i=>i.id)}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(i)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){const i=Q0e(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof xn&&i.push(...l.getAllInteractiveMethods())}),w(i)}};O(rm,"repository",{APILoad:async(i,...a)=>null});let ki=rm;function zt(d,u){if(!d)throw new Error("Entity is null");const i=u.get(d.id);switch(d.type){case f.LiteralValue:return i||new $i(d,u);case f.DefinitionEntity:return i||new wa(d,u);case f.PrimitiveEntity:return i||new ki(d,u);case f.FunctionDeclaration:return i||new Ka(d,u);case f.GlobalEvent:return i||new qa(d,u);case f.DataType:return i||new is(d,u);case f.Property:return i||new jn(d,u);case f.FunctionCall:return i||new so(d,u);case f.Condition:return i||new Za(d,u);case f.Operation:return i||new ka(d,u);case f.VariableDeclaration:return i||new Wa(d,u);case f.VariableInstance:return i||new Ja(d,u);case f.OutputMap:return i||new rn(d,u);case f.ReturnDeclaration:return i||new Ki(d,u);case f.ArgumentDeclaration:return i||new Ea(d,u);case f.InputMap:return i||new Ln(d,u);case f.Project:return i||new V(d);case f.InstalledProject:return i||new Ya(d,u);case f.ActionDescriptor:return i||new ht(d,u);case f.ReturnStatement:return i||new Sa(d,u);case f.Loop:return i||new Oi(d,u);case f.Search:return i||new Ha(d,u);case f.ValueDescriptor:return i||new sn(d,u);case f.BuiltInBaseEntity:return i||new xn(d,u);case f.InternalCall:return i||new za(d,u);case f.ContinueStatement:return i||new Ti(d,u);case f.BreakStatement:return i||new Xa(d,u);case f.GenericReference:return u.get(d.entityId);default:throw new Error("Invalid entity type: "+d.type)}}function ee(d,u){if(!d)throw new Error("Entity is null");const i=zt(d,u);return i.subscribe(),i}function eve(d,u){if(!d)throw new Error("Entity is null");switch(d.type){case f.LiteralValue:return $i.fromGenerationTarget(d,u);case f.DefinitionEntity:return wa.fromGenerationTarget(d,u);case f.FunctionDeclaration:return Ka.fromGenerationTarget(d,u);case f.GlobalEvent:return qa.fromGenerationTarget(d,u);case f.DataType:return is.fromGenerationTarget(d,u);case f.Property:return jn.fromGenerationTarget(d,u);case f.FunctionCall:return so.fromGenerationTarget(d,u);case f.Condition:return Za.fromGenerationTarget(d,u);case f.Operation:return ka.fromGenerationTarget(d,u);case f.VariableDeclaration:return Wa.fromGenerationTarget(d,u);case f.VariableInstance:return Ja.fromGenerationTarget(d,u);case f.OutputMap:return rn.fromGenerationTarget(d,u);case f.ReturnDeclaration:return Ki.fromGenerationTarget(d,u);case f.ArgumentDeclaration:return Ea.fromGenerationTarget(d,u);case f.InputMap:return Ln.fromGenerationTarget(d,u);case f.InstalledProject:return Ya.fromGenerationTarget(d,u);case f.ReturnStatement:return Sa.fromGenerationTarget(d,u);case f.Loop:return Oi.fromGenerationTarget(d,u);case f.Search:return Ha.fromGenerationTarget(d,u);case f.ActionDescriptor:return ht.fromGenerationTarget(d,u);case f.ValueDescriptor:return sn.fromGenerationTarget(d,u);case f.InternalCall:return za.fromGenerationTarget(d,u);case f.ContinueStatement:return Ti.fromGenerationTarget(d,u);case f.BreakStatement:return Xa.fromGenerationTarget(d,u);default:throw new Error("Invalid entity type: "+d.type)}}const xe={seenEntityMaps:new Map,seenEntities:new Set,timestamp:L().toISOString()};class GG{constructor(){O(this,"initialData")}}const me={cascade:!1},KG={APILoad:async(d,...u)=>null},tve={APICreate:async(d,...u)=>d,APIUpdate:async(d,...u)=>d,APIDelete:async(d,...u)=>d,APIClone:async(d,...u)=>{},APILoadVersion:async(d,u,...i)=>null,...KG};class rve{}class ive extends GG{}class sve{}class nve{}class ave{}class JA{}class ove extends JA{}class lve extends JA{}class dve{}class Up{static initReadsValue(u){if(u.initialData.readsValue&&u.initialData.readsValue.type!==f.GenericReference)u.readsValue=ee(u.initialData.readsValue,u.project);else if(u.initialData.readsValue&&u.initialData.readsValue.type===f.GenericReference){const i=Ni(u.initialData.readsValue,u.project);i&&(u.readsValue=i)}if(u.readsValue){if(ot.includes(u.readsValue.type)){let i=u.parent;Dr.includes(i.type)||(i=i.parent);const a=u.type===f.InputMap&&u.parent.type===f.Loop;a&&(i=u.parent.parent),u.readsValue.setParent(i,null),u.readsValue.initChildren(null),i&&i.type!==f.Project&&!a&&i.detachedChildren.includes(u)?i.replaceDetachedChild(u,u.readsValue):i&&i.type!==f.Project&&!a&&i.subscribeDetachedChild(u.readsValue)}u.readsValue.addValueReader(u,null)}return u.readsValue}}class jp{static initWritesValues(u,i){const a=u.initialData.writesValues.reduce((p,t)=>{if(t.type===f.GenericReference||u.writesValues.some(v=>v.id===t.id))return p;const y=ee(t,u.project);return y.setValueWriter(u,null),ot.includes(y.type)&&(y.setParent(i,null),y.initChildren(null)),[...p,y]},[]),l=[...u.writesValues];return u.writesValues=w([...l,...a]),u.writesValues}}class uve{}var gr=(d=>(d.PROJECT_INITIALIZED="project-initialized",d.CHANGE_SET_CLOSED="change-set-closed",d.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",d.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",d.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",d.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",d.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",d.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",d.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",d))(gr||{});const WA={...zb,events:new wp},kG={requestActiveDynamicValue:d=>null,...WA},it=class it extends Rr{constructor(i,a={...kG,events:new wp}){super(i);O(this,"initialData");O(this,"id");O(this,"type",f.Project);O(this,"name",null);O(this,"description",null);O(this,"x");O(this,"y");O(this,"entities",[]);O(this,"projects",[]);O(this,"functions",[]);O(this,"events",[]);O(this,"variableDeclarations",[]);O(this,"variableInstances",[]);O(this,"conditions",[]);O(this,"operations",[]);O(this,"functionCalls",[]);O(this,"loops",[]);O(this,"searches",[]);O(this,"primitives",[]);O(this,"builtInBaseEntities",[]);O(this,"operationDeclarations",[]);O(this,"globalEventActionDescriptors",[]);O(this,"loopDeclarations",[]);O(this,"loopDeclarationsBodies",[]);O(this,"conditionDeclarations",[]);O(this,"valueDescriptors",[]);O(this,"dataTypes",[]);O(this,"project");O(this,"instances",{});O(this,"builtInInstances",{});O(this,"deletedInstances",{});O(this,"errors",[]);O(this,"references",[]);O(this,"history",[]);O(this,"undoableStackValueIndex",-1);O(this,"detachedDependents",{});O(this,"knownVersions",null);O(this,"activeVersion",!1);O(this,"initialized",!1);O(this,"startedInitialization",!1);O(this,"onCloseChangeSetCallback",null);O(this,"onAddChangeSetCallback",null);O(this,"onDiscardChangeSetCallback",null);if(this.parentContext=a,this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this,!it.UUID)throw new Error("UUID module is already initialized. Please inject a valid UUID module.")}static get UUID(){return this.parentContext.requestModule("uuid")}static new(i=null){return{id:it.UUID.uuid(),version:it.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||L().toISOString(),author:(i==null?void 0:i.author)||it.sessionAuthor,previousVersion:null,deleted:!1,type:f.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[];return p.push(...Or(l)),{errors:p,modifiedData:l}}get off(){return this.parentContext.events.off}get on(){return this.parentContext.events.on}get emit(){return this.parentContext.events.emit}async closePendingChangeSets(){const i=this.history.find(a=>a.dirty&&!a.open);i&&await this.closeChangeSet(i)}async onCloseChangeSet(i){this.onCloseChangeSetCallback=i,await this.closePendingChangeSets()}onAddChangeSet(i){this.onAddChangeSetCallback=i}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}async closeChangeSet(i){const a=this.history.findIndex(t=>t.id===i.id),l=this.history.slice(0,a),p=l[l.length-1];if(!(p!=null&&p.dirty)&&this.onCloseChangeSetCallback){(await this.onCloseChangeSetCallback(i)).success&&(i.dirty=!1,this.emit("change-set-closed",i),this.closePendingChangeSets());return}}toLatestChangeSet(i,a,l,p=!1,t="here-this"){if(!this.history.length)return new F(this,i,a,l,p,t);const y=this.history[this.history.length-1];return y.open?y:this.addChangeSet(new F(this,i,a,l,p,t))}addChangeSet(i){var p,t;if(!this.history.length)return this.undoableStackValueIndex=Eb(this.undoableStackValueIndex,this.history,i),(p=this.onAddChangeSetCallback)==null||p.call(this,i,this.undoableStackValueIndex),i;const a=this.history.find(y=>y.id===(i==null?void 0:i.id));if(a)return a;const l=this.history.find(y=>y.open);if(l)throw Fe.warn("Previous still open: ",l),Fe.warn("New change set: ",i),new Error(`There is already an open change-set with id '${l.id}'.`);return this.undoableStackValueIndex=Eb(this.undoableStackValueIndex,this.history,i),(t=this.onAddChangeSetCallback)==null||t.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var l;const a=this.history.findIndex(p=>p.id===(i==null?void 0:i.id));return a!==-1&&(this.history.splice(a,1),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(l=this.onDiscardChangeSetCallback)==null||l.call(this,i)),this}async inject(...i){return await Promise.all(i.map(a=>new Promise(async l=>{await a.init(this),l(null)}))),this}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return{updated:w(p),added:w(t),removed:w(y),affected:w(v),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){if(i&&!L(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&L(i).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=it.UUID.uuid(),this.createdAt=L(i).toISOString()||L().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new it(this);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this};if(!this.knownVersions){const T=new Map;for(const[R,A]of this.knownVersions||new Map){if(T.set(R,A),A.activeVersion=!1,A.knownVersions)for(const[P,N]of A.knownVersions)T.set(P,N);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new it(T)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.entities=y.entities,this.projects=y.projects,this.functions=y.functions,this.events=y.events,this.variableDeclarations=y.variableDeclarations,this.variableInstances=y.variableInstances,this.conditions=y.conditions,this.operations=y.operations,this.functionCalls=y.functionCalls,this.loops=y.loops,this.searches=y.searches,{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"update-with-shallow-transfer"))){return this.metaSync(i,a),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];return{updated:w(i),added:w(a),removed:w(l),affected:w(p),self:this}}afterAllChildrenInitialized(i=null){const a=[],l=[],p=[],t=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),this.captureVersion(),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}addSelfToProject(i){const a=[],l=[],p=[],t=[];return this.subscribe(),this.subscribeToDependencies(),{updated:w(a),added:w(l),removed:w(p),affected:w(t),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.projects=this.initialData.projects.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableDeclarations=this.initialData.variableDeclarations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.variableInstances=this.initialData.variableInstances.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.conditions=this.initialData.conditions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.operations=this.initialData.operations.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functions=this.initialData.functions.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.events=this.initialData.events.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.functionCalls=this.initialData.functionCalls.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.loops=this.initialData.loops.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.searches=this.initialData.searches.map(a=>{const l=ee(a,this);return l.setParent(this,null),l.initChildren(i),l}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,a=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"meta-sync"))){const l=Cr(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.description=i.description!==void 0?i.description:p.description,this.x=i.x||p.x,this.y=i.y||p.y,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=me,...a){return await it.repository.APILoad(this.id,...a),this}async APICreate(i=me,...a){return await it.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=me,...a){return await it.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=me,...a){return await it.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=me,...a){return await it.repository.APIClone(this.id,...a),this}async APILoadVersion(i=me,a,...l){return await it.repository.APILoadVersion(this.id,a,...l)}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new F(this.project,it.sessionAuthor,L().toISOString(),this,!0,"restore-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlatIds(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlatIds(i)),...this.operationDeclarations.flatMap(a=>a.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlatIds(i)),...this.loopDeclarations.flatMap(a=>a.toFlatIds(i)),...this.conditionDeclarations.flatMap(a=>a.toFlatIds(i)),...this.valueDescriptors.flatMap(a=>a.toFlatIds(i)),...this.dataTypes.flatMap(a=>a.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(a=>a.toFlat(i)),...this.builtInBaseEntities.flatMap(a=>a.toFlat(i)),...this.operationDeclarations.flatMap(a=>a.toFlat(i)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlat(i)),...this.loopDeclarations.flatMap(a=>a.toFlat(i)),...this.conditionDeclarations.flatMap(a=>a.toFlat(i)),...this.valueDescriptors.flatMap(a=>a.toFlat(i)),...this.dataTypes.flatMap(a=>a.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(l=>l.toFlat(i)),...this.functions.flatMap(l=>l.toFlat(i)),...this.events.flatMap(l=>l.toFlat(i)),...this.projects.flatMap(l=>l.toFlat(i)),...this.variableDeclarations.flatMap(l=>l.toFlat(i)),...this.variableInstances.flatMap(l=>l.toFlat(i)),...this.conditions.flatMap(l=>l.toFlat(i)),...this.operations.flatMap(l=>l.toFlat(i)),...this.functionCalls.flatMap(l=>l.toFlat(i)),...this.loops.flatMap(l=>l.toFlat(i)),...this.searches.flatMap(l=>l.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(l=>l.toFlatIds(i)),...this.functions.flatMap(l=>l.toFlatIds(i)),...this.events.flatMap(l=>l.toFlatIds(i)),...this.projects.flatMap(l=>l.toFlatIds(i)),...this.variableDeclarations.flatMap(l=>l.toFlatIds(i)),...this.variableInstances.flatMap(l=>l.toFlatIds(i)),...this.conditions.flatMap(l=>l.toFlatIds(i)),...this.operations.flatMap(l=>l.toFlatIds(i)),...this.functionCalls.flatMap(l=>l.toFlatIds(i)),...this.loops.flatMap(l=>l.toFlatIds(i)),...this.searches.flatMap(l=>l.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(a=>a.toJSON(i)),variableDeclarations:this.variableDeclarations.map(a=>a.toJSON(i)),variableInstances:this.variableInstances.map(a=>a.toJSON(i)),conditions:this.conditions.map(a=>a.toJSON(i)),operations:this.operations.map(a=>a.toJSON(i)),loops:this.loops.map(a=>a.toJSON(i)),searches:this.searches.map(a=>a.toJSON(i)),functions:this.functions.map(a=>a.toJSON(i)),events:this.events.map(a=>a.toJSON(i)),projects:this.projects.map(a=>a.toJSON(i)),functionCalls:this.functionCalls.map(a=>a.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const a=new Map,l=new Set,p=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(t=>{if(p.includes(t)){a.set(t,t);return}a.set(t,it.UUID.uuid())}),l.add(this.id),{id:a.get(this.id),version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),projects:this.projects.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableDeclarations:this.variableDeclarations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),variableInstances:this.variableInstances.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),conditions:this.conditions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),operations:this.operations.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functions:this.functions.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),events:this.events.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),functionCalls:this.functionCalls.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),loops:this.loops.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null})),searches:this.searches.map(t=>t.toJSONClone({...i,seenEntityMaps:a,seenEntities:l,newId:null}))}}toReference(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+it.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=xe){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,entities:this.entities.map(p=>p.toReference(i)),functions:this.functions.map(p=>p.toReference(i)),events:this.events.map(p=>p.toReference(i)),projects:this.projects.map(p=>p.toReference(i)),variableDeclarations:this.variableDeclarations.map(p=>p.toReference(i)),variableInstances:this.variableInstances.map(p=>p.toReference(i)),conditions:this.conditions.map(p=>p.toReference(i)),operations:this.operations.map(p=>p.toReference(i)),functionCalls:this.functionCalls.map(p=>p.toReference(i)),loops:this.loops.map(p=>p.toReference(i)),searches:this.searches.map(p=>p.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(l=>l.toFlatJSON(i)),...this.functions.flatMap(l=>l.toFlatJSON(i)),...this.events.flatMap(l=>l.toFlatJSON(i)),...this.projects.flatMap(l=>l.toFlatJSON(i)),...this.variableDeclarations.flatMap(l=>l.toFlatJSON(i)),...this.variableInstances.flatMap(l=>l.toFlatJSON(i)),...this.conditions.flatMap(l=>l.toFlatJSON(i)),...this.operations.flatMap(l=>l.toFlatJSON(i)),...this.functionCalls.flatMap(l=>l.toFlatJSON(i)),...this.loops.flatMap(l=>l.toFlatJSON(i)),...this.searches.flatMap(l=>l.toFlatJSON(i))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.events.flatMap(l=>l.toFlatGenerationTarget(i)),...this.projects.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(l=>l.toFlatGenerationTarget(i)),...this.conditions.flatMap(l=>l.toFlatGenerationTarget(i)),...this.operations.flatMap(l=>l.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(l=>l.toFlatGenerationTarget(i)),...this.loops.flatMap(l=>l.toFlatGenerationTarget(i)),...this.searches.flatMap(l=>l.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){const i=Nfe(),a=this.toJSON();return i.safeParse(a),this.validateChildren(),{success:!0,error:null,data:a}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(a=>a.getErrors()),...this.projects.flatMap(a=>a.getErrors()),...this.functions.flatMap(a=>a.getErrors()),...this.events.flatMap(a=>a.getErrors()),...this.variableDeclarations.flatMap(a=>a.getErrors()),...this.variableInstances.flatMap(a=>a.getErrors()),...this.conditions.flatMap(a=>a.getErrors()),...this.operations.flatMap(a=>a.getErrors()),...this.functionCalls.flatMap(a=>a.getErrors()),...this.loops.flatMap(a=>a.getErrors()),...this.searches.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(){return this}getDefinitionEntity(i){return this.entities.find(a=>a.id===i)||null}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const a=this.entities.findIndex(l=>l.id===i.id);if(a>-1){const l=this.entities[a];return this.entities.splice(a,1),l}return null}removeCondition(i){const a=this.conditions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.conditions[a];return this.conditions.splice(a,1),l}return null}removeOperation(i){const a=this.operations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.operations[a];return this.operations.splice(a,1),l}return null}removeLoop(i){const a=this.loops.findIndex(l=>l.id===i.id);if(a>-1){const l=this.loops[a];return this.loops.splice(a,1),l}return null}removeSearch(i){const a=this.searches.findIndex(l=>l.id===i.id);if(a>-1){const l=this.searches[a];return this.searches.splice(a,1),l}return null}removeFunctionCall(i){const a=this.functionCalls.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functionCalls[a];return this.functionCalls.splice(a,1),l}return null}removeVariableInstance(i){const a=this.variableInstances.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableInstances[a];return this.variableInstances.splice(a,1),l}return null}removeVariableDeclaration(i){const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}removeFunctionDeclaration(i){const a=this.functions.findIndex(l=>l.id===i.id);if(a>-1){const l=this.functions[a];return this.functions.splice(a,1),l}return null}removeInstalledProject(i){const a=this.projects.findIndex(l=>l.id===i.id);if(a>-1){const l=this.projects[a];return this.projects.splice(a,1),l}return null}removeGlobalEvent(i){const a=this.events.findIndex(l=>l.id===i.id);if(a>-1){const l=this.events[a];return this.events.splice(a,1),l}return null}removeTopLevelVariableDeclaration(i){if(i.type!==f.VariableDeclaration)return null;const a=this.variableDeclarations.findIndex(l=>l.id===i.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(a=>a.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.ReturnStatement||t.type===f.ContinueStatement||t.type===f.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(a=>a.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.functionCalls.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.conditions.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.operations.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.loops.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[]),...this.searches.reduce((a,l)=>{const p=sr(l);return[...a,...p]},[])]}getVariableInstances(){return[...this.variableInstances,...this.entities.reduce((a,l)=>[...a,...l.methods.flatMap(p=>{const y=mt(p).filter(v=>v.type===f.VariableInstance);return[...a,...y]})],[]),...this.getEntryPoints().reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableInstance);return[...a,...t]},[])]}getVariableDeclarations(){return w([...this.variableDeclarations,...this.entities.reduce((a,l)=>[...a,...l.methods.flatMap(p=>{const y=mt(p).filter(v=>v.type===f.VariableDeclaration);return[...a,...y]})],[]),...this.getEntryPoints().reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=sr(l).filter(y=>y.type===f.VariableDeclaration);return[...a,...t]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.searches.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.functionCalls.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.conditions.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.operations.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.loops.reduce((a,l)=>{const p=mt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),a=this.getVariableDeclarations();return i.forEach(l=>{if(!l.declaration){const p=l.initialData,t=p.declaration.entityId||p.declaration.id,y=a.find(v=>v.id===t);y&&l.setDeclaration(y)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===Ve.PERSISTED_ENTITY)||null}requestActiveDynamicValue(i){var l,p;const a=(p=(l=this.parentContext).requestActiveDynamicValue)==null?void 0:p.call(l,i);if(!a){const t=i.getDefaultValue();return t?{value:t,type:Te.DefaultValue,inheritanceLink:null,valueOwner:i}:null}return a||null}requestModule(i){if(this.parentContext.requestModule){const a=this.parentContext.requestModule(i);return!a&&i==="uuid"?$u:a||null}return i==="uuid"?$u:null}undo(){Fe.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,Fe.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],a=this.history[this.undoableStackValueIndex];return Fe.log("Current change set: ",i==null?void 0:i.toJSON()),Fe.log("Change set to restore: ",a==null?void 0:a.toJSON()),mb(i||"initial",a||"initial",this)}redo(){Fe.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,Fe.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],a=this.history[this.undoableStackValueIndex];return Fe.log("Current change set: ",i==null?void 0:i.toJSON()),Fe.log("Change set to restore: ",a.toJSON()),mb(i||"initial",a||"initial",this)}applyExternalChangeSet(i){const a=i.payload,l=this.addChangeSet(new F(this,i.userAuthor,i.emittedAt,this)),p=a.updated[this.id];if(!p)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const t={...a.added,...a.updated,...a.removed},y=[...Object.keys(a.added),...Object.keys(a.updated),...Object.keys(a.removed)];y.forEach(T=>{var R;if(!t[T]){Fe.warn(`Entity '${T}' not found in change set transfer. Cannot apply changes.`);const A=(R=this.get(T))==null?void 0:R.toShallowJSON();throw A?Fe.warn("Entity in project: ",A):Fe.warn("Entity not in project"),new Error(`Entity '${T}' not found in change set transfer. Cannot apply changes.`)}});const v=new Un(p);return v.flatRecord=t,v.order=y,v.orderEntities(),Fe.log("All entities: ",v.order.map((T,R)=>`${R+1}: ${t[T].type} - ${T}`).join(`,
|
|
404
404
|
`)),Fe.log("Persisting new additions"),v.visit(async(T,R)=>{if(a.added[T.id]){Fe.log("Adding: ",T.id);try{const A=ee(T,this);if(A.hydrateAncestors(),A.addSelfToProject(l),l.add(A,G.Added),!this.get(T.id))throw new Error(`Entity ${T.id} was not added to the project`)}catch(A){Fe.error("Error: ",A),Fe.error("Errored entity: ",T)}}}),Fe.log("Persisting updates"),v.visit(async(T,R)=>{if(a.updated[T.id]){Fe.log("Updating: ",T.id);try{const A=this.get(T.id);A?(A.updateWithShallowTransfer(T,l),l.add(A,G.Updated)):Fe.warn(`Active version of ${T.id} not found when applying external changes`)}catch(A){Fe.error("Error: ",A),Fe.error("Errored entity: ",T)}}}),Fe.log("Persisting removals"),v.visit(async(T,R)=>{if(a.removed[T.id]){Fe.log("Removing: ",T.id);try{const A=this.get(T.id);A&&A.remove({ignoreUpstream:!1},l)}catch(A){Fe.error("Error: ",A),Fe.error("Errored entity: ",T)}}}),l}toFullProjectTransfer(){const i=new Un(this),a={};return i.visit(l=>{const p=l.toShallowJSON();a[l.id]=p}),{order:i.order,size:i.order.length,record:a}}};O(it,"parentContext",WA),O(it,"sessionAuthor","1"),O(it,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),O(it,"type",f.Project),O(it,"USER_MANAGED_PARENT_TYPES",[]),O(it,"PARENT_TYPES",[...it.USER_MANAGED_PARENT_TYPES]),O(it,"MUTABLE_BASE_PROPERTIES",["name","description"]),O(it,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),O(it,"BASE_PROPERTIES",[...it.MUTABLE_BASE_PROPERTIES,...it.INMUTABLE_BASE_PROPERTIES]),O(it,"MUTABLE_META_PROPERTIES",[...it.MUTABLE_BASE_PROPERTIES,"x","y"]),O(it,"INMUTABLE_META_PROPERTIES",[...it.INMUTABLE_BASE_PROPERTIES]),O(it,"META_PROPERTIES",[...it.MUTABLE_META_PROPERTIES,...it.INMUTABLE_META_PROPERTIES]),O(it,"MUTABLE_UPSTREAM_PROPERTIES",[]),O(it,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),O(it,"UPSTREAM_PROPERTIES",[...it.MUTABLE_UPSTREAM_PROPERTIES,...it.INMUTABLE_UPSTREAM_PROPERTIES]),O(it,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),O(it,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),O(it,"DOWNSTREAM_PROPERTIES",[...it.MUTABLE_DOWNSTREAM_PROPERTIES,...it.INMUTABLE_DOWNSTREAM_PROPERTIES]),O(it,"PROPERTIES",[...it.META_PROPERTIES,...it.UPSTREAM_PROPERTIES,...it.DOWNSTREAM_PROPERTIES]);let V=it;class SG extends ht{constructor(i){super(zs,i);O(this,"id",ur.Parallel);O(this,"name",ur.Parallel);O(this,"description","Programmatically execute a list of actions one after the other");O(this,"version","1");O(this,"autoexecutable",!0);O(this,"initialData",zs);O(this,"type",f.ActionDescriptor);O(this,"inputs",[]);O(this,"outputs",[]);O(this,"error",null);O(this,"project");this.project=i,this.inputs=zs.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=zs.outputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=zs.error?ee(zs.error,this.project):null}}class qG extends ht{constructor(i){super(Bi,i);O(this,"id",Bi.id);O(this,"name",Bi.name);O(this,"description",Bi.description);O(this,"version",Bi.version);O(this,"autoexecutable",!1);O(this,"initialData",Bi);O(this,"type",f.ActionDescriptor);O(this,"inputs",[]);O(this,"outputs",[]);O(this,"error",null);O(this,"project");this.project=i,this.inputs=Bi.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=Bi.outputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=Bi.error?ee(Bi.error,this.project):null}}class ZG extends ht{constructor(i){super(oa,i);O(this,"id",ur.Sequential);O(this,"name",ur.Sequential);O(this,"description","Programmatically execute a list of actions one after the other");O(this,"version","1");O(this,"autoexecutable",!0);O(this,"initialData",oa);O(this,"type",f.ActionDescriptor);O(this,"inputs",[]);O(this,"outputs",[]);O(this,"error",null);O(this,"project");this.project=i,this.inputs=oa.inputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=oa.outputs.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=oa.error?ee(oa.error,this.project):null}}class cve extends ht{constructor(u){super(Nu,u)}}class pve extends ht{constructor(u){super(Oo,u)}}class fve extends ht{constructor(i){super(Co,i);O(this,"autoexecutable",!0)}getEntityToMatchInputMap(i){return i.inputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===ve.operation[cr.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(i){return i.inputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===ve.operation[cr.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(i){return i.outputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===ve.operation[cr.Validate].outputs.outputEntity.id})||null}getEntityToMatch(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"get-entity-to-match-validate-data"))){var t;const l=((t=this.project.requestActiveDynamicValue(i))==null?void 0:t.value)||null,p=l==null?void 0:l.valueAsTypeSingle;return a==null||a.attemptAutoclose("get-entity-to-match-validate-data",this.id),p}syncOperationInstance(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-operation-instance-validate-data"))){const l=[],p=[],t=[],y=[],v=this.getEntityToMatchInputMap(i);if(v){const{added:A,updated:P,removed:N,affected:U}=this.syncEntityToMatchInputMapDataType(v,a);l.push(...P),p.push(...A),t.push(...N),y.push(...U)}const T=this.getDataToValidateInputMap(i);if(T){const{added:A,updated:P,removed:N,affected:U}=this.syncDataToValidateInputMapDataType(T,a);l.push(...P),p.push(...A),t.push(...N),y.push(...U)}const R=this.getOutputDataOutputMap(i);if(R){const{added:A,updated:P,removed:N,affected:U}=this.syncOutputDataOutputMapDataType(R,a);l.push(...P),p.push(...A),t.push(...N),y.push(...U)}return a==null||a.attemptAutoclose("sync-operation-instance-validate-data",this.id),{updated:w(l),added:w(p),removed:w(t),affected:w(y),self:i}}syncEntityToMatchInputMapDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-entity-to-match-input-map-data-type"))){var R,A,P,N,U,K,k,J,se,te,ce,re,fe,z,Y,ue;const l=[],p=[],t=[],y=[];if(((R=i.declaration)==null?void 0:R.id)!==ve.operation[cr.Validate].inputs.entityToMatch.id)return a==null||a.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const v=((A=this.project.requestActiveDynamicValue(i))==null?void 0:A.value)||null,T=v==null?void 0:v.valueAsTypeSingle;if(!i.dataType){const H={id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||V.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:((P=i.declaration.dataType)==null?void 0:P.options)||null,implementationChooseOne:((N=i.declaration.dataType)==null?void 0:N.implementationChooseOne)||!1,staticEntities:((U=i.declaration.dataType)==null?void 0:U.staticEntities)??null,interactiveEntities:((K=i.declaration.dataType)==null?void 0:K.interactiveEntities)??null,actionEntities:((k=i.declaration.dataType)==null?void 0:k.actionEntities)??null,isList:((J=i.declaration.dataType)==null?void 0:J.isList)||!1,andChildrenGroup:null,orChildrenGroup:null,asType:!0,entity:(T==null?void 0:T.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},ae=ee(H,i.project);ae.hydrateAncestors(),ae.setParent(i,a),ae.initChildren(a),ae.setEntity(T,a),a==null||a.add(ae,G.Added),l.push(ae),i.setDataType(ae,a)}return(Y=i.dataType)==null||Y.metaSync({inferred:!0,like:!1,asType:!0,options:((se=i.declaration.dataType)==null?void 0:se.options)||null,implementationChooseOne:((te=i.declaration.dataType)==null?void 0:te.implementationChooseOne)||!1,staticEntities:((ce=i.declaration.dataType)==null?void 0:ce.staticEntities)??null,interactiveEntities:((re=i.declaration.dataType)==null?void 0:re.interactiveEntities)??null,actionEntities:((fe=i.declaration.dataType)==null?void 0:fe.actionEntities)??null,isList:((z=i.declaration.dataType)==null?void 0:z.isList)||!1},a),(ue=i.dataType)==null||ue.setEntity(T,a),i.dataType&&p.push(i.dataType),a==null||a.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:w(p),added:w(l),removed:w(t),affected:w(y),self:i.dataType}}syncDataToValidateInputMapDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-data-to-validate-input-map-data-type"))){var A,P,N;const l=[],p=[],t=[],y=[];if(((A=i.declaration)==null?void 0:A.id)!==ve.operation[cr.Validate].inputs.dataToValidate.id)return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const v=this.getEntityToMatchInputMap(i.parent);if(!v)return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(v,a))return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!i.dataType){const U={id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||V.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,isList:!1,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,asType:!1,entity:null,like:!0,inferred:!0,parent:i.toReference()},K=ee(U,i.project);K.setParent(i,a),K.initChildren(a),a==null||a.add(K,G.Added),l.push(K),i.setDataType(K,a)}(P=i.dataType)==null||P.metaSync({inferred:!0,like:!0,asType:!1},a);const R=this.getEntityToMatch(v,a);return(N=i.dataType)==null||N.setEntity(R,a),i.dataType&&p.push(i.dataType),a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:w(p),added:w(l),removed:w(t),affected:w(y),self:i.dataType}}syncOutputDataOutputMapDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"sync-output-data-output-map-data-type"))){var P,N,U,K;const l=[],p=[],t=[],y=[];if(((P=i.declaration)==null?void 0:P.id)!==ve.operation[cr.Validate].outputs.outputEntity.id)return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const v=this.getEntityToMatchInputMap(i.parent);if(!v)return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(v,a))return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const R=((N=this.project.requestActiveDynamicValue(v))==null?void 0:N.value)||null,A=(R==null?void 0:R.valueAsTypeSingle)||null;if(!i.dataType){const k={id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||V.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:(A==null?void 0:A.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},J=ee(k,i.project);J.hydrateAncestors(),J.setParent(i,a),J.initChildren(a),J.setEntity(A,a),a==null||a.add(J,G.Added),l.push(J),i.setDataType(J,a)}return(U=i.dataType)==null||U.metaSync({inferred:!0,like:!0,asType:!1},a),(K=i.dataType)==null||K.setEntity(A,a),i.dataType&&p.push(i.dataType),a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:w(p),added:w(l),removed:w(t),affected:w(y),self:i.dataType}}inferInputMapDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"infer-input-map-data-type-validate-data"))){var p,t,y;if(((p=i.declaration)==null?void 0:p.id)===ve.operation[cr.Validate].inputs.entityToMatch.id){const{added:v,updated:T,removed:R,affected:A}=this.syncEntityToMatchInputMapDataType(i,a);return a==null||a.attemptAutoclose("infer-input-map-data-type",this.id),{updated:w(T),added:w(v),removed:w(R),affected:w(A),self:i.dataType}}if(((t=i.declaration)==null?void 0:t.id)===ve.operation[cr.Validate].inputs.dataToValidate.id){const{added:v,updated:T,removed:R,affected:A}=this.syncDataToValidateInputMapDataType(i,a);return a==null||a.attemptAutoclose("infer-input-map-data-type",this.id),{updated:w(T),added:w(v),removed:w(R),affected:w(A),self:i.dataType}}const l=(y=i.declaration)==null?void 0:y.getDataType(a);if(l&&l.isResolved)return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:l};if(i.readsValue){const v=tn(i.readsValue,a);return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:v}}return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:null}}inferOutputMapDataType(i,a=this.project.addChangeSet(new F(this.project,V.sessionAuthor,L().toISOString(),this,!0,"infer-output-map-data-type-validate-data"))){var l;if(((l=i.declaration)==null?void 0:l.id)===ve.operation[cr.Validate].outputs.outputEntity.id){const{added:p,updated:t,removed:y,affected:v}=this.syncOutputDataOutputMapDataType(i,a);return a==null||a.attemptAutoclose("infer-output-map-data-type-validate-data",this.id),{updated:w(t),added:w(p),removed:w(y),affected:w(v),self:i.dataType}}return{updated:[],added:[],removed:[],affected:[],self:null}}}class hve extends ht{constructor(u){super(rv,u)}}class yve extends ht{constructor(u){super(sv,u)}}class mve extends ht{constructor(u){super(nv,u)}}class vve extends ht{constructor(u){super(Mf,u)}}class Eve extends ht{constructor(u){super(Nf,u)}}class Tve extends ht{constructor(u){super(Vu,u)}}function bve(d){const u=[new ZG(d),new SG(d),new qG(d),new cve(d),new pve(d),new fve(d),new vve(d),new hve(d),new mve(d),new yve(d),new Eve(d),new Tve(d),new ht(tv,d),new ht(ev,d),new ht(hv,d),new ht(yv,d),new ht(mv,d),new ht(vv,d),new ht(Ev,d),new ht(Tv,d),new ht(bv,d),new ht(Av,d),new ht(Iv,d),new ht(wv,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.operationDeclarations=u,u}class JG extends xn{constructor(i){super(hi,i);O(this,"initialData");O(this,"id",Ve.PERSISTED_ENTITY);O(this,"version","1");O(this,"name",Ve.PERSISTED_ENTITY);O(this,"description",hi.description);O(this,"type",f.BuiltInBaseEntity);O(this,"abstract",hi.abstract);O(this,"static",hi.static);O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"errors",[]);O(this,"project");this.initialData=hi,this.project=i,this.id=hi.id,this.version=hi.version,this.name=hi.name,this.static=hi.static,this.abstract=hi.abstract,this.properties=this.initialData.properties.map(a=>{const l=ee(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.methods=this.initialData.methods.map(a=>{const l=ee(a,this.project);return l.parent=this,l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=ee(a,this.project);return l.parent=this,l}),this.extends=this.initialData.extends.map(a=>ee(a,this.project))}}var WG=(d=>(d.StatusCodeMustBeNumber="status-code-must-be-number",d.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",d))(WG||{});function HG(d,u){const i=[];if(typeof u!="number"){const a=new Xt({id:d.id+"--status-code-must-be-number",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value must be a number.`,issue:null,severity:q.Error,code:"status-code-must-be-number",entity:d});return i.push(a),{errors:i,override:u}}if(u<100){const a=new Xt({id:d.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value must be a number between 100 and 599.`,issue:null,severity:q.Error,code:"status-code-must-be-between-100-and-599",entity:d});i.push(a)}if(u>599){const a=new Xt({id:d.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${d.type} with id "${d.id}" has an invalid value "${u}". The value must be a number between 100 and 599.`,issue:null,severity:q.Error,code:"status-code-must-be-between-100-and-599",entity:d});i.push(a)}return{errors:i,override:u}}class YG extends xn{constructor(i){super(Xi,i);O(this,"initialData");O(this,"id",Ve.PERSISTED_ENTITY);O(this,"version","1");O(this,"name",Ve.PERSISTED_ENTITY);O(this,"description",Xi.description);O(this,"type",f.BuiltInBaseEntity);O(this,"abstract",Xi.abstract);O(this,"static",Xi.static);O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"errors",[]);O(this,"project");this.initialData=Xi,this.project=i,this.id=Xi.id,this.version=Xi.version,this.name=Xi.name,this.static=Xi.static,this.abstract=Xi.abstract,this.properties=this.initialData.properties.map(t=>{const y=ee(t,this.project);return y.setParent(this,null),y.initChildren(null),y}),this.methods=this.initialData.methods.map(t=>{const y=ee(t,this.project);return y.parent=this,y}),this.abstractMethods=this.initialData.abstractMethods.map(t=>{const y=ee(t,this.project);return y.parent=this,y}),this.extends=this.initialData.extends.map(t=>ee(t,this.project));const a=this.properties.find(t=>t.id===ve["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!a)throw new Error("Path property not found in endpoint entity");a._codeNativeValueValidation=(t,y)=>bF(t,y);const l=this.abstractMethods.find(t=>t.id===ve["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!l)throw new Error("Handler method not found in endpoint entity");const p=l.outputs.find(t=>t.id===ve["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.outputs.statusCode.id);if(!p)throw new Error("Status code output not found in handler method");p.codeNativeValueValidation=(t,y)=>HG(t,y)}}const Ave="test_primitive_entities_export";class Ive extends xn{constructor(i){super(li,i);O(this,"initialData");O(this,"id",Ve.PERSISTED_ENTITY);O(this,"version","1");O(this,"name",Ve.PERSISTED_ENTITY);O(this,"description",li.description);O(this,"type",f.BuiltInBaseEntity);O(this,"abstract",li.abstract);O(this,"static",li.static);O(this,"properties",[]);O(this,"methods",[]);O(this,"abstractMethods",[]);O(this,"extends",[]);O(this,"errors",[]);O(this,"project");this.initialData=li,this.project=i,this.id=li.id,this.version=li.version,this.name=li.name,this.static=li.static,this.abstract=li.abstract,this.properties=this.initialData.properties.map(l=>{const p=ee(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=ee(l,this.project);return p.parent=this,p}),this.extends=this.initialData.extends.map(l=>ee(l,this.project));const a=this.properties.find(l=>l.id===ve["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id);if(!a)throw new Error("Path property not found in endpoint entity");a._codeNativeValueValidation=(l,p)=>AF(l,p)}}function wve(d){const u=[new JG(d),new YG(d),new Ive(d),new xn(ih,d)];return u.forEach(i=>{d.subscribeBuiltInInstance(i)}),d.builtInBaseEntities=u,u}function Rve(d){const u=[new ki(qe,d),new ki(ia,d),new ki(lt,d),new ki(W0,d),new ki(oi,d),new ki(sa,d),new ki(bn,d),new ki(na,d),new ki(Ul,d)];return u.forEach(i=>{d.subscribeBuiltInInstance(i)}),d.primitives=u,u}function gve(d){const u=[new ht(nh,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.globalEventActionDescriptors=u,u}function _ve(d){const u=[new ht(Uu,d),new ht(Va,d),new ht(Bu,d),new ht(Fl,d),new ht(Gl,d),new ht(Wf,d)];u.forEach(a=>{a.initChildren(null),d.subscribeBuiltInInstance(a)}),d.loopDeclarations=u;const i=[new ht(Xf,d),new ht(Mu,d),new ht(Yf,d),new ht(Ov,d),new ht($v,d),new ht(Hf,d)];return i.forEach(a=>{a.initChildren(null),d.subscribeBuiltInInstance(a)}),d.loopDeclarationsBodies=i,u}function Dve(d){const u=[new sn(ah,d),new sn(zv,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.valueDescriptors=u,u}function Ove(d){const u=[new ht(jo,d),new ht(Wv,d),new ht(Zl,d)];return u.forEach(i=>{i.initChildren(null),d.subscribeBuiltInInstance(i)}),d.conditionDeclarations=u,u}const dl={},Qy={},xp={empty:!1,enrich:!0,mock:!1,ignoreCache:!1,onFetch:async()=>null,manuallyInit:!1};function zG(d,u={enrich:!0,shallowErrors:!1},i){const a={enrich:!0,shallowErrors:!1,...u},{enrich:l,shallowErrors:p}=a,t=d.project,y=d.record,v=new Un(t),T=new Set;y[t.id]=t,T.add(t.id);const R=L().toISOString();Object.values(y).forEach(N=>{!N||v.allBuiltInEntityIds.includes(N.id)||T.add(N.id)}),v.order=Array.from(T),v.flatRecord=y,v.orderEntities();const A=em(d.project,i);A.instances[t.id]=A;const P=l?A.addChangeSet(new F(A,V.sessionAuthor,R,A,!0,"project-init-from-fetch-result")):null;return v.visit(N=>{if(N.id===A.id)return;const U=ee(N,A);try{U.hydrateAncestors(),U.addSelfToProject(null);const K=Nd(N);Object.keys(K.downstream).forEach(k=>{const J=A.get(k);J&&J.hydrateAncestors()})}catch(K){if(p)Fe.error("Error hydrating ancestors: ",K);else throw K}}),l?(v.visit(N=>{if(N.id===A.id)return;const U=A.get(N.id);U&&U.afterAllChildrenInitialized(P)}),A.afterAllChildrenInitialized(P)):tm(A,R).forEach(U=>{U.remove({ignoreUpstream:!0},null)}),A.instancesList.forEach(N=>{N.previousVersion=null}),P==null||P.attemptAutoclose("project-init-from-fetch-result",A.id),A}async function Cve(d,u=xp){const i={...xp,...u};if(i.empty)return{data:{project:{id:d.id,type:f.Project,version:V.UUID.uuid(),createdAt:L().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]},record:{}}};if(i.mock){const l={...lT};return l.id=d.id,{data:{project:l,record:{}}}}return Fe.log("Fetching project from external API"),new Promise(async l=>{try{if(i.onFetch){const p=await i.onFetch(d.id);if(p){l({data:p});return}}else l({data:null})}catch(p){Fe.error("Error fetching project: ",p),l({data:null})}})}function em(d,u){const i=new V(d,u);return Rve(i),wve(i),bve(i),gve(i),_ve(i),Dve(i),Ove(i),Array.from(new Set([...i.getAllBuiltInIds(),...xs()])).forEach(l=>{if(!i.builtInInstances[l]&&i.instances[l])i.builtInInstances[l]=i.instances[l],delete i.instances[l];else if(!i.builtInInstances[l])throw new Error(`Built in entity was not properly initialized: ${l}`)}),i.instances[i.id]=i,i}function tm(d,u){return d.instancesList.filter(a=>L(a.createdAt).isAfter(L(u)||!!a.previousVersion))}function $ve(d,{enrich:u}={enrich:!0},i){const a=new Map,l=new Map,p=Array.from(new Set([...d.getAllBuiltInIds(),...xs()]));Object.keys(d.instances).forEach(A=>{if(p.includes(A)){a.set(A,A),l.set(A,A);return}const P=d.get(A);if(!Hy(P,{...d.instances,...d.builtInInstances}).every(k=>!p.includes(k))){a.set(A,A),l.set(A,A);return}const K=V.UUID.uuid();a.set(A,K),l.set(K,A)});const t=L().toISOString(),y=d.toShallowJSON({seenEntityMaps:a});y.previousVersion=null,y.createdAt=t,y.version=V.UUID.uuid();const v=em(y,i);v.instances[v.id]=v;const T=u?v.addChangeSet(new F(v,V.sessionAuthor,t,v,!0,"project-clone")):null,R=new Un(d);return R.visit(A=>{const P=A.toShallowJSON({seenEntityMaps:a});P.previousVersion=null,P.createdAt=t,P.version=V.UUID.uuid();const N=Nd(P,MF(R.flatRecord,a));if(Object.keys(N.upstream).length){let K=!1;if(Object.keys(N.upstream).forEach(k=>{if(!K&&(!v.get(k)||v.getDeleted(k))){K=!0;return}}),K)return}const U=ee(P,v);U.hydrateAncestors(),U.addSelfToProject(T),T==null||T.add(U,G.Added)}),u?(R.visit(A=>{if(A.id===v.id)return;const P=v.get(a.get(A.id));P&&P.afterAllChildrenInitialized(T)}),v.afterAllChildrenInitialized(T)):tm(v,t).forEach(P=>{P.remove({ignoreUpstream:!0},null)}),v.instancesList.forEach(A=>{A.previousVersion=null}),T==null||T.attemptAutoclose("project-clone",v.id),v}function XG(d,{enrich:u}={enrich:!0},i){const a=em(d,i),l=L().toISOString(),p=u?a.addChangeSet(new F(a,V.sessionAuthor,l,a,!0,"project-init")):null;p&&(p.type=yb.Automatic);const t=new Un(d);return t.visit(y=>{const v=ee(y,a);v.hydrateAncestors(),v.addSelfToProject(p)}),u?(t.visit(y=>{if(y.id===a.id)return;const v=a.get(y.id);v&&v.afterAllChildrenInitialized(p)}),a.afterAllChildrenInitialized(p)):(tm(a,l).forEach(T=>{T.remove({ignoreUpstream:!0},null)}),new Un(a).visit(T=>{T.initialized=!0,T.captureVersion()})),a.initialized=!0,p==null||p.attemptAutoclose("project-init",a.id),a}async function Pve(d,u=xp,i){const a={...xp,...u};if(d.id&&dl[d.id]&&!a.ignoreCache)return dl[d.id];if(d.id&&Qy[d.id]&&!a.ignoreCache)return await Qy[d.id],dl[d.id];const l=Cve(d,a);d.id&&(Qy[d.id]=l);const p=await l;if(p.data){let t;return a.mock?t=XG(lT,{enrich:!!a.enrich},i):p.data instanceof V?t=p.data:t=zG(p.data,{enrich:!!a.enrich},i),dl[d.id]=t,d.id&&delete Qy[d.id],t}return null}function Vve(d){return dl[d.id]&&delete dl[d.id],null}D.AI_VALUE_CONNECTION_GENERATION_ACTION_EXPLANATION=AA,D.ALL_BUILT_IN_BASE_ENTITIES=MN,D.ALL_BUILT_IN_CONDITION_ENTITIES=XN,D.ALL_BUILT_IN_GLOBAL_EVENT_ENTITIES=e2,D.ALL_BUILT_IN_LOOP_BODY_ENTITIES=dV,D.ALL_BUILT_IN_LOOP_ENTITIES=lV,D.ALL_BUILT_IN_OPERATION_ENTITIES=b$,D.ALL_BUILT_IN_PRIMITIVE_ENTITIES=w1,D.ALL_BUILT_IN_TOP_LEVEL_ENTITIES=a2,D.ALL_BUILT_IN_VALUE_DESCRIPTORS=n2,D.ALL_CONNECTION_DISABLED_REASONS=_me,D.ALL_OTHER_DISABLED_REASONS=Ome,D.ALL_TESTING_DISABLED_REASONS=Dme,D.ActionDescriptorState=ht,D.ActionInputMapState=Qye,D.ActionOutputMapState=rme,D.AppendToListOperationInputIds=P_,D.AppendToListOperationOutputIds=V_,D.Area=ci,D.ArgumentDeclarationDependencyField=mx,D.ArgumentDeclarationState=Ea,D.BREAK_AND_CONTINUE_STATEMENTS_RETURN_DECLARATIONS_EXPLANATION=vA,D.BUILT_IN_BASE_ENTITY_IDS=ve,D.BUILT_IN_ENTITY_TYPES=zi,D.BaseCanvasDraggableState=sve,D.BaseEntityNames=Ve,D.BaseState=ive,D.BaseValueDescriptorIds=Ml,D.BreakStatementDependencyField=bx,D.BreakStatementState=Xa,D.BuiltInBaseEntityState=xn,D.BuiltInFunctionIds=Li,D.CACHED_PROJECTS_BY_ID=dl,D.CALLABLE_ENTITIES_EXPLANATION=Kme,D.CALLABLE_TYPES=$s,D.CALLER_ENTITIES_EXPLANATION=sF,D.CALLER_TYPES=Ps,D.CALLS_UPDATE_EXPLANATION=to,D.CANVAS_BASE_X=Zx,D.CANVAS_BASE_Y=Jx,D.CANVAS_CARD_HEADER_CENTER_HEIGHT=Pd,D.CANVAS_CARD_WIDTH=kx,D.CANVAS_COMPLEX_CARD_HEIGHT=bme,D.CANVAS_HORIZONTAL_BUFFER_BETWEEN_CARDS=nA,D.CANVAS_SIMPLE_CARD_HEIGHT=iA,D.CANVAS_SIZE=rA,D.CANVAS_VERTICAL_BUFFER_BETWEEN_CARDS=_y,D.CARD_FOOTER_HEIGHT=gy,D.CARD_PROPERTIES_SECTION_PADDING=ba,D.CARD_PROPERTIES_SECTION_SINGLE_PADDING=sA,D.CHILDREN_TYPES=D8,D.COMPARISON_CONDITIONS=YN,D.CONDITIONS=zN,D.CUSTOM_ENTITY_OPERATIONS=QD,D.CallableEntityClass=ave,D.CallerEntityClass=JA,D.CanvasEntityConnectionDisabledReason=aA,D.CanvasEntityOtherDisabledReason=lA,D.CanvasEntityTestingDisabledReason=oA,D.ChangeSet=F,D.ChangeSetChangeCaptureType=yb,D.ChangeSetEntityChangeType=G,D.ChildEntityBaseClass=nve,D.CommonStringValidationErrorCodes=TF,D.ComparisonOperatorTypes=vr,D.ConditionDependencyField=UU,D.ConditionState=Za,D.ContinueStatementDependencyField=VU,D.ContinueStatementState=Ti,D.CreateNewInputIds=DD,D.CreateNewOutputIds=OD,D.DEFAULT_BASE_EXTENSIONS_CONTEXT=zb,D.DEFAULT_EXECUTION_INSTANCE_PARENT_CONTEXT=Gx,D.DEFAULT_PROJECT_INSTANCE_PARENT_CONTEXT=kG,D.DEFAULT_PROJECT_STATIC_PARENT_CONTEXT=WA,D.DEFAULT_UUID_MODULE=$u,D.DRAGGABLE_CALLABLE_TYPES=J0,D.DRAGGABLE_CALLER_TYPES=h1,D.DRAGGABLE_ELEMENT_TYPES=Vf,D.DRAGGABLE_EXECUTABLE_TYPES=g8,D.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES=Pf,D.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=Z0,D.DataTypeCompatibilityTypes=Ms,D.DataTypeDependencyField=Tb,D.DataTypeParentChildRelation=ai,D.DataTypeState=is,D.DefinitionEntityDependencyField=Xy,D.DefinitionEntityState=wa,D.DynamicValueTypes=Te,D.EDITABLE_PERSISTANCE_REPOSITORY_DEFAULTS=tve,D.ENTITIES_WITH_VALLUES_EXPLANATION=$y,D.ENTITY_PERSISTANCE_OPTIONS_DEFAULTS=me,D.ENTITY_RECUSION_OPTIONS_DEFAULTS=xe,D.ENTITY_TYPES=_8,D.ENTITY_WITH_CODE_NAMES_TYPES=m1,D.ENTITY_WITH_DECLARATION_TYPES=w8,D.ENTITY_WITH_LOGIC_SCOPE_TYPES=Dr,D.ENTITY_WITH_NAMES_TYPES=y1,D.ENTITY_WITH_PARENT_TYPES=A8,D.ENTITY_WITH_USER_MANAGED_DECLARATION_TYPES=p1,D.ENTITY_WITH_USER_MANAGED_SINGLE_IMPLEMENTS_TYPES=I8,D.ENTITY_WITH_VALUE_TYPES=q0,D.ENTRY_POINT_ENTITIES_EXPLANATION=_p,D.ENTRY_POINT_TYPES=tr,D.ERROR_PROPERTY_HEIGHT=Ry,D.EVENT_TYPES=_o,D.EXECUTABLE_TYPES=R8,D.EXECUTION_OPERATIONS=_D,D.EfimeralValueStore=mp,D.EndpointEntity=YG,D.EntityError=Xt,D.EntityErrorSeverity=q,D.EntityGenerationError=Q,D.EntityGenerationErrorCode=S,D.EntityInstanceErrorCode=oe,D.EntityOperations=cr,D.EntityType=f,D.EntityWithLogicScopeClass=uve,D.EntityWithValueClass=dve,D.EntryPointEntityClass=ove,D.Execution=Bn,D.ExecutionOperations=ur,D.ExecutionState=Xb,D.ExecutionTerminationType=Je,D.ExplicitInfrastructureResource=pA,D.ExtensionContextType=xx,D.ExtensionPermissions=Fx,D.ExtensionsRegistry=mme,D.ExtentionPriority=Ay,D.FunctionCallDependencyField=yF,D.FunctionCallState=so,D.FunctionDeclarationDependencyField=RU,D.FunctionDeclarationState=Ka,D.GET_PROJECT_OPTIONS_DEFAULTS=xp,D.GLOBAL_EVENT_DECLARATIONS=QN,D.GetLastInListOperationInputIds=T_,D.GetLastInListOperationOutputIds=b_,D.GlobalEventNames=ra,D.GlobalEventState=qa,D.HTTPOperations=Ei,D.HTTPStatucCodeValidationErrorCodes=WG,D.HTTP_OPERATIONS=NO,D.ImplicitGlobalInfrastructureResource=fA,D.InfrastructureResource=cA,D.InfrastructureResourceStatus=eF,D.InputMapDependencyField=px,D.InputMapState=Ln,D.InstalledProjectState=Ya,D.InternalCallDependencyField=ux,D.InternalCallState=za,D.JoinListOperationInputIds=xg,D.JoinListOperationOutputIds=Fg,D.LIST_OPERATIONS=q_,D.ListOperations=vt,D.LiteralValueDependencyField=Ex,D.LiteralValueState=$i,D.Logger=Fe,D.LoopDependencyField=BU,D.LoopState=Oi,D.LoopTypes=Ze,D.MAIN_VALUE_PROPERTY_HEADER_HEIGHT=wy,D.MAIN_VALUE_SUB_PROPERTY_HEIGHT=Ame,D.NESTED_PROPERTY_HEIGHT=Sx,D.NON_INTERACTIVE_BASE_ENTITIES_EXPLANATION=ro,D.NUMBER_OPERATIONS=Q1,D.NumberOperations=mr,D.OPERATION_DECLARATIONS=T$,D.OperationDependencyField=DU,D.OperationState=ka,D.OutputMapDependencyField=hx,D.OutputMapParentChildRelation=Bl,D.OutputMapState=rn,D.PARENT_AUTO_CALCULATION_FROM_CALLER_EXPLANATION=Py,D.PASS_THROUGH_CALLABLE_ENTITIES_EXPLANATION=eo,D.PASS_THROUGH_CALLABLE_TYPES=nr,D.PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=f1,D.PLACEHOLDER_VALUE_STORE_CLIENT=wx,D.PROPERTY_HEIGHT=Iy,D.PROPERTY_NOT_VALUE_READER_WRITTER_EXPLANATION=bA,D.PUBLISHING_DISABLED_REASONS=tF,D.ParallelExecutionOperation=SG,D.PassThroughCallableEntityClass=lve,D.PersistedEntity=JG,D.PrimitiveEntityState=ki,D.PrimitiveTypes=X,D.ProjectState=V,D.ProjectStateEvents=gr,D.PropertyDependencyField=MG,D.PropertyState=jn,D.PublicationRun=Nme,D.PublicationStep=Qx,D.RANDOMNESS_OPERATIONS=E$,D.READABLE_ENTITY_TYPES=Qb,D.READ_ONLY_ENTITY_PERSISTANCE_REPOSITORY=KG,D.RETURN_STATEMENT_RETURN_DECLARATIONS_EXPLANATION=kme,D.RandomnessOperations=Le,D.ReturnDeclarationDependencyField=CU,D.ReturnDeclarationState=Ki,D.ReturnStatementDependencyField=bb,D.ReturnStatementState=Sa,D.SQLAST=kye,D.STANDALONE_CONDITIONS=GN,D.STATIC_PROPERTY_HEIGHT=qx,D.STRING_OPERATIONS=jg,D.ScopeCompatibilityType=Jy,D.SearchDependencyField=Qj,D.SearchState=Ha,D.SequentialExecutionOperation=ZG,D.SequentialExecutionOperationInputIds=fD,D.SequentialExecutionOperationOutputIds=hD,D.SharedEntityErrorCode=ne,D.SharedStateFunctionality=GG,D.SplitListOperationInputIds=t_,D.SplitListOperationOutputIds=r_,D.StandaloneOperatorTypes=kr,D.StringOperations=It,D.TERMINATION_TYPES=pr,D.Traverser=Un,D.USER_MANAGED_ENTITY_TYPES=v1,D.UserManagedEntityStateTemplate=rve,D.VALUE_READING_ENTITIES_EXPLANATION=TA,D.VALUE_READING_TYPES=Tn,D.VALUE_WRITING_ENTITIES_EXPLANATION=nF,D.VALUE_WRITING_TYPES=Ur,D.VARIABLE_DATA_TYPE_INFERRANCE_EXPLANATION=EA,D.VARIABLE_TYPES=ot,D.ValueAutogenerationType=Mr,D.ValueDescriptorDependencyField=Ix,D.ValueDescriptorParentChildRelation=le,D.ValueDescriptorState=sn,D.ValueReadingEntityClass=Up,D.ValueWritingEntityClass=jp,D.VariableDeclarationDependencyField=GU,D.VariableDeclarationState=Wa,D.VariableInputMapState=Xye,D.VariableInstanceDependencyField=Ib,D.VariableInstanceState=Ja,D.VariableOutputMapState=tme,D.WaitOperation=qG,D.WaitOperationInputIds=aD,D.WaitOperationOutputIds=oD,D.actionDescriptorValidation=Xfe,D.addDisabledReasons=$me,D.afterLiteralValueAsTypeChangeSideEffects=Ux,D.afterLiteralValueAsTypeDeleteSideEffects=Mx,D.afterLiteralValueChangeSideEffects=Lx,D.afterLiteralValueDeleteSideEffects=Nx,D.aggregateVariableInputsNextValues=vp,D.aggregateVariableInputsValues=vy,D.appendToListOperation=Mf,D.appendToListOperationElementToAppendArgument=ov,D.appendToListOperationElementToAppendArgumentParentRef=F_,D.appendToListOperationElementToAppendArgumentRef=B_,D.appendToListOperationError=S_,D.appendToListOperationErrorParentRef=k_,D.appendToListOperationListArgument=av,D.appendToListOperationListArgumentParentRef=x_,D.appendToListOperationListArgumentRef=N_,D.appendToListOperationListDataType=L_,D.appendToListOperationResultListDataType=j_,D.appendToListOperationResultListReturn=K_,D.appendToListOperationResultListReturnParentRef=G_,D.appendToListOperationResultListReturnRef=U_,D.appendToListOperationSecondListDataType=M_,D.applyNewScope=Se,D.argumentDeclarationValidation=ime,D.asGenerationActionExample=Mn,D.assembleAndAddLiteralValueFromDataType=nn,D.assembleStandaloneLiteralValueFromDataType=et,D.booleanPrototype=ia,D.breakStatementValidation=ame,D.calculateCardSize=Hx,D.calculateMethodCardSize=Wx,D.calculateNewParentBasedOnCallers=Op,D.capitalizeFirstLetter=di,D.changeSetJSONRecordToUniqueIds=Gfe,D.checkAreDataTypesCompatible=Us,D.checkAreDefinitionEntitiesCompatibleAsDataType=sx,D.checkArePropertiesCompatibleAsDataType=ix,D.checkExtendsBaseEntity=Wy,D.checkHasBaseEntity=as,D.checkHasMetadataChanged=Cr,D.checkImplementationsOverlap=Ia,D.checkImplementsBaseEntity=R0e,D.checkIsBranchDependentButNotDirectlyOnBranch=ll,D.checkIsBranchDependentOnBranch=OA,D.checkIsBuiltIn=UA,D.checkIsCallableEntityReachable=Bp,D.checkIsCanvasEntity=I0e,D.checkIsDefEntityInlineDeclaredForSearchOutputType=xb,D.checkIsDetachedBranch=vG,D.checkIsDetachedBranchShallow=BA,D.checkIsEmptyValue=my,D.checkIsGlobalVariable=b0e,D.checkIsGloballyDeclared=LA,D.checkIsLiteralValueEmpty=qb,D.checkIsMethod=MA,D.checkIsNestedScope=Zy,D.checkIsRequiredValue=Ta,D.checkScopeCompatibility=Fs,D.checkShouldInputOrOutputBePartOfFinalVariableObjectValue=Mp,D.checkShouldPropertyBePartOfFinalVariableObjectValue=jA,D.cloneProject=$ve,D.conditionValidation=Qfe,D.continueStatementValidation=Wfe,D.convertToAbstract=t0e,D.convertToNonAbstract=r0e,D.convertToNonStatic=s0e,D.convertToStatic=i0e,D.countedLoopActionDescriptor=Uu,D.countedLoopActionDescriptorDynamicReturnDeclaration=eV,D.countedLoopActionDescriptorDynamicReturnDeclarationParentRef=QP,D.countedLoopActionDescriptorStringArgumentDeclaration=XP,D.countedLoopActionDescriptorStringArgumentDeclarationDataType=YP,D.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValue=WP,D.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValueParentRef=JP,D.countedLoopActionDescriptorStringArgumentDeclarationDataTypeParentRef=HP,D.countedLoopActionDescriptorStringArgumentDeclarationParentRef=zP,D.countedLoopBodyActionDescriptor=Xf,D.countedLoopBodyActionDescriptorAnyDynamicArgument=nV,D.countedLoopBodyActionDescriptorAnyDynamicArgumentParentRef=sV,D.countedLoopBodyActionDescriptorAnyDynamicReturn=oV,D.countedLoopBodyActionDescriptorAnyDynamicReturnParentRef=aV,D.countedLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Vv,D.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=rV,D.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=tV,D.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=iV,D.createDefinitionEntityFromJSONObject=My,D.createEntityError=st,D.createNestedDataTypeForEntity=EF,D.createNewInstanceOperation=Oo,D.createNewInstanceOperationEntityToInstanciateArgument=MD,D.createNewInstanceOperationEntityToInstanciateArgumentRef=ND,D.createNewInstanceOperationEntityToInstanciateDataType=LD,D.createNewInstanceOperationError=FD,D.createNewInstanceOperationErrorParentRef=xD,D.createNewInstanceOperationNewEntityDataArgument=VD,D.createNewInstanceOperationNewEntityDataArgumentDataType=PD,D.createNewInstanceOperationNewEntityDataArgumentDataTypeParentRef=$D,D.createNewInstanceOperationNewEntityDataArgumentParentRef=CD,D.createNewInstanceOperationOutputEntityDeclaration=jD,D.createNewInstanceOperationOutputEntityDeclarationParentRef=UD,D.createNewInstanceOperationRef=BD,D.createSemanticId=PG,D.createStateFromGenerationTargetType=eve,D.createStateFromType=zt,D.createStateFromTypeAndSubscribe=ee,D.cronJobBuiltInBaseEntity=ih,D.cronJobBuiltInBaseEntityExpressionProperty=LN,D.cronJobBuiltInBaseEntityExpressionPropertyDataTypeRef=L8,D.cronJobBuiltInBaseEntityExpressionPropertyRef=VN,D.cronJobBuiltInBaseEntityRef=NN,D.cronJobTriggeredFunctionDeclarationBlueprint=Zv,D.cronJobTriggeredFunctionDeclarationBlueprintParentRef=$N,D.dataTypeCompatibilityToErrorExplanation=fF,D.dataTypeValidation=Kfe,D.datePrototype=bn,D.dateValueAutogenerationSchema=YT,D.definitionEntityToZodSchema=y2,D.definitionEntityValidation=Y0e,D.deletePersistedEntityMethod=qv,D.deletePersistedEntityMethodParentRef=hN,D.deleteRootProject=Vve,D.emitSideEffects=wU,D.emptyCondition=Wv,D.emptyConditionArgument=FN,D.emptyConditionRef=xN,D.endpointBuiltInBaseEntity=Xi,D.endpointBuiltInBaseEntityRef=fV,D.endpointBuiltInBaseEntityRefFour=HV,D.endpointBuiltInBaseEntityRefThree=IV,D.endpointBuiltInBaseEntityRefTwo=EV,D.endpointBuiltInCorsProperty=hV,D.endpointBuiltInCorsPropertyDataType=pV,D.endpointBuiltInCorsPropertyDataTypeRef=uV,D.endpointBuiltInCorsPropertyRef=cV,D.endpointBuiltInMethodProperty=Lv,D.endpointBuiltInMethodPropertyDataType=AV,D.endpointBuiltInMethodPropertyDataTypeRef=TV,D.endpointBuiltInMethodPropertyRef=bV,D.endpointBuiltInPathProperty=Nv,D.endpointBuiltInPathPropertyDataType=vV,D.endpointBuiltInPathPropertyDataTypeRef=yV,D.endpointBuiltInPathPropertyRef=mV,D.endpointPathParamsArgumentDeclaration=Mv,D.endpointPathParamsArgumentDeclarationRef=VV,D.endpointPathParamsVariableDataType=NV,D.endpointPathParamsVariableDataTypeRef=PV,D.endpointReachedTriggerActionDescriptor=Kv,D.endpointReachedTriggerActionDescriptorRef=LV,D.endpointReachedTriggerActionDescriptorRefFour=UV,D.endpointReachedTriggerActionDescriptorRefThree=MV,D.endpointReachedTriggerActionDescriptorRefTwo=BV,D.endpointRequestBodyArgumentDeclaration=jv,D.endpointRequestBodyArgumentDeclarationRef=_V,D.endpointRequestBodyVariableDataType=DV,D.endpointRequestHeadersArgumentDeclaration=Bv,D.endpointRequestHeadersArgumentDeclarationRef=RV,D.endpointRequestHeadersVariableDataType=gV,D.endpointRequestHeadersVariableDataTypeRef=wV,D.endpointRequestQueryParamsArgumentDeclaration=Uv,D.endpointRequestQueryParamsArgumentDeclarationRef=CV,D.endpointRequestQueryParamsVariableDataType=$V,D.endpointRequestQueryParamsVariableDataTypeRef=OV,D.endpointResponseBodyDataType=JV,D.endpointResponseBodyReturnDeclaration=Gv,D.endpointResponseBodyReturnDeclarationRef=ZV,D.endpointResponseCodeDataType=xV,D.endpointResponseCodeReturnDeclaration=xv,D.endpointResponseCodeReturnDeclarationDefaultValueParentRef=GV,D.endpointResponseCodeReturnDeclarationRef=jV,D.endpointResponseHeadersDataType=SV,D.endpointResponseHeadersDataTypeRef=KV,D.endpointResponseHeadersReturnDeclaration=Fv,D.endpointResponseHeadersReturnDeclarationRef=kV,D.endpointReturnStatementRef=FV,D.endpointReturnStatementRefThree=WV,D.endpointReturnStatementRefTwo=qV,D.enerateRandomIntegerOperationError=JO,D.enerateRandomIntegerOperationErrorParentRef=ZO,D.enrichFromKnownEntities=Cp,D.enumOptionsProperty=I1,D.enumOptionsPropertyDataType=b1,D.enumOptionsPropertyDataTypeRef=E1,D.enumOptionsPropertyRef=T1,D.enumPrototype=sa,D.enumPrototypeRef=A1,D.errorCodeToMessage=Rp,D.executionBuiltInBaseEntity=sh,D.executionBuiltInEntityAbortMethod=Jv,D.executionBuiltInEntityAbortMethodParentRef=BN,D.filterOutDuplicateEntities=w,D.filterOutDuplicateErrors=U4,D.findEntityFromKeys=gA,D.findReferenceToSelfInList=BF,D.findReferencesToSelfInProject=f0e,D.flattenActionDescriptor=UF,D.flattenArgumentDeclaration=jF,D.flattenBreakStatement=xF,D.flattenBuiltInBaseEntity=FF,D.flattenCalls=js,D.flattenCanvasAncestorsUntil=Vd,D.flattenCondition=GF,D.flattenContinueStatement=KF,D.flattenDataType=SF,D.flattenDefinitionEntity=kF,D.flattenDefinitionEntityExtensionAndImplementationTypes=Md,D.flattenDefinitionEntityExtensionTypes=Pp,D.flattenDefinitionEntityExtensions=PA,D.flattenDefinitionEntityImplementations=VA,D.flattenDefinitionEntityImplementionTypes=$p,D.flattenDerivedCanvasEntities=ns,D.flattenDetachedBranch=TG,D.flattenElementCalls=mt,D.flattenElementCallsOnTheSameScope=p0e,D.flattenEntity=ye,D.flattenFunctionCall=qF,D.flattenFunctionDeclaration=ZF,D.flattenGlobalEvent=JF,D.flattenInputMap=WF,D.flattenInstalledProject=HF,D.flattenInternalCall=YF,D.flattenLiteralValue=zF,D.flattenLoop=XF,D.flattenOperation=QF,D.flattenOutputMap=eG,D.flattenPrimitiveEntity=tG,D.flattenProject=rG,D.flattenProjectElements=LF,D.flattenProperty=iG,D.flattenRelatedCallableElementsOnTheRight=yG,D.flattenRelatedCanvasElementsOnTheLeft=mG,D.flattenRelatedCanvasElementsOnTheRight=Sy,D.flattenReturnDeclaration=sG,D.flattenReturnStatement=nG,D.flattenSearch=aG,D.flattenValueDescriptor=oG,D.flattenVariableDeclaration=lG,D.flattenVariableInstance=dG,D.flattenVariableReads=NF,D.flattenVariableWrites=VF,D.flattenVariables=sr,D.fromChangeSetToRecordChangeSet=$0e,D.fromLiteralValueTypeToPrimitiveType=Ub,D.fromPublishingDisabledCodeToReadable=Mme,D.fromZodParseToEntityGenerationErrors=hA,D.functionCallValidation=Xme,D.functionDeclarationValidation=Ffe,D.generate=ph,D.generateActionExample=Sme,D.generateExecutionDataType=Hye,D.generateHexadecimalTokenOperation=wv,D.generateHexadecimalTokenOperationError=v$,D.generateHexadecimalTokenOperationErrorParentRef=m$,D.generateHexadecimalTokenOperationResultStringDataType=f$,D.generateHexadecimalTokenOperationResultStringDataTypeParentRef=p$,D.generateHexadecimalTokenOperationResultStringOutput=y$,D.generateHexadecimalTokenOperationResultStringOutputParentRef=h$,D.generateIdFromStrategy=Nr,D.generateIdentifierOperation=bv,D.generateIdentifierOperationAlphabetInput=JC,D.generateIdentifierOperationAlphabetInputParentRef=SC,D.generateIdentifierOperationAlphabetInputType=ZC,D.generateIdentifierOperationAlphabetInputTypeParentRef=qC,D.generateIdentifierOperationError=QC,D.generateIdentifierOperationErrorParentRef=XC,D.generateIdentifierOperationLengthInput=kC,D.generateIdentifierOperationLengthInputParentRef=FC,D.generateIdentifierOperationLengthInputType=KC,D.generateIdentifierOperationLengthInputTypeParentRef=GC,D.generateIdentifierOperationResultStringDataType=YC,D.generateIdentifierOperationResultStringDataTypeParentRef=HC,D.generateIdentifierOperationResultStringOutput=zC,D.generateIdentifierOperationResultStringOutputParentRef=WC,D.generateMutablePropertiesExplanation=Dy,D.generatePlaceholderValueStore=lme,D.generateRandomAlphanumericOperation=Tv,D.generateRandomAlphanumericOperationError=xC,D.generateRandomAlphanumericOperationErrorParentRef=jC,D.generateRandomAlphanumericOperationLengthInput=NC,D.generateRandomAlphanumericOperationLengthInputParentRef=$C,D.generateRandomAlphanumericOperationLengthInputType=VC,D.generateRandomAlphanumericOperationLengthInputTypeParentRef=PC,D.generateRandomAlphanumericOperationResultStringDataType=BC,D.generateRandomAlphanumericOperationResultStringDataTypeParentRef=LC,D.generateRandomAlphanumericOperationResultStringOutput=UC,D.generateRandomAlphanumericOperationResultStringOutputParentRef=MC,D.generateRandomBase62Operation=vv,D.generateRandomBase62OperationError=TC,D.generateRandomBase62OperationErrorParentRef=EC,D.generateRandomBase62OperationLengthInput=fC,D.generateRandomBase62OperationLengthInputParentRef=uC,D.generateRandomBase62OperationLengthInputType=pC,D.generateRandomBase62OperationLengthInputTypeParentRef=cC,D.generateRandomBase62OperationResultStringDataType=yC,D.generateRandomBase62OperationResultStringDataTypeParentRef=hC,D.generateRandomBase62OperationResultStringOutput=vC,D.generateRandomBase62OperationResultStringOutputParentRef=mC,D.generateRandomBase64Operation=Ev,D.generateRandomBase64OperationError=CC,D.generateRandomBase64OperationErrorParentRef=OC,D.generateRandomBase64OperationLengthInput=wC,D.generateRandomBase64OperationLengthInputParentRef=bC,D.generateRandomBase64OperationLengthInputType=IC,D.generateRandomBase64OperationLengthInputTypeParentRef=AC,D.generateRandomBase64OperationResultStringDataType=gC,D.generateRandomBase64OperationResultStringDataTypeParentRef=RC,D.generateRandomBase64OperationResultStringOutput=DC,D.generateRandomBase64OperationResultStringOutputParentRef=_C,D.generateRandomBoolean=C2,D.generateRandomDate=T2,D.generateRandomDateAfter=m2,D.generateRandomDateBefore=v2,D.generateRandomDateBetweenRange=E2,D.generateRandomFloatOperation=yv,D.generateRandomFloatOperationError=QO,D.generateRandomFloatOperationErrorParentRef=XO,D.generateRandomFloatOperationResultNumberDataType=HO,D.generateRandomFloatOperationResultNumberDataTypeParentRef=WO,D.generateRandomFloatOperationResultNumberOutput=zO,D.generateRandomFloatOperationResultNumberOutputParentRef=YO,D.generateRandomHexadecimalOperation=mv,D.generateRandomHexadecimalOperationError=dC,D.generateRandomHexadecimalOperationErrorParentRef=lC,D.generateRandomHexadecimalOperationLengthInput=iC,D.generateRandomHexadecimalOperationLengthInputParentRef=eC,D.generateRandomHexadecimalOperationLengthInputType=rC,D.generateRandomHexadecimalOperationLengthInputTypeParentRef=tC,D.generateRandomHexadecimalOperationResultStringDataType=nC,D.generateRandomHexadecimalOperationResultStringDataTypeParentRef=sC,D.generateRandomHexadecimalOperationResultStringOutput=oC,D.generateRandomHexadecimalOperationResultStringOutputParentRef=aC,D.generateRandomIntegerOperation=hv,D.generateRandomIntegerOperationMaxValueInput=GO,D.generateRandomIntegerOperationMaxValueInputParentRef=jO,D.generateRandomIntegerOperationMaxValueInputType=FO,D.generateRandomIntegerOperationMaxValueInputTypeParentRef=xO,D.generateRandomIntegerOperationMinValueInput=qO,D.generateRandomIntegerOperationMinValueInputParentRef=KO,D.generateRandomIntegerOperationMinValueInputType=SO,D.generateRandomIntegerOperationMinValueInputTypeParentRef=kO,D.generateRandomIntegerOperationResultNumberDataType=BO,D.generateRandomIntegerOperationResultNumberDataTypeParentRef=LO,D.generateRandomIntegerOperationResultNumberOutput=UO,D.generateRandomIntegerOperationResultNumberOutputParentRef=MO,D.generateRandomNumber=R2,D.generateRandomNumberAfter=A2,D.generateRandomNumberBefore=I2,D.generateRandomNumberBetweenRange=w2,D.generateRandomText=O2,D.generateRandomTextAfter=g2,D.generateRandomTextBefore=_2,D.generateRandomTextBetweenRange=D2,D.generateRandomUUIDv4Operation=Av,D.generateRandomUUIDv4OperationError=n$,D.generateRandomUUIDv4OperationErrorParentRef=s$,D.generateRandomUUIDv4OperationResultStringDataType=t$,D.generateRandomUUIDv4OperationResultStringDataTypeParentRef=e$,D.generateRandomUUIDv4OperationResultStringOutput=i$,D.generateRandomUUIDv4OperationResultStringOutputParentRef=r$,D.generateShortIdentifierOperation=Iv,D.generateShortIdentifierOperationError=c$,D.generateShortIdentifierOperationErrorParentRef=u$,D.generateShortIdentifierOperationResultStringDataType=o$,D.generateShortIdentifierOperationResultStringDataTypeParentRef=a$,D.generateShortIdentifierOperationResultStringOutput=d$,D.generateShortIdentifierOperationResultStringOutputParentRef=l$,D.generateStandaloneIfDefault=dme,D.generateUniqueUUID=b2,D.getAllActionDescriptorsForConditions=Ly,D.getAllActionDescriptorsForGlobalEvents=Vy,D.getAllActionDescriptorsForLoops=Ny,D.getAllActionDescriptorsForOperations=Wme,D.getAllBuiltInEntityIds=xs,D.getAllGloballyDeclaredFunctionDeclarationsExplanation=uF,D.getAllVariablesInScope=N0e,D.getBaseBuiltInEntities=Pi,D.getBaseSchemaBasedOnType=rF,D.getBuiltInEntityOwner=ao,D.getCallableEntitiesDerivedFromInternalCalls=hG,D.getCallableEntitiesDerivedFromWrites=Bd,D.getCallableEntityReferenceSchema=ui,D.getCallableEntityTypeSchema=vU,D.getCalledBy=Is,D.getCallerEntityReferenceSchema=Xpe,D.getCallerEntityTypeSchema=zpe,D.getCalls=xy,D.getCanvasEntitiesDerivedFromInternalCalls=fG,D.getCanvasEntitiesDerivedFromWrites=Ld,D.getCanvasEntityDerivedFromValueReadingEntity=Ky,D.getCanvasEntityDerivedFromValueReadingEntityFromTransfer=pG,D.getCanvasEntityReferenceSchema=yfe,D.getCanvasEntityTypeSchema=hfe,D.getChildrenEntityWithValues=a0e,D.getColumnProperties=Ud,D.getCommonAncestor=CA,D.getCommonChildren=Uy,D.getDatabaseEntities=_0e,D.getDatabaseEntity=O0e,D.getDeclaration=bi,D.getDeclarationOutputedError=V0e,D.getDeepestScope=AG,D.getDefaultRelationalDatabaseEntityOrFirst=wG,D.getDraggableCallableEntityReferenceSchema=TU,D.getDraggableCallableEntityTypeSchema=EU,D.getDraggableCallerEntityReferenceSchema=efe,D.getDraggableCallerEntityTypeSchema=Qpe,D.getDraggableExecutableEntityReferenceSchema=sfe,D.getDraggableExecutableEntityTypeSchema=ife,D.getDraggablePassThroughCallableEntityReferenceSchema=ty,D.getDraggablePassThroughCallableEntityTypeSchema=ey,D.getDraggablePlayableEntityReferenceSchema=dfe,D.getDraggablePlayableEntityTypeSchema=lfe,D.getEntitiesCreatedSinceInitialization=tm,D.getEntitiesToPropagateValuesTo=an,D.getEntityArgumentDeclarations=$A,D.getEntityInputMaps=uG,D.getEntityOutputMaps=v0e,D.getEntityReferenceSchema=ffe,D.getEntityReturnDeclarations=cG,D.getEntityTypeSchema=pfe,D.getEntityWithLogicScopeReferenceSchema=ma,D.getEntityWithLogicScopeTypeSchema=nfe,D.getEntityWithValueReferenceSchema=mU,D.getEntityWithValueTypeSchema=Ype,D.getEntryPointEntityReferenceSchema=ii,D.getEntryPointEntityTypeSchema=Ga,D.getEventEntityReferenceSchema=Xh,D.getEventEntityTypeSchema=zh,D.getEventNameFromDefinition=Bme,D.getExecutableEntityReferenceSchema=rfe,D.getExecutableEntityTypeSchema=tfe,D.getExtendedBuiltInEntity=E0e,D.getExtendedDefinitionEntity=qy,D.getFirstNonLoopScopeOwner=Gr,D.getGenerationTargetSchemaBasedOnType=iF,D.getHTTPAPINameFromProjectId=zx,D.getHeadIfPartOfDetachedBranch=EG,D.getHighestScope=bG,D.getImplementedBuiltInEntity=T0e,D.getIsInteractive=Vp,D.getLastInListOperation=nv,D.getLastInListOperationError=$_,D.getLastInListOperationErrorParentRef=C_,D.getLastInListOperationInputListArgument=__,D.getLastInListOperationInputListArgumentParentRef=g_,D.getLastInListOperationInputListArgumentRef=A_,D.getLastInListOperationInputListDataType=I_,D.getLastInListOperationOutputElementDataType=R_,D.getLastInListOperationOutputElementReturn=O_,D.getLastInListOperationOutputElementReturnParentRef=D_,D.getLastInListOperationOutputElementReturnRef=w_,D.getLinkedEntitiesFromArgumentDeclaration=c0e,D.getLiteralValueNameFromDataType=rl,D.getLowestPersistedEntityImplementation=NA,D.getOnlyRelevantErrorsForPublication=zme,D.getParentCallableEntity=IF,D.getParentCallerEntity=RF,D.getParentCanvasEntities=Ai,D.getParentCanvasEntity=or,D.getParentCanvasEntityFromTransfer=jy,D.getParentEntryPoint=n0e,D.getParentPassthroughCallableEntity=wF,D.getPassThroughCallableEntityReferenceSchema=Tr,D.getPassThroughCallableEntityTypeSchema=Qh,D.getPeristedEntities=g0e,D.getPlayableEntityReferenceSchema=ofe,D.getPlayableEntityTypeSchema=afe,D.getProject=Pve,D.getPrototypeByType=Np,D.getRecordOrderForTraversal=e0e,D.getRecusriveParentsIds=Hy,D.getReferenceEntityId=Z,D.getReferencedEntitiesStateOrErrors=Cy,D.getReferencedEntityStateOrErrors=yA,D.getReferencedIds=Nd,D.getRelatedCallableElementsOnTheRight=ky,D.getRelatedCanvasElementsOnTheLeft=no,D.getRelatedCanvasElementsOnTheLeftFromTransfer=h0e,D.getRelatedCanvasElementsOnTheRight=ln,D.getRelationalDBInstanceNameFromEntityId=Xx,D.getRootEntryPointScopeOwner=Lp,D.getScopeOwner=Vi,D.getStateClassFromType=C0e,D.getStepNameFromDefinition=Lme,D.getTerminationReferenceSchema=cfe,D.getTerminationTypeSchema=ufe,D.getTopLevelParentEntityId=RG,D.getTouchedCanvasEntitiesFromChangeSet=P0e,D.getUsedArgFromDeclaration=y0e,D.getUsedReturnFromDeclaration=m0e,D.getValueReadingEntityReferenceSchema=yU,D.getValueReadingEntityTypeSchema=ya,D.getValueWritingEntityReferenceSchema=Hpe,D.getValueWritingEntityTypeSchema=yc,D.getVariableFromInputMapping=_F,D.getVariableFromReturnVariablePointer=CF,D.getVariableReferenceSchema=Fa,D.getVariableTypeSchema=Yo,D.getVariablesFromArgumentDeclarations=Gy,D.getVariablesFromInputMaps=DF,D.getVariablesFromOutputMapping=$F,D.getVariablesFromOutputMaps=PF,D.getVariablesFromReturnDeclarations=OF,D.getVariablesInSameOrHigherScope=Sb,D.getWrites=Fy,D.globalEventValidation=Hfe,D.groupCallsBasedOnParallelizableExecution=l0e,D.handleAfterEntityImplementationSideEffects=vF,D.handleBeforeEntityImplementationSideEffects=mF,D.handleLiteralValueChange=ume,D.handleLiteralValueDelete=Bx,D.handleValueAsTypeChange=cme,D.handleValueAsTypeDelete=jx,D.httpRequestBodyArgument=Ff,D.httpRequestBodyArgumentRef=pO,D.httpRequestBodyDataType=fO,D.httpRequestHeadersArgument=xf,D.httpRequestHeadersArgumentRef=uO,D.httpRequestHeadersDataType=cO,D.httpRequestMethodArgument=Uf,D.httpRequestMethodArgumentRef=lO,D.httpRequestMethodDataType=dO,D.httpRequestMethodDataTypeRef=aO,D.httpRequestOperation=Nu,D.httpRequestOperationErrorValueDescriptor=fv,D.httpRequestOperationErrorValueDescriptorDatatype=VO,D.httpRequestOperationErrorValueDescriptorRef=PO,D.httpRequestOperationRef=DO,D.httpRequestOperationRefEight=CO,D.httpRequestOperationRefFive=gO,D.httpRequestOperationRefFour=RO,D.httpRequestOperationRefNine=$O,D.httpRequestOperationRefSeven=OO,D.httpRequestOperationRefSix=_O,D.httpRequestOperationRefThree=wO,D.httpRequestOperationRefTwo=IO,D.httpRequestQueryParamsArgument=pv,D.httpRequestQueryParamsArgumentRef=sO,D.httpRequestQueryParamsDataType=nO,D.httpRequestVariableURLArgument=jf,D.httpRequestVariableURLArgumentRef=rO,D.httpRequestVariableURLDataType=iO,D.httpRequestVariableURLDataTypeRef=eO,D.httpResponseBodyReturnDataType=AO,D.httpResponseBodyReturnDataTypeRef=TO,D.httpResponseBodyReturnReturn=kf,D.httpResponseBodyReturnReturnRef=bO,D.httpResponseCodeDataType=yO,D.httpResponseCodeReturn=Gf,D.httpResponseCodeReturnRef=hO,D.httpResponseHeadersDataType=EO,D.httpResponseHeadersDataTypeRef=mO,D.httpResponseHeadersReturn=Kf,D.httpResponseHeadersReturnRef=vO,D.httpStatusCodeValueValidation=HG,D.hydrateOrDiscardLiteralValue=Rx,D.implement=By,D.inferArgumentDeclarationDataType=nx,D.inferDataType=tn,D.inferInputMapDataType=Gb,D.inferOutputMapDataType=kb,D.inferPropertyDataType=lx,D.inferReturnDeclarationDataType=Kb,D.inferValueDescriptorDataType=dx,D.inferVariableDeclarationDataType=ox,D.inferVariableInstanceDataType=ax,D.initBaseProjectEntity=em,D.initProject=XG,D.initProjectFromFetchResult=zG,D.inputMapValidation=Yye,D.installedProjectValidation=Jye,D.internalCallValidation=Wye,D.isPromise=RA,D.isUUID=VG,D.iterateOverListActionDescriptorListArgumentDeclaration=z$,D.iterateOverListActionDescriptorListArgumentDeclarationDataType=H$,D.iterateOverListActionDescriptorListArgumentDeclarationDataTypeParentRef=W$,D.iterateOverListActionDescriptorListArgumentDeclarationParentRef=Y$,D.iterateOverListLoopActionDescriptor=Va,D.iterateOverListLoopActionDescriptorDynamicReturnDeclaration=Q$,D.iterateOverListLoopActionDescriptorDynamicReturnDeclarationParentRef=X$,D.iterateOverListLoopBodyActionDescriptor=Mu,D.iterateOverListLoopBodyActionDescriptorAnyDynamicArgument=lP,D.iterateOverListLoopBodyActionDescriptorAnyDynamicArgumentParentRef=oP,D.iterateOverListLoopBodyActionDescriptorAnyDynamicReturn=uP,D.iterateOverListLoopBodyActionDescriptorAnyDynamicReturnParentRef=dP,D.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclaration=zf,D.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=tP,D.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=eP,D.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=rP,D.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclaration=aP,D.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=sP,D.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=iP,D.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=nP,D.iterateOverObjectKeysActionDescriptorObjectArgumentDeclaration=yP,D.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataType=fP,D.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataTypeParentRef=pP,D.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationParentRef=hP,D.iterateOverObjectKeysLoopActionDescriptor=Fl,D.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclaration=vP,D.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclarationParentRef=mP,D.iterateOverObjectKeysLoopBodyActionDescriptor=Ov,D.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgument=_P,D.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgumentParentRef=gP,D.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturn=OP,D.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturnParentRef=DP,D.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Dv,D.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=TP,D.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=EP,D.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=bP,D.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclaration=RP,D.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=IP,D.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=AP,D.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=wP,D.iterateOverObjectValuesActionDescriptorObjectArgumentDeclaration=NP,D.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataType=PP,D.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataTypeParentRef=$P,D.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationParentRef=VP,D.iterateOverObjectValuesLoopActionDescriptor=Gl,D.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclaration=BP,D.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclarationParentRef=LP,D.iterateOverObjectValuesLoopBodyActionDescriptor=$v,D.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgument=SP,D.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgumentParentRef=kP,D.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturn=ZP,D.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturnParentRef=qP,D.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Cv,D.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=UP,D.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=MP,D.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=jP,D.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclaration=KP,D.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=FP,D.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=xP,D.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=GP,D.iterateOverStringActionDescriptorDynamicReturnDeclaration=M$,D.iterateOverStringActionDescriptorDynamicReturnDeclarationParentRef=B$,D.iterateOverStringActionDescriptorStringArgumentDeclaration=L$,D.iterateOverStringActionDescriptorStringArgumentDeclarationDataType=V$,D.iterateOverStringActionDescriptorStringArgumentDeclarationDataTypeParentRef=P$,D.iterateOverStringActionDescriptorStringArgumentDeclarationParentRef=N$,D.iterateOverStringLoopActionDescriptor=Bu,D.iterateOverStringLoopBodyActionDescriptor=Yf,D.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgument=S$,D.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgumentParentRef=k$,D.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturn=Z$,D.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturnParentRef=q$,D.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclaration=gv,D.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=j$,D.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=U$,D.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=x$,D.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclaration=_v,D.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=G$,D.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=F$,D.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=K$,D.joinListOperation=rv,D.joinListOperationError=e_,D.joinListOperationErrorParentRef=Qg,D.joinListOperationFirstListArgument=Wg,D.joinListOperationFirstListArgumentParentRef=Jg,D.joinListOperationFirstListArgumentRef=Gg,D.joinListOperationFirstListDataType=Kg,D.joinListOperationResultListDataType=Zg,D.joinListOperationResultListReturn=Xg,D.joinListOperationResultListReturnParentRef=zg,D.joinListOperationResultListReturnRef=qg,D.joinListOperationSecondListArgument=Yg,D.joinListOperationSecondListArgumentParentRef=Hg,D.joinListOperationSecondListArgumentRef=kg,D.joinListOperationSecondListDataType=Sg,D.joinListWithLastSeparator=Xe,D.joinStringsOperation=Vu,D.joinStringsOperationDynamicStringArgument=bg,D.joinStringsOperationDynamicStringArgumentParentRef=Tg,D.joinStringsOperationDynamicStringArgumentRef=vg,D.joinStringsOperationDynamicStringDataType=Eg,D.joinStringsOperationError=mg,D.joinStringsOperationErrorParentRef=yg,D.joinStringsOperationFirstStringArgument=Lf,D.joinStringsOperationFirstStringArgumentParentRef=ag,D.joinStringsOperationFirstStringArgumentRef=eg,D.joinStringsOperationFirstStringDataType=tg,D.joinStringsOperationResultStringDataType=ng,D.joinStringsOperationResultStringReturn=Pu,D.joinStringsOperationResultStringReturnParentRef=hg,D.joinStringsOperationResultStringReturnRef=sg,D.joinStringsOperationSecondStringArgument=Bf,D.joinStringsOperationSecondStringArgumentParentRef=fg,D.joinStringsOperationSecondStringArgumentRef=rg,D.joinStringsOperationSecondStringDataType=ig,D.joinStringsOperationSeparatorStringArgument=pg,D.joinStringsOperationSeparatorStringArgumentParentRef=cg,D.joinStringsOperationSeparatorStringArgumentRef=og,D.joinStringsOperationSeparatorStringDataType=ug,D.joinStringsOperationSeparatorStringDataTypeDefaultValue=dg,D.joinStringsOperationSeparatorStringDataTypeDefaultValueParentRef=lg,D.keyValuePrototype=Ul,D.literalValueValidation=sme,D.loopValidation=zfe,D.lowercaseFirstLetter=dd,D.manualFlowActionDescriptorDeclarationArgumentDeclaration=Rv,D.manualFlowActionDescriptorDeclarationArgumentDeclarationDataType=R$,D.manualFlowActionDescriptorDeclarationArgumentDeclarationDataTypeParentRef=w$,D.manualFlowActionDescriptorDeclarationArgumentDeclarationParentRef=g$,D.manualFlowLoopActionDescriptor=Wf,D.manualFlowLoopActionDescriptorDynamicReturnDeclaration=I$,D.manualFlowLoopActionDescriptorDynamicReturnDeclarationParentRef=A$,D.manualFlowLoopBodyActionDescriptor=Hf,D.manualFlowLoopBodyActionDescriptorAnyDynamicArgument=D$,D.manualFlowLoopBodyActionDescriptorAnyDynamicArgumentParentRef=_$,D.manualFlowLoopBodyActionDescriptorAnyDynamicReturn=C$,D.manualFlowLoopBodyActionDescriptorAnyDynamicReturnParentRef=O$,D.mapActionDescriptorToTypeItRepresents=w0e,D.mapRecord=MF,D.mergeArraysOfStringsWithoutDuplicates=Cme,D.mergeEntityErrorsList=dde,D.mergeListOfEntities=A0e,D.methodDefaultValue=oO,D.mockClientProject=lT,D.moreThanOrEqualCondition=Zl,D.moreThanOrEqualConditionLeftHandArgument=qN,D.moreThanOrEqualConditionLeftHandArgumentDataType=kN,D.moreThanOrEqualConditionLeftHandArgumentDataTypeParentRef=KN,D.moreThanOrEqualConditionLeftHandArgumentParentRef=SN,D.moreThanOrEqualConditionRightHandArgument=HN,D.moreThanOrEqualConditionRightHandArgumentDataType=JN,D.moreThanOrEqualConditionRightHandArgumentDataTypeParentRef=ZN,D.moreThanOrEqualConditionRightHandArgumentParentRef=WN,D.noSpacesOrDashesValueValidation=AF,D.noSpacesValueValidation=bF,D.notEmptyCondition=jo,D.notEmptyConditionArgument=jN,D.notEmptyConditionRef=UN,D.nullPrototype=W0,D.numberAdditionOperation=Nf,D.numberAdditionOperationDynamicSummandArgument=M1,D.numberAdditionOperationDynamicSummandArgumentType=B1,D.numberAdditionOperationDynamicSummandArgumentTypeParentRef=L1,D.numberAdditionOperationError=N1,D.numberAdditionOperationErrorParentRef=V1,D.numberAdditionOperationFirstNumberArgument=H0,D.numberAdditionOperationFirstNumberArgumentRef=R1,D.numberAdditionOperationFirstNumberDataType=g1,D.numberAdditionOperationRef=$1,D.numberAdditionOperationRefThree=z0,D.numberAdditionOperationRefTwo=P1,D.numberAdditionOperationResultNumberDataType=C1,D.numberAdditionOperationResultNumberReturn=X0,D.numberAdditionOperationResultNumberReturnRef=O1,D.numberAdditionOperationSecondNumberArgument=Y0,D.numberAdditionOperationSecondNumberArgumentRef=_1,D.numberAdditionOperationSecondNumberDataType=D1,D.numberPrototype=lt,D.numberSubtractionOperation=ev,D.numberSubtractionOperationDynamicSubtrahendArgument=X1,D.numberSubtractionOperationDynamicSubtrahendArgumentType=z1,D.numberSubtractionOperationDynamicSubtrahendArgumentTypeParentRef=Y1,D.numberSubtractionOperationError=H1,D.numberSubtractionOperationErrorParentRef=W1,D.numberSubtractionOperationFirstNumberArgument=k1,D.numberSubtractionOperationFirstNumberArgumentRef=U1,D.numberSubtractionOperationFirstNumberDataType=j1,D.numberSubtractionOperationRef=Q0,D.numberSubtractionOperationRefThree=Z1,D.numberSubtractionOperationRefTwo=S1,D.numberSubtractionOperationResultNumberDataType=K1,D.numberSubtractionOperationResultNumberReturn=J1,D.numberSubtractionOperationResultNumberReturnRef=G1,D.numberSubtractionOperationSecondNumberArgument=q1,D.numberSubtractionOperationSecondNumberArgumentRef=x1,D.numberSubtractionOperationSecondNumberDataType=F1,D.numberValueAutogenerationSchema=HT,D.operationValidation=qfe,D.orderEntitiesForTraversal=Qme,D.outputMapValidation=eme,D.parallelExecutionOperation=zs,D.parallelExecutionOperationError=nD,D.parallelExecutionOperationErrorParentRef=sD,D.parallelExecutionOperationListOfExecutionResultsDataType=tD,D.parallelExecutionOperationListOfExecutionResultsReturn=dv,D.parallelExecutionOperationListOfExecutionResultsReturnRef=eD,D.parallelExecutionOperationListOfFunctionsArgument=lv,D.parallelExecutionOperationListOfFunctionsArgumentDatatype=Q_,D.parallelExecutionOperationListOfFunctionsArgumentRef=X_,D.parallelExecutionOperationListOfFunctionsBlueprint=z_,D.parallelExecutionOperationListOfFunctionsBlueprintDynamicInput=H_,D.parallelExecutionOperationListOfFunctionsBlueprintDynamicInputParentRef=W_,D.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutput=J_,D.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutputParentRef=Z_,D.parallelExecutionOperationListOfFunctionsBlueprintParentRef=Y_,D.parallelExecutionOperationRef=rD,D.parallelExecutionOperationRefThree=iD,D.persistedBuiltInBaseEntity=hi,D.persistedBuiltInBaseEntityDatabaseProperty=kl,D.persistedBuiltInBaseEntityDatabasePropertyDataType=TN,D.persistedBuiltInBaseEntityDatabasePropertyDataTypeRef=V8,D.persistedBuiltInBaseEntityDatabasePropertyParentRef=bN,D.persistedBuiltInBaseEntityDatabasePropertyRef=EN,D.persistedBuiltInBaseEntityPrimaryKeyProperty=Sl,D.persistedBuiltInBaseEntityPrimaryKeyPropertyDataType=ON,D.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOption=IN,D.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOptionParentRef=AN,D.persistedBuiltInBaseEntityPrimaryKeyPropertyParentRef=CN,D.persistedBuiltInBaseEntityPrimaryKeyPropertyRef=DN,D.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOption=RN,D.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOptionParentRef=wN,D.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOption=_N,D.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOptionParentRef=gN,D.printEntity=DA,D.processOutputGlobalValueDescriptorDataType=r2,D.processOutputGlobalValueDescriptorReturn=ah,D.processOutputGlobalValueDescriptorReturnRef=t2,D.projectPublicationCompletedGlobalEvent=nh,D.propagateNewInputOrOutputMapValueAsTypeToParentVariable=Ip,D.propagateNewInputOrOutputMapValueToParentVariable=Ap,D.propagateNewStaticPropertyValueAsTypeToVariables=nl,D.propagateNewStaticPropertyValueToVariables=sl,D.propertyToZodSchema=h2,D.propertyValidation=j0e,D.readValueFromWritter=$d,D.rebaseStack=Eb,D.relationalDatabaseBuiltInBaseEntity=li,D.relationalDatabaseBuiltInBaseEntityAutoscalingProperty=Sv,D.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataType=pN,D.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataTypeRef=cN,D.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyParentRef=fN,D.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyRef=uN,D.relationalDatabaseBuiltInBaseEntityDefaultProperty=kv,D.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataType=dN,D.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataTypeRef=oN,D.relationalDatabaseBuiltInBaseEntityDefaultPropertyRef=lN,D.relationalDatabaseBuiltInBaseEntityIdentifierProperty=Qf,D.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataType=XV,D.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataTypeRef=YV,D.relationalDatabaseBuiltInBaseEntityIdentifierPropertyRef=zV,D.relationalDatabaseBuiltInBaseEntityMinSizeProperty=rh,D.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataType=aN,D.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataTypeRef=sN,D.relationalDatabaseBuiltInBaseEntityMinSizePropertyRef=nN,D.relationalDatabaseBuiltInBaseEntityPasswordProperty=th,D.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataType=rN,D.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataTypeRef=P8,D.relationalDatabaseBuiltInBaseEntityPasswordPropertyDefaultValueParentRef=iN,D.relationalDatabaseBuiltInBaseEntityPasswordPropertyRef=tN,D.relationalDatabaseBuiltInBaseEntityRef=Kl,D.relationalDatabaseBuiltInBaseEntityUsernameProperty=eh,D.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataType=eN,D.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataTypeRef=$8,D.relationalDatabaseBuiltInBaseEntityUsernamePropertyRef=QV,D.removeDisabledReasons=Pme,D.resolveActionDescriptorName=$G,D.resolveArgumentDeclarationValue=Jb,D.resolveBaseEntityName=_G,D.resolveBuiltInBaseEntityDataTypeLabel=DG,D.resolveCardSubheader=Eme,D.resolveClonedEntityProject=Vr,D.resolveConditionOperatorLabel=zy,D.resolveDataType=yy,D.resolveDataTypeEntityOrNestedChildrenFromLiteralValue=_A,D.resolveDataTypeLabel=xd,D.resolveDatatypeIconName=vme,D.resolveDefinitionEntityDataTypeLabel=B0e,D.resolveDefinitionEntitySubheader=eA,D.resolveEntityCodeName=qA,D.resolveEntityDataTypeLabel=L0e,D.resolveEntityName=ie,D.resolveEntitySubheader=Tme,D.resolveFirstCallsSecond=d0e,D.resolveFirstWritesSecond=u0e,D.resolveFunctionDeclarationCardSubheader=tA,D.resolveInputMapNextStandaloneValue=Tp,D.resolveInputMapNextValue=Ty,D.resolveInputMapNextValueAsPropertyOfAnObject=Ox,D.resolveInputMapStandaloneValue=bp,D.resolveInputMapValue=$x,D.resolveInputMapValueAsPropertyOfAnObject=Cx,D.resolveMethodCardSubheader=Kx,D.resolveNextValue=by,D.resolveOutputMapValue=Hb,D.resolvePersistedDefinitionEntityDatabaseEntity=IG,D.resolvePrimaryKeyProperty=D0e,D.resolvePrimitiveEntityForSearchLiteralValueType=jb,D.resolvePrimitiveEntityName=CG,D.resolvePropertyValue=Px,D.resolvePublicationStepStatusFromType=jme,D.resolveResourceNameFromType=Ume,D.resolveReturnDeclarationValue=Wb,D.resolveSearchName=OG,D.resolveValue=il,D.resolveValueDescriptorValue=Vx,D.resolveVarDeclarationAggregateObjectValue=_x,D.resolveVarDeclarationNextAggregateObjectValue=gx,D.resolveVarDeclarationNextValue=Ep,D.resolveVarDeclarationValue=Zb,D.resolveVarInstanceNextValue=Ey,D.resolveVarInstanceValue=Dx,D.resolveVariableScope=zye,D.returnDeclarationValidation=Zfe,D.returnStatementValidation=Jfe,D.savePersistedEntityMethod=mN,D.savePersistedEntityMethodParentRef=yN,D.searchStatementErrorGlobalValueDescriptor=zv,D.searchStatementErrorGlobalValueDescriptorDataType=s2,D.searchStatementErrorGlobalValueDescriptorRef=i2,D.searchStatementState=Sye,D.searchStatementUtils=Zye,D.searchValidation=rhe,D.sequentialExecutionOperation=oa,D.sequentialExecutionOperationError=gD,D.sequentialExecutionOperationErrorParentRef=RD,D.sequentialExecutionOperationListOfExecutionResultsDataType=AD,D.sequentialExecutionOperationListOfExecutionResultsReturn=cv,D.sequentialExecutionOperationListOfExecutionResultsReturnParentRef=wD,D.sequentialExecutionOperationListOfExecutionResultsReturnRef=bD,D.sequentialExecutionOperationListOfFunctionsArgument=uv,D.sequentialExecutionOperationListOfFunctionsArgumentDatatype=TD,D.sequentialExecutionOperationListOfFunctionsArgumentParentRef=ID,D.sequentialExecutionOperationListOfFunctionsArgumentRef=ED,D.sequentialExecutionOperationListOfFunctionsBlueprint=vD,D.sequentialExecutionOperationListOfFunctionsBlueprintDynamicInput=mD,D.sequentialExecutionOperationListOfFunctionsBlueprintDynamicOutput=yD,D.sortCallsBasedOnExecutionDependencies=gF,D.sortChildrenEntitiesBasedOnExecutionDependencies=o0e,D.splitListOperation=sv,D.splitListOperationError=E_,D.splitListOperationErrorParentRef=v_,D.splitListOperationFirstOutputListDataType=o_,D.splitListOperationFirstOutputListReturn=f_,D.splitListOperationFirstOutputListReturnParentRef=p_,D.splitListOperationFirstOutputListReturnRef=iv,D.splitListOperationInputListArgument=d_,D.splitListOperationInputListArgumentParentRef=l_,D.splitListOperationInputListArgumentRef=i_,D.splitListOperationInputListDataType=s_,D.splitListOperationSecondOutputListDataType=h_,D.splitListOperationSecondOutputListReturn=m_,D.splitListOperationSecondOutputListReturnParentRef=y_,D.splitListOperationSplitIndexArgument=c_,D.splitListOperationSplitIndexArgumentParentRef=u_,D.splitListOperationSplitIndexArgumentRef=n_,D.splitListOperationSplitIndexDataType=a_,D.splitStringOperation=tv,D.splitStringOperationError=Ug,D.splitStringOperationErrorParentRef=Mg,D.splitStringOperationFirstPartResultStringDataType=_g,D.splitStringOperationFirstPartResultStringReturn=Bg,D.splitStringOperationFirstPartResultStringReturnParentRef=Lg,D.splitStringOperationFirstPartResultStringReturnRef=gg,D.splitStringOperationIndexArgument=Vg,D.splitStringOperationIndexArgumentParentRef=Pg,D.splitStringOperationIndexArgumentRef=wg,D.splitStringOperationIndexDataType=Rg,D.splitStringOperationSecondPartResultStringDataType=Og,D.splitStringOperationSecondPartResultStringReturn=O8,D.splitStringOperationSecondPartResultStringReturnParentRef=Ng,D.splitStringOperationSecondPartResultStringReturnRef=Dg,D.splitStringOperationStringArgument=$g,D.splitStringOperationStringArgumentParentRef=Cg,D.splitStringOperationStringArgumentRef=Ag,D.splitStringOperationStringDataType=Ig,D.stringPrototype=qe,D.stringValueAutogenerationSchema=WT,D.suggestNewIdForEntity=ZA,D.syncSearchEntityOutput=Fb,D.test_primitive_entities_export=Ave,D.toCamelCase=$r,D.toEntityState=Ni,D.toKebabCase=gG,D.toLowerCaseKebabCase=Yy,D.toPascalCase=jd,D.transitionProjectVersion=mb,D.translateLogicErrorCode=Ime,D.translateLogicErrorCodeShort=wme,D.translateLogicErrorCodeShortWithEntityName=Rme,D.translateLogicErrorCodeWithEntityName=gme,D.traverseChangeSet=vb,D.untypedDataPrototype=oi,D.updateErrorsList=ar,D.urlDefaultValue=tO,D.uuidPrototype=na,D.validateArgumentDeclarationName=kA,D.validateCalledByErrorIdInAction=Zme,D.validateCalledByIdInAction=qme,D.validateCallers=dF,D.validateConditionEntityDeclaration=Hme,D.validateDataOperation=Co,D.validateDataOperationDataToValidateArgument=SD,D.validateDataOperationDataToValidateArgumentParentRef=kD,D.validateDataOperationDataToValidateArgumentRef=GD,D.validateDataOperationDataToValidateDataType=KD,D.validateDataOperationEntityToMatchTypeArgument=WD,D.validateDataOperationEntityToMatchTypeArgumentParentRef=JD,D.validateDataOperationEntityToMatchTypeArgumentRef=qD,D.validateDataOperationEntityToMatchTypeDataType=ZD,D.validateDataOperationError=XD,D.validateDataOperationErrorParentRef=zD,D.validateDataOperationOutputEntityDeclaration=YD,D.validateDataOperationOutputEntityDeclarationParentRef=HD,D.validateDefinitionEntityName=xA,D.validateEntryCaller=lF,D.validateErrorCaller=oF,D.validateFunctionCallDeclaration=cF,D.validateFunctionDeclarationName=FA,D.validateGeneratedEntityParentIsNotBuiltInEntity=Gme,D.validateGeneration=xme,D.validateGenerationTarget=Or,D.validateGenerationUpdate=Fme,D.validateLoopEntityDeclaration=Yme,D.validateMissingValue=io,D.validateName=M0e,D.validateOperationEntityDeclaration=pF,D.validatePropertyName=KA,D.validateReachability=Aa,D.validateReadsValueInActionPayload=Jme,D.validateReferenceObject=Oy,D.validateReferenceToOne=mA,D.validateReferences=zr,D.validateReturnDeclarationName=SA,D.validateSuccessCaller=aF,D.validateValueReaderGenerationUpdate=Dp,D.validateValueWritter=IA,D.validateVariableDeclarationName=GA,D.validateVariableInternalCallUse=wA,D.valueAutogenerationCurrentDateAndTimeSchema=QM,D.valueAutogenerationGenericSchema=Gh,D.valueAutogenerationOptions=zT,D.valueAutogenerationOptionsSchema=XM,D.valueAutogenerationRandomBooleanSchema=JT,D.valueAutogenerationRandomDateBetweenSchema=lU,D.valueAutogenerationRandomDateFromSchema=aU,D.valueAutogenerationRandomDateSchema=Sh,D.valueAutogenerationRandomDateUntilSchema=oU,D.valueAutogenerationRandomNumberBetweenSchema=rU,D.valueAutogenerationRandomNumberFromSchema=eU,D.valueAutogenerationRandomNumberSchema=Kh,D.valueAutogenerationRandomNumberUntilSchema=tU,D.valueAutogenerationRandomSchema=cc,D.valueAutogenerationRandomTextBetweenSchema=nU,D.valueAutogenerationRandomTextFromSchema=iU,D.valueAutogenerationRandomTextSchema=kh,D.valueAutogenerationRandomTextUntilSchema=sU,D.valueAutogenerationRangeValueTypesSchema=uc,D.valueAutogenerationUniqueSchema=ZT,D.valueDescriptorValidation=ome,D.variableDeclarationValidation=ehe,D.variableInstanceValidation=the,D.waitOperation=Bi,D.waitOperationMillisecondsNumberArgument=Do,D.waitOperationMillisecondsNumberArgumentRef=lD,D.waitOperationMillisecondsNumberDataType=dD,D.waitOperationOperationError=pD,D.waitOperationOperationErrorParentRef=cD,D.waitOperationRef=uD,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|