@elyx-code/project-logic-tree 0.0.7002 → 0.0.7003

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.cjs CHANGED
@@ -207,7 +207,7 @@ You shouldn't have to manually update a 'parent' property.
207
207
  Specifically for break statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];if(r==="break-statement-parent-field"){const{updated:m,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...m),e.push(...E),f.push(...b)}if(r==="break-statement-parent-data-type-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}if(r==="break-statement-parent-data-type-entity-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];if(r==="break-statement-parent-field"){const{updated:m,added:E,removed:b}=this.restore({},a);c.push(...m),e.push(...E),f.push(...b)}if(r==="break-statement-parent-data-type-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}if(r==="break-statement-parent-data-type-entity-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_;return this.parent.unsubscribeDependents([{entity:this,field:"break-statement-parent-field"}]),(a=(r=(i=this.dataType)==null?void 0:i.entity)==null?void 0:r.unsubscribeDependents)==null||a.call(r,[{entity:this,field:"break-statement-data-type-entity-field"}]),(e=(c=this.dataType)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"break-statement-data-type-field"}]),(E=(m=(h=(f=this.parent)==null?void 0:f.dataType)==null?void 0:h.entity)==null?void 0:m.unsubscribeDependents)==null||E.call(m,[{entity:this,field:"break-statement-parent-data-type-entity-field"}]),(_=(A=(b=this.parent)==null?void 0:b.dataType)==null?void 0:A.unsubscribeDependents)==null||_.call(A,[{entity:this,field:"break-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,V;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"break-statement-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.subscribeDependents)==null||c.call(a,[{entity:this,field:"break-statement-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||f.call(e,[{entity:this,field:"break-statement-data-type-field"}]),(b=(E=(m=(h=this.parent)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"break-statement-parent-data-type-entity-field"}]),(V=(_=(A=this.parent)==null?void 0:A.dataType)==null?void 0:_.subscribeDependents)==null||V.call(_,[{entity:this,field:"break-statement-parent-data-type-field"}]),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new Ki(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new Ki(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,V]of A.knownVersions)E.set(_,V);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new Ki(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.outputs=[...h.outputs],this.readsValue=h.readsValue,this.defaultValue=h.defaultValue,this.dataType=h.dataType,this.throws=h.throws,this.calledBySuccess=[...h.calledBySuccess],this.calledByError=[...h.calledByError],this.calledByEntry=[...h.calledByEntry],this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),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 a=re(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const a=re(i.readsValue),c=this.project.get(a),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(r),c&&this.setValueWriter(c,r)}else this.removeValueWriter(r);if(i.calledByEntry.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addEntryCaller(e,r),e.addCall(this,r))}),[...this.calledByEntry].forEach(a=>{i.calledByEntry.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledBySuccess.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addSuccessCaller(e,r),e.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(a=>{i.calledBySuccess.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledByError.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addErrorCaller(e,r),e.addErrorCall(this,r))}),[...this.calledByError].forEach(a=>{i.calledByError.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.outputs.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addOutput(e,r),e.setParent(this,r))}),[...this.outputs].forEach(a=>{i.outputs.find(e=>re(e)===a.id)||(this.removeOutput(a,r),a.removeFromParent(r))}),i.dataType){const a=re(i.dataType),c=this.project.get(a);c&&this.setDataType(c,r)}else this.setDataType(null,r);if(i.defaultValue){const a=re(i.defaultValue),c=this.project.get(a);c&&this.setDefaultValue(c,r)}else this.setDefaultValue(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return J.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const f=re(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}if(i.readsValue){const f=re(i.readsValue),h=this.project.get(f);if(!h)throw new Error(`${this.type} with id '${this.id}' has a 'readsValue' reference '${f}' that isn't found in the project`);const m=this.readsValue;m&&m.id!==(h==null?void 0:h.id)&&this.removeValueWriter(r),h&&this.setValueWriter(h,r)}else i.readsValue===null&&this.removeValueWriter(r);return(a=i.calledByEntry)==null||a.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addEntryCaller(m,r),m.addCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByEntry' reference '${h}' that isn't found in the project`)}),i.calledByEntry&&[...this.calledByEntry].forEach(f=>{var m;((m=i.calledByEntry)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addSuccessCaller(m,r),m.addSuccessCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledBySuccess' reference '${h}' that isn't found in the project`)}),i.calledBySuccess&&[...this.calledBySuccess].forEach(f=>{var m;((m=i.calledBySuccess)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addErrorCaller(m,r),m.addErrorCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByError' reference '${h}' that isn't found in the project`)}),i.calledByError&&[...this.calledByError].forEach(f=>{var m;((m=i.calledByError)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=re(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.readsValue){const e=re(this.initialData.readsValue),f=this.project.get(e);f&&(this.setValueWriter(f,null),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=re(e),h=this.project.get(f);h&&(this.addEntryCaller(h,null),i.push(h))}),this.initialData.calledBySuccess.forEach(e=>{const f=re(e),h=this.project.get(f);h&&(this.addSuccessCaller(h,null),i.push(h))}),this.initialData.calledByError.forEach(e=>{const f=re(e),h=this.project.get(f);h&&(this.addErrorCaller(h,null),i.push(h))}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred,this.readsValue&&this.defaultValue&&(this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)||this.defaultValue.remove({ignoreUpstream:!1},i),this.setDefaultValue(null,i)),this.defaultValue&&!this.readsValue&&!this.project.diggestedBuiltInBaseEntitiesIds.has(this.id)&&this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)){const b=this.defaultValue.clone(i,this);this.setDefaultValue(b,i)}const{added:f,updated:h,removed:m,affected:E}=this.syncInputs(i);return a.push(...f),r.push(...h),c.push(...m),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,A)=>{var _,V;return(b.index??((_=b.declaration)==null?void 0:_.index))-(A.index??((V=A.declaration)==null?void 0:V.index))}),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){var f,h;const r=[this],a=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),r.push(this.readsValue)),this.calledByEntry.forEach(m=>{m.addCall(this,i),r.push(m)}),this.calledBySuccess.forEach(m=>{m.addSuccessCall(this,i),r.push(m)}),this.calledByError.forEach(m=>{m.addErrorCall(this,i),r.push(m)}),this.parent.addBreakStatement(this),e.push(this.parent),i==null||i.add(this.parent,H.Affected),(f=this.parent)==null||f.breakStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),(h=this.parent)==null||h.continueStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}--${Me.CannotSuccessCallItself}`,action:w.AddSuccessCaller,owner:this,errorReason:Me.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddSuccessCaller})),this.calledBySuccess.find(e=>e.id===i.id)||(this.calledBySuccess.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Me.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Me.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddErrorCaller})),this.calledByError.find(e=>e.id===i.id)||(this.calledByError.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddEntryCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddEntryCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddEntryCaller}-${this.id}--${Me.CannotEntryCallItself}`,action:w.AddEntryCaller,owner:this,errorReason:Me.CannotEntryCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddEntryCaller})),this.calledByEntry.find(e=>e.id===i.id)||(this.calledByEntry.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}removeCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-caller")),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCaller,r)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),a&&gt(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}setThrows(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-throws"))){var a;if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==ud.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((a=this.throws)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.throws=i,r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose("set-throws",this.id),this}addOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,r)?this.outputs.includes(i)?(r==null||r.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),r==null||r.add(this,H.Affected),r==null||r.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("add-output",this.id),this)}removeOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("remove-output",this.id),this;const a=this.outputs.findIndex(c=>c.id===i.id);return a>-1&&(this.outputs.splice(a,1),r&&(r==null||r.add(this,H.Affected))),r==null||r.attemptAutoclose("remove-output",this.id),this}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,H.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setValueWriter(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueWriter))){var a,c,e;return this.checkCanEditFromScopeOwnerWithSideEffects(this,w.SetValueWriter,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.SetValueWriter}-${this.id}--${Me.CannotValueWriteItself}`,action:w.SetValueWriter,owner:this,errorReason:Me.CannotValueWriteItself,rootAction:((a=r==null?void 0:r.self)==null?void 0:a.id)===this.id&&(r==null?void 0:r.actionName)===w.SetValueWriter})),((c=this.readsValue)==null?void 0:c.id)!==(i==null?void 0:i.id)&&(this.readsValue=i,this.readsValue&&((e=this.defaultValue)==null||e.remove({ignoreUpstream:!1},r)),r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose(w.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditFromScopeOwnerWithSideEffects(this,w.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(w.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=Re(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=Re(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),uy.initReadsValue(this),this.outputs=this.initialData.outputs.map(r=>{const a=Re(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.throws&&(this.throws=Re(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=an(this,i,r),c=nn(this,a),e=this.toMeta();return this.x=a.x||e.x,this.y=a.y||e.y,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,H.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,H.Added):c&&(r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Se,...r){return await Ki.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await Ki.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await Ki.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await Ki.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await Ki.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await Ki.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent.removeBreakStatement(this),e.push(this.parent),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h,m,E;if(!this.checkCanDelete(this,r))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Me.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Me.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.actionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(b=>{const{updated:A,removed:_,added:V}=b.entity.onDetachedDependencyRemoved(this,b.field,r);a.push(...A),c.push(..._),e.push(...V)}),this.readsValue&&(a.push(this.readsValue),this.readsValue.removeValueReader(this,r)),this.outputs.forEach(b=>{const{updated:A,removed:_}=b.remove({ignoreUpstream:!0},r);a.push(...A),c.push(..._)}),this.throws){const{updated:b,removed:A}=this.throws.remove({ignoreUpstream:!0},r);a.push(...b),c.push(...A)}if(this.dataType){const{updated:b,removed:A}=this.dataType.remove({ignoreUpstream:!0},r);a.push(...b),c.push(...A)}if(!i){const b=this.removeFromParent(r);e.push(...b.added),a.push(...b.updated),c.push(...b.removed),f.push(...b.affected),this.calledBy.forEach(A=>{a.push(A),A.removeCall(this,r)})}return r==null||r.add(this.parent,H.Affected),(m=this.parent)==null||m.breakStatements.forEach(b=>{b.id!==this.id&&(f.push(b),r==null||r.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(f.push(b),r==null||r.add(b,H.Affected))}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(w.RestoreEntity,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(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.readsValue&&(a.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.throws){const{updated:f}=this.throws.restore({},i);a.push(...f)}if(this.dataType){const{updated:f}=this.dataType.restore({},i);a.push(...f)}return this.parent.addBreakStatement(this),this.calledBySuccess.forEach(f=>{a.push(f),f.addSuccessCall(this,i)}),this.calledByError.forEach(f=>{a.push(f),f.addErrorCall(this,i)}),this.calledByEntry.forEach(f=>{a.push(f),f.addCall(this,i)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(a=>a.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(a=>a.toFlatIds(i)),...this.throws?this.throws.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,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var r,a,c,e,f;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,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((r=this.defaultValue)==null?void 0:r.toJSON(i))||null,dataType:((a=this.dataType)==null?void 0:a.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,outputs:this.outputs.map(h=>h.toJSON(i)),calledBySuccess:this.calledBySuccess.map(h=>h.toReference()),calledByError:this.calledByError.map(h=>h.toReference()),calledByEntry:this.calledByEntry.map(h=>h.toReference()),parent:((e=this.parent)==null?void 0:e.toReference())||null,throws:((f=this.throws)==null?void 0:f.toJSON(i))||null})}toJSONClone(i=at){var a,c,e,f,h,m,E,b,A,_;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||pn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((m=this.defaultValue)==null?void 0:m.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,outputs:this.outputs.map(V=>V.toJSONClone({...i,newId:null})),calledBySuccess:this.calledBySuccess.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),parent:((A=this.parent)==null?void 0:A.toReference({seenEntityMaps:i.seenEntityMaps}))||null,throws:((_=this.throws)==null?void 0:_.toJSONClone({...i,newId:null}))||null})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f,h,m;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((f=this.readsValue)==null?void 0:f.toReference(i))||null,outputs:this.outputs.map(E=>E.toReference(i)),calledBySuccess:this.calledBySuccess.map(E=>E.toReference(i)),calledByError:this.calledByError.map(E=>E.toReference(i)),calledByEntry:this.calledByEntry.map(E=>E.toReference(i)),throws:((h=this.throws)==null?void 0:h.toReference(i))||null,parent:((m=this.parent)==null?void 0:m.toReference(i))||null}}toFlatJSON(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.defaultValue)==null?void 0:a.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.throws?this.throws.toFlatJSON(i):[]])}toGenerationTarget(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,calledByEntry:this.calledByEntry.map(c=>c.id),calledByError:this.calledByError.map(c=>c.id),calledBySuccess:this.calledBySuccess.map(c=>c.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.defaultValue)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,r,a;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(r=this.defaultValue)==null||r.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(a=this.throws)==null||a.clearErrors(),this}validate(){return this.errors=L4e(this),{success:!0}}async validateAsync(i={}){const r=J.YieldTracker.from(i);return this.errors=await $4e(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...((r=this.defaultValue)==null?void 0:r.getErrors())||[],...((a=this.dataType)==null?void 0:a.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const r=J.YieldTracker.from(i),a=[...this.errors];if(await r.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:r});a.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:r});a.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:r});a.push(...c)}return a}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-default-value",this.id),this;const a=this.defaultValue;if((a==null?void 0:a.id)!==(i==null?void 0:i.id)){if(a==null||a.remove({ignoreUpstream:!0},r),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(r),c==null||c.removeValueReader(this,r)}r==null||r.add(this,H.Affected)}return r==null||r.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var P,M,j;const e=qr(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.outputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.deletable=!0,f.editable=!0;const b=lr(f,e);r?b.setParent(r,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const A=(P=this.dataType)==null?void 0:P.clone(i,b,x.UUID.uuid(),c);b.setDataType(A||null,i);const _=(M=this.defaultValue)==null?void 0:M.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(_||null,i);const V=(j=this.outputs)==null?void 0:j.map((G,K)=>G.clone(i,b,E+"-return-declaration-"+K+"-id",c));return b.outputs=V,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i||b.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}getMasterInputWithValueWriterFromAllInstances(i){return C([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>de(c,this.project)===de(i,this.project)&&!!c.readsValue)||i}removeUnrecognizedInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[],f=this.getDataType(null);return f&&!f.isObject()?[...this.outputs].forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}):f&&f.hasStrictObjectStructure()&&[...this.outputs].forEach(m=>{if(!m.declaration){const b=m.remove({ignoreUpstream:!1},i);c.push(...b.removed),r.push(...b.updated);return}if(![...(f==null?void 0:f.entity).allProperties].find(b=>m.declaration===b)){const b=m.remove({ignoreUpstream:!1},i);c.push(...b.removed),r.push(...b.updated)}}),this.outputs.filter((m,E)=>{const b=this.outputs.findIndex(_=>_.declaration===m.declaration&&_!==m);if(b===-1)return!1;const A=this.outputs[b];return B(A==null?void 0:A.createdAt).isSame(B(m.createdAt))?E>b:!!B(A==null?void 0:A.createdAt).isAfter(m.createdAt)}).forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-break-statement-inputs"))){const r=[],a=[],c=[],e=[],f=this.getDataType(i);if(f)if(f.entity){if(f.isObject()){const b=[...f.entity.properties];this.outputs.filter(V=>!V.declaration||!b.find(P=>{var M;return P.id===((M=V.declaration)==null?void 0:M.id)})).forEach(V=>{const P=b.find(M=>de(M,this.project)===de(V,this.project));P&&V.setDeclaration(P,i)}),b.filter(V=>!this.outputs.find(P=>{var M;return((M=P.declaration)==null?void 0:M.id)===V.id})).forEach(V=>{const P={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:V,defaultValue:null,index:V.index,readsValue:null},M=Re(P,this.project);return M.hydrateAncestors(),i==null||i.add(M,H.Added),M.setParent(this,i),M.initChildren(i),this.addOutput(M,i),i||M.captureVersion(),M})}}else return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const{updated:h,added:m,removed:E}=this.removeUnrecognizedInputs(i);return a.push(...h),r.push(...m),c.push(...E),this.outputs.forEach(b=>{const{updated:A,added:_,removed:V}=b.afterAllChildrenInitialized(i);a.push(...A),r.push(..._),c.push(...V)}),this.outputs.sort((b,A)=>b.index-A.index),i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}setDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetDataType,this.id),this;const a=this.dataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.dataType=i,this.subscribeToDependencies(),r==null||r.add(this,H.Affected)),r==null||r.attemptAutoclose(w.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const r=this.parent.getDataType(i);return r?(i==null||i.attemptAutoclose("get-data-type",this.id),r):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};R(Ki,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(Ki,"type",d.BreakStatement),R(Ki,"USER_MANAGED_PARENT_TYPES",[d.Loop]),R(Ki,"PARENT_TYPES",[...Ki.USER_MANAGED_PARENT_TYPES]),R(Ki,"MUTABLE_BASE_PROPERTIES",[]),R(Ki,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(Ki,"BASE_PROPERTIES",[...Ki.MUTABLE_BASE_PROPERTIES,...Ki.INMUTABLE_BASE_PROPERTIES]),R(Ki,"MUTABLE_META_PROPERTIES",["x","y"]),R(Ki,"INMUTABLE_META_PROPERTIES",[...Ki.INMUTABLE_BASE_PROPERTIES]),R(Ki,"META_PROPERTIES",[...Ki.MUTABLE_META_PROPERTIES,...Ki.INMUTABLE_META_PROPERTIES]),R(Ki,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),R(Ki,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(Ki,"UPSTREAM_PROPERTIES",[...Ki.MUTABLE_UPSTREAM_PROPERTIES,...Ki.INMUTABLE_UPSTREAM_PROPERTIES]),R(Ki,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),R(Ki,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),R(Ki,"DOWNSTREAM_PROPERTIES",[...Ki.MUTABLE_DOWNSTREAM_PROPERTIES,...Ki.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(Ki,"PROPERTIES",[...Ki.META_PROPERTIES,...Ki.UPSTREAM_PROPERTIES,...Ki.DOWNSTREAM_PROPERTIES]);let Up=Ki;async function M4e(s,p={}){var c;const i=J.YieldTracker.from(p),r=[...wn(s),...is(s)];await i.tick();const a=Ft(s.errors,r);for(const e of s.outputs)await e.validateAsync({tracker:i});return await((c=s.throws)==null?void 0:c.validateAsync({tracker:i})),a}function G4e(s){var i;s.outputs.forEach(r=>r.validate()),(i=s.throws)==null||i.validate();const p=[...wn(s),...is(s)];return Ft(s.errors,p)}const yCi=Object.freeze(Object.defineProperty({__proto__:null,validate:G4e,validateAsync:M4e},Symbol.toStringTag,{value:"Module"}));var j4e=(s=>(s.Parent="continue-statement-parent-field",s.DataTypeEntity="continue-statement-data-type-entity-field",s.DataType="continue-statement-data-type-field",s.ParentDataType="continue-statement-parent-data-type-field",s.ParentDataTypeEntity="continue-statement-parent-data-type-entity-field",s))(j4e||{});const qi=class qi extends cn{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"x");R(this,"y");R(this,"type",d.ContinueStatement);R(this,"outputs",[]);R(this,"readsValue",null);R(this,"dataType",null);R(this,"defaultValue",null);R(this,"calledBySuccess",[]);R(this,"calledByError",[]);R(this,"calledByEntry",[]);R(this,"throws",null);R(this,"project");R(this,"errors",[]);R(this,"parent");R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"suggestion",!1);R(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=r,this.id=i.id,this.x=i.x,this.y=i.y}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ContinueStatement,outputs:[],defaultValue:null,dataType:null,readsValue:null,throws:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],x:0,y:0}}static fromGenerationTarget(i,r,a){const c=a===void 0?r.addChangeSet(new S(r,x.sessionAuthor,B().toISOString(),r,!0,w.CreateFromGenerationTarget)):a,e=re(i.parent),f=r.get(e),h=(i.calledByEntry||[]).map(V=>{const P=re(V);return r.get(P)}),m=(i.calledBySuccess||[]).map(V=>{const P=re(V);return r.get(P)}),E=(i.calledByError||[]).map(V=>{const P=re(V);return r.get(P)});let b=null;if(i.readsValue){const V=re(i.readsValue);b=r.get(V)}const A={id:i.id,version:x.UUID.uuid(),createdAt:(c==null?void 0:c.timestamp)||B().toISOString(),author:(c==null?void 0:c.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ContinueStatement,x:0,y:0,outputs:[],defaultValue:null,dataType:null,readsValue:b?b.toReference():null,calledByEntry:h.map(V=>V.toReference()),calledBySuccess:m.map(V=>V.toReference()),calledByError:E.map(V=>V.toReference()),throws:null,parent:f.toReference()},_=Re(A,r);return _.hydrateAncestors(),_.setParent(f,c),_.addSelfToProject(c),c==null||c.add(_,H.Added),_.initChildren(c),c||_.captureVersion(),_}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=Mn(a,{parent:{list:!1,types:[d.Loop]}},r);c.push(...f.explanations),a=f.modifiedData;const h=rn(a);return e.push(...f.errors,...h.errors),c.push(...h.explanations),{errors:e,explanations:c,modifiedData:a}}get codeNativeValueValidation(){return this._codeNativeValueValidation||null}validateGeneratedUpdate(i){const r=[],a=[];let c=JSON.parse(JSON.stringify(i));const e=dy(c,this);return c=e.modifiedData,r.push(...e.errors),i.parent&&r.push(new Ce({id:`${this.id}--${me.InvalidParentUpdate}`,code:me.InvalidParentUpdate,severity:ve.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
208
208
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
209
209
  You shouldn't have to manually update a 'parent' property.
210
- Specifically for continue statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];if(r==="continue-statement-parent-field"){const{updated:m,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-entity-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];if(r==="continue-statement-parent-field"){const{updated:m,added:E,removed:b}=this.restore({},a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-entity-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,V;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.unsubscribeDependents)==null||c.call(a,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||f.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(m=(h=this.parent)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),(V=(_=(A=this.parent)==null?void 0:A.dataType)==null?void 0:_.unsubscribeDependents)==null||V.call(_,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,V;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.subscribeDependents)==null||c.call(a,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||f.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(m=(h=this.parent)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),(V=(_=(A=this.parent)==null?void 0:A.dataType)==null?void 0:_.subscribeDependents)==null||V.call(_,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new qi(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new qi(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,V]of A.knownVersions)E.set(_,V);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new qi(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.outputs=[...h.outputs],this.readsValue=h.readsValue,this.defaultValue=h.defaultValue,this.dataType=h.dataType,this.throws=h.throws,this.calledBySuccess=[...h.calledBySuccess],this.calledByError=[...h.calledByError],this.calledByEntry=[...h.calledByEntry],this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),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 a=re(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const a=re(i.readsValue),c=this.project.get(a),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(r),c&&this.setValueWriter(c,r)}else this.removeValueWriter(r);if(i.calledByEntry.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addEntryCaller(e,r),e.addCall(this,r))}),[...this.calledByEntry].forEach(a=>{i.calledByEntry.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledBySuccess.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addSuccessCaller(e,r),e.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(a=>{i.calledBySuccess.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledByError.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addErrorCaller(e,r),e.addErrorCall(this,r))}),[...this.calledByError].forEach(a=>{i.calledByError.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.outputs.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addOutput(e,r),e.setParent(this,r))}),[...this.outputs].forEach(a=>{i.outputs.find(e=>re(e)===a.id)||(this.removeOutput(a,r),a.removeFromParent(r))}),i.dataType){const a=re(i.dataType),c=this.project.get(a);c&&this.setDataType(c,r)}else this.setDataType(null,r);if(i.defaultValue){const a=re(i.defaultValue),c=this.project.get(a);c&&this.setDefaultValue(c,r)}else this.setDefaultValue(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return J.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const f=re(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}if(i.readsValue){const f=re(i.readsValue),h=this.project.get(f);if(!h)throw new Error(`${this.type} with id '${this.id}' has a 'readsValue' reference '${f}' that isn't found in the project`);const m=this.readsValue;m&&m.id!==(h==null?void 0:h.id)&&this.removeValueWriter(r),h&&this.setValueWriter(h,r)}else i.readsValue===null&&this.removeValueWriter(r);return(a=i.calledByEntry)==null||a.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addEntryCaller(m,r),m.addCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByEntry' reference '${h}' that isn't found in the project`)}),i.calledByEntry&&[...this.calledByEntry].forEach(f=>{var m;((m=i.calledByEntry)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addSuccessCaller(m,r),m.addSuccessCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledBySuccess' reference '${h}' that isn't found in the project`)}),i.calledBySuccess&&[...this.calledBySuccess].forEach(f=>{var m;((m=i.calledBySuccess)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addErrorCaller(m,r),m.addErrorCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByError' reference '${h}' that isn't found in the project`)}),i.calledByError&&[...this.calledByError].forEach(f=>{var m;((m=i.calledByError)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=re(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.readsValue){const e=re(this.initialData.readsValue),f=this.project.get(e);f&&(this.setValueWriter(f,null),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=re(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=re(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=re(e),h=this.project.get(f);h&&this.addErrorCaller(h,null)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred,this.readsValue&&this.defaultValue&&(this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)||this.defaultValue.remove({ignoreUpstream:!1},i),this.setDefaultValue(null,i)),this.defaultValue&&!this.readsValue&&!this.project.diggestedBuiltInBaseEntitiesIds.has(this.id)&&this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)){const b=this.defaultValue.clone(i,this);this.setDefaultValue(b,i)}const{added:f,updated:h,removed:m,affected:E}=this.syncInputs(i);return a.push(...f),r.push(...h),c.push(...m),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,A)=>{var _,V;return(b.index??((_=b.declaration)==null?void 0:_.index))-(A.index??((V=A.declaration)==null?void 0:V.index))}),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){var f,h;const r=[this],a=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),r.push(this.readsValue)),this.calledByEntry.forEach(m=>{m.addCall(this,i),r.push(m)}),this.calledBySuccess.forEach(m=>{m.addSuccessCall(this,i),r.push(m)}),this.calledByError.forEach(m=>{m.addErrorCall(this,i),r.push(m)}),this.parent.addContinueStatement(this),r.push(this),i==null||i.add(this.parent,H.Affected),(f=this.parent)==null||f.breakStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),(h=this.parent)==null||h.continueStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}--${Me.CannotSuccessCallItself}`,action:w.AddSuccessCaller,owner:this,errorReason:Me.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddSuccessCaller})),this.calledBySuccess.find(e=>e.id===i.id)||(this.calledBySuccess.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Me.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Me.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddErrorCaller})),this.calledByError.find(e=>e.id===i.id)||(this.calledByError.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddEntryCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddEntryCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddEntryCaller}-${this.id}--${Me.CannotEntryCallItself}`,action:w.AddEntryCaller,owner:this,errorReason:Me.CannotEntryCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddEntryCaller})),this.calledByEntry.find(e=>e.id===i.id)||(this.calledByEntry.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}removeCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-caller")),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCaller,r)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),a&&gt(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}setThrows(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-throws"))){var a;if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==ud.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((a=this.throws)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.throws=i,r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose("set-throws",this.id),this}addOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,r)?this.outputs.includes(i)?(r==null||r.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),r==null||r.add(this,H.Affected),r==null||r.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("add-output",this.id),this)}removeOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("remove-output",this.id),this;const a=this.outputs.findIndex(c=>c.id===i.id);return a>-1&&(this.outputs.splice(a,1),r&&(r==null||r.add(this,H.Affected))),r==null||r.attemptAutoclose("remove-output",this.id),this}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,H.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setValueWriter(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueWriter))){var a,c,e;return this.checkCanEditFromScopeOwnerWithSideEffects(this,w.SetValueWriter,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.SetValueWriter}-${this.id}--${Me.CannotValueWriteItself}`,action:w.SetValueWriter,owner:this,errorReason:Me.CannotValueWriteItself,rootAction:((a=r==null?void 0:r.self)==null?void 0:a.id)===this.id&&(r==null?void 0:r.actionName)===w.SetValueWriter})),((c=this.readsValue)==null?void 0:c.id)!==(i==null?void 0:i.id)&&(this.readsValue=i,this.readsValue&&((e=this.defaultValue)==null||e.remove({ignoreUpstream:!1},r)),r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose(w.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditFromScopeOwnerWithSideEffects(this,w.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(w.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=Re(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=Re(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),uy.initReadsValue(this),this.outputs=this.initialData.outputs.map(r=>{const a=Re(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.throws&&(this.throws=Re(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=an(this,i,r),c=nn(this,a),e=this.toMeta();return this.x=a.x||e.x,this.y=a.y||e.y,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,H.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,H.Added):c&&(r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Se,...r){return await qi.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await qi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await qi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await qi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await qi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await qi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent.removeContinueStatement(this),this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h,m,E;if(!this.checkCanDelete(this,r))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Me.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Me.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.actionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(b=>{const{updated:A,removed:_,added:V}=b.entity.onDetachedDependencyRemoved(this,b.field,r);a.push(...A),c.push(..._),e.push(...V)}),this.readsValue&&(a.push(this.readsValue),this.readsValue.removeValueReader(this,r)),this.outputs.forEach(b=>{const{updated:A,removed:_}=b.remove({ignoreUpstream:!0},r);a.push(...A),c.push(..._)}),this.throws){const{updated:b,removed:A}=this.throws.remove({ignoreUpstream:!0},r);a.push(...b),c.push(...A)}if(this.dataType){const{updated:b,removed:A}=this.dataType.remove({ignoreUpstream:!0},r);a.push(...b),c.push(...A)}if(!i){const b=this.removeFromParent(r);e.push(...b.added),a.push(...b.updated),c.push(...b.removed),f.push(...b.affected),this.calledBy.forEach(A=>{a.push(A),A.removeCall(this,r)})}return r==null||r.add(this.parent,H.Affected),(m=this.parent)==null||m.breakStatements.forEach(b=>{b.id!==this.id&&(f.push(b),r==null||r.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(f.push(b),r==null||r.add(b,H.Affected))}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(w.RestoreEntity,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(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.readsValue&&(a.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.throws){const{updated:f}=this.throws.restore({},i);a.push(...f)}if(this.dataType){const{updated:f}=this.dataType.restore({},i);a.push(...f)}return this.parent.addContinueStatement(this),this.calledBySuccess.forEach(f=>{a.push(f),f.addSuccessCall(this,i)}),this.calledByError.forEach(f=>{a.push(f),f.addErrorCall(this,i)}),this.calledByEntry.forEach(f=>{a.push(f),f.addCall(this,i)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(a=>a.toFlat(i)),...this.calledBy.flatMap(a=>a.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(a=>a.toFlatIds(i)),...this.calledBy.flatMap(a=>a.toFlatIds(i)),...this.throws?this.throws.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,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var r,a,c,e,f;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,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((r=this.defaultValue)==null?void 0:r.toJSON(i))||null,dataType:((a=this.dataType)==null?void 0:a.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,calledBySuccess:this.calledBySuccess.map(h=>h.toReference()),calledByError:this.calledByError.map(h=>h.toReference()),calledByEntry:this.calledByEntry.map(h=>h.toReference()),outputs:this.outputs.map(h=>h.toJSON(i)),throws:((e=this.throws)==null?void 0:e.toJSON(i))||null,parent:((f=this.parent)==null?void 0:f.toReference())||null})}toJSONClone(i=at){var a,c,e,f,h,m,E,b,A,_;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||pn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((m=this.defaultValue)==null?void 0:m.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,calledBySuccess:this.calledBySuccess.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),outputs:this.outputs.map(V=>V.toJSONClone({...i,newId:null})),throws:((A=this.throws)==null?void 0:A.toJSONClone({...i,newId:null}))||null,parent:((_=this.parent)==null?void 0:_.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f,h;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((f=this.readsValue)==null?void 0:f.toReference(i))||null,outputs:this.outputs.map(m=>m.toReference(i)),calledBySuccess:this.calledBySuccess.map(m=>m.toReference(i)),calledByError:this.calledByError.map(m=>m.toReference(i)),calledByEntry:this.calledByEntry.map(m=>m.toReference(i)),throws:((h=this.throws)==null?void 0:h.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.defaultValue)==null?void 0:a.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(f=>f.toFlatJSON(i)),...this.calledBy.flatMap(f=>f.toFlatJSON(i)),...((e=this.throws)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,calledByEntry:this.calledByEntry.map(c=>c.id),calledByError:this.calledByError.map(c=>c.id),calledBySuccess:this.calledBySuccess.map(c=>c.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.defaultValue)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,r,a;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(r=this.defaultValue)==null||r.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(a=this.throws)==null||a.clearErrors(),this}validate(){return this.errors=G4e(this),{success:!0}}async validateAsync(i={}){const r=J.YieldTracker.from(i);return this.errors=await M4e(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...((r=this.defaultValue)==null?void 0:r.getErrors())||[],...((a=this.dataType)==null?void 0:a.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const r=J.YieldTracker.from(i),a=[...this.errors];if(await r.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:r});a.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:r});a.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:r});a.push(...c)}return a}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-default-value",this.id),this;const a=this.defaultValue;if((a==null?void 0:a.id)!==(i==null?void 0:i.id)){if(a==null||a.remove({ignoreUpstream:!0},r),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(r),c==null||c.removeValueReader(this,r)}r==null||r.add(this,H.Affected)}return r==null||r.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var P,M,j;const e=qr(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.outputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.deletable=!0,f.editable=!0;const b=lr(f,e);r?b.setParent(r,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const A=(P=this.dataType)==null?void 0:P.clone(i,b,x.UUID.uuid(),c);b.setDataType(A||null,i);const _=(M=this.defaultValue)==null?void 0:M.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(_||null,i);const V=(j=this.outputs)==null?void 0:j.map((G,K)=>G.clone(i,b,E+"-return-declaration-"+K+"-id",c));return b.outputs=V,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i||b.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}getMasterInputWithValueWriterFromAllInstances(i){return C([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>de(c,this.project)===de(i,this.project)&&!!c.readsValue)||i}removeUnrecognizedInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[],f=this.getDataType(null);return f&&!f.isObject()?[...this.outputs].forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}):f&&f.hasStrictObjectStructure()&&[...this.outputs].forEach(m=>{if(!m.declaration){const b=m.remove({ignoreUpstream:!1},i);c.push(...b.removed),r.push(...b.updated);return}if(![...(f==null?void 0:f.entity).allProperties].find(b=>m.declaration===b)){const b=m.remove({ignoreUpstream:!1},i);c.push(...b.removed),r.push(...b.updated)}}),this.outputs.filter((m,E)=>{const b=this.outputs.findIndex(_=>_.declaration===m.declaration&&_!==m);if(b===-1)return!1;const A=this.outputs[b];return B(A==null?void 0:A.createdAt).isSame(B(m.createdAt))?E>b:!!B(A==null?void 0:A.createdAt).isAfter(m.createdAt)}).forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-continue-statement-inputs"))){const r=[],a=[],c=[],e=[],f=this.getDataType(i);if(f)if(f.entity){if(f.isObject()){const b=[...f.entity.properties];this.outputs.filter(V=>!V.declaration||!b.find(P=>{var M;return P.id===((M=V.declaration)==null?void 0:M.id)})).forEach(V=>{const P=b.find(M=>de(M,this.project)===de(V,this.project));P&&V.setDeclaration(P,i)}),b.filter(V=>!this.outputs.find(P=>{var M;return((M=P.declaration)==null?void 0:M.id)===V.id})).forEach(V=>{const P={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:V,defaultValue:null,index:V.index,readsValue:null},M=Re(P,this.project);return M.hydrateAncestors(),M.addSelfToProject(i),i==null||i.add(M,H.Added),M.setParent(this,i),M.initChildren(i),this.addOutput(M,i),i||M.captureVersion(),M})}}else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const{updated:h,added:m,removed:E}=this.removeUnrecognizedInputs(i);return a.push(...h),r.push(...m),c.push(...E),this.outputs.forEach(b=>{const{updated:A,added:_,removed:V}=b.afterAllChildrenInitialized(i);a.push(...A),r.push(..._),c.push(...V)}),this.outputs.sort((b,A)=>b.index-A.index),i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}setDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetDataType,this.id),this;const a=this.dataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.dataType=i,this.subscribeToDependencies(),r==null||r.add(this,H.Affected)),r==null||r.attemptAutoclose(w.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const r=this.parent.getDataType(i);return r?(i==null||i.attemptAutoclose("get-data-type",this.id),r):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};R(qi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(qi,"type",d.ContinueStatement),R(qi,"USER_MANAGED_PARENT_TYPES",[d.Loop]),R(qi,"PARENT_TYPES",[...qi.USER_MANAGED_PARENT_TYPES]),R(qi,"MUTABLE_BASE_PROPERTIES",[]),R(qi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(qi,"BASE_PROPERTIES",[...qi.MUTABLE_BASE_PROPERTIES,...qi.INMUTABLE_BASE_PROPERTIES]),R(qi,"MUTABLE_META_PROPERTIES",["x","y"]),R(qi,"INMUTABLE_META_PROPERTIES",[...qi.INMUTABLE_BASE_PROPERTIES]),R(qi,"META_PROPERTIES",[...qi.MUTABLE_META_PROPERTIES,...qi.INMUTABLE_META_PROPERTIES]),R(qi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),R(qi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(qi,"UPSTREAM_PROPERTIES",[...qi.MUTABLE_UPSTREAM_PROPERTIES,...qi.INMUTABLE_UPSTREAM_PROPERTIES]),R(qi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),R(qi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),R(qi,"DOWNSTREAM_PROPERTIES",[...qi.MUTABLE_DOWNSTREAM_PROPERTIES,...qi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(qi,"PROPERTIES",[...qi.META_PROPERTIES,...qi.UPSTREAM_PROPERTIES,...qi.DOWNSTREAM_PROPERTIES]);let Fp=qi;function hCi(){return bt([st({type:nt(d.ValueDescriptor)}),Fr(We(),zr())])}function mCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ValueDescriptor)})}function k4e(){return st({id:We(),type:nt(d.ValueDescriptor),name:We(),required:vr()})}function TCi(){return k4e().merge(st({}))}function vCi(){return bt([st({type:nt(d.Property)}),Fr(We(),zr())])}function ECi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Property)})}function U4e(){return st({id:We(),type:nt(d.Property),name:We(),description:We().nullable(),private:vr(),static:vr(),required:vr(),abstract:vr()})}function bCi(){return U4e().merge(st({}))}function ACi(){return Mm([ge.CRON_JOB,ge.HTTP_ENDPOINT,ge.PERSISTED_ENTITY,ge.RELATIONAL_DATABASE])}function gCi(){return bt([st({type:nt(d.BuiltInBaseEntity)}),Fr(We(),zr())])}function ICi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.BuiltInBaseEntity)})}function F4e(){return st({id:We(),version:We(),type:nt(d.BuiltInBaseEntity),name:ACi(),description:We().nullable(),abstract:vr(),static:vr()})}function RCi(){return F4e().merge(st({}))}function p_(){return bt([st({type:nt(d.ActionDescriptor)}),Fr(We(),zr())])}function c_(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ActionDescriptor)})}function dV(){return st({id:We(),type:nt(d.ActionDescriptor),name:We(),description:We().nullable()})}function DCi(){return dV().merge(st({}))}function wCi(){return bt([st({type:nt(d.PrimitiveEntity)}),Fr(We(),zr())])}function CCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.PrimitiveEntity)})}function uV(){return st({id:We(),type:nt(d.PrimitiveEntity),name:We(),description:We().nullable(),static:vr(),abstract:vr()})}function OCi(){return uV().merge(st({}))}function _Ci(){return bt([st({type:nt(d.DataType)}),Fr(We(),zr())])}function VCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.DataType)})}function K4e(){return st({id:We(),type:nt(d.DataType),isList:vr().nullable(),asType:vr().nullable(),options:Vx(We()).optional(),like:vr().nullable(),implementationChooseOne:vr().nullable(),foreignKeyAllowed:vr().nullable(),staticEntities:vr().nullable(),interactiveEntities:vr().nullable(),actionEntities:vr().nullable(),parentRelationType:Mm([Ye.AndDataTypeGroup,Ye.OrDataTypeGroup]).nullable().optional()})}function PCi(){return K4e().merge(st({entity:We().nullable().optional(),foreignKeyRef:We().nullable().optional(),asType:vr().nullable().optional(),like:vr().nullable().optional(),isList:vr().nullable().optional(),implementationChooseOne:vr().nullable().optional(),foreignKeyAllowed:vr().nullable().optional(),staticEntities:vr().nullable().optional(),interactiveEntities:vr().nullable().optional(),actionEntities:vr().nullable().optional(),parentRelationType:Mm([Ye.AndDataTypeGroup,Ye.OrDataTypeGroup]).nullable().optional()}))}function Fm(){return bt([st({type:nt(d.ContinueStatement)}),Fr(We(),zr())])}function Km(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ContinueStatement)})}function q4e(){return st({id:We(),type:nt(d.ContinueStatement)})}function NCi(){return q4e().merge(st({}))}function UE(){return bt([st({type:nt(d.Loop)}),Fr(We(),zr())])}function FE(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Loop)})}function xCi(){return st({id:We(),type:nt(d.Loop)})}function $Ci(){return xCi().merge(st({declaration:bt([We(),HE()])}))}function qm(){return bt([st({type:nt(d.BreakStatement)}),Fr(We(),zr())])}function Sm(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.BreakStatement)})}function S4e(){return st({id:We(),type:nt(d.BreakStatement)})}function LCi(){return S4e().merge(st({}))}function q$(){return bt([st({type:nt(d.OutputMap)}),Fr(We(),zr())])}function S$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.OutputMap)})}function Z4e(){return st({id:We(),type:nt(d.OutputMap)})}function BCi(){return Z4e().merge(st({}))}function KE(){return bt([st({type:nt(d.Operation)}),Fr(We(),zr())])}function qE(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Operation)})}function H4e(){return st({id:We(),type:nt(d.Operation)})}function MCi(){return H4e().merge(st({}))}function S1(){return bt([We(),Pa(),vr(),bs(),ou()])}function W4e(){return Fr(We(),S1())}function GCi(){return Vx(bt([S1(),W4e()]))}function jCi(){return bt([S1(),W4e(),GCi()])}function z4e(){return bt([S1(),jCi()])}function kCi(){return Mm(Object.values(fe))}function UCi(){return st({id:We(),name:kCi(),type:nt(d.LiteralValue),value:z4e().nullable()})}function FCi(){return UCi().merge(st({value:z4e().nullable().optional(),valueAsTypeList:Vx(We()).nullable().optional(),valueAsTypeSingle:We().nullable().optional()}))}function SE(){return bt([st({type:nt(d.FunctionCall)}),Fr(We(),zr())])}function ZE(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.FunctionCall)})}function Y4e(){return st({id:We(),type:nt(d.FunctionCall)})}function KCi(){return Y4e().merge(st({}))}function Z1(){return bt([st({type:nt(d.Condition)}),Fr(We(),zr())])}function H1(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Condition)})}function J4e(){return st({id:We(),type:nt(d.Condition)})}function qCi(){return J4e().merge(st({}))}function W1(){return bt([st({type:nt(d.Search)}),Fr(We(),zr())])}function z1(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Search)})}function Q4e(){return st({id:We(),type:nt(d.Search),name:We(),query:zr(),description:We().nullable()})}function SCi(){return Q4e().merge(st({}))}function Z$(){return bt([st({type:nt(d.InternalCall)}),Fr(We(),zr())])}function H$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.InternalCall)})}function X4e(){return st({id:We(),type:nt(d.InternalCall),index:Pa()})}function ZCi(){return X4e().merge(st({declaration:bt([We(),HE()])}))}function eje(){return bt([st({type:nt(d.InputMap)}),Fr(We(),zr())])}function tje(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.InputMap)})}function ije(){return st({id:We(),type:nt(d.InputMap),name:We().nullable().optional(),description:We().nullable().optional()})}function HCi(){return ije().merge(st({}))}function WCi(){return bt([st({type:nt(d.VariableDeclaration)}),Fr(We(),zr())])}function zCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.VariableDeclaration)})}function rje(){return st({id:We(),type:nt(d.VariableDeclaration),name:We(),description:We().nullable()})}function YCi(){return rje().merge(st({}))}function JCi(){return bt([st({type:nt(d.VariableInstance)}),Fr(We(),zr())])}function QCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.VariableInstance)})}function nje(){return st({id:We(),type:nt(d.VariableInstance)})}function XCi(){return nje().merge(st({}))}function Zm(){return bt([st({type:nt(d.ReturnStatement)}),Fr(We(),zr())])}function Hm(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ReturnStatement)})}function aje(){return st({id:We(),type:nt(d.ReturnStatement)})}function eOi(){return aje().merge(st({}))}function sje(){return bt([st({type:nt(d.InstalledProject)}),Fr(We(),zr())])}function lje(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.InstalledProject)})}function tOi(){return st({id:We(),type:nt(d.InstalledProject)})}function iOi(){return st({})}function rOi(){return bt([st({type:nt(d.GlobalEvent)}),Fr(We(),zr())])}function nOi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.GlobalEvent)})}function oje(){return st({id:We(),type:nt(d.GlobalEvent),name:We(),collapsed:vr()})}function aOi(){return oje().merge(st({}))}function ay(){return bt([WCi(),JCi()])}function sy(){return bt([zCi(),QCi()])}function dje(){return bt([ay(),eje(),Zm(),qm(),Fm()])}function uje(){return bt([sy(),tje(),Hm(),Sm(),Km()])}function sOi(){return bt([ay(),W$(),q$(),KE(),Z$(),SE()])}function lOi(){return bt([sy(),z$(),S$(),qE(),H$(),ZE()])}function oOi(){return bt([W$(),q$(),dje()])}function dOi(){return bt([z$(),S$(),uje()])}function Y1(){return rOi()}function J1(){return nOi()}function Q1(){return bt([KE(),SE(),Z1(),W1(),ay(),Z$(),UE()])}function X1(){return bt([qE(),ZE(),H1(),z1(),sy(),H$(),FE()])}function eD(){return bt([KE(),SE(),Z1(),W1(),ay(),UE()])}function tD(){return bt([qE(),ZE(),H1(),z1(),sy(),FE()])}function pje(){return bt([Q1(),Zm(),qm(),Fm()])}function cje(){return bt([X1(),Hm(),Sm(),Km()])}function fje(){return bt([eD(),Zm(),qm(),Fm()])}function yje(){return bt([tD(),Hm(),Sm(),Km()])}function Fc(){return bt([HE(),Y1()])}function Kc(){return bt([Y$(),J1()])}function uOi(){return bt([Q1(),Fc()])}function pOi(){return bt([X1(),Kc()])}function cOi(){return bt([eD(),Fc()])}function fOi(){return bt([tD(),Kc()])}function yOi(){return bt([pje(),Fc()])}function hOi(){return bt([cje(),Kc()])}function mOi(){return bt([fje(),Fc()])}function TOi(){return bt([yje(),Kc()])}function vOi(){return bt([Fc(),UE()])}function EOi(){return bt([Kc(),FE()])}function bOi(){return bt([Q1(),Fc()])}function AOi(){return bt([X1(),Kc()])}function gOi(){return bt([eD(),Fc()])}function IOi(){return bt([tD(),Kc()])}function ROi(){return bt([Zm(),qm(),Fm()])}function DOi(){return bt([Hm(),Sm(),Km()])}function wOi(){return bt([gCi(),NOi(),sje(),vje(),HE(),Y1(),ay(),eje(),q$(),Z1(),KE(),SE(),W$(),wCi(),_Ci(),vCi(),p_(),Zm(),Fm(),qm(),UE(),W1(),p_(),p_(),hCi(),Z$()])}function COi(){return bt([ICi(),xOi(),lje(),Eje(),Y$(),J1(),sy(),tje(),S$(),H1(),qE(),ZE(),z$(),CCi(),VCi(),ECi(),c_(),Hm(),Km(),Sm(),FE(),z1(),c_(),c_(),mCi(),H$()])}function OOi(){return bt([sje(),vje(),HE(),Y1(),ay(),Z1(),KE(),SE(),Zm(),Fm(),qm(),UE(),W1()])}function _Oi(){return bt([lje(),Eje(),Y$(),J1(),sy(),H1(),qE(),ZE(),Hm(),Km(),Sm(),FE(),z1()])}function W$(){return bt([st({type:nt(d.ArgumentDeclaration)}),Fr(We(),zr())])}function z$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ArgumentDeclaration)})}function hje(){return st({id:We(),type:nt(d.ArgumentDeclaration)})}function VOi(){return hje().merge(st({}))}function HE(){return bt([st({type:nt(d.FunctionDeclaration)}),Fr(We(),zr())])}function Y$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.FunctionDeclaration)})}function mje(){return st({id:We(),type:nt(d.FunctionDeclaration),name:We(),description:We().nullable()})}function POi(){return mje()}function NOi(){return bt([st({type:nt(d.Project)}),Fr(We(),zr())])}function xOi(){return st({entityType:nt(d.Project),entityId:We(),id:We(),type:nt(d.GenericReference)})}function Tje(){return st({id:We(),type:nt(d.Project),name:We(),description:We().nullable()})}function $Oi(){return Tje()}function vje(){return bt([st({type:nt(d.DefinitionEntity)}),Fr(We(),zr())])}function Eje(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.DefinitionEntity)})}function bje(){return st({id:We(),type:nt(d.DefinitionEntity),name:We(),description:We().nullable(),static:vr(),abstract:vr()})}function LOi(){return bje().merge(st({}))}var Aje="1.13.8",oF=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||Function("return this")()||{},iD=Array.prototype,J$=Object.prototype,dF=typeof Symbol<"u"?Symbol.prototype:null,BOi=iD.push,WE=iD.slice,yv=J$.toString,MOi=J$.hasOwnProperty,gje=typeof ArrayBuffer<"u",GOi=typeof DataView<"u",jOi=Array.isArray,uF=Object.keys,pF=Object.create,cF=gje&&ArrayBuffer.isView,kOi=isNaN,UOi=isFinite,Ije=!{toString:null}.propertyIsEnumerable("toString"),fF=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],FOi=Math.pow(2,53)-1;function gs(s,p){return p=p==null?s.length-1:+p,function(){for(var i=Math.max(arguments.length-p,0),r=Array(i),a=0;a<i;a++)r[a]=arguments[a+p];switch(p){case 0:return s.call(this,r);case 1:return s.call(this,arguments[0],r);case 2:return s.call(this,arguments[0],arguments[1],r)}var c=Array(p+1);for(a=0;a<p;a++)c[a]=arguments[a];return c[p]=r,s.apply(this,c)}}function ly(s){var p=typeof s;return p==="function"||p==="object"&&!!s}function KOi(s){return s===null}function Rje(s){return s===void 0}function Dje(s){return s===!0||s===!1||yv.call(s)==="[object Boolean]"}function qOi(s){return!!(s&&s.nodeType===1)}function La(s){var p="[object "+s+"]";return function(i){return yv.call(i)===p}}const Q$=La("String"),wje=La("Number"),SOi=La("Date"),ZOi=La("RegExp"),HOi=La("Error"),Cje=La("Symbol"),Oje=La("ArrayBuffer");var _je=La("Function"),WOi=oF.document&&oF.document.childNodes;typeof/./!="function"&&typeof Int8Array!="object"&&typeof WOi!="function"&&(_je=function(s){return typeof s=="function"||!1});const Ya=_je,Vje=La("Object");var Pje=GOi&&(!/\[native code\]/.test(String(DataView))||Vje(new DataView(new ArrayBuffer(8)))),X$=typeof Map<"u"&&Vje(new Map),zOi=La("DataView");function YOi(s){return s!=null&&Ya(s.getInt8)&&Oje(s.buffer)}const Wg=Pje?YOi:zOi,oy=jOi||La("Array");function qc(s,p){return s!=null&&MOi.call(s,p)}var pV=La("Arguments");(function(){pV(arguments)||(pV=function(s){return qc(s,"callee")})})();const eL=pV;function JOi(s){return!Cje(s)&&UOi(s)&&!isNaN(parseFloat(s))}function Nje(s){return wje(s)&&kOi(s)}function xje(s){return function(){return s}}function $je(s){return function(p){var i=s(p);return typeof i=="number"&&i>=0&&i<=FOi}}function Lje(s){return function(p){return p==null?void 0:p[s]}}const zg=Lje("byteLength"),QOi=$je(zg);var XOi=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;function e_i(s){return cF?cF(s)&&!Wg(s):QOi(s)&&XOi.test(yv.call(s))}const Bje=gje?e_i:xje(!1),Oa=Lje("length");function t_i(s){for(var p={},i=s.length,r=0;r<i;++r)p[s[r]]=!0;return{contains:function(a){return p[a]===!0},push:function(a){return p[a]=!0,s.push(a)}}}function Mje(s,p){p=t_i(p);var i=fF.length,r=s.constructor,a=Ya(r)&&r.prototype||J$,c="constructor";for(qc(s,c)&&!p.contains(c)&&p.push(c);i--;)c=fF[i],c in s&&s[c]!==a[c]&&!p.contains(c)&&p.push(c)}function ia(s){if(!ly(s))return[];if(uF)return uF(s);var p=[];for(var i in s)qc(s,i)&&p.push(i);return Ije&&Mje(s,p),p}function QT(s){if(s==null)return!0;var p=Oa(s);return typeof p=="number"&&(oy(s)||Q$(s)||eL(s))?p===0:Oa(ia(s))===0}function Gje(s,p){var i=ia(p),r=i.length;if(s==null)return!r;for(var a=Object(s),c=0;c<r;c++){var e=i[c];if(p[e]!==a[e]||!(e in a))return!1}return!0}function Rr(s){if(s instanceof Rr)return s;if(!(this instanceof Rr))return new Rr(s);this._wrapped=s}Rr.VERSION=Aje;Rr.prototype.value=function(){return this._wrapped};Rr.prototype.valueOf=Rr.prototype.toJSON=Rr.prototype.value;Rr.prototype.toString=function(){return String(this._wrapped)};function yF(s){return new Uint8Array(s.buffer||s,s.byteOffset||0,zg(s))}var hF="[object DataView]";function i_i(s,p){for(var i=[{a:s,b:p}],r=[],a=[];i.length;){var c=i.pop();if(c===!0){r.pop(),a.pop();continue}if(s=c.a,p=c.b,s===p){if(s!==0||1/s===1/p)continue;return!1}if(s==null||p==null)return!1;if(s!==s){if(p!==p)continue;return!1}var e=typeof s;if(e!=="function"&&e!=="object"&&typeof p!="object")return!1;s instanceof Rr&&(s=s._wrapped),p instanceof Rr&&(p=p._wrapped);var f=yv.call(s);if(f!==yv.call(p))return!1;if(Pje&&f=="[object Object]"&&Wg(s)){if(!Wg(p))return!1;f=hF}switch(f){case"[object RegExp]":case"[object String]":if(""+s==""+p)continue;return!1;case"[object Number]":i.push({a:+s,b:+p});continue;case"[object Date]":case"[object Boolean]":if(+s==+p)continue;return!1;case"[object Symbol]":if(dF.valueOf.call(s)===dF.valueOf.call(p))continue;return!1;case"[object ArrayBuffer]":case hF:i.push({a:yF(s),b:yF(p)});continue}var h=f==="[object Array]";if(!h&&Bje(s)){var m=zg(s);if(m!==zg(p))return!1;if(s.buffer===p.buffer&&s.byteOffset===p.byteOffset)continue;h=!0}if(!h){if(typeof s!="object"||typeof p!="object")return!1;var E=s.constructor,b=p.constructor;if(E!==b&&!(Ya(E)&&E instanceof E&&Ya(b)&&b instanceof b)&&"constructor"in s&&"constructor"in p)return!1}for(var A=r.length;A--;)if(r[A]===s){if(a[A]===p)break;return!1}if(!(A>=0))if(r.push(s),a.push(p),i.push(!0),h){if(A=s.length,A!==p.length)return!1;for(;A--;)i.push({a:s[A],b:p[A]})}else{var _=ia(s),V;if(A=_.length,ia(p).length!==A)return!1;for(;A--;){if(V=_[A],!qc(p,V))return!1;i.push({a:s[V],b:p[V]})}}}return!0}function zE(s){if(!ly(s))return[];var p=[];for(var i in s)p.push(i);return Ije&&Mje(s,p),p}function tL(s){var p=Oa(s);return function(i){if(i==null)return!1;var r=zE(i);if(Oa(r))return!1;for(var a=0;a<p;a++)if(!Ya(i[s[a]]))return!1;return s!==Uje||!Ya(i[iL])}}var iL="forEach",jje="has",rL=["clear","delete"],kje=["get",jje,"set"],r_i=rL.concat(iL,kje),Uje=rL.concat(kje),n_i=["add"].concat(rL,iL,jje);const a_i=X$?tL(r_i):La("Map"),s_i=X$?tL(Uje):La("WeakMap"),l_i=X$?tL(n_i):La("Set"),o_i=La("WeakSet");function Wm(s){for(var p=ia(s),i=p.length,r=Array(i),a=0;a<i;a++)r[a]=s[p[a]];return r}function d_i(s){for(var p=ia(s),i=p.length,r=Array(i),a=0;a<i;a++)r[a]=[p[a],s[p[a]]];return r}function Fje(s){for(var p={},i=ia(s),r=0,a=i.length;r<a;r++)p[s[i[r]]]=i[r];return p}function cV(s){var p=[];for(var i in s)Ya(s[i])&&p.push(i);return p.sort()}function nL(s,p){return function(i){var r=arguments.length;if(p&&(i=Object(i)),r<2||i==null)return i;for(var a=1;a<r;a++)for(var c=arguments[a],e=s(c),f=e.length,h=0;h<f;h++){var m=e[h];(!p||i[m]===void 0)&&(i[m]=c[m])}return i}}const Kje=nL(zE),Yg=nL(ia),qje=nL(zE,!0);function u_i(){return function(){}}function Sje(s){if(!ly(s))return{};if(pF)return pF(s);var p=u_i();p.prototype=s;var i=new p;return p.prototype=null,i}function p_i(s,p){var i=Sje(s);return p&&Yg(i,p),i}function c_i(s){return ly(s)?oy(s)?s.slice():Kje({},s):s}function f_i(s,p){return p(s),s}function Zje(s){return oy(s)?s:[s]}Rr.toPath=Zje;function YE(s){return Rr.toPath(s)}function aL(s,p){for(var i=p.length,r=0;r<i;r++){if(s==null)return;s=s[p[r]]}return i?s:void 0}function Hje(s,p,i){var r=aL(s,YE(p));return Rje(r)?i:r}function y_i(s,p){p=YE(p);for(var i=p.length,r=0;r<i;r++){var a=p[r];if(!qc(s,a))return!1;s=s[a]}return!!i}function sL(s){return s}function hv(s){return s=Yg({},s),function(p){return Gje(p,s)}}function lL(s){return s=YE(s),function(p){return aL(p,s)}}function JE(s,p,i){if(p===void 0)return s;switch(i??3){case 1:return function(r){return s.call(p,r)};case 3:return function(r,a,c){return s.call(p,r,a,c)};case 4:return function(r,a,c,e){return s.call(p,r,a,c,e)}}return function(){return s.apply(p,arguments)}}function Wje(s,p,i){return s==null?sL:Ya(s)?JE(s,p,i):ly(s)&&!oy(s)?hv(s):lL(s)}function oL(s,p){return Wje(s,p,1/0)}Rr.iteratee=oL;function Ps(s,p,i){return Rr.iteratee!==oL?Rr.iteratee(s,p):Wje(s,p,i)}function h_i(s,p,i){p=Ps(p,i);for(var r=ia(s),a=r.length,c={},e=0;e<a;e++){var f=r[e];c[f]=p(s[f],f,s)}return c}function zje(){}function m_i(s){return s==null?zje:function(p){return Hje(s,p)}}function T_i(s,p,i){var r=Array(Math.max(0,s));p=JE(p,i,1);for(var a=0;a<s;a++)r[a]=p(a);return r}function fV(s,p){return p==null&&(p=s,s=0),s+Math.floor(Math.random()*(p-s+1))}const mv=Date.now||function(){return new Date().getTime()};function Yje(s){var p=function(c){return s[c]},i="(?:"+ia(s).join("|")+")",r=RegExp(i),a=RegExp(i,"g");return function(c){return c=c==null?"":""+c,r.test(c)?c.replace(a,p):c}}const Jje={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},v_i=Yje(Jje),E_i=Fje(Jje),b_i=Yje(E_i),A_i=Rr.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var f_=/(.)^/,g_i={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},I_i=/\\|'|\r|\n|\u2028|\u2029/g;function R_i(s){return"\\"+g_i[s]}var D_i=/^\s*(\w|\$)+\s*$/;function w_i(s,p,i){!p&&i&&(p=i),p=qje({},p,Rr.templateSettings);var r=RegExp([(p.escape||f_).source,(p.interpolate||f_).source,(p.evaluate||f_).source].join("|")+"|$","g"),a=0,c="__p+='";s.replace(r,function(m,E,b,A,_){return c+=s.slice(a,_).replace(I_i,R_i),a=_+m.length,E?c+=`'+
210
+ Specifically for continue statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];if(r==="continue-statement-parent-field"){const{updated:m,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-entity-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];if(r==="continue-statement-parent-field"){const{updated:m,added:E,removed:b}=this.restore({},a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}if(r==="continue-statement-parent-data-type-entity-field"){const{updated:m,added:E,removed:b}=this.afterAllChildrenInitialized(a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,V;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.unsubscribeDependents)==null||c.call(a,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||f.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(m=(h=this.parent)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),(V=(_=(A=this.parent)==null?void 0:A.dataType)==null?void 0:_.unsubscribeDependents)==null||V.call(_,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,V;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.subscribeDependents)==null||c.call(a,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||f.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(m=(h=this.parent)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),(V=(_=(A=this.parent)==null?void 0:A.dataType)==null?void 0:_.subscribeDependents)==null||V.call(_,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new qi(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new qi(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,V]of A.knownVersions)E.set(_,V);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new qi(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.outputs=[...h.outputs],this.readsValue=h.readsValue,this.defaultValue=h.defaultValue,this.dataType=h.dataType,this.throws=h.throws,this.calledBySuccess=[...h.calledBySuccess],this.calledByError=[...h.calledByError],this.calledByEntry=[...h.calledByEntry],this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),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 a=re(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const a=re(i.readsValue),c=this.project.get(a),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(r),c&&this.setValueWriter(c,r)}else this.removeValueWriter(r);if(i.calledByEntry.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addEntryCaller(e,r),e.addCall(this,r))}),[...this.calledByEntry].forEach(a=>{i.calledByEntry.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledBySuccess.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addSuccessCaller(e,r),e.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(a=>{i.calledBySuccess.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledByError.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addErrorCaller(e,r),e.addErrorCall(this,r))}),[...this.calledByError].forEach(a=>{i.calledByError.find(e=>re(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.outputs.forEach(a=>{const c=re(a),e=this.project.get(c);e&&(this.addOutput(e,r),e.setParent(this,r))}),[...this.outputs].forEach(a=>{i.outputs.find(e=>re(e)===a.id)||(this.removeOutput(a,r),a.removeFromParent(r))}),i.dataType){const a=re(i.dataType),c=this.project.get(a);c&&this.setDataType(c,r)}else this.setDataType(null,r);if(i.defaultValue){const a=re(i.defaultValue),c=this.project.get(a);c&&this.setDefaultValue(c,r)}else this.setDefaultValue(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return J.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const f=re(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}if(i.readsValue){const f=re(i.readsValue),h=this.project.get(f);if(!h)throw new Error(`${this.type} with id '${this.id}' has a 'readsValue' reference '${f}' that isn't found in the project`);const m=this.readsValue;m&&m.id!==(h==null?void 0:h.id)&&this.removeValueWriter(r),h&&this.setValueWriter(h,r)}else i.readsValue===null&&this.removeValueWriter(r);return(a=i.calledByEntry)==null||a.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addEntryCaller(m,r),m.addCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByEntry' reference '${h}' that isn't found in the project`)}),i.calledByEntry&&[...this.calledByEntry].forEach(f=>{var m;((m=i.calledByEntry)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addSuccessCaller(m,r),m.addSuccessCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledBySuccess' reference '${h}' that isn't found in the project`)}),i.calledBySuccess&&[...this.calledBySuccess].forEach(f=>{var m;((m=i.calledBySuccess)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=re(f),m=this.project.get(h);if(m)this.addErrorCaller(m,r),m.addErrorCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByError' reference '${h}' that isn't found in the project`)}),i.calledByError&&[...this.calledByError].forEach(f=>{var m;((m=i.calledByError)==null?void 0:m.find(E=>re(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=re(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.readsValue){const e=re(this.initialData.readsValue),f=this.project.get(e);f&&(this.setValueWriter(f,null),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=re(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=re(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=re(e),h=this.project.get(f);h&&this.addErrorCaller(h,null)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred,this.readsValue&&this.defaultValue&&(this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)||this.defaultValue.remove({ignoreUpstream:!1},i),this.setDefaultValue(null,i)),this.defaultValue&&!this.readsValue&&!this.project.diggestedBuiltInBaseEntitiesIds.has(this.id)&&this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)){const b=this.defaultValue.clone(i,this);this.setDefaultValue(b,i)}const{added:f,updated:h,removed:m,affected:E}=this.syncInputs(i);return a.push(...f),r.push(...h),c.push(...m),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,A)=>{var _,V;return(b.index??((_=b.declaration)==null?void 0:_.index))-(A.index??((V=A.declaration)==null?void 0:V.index))}),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){var f,h;const r=[this],a=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),r.push(this.readsValue)),this.calledByEntry.forEach(m=>{m.addCall(this,i),r.push(m)}),this.calledBySuccess.forEach(m=>{m.addSuccessCall(this,i),r.push(m)}),this.calledByError.forEach(m=>{m.addErrorCall(this,i),r.push(m)}),this.parent.addContinueStatement(this),r.push(this),i==null||i.add(this.parent,H.Affected),(f=this.parent)==null||f.breakStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),(h=this.parent)==null||h.continueStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}--${Me.CannotSuccessCallItself}`,action:w.AddSuccessCaller,owner:this,errorReason:Me.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddSuccessCaller})),this.calledBySuccess.find(e=>e.id===i.id)||(this.calledBySuccess.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Me.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Me.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddErrorCaller})),this.calledByError.find(e=>e.id===i.id)||(this.calledByError.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddEntryCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddEntryCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddEntryCaller}-${this.id}--${Me.CannotEntryCallItself}`,action:w.AddEntryCaller,owner:this,errorReason:Me.CannotEntryCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.actionName)===w.AddEntryCaller})),this.calledByEntry.find(e=>e.id===i.id)||(this.calledByEntry.push(i),r==null||r.add(this,H.Updated),a&&gt(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}removeCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-caller")),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCaller,r)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,H.Updated),r==null||r.add(c,H.Affected),!1)),a&&gt(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}setThrows(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-throws"))){var a;if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==ud.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((a=this.throws)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.throws=i,r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose("set-throws",this.id),this}addOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,r)?this.outputs.includes(i)?(r==null||r.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),r==null||r.add(this,H.Affected),r==null||r.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("add-output",this.id),this)}removeOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("remove-output",this.id),this;const a=this.outputs.findIndex(c=>c.id===i.id);return a>-1&&(this.outputs.splice(a,1),r&&(r==null||r.add(this,H.Affected))),r==null||r.attemptAutoclose("remove-output",this.id),this}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,H.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setValueWriter(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueWriter))){var a,c,e;return this.checkCanEditFromScopeOwnerWithSideEffects(this,w.SetValueWriter,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.SetValueWriter}-${this.id}--${Me.CannotValueWriteItself}`,action:w.SetValueWriter,owner:this,errorReason:Me.CannotValueWriteItself,rootAction:((a=r==null?void 0:r.self)==null?void 0:a.id)===this.id&&(r==null?void 0:r.actionName)===w.SetValueWriter})),((c=this.readsValue)==null?void 0:c.id)!==(i==null?void 0:i.id)&&(this.readsValue=i,this.readsValue&&((e=this.defaultValue)==null||e.remove({ignoreUpstream:!1},r)),r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose(w.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditFromScopeOwnerWithSideEffects(this,w.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(w.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=Re(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=Re(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),uy.initReadsValue(this),this.outputs=this.initialData.outputs.map(r=>{const a=Re(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.throws&&(this.throws=Re(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=an(this,i,r),c=nn(this,a),e=this.toMeta();return this.x=a.x||e.x,this.y=a.y||e.y,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,H.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,H.Added):c&&(r==null||r.add(this,H.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Se,...r){return await qi.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await qi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await qi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await qi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await qi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await qi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent.removeContinueStatement(this),this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h,m,E;if(!this.checkCanDelete(this,r))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Me.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Me.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.actionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(b=>{const{updated:A,removed:_,added:V}=b.entity.onDetachedDependencyRemoved(this,b.field,r);a.push(...A),c.push(..._),e.push(...V)}),this.readsValue&&(a.push(this.readsValue),this.readsValue.removeValueReader(this,r)),this.outputs.forEach(b=>{const{updated:A,removed:_}=b.remove({ignoreUpstream:!0},r);a.push(...A),c.push(..._)}),this.throws){const{updated:b,removed:A}=this.throws.remove({ignoreUpstream:!0},r);a.push(...b),c.push(...A)}if(this.dataType){const{updated:b,removed:A}=this.dataType.remove({ignoreUpstream:!0},r);a.push(...b),c.push(...A)}if(!i){const b=this.removeFromParent(r);e.push(...b.added),a.push(...b.updated),c.push(...b.removed),f.push(...b.affected),this.calledBy.forEach(A=>{a.push(A),A.removeCall(this,r)})}return r==null||r.add(this.parent,H.Affected),(m=this.parent)==null||m.breakStatements.forEach(b=>{b.id!==this.id&&(f.push(b),r==null||r.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(f.push(b),r==null||r.add(b,H.Affected))}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(w.RestoreEntity,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(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.readsValue&&(a.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.throws){const{updated:f}=this.throws.restore({},i);a.push(...f)}if(this.dataType){const{updated:f}=this.dataType.restore({},i);a.push(...f)}return this.parent.addContinueStatement(this),this.calledBySuccess.forEach(f=>{a.push(f),f.addSuccessCall(this,i)}),this.calledByError.forEach(f=>{a.push(f),f.addErrorCall(this,i)}),this.calledByEntry.forEach(f=>{a.push(f),f.addCall(this,i)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(a=>a.toFlat(i)),...this.calledBy.flatMap(a=>a.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(a=>a.toFlatIds(i)),...this.calledBy.flatMap(a=>a.toFlatIds(i)),...this.throws?this.throws.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,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var r,a,c,e,f;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,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((r=this.defaultValue)==null?void 0:r.toJSON(i))||null,dataType:((a=this.dataType)==null?void 0:a.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,calledBySuccess:this.calledBySuccess.map(h=>h.toReference()),calledByError:this.calledByError.map(h=>h.toReference()),calledByEntry:this.calledByEntry.map(h=>h.toReference()),outputs:this.outputs.map(h=>h.toJSON(i)),throws:((e=this.throws)==null?void 0:e.toJSON(i))||null,parent:((f=this.parent)==null?void 0:f.toReference())||null})}toJSONClone(i=at){var a,c,e,f,h,m,E,b,A,_;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||pn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((m=this.defaultValue)==null?void 0:m.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,calledBySuccess:this.calledBySuccess.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),outputs:this.outputs.map(V=>V.toJSONClone({...i,newId:null})),throws:((A=this.throws)==null?void 0:A.toJSONClone({...i,newId:null}))||null,parent:((_=this.parent)==null?void 0:_.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f,h;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((f=this.readsValue)==null?void 0:f.toReference(i))||null,outputs:this.outputs.map(m=>m.toReference(i)),calledBySuccess:this.calledBySuccess.map(m=>m.toReference(i)),calledByError:this.calledByError.map(m=>m.toReference(i)),calledByEntry:this.calledByEntry.map(m=>m.toReference(i)),throws:((h=this.throws)==null?void 0:h.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.defaultValue)==null?void 0:a.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(f=>f.toFlatJSON(i)),...this.calledBy.flatMap(f=>f.toFlatJSON(i)),...((e=this.throws)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,calledByEntry:this.calledByEntry.map(c=>c.id),calledByError:this.calledByError.map(c=>c.id),calledBySuccess:this.calledBySuccess.map(c=>c.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.defaultValue)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,r,a;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(r=this.defaultValue)==null||r.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(a=this.throws)==null||a.clearErrors(),this}validate(){return this.errors=G4e(this),{success:!0}}async validateAsync(i={}){const r=J.YieldTracker.from(i);return this.errors=await M4e(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...((r=this.defaultValue)==null?void 0:r.getErrors())||[],...((a=this.dataType)==null?void 0:a.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const r=J.YieldTracker.from(i),a=[...this.errors];if(await r.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:r});a.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:r});a.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:r});a.push(...c)}return a}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-default-value",this.id),this;const a=this.defaultValue;if((a==null?void 0:a.id)!==(i==null?void 0:i.id)){if(a==null||a.remove({ignoreUpstream:!0},r),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(r),c==null||c.removeValueReader(this,r)}r==null||r.add(this,H.Affected)}return r==null||r.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var P,M,j;const e=qr(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.outputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.deletable=!0,f.editable=!0;const b=lr(f,e);r?b.setParent(r,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const A=(P=this.dataType)==null?void 0:P.clone(i,b,x.UUID.uuid(),c);b.setDataType(A||null,i);const _=(M=this.defaultValue)==null?void 0:M.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(_||null,i);const V=(j=this.outputs)==null?void 0:j.map((G,K)=>G.clone(i,b,E+"-return-declaration-"+K+"-id",c));return b.outputs=V,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i||b.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}getMasterInputWithValueWriterFromAllInstances(i){return C([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>de(c,this.project)===de(i,this.project)&&!!c.readsValue)||i}removeUnrecognizedInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[],f=this.getDataType(null);return f&&!f.isObject()?[...this.outputs].forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}):f&&f.hasStrictObjectStructure()&&[...this.outputs].forEach(m=>{if(!m.declaration){const b=m.remove({ignoreUpstream:!1},i);c.push(...b.removed),r.push(...b.updated);return}if(![...(f==null?void 0:f.entity).allProperties].find(b=>m.declaration===b)){const b=m.remove({ignoreUpstream:!1},i);c.push(...b.removed),r.push(...b.updated)}}),this.outputs.filter((m,E)=>{const b=this.outputs.findIndex(_=>_.declaration===m.declaration&&_!==m);if(b===-1)return!1;const A=this.outputs[b];return B(A==null?void 0:A.createdAt).isSame(B(m.createdAt))?E>b:!!B(A==null?void 0:A.createdAt).isAfter(m.createdAt)}).forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-continue-statement-inputs"))){const r=[],a=[],c=[],e=[],f=this.getDataType(i);if(f)if(f.entity){if(f.isObject()){const b=[...f.entity.properties];this.outputs.filter(V=>!V.declaration||!b.find(P=>{var M;return P.id===((M=V.declaration)==null?void 0:M.id)})).forEach(V=>{const P=b.find(M=>de(M,this.project)===de(V,this.project));P&&V.setDeclaration(P,i)}),b.filter(V=>!this.outputs.find(P=>{var M;return((M=P.declaration)==null?void 0:M.id)===V.id})).forEach(V=>{const P={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:V,defaultValue:null,index:V.index,readsValue:null},M=Re(P,this.project);return M.hydrateAncestors(),M.addSelfToProject(i),i==null||i.add(M,H.Added),M.setParent(this,i),M.initChildren(i),this.addOutput(M,i),i||M.captureVersion(),M})}}else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const{updated:h,added:m,removed:E}=this.removeUnrecognizedInputs(i);return a.push(...h),r.push(...m),c.push(...E),this.outputs.forEach(b=>{const{updated:A,added:_,removed:V}=b.afterAllChildrenInitialized(i);a.push(...A),r.push(..._),c.push(...V)}),this.outputs.sort((b,A)=>b.index-A.index),i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}setDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetDataType,this.id),this;const a=this.dataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.dataType=i,this.subscribeToDependencies(),r==null||r.add(this,H.Affected)),r==null||r.attemptAutoclose(w.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const r=this.parent.getDataType(i);return r?(i==null||i.attemptAutoclose("get-data-type",this.id),r):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};R(qi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(qi,"type",d.ContinueStatement),R(qi,"USER_MANAGED_PARENT_TYPES",[d.Loop]),R(qi,"PARENT_TYPES",[...qi.USER_MANAGED_PARENT_TYPES]),R(qi,"MUTABLE_BASE_PROPERTIES",[]),R(qi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(qi,"BASE_PROPERTIES",[...qi.MUTABLE_BASE_PROPERTIES,...qi.INMUTABLE_BASE_PROPERTIES]),R(qi,"MUTABLE_META_PROPERTIES",["x","y"]),R(qi,"INMUTABLE_META_PROPERTIES",[...qi.INMUTABLE_BASE_PROPERTIES]),R(qi,"META_PROPERTIES",[...qi.MUTABLE_META_PROPERTIES,...qi.INMUTABLE_META_PROPERTIES]),R(qi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),R(qi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(qi,"UPSTREAM_PROPERTIES",[...qi.MUTABLE_UPSTREAM_PROPERTIES,...qi.INMUTABLE_UPSTREAM_PROPERTIES]),R(qi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),R(qi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),R(qi,"DOWNSTREAM_PROPERTIES",[...qi.MUTABLE_DOWNSTREAM_PROPERTIES,...qi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(qi,"PROPERTIES",[...qi.META_PROPERTIES,...qi.UPSTREAM_PROPERTIES,...qi.DOWNSTREAM_PROPERTIES]);let Fp=qi;function hCi(){return bt([st({type:nt(d.ValueDescriptor)}),Fr(We(),zr())])}function mCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ValueDescriptor)})}function k4e(){return st({id:We(),type:nt(d.ValueDescriptor),name:We(),required:vr()})}function TCi(){return k4e().merge(st({}))}function vCi(){return bt([st({type:nt(d.Property)}),Fr(We(),zr())])}function ECi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Property)})}function U4e(){return st({id:We(),type:nt(d.Property),name:We(),description:We().nullable(),private:vr(),static:vr(),required:vr(),abstract:vr()})}function bCi(){return U4e().merge(st({}))}function ACi(){return Mm([ge.CRON_JOB,ge.HTTP_ENDPOINT,ge.PERSISTED_ENTITY,ge.RELATIONAL_DATABASE])}function gCi(){return bt([st({type:nt(d.BuiltInBaseEntity)}),Fr(We(),zr())])}function ICi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.BuiltInBaseEntity)})}function F4e(){return st({id:We(),version:We(),type:nt(d.BuiltInBaseEntity),name:ACi(),description:We().nullable(),abstract:vr(),static:vr()})}function RCi(){return F4e().merge(st({}))}function p_(){return bt([st({type:nt(d.ActionDescriptor)}),Fr(We(),zr())])}function c_(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ActionDescriptor)})}function dV(){return st({id:We(),type:nt(d.ActionDescriptor),name:We(),description:We().nullable()})}function DCi(){return dV().merge(st({}))}function wCi(){return bt([st({type:nt(d.PrimitiveEntity)}),Fr(We(),zr())])}function CCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.PrimitiveEntity)})}function uV(){return st({id:We(),type:nt(d.PrimitiveEntity),name:We(),description:We().nullable(),static:vr(),abstract:vr()})}function OCi(){return uV().merge(st({}))}function _Ci(){return bt([st({type:nt(d.DataType)}),Fr(We(),zr())])}function VCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.DataType)})}function K4e(){return st({id:We(),type:nt(d.DataType),isList:vr().nullable(),asType:vr().nullable(),options:Vx(We()).optional(),like:vr().nullable(),implementationChooseOne:vr().nullable(),foreignKeyAllowed:vr().nullable(),staticEntities:vr().nullable(),interactiveEntities:vr().nullable(),actionEntities:vr().nullable(),parentRelationType:Mm([Ye.AndDataTypeGroup,Ye.OrDataTypeGroup]).nullable().optional()})}function PCi(){return K4e().merge(st({entity:We().nullable().optional(),foreignKeyRef:We().nullable().optional(),asType:vr().nullable().optional(),like:vr().nullable().optional(),isList:vr().nullable().optional(),implementationChooseOne:vr().nullable().optional(),foreignKeyAllowed:vr().nullable().optional(),staticEntities:vr().nullable().optional(),interactiveEntities:vr().nullable().optional(),actionEntities:vr().nullable().optional(),parentRelationType:Mm([Ye.AndDataTypeGroup,Ye.OrDataTypeGroup]).nullable().optional()}))}function Fm(){return bt([st({type:nt(d.ContinueStatement)}),Fr(We(),zr())])}function Km(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ContinueStatement)})}function q4e(){return st({id:We(),type:nt(d.ContinueStatement)})}function NCi(){return q4e().merge(st({}))}function UE(){return bt([st({type:nt(d.Loop)}),Fr(We(),zr())])}function FE(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Loop)})}function xCi(){return st({id:We(),type:nt(d.Loop)})}function $Ci(){return xCi().merge(st({declaration:bt([We(),HE()])}))}function qm(){return bt([st({type:nt(d.BreakStatement)}),Fr(We(),zr())])}function Sm(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.BreakStatement)})}function S4e(){return st({id:We(),type:nt(d.BreakStatement)})}function LCi(){return S4e().merge(st({}))}function q$(){return bt([st({type:nt(d.OutputMap)}),Fr(We(),zr())])}function S$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.OutputMap)})}function Z4e(){return st({id:We(),type:nt(d.OutputMap)})}function BCi(){return Z4e().merge(st({}))}function KE(){return bt([st({type:nt(d.Operation)}),Fr(We(),zr())])}function qE(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Operation)})}function H4e(){return st({id:We(),type:nt(d.Operation)})}function MCi(){return H4e().merge(st({}))}function S1(){return bt([We(),Pa(),vr(),bs(),ou()])}function W4e(){return Fr(We(),S1())}function GCi(){return Vx(bt([S1(),W4e()]))}function jCi(){return bt([S1(),W4e(),GCi()])}function z4e(){return bt([S1(),jCi()])}function kCi(){return Mm(Object.values(fe))}function UCi(){return st({id:We(),name:kCi(),type:nt(d.LiteralValue),value:z4e().nullable(),rawString:We().optional().nullable()})}function FCi(){return UCi().merge(st({value:z4e().nullable().optional(),rawString:We().optional().nullable(),valueAsTypeList:Vx(We()).nullable().optional(),valueAsTypeSingle:We().nullable().optional()}))}function SE(){return bt([st({type:nt(d.FunctionCall)}),Fr(We(),zr())])}function ZE(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.FunctionCall)})}function Y4e(){return st({id:We(),type:nt(d.FunctionCall)})}function KCi(){return Y4e().merge(st({}))}function Z1(){return bt([st({type:nt(d.Condition)}),Fr(We(),zr())])}function H1(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Condition)})}function J4e(){return st({id:We(),type:nt(d.Condition)})}function qCi(){return J4e().merge(st({}))}function W1(){return bt([st({type:nt(d.Search)}),Fr(We(),zr())])}function z1(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.Search)})}function Q4e(){return st({id:We(),type:nt(d.Search),name:We(),query:zr(),description:We().nullable()})}function SCi(){return Q4e().merge(st({}))}function Z$(){return bt([st({type:nt(d.InternalCall)}),Fr(We(),zr())])}function H$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.InternalCall)})}function X4e(){return st({id:We(),type:nt(d.InternalCall),index:Pa()})}function ZCi(){return X4e().merge(st({declaration:bt([We(),HE()])}))}function eje(){return bt([st({type:nt(d.InputMap)}),Fr(We(),zr())])}function tje(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.InputMap)})}function ije(){return st({id:We(),type:nt(d.InputMap),name:We().nullable().optional(),description:We().nullable().optional()})}function HCi(){return ije().merge(st({}))}function WCi(){return bt([st({type:nt(d.VariableDeclaration)}),Fr(We(),zr())])}function zCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.VariableDeclaration)})}function rje(){return st({id:We(),type:nt(d.VariableDeclaration),name:We(),description:We().nullable()})}function YCi(){return rje().merge(st({}))}function JCi(){return bt([st({type:nt(d.VariableInstance)}),Fr(We(),zr())])}function QCi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.VariableInstance)})}function nje(){return st({id:We(),type:nt(d.VariableInstance)})}function XCi(){return nje().merge(st({}))}function Zm(){return bt([st({type:nt(d.ReturnStatement)}),Fr(We(),zr())])}function Hm(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ReturnStatement)})}function aje(){return st({id:We(),type:nt(d.ReturnStatement)})}function eOi(){return aje().merge(st({}))}function sje(){return bt([st({type:nt(d.InstalledProject)}),Fr(We(),zr())])}function lje(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.InstalledProject)})}function tOi(){return st({id:We(),type:nt(d.InstalledProject)})}function iOi(){return st({})}function rOi(){return bt([st({type:nt(d.GlobalEvent)}),Fr(We(),zr())])}function nOi(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.GlobalEvent)})}function oje(){return st({id:We(),type:nt(d.GlobalEvent),name:We(),collapsed:vr()})}function aOi(){return oje().merge(st({}))}function ay(){return bt([WCi(),JCi()])}function sy(){return bt([zCi(),QCi()])}function dje(){return bt([ay(),eje(),Zm(),qm(),Fm()])}function uje(){return bt([sy(),tje(),Hm(),Sm(),Km()])}function sOi(){return bt([ay(),W$(),q$(),KE(),Z$(),SE()])}function lOi(){return bt([sy(),z$(),S$(),qE(),H$(),ZE()])}function oOi(){return bt([W$(),q$(),dje()])}function dOi(){return bt([z$(),S$(),uje()])}function Y1(){return rOi()}function J1(){return nOi()}function Q1(){return bt([KE(),SE(),Z1(),W1(),ay(),Z$(),UE()])}function X1(){return bt([qE(),ZE(),H1(),z1(),sy(),H$(),FE()])}function eD(){return bt([KE(),SE(),Z1(),W1(),ay(),UE()])}function tD(){return bt([qE(),ZE(),H1(),z1(),sy(),FE()])}function pje(){return bt([Q1(),Zm(),qm(),Fm()])}function cje(){return bt([X1(),Hm(),Sm(),Km()])}function fje(){return bt([eD(),Zm(),qm(),Fm()])}function yje(){return bt([tD(),Hm(),Sm(),Km()])}function Fc(){return bt([HE(),Y1()])}function Kc(){return bt([Y$(),J1()])}function uOi(){return bt([Q1(),Fc()])}function pOi(){return bt([X1(),Kc()])}function cOi(){return bt([eD(),Fc()])}function fOi(){return bt([tD(),Kc()])}function yOi(){return bt([pje(),Fc()])}function hOi(){return bt([cje(),Kc()])}function mOi(){return bt([fje(),Fc()])}function TOi(){return bt([yje(),Kc()])}function vOi(){return bt([Fc(),UE()])}function EOi(){return bt([Kc(),FE()])}function bOi(){return bt([Q1(),Fc()])}function AOi(){return bt([X1(),Kc()])}function gOi(){return bt([eD(),Fc()])}function IOi(){return bt([tD(),Kc()])}function ROi(){return bt([Zm(),qm(),Fm()])}function DOi(){return bt([Hm(),Sm(),Km()])}function wOi(){return bt([gCi(),NOi(),sje(),vje(),HE(),Y1(),ay(),eje(),q$(),Z1(),KE(),SE(),W$(),wCi(),_Ci(),vCi(),p_(),Zm(),Fm(),qm(),UE(),W1(),p_(),p_(),hCi(),Z$()])}function COi(){return bt([ICi(),xOi(),lje(),Eje(),Y$(),J1(),sy(),tje(),S$(),H1(),qE(),ZE(),z$(),CCi(),VCi(),ECi(),c_(),Hm(),Km(),Sm(),FE(),z1(),c_(),c_(),mCi(),H$()])}function OOi(){return bt([sje(),vje(),HE(),Y1(),ay(),Z1(),KE(),SE(),Zm(),Fm(),qm(),UE(),W1()])}function _Oi(){return bt([lje(),Eje(),Y$(),J1(),sy(),H1(),qE(),ZE(),Hm(),Km(),Sm(),FE(),z1()])}function W$(){return bt([st({type:nt(d.ArgumentDeclaration)}),Fr(We(),zr())])}function z$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.ArgumentDeclaration)})}function hje(){return st({id:We(),type:nt(d.ArgumentDeclaration)})}function VOi(){return hje().merge(st({}))}function HE(){return bt([st({type:nt(d.FunctionDeclaration)}),Fr(We(),zr())])}function Y$(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.FunctionDeclaration)})}function mje(){return st({id:We(),type:nt(d.FunctionDeclaration),name:We(),description:We().nullable()})}function POi(){return mje()}function NOi(){return bt([st({type:nt(d.Project)}),Fr(We(),zr())])}function xOi(){return st({entityType:nt(d.Project),entityId:We(),id:We(),type:nt(d.GenericReference)})}function Tje(){return st({id:We(),type:nt(d.Project),name:We(),description:We().nullable()})}function $Oi(){return Tje()}function vje(){return bt([st({type:nt(d.DefinitionEntity)}),Fr(We(),zr())])}function Eje(){return st({id:We(),type:nt(d.GenericReference),entityId:We(),entityType:nt(d.DefinitionEntity)})}function bje(){return st({id:We(),type:nt(d.DefinitionEntity),name:We(),description:We().nullable(),static:vr(),abstract:vr()})}function LOi(){return bje().merge(st({}))}var Aje="1.13.8",oF=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||Function("return this")()||{},iD=Array.prototype,J$=Object.prototype,dF=typeof Symbol<"u"?Symbol.prototype:null,BOi=iD.push,WE=iD.slice,yv=J$.toString,MOi=J$.hasOwnProperty,gje=typeof ArrayBuffer<"u",GOi=typeof DataView<"u",jOi=Array.isArray,uF=Object.keys,pF=Object.create,cF=gje&&ArrayBuffer.isView,kOi=isNaN,UOi=isFinite,Ije=!{toString:null}.propertyIsEnumerable("toString"),fF=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],FOi=Math.pow(2,53)-1;function gs(s,p){return p=p==null?s.length-1:+p,function(){for(var i=Math.max(arguments.length-p,0),r=Array(i),a=0;a<i;a++)r[a]=arguments[a+p];switch(p){case 0:return s.call(this,r);case 1:return s.call(this,arguments[0],r);case 2:return s.call(this,arguments[0],arguments[1],r)}var c=Array(p+1);for(a=0;a<p;a++)c[a]=arguments[a];return c[p]=r,s.apply(this,c)}}function ly(s){var p=typeof s;return p==="function"||p==="object"&&!!s}function KOi(s){return s===null}function Rje(s){return s===void 0}function Dje(s){return s===!0||s===!1||yv.call(s)==="[object Boolean]"}function qOi(s){return!!(s&&s.nodeType===1)}function La(s){var p="[object "+s+"]";return function(i){return yv.call(i)===p}}const Q$=La("String"),wje=La("Number"),SOi=La("Date"),ZOi=La("RegExp"),HOi=La("Error"),Cje=La("Symbol"),Oje=La("ArrayBuffer");var _je=La("Function"),WOi=oF.document&&oF.document.childNodes;typeof/./!="function"&&typeof Int8Array!="object"&&typeof WOi!="function"&&(_je=function(s){return typeof s=="function"||!1});const Ya=_je,Vje=La("Object");var Pje=GOi&&(!/\[native code\]/.test(String(DataView))||Vje(new DataView(new ArrayBuffer(8)))),X$=typeof Map<"u"&&Vje(new Map),zOi=La("DataView");function YOi(s){return s!=null&&Ya(s.getInt8)&&Oje(s.buffer)}const Wg=Pje?YOi:zOi,oy=jOi||La("Array");function qc(s,p){return s!=null&&MOi.call(s,p)}var pV=La("Arguments");(function(){pV(arguments)||(pV=function(s){return qc(s,"callee")})})();const eL=pV;function JOi(s){return!Cje(s)&&UOi(s)&&!isNaN(parseFloat(s))}function Nje(s){return wje(s)&&kOi(s)}function xje(s){return function(){return s}}function $je(s){return function(p){var i=s(p);return typeof i=="number"&&i>=0&&i<=FOi}}function Lje(s){return function(p){return p==null?void 0:p[s]}}const zg=Lje("byteLength"),QOi=$je(zg);var XOi=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;function e_i(s){return cF?cF(s)&&!Wg(s):QOi(s)&&XOi.test(yv.call(s))}const Bje=gje?e_i:xje(!1),Oa=Lje("length");function t_i(s){for(var p={},i=s.length,r=0;r<i;++r)p[s[r]]=!0;return{contains:function(a){return p[a]===!0},push:function(a){return p[a]=!0,s.push(a)}}}function Mje(s,p){p=t_i(p);var i=fF.length,r=s.constructor,a=Ya(r)&&r.prototype||J$,c="constructor";for(qc(s,c)&&!p.contains(c)&&p.push(c);i--;)c=fF[i],c in s&&s[c]!==a[c]&&!p.contains(c)&&p.push(c)}function ia(s){if(!ly(s))return[];if(uF)return uF(s);var p=[];for(var i in s)qc(s,i)&&p.push(i);return Ije&&Mje(s,p),p}function QT(s){if(s==null)return!0;var p=Oa(s);return typeof p=="number"&&(oy(s)||Q$(s)||eL(s))?p===0:Oa(ia(s))===0}function Gje(s,p){var i=ia(p),r=i.length;if(s==null)return!r;for(var a=Object(s),c=0;c<r;c++){var e=i[c];if(p[e]!==a[e]||!(e in a))return!1}return!0}function Rr(s){if(s instanceof Rr)return s;if(!(this instanceof Rr))return new Rr(s);this._wrapped=s}Rr.VERSION=Aje;Rr.prototype.value=function(){return this._wrapped};Rr.prototype.valueOf=Rr.prototype.toJSON=Rr.prototype.value;Rr.prototype.toString=function(){return String(this._wrapped)};function yF(s){return new Uint8Array(s.buffer||s,s.byteOffset||0,zg(s))}var hF="[object DataView]";function i_i(s,p){for(var i=[{a:s,b:p}],r=[],a=[];i.length;){var c=i.pop();if(c===!0){r.pop(),a.pop();continue}if(s=c.a,p=c.b,s===p){if(s!==0||1/s===1/p)continue;return!1}if(s==null||p==null)return!1;if(s!==s){if(p!==p)continue;return!1}var e=typeof s;if(e!=="function"&&e!=="object"&&typeof p!="object")return!1;s instanceof Rr&&(s=s._wrapped),p instanceof Rr&&(p=p._wrapped);var f=yv.call(s);if(f!==yv.call(p))return!1;if(Pje&&f=="[object Object]"&&Wg(s)){if(!Wg(p))return!1;f=hF}switch(f){case"[object RegExp]":case"[object String]":if(""+s==""+p)continue;return!1;case"[object Number]":i.push({a:+s,b:+p});continue;case"[object Date]":case"[object Boolean]":if(+s==+p)continue;return!1;case"[object Symbol]":if(dF.valueOf.call(s)===dF.valueOf.call(p))continue;return!1;case"[object ArrayBuffer]":case hF:i.push({a:yF(s),b:yF(p)});continue}var h=f==="[object Array]";if(!h&&Bje(s)){var m=zg(s);if(m!==zg(p))return!1;if(s.buffer===p.buffer&&s.byteOffset===p.byteOffset)continue;h=!0}if(!h){if(typeof s!="object"||typeof p!="object")return!1;var E=s.constructor,b=p.constructor;if(E!==b&&!(Ya(E)&&E instanceof E&&Ya(b)&&b instanceof b)&&"constructor"in s&&"constructor"in p)return!1}for(var A=r.length;A--;)if(r[A]===s){if(a[A]===p)break;return!1}if(!(A>=0))if(r.push(s),a.push(p),i.push(!0),h){if(A=s.length,A!==p.length)return!1;for(;A--;)i.push({a:s[A],b:p[A]})}else{var _=ia(s),V;if(A=_.length,ia(p).length!==A)return!1;for(;A--;){if(V=_[A],!qc(p,V))return!1;i.push({a:s[V],b:p[V]})}}}return!0}function zE(s){if(!ly(s))return[];var p=[];for(var i in s)p.push(i);return Ije&&Mje(s,p),p}function tL(s){var p=Oa(s);return function(i){if(i==null)return!1;var r=zE(i);if(Oa(r))return!1;for(var a=0;a<p;a++)if(!Ya(i[s[a]]))return!1;return s!==Uje||!Ya(i[iL])}}var iL="forEach",jje="has",rL=["clear","delete"],kje=["get",jje,"set"],r_i=rL.concat(iL,kje),Uje=rL.concat(kje),n_i=["add"].concat(rL,iL,jje);const a_i=X$?tL(r_i):La("Map"),s_i=X$?tL(Uje):La("WeakMap"),l_i=X$?tL(n_i):La("Set"),o_i=La("WeakSet");function Wm(s){for(var p=ia(s),i=p.length,r=Array(i),a=0;a<i;a++)r[a]=s[p[a]];return r}function d_i(s){for(var p=ia(s),i=p.length,r=Array(i),a=0;a<i;a++)r[a]=[p[a],s[p[a]]];return r}function Fje(s){for(var p={},i=ia(s),r=0,a=i.length;r<a;r++)p[s[i[r]]]=i[r];return p}function cV(s){var p=[];for(var i in s)Ya(s[i])&&p.push(i);return p.sort()}function nL(s,p){return function(i){var r=arguments.length;if(p&&(i=Object(i)),r<2||i==null)return i;for(var a=1;a<r;a++)for(var c=arguments[a],e=s(c),f=e.length,h=0;h<f;h++){var m=e[h];(!p||i[m]===void 0)&&(i[m]=c[m])}return i}}const Kje=nL(zE),Yg=nL(ia),qje=nL(zE,!0);function u_i(){return function(){}}function Sje(s){if(!ly(s))return{};if(pF)return pF(s);var p=u_i();p.prototype=s;var i=new p;return p.prototype=null,i}function p_i(s,p){var i=Sje(s);return p&&Yg(i,p),i}function c_i(s){return ly(s)?oy(s)?s.slice():Kje({},s):s}function f_i(s,p){return p(s),s}function Zje(s){return oy(s)?s:[s]}Rr.toPath=Zje;function YE(s){return Rr.toPath(s)}function aL(s,p){for(var i=p.length,r=0;r<i;r++){if(s==null)return;s=s[p[r]]}return i?s:void 0}function Hje(s,p,i){var r=aL(s,YE(p));return Rje(r)?i:r}function y_i(s,p){p=YE(p);for(var i=p.length,r=0;r<i;r++){var a=p[r];if(!qc(s,a))return!1;s=s[a]}return!!i}function sL(s){return s}function hv(s){return s=Yg({},s),function(p){return Gje(p,s)}}function lL(s){return s=YE(s),function(p){return aL(p,s)}}function JE(s,p,i){if(p===void 0)return s;switch(i??3){case 1:return function(r){return s.call(p,r)};case 3:return function(r,a,c){return s.call(p,r,a,c)};case 4:return function(r,a,c,e){return s.call(p,r,a,c,e)}}return function(){return s.apply(p,arguments)}}function Wje(s,p,i){return s==null?sL:Ya(s)?JE(s,p,i):ly(s)&&!oy(s)?hv(s):lL(s)}function oL(s,p){return Wje(s,p,1/0)}Rr.iteratee=oL;function Ps(s,p,i){return Rr.iteratee!==oL?Rr.iteratee(s,p):Wje(s,p,i)}function h_i(s,p,i){p=Ps(p,i);for(var r=ia(s),a=r.length,c={},e=0;e<a;e++){var f=r[e];c[f]=p(s[f],f,s)}return c}function zje(){}function m_i(s){return s==null?zje:function(p){return Hje(s,p)}}function T_i(s,p,i){var r=Array(Math.max(0,s));p=JE(p,i,1);for(var a=0;a<s;a++)r[a]=p(a);return r}function fV(s,p){return p==null&&(p=s,s=0),s+Math.floor(Math.random()*(p-s+1))}const mv=Date.now||function(){return new Date().getTime()};function Yje(s){var p=function(c){return s[c]},i="(?:"+ia(s).join("|")+")",r=RegExp(i),a=RegExp(i,"g");return function(c){return c=c==null?"":""+c,r.test(c)?c.replace(a,p):c}}const Jje={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},v_i=Yje(Jje),E_i=Fje(Jje),b_i=Yje(E_i),A_i=Rr.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var f_=/(.)^/,g_i={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},I_i=/\\|'|\r|\n|\u2028|\u2029/g;function R_i(s){return"\\"+g_i[s]}var D_i=/^\s*(\w|\$)+\s*$/;function w_i(s,p,i){!p&&i&&(p=i),p=qje({},p,Rr.templateSettings);var r=RegExp([(p.escape||f_).source,(p.interpolate||f_).source,(p.evaluate||f_).source].join("|")+"|$","g"),a=0,c="__p+='";s.replace(r,function(m,E,b,A,_){return c+=s.slice(a,_).replace(I_i,R_i),a=_+m.length,E?c+=`'+
211
211
  ((__t=(`+E+`))==null?'':_.escape(__t))+
