@elyx-code/project-logic-tree 0.0.6715 → 0.0.6716
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 +1 -1
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -95,7 +95,7 @@ Specifically for variables, their scope is also calculated from their value read
|
|
|
95
95
|
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m;return(n=(i=this.parent)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"parent"}]),(e=(c=(s=this.declaration.dataType)==null?void 0:s.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),(m=(y=this.declaration)==null?void 0:y.unsubscribeDependents)==null||m.call(y,[{entity:this,field:"var-declaration"}]),this}subscribeToDependencies(){var i,n,s,c;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),(c=(s=(n=this.declaration.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"data-type-entity"}]),this.declaration.subscribeDependents([{entity:this,field:"var-declaration"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new yi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.declaration=this.declaration,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,P]of b.knownVersions)v.set(w,P);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new yi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=re(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=re(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.declaration){const s=re(i.declaration),c=this.project.get(s);c&&this.setDeclaration(c)}if(i.calledByEntry.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>re(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>re(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.defaultValue){const s=re(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>re(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=re(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}if(this.initialData.declaration){const e=re(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){var xe;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(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.declaration.dataType||(xe=this.declaration.dataType)!=null&&xe.inferred){const{added:Me,updated:Se,removed:je,affected:Ze}=this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...Me),n.push(...Se),c.push(...je),e.push(...Ze)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:P,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...P),e.push(...$);const{added:L,updated:j,removed:F,affected:q}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...j),c.push(...F),e.push(...q);const{added:X,updated:ae,removed:ee,affected:fe}=this.removeUnrecognizedInputs(i);s.push(...X),n.push(...ae),c.push(...ee),e.push(...fe);const{added:oe,updated:ce,removed:Te,affected:de}=this.removeUnrecognizedOutputs(i);s.push(...oe),n.push(...ce),c.push(...Te),e.push(...de);const{added:ye,updated:_e,removed:Pe,affected:Ge}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(..._e),c.push(...Pe),e.push(...Ge),this.inputs.sort((Me,Se)=>{var je,Ze;return(Me.index??((je=Me.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.outputs.sort((Me,Se)=>{var je,Ze;return(Me.index??((je=Me.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length||!!i.writesValues.length||!!i.successCalls.length||!!i.errorCalls.length)}get unusedInternalCalls(){const i=this.usedInternalCalls;return this.internalCalls.filter(s=>!(i.find(y=>y.id===s.id)||i.find(y=>y.declaration===s.declaration)))}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-instance-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-instance-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n)?this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this):this}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=he(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.declaration.type===d.GenericReference){const n=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!n)return this;this.declaration=n}else this.declaration=he(this.initialData.declaration,this.project),this.declaration.initChildren(i);return _v.initWritesValues(this,this.parent),af.initReadsValue(this),this.initialData.inputs.forEach(n=>{const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,i),s}),this.successCalls=this.initialData.successCalls.map(n=>{const s=he(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=rn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=he(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=rn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.internalCalls=this.initialData.internalCalls.reduce((n,s)=>{if(s.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(s);if(!c)return n;const e=c;return e.setParent(this,null),[...n,e]}else{const c=he(s,this.project);return c.setParent(this,null),c.initChildren(i),[...n,c]}},[]),this.initialData.error&&(this.error=he(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Lr(this,i,n),c=$r(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await yi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await yi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await yi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await yi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await yi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await yi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableInstance(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:rr.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}return this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...this.writesValues.flatMap(e=>e.toFlat(i)),...((c=this.readsValue)==null?void 0:c.toFlat(i))||[],...this.successCalls.flatMap(e=>e.toFlat(i)),...this.errorCalls.flatMap(e=>e.toFlat(i)),...this.inputs.flatMap(e=>e.toFlat(i)),...this.outputs.flatMap(e=>e.toFlat(i)),...this.internalCalls.flatMap(e=>e.toFlat(i))])}toFlatIds(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...this.writesValues.flatMap(c=>c.toFlatIds(i)),...this.successCalls.flatMap(c=>c.toFlatIds(i)),...this.errorCalls.flatMap(c=>c.toFlatIds(i)),...this.inputs.flatMap(c=>c.toFlatIds(i)),...this.outputs.flatMap(c=>c.toFlatIds(i)),...this.internalCalls.flatMap(c=>c.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,catchesError:this.catchesError,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 n,s,c;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,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,declaration:this.declaration.toJSON(i),defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,readsValue:((s=this.readsValue)==null?void 0:s.toReference())||null,writesValues:this.writesValues.map(e=>e.toJSON(i)),inputs:this.inputs.map(e=>e.toJSON(i)),outputs:this.outputs.map(e=>e.toJSON(i)),successCalls:this.successCalls.map(e=>e.toJSON(i)),errorCalls:this.errorCalls.map(e=>e.toJSON(i)),internalCalls:this.internalCalls.map(e=>e.toJSON(i)),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),parent:this.parent.toReference(),error:((c=this.error)==null?void 0:c.toJSON(i))||null,x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,declaration:this.declaration.toReference({seenEntityMaps:i.seenEntityMaps}),readsValue:((E=this.readsValue)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps}))||null,writesValues:this.writesValues.map(w=>w.toJSONClone({...i,newId:null})),inputs:this.inputs.map(w=>w.toJSONClone({...i,newId:null})),outputs:this.outputs.map(w=>w.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(w=>w.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(w=>w.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(w=>this.calledBy.length||this.readsValue?w.toJSONClone({...i,newId:null}):w.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),error:((b=this.error)==null?void 0:b.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,catchesError:this.catchesError,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,declaration:((e=this.declaration)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.declaration)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i)),...this.calledBy.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.declaration)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.readsValue)==null?void 0:e.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(y=>y.toFlatGenerationTarget(i)),...this.successCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.inputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.outputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(y=>y.toFlatGenerationTarget(i))])}clearErrors(){var i;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),this.inputs.forEach(n=>n.clearErrors()),this.outputs.forEach(n=>n.clearErrors()),this.successCalls.forEach(n=>n.clearErrors()),this.errorCalls.forEach(n=>n.clearErrors()),this.internalCalls.forEach(n=>n.clearErrors()),this}validate(){return this.errors=jLe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await kLe(this,{tracker:n}),{success:!0}}getErrors(){var n;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...this.inputs.flatMap(s=>s.getErrors()),...this.internalCalls.flatMap(s=>s.getErrors()),...this.outputs.flatMap(s=>s.getErrors())]}async getErrorsAsync(i={}){var e;const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();const c=await((e=this.defaultValue)==null?void 0:e.getErrorsAsync({tracker:n}));c&&s.push(...c);for(const y of this.inputs){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}for(const y of this.internalCalls){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}for(const y of this.outputs){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}return s}getShallowErrors(){return this.errors}getDefaultValue(){var i;return this.defaultValue||((i=this.declaration)==null?void 0:i.defaultValue)||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var $,L,j,F;const e=Vr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Ki(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=($=this.defaultValue)==null?void 0:$.clone(i,v,x.UUID.uuid(),c);v.defaultValue=E||null;const b=(L=this.inputs)==null?void 0:L.map(q=>q.clone(i,v,x.UUID.uuid(),c));v.inputs=b;const w=(j=this.outputs)==null?void 0:j.map(q=>q.clone(i,v,x.UUID.uuid(),c));v.outputs=w;const P=(F=this.internalCalls)==null?void 0:F.map(q=>q.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=P,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}setDeclaration(i){return this.declaration!==i&&(this.declaration=i),this}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.inputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.inputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-instance-outputs"))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.outputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.outputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose("remove-unrecognized-variable-instance-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.declaration.dataType||!this.declaration.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.declaration.dataType&&this.declaration.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const m=[...this.declaration.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,P;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((P=b.extends)==null?void 0:P.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-instance-inputs"))){const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.properties];y.filter(b=>!b.getDataType(i)).forEach(b=>{const w=this.inputs.find(L=>se(L,this.project)===se(b,this.project));if(!w)return;const P=this.declaration.getMasterInputWithValueWritterFromAllInstances(w);if(!P)return;const $=Oo(P);b.setDataType($,i),w.setDeclaration(b,i)}),y.filter(b=>!this.inputs.find(w=>{var P;return((P=w.declaration)==null?void 0:P.id)===b.id})).forEach(b=>{const w={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().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:b,defaultValue:null,index:b.index,readsValue:null},P=he(w,this.project);return P.setParent(this,i),P.initChildren(i),i==null||i.add(P,H.Added),this.addInput(P,i),P}),this.inputs.filter(b=>!b.declaration).forEach(b=>{const w=y.find(P=>se(P,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)})}}else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity)[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList&&[...this.declaration.dataType.entity.properties].filter(v=>!this.outputs.find(E=>E.declaration===v)).map(v=>{const E={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:v,index:v.index,writesValues:[]},b=he(E,this.project);return b.setParent(this,i),b.initChildren(i),i==null||i.add(b,H.Added),this.addOutput(b,i),b});else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,P;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((P=b.extends)==null?void 0:P.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,j,F,q;return((($=w.declaration)==null?void 0:$.id)||((j=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:j.entityId)||((q=(F=w.initialData)==null?void 0:F.declaration)==null?void 0:q.id))===E.id})).forEach(E=>{const b=this.internalCalls.find(w=>{const P=_c(w.declaration),$=_c(E);return P.id===$.id});if(b)b.setDeclaration(E),b.subscribeToDependencies();else{const w=E.createInternalCall(i,this);i==null||i.add(w,H.Added),this.addInternalCall(w)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;const n=((s=this.declaration)==null?void 0:s.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),n}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(yi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(yi,"type",d.VariableInstance),I(yi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(yi,"PARENT_TYPES",[...yi.USER_MANAGED_PARENT_TYPES]),I(yi,"MUTABLE_BASE_PROPERTIES",["catchesError"]),I(yi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(yi,"BASE_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES,...yi.INMUTABLE_BASE_PROPERTIES]),I(yi,"MUTABLE_META_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(yi,"INMUTABLE_META_PROPERTIES",[...yi.INMUTABLE_BASE_PROPERTIES]),I(yi,"META_PROPERTIES",[...yi.MUTABLE_META_PROPERTIES,...yi.INMUTABLE_META_PROPERTIES]),I(yi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(yi,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),I(yi,"UPSTREAM_PROPERTIES",[...yi.MUTABLE_UPSTREAM_PROPERTIES,...yi.INMUTABLE_UPSTREAM_PROPERTIES]),I(yi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(yi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(yi,"DOWNSTREAM_PROPERTIES",[...yi.MUTABLE_DOWNSTREAM_PROPERTIES,...yi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(yi,"PROPERTIES",[...yi.META_PROPERTIES,...yi.UPSTREAM_PROPERTIES,...yi.DOWNSTREAM_PROPERTIES]);let Lu=yi;var ULe=(o=>(o.Parent="variable-declaration-parent",o.DataTypeEntity="variable-declaration-data-type-entity",o.DataType="variable-declaration-data-type",o))(ULe||{});const hi=class hi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"codeName",null);I(this,"description",null);I(this,"required",!1);I(this,"constant",!1);I(this,"x");I(this,"y");I(this,"type",d.VariableDeclaration);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"dataType",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"parent");I(this,"errors",[]);I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.constant=i.constant,this.codeName=i.codeName,this.required=i.required,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:!1,name:"",codeName:null,description:"",dataType:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,constant:!1,required:!1,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let s=n;if(i.parent){const b=re(i.parent);s=n.get(b)}const c=i.calledByEntry.map(b=>{const w=re(b);return n.get(w)}),e=i.calledBySuccess.map(b=>{const w=re(b);return n.get(w)}),y=i.calledByError.map(b=>{const w=re(b);return n.get(w)});let m=null;if(i.readsValue){const b=re(i.readsValue);m=n.get(b)}const v={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:i.catchesError||!1,name:i.name,defaultValue:null,codeName:i.codeName||null,description:i.description||null,constant:i.constant||!1,required:i.required||!1,calledByEntry:c,calledBySuccess:e,calledByError:y,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:m,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:s},E=he(v,n);return E.setParent(s,null),E}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[...nr,d.Project],optional:!0}},n);s=e.modifiedData;const y=RV(s,n);return c.push(...e.errors,...y,...xr(s)),{errors:c,modifiedData:s}}get variableInstances(){const i=[];return Object.values(this.detachedDependents).forEach(n=>{n.field===vN.VarDeclaration&&!i.includes(n.entity)&&i.push(n.entity)}),i}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=nf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ne.InvalidParentUpdate}`,code:ne.InvalidParentUpdate,severity:pe.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
96
96
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
97
97
|
Specifically for variables, their scope is also calculated from their value readers and value writters.
|
|
98
|
-
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}subscribeToDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new hi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,P]of b.knownVersions)v.set(w,P);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new hi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=re(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=re(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>re(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>re(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.dataType){const s=re(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=re(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>re(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=re(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred){const{added:xe,updated:Me,removed:Se,affected:je}=this.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...xe),n.push(...Me),c.push(...Se),e.push(...je)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:P,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...P),e.push(...$);const{added:L,updated:j,removed:F,affected:q}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...j),c.push(...F),e.push(...q);const{added:X,updated:ae,removed:ee,affected:fe}=this.removeUnrecognizedInputs(i);s.push(...X),n.push(...ae),c.push(...ee),e.push(...fe);const{added:oe,updated:ce,removed:Te,affected:de}=this.removeUnrecognizedOutputs(i);s.push(...oe),n.push(...ce),c.push(...Te),e.push(...de);const{added:ye,updated:_e,removed:Pe,affected:Ge}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(..._e),c.push(...Pe),e.push(...Ge),this.parent===this.project&&(this.catchesError&&(i==null||i.event({id:`${_.RemoveErrorCatching}-${this.id}`,action:_.RemoveErrorCatching,owner:this,errorReason:rr.GlobalVariableDeclarationCannnotCatchError,rootAction:!1}),this.metaSync({catchesError:!1},i)),this.errorCalls.length&&(i==null||i.event({id:`${_.RemoveAllErrorCalls}-${this.id}`,action:_.RemoveAllErrorCalls,owner:this,errorReason:rr.GlobalVariableDeclarationCannotCallFromError,rootAction:!1}),[...this.errorCalls].forEach(xe=>{this.removeCall(xe,i),xe.removeCaller(this,i)})),this.calledBy.length&&(i==null||i.event({id:`${_.RemoveAllCallers}-${this.id}`,action:_.RemoveAllCallers,owner:this,errorReason:rr.GlobalVariableDeclarationCannotBeCalled,rootAction:!1}),[...this.calledBy].forEach(xe=>{this.removeCaller(xe,i),xe.removeCall(this,i)}))),this.inputs.sort((xe,Me)=>{var Se,je;return(xe.index??((Se=xe.declaration)==null?void 0:Se.index))-(Me.index??((je=Me.declaration)==null?void 0:je.index))}),this.outputs.sort((xe,Me)=>{var Se,je;return(xe.index??((Se=xe.declaration)==null?void 0:Se.index))-(Me.index??((je=Me.declaration)==null?void 0:je.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(i=>!i.calledBy.length)}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-declaration-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-declaration-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n)?this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this):this}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=he(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const n=he(this.initialData.dataType,this.project);this.setDataType(n,i),this.dataType.setParent(this,null),this.dataType.initChildren(i)}return _v.initWritesValues(this,this.parent),af.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(n=>{const s=he(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=rn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=he(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=rn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.initialData.inputs.forEach(n=>{const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,null),s}),this.initialData.internalCalls.forEach(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(n);if(!c)return;c.setParent(this,null),c.initChildren(i),this.addInternalCall(c);return}const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInternalCall(s),s}),this.initialData.error&&(this.error=he(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.inputs,...this.variableInstances.flatMap(c=>c.inputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}inferDataTypeAndSyncInstancesInputsAndOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"infer-data-type-and-sync-instances-inputs-and-outputs"))){var F,q,X,ae,ee,fe,oe;const n=[],s=[],c=[],e=[];if(!this.dataType){const ce=ir.new(i);ce.parent=this.toReference(),ce.inferred=!0;const Te=he(ce,this.project);Te.hydrateAncestors(),Te.addSelfToProject(i),this.setDataType(Te,i),Te.setParent(this,i),Te.initChildren(i),i==null||i.add(Te,H.Added),Te.metaSync({inferred:!0,like:!0},i)}if(this.readsValue&&((F=this.dataType)!=null&&F.inferred)){const ce=this.readsValue.getDataType(null);ce&&((q=this.dataType)==null||q.merge(ce,i),this.dataType.metaSync({inferred:!0,like:!0},i))}const y=D([...this.inputs,...this.variableInstances.flatMap(ce=>ce.inputs)]),m=[];if(y.forEach(ce=>{m.find(de=>se(de,this.project)===se(ce,this.project))||m.push(ce)}),(!((X=this.dataType)!=null&&X.entity)||((ee=(ae=this.dataType)==null?void 0:ae.entity)==null?void 0:ee.type)===d.DefinitionEntity&&((fe=this.dataType)==null?void 0:fe.entity.parent)===this.dataType)&&((oe=this.dataType)==null||oe.inferFromInputs(m,i)),!this.dataType)return i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this};const{updated:v,added:E,removed:b,affected:w}=this.syncInputs(i);n.push(...E),s.push(...v),c.push(...b),e.push(...w);const{updated:P,added:$,removed:L,affected:j}=this.syncOutputs(i);return n.push(...$),s.push(...P),c.push(...L),e.push(...j),this.variableInstances.forEach(ce=>{const{updated:Te,added:de,removed:ye,affected:_e}=ce.syncInputs(i);n.push(...de),s.push(...Te),c.push(...ye),e.push(..._e);const{updated:Pe,added:Ge,removed:xe,affected:Me}=ce.syncOutputs(i);n.push(...Ge),s.push(...Pe),c.push(...xe),e.push(...Me)}),i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this}}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Lr(this,i,n),c=$r(this,s),e=this.toMeta();return this.name=s.name!==void 0?s.name:e.name,this.codeName=s.codeName!==void 0?s.codeName:e.codeName,this.description=s.description!==void 0?s.description:e.description,this.x=s.x||e.x,this.y=s.y||e.y,this.constant=s.constant!==void 0?s.constant:e.constant,this.required=s.required!==void 0?s.required:e.required,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await hi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await hi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await hi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await hi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await hi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await hi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableDeclaration(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:rr.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.dataType){const{updated:v,removed:E}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...((c=this.dataType)==null?void 0:c.toFlat(i))||[],...((e=this.readsValue)==null?void 0:e.toFlat(i))||[],...this.writesValues.flatMap(y=>y.toFlat(i)),...this.successCalls.flatMap(y=>y.toFlat(i)),...this.errorCalls.flatMap(y=>y.toFlat(i)),...this.inputs.flatMap(y=>y.toFlat(i)),...this.outputs.flatMap(y=>y.toFlat(i)),...this.internalCalls.flatMap(y=>y.toFlat(i)),...this.calledBy.flatMap(y=>y.toFlat(i)),...this.variableInstances.flatMap(y=>y.toFlat(i))])}toFlatIds(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...((c=this.dataType)==null?void 0:c.toFlatIds(i))||[],...this.writesValues.flatMap(e=>e.toFlatIds(i)),...this.successCalls.flatMap(e=>e.toFlatIds(i)),...this.errorCalls.flatMap(e=>e.toFlatIds(i)),...this.inputs.flatMap(e=>e.toFlatIds(i)),...this.outputs.flatMap(e=>e.toFlatIds(i)),...this.internalCalls.flatMap(e=>e.toFlatIds(i)),...this.variableInstances.flatMap(e=>e.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,catchesError:this.catchesError,description:this.description,required:this.required,constant:this.constant,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,c,e;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,name:this.name,codeName:this.codeName,description:this.description,catchesError:this.catchesError,constant:this.constant,required:this.required,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,writesValues:this.writesValues.map(y=>y.toJSON(i)),inputs:this.inputs.map(y=>y.toJSON(i)),outputs:this.outputs.map(y=>y.toJSON(i)),successCalls:this.successCalls.map(y=>y.toJSON(i)),errorCalls:this.errorCalls.map(y=>y.toJSON(i)),internalCalls:this.internalCalls.map(y=>y.toJSON(i)),calledBySuccess:this.calledBySuccess.map(y=>y.toReference()),calledByError:this.calledByError.map(y=>y.toReference()),calledByEntry:this.calledByEntry.map(y=>y.toReference()),error:((e=this.error)==null?void 0:e.toJSON(i))||null,parent:this.parent.toReference(),x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,codeName:this.codeName,constant:this.constant,required:this.required,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,catchesError:this.catchesError,defaultValue:((v=this.defaultValue)==null?void 0:v.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,writesValues:this.writesValues.map(P=>P.toJSONClone({...i,newId:null})),inputs:this.inputs.map(P=>P.toJSONClone({...i,newId:null})),outputs:this.outputs.map(P=>P.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(P=>P.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(P=>P.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(P=>this.calledBy.length||this.readsValue?P.toJSONClone({...i,newId:null}):P.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(P=>P.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(P=>P.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(P=>P.toReference({seenEntityMaps:i.seenEntityMaps})),error:((w=this.error)==null?void 0:w.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,catchesError:this.catchesError,required:this.required,constant:this.constant,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:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(e=>e.toFlatGenerationTarget(i)),...this.successCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.inputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,n;return this.errors=[],this.inputs.forEach(s=>s.clearErrors()),this.outputs.forEach(s=>s.clearErrors()),this.successCalls.forEach(s=>s.clearErrors()),this.errorCalls.forEach(s=>s.clearErrors()),this.internalCalls.forEach(s=>s.clearErrors()),(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this}validate(){return this.errors=GLe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await BLe(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.inputs.flatMap(c=>c.getErrors()),...this.internalCalls.flatMap(c=>c.getErrors()),...this.outputs.flatMap(c=>c.getErrors())]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.inputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.internalCalls){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,j,F,q,X;const e=Vr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Ki(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=(L=this.dataType)==null?void 0:L.clone(i,v,x.UUID.uuid(),c);v.setDataType(E||null,i);const b=(j=this.defaultValue)==null?void 0:j.clone(i,v,x.UUID.uuid(),c);v.setDefaultValue(b||null,i);const w=(F=this.inputs)==null?void 0:F.map(ae=>ae.clone(i,v,x.UUID.uuid(),c));v.inputs=w;const P=(q=this.outputs)==null?void 0:q.map(ae=>ae.clone(i,v,x.UUID.uuid(),c));v.outputs=P;const $=(X=this.internalCalls)==null?void 0:X.map(ae=>ae.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=$,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}createInstance(i=this.project,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"create-instance")),s={}){const c={id:s.id||x.UUID.uuid(),version:s.version||x.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,parent:i.toReference(),catchesError:s.catchesError||!1,defaultValue:s.defaultValue||null,successCalls:s.successCalls||[],errorCalls:s.errorCalls||[],inputs:s.inputs||[],outputs:s.outputs||[],writesValues:s.writesValues||[],internalCalls:s.internalCalls||[],readsValue:s.readsValue||null,calledByEntry:s.calledByEntry||[],calledBySuccess:s.calledBySuccess||[],calledByError:s.calledByError||[],error:s.error||null,declaration:this.toReference(),x:0,y:0},e=he(c,this.project);return e.hydrateAncestors(),e.setParent(i,n),n==null||n.add(e,H.Added),e.addSelfToProject(n),e.initChildren(n),i===this.project&&this.project.addVariableInstance(e),n==null||n.attemptAutoclose("create-instance",this.id),e}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){var m;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(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.inputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.inputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}if(!sA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.inputs.filter((v,E)=>{const b=this.inputs.findIndex(P=>P.declaration===v.declaration&&P!==v);if(b===-1)return!1;const w=this.inputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-outputs"))){var m;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.outputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.outputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>{var P;return((P=E.declaration)==null?void 0:P.id)===(w==null?void 0:w.id)})){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!sA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.outputs.filter((v,E)=>{const b=this.outputs.findIndex(P=>P.declaration===v.declaration&&P!==v);if(b===-1)return!1;const w=this.outputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.dataType||!this.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.dataType&&this.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const m=[...this.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,P;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((P=b.extends)==null?void 0:P.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-declaration-inputs"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties];y.filter(b=>!b.getDataType(i)).forEach(b=>{const w=this.inputs.find(L=>se(L,this.project)===se(b,this.project));if(!w)return;const P=this.getMasterInputWithValueWritterFromAllInstances(w);if(!P)return;const $=Oo(P);b.setDataType($,i),w.setDeclaration(b,i)}),y.filter(b=>bV(b)?!this.inputs.find(w=>{var P;return((P=w.declaration)==null?void 0:P.id)===b.id}):!1).forEach(b=>{const w={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().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:b,defaultValue:null,index:b.index,readsValue:null},P=he(w,this.project);return P.hydrateAncestors(),i==null||i.add(P,H.Added),P.setParent(this,i),P.initChildren(i),this.addInput(P,i),P}),this.inputs.filter(b=>!b.declaration).forEach(b=>{const w=y.find(P=>se(P,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)})}}else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties],m=y.filter(v=>!this.outputs.find(E=>{var b;return((b=E.declaration)==null?void 0:b.id)===(v==null?void 0:v.id)}));this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&(console.log("Unused properties for variable declaration:",m.map(v=>`${v.id} -- ${v.name}`)),console.log("Existing outputs:",this.outputs.map(v=>{var E;return`${(E=v.declaration)==null?void 0:E.id} -- ${v.declaration?v.declaration.name:"no-declaration"}`})),console.log("All properties:",y.map(v=>`${v.id} -- ${v.name}`)),console.log("Data type inferred:",this.dataType.inferred)),m.map(v=>{const E={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:v==null?void 0:v.toJSON(),index:v.index,writesValues:[]};if(this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2")throw console.log("Creating output for property:",v),new Error("[VariableDeclarationState.syncOutputs] Creating new output from property");const b=he(E,this.project);return b.hydrateAncestors(),i==null||i.add(b,H.Added),b.setParent(this,i),b.initChildren(i),this.addOutput(b,i),b}),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Final outputs:",this.outputs.map(v=>{var E;return`${(E=v.declaration)==null?void 0:E.id} -- ${v.declaration?v.declaration.name:"no-declaration"}`}))}}else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const y=[...this.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,P;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((P=b.extends)==null?void 0:P.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,j,F,q;return((($=w.declaration)==null?void 0:$.id)||((j=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:j.entityId)||((q=(F=w.initialData)==null?void 0:F.declaration)==null?void 0:q.id))===E.id})).forEach(E=>{var w;const b=this.internalCalls.find(P=>{const $=_c(P.declaration),L=_c(E);return $.id===L.id});if(b&&((w=b.declaration)==null?void 0:w.id)!==E.id)b.setDeclaration(E);else{const P=E.createInternalCall(i,this);i==null||i.add(P,H.Added),this.addInternalCall(P)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.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(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){return(!this.dataType||this.dataType.inferred)&&this.project.initialized&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(i),i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(hi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(hi,"type",d.VariableDeclaration),I(hi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(hi,"PARENT_TYPES",[...hi.USER_MANAGED_PARENT_TYPES]),I(hi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","constant","required","catchesError"]),I(hi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(hi,"BASE_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"MUTABLE_META_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(hi,"INMUTABLE_META_PROPERTIES",[...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"META_PROPERTIES",[...hi.MUTABLE_META_PROPERTIES,...hi.INMUTABLE_META_PROPERTIES]),I(hi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(hi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(hi,"UPSTREAM_PROPERTIES",[...hi.MUTABLE_UPSTREAM_PROPERTIES,...hi.INMUTABLE_UPSTREAM_PROPERTIES]),I(hi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(hi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(hi,"DOWNSTREAM_PROPERTIES",[...hi.MUTABLE_DOWNSTREAM_PROPERTIES,...hi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(hi,"PROPERTIES",[...hi.META_PROPERTIES,...hi.UPSTREAM_PROPERTIES,...hi.DOWNSTREAM_PROPERTIES]);let Mu=hi;async function KLe(o,p={}){var y,m;const i=J.YieldTracker.from(p),n=ia(o),s=ra(o),c=[...n,...s],e=Mt(o.errors,c);await i.tick();for(const v of o.inputsDeclarations)await v.validateAsync({tracker:i});for(const v of o.inputs)await v.validateAsync({tracker:i});for(const v of o.outputs)await v.validateAsync({tracker:i});return await((y=o.error)==null?void 0:y.validateAsync({tracker:i})),await((m=o.dataType)==null?void 0:m.validateAsync({tracker:i})),e}function FLe(o){var n,s;o.inputsDeclarations.forEach(c=>c.validate()),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),(n=o.error)==null||n.validate(),(s=o.dataType)==null||s.validate();const i=[...ia(o),...ra(o)];return Mt(o.errors,i)}const iAi=Object.freeze(Object.defineProperty({__proto__:null,validate:FLe,validateAsync:KLe},Symbol.toStringTag,{value:"Module"}));var Dy={},SLe={},qLe={};Object.defineProperty(qLe,"__esModule",{value:!0});var ZLe={};Object.defineProperty(ZLe,"__esModule",{value:!0});var HLe={};Object.defineProperty(HLe,"__esModule",{value:!0});var WLe={};Object.defineProperty(WLe,"__esModule",{value:!0});var zLe={};Object.defineProperty(zLe,"__esModule",{value:!0});var JLe={};Object.defineProperty(JLe,"__esModule",{value:!0});var YLe={};Object.defineProperty(YLe,"__esModule",{value:!0});var XLe={};Object.defineProperty(XLe,"__esModule",{value:!0});var QLe={};Object.defineProperty(QLe,"__esModule",{value:!0});var e2e={};Object.defineProperty(e2e,"__esModule",{value:!0});var t2e={};Object.defineProperty(t2e,"__esModule",{value:!0});var i2e={};Object.defineProperty(i2e,"__esModule",{value:!0});var r2e={};Object.defineProperty(r2e,"__esModule",{value:!0});var n2e={};Object.defineProperty(n2e,"__esModule",{value:!0});var a2e={};Object.defineProperty(a2e,"__esModule",{value:!0});var s2e={};Object.defineProperty(s2e,"__esModule",{value:!0});var l2e={};Object.defineProperty(l2e,"__esModule",{value:!0});var o2e={};Object.defineProperty(o2e,"__esModule",{value:!0});var d2e={};Object.defineProperty(d2e,"__esModule",{value:!0});var u2e={};Object.defineProperty(u2e,"__esModule",{value:!0});var p2e={};Object.defineProperty(p2e,"__esModule",{value:!0});var c2e={};Object.defineProperty(c2e,"__esModule",{value:!0});var f2e={};Object.defineProperty(f2e,"__esModule",{value:!0});var y2e={};Object.defineProperty(y2e,"__esModule",{value:!0});var h2e={};Object.defineProperty(h2e,"__esModule",{value:!0});var m2e={};Object.defineProperty(m2e,"__esModule",{value:!0});var T2e={};Object.defineProperty(T2e,"__esModule",{value:!0});var v2e={};Object.defineProperty(v2e,"__esModule",{value:!0});var E2e={};Object.defineProperty(E2e,"__esModule",{value:!0});var b2e={};Object.defineProperty(b2e,"__esModule",{value:!0});var A2e={};Object.defineProperty(A2e,"__esModule",{value:!0});var g2e={};Object.defineProperty(g2e,"__esModule",{value:!0});var I2e={};Object.defineProperty(I2e,"__esModule",{value:!0});var R2e={};Object.defineProperty(R2e,"__esModule",{value:!0});var D2e={};Object.defineProperty(D2e,"__esModule",{value:!0});var w2e={};Object.defineProperty(w2e,"__esModule",{value:!0});var O2e={};Object.defineProperty(O2e,"__esModule",{value:!0});var C2e={};Object.defineProperty(C2e,"__esModule",{value:!0});var _2e={};Object.defineProperty(_2e,"__esModule",{value:!0});var P2e={};Object.defineProperty(P2e,"__esModule",{value:!0});var V2e={};Object.defineProperty(V2e,"__esModule",{value:!0});var N2e={};Object.defineProperty(N2e,"__esModule",{value:!0});var x2e={};Object.defineProperty(x2e,"__esModule",{value:!0});(function(o){var p=Pr&&Pr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Pr&&Pr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(qLe,o),i(ZLe,o),i(HLe,o),i(WLe,o),i(zLe,o),i(JLe,o),i(YLe,o),i(XLe,o),i(QLe,o),i(e2e,o),i(t2e,o),i(i2e,o),i(r2e,o),i(n2e,o),i(a2e,o),i(s2e,o),i(l2e,o),i(o2e,o),i(d2e,o),i(u2e,o),i(p2e,o),i(c2e,o),i(f2e,o),i(y2e,o),i(h2e,o),i(m2e,o),i(T2e,o),i(v2e,o),i(E2e,o),i(b2e,o),i(A2e,o),i(g2e,o),i(I2e,o),i(R2e,o),i(D2e,o),i(w2e,o),i(O2e,o),i(C2e,o),i(_2e,o),i(P2e,o),i(V2e,o),i(N2e,o),i(x2e,o)})(SLe);var $2e={},aa={};Object.defineProperty(aa,"__esModule",{value:!0});aa.isObject=aa.isString=aa.isDefined=aa.last=aa.identity=void 0;const rAi=o=>o;aa.identity=rAi;const nAi=o=>o[o.length-1];aa.last=nAi;const aAi=o=>o!==void 0;aa.isDefined=aAi;const sAi=o=>typeof o=="string";aa.isString=sAi;const lAi=o=>typeof o=="object"&&o!==null&&!(o instanceof Array);aa.isObject=lAi;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.cstVisitor=o.VisitorAction=void 0;const p=aa;var i;(function(c){c[c.SKIP=1]="SKIP"})(i=o.VisitorAction||(o.VisitorAction={}));function n(c){const e=y=>{const m=c[y.type];if((m==null?void 0:m(y))!==i.SKIP)for(const E of Object.values(y))s(E)?e(E):E instanceof Array&&E.filter(s).forEach(b=>e(b))};return e}o.cstVisitor=n;const s=c=>(0,p.isObject)(c)&&(0,p.isString)(c.type)})($2e);var uv={};Object.defineProperty(uv,"__esModule",{value:!0});uv.cstTransformer=void 0;function oAi(o){return p=>{const i=o[p.type];if(!i)throw p.type?new Error(`No transform map entry for ${p.type}`):new Error(`No type field on node: ${JSON.stringify(p)}`);return i(p)}}uv.cstTransformer=oAi;var L2e={},pv={};Object.defineProperty(pv,"__esModule",{value:!0});pv.bigqueryKeywords=void 0;pv.bigqueryKeywords={ALL:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASSERT_ROWS_MODIFIED:!0,AT:!0,BETWEEN:!0,BY:!0,CASE:!0,CAST:!0,COLLATE:!0,CONTAINS:!0,CREATE:!0,CROSS:!0,CUBE:!0,CURRENT:!0,DEFAULT:!0,DEFINE:!0,DESC:!0,DISTINCT:!0,ELSE:!0,END:!0,ENUM:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXISTS:!0,EXTRACT:!0,FALSE:!0,FETCH:!0,FOLLOWING:!0,FOR:!0,FROM:!0,FULL:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HASH:!0,HAVING:!0,IF:!0,IGNORE:!0,IN:!0,INNER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,JOIN:!0,LATERAL:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOOKUP:!0,MERGE:!0,NATURAL:!0,NEW:!0,NO:!0,NOT:!0,NULL:!0,NULLS:!0,OF:!0,ON:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,PARTITION:!0,PRECEDING:!0,PROTO:!0,QUALIFY:!0,RANGE:!0,RECURSIVE:!0,RESPECT:!0,RIGHT:!0,ROLLUP:!0,ROWS:!0,SELECT:!0,SET:!0,SOME:!0,STRUCT:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TREAT:!0,TRUE:!0,UNBOUNDED:!0,UNION:!0,UNNEST:!0,USING:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0};var cv={};Object.defineProperty(cv,"__esModule",{value:!0});cv.mariadbKeywords=void 0;cv.mariadbKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DELETE_DOMAIN_ID:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DO_DOMAIN_IDS:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,GENERAL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IGNORE_DOMAIN_IDS:!0,IGNORE_SERVER_IDS:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,ITERATE:!0,JOIN:!0,KEY:!0,KEYS:!0,KILL:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_HEARTBEAT_PERIOD:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NULL:!0,NUMERIC:!0,OFFSET:!0,ON:!0,OPTIMIZE:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PAGE_CHECKSUM:!0,PARSE_VCOL_EXPR:!0,PARTITION:!0,POSITION:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REF_SYSTEM_ID:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,RETURNING:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROWS:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SLOW:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STATS_AUTO_RECALC:!0,STATS_PERSISTENT:!0,STATS_SAMPLE_PAGES:!0,STRAIGHT_JOIN:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var fv={};Object.defineProperty(fv,"__esModule",{value:!0});fv.mysqlKeywords=void 0;fv.mysqlKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CUBE:!0,CUME_DIST:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DENSE_RANK:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,EMPTY:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FIRST_VALUE:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,FUNCTION:!0,GENERATED:!0,GET:!0,GRANT:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IO_AFTER_GTIDS:!0,IO_BEFORE_GTIDS:!0,IS:!0,ITERATE:!0,JOIN:!0,JSON_TABLE:!0,KEY:!0,KEYS:!0,KILL:!0,LAG:!0,LAST_VALUE:!0,LATERAL:!0,LEAD:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_BIND:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NTH_VALUE:!0,NTILE:!0,NULL:!0,NUMERIC:!0,OF:!0,ON:!0,OPTIMIZE:!0,OPTIMIZER_COSTS:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PARTITION:!0,PERCENT_RANK:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,RANK:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROW:!0,ROWS:!0,ROW_NUMBER:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STORED:!0,STRAIGHT_JOIN:!0,SYSTEM:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var yv={};Object.defineProperty(yv,"__esModule",{value:!0});yv.sqliteKeywords=void 0;yv.sqliteKeywords={ABORT:!0,ACTION:!0,ADD:!0,AFTER:!0,ALL:!0,ALTER:!0,ALWAYS:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ATTACH:!0,AUTOINCREMENT:!0,BEFORE:!0,BEGIN:!0,BETWEEN:!0,BY:!0,CASCADE:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COMMIT:!0,CONFLICT:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,DATABASE:!0,DEFAULT:!0,DEFERRABLE:!0,DEFERRED:!0,DELETE:!0,DESC:!0,DETACH:!0,DISTINCT:!0,DO:!0,DROP:!0,EACH:!0,ELSE:!0,END:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXCLUSIVE:!0,EXISTS:!0,EXPLAIN:!0,FAIL:!0,FILTER:!0,FIRST:!0,FOLLOWING:!0,FOR:!0,FOREIGN:!0,FROM:!0,FULL:!0,GENERATED:!0,GLOB:!0,GROUP:!0,GROUPS:!0,HAVING:!0,IF:!0,IGNORE:!0,IMMEDIATE:!0,IN:!0,INDEX:!0,INDEXED:!0,INITIALLY:!0,INNER:!0,INSERT:!0,INSTEAD:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LAST:!0,LEFT:!0,LIKE:!0,LIMIT:!0,MATCH:!0,MATERIALIZED:!0,NATURAL:!0,NO:!0,NOT:!0,NOTHING:!0,NOTNULL:!0,NULL:!0,NULLS:!0,OF:!0,OFFSET:!0,ON:!0,OR:!0,ORDER:!0,OTHERS:!0,OUTER:!0,OVER:!0,PARTITION:!0,PLAN:!0,PRAGMA:!0,PRECEDING:!0,PRIMARY:!0,QUERY:!0,RAISE:!0,RANGE:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,REINDEX:!0,RELEASE:!0,RENAME:!0,REPLACE:!0,RESTRICT:!0,RETURNING:!0,RIGHT:!0,ROLLBACK:!0,ROW:!0,ROWS:!0,SAVEPOINT:!0,SELECT:!0,SET:!0,TABLE:!0,TEMP:!0,TEMPORARY:!0,THEN:!0,TIES:!0,TO:!0,TRANSACTION:!0,TRIGGER:!0,UNBOUNDED:!0,UNION:!0,UNIQUE:!0,UPDATE:!0,USING:!0,VACUUM:!0,VALUES:!0,VIEW:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHOUT:!0};var hv={};Object.defineProperty(hv,"__esModule",{value:!0});hv.postgresqlKeywords=void 0;hv.postgresqlKeywords={ALL:!0,ANALYSE:!0,ANALYZE:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASYMMETRIC:!0,AUTHORIZATION:!0,BOTH:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT_CATALOG:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_SCHEMA:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,DAY:!0,DEFAULT:!0,DEFERRABLE:!0,DESC:!0,DISTINCT:!0,DO:!0,ELSE:!0,END:!0,EXCEPT:!0,FALSE:!0,FETCH:!0,FILTER:!0,FOR:!0,FOREIGN:!0,FREEZE:!0,FROM:!0,FULL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HOUR:!0,ILIKE:!0,IN:!0,INITIALLY:!0,INNER:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LATERAL:!0,LEADING:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,MINUTE:!0,MONTH:!0,NATURAL:!0,NOT:!0,NOTNULL:!0,NULL:!0,OFFSET:!0,ON:!0,ONLY:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,OVERLAPS:!0,PLACING:!0,PRECISION:!0,PRIMARY:!0,REFERENCES:!0,RETURNING:!0,RIGHT:!0,SECOND:!0,SELECT:!0,SESSION_USER:!0,SIMILAR:!0,SOME:!0,SYMMETRIC:!0,SYSTEM_USER:!0,TABLE:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TRAILING:!0,TRUE:!0,UNION:!0,UNIQUE:!0,USER:!0,USING:!0,VARIADIC:!0,VARYING:!0,VERBOSE:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0,WITHOUT:!0,YEAR:!0,SET:!0};(function(o){var p=Pr&&Pr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Pr&&Pr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(pv,o),i(cv,o),i(fv,o),i(yv,o),i(hv,o)})(L2e);var qm={};Object.defineProperty(qm,"__esModule",{value:!0});qm.FormattedSyntaxError=void 0;class dAi extends Error{constructor(p,i,n){super(uAi(p,i,n))}}qm.FormattedSyntaxError=dAi;function uAi(o,p,i){const n=o.location.start.line,s=o.location.start.column,c=p.split(/\r\n|\n|\r/)[n-1],e="".padStart(String(n).length),y=cAi(pAi(o.found,s,c)),m=fAi(o.expected);return`Syntax Error: Unexpected ${y}
|
|
98
|
+
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}subscribeToDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new hi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,P]of b.knownVersions)v.set(w,P);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new hi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=re(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=re(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>re(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>re(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>re(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.dataType){const s=re(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=re(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=re(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>re(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=re(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=re(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred){const{added:xe,updated:Me,removed:Se,affected:je}=this.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...xe),n.push(...Me),c.push(...Se),e.push(...je)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:P,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...P),e.push(...$);const{added:L,updated:j,removed:F,affected:q}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...j),c.push(...F),e.push(...q);const{added:X,updated:ae,removed:ee,affected:fe}=this.removeUnrecognizedInputs(i);s.push(...X),n.push(...ae),c.push(...ee),e.push(...fe);const{added:oe,updated:ce,removed:Te,affected:de}=this.removeUnrecognizedOutputs(i);s.push(...oe),n.push(...ce),c.push(...Te),e.push(...de);const{added:ye,updated:_e,removed:Pe,affected:Ge}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(..._e),c.push(...Pe),e.push(...Ge),this.parent===this.project&&(this.catchesError&&(i==null||i.event({id:`${_.RemoveErrorCatching}-${this.id}`,action:_.RemoveErrorCatching,owner:this,errorReason:rr.GlobalVariableDeclarationCannnotCatchError,rootAction:!1}),this.metaSync({catchesError:!1},i)),this.errorCalls.length&&(i==null||i.event({id:`${_.RemoveAllErrorCalls}-${this.id}`,action:_.RemoveAllErrorCalls,owner:this,errorReason:rr.GlobalVariableDeclarationCannotCallFromError,rootAction:!1}),[...this.errorCalls].forEach(xe=>{this.removeCall(xe,i),xe.removeCaller(this,i)})),this.calledBy.length&&(i==null||i.event({id:`${_.RemoveAllCallers}-${this.id}`,action:_.RemoveAllCallers,owner:this,errorReason:rr.GlobalVariableDeclarationCannotBeCalled,rootAction:!1}),[...this.calledBy].forEach(xe=>{this.removeCaller(xe,i),xe.removeCall(this,i)}))),this.inputs.sort((xe,Me)=>{var Se,je;return(xe.index??((Se=xe.declaration)==null?void 0:Se.index))-(Me.index??((je=Me.declaration)==null?void 0:je.index))}),this.outputs.sort((xe,Me)=>{var Se,je;return(xe.index??((Se=xe.declaration)==null?void 0:Se.index))-(Me.index??((je=Me.declaration)==null?void 0:je.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(i=>!i.calledBy.length)}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-declaration-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-declaration-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n)?this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this):this}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=he(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const n=he(this.initialData.dataType,this.project);this.setDataType(n,i),this.dataType.setParent(this,null),this.dataType.initChildren(i)}return _v.initWritesValues(this,this.parent),af.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(n=>{const s=he(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=rn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=he(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=rn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.initialData.inputs.forEach(n=>{const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,null),s}),this.initialData.internalCalls.forEach(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(n);if(!c)return;c.setParent(this,null),c.initChildren(i),this.addInternalCall(c);return}const s=he(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInternalCall(s),s}),this.initialData.error&&(this.error=he(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.inputs,...this.variableInstances.flatMap(c=>c.inputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}inferDataTypeAndSyncInstancesInputsAndOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"infer-data-type-and-sync-instances-inputs-and-outputs"))){var F,q,X,ae,ee,fe,oe;const n=[],s=[],c=[],e=[];if(!this.dataType){const ce=ir.new(i);ce.parent=this.toReference(),ce.inferred=!0;const Te=he(ce,this.project);Te.hydrateAncestors(),Te.addSelfToProject(i),this.setDataType(Te,i),Te.setParent(this,i),Te.initChildren(i),i==null||i.add(Te,H.Added),Te.metaSync({inferred:!0,like:!0},i)}if(this.readsValue&&((F=this.dataType)!=null&&F.inferred)){const ce=this.readsValue.getDataType(null);ce&&((q=this.dataType)==null||q.merge(ce,i),this.dataType.metaSync({inferred:!0,like:!0},i))}const y=D([...this.inputs,...this.variableInstances.flatMap(ce=>ce.inputs)]),m=[];if(y.forEach(ce=>{m.find(de=>se(de,this.project)===se(ce,this.project))||m.push(ce)}),(!((X=this.dataType)!=null&&X.entity)||((ee=(ae=this.dataType)==null?void 0:ae.entity)==null?void 0:ee.type)===d.DefinitionEntity&&((fe=this.dataType)==null?void 0:fe.entity.parent)===this.dataType)&&((oe=this.dataType)==null||oe.inferFromInputs(m,i)),!this.dataType)return i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this};const{updated:v,added:E,removed:b,affected:w}=this.syncInputs(i);n.push(...E),s.push(...v),c.push(...b),e.push(...w);const{updated:P,added:$,removed:L,affected:j}=this.syncOutputs(i);return n.push(...$),s.push(...P),c.push(...L),e.push(...j),this.variableInstances.forEach(ce=>{const{updated:Te,added:de,removed:ye,affected:_e}=ce.syncInputs(i);n.push(...de),s.push(...Te),c.push(...ye),e.push(..._e);const{updated:Pe,added:Ge,removed:xe,affected:Me}=ce.syncOutputs(i);n.push(...Ge),s.push(...Pe),c.push(...xe),e.push(...Me)}),i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this}}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Lr(this,i,n),c=$r(this,s),e=this.toMeta();return this.name=s.name!==void 0?s.name:e.name,this.codeName=s.codeName!==void 0?s.codeName:e.codeName,this.description=s.description!==void 0?s.description:e.description,this.x=s.x||e.x,this.y=s.y||e.y,this.constant=s.constant!==void 0?s.constant:e.constant,this.required=s.required!==void 0?s.required:e.required,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await hi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await hi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await hi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await hi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await hi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await hi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableDeclaration(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:rr.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.dataType){const{updated:v,removed:E}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...((c=this.dataType)==null?void 0:c.toFlat(i))||[],...((e=this.readsValue)==null?void 0:e.toFlat(i))||[],...this.writesValues.flatMap(y=>y.toFlat(i)),...this.successCalls.flatMap(y=>y.toFlat(i)),...this.errorCalls.flatMap(y=>y.toFlat(i)),...this.inputs.flatMap(y=>y.toFlat(i)),...this.outputs.flatMap(y=>y.toFlat(i)),...this.internalCalls.flatMap(y=>y.toFlat(i)),...this.calledBy.flatMap(y=>y.toFlat(i)),...this.variableInstances.flatMap(y=>y.toFlat(i))])}toFlatIds(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...((c=this.dataType)==null?void 0:c.toFlatIds(i))||[],...this.writesValues.flatMap(e=>e.toFlatIds(i)),...this.successCalls.flatMap(e=>e.toFlatIds(i)),...this.errorCalls.flatMap(e=>e.toFlatIds(i)),...this.inputs.flatMap(e=>e.toFlatIds(i)),...this.outputs.flatMap(e=>e.toFlatIds(i)),...this.internalCalls.flatMap(e=>e.toFlatIds(i)),...this.variableInstances.flatMap(e=>e.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,catchesError:this.catchesError,description:this.description,required:this.required,constant:this.constant,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,c,e;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,name:this.name,codeName:this.codeName,description:this.description,catchesError:this.catchesError,constant:this.constant,required:this.required,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,writesValues:this.writesValues.map(y=>y.toJSON(i)),inputs:this.inputs.map(y=>y.toJSON(i)),outputs:this.outputs.map(y=>y.toJSON(i)),successCalls:this.successCalls.map(y=>y.toJSON(i)),errorCalls:this.errorCalls.map(y=>y.toJSON(i)),internalCalls:this.internalCalls.map(y=>y.toJSON(i)),calledBySuccess:this.calledBySuccess.map(y=>y.toReference()),calledByError:this.calledByError.map(y=>y.toReference()),calledByEntry:this.calledByEntry.map(y=>y.toReference()),error:((e=this.error)==null?void 0:e.toJSON(i))||null,parent:this.parent.toReference(),x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,codeName:this.codeName,constant:this.constant,required:this.required,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,catchesError:this.catchesError,defaultValue:((v=this.defaultValue)==null?void 0:v.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,writesValues:this.writesValues.map(P=>P.toJSONClone({...i,newId:null})),inputs:this.inputs.map(P=>P.toJSONClone({...i,newId:null})),outputs:this.outputs.map(P=>P.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(P=>P.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(P=>P.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(P=>this.calledBy.length||this.readsValue?P.toJSONClone({...i,newId:null}):P.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(P=>P.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(P=>P.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(P=>P.toReference({seenEntityMaps:i.seenEntityMaps})),error:((w=this.error)==null?void 0:w.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,catchesError:this.catchesError,required:this.required,constant:this.constant,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:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(e=>e.toFlatGenerationTarget(i)),...this.successCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.inputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,n;return this.errors=[],this.inputs.forEach(s=>s.clearErrors()),this.outputs.forEach(s=>s.clearErrors()),this.successCalls.forEach(s=>s.clearErrors()),this.errorCalls.forEach(s=>s.clearErrors()),this.internalCalls.forEach(s=>s.clearErrors()),(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this}validate(){return this.errors=GLe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await BLe(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.inputs.flatMap(c=>c.getErrors()),...this.internalCalls.flatMap(c=>c.getErrors()),...this.outputs.flatMap(c=>c.getErrors())]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.inputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.internalCalls){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,j,F,q,X;const e=Vr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Ki(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=(L=this.dataType)==null?void 0:L.clone(i,v,x.UUID.uuid(),c);v.setDataType(E||null,i);const b=(j=this.defaultValue)==null?void 0:j.clone(i,v,x.UUID.uuid(),c);v.setDefaultValue(b||null,i);const w=(F=this.inputs)==null?void 0:F.map(ae=>ae.clone(i,v,x.UUID.uuid(),c));v.inputs=w;const P=(q=this.outputs)==null?void 0:q.map(ae=>ae.clone(i,v,x.UUID.uuid(),c));v.outputs=P;const $=(X=this.internalCalls)==null?void 0:X.map(ae=>ae.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=$,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}createInstance(i=this.project,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"create-instance")),s={}){const c={id:s.id||x.UUID.uuid(),version:s.version||x.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,parent:i.toReference(),catchesError:s.catchesError||!1,defaultValue:s.defaultValue||null,successCalls:s.successCalls||[],errorCalls:s.errorCalls||[],inputs:s.inputs||[],outputs:s.outputs||[],writesValues:s.writesValues||[],internalCalls:s.internalCalls||[],readsValue:s.readsValue||null,calledByEntry:s.calledByEntry||[],calledBySuccess:s.calledBySuccess||[],calledByError:s.calledByError||[],error:s.error||null,declaration:this.toReference(),x:0,y:0},e=he(c,this.project);return e.hydrateAncestors(),e.setParent(i,n),n==null||n.add(e,H.Added),e.addSelfToProject(n),e.initChildren(n),i===this.project&&this.project.addVariableInstance(e),n==null||n.attemptAutoclose("create-instance",this.id),e}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){var m;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(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.inputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.inputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}if(!sA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.inputs.filter((v,E)=>{const b=this.inputs.findIndex(P=>P.declaration===v.declaration&&P!==v);if(b===-1)return!1;const w=this.inputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-outputs"))){var m;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.outputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.outputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>{var P;return((P=E.declaration)==null?void 0:P.id)===(w==null?void 0:w.id)})){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!sA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.outputs.filter((v,E)=>{const b=this.outputs.findIndex(P=>P.declaration===v.declaration&&P!==v);if(b===-1)return!1;const w=this.outputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.dataType||!this.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.dataType&&this.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const m=[...this.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,P;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((P=b.extends)==null?void 0:P.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-declaration-inputs"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties];y.filter(b=>!b.getDataType(i)).forEach(b=>{const w=this.inputs.find(L=>se(L,this.project)===se(b,this.project));if(!w)return;const P=this.getMasterInputWithValueWritterFromAllInstances(w);if(!P)return;const $=Oo(P);b.setDataType($,i),w.setDeclaration(b,i)}),y.filter(b=>bV(b)?!this.inputs.find(w=>{var P;return((P=w.declaration)==null?void 0:P.id)===b.id}):!1).forEach(b=>{const w={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().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:b,defaultValue:null,index:b.index,readsValue:null},P=he(w,this.project);return P.hydrateAncestors(),i==null||i.add(P,H.Added),P.setParent(this,i),P.initChildren(i),this.addInput(P,i),P}),this.inputs.filter(b=>!b.declaration).forEach(b=>{const w=y.find(P=>se(P,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)})}}else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("[syncOutputs] Starting syncOutputs for variable declaration"),!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties],m=y.filter(v=>!this.outputs.find(E=>{var b;return((b=E.declaration)==null?void 0:b.id)===(v==null?void 0:v.id)}));this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&(console.log("Unused properties for variable declaration:",m.map(v=>`${v.id} -- ${v.name}`)),console.log("Existing outputs:",this.outputs.map(v=>{var E;return`${(E=v.declaration)==null?void 0:E.id} -- ${v.declaration?v.declaration.name:"no-declaration"}`})),console.log("All properties:",y.map(v=>`${v.id} -- ${v.name}`)),console.log("Data type inferred:",this.dataType.inferred)),m.map(v=>{const E={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:v==null?void 0:v.toJSON(),index:v.index,writesValues:[]};if(this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2")throw console.log("Creating output for property:",v),new Error("[VariableDeclarationState.syncOutputs] Creating new output from property");const b=he(E,this.project);return this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Created output for property:",b),b.hydrateAncestors(),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Hydrated output for property:",b),i==null||i.add(b,H.Added),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Registered output in cs:",b),b.setParent(this,i),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Set parent, of output for property:",b),b.initChildren(i),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Initialized output for property:",b),this.addOutput(b,i),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Added output for property to parent:",b),b}),this.id==="0f7ef123-9320-4a91-9bb6-32f4e77e52f2"&&console.log("Final outputs:",this.outputs.map(v=>{var E;return`${(E=v.declaration)==null?void 0:E.id} -- ${v.declaration?v.declaration.name:"no-declaration"}`}))}}else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const y=[...this.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,P;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((P=b.extends)==null?void 0:P.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,j,F,q;return((($=w.declaration)==null?void 0:$.id)||((j=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:j.entityId)||((q=(F=w.initialData)==null?void 0:F.declaration)==null?void 0:q.id))===E.id})).forEach(E=>{var w;const b=this.internalCalls.find(P=>{const $=_c(P.declaration),L=_c(E);return $.id===L.id});if(b&&((w=b.declaration)==null?void 0:w.id)!==E.id)b.setDeclaration(E);else{const P=E.createInternalCall(i,this);i==null||i.add(P,H.Added),this.addInternalCall(P)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.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(_.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(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){return(!this.dataType||this.dataType.inferred)&&this.project.initialized&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(i),i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(hi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(hi,"type",d.VariableDeclaration),I(hi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(hi,"PARENT_TYPES",[...hi.USER_MANAGED_PARENT_TYPES]),I(hi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","constant","required","catchesError"]),I(hi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(hi,"BASE_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"MUTABLE_META_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(hi,"INMUTABLE_META_PROPERTIES",[...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"META_PROPERTIES",[...hi.MUTABLE_META_PROPERTIES,...hi.INMUTABLE_META_PROPERTIES]),I(hi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(hi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(hi,"UPSTREAM_PROPERTIES",[...hi.MUTABLE_UPSTREAM_PROPERTIES,...hi.INMUTABLE_UPSTREAM_PROPERTIES]),I(hi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(hi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(hi,"DOWNSTREAM_PROPERTIES",[...hi.MUTABLE_DOWNSTREAM_PROPERTIES,...hi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(hi,"PROPERTIES",[...hi.META_PROPERTIES,...hi.UPSTREAM_PROPERTIES,...hi.DOWNSTREAM_PROPERTIES]);let Mu=hi;async function KLe(o,p={}){var y,m;const i=J.YieldTracker.from(p),n=ia(o),s=ra(o),c=[...n,...s],e=Mt(o.errors,c);await i.tick();for(const v of o.inputsDeclarations)await v.validateAsync({tracker:i});for(const v of o.inputs)await v.validateAsync({tracker:i});for(const v of o.outputs)await v.validateAsync({tracker:i});return await((y=o.error)==null?void 0:y.validateAsync({tracker:i})),await((m=o.dataType)==null?void 0:m.validateAsync({tracker:i})),e}function FLe(o){var n,s;o.inputsDeclarations.forEach(c=>c.validate()),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),(n=o.error)==null||n.validate(),(s=o.dataType)==null||s.validate();const i=[...ia(o),...ra(o)];return Mt(o.errors,i)}const iAi=Object.freeze(Object.defineProperty({__proto__:null,validate:FLe,validateAsync:KLe},Symbol.toStringTag,{value:"Module"}));var Dy={},SLe={},qLe={};Object.defineProperty(qLe,"__esModule",{value:!0});var ZLe={};Object.defineProperty(ZLe,"__esModule",{value:!0});var HLe={};Object.defineProperty(HLe,"__esModule",{value:!0});var WLe={};Object.defineProperty(WLe,"__esModule",{value:!0});var zLe={};Object.defineProperty(zLe,"__esModule",{value:!0});var JLe={};Object.defineProperty(JLe,"__esModule",{value:!0});var YLe={};Object.defineProperty(YLe,"__esModule",{value:!0});var XLe={};Object.defineProperty(XLe,"__esModule",{value:!0});var QLe={};Object.defineProperty(QLe,"__esModule",{value:!0});var e2e={};Object.defineProperty(e2e,"__esModule",{value:!0});var t2e={};Object.defineProperty(t2e,"__esModule",{value:!0});var i2e={};Object.defineProperty(i2e,"__esModule",{value:!0});var r2e={};Object.defineProperty(r2e,"__esModule",{value:!0});var n2e={};Object.defineProperty(n2e,"__esModule",{value:!0});var a2e={};Object.defineProperty(a2e,"__esModule",{value:!0});var s2e={};Object.defineProperty(s2e,"__esModule",{value:!0});var l2e={};Object.defineProperty(l2e,"__esModule",{value:!0});var o2e={};Object.defineProperty(o2e,"__esModule",{value:!0});var d2e={};Object.defineProperty(d2e,"__esModule",{value:!0});var u2e={};Object.defineProperty(u2e,"__esModule",{value:!0});var p2e={};Object.defineProperty(p2e,"__esModule",{value:!0});var c2e={};Object.defineProperty(c2e,"__esModule",{value:!0});var f2e={};Object.defineProperty(f2e,"__esModule",{value:!0});var y2e={};Object.defineProperty(y2e,"__esModule",{value:!0});var h2e={};Object.defineProperty(h2e,"__esModule",{value:!0});var m2e={};Object.defineProperty(m2e,"__esModule",{value:!0});var T2e={};Object.defineProperty(T2e,"__esModule",{value:!0});var v2e={};Object.defineProperty(v2e,"__esModule",{value:!0});var E2e={};Object.defineProperty(E2e,"__esModule",{value:!0});var b2e={};Object.defineProperty(b2e,"__esModule",{value:!0});var A2e={};Object.defineProperty(A2e,"__esModule",{value:!0});var g2e={};Object.defineProperty(g2e,"__esModule",{value:!0});var I2e={};Object.defineProperty(I2e,"__esModule",{value:!0});var R2e={};Object.defineProperty(R2e,"__esModule",{value:!0});var D2e={};Object.defineProperty(D2e,"__esModule",{value:!0});var w2e={};Object.defineProperty(w2e,"__esModule",{value:!0});var O2e={};Object.defineProperty(O2e,"__esModule",{value:!0});var C2e={};Object.defineProperty(C2e,"__esModule",{value:!0});var _2e={};Object.defineProperty(_2e,"__esModule",{value:!0});var P2e={};Object.defineProperty(P2e,"__esModule",{value:!0});var V2e={};Object.defineProperty(V2e,"__esModule",{value:!0});var N2e={};Object.defineProperty(N2e,"__esModule",{value:!0});var x2e={};Object.defineProperty(x2e,"__esModule",{value:!0});(function(o){var p=Pr&&Pr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Pr&&Pr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(qLe,o),i(ZLe,o),i(HLe,o),i(WLe,o),i(zLe,o),i(JLe,o),i(YLe,o),i(XLe,o),i(QLe,o),i(e2e,o),i(t2e,o),i(i2e,o),i(r2e,o),i(n2e,o),i(a2e,o),i(s2e,o),i(l2e,o),i(o2e,o),i(d2e,o),i(u2e,o),i(p2e,o),i(c2e,o),i(f2e,o),i(y2e,o),i(h2e,o),i(m2e,o),i(T2e,o),i(v2e,o),i(E2e,o),i(b2e,o),i(A2e,o),i(g2e,o),i(I2e,o),i(R2e,o),i(D2e,o),i(w2e,o),i(O2e,o),i(C2e,o),i(_2e,o),i(P2e,o),i(V2e,o),i(N2e,o),i(x2e,o)})(SLe);var $2e={},aa={};Object.defineProperty(aa,"__esModule",{value:!0});aa.isObject=aa.isString=aa.isDefined=aa.last=aa.identity=void 0;const rAi=o=>o;aa.identity=rAi;const nAi=o=>o[o.length-1];aa.last=nAi;const aAi=o=>o!==void 0;aa.isDefined=aAi;const sAi=o=>typeof o=="string";aa.isString=sAi;const lAi=o=>typeof o=="object"&&o!==null&&!(o instanceof Array);aa.isObject=lAi;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.cstVisitor=o.VisitorAction=void 0;const p=aa;var i;(function(c){c[c.SKIP=1]="SKIP"})(i=o.VisitorAction||(o.VisitorAction={}));function n(c){const e=y=>{const m=c[y.type];if((m==null?void 0:m(y))!==i.SKIP)for(const E of Object.values(y))s(E)?e(E):E instanceof Array&&E.filter(s).forEach(b=>e(b))};return e}o.cstVisitor=n;const s=c=>(0,p.isObject)(c)&&(0,p.isString)(c.type)})($2e);var uv={};Object.defineProperty(uv,"__esModule",{value:!0});uv.cstTransformer=void 0;function oAi(o){return p=>{const i=o[p.type];if(!i)throw p.type?new Error(`No transform map entry for ${p.type}`):new Error(`No type field on node: ${JSON.stringify(p)}`);return i(p)}}uv.cstTransformer=oAi;var L2e={},pv={};Object.defineProperty(pv,"__esModule",{value:!0});pv.bigqueryKeywords=void 0;pv.bigqueryKeywords={ALL:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASSERT_ROWS_MODIFIED:!0,AT:!0,BETWEEN:!0,BY:!0,CASE:!0,CAST:!0,COLLATE:!0,CONTAINS:!0,CREATE:!0,CROSS:!0,CUBE:!0,CURRENT:!0,DEFAULT:!0,DEFINE:!0,DESC:!0,DISTINCT:!0,ELSE:!0,END:!0,ENUM:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXISTS:!0,EXTRACT:!0,FALSE:!0,FETCH:!0,FOLLOWING:!0,FOR:!0,FROM:!0,FULL:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HASH:!0,HAVING:!0,IF:!0,IGNORE:!0,IN:!0,INNER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,JOIN:!0,LATERAL:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOOKUP:!0,MERGE:!0,NATURAL:!0,NEW:!0,NO:!0,NOT:!0,NULL:!0,NULLS:!0,OF:!0,ON:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,PARTITION:!0,PRECEDING:!0,PROTO:!0,QUALIFY:!0,RANGE:!0,RECURSIVE:!0,RESPECT:!0,RIGHT:!0,ROLLUP:!0,ROWS:!0,SELECT:!0,SET:!0,SOME:!0,STRUCT:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TREAT:!0,TRUE:!0,UNBOUNDED:!0,UNION:!0,UNNEST:!0,USING:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0};var cv={};Object.defineProperty(cv,"__esModule",{value:!0});cv.mariadbKeywords=void 0;cv.mariadbKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DELETE_DOMAIN_ID:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DO_DOMAIN_IDS:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,GENERAL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IGNORE_DOMAIN_IDS:!0,IGNORE_SERVER_IDS:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,ITERATE:!0,JOIN:!0,KEY:!0,KEYS:!0,KILL:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_HEARTBEAT_PERIOD:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NULL:!0,NUMERIC:!0,OFFSET:!0,ON:!0,OPTIMIZE:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PAGE_CHECKSUM:!0,PARSE_VCOL_EXPR:!0,PARTITION:!0,POSITION:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REF_SYSTEM_ID:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,RETURNING:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROWS:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SLOW:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STATS_AUTO_RECALC:!0,STATS_PERSISTENT:!0,STATS_SAMPLE_PAGES:!0,STRAIGHT_JOIN:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var fv={};Object.defineProperty(fv,"__esModule",{value:!0});fv.mysqlKeywords=void 0;fv.mysqlKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CUBE:!0,CUME_DIST:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DENSE_RANK:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,EMPTY:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FIRST_VALUE:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,FUNCTION:!0,GENERATED:!0,GET:!0,GRANT:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IO_AFTER_GTIDS:!0,IO_BEFORE_GTIDS:!0,IS:!0,ITERATE:!0,JOIN:!0,JSON_TABLE:!0,KEY:!0,KEYS:!0,KILL:!0,LAG:!0,LAST_VALUE:!0,LATERAL:!0,LEAD:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_BIND:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NTH_VALUE:!0,NTILE:!0,NULL:!0,NUMERIC:!0,OF:!0,ON:!0,OPTIMIZE:!0,OPTIMIZER_COSTS:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PARTITION:!0,PERCENT_RANK:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,RANK:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROW:!0,ROWS:!0,ROW_NUMBER:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STORED:!0,STRAIGHT_JOIN:!0,SYSTEM:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var yv={};Object.defineProperty(yv,"__esModule",{value:!0});yv.sqliteKeywords=void 0;yv.sqliteKeywords={ABORT:!0,ACTION:!0,ADD:!0,AFTER:!0,ALL:!0,ALTER:!0,ALWAYS:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ATTACH:!0,AUTOINCREMENT:!0,BEFORE:!0,BEGIN:!0,BETWEEN:!0,BY:!0,CASCADE:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COMMIT:!0,CONFLICT:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,DATABASE:!0,DEFAULT:!0,DEFERRABLE:!0,DEFERRED:!0,DELETE:!0,DESC:!0,DETACH:!0,DISTINCT:!0,DO:!0,DROP:!0,EACH:!0,ELSE:!0,END:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXCLUSIVE:!0,EXISTS:!0,EXPLAIN:!0,FAIL:!0,FILTER:!0,FIRST:!0,FOLLOWING:!0,FOR:!0,FOREIGN:!0,FROM:!0,FULL:!0,GENERATED:!0,GLOB:!0,GROUP:!0,GROUPS:!0,HAVING:!0,IF:!0,IGNORE:!0,IMMEDIATE:!0,IN:!0,INDEX:!0,INDEXED:!0,INITIALLY:!0,INNER:!0,INSERT:!0,INSTEAD:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LAST:!0,LEFT:!0,LIKE:!0,LIMIT:!0,MATCH:!0,MATERIALIZED:!0,NATURAL:!0,NO:!0,NOT:!0,NOTHING:!0,NOTNULL:!0,NULL:!0,NULLS:!0,OF:!0,OFFSET:!0,ON:!0,OR:!0,ORDER:!0,OTHERS:!0,OUTER:!0,OVER:!0,PARTITION:!0,PLAN:!0,PRAGMA:!0,PRECEDING:!0,PRIMARY:!0,QUERY:!0,RAISE:!0,RANGE:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,REINDEX:!0,RELEASE:!0,RENAME:!0,REPLACE:!0,RESTRICT:!0,RETURNING:!0,RIGHT:!0,ROLLBACK:!0,ROW:!0,ROWS:!0,SAVEPOINT:!0,SELECT:!0,SET:!0,TABLE:!0,TEMP:!0,TEMPORARY:!0,THEN:!0,TIES:!0,TO:!0,TRANSACTION:!0,TRIGGER:!0,UNBOUNDED:!0,UNION:!0,UNIQUE:!0,UPDATE:!0,USING:!0,VACUUM:!0,VALUES:!0,VIEW:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHOUT:!0};var hv={};Object.defineProperty(hv,"__esModule",{value:!0});hv.postgresqlKeywords=void 0;hv.postgresqlKeywords={ALL:!0,ANALYSE:!0,ANALYZE:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASYMMETRIC:!0,AUTHORIZATION:!0,BOTH:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT_CATALOG:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_SCHEMA:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,DAY:!0,DEFAULT:!0,DEFERRABLE:!0,DESC:!0,DISTINCT:!0,DO:!0,ELSE:!0,END:!0,EXCEPT:!0,FALSE:!0,FETCH:!0,FILTER:!0,FOR:!0,FOREIGN:!0,FREEZE:!0,FROM:!0,FULL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HOUR:!0,ILIKE:!0,IN:!0,INITIALLY:!0,INNER:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LATERAL:!0,LEADING:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,MINUTE:!0,MONTH:!0,NATURAL:!0,NOT:!0,NOTNULL:!0,NULL:!0,OFFSET:!0,ON:!0,ONLY:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,OVERLAPS:!0,PLACING:!0,PRECISION:!0,PRIMARY:!0,REFERENCES:!0,RETURNING:!0,RIGHT:!0,SECOND:!0,SELECT:!0,SESSION_USER:!0,SIMILAR:!0,SOME:!0,SYMMETRIC:!0,SYSTEM_USER:!0,TABLE:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TRAILING:!0,TRUE:!0,UNION:!0,UNIQUE:!0,USER:!0,USING:!0,VARIADIC:!0,VARYING:!0,VERBOSE:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0,WITHOUT:!0,YEAR:!0,SET:!0};(function(o){var p=Pr&&Pr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Pr&&Pr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(pv,o),i(cv,o),i(fv,o),i(yv,o),i(hv,o)})(L2e);var qm={};Object.defineProperty(qm,"__esModule",{value:!0});qm.FormattedSyntaxError=void 0;class dAi extends Error{constructor(p,i,n){super(uAi(p,i,n))}}qm.FormattedSyntaxError=dAi;function uAi(o,p,i){const n=o.location.start.line,s=o.location.start.column,c=p.split(/\r\n|\n|\r/)[n-1],e="".padStart(String(n).length),y=cAi(pAi(o.found,s,c)),m=fAi(o.expected);return`Syntax Error: Unexpected ${y}
|
|
99
99
|
Was expecting to see: ${m}
|
|
100
100
|
--> ${i||"undefined"}:${n}:${s}
|
|
101
101
|
${e} |
|
package/dist/index.js
CHANGED
|
@@ -129987,7 +129987,9 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
|
|
|
129987
129987
|
_.SyncOutputs
|
|
129988
129988
|
)
|
|
129989
129989
|
)) {
|
|
129990
|
-
if (
|
|
129990
|
+
if (this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log(
|
|
129991
|
+
"[syncOutputs] Starting syncOutputs for variable declaration"
|
|
129992
|
+
), !this.checkCanEdit(this, i))
|
|
129991
129993
|
return ie.warn(
|
|
129992
129994
|
`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`
|
|
129993
129995
|
), i == null || i.attemptAutoclose(_.SyncOutputs, this.id), {
|
|
@@ -130047,7 +130049,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
|
|
|
130047
130049
|
b,
|
|
130048
130050
|
this.project
|
|
130049
130051
|
);
|
|
130050
|
-
return E.hydrateAncestors(), i == null || i.add(E, H.Added), E.setParent(this, i), E.initChildren(i), this.addOutput(E, i), E;
|
|
130052
|
+
return this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log("Created output for property:", E), E.hydrateAncestors(), this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log("Hydrated output for property:", E), i == null || i.add(E, H.Added), this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log("Registered output in cs:", E), E.setParent(this, i), this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log("Set parent, of output for property:", E), E.initChildren(i), this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log("Initialized output for property:", E), this.addOutput(E, i), this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log("Added output for property to parent:", E), E;
|
|
130051
130053
|
}), this.id === "0f7ef123-9320-4a91-9bb6-32f4e77e52f2" && console.log(
|
|
130052
130054
|
"Final outputs:",
|
|
130053
130055
|
this.outputs.map(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyx-code/project-logic-tree",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6716",
|
|
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",
|