212
212
  '`:b?c+=`'+
213
213
  ((__t=(`+b+`))==null?'':__t)+
package/dist/index.js CHANGED
@@ -177408,20 +177408,24 @@ function _Z() {
177408
177408
  ]);
177409
177409
  }
177410
177410
  function zIi() {
177411
- return l0(Object.values(fe));
177411
+ return l0(
177412
+ Object.values(fe)
177413
+ );
177412
177414
  }
177413
177415
  function JIi() {
177414
177416
  return st({
177415
177417
  id: ze(),
177416
177418
  name: zIi(),
177417
177419
  type: at(d.LiteralValue),
177418
- value: _Z().nullable()
177420
+ value: _Z().nullable(),
177421
+ rawString: ze().optional().nullable()
177419
177422
  });
177420
177423
  }
177421
177424
  function YIi() {
177422
177425
  return JIi().merge(
177423
177426
  st({
177424
177427
  value: _Z().nullable().optional(),
177428
+ rawString: ze().optional().nullable(),
177425
177429
  valueAsTypeList: z_(ze()).nullable().optional(),
177426
177430
  valueAsTypeSingle: ze().nullable().optional()
177427
177431
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.7002",
3
+ "version": "0.0.7003",
4
4
  "author": "Sergio Herrero",
5
5
  "license": "UNLICENSED",
6
6
  "description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",