@elyx-code/project-logic-tree 0.0.6894 → 0.0.6895
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 +2 -2
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -46,7 +46,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
46
46
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
47
47
|
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writers of its inputs, or the value readers of its outputs.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];if(r==="loop-parent-field"){const{updated:m,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];if(r==="loop-parent-field"){const{updated:m,added:E,removed:b}=this.restore({},a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,P;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"loop-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.unsubscribeDependents)==null||c.call(a,[{entity:this,field:"loop-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||f.call(e,[{entity:this,field:"loop-data-type-field"}]),(b=(E=(m=(h=this.body)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"loop-body-data-type-entity-field"}]),(P=(_=(A=this.body)==null?void 0:A.dataType)==null?void 0:_.unsubscribeDependents)==null||P.call(_,[{entity:this,field:"loop-body-data-type-field"}]),this}subscribeToDependencies(){var i,r,a,c,e,f,h,m,E,b,A,_,P;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"loop-parent-field"}]),(c=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.subscribeDependents)==null||c.call(a,[{entity:this,field:"loop-data-type-entity-field"}]),(f=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||f.call(e,[{entity:this,field:"loop-data-type-field"}]),(b=(E=(m=(h=this.body)==null?void 0:h.dataType)==null?void 0:m.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"loop-body-data-type-entity-field"}]),(P=(_=(A=this.body)==null?void 0:A.dataType)==null?void 0:_.subscribeDependents)==null||P.call(_,[{entity:this,field:"loop-body-data-type-field"}]),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new ei(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new ei(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.error=this.error,i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.declaration=this.declaration,i.body=this.body,i.calledByEntry=[...this.calledByEntry],i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.writesValues=[...this.writesValues],i.dataType=this.dataType,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new ei(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.inputs=[...h.inputs],this.outputs=[...h.outputs],this.error=h.error,this.successCalls=[...h.successCalls],this.errorCalls=[...h.errorCalls],this.declaration=h.declaration,this.body=h.body,this.calledBySuccess=[...h.calledBySuccess],this.calledByError=[...h.calledByError],this.calledByEntry=[...h.calledByEntry],this.writesValues=[...h.writesValues],this.dataType=h.dataType,this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const a=ie(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.declaration){const a=ie(i.declaration),c=this.project.get(a);c&&this.setDeclaration(c)}if(i.calledByEntry.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&(this.addEntryCaller(e,r),e.addCall(this,r))}),[...this.calledByEntry].forEach(a=>{i.calledByEntry.find(e=>ie(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledBySuccess.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&(this.addSuccessCaller(e,r),e.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(a=>{i.calledBySuccess.find(e=>ie(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledByError.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&(this.addErrorCaller(e,r),e.addErrorCall(this,r))}),[...this.calledByError].forEach(a=>{i.calledByError.find(e=>ie(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.dataType){const a=ie(i.dataType),c=this.project.get(a);c&&this.setDataType(c,r)}else this.setDataType(null,r);return i.outputs.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&(this.addOutput(e,r),e.setParent(this,r))}),[...this.outputs].forEach(a=>{i.outputs.find(e=>ie(e)===a.id)||(this.removeOutput(a,r),a.removeFromParent(r))}),i.inputs.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&(this.addInput(e,r),e.setParent(this,r))}),[...this.inputs].forEach(a=>{i.inputs.find(e=>ie(e)===a.id)||(this.removeInput(a,r),a.removeFromParent(r))}),i.writesValues.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&(this.addValueReader(e,r),e.setValueWriter(this,r))}),[...this.writesValues].forEach(a=>{i.writesValues.find(e=>ie(e)===a.id)||(this.removeValueReader(a,r),a.setValueWriter(null,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const f=ie(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}if(i.declaration){const f=ie(i.declaration),h=this.project.get(f);if(h)this.setDeclaration(h);else throw new Error(`${this.type} with id '${this.id}' has a 'declaration' reference '${f}' that isn't found in the project`)}return(a=i.calledByEntry)==null||a.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addEntryCaller(m,r),m.addCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByEntry' reference '${h}' that isn't found in the project`)}),i.calledByEntry&&[...this.calledByEntry].forEach(f=>{var m;((m=i.calledByEntry)==null?void 0:m.find(E=>ie(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addSuccessCaller(m,r),m.addSuccessCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledBySuccess' reference '${h}' that isn't found in the project`)}),i.calledBySuccess&&[...this.calledBySuccess].forEach(f=>{var m;((m=i.calledBySuccess)==null?void 0:m.find(E=>ie(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addErrorCaller(m,r),m.addErrorCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByError' reference '${h}' that isn't found in the project`)}),i.calledByError&&[...this.calledByError].forEach(f=>{var m;((m=i.calledByError)==null?void 0:m.find(E=>ie(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.declaration){const e=ie(this.initialData.declaration),f=this.project.get(e);f&&(this.setDeclaration(f),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.addErrorCaller(h,null)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.initialized=!0,this.checkIsSynced())return i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};const{updated:f,added:h,removed:m}=this.syncChildren(i);return r.push(...f),a.push(...h),c.push(...m),this.inputs.sort((E,b)=>{var A,_;return(E.index??((A=E.declaration)==null?void 0:A.index))-(b.index??((_=b.declaration)==null?void 0:_.index))}),this.outputs.sort((E,b)=>{var A,_;return(E.index??((A=E.declaration)==null?void 0:A.index))-(b.index??((_=b.declaration)==null?void 0:_.index))}),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];return this.parent===this.project&&this.project.addLoop(this),this.successCalls.forEach(f=>{f.addSuccessCaller(this,i),r.push(f)}),this.errorCalls.forEach(f=>{f.addErrorCaller(this,i),r.push(f)}),this.calledByEntry.forEach(f=>{f.addCall(this,i),r.push(f)}),this.calledBySuccess.forEach(f=>{f.addSuccessCall(this,i),r.push(f)}),this.calledByError.forEach(f=>{f.addErrorCall(this,i),r.push(f)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveInput))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveInput,this.id),this;const a=this.inputs.findIndex(c=>c.id===i.id);return a>-1&&(this.inputs.splice(a,1),r&&(r==null||r.add(this,W.Affected))),r==null||r.attemptAutoclose(w.RemoveInput,this.id),this}addInput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddInput))){return this.checkCanEdit(this,r)?this.inputs.includes(i)?(r==null||r.attemptAutoclose(w.AddInput,this.id),this):(this.inputs.push(i),r==null||r.add(this,W.Affected),r==null||r.attemptAutoclose(w.AddInput,this.id),this):(Y.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddInput,this.id),this)}addOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,r)?this.outputs.includes(i)?(r==null||r.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),r==null||r.add(this,W.Affected),r==null||r.attemptAutoclose("add-output",this.id),this):(Y.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("add-output",this.id),this)}removeOutput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("remove-output",this.id),this;const a=this.outputs.findIndex(c=>c.id===i.id);return a>-1&&(this.outputs.splice(a,1),r&&(r==null||r.add(this,W.Affected))),r==null||r.attemptAutoclose("remove-output",this.id),this}setBody(i){return this.body=i,this}detachBody(){return this.body=null,this}addSuccessCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}--${Be.CannotSuccessCallItself}`,action:w.AddSuccessCaller,owner:this,errorReason:Be.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddSuccessCaller})),this.calledBySuccess.find(e=>e.id===i.id)||(this.calledBySuccess.push(i),r==null||r.add(this,W.Updated),a&&Et(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Be.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Be.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddErrorCaller})),this.calledByError.find(e=>e.id===i.id)||(this.calledByError.push(i),r==null||r.add(this,W.Updated),a&&Et(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddEntryCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddEntryCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddEntryCaller}-${this.id}--${Be.CannotEntryCallItself}`,action:w.AddEntryCaller,owner:this,errorReason:Be.CannotEntryCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddEntryCaller})),this.calledByEntry.find(e=>e.id===i.id)||(this.calledByEntry.push(i),r==null||r.add(this,W.Updated),a&&Et(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}addErrorCall(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCall)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCall,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Be.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Be.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddErrorCaller})),this.errorCalls.find(e=>e.id===i.id)||(this.errorCalls.push(i),this.catchesError&&this.metaSync({catchesError:!1},r),a&&Et(this,r),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.AddErrorCall,this.id),this):this}addSuccessCall(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCall)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCall,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}`,action:w.AddSuccessCaller,owner:this,errorReason:Be.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddSuccessCaller})),this.successCalls.find(e=>e.id===i.id)||(this.successCalls.push(i),a&&Et(this,r),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.AddSuccessCall,this.id),this):this}removeCall(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveCall)),a=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCall,r))return this;const c=this.successCalls.findIndex(f=>f.id===i.id);c>-1&&(this.successCalls.splice(c,1),r==null||r.add(this,W.Affected));const e=this.errorCalls.findIndex(f=>f.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),r==null||r.add(this,W.Affected)),a&&Et(this,r),r==null||r.attemptAutoclose(w.RemoveCall,this.id),this}removeCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-caller")),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCaller,r)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,W.Updated),r==null||r.add(c,W.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,W.Updated),r==null||r.add(c,W.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,W.Updated),r==null||r.add(c,W.Affected),!1)),a&&Et(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}replaceDetachedChild(i,r){const a=this.detachedChildren.indexOf(i);return a!==-1&&(this.detachedChildren[a]=r),this}subscribeDetachedChild(i){return this.detachedChildren.includes(i)||this.detachedChildren.push(i),this}unsubscribeDetachedChild(i){const r=this.detachedChildren.indexOf(i);return r!==-1&&this.detachedChildren.splice(r,1),this}setError(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetErrorEntity))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetErrorEntity,this.id),this;const a=this.error;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.error=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetErrorEntity,this.id),this}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setDeclaration(i){return this.declaration=i,this}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.declaration=ge(this.initialData.declaration,this.project),this.initialData.dataType){const r=ge(this.initialData.dataType,this.project);this.setDataType(r,null),this.dataType.setParent(this,null),this.dataType.initChildren(i)}return this.successCalls=this.initialData.successCalls.map(r=>{const a=ge(r,this.project);if(a.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(a.type))a.setParent(this.parent.parent,null),a.initChildren(i);else if(a.type===d.ReturnStatement){const c=An(this,this.project);a.setParent(c,null),a.initChildren(i)}else a.type!==d.InternalCall&&(a.setParent(this.parent,null),a.initChildren(i));return a}),this.errorCalls=this.initialData.errorCalls.map(r=>{const a=ge(r,this.project);if(a.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(a.type))a.setParent(this.parent.parent,null),a.initChildren(i);else if(a.type===d.ReturnStatement){const c=An(this,this.project);a.setParent(c,null),a.initChildren(i)}else a.type!==d.InternalCall&&(a.setParent(this.parent,null),a.initChildren(i));return a}),this.inputs=this.initialData.inputs.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.outputs=this.initialData.outputs.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.body&&(this.body=ge(this.initialData.body,this.project),this.body.setParent(this,null),this.body.initChildren(i)),this.initialData.error&&(this.error=ge(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}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.x=a.x||e.x,this.y=a.y||e.y,this.catchesError=a.catchesError!==void 0?a.catchesError:this.catchesError,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await ei.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await ei.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await ei.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await ei.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await ei.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await ei.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeLoop(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),this.inputs.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.outputs.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.body.remove({ignoreUpstream:!0},r),this.error){const{updated:m,removed:E}=this.error.remove({ignoreUpstream:!0},r);a.push(...m),c.push(...E)}if(this.dataType){const{updated:m,removed:E}=this.dataType.remove({ignoreUpstream:!0},r);a.push(...m),c.push(...E)}if(this.successCalls.forEach(m=>{a.push(m),m.removeCaller(this,r)}),this.errorCalls.forEach(m=>{a.push(m),m.removeCaller(this,r)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected),this.calledBy.forEach(E=>{a.push(E),E.removeCall(this,r)})}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),this.inputs.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.outputs.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.body.restore({},i),this.successCalls.forEach(f=>{a.push(f),f.addSuccessCaller(this,i)}),this.errorCalls.forEach(f=>{a.push(f),f.addErrorCaller(this,i)}),this.error){const{updated:f}=this.error.restore({},i);a.push(...f)}if(this.dataType){const{updated:f}=this.dataType.restore({},i);a.push(...f)}return this.calledBySuccess.forEach(f=>{a.push(f),f.addSuccessCall(this,i)}),this.calledByError.forEach(f=>{a.push(f),f.addErrorCall(this,i)}),this.calledByEntry.forEach(f=>{a.push(f),f.addCall(this,i)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.inputs.flatMap(a=>a.toFlat(i)),...this.outputs.flatMap(a=>a.toFlat(i)),...this.successCalls.flatMap(a=>a.toFlat(i)),...this.errorCalls.flatMap(a=>a.toFlat(i)),...this.error?this.error.toFlat(i):[],...this.body?this.body.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[],...this.continueStatements.flatMap(a=>a.toFlat(i)),...this.breakStatements.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.inputs.flatMap(a=>a.toFlatIds(i)),...this.outputs.flatMap(a=>a.toFlatIds(i)),...this.successCalls.flatMap(a=>a.toFlatIds(i)),...this.errorCalls.flatMap(a=>a.toFlatIds(i)),...this.error?this.error.toFlatIds(i):[],...this.body?this.body.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[],...this.continueStatements.flatMap(a=>a.toFlatIds(i)),...this.breakStatements.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,catchesError:this.catchesError}}toJSON(i=new Set){var r,a;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,catchesError:this.catchesError,x:this.x,y:this.y,dataType:((r=this.dataType)==null?void 0:r.toJSON(i))||null,calledBySuccess:this.calledBySuccess.map(c=>c.toReference()),calledByError:this.calledByError.map(c=>c.toReference()),calledByEntry:this.calledByEntry.map(c=>c.toReference()),writesValues:this.writesValues.map(c=>c.toJSON(i)),declaration:this.declaration.toJSON(i),inputs:this.inputs.map(c=>c.toJSON(i)),outputs:this.outputs.map(c=>c.toJSON(i)),successCalls:this.successCalls.map(c=>c.toJSON(i)),errorCalls:this.errorCalls.map(c=>c.toJSON(i)),error:((a=this.error)==null?void 0:a.toJSON(i))||null,body:this.body.toJSON(i),parent:this.parent.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,catchesError:this.catchesError,dataType:((m=this.dataType)==null?void 0:m.toJSONClone({...i,newId:null}))||null,calledBySuccess:this.calledBySuccess.map(b=>b.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(b=>b.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(b=>b.toReference({seenEntityMaps:i.seenEntityMaps})),declaration:this.declaration.toJSON(),inputs:this.inputs.map(b=>b.toJSONClone({...i,newId:null})),outputs:this.outputs.map(b=>b.toJSONClone({...i,newId:null})),writesValues:this.writesValues.map(b=>b.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(b=>b.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(b=>b.toJSONClone({...i,newId:null})),error:((E=this.error)==null?void 0:E.toJSONClone({...i,newId:null}))||null,body:this.body.toJSONClone({...i,newId:null}),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f,h;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,catchesError:this.catchesError,x:this.x,y:this.y,dataType:((c=this.dataType)==null?void 0:c.toReference(i))||null,declaration:((e=this.declaration)==null?void 0:e.toReference(i))||null,body:((f=this.body)==null?void 0:f.toReference(i))||null,inputs:this.inputs.map(m=>m.toReference(i)),outputs:this.outputs.map(m=>m.toReference(i)),writesValues:this.writesValues.map(m=>m.toReference(i)),successCalls:this.successCalls.map(m=>m.toReference(i)),errorCalls:this.errorCalls.map(m=>m.toReference(i)),calledBySuccess:this.calledBySuccess.map(m=>m.toReference(i)),calledByError:this.calledByError.map(m=>m.toReference(i)),calledByEntry:this.calledByEntry.map(m=>m.toReference(i)),error:((h=this.error)==null?void 0:h.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.body)==null?void 0:a.toFlatJSON(i))||[],...this.successCalls.flatMap(c=>c.toFlatJSON(i)),...this.errorCalls.flatMap(c=>c.toFlatJSON(i)),...this.inputs.flatMap(c=>c.toFlatJSON(i)),...this.outputs.flatMap(c=>c.toFlatJSON(i)),...this.continueStatements.flatMap(c=>c.toFlatJSON(i)),...this.breakStatements.flatMap(c=>c.toFlatJSON(i)),...this.error?this.error.toFlatJSON(i):[],...this.dataType?this.dataType.toFlatJSON(i):[]])}toGenerationTarget(i=at){var c,e;const r=this.parent.type===d.Project?void 0:(c=i.seenEntityMaps)!=null&&c.has(this.parent.id)?i.seenEntityMaps.get(this.parent.id):this.parent.id;let a=this.id;return(e=i.seenEntityMaps)!=null&&e.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,type:this.type,calledByEntry:this.calledByEntry.map(f=>f.id),calledBySuccess:this.calledBySuccess.map(f=>f.id),calledByError:this.calledByError.map(f=>f.id),declaration:this.declaration.id,parent:r}}toFlatGenerationTarget(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.body)==null?void 0:a.toFlatGenerationTarget(i))||[],...this.successCalls.flatMap(c=>c.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(c=>c.toFlatGenerationTarget(i)),...this.inputs.flatMap(c=>c.toFlatGenerationTarget(i)),...this.outputs.flatMap(c=>c.toFlatGenerationTarget(i)),...this.continueStatements.flatMap(c=>c.toFlatGenerationTarget(i)),...this.breakStatements.flatMap(c=>c.toFlatGenerationTarget(i)),...this.error?this.error.toFlatGenerationTarget(i):[],...this.dataType?this.dataType.toFlatGenerationTarget(i):[]])}clearErrors(){var i,r;return this.errors=[],this.inputs.forEach(a=>a.clearErrors()),this.outputs.forEach(a=>a.clearErrors()),this.successCalls.forEach(a=>a.clearErrors()),this.errorCalls.forEach(a=>a.clearErrors()),this.continueStatements.forEach(a=>a.clearErrors()),this.breakStatements.forEach(a=>a.clearErrors()),(i=this.error)==null||i.clearErrors(),(r=this.dataType)==null||r.clearErrors(),this}validate(){return this.errors=Gx(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await eVe(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors,...this.inputs.flatMap(r=>r.getErrors()),...this.outputs.flatMap(r=>r.getErrors()),...this.body?this.body.getErrors():[],...this.error?this.error.getErrors():[],...this.dataType?this.dataType.getErrors():[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.inputs)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.outputs)a.push(...await c.getErrorsAsync({tracker:r}));return this.body&&a.push(...await this.body.getErrorsAsync({tracker:r})),this.error&&a.push(...await this.error.getErrorsAsync({tracker:r})),this.dataType&&a.push(...await this.dataType.getErrorsAsync({tracker:r})),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var P,V;const e=Ur(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.inputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.deletable=!0,f.editable=!0;const b=nr(f,e);r?b.setParent(r,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,W.Added);const A=(P=this.inputs)==null?void 0:P.map((j,M)=>j.clone(i,b,E+"-input-map-"+M+"-id",c));b.inputs=A;const _=(V=this.outputs)==null?void 0:V.map((j,M)=>j.clone(i,b,E+"-output-map-"+M+"-id",c));return b.outputs=_,this.body&&(b.body=this.body.clone(i,b,E+"-body-id",c,!0)),this.error&&(b.error=this.error.clone(i,b,E+"-error-map-id",c)),this.dataType&&(b.dataType=this.dataType.clone(i,b,E+"-data-type-id",c)),i||b.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}getVariableInstances(){return this.body?ur(this.body).filter(a=>a.type===d.VariableInstance):[]}addReturnStatement(i){return Gt.includes(this.parent.type)&&this.parent.addReturnStatement(i),this}removeReturnStatement(i){return Gt.includes(this.parent.type)&&this.parent.removeReturnStatement(i),this}addBreakStatement(i){return this.breakStatements.includes(i)||this.breakStatements.push(i),this}removeBreakStatement(i){const r=this.breakStatements.indexOf(i);return r!==-1&&this.breakStatements.splice(r,1),this}addContinueStatement(i){return this.continueStatements.includes(i)||this.continueStatements.push(i),this}removeContinueStatement(i){const r=this.continueStatements.indexOf(i);return r!==-1&&this.continueStatements.splice(r,1),this}getUniqueInputMaps(){const i=[];return[...this.breakStatements,...this.continueStatements].forEach(a=>{a.outputs.filter(e=>{var f;return!e.deleted&&!((f=e.declaration)!=null&&f.deleted)}).forEach(e=>{i.find(h=>h===e||oe(h,this.project)===oe(e,this.project)&&di(h.dataType,e.dataType))||i.push(e)})}),C(i)}syncTerminationStatements(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-termination-statements"))){const r=[],a=[],c=[],e=[],f=this.getUniqueInputMaps();return[...this.breakStatements,...this.continueStatements].forEach(m=>{const E=m.outputs.filter(A=>{var _;return!A.deleted&&!((_=A.declaration)!=null&&_.deleted)}),b=f.filter(A=>!E.find(_=>oe(A,this.project)===oe(_,this.project)&&di(A.dataType,_.dataType)));b.length&&(r.push(m),i==null||i.add(m,W.Updated)),b.forEach(A=>{const _=A.clone(i,m);i==null||i.add(_,W.Added),_.addSelfToProject(i),a.push(_)})}),i==null||i.attemptAutoclose("sync-termination-statements",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncBodyInputIndexes(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-body-input-indexes"))){const r=[],a=[],c=[],e=[];return this.body.inputs.sort((f,h)=>f.index-h.index),i==null||i.attemptAutoclose("sync-body-input-indexes",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncBodyArgumentsDeclarations(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-body-arguments-declarations"))){var V,j,M,G,q,re;const r=[],a=[],c=[],e=[],{updated:f,added:h,removed:m}=this.syncFixedBodyArgumentDeclarations(i);r.push(...f),a.push(...h),c.push(...m);const E=this.getUniqueInputMaps(),b=this.body.inputs;if(E.sort((ee,se)=>ee.index-se.index),((M=(j=(V=this.body)==null?void 0:V.dataType)==null?void 0:j.entity)==null?void 0:M.id)!==ne["primitive-entity"].void.id&&!b.find(se=>{var te,le,ue,z,X,pe,de;return se.id!==((te=this.currentIterationNumberArgumentDeclaration)==null?void 0:te.id)&&se.id!==((le=this.currentValueArgumentDeclaration)==null?void 0:le.id)&&((z=(ue=se.dataType)==null?void 0:ue.entity)==null?void 0:z.id)===((de=(pe=(X=this.body)==null?void 0:X.dataType)==null?void 0:pe.entity)==null?void 0:de.id)})){let se=0;this.currentIterationNumberArgumentDeclaration&&se++,this.currentValueArgumentDeclaration&&se++;const te=Za.new(i);te.name="Aggregate result",te.description="Aggretated list of all previously outputted values from each iteration",te.constant=!0,te.index=se,te.required=!1,te.parent=this.body.toReference();const le=ge(te,this.project);if(le.hydrateAncestors(),le.addSelfToProject(i),i==null||i.add(le,W.Added),a.push(le),le.setParent(this.body,i),le.initChildren(i),!le.dataType&&((G=this.body)!=null&&G.dataType)){const ue=mr.new(i);ue.parent=le.toReference();const z=ge(ue,this.project);z.hydrateAncestors(),z.addSelfToProject(i),a.push(z),z.setParent(le,i),z.initChildren(i),z.merge((q=this.body)==null?void 0:q.dataType,i),z.setEntity((re=this.body)==null?void 0:re.dataType.entity,i),i==null||i.add(z,W.Added),i||z.captureVersion()}i||le.captureVersion()}const{updated:A,added:_,removed:P}=this.removeExtraBodyArgumentDeclarations(i);return r.push(...A),a.push(..._),c.push(...P),i==null||i.attemptAutoclose("sync-body-arguments-declarations",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}reAttachAllTerminationInputMapsToDeclarations(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"reattach-termination-input-maps-to-declarations"))){var h,m,E;const r=[],a=[],c=[],e=[];return!((h=this.body)!=null&&h.dataType)||!((m=this.body)!=null&&m.dataType.entity)||((E=this.body)==null?void 0:E.dataType.entity.type)!==d.DefinitionEntity?(i==null||i.attemptAutoclose("reattach-termination-input-maps-to-declarations",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}):([...this.breakStatements,...this.continueStatements].forEach(b=>{var j,M,G;const A=b.outputs.filter(q=>{var re;return!q.deleted&&!((re=q.declaration)!=null&&re.deleted)}),_=A.filter(q=>!q.declaration&&!!q.readsValue),P=A.filter(q=>!q.declaration&&!q.readsValue);let V=(((G=(M=(j=this.body)==null?void 0:j.dataType)==null?void 0:M.entity)==null?void 0:G.properties)||[]).filter(q=>!A.find(re=>{var ee,se;return!re.deleted&&!((ee=re.declaration)!=null&&ee.deleted)&&((se=re.declaration)==null?void 0:se.id)===q.id}));_.forEach(q=>{const re=q.getDataType(i);if(q.readsValue){const ee=oe(q.readsValue,this.project),se=V.find(te=>oe(te,this.project)===ee&&di(te.dataType,re));if(se){q.setDeclaration(se,i),r.push(q),V=V.filter(te=>te!==se);return}}}),P.forEach(q=>{const re=q.getDataType(i),ee=V.find(se=>di(se.dataType,re));if(ee){q.setDeclaration(ee,i),r.push(q),V=V.filter(se=>se!==ee);return}}),A.forEach(q=>{const re=V.find(ee=>oe(ee,this.project)===oe(q,this.project));q.declaration&&!V.includes(q.declaration)&&re&&(q.setDeclaration(re,i),r.push(q),V=V.filter(ee=>ee!==re))})}),i==null||i.attemptAutoclose("reattach-termination-input-maps-to-declarations",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this})}syncOutputDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-outputs-properties"))){var V,j,M,G,q,re,ee,se,te,le,ue,z,X,pe,de,me,ve,we,Re,xe,je,Se,Je;const r=[],a=[],c=[],e=[],f=[...this.breakStatements,...this.continueStatements];if(!f.every(Ze=>Ze.initialized))return i==null||i.attemptAutoclose("sync-outputs-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};let h=!1;if(!((V=this.body)!=null&&V.dataType)){const Ze=mr.new(i);Ze.parent=this.body.toReference(),Ze.inferred=!0;const et=ge(Ze,this.project);et.hydrateAncestors(),et.addSelfToProject(i),i==null||i.add(et,W.Added),et.initChildren(i),a.push(et),h=!0}const m=f.find(Ze=>!!Ze.readsValue);if(m){const Ze=(j=m.readsValue)==null?void 0:j.getDataType(i);Ze&&((G=(M=this.body)==null?void 0:M.dataType)==null||G.merge(Ze,i))}h&&(i||(re=(q=this.body)==null?void 0:q.dataType)==null||re.captureVersion());const E=this.getUniqueInputMaps();let b=(se=(ee=this.body)==null?void 0:ee.dataType)==null?void 0:se.entity;if(E.length&&(!b||b.id===ne["primitive-entity"].void.id)){const Ze=Fs.new(i);Ze.parent=((te=this.body)==null?void 0:te.dataType).toReference(),Ze.name=`${oe(this,this.project)} output definition`,Ze.description=`The definition of the output data type of the loop '${oe(this,this.project)}'`;const et=ge(Ze,this.project);et.setParent((le=this.body)==null?void 0:le.dataType,i),et.hydrateAncestors(),i==null||i.add(et,W.Added),et.addSelfToProject(i),et.initChildren(i),a.push(et),b=et,(z=(ue=this.body)==null?void 0:ue.dataType)==null||z.metaSync({inferred:!0},i),i||et.captureVersion()}const A=(b==null?void 0:b.properties)||[];(pe=(X=this.body)==null?void 0:X.dataType)!=null&&pe.inferred&&((me=(de=this.body)==null?void 0:de.dataType.entity)==null?void 0:me.type)===d.DefinitionEntity&&(E.forEach(Ze=>{var tn,yr,or,un,Vs;const et=Ze.getDataType(i);let jt=A.find(xr=>oe(xr,this.project)===oe(Ze,this.project)&&di(xr.dataType,Ze.dataType));if(!jt){const xr=Es.new(i);xr.name=oe(Ze,this.project),xr.description=`Aggretated list of all previously outputted values from each iteration by the output '${oe(Ze,this.project)}'`,xr.index=Ze.index,xr.required=((tn=Ze.declaration)==null?void 0:tn.required)||!1,xr.parent=((or=(yr=this.body)==null?void 0:yr.dataType)==null?void 0:or.entity).toReference();const Bn=ge(xr,this.project);Bn.hydrateAncestors(),Bn.setParent((Vs=(un=this.body)==null?void 0:un.dataType)==null?void 0:Vs.entity,i),Bn.addSelfToProject(i),i==null||i.add(Bn,W.Added),Bn.initChildren(i),a.push(Bn),jt=Bn,i||Bn.captureVersion()}jt.index!==Ze.index&&(jt.metaSync({index:Ze.index},i),r.push(jt));let Ti=jt.getDataType(i);if(et)if(!Ti||!di(Ti,et)){if(!Ti){const xr=et.clone(i,jt);i==null||i.add(xr,W.Added),xr.addSelfToProject(i),Ti=xr,a.push(xr),r.push(jt)}Ti.merge(et,i),Ti.metaSync({isList:!0},i)}else Ti.isList||(Ti.metaSync({isList:!0},i),r.push(Ti));if(!et&&!Ti){const xr={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,parentRelationType:null,isList:!0,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parent:jt.toReference()},Bn=ge(xr,this.project);Bn.metaSync({isList:!0},i),Bn.hydrateAncestors(),Bn.setParent(jt,i),Bn.addSelfToProject(i),i==null||i.add(Bn,W.Added),Bn.initChildren(i),a.push(Bn),i||Bn.captureVersion()}}),this.reAttachAllTerminationInputMapsToDeclarations(i)),(we=(ve=this.body)==null?void 0:ve.dataType)!=null&&we.inferred&&((xe=(Re=this.body)==null?void 0:Re.dataType.entity)==null?void 0:xe.type)===d.DefinitionEntity&&A.filter(et=>!E.find(jt=>oe(et,this.project)===oe(jt,this.project))).forEach(et=>{if(!(i!=null&&i.hasRemoved(et.id))&&!et.deleted){const{updated:Dt,removed:jt}=et.remove({ignoreUpstream:!1},i);r.push(...Dt),c.push(...jt)}}),f.forEach(Ze=>{Ze.outputs.filter(Dt=>{var jt;return!Dt.deleted&&!((jt=Dt.declaration)!=null&&jt.deleted)}).forEach(Dt=>{var Li,Ti,tn;if(!(((tn=(Ti=(Li=this.body)==null?void 0:Li.dataType)==null?void 0:Ti.entity)==null?void 0:tn.properties)||[]).find(yr=>{var or;return((or=Dt.declaration)==null?void 0:or.id)===yr.id})&&!(i!=null&&i.hasRemoved(Dt.id))&&!Dt.deleted){const{updated:yr,removed:or}=Dt.remove({ignoreUpstream:!1},i);r.push(...yr),c.push(...or)}})});const _=this.getUniqueInputMaps();if(f.every(Ze=>!Ze.readsValue)&&!_.length){const Ze=this.project.getBuiltIn(ne["primitive-entity"].void.id);(Se=(je=this.body)==null?void 0:je.dataType)==null||Se.setEntity(Ze,i),r.push((Je=this.body)==null?void 0:Je.dataType)}return i==null||i.attemptAutoclose("sync-outputs-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncOutputMaps(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SyncOutputs))){var E,b,A;const r=[],a=[],c=[],e=[],f=((A=(b=(E=this.body)==null?void 0:E.dataType)==null?void 0:b.entity)==null?void 0:A.properties)||[],h=this.outputs;return f.forEach(_=>{var j;let V=h.find(M=>{var G,q;return((G=M.declaration)==null?void 0:G.id)===_.id&&di((q=M.declaration)==null?void 0:q.dataType,_.dataType)});if(V)((j=V.declaration)==null?void 0:j.id)!==_.id&&(V.setDeclaration(_,i),r.push(V));else{const M={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,index:_.index,declaration:_.toJSON(),writesValues:[],parent:this.toReference()},G=ge(M,this.project);G.hydrateAncestors(),G.setParent(this,i),G.addSelfToProject(i),i==null||i.add(G,W.Added),G.initChildren(i),a.push(G),i||G.captureVersion(),V=G}V.index!==_.index&&(V.metaSync({index:_.index},i),r.push(V))}),h.filter(_=>!f.find(V=>{var j;return((j=_.declaration)==null?void 0:j.id)===V.id})).forEach(_=>{const{updated:P,removed:V}=_.remove({ignoreUpstream:!1},i);r.push(...P),c.push(...V)}),this.outputs.forEach(_=>{const{updated:P,added:V,removed:j}=_.afterAllChildrenInitialized(i);r.push(...P),a.push(...V),c.push(...j)}),this.outputs.sort((_,P)=>_.index-P.index),i==null||i.attemptAutoclose(w.SyncOutputs,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}createCurrentIterationNumberArgumentDeclaration(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"create-current-iteration-number-argument-declaration"))){const r=[],a=[],c=[],e=[];let h=this.body.inputs.find(A=>{var _;return A.name===ei.CURRENT_ITERATION_NUMBER_ARG_NAME||A.id===((_=this.currentIterationNumberArgumentDeclaration)==null?void 0:_.id)});const m=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!h){const A={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:ei.CURRENT_ITERATION_NUMBER_ARG_NAME,codeName:null,description:"The number of the current iteration",defaultValue:null,constant:!0,dataType:null,implements:[m==null?void 0:m.toJSON()],index:this.body.inputs.length,required:!0,parent:this.body.toReference(),writesValues:[]},_=ge(A,this.project);_.hydrateAncestors(),_.setParent(this.body,i),_.addSelfToProject(i),i==null||i.add(_,W.Added),_.initChildren(i),a.push(_),i||_.captureVersion(),h=_}!h.index&&h.index!==0&&(h.metaSync({index:0},i),r.push(h)),(!h.implements||!h.implements.find(A=>A.id===m.id))&&(h.addImplementation(m,i),r.push(h));let b=h.getDataType(i);if(!b){const A={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,parentRelationType:null,isList:!1,index:null,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parent:h.toReference()},_=ge(A,this.project);_.hydrateAncestors(),_.setParent(h,i),_.addSelfToProject(i),i==null||i.add(_,W.Added),_.initChildren(i),a.push(_),i||_.captureVersion(),b=_}if(!b.entity||b.entity.type!==d.PrimitiveEntity||b.entity.name!==fe.Number||b.entity.id!==ne["primitive-entity"].number.id){const A=this.project.getBuiltIn(ne["primitive-entity"].number.id);b.setEntity(A,i),r.push(b)}return i==null||i.attemptAutoclose("create-current-iteration-number-argument-declaration",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}removeExtraBodyArgumentDeclarations(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-extra-body-argument-declarations"))){const r=[],a=[],c=[],e=[];return this.body.inputs.filter(m=>{var E,b,A,_,P,V,j,M;return m===this.currentIterationNumberArgumentDeclaration||m===this.currentValueArgumentDeclaration?!1:((A=(b=(E=this.body)==null?void 0:E.dataType)==null?void 0:b.entity)==null?void 0:A.id)===ne["primitive-entity"].void.id?!0:((P=(_=m.dataType)==null?void 0:_.entity)==null?void 0:P.id)!==((M=(j=(V=this.body)==null?void 0:V.dataType)==null?void 0:j.entity)==null?void 0:M.id)}).forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!1},i);r.push(...E),c.push(...b)}),i==null||i.attemptAutoclose("remove-extra-body-argument-declarations",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}createCurrentValueInputBasedOnInputMap(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"create-current-value-input-based-on-input-map"))){var E,b,A,_,P,V,j,M,G;const r=[],a=[],c=[],e=[];switch(this.declaration.id){case ft.List:{const q=this.body.inputs.find(se=>!!se.implements.find(te=>te.id===ne[d.Loop][ft.List].body.inputs.currentValue.id)),re=this.inputs.find(se=>{var te;return((te=se.declaration)==null?void 0:te.id)===ne[d.Loop][ft.List].inputs.list.id});if(!re)break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(q){ee&&!q.implements.find(ue=>ue.id===ee.id)&&(q.addImplementation(ee,i),r.push(q));let te=q.getDataType(i);if(!te){const ue={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parent:(E=this.currentValueArgumentDeclaration)==null?void 0:E.toReference()},z=ge(ue,this.project);z.hydrateAncestors(),z.setParent(this.currentValueArgumentDeclaration,i),z.addSelfToProject(i),i==null||i.add(z,W.Added),z.initChildren(i),a.push(z),i||z.captureVersion(),te=z}const le=re.getDataType(i);te.merge(le,i),te.metaSync({isList:!1},i)}else{const se={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:ei.CURRENT_VALUE_ARG_NAME,codeName:null,description:null,defaultValue:null,index:this.body.inputs.length,constant:!0,required:!0,implements:[ee],writesValues:[],dataType:null,parent:this.body.toReference()},te=ge(se,this.project);te.hydrateAncestors(),te.setParent(this.body,i),te.addSelfToProject(i),i==null||i.add(te,W.Added),te.initChildren(i),ee&&!te.implements.find(le=>le.id===ee.id)&&(te.addImplementation(ee,i),r.push(te)),a.push(te),i||te.captureVersion()}break}case ft.ManualFlow:break;case ft.Counted:break;case ft.ObjectKeys:{const q=this.body.inputs.find(se=>!!se.implements.find(te=>te.id===ne[d.Loop][ft.ObjectKeys].body.inputs.currentValue.id));if(!this.inputs.find(se=>{var te;return((te=se.declaration)==null?void 0:te.id)===ne[d.Loop][ft.ObjectKeys].inputs.object.id}))break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(q){ee&&!q.implements.find(le=>le.id===ee.id)&&(q.addImplementation(ee),r.push(q));let te=q.getDataType(i);if(te){const le=this.project.getBuiltIn(ne["primitive-entity"].string.id);((A=te.entity)==null?void 0:A.id)!==le.id&&(te.setEntity(le,i),r.push(te))}else{const le={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parent:(b=this.currentValueArgumentDeclaration)==null?void 0:b.toReference()},ue=ge(le,this.project);ue.hydrateAncestors(),ue.setParent(this.currentValueArgumentDeclaration,i),ue.addSelfToProject(i),i==null||i.add(ue,W.Added),ue.initChildren(i),i||ue.captureVersion(),te=ue}}else{const se={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:ei.CURRENT_VALUE_ARG_NAME,codeName:null,description:null,defaultValue:null,index:this.body.inputs.length,constant:!0,required:!0,implements:[ee],writesValues:[],dataType:null,parent:this.body.toReference()},te=ge(se,this.project);te.hydrateAncestors(),te.setParent(this.body,i),te.addSelfToProject(i),i==null||i.add(te,W.Added),te.initChildren(i),ee&&!te.implements.find(le=>le.id===ee.id)&&(te.addImplementation(ee,i),r.push(te)),a.push(te),i||te.captureVersion()}break}case ft.ObjectValues:{const q=this.body.inputs.find(se=>!!se.implements.find(te=>te.id===ne[d.Loop][ft.ObjectValues].body.inputs.currentValue.id)),re=this.inputs.find(se=>{var te;return((te=se.declaration)==null?void 0:te.id)===ne[d.Loop][ft.ObjectValues].inputs.object.id});if(!re)break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(q){ee&&!q.implements.find(le=>le.id===ee.id)&&(q.addImplementation(ee,i),r.push(q));let te=q.getDataType(i);if(te){const le=re.getDataType(i),ue=((V=le==null?void 0:le.entity)==null?void 0:V.properties)||[];(j=te.orChildrenGroup)==null||j.forEach(z=>{const{updated:X,removed:pe}=z.remove({ignoreUpstream:!1},i);r.push(...X),c.push(...pe)}),ue.forEach(z=>{if(!z.getDataType(i)){const pe={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,index:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parentRelationType:ze.OrDataTypeGroup,parent:te.toReference()},de=ge(pe,this.project);de.hydrateAncestors(),de.setParent(te,i),de.addSelfToProject(i),i==null||i.add(de,W.Added),de.initChildren(i),i||de.captureVersion(),a.push(de)}})}else{const le={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parent:(_=this.currentValueArgumentDeclaration)==null?void 0:_.toReference()},ue=ge(le,this.project);ue.hydrateAncestors(),ue.setParent(this.currentValueArgumentDeclaration,i),ue.addSelfToProject(i),i==null||i.add(ue,W.Added),ue.initChildren(i),i||ue.captureVersion(),te=ue;const z=re.getDataType(i);(((P=z==null?void 0:z.entity)==null?void 0:P.properties)||[]).forEach(pe=>{if(!pe.getDataType(i)){const me={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,index:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parentRelationType:ze.OrDataTypeGroup,parent:ue.toReference()},ve=ge(me,this.project);ve.hydrateAncestors(),ve.setParent(ue,i),ve.addSelfToProject(i),i==null||i.add(ve,W.Added),ve.initChildren(i),i||ve.captureVersion(),a.push(ve)}})}}else{const se={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:ei.CURRENT_VALUE_ARG_NAME,codeName:null,description:null,constant:!0,defaultValue:null,index:this.body.inputs.length,required:!0,implements:[ee],writesValues:[],dataType:null,parent:this.body.toReference()},te=ge(se,this.project);te.hydrateAncestors(),te.setParent(this.body,i),te.addSelfToProject(i),i==null||i.add(te,W.Added),te.initChildren(i),ee&&!te.implements.find(le=>le.id===ee.id)&&(te.addImplementation(ee,i),r.push(te)),a.push(te),i||te.captureVersion()}break}case ft.String:{const q=this.body.inputs.find(se=>!!se.implements.find(te=>te.id===ne[d.Loop][ft.String].body.inputs.currentValue.id));if(!this.inputs.find(se=>{var te;return((te=se.declaration)==null?void 0:te.id)===ne[d.Loop][ft.String].inputs.string.id}))break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(q){ee&&!q.implements.find(le=>le.id===ee.id)&&(q.addImplementation(ee,i),r.push(q));let te=q.getDataType(i);if(te){const le=this.project.getBuiltIn(ne["primitive-entity"].string.id);((G=te.entity)==null?void 0:G.id)!==le.id&&(te.setEntity(le,i),r.push(te))}else{const le={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,foreignKeyRef:null,foreignKeyAllowed:null,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:null,orChildrenGroup:null,parent:(M=this.currentValueArgumentDeclaration)==null?void 0:M.toReference()},ue=ge(le,this.project);ue.hydrateAncestors(),ue.setParent(this.currentValueArgumentDeclaration,i),ue.addSelfToProject(i),i==null||i.add(ue,W.Added),ue.initChildren(i),i||ue.captureVersion(),a.push(ue),te=ue}}else{const se={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:ei.CURRENT_VALUE_ARG_NAME,codeName:null,description:null,index:this.body.inputs.length,required:!0,constant:!0,defaultValue:null,implements:[ee],writesValues:[],dataType:null,parent:this.body.toReference()},te=ge(se,this.project);te.hydrateAncestors(),te.setParent(this.body,i),te.addSelfToProject(i),i==null||i.add(te,W.Added),te.initChildren(i),ee&&!te.implements.find(le=>le.id===ee.id)&&(te.addImplementation(ee,i),r.push(te)),a.push(te),i||te.captureVersion()}break}}const{updated:f,added:h,removed:m}=this.removeExtraBodyArgumentDeclarations(i);return r.push(...f),a.push(...h),c.push(...m),i==null||i.attemptAutoclose("create-current-value-input-based-on-input-map",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncFixedBodyArgumentDeclarations(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-fixed-body-argument-declarations"))){const r=[],a=[],c=[],e=[],{updated:f,added:h,removed:m}=this.createCurrentIterationNumberArgumentDeclaration(i);r.push(...f),a.push(...h),c.push(...m);const{updated:E,added:b,removed:A}=this.createCurrentValueInputBasedOnInputMap(i);return r.push(...E),a.push(...b),c.push(...A),i==null||i.attemptAutoclose("sync-fixed-body-argument-declarations",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncInputMaps(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-input-maps"))){const r=[],a=[],c=[],e=[];switch(this.declaration.id){case ft.List:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===ne[d.Loop]["list-loop"].inputs.list.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==ne[d.Loop]["list-loop"].inputs.list.id){const m=this.project.get(ne[d.Loop]["list-loop"].inputs.list.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(ne[d.Loop]["list-loop"].inputs.list.id),E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,name:null,codeName:null,description:null,index:0,declaration:m.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},b=ge(E,this.project);b.hydrateAncestors(),b.setParent(this,i),b.addSelfToProject(i),i==null||i.add(b,W.Added),b.initChildren(i),i||b.captureVersion(),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==ne[d.Loop]["list-loop"].inputs.list.id&&(m.remove({ignoreUpstream:!1},i),c.push(m))}),this.inputs.sort((m,E)=>B(m.createdAt).isBefore(B(E.createdAt))?-1:1).forEach((m,E)=>{E!==0&&(m.remove({ignoreUpstream:!1},i),c.push(m))});break}case ft.ManualFlow:{this.inputs.forEach(f=>{f.remove({ignoreUpstream:!1},i),c.push(f)});break}case ft.Counted:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===ne[d.Loop]["counted-loop"].inputs.number.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==ne[d.Loop]["counted-loop"].inputs.number.id){const m=this.project.get(ne[d.Loop]["counted-loop"].inputs.number.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(ne[d.Loop]["counted-loop"].inputs.number.id),E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,name:null,codeName:null,description:null,index:0,declaration:m.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},b=ge(E,this.project);b.hydrateAncestors(),b.setParent(this,i),b.addSelfToProject(i),i==null||i.add(b,W.Added),b.initChildren(i),i||b.captureVersion(),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==ne[d.Loop]["counted-loop"].inputs.number.id&&(m.remove({ignoreUpstream:!1},i),c.push(m))}),this.inputs.sort((m,E)=>B(m.createdAt).isBefore(B(E.createdAt))?-1:1).forEach((m,E)=>{E!==0&&(m.remove({ignoreUpstream:!1},i),c.push(m))});break}case ft.ObjectKeys:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===ne[d.Loop]["object-keys-loop"].inputs.object.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==ne[d.Loop]["object-keys-loop"].inputs.object.id){const m=this.project.get(ne[d.Loop]["object-keys-loop"].inputs.object.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(ne[d.Loop]["object-keys-loop"].inputs.object.id),E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,name:null,codeName:null,description:null,index:0,declaration:m.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},b=ge(E,this.project);b.hydrateAncestors(),b.setParent(this,i),b.addSelfToProject(i),i==null||i.add(b,W.Added),b.initChildren(i),i||b.captureVersion(),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==ne[d.Loop]["object-keys-loop"].inputs.object.id&&(m.remove({ignoreUpstream:!1},i),c.push(m))}),this.inputs.sort((m,E)=>B(m.createdAt).isBefore(B(E.createdAt))?-1:1).forEach((m,E)=>{E!==0&&(m.remove({ignoreUpstream:!1},i),c.push(m))});break}case ft.ObjectValues:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===ne[d.Loop]["object-values-loop"].inputs.object.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==ne[d.Loop]["object-values-loop"].inputs.object.id){const m=this.project.get(ne[d.Loop]["object-values-loop"].inputs.object.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(ne[d.Loop]["object-values-loop"].inputs.object.id),E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,name:null,codeName:null,description:null,index:0,declaration:m.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},b=ge(E,this.project);b.hydrateAncestors(),b.setParent(this,i),b.addSelfToProject(i),i==null||i.add(b,W.Added),b.initChildren(i),i||b.captureVersion(),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==ne[d.Loop]["object-values-loop"].inputs.object.id&&(m.remove({ignoreUpstream:!1},i),c.push(m))}),this.inputs.sort((m,E)=>B(m.createdAt).isBefore(B(E.createdAt))?-1:1).forEach((m,E)=>{E!==0&&(m.remove({ignoreUpstream:!1},i),c.push(m))});break}case ft.String:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===ne[d.Loop]["string-loop"].inputs.string.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==ne[d.Loop]["string-loop"].inputs.string.id){const m=this.project.get(ne[d.Loop]["string-loop"].inputs.string.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(ne[d.Loop]["string-loop"].inputs.string.id),E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,name:null,codeName:null,description:null,index:0,declaration:m.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},b=ge(E,this.project);b.hydrateAncestors(),b.setParent(this,i),b.addSelfToProject(i),i==null||i.add(b,W.Added),b.initChildren(i),i||b.captureVersion(),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==ne[d.Loop]["string-loop"].inputs.string.id&&(m.remove({ignoreUpstream:!1},i),c.push(m))}),this.inputs.sort((m,E)=>B(m.createdAt).isBefore(B(E.createdAt))?-1:1).forEach((m,E)=>{E!==0&&(m.remove({ignoreUpstream:!1},i),c.push(m))});break}}return this.inputs.forEach(f=>{const{updated:h,added:m,removed:E}=f.afterAllChildrenInitialized(i);r.push(...h),a.push(...m),c.push(...E)}),this.inputs.sort((f,h)=>f.index-h.index),i==null||i.attemptAutoclose("sync-input-maps",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}getValueInputMapDeclarationId(){switch(this.declaration.id){case ft.List:return ne[d.Loop]["list-loop"].inputs.list.id;case ft.ObjectKeys:return ne[d.Loop]["object-keys-loop"].inputs.object.id;case ft.ObjectValues:return ne[d.Loop]["object-values-loop"].inputs.object.id;case ft.String:return ne[d.Loop]["string-loop"].inputs.string.id;case ft.Counted:return ne[d.Loop]["counted-loop"].inputs.number.id;default:return null}}getCurrentValueBuiltInValueDescriptor(){var r;if(this.declaration.id===ft.ManualFlow||this.declaration.id===ft.Counted)return null;const i=(r=ne[d.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:r.id;return i?this.project.get(i):null}getCurrentIterationNumberBuiltInValueDescriptor(){const i=ne[d.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(i)}syncBody(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-body"))){var m;const r=[],a=[],c=[],e=[],f=ne[d.Loop][this.declaration.id].body.id,h=this.project.getBuiltIn(f);if(this.body)((m=this.body.implements)==null?void 0:m.id)!==h.id&&(this.body.setImplements(h,i),this.body.setParent(this,i),r.push(this.body));else{const E=Td.new(i);E.implements=h.toJSON(),E.name=h.name,E.parent=this.toReference();const b=ge(E,this.project);b.hydrateAncestors(),b.setParent(this,i),b.addSelfToProject(i),i==null||i.add(b,W.Added),b.initChildren(i),i||b.captureVersion(),a.push(b)}return i==null||i.attemptAutoclose("sync-body",this.id),{self:this,updated:C(r),added:C(a),removed:C(c),affected:C(e)}}checkIsSynced(){var b,A,_,P,V,j,M,G,q,re,ee,se,te,le,ue,z,X,pe,de,me,ve,we,Re,xe,je;if((!this.body||!((b=this.body)!=null&&b.dataType)||!((A=this.body)!=null&&A.dataType.entity))&&this.id)return!1;const i=[ft.List,ft.ObjectKeys,ft.ObjectValues,ft.String],r=this.body.inputs.find(Se=>Se.implements.find(Je=>Je.id===ne[d.Loop][this.declaration.id].body.inputs.iterationNumber.id))||null,a=this.body.inputs.find(Se=>Se.implements.find(Je=>{var Ze;return Je.id===((Ze=ne[d.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:Ze.id)}))||null;if(!r||i.includes(this.declaration.id)&&!a)return!1;const c=[...this.breakStatements,...this.continueStatements];if(((V=(P=(_=this.body)==null?void 0:_.dataType)==null?void 0:P.entity)==null?void 0:V.id)!==ne["primitive-entity"].void.id){if(!this.body.inputs.find(Je=>{var Ze,et,Dt,jt,Li;return((et=(Ze=Je.dataType)==null?void 0:Ze.entity)==null?void 0:et.id)===((Li=(jt=(Dt=this.body)==null?void 0:Dt.dataType)==null?void 0:jt.entity)==null?void 0:Li.id)})||((G=(M=(j=this.body)==null?void 0:j.dataType)==null?void 0:M.entity)==null?void 0:G.type)===d.DefinitionEntity&&(!((re=(q=this.body)==null?void 0:q.dataType)==null?void 0:re.entity).properties.every(et=>this.outputs.find(Dt=>{var jt;return((jt=Dt.declaration)==null?void 0:jt.id)===et.id}))||!c.every(et=>{var Ti,tn;const Dt=et.outputs.filter(yr=>!yr.deleted),jt=((tn=(Ti=this.body)==null?void 0:Ti.dataType)==null?void 0:tn.entity).properties.every(yr=>Dt.find(or=>{var un;return((un=or.declaration)==null?void 0:un.id)===yr.id})),Li=Dt.every(yr=>{var or,un;return((un=(or=this.body)==null?void 0:or.dataType)==null?void 0:un.entity).properties.find(Vs=>{var xr;return Vs.id===((xr=yr.declaration)==null?void 0:xr.id)})});return jt&&Li})))return!1}else if(this.body.inputs.find(Ze=>{var et,Dt,jt,Li,Ti;return((Dt=(et=Ze.dataType)==null?void 0:et.entity)==null?void 0:Dt.id)===((Ti=(Li=(jt=this.body)==null?void 0:jt.dataType)==null?void 0:Li.entity)==null?void 0:Ti.id)})||this.outputs.length>0||![...this.breakStatements,...this.continueStatements].every(Ze=>Ze.outputs.filter(et=>!et.deleted).length===0))return!1;if([ft.List,ft.Counted,ft.ObjectKeys,ft.ObjectValues,ft.String].includes(this.declaration.id)){if(this.inputs.length!==1)return!1;const Se=this.inputs[0],Je=this.getValueInputMapDeclarationId();if(((ee=Se.declaration)==null?void 0:ee.id)!==Je)return!1}else if(this.inputs.length>0)return!1;if((te=(se=this.body)==null?void 0:se.dataType)!=null&&te.inferred){const Se=this.getUniqueInputMaps();if(c.every(Dt=>!Dt.readsValue)&&!Se.length&&((z=(ue=(le=this.body)==null?void 0:le.dataType)==null?void 0:ue.entity)==null?void 0:z.id)!==ne["primitive-entity"].void.id)return!1;const Ze=c.find(Dt=>Dt.readsValue),et=(de=(pe=(X=Ze==null?void 0:Ze.readsValue)==null?void 0:X.getDataType(null))==null?void 0:pe.entity)==null?void 0:de.id;if(et&&et!==((we=(ve=(me=this.body)==null?void 0:me.dataType)==null?void 0:ve.entity)==null?void 0:we.id))return!1}const f=((je=(xe=(Re=this.body)==null?void 0:Re.dataType)==null?void 0:xe.entity)==null?void 0:je.properties)||[],h=this.outputs,m=f.every(Se=>h.find(Je=>{var Ze;return((Ze=Je.declaration)==null?void 0:Ze.id)===Se.id})),E=h.every(Se=>f.find(Je=>{var Ze;return Je.id===((Ze=Se.declaration)==null?void 0:Ze.id)}));return!(!m||!E)}syncFromDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-from-data-type"))){const r=[],a=[],c=[],e=[],{updated:f,added:h,removed:m}=this.syncOutputDataType(i);r.push(...f),a.push(...h),c.push(...m);const{updated:E,added:b,removed:A}=this.syncBodyArgumentsDeclarations(i);r.push(...E),a.push(...b),c.push(...A);const{updated:_,added:P,removed:V}=this.syncBodyInputIndexes(i);r.push(..._),a.push(...P),c.push(...V);const{updated:j,added:M,removed:G}=this.syncOutputMaps(i);return r.push(...j),a.push(...M),c.push(...G),i==null||i.attemptAutoclose("sync-from-data-type",this.id),{self:this,updated:C(r),added:C(a),removed:C(c),affected:C(e)}}syncChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-children"))){const r=[],a=[],c=[],e=[],{updated:f,added:h,removed:m}=this.syncBody(i);r.push(...f),a.push(...h),c.push(...m);const{updated:E,added:b,removed:A}=this.syncInputMaps(i);r.push(...E),a.push(...b),c.push(...A);const{updated:_,added:P,removed:V}=this.syncTerminationStatements(i);r.push(..._),a.push(...P),c.push(...V);const{updated:j,added:M,removed:G}=this.syncFromDataType(i);return r.push(...j),a.push(...M),c.push(...G),i==null||i.attemptAutoclose("sync-children",this.id),{self:this,updated:C(r),added:C(a),removed:C(c),affected:C(e)}}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)}addValueReader(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddValueReader))){var e,f,h,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,w.AddValueReader,r))return this;(i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.SetValueWriter}-${this.id}`,action:w.SetValueWriter,owner:this,errorReason:Be.CannotValueWriteItself,rootAction:((e=r==null?void 0:r.self)==null?void 0:e.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.SetValueWriter}));const a=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((f=i.declaration)==null?void 0:f.type)===d.Property&&((h=i.declaration)==null?void 0:h.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(a||c)&&i?(r==null||r.event({id:`${w.SetValueWriter}-${this.id}--${i.id}`,action:w.SetValueWriter,owner:i,counterpart:this,errorReason:Be.ValueReadingOverridesConstantVariable,rootAction:!1}),r==null||r.attemptAutoclose(w.AddValueReader,this.id),this):this.writesValues.includes(i)?(r==null||r.attemptAutoclose(w.AddValueReader,this.id),this):(this.writesValues.push(i),r==null||r.add(this,W.Affected),this)}setDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetDataType,this.id),this;const a=this.dataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.dataType=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetDataType,this.id),this}removeValueReader(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,w.RemoveValueReader,r)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(a=>a.id!==i.id),r==null||r.add(this,W.Affected),this):(r==null||r.attemptAutoclose(w.RemoveValueReader,this.id),this):this}removeDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.dataType=null),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this):(Y.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){var r;return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||((r=this.body)==null?void 0:r.dataType)||null}};R(ei,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(ei,"type",d.Loop),R(ei,"USER_MANAGED_PARENT_TYPES",[...Ir,d.Project]),R(ei,"PARENT_TYPES",[...Ji.USER_MANAGED_PARENT_TYPES]),R(ei,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),R(ei,"CURRENT_VALUE_ARG_NAME","Current value"),R(ei,"MUTABLE_BASE_PROPERTIES",["catchesError"]),R(ei,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(ei,"BASE_PROPERTIES",[...ei.MUTABLE_BASE_PROPERTIES,...ei.INMUTABLE_BASE_PROPERTIES]),R(ei,"MUTABLE_META_PROPERTIES",[...ei.MUTABLE_BASE_PROPERTIES,"x","y"]),R(ei,"INMUTABLE_META_PROPERTIES",[...ei.INMUTABLE_BASE_PROPERTIES]),R(ei,"META_PROPERTIES",[...ei.MUTABLE_META_PROPERTIES,...ei.INMUTABLE_META_PROPERTIES]),R(ei,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),R(ei,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration","dataType"]),R(ei,"UPSTREAM_PROPERTIES",[...ei.MUTABLE_UPSTREAM_PROPERTIES,...ei.INMUTABLE_UPSTREAM_PROPERTIES]),R(ei,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","successCalls","errorCalls","error","breakStatements","continueStatements"]),R(ei,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(ei,"DOWNSTREAM_PROPERTIES",[...ei.MUTABLE_DOWNSTREAM_PROPERTIES,...ei.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(ei,"PROPERTIES",[...ei.META_PROPERTIES,...ei.UPSTREAM_PROPERTIES,...ei.DOWNSTREAM_PROPERTIES]);let _p=ei;async function nVe(s,p={}){const i=Y.YieldTracker.from(p),r=Aa(s),a=ga(s),c=[...r,...a],e=St(s.errors,c);await i.tick();for(const f of s.inputs)await f.validateAsync({tracker:i});return e}function aVe(s){s.inputs.forEach(a=>a.validate());const p=Aa(s),i=ga(s),r=[...p,...i];return St(s.errors,r)}const Lgi=Object.freeze(Object.defineProperty({__proto__:null,validate:aVe,validateAsync:nVe},Symbol.toStringTag,{value:"Module"}));var sVe=(s=>(s.Parent="parent",s))(sVe||{});const Gi=class Gi extends dn{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"x");R(this,"y");R(this,"type",d.Condition);R(this,"index",null);R(this,"successCalls",[]);R(this,"errorCalls",[]);R(this,"declaration");R(this,"inputs",[]);R(this,"calledBySuccess",[]);R(this,"calledByError",[]);R(this,"calledByEntry",[]);R(this,"andChildrenGroup",null);R(this,"orChildrenGroup",null);R(this,"project");R(this,"errors",[]);R(this,"parent");R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);this.initialData=i,this.project=r,this.id=i.id,this.x=i.x,this.y=i.y,this.index=i.index??null}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Condition,declaration:null,index:null,inputs:[],parent:null,andChildrenGroup:null,orChildrenGroup:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(i,r,a){var P,V;const c=a===void 0?r.addChangeSet(new S(r,x.sessionAuthor,B().toISOString(),r,!0,w.CreateFromGenerationTarget)):a;let e=r;if(i.parent){const j=ie(i.parent);e=r.get(j)}const f=(i.calledByEntry||[]).map(j=>{const M=ie(j);return r.get(M)}),h=(i.calledBySuccess||[]).map(j=>{const M=ie(j);return r.get(M)}),m=(i.calledByError||[]).map(j=>{const M=ie(j);return r.get(M)});let E;if(i.declaration){const j=ie(i.declaration);E=r.get(j)}let b=null;e&&e.type===d.Condition&&(((P=e.declaration)==null?void 0:P.id)===Cr.Or?b=(e.orChildrenGroup||[]).length:((V=e.declaration)==null?void 0:V.id)===Cr.And&&(b=(e.andChildrenGroup||[]).length));const A={id:i.id,version:x.UUID.uuid(),createdAt:(c==null?void 0:c.timestamp)||B().toISOString(),author:(c==null?void 0:c.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Condition,index:b,declaration:E.toJSON(),andChildrenGroup:[],orChildrenGroup:[],calledByEntry:f.map(j=>j.toReference()),calledBySuccess:h.map(j=>j.toReference()),calledByError:m.map(j=>j.toReference()),errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:e.toReference()},_=ge(A,r);return _.hydrateAncestors(),_.setParent(e,c),_.addSelfToProject(c),c==null||c.add(_,W.Added),_.initChildren(c),c||_.captureVersion(),_}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=Ln(a,{parent:{list:!1,types:[...Ir,d.Project],optional:!0}},r);c.push(...f.explanations),a=f.modifiedData;const h=Qr(a);if(e.push(...f.errors,...h.errors),c.push(...h.explanations),!i.declaration)e.push(new De({id:`${i.id}--${Ce.InvalidObjectStructure}`,code:Ce.InvalidObjectStructure,severity:Te.Error,message:`Entity of type '${i.type}' with id '${i.id}' is missing the 'declaration' property. This property is required for a '${i.type}' entity and must point to one of the built-in action descriptors reserved for '${d.Condition}' entities.`})),c.push({id:Yi.AllConditionActionDescriptors,message:Wg(r)});else if(!r.get(i.declaration))e.push(new De({id:`${i.id}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:Te.Error,message:`Entity of type '${i.type}' with id '${i.id}' has an 'declaration' property that isn't found in the project. The 'declaration' property must point to one of the built-in action descriptors reserved for '${d.Condition}' entities.`})),c.push({id:Yi.AllConditionActionDescriptors,message:Wg(r)});else{const E=xke(i.declaration,r);e.push(...E.errors),c.push(...E.explanations)}return{errors:e,explanations:c,modifiedData:a}}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new De({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:Te.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.
|
|
48
48
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];if(r==="parent"){const{updated:m,added:E,removed:b}=this.remove({ignoreUpstream:!1},a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];if(r==="parent"){const{updated:m,added:E,removed:b}=this.restore({},a);c.push(...m),e.push(...E),f.push(...b)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this.parent.unsubscribeDependents([{entity:this,field:"parent"}]),this}subscribeToDependencies(){var i;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new Gi(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new Gi(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.inputs=[...this.inputs],i.declaration=this.declaration,i.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,i.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new Gi(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.inputs=[...h.inputs],this.declaration=h.declaration,this.andChildrenGroup=h.andChildrenGroup?[...h.andChildrenGroup]:null,this.orChildrenGroup=h.orChildrenGroup?[...h.orChildrenGroup]:null,this.successCalls=[...h.successCalls],this.errorCalls=[...h.errorCalls],this.calledBySuccess=[...h.calledBySuccess],this.calledByError=[...h.calledByError],this.calledByEntry=[...h.calledByEntry],this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){var a,c;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,i.parent){const e=ie(i.parent),f=this.project.get(e),h=this.parent;if(h&&h.id!==(f==null?void 0:f.id)&&this.removeFromParent(r),f)this.setParent(f,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.declaration){const e=ie(i.declaration),f=this.project.get(e);f&&this.setDeclaration(f)}return(a=i.andChildrenGroup)==null||a.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&(this.addToAndGroup(h,r),h.setParent(this,r))}),[...this.andChildrenGroup||[]].forEach(e=>{var h;((h=i.andChildrenGroup)==null?void 0:h.find(m=>ie(m)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&(this.addToOrGroup(h,r),h.setParent(this,r))}),[...this.orChildrenGroup||[]].forEach(e=>{var h;((h=i.orChildrenGroup)==null?void 0:h.find(m=>ie(m)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),i.calledByEntry.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&(this.addEntryCaller(h,r),h.addCall(this,r))}),[...this.calledByEntry].forEach(e=>{i.calledByEntry.find(h=>ie(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),i.calledBySuccess.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&(this.addSuccessCaller(h,r),h.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(e=>{i.calledBySuccess.find(h=>ie(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),i.calledByError.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&(this.addErrorCaller(h,r),h.addErrorCall(this,r))}),[...this.calledByError].forEach(e=>{i.calledByError.find(h=>ie(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const f=ie(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}if(i.declaration){const f=ie(i.declaration),h=this.project.get(f);if(h)this.setDeclaration(h);else throw new Error(`${this.type} with id '${this.id}' has a 'declaration' reference '${f}' that isn't found in the project`)}return(a=i.calledByEntry)==null||a.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addEntryCaller(m,r),m.addCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByEntry' reference '${h}' that isn't found in the project`)}),i.calledByEntry&&[...this.calledByEntry].forEach(f=>{var m;((m=i.calledByEntry)==null?void 0:m.find(E=>ie(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addSuccessCaller(m,r),m.addSuccessCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledBySuccess' reference '${h}' that isn't found in the project`)}),i.calledBySuccess&&[...this.calledBySuccess].forEach(f=>{var m;((m=i.calledBySuccess)==null?void 0:m.find(E=>ie(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addErrorCaller(m,r),m.addErrorCall(this,r);else throw new Error(`${this.type} with id '${this.id}' has a 'calledByError' reference '${h}' that isn't found in the project`)}),i.calledByError&&[...this.calledByError].forEach(f=>{var m;((m=i.calledByError)==null?void 0:m.find(E=>ie(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null);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.declaration){const e=ie(this.initialData.declaration),f=this.project.get(e);f&&(this.setDeclaration(f),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.addErrorCaller(h,null)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){var E,b;if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.initialized=!0,this.parent.type===d.Condition){let A=this.index||0;const _=(this.parent.declaration.id===Cr.And?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(V=>!V.deleted&&V.id!==this.id);_.length&&(A>_.length+1?A=_.length:A<0&&(A=0)),_.find(V=>(V.index||0)===A&&!V.deleted)&&_.filter(V=>(V.index||0)>=A&&!V.deleted).forEach(V=>{V.metaSync({index:(V.index||0)+1},i),i==null||i.add(V,W.Updated),r.push(V)}),this.metaSync({index:A},i)}(E=this.andChildrenGroup)!=null&&E.length&&this.andChildrenGroup.sort((A,_)=>(A.index||0)-(_.index||0)),(b=this.orChildrenGroup)!=null&&b.length&&this.orChildrenGroup.sort((A,_)=>(A.index||0)-(_.index||0)),this.inputs.sort((A,_)=>{var P,V;return(A.index??((P=A.declaration)==null?void 0:P.index))-(_.index??((V=_.declaration)==null?void 0:V.index))});const{updated:f,added:h,removed:m}=this.syncInputs(i);return r.push(...f),a.push(...h),c.push(...m),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];return this.parent===this.project?this.project.addCondition(this):this.parent.type===d.Condition&&(this.parent.declaration.id===Cr.And?this.parent.addToAndGroup(this,i):this.parent.declaration.id===Cr.Or&&this.parent.addToOrGroup(this,i)),this.successCalls.forEach(f=>{f.addSuccessCaller(this,i),r.push(f)}),this.errorCalls.forEach(f=>{f.addErrorCaller(this,i),r.push(f)}),this.calledByEntry.forEach(f=>{f.addCall(this,i),r.push(f)}),this.calledBySuccess.forEach(f=>{f.addSuccessCall(this,i),r.push(f)}),this.calledByError.forEach(f=>{f.addErrorCall(this,i),r.push(f)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveInput))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveInput,this.id),this;const a=this.inputs.findIndex(c=>c.id===i.id);return a>-1&&(this.inputs.splice(a,1),r&&(r==null||r.add(this,W.Affected))),r==null||r.attemptAutoclose(w.RemoveInput,this.id),this}addInput(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddInput))){return this.checkCanEdit(this,r)?this.inputs.includes(i)?(r==null||r.attemptAutoclose(w.AddInput,this.id),this):(this.inputs.push(i),r==null||r.add(this,W.Affected),r==null||r.attemptAutoclose(w.AddInput,this.id),this):(Y.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddInput,this.id),this)}addOutput(i){return this}removeOutput(i){return this}addSuccessCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}--${Be.CannotSuccessCallItself}`,action:w.AddSuccessCaller,owner:this,errorReason:Be.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddSuccessCaller})),this.calledBySuccess.find(e=>e.id===i.id)||(this.calledBySuccess.push(i),r==null||r.add(this,W.Updated),a&&Et(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Be.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Be.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddErrorCaller})),this.calledByError.find(e=>e.id===i.id)||(this.calledByError.push(i),r==null||r.add(this,W.Updated),a&&Et(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddEntryCaller)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddEntryCaller,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddEntryCaller}-${this.id}--${Be.CannotEntryCallItself}`,action:w.AddEntryCaller,owner:this,errorReason:Be.CannotEntryCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddEntryCaller})),this.calledByEntry.find(e=>e.id===i.id)||(this.calledByEntry.push(i),r==null||r.add(this,W.Updated),a&&Et(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}addErrorCall(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddErrorCall)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddErrorCall,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddErrorCaller}-${this.id}--${Be.CannotErrorCallItself}`,action:w.AddErrorCaller,owner:this,errorReason:Be.CannotErrorCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddErrorCaller})),this.errorCalls.find(e=>e.id===i.id)||(this.errorCalls.push(i),a&&Et(this,r),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.AddErrorCall,this.id),this):this}addSuccessCall(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddSuccessCall)),a=!1){var c;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.AddSuccessCall,r)?((i==null?void 0:i.id)===this.id&&(r==null||r.event({id:`${w.AddSuccessCaller}-${this.id}`,action:w.AddSuccessCaller,owner:this,errorReason:Be.CannotSuccessCallItself,rootAction:((c=r==null?void 0:r.self)==null?void 0:c.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.AddSuccessCaller})),this.successCalls.find(e=>e.id===i.id)||(this.successCalls.push(i),a&&Et(this,r),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.AddSuccessCall,this.id),this):this}removeCall(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveCall)),a=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCall,r))return this;const c=this.successCalls.findIndex(f=>f.id===i.id);c>-1&&(this.successCalls.splice(c,1),r==null||r.add(this,W.Affected));const e=this.errorCalls.findIndex(f=>f.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),r==null||r.add(this,W.Affected)),a&&Et(this,r),r==null||r.attemptAutoclose(w.RemoveCall,this.id),this}removeCaller(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveCaller)),a=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.RemoveCaller,r)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,W.Updated),r==null||r.add(c,W.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,W.Updated),r==null||r.add(c,W.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(r==null||r.add(this,W.Updated),r==null||r.add(c,W.Affected),!1)),a&&Et(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}removeChildGroup(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveChildGroup))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[removeChildGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveChildGroup,this.id),this;if(this.andChildrenGroup){const a=this.andChildrenGroup.findIndex(c=>c.id===i.id);a!==-1&&(this.andChildrenGroup.splice(a,1),r==null||r.add(this,W.Updated))}if(this.orChildrenGroup){const a=this.orChildrenGroup.findIndex(c=>c.id===i.id);a!==-1&&(this.orChildrenGroup.splice(a,1),r==null||r.add(this,W.Updated))}return r==null||r.attemptAutoclose(w.RemoveChildGroup,this.id),this}setDeclaration(i){return this.declaration=i,this}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.declaration=ge(this.initialData.declaration,this.project),this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a})),this.successCalls=this.initialData.successCalls.map(r=>{const a=ge(r,this.project);if(a.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(a.type))a.setParent(this.parent.parent,null),a.initChildren(i);else if(a.type===d.ReturnStatement){const c=An(this,this.project);a.setParent(c,null),a.initChildren(i)}else a.type!==d.InternalCall&&(a.setParent(this.parent,null),a.initChildren(i));return a}),this.errorCalls=this.initialData.errorCalls.map(r=>{const a=ge(r,this.project);if(a.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(a.type))a.setParent(this.parent.parent,null),a.initChildren(i);else if(a.type===d.ReturnStatement){const c=An(this,this.project);a.setParent(c,null),a.initChildren(i)}else a.type!==d.InternalCall&&(a.setParent(this.parent,null),a.initChildren(i));return a}),this.inputs=this.initialData.inputs.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.x=a.x!==void 0?a.x:e.x,this.y=a.y!==void 0?a.y:e.y,this.index=a.index!==void 0?a.index:e.index,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await Gi.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await Gi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await Gi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await Gi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await Gi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await Gi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){var f;if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeCondition(this),e.push(this.parent)):((f=this.parent)==null?void 0:f.type)===d.Condition?this.parent.removeChildGroup(this):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),this.andChildrenGroup&&this.andChildrenGroup.forEach(m=>{const{removed:E,updated:b}=m.remove({ignoreUpstream:!0},r);c.push(...E),a.push(...b)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(m=>{const{removed:E,updated:b}=m.remove({ignoreUpstream:!0},r);c.push(...E),a.push(...b)}),this.inputs.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.successCalls.forEach(m=>{a.push(m),m.removeCaller(this,r)}),this.errorCalls.forEach(m=>{a.push(m),m.removeCaller(this,r)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected),this.calledBy.forEach(E=>{a.push(E),E.removeCall(this,r)})}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.andChildrenGroup&&this.andChildrenGroup.forEach(f=>{const{updated:h,added:m}=f.restore({},i);a.push(...h),r.push(...m)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(f=>{const{updated:h,added:m}=f.restore({},i);a.push(...h),r.push(...m)}),this.inputs.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.successCalls.forEach(f=>{a.push(f),f.addSuccessCaller(this,i)}),this.errorCalls.forEach(f=>{a.push(f),f.addErrorCaller(this,i)}),this.calledBySuccess.forEach(f=>{a.push(f),f.addSuccessCall(this,i)}),this.calledByError.forEach(f=>{a.push(f),f.addErrorCall(this,i)}),this.calledByEntry.forEach(f=>{a.push(f),f.addCall(this,i)}),this.parent.type===d.Project&&this.project.addCondition(this),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this})}toFlat(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((a=this.andChildrenGroup)==null?void 0:a.flatMap(e=>e.toFlat(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(e=>e.toFlat(i)))||[],...this.inputs.flatMap(e=>e.toFlat(i)),...this.successCalls.flatMap(e=>e.toFlat(i)),...this.errorCalls.flatMap(e=>e.toFlat(i)),...this.calledBy.flatMap(e=>e.toFlat(i))])}toFlatIds(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((a=this.andChildrenGroup)==null?void 0:a.flatMap(e=>e.toFlatIds(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(e=>e.toFlatIds(i)))||[],...this.inputs.flatMap(e=>e.toFlatIds(i)),...this.successCalls.flatMap(e=>e.toFlatIds(i)),...this.errorCalls.flatMap(e=>e.toFlatIds(i)),...this.calledBy.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,index:this.index,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var r,a;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,index:this.index,x:this.x,y:this.y,declaration:this.declaration.toJSON(i),andChildrenGroup:((r=this.andChildrenGroup)==null?void 0:r.map(c=>c.toJSON(i)))||null,orChildrenGroup:((a=this.orChildrenGroup)==null?void 0:a.map(c=>c.toJSON(i)))||null,successCalls:this.successCalls.map(c=>c.toJSON(i)),errorCalls:this.errorCalls.map(c=>c.toJSON(i)),calledBySuccess:this.calledBySuccess.map(c=>c.toReference()),calledByError:this.calledByError.map(c=>c.toReference()),calledByEntry:this.calledByEntry.map(c=>c.toReference()),inputs:this.inputs.map(c=>c.toJSON(i)),parent:this.parent.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,x:this.x,y:this.y,declaration:this.declaration.toJSON(),andChildrenGroup:((m=this.andChildrenGroup)==null?void 0:m.map(b=>b.toJSONClone({...i,newId:null})))||null,orChildrenGroup:((E=this.orChildrenGroup)==null?void 0:E.map(b=>b.toJSONClone({...i,newId:null})))||null,successCalls:this.successCalls.map(b=>b.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(b=>b.toJSONClone({...i,newId:null})),calledBySuccess:this.calledBySuccess.map(b=>b.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(b=>b.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(b=>b.toReference({seenEntityMaps:i.seenEntityMaps})),inputs:this.inputs.map(b=>b.toJSONClone({...i,newId:null})),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,x:this.x,y:this.y,declaration:this.declaration.toReference(i),andChildrenGroup:((c=this.andChildrenGroup)==null?void 0:c.map(f=>f.toReference(i)))||null,orChildrenGroup:((e=this.orChildrenGroup)==null?void 0:e.map(f=>f.toReference(i)))||null,inputs:this.inputs.map(f=>f.toReference(i)),successCalls:this.successCalls.map(f=>f.toReference(i)),errorCalls:this.errorCalls.map(f=>f.toReference(i)),calledBySuccess:this.calledBySuccess.map(f=>f.toReference(i)),calledByError:this.calledByError.map(f=>f.toReference(i)),calledByEntry:this.calledByEntry.map(f=>f.toReference(i)),parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.andChildrenGroup)==null?void 0:a.flatMap(e=>e.toFlatJSON(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(e=>e.toFlatJSON(i)))||[],...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.calledBy.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(i=at){var c,e;const r=this.parent.type===d.Project?void 0:(c=i.seenEntityMaps)!=null&&c.has(this.parent.id)?i.seenEntityMaps.get(this.parent.id):this.parent.id;let a=this.id;return(e=i.seenEntityMaps)!=null&&e.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(f=>f.id),calledBySuccess:this.calledBySuccess.map(f=>f.id),calledByError:this.calledByError.map(f=>f.id),parent:r}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.andChildrenGroup)==null?void 0:a.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...this.inputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.successCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,r;return this.errors=[],(i=this.andChildrenGroup)==null||i.forEach(a=>a.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(a=>a.clearErrors()),this.inputs.forEach(a=>a.clearErrors()),this.successCalls.forEach(a=>a.clearErrors()),this.errorCalls.forEach(a=>a.clearErrors()),this}validate(){return this.errors=aVe(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await nVe(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors,...this.inputs.flatMap(r=>r.getErrors()),...this.andChildrenGroup?this.andChildrenGroup.flatMap(r=>r.getErrors()):[],...this.orChildrenGroup?this.orChildrenGroup.flatMap(r=>r.getErrors()):[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.inputs){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(await r.tick(),this.andChildrenGroup)for(const c of this.andChildrenGroup){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(this.orChildrenGroup)for(const c of this.orChildrenGroup){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var V,j,M;const e=Ur(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.inputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.deletable=!0,f.editable=!0;const b=nr(f,e);r?b.setParent(r,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,W.Added);const A=(V=this.andChildrenGroup)==null?void 0:V.map(G=>G.clone(i,b,x.UUID.uuid(),c)),_=(j=this.orChildrenGroup)==null?void 0:j.map(G=>G.clone(i,b,x.UUID.uuid(),c));b.andChildrenGroup=A||null,b.orChildrenGroup=_||null;const P=(M=this.inputs)==null?void 0:M.map((G,q)=>G.clone(i,b,E+"-input-map-"+q+"-id",c));return b.inputs=P,i||b.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}addToAndGroup(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddToAndGroup))){return this.checkCanEdit(this,r)?(this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(i)||(this.andChildrenGroup.push(i),r==null||r.add(i,W.Affected)),r==null||r.attemptAutoclose(w.AddToAndGroup,this.id),this):(Y.Logger.warn(`[addToAndGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddToAndGroup,this.id),this)}addToOrGroup(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddToOrGroup))){return this.checkCanEdit(this,r)?(this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(i)||(this.orChildrenGroup.push(i),r==null||r.add(i,W.Affected)),r==null||r.attemptAutoclose(w.AddToOrGroup,this.id),this):(Y.Logger.warn(`[addToOrGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddToOrGroup,this.id),this)}removeUnrecognizedInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.inputs.forEach(h=>{if(!this.declaration.inputs.find(E=>{var b;return E.id===((b=h.declaration)==null?void 0:b.id)})){const E=h.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}}),this.inputs.filter((h,m)=>{const E=this.inputs.findIndex(A=>A.declaration===h.declaration&&A!==h);if(E===-1)return!1;const b=this.inputs[E];return B(b==null?void 0:b.createdAt).isSame(B(h.createdAt))?m>E:!!B(b==null?void 0:b.createdAt).isAfter(h.createdAt)}).forEach(h=>{const m=h.remove({ignoreUpstream:!1},i);c.push(...m.removed),r.push(...m.updated)}),i==null||i.attemptAutoclose(w.RemoveUnrecognizedInputs,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncInputs(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SyncInputs))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[syncInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.SyncInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[],f=this.declaration.inputs.filter(b=>b.parentRelationType===k.FixedArguments&&!this.inputs.find(A=>A.declaration.id===b.id));this.inputs.sort((b,A)=>b.index-A.index),f.forEach(b=>{this.inputs.forEach(P=>{P.index>=b.index&&P.metaSync({index:P.index+1},i)});const A={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,dataType:null,parentRelationType:null,declaration:b.toJSON(),readsValue:null,defaultValue:null,index:b.index,name:null,codeName:null,description:null,parent:this.toReference()},_=ge(A,this.project);_.setParent(this,i),_.addSelfToProject(i),i==null||i.add(_,W.Added),_.initChildren(i),i||_.captureVersion()}),this.inputs.sort((b,A)=>b.index-A.index);const{updated:h,added:m,removed:E}=this.removeUnrecognizedInputs(i);return r.push(...h),a.push(...m),c.push(...E),this.inputs.forEach(b=>{const{updated:A,added:_,removed:P}=b.afterAllChildrenInitialized(i);r.push(...A),a.push(..._),c.push(...P)}),this.inputs.sort((b,A)=>b.index-A.index),i==null||i.attemptAutoclose(w.SyncInputs,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return[]}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return[]}getDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){var a;const r=((a=this.declaration)==null?void 0:a.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),r}};R(Gi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(Gi,"type",d.Condition),R(Gi,"USER_MANAGED_PARENT_TYPES",[...Ir,d.Project,d.Condition]),R(Gi,"PARENT_TYPES",[...Gi.USER_MANAGED_PARENT_TYPES]),R(Gi,"MUTABLE_BASE_PROPERTIES",["operator"]),R(Gi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","index"]),R(Gi,"BASE_PROPERTIES",[...Gi.MUTABLE_BASE_PROPERTIES,...Gi.INMUTABLE_BASE_PROPERTIES]),R(Gi,"MUTABLE_META_PROPERTIES",["x","y"]),R(Gi,"INMUTABLE_META_PROPERTIES",[...Gi.INMUTABLE_BASE_PROPERTIES]),R(Gi,"META_PROPERTIES",[...Gi.MUTABLE_META_PROPERTIES,...Gi.INMUTABLE_META_PROPERTIES]),R(Gi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","parent"]),R(Gi,"INMUTABLE_UPSTREAM_PROPERTIES",[]),R(Gi,"UPSTREAM_PROPERTIES",[...Gi.MUTABLE_UPSTREAM_PROPERTIES,...Gi.INMUTABLE_UPSTREAM_PROPERTIES]),R(Gi,"MUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup","successCalls","errorCalls","inputsDeclarations","inputs"]),R(Gi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(Gi,"DOWNSTREAM_PROPERTIES",[...Gi.MUTABLE_DOWNSTREAM_PROPERTIES,...Gi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(Gi,"PROPERTIES",[...Gi.META_PROPERTIES,...Gi.UPSTREAM_PROPERTIES,...Gi.DOWNSTREAM_PROPERTIES]);let Vp=Gi;async function Bgi(s,p={}){const i=Y.YieldTracker.from(p),r=[],a=St(s.errors,r);return await i.tick(),a}function Mgi(s){const p=[];return St(s.errors,p)}async function lVe(s,p={}){const i=Y.YieldTracker.from(p),r=[],a=St(s.errors,r);return await i.tick(),a}function oVe(s){const p=[];return St(s.errors,p)}const Ggi=Object.freeze(Object.defineProperty({__proto__:null,validate:oVe,validateAsync:lVe},Symbol.toStringTag,{value:"Module"}));function jgi(s,p){const i=[],r=[];if(s.parent)if(s.parent){const a=p.get(s.parent);a?Nr.USER_MANAGED_PARENT_TYPES.includes(a.type)||r.push(new De({id:`${s.id}--${s.parent}--${he.InvalidParentReference}`,code:he.InvalidParentReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has a parent reference which is of type ${a.type}, and therefore that isn't pointing to the following valid types for this reference: '${vt(Nr.USER_MANAGED_PARENT_TYPES,"', '","' or '")}'.`})):r.push(new De({id:`${s.id}--${s.parent}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", is referencing an entity with id "${s.parent}" at 'parent' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}else r.push(new De({id:`${s.id}--${Ce.InvalidObjectStructure}`,code:Ce.InvalidObjectStructure,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}" is missing a 'parent' reference. The 'parent' of a literal value entity must be a reference to an entity of type '${vt(Nr.USER_MANAGED_PARENT_TYPES,"', '","', or '")}'.`}));else return r.push(new De({id:`${s.id}--${Ce.InvalidObjectStructure}`,code:Ce.InvalidObjectStructure,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}" is missing a 'parent' reference. The 'parent' of a literal value entity must be a reference to an entity of type '${vt(Nr.USER_MANAGED_PARENT_TYPES,"', '","', or '")}'.`})),{errors:r,explanations:i};if(s.valueAsTypeSingle){const a=[],c=[],e=s.valueAsTypeSingle;Array.isArray(e)?e.forEach(f=>{typeof f=="string"?c.push(f):a.push(f)}):typeof e=="string"?c.push(e):a.push(e),a.forEach(f=>{const h=X1(f);r.push(...h),h.length===0&&c.push(f.entityId)}),c.forEach(f=>{const h=p.get(f);h?[d.DefinitionEntity,d.BuiltInBaseEntity].includes(h.type)||r.push(new De({id:`${s.id}--${f}--${he.InvalidImplementsReference}`,code:he.InvalidImplementsReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has an 'valueAsTypeSingle' reference which is of type ${h.type}, and therefore that isn't pointing to the following valid types for this reference: 'definition-entity', 'function-declaration' or 'operation'.`})):r.push(new De({id:`${s.id}--${f}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", is referencing an entity with id "${f}" at 'valueAsTypeSingle' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))})}return{errors:r,explanations:i}}var dVe=(s=>(s.ValueAsTypeSingle="value-as-type-single",s.ValueAsTypeList="value-as-type-list",s))(dVe||{});const ci=class ci extends dn{constructor(i,r){super(i);R(this,"initialData");R(this,"type",d.LiteralValue);R(this,"id");R(this,"name");R(this,"autogeneration",null);R(this,"value",null);R(this,"valueAsTypeSingle",null);R(this,"valueAsTypeList",null);R(this,"errors",[]);R(this,"parent");R(this,"standaloneParent");R(this,"project");R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"standalone",!1);if(this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.autogeneration=i.autogeneration,this.value=i.value,!this.name)throw new Error("[LiteralValueState.constructor] Must have a name in the initial data passed to the constructor")}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:"",autogeneration:null,value:null,valueAsTypeSingle:null,valueAsTypeList:null,parent:null}}static fromGenerationTarget(i,r,a){const c=a===void 0?r.addChangeSet(new S(r,x.sessionAuthor,B().toISOString(),r,!0,w.CreateFromGenerationTarget)):a,e=ie(i.parent),f=r.get(e);let h=null,m=null;i.valueAsTypeList?Array.isArray(i.valueAsTypeList)&&(m=i.valueAsTypeList.map(A=>r.get(A)||r.getBuiltIn(A))):i.valueAsTypeSingle&&(h=r.get(i.valueAsTypeSingle)||r.getBuiltIn(i.valueAsTypeSingle));const E={id:i.id,version:x.UUID.uuid(),createdAt:(c==null?void 0:c.timestamp)||B().toISOString(),author:(c==null?void 0:c.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:i.name,autogeneration:i.autogeneration,valueAsTypeSingle:h,valueAsTypeList:m,value:i.value||null,parent:f.toReference()},b=ge(E,r);return b.hydrateAncestors(),b.setParent(f,c),b.addSelfToProject(c),c==null||c.add(b,W.Added),b.initChildren(c),c||b.captureVersion(),b}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));(a.valueAsTypeList||a.valueAsTypeSingle)&&(a.name=fe.EntityTemplate);const c=[],e=[],f=jgi(a,r),h=Qr(a);return e.push(...f.errors,...h.errors),c.push(...f.explanations,...h.explanations),{errors:e,explanations:c,modifiedData:a}}get valueAsType(){return this.valueAsTypeSingle?this.valueAsTypeSingle:this.valueAsTypeList?this.valueAsTypeList:null}get isFinal(){return!!(this.parent.type===d.Property&&(this.parent.constant||this.parent.implements.some(i=>i.constant))||this.parent.type===d.Property&&this.parent.parent.type===d.DefinitionEntity&&!bl(this.parent.parent))}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new De({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:Te.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
49
|
-
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return r==="value-as-type-single"&&(this.valueAsTypeSingle=null,a==null||a.add(this,W.Updated)),r==="value-as-type-list"&&(this.valueAsTypeList=(this.valueAsTypeList||[]).filter(m=>m.id!==i.id),a==null||a.add(this,W.Updated)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return r==="value-as-type-single"&&(this.valueAsTypeSingle=i,a==null||a.add(this,W.Updated)),r==="value-as-type-list"&&(this.valueAsTypeList=[...Array.isArray(this.valueAsTypeList||[])?this.valueAsTypeList:[],i],a==null||a.add(this,W.Updated)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.unsubscribeDependents([{entity:this,field:"value-as-type-single"}]),this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.unsubscribeDependents([{entity:this,field:"value-as-type-list"}])}),this}subscribeToDependencies(){return!this.valueAsTypeSingle&&!this.valueAsTypeList?this:(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.subscribeDependents([{entity:this,field:"value-as-type-list"}])}):this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.subscribeDependents([{entity:this,field:"value-as-type-single"}]),this)}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new ci(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new ci(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.valueAsTypeSingle=this.valueAsTypeSingle,i.valueAsTypeList=this.valueAsTypeList?[...this.valueAsTypeList]:this.valueAsTypeList,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new ci(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.valueAsTypeSingle=h.valueAsTypeSingle,this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent&&i.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(i.parent){const a=ie(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else if(i.standaloneParent){const a=ie(i.standaloneParent),c=this.project.get(a);if(c)this.setStandaloneParent(c,r);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${a}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.valueAsTypeList&&Array.isArray(i.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],i.valueAsTypeList.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&this.addValueAsTypeToList(e,r)}),[...this.valueAsTypeList].forEach(a=>{(i.valueAsTypeList||[]).find(e=>ie(e)===a.id)||this.removeValueAsTypeFromList(a,r)}),this.setValueAsTypeSingle(null,r),this.metaSync({value:null},r);else if(i.valueAsTypeSingle){const a=ie(i.valueAsTypeSingle),c=this.project.get(a);c&&(this.setValueAsTypeSingle(c,r),this.setValueAsTypeList(null,r),this.metaSync({value:null},r))}else this.setValueAsTypeSingle(null,r),this.setValueAsTypeList(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent&&i.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(i.parent){const a=ie(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else if(i.standaloneParent){const a=ie(i.standaloneParent),c=this.project.get(a);if(c)this.setStandaloneParent(c,r);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${a}' that isn't found in the project`)}if(i.valueAsTypeList&&Array.isArray(i.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],i.valueAsTypeList.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&this.addValueAsTypeToList(e,r)}),[...this.valueAsTypeList].forEach(a=>{(i.valueAsTypeList||[]).find(e=>ie(e)===a.id)||this.removeValueAsTypeFromList(a,r)}),this.setValueAsTypeSingle(null,r),this.metaSync({value:null},r);else if(i.valueAsTypeSingle){const a=ie(i.valueAsTypeSingle),c=this.project.get(a);c&&(this.setValueAsTypeSingle(c,r),this.setValueAsTypeList(null,r),this.metaSync({value:null},r))}return(i.valueAsTypeSingle===null||i.valueAsTypeList||i.value!==null&&i.value!==void 0)&&this.setValueAsTypeSingle(null,r),(i.valueAsTypeList===null||i.valueAsTypeSingle||i.value!==null&&i.value!==void 0)&&this.setValueAsTypeList(null,r),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent&&this.initialData.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(Y.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating parent reference '${e}' for entity with id '${this.id}'`),f)Y.Logger.log(`[LiteralValueState.hydrateAncestors] Setting parent reference '${f.id}' for entity with id '${this.id}'`),this.setParent(f,null),i.push(f);else throw Y.Logger.error(`[LiteralValueState.hydrateAncestors] Parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else if(this.initialData.standaloneParent){const e=ie(this.initialData.standaloneParent),f=this.project.get(e);if(Y.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating standalone parent reference '${e}' for entity with id '${this.id}'`),f)Y.Logger.log(`[LiteralValueState.hydrateAncestors] Setting standalone parent reference '${f.id}' for entity with id '${this.id}'`),this.setStandaloneParent(f,null);else throw Y.Logger.error(`[LiteralValueState.hydrateAncestors] Standalone parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${e}' that isn't found in the project`)}else throw Y.Logger.error(`[LiteralValueState.hydrateAncestors] Entity with id '${this.id}' must have a 'parent'`),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],this.initialData.valueAsTypeList.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.valueAsTypeList.push(h)});else if(this.initialData.valueAsTypeSingle){const e=ie(this.initialData.valueAsTypeSingle),f=this.project.get(e);f&&(this.valueAsTypeSingle=f)}return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.initialized=!0,i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){var f,h;const r=[this],a=[],c=[],e=[];return((f=this.parent)==null?void 0:f.type)===d.DataType?this.parent.setEntity(this,i):(h=this.parent)==null||h.setDefaultValue(this,i),e.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setStandaloneParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetStandaloneParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetStandaloneParent,r)?(((a=this.standaloneParent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.standaloneParent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetStandaloneParent,this.id),this):this}addValueAsTypeToList(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddValueAsTypeToList))){return this.checkCanEdit(this,r)?((this.valueAsTypeList||[]).includes(i)||(this.valueAsTypeList=this.valueAsTypeList||[],this.valueAsTypeList.push(i),this.value!==null&&this.metaSync({value:null},r),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,r==null||r.add(this,W.Updated)),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddValueAsTypeToList,this.id),this):(Y.Logger.warn(`[addValueAsTypeToList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddValueAsTypeToList,this.id),this)}removeValueAsTypeFromList(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveValueAsTypeFromList))){return this.checkCanEdit(this,r)?(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&(this.valueAsTypeList||[]).includes(i)&&(this.valueAsTypeList=this.valueAsTypeList.filter(a=>a.id!==i.id),this.valueAsTypeList.length===0?this.valueAsTypeList=null:(this.value!==null&&this.metaSync({value:null},r),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,r==null||r.add(this,W.Updated))),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveValueAsTypeFromList,this.id),this):(Y.Logger.warn(`[removeValueAsTypeFromList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveValueAsTypeFromList,this.id),this)}setValueAsTypeSingle(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueAsTypeSingle))){return this.checkCanEdit(this,r)?(this.valueAsTypeSingle!==i&&(this.valueAsTypeSingle=i,r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.SetValueAsTypeSingle,this.id),this):(Y.Logger.warn(`[setValueAsTypeSingle] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetValueAsTypeSingle,this.id),this)}setValueAsTypeList(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueAsTypeList))){var a,c;return this.checkCanEdit(this,r)?(!i&&this.valueAsTypeList?(this.valueAsTypeList=null,r==null||r.add(this,W.Updated)):i&&!this.valueAsTypeList?(this.valueAsTypeList=i,r==null||r.add(this,W.Updated)):i&&this.valueAsTypeList&&((a=this.valueAsTypeList)==null?void 0:a.length)!==i.length?(this.valueAsTypeList=i,r==null||r.add(this,W.Updated)):i&&this.valueAsTypeList&&((c=this.valueAsTypeList)!=null&&c.every((e,f)=>e!==i[f]))&&(this.valueAsTypeList=i,r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.SetValueAsTypeList,this.id),this):(Y.Logger.warn(`[setValueAsTypeList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetValueAsTypeList,this.id),this)}setValueAsType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueAsType))){return this.checkCanEdit(this,r)?i?(Array.isArray(i)?this.setValueAsTypeList(i,r):this.setValueAsTypeSingle(i,r),r==null||r.attemptAutoclose(w.SetValueAsType,this.id),this):(this.setValueAsTypeSingle(null,r),this.setValueAsTypeList(null,r),this):(Y.Logger.warn(`[setValueAsType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetValueAsType,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.standalone){if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(r=>{if(r.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(r);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.entityType}' with id '${r.entityId}' that is not part of the project state.`);return c}const a=this.project.get(r.id);if(!a)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.type}' with id '${r.id}' that is not part of the project state.`);return a});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const a=this.project.findSubscribedBuiltInInstanceFromReference(this.initialData.valueAsTypeSingle);if(!a)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=a,this}const r=this.project.get(this.initialData.valueAsTypeSingle.id);if(!r)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=r}return this}if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(r=>{if(r.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(r);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.entityType}' with id '${r.entityId}' that is not part of the project state.`);return c}const a=this.project.get(r.id);if(!a)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.type}' with id '${r.id}' that is not part of the project state.`);return a});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const a=ie(this.initialData.valueAsTypeSingle),c=a?this.project.get(a):null;if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=c,this}const r=this.project.get(this.initialData.valueAsTypeSingle.id);if(!r)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=r}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.autogeneration=a.autogeneration!==void 0?a.autogeneration:e.autogeneration,this.value=a.value!==void 0?a.value:e.value,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await ci.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await ci.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await ci.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await ci.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await ci.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await ci.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent&&(this.parent.type===d.DataType?this.parent.setEntity(null,i):pI.includes(this.parent.type)&&this.parent.setDefaultValue(null,i),e.push(this.parent)),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected)}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlat(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlat(i)):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatIds(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlatIds(i)):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,value:this.value,autogeneration:this.autogeneration,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:((r=this.valueAsTypeSingle)==null?void 0:r.toJSON(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(e=>e.toJSON(i)):null,parent:(a=this.parent)==null?void 0:a.toReference(),standaloneParent:(c=this.standaloneParent)==null?void 0:c.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:this.valueAsTypeSingle?this.project.getBuiltIn(this.valueAsTypeSingle.id)?this.valueAsTypeSingle.toJSON():this.valueAsTypeSingle.toJSONClone({...i,newId:null}):null,valueAsTypeList:this.valueAsTypeSingle&&Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(b=>this.project.getBuiltIn(b.id)?b.toJSON(i.seenEntities):b.toJSONClone({...i,newId:null})):null,parent:(m=this.parent)==null?void 0:m.toReference({seenEntityMaps:i.seenEntityMaps}),standaloneParent:(E=this.standaloneParent)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,valueAsTypeSingle:((c=this.valueAsTypeSingle)==null?void 0:c.toReference(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(h=>h.toReference(i)):null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.toReference(i),standaloneParent:(f=this.standaloneParent)==null?void 0:f.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatJSON(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlatJSON(i)):[]])}toGenerationTarget(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,name:this.name,valueAsTypeSingle:((c=this.valueAsTypeSingle)==null?void 0:c.id)||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(h=>h.id):null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.id,standaloneParent:(f=this.standaloneParent)==null?void 0:f.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatGenerationTarget(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlatGenerationTarget(i)):[]])}clearErrors(){return this.errors=[],this}validate(){return this.errors=oVe(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await lVe(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];return await r.tick(),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){const e=Ur(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.editable=!0,f.deletable=!0;const m=nr(f,e);return m.hydrateAncestors(),r&&m.setParent(r,i),c&&(m.subscribe(),m.addSelfToProject(i)),i==null||i.add(m,W.Added),m.initChildren(i),i||m.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),m}merge(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"merge-literal-value"))){const a=[],c=[],e=[],f=[];return this.valueAsTypeSingle!==(i==null?void 0:i.valueAsTypeSingle)&&(this.setValueAsType(i.valueAsTypeSingle,r),a.push(this)),this.valueAsTypeList!==i.valueAsTypeList&&(this.setValueAsTypeList(i.valueAsTypeList,r),a.push(this)),this.value!==i.value&&(this.metaSync({value:i.value},r),a.push(this)),this.autogeneration!==i.autogeneration&&(this.metaSync({autogeneration:i.autogeneration},r),a.push(this)),this.name!==i.name&&(this.metaSync({name:i.name},r),a.push(this)),r==null||r.attemptAutoclose("merge-literal-value",this.id),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}};R(ci,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(ci,"type",d.LiteralValue),R(ci,"USER_MANAGED_PARENT_TYPES",[d.DataType,d.InputMap,d.Property,d.ArgumentDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement,d.VariableDeclaration,d.VariableInstance,d.ValueDescriptor]),R(ci,"USER_MANAGED_STANDALONE_PARENT_TYPES",[...uI]),R(ci,"PARENT_TYPES",[...ci.USER_MANAGED_PARENT_TYPES]),R(ci,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),R(ci,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(ci,"BASE_PROPERTIES",[...ci.MUTABLE_BASE_PROPERTIES,...ci.INMUTABLE_BASE_PROPERTIES]),R(ci,"MUTABLE_META_PROPERTIES",[...ci.MUTABLE_BASE_PROPERTIES]),R(ci,"INMUTABLE_META_PROPERTIES",[...ci.INMUTABLE_BASE_PROPERTIES]),R(ci,"META_PROPERTIES",[...ci.MUTABLE_META_PROPERTIES,...ci.INMUTABLE_META_PROPERTIES]),R(ci,"MUTABLE_UPSTREAM_PROPERTIES",["valueAsTypeSingle","valueAsTypeList"]),R(ci,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(ci,"UPSTREAM_PROPERTIES",[...ci.MUTABLE_UPSTREAM_PROPERTIES,...ci.INMUTABLE_UPSTREAM_PROPERTIES]),R(ci,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),R(ci,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(ci,"DOWNSTREAM_PROPERTIES",[...ci.MUTABLE_DOWNSTREAM_PROPERTIES,...ci.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(ci,"PROPERTIES",[...ci.META_PROPERTIES,...ci.UPSTREAM_PROPERTIES,...ci.DOWNSTREAM_PROPERTIES]);let Nr=ci;function ey(s){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const i=new Uint8Array(s);return crypto.getRandomValues(i),i}const{randomBytes:p}=require("crypto");return p(s)}function uVe(s,p){const i=p-s+1,a=h1()*i;return Math.floor(a)+s}function pVe(){const s=ey(4);return(s[0]<<24|s[1]<<16|s[2]<<8|s[3])>>>0}function h1(){return pVe()/2**32}function jx(s){const p=ey(s);return Array.from(p).map(i=>i.toString(16).padStart(2,"0")).join("")}const L_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function kx(s){let p="";const i=ey(s);for(let r=0;r<s;r++)p+=L_[i[r]%L_.length];return p}function cVe(s){const p=ey(s);let i;if(typeof Buffer<"u")i=Buffer.from(p).toString("base64");else{const r=String.fromCharCode(...p);i=btoa(r)}return i.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ux(s){return kx(s)}function Fx(s,p=L_){let i="";const r=ey(s);for(let a=0;a<s;a++)i+=p[r[a]%p.length];return i}function Ep(){const s=ey(16);s[6]=s[6]&15|64,s[8]=s[8]&63|128;const p=Array.from(s).map(i=>i.toString(16).padStart(2,"0")).join("");return[p.slice(0,8),p.slice(8,12),p.slice(12,16),p.slice(16,20),p.slice(20,32)].join("-")}function fVe(){return Fx(6)}function yVe(){return jx(32)}const kgi=63,Ugi=/^[a-z][a-z0-9-]*[a-z0-9]$/;function Fgi(s){return s.length>=1&&s.length<=kgi&&Ugi.test(s)&&!s.includes("--")}function*Kgi(){yield"";const s="abcdefghijklmnopqrstuvwxyz";for(let p=1;;p++){const i=new Array(p).fill(0);let r=!1;for(;!r;){yield i.map(a=>s[a]).join("");for(let a=p-1;a>=0&&(i[a]++,!(i[a]<s.length));a--)i[a]=0,a===0&&(r=!0)}}}function qgi(s,p){const i=new Set(s.map(a=>a.toLowerCase())),r=p>0?"secondary-db":"main";for(const a of Kgi()){const c=a?`${r}-${a}`:r;if(Fgi(c)&&!i.has(c))return c}throw new Error("Unable to generate identifier")}function hVe(s,p){switch(s.id){case ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=s.project.entities.filter(h=>!!h.implements.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),r=i.find(h=>{const m=h.properties.find(A=>A.implements.find(_=>_.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=m==null?void 0:m.getDefaultValue();return(E==null?void 0:E.value)===!0});if(!r&&i.length){const m=i[0].properties.find(b=>b.implements.find(A=>A.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=m==null?void 0:m.defaultValue;if(E)E.metaSync({value:!0},p);else if(m!=null&&m.dataType){const b={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:fe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:m==null?void 0:m.toReference()},A=ge(b,s.project);return A.hydrateAncestors(),A.setParent(m,p),A.addSelfToProject(p),p==null||p.add(A,W.Added),A.initChildren(p),p||A.captureVersion(),{newEntities:[A]}}return{newEntities:[]}}else if(r)return{newEntities:[]};const a=s.project.get(ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),c=m1(a,"Main database",p);if(c.errors.length>0)return{newEntities:[]};const e=c.properties.find(h=>h.implements.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),f=e==null?void 0:e.defaultValue;if(f)f.metaSync({value:!0},p);else if(e!=null&&e.dataType){const h={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:fe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},m=ge(h,s.project);m.hydrateAncestors(),m.setParent(e,p),m.addSelfToProject(p),p==null||p.add(m,W.Added),m.initChildren(p),p||m.captureVersion()}return{newEntities:[c]}}}return{newEntities:[]}}function mVe(s,p){const i=[],r=[],a=[],c=[];return s.implements.filter(f=>f.type===d.BuiltInBaseEntity).forEach(f=>{var h,m,E,b,A,_,P,V,j;switch(f.id){case ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const M=s.project.entities.filter(te=>te.implements.find(le=>le.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let G=M.find(te=>!!te.properties.find(le=>{var ue;return le.implements.find(z=>z.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((ue=le.getDefaultValue())==null?void 0:ue.value)===!0}));if(!G&&M.length)G=M[0];else if(!G&&!M.length){G=s.project.getBuiltIn(ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",p);const le=G.properties.find(ue=>ue.implements.find(z=>z.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));(h=le==null?void 0:le.defaultValue)==null||h.metaSync({value:!0},p),r.push(G)}const q=s.properties.find(te=>te.implements.find(le=>le.id===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id));if(q&&!(q!=null&&q.defaultValue)){const te={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:fe.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:(G==null?void 0:G.toJSON())||null,valueAsTypeList:null,parent:q==null?void 0:q.toReference()},le=ge(te,s.project);le.hydrateAncestors(),le.setParent(q,p),le.addSelfToProject(p),p==null||p.add(le,W.Added),le.initChildren(p),(q==null?void 0:q.defaultValue).setValueAsTypeSingle(G||null,p),r.push(le),p||le.captureVersion();return}else q!=null&&q.defaultValue&&!(q!=null&&q.defaultValue.valueAsTypeSingle)&&(q==null||q.defaultValue.setValueAsTypeSingle(G||null,p));const re=s.properties.find(te=>te.implements.find(le=>le.id===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.primaryKey.id));if(!re)throw new Error(`[handleAfterEntityImplementationSideEffects] Primary key property not found for implemented base entity ${ne["built-in-base-entity"]}`);let ee=!1;if(!re.dataType){const te=mr.new(p);te.parent=re.toReference();const le=ge(te,s.project);le.hydrateAncestors(),le.setParent(re,p),le.addSelfToProject(p),p==null||p.add(le,W.Added),le.initChildren(p),ee=!0}const se=s.project.getBuiltIn(ne["primitive-entity"].number.id);(m=re.dataType)==null||m.setEntity(se,p),ee&&(p||(E=re.dataType)==null||E.captureVersion());return}case ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id:{const M=s.project.entities.filter(z=>z.implements.find(X=>X.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)&&z.id!==s.id),G=M.map(z=>{var de;const X=z.properties.find(me=>me.implements.find(ve=>ve.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));return(de=X==null?void 0:X.getDefaultValue())==null?void 0:de.value}).filter(z=>!!z),q=s.properties.find(z=>z.implements.find(X=>X.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));if(!M.find(z=>!!z.properties.find(X=>{var pe;return X.implements.find(de=>de.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((pe=X.getDefaultValue())==null?void 0:pe.value)===!0}))){const z=s.properties.find(pe=>pe.implements.find(de=>de.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));if(!z)throw new Error("Default boolean property not found for relational database entity with id: "+s.id);let X=!1;if(!(z!=null&&z.defaultValue)){const pe=Nr.new(p);pe.parent=z.toReference();const de=ge(pe,s.project);de.hydrateAncestors(),de.setParent(z,p),de.addSelfToProject(p),p==null||p.add(de,W.Added),de.initChildren(p),X=!0}(b=z==null?void 0:z.defaultValue)==null||b.metaSync({value:!0},p),X&&(p||(A=z==null?void 0:z.defaultValue)==null||A.captureVersion())}if(!q)throw new Error("Identifier property not found for relational database entity with id: "+s.id);let ee=!1;if(!(q!=null&&q.defaultValue)){const z=Nr.new(p);z.parent=q.toReference();const X=ge(z,s.project);X.hydrateAncestors(),X.setParent(q,p),X.addSelfToProject(p),p==null||p.add(X,W.Added),X.initChildren(p),ee=!0}const se=qgi(G,M.length);(_=q.defaultValue)==null||_.metaSync({value:se},p),ee&&(p||(P=q.defaultValue)==null||P.captureVersion());const te=s.properties.find(z=>z.implements.find(X=>X.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.password.id));if(!te)throw new Error(`[handleAfterEntityImplementationSideEffects] Password property not found for implemented base entity ${ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id} with id ${s.id}`);let le=!1;if(!te.defaultValue){const z=Nr.new(p);z.parent=te.toReference();const X=ge(z,s.project);X.hydrateAncestors(),X.setParent(te,p),X.addSelfToProject(p),p==null||p.add(X,W.Added),X.initChildren(p),r.push(X),le=!0}const ue=Ux(24);(V=te.defaultValue)==null||V.metaSync({value:ue},p),le&&(p||(j=te.defaultValue)==null||j.captureVersion());return}case ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id:{const M=s.properties.find(ee=>ee.implements.find(se=>se.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.time.id));if(!M)throw new Error(`[handleAfterEntityImplementationSideEffects] Time property not found for implemented base entity ${ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${s.id}`);let G=M.defaultValue||null;if(!G){const ee=Nr.new(p);ee.parent=M.toReference(),ee.name=fe.Date,ee.id=x.UUID.uuid(),G=ge(ee,s.project),G.hydrateAncestors(),G.setParent(M,p),G.addSelfToProject(p),G.initChildren(p),p==null||p.add(G,W.Added)}G.metaSync({value:new Date().toISOString()},p),G.metaSync({editable:!1,deletable:!1},p),M.metaSync({editable:!1,deletable:!1},p);const q=s.properties.find(ee=>ee.implements.find(se=>se.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id));if(!q)throw new Error(`[handleAfterEntityImplementationSideEffects] Definition property not found for implemented base entity ${ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${s.id}`);let re=q.defaultValue||null;if(!re){const ee=Nr.new(p);ee.name=fe.EntityTemplate,ee.parent=q.toReference(),ee.id=x.UUID.uuid(),re=ge(ee,s.project),re.hydrateAncestors(),re.setParent(q,p),re.addSelfToProject(p),re.initChildren(p),p==null||p.add(re,W.Added)}}}}),{self:s,updated:C(i),added:C(r),removed:C(a),affected:C(c)}}function m1(s,p,i,r){const a=r||x.UUID.uuid(),c=Fs.new(i);c.id=a,c.name=p,c.static=s.static,c.implements=[s.toJSON()],c.parent=s.project.toReference(),c.static=s.static,hVe(s,i);const e=ge(c,s.project);return e.hydrateAncestors(),i==null||i.add(e,W.Added),e.addSelfToProject(i),e.initChildren(i),i||e.captureVersion(),mVe(e,i),e.afterAllChildrenInitialized(i),e}function Kx(s,p){return p.entities.find(a=>{const c=a.properties,e=c.map(b=>b.name),f=s.every(b=>e.includes(b)),h=e.filter(b=>!s.includes(b)),m=c.every(b=>!h.includes(b.name)||!b.required);return f&&m})||null}function TVe(s,p,i,r=ze.OrDataTypeGroup){const a=[],c=[],e=[],f=[],h=x.UUID.uuid(),m=mr.new(i);m.id=h,m.parent=p.toReference(),m.like=!0,m.parentRelationType=r;const E=ge(m,s.project);return c.push(E),E.setParent(p,i),E.addSelfToProject(i),i==null||i.add(E,W.Added),E.setEntity(s,i),E.initChildren(i),i||E.captureVersion(),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:E}}function qx(s,p,i,r,a){var m,E,b,A,_,P,V,j;const c=[],e=[],f=[],h=[];switch(typeof s){case"string":let M=!1;const G=new Date(s);if(G instanceof Date&&!isNaN(G.valueOf())&&(M=!0),M){const q=p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Date].id);p.setEntity(q,r);break}else{const q=p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.String].id);p.setEntity(q,r);break}case"number":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Number].id),r);break;case"boolean":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Boolean].id),r);break;case"object":if(s===null){p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Null].id),r);break}else if(Array.isArray(s))if(p.metaSync({isList:!0},r),s.length>0){const q=s.slice(0,5).filter(ee=>ee!==void 0);if(q.every(ee=>typeof ee==typeof q[0])&&(typeof q[0]!="object"||q[0]===null))switch(typeof q[0]){case"string":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.String].id),r);break;case"number":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Number].id),r);break;case"boolean":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Boolean].id),r);break;case"object":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Null].id),r);break}else{const ee=[];let se=!1;q.forEach(le=>{var ue,z,X,pe;if(Array.isArray(le)&&(se=!0),typeof le=="object"&&!Array.isArray(le)&&le!==null){const de=ug(le,p.project,{...i,id:x.UUID.uuid()},r,a);de.hasCreated&&ee.push((ue=de.changeSet)==null?void 0:ue.self),c.push(...(z=de.changeSet)==null?void 0:z.updated),e.push(...(X=de.changeSet)==null?void 0:X.added),f.push(...(pe=de.changeSet)==null?void 0:pe.removed)}});const te=C(ee);if(!te.length&&!se){q.forEach(le=>{const ue=mr.new(r);ue.parentRelationType=ze.OrDataTypeGroup,ue.parent=p.toReference();const z=ge(ue,p.project);switch(z.hydrateAncestors(),z.setParent(p,r),z.addSelfToProject(r),r==null||r.add(z,W.Added),z.initChildren(r),typeof le){case"string":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.String].id),r);break;case"number":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Number].id),r);break;case"boolean":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Boolean].id),r);break;case"object":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Null].id),r);break}r||z.captureVersion()});break}else te.length===1&&!se?p.setEntity(te[0],r):q.forEach(le=>{if(typeof le=="object"&&!Array.isArray(le)&&le!==null){const ue=Kx(Object.keys(le),p.project);if(ue){const z=TVe(ue||te[0],p,r,ze.OrDataTypeGroup);c.push(...z.updated),e.push(...z.added),f.push(...z.removed)}}else{const ue=mr.new(r);ue.parentRelationType=ze.OrDataTypeGroup,ue.parent=p.toReference();const z=ge(ue,p.project);z.hydrateAncestors(),z.setParent(p,r),z.addSelfToProject(r),r==null||r.add(z,W.Added),z.initChildren(r);const X=qx(le,z,{...i,id:x.UUID.uuid()},r,a);c.push(...X.updated),e.push(...X.added),f.push(...X.removed),r||z.captureVersion()}})}}else{const q=ug(s[0],p.project,{...i},r,a);p.setEntity((m=q.changeSet)==null?void 0:m.self,r),c.push(...(E=q.changeSet)==null?void 0:E.updated),e.push(...(b=q.changeSet)==null?void 0:b.added),f.push(...(A=q.changeSet)==null?void 0:A.removed);break}else{const q=ug(s,p.project,{...i},r,a);p.setEntity((_=q.changeSet)==null?void 0:_.self,r),c.push(...(P=q.changeSet)==null?void 0:P.updated),e.push(...(V=q.changeSet)==null?void 0:V.added),f.push(...(j=q.changeSet)==null?void 0:j.removed);break}}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:p}}function ug(s,p,i,r,a){const c=[],e=[],f=[],h=[],m=Object.keys(s),E=Kx(m,p);if(E)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:E}};const b=a?i.name+" of "+a.name:i.name,_={id:i.id||x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:b,codeName:null,deletable:!0,editable:!0,type:d.DefinitionEntity,additionalProperties:!1,additionalPropertiesDataType:null,allPropertiesImplement:null,description:i.description||null,static:i.static||!1,abstract:i.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:p.toReference()},P=ge(_,p);return P.hydrateAncestors(),P.setParent(p,r),P.addSelfToProject(r),r==null||r.add(P,W.Added),P.initChildren(r),e.push(P),m.forEach((V,j)=>{const M=x.UUID.uuid(),G=Es.new(r);G.id=M,G.name=V,G.codeName=V,G.parent=P.toReference(),G.index=j,G.required=!0,G.interactive=!0;const q=ge(G,p);q.hydrateAncestors(),q.setParent(P,r),q.addSelfToProject(r),r==null||r.add(q,W.Added),q.initChildren(r),e.push(q);const re=s[V],ee=x.UUID.uuid(),se=mr.new(r);se.id=ee,se.parent=q.toReference(),se.like=!0,se.isList=!1;const te=ge(se,p);te.hydrateAncestors(),te.setParent(q,r),te.addSelfToProject(r),r==null||r.add(te,W.Added),te.initChildren(r),e.push(te);const le=qx(re,te,{...i,name:V,id:x.UUID.uuid()},r,a||P);c.push(...le.updated),e.push(...le.added),f.push(...le.removed),r||(q.captureVersion(),te.captureVersion())}),r||P.captureVersion(),{hasCreated:!0,changeSet:{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:P}}}function Yd(s,p,i,r){const a=[];return!s.length||!p.length?{errors:a,overlap:!1}:(s.length>p.length?s.forEach(c=>{const e=p.find(h=>h.name===c.name),f=p.find(h=>{var m,E;return Array.isArray(h.implements)?h.implements.some(b=>!!c.implements.find(A=>A.id===b.id)):((m=h.implements)==null?void 0:m.id)===((E=c.implements)==null?void 0:E.id)});if(e){const h=new Fi({id:c.id+"--"+e.id+"--"+r,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${e.type} ${e.name} with id "${e.id}" that has the same name`,severity:Te.Error,code:r,entity:c,firstRelationship:e});a.push(h)}if(f){const h=new Fi({id:c.id+"--"+f.id+"--"+i,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${f.type} ${f.name} with id "${f.id}" that implements the same base descriptor`,severity:Te.Error,code:i,entity:c,firstRelationship:f});a.push(h)}}):p.forEach(c=>{var h;const e=s.find(m=>m.name===c.name),f=s.find(m=>{var E,b;return m.implements&&Array.isArray(m.implements)?m.implements.some(A=>!!c.implements.find(_=>_.id===A.id)):((E=m.implements)==null?void 0:E.id)===((b=c.implements)==null?void 0:b.id)});if(e){const m=new Fi({id:e.id+"--"+c.id+"--"+r,message:`Entity of type ${e.type} named "${e.name}" with id "${e.id}" overrides a base entity ${c.name} with id "${c.id}" that has the same name`,severity:Te.Error,code:r,entity:e,firstRelationship:c});a.push(m)}if(f){const m=new Fi({id:f.id+"--"+c.id+"--"+i,message:`Entity of type ${f.type} named "${f.name}" with id "${f.id}" overrides a base entity ${c.name} with id "${c.id}" that implements the same base ${Array.isArray(f==null?void 0:f.implements)?vt(f==null?void 0:f.implements.map(E=>E.type),"', '","' and '"):(h=f.implements)==null?void 0:h.id}`,severity:Te.Error,code:i,entity:f,firstRelationship:c});a.push(m)}}),{errors:a,overlap:!!a.length})}function Sgi(s,p){return s.abstract||(s.properties.forEach(r=>{r.abstract||r.metaSync({abstract:!0},p)}),Object.values(s.detachedDependents).forEach(r=>{r.field===TL.EntityField&&r.entity.remove({ignoreUpstream:!1},p)}),s.metaSync({abstract:!0},p)),s}function Zgi(s,p){return s.abstract&&(s.properties.forEach(r=>{r.abstract&&r.metaSync({abstract:!1},p)}),Object.values(s.detachedDependents).forEach(r=>{(r.field===zg.Implements||r.field===zg.Extends)&&r.entity.onDetachedDependencyRemoved(s,r.field,p)}),s.metaSync({abstract:!1},p)),s}function Hgi(s,p){return s.static||(s.properties.forEach(r=>{r.static||r.metaSync({static:!0},p)}),s.metaSync({static:!0},p)),s}function Wgi(s,p){return s.static&&s.metaSync({static:!1},p),s}const JT=class JT extends $x{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"version");R(this,"name");R(this,"description",null);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",!1);R(this,"static");R(this,"additionalProperties",!1);R(this,"properties",[]);R(this,"allPropertiesImplement",null);R(this,"additionalPropertiesDataType",null);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"interactive",!1);R(this,"errors",[]);R(this,"project");if(this.initialData=this.initialData||i,this.project=this.project||r,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.additionalProperties=i.additionalProperties,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.initialData.allPropertiesImplement){const a=ge(this.initialData.allPropertiesImplement,this.project);a.setParent(this,null),a.initChildren(null),this.allPropertiesImplement=a}if(this.initialData.additionalPropertiesDataType){const a=ge(this.initialData.additionalPropertiesDataType,this.project);a.setParent(this,null),a.initChildren(null),this.additionalPropertiesDataType=a}this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project))}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allMethods)||[],r=[...i].filter(c=>!i.some(e=>e.id!==c.id));return C(r)}get allBasePropertiesFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allProperties)||[],r=[...i].filter(c=>!i.some(e=>{var f;return e.id!==c.id&&(!!e.implements.find(h=>h.id===c.id)||((f=e.extends)==null?void 0:f.id)===c.id)}));return C(r)}get allBasePropertiesFromExtendedAndImplementedEntities(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C([...r])}get allBaseMethodsFromExtendedAndImplementedEntities(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>r.type===d.PrimitiveEntity?i:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||!!E.implements.find(A=>A.id===h.id)}))},[])].filter(i=>!!i.abstract))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods,...this.abstractMethods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeBuiltInInstance(this),this}unsubscribe(){return this.project.unsubscribeBuiltInInstance(this),this}async APILoad(i=Ke,...r){return await JT.repository.APILoad(this.id,...r),this}toFlat(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...((a=this.extends)==null?void 0:a.toFlat(i))||[]])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...((a=this.extends)==null?void 0:a.toFlatIds(i))||[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,interactive:this.interactive,additionalProperties:this.additionalProperties,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,additionalProperties:this.additionalProperties,interactive:this.interactive,additionalPropertiesDataType:((r=this.additionalPropertiesDataType)==null?void 0:r.toJSON(i))||null,allPropertiesImplement:((a=this.allPropertiesImplement)==null?void 0:a.toJSON(i))||null,properties:this.properties.map(e=>e.toJSON(i)),methods:this.methods.map(e=>e.toJSON(i)),abstractMethods:this.abstractMethods.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null})}toReference(i=at){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=at){var r,a,c;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,additionalProperties:this.additionalProperties,additionalPropertiesDataType:((r=this.additionalPropertiesDataType)==null?void 0:r.toReference())||null,allPropertiesImplement:((a=this.allPropertiesImplement)==null?void 0:a.toReference())||null,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),extends:((c=this.extends)==null?void 0:c.toReference())||null}}toFlatJSON(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(e=>e.toFlatJSON(i)),...this.methods.flatMap(e=>e.toFlatJSON(i)),...this.abstractMethods.flatMap(e=>e.toFlatJSON(i)),...((a=this.additionalPropertiesDataType)==null?void 0:a.toFlatJSON(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var r;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,additionalProperties:this.additionalProperties,extends:(r=this.extends)==null?void 0:r.id}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(e=>e.toFlatGenerationTarget(i)),...this.methods.flatMap(e=>e.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(e=>e.toFlatGenerationTarget(i)),...((a=this.additionalPropertiesDataType)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,r;return this.errors=[],this.properties.forEach(a=>a.clearErrors()),this.methods.forEach(a=>a.clearErrors()),this.abstractMethods.forEach(a=>a.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(r=this.allPropertiesImplement)==null||r.clearErrors(),this}validate(){return this.errors=Mgi(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await Bgi(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((r=this.additionalPropertiesDataType)==null?void 0:r.getErrors())||[],...((a=this.allPropertiesImplement)==null?void 0:a.getErrors())||[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(this.additionalPropertiesDataType){const c=await this.additionalPropertiesDataType.getErrorsAsync({tracker:r});a.push(...c)}if(this.allPropertiesImplement){const c=await this.allPropertiesImplement.getErrorsAsync({tracker:r});a.push(...c)}return a}getShallowErrors(){return this.errors}implement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),null,!0,"implement-built-in-base-entity")),a){const c=m1(this,i,r,a);return r==null||r.attemptAutoclose("implement-built-in-base-entity",this.id),c}getAllPropertiesImplements(){var r;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),((r=this.extends)==null?void 0:r.type)===d.BuiltInBaseEntity&&i.push(...this.extends.getAllPropertiesImplements()||[]),i}getAllInteractiveMethods(){const i=[];if(this.interactive){if(i.push(...this.methods,...this.abstractMethods),!this.extends||this.extends.type===d.BuiltInBaseEntity&&this.extends.interactive||this.extends.type===d.PrimitiveEntity)return i;this.extends instanceof JT&&i.push(...this.extends.getAllInteractiveMethods())}return C(i)}getRawDefaultValue(){const i={};return this.properties.forEach(r=>{var e;if(!bv(r))return;const a=oe(r,this.project),c=r.codeName||vp(r,this.project)||cs(Xi(a));i[c]=((e=r.getDefaultValue())==null?void 0:e.value)||null}),i}};R(JT,"repository",{APILoad:async(i,...r)=>null});let vd=JT;class vVe extends vd{constructor(i){super(On,i);R(this,"initialData");R(this,"id",Ae.PERSISTED_ENTITY);R(this,"version","1");R(this,"name",Ae.PERSISTED_ENTITY);R(this,"description",On.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",On.abstract);R(this,"static",On.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=On,this.project=i,this.id=On.id,this.version=On.version,this.name=On.name,this.static=On.static,this.abstract=On.abstract,this.properties=this.initialData.properties.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.methods=this.initialData.methods.map(r=>{const a=ge(r,this.project);return a.parent=this,a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=ge(r,this.project);return a.parent=this,a}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project))}}var Pn=(s=>(s.ValueMustBeString="value-must-be-string",s.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",s.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",s.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",s))(Pn||{});function Sx(s,p){const i=[],r=p;if(!r)return{errors:i,override:p};if(typeof r!="string")return{errors:[],override:p};if(r.includes(" ")){const a=new Fi({id:s.id+"--string-value-must-not-have-spaces",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value cannot contain spaces.`,severity:Te.Error,code:"string-value-must-not-have-spaces",entity:s});i.push(a)}return{errors:i,override:r.replace(/\s/g,"-")}}function EVe(s,p){const i=[],r=p;if(!r)return{errors:i,override:p};if(typeof r!="string")return{errors:[],override:p};if(r.includes(" ")){const a=new Fi({id:s.id+"--string-value-must-not-have-spaces",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:Te.Error,code:"string-value-must-not-have-spaces",entity:s});i.push(a)}if(r.includes("-")){const a=new Fi({id:s.id+"--string-value-must-not-have-dashes",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:Te.Error,code:"string-value-must-not-have-dashes",entity:s});i.push(a)}return{errors:i,override:r.replace(/\s|-/g,"_")}}var Ed=(s=>(s.StatusCodeMustBeNumber="status-code-must-be-number",s.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",s))(Ed||{});function bVe(s,p){const i=[];if(typeof p!="number"){const r=new Fi({id:s.id+"--status-code-must-be-number",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be a number.`,severity:Te.Error,code:"status-code-must-be-number",entity:s});return i.push(r),{errors:i,override:p}}if(p<100||p>599){const r=new Fi({id:s.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:Te.Error,code:"status-code-must-be-between-100-and-599",entity:s});i.push(r)}return{errors:i,override:p}}class AVe extends vd{constructor(i){var f,h;super(os,i);R(this,"initialData");R(this,"id",Ae.HTTP_ENDPOINT);R(this,"version","1");R(this,"name",Ae.HTTP_ENDPOINT);R(this,"description",os.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",os.abstract);R(this,"static",os.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=os,this.project=i,this.id=os.id,this.version=os.version,this.name=os.name,this.static=os.static,this.abstract=os.abstract,this.properties=this.initialData.properties.map(m=>{const E=ge(m,this.project);return E.setParent(this,null),E.initChildren(null),E}),this.methods=this.initialData.methods.map(m=>{const E=ge(m,this.project);return E.parent=this,E}),this.abstractMethods=this.initialData.abstractMethods.map(m=>{const E=ge(m,this.project);return E.parent=this,E}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project));const r=this.properties.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!r)throw new Error("Path property not found in endpoint entity");r._codeNativeValueValidation=(m,E)=>{var j;const b=Sx(m,E),A=m.parent,_=A.properties.find(M=>M.implements.find(G=>G.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id)),P=(j=_==null?void 0:_.getDefaultValue())==null?void 0:j.value;if(m.project.entities.filter(M=>si(M,Ae.HTTP_ENDPOINT)&&M.id!==A.id).some(M=>{var re,ee;const G=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id));if(((re=G==null?void 0:G.getDefaultValue())==null?void 0:re.value)!==P)return!1;const q=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(!q)throw new Error(`"Path" property not found in endpoint entity "${M.name}" (${M.id})`);return((ee=q.getDefaultValue())==null?void 0:ee.value)===E})){const M=new Fi({id:m.id+"--"+Pn.MustBeUniqueAmongSameEntities,message:`Path "${E}" is already in use by another endpoint with the ${P} method.`,severity:Te.Error,code:Pn.MustBeUniqueAmongSameEntities,entity:m});b.errors.push(M)}return b};const a=this.properties.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id);a&&(a._codeNativeValueValidation=(m,E)=>{var j;const b={errors:[],override:E},A=m.parent,_=A.properties.find(M=>M.implements.find(G=>G.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id)),P=(j=_==null?void 0:_.getDefaultValue())==null?void 0:j.value;if(m.project.entities.filter(M=>si(M,Ae.HTTP_ENDPOINT)&&M.id!==A.id).some(M=>{var re,ee;const G=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(((re=G==null?void 0:G.getDefaultValue())==null?void 0:re.value)!==P)return!1;const q=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id));return((ee=q==null?void 0:q.getDefaultValue())==null?void 0:ee.value)===E})){const M=new Fi({id:m.id+"--"+Pn.MustBeUniqueAmongSameEntities,message:`Method "${E}" cannot be used because another endpoint is already using the ${E} method on path "${P}".`,severity:Te.Error,code:Pn.MustBeUniqueAmongSameEntities,entity:m});b.errors.push(M)}return b});const c=this.abstractMethods.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!c)throw new Error("Handler method not found in endpoint entity");const e=(((h=(f=c.dataType)==null?void 0:f.entity)==null?void 0:h.properties)||[]).find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.dataType.entity.properties.statusCode.id);if(!e)throw new Error("Status code output not found in handler method");e._codeNativeValueValidation=(m,E)=>bVe(m,E)}}var KT=(s=>(s.InvalidCharacters="cron-invalid-characters",s.MustHaveSixFields="cron-must-have-six-fields",s.DayOfMonthAndWeekConflict="cron-day-of-month-and-week-conflict",s))(KT||{});function gVe(s,p){const i=[];let r=p;if(typeof p!="string"){const e=new Fi({id:s.id+"--"+Pn.ValueMustBeString,message:`Entity of type ${s.type} with id "${s.id}" has an invalid value. The cron expression must be a string.`,severity:Te.Error,code:Pn.ValueMustBeString,entity:s});return i.push(e),{errors:i,override:""}}r=p.trimStart().replace(/\s{2,}/g," ");const a=/[^0-9A-Z *?\-/,LW#]/g;if(a.test(r)){const e=Array.from(new Set(r.match(a)));i.push(new Fi({id:s.id+"--cron-invalid-characters",message:`Cron expression contains invalid characters: "${e.join(", ")}". Only alphanumeric characters and (* ? - / , L W #) are allowed.`,severity:Te.Error,code:"cron-invalid-characters",entity:s})),r=r.replace(a,"")}const c=r.split(" ").filter(Boolean);if(c.length!==6)i.push(new Fi({id:s.id+"--cron-must-have-six-fields",message:`AWS Cron expressions must have exactly 6 fields separated by spaces (Minutes, Hours, Day-of-month, Month, Day-of-week, Year). Currently has ${c.length}.`,severity:Te.Error,code:"cron-must-have-six-fields",entity:s}));else{const e=c[2],f=c[4];e!=="?"&&f!=="?"&&(i.push(new Fi({id:s.id+"--cron-day-of-month-and-week-conflict",message:"AWS restricts defining both Day-of-month and Day-of-week simultaneously. If you specify one, the other must be '?'",severity:Te.Error,code:"cron-day-of-month-and-week-conflict",entity:s})),e==="*"&&f==="*"&&(c[4]="?",r=c.join(" ")))}return{errors:i,override:r}}class IVe extends vd{constructor(i){super(Gs,i);R(this,"initialData");R(this,"id",Ae.CRON_JOB);R(this,"version","1");R(this,"name",Ae.CRON_JOB);R(this,"description",Gs.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",Gs.abstract);R(this,"static",Gs.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=Gs,this.project=i,this.id=Gs.id,this.version=Gs.version,this.name=Gs.name,this.static=Gs.static,this.abstract=Gs.abstract,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project));const r=this.properties.find(a=>a.id===ne["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.properties.expression.id);if(!r)throw new Error("Expression property not found in cron job entity");r._codeNativeValueValidation=(a,c)=>gVe(a,c)}}class RVe extends vd{constructor(i){super(qn,i);R(this,"initialData");R(this,"id",Ae.RELATIONAL_DATABASE);R(this,"version","1");R(this,"name",Ae.RELATIONAL_DATABASE);R(this,"description",qn.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",qn.abstract);R(this,"static",qn.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=qn,this.project=i,this.id=qn.id,this.version=qn.version,this.name=qn.name,this.static=qn.static,this.abstract=qn.abstract,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project));const r=this.properties.find(a=>a.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id);if(!r)throw new Error("Path property not found in endpoint entity");r._codeNativeValueValidation=(a,c)=>EVe(a,c)}}class DVe extends Ji{constructor(i){super(ya,i);R(this,"id",ya.id);R(this,"name",ya.name);R(this,"description",ya.description);R(this,"version",ya.version);R(this,"autoexecutable",!1);R(this,"type",d.ActionDescriptor);R(this,"inputs",[]);R(this,"dataType",null);R(this,"error",null);R(this,"project");this.project=i,this.inputs=ya.inputs.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.dataType=ge(ya.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=ya.error?ge(ya.error,this.project):null}}var fs=(s=>(s.UUIDMustBeString="uuid-must-be-string",s.UUIDMustBeValidFormat="uuid-must-be-valid-format",s.UUIDMustNotContainSpaces="uuid-must-not-contain-spaces",s))(fs||{});function zgi(s,p){const i=[];if(typeof p!="string"){const a=new Fi({id:s.id+"--uuid-must-be-string",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be text.`,severity:Te.Error,code:"uuid-must-be-string",entity:s});return i.push(a),{errors:i,override:p}}const r=Sx(s,p);if(r.errors.length>0)return i.push(...r.errors),{errors:i,override:p};if(!xx(p)){const a=new Fi({id:s.id+"--uuid-must-be-valid-format",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be a valid UUID format. Eg: "123e4567-e89b-12d3-a456-426614174000".`,severity:Te.Error,code:"uuid-must-be-valid-format",entity:s});i.push(a)}return{errors:i,override:p}}var Me=(s=>(s.Inherited="inherited",s.DefaultValue="default-value",s.Missing="missing",s.Empty="empty",s.AutoCalculated="auto-calculated",s.QueuedAutocalculation="queued-autocalculation",s.External="external",s.Testing="testing",s.ExecutionResult="execution-result",s))(Me||{});const wVe={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function PT(s,p){return{...wVe,id:s,project:p}}class NT{constructor(p,i){R(this,"initialized",!1);R(this,"id");R(this,"project");R(this,"values",{});R(this,"onWriteCallback",()=>{});R(this,"onRemoveCallback",()=>{});this.id=p,this.project=i,this.init()}onWrite(p){this.onWriteCallback=p}onRemove(p){this.onRemoveCallback=p}init(){var r;if(!((r=this.project)!=null&&r.id)||this.initialized)return;const p={},i={};Object.keys(p).forEach(a=>{const c=p[a],e=new Nr(c,this.project);try{if(c.parent){const m=this.project.findSubscribedInstanceFromReference(c.parent);if(!m)return;e.setParent(m,null),e.hydrateAncestors(),e.initChildren(null)}else if(c.standaloneParent){const m=this.project.findSubscribedInstanceFromReference(c.standaloneParent);if(!m)return;e.standalone=!0,e.setStandaloneParent(m,null),e.hydrateAncestors(),e.initChildren(null)}i[a]=e;const f=e.parent||e.standaloneParent,h=KVe(e,f,this.project);h?i[a]=h:delete p[a]}catch(f){Y.Logger.error("Error hydrating ancestors: ",f),delete p[a]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const p={};return Object.keys(this.values).forEach(i=>{p[i]=this.values[i].toJSON()}),p}writeValue(p,i){if(!p)throw new Error("The value owner entity is required when writing a value to a value store");let a=this.values[p.id];if(!a)if(i instanceof Nr)a=i;else if(i)a=nr(i,this.project);else{const c={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:null,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:p.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:yf(p.getDataType(null))};a=nr(c,this.project)}a.standalone=!0,a.initialData.standaloneParent||Y.Logger.warn("instance.initialData: ",a.initialData),a.setStandaloneParent(p,null),a.hydrateAncestors(),a.initChildren(null),i&&(a.metaSync({...i},null),a.setValueAsType(i.valueAsType,null)),this.values[p.id]=a,this.onWriteCallback(p,a)}readValue(p){return this.values[p]||null}removeValue(p){if(!this.values[p])return;delete this.values[p];const i=this.project.get(p);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function br(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function Zx(s){if(Array.isArray(s))return s.map(h=>typeof h=="number"?h:e(h)?Number(h):String(h));const p=[];let i=0,r="",a=!1,c=null;for(;i<s.length;){const h=s[i];if(h==="."&&!a){r.length&&(p.push(f(r)),r=""),i++;continue}if(h==="["&&!a){r.length&&(p.push(f(r)),r=""),a=!0,i++;continue}if(a){if(!c&&(h==='"'||h==="'")){c=h,i++;continue}if(c){if(h==="\\"&&i+1<s.length){r+=s[i+1],i+=2;continue}if(h===c){c=null,i++;continue}r+=h,i++;continue}if(h==="]"){p.push(f(r)),r="",a=!1,i++;continue}if(/\s/.test(h)&&!c){i++;continue}r+=h,i++;continue}r+=h,i++}return r.length&&p.push(f(r)),p;function e(h){return/^[0-9]+$/.test(h)}function f(h){const m=h.trim();return e(m)?Number(m):m}}function T1(s,p,i){if(s==null)return i;const r=Zx(p);let a=s;for(let c=0;c<r.length;c++){const e=r[c];if(a==null)return i;if(Array.isArray(a)&&typeof e=="number"){if(!(e in a))return i;a=a[e]}else{if(!Object.prototype.hasOwnProperty.call(a,e))return i;a=a[e]}}return a}const Ygi=new Set(["__proto__","prototype","constructor"]);function CVe(s){return typeof s=="string"&&Ygi.has(s)}function Jgi(s,p,i,r){const{createMissing:a=!0,coerce:c=!0}=r??{};if(s==null||typeof s!="object")throw new TypeError("set(...) expects a non-null object as target.");const e=Zx(p);if(e.length===0)throw new Error("set(...) path must not be empty.");let f=s;for(let h=0;h<e.length;h++){const m=e[h];if(CVe(m))throw new Error(`Refusing to set unsafe key "${String(m)}" on object.`);const E=h===e.length-1,A=typeof e[h+1]=="number",_=Array.isArray(f)&&typeof m=="number";if(E){if(_&&f[m]==null&&!a)throw new Error(`set(...) missing array index "${String(m)}" (createMissing=false).`);return f[m]=i,s}else{if(!Object.prototype.hasOwnProperty.call(f,m)||f[m]==null){if(!a)throw new Error(`set(...) missing parent at segment "${String(m)}" (createMissing=false).`);f[m]=A?[]:{}}else{const P=f[m],V=P!==null&&typeof P=="object",j=Array.isArray(P);if(A){if(!j){if(!c)throw new Error(`set(...) expected an array at "${String(m)}" but found non-array (coerce=false).`);f[m]=[]}}else if(!V||j){if(!c)throw new Error(`set(...) expected an object at "${String(m)}" but found non-object (coerce=false).`);f[m]={}}}f=f[m]}}return s}function Hx(s,p,i,r){const a=Zx(p);if(a.length===0)return s;function c(e,f){const h=a[f],m=f===a.length-1;if(r==="strict-set"||r==="strict-delete"){if(CVe(h))throw new Error(`Unsafe key "${String(h)}"`);if(e==null||typeof e!="object"&&!Array.isArray(e))throw new Error(`Missing parent or invalid container at segment "${String(h)}".`);if(r==="strict-delete"&&m&&!(h in e))return e}let E;if(Array.isArray(e))E=[...e];else if(e&&typeof e=="object")E={...e};else if(r==="safe-set")E=typeof h=="number"?[]:{};else throw new Error(`Cannot traverse path at "${String(h)}"`);if(m)return r==="strict-delete"?delete E[h]:E[h]=i,E;const b=e?e[h]:void 0;if(r==="safe-set"&&b==null){const A=typeof a[f+1]=="number",_=c(A?[]:{},f+1);return E[h]=_,E}return E[h]=c(b,f+1),E}if(s==null&&r==="safe-set"){const e=typeof a[0]=="number";return c(e?[]:{},0)}return c(s,0)}const Kk=Symbol("missing"),Qgi=s=>s!=null&&typeof s=="object";function v1(s,p){if(typeof s!="string")throw new TypeError(`${p} expects the key to be a string.`);return s}function Lm(s,p){if(typeof s!="string"&&!Array.isArray(s))throw new TypeError(`${p} expects the path to be string or array.`);return s}function ty(s,p){if(!br(s))throw new TypeError(`${p} expects the first argument to be an object.`);return s??{}}function OVe(s,p){const i=v1(p,"ReadKey");return(s??{})[i]}function _Ve(s,p,i){const r=v1(p,"WriteKey");if(s&&typeof s=="object"){const a=Array.isArray(s)?[...s]:{...s};return a[r]=i,a}return{[r]:i}}function VVe(s,p){if(!s||typeof s!="object")return{};const i=String(p),{[i]:r,...a}=s;return a}function PVe(s,p,i){const r=ty(s,"ReadNestedKey"),a=Lm(p,"ReadNestedKey");return T1(r,a,i)}function NVe(s,p,i){const r=ty(s,"WriteNestedKey"),a=Lm(p,"WriteNestedKey");return Hx(r,a,i,"strict-set")}function xVe(s,p,i){const r=ty(s,"WriteSafeNestedKeyRecursively"),a=Lm(p,"WriteSafeNestedKeyRecursively");return Hx(r,a,i,"safe-set")}function $Ve(s,p){const i=ty(s,"DeleteNestedKey"),r=Lm(p,"DeleteNestedKey");return Hx(i,r,null,"strict-delete")}function LVe(s,p){const i=v1(p,"HasKey"),r=s;return r!=null&&Qgi(r)&&Object.prototype.hasOwnProperty.call(r,i)}function BVe(s,p,i){const r=v1(p,"KeyValueEquals");return s==null||typeof s!="object"?!1:s[r]===i}function MVe(s,p){const i=s,r=Lm(p,"HasNestedKey");return T1(i,r,Kk)!==Kk}function GVe(s,p,i){const r=Lm(p,"NestedKeyValueEquals");return T1(s,r)===i}function jVe(...s){const p={};for(let i=0;i<s.length;i++){const r=s[i];if(r!=null){if(!br(r))throw new TypeError("MergeObjects expects every argument to be an object (or null/undefined).");Object.assign(p,r)}}return p}function kVe(s){const p=ty(s,"ObjectKeys");return Object.keys(p)}function UVe(s){const p=ty(s,"ObjectValues");return Object.values(p)}function FVe(s){const p=ty(s,"ObjectEntries");return Object.entries(p)}function Xgi(s){return{execution:null,project:s,localTestValues:PT("local-test-values",s),resolvedValues:PT("resolved-values",s),persistedExecutionResults:PT("persisted-execution-results",s),lastExecutionResults:PT("last-execution-results",s),getValueTypePreference:()=>null,setValueTypePreference:()=>{}}}function ku(s,p,i,r){var f;let a;if(((f=s==null?void 0:s.entity)==null?void 0:f.type)===d.PrimitiveEntity)switch(s.entity.name){case fe.EntityTemplate:a=fe.EntityTemplate;break;case fe.String:a=fe.String;break;case fe.Number:a=fe.Number;break;case fe.Boolean:a=fe.Boolean;break;case fe.Null:a=fe.Null;break;case fe.Enum:a=fe.Enum;break;case fe.KeyValue:a=fe.KeyValue;break;case fe.Untyped:a=fe.Untyped;break;case fe.KeyValue:a=fe.KeyValue;break;case fe.Date:a=fe.Date;break;case fe.UUID:a=fe.UUID;break;case fe.File:a=fe.File;break;case fe.Void:a=fe.Void;break;case fe.ActionDescriptor:a=fe.ActionDescriptor;break;case fe.Bytes:a=fe.Bytes;break;default:throw new Error(`Primitive type ${oe(s.entity,i)} is not supported`)}else a=fe.Untyped;const c=Nr.new(r);c.name=a,c.parent=p.toReference();const e=ge(c,i);return e.hydrateAncestors(),r==null||r.add(e,W.Added),e.addSelfToProject(r),e.initChildren(r),e}function cd(s,p,i=new Set){var r,a,c;if(i.has(s.id))return[];if(i.add(s.id),Lt.includes(s.type)){const e=Er(s);return C([e,...[e].flatMap(f=>cd(f,p,i))])}else if(s.type===d.OutputMap){if(Lt.includes(s.parent.type)&&((r=s.declaration)==null?void 0:r.type)===d.Property&&s.declaration.static)return C([s,s.declaration,...[s,s.declaration].flatMap(e=>cd(e,p,i))])}else if(s.type===d.InputMap&&Lt.includes(s.parent.type)&&((a=s.declaration)==null?void 0:a.type)===d.Property&&(c=s.declaration)!=null&&c.static)return C([s.declaration,...[s.declaration].flatMap(e=>cd(e,p,i))]);return[s]}function KVe(s,p,i){return s}function Bm(s,p,i=!1){const r=s.readsValue;let a=null;const c=Df(r,p,i);if(c){const e={sources:[c],target:s};a={value:c.value,valueOwner:s,type:Me.Inherited,inheritanceLink:e}}return a}function $t(s,p,i){var f;if(!p)return null;let r;if(((f=s==null?void 0:s.entity)==null?void 0:f.type)===d.PrimitiveEntity)switch(s.entity.name){case fe.EntityTemplate:r=fe.EntityTemplate;break;case fe.String:r=fe.String;break;case fe.Number:r=fe.Number;break;case fe.Boolean:r=fe.Boolean;break;case fe.Null:r=fe.Null;break;case fe.Enum:r=fe.Enum;break;case fe.KeyValue:r=fe.KeyValue;break;case fe.Untyped:r=fe.Untyped;break;case fe.KeyValue:r=fe.KeyValue;break;case fe.Date:r=fe.Date;break;case fe.UUID:r=fe.UUID;break;case fe.File:r=fe.File;break;case fe.Void:r=fe.Void;break;case fe.ActionDescriptor:r=fe.ActionDescriptor;break;case fe.Bytes:r=fe.Bytes;break;default:throw new Error(`Primitive type ${oe(s.entity,i)} is not supported`)}else r=fe.Untyped;if(!i.get(p.id))return null;const c=Nr.new(null);c.name=r,c.standaloneParent=p.toReference();let e=new Nr(c,i);return e.hydrateAncestors(),e.standalone=!0,e.setStandaloneParent(p,null),e.initChildren(null),e}function qVe(s,p,i=!1){var c,e;if(p.execution&&p.execution.hasEntity(s)&&!i){const f=(c=p.lastExecutionResults)==null?void 0:c.readValue(s.id);if(f)return{value:f,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(e=p.localTestValues)==null?void 0:e.readValue(s.id),a=p.getValueTypePreference(s.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null}:{value:null,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:null}}function pg(s,p,i,r=!1){var e,f;const a={...s},c=p.type===d.VariableDeclaration?p.inputs:At.includes(p.type)?p.outputs:[];if(!c||c.length===0)return a;for(const h of c){if(!rb(h))continue;const m=ev(h,i,r);if(m&&m.value){const E=oe(h,i.project),b=h.codeName||((e=h.declaration)==null?void 0:e.codeName)||Xi(E);a[b]=kn((m==null?void 0:m.value)||null)?a[b]:(f=m==null?void 0:m.value)==null?void 0:f.value}}return a}function xT(s,p,i,r=!1){var e,f;const a={...s},c=p.inputs;if(!c)return a;for(const h of c){if(!rb(h))continue;const m=RE(h,i,r);if(m&&m.value){const E=oe(h,i.project),b=h.codeName||((e=h.declaration)==null?void 0:e.codeName)||Xi(E);a[b]=(f=m==null?void 0:m.value)==null?void 0:f.value}}return a}function SVe(s,p,i=!1){var E,b,A,_,P,V,j,M;let r={};if(((b=(E=s.getDataType(null))==null?void 0:E.entity)==null?void 0:b.type)===d.DefinitionEntity&&(r={...r,...((A=s.getDataType(null))==null?void 0:A.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(s)&&!i){const G=(_=p.lastExecutionResults)==null?void 0:_.readValue(s.id);if(G){if(br(G.value)){const re={...r,...G.value},ee={...xT(re,s,p,i)};G.metaSync({value:ee},null)}return{value:G,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}}const a=!!((P=p.execution)!=null&&P.entities.length),c=(V=p.execution)==null?void 0:V.hasEntity(s),e=s.readsValue;let f=null;if(e){const G=(j=p.execution)==null?void 0:j.hasEntity(e);if((!a||a&&G&&c||a&&!G&&!c)&&(f=Bm(s,p,i),f&&f.value&&br(f.value.value))){const re={...r,...f.value.value},ee={...xT(re,s,p,i)};f.value.metaSync({value:ee},null)}}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h){const G=h;if(G&&G.value===null&&G.autogeneration){const q=TD(G);if(G.metaSync({value:q},null),br(q)){const re={...xT(q,s,p,i)};G.metaSync({value:re},null)}}(i||m===null||m!==Me.Testing)&&(f={value:G,valueOwner:s,type:kn(G)?s.readsValue?Me.Inherited:Me.Empty:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const G=(M=p.localTestValues)==null?void 0:M.readValue(s.id);if(G){if(br(G.value)){const q={...r,...G.value},re={...xT(q,s,p,i)};G.metaSync({value:re},null)}return{value:G,valueOwner:s,type:Me.Testing,inheritanceLink:null}}}return kn((f==null?void 0:f.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function Wx(s,p,i=!1){var e,f,h,m,E,b,A,_,P;let r={};if(((f=(e=s.getDataType(null))==null?void 0:e.entity)==null?void 0:f.type)===d.DefinitionEntity&&(r={...r,...((h=s.getDataType(null))==null?void 0:h.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(s)&&!i){const V=(m=p.lastExecutionResults)==null?void 0:m.readValue(s.id);if(V){if(br(V.value)){const M={...r,...V.value},G=pg(M,s,p,i);V==null||V.metaSync({value:G},null)}return{value:V,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}}const a=(E=p.localTestValues)==null?void 0:E.readValue(s.id),c=p.getValueTypePreference(s.id);if(a&&!i&&(c===null||c!==Me.DefaultValue)){if(br(a.value)){const j={...r,...a.value},M=pg(j,s,p,i);a.metaSync({value:M},null)}return{value:a,valueOwner:s,type:Me.Testing,inheritanceLink:null}}if((b=s.getDataType(null))!=null&&b.entity&&((_=(A=s.getDataType(null))==null?void 0:A.entity)==null?void 0:_.type)===d.DefinitionEntity&&((P=s.getDataType(null))!=null&&P.isObject())){const V=$t(s.dataType,s,p.project),j=pg(r,s,p,i);return V==null||V.metaSync({value:j},null),{value:V,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null}}return null}function IE(s,p,i=!1){var E,b,A,_,P;if((E=s.dataType)!=null&&E.isObject())return SVe(s,p,i);const r=yt(s),a=!!((b=p.execution)!=null&&b.entities.length),c=(A=p.execution)==null?void 0:A.hasEntity(r),e=s.readsValue;let f=null;if(e){const V=(_=p.execution)==null?void 0:_.hasEntity(e);(!a||a&&V&&c||a&&!V&&!c)&&(f=Bm(s,p,i))}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h){const V=h;if(V&&V.value===null&&V.autogeneration){const j=TD(V);V.metaSync({value:j},null)}(i||m===null||m!==Me.Testing)&&(f={value:V,valueOwner:s,type:kn(V)?s.readsValue?Me.Inherited:Me.Empty:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const V=(P=p.localTestValues)==null?void 0:P.readValue(s.id);if(V)return{value:V,valueOwner:s,type:Me.Testing,inheritanceLink:null}}return kn((f==null?void 0:f.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function zx(s,p,i=!1){var e,f,h;if((e=s.dataType)!=null&&e.isObject())return Wx(s,p);if(p.execution&&p.execution.hasEntity(s)&&!i){const m=(f=p.lastExecutionResults)==null?void 0:f.readValue(s.id);if(m)return{value:m,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(h=p.localTestValues)==null?void 0:h.readValue(s.id),a=p.getValueTypePreference(s.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null}:IE(s,p,i)}function Yx(s,p,i=!1){var A,_,P,V;const r=!!((A=p.execution)!=null&&A.entities.length),a=(_=p.execution)==null?void 0:_.hasEntity(s);let c=null;const e=s.readsValue;if(e){const j=(P=p.execution)==null?void 0:P.hasEntity(e);(!r||r&&j&&a||r&&!j&&!a)&&(c=Bm(s,p,i))}const f=s.declaration;if(!c&&f){const j=IE(f,p);j&&j.value&&(c=j)}const h=p.getValueTypePreference(s.id);if(!c||(c.type===Me.DefaultValue||c.type===Me.External)&&!i||h===null||h!==Me.DefaultValue){const j=(V=p.localTestValues)==null?void 0:V.readValue(s.id);if(j)return{value:j,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const m=pu(s),E=s.getDataType(null);return m&&a&&(!(c!=null&&c.value)||!ps(E)&&du(c==null?void 0:c.value))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:a&&!m&&kn((c==null?void 0:c.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:c||{value:null,valueOwner:s,type:Me.External,inheritanceLink:null}}function ZVe(s,p,i=!1){return zx(s.declaration,p,i)}function HVe(s,p,i=!1){var A,_,P,V;if(!i&&p.execution&&p.execution.hasEntity(s)){const j=(A=p.lastExecutionResults)==null?void 0:A.readValue(s.id);if(j)return{value:j,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=yt(s),a=s.parent.type===d.FunctionDeclaration&&s.parent.parent.type===d.Loop?s.parent:null,c=!!((_=p.execution)!=null&&_.hasEntity(r))||!!a&&!!((P=p.execution)!=null&&P.hasEntity(a));let e=null;const f=s.defaultValue,h=p.getValueTypePreference(s.id);if(f){const j=f||null;if(j&&j.value===null&&j.autogeneration){const M=TD(j);j.metaSync({value:M},null)}(i||h===null||h!==Me.Testing)&&(e={value:j,valueOwner:s,type:kn(j)?Me.Empty:Me.DefaultValue,inheritanceLink:null})}if(!e||(e.type===Me.DefaultValue||e.type===Me.External)&&!i||h===null||h!==Me.DefaultValue){const j=(V=p.localTestValues)==null?void 0:V.readValue(s.id),M=p.getValueTypePreference(s.id);if(j&&!i&&(M===null||M!==Me.DefaultValue))return{value:j,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const m=pu(s),E=s.getDataType(null);let b=m&&c&&(!(e!=null&&e.value)||!ps(E)&&du(e==null?void 0:e.value));return r.type===d.Loop&&c&&(b=!1),b?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:c&&!m&&kn((e==null?void 0:e.value)||null)?{value:null,valueOwner:s,type:Me.Empty,inheritanceLink:null}:e||{value:null,valueOwner:s,type:Me.External,inheritanceLink:null}}function Jx(s,p,i=!1){var _,P,V,j,M,G;if((_=s.getDataType(null))!=null&&_.isObject())return Wx(s,p);if(p.execution&&p.execution.hasEntity(s)&&!i){const q=(P=p.lastExecutionResults)==null?void 0:P.readValue(s.id);if(q)return{value:q,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=yt(s),a=!!((V=p.execution)!=null&&V.entities.length),c=(j=p.execution)==null?void 0:j.hasEntity(r),e=s.readsValue;let f=null;if(e){const q=(M=p.execution)==null?void 0:M.hasEntity(e);(!a||a&&q&&c||a&&!q&&!c)&&(f=Bm(s,p,i))}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h){const q=h;(i||m===null||m!==Me.Testing)&&(f={value:q,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const q=(G=p.localTestValues)==null?void 0:G.readValue(s.id);if(q)return{value:q,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const E=pu(s),b=s.getDataType(null);return E&&(!(f!=null&&f.value)||!ps(b)&&du(f==null?void 0:f.value))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:!E&&kn((f==null?void 0:f.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function WVe(s,p,i=!1){var f,h,m,E,b,A,_,P,V,j,M,G,q;if(p.execution&&p.execution.hasEntity(s)&&!i){const re=(f=p.lastExecutionResults)==null?void 0:f.readValue(s.id);if(re)return{value:re,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=jp(s);if(Ip.includes(r.type)){const re=Df(r,p,i),ee=s.codeName||((h=s.declaration)==null?void 0:h.codeName)||Xi(oe(s,p.project));if(re!=null&&re.value&&br(re.value.value)){const se=re.value.value[ee],te=$t(s.getDataType(null),s,p.project);return te==null||te.metaSync({value:se},null),{value:te,valueOwner:s,type:!Lt.includes(r.type)&&re.type===Me.Empty?Me.QueuedAutocalculation:re.type,inheritanceLink:{sources:[re],target:s}}}return{value:null,valueOwner:s,type:Lt.includes(r.type)?Me.Empty:Me.QueuedAutocalculation,inheritanceLink:null}}const a=(m=p.execution)==null?void 0:m.hasEntity(r),c=((E=p.execution)==null?void 0:E.state)===f$.Running;if((b=p.persistedExecutionResults)!=null&&b.values[s.id]&&!a&&!c&&!i){const re=(A=p.persistedExecutionResults)==null?void 0:A.readValue(s.id);if((re==null?void 0:re.value)!==null||(re==null?void 0:re.valueAsType)!==null)return{value:re,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const e=s.parent;if(!e)throw new Error(`Couldn't find the parent that generates the output ${s.id}`);switch(e.type){case d.VariableInstance:{const ee=Yx(e,p,i);if(ee&&ee.value){const te=s.declaration;if(br(ee.value.value)){const le=ee.value.value[te.name],ue=$t(((_=s.declaration)==null?void 0:_.dataType)||null,s,p.project);return ue==null||ue.metaSync({value:le},null),{value:ue,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:[ee],target:s}}}}const se=$t(((P=s.declaration)==null?void 0:P.dataType)||null,s,p.project);return se==null||se.metaSync({value:null},null),{value:se,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:s}}}case d.VariableDeclaration:{const ee=IE(e,p,i);if(ee&&ee.value){const te=s.declaration;if(br(ee.value.value)){const le=ee.value.value[te.name],ue=$t(((V=s.declaration)==null?void 0:V.dataType)||null,s,p.project);return ue==null||ue.metaSync({value:le},null),{value:ue,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:[ee],target:s}}}}const se=$t(((j=s.declaration)==null?void 0:j.dataType)||null,s,p.project);return se==null||se.metaSync({value:null},null),{value:se,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:s}}}case d.Operation:{const re=e.outputs.map(se=>{var te,le;if((te=p.persistedExecutionResults)!=null&&te.values[se.id]){const ue=(le=p.persistedExecutionResults)==null?void 0:le.values[se.id];if(ue.value!==null||ue.valueAsType!==null)return{value:ue,valueOwner:se,type:Me.ExecutionResult,inheritanceLink:null}}}).filter(se=>!!se),ee=$t(((M=s.declaration)==null?void 0:M.dataType)||null,s,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:s}:null}}case d.FunctionCall:{const re=e.inputs.map(se=>Ng(se,p,i)).filter(se=>!!se),ee=$t(((G=s.declaration)==null?void 0:G.dataType)||null,s,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:s}:null}}case d.Loop:{const re=e.inputs.map(se=>Ng(se,p,i)).filter(se=>!!se),ee=$t(((q=s.declaration)==null?void 0:q.dataType)||null,s,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:s}:null}}case d.Search:return{value:null,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:null}}return null}function B_(s,p,i=!1){var b,A,_;if(![...At,...Lt].includes(s.parent.type)||!rb(s))return null;if(((b=s.declaration)==null?void 0:b.type)===d.Property&&s.declaration.static)return Df(s.declaration,p);const r=RE(s,p,i);if(r&&r.type!==Me.Empty&&r.type!==Me.Missing)return r;const a=Er(s.parent),c=sd(a,p,i),e=s.codeName||((A=s.declaration)==null?void 0:A.codeName)||Xi(oe(s,p.project)),f=$t(s.getDataType(null),s,p.project),h=pu(s),m=(_=c==null?void 0:c.value)==null?void 0:_.value;if(m&&br(m)){let P=m[e];m[e]===void 0&&(P=null),f==null||f.metaSync({value:P},null);const V=pu(s),j=s.getDataType(null);return V&&(!f||!ps(j)&&du(f))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:{value:f,valueOwner:s,type:c.type,inheritanceLink:{sources:c?[c]:[],target:s}}}return h?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}}function M_(s,p,i=!1){var b,A,_,P,V,j,M,G;if(![...At,...Lt].includes(s.parent.type)||!rb(s))return null;if(((b=s.declaration)==null?void 0:b.type)===d.Property&&s.declaration.static)return Df(s.declaration,p,i);const r=At.includes(s.parent.type)?s.parent:Er(s.parent),a=Df(r,p,i);let c=s;r.type===d.VariableDeclaration&&(c=(s.parent===r?s:r.inputs.find(re=>{var ee,se;return((ee=re.declaration)==null?void 0:ee.id)===((se=s.declaration)==null?void 0:se.id)}))||s);const e=ev(c,p,i),f=s.codeName||((A=s.declaration)==null?void 0:A.codeName)||Xi(oe(s,p.project)),h=(r.type===d.VariableDeclaration,s.defaultValue||$t(s.getDataType(null),s,p.project)),m=(_=a==null?void 0:a.value)==null?void 0:_.value;if(((a==null?void 0:a.type)===Me.ExecutionResult||(a==null?void 0:a.type)===Me.Testing)&&!i&&m&&br(m)){let q=m[f];return m[f]===void 0&&(q=null),h==null||h.metaSync({value:q},null),{value:h,valueOwner:s,type:a.type,inheritanceLink:{sources:a?[a]:[],target:s}}}if(e&&e.type!==Me.Empty&&e.type!==Me.Missing)return e;if(m&&br(m)){let q=m[f];m[f]===void 0&&(q=null),h!=null&&h.standaloneParent&&(h==null||h.metaSync({value:q},null));const re=pu(s),ee=s.getDataType(null),se=re&&(!h||!ps(ee)&&du(h)),te=!!((P=p.execution)!=null&&P.entities.length),le=(V=p.execution)==null?void 0:V.hasEntity(r),ue=r.readsValue;if(ue){const z=(j=p.execution)==null?void 0:j.hasEntity(ue);if(se&&(!te||te&&z&&le||te&&!z&&!le))return{value:null,valueOwner:s,type:Me.Inherited,inheritanceLink:null}}if(s.readsValue){const z=(M=p.execution)==null?void 0:M.hasEntity(s.readsValue);if(se&&(!te||te&&z&&le||te&&!z&&!le))return{value:null,valueOwner:s,type:Me.Inherited,inheritanceLink:null}}return se?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:{value:h,valueOwner:s,type:((G=h==null?void 0:h.parent)==null?void 0:G.id)===(s==null?void 0:s.id)?a.type:Me.Inherited,inheritanceLink:{sources:a?[a]:[],target:s}}}return ev(s,p,i)}function RE(s,p,i=!1){var _,P,V,j,M,G;const r=yt(s),a=!!((_=p.execution)!=null&&_.entities.length),c=(P=p.execution)==null?void 0:P.hasEntity(r),e=s.readsValue;let f=null;if(e){const q=(V=p.execution)==null?void 0:V.hasEntity(e);(!a||a&&q&&c||a&&!q&&!c)&&(f=Bm(s,p,i))}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h&&(i||m===null||m!==Me.Testing)&&(f={value:h,valueOwner:s,type:du(h)?Me.Empty:Me.DefaultValue,inheritanceLink:null}),!f||f.type===Me.DefaultValue||(f==null?void 0:f.type)===Me.Empty){const q=(j=p.persistedExecutionResults)==null?void 0:j.readValue(s.id);if(q&&!i)return{value:q,valueOwner:s,type:Me.Testing,inheritanceLink:null};const re=(M=p.localTestValues)==null?void 0:M.readValue(s.id);if(re&&!i&&(m===null||m!==Me.DefaultValue))return{value:re,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const E=pu(s),b=s.getDataType(null),A=E&&(!(f!=null&&f.value)||!ps(b)&&du(f==null?void 0:f.value));if(s.readsValue){const q=(G=p.execution)==null?void 0:G.hasEntity(s.readsValue);if(A&&(!a||a&&q&&c||a&&!q&&!c))return{value:null,valueOwner:s,type:Me.Inherited,inheritanceLink:null}}return A?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:(f==null?void 0:f.inheritanceLink)||null}:!E&&(!f||f.type===Me.Inherited)&&!(f!=null&&f.inheritanceLink)?{value:null,valueOwner:s,type:s.readsValue||!(f!=null&&f.value)?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function ev(s,p,i=!1){var e,f;if(p.execution&&p.execution.hasEntity(s)&&!i){const h=(e=p.lastExecutionResults)==null?void 0:e.readValue(s.id);if(h)return{value:h,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(f=p.localTestValues)==null?void 0:f.readValue(s.id),a=p.getValueTypePreference(s.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null}:RE(s,p,i)}function Ng(s,p,i=!1){var r,a;return Lt.includes(s.parent.type)&&(r=Er(s.parent).dataType)!=null&&r.isObject()||At.includes(s.parent.type)&&(a=s.parent.getDataType(null))!=null&&a.isObject()?B_(s,p,i):RE(s,p,i)}function zVe(s,p,i=!1){var r,a;return Lt.includes(s.parent.type)&&(r=Er(s.parent).dataType)!=null&&r.isObject()||At.includes(s.parent.type)&&(a=s.parent.getDataType(null))!=null&&a.isObject()?M_(s,p,i):ev(s,p,i)}function YVe(s,p,i=!1){var E,b;if(!s.static)return null;if(p.execution){const A=(E=p.lastExecutionResults)==null?void 0:E.readValue(s.id);if(A&&!i)return{value:A,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(b=p.localTestValues)==null?void 0:b.readValue(s.id),a=p.getValueTypePreference(s.id);if(r&&!i&&(a===null||a!==Me.DefaultValue))return{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null};const c=s.defaultValue;let e=null;c&&(i||a===null||a!==Me.Testing)&&(e={value:c,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null});const f=pu(s),h=s.getDataType(null);return f&&(!(e!=null&&e.value)||!ps(h)&&du(e==null?void 0:e.value))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:kn(e==null?void 0:e.value)?{value:null,valueOwner:s,type:Me.Empty,inheritanceLink:null}:e}function JVe(s,p,i=!1){var f,h;if(p.execution&&p.execution.hasEntity(s)&&!i){const m=(f=p.lastExecutionResults)==null?void 0:f.readValue(s.id);if(m)return{value:m,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(h=p.localTestValues)==null?void 0:h.readValue(s.id),a=p.getValueTypePreference(s.id);if(r&&!i&&(a===null||a!==Me.DefaultValue))return{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null};const c=s.defaultValue;let e=null;return c&&(i||a===null||a!==Me.Testing)&&(e={value:c,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null}),kn((e==null?void 0:e.value)||null)?{value:null,valueOwner:s,type:Me.Empty,inheritanceLink:null}:e}function Df(s,p,i=!1){switch(s.type){case d.ArgumentDeclaration:return HVe(s,p,i);case d.InputMap:return zVe(s,p,i);case d.VariableDeclaration:return zx(s,p,i);case d.VariableInstance:return ZVe(s,p,i);case d.OutputMap:return WVe(s,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return Jx(s,p,i);case d.Property:return YVe(s,p,i);case d.ValueDescriptor:return JVe(s,p,i);case d.Operation:case d.FunctionCall:case d.InternalCall:case d.Search:return qVe(s,p,i);default:return null}}function sd(s,p,i=!1){switch(s.type){case d.InputMap:return Ng(s,p,i);case d.VariableDeclaration:return IE(s,p,i);case d.VariableInstance:return Yx(s,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return Jx(s,p,i);default:return null}}function eIi(s){var p;if(s&&s.type===Me.DefaultValue&&s.value&&s.valueOwner&&(!pI.includes(s.valueOwner.type)||((p=s.valueOwner.defaultValue)==null?void 0:p.id)===s.value.id)){const i=$t(s.valueOwner.getDataType(null),s.valueOwner,s.valueOwner.project);return{type:Me.DefaultValue,value:i,valueOwner:s.valueOwner,inheritanceLink:null}}return s}function Af(s,p,i,r){let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=s.parent;return p.getVariableDeclarations().forEach(m=>{var b,A,_,P,V,j;const E=m.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===f.id){let M=a?m.defaultValue:e==null?void 0:e.readValue(m.id);M?!a&&M&&M.id===((A=m.defaultValue)==null?void 0:A.id)&&(M=$t(m.getDataType(null),m,p)):a?M=ku(m.getDataType(null),m,p,c):M=$t(m.getDataType(null),m,p);const G=oe(s,p),q=s.codeName||((_=s.extends)==null?void 0:_.codeName)||((P=s.implements[0])==null?void 0:P.codeName)||Xi(G);let re={};((j=(V=m.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(re={...re,...m.dataType.entity.getActiveRawDefaultValue()}),br(M==null?void 0:M.value)&&(re={...re,...M.value}),re[q]=i,M==null||M.metaSync({value:re},c),a||e==null||e.writeValue(m,M);return}}),c}function tv(s,p,i,r){var _,P,V,j;let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=Er(s.parent),h=f.getDataType(null);if(!(h!=null&&h.isObject()))return c;let m=a?f.defaultValue:e==null?void 0:e.readValue(f.id);m?!a&&m&&m.id===((_=f.defaultValue)==null?void 0:_.id)&&(m=$t(f.getDataType(null),f,p)):a?m=ku(f.getDataType(null),f,p,c):m=$t(f.getDataType(null),f,p);const E=oe(s,p),b=s.codeName||((P=s.declaration)==null?void 0:P.codeName)||Xi(E);let A={};if(((j=(V=f.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(A={...A,...f.dataType.entity.getActiveRawDefaultValue()}),br(m==null?void 0:m.value)&&(A={...A,...m.value}),A[b]=i,m==null||m.metaSync({value:A},c),a||e==null||e.writeValue(f,m),(i===""||i===null||i===void 0)&&s.type===d.OutputMap){const M=f.inputs.find(G=>{var q,re;return((q=G.declaration)==null?void 0:q.id)===((re=s.declaration)==null?void 0:re.id)||oe(G,p)===E});if(M){let G=a?M.defaultValue:e==null?void 0:e.readValue(M.id);G&&G.metaSync({value:null},c),a||e==null||e.removeValue(M.id)}}return c}function QVe(s,p,i){var e,f,h,m,E;let r=!1,a=null,c=null;if(i instanceof S?(r=!0,a=i,c=null):(a=null,c=i),Lt.includes(s.type)){const b=Er(s);(e=b.dataType)!=null&&e.isObject()&&b.inputs.forEach(A=>{var _,P,V,j,M,G;if(((_=A.declaration)==null?void 0:_.type)===d.Property&&A.declaration.static){let q=r?((P=A.getDefaultValue)==null?void 0:P.call(A))||null:c==null?void 0:c.readValue(A.declaration.id);q?!r&&q&&q.id===((V=A.declaration.defaultValue)==null?void 0:V.id)&&(q=$t(A.declaration.getDataType(null),A.declaration,p)):r?q=ku(A.declaration.getDataType(null),A.declaration,p,a):q=$t(A.declaration.getDataType(null),A.declaration,p),q==null||q.metaSync({value:null},a),r||c==null||c.removeValue((j=A.declaration)==null?void 0:j.id)}else if(((M=A.declaration)==null?void 0:M.type)===d.Property){let q=r?((G=A.getDefaultValue)==null?void 0:G.call(A))||null:c==null?void 0:c.readValue(A.id);q&&q.metaSync({value:null},a),r||c==null||c.removeValue(A.id)}})}else s.type===d.InputMap?((f=s.declaration)==null?void 0:f.type)===d.Property&&s.declaration.static?Af(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((h=s.declaration)==null?void 0:h.type)===d.Property&&tv(s,p,null,i):s.type===d.OutputMap?((m=s.declaration)==null?void 0:m.type)===d.Property&&s.declaration.static?Af(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((E=s.declaration)==null?void 0:E.type)===d.Property&&tv(s,p,null,i):s.type===d.Property&&s.static&&Af(s,p,null,i);return a}function XVe(s,p,i,r){var f,h,m,E,b,A,_;let a=!1,c=null,e=null;if(r instanceof S?(a=!0,c=r,e=null):(c=null,e=r),Lt.includes(p.type)){const P=Er(p);if((f=P.dataType)!=null&&f.isObject()){let V={};((m=(h=P.dataType)==null?void 0:h.entity)==null?void 0:m.type)===d.DefinitionEntity&&(V={...V,...P.dataType.entity.getActiveRawDefaultValue()});const j=br(s)?s:V;P.inputs.forEach(M=>{var G,q,re,ee,se,te;if(((G=M.declaration)==null?void 0:G.type)===d.Property&&M.declaration.static){let le=a?((q=p.getDefaultValue)==null?void 0:q.call(p))||null:e==null?void 0:e.readValue(M.declaration.id);le?!a&&le&&le.id===((re=M.declaration.defaultValue)==null?void 0:re.id)&&(le=$t(M.declaration.getDataType(null),M.declaration,i)):a?le=ku(M.declaration.getDataType(null),M.declaration,i,c):le=$t(M.declaration.getDataType(null),M.declaration,i);const ue=oe(M,i),z=M.codeName||((ee=M.declaration)==null?void 0:ee.codeName)||Xi(ue),X=j[z];le==null||le.metaSync({value:X},c),a||e==null||e.writeValue(M.declaration,le)}else if(((se=M.declaration)==null?void 0:se.type)===d.Property){let le=a?((te=p.getDefaultValue)==null?void 0:te.call(p))||null:e==null?void 0:e.readValue(M.id);le&&le.metaSync({value:null},c),a||e==null||e.removeValue(M.id)}})}}else p.type===d.InputMap?((E=p.declaration)==null?void 0:E.type)===d.Property&&p.declaration.static?Af(p.declaration,i,s,r):Lt.includes(p.parent.type)&&((b=p.declaration)==null?void 0:b.type)===d.Property&&tv(p,i,s,r):p.type===d.OutputMap?((A=p.declaration)==null?void 0:A.type)===d.Property&&p.declaration.static?Af(p.declaration,i,null,r):Lt.includes(p.parent.type)&&((_=p.declaration)==null?void 0:_.type)===d.Property&&tv(p,i,null,r):p.type===d.Property&&p.static&&Af(p,i,s,r);return c}function tIi(s,p,i){const r=cd(s,p);let a=!1,c=null,e=null;return i instanceof S?(a=!0,c=i,e=null):(c=null,e=i),r.forEach(f=>{var m;let h=a?((m=f.getDefaultValue)==null?void 0:m.call(f))||null:e==null?void 0:e.readValue(f.id);a?h==null||h.remove({ignoreUpstream:!1},c):e==null||e.removeValue(f.id),QVe(f,p,i)}),c}function iIi(s,p,i,r){const a=cd(p,i);let c=!1,e=null,f=null;return r instanceof S?(c=!0,e=r,f=null):(e=null,f=r),i.diggestedBuiltInBaseEntitiesIds.has(p.id)||a.forEach(h=>{var E,b,A,_;if(i.diggestedBuiltInBaseEntitiesIds.has(h.id))return;let m=null;if(c){const P=((E=h.getDefaultValue)==null?void 0:E.call(h))||null;P&&(i.diggestedBuiltInBaseEntitiesIds.has(P.id)||((b=P.parent)==null?void 0:b.id)!==h.id?m=P.clone(e,h):m=P)}else m=f==null?void 0:f.readValue(h.id);m?!c&&m&&m.id===((_=(A=h.getDefaultValue)==null?void 0:A.call(h))==null?void 0:_.id)&&(m=$t(h.getDataType(null),h,i)):c?(m=ku(h.getDataType(null),h,i,e),e==null||e.add(m,W.Added)):m=$t(h.getDataType(null),h,i),m==null||m.setValueAsType(null,e),m==null||m.metaSync({value:s},e),c||f==null||f.writeValue(h,m),XVe(s,h,i,r)}),e}function gf(s,p,i,r){let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=s.parent;return p.getVariableDeclarations().forEach(m=>{var b,A,_,P,V,j;const E=m.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===f.id){let M=a?m.defaultValue:e==null?void 0:e.readValue(m.id);M?!a&&M&&M.id===((A=m.defaultValue)==null?void 0:A.id)&&(M=$t(m.getDataType(null),m,p)):a?M=ku(m.getDataType(null),m,p,c):M=$t(m.getDataType(null),m,p);const G=oe(s,p),q=s.codeName||((_=s.extends)==null?void 0:_.codeName)||((P=s.implements[0])==null?void 0:P.codeName)||Xi(G);let re={};((j=(V=m.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(re={...re,...m.dataType.entity.getActiveRawDefaultValue()}),br(M==null?void 0:M.value)&&(re={...re,...M.value}),Array.isArray(i)?re[q]=(i==null?void 0:i.map(ee=>ee.toShallowJSON()))||null:re[q]=(i==null?void 0:i.toShallowJSON())||null,M==null||M.metaSync({value:re},c),a||e==null||e.writeValue(m,M);return}}),c}function iv(s,p,i,r){var _,P,V,j;let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=Er(s.parent),h=f.getDataType(null);if(!(h!=null&&h.isObject()))return c;let m=a?f.defaultValue:e==null?void 0:e.readValue(f.id);m?!a&&m&&m.id===((_=f.defaultValue)==null?void 0:_.id)&&(m=$t(f.getDataType(null),f,p)):a?m=ku(f.getDataType(null),f,p,c):m=$t(f.getDataType(null),f,p);const E=oe(s,p),b=s.codeName||((P=s.declaration)==null?void 0:P.codeName)||Xi(E);let A={};if(((j=(V=f.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(A={...A,...f.dataType.entity.getActiveRawDefaultValue()}),br(m==null?void 0:m.value)&&(A={...A,...m.value}),Array.isArray(i)?A[b]=(i==null?void 0:i.map(M=>M.toShallowJSON()))||null:A[b]=(i==null?void 0:i.toShallowJSON())||null,m==null||m.metaSync({value:A},c),a||e==null||e.writeValue(f,m),i==null&&s.type===d.OutputMap){const M=f.inputs.find(G=>{var q,re;return((q=G.declaration)==null?void 0:q.id)===((re=s.declaration)==null?void 0:re.id)||oe(G,p)===E});if(M){let G=a?M.defaultValue:e==null?void 0:e.readValue(M.id);G&&(Array.isArray(i)?G==null||G.setValueAsTypeList(i,c):G==null||G.setValueAsTypeSingle(i,c)),a||e==null||e.removeValue(M.id)}}return c}function ePe(s,p,i){var r,a,c,e;return s.type===d.InputMap?((r=s.declaration)==null?void 0:r.type)===d.Property&&s.declaration.static?gf(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((a=s.declaration)==null?void 0:a.type)===d.Property&&iv(s,p,null,i):s.type===d.OutputMap?((c=s.declaration)==null?void 0:c.type)===d.Property&&s.declaration.static?gf(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((e=s.declaration)==null?void 0:e.type)===d.Property&&iv(s,p,null,i):s.type===d.Property&&s.static&&gf(s,p,null,i),i}function tPe(s,p,i,r){var a,c,e,f;return p.type===d.InputMap?((a=p.declaration)==null?void 0:a.type)===d.Property&&p.declaration.static?gf(p.declaration,i,s,r):Lt.includes(p.parent.type)&&((c=p.declaration)==null?void 0:c.type)===d.Property&&iv(p,i,s,r):p.type===d.OutputMap?((e=p.declaration)==null?void 0:e.type)===d.Property&&p.declaration.static?gf(p.declaration,i,null,r):Lt.includes(p.parent.type)&&((f=p.declaration)==null?void 0:f.type)===d.Property&&iv(p,i,null,r):p.type===d.Property&&p.static&&gf(p,i,s,r),r}function rIi(s,p,i){const r=cd(s,p);let a=!1,c=null,e=null;return i instanceof S?(a=!0,c=i,e=null):(c=null,e=i),r.forEach(f=>{var m;let h=a?(m=f.getDefaultValue)==null?void 0:m.call(f):e==null?void 0:e.readValue(f.id);a?h==null||h.remove({ignoreUpstream:!1},c):e==null||e.removeValue(f.id),ePe(f,p,i)}),c}function nIi(s,p,i,r){const a=cd(p,i);let c=!1,e=null,f=null;return r instanceof S?(c=!0,e=r,f=null):(e=null,f=r),a.forEach(h=>{var E,b,A;let m=c?(E=h.getDefaultValue)==null?void 0:E.call(h):f==null?void 0:f.readValue(h.id);m?!c&&m&&m.id===((A=(b=h.getDefaultValue)==null?void 0:b.call(h))==null?void 0:A.id)&&(m=$t(h.getDataType(null),h,h.project)):c?m=ku(h.getDataType(null),h,i,e):m=$t(h.getDataType(null),h,i),Array.isArray(s)?m==null||m.setValueAsTypeList(s,e):m==null||m.setValueAsTypeSingle(s,e),m==null||m.metaSync({value:null},e),c||f==null||f.writeValue(h,m),tPe(s,h,i,r)}),e}class E1{constructor(p,i){this.extensionsRegistry=p,this.contextType=i,this.off=this.extensionsRegistry.off.bind(this.extensionsRegistry),this.on=this.extensionsRegistry.on.bind(this.extensionsRegistry),this.emit=this.extensionsRegistry.emit.bind(this.extensionsRegistry),this.emitAsync=this.extensionsRegistry.emitAsync.bind(this.extensionsRegistry),this.emitAsyncAll=this.extensionsRegistry.emitAsyncAll.bind(this.extensionsRegistry),this.emitAsyncAllSettled=this.extensionsRegistry.emitAsyncAllSettled.bind(this.extensionsRegistry),this.emitAsyncSequentially=this.extensionsRegistry.emitAsyncSequentially.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAll=this.extensionsRegistry.emitAsyncSequentiallyAll.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAllSettled=this.extensionsRegistry.emitAsyncSequentiallyAllSettled.bind(this.extensionsRegistry)}on(p,i){this.extensionsRegistry.on(p,i)}emit(p,...i){this.extensionsRegistry.emit(p,...i)}off(p,i){this.extensionsRegistry.off(p,i)}emitAsync(p,...i){return this.extensionsRegistry.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.extensionsRegistry.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.extensionsRegistry.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.extensionsRegistry.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled(p,...i)}}var Oe=(s=>(s[s.High=1]="High",s[s.Normal=5]="Normal",s[s.Low=10]="Low",s))(Oe||{}),ae=(s=>(s.Logic="logic",s.EditorGUI="editor-gui",s.GUI="gui",s.Editor="editor",s.Compile="compile",s.PublicationRun="publication-run",s))(ae||{}),_e=(s=>(s.All="*",s.OnAll="on:*",s.EmitAll="emit:*",s.ReadAll="read:*",s.WriteAll="write:*",s.UpdateAll="update:*",s.DoAll="do:*",s.OnLogicAll="on:logic:*",s.EmitLogicAll="emit:logic:*",s.ReadLogicAll="read:logic:*",s.WriteLogicAll="write:logic:*",s.UpdateLogicAll="update:logic:*",s.DoLogicAll="do:logic:*",s.OnGUIAll="on:gui:*",s.EmitGUIAll="emit:gui:*",s.ReadGUIAll="read:gui:*",s.WriteGUIAll="write:gui:*",s.UpdateGUIAll="update:gui:*",s.DoGUIAll="do:gui:*",s.OnEditorAll="on:editor:*",s.EmitEditorAll="emit:editor:*",s.ReadEditorAll="read:editor:*",s.WriteEditorAll="write:editor:*",s.UpdateEditorAll="update:editor:*",s.DoEditorAll="do:editor:*",s.OnCompileBefore="on:compile:before:DefinitionEntity",s.OnCompileDefault="on:compile:default:DefinitionEntity",s.OnCompileAfter="on:compile:after:DefinitionEntity",s.EmitCompile="emit:compile:DefinitionEntity",s.DoEditorPublish="do:editor:publish",s.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",s.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",s.UpdateGUIGlobalTheme="update:gui:global:theme",s))(_e||{});class iPe{constructor(p){R(this,"state",new Map);p&&(this.state=new Map(Object.entries(p)))}get(p){return this.state.get(p)}set(p,i){this.state.set(p,i)}delete(p){this.state.delete(p)}}class rPe extends iPe{constructor(p,i){super(i),this.parentExtension=p}}class Pe{constructor(p,i){R(this,"manifest");R(this,"module");R(this,"state");this.extensionsRegistry=p,this.state=new rPe(this,i)}}class G_ extends E1{constructor(i,r){super(i,ae.Logic);R(this,"id");this._project=r,this.id=r.id}get type(){return this._project.type}get name(){return this._project.name}get description(){return this._project.description}get version(){return this._project.version}get createdAt(){return this._project.createdAt}get previousVersion(){return this._project.previousVersion}get author(){return this._project.author}get deleted(){return this._project.deleted}get editable(){return this._project.editable}get deletable(){return this._project.deletable}get entities(){return[...this._project.entities]}get projects(){return[...this._project.projects]}get functions(){return[...this._project.functions]}get events(){return[...this._project.events]}get variableDeclarations(){return[...this._project.variableDeclarations]}get variableInstances(){return[...this._project.variableInstances]}get conditions(){return[...this._project.conditions]}get operations(){return[...this._project.operations]}get functionCalls(){return[...this._project.functionCalls]}get loops(){return[...this._project.loops]}get searches(){return[...this._project.searches]}get primitives(){return[...this._project.primitives]}get builtInBaseEntities(){return[...this._project.builtInBaseEntities]}get operationDeclarations(){return[...this._project.operationDeclarations]}get globalEventActionDescriptors(){return[...this._project.globalEventActionDescriptors]}get loopDeclarations(){return[...this._project.loopDeclarations]}get loopDeclarationsBodies(){return[...this._project.loopDeclarationsBodies]}get conditionDeclarations(){return[...this._project.conditionDeclarations]}get valueDescriptors(){return[...this._project.valueDescriptors]}get dataTypes(){return[...this._project.dataTypes]}get errors(){return[...this._project.errors]}get history(){return[...this._project.history]}get undoableStackValueIndex(){return this._project.undoableStackValueIndex}get knownVersions(){return this._project.knownVersions}get activeVersion(){return this._project.activeVersion}get initialized(){return this._project.initialized}get startedInitialization(){return this._project.startedInitialization}closePersistChangeSetsSequentially(){return this._project.closePersistChangeSetsSequentially()}persistChangeSetSequentially(i){return this._project.persistChangeSetSequentially(i)}toLatestChangeSet(i,r,a,c=!1,e="here-this"){return this._project.toLatestChangeSet(i,r,a,c,e)}addChangeSet(i){return this._project.addChangeSet(i)}discardChangeSet(i){return this._project.discardChangeSet(i)}subscribeDependents(i){return this._project.subscribeDependents(i)}unsubscribeDependents(i){return this._project.unsubscribeDependents(i)}syncDependents(i){return this._project.syncDependents(i)}onDetachedDependencyRemoved(i,r,a){return this._project.onDetachedDependencyRemoved(i,r,a)}onDetachedDependencyRestored(i,r,a){return this._project.onDetachedDependencyRestored(i,r,a)}increaseVersion(i){return this._project.increaseVersion(i)}captureVersion(){return this._project.captureVersion()}restoreVersion(i){return this._project.restoreVersion(i)}updateWithShallowTransfer(i,r){return this._project.updateWithShallowTransfer(i,r)}hydrateAncestors(){return this._project.hydrateAncestors()}afterAllChildrenInitialized(i=null){return this._project.afterAllChildrenInitialized(i)}addSelfToProject(i){return this._project.addSelfToProject(i)}get instancesList(){return[...this._project.instancesList]}isOperationDeclaration(i){return this._project.isOperationDeclaration(i)}isGlobalEventActionDescriptor(i){return this._project.isGlobalEventActionDescriptor(i)}isLoopDeclaration(i){return this._project.isLoopDeclaration(i)}isConditionDeclaration(i){return this._project.isConditionDeclaration(i)}findSubscribedBuiltInInstance(i){return this._project.findSubscribedBuiltInInstance(i)}get(i){return this._project.get(i)}getDeleted(i){return this._project.getDeleted(i)}getManaged(i){return this._project.getManaged(i)}getBuiltIn(i){return this._project.getBuiltIn(i)}findSubscribedInstanceFromReference(i){return this._project.findSubscribedInstanceFromReference(i)}findSubscribedBuiltInInstanceFromReference(i){return this._project.findSubscribedBuiltInInstanceFromReference(i)}metaSync(i,r){return this._project.metaSync(i,r)}getAllBuiltInIds(){return this._project.getAllBuiltInIds()}getAllBuiltIn(){return this._project.getAllBuiltIn()}toFlat(i){return this._project.toFlat(i)}toFlatIds(i){return this._project.toFlatIds(i)}toMeta(){return this._project.toMeta()}toJSON(i){return this._project.toJSON(i)}toJSONClone(i){return this._project.toJSONClone(i)}toReference(i){return this._project.toReference(i)}toShallowJSON(i){return this._project.toShallowJSON(i)}toFlatJSON(i){return this._project.toFlatJSON(i)}toGenerationTarget(i){return this._project.toGenerationTarget(i)}toFlatGenerationTarget(i){return this._project.toFlatGenerationTarget(i)}clearErrors(){return this._project.clearErrors()}validate(){return this._project.validate()}validateChildren(){return this._project.validateChildren()}getErrors(){return this._project.getErrors()}getShallowErrors(){return this._project.getShallowErrors()}addDefinitionEntity(i){return this._project.addDefinitionEntity(i)}addFunctionDeclaration(i){return this._project.addFunctionDeclaration(i)}addFunctionCall(i){return this._project.addFunctionCall(i)}addVariableDeclaration(i){return this._project.addVariableDeclaration(i)}addVariableInstance(i){return this._project.addVariableInstance(i)}addInstalledProject(i){return this._project.addInstalledProject(i)}addGlobalEvent(i){return this._project.addGlobalEvent(i)}addCondition(i){return this._project.addCondition(i)}addOperation(i){return this._project.addOperation(i)}addLoop(i){return this._project.addLoop(i)}addSearch(i){return this._project.addSearch(i)}removeDefinitionEntity(i){return this._project.removeDefinitionEntity(i)}removeCondition(i){return this._project.removeCondition(i)}removeOperation(i){return this._project.removeOperation(i)}removeLoop(i){return this._project.removeLoop(i)}removeSearch(i){return this._project.removeSearch(i)}removeFunctionCall(i){return this._project.removeFunctionCall(i)}removeVariableInstance(i){return this._project.removeVariableInstance(i)}removeVariableDeclaration(i){return this._project.removeVariableDeclaration(i)}removeFunctionDeclaration(i){return this._project.removeFunctionDeclaration(i)}removeInstalledProject(i){return this._project.removeInstalledProject(i)}removeGlobalEvent(i){return this._project.removeGlobalEvent(i)}removeTopLevelVariableDeclaration(i){return this._project.removeTopLevelVariableDeclaration(i)}getEntryPoints(){return this._project.getEntryPoints()}getTerminationStatements(){return this._project.getTerminationStatements()}getFunctionDeclaration(i){return this._project.getFunctionDeclaration(i)}getConditions(){return this._project.getConditions()}getOperations(){return this._project.getOperations()}getVariables(){return this._project.getVariables()}getVariableInstances(){return this._project.getVariableInstances()}getVariableDeclarations(){return this._project.getVariableDeclarations()}getLoops(){return this._project.getLoops()}getSearches(){return this._project.getSearches()}getBuiltInPersistedEntity(){return this._project.getBuiltInPersistedEntity()}requestActiveDynamicValue(i,r=!1){return this._project.requestActiveDynamicValue(i,r)}undo(){return this._project.undo()}redo(){return this._project.redo()}applyExternalChangeSet(i){return this._project.applyExternalChangeSet(i)}toFullProjectTransfer(){return this._project.toFullProjectTransfer()}}function aIi(s,p){return p instanceof G_?p:new G_(s,p)}const uh="built-in-function-implementations__",$e="operations-implementations__",ls="conditions-implementations__",Ve={UUID:"uuid",SEARCH_NODE_IMPLEMENTATION:"search-node-implementation",BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION:uh+Br.AbortExecution,BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY:uh+Br.CreatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY:uh+Br.UpdatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY:uh+Br.DeletePersistedEntity,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY:$e+Ft.Empty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY:$e+Ft.NotEmpty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL:$e+Ft.PrimitiveEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL:$e+Ft.PrimitiveNotEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST:$e+Tn.HttpRequest,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SQL:$e+no.ExecuteSQL,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY:$e+Le.Validate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT:$e+hs.Wait,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN:$e+ye.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT:$e+ye.Split,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS:$e+ye.DeleteLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS:$e+ye.DeleteFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX:$e+ye.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX:$e+ye.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS:$e+ye.ReplaceFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS:$e+ye.ReplaceLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL:$e+ye.ReplaceAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX:$e+ye.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM:$e+ye.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST:$e+ye.GetFirst,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST:$e+ye.GetLast,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND:$e+ye.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND:$e+ye.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE:$e+ye.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH:$e+ye.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS:$e+ye.GetFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS:$e+ye.GetLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE:$e+ye.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT:$e+ye.Concat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF:$e+ye.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF:$e+ye.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE:$e+ye.Unique,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN:$e+ye.Flatten,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT:$e+ye.Sort,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE:$e+ye.Shuffle,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK:$e+ye.Chunk,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START:$e+ye.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END:$e+ye.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT:$e+ye.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH:$e+H.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE:$e+H.ToLowerCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE:$e+H.ToUpperCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN:$e+H.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS:$e+ye.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL:$e+ye.ContainsAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY:$e+ye.ContainsAny,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX:$e+H.SplitAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS:$e+H.SplitAtAllSeparators,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR:$e+H.SplitAtFirstSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR:$e+H.SplitAtLastSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS:$e+H.DeleteLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS:$e+H.DeleteFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX:$e+H.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX:$e+H.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS:$e+H.ReplaceFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS:$e+H.ReplaceLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX:$e+H.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH:$e+H.ReplaceFirstMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH:$e+H.ReplaceLastMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES:$e+H.ReplaceAllMatches,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM:$e+H.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS:$e+H.GetFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS:$e+H.GetLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF:$e+H.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND:$e+H.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND:$e+H.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE:$e+H.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM:$e+H.Trim,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START:$e+H.TrimStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END:$e+H.TrimEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING:$e+H.Substring,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE:$e+H.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START:$e+H.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END:$e+H.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT:$e+H.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF:$e+H.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX:$e+H.MatchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX:$e+H.MatchAllRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX:$e+H.SearchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX:$e+H.ReplaceRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE:$e+H.NormalizeUnicode,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS:$e+H.RemoveDiacritics,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES:$e+H.CountOccurrences,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX:$e+H.EnsurePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX:$e+H.EnsureSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX:$e+H.RemovePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX:$e+H.RemoveSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION:$e+ce.Addition,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION:$e+ce.Subtraction,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION:$e+ce.Multiplication,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION:$e+ce.Division,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER:$e+ce.Remainder,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION:$e+ce.Exponentiation,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE:$e+ce.Absolute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN:$e+ce.Sign,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND:$e+ce.Round,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE:$e+ce.Negate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR:$e+ce.Floor,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL:$e+ce.Ceil,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP:$e+ce.Clamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC:$e+ce.Trunc,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS:$e+ce.RoundToDecimals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP:$e+ce.SnapToStep,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE:$e+ce.MapRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE:$e+ce.Average,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN:$e+ce.Median,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF:$e+ce.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF:$e+ce.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT:$e+ce.SquareRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT:$e+ce.CubeRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT:$e+ce.NthRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP:$e+ce.Exp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL:$e+ce.LogNatural,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10:$e+ce.Log10,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN:$e+ce.Sin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS:$e+ce.Cos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN:$e+ce.Tan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN:$e+ce.Asin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS:$e+ce.Acos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN:$e+ce.Atan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2:$e+ce.Atan2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS:$e+ce.ToRadians,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES:$e+ce.ToDegrees,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF:$e+ce.PercentOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE:$e+ce.PercentageChange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN:$e+ce.MoreThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN:$e+ce.LessThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL:$e+ce.LessThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL:$e+ce.MoreThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER:$e+nt.GenerateRandomInteger,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT:$e+nt.GenerateRandomFloat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL:$e+nt.GenerateRandomHexadecimal,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62:$e+nt.GenerateRandomBase62,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64:$e+nt.GenerateRandomBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC:$e+nt.GenerateRandomAlphanumeric,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER:$e+nt.GenerateIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4:$e+nt.GenerateRandomUUIDv4,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER:$e+nt.GenerateShortIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN:$e+nt.GenerateHexadecimalToken,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH:$e+H.StartsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH:$e+H.EndsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS:$e+H.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX:$e+H.MatchesRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP:$e+K.GetCurrentTimestamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE:$e+K.FormatDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE:$e+K.ParseDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE:$e+K.AddToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE:$e+K.SubtractFromDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES:$e+K.DifferenceBetweenDates,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE:$e+K.ToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX:$e+K.ToUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX:$e+K.FromUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING:$e+K.ToISOString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR:$e+K.GetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH:$e+K.GetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE:$e+K.GetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR:$e+K.GetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE:$e+K.GetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND:$e+K.GetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND:$e+K.GetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY:$e+K.GetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR:$e+K.GetWeekOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER:$e+K.GetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR:$e+K.GetDayOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH:$e+K.GetDaysInMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE:$e+K.GetCurrentIanaTimeZone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR:$e+K.SetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH:$e+K.SetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE:$e+K.SetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR:$e+K.SetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE:$e+K.SetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND:$e+K.SetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND:$e+K.SetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY:$e+K.SetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER:$e+K.SetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF:$e+K.StartOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF:$e+K.EndOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO:$e+K.RoundTo,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE:ls+K.IsBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER:ls+K.IsAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME:ls+K.IsSame,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE:ls+K.IsSameOrBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER:ls+K.IsSameOrAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN:ls+K.IsBetween,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID:ls+K.IsValid,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR:ls+K.IsLeapYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE:$e+K.ClampToRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF:$e+K.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF:$e+K.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW:$e+K.FromNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW:$e+K.ToNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF:$e+K.HumanizeDiff,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS:$e+K.AddBusinessDays,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY:$e+K.NextWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY:$e+K.PreviousWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC:$e+K.ToUTC,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE:$e+K.ConvertTimezone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET:$e+K.GetTimezoneOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET:$e+K.SetUTCOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY:$e+Le.ReadKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY:$e+Le.WriteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY:$e+Le.DeleteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY:$e+Le.ReadNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY:$e+Le.WriteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY:$e+Le.DeleteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY:$e+Le.WriteSafeNestedKeyRecursively,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY:ls+Le.HasKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY:ls+Le.HasNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS:ls+Le.KeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS:ls+Le.NestedKeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE:ls+Le.IsInstanceOfType,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE:$e+Le.Merge,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS:$e+Le.Keys,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES:$e+Le.Values,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES:$e+Le.Entries,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF:$e+Xe.GetTypeOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH:$e+xi.Hash,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC:$e+xi.Hmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES:$e+nt.GenerateRandomBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL:$e+xi.ConstantTimeEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2:$e+xi.DeriveKeyPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2:$e+En.HashPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2:$e+En.VerifyPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC:$e+cr.BuildJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC:$e+cr.VerifyJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE:$e+cr.DecodeJwt,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING:$e+Xe.FromBytesToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES:$e+Xe.ToBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER:$e+Xe.ToNumber,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING:$e+Xe.ToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64:$e+Xe.EncodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64:$e+Xe.DecodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL:$e+Xe.EncodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL:$e+Xe.DecodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX:$e+Xe.EncodeHex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX:$e+Xe.DecodeHex,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE:$e+vn.Parse,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY:$e+vn.Stringify};class nPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION,version:"1.0.0",description:'Implementation for the built-in function "Abort Execution". It terminates the execution of the current entity being run.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class aPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Delete Persisted Entity". It deletes the current entity as an entry in the persisted storage.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class sPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Create Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class lPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Update Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class oPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.SEARCH_NODE_IMPLEMENTATION,version:"1.0.0",description:"Implementation for search nodes when they get executed and query data.",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({error:"Search module not implemented",data:null})})}}class dPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.UUID,version:"1.0.0",description:"UUID generation module, for all contexts and runtimes",initPriority:Oe.High,permissions:[_e.All],contexts:[]});R(this,"module",IV)}}const uPe=s=>s.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class pPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY,version:"1.0.0",description:"Comparison: Empty (!value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.Empty);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=uPe(r),c=!a;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class cPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY,version:"1.0.0",description:"Comparison: NotEmpty (!!value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.NotEmpty);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=uPe(r),c=!!a;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}const nI=class nI extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveEqual (typed equality / deep JSON equality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.PrimitiveEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const E=(c=(a=r[0])==null?void 0:a.value)==null?void 0:c.name,b=(f=(e=r[0])==null?void 0:e.value)==null?void 0:f.value,A=(m=(h=r[1])==null?void 0:h.value)==null?void 0:m.value;let _=!1;return E&&nI.primitiveSet.has(E)?_=b===A:E===fe.Untyped||E===fe.KeyValue?_=JSON.stringify(b)===JSON.stringify(A):_=!1,{value:U.Success,error:null,result:_}}catch(E){return{value:U.UnhandledError,error:E,result:null}}}})}};R(nI,"primitiveSet",new Set([fe.String,fe.Number,fe.Boolean,fe.Null,fe.Enum,fe.Date,fe.UUID]));let xg=nI;const aI=class aI extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveNotEqual (typed inequality / deep JSON inequality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.PrimitiveNotEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const E=(c=(a=r[0])==null?void 0:a.value)==null?void 0:c.name,b=(f=(e=r[0])==null?void 0:e.value)==null?void 0:f.value,A=(m=(h=r[1])==null?void 0:h.value)==null?void 0:m.value;let _=!1;return E&&aI.primitiveSet.has(E)?_=b!==A:E===fe.Untyped||E===fe.KeyValue?_=JSON.stringify(b)!==JSON.stringify(A):_=!1,{value:U.Success,error:null,result:_}}catch(E){return{value:U.UnhandledError,error:E,result:null}}}})}};R(aI,"primitiveSet",new Set([fe.String,fe.Number,fe.Boolean,fe.Null,fe.Enum,fe.Date,fe.UUID]));let $g=aI;var fPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="minute",r=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g;return function(c,e,f){var h=e.prototype;f.utc=function(V){var j={date:V,utc:!0,args:arguments};return new e(j)},h.utc=function(V){var j=f(this.toDate(),{locale:this.$L,utc:!0});return V?j.add(this.utcOffset(),i):j},h.local=function(){return f(this.toDate(),{locale:this.$L,utc:!1})};var m=h.parse;h.parse=function(V){V.utc&&(this.$u=!0),this.$utils().u(V.$offset)||(this.$offset=V.$offset),m.call(this,V)};var E=h.init;h.init=function(){if(this.$u){var V=this.$d;this.$y=V.getUTCFullYear(),this.$M=V.getUTCMonth(),this.$D=V.getUTCDate(),this.$W=V.getUTCDay(),this.$H=V.getUTCHours(),this.$m=V.getUTCMinutes(),this.$s=V.getUTCSeconds(),this.$ms=V.getUTCMilliseconds()}else E.call(this)};var b=h.utcOffset;h.utcOffset=function(V,j){var M=this.$utils().u;if(M(V))return this.$u?0:M(this.$offset)?b.call(this):this.$offset;if(typeof V=="string"&&(V=function(ee){ee===void 0&&(ee="");var se=ee.match(r);if(!se)return null;var te=(""+se[0]).match(a)||["-",0,0],le=te[0],ue=60*+te[1]+ +te[2];return ue===0?0:le==="+"?ue:-ue}(V),V===null))return this;var G=Math.abs(V)<=16?60*V:V;if(G===0)return this.utc(j);var q=this.clone();if(j)return q.$offset=G,q.$u=!1,q;var re=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(q=this.local().add(G+re,i)).$offset=G,q.$x.$localOffset=re,q};var A=h.format;h.format=function(V){var j=V||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return A.call(this,j)},h.valueOf=function(){var V=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*V},h.isUTC=function(){return!!this.$u},h.toISOString=function(){return this.toDate().toISOString()},h.toString=function(){return this.toDate().toUTCString()};var _=h.toDate;h.toDate=function(V){return V==="s"&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():_.call(this)};var P=h.diff;h.diff=function(V,j,M){if(V&&this.$u===V.$u)return P.call(this,V,j,M);var G=this.local(),q=f(V).local();return P.call(G,q,j,M)}}})})(fPe);var sIi=fPe.exports;const lIi=Cs(sIi);var yPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(a,c,e){var f,h=function(A,_,P){P===void 0&&(P={});var V=new Date(A),j=function(M,G){G===void 0&&(G={});var q=G.timeZoneName||"short",re=M+"|"+q,ee=r[re];return ee||(ee=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:q}),r[re]=ee),ee}(_,P);return j.formatToParts(V)},m=function(A,_){for(var P=h(A,_),V=[],j=0;j<P.length;j+=1){var M=P[j],G=M.type,q=M.value,re=i[G];re>=0&&(V[re]=parseInt(q,10))}var ee=V[3],se=ee===24?0:ee,te=V[0]+"-"+V[1]+"-"+V[2]+" "+se+":"+V[4]+":"+V[5]+":000",le=+A;return(e.utc(te).valueOf()-(le-=le%1e3))/6e4},E=c.prototype;E.tz=function(A,_){A===void 0&&(A=f);var P,V=this.utcOffset(),j=this.toDate(),M=j.toLocaleString("en-US",{timeZone:A}),G=Math.round((j-new Date(M))/1e3/60),q=15*-Math.round(j.getTimezoneOffset()/15)-G;if(!Number(q))P=this.utcOffset(0,_);else if(P=e(M,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(q,!0),_){var re=P.utcOffset();P=P.add(V-re,"minute")}return P.$x.$timezone=A,P},E.offsetName=function(A){var _=this.$x.$timezone||e.tz.guess(),P=h(this.valueOf(),_,{timeZoneName:A}).find(function(V){return V.type.toLowerCase()==="timezonename"});return P&&P.value};var b=E.startOf;E.startOf=function(A,_){if(!this.$x||!this.$x.$timezone)return b.call(this,A,_);var P=e(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return b.call(P,A,_).tz(this.$x.$timezone,!0)},e.tz=function(A,_,P){var V=P&&_,j=P||_||f,M=m(+e(),j);if(typeof A!="string")return e(A).tz(j);var G=function(se,te,le){var ue=se-60*te*1e3,z=m(ue,le);if(te===z)return[ue,te];var X=m(ue-=60*(z-te)*1e3,le);return z===X?[ue,z]:[se-60*Math.min(z,X)*1e3,Math.max(z,X)]}(e.utc(A,V).valueOf(),M,j),q=G[0],re=G[1],ee=e(q).utcOffset(re);return ee.$x.$timezone=j,ee},e.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},e.tz.setDefault=function(A){f=A}}})})(yPe);var oIi=yPe.exports;const dIi=Cs(oIi);var hPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r,a){r.prototype.isBetween=function(c,e,f,h){var m=a(c),E=a(e),b=(h=h||"()")[0]==="(",A=h[1]===")";return(b?this.isAfter(m,f):!this.isBefore(m,f))&&(A?this.isBefore(E,f):!this.isAfter(E,f))||(b?this.isBefore(m,f):!this.isAfter(m,f))&&(A?this.isAfter(E,f):!this.isBefore(E,f))}}})})(hPe);var uIi=hPe.exports;const pIi=Cs(uIi);var mPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r){r.prototype.isSameOrAfter=function(a,c){return this.isSame(a,c)||this.isAfter(a,c)}}})})(mPe);var cIi=mPe.exports;const fIi=Cs(cIi);var TPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r){r.prototype.isSameOrBefore=function(a,c){return this.isSame(a,c)||this.isBefore(a,c)}}})})(TPe);var yIi=TPe.exports;const hIi=Cs(yIi);var vPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="week",r="year";return function(a,c,e){var f=c.prototype;f.week=function(h){if(h===void 0&&(h=null),h!==null)return this.add(7*(h-this.week()),"day");var m=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var E=e(this).startOf(r).add(1,r).date(m),b=e(this).endOf(i);if(E.isBefore(b))return 1}var A=e(this).startOf(r).date(m).startOf(i).subtract(1,"millisecond"),_=this.diff(A,i,!0);return _<0?e(this).startOf("week").week():Math.ceil(_)},f.weeks=function(h){return h===void 0&&(h=null),this.week(h)}}})})(vPe);var mIi=vPe.exports;const TIi=Cs(mIi);var EPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="day";return function(r,a,c){var e=function(m){return m.add(4-m.isoWeekday(),i)},f=a.prototype;f.isoWeekYear=function(){return e(this).year()},f.isoWeek=function(m){if(!this.$utils().u(m))return this.add(7*(m-this.isoWeek()),i);var E,b,A,_,P=e(this),V=(E=this.isoWeekYear(),b=this.$u,A=(b?c.utc:c)().year(E).startOf("year"),_=4-A.isoWeekday(),A.isoWeekday()>4&&(_+=7),A.add(_,i));return P.diff(V,"week")+1},f.isoWeekday=function(m){return this.$utils().u(m)?this.day()||7:this.day(this.day()%7?m:m-7)};var h=f.startOf;f.startOf=function(m,E){var b=this.$utils(),A=!!b.u(E)||E;return b.p(m)==="isoweek"?A?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):h.bind(this)(m,E)}}})})(EPe);var vIi=EPe.exports;const EIi=Cs(vIi);var bPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="month",r="quarter";return function(a,c){var e=c.prototype;e.quarter=function(m){return this.$utils().u(m)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(m-1))};var f=e.add;e.add=function(m,E){return m=Number(m),this.$utils().p(E)===r?this.add(3*m,i):f.bind(this)(m,E)};var h=e.startOf;e.startOf=function(m,E){var b=this.$utils(),A=!!b.u(E)||E;if(b.p(m)===r){var _=this.quarter()-1;return A?this.month(3*_).startOf(i).startOf("day"):this.month(3*_+2).endOf(i).endOf("day")}return h.bind(this)(m,E)}}})})(bPe);var bIi=bPe.exports;const AIi=Cs(bIi);var APe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r,a){r.prototype.dayOfYear=function(c){var e=Math.round((a(this).startOf("day")-a(this).startOf("year"))/864e5)+1;return c==null?e:this.add(c-e,"day")}}})})(APe);var gIi=APe.exports;const IIi=Cs(gIi);var gPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r,a){i=i||{};var c=r.prototype,e={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function f(m,E,b,A){return c.fromToBase(m,E,b,A)}a.en.relativeTime=e,c.fromToBase=function(m,E,b,A,_){for(var P,V,j,M=b.$locale().relativeTime||e,G=i.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],q=G.length,re=0;re<q;re+=1){var ee=G[re];ee.d&&(P=A?a(m).diff(b,ee.d,!0):b.diff(m,ee.d,!0));var se=(i.rounding||Math.round)(Math.abs(P));if(j=P>0,se<=ee.r||!ee.r){se<=1&&re>0&&(ee=G[re-1]);var te=M[ee.l];_&&(se=_(""+se)),V=typeof te=="string"?te.replace("%d",se):te(se,E,ee.l,j);break}}if(E)return V;var le=j?M.future:M.past;return typeof le=="function"?le(V):le.replace("%s",V)},c.to=function(m,E){return f(m,E,this,!0)},c.from=function(m,E){return f(m,E,this)};var h=function(m){return m.$u?a.utc():a()};c.toNow=function(m){return this.to(h(this),m)},c.fromNow=function(m){return this.from(h(this),m)}}})})(gPe);var RIi=gPe.exports;const DIi=Cs(RIi);var IPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i,r,a=1e3,c=6e4,e=36e5,f=864e5,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,m=31536e6,E=2628e6,b=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,A={years:m,months:E,days:f,hours:e,minutes:c,seconds:a,milliseconds:1,weeks:6048e5},_=function(se){return se instanceof re},P=function(se,te,le){return new re(se,le,te.$l)},V=function(se){return r.p(se)+"s"},j=function(se){return se<0},M=function(se){return j(se)?Math.ceil(se):Math.floor(se)},G=function(se){return Math.abs(se)},q=function(se,te){return se?j(se)?{negative:!0,format:""+G(se)+te}:{negative:!1,format:""+se+te}:{negative:!1,format:""}},re=function(){function se(le,ue,z){var X=this;if(this.$d={},this.$l=z,le===void 0&&(this.$ms=0,this.parseFromMilliseconds()),ue)return P(le*A[V(ue)],this);if(typeof le=="number")return this.$ms=le,this.parseFromMilliseconds(),this;if(typeof le=="object")return Object.keys(le).forEach(function(me){X.$d[V(me)]=le[me]}),this.calMilliseconds(),this;if(typeof le=="string"){var pe=le.match(b);if(pe){var de=pe.slice(2).map(function(me){return me!=null?Number(me):0});return this.$d.years=de[0],this.$d.months=de[1],this.$d.weeks=de[2],this.$d.days=de[3],this.$d.hours=de[4],this.$d.minutes=de[5],this.$d.seconds=de[6],this.calMilliseconds(),this}}return this}var te=se.prototype;return te.calMilliseconds=function(){var le=this;this.$ms=Object.keys(this.$d).reduce(function(ue,z){return ue+(le.$d[z]||0)*A[z]},0)},te.parseFromMilliseconds=function(){var le=this.$ms;this.$d.years=M(le/m),le%=m,this.$d.months=M(le/E),le%=E,this.$d.days=M(le/f),le%=f,this.$d.hours=M(le/e),le%=e,this.$d.minutes=M(le/c),le%=c,this.$d.seconds=M(le/a),le%=a,this.$d.milliseconds=le},te.toISOString=function(){var le=q(this.$d.years,"Y"),ue=q(this.$d.months,"M"),z=+this.$d.days||0;this.$d.weeks&&(z+=7*this.$d.weeks);var X=q(z,"D"),pe=q(this.$d.hours,"H"),de=q(this.$d.minutes,"M"),me=this.$d.seconds||0;this.$d.milliseconds&&(me+=this.$d.milliseconds/1e3,me=Math.round(1e3*me)/1e3);var ve=q(me,"S"),we=le.negative||ue.negative||X.negative||pe.negative||de.negative||ve.negative,Re=pe.format||de.format||ve.format?"T":"",xe=(we?"-":"")+"P"+le.format+ue.format+X.format+Re+pe.format+de.format+ve.format;return xe==="P"||xe==="-P"?"P0D":xe},te.toJSON=function(){return this.toISOString()},te.format=function(le){var ue=le||"YYYY-MM-DDTHH:mm:ss",z={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return ue.replace(h,function(X,pe){return pe||String(z[X])})},te.as=function(le){return this.$ms/A[V(le)]},te.get=function(le){var ue=this.$ms,z=V(le);return z==="milliseconds"?ue%=1e3:ue=z==="weeks"?M(ue/A[z]):this.$d[z],ue||0},te.add=function(le,ue,z){var X;return X=ue?le*A[V(ue)]:_(le)?le.$ms:P(le,this).$ms,P(this.$ms+X*(z?-1:1),this)},te.subtract=function(le,ue){return this.add(le,ue,!0)},te.locale=function(le){var ue=this.clone();return ue.$l=le,ue},te.clone=function(){return P(this.$ms,this)},te.humanize=function(le){return i().add(this.$ms,"ms").locale(this.$l).fromNow(!le)},te.valueOf=function(){return this.asMilliseconds()},te.milliseconds=function(){return this.get("milliseconds")},te.asMilliseconds=function(){return this.as("milliseconds")},te.seconds=function(){return this.get("seconds")},te.asSeconds=function(){return this.as("seconds")},te.minutes=function(){return this.get("minutes")},te.asMinutes=function(){return this.as("minutes")},te.hours=function(){return this.get("hours")},te.asHours=function(){return this.as("hours")},te.days=function(){return this.get("days")},te.asDays=function(){return this.as("days")},te.weeks=function(){return this.get("weeks")},te.asWeeks=function(){return this.as("weeks")},te.months=function(){return this.get("months")},te.asMonths=function(){return this.as("months")},te.years=function(){return this.get("years")},te.asYears=function(){return this.as("years")},se}(),ee=function(se,te,le){return se.add(te.years()*le,"y").add(te.months()*le,"M").add(te.days()*le,"d").add(te.hours()*le,"h").add(te.minutes()*le,"m").add(te.seconds()*le,"s").add(te.milliseconds()*le,"ms")};return function(se,te,le){i=le,r=le().$utils(),le.duration=function(X,pe){var de=le.locale();return P(X,{$l:de},pe)},le.isDuration=_;var ue=te.prototype.add,z=te.prototype.subtract;te.prototype.add=function(X,pe){return _(X)?ee(this,X,1):ue.bind(this)(X,pe)},te.prototype.subtract=function(X,pe){return _(X)?ee(this,X,-1):z.bind(this)(X,pe)}}})})(IPe);var wIi=IPe.exports;const CIi=Cs(wIi);var RPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(RPe);var OIi=RPe.exports;const _Ii=Cs(OIi);B.extend(lIi);B.extend(dIi);B.extend(pIi);B.extend(fIi);B.extend(hIi);B.extend(TIi);B.extend(EIi);B.extend(AIi);B.extend(IIi);B.extend(DIi);B.extend(CIi);B.extend(_Ii);const Nt=s=>B(s),Tr=s=>s.toISOString();function DPe(){return Tr(B())}function wPe(s,p){return Nt(s).format(p)}function CPe(s){return Tr(B(s))}function OPe(s){if(s==null)throw new TypeError("ToDate expects a non-null value.");if(typeof s=="string"){const p=B(s);if(!p.isValid())throw new TypeError("Invalid date string.");return p.toISOString()}if(typeof s=="number"&&Number.isFinite(s)){const p=Math.abs(s)<1e12?B.unix(s):B(s);if(!p.isValid())throw new TypeError("Invalid numeric timestamp.");return p.toISOString()}if(s instanceof Date){const p=B(s);if(!p.isValid())throw new TypeError("Invalid Date object.");return p.toISOString()}throw new TypeError("Unsupported value type for ToDate. Provide a string, number, or Date.")}function _Pe(s,p,i){return Tr(Nt(s).add(p,i))}function VPe(s,p,i){return Tr(Nt(s).subtract(p,i))}function PPe(s,p,i,r=!1){return Nt(s).diff(Nt(p),i,r)}function NPe(s){return Nt(s).unix()}function xPe(s){return Tr(B.unix(s))}function $Pe(s){return Tr(Nt(s))}function LPe(s){return Nt(s).year()}function BPe(s){return Nt(s).month()}function MPe(s){return Nt(s).date()}function GPe(s){return Nt(s).hour()}function jPe(s){return Nt(s).minute()}function kPe(s){return Nt(s).second()}function UPe(s){return Nt(s).millisecond()}function FPe(s){return Nt(s).isoWeekday()}function KPe(s){return Nt(s).week()}function qPe(s){return Nt(s).quarter()}function SPe(s){return Nt(s).dayOfYear()}function ZPe(s){return Nt(s).daysInMonth()}function HPe(s,p){return Tr(Nt(s).year(p))}function WPe(s,p){return Tr(Nt(s).month(p))}function zPe(s,p){return Tr(Nt(s).date(p))}function YPe(s,p){return Tr(Nt(s).hour(p))}function JPe(s,p){return Tr(Nt(s).minute(p))}function QPe(s,p){return Tr(Nt(s).second(p))}function XPe(s,p){return Tr(Nt(s).millisecond(p))}function eNe(s,p){return Tr(Nt(s).isoWeekday(p))}function tNe(s,p){return Tr(Nt(s).quarter(p))}function iNe(s,p){return Tr(Nt(s).startOf(p))}function rNe(s,p){return Tr(Nt(s).endOf(p))}function nNe(s,p){const i=Nt(s),r=i.startOf(p),a=i.endOf(p),c=r.valueOf()+(a.valueOf()-r.valueOf())/2;return Tr(i.valueOf()<c?r:a)}function aNe(s,p,i){return Nt(s).isBefore(Nt(p),i)}function sNe(s,p,i){return Nt(s).isAfter(Nt(p),i)}function lNe(s,p,i){return Nt(s).isSame(Nt(p),i)}function oNe(s,p,i){return Nt(s).isSameOrBefore(Nt(p),i)}function dNe(s,p,i){return Nt(s).isSameOrAfter(Nt(p),i)}function uNe(s,p,i,r,a="()"){return Nt(s).isBetween(Nt(p),Nt(i),r,a)}function pNe(s){return B(s).isValid()}function cNe(s){return Nt(s).isLeapYear()}function fNe(s,p,i){const r=Nt(s);return r.isBefore(p)?Tr(Nt(p)):r.isAfter(i)?Tr(Nt(i)):Tr(r)}function yNe(s){if(s.length===0)throw new Error("minOf requires at least one date");let p=Nt(s[0]);for(let i=1;i<s.length;i++){const r=Nt(s[i]);r.isBefore(p)&&(p=r)}return Tr(p)}function hNe(s){if(s.length===0)throw new Error("maxOf requires at least one date");let p=Nt(s[0]);for(let i=1;i<s.length;i++){const r=Nt(s[i]);r.isAfter(p)&&(p=r)}return Tr(p)}function mNe(s,p=!1){return Nt(s).fromNow(p)}function TNe(s,p=!1){return Nt(s).toNow(p)}function vNe(s,p,i=!0){const r=Nt(s).diff(Nt(p),"millisecond",!0),a=Math.abs(r),e=B.duration(a,"milliseconds").humanize();return i?r>=0?`in ${e}`:`${e} ago`:e}function ENe(s,p,i=["6","7"],r=[]){const a=m=>r.some(E=>Nt(E).isSame(m,"day")),c=m=>((m.day()+6)%7+1).toString();let e=Nt(s);const f=p>=0?1:-1;let h=Math.abs(p);for(;h>0;){e=e.add(f,"day");const m=c(e);!i.includes(m)&&!a(e)&&h--}return Tr(e)}function bNe(s,p){let i=Nt(s);const r=p;for(let a=0;a<7;a++)if(i=i.add(1,"day"),i.isoWeekday()===r)return Tr(i);return Tr(i)}function ANe(s,p){let i=Nt(s);const r=p;for(let a=0;a<7;a++)if(i=i.subtract(1,"day"),i.isoWeekday()===r)return Tr(i);return Tr(i)}const gNe="Local";function Qx(){try{const s=Intl.DateTimeFormat().resolvedOptions().timeZone;if(s&&typeof s=="string")return s}catch{}try{if(typeof process<"u"&&process.env&&process.env.TZ)return process.env.TZ}catch{}return null}function Xx(){const s=Qx();if(s)return s;throw new Error("Unable to detect current IANA timezone from host environment.")}function INe(s,p,i=!1){let r=p;if(r===gNe){const e=Qx();if(!e)throw new Error("Unable to detect current timezone from host environment.");r=e}const a=r?B.tz(s,r):Nt(s),c=i?a.utc(!0):a.utc();return Tr(c)}function RNe(s,p,i=!1){const r=Nt(s);return Tr(i?r.tz(p,!0):r.tz(p))}function DNe(s,p){const i=s===gNe?Xx():s;return Nt(p).tz(i).utcOffset()}function wNe(s,p,i=!1){return Tr(Nt(s).utcOffset(p,i))}class CNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP,version:"1.0.0",description:"Date get current timestamp operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetCurrentTimestamp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=DPe();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ONe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE,version:"1.0.0",description:"Date format operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.FormatDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=wPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _Ne extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE,version:"1.0.0",description:"Date parse operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ParseDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=CPe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE,version:"1.0.0",description:"Date add-to-date operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.AddToDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=_Pe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class PNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE,version:"1.0.0",description:"Date subtract-from-date operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SubtractFromDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=VPe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class NNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES,version:"1.0.0",description:"Date difference-between-dates operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.DifferenceBetweenDates);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2],h=a[3]??!1,m=PPe(c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VIi extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE,version:"1.0.0",description:"Date to-date operation implementation module (coerce to ISO 8601 string)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=OPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class xNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX,version:"1.0.0",description:"Date to-unix operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToUnix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=NPe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class $Ne extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX,version:"1.0.0",description:"Date from-unix operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.FromUnix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=xPe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class LNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING,version:"1.0.0",description:"Date to-iso-string operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToISOString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=$Pe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class BNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR,version:"1.0.0",description:"Date get-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=LPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class MNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH,version:"1.0.0",description:"Date get-month (0-based) operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetMonth);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=BPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class GNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE,version:"1.0.0",description:"Date get-date (day of month) operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=MPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class jNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR,version:"1.0.0",description:"Date get-hour operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetHour);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=GPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class kNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE,version:"1.0.0",description:"Date get-minute operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetMinute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=jPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class UNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND,version:"1.0.0",description:"Date get-second operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetSecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=kPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class FNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND,version:"1.0.0",description:"Date get-millisecond operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetMillisecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=UPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class KNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY,version:"1.0.0",description:"Date get-iso-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetIsoWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=FPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class qNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR,version:"1.0.0",description:"Date get-week-of-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetWeekOfYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=KPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class SNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER,version:"1.0.0",description:"Date get-quarter operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetQuarter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=qPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ZNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR,version:"1.0.0",description:"Date get-day-of-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetDayOfYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=SPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class HNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH,version:"1.0.0",description:"Date get-days-in-month operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetDaysInMonth);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=ZPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class WNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE,version:"1.0.0",description:"Date get-current-iana-timezone operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetCurrentIanaTimeZone);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=Xx();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class zNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR,version:"1.0.0",description:"Date set-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=HPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class YNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH,version:"1.0.0",description:"Date set-month operation implementation module (0-based month)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetMonth);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=WPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class JNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE,version:"1.0.0",description:"Date set-date (day of month) operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=zPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class QNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR,version:"1.0.0",description:"Date set-hour operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetHour);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=YPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class XNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE,version:"1.0.0",description:"Date set-minute operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetMinute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=JPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class exe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND,version:"1.0.0",description:"Date set-second operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetSecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=QPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class txe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND,version:"1.0.0",description:"Date set-millisecond operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetMillisecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=XPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ixe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY,version:"1.0.0",description:"Date set-iso-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetIsoWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=eNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class rxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER,version:"1.0.0",description:"Date set-quarter operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetQuarter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=tNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class nxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF,version:"1.0.0",description:"Date start-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.StartOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=iNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class axe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF,version:"1.0.0",description:"Date end-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.EndOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=rNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class sxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO,version:"1.0.0",description:"Date round-to operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.RoundTo);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=nNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class lxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE,version:"1.0.0",description:"Date is-before operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsBefore);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=aNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class oxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER,version:"1.0.0",description:"Date is-after operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsAfter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=sNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class dxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME,version:"1.0.0",description:"Date is-same operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsSame);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=lNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE,version:"1.0.0",description:"Date is-same-or-before operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsSameOrBefore);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=oNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class pxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER,version:"1.0.0",description:"Date is-same-or-after operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsSameOrAfter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=dNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class cxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN,version:"1.0.0",description:"Date is-between operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsBetween);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(b=>{var A,_;return((A=b.value)==null?void 0:A.valueAsType)||((_=b.value)==null?void 0:_.value)}),c=a[0],e=a[1],f=a[2],h=a[3],m=a[4],E=uNe(c,e,f,h,m??void 0);return{value:U.Success,error:null,result:E}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class fxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID,version:"1.0.0",description:"Date is-valid operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsValid);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=pNe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class yxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR,version:"1.0.0",description:"Date is-leap-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsLeapYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=cNe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class hxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE,version:"1.0.0",description:"Date clamp-to-range operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ClampToRange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=fNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class mxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF,version:"1.0.0",description:"Date min-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.MinOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),c=a.length===1&&Array.isArray(a[0])?a[0]:a,e=yNe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Txe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF,version:"1.0.0",description:"Date max-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.MaxOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),c=a.length===1&&Array.isArray(a[0])?a[0]:a,e=hNe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class vxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW,version:"1.0.0",description:"Date from-now operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.FromNow);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),f=mNe(a,c??!1);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Exe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW,version:"1.0.0",description:"Date to-now operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToNow);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),f=TNe(a,c??!1);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class bxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF,version:"1.0.0",description:"Date humanize-diff operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.HumanizeDiff);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=vNe(a,c,e??!0);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Axe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS,version:"1.1.0",description:"Date add-business-days operation implementation module (ISO-weekend strings)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.AddBusinessDays);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2]??void 0,h=a[3]??[],m=ENe(c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class gxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY,version:"1.0.0",description:"Date next-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.NextWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),e=bNe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Ixe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY,version:"1.0.0",description:"Date previous-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.PreviousWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),e=ANe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Rxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC,version:"1.1.0",description:"Date to-utc operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToUTC);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1]||void 0,f=a[2]??!1,h=INe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Dxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE,version:"1.0.0",description:"Date convert-timezone operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ConvertTimezone);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=RNe(a,c,e??!1);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class wxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET,version:"1.0.0",description:"Date get-timezone-offset operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetTimezoneOffset);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=DNe(a,c);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Cxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET,version:"1.0.0",description:"Date set-utc-offset operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetUTCOffset);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=wNe(a,c,e??!1);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Oxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(hs.Wait);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)})[0];return typeof c!="number"||c<0?{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"Invalid wait time provided",result:null}:(await new Promise(e=>setTimeout(e,c)),{value:U.Success,error:null,result:null})}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const PIi=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,e$=s=>s===null||["string","number","boolean"].includes(typeof s);function Wn(s,p="Input must be an array"){if(!Array.isArray(s))throw new TypeError(p);return s}function jo(s){const p=Wn(s,"Input must be an array");if(!p||p.length===0)throw new TypeError("No list provided or list is empty");return p}function t$(s){return Array.isArray(s)?s:[]}function Us(s){return Number(s)}function _xe(s){if(!s||s.length===0)throw new TypeError("No input lists provided");if(!s.every(r=>Array.isArray(r)))throw new TypeError("All inputs must be arrays");const[p,...i]=s;return i.reduce((r,a)=>r.concat(a),p)}function Vxe(s,...p){if(!Array.isArray(s))throw new TypeError("First input must be an array");if(!p.every(i=>Array.isArray(i)))throw new TypeError("All subsequent inputs must be arrays");return s.concat(...p)}function Pxe(s,p){const i=jo(s),r=Us(p);return[i.slice(0,r),i.slice(r)]}function Nxe(s){return jo(s).slice().reverse()}function xxe(s){return jo(s).slice(0,-1)}function $xe(s){return jo(s).slice(1)}function Lxe(s,p,i){const r=Wn(s),a=Us(p);if(a<0||a>r.length)throw new TypeError("Index out of bounds");return[...r.slice(0,a),i,...r.slice(a)]}function Bxe(s,p,i){const r=jo(s),a=Us(p);if(a<0||a>=r.length)throw new TypeError("Index out of bounds");const c=[...r];return c[a]=i,c}function Mxe(s,p,i){const r=jo(s),a=r.indexOf(p);if(a===-1)return r;const c=[...r];return c[a]=i,c}function Gxe(s,p,i){const r=jo(s),a=r.lastIndexOf(p);if(a===-1)return r;const c=[...r];return c[a]=i,c}function jxe(s,p,i){return jo(s).map(a=>a===p?i:a)}function kxe(s,p){const i=jo(s),r=Us(p);if(r<0||r>=i.length)throw new TypeError("Index out of bounds");return i[r]}function Uxe(s){return jo(s)[0]}function Fxe(s){const p=jo(s);return p[p.length-1]}function Kxe(s,p,...i){return[...Wn(s),p,...i]}function qxe(s,p){const i=Wn(s);return[p,...i]}function Sxe(s){return Wn(s).length}function Zxe(s,p){const i=Wn(s),r=Us(p);if(r<0||r>=i.length)throw new TypeError("Index out of bounds");return i.slice(0,r).concat(i.slice(r+1))}function Hxe(s,p){const i=Wn(s),r=Math.max(0,Us(p)??0);return i.slice(0,r)}function Wxe(s,p){const i=Wn(s),r=Math.max(0,Us(p)??0);return r===0?[]:i.slice(-r)}function zxe(s,p,i){const r=Wn(s),a=p==null?void 0:Us(p),c=i==null?void 0:Us(i);return r.slice(a,c)}function Yxe(s,p){return Wn(s).indexOf(p)}function Jxe(s,p){return Wn(s).lastIndexOf(p)}function Qxe(s){const p=Wn(s),i=[],r=new Set;for(const a of p)r.has(a)||(r.add(a),i.push(a));return i}function Xxe(s){return Wn(s).reduce((i,r)=>i.concat(r),[])}function e$e(s){const p=Wn(s);if(p.length<=1)return[...p];const i=p[0],r=typeof i=="number"&&p.every(e=>typeof e=="number"&&Number.isFinite(e)),a=typeof i=="string"&&p.every(e=>typeof e=="string");let c=null;if(r?c="number":a&&(c=p.every(f=>PIi.test(f)&&B(f).isValid())?"date":"string"),!c)throw new TypeError("All items must be of the same supported type: number, string, or ISO date string.");return c==="number"?[...p].sort((e,f)=>e-f):c==="string"?[...p].sort((e,f)=>e.localeCompare(f)):[...p].sort((e,f)=>B(e).valueOf()-B(f).valueOf())}function t$e(s){const i=[...Wn(s)];for(let r=i.length-1;r>0;r--){const a=Math.floor(h1()*(r+1));[i[r],i[a]]=[i[a],i[r]]}return i}function i$e(s,p){const i=Wn(s),r=Math.max(1,Us(p)||1),a=[];for(let c=0;c<i.length;c+=r)a.push(i.slice(c,c+r));return a}function r$e(s,p,i){const r=Wn(s),a=Math.max(0,Us(p)||0);if(r.length>=a)return[...r];const c=a-r.length;return Array(c).fill(i).concat(r)}function n$e(s,p,i){const r=Wn(s),a=Math.max(0,Us(p)||0);if(r.length>=a)return[...r];const c=a-r.length,e=Array(c).fill(i);return r.concat(e)}function a$e(s,p){const i=Wn(s),r=Math.max(0,Us(p)||0),a=[];for(let c=0;c<r;c++)a.push(...i);return a}function s$e(s,p){if(!e$(p))throw new TypeError("Contains expects the needle to be a primitive (string | number | boolean | null).");return t$(s).some(r=>r===p)}function l$e(s,p){const i=t$(s),r=Array.isArray(p)?p:[p];if(r.length===0)return!1;if(!r.every(e$))throw new TypeError("ContainsAll expects all needles to be primitives (string | number | boolean | null).");return r.every(a=>i.includes(a))}function o$e(s,p){const i=t$(s),r=Array.isArray(p)?p:[p];if(r.length===0)return!1;if(!r.every(e$))throw new TypeError("ContainsAny expects all needles to be primitives (string | number | boolean | null).");return r.some(a=>i.includes(a))}class d$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Join);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=_xe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class u$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Split);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],[f,h]=Pxe(c,e);return{value:U.Success,error:null,result:[f,h]}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class p$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Reverse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Nxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class c$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS,version:"1.0.0",description:"List delete last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.DeleteLastNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=xxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class f$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS,version:"1.0.0",description:"List delete first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.DeleteFirstNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=$xe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class y$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.AddAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Lxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class h$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Bxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class m$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS,version:"1.0.0",description:"List replace first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceFirstNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Mxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class T$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS,version:"1.0.0",description:"List replace last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceLastNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Gxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class v$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL,version:"1.0.0",description:"List replace all operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceAll);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=jxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class E$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.GetIndexItem);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=kxe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class b$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.GetFirst);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Uxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class A$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.GetLast);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Fxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class g$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Append);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a.slice(2),h=Kxe(c,e,...f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class I$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Prepend);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=qxe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class R$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH,version:"1.0.0",description:"List get length",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetLength);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(c=>{var e,f;return((e=c.value)==null?void 0:e.valueAsType)??((f=c.value)==null?void 0:f.value)});return{value:U.Success,error:null,result:Sxe(a)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class D$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX,version:"1.0.0",description:"List delete one item at index (non-mutating)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.DeleteAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Zxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class w$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS,version:"1.0.0",description:"List get first N items",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetFirstNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Hxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class C$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS,version:"1.0.0",description:"List get last N items",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetLastNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Wxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class O$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE,version:"1.0.0",description:"List slice(start, end)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Slice);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=zxe(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT,version:"1.0.0",description:"List concat(base, ...others)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Concat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),[c,...e]=a,f=Vxe(c,...e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class V$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF,version:"1.0.0",description:"List listGetIndexOf(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Yxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class P$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF,version:"1.0.0",description:"List listGetLastIndexOf(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetLastIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Jxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class N$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE,version:"1.0.0",description:"List unique (stable, by reference/===)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Unique);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=Qxe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class x$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN,version:"1.0.0",description:"List flatten one level",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Flatten);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=Xxe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class $$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT,version:"1.0.0",description:"List sort (non-mutating). Supports lists of strings (alphabetic), numbers (numeric), or ISO date strings (chronological).",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Sort);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=e$e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class L$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE,version:"1.0.0",description:"List shuffle (Fisher–Yates, secure RNG helper)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Shuffle);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=t$e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class B$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK,version:"1.0.0",description:"List chunk(size) -> list of lists",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Chunk);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=i$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class M$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START,version:"1.0.0",description:"List padStart(targetLength, padValue)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.PadStart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=r$e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class G$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END,version:"1.0.0",description:"List padEnd(targetLength, padValue)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.PadEnd);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=n$e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class j$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT,version:"1.0.0",description:"List repeat(count)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Repeat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=a$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class k$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS,version:"1.0.0",description:"List contains (primitive needles)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Contains);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=s$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class U$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL,version:"1.0.0",description:"List contains all (primitive needles)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.ContainsAll);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=l$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class F$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY,version:"1.0.0",description:"List contains any (primitive needles)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.ContainsAny);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=o$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class NIi extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH,version:"1.0.0",description:"Returns the number of characters in a string",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.GetLength);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.length;return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class K$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Join);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a,c,e;try{const f=r.find(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.separator.id}),h=((a=f==null?void 0:f.value)==null?void 0:a.value)||"",m=r.find(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.first.id}),E=((c=m==null?void 0:m.value)==null?void 0:c.value)||"",b=r.find(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.second.id}),A=((e=b==null?void 0:b.value)==null?void 0:e.value)||"",P=r.filter(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.dynamicString.id}).map(j=>{var M,G;return((M=j.value)==null?void 0:M.valueAsType)||((G=j.value)==null?void 0:G.value)||""}),V=[E,A,...P].join(h);return{value:U.Success,error:null,result:V}}catch(f){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:f,result:null}}}})}}class q$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX,version:"1.0.0",description:"String split at index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f={firstPart:c.slice(0,e),secondPart:c.slice(e)};return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class S$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS,version:"1.0.0",description:"String split at all the occurrences of separators operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtAllSeparators);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=c.split(e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Z$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR,version:"1.0.0",description:"String split at the first occurrence of a separator operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtFirstSeparator);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=c.indexOf(e),h={firstPart:c.slice(0,f),secondPart:c.slice(f+e.length)};return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class H$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR,version:"1.0.0",description:"String split at the last occurrence of a separator operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtLastSeparator);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=c.lastIndexOf(e),h={firstPart:c.slice(0,f),secondPart:c.slice(f+e.length)};return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class W$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS,version:"1.0.0",description:"String delete last number of characters operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.DeleteLastNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(0,-e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class z$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS,version:"1.0.0",description:"String delete first number of characters operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.DeleteFirstNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(0,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Y$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Reverse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const e=c.split("").reverse().join("");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class J$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ToLowerCase);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const e=c.toLowerCase();return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Q$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ToUpperCase);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const e=c.toUpperCase();return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class X$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.DeleteAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=Math.min(f,c.length-e),m=c.slice(0,e)+c.slice(e+h);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class eLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.AddAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.slice(0,e)+f+c.slice(e);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class tLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS,version:"1.0.0",description:"String replace first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceFirstNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1]??1,f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=f+c.slice(e);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class iLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS,version:"1.0.0",description:"String replace last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceLastNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1]??1,f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.slice(0,-e)+f;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class rLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2]??1,h=a[3];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const m=(c.slice(0,e)||"")+h+(c.slice(e+f)||"");return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class nLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceFirstMatch);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.replace(e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class aLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceLastMatch);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.lastIndexOf(e),m=h===-1?c:c.substring(0,h)+f+c.substring(h+e.length);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class sLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceAllMatches);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.split(e).join(f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class lLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetIndexItem);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.charAt(e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class oLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS,version:"1.0.0",description:"String get last N chars operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetLastNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(-e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class dLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS,version:"1.0.0",description:"String get first N chars operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetFirstNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(0,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No search value provided",result:null};const f=c.indexOf(e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class pLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Append);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No value to append provided",result:null};const f=a.slice(2);if(!f.every(m=>typeof m=="string"))return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"All values to append must be strings",result:null};const h=[c,e,...f].join("");return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class cLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Prepend);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=e+c;return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class fLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM,version:"1.0.0",description:"String trim implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Trim);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.trim();return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class yLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START,version:"1.0.0",description:"String trimStart implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.TrimStart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.trimStart();return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class hLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END,version:"1.0.0",description:"String trimEnd implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.TrimEnd);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.trimEnd();return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class mLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING,version:"1.0.0",description:"String substring(start, end?) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Substring);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.substring(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class TLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE,version:"1.0.0",description:"String slice(start, end?) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Slice);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.slice(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class vLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF,version:"1.0.0",description:"String lastIndexOf(search, fromIndex?) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.GetLastIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.lastIndexOf(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ELe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START,version:"1.0.0",description:"String padStart(targetLength, padString?) implementation",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.PadStart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.padStart(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class bLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END,version:"1.0.0",description:"String padEnd(targetLength, padString?) implementation",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.PadEnd);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.padEnd(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ALe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT,version:"1.0.0",description:"String repeat(count) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Repeat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=a.repeat(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class gLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX,version:"1.0.0",description:"String match(regex) -> first match array or null",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.MatchRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),f=new RegExp(String(c??""),e?String(e):void 0),h=String(a??"").match(f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ILe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX,version:"1.0.0",description:"String matchAll(regex) -> array of matches",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.MatchAllRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(b=>{var A,_;return((A=b.value)==null?void 0:A.valueAsType)??((_=b.value)==null?void 0:_.value)}),f=e?String(e):"",h=f.includes("g")?f:f+"g",m=new RegExp(String(c??""),h),E=Array.from(String(a??"").matchAll(m),b=>Array.from(b));return{value:U.Success,error:null,result:E}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class RLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX,version:"1.0.0",description:"String search(regex) -> index or -1",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.SearchRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});let f=-1;try{const h=new RegExp(String(c??""),e?String(e):void 0);f=String(a??"").search(h)}catch{f=-1}return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class DLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX,version:"1.0.0",description:"String replace using RegExp (pattern, replacement, flags?)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.ReplaceRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)});let h=String(a??"");const m=new RegExp(String(c??""),f?String(f):void 0);return h=h.replace(m,String(e??"")),{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class wLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE,version:"1.0.0",description:"String normalize(form?) implementation module (NFC by default)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.NormalizeUnicode);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=a.normalize(c||"NFC");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const sI=class sI extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS,version:"1.0.0",description:"Remove diacritics via NFD decomposition + strip combining marks",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.RemoveDiacritics);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=String(a??"").normalize("NFD").replace(sI.COMBINING_MARKS,"");return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}};R(sI,"COMBINING_MARKS",/[\u0300-\u036f]/g);let Lg=sI;class CLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES,version:"1.0.0",description:"Count literal substring occurrences in a string",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.CountOccurrences);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=f===""?0:e.split(f).length-1;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class OLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX,version:"1.0.0",description:"Ensure string starts with given prefix (add if missing)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.EnsurePrefix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.startsWith(f)?e:f+e;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _Le extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX,version:"1.0.0",description:"Ensure string ends with given suffix (add if missing)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.EnsureSuffix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.endsWith(f)?e:e+f;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX,version:"1.0.0",description:"Remove prefix if present",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.RemovePrefix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.startsWith(f)?e.slice(f.length):e;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class PLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX,version:"1.0.0",description:"Remove suffix if present",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.RemoveSuffix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.endsWith(f)?e.slice(0,-f.length):e;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class NLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH,version:"1.0.0",description:"String startsWith(needle) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.StartsWith);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("StartsWith expects two strings.");const e=a.startsWith(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class xLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH,version:"1.0.0",description:"String endsWith(needle) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.EndsWith);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("EndsWith expects two strings.");const e=a.endsWith(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class $Le extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS,version:"1.0.0",description:"String includes(needle) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Contains);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("Contains expects two strings.");const e=a.includes(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class LLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX,version:"1.0.0",description:"Regex test: new RegExp(pattern, flags?).test(src) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.MatchesRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("MatchesRegex expects source and pattern to be strings.");if(!(e===void 0||typeof e=="string"))throw new TypeError("MatchesRegex flags must be a string if provided.");let f=!1;return f=new RegExp(c,e).test(a),{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}function BLe(s,p){const i=Number(s),a=10**Math.max(0,Number(p)||0);return Math.round(i*a)/a}function MLe(s,p){const i=Number(s),r=Math.abs(Number(p)||0);return r===0?i:Math.round(i/r)*r}function GLe(s,p,i){const r=Number(s),a=Number(p),c=Number(i);return Math.min(Math.max(r,a),c)}function jLe(s,p,i,r,a){const c=Number(s),e=Number(p),f=Number(i),h=Number(r),m=Number(a);if(e===f)throw new Error("Input range cannot be zero");const E=(c-e)/(f-e);return h+E*(m-h)}function kLe(...s){const p=s.map(r=>Number(r));return p.length===0?0:p.reduce((r,a)=>r+a,0)/p.length}function ULe(...s){const p=s.map(r=>Number(r)).sort((r,a)=>r-a);if(p.length===0)return 0;const i=Math.floor(p.length/2);return p.length%2?p[i]:(p[i-1]+p[i])/2}function FLe(s,p){const i=Number(s),r=Number(p);return r===0?NaN:i<0&&r%2===1?-Math.pow(-i,1/r):Math.pow(i,1/r)}function KLe(s,p){const i=Number(s),r=Number(p);return i===0?1/0:(r-i)/i*100}const $i=s=>s.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class qLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Addition);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=$i(r).reduce((e,f)=>e+f,0);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class SLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Subtraction);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=$i(r).reduce((e,f)=>e-f,0);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ZLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Multiplication);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=$i(r).reduce((e,f)=>e*f,1);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class HLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Division);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=$i(r);if(c===0)throw new Error("Division by zero is not allowed");const e=a/c;return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class WLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Remainder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=$i(r);if(c===0)throw new Error("Division by zero is not allowed");const e=a%c;return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class zLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Exponentiation);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=$i(r),e=Math.pow(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class YLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE,version:"1.0.0",description:"Number negate (unary -x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Negate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:-a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class JLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE,version:"1.0.0",description:"Number absolute (|x|)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Absolute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.abs(Number(a))}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class QLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN,version:"1.0.0",description:"Number sign (-1 | 0 | 1)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Sign);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.sign(Number(a))}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class XLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND,version:"1.0.0",description:"Number round to nearest integer",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Round);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.round(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class e2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR,version:"1.0.0",description:"Number floor (⌊x⌋)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Floor);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.floor(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class t2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL,version:"1.0.0",description:"Number ceil (⌈x⌉)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Ceil);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.ceil(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class i2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC,version:"1.0.0",description:"Number truncation (drop fractional part)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Trunc);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.trunc(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class r2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS,version:"1.0.0",description:"Round to N decimals",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.RoundToDecimals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=BLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class n2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP,version:"1.0.0",description:"Snap a number to the nearest multiple of step (>=0 step)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.SnapToStep);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=MLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class a2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP,version:"1.0.0",description:"Clamp value to [min, max]",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Clamp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=$i(r),f=GLe(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class s2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE,version:"1.0.0",description:"Map value from [inMin,inMax] to [outMin,outMax]",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MapRange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h]=$i(r),m=jLe(a,c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class l2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE,version:"1.0.0",description:"Average(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Average);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r),c=kLe(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class o2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN,version:"1.0.0",description:"Median(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Median);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r),c=ULe(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class d2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF,version:"1.0.0",description:"Min(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MinOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r).map(Number),c=a.length?Math.min(...a):1/0;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class u2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF,version:"1.0.0",description:"Max(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MaxOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r).map(Number),c=a.length?Math.max(...a):-1/0;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class p2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT,version:"1.0.0",description:"Square root",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.SquareRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.sqrt(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class c2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT,version:"1.0.0",description:"Cube root",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.CubeRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.cbrt(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class f2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT,version:"1.0.0",description:"Nth root (value, n)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.NthRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=FLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class y2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP,version:"1.0.0",description:"e^x",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Exp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.exp(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class h2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL,version:"1.0.0",description:"Natural log ln(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.LogNatural);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.log(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class m2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10,version:"1.0.0",description:"Log base 10",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Log10);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r),c=Number(a),e=Math.log10?Math.log10(c):Math.log(c)/Math.LN10;return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class T2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN,version:"1.0.0",description:"sin(x in radians)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Sin);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.sin(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class v2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS,version:"1.0.0",description:"cos(x in radians)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Cos);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.cos(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class E2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN,version:"1.0.0",description:"tan(x in radians)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Tan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.tan(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class b2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN,version:"1.0.0",description:"asin(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Asin);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.asin(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class A2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS,version:"1.0.0",description:"acos(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Acos);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.acos(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class g2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN,version:"1.0.0",description:"atan(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Atan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.atan(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class I2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2,version:"1.0.0",description:"atan2(y, x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Atan2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:Math.atan2(Number(a),Number(c))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class R2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS,version:"1.0.0",description:"deg → rad",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.ToRadians);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Number(a)*Math.PI/180}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class D2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES,version:"1.0.0",description:"rad → deg",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.ToDegrees);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Number(a)*180/Math.PI}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class w2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF,version:"1.0.0",description:"x percent of y",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.PercentOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=Number(a)/100*Number(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class j_ extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE,version:"1.0.0",description:"((new-old)/old)*100",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.PercentageChange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=KLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class C2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN,version:"1.0.0",description:"a < b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.LessThan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a<c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class O2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN,version:"1.0.0",description:"a > b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MoreThan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a>c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class _2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL,version:"1.0.0",description:"a <= b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.LessThanOrEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a<=c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class V2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL,version:"1.0.0",description:"a >= b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MoreThanOrEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a>=c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}function P2e(s,p){return function(){return s.apply(p,arguments)}}const{toString:xIi}=Object.prototype,{getPrototypeOf:i$}=Object,{iterator:b1,toStringTag:N2e}=Symbol,A1=(s=>p=>{const i=xIi.call(p);return s[i]||(s[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),ko=s=>(s=s.toLowerCase(),p=>A1(p)===s),g1=s=>p=>typeof p===s,{isArray:Mm}=Array,Dh=g1("undefined");function DE(s){return s!==null&&!Dh(s)&&s.constructor!==null&&!Dh(s.constructor)&&ys(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const x2e=ko("ArrayBuffer");function $Ii(s){let p;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?p=ArrayBuffer.isView(s):p=s&&s.buffer&&x2e(s.buffer),p}const LIi=g1("string"),ys=g1("function"),$2e=g1("number"),wE=s=>s!==null&&typeof s=="object",BIi=s=>s===!0||s===!1,cg=s=>{if(A1(s)!=="object")return!1;const p=i$(s);return(p===null||p===Object.prototype||Object.getPrototypeOf(p)===null)&&!(N2e in s)&&!(b1 in s)},MIi=s=>{if(!wE(s)||DE(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},GIi=ko("Date"),jIi=ko("File"),kIi=s=>!!(s&&typeof s.uri<"u"),UIi=s=>s&&typeof s.getParts<"u",FIi=ko("Blob"),KIi=ko("FileList"),qIi=s=>wE(s)&&ys(s.pipe);function SIi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const qk=SIi(),Sk=typeof qk.FormData<"u"?qk.FormData:void 0,ZIi=s=>{let p;return s&&(Sk&&s instanceof Sk||ys(s.append)&&((p=A1(s))==="formdata"||p==="object"&&ys(s.toString)&&s.toString()==="[object FormData]"))},HIi=ko("URLSearchParams"),[WIi,zIi,YIi,JIi]=["ReadableStream","Request","Response","Headers"].map(ko),QIi=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function CE(s,p,{allOwnKeys:i=!1}={}){if(s===null||typeof s>"u")return;let r,a;if(typeof s!="object"&&(s=[s]),Mm(s))for(r=0,a=s.length;r<a;r++)p.call(null,s[r],r,s);else{if(DE(s))return;const c=i?Object.getOwnPropertyNames(s):Object.keys(s),e=c.length;let f;for(r=0;r<e;r++)f=c[r],p.call(null,s[f],f,s)}}function L2e(s,p){if(DE(s))return null;p=p.toLowerCase();const i=Object.keys(s);let r=i.length,a;for(;r-- >0;)if(a=i[r],p===a.toLowerCase())return a;return null}const Tf=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),B2e=s=>!Dh(s)&&s!==Tf;function k_(){const{caseless:s,skipUndefined:p}=B2e(this)&&this||{},i={},r=(a,c)=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const e=s&&L2e(i,c)||c;cg(i[e])&&cg(a)?i[e]=k_(i[e],a):cg(a)?i[e]=k_({},a):Mm(a)?i[e]=a.slice():(!p||!Dh(a))&&(i[e]=a)};for(let a=0,c=arguments.length;a<c;a++)arguments[a]&&CE(arguments[a],r);return i}const XIi=(s,p,i,{allOwnKeys:r}={})=>(CE(p,(a,c)=>{i&&ys(a)?Object.defineProperty(s,c,{value:P2e(a,i),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(s,c,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),s),eRi=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),tRi=(s,p,i,r)=>{s.prototype=Object.create(p.prototype,r),Object.defineProperty(s.prototype,"constructor",{value:s,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(s,"super",{value:p.prototype}),i&&Object.assign(s.prototype,i)},iRi=(s,p,i,r)=>{let a,c,e;const f={};if(p=p||{},s==null)return p;do{for(a=Object.getOwnPropertyNames(s),c=a.length;c-- >0;)e=a[c],(!r||r(e,s,p))&&!f[e]&&(p[e]=s[e],f[e]=!0);s=i!==!1&&i$(s)}while(s&&(!i||i(s,p))&&s!==Object.prototype);return p},rRi=(s,p,i)=>{s=String(s),(i===void 0||i>s.length)&&(i=s.length),i-=p.length;const r=s.indexOf(p,i);return r!==-1&&r===i},nRi=s=>{if(!s)return null;if(Mm(s))return s;let p=s.length;if(!$2e(p))return null;const i=new Array(p);for(;p-- >0;)i[p]=s[p];return i},aRi=(s=>p=>s&&p instanceof s)(typeof Uint8Array<"u"&&i$(Uint8Array)),sRi=(s,p)=>{const r=(s&&s[b1]).call(s);let a;for(;(a=r.next())&&!a.done;){const c=a.value;p.call(s,c[0],c[1])}},lRi=(s,p)=>{let i;const r=[];for(;(i=s.exec(p))!==null;)r.push(i);return r},oRi=ko("HTMLFormElement"),dRi=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,r,a){return r.toUpperCase()+a}),Zk=(({hasOwnProperty:s})=>(p,i)=>s.call(p,i))(Object.prototype),uRi=ko("RegExp"),M2e=(s,p)=>{const i=Object.getOwnPropertyDescriptors(s),r={};CE(i,(a,c)=>{let e;(e=p(a,c,s))!==!1&&(r[c]=e||a)}),Object.defineProperties(s,r)},pRi=s=>{M2e(s,(p,i)=>{if(ys(s)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const r=s[i];if(ys(r)){if(p.enumerable=!1,"writable"in p){p.writable=!1;return}p.set||(p.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},cRi=(s,p)=>{const i={},r=a=>{a.forEach(c=>{i[c]=!0})};return Mm(s)?r(s):r(String(s).split(p)),i},fRi=()=>{},yRi=(s,p)=>s!=null&&Number.isFinite(s=+s)?s:p;function hRi(s){return!!(s&&ys(s.append)&&s[N2e]==="FormData"&&s[b1])}const mRi=s=>{const p=new Array(10),i=(r,a)=>{if(wE(r)){if(p.indexOf(r)>=0)return;if(DE(r))return r;if(!("toJSON"in r)){p[a]=r;const c=Mm(r)?[]:{};return CE(r,(e,f)=>{const h=i(e,a+1);!Dh(h)&&(c[f]=h)}),p[a]=void 0,c}}return r};return i(s,0)},TRi=ko("AsyncFunction"),vRi=s=>s&&(wE(s)||ys(s))&&ys(s.then)&&ys(s.catch),G2e=((s,p)=>s?setImmediate:p?((i,r)=>(Tf.addEventListener("message",({source:a,data:c})=>{a===Tf&&c===i&&r.length&&r.shift()()},!1),a=>{r.push(a),Tf.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",ys(Tf.postMessage)),ERi=typeof queueMicrotask<"u"?queueMicrotask.bind(Tf):typeof process<"u"&&process.nextTick||G2e,bRi=s=>s!=null&&ys(s[b1]),qe={isArray:Mm,isArrayBuffer:x2e,isBuffer:DE,isFormData:ZIi,isArrayBufferView:$Ii,isString:LIi,isNumber:$2e,isBoolean:BIi,isObject:wE,isPlainObject:cg,isEmptyObject:MIi,isReadableStream:WIi,isRequest:zIi,isResponse:YIi,isHeaders:JIi,isUndefined:Dh,isDate:GIi,isFile:jIi,isReactNativeBlob:kIi,isReactNative:UIi,isBlob:FIi,isRegExp:uRi,isFunction:ys,isStream:qIi,isURLSearchParams:HIi,isTypedArray:aRi,isFileList:KIi,forEach:CE,merge:k_,extend:XIi,trim:QIi,stripBOM:eRi,inherits:tRi,toFlatObject:iRi,kindOf:A1,kindOfTest:ko,endsWith:rRi,toArray:nRi,forEachEntry:sRi,matchAll:lRi,isHTMLForm:oRi,hasOwnProperty:Zk,hasOwnProp:Zk,reduceDescriptors:M2e,freezeMethods:pRi,toObjectSet:cRi,toCamelCase:dRi,noop:fRi,toFiniteNumber:yRi,findKey:L2e,global:Tf,isContextDefined:B2e,isSpecCompliantForm:hRi,toJSONObject:mRi,isAsyncFn:TRi,isThenable:vRi,setImmediate:G2e,asap:ERi,isIterable:bRi};class Ya extends Error{static from(p,i,r,a,c,e){const f=new Ya(p.message,i||p.code,r,a,c);return f.cause=p,f.name=p.name,p.status!=null&&f.status==null&&(f.status=p.status),e&&Object.assign(f,e),f}constructor(p,i,r,a,c){super(p),Object.defineProperty(this,"message",{value:p,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,i&&(this.code=i),r&&(this.config=r),a&&(this.request=a),c&&(this.response=c,this.status=c.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:qe.toJSONObject(this.config),code:this.code,status:this.status}}}Ya.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ya.ERR_BAD_OPTION="ERR_BAD_OPTION";Ya.ECONNABORTED="ECONNABORTED";Ya.ETIMEDOUT="ETIMEDOUT";Ya.ERR_NETWORK="ERR_NETWORK";Ya.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ya.ERR_DEPRECATED="ERR_DEPRECATED";Ya.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ya.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ya.ERR_CANCELED="ERR_CANCELED";Ya.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ya.ERR_INVALID_URL="ERR_INVALID_URL";const ir=Ya,ARi=null;function U_(s){return qe.isPlainObject(s)||qe.isArray(s)}function j2e(s){return qe.endsWith(s,"[]")?s.slice(0,-2):s}function XO(s,p,i){return s?s.concat(p).map(function(a,c){return a=j2e(a),!i&&c?"["+a+"]":a}).join(i?".":""):p}function gRi(s){return qe.isArray(s)&&!s.some(U_)}const IRi=qe.toFlatObject(qe,{},null,function(p){return/^is[A-Z]/.test(p)});function I1(s,p,i){if(!qe.isObject(s))throw new TypeError("target must be an object");p=p||new FormData,i=qe.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(V,j){return!qe.isUndefined(j[V])});const r=i.metaTokens,a=i.visitor||E,c=i.dots,e=i.indexes,h=(i.Blob||typeof Blob<"u"&&Blob)&&qe.isSpecCompliantForm(p);if(!qe.isFunction(a))throw new TypeError("visitor must be a function");function m(P){if(P===null)return"";if(qe.isDate(P))return P.toISOString();if(qe.isBoolean(P))return P.toString();if(!h&&qe.isBlob(P))throw new ir("Blob is not supported. Use a Buffer instead.");return qe.isArrayBuffer(P)||qe.isTypedArray(P)?h&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function E(P,V,j){let M=P;if(qe.isReactNative(p)&&qe.isReactNativeBlob(P))return p.append(XO(j,V,c),m(P)),!1;if(P&&!j&&typeof P=="object"){if(qe.endsWith(V,"{}"))V=r?V:V.slice(0,-2),P=JSON.stringify(P);else if(qe.isArray(P)&&gRi(P)||(qe.isFileList(P)||qe.endsWith(V,"[]"))&&(M=qe.toArray(P)))return V=j2e(V),M.forEach(function(q,re){!(qe.isUndefined(q)||q===null)&&p.append(e===!0?XO([V],re,c):e===null?V:V+"[]",m(q))}),!1}return U_(P)?!0:(p.append(XO(j,V,c),m(P)),!1)}const b=[],A=Object.assign(IRi,{defaultVisitor:E,convertValue:m,isVisitable:U_});function _(P,V){if(!qe.isUndefined(P)){if(b.indexOf(P)!==-1)throw Error("Circular reference detected in "+V.join("."));b.push(P),qe.forEach(P,function(M,G){(!(qe.isUndefined(M)||M===null)&&a.call(p,M,qe.isString(G)?G.trim():G,V,A))===!0&&_(M,V?V.concat(G):[G])}),b.pop()}}if(!qe.isObject(s))throw new TypeError("data must be an object");return _(s),p}function Hk(s){const p={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(r){return p[r]})}function r$(s,p){this._pairs=[],s&&I1(s,this,p)}const k2e=r$.prototype;k2e.append=function(p,i){this._pairs.push([p,i])};k2e.toString=function(p){const i=p?function(r){return p.call(this,r,Hk)}:Hk;return this._pairs.map(function(a){return i(a[0])+"="+i(a[1])},"").join("&")};function RRi(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function U2e(s,p,i){if(!p)return s;const r=i&&i.encode||RRi,a=qe.isFunction(i)?{serialize:i}:i,c=a&&a.serialize;let e;if(c?e=c(p,a):e=qe.isURLSearchParams(p)?p.toString():new r$(p,a).toString(r),e){const f=s.indexOf("#");f!==-1&&(s=s.slice(0,f)),s+=(s.indexOf("?")===-1?"?":"&")+e}return s}class DRi{constructor(){this.handlers=[]}use(p,i,r){return this.handlers.push({fulfilled:p,rejected:i,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(p){this.handlers[p]&&(this.handlers[p]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(p){qe.forEach(this.handlers,function(r){r!==null&&p(r)})}}const Wk=DRi,n$={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},wRi=typeof URLSearchParams<"u"?URLSearchParams:r$,CRi=typeof FormData<"u"?FormData:null,ORi=typeof Blob<"u"?Blob:null,_Ri={isBrowser:!0,classes:{URLSearchParams:wRi,FormData:CRi,Blob:ORi},protocols:["http","https","file","blob","url","data"]},a$=typeof window<"u"&&typeof document<"u",F_=typeof navigator=="object"&&navigator||void 0,VRi=a$&&(!F_||["ReactNative","NativeScript","NS"].indexOf(F_.product)<0),PRi=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),NRi=a$&&window.location.href||"http://localhost",xRi=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:a$,hasStandardBrowserEnv:VRi,hasStandardBrowserWebWorkerEnv:PRi,navigator:F_,origin:NRi},Symbol.toStringTag,{value:"Module"})),Ra={...xRi,..._Ri};function $Ri(s,p){return I1(s,new Ra.classes.URLSearchParams,{visitor:function(i,r,a,c){return Ra.isNode&&qe.isBuffer(i)?(this.append(r,i.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)},...p})}function LRi(s){return qe.matchAll(/\w+|\[(\w*)]/g,s).map(p=>p[0]==="[]"?"":p[1]||p[0])}function BRi(s){const p={},i=Object.keys(s);let r;const a=i.length;let c;for(r=0;r<a;r++)c=i[r],p[c]=s[c];return p}function F2e(s){function p(i,r,a,c){let e=i[c++];if(e==="__proto__")return!0;const f=Number.isFinite(+e),h=c>=i.length;return e=!e&&qe.isArray(a)?a.length:e,h?(qe.hasOwnProp(a,e)?a[e]=[a[e],r]:a[e]=r,!f):((!a[e]||!qe.isObject(a[e]))&&(a[e]=[]),p(i,r,a[e],c)&&qe.isArray(a[e])&&(a[e]=BRi(a[e])),!f)}if(qe.isFormData(s)&&qe.isFunction(s.entries)){const i={};return qe.forEachEntry(s,(r,a)=>{p(LRi(r),a,i,0)}),i}return null}function MRi(s,p,i){if(qe.isString(s))try{return(p||JSON.parse)(s),qe.trim(s)}catch(r){if(r.name!=="SyntaxError")throw r}return(i||JSON.stringify)(s)}const s$={transitional:n$,adapter:["xhr","http","fetch"],transformRequest:[function(p,i){const r=i.getContentType()||"",a=r.indexOf("application/json")>-1,c=qe.isObject(p);if(c&&qe.isHTMLForm(p)&&(p=new FormData(p)),qe.isFormData(p))return a?JSON.stringify(F2e(p)):p;if(qe.isArrayBuffer(p)||qe.isBuffer(p)||qe.isStream(p)||qe.isFile(p)||qe.isBlob(p)||qe.isReadableStream(p))return p;if(qe.isArrayBufferView(p))return p.buffer;if(qe.isURLSearchParams(p))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),p.toString();let f;if(c){if(r.indexOf("application/x-www-form-urlencoded")>-1)return $Ri(p,this.formSerializer).toString();if((f=qe.isFileList(p))||r.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return I1(f?{"files[]":p}:p,h&&new h,this.formSerializer)}}return c||a?(i.setContentType("application/json",!1),MRi(p)):p}],transformResponse:[function(p){const i=this.transitional||s$.transitional,r=i&&i.forcedJSONParsing,a=this.responseType==="json";if(qe.isResponse(p)||qe.isReadableStream(p))return p;if(p&&qe.isString(p)&&(r&&!this.responseType||a)){const e=!(i&&i.silentJSONParsing)&&a;try{return JSON.parse(p,this.parseReviver)}catch(f){if(e)throw f.name==="SyntaxError"?ir.from(f,ir.ERR_BAD_RESPONSE,this,null,this.response):f}}return p}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ra.classes.FormData,Blob:Ra.classes.Blob},validateStatus:function(p){return p>=200&&p<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};qe.forEach(["delete","get","head","post","put","patch"],s=>{s$.headers[s]={}});const l$=s$,GRi=qe.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),jRi=s=>{const p={};let i,r,a;return s&&s.split(`
|
|
49
|
+
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return r==="value-as-type-single"&&(this.valueAsTypeSingle=null,a==null||a.add(this,W.Updated)),r==="value-as-type-list"&&(this.valueAsTypeList=(this.valueAsTypeList||[]).filter(m=>m.id!==i.id),a==null||a.add(this,W.Updated)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return r==="value-as-type-single"&&(this.valueAsTypeSingle=i,a==null||a.add(this,W.Updated)),r==="value-as-type-list"&&(this.valueAsTypeList=[...Array.isArray(this.valueAsTypeList||[])?this.valueAsTypeList:[],i],a==null||a.add(this,W.Updated)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.unsubscribeDependents([{entity:this,field:"value-as-type-single"}]),this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.unsubscribeDependents([{entity:this,field:"value-as-type-list"}])}),this}subscribeToDependencies(){return!this.valueAsTypeSingle&&!this.valueAsTypeList?this:(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.subscribeDependents([{entity:this,field:"value-as-type-list"}])}):this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.subscribeDependents([{entity:this,field:"value-as-type-single"}]),this)}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new ci(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new ci(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.valueAsTypeSingle=this.valueAsTypeSingle,i.valueAsTypeList=this.valueAsTypeList?[...this.valueAsTypeList]:this.valueAsTypeList,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new ci(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.valueAsTypeSingle=h.valueAsTypeSingle,this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent&&i.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(i.parent){const a=ie(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else if(i.standaloneParent){const a=ie(i.standaloneParent),c=this.project.get(a);if(c)this.setStandaloneParent(c,r);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${a}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.valueAsTypeList&&Array.isArray(i.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],i.valueAsTypeList.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&this.addValueAsTypeToList(e,r)}),[...this.valueAsTypeList].forEach(a=>{(i.valueAsTypeList||[]).find(e=>ie(e)===a.id)||this.removeValueAsTypeFromList(a,r)}),this.setValueAsTypeSingle(null,r),this.metaSync({value:null},r);else if(i.valueAsTypeSingle){const a=ie(i.valueAsTypeSingle),c=this.project.get(a);c&&(this.setValueAsTypeSingle(c,r),this.setValueAsTypeList(null,r),this.metaSync({value:null},r))}else this.setValueAsTypeSingle(null,r),this.setValueAsTypeList(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent&&i.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(i.parent){const a=ie(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,r),this.addSelfToProject(r);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${a}' that isn't found in the project`)}else if(i.standaloneParent){const a=ie(i.standaloneParent),c=this.project.get(a);if(c)this.setStandaloneParent(c,r);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${a}' that isn't found in the project`)}if(i.valueAsTypeList&&Array.isArray(i.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],i.valueAsTypeList.forEach(a=>{const c=ie(a),e=this.project.get(c);e&&this.addValueAsTypeToList(e,r)}),[...this.valueAsTypeList].forEach(a=>{(i.valueAsTypeList||[]).find(e=>ie(e)===a.id)||this.removeValueAsTypeFromList(a,r)}),this.setValueAsTypeSingle(null,r),this.metaSync({value:null},r);else if(i.valueAsTypeSingle){const a=ie(i.valueAsTypeSingle),c=this.project.get(a);c&&(this.setValueAsTypeSingle(c,r),this.setValueAsTypeList(null,r),this.metaSync({value:null},r))}return(i.valueAsTypeSingle===null||i.valueAsTypeList||i.value!==null&&i.value!==void 0)&&this.setValueAsTypeSingle(null,r),(i.valueAsTypeList===null||i.valueAsTypeSingle||i.value!==null&&i.value!==void 0)&&this.setValueAsTypeList(null,r),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent&&this.initialData.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(Y.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating parent reference '${e}' for entity with id '${this.id}'`),f)Y.Logger.log(`[LiteralValueState.hydrateAncestors] Setting parent reference '${f.id}' for entity with id '${this.id}'`),this.setParent(f,null),i.push(f);else throw Y.Logger.error(`[LiteralValueState.hydrateAncestors] Parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else if(this.initialData.standaloneParent){const e=ie(this.initialData.standaloneParent),f=this.project.get(e);if(Y.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating standalone parent reference '${e}' for entity with id '${this.id}'`),f)Y.Logger.log(`[LiteralValueState.hydrateAncestors] Setting standalone parent reference '${f.id}' for entity with id '${this.id}'`),this.setStandaloneParent(f,null);else throw Y.Logger.error(`[LiteralValueState.hydrateAncestors] Standalone parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${e}' that isn't found in the project`)}else throw Y.Logger.error(`[LiteralValueState.hydrateAncestors] Entity with id '${this.id}' must have a 'parent'`),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],this.initialData.valueAsTypeList.forEach(e=>{const f=ie(e),h=this.project.get(f);h&&this.valueAsTypeList.push(h)});else if(this.initialData.valueAsTypeSingle){const e=ie(this.initialData.valueAsTypeSingle),f=this.project.get(e);f&&(this.valueAsTypeSingle=f)}return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.initialized=!0,i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){var f,h;const r=[this],a=[],c=[],e=[];return((f=this.parent)==null?void 0:f.type)===d.DataType?this.parent.setEntity(this,i):(h=this.parent)==null||h.setDefaultValue(this,i),e.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setStandaloneParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetStandaloneParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetStandaloneParent,r)?(((a=this.standaloneParent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.standaloneParent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetStandaloneParent,this.id),this):this}addValueAsTypeToList(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddValueAsTypeToList))){return this.checkCanEdit(this,r)?((this.valueAsTypeList||[]).includes(i)||(this.valueAsTypeList=this.valueAsTypeList||[],this.valueAsTypeList.push(i),this.value!==null&&this.metaSync({value:null},r),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,r==null||r.add(this,W.Updated)),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddValueAsTypeToList,this.id),this):(Y.Logger.warn(`[addValueAsTypeToList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddValueAsTypeToList,this.id),this)}removeValueAsTypeFromList(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveValueAsTypeFromList))){return this.checkCanEdit(this,r)?(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&(this.valueAsTypeList||[]).includes(i)&&(this.valueAsTypeList=this.valueAsTypeList.filter(a=>a.id!==i.id),this.valueAsTypeList.length===0?this.valueAsTypeList=null:(this.value!==null&&this.metaSync({value:null},r),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,r==null||r.add(this,W.Updated))),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveValueAsTypeFromList,this.id),this):(Y.Logger.warn(`[removeValueAsTypeFromList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveValueAsTypeFromList,this.id),this)}setValueAsTypeSingle(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueAsTypeSingle))){return this.checkCanEdit(this,r)?(this.valueAsTypeSingle!==i&&(this.valueAsTypeSingle=i,r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.SetValueAsTypeSingle,this.id),this):(Y.Logger.warn(`[setValueAsTypeSingle] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetValueAsTypeSingle,this.id),this)}setValueAsTypeList(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueAsTypeList))){var a,c;return this.checkCanEdit(this,r)?(!i&&this.valueAsTypeList?(this.valueAsTypeList=null,r==null||r.add(this,W.Updated)):i&&!this.valueAsTypeList?(this.valueAsTypeList=i,r==null||r.add(this,W.Updated)):i&&this.valueAsTypeList&&((a=this.valueAsTypeList)==null?void 0:a.length)!==i.length?(this.valueAsTypeList=i,r==null||r.add(this,W.Updated)):i&&this.valueAsTypeList&&((c=this.valueAsTypeList)!=null&&c.every((e,f)=>e!==i[f]))&&(this.valueAsTypeList=i,r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.SetValueAsTypeList,this.id),this):(Y.Logger.warn(`[setValueAsTypeList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetValueAsTypeList,this.id),this)}setValueAsType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetValueAsType))){return this.checkCanEdit(this,r)?i?(Array.isArray(i)?this.setValueAsTypeList(i,r):this.setValueAsTypeSingle(i,r),r==null||r.attemptAutoclose(w.SetValueAsType,this.id),this):(this.setValueAsTypeSingle(null,r),this.setValueAsTypeList(null,r),this):(Y.Logger.warn(`[setValueAsType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetValueAsType,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.standalone){if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(r=>{if(r.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(r);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.entityType}' with id '${r.entityId}' that is not part of the project state.`);return c}const a=this.project.get(r.id);if(!a)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.type}' with id '${r.id}' that is not part of the project state.`);return a});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const a=this.project.findSubscribedBuiltInInstanceFromReference(this.initialData.valueAsTypeSingle);if(!a)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=a,this}const r=this.project.get(this.initialData.valueAsTypeSingle.id);if(!r)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=r}return this}if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(r=>{if(r.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(r);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.entityType}' with id '${r.entityId}' that is not part of the project state.`);return c}const a=this.project.get(r.id);if(!a)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${r.type}' with id '${r.id}' that is not part of the project state.`);return a});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const a=ie(this.initialData.valueAsTypeSingle),c=a?this.project.get(a):null;if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=c,this}const r=this.project.get(this.initialData.valueAsTypeSingle.id);if(!r)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=r}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.autogeneration=a.autogeneration!==void 0?a.autogeneration:e.autogeneration,this.value=a.value!==void 0?a.value:e.value,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await ci.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await ci.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await ci.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await ci.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await ci.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await ci.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent&&(this.parent.type===d.DataType?this.parent.setEntity(null,i):pI.includes(this.parent.type)&&this.parent.setDefaultValue(null,i),e.push(this.parent)),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected)}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlat(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlat(i)):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatIds(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlatIds(i)):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,value:this.value,autogeneration:this.autogeneration,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:((r=this.valueAsTypeSingle)==null?void 0:r.toJSON(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(e=>e.toJSON(i)):null,parent:(a=this.parent)==null?void 0:a.toReference(),standaloneParent:(c=this.standaloneParent)==null?void 0:c.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:this.valueAsTypeSingle?this.project.getBuiltIn(this.valueAsTypeSingle.id)?this.valueAsTypeSingle.toJSON():this.valueAsTypeSingle.toJSONClone({...i,newId:null}):null,valueAsTypeList:this.valueAsTypeSingle&&Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(b=>this.project.getBuiltIn(b.id)?b.toJSON(i.seenEntities):b.toJSONClone({...i,newId:null})):null,parent:(m=this.parent)==null?void 0:m.toReference({seenEntityMaps:i.seenEntityMaps}),standaloneParent:(E=this.standaloneParent)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,valueAsTypeSingle:((c=this.valueAsTypeSingle)==null?void 0:c.toReference(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(h=>h.toReference(i)):null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.toReference(i),standaloneParent:(f=this.standaloneParent)==null?void 0:f.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatJSON(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlatJSON(i)):[]])}toGenerationTarget(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,name:this.name,valueAsTypeSingle:((c=this.valueAsTypeSingle)==null?void 0:c.id)||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(h=>h.id):null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.id,standaloneParent:(f=this.standaloneParent)==null?void 0:f.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatGenerationTarget(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(a=>a.toFlatGenerationTarget(i)):[]])}clearErrors(){return this.errors=[],this}validate(){return this.errors=oVe(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await lVe(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];return await r.tick(),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){const e=Ur(r,this),f=this.toJSON(),h=a||x.UUID.uuid();f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.editable=!0,f.deletable=!0;const m=nr(f,e);return m.hydrateAncestors(),r&&m.setParent(r,i),c&&(m.subscribe(),m.addSelfToProject(i)),i==null||i.add(m,W.Added),m.initChildren(i),i||m.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),m}merge(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"merge-literal-value"))){const a=[],c=[],e=[],f=[];return this.valueAsTypeSingle!==(i==null?void 0:i.valueAsTypeSingle)&&(this.setValueAsType(i.valueAsTypeSingle,r),a.push(this)),this.valueAsTypeList!==i.valueAsTypeList&&(this.setValueAsTypeList(i.valueAsTypeList,r),a.push(this)),this.value!==i.value&&(this.metaSync({value:i.value},r),a.push(this)),this.autogeneration!==i.autogeneration&&(this.metaSync({autogeneration:i.autogeneration},r),a.push(this)),this.name!==i.name&&(this.metaSync({name:i.name},r),a.push(this)),r==null||r.attemptAutoclose("merge-literal-value",this.id),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}};R(ci,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(ci,"type",d.LiteralValue),R(ci,"USER_MANAGED_PARENT_TYPES",[d.DataType,d.InputMap,d.Property,d.ArgumentDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement,d.VariableDeclaration,d.VariableInstance,d.ValueDescriptor]),R(ci,"USER_MANAGED_STANDALONE_PARENT_TYPES",[...uI]),R(ci,"PARENT_TYPES",[...ci.USER_MANAGED_PARENT_TYPES]),R(ci,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),R(ci,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(ci,"BASE_PROPERTIES",[...ci.MUTABLE_BASE_PROPERTIES,...ci.INMUTABLE_BASE_PROPERTIES]),R(ci,"MUTABLE_META_PROPERTIES",[...ci.MUTABLE_BASE_PROPERTIES]),R(ci,"INMUTABLE_META_PROPERTIES",[...ci.INMUTABLE_BASE_PROPERTIES]),R(ci,"META_PROPERTIES",[...ci.MUTABLE_META_PROPERTIES,...ci.INMUTABLE_META_PROPERTIES]),R(ci,"MUTABLE_UPSTREAM_PROPERTIES",["valueAsTypeSingle","valueAsTypeList"]),R(ci,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(ci,"UPSTREAM_PROPERTIES",[...ci.MUTABLE_UPSTREAM_PROPERTIES,...ci.INMUTABLE_UPSTREAM_PROPERTIES]),R(ci,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),R(ci,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(ci,"DOWNSTREAM_PROPERTIES",[...ci.MUTABLE_DOWNSTREAM_PROPERTIES,...ci.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(ci,"PROPERTIES",[...ci.META_PROPERTIES,...ci.UPSTREAM_PROPERTIES,...ci.DOWNSTREAM_PROPERTIES]);let Nr=ci;function ey(s){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const i=new Uint8Array(s);return crypto.getRandomValues(i),i}const{randomBytes:p}=require("crypto");return p(s)}function uVe(s,p){const i=p-s+1,a=h1()*i;return Math.floor(a)+s}function pVe(){const s=ey(4);return(s[0]<<24|s[1]<<16|s[2]<<8|s[3])>>>0}function h1(){return pVe()/2**32}function jx(s){const p=ey(s);return Array.from(p).map(i=>i.toString(16).padStart(2,"0")).join("")}const L_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function kx(s){let p="";const i=ey(s);for(let r=0;r<s;r++)p+=L_[i[r]%L_.length];return p}function cVe(s){const p=ey(s);let i;if(typeof Buffer<"u")i=Buffer.from(p).toString("base64");else{const r=String.fromCharCode(...p);i=btoa(r)}return i.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ux(s){return kx(s)}function Fx(s,p=L_){let i="";const r=ey(s);for(let a=0;a<s;a++)i+=p[r[a]%p.length];return i}function Ep(){const s=ey(16);s[6]=s[6]&15|64,s[8]=s[8]&63|128;const p=Array.from(s).map(i=>i.toString(16).padStart(2,"0")).join("");return[p.slice(0,8),p.slice(8,12),p.slice(12,16),p.slice(16,20),p.slice(20,32)].join("-")}function fVe(){return Fx(6)}function yVe(){return jx(32)}const kgi=63,Ugi=/^[a-z][a-z0-9-]*[a-z0-9]$/;function Fgi(s){return s.length>=1&&s.length<=kgi&&Ugi.test(s)&&!s.includes("--")}function*Kgi(){yield"";const s="abcdefghijklmnopqrstuvwxyz";for(let p=1;;p++){const i=new Array(p).fill(0);let r=!1;for(;!r;){yield i.map(a=>s[a]).join("");for(let a=p-1;a>=0&&(i[a]++,!(i[a]<s.length));a--)i[a]=0,a===0&&(r=!0)}}}function qgi(s,p){const i=new Set(s.map(a=>a.toLowerCase())),r=p>0?"secondary-db":"main";for(const a of Kgi()){const c=a?`${r}-${a}`:r;if(Fgi(c)&&!i.has(c))return c}throw new Error("Unable to generate identifier")}function hVe(s,p){switch(s.id){case ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=s.project.entities.filter(h=>!!h.implements.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),r=i.find(h=>{const m=h.properties.find(A=>A.implements.find(_=>_.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=m==null?void 0:m.getDefaultValue();return(E==null?void 0:E.value)===!0});if(!r&&i.length){const m=i[0].properties.find(b=>b.implements.find(A=>A.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=m==null?void 0:m.defaultValue;if(E)E.metaSync({value:!0},p);else if(m!=null&&m.dataType){const b={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:fe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:m==null?void 0:m.toReference()},A=ge(b,s.project);return A.hydrateAncestors(),A.setParent(m,p),A.addSelfToProject(p),p==null||p.add(A,W.Added),A.initChildren(p),p||A.captureVersion(),{newEntities:[A]}}return{newEntities:[]}}else if(r)return{newEntities:[]};const a=s.project.get(ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),c=m1(a,"Main database",p);if(c.errors.length>0)return{newEntities:[]};const e=c.properties.find(h=>h.implements.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),f=e==null?void 0:e.defaultValue;if(f)f.metaSync({value:!0},p);else if(e!=null&&e.dataType){const h={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:fe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},m=ge(h,s.project);m.hydrateAncestors(),m.setParent(e,p),m.addSelfToProject(p),p==null||p.add(m,W.Added),m.initChildren(p),p||m.captureVersion()}return{newEntities:[c]}}}return{newEntities:[]}}function mVe(s,p){const i=[],r=[],a=[],c=[];return s.implements.filter(f=>f.type===d.BuiltInBaseEntity).forEach(f=>{var h,m,E,b,A,_,P,V,j;switch(f.id){case ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const M=s.project.entities.filter(te=>te.implements.find(le=>le.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let G=M.find(te=>!!te.properties.find(le=>{var ue;return le.implements.find(z=>z.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((ue=le.getDefaultValue())==null?void 0:ue.value)===!0}));if(!G&&M.length)G=M[0];else if(!G&&!M.length){G=s.project.getBuiltIn(ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",p);const le=G.properties.find(ue=>ue.implements.find(z=>z.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));(h=le==null?void 0:le.defaultValue)==null||h.metaSync({value:!0},p),r.push(G)}const q=s.properties.find(te=>te.implements.find(le=>le.id===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id));if(q&&!(q!=null&&q.defaultValue)){const te={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:fe.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:(G==null?void 0:G.toJSON())||null,valueAsTypeList:null,parent:q==null?void 0:q.toReference()},le=ge(te,s.project);le.hydrateAncestors(),le.setParent(q,p),le.addSelfToProject(p),p==null||p.add(le,W.Added),le.initChildren(p),(q==null?void 0:q.defaultValue).setValueAsTypeSingle(G||null,p),r.push(le),p||le.captureVersion();return}else q!=null&&q.defaultValue&&!(q!=null&&q.defaultValue.valueAsTypeSingle)&&(q==null||q.defaultValue.setValueAsTypeSingle(G||null,p));const re=s.properties.find(te=>te.implements.find(le=>le.id===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.primaryKey.id));if(!re)throw new Error(`[handleAfterEntityImplementationSideEffects] Primary key property not found for implemented base entity ${ne["built-in-base-entity"]}`);let ee=!1;if(!re.dataType){const te=mr.new(p);te.parent=re.toReference();const le=ge(te,s.project);le.hydrateAncestors(),le.setParent(re,p),le.addSelfToProject(p),p==null||p.add(le,W.Added),le.initChildren(p),ee=!0}const se=s.project.getBuiltIn(ne["primitive-entity"].number.id);(m=re.dataType)==null||m.setEntity(se,p),ee&&(p||(E=re.dataType)==null||E.captureVersion());return}case ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id:{const M=s.project.entities.filter(z=>z.implements.find(X=>X.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)&&z.id!==s.id),G=M.map(z=>{var de;const X=z.properties.find(me=>me.implements.find(ve=>ve.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));return(de=X==null?void 0:X.getDefaultValue())==null?void 0:de.value}).filter(z=>!!z),q=s.properties.find(z=>z.implements.find(X=>X.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));if(!M.find(z=>!!z.properties.find(X=>{var pe;return X.implements.find(de=>de.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((pe=X.getDefaultValue())==null?void 0:pe.value)===!0}))){const z=s.properties.find(pe=>pe.implements.find(de=>de.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));if(!z)throw new Error("Default boolean property not found for relational database entity with id: "+s.id);let X=!1;if(!(z!=null&&z.defaultValue)){const pe=Nr.new(p);pe.parent=z.toReference();const de=ge(pe,s.project);de.hydrateAncestors(),de.setParent(z,p),de.addSelfToProject(p),p==null||p.add(de,W.Added),de.initChildren(p),X=!0}(b=z==null?void 0:z.defaultValue)==null||b.metaSync({value:!0},p),X&&(p||(A=z==null?void 0:z.defaultValue)==null||A.captureVersion())}if(!q)throw new Error("Identifier property not found for relational database entity with id: "+s.id);let ee=!1;if(!(q!=null&&q.defaultValue)){const z=Nr.new(p);z.parent=q.toReference();const X=ge(z,s.project);X.hydrateAncestors(),X.setParent(q,p),X.addSelfToProject(p),p==null||p.add(X,W.Added),X.initChildren(p),ee=!0}const se=qgi(G,M.length);(_=q.defaultValue)==null||_.metaSync({value:se},p),ee&&(p||(P=q.defaultValue)==null||P.captureVersion());const te=s.properties.find(z=>z.implements.find(X=>X.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.password.id));if(!te)throw new Error(`[handleAfterEntityImplementationSideEffects] Password property not found for implemented base entity ${ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id} with id ${s.id}`);let le=!1;if(!te.defaultValue){const z=Nr.new(p);z.parent=te.toReference();const X=ge(z,s.project);X.hydrateAncestors(),X.setParent(te,p),X.addSelfToProject(p),p==null||p.add(X,W.Added),X.initChildren(p),r.push(X),le=!0}const ue=Ux(24);(V=te.defaultValue)==null||V.metaSync({value:ue},p),le&&(p||(j=te.defaultValue)==null||j.captureVersion());return}case ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id:{const M=s.properties.find(ee=>ee.implements.find(se=>se.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.time.id));if(!M)throw new Error(`[handleAfterEntityImplementationSideEffects] Time property not found for implemented base entity ${ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${s.id}`);let G=M.defaultValue||null;if(!G){const ee=Nr.new(p);ee.parent=M.toReference(),ee.name=fe.Date,ee.id=x.UUID.uuid(),G=ge(ee,s.project),G.hydrateAncestors(),G.setParent(M,p),G.addSelfToProject(p),G.initChildren(p),p==null||p.add(G,W.Added)}G.metaSync({value:new Date().toISOString()},p),G.metaSync({editable:!1,deletable:!1},p),M.metaSync({editable:!1,deletable:!1},p);const q=s.properties.find(ee=>ee.implements.find(se=>se.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id));if(!q)throw new Error(`[handleAfterEntityImplementationSideEffects] Definition property not found for implemented base entity ${ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${s.id}`);let re=q.defaultValue||null;if(!re){const ee=Nr.new(p);ee.name=fe.EntityTemplate,ee.parent=q.toReference(),ee.id=x.UUID.uuid(),re=ge(ee,s.project),re.hydrateAncestors(),re.setParent(q,p),re.addSelfToProject(p),re.initChildren(p),p==null||p.add(re,W.Added)}}}}),{self:s,updated:C(i),added:C(r),removed:C(a),affected:C(c)}}function m1(s,p,i,r){const a=r||x.UUID.uuid(),c=Fs.new(i);c.id=a,c.name=p,c.static=s.static,c.implements=[s.toJSON()],c.parent=s.project.toReference(),c.static=s.static,hVe(s,i);const e=ge(c,s.project);return e.hydrateAncestors(),i==null||i.add(e,W.Added),e.addSelfToProject(i),e.initChildren(i),i||e.captureVersion(),mVe(e,i),e.afterAllChildrenInitialized(i),e}function Kx(s,p){return p.entities.find(a=>{const c=a.properties,e=c.map(b=>b.name),f=s.every(b=>e.includes(b)),h=e.filter(b=>!s.includes(b)),m=c.every(b=>!h.includes(b.name)||!b.required);return f&&m})||null}function TVe(s,p,i,r=ze.OrDataTypeGroup){const a=[],c=[],e=[],f=[],h=x.UUID.uuid(),m=mr.new(i);m.id=h,m.parent=p.toReference(),m.like=!0,m.parentRelationType=r;const E=ge(m,s.project);return c.push(E),E.setParent(p,i),E.addSelfToProject(i),i==null||i.add(E,W.Added),E.setEntity(s,i),E.initChildren(i),i||E.captureVersion(),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:E}}function qx(s,p,i,r,a){var m,E,b,A,_,P,V,j;const c=[],e=[],f=[],h=[];switch(typeof s){case"string":let M=!1;const G=new Date(s);if(G instanceof Date&&!isNaN(G.valueOf())&&(M=!0),M){const q=p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Date].id);p.setEntity(q,r);break}else{const q=p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.String].id);p.setEntity(q,r);break}case"number":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Number].id),r);break;case"boolean":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Boolean].id),r);break;case"object":if(s===null){p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Null].id),r);break}else if(Array.isArray(s))if(p.metaSync({isList:!0},r),s.length>0){const q=s.slice(0,5).filter(ee=>ee!==void 0);if(q.every(ee=>typeof ee==typeof q[0])&&(typeof q[0]!="object"||q[0]===null))switch(typeof q[0]){case"string":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.String].id),r);break;case"number":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Number].id),r);break;case"boolean":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Boolean].id),r);break;case"object":p.setEntity(p.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Null].id),r);break}else{const ee=[];let se=!1;q.forEach(le=>{var ue,z,X,pe;if(Array.isArray(le)&&(se=!0),typeof le=="object"&&!Array.isArray(le)&&le!==null){const de=ug(le,p.project,{...i,id:x.UUID.uuid()},r,a);de.hasCreated&&ee.push((ue=de.changeSet)==null?void 0:ue.self),c.push(...(z=de.changeSet)==null?void 0:z.updated),e.push(...(X=de.changeSet)==null?void 0:X.added),f.push(...(pe=de.changeSet)==null?void 0:pe.removed)}});const te=C(ee);if(!te.length&&!se){q.forEach(le=>{const ue=mr.new(r);ue.parentRelationType=ze.OrDataTypeGroup,ue.parent=p.toReference();const z=ge(ue,p.project);switch(z.hydrateAncestors(),z.setParent(p,r),z.addSelfToProject(r),r==null||r.add(z,W.Added),z.initChildren(r),typeof le){case"string":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.String].id),r);break;case"number":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Number].id),r);break;case"boolean":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Boolean].id),r);break;case"object":z.setEntity(z.project.getBuiltIn(ne[d.PrimitiveEntity][fe.Null].id),r);break}r||z.captureVersion()});break}else te.length===1&&!se?p.setEntity(te[0],r):q.forEach(le=>{if(typeof le=="object"&&!Array.isArray(le)&&le!==null){const ue=Kx(Object.keys(le),p.project);if(ue){const z=TVe(ue||te[0],p,r,ze.OrDataTypeGroup);c.push(...z.updated),e.push(...z.added),f.push(...z.removed)}}else{const ue=mr.new(r);ue.parentRelationType=ze.OrDataTypeGroup,ue.parent=p.toReference();const z=ge(ue,p.project);z.hydrateAncestors(),z.setParent(p,r),z.addSelfToProject(r),r==null||r.add(z,W.Added),z.initChildren(r);const X=qx(le,z,{...i,id:x.UUID.uuid()},r,a);c.push(...X.updated),e.push(...X.added),f.push(...X.removed),r||z.captureVersion()}})}}else{const q=ug(s[0],p.project,{...i},r,a);p.setEntity((m=q.changeSet)==null?void 0:m.self,r),c.push(...(E=q.changeSet)==null?void 0:E.updated),e.push(...(b=q.changeSet)==null?void 0:b.added),f.push(...(A=q.changeSet)==null?void 0:A.removed);break}else{const q=ug(s,p.project,{...i},r,a);p.setEntity((_=q.changeSet)==null?void 0:_.self,r),c.push(...(P=q.changeSet)==null?void 0:P.updated),e.push(...(V=q.changeSet)==null?void 0:V.added),f.push(...(j=q.changeSet)==null?void 0:j.removed);break}}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:p}}function ug(s,p,i,r,a){const c=[],e=[],f=[],h=[],m=Object.keys(s),E=Kx(m,p);if(E)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:E}};const b=a?i.name+" of "+a.name:i.name,_={id:i.id||x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:b,codeName:null,deletable:!0,editable:!0,type:d.DefinitionEntity,additionalProperties:!1,additionalPropertiesDataType:null,allPropertiesImplement:null,description:i.description||null,static:i.static||!1,abstract:i.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:p.toReference()},P=ge(_,p);return P.hydrateAncestors(),P.setParent(p,r),P.addSelfToProject(r),r==null||r.add(P,W.Added),P.initChildren(r),e.push(P),m.forEach((V,j)=>{const M=x.UUID.uuid(),G=Es.new(r);G.id=M,G.name=V,G.codeName=V,G.parent=P.toReference(),G.index=j,G.required=!0,G.interactive=!0;const q=ge(G,p);q.hydrateAncestors(),q.setParent(P,r),q.addSelfToProject(r),r==null||r.add(q,W.Added),q.initChildren(r),e.push(q);const re=s[V],ee=x.UUID.uuid(),se=mr.new(r);se.id=ee,se.parent=q.toReference(),se.like=!0,se.isList=!1;const te=ge(se,p);te.hydrateAncestors(),te.setParent(q,r),te.addSelfToProject(r),r==null||r.add(te,W.Added),te.initChildren(r),e.push(te);const le=qx(re,te,{...i,name:V,id:x.UUID.uuid()},r,a||P);c.push(...le.updated),e.push(...le.added),f.push(...le.removed),r||(q.captureVersion(),te.captureVersion())}),r||P.captureVersion(),{hasCreated:!0,changeSet:{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:P}}}function Yd(s,p,i,r){const a=[];return!s.length||!p.length?{errors:a,overlap:!1}:(s.length>p.length?s.forEach(c=>{const e=p.find(h=>h.name===c.name),f=p.find(h=>{var m,E;return Array.isArray(h.implements)?h.implements.some(b=>!!c.implements.find(A=>A.id===b.id)):((m=h.implements)==null?void 0:m.id)===((E=c.implements)==null?void 0:E.id)});if(e){const h=new Fi({id:c.id+"--"+e.id+"--"+r,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${e.type} ${e.name} with id "${e.id}" that has the same name`,severity:Te.Error,code:r,entity:c,firstRelationship:e});a.push(h)}if(f){const h=new Fi({id:c.id+"--"+f.id+"--"+i,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${f.type} ${f.name} with id "${f.id}" that implements the same base descriptor`,severity:Te.Error,code:i,entity:c,firstRelationship:f});a.push(h)}}):p.forEach(c=>{var h;const e=s.find(m=>m.name===c.name),f=s.find(m=>{var E,b;return m.implements&&Array.isArray(m.implements)?m.implements.some(A=>!!c.implements.find(_=>_.id===A.id)):((E=m.implements)==null?void 0:E.id)===((b=c.implements)==null?void 0:b.id)});if(e){const m=new Fi({id:e.id+"--"+c.id+"--"+r,message:`Entity of type ${e.type} named "${e.name}" with id "${e.id}" overrides a base entity ${c.name} with id "${c.id}" that has the same name`,severity:Te.Error,code:r,entity:e,firstRelationship:c});a.push(m)}if(f){const m=new Fi({id:f.id+"--"+c.id+"--"+i,message:`Entity of type ${f.type} named "${f.name}" with id "${f.id}" overrides a base entity ${c.name} with id "${c.id}" that implements the same base ${Array.isArray(f==null?void 0:f.implements)?vt(f==null?void 0:f.implements.map(E=>E.type),"', '","' and '"):(h=f.implements)==null?void 0:h.id}`,severity:Te.Error,code:i,entity:f,firstRelationship:c});a.push(m)}}),{errors:a,overlap:!!a.length})}function Sgi(s,p){return s.abstract||(s.properties.forEach(r=>{r.abstract||r.metaSync({abstract:!0},p)}),Object.values(s.detachedDependents).forEach(r=>{r.field===TL.EntityField&&r.entity.remove({ignoreUpstream:!1},p)}),s.metaSync({abstract:!0},p)),s}function Zgi(s,p){return s.abstract&&(s.properties.forEach(r=>{r.abstract&&r.metaSync({abstract:!1},p)}),Object.values(s.detachedDependents).forEach(r=>{(r.field===zg.Implements||r.field===zg.Extends)&&r.entity.onDetachedDependencyRemoved(s,r.field,p)}),s.metaSync({abstract:!1},p)),s}function Hgi(s,p){return s.static||(s.properties.forEach(r=>{r.static||r.metaSync({static:!0},p)}),s.metaSync({static:!0},p)),s}function Wgi(s,p){return s.static&&s.metaSync({static:!1},p),s}const JT=class JT extends $x{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"version");R(this,"name");R(this,"description",null);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",!1);R(this,"static");R(this,"additionalProperties",!1);R(this,"properties",[]);R(this,"allPropertiesImplement",null);R(this,"additionalPropertiesDataType",null);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"interactive",!1);R(this,"errors",[]);R(this,"project");if(this.initialData=this.initialData||i,this.project=this.project||r,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.additionalProperties=i.additionalProperties,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.initialData.allPropertiesImplement){const a=ge(this.initialData.allPropertiesImplement,this.project);a.setParent(this,null),a.initChildren(null),this.allPropertiesImplement=a}if(this.initialData.additionalPropertiesDataType){const a=ge(this.initialData.additionalPropertiesDataType,this.project);a.setParent(this,null),a.initChildren(null),this.additionalPropertiesDataType=a}this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project))}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allMethods)||[],r=[...i].filter(c=>!i.some(e=>e.id!==c.id));return C(r)}get allBasePropertiesFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allProperties)||[],r=[...i].filter(c=>!i.some(e=>{var f;return e.id!==c.id&&(!!e.implements.find(h=>h.id===c.id)||((f=e.extends)==null?void 0:f.id)===c.id)}));return C(r)}get allBasePropertiesFromExtendedAndImplementedEntities(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C([...r])}get allBaseMethodsFromExtendedAndImplementedEntities(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>r.type===d.PrimitiveEntity?i:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||!!E.implements.find(A=>A.id===h.id)}))},[])].filter(i=>!!i.abstract))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods,...this.abstractMethods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeBuiltInInstance(this),this}unsubscribe(){return this.project.unsubscribeBuiltInInstance(this),this}async APILoad(i=Ke,...r){return await JT.repository.APILoad(this.id,...r),this}toFlat(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...((a=this.extends)==null?void 0:a.toFlat(i))||[]])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...((a=this.extends)==null?void 0:a.toFlatIds(i))||[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,interactive:this.interactive,additionalProperties:this.additionalProperties,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,additionalProperties:this.additionalProperties,interactive:this.interactive,additionalPropertiesDataType:((r=this.additionalPropertiesDataType)==null?void 0:r.toJSON(i))||null,allPropertiesImplement:((a=this.allPropertiesImplement)==null?void 0:a.toJSON(i))||null,properties:this.properties.map(e=>e.toJSON(i)),methods:this.methods.map(e=>e.toJSON(i)),abstractMethods:this.abstractMethods.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null})}toReference(i=at){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=at){var r,a,c;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,interactive:this.interactive,additionalProperties:this.additionalProperties,additionalPropertiesDataType:((r=this.additionalPropertiesDataType)==null?void 0:r.toReference())||null,allPropertiesImplement:((a=this.allPropertiesImplement)==null?void 0:a.toReference())||null,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),extends:((c=this.extends)==null?void 0:c.toReference())||null}}toFlatJSON(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(e=>e.toFlatJSON(i)),...this.methods.flatMap(e=>e.toFlatJSON(i)),...this.abstractMethods.flatMap(e=>e.toFlatJSON(i)),...((a=this.additionalPropertiesDataType)==null?void 0:a.toFlatJSON(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var r;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,additionalProperties:this.additionalProperties,extends:(r=this.extends)==null?void 0:r.id}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(e=>e.toFlatGenerationTarget(i)),...this.methods.flatMap(e=>e.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(e=>e.toFlatGenerationTarget(i)),...((a=this.additionalPropertiesDataType)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,r;return this.errors=[],this.properties.forEach(a=>a.clearErrors()),this.methods.forEach(a=>a.clearErrors()),this.abstractMethods.forEach(a=>a.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(r=this.allPropertiesImplement)==null||r.clearErrors(),this}validate(){return this.errors=Mgi(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await Bgi(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((r=this.additionalPropertiesDataType)==null?void 0:r.getErrors())||[],...((a=this.allPropertiesImplement)==null?void 0:a.getErrors())||[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}if(this.additionalPropertiesDataType){const c=await this.additionalPropertiesDataType.getErrorsAsync({tracker:r});a.push(...c)}if(this.allPropertiesImplement){const c=await this.allPropertiesImplement.getErrorsAsync({tracker:r});a.push(...c)}return a}getShallowErrors(){return this.errors}implement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),null,!0,"implement-built-in-base-entity")),a){const c=m1(this,i,r,a);return r==null||r.attemptAutoclose("implement-built-in-base-entity",this.id),c}getAllPropertiesImplements(){var r;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),((r=this.extends)==null?void 0:r.type)===d.BuiltInBaseEntity&&i.push(...this.extends.getAllPropertiesImplements()||[]),i}getAllInteractiveMethods(){const i=[];if(this.interactive){if(i.push(...this.methods,...this.abstractMethods),!this.extends||this.extends.type===d.BuiltInBaseEntity&&this.extends.interactive||this.extends.type===d.PrimitiveEntity)return i;this.extends instanceof JT&&i.push(...this.extends.getAllInteractiveMethods())}return C(i)}getRawDefaultValue(){const i={};return this.properties.forEach(r=>{var e;if(!bv(r)||!r.defaultValue)return;const a=oe(r,this.project),c=r.codeName||vp(r,this.project)||cs(Xi(a));i[c]=((e=r.getDefaultValue())==null?void 0:e.value)||null}),i}};R(JT,"repository",{APILoad:async(i,...r)=>null});let vd=JT;class vVe extends vd{constructor(i){super(On,i);R(this,"initialData");R(this,"id",Ae.PERSISTED_ENTITY);R(this,"version","1");R(this,"name",Ae.PERSISTED_ENTITY);R(this,"description",On.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",On.abstract);R(this,"static",On.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=On,this.project=i,this.id=On.id,this.version=On.version,this.name=On.name,this.static=On.static,this.abstract=On.abstract,this.properties=this.initialData.properties.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.methods=this.initialData.methods.map(r=>{const a=ge(r,this.project);return a.parent=this,a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=ge(r,this.project);return a.parent=this,a}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project))}}var Pn=(s=>(s.ValueMustBeString="value-must-be-string",s.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",s.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",s.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",s))(Pn||{});function Sx(s,p){const i=[],r=p;if(!r)return{errors:i,override:p};if(typeof r!="string")return{errors:[],override:p};if(r.includes(" ")){const a=new Fi({id:s.id+"--string-value-must-not-have-spaces",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value cannot contain spaces.`,severity:Te.Error,code:"string-value-must-not-have-spaces",entity:s});i.push(a)}return{errors:i,override:r.replace(/\s/g,"-")}}function EVe(s,p){const i=[],r=p;if(!r)return{errors:i,override:p};if(typeof r!="string")return{errors:[],override:p};if(r.includes(" ")){const a=new Fi({id:s.id+"--string-value-must-not-have-spaces",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:Te.Error,code:"string-value-must-not-have-spaces",entity:s});i.push(a)}if(r.includes("-")){const a=new Fi({id:s.id+"--string-value-must-not-have-dashes",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:Te.Error,code:"string-value-must-not-have-dashes",entity:s});i.push(a)}return{errors:i,override:r.replace(/\s|-/g,"_")}}var Ed=(s=>(s.StatusCodeMustBeNumber="status-code-must-be-number",s.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",s))(Ed||{});function bVe(s,p){const i=[];if(typeof p!="number"){const r=new Fi({id:s.id+"--status-code-must-be-number",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be a number.`,severity:Te.Error,code:"status-code-must-be-number",entity:s});return i.push(r),{errors:i,override:p}}if(p<100||p>599){const r=new Fi({id:s.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:Te.Error,code:"status-code-must-be-between-100-and-599",entity:s});i.push(r)}return{errors:i,override:p}}class AVe extends vd{constructor(i){var f,h;super(os,i);R(this,"initialData");R(this,"id",Ae.HTTP_ENDPOINT);R(this,"version","1");R(this,"name",Ae.HTTP_ENDPOINT);R(this,"description",os.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",os.abstract);R(this,"static",os.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=os,this.project=i,this.id=os.id,this.version=os.version,this.name=os.name,this.static=os.static,this.abstract=os.abstract,this.properties=this.initialData.properties.map(m=>{const E=ge(m,this.project);return E.setParent(this,null),E.initChildren(null),E}),this.methods=this.initialData.methods.map(m=>{const E=ge(m,this.project);return E.parent=this,E}),this.abstractMethods=this.initialData.abstractMethods.map(m=>{const E=ge(m,this.project);return E.parent=this,E}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project));const r=this.properties.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!r)throw new Error("Path property not found in endpoint entity");r._codeNativeValueValidation=(m,E)=>{var j;const b=Sx(m,E),A=m.parent,_=A.properties.find(M=>M.implements.find(G=>G.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id)),P=(j=_==null?void 0:_.getDefaultValue())==null?void 0:j.value;if(m.project.entities.filter(M=>si(M,Ae.HTTP_ENDPOINT)&&M.id!==A.id).some(M=>{var re,ee;const G=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id));if(((re=G==null?void 0:G.getDefaultValue())==null?void 0:re.value)!==P)return!1;const q=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(!q)throw new Error(`"Path" property not found in endpoint entity "${M.name}" (${M.id})`);return((ee=q.getDefaultValue())==null?void 0:ee.value)===E})){const M=new Fi({id:m.id+"--"+Pn.MustBeUniqueAmongSameEntities,message:`Path "${E}" is already in use by another endpoint with the ${P} method.`,severity:Te.Error,code:Pn.MustBeUniqueAmongSameEntities,entity:m});b.errors.push(M)}return b};const a=this.properties.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id);a&&(a._codeNativeValueValidation=(m,E)=>{var j;const b={errors:[],override:E},A=m.parent,_=A.properties.find(M=>M.implements.find(G=>G.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id)),P=(j=_==null?void 0:_.getDefaultValue())==null?void 0:j.value;if(m.project.entities.filter(M=>si(M,Ae.HTTP_ENDPOINT)&&M.id!==A.id).some(M=>{var re,ee;const G=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(((re=G==null?void 0:G.getDefaultValue())==null?void 0:re.value)!==P)return!1;const q=M.properties.find(se=>se.implements.find(te=>te.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id));return((ee=q==null?void 0:q.getDefaultValue())==null?void 0:ee.value)===E})){const M=new Fi({id:m.id+"--"+Pn.MustBeUniqueAmongSameEntities,message:`Method "${E}" cannot be used because another endpoint is already using the ${E} method on path "${P}".`,severity:Te.Error,code:Pn.MustBeUniqueAmongSameEntities,entity:m});b.errors.push(M)}return b});const c=this.abstractMethods.find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!c)throw new Error("Handler method not found in endpoint entity");const e=(((h=(f=c.dataType)==null?void 0:f.entity)==null?void 0:h.properties)||[]).find(m=>m.id===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.dataType.entity.properties.statusCode.id);if(!e)throw new Error("Status code output not found in handler method");e._codeNativeValueValidation=(m,E)=>bVe(m,E)}}var KT=(s=>(s.InvalidCharacters="cron-invalid-characters",s.MustHaveSixFields="cron-must-have-six-fields",s.DayOfMonthAndWeekConflict="cron-day-of-month-and-week-conflict",s))(KT||{});function gVe(s,p){const i=[];let r=p;if(typeof p!="string"){const e=new Fi({id:s.id+"--"+Pn.ValueMustBeString,message:`Entity of type ${s.type} with id "${s.id}" has an invalid value. The cron expression must be a string.`,severity:Te.Error,code:Pn.ValueMustBeString,entity:s});return i.push(e),{errors:i,override:""}}r=p.trimStart().replace(/\s{2,}/g," ");const a=/[^0-9A-Z *?\-/,LW#]/g;if(a.test(r)){const e=Array.from(new Set(r.match(a)));i.push(new Fi({id:s.id+"--cron-invalid-characters",message:`Cron expression contains invalid characters: "${e.join(", ")}". Only alphanumeric characters and (* ? - / , L W #) are allowed.`,severity:Te.Error,code:"cron-invalid-characters",entity:s})),r=r.replace(a,"")}const c=r.split(" ").filter(Boolean);if(c.length!==6)i.push(new Fi({id:s.id+"--cron-must-have-six-fields",message:`AWS Cron expressions must have exactly 6 fields separated by spaces (Minutes, Hours, Day-of-month, Month, Day-of-week, Year). Currently has ${c.length}.`,severity:Te.Error,code:"cron-must-have-six-fields",entity:s}));else{const e=c[2],f=c[4];e!=="?"&&f!=="?"&&(i.push(new Fi({id:s.id+"--cron-day-of-month-and-week-conflict",message:"AWS restricts defining both Day-of-month and Day-of-week simultaneously. If you specify one, the other must be '?'",severity:Te.Error,code:"cron-day-of-month-and-week-conflict",entity:s})),e==="*"&&f==="*"&&(c[4]="?",r=c.join(" ")))}return{errors:i,override:r}}class IVe extends vd{constructor(i){super(Gs,i);R(this,"initialData");R(this,"id",Ae.CRON_JOB);R(this,"version","1");R(this,"name",Ae.CRON_JOB);R(this,"description",Gs.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",Gs.abstract);R(this,"static",Gs.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=Gs,this.project=i,this.id=Gs.id,this.version=Gs.version,this.name=Gs.name,this.static=Gs.static,this.abstract=Gs.abstract,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project));const r=this.properties.find(a=>a.id===ne["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.properties.expression.id);if(!r)throw new Error("Expression property not found in cron job entity");r._codeNativeValueValidation=(a,c)=>gVe(a,c)}}class RVe extends vd{constructor(i){super(qn,i);R(this,"initialData");R(this,"id",Ae.RELATIONAL_DATABASE);R(this,"version","1");R(this,"name",Ae.RELATIONAL_DATABASE);R(this,"description",qn.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",qn.abstract);R(this,"static",qn.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=qn,this.project=i,this.id=qn.id,this.version=qn.version,this.name=qn.name,this.static=qn.static,this.abstract=qn.abstract,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project));const r=this.properties.find(a=>a.id===ne["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id);if(!r)throw new Error("Path property not found in endpoint entity");r._codeNativeValueValidation=(a,c)=>EVe(a,c)}}class DVe extends Ji{constructor(i){super(ya,i);R(this,"id",ya.id);R(this,"name",ya.name);R(this,"description",ya.description);R(this,"version",ya.version);R(this,"autoexecutable",!1);R(this,"type",d.ActionDescriptor);R(this,"inputs",[]);R(this,"dataType",null);R(this,"error",null);R(this,"project");this.project=i,this.inputs=ya.inputs.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.dataType=ge(ya.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=ya.error?ge(ya.error,this.project):null}}var fs=(s=>(s.UUIDMustBeString="uuid-must-be-string",s.UUIDMustBeValidFormat="uuid-must-be-valid-format",s.UUIDMustNotContainSpaces="uuid-must-not-contain-spaces",s))(fs||{});function zgi(s,p){const i=[];if(typeof p!="string"){const a=new Fi({id:s.id+"--uuid-must-be-string",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be text.`,severity:Te.Error,code:"uuid-must-be-string",entity:s});return i.push(a),{errors:i,override:p}}const r=Sx(s,p);if(r.errors.length>0)return i.push(...r.errors),{errors:i,override:p};if(!xx(p)){const a=new Fi({id:s.id+"--uuid-must-be-valid-format",message:`Entity of type ${s.type} with id "${s.id}" has an invalid value "${p}". The value must be a valid UUID format. Eg: "123e4567-e89b-12d3-a456-426614174000".`,severity:Te.Error,code:"uuid-must-be-valid-format",entity:s});i.push(a)}return{errors:i,override:p}}var Me=(s=>(s.Inherited="inherited",s.DefaultValue="default-value",s.Missing="missing",s.Empty="empty",s.AutoCalculated="auto-calculated",s.QueuedAutocalculation="queued-autocalculation",s.External="external",s.Testing="testing",s.ExecutionResult="execution-result",s))(Me||{});const wVe={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function PT(s,p){return{...wVe,id:s,project:p}}class NT{constructor(p,i){R(this,"initialized",!1);R(this,"id");R(this,"project");R(this,"values",{});R(this,"onWriteCallback",()=>{});R(this,"onRemoveCallback",()=>{});this.id=p,this.project=i,this.init()}onWrite(p){this.onWriteCallback=p}onRemove(p){this.onRemoveCallback=p}init(){var r;if(!((r=this.project)!=null&&r.id)||this.initialized)return;const p={},i={};Object.keys(p).forEach(a=>{const c=p[a],e=new Nr(c,this.project);try{if(c.parent){const m=this.project.findSubscribedInstanceFromReference(c.parent);if(!m)return;e.setParent(m,null),e.hydrateAncestors(),e.initChildren(null)}else if(c.standaloneParent){const m=this.project.findSubscribedInstanceFromReference(c.standaloneParent);if(!m)return;e.standalone=!0,e.setStandaloneParent(m,null),e.hydrateAncestors(),e.initChildren(null)}i[a]=e;const f=e.parent||e.standaloneParent,h=KVe(e,f,this.project);h?i[a]=h:delete p[a]}catch(f){Y.Logger.error("Error hydrating ancestors: ",f),delete p[a]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const p={};return Object.keys(this.values).forEach(i=>{p[i]=this.values[i].toJSON()}),p}writeValue(p,i){if(!p)throw new Error("The value owner entity is required when writing a value to a value store");let a=this.values[p.id];if(!a)if(i instanceof Nr)a=i;else if(i)a=nr(i,this.project);else{const c={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:null,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:p.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:yf(p.getDataType(null))};a=nr(c,this.project)}a.standalone=!0,a.initialData.standaloneParent||Y.Logger.warn("instance.initialData: ",a.initialData),a.setStandaloneParent(p,null),a.hydrateAncestors(),a.initChildren(null),i&&(a.metaSync({...i},null),a.setValueAsType(i.valueAsType,null)),this.values[p.id]=a,this.onWriteCallback(p,a)}readValue(p){return this.values[p]||null}removeValue(p){if(!this.values[p])return;delete this.values[p];const i=this.project.get(p);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function br(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function Zx(s){if(Array.isArray(s))return s.map(h=>typeof h=="number"?h:e(h)?Number(h):String(h));const p=[];let i=0,r="",a=!1,c=null;for(;i<s.length;){const h=s[i];if(h==="."&&!a){r.length&&(p.push(f(r)),r=""),i++;continue}if(h==="["&&!a){r.length&&(p.push(f(r)),r=""),a=!0,i++;continue}if(a){if(!c&&(h==='"'||h==="'")){c=h,i++;continue}if(c){if(h==="\\"&&i+1<s.length){r+=s[i+1],i+=2;continue}if(h===c){c=null,i++;continue}r+=h,i++;continue}if(h==="]"){p.push(f(r)),r="",a=!1,i++;continue}if(/\s/.test(h)&&!c){i++;continue}r+=h,i++;continue}r+=h,i++}return r.length&&p.push(f(r)),p;function e(h){return/^[0-9]+$/.test(h)}function f(h){const m=h.trim();return e(m)?Number(m):m}}function T1(s,p,i){if(s==null)return i;const r=Zx(p);let a=s;for(let c=0;c<r.length;c++){const e=r[c];if(a==null)return i;if(Array.isArray(a)&&typeof e=="number"){if(!(e in a))return i;a=a[e]}else{if(!Object.prototype.hasOwnProperty.call(a,e))return i;a=a[e]}}return a}const Ygi=new Set(["__proto__","prototype","constructor"]);function CVe(s){return typeof s=="string"&&Ygi.has(s)}function Jgi(s,p,i,r){const{createMissing:a=!0,coerce:c=!0}=r??{};if(s==null||typeof s!="object")throw new TypeError("set(...) expects a non-null object as target.");const e=Zx(p);if(e.length===0)throw new Error("set(...) path must not be empty.");let f=s;for(let h=0;h<e.length;h++){const m=e[h];if(CVe(m))throw new Error(`Refusing to set unsafe key "${String(m)}" on object.`);const E=h===e.length-1,A=typeof e[h+1]=="number",_=Array.isArray(f)&&typeof m=="number";if(E){if(_&&f[m]==null&&!a)throw new Error(`set(...) missing array index "${String(m)}" (createMissing=false).`);return f[m]=i,s}else{if(!Object.prototype.hasOwnProperty.call(f,m)||f[m]==null){if(!a)throw new Error(`set(...) missing parent at segment "${String(m)}" (createMissing=false).`);f[m]=A?[]:{}}else{const P=f[m],V=P!==null&&typeof P=="object",j=Array.isArray(P);if(A){if(!j){if(!c)throw new Error(`set(...) expected an array at "${String(m)}" but found non-array (coerce=false).`);f[m]=[]}}else if(!V||j){if(!c)throw new Error(`set(...) expected an object at "${String(m)}" but found non-object (coerce=false).`);f[m]={}}}f=f[m]}}return s}function Hx(s,p,i,r){const a=Zx(p);if(a.length===0)return s;function c(e,f){const h=a[f],m=f===a.length-1;if(r==="strict-set"||r==="strict-delete"){if(CVe(h))throw new Error(`Unsafe key "${String(h)}"`);if(e==null||typeof e!="object"&&!Array.isArray(e))throw new Error(`Missing parent or invalid container at segment "${String(h)}".`);if(r==="strict-delete"&&m&&!(h in e))return e}let E;if(Array.isArray(e))E=[...e];else if(e&&typeof e=="object")E={...e};else if(r==="safe-set")E=typeof h=="number"?[]:{};else throw new Error(`Cannot traverse path at "${String(h)}"`);if(m)return r==="strict-delete"?delete E[h]:E[h]=i,E;const b=e?e[h]:void 0;if(r==="safe-set"&&b==null){const A=typeof a[f+1]=="number",_=c(A?[]:{},f+1);return E[h]=_,E}return E[h]=c(b,f+1),E}if(s==null&&r==="safe-set"){const e=typeof a[0]=="number";return c(e?[]:{},0)}return c(s,0)}const Kk=Symbol("missing"),Qgi=s=>s!=null&&typeof s=="object";function v1(s,p){if(typeof s!="string")throw new TypeError(`${p} expects the key to be a string.`);return s}function Lm(s,p){if(typeof s!="string"&&!Array.isArray(s))throw new TypeError(`${p} expects the path to be string or array.`);return s}function ty(s,p){if(!br(s))throw new TypeError(`${p} expects the first argument to be an object.`);return s??{}}function OVe(s,p){const i=v1(p,"ReadKey");return(s??{})[i]}function _Ve(s,p,i){const r=v1(p,"WriteKey");if(s&&typeof s=="object"){const a=Array.isArray(s)?[...s]:{...s};return a[r]=i,a}return{[r]:i}}function VVe(s,p){if(!s||typeof s!="object")return{};const i=String(p),{[i]:r,...a}=s;return a}function PVe(s,p,i){const r=ty(s,"ReadNestedKey"),a=Lm(p,"ReadNestedKey");return T1(r,a,i)}function NVe(s,p,i){const r=ty(s,"WriteNestedKey"),a=Lm(p,"WriteNestedKey");return Hx(r,a,i,"strict-set")}function xVe(s,p,i){const r=ty(s,"WriteSafeNestedKeyRecursively"),a=Lm(p,"WriteSafeNestedKeyRecursively");return Hx(r,a,i,"safe-set")}function $Ve(s,p){const i=ty(s,"DeleteNestedKey"),r=Lm(p,"DeleteNestedKey");return Hx(i,r,null,"strict-delete")}function LVe(s,p){const i=v1(p,"HasKey"),r=s;return r!=null&&Qgi(r)&&Object.prototype.hasOwnProperty.call(r,i)}function BVe(s,p,i){const r=v1(p,"KeyValueEquals");return s==null||typeof s!="object"?!1:s[r]===i}function MVe(s,p){const i=s,r=Lm(p,"HasNestedKey");return T1(i,r,Kk)!==Kk}function GVe(s,p,i){const r=Lm(p,"NestedKeyValueEquals");return T1(s,r)===i}function jVe(...s){const p={};for(let i=0;i<s.length;i++){const r=s[i];if(r!=null){if(!br(r))throw new TypeError("MergeObjects expects every argument to be an object (or null/undefined).");Object.assign(p,r)}}return p}function kVe(s){const p=ty(s,"ObjectKeys");return Object.keys(p)}function UVe(s){const p=ty(s,"ObjectValues");return Object.values(p)}function FVe(s){const p=ty(s,"ObjectEntries");return Object.entries(p)}function Xgi(s){return{execution:null,project:s,localTestValues:PT("local-test-values",s),resolvedValues:PT("resolved-values",s),persistedExecutionResults:PT("persisted-execution-results",s),lastExecutionResults:PT("last-execution-results",s),getValueTypePreference:()=>null,setValueTypePreference:()=>{}}}function ku(s,p,i,r){var f;let a;if(((f=s==null?void 0:s.entity)==null?void 0:f.type)===d.PrimitiveEntity)switch(s.entity.name){case fe.EntityTemplate:a=fe.EntityTemplate;break;case fe.String:a=fe.String;break;case fe.Number:a=fe.Number;break;case fe.Boolean:a=fe.Boolean;break;case fe.Null:a=fe.Null;break;case fe.Enum:a=fe.Enum;break;case fe.KeyValue:a=fe.KeyValue;break;case fe.Untyped:a=fe.Untyped;break;case fe.KeyValue:a=fe.KeyValue;break;case fe.Date:a=fe.Date;break;case fe.UUID:a=fe.UUID;break;case fe.File:a=fe.File;break;case fe.Void:a=fe.Void;break;case fe.ActionDescriptor:a=fe.ActionDescriptor;break;case fe.Bytes:a=fe.Bytes;break;default:throw new Error(`Primitive type ${oe(s.entity,i)} is not supported`)}else a=fe.Untyped;const c=Nr.new(r);c.name=a,c.parent=p.toReference();const e=ge(c,i);return e.hydrateAncestors(),r==null||r.add(e,W.Added),e.addSelfToProject(r),e.initChildren(r),e}function cd(s,p,i=new Set){var r,a,c;if(i.has(s.id))return[];if(i.add(s.id),Lt.includes(s.type)){const e=Er(s);return C([e,...[e].flatMap(f=>cd(f,p,i))])}else if(s.type===d.OutputMap){if(Lt.includes(s.parent.type)&&((r=s.declaration)==null?void 0:r.type)===d.Property&&s.declaration.static)return C([s,s.declaration,...[s,s.declaration].flatMap(e=>cd(e,p,i))])}else if(s.type===d.InputMap&&Lt.includes(s.parent.type)&&((a=s.declaration)==null?void 0:a.type)===d.Property&&(c=s.declaration)!=null&&c.static)return C([s.declaration,...[s.declaration].flatMap(e=>cd(e,p,i))]);return[s]}function KVe(s,p,i){return s}function Bm(s,p,i=!1){const r=s.readsValue;let a=null;const c=Df(r,p,i);if(c){const e={sources:[c],target:s};a={value:c.value,valueOwner:s,type:Me.Inherited,inheritanceLink:e}}return a}function $t(s,p,i){var f;if(!p)return null;let r;if(((f=s==null?void 0:s.entity)==null?void 0:f.type)===d.PrimitiveEntity)switch(s.entity.name){case fe.EntityTemplate:r=fe.EntityTemplate;break;case fe.String:r=fe.String;break;case fe.Number:r=fe.Number;break;case fe.Boolean:r=fe.Boolean;break;case fe.Null:r=fe.Null;break;case fe.Enum:r=fe.Enum;break;case fe.KeyValue:r=fe.KeyValue;break;case fe.Untyped:r=fe.Untyped;break;case fe.KeyValue:r=fe.KeyValue;break;case fe.Date:r=fe.Date;break;case fe.UUID:r=fe.UUID;break;case fe.File:r=fe.File;break;case fe.Void:r=fe.Void;break;case fe.ActionDescriptor:r=fe.ActionDescriptor;break;case fe.Bytes:r=fe.Bytes;break;default:throw new Error(`Primitive type ${oe(s.entity,i)} is not supported`)}else r=fe.Untyped;if(!i.get(p.id))return null;const c=Nr.new(null);c.name=r,c.standaloneParent=p.toReference();let e=new Nr(c,i);return e.hydrateAncestors(),e.standalone=!0,e.setStandaloneParent(p,null),e.initChildren(null),e}function qVe(s,p,i=!1){var c,e;if(p.execution&&p.execution.hasEntity(s)&&!i){const f=(c=p.lastExecutionResults)==null?void 0:c.readValue(s.id);if(f)return{value:f,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(e=p.localTestValues)==null?void 0:e.readValue(s.id),a=p.getValueTypePreference(s.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null}:{value:null,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:null}}function pg(s,p,i,r=!1){var e,f;const a={...s},c=p.type===d.VariableDeclaration?p.inputs:At.includes(p.type)?p.outputs:[];if(!c||c.length===0)return a;for(const h of c){if(!rb(h))continue;const m=ev(h,i,r);if(m&&m.value){const E=oe(h,i.project),b=h.codeName||((e=h.declaration)==null?void 0:e.codeName)||Xi(E);a[b]=kn((m==null?void 0:m.value)||null)?a[b]:(f=m==null?void 0:m.value)==null?void 0:f.value}}return a}function xT(s,p,i,r=!1){var e,f;const a={...s},c=p.inputs;if(!c)return a;for(const h of c){if(!rb(h))continue;const m=RE(h,i,r);if(m&&m.value){const E=oe(h,i.project),b=h.codeName||((e=h.declaration)==null?void 0:e.codeName)||Xi(E);a[b]=(f=m==null?void 0:m.value)==null?void 0:f.value}}return a}function SVe(s,p,i=!1){var E,b,A,_,P,V,j,M;let r={};if(((b=(E=s.getDataType(null))==null?void 0:E.entity)==null?void 0:b.type)===d.DefinitionEntity&&(r={...r,...((A=s.getDataType(null))==null?void 0:A.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(s)&&!i){const G=(_=p.lastExecutionResults)==null?void 0:_.readValue(s.id);if(G){if(br(G.value)){const re={...r,...G.value},ee={...xT(re,s,p,i)};G.metaSync({value:ee},null)}return{value:G,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}}const a=!!((P=p.execution)!=null&&P.entities.length),c=(V=p.execution)==null?void 0:V.hasEntity(s),e=s.readsValue;let f=null;if(e){const G=(j=p.execution)==null?void 0:j.hasEntity(e);if((!a||a&&G&&c||a&&!G&&!c)&&(f=Bm(s,p,i),f&&f.value&&br(f.value.value))){const re={...r,...f.value.value},ee={...xT(re,s,p,i)};f.value.metaSync({value:ee},null)}}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h){const G=h;if(G&&G.value===null&&G.autogeneration){const q=TD(G);if(G.metaSync({value:q},null),br(q)){const re={...xT(q,s,p,i)};G.metaSync({value:re},null)}}(i||m===null||m!==Me.Testing)&&(f={value:G,valueOwner:s,type:kn(G)?s.readsValue?Me.Inherited:Me.Empty:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const G=(M=p.localTestValues)==null?void 0:M.readValue(s.id);if(G){if(br(G.value)){const q={...r,...G.value},re={...xT(q,s,p,i)};G.metaSync({value:re},null)}return{value:G,valueOwner:s,type:Me.Testing,inheritanceLink:null}}}return kn((f==null?void 0:f.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function Wx(s,p,i=!1){var e,f,h,m,E,b,A,_,P;let r={};if(((f=(e=s.getDataType(null))==null?void 0:e.entity)==null?void 0:f.type)===d.DefinitionEntity&&(r={...r,...((h=s.getDataType(null))==null?void 0:h.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(s)&&!i){const V=(m=p.lastExecutionResults)==null?void 0:m.readValue(s.id);if(V){if(br(V.value)){const M={...r,...V.value},G=pg(M,s,p,i);V==null||V.metaSync({value:G},null)}return{value:V,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}}const a=(E=p.localTestValues)==null?void 0:E.readValue(s.id),c=p.getValueTypePreference(s.id);if(a&&!i&&(c===null||c!==Me.DefaultValue)){if(br(a.value)){const j={...r,...a.value},M=pg(j,s,p,i);a.metaSync({value:M},null)}return{value:a,valueOwner:s,type:Me.Testing,inheritanceLink:null}}if((b=s.getDataType(null))!=null&&b.entity&&((_=(A=s.getDataType(null))==null?void 0:A.entity)==null?void 0:_.type)===d.DefinitionEntity&&((P=s.getDataType(null))!=null&&P.isObject())){const V=$t(s.dataType,s,p.project),j=pg(r,s,p,i);return V==null||V.metaSync({value:j},null),{value:V,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null}}return null}function IE(s,p,i=!1){var E,b,A,_,P;if((E=s.dataType)!=null&&E.isObject())return SVe(s,p,i);const r=yt(s),a=!!((b=p.execution)!=null&&b.entities.length),c=(A=p.execution)==null?void 0:A.hasEntity(r),e=s.readsValue;let f=null;if(e){const V=(_=p.execution)==null?void 0:_.hasEntity(e);(!a||a&&V&&c||a&&!V&&!c)&&(f=Bm(s,p,i))}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h){const V=h;if(V&&V.value===null&&V.autogeneration){const j=TD(V);V.metaSync({value:j},null)}(i||m===null||m!==Me.Testing)&&(f={value:V,valueOwner:s,type:kn(V)?s.readsValue?Me.Inherited:Me.Empty:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const V=(P=p.localTestValues)==null?void 0:P.readValue(s.id);if(V)return{value:V,valueOwner:s,type:Me.Testing,inheritanceLink:null}}return kn((f==null?void 0:f.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function zx(s,p,i=!1){var e,f,h;if((e=s.dataType)!=null&&e.isObject())return Wx(s,p);if(p.execution&&p.execution.hasEntity(s)&&!i){const m=(f=p.lastExecutionResults)==null?void 0:f.readValue(s.id);if(m)return{value:m,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(h=p.localTestValues)==null?void 0:h.readValue(s.id),a=p.getValueTypePreference(s.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null}:IE(s,p,i)}function Yx(s,p,i=!1){var A,_,P,V;const r=!!((A=p.execution)!=null&&A.entities.length),a=(_=p.execution)==null?void 0:_.hasEntity(s);let c=null;const e=s.readsValue;if(e){const j=(P=p.execution)==null?void 0:P.hasEntity(e);(!r||r&&j&&a||r&&!j&&!a)&&(c=Bm(s,p,i))}const f=s.declaration;if(!c&&f){const j=IE(f,p);j&&j.value&&(c=j)}const h=p.getValueTypePreference(s.id);if(!c||(c.type===Me.DefaultValue||c.type===Me.External)&&!i||h===null||h!==Me.DefaultValue){const j=(V=p.localTestValues)==null?void 0:V.readValue(s.id);if(j)return{value:j,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const m=pu(s),E=s.getDataType(null);return m&&a&&(!(c!=null&&c.value)||!ps(E)&&du(c==null?void 0:c.value))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:a&&!m&&kn((c==null?void 0:c.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:c||{value:null,valueOwner:s,type:Me.External,inheritanceLink:null}}function ZVe(s,p,i=!1){return zx(s.declaration,p,i)}function HVe(s,p,i=!1){var A,_,P,V;if(!i&&p.execution&&p.execution.hasEntity(s)){const j=(A=p.lastExecutionResults)==null?void 0:A.readValue(s.id);if(j)return{value:j,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=yt(s),a=s.parent.type===d.FunctionDeclaration&&s.parent.parent.type===d.Loop?s.parent:null,c=!!((_=p.execution)!=null&&_.hasEntity(r))||!!a&&!!((P=p.execution)!=null&&P.hasEntity(a));let e=null;const f=s.defaultValue,h=p.getValueTypePreference(s.id);if(f){const j=f||null;if(j&&j.value===null&&j.autogeneration){const M=TD(j);j.metaSync({value:M},null)}(i||h===null||h!==Me.Testing)&&(e={value:j,valueOwner:s,type:kn(j)?Me.Empty:Me.DefaultValue,inheritanceLink:null})}if(!e||(e.type===Me.DefaultValue||e.type===Me.External)&&!i||h===null||h!==Me.DefaultValue){const j=(V=p.localTestValues)==null?void 0:V.readValue(s.id),M=p.getValueTypePreference(s.id);if(j&&!i&&(M===null||M!==Me.DefaultValue))return{value:j,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const m=pu(s),E=s.getDataType(null);let b=m&&c&&(!(e!=null&&e.value)||!ps(E)&&du(e==null?void 0:e.value));return r.type===d.Loop&&c&&(b=!1),b?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:c&&!m&&kn((e==null?void 0:e.value)||null)?{value:null,valueOwner:s,type:Me.Empty,inheritanceLink:null}:e||{value:null,valueOwner:s,type:Me.External,inheritanceLink:null}}function Jx(s,p,i=!1){var _,P,V,j,M,G;if((_=s.getDataType(null))!=null&&_.isObject())return Wx(s,p);if(p.execution&&p.execution.hasEntity(s)&&!i){const q=(P=p.lastExecutionResults)==null?void 0:P.readValue(s.id);if(q)return{value:q,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=yt(s),a=!!((V=p.execution)!=null&&V.entities.length),c=(j=p.execution)==null?void 0:j.hasEntity(r),e=s.readsValue;let f=null;if(e){const q=(M=p.execution)==null?void 0:M.hasEntity(e);(!a||a&&q&&c||a&&!q&&!c)&&(f=Bm(s,p,i))}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h){const q=h;(i||m===null||m!==Me.Testing)&&(f={value:q,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const q=(G=p.localTestValues)==null?void 0:G.readValue(s.id);if(q)return{value:q,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const E=pu(s),b=s.getDataType(null);return E&&(!(f!=null&&f.value)||!ps(b)&&du(f==null?void 0:f.value))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:!E&&kn((f==null?void 0:f.value)||null)?{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function WVe(s,p,i=!1){var f,h,m,E,b,A,_,P,V,j,M,G,q;if(p.execution&&p.execution.hasEntity(s)&&!i){const re=(f=p.lastExecutionResults)==null?void 0:f.readValue(s.id);if(re)return{value:re,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=jp(s);if(Ip.includes(r.type)){const re=Df(r,p,i),ee=s.codeName||((h=s.declaration)==null?void 0:h.codeName)||Xi(oe(s,p.project));if(re!=null&&re.value&&br(re.value.value)){const se=re.value.value[ee],te=$t(s.getDataType(null),s,p.project);return te==null||te.metaSync({value:se},null),{value:te,valueOwner:s,type:!Lt.includes(r.type)&&re.type===Me.Empty?Me.QueuedAutocalculation:re.type,inheritanceLink:{sources:[re],target:s}}}return{value:null,valueOwner:s,type:Lt.includes(r.type)?Me.Empty:Me.QueuedAutocalculation,inheritanceLink:null}}const a=(m=p.execution)==null?void 0:m.hasEntity(r),c=((E=p.execution)==null?void 0:E.state)===f$.Running;if((b=p.persistedExecutionResults)!=null&&b.values[s.id]&&!a&&!c&&!i){const re=(A=p.persistedExecutionResults)==null?void 0:A.readValue(s.id);if((re==null?void 0:re.value)!==null||(re==null?void 0:re.valueAsType)!==null)return{value:re,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const e=s.parent;if(!e)throw new Error(`Couldn't find the parent that generates the output ${s.id}`);switch(e.type){case d.VariableInstance:{const ee=Yx(e,p,i);if(ee&&ee.value){const te=s.declaration;if(br(ee.value.value)){const le=ee.value.value[te.name],ue=$t(((_=s.declaration)==null?void 0:_.dataType)||null,s,p.project);return ue==null||ue.metaSync({value:le},null),{value:ue,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:[ee],target:s}}}}const se=$t(((P=s.declaration)==null?void 0:P.dataType)||null,s,p.project);return se==null||se.metaSync({value:null},null),{value:se,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:s}}}case d.VariableDeclaration:{const ee=IE(e,p,i);if(ee&&ee.value){const te=s.declaration;if(br(ee.value.value)){const le=ee.value.value[te.name],ue=$t(((V=s.declaration)==null?void 0:V.dataType)||null,s,p.project);return ue==null||ue.metaSync({value:le},null),{value:ue,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:[ee],target:s}}}}const se=$t(((j=s.declaration)==null?void 0:j.dataType)||null,s,p.project);return se==null||se.metaSync({value:null},null),{value:se,valueOwner:s,type:Me.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:s}}}case d.Operation:{const re=e.outputs.map(se=>{var te,le;if((te=p.persistedExecutionResults)!=null&&te.values[se.id]){const ue=(le=p.persistedExecutionResults)==null?void 0:le.values[se.id];if(ue.value!==null||ue.valueAsType!==null)return{value:ue,valueOwner:se,type:Me.ExecutionResult,inheritanceLink:null}}}).filter(se=>!!se),ee=$t(((M=s.declaration)==null?void 0:M.dataType)||null,s,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:s}:null}}case d.FunctionCall:{const re=e.inputs.map(se=>Ng(se,p,i)).filter(se=>!!se),ee=$t(((G=s.declaration)==null?void 0:G.dataType)||null,s,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:s}:null}}case d.Loop:{const re=e.inputs.map(se=>Ng(se,p,i)).filter(se=>!!se),ee=$t(((q=s.declaration)==null?void 0:q.dataType)||null,s,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:s}:null}}case d.Search:return{value:null,valueOwner:s,type:Me.QueuedAutocalculation,inheritanceLink:null}}return null}function B_(s,p,i=!1){var b,A,_;if(![...At,...Lt].includes(s.parent.type)||!rb(s))return null;if(((b=s.declaration)==null?void 0:b.type)===d.Property&&s.declaration.static)return Df(s.declaration,p);const r=RE(s,p,i);if(r&&r.type!==Me.Empty&&r.type!==Me.Missing)return r;const a=Er(s.parent),c=sd(a,p,i),e=s.codeName||((A=s.declaration)==null?void 0:A.codeName)||Xi(oe(s,p.project)),f=$t(s.getDataType(null),s,p.project),h=pu(s),m=(_=c==null?void 0:c.value)==null?void 0:_.value;if(m&&br(m)){let P=m[e];m[e]===void 0&&(P=null),f==null||f.metaSync({value:P},null);const V=pu(s),j=s.getDataType(null);return V&&(!f||!ps(j)&&du(f))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:{value:f,valueOwner:s,type:c.type,inheritanceLink:{sources:c?[c]:[],target:s}}}return h?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:{value:null,valueOwner:s,type:s.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}}function M_(s,p,i=!1){var b,A,_,P,V,j,M,G;if(![...At,...Lt].includes(s.parent.type)||!rb(s))return null;if(((b=s.declaration)==null?void 0:b.type)===d.Property&&s.declaration.static)return Df(s.declaration,p,i);const r=At.includes(s.parent.type)?s.parent:Er(s.parent),a=Df(r,p,i);let c=s;r.type===d.VariableDeclaration&&(c=(s.parent===r?s:r.inputs.find(re=>{var ee,se;return((ee=re.declaration)==null?void 0:ee.id)===((se=s.declaration)==null?void 0:se.id)}))||s);const e=ev(c,p,i),f=s.codeName||((A=s.declaration)==null?void 0:A.codeName)||Xi(oe(s,p.project)),h=(r.type===d.VariableDeclaration,s.defaultValue||$t(s.getDataType(null),s,p.project)),m=(_=a==null?void 0:a.value)==null?void 0:_.value;if(((a==null?void 0:a.type)===Me.ExecutionResult||(a==null?void 0:a.type)===Me.Testing)&&!i&&m&&br(m)){let q=m[f];return m[f]===void 0&&(q=null),h==null||h.metaSync({value:q},null),{value:h,valueOwner:s,type:a.type,inheritanceLink:{sources:a?[a]:[],target:s}}}if(e&&e.type!==Me.Empty&&e.type!==Me.Missing)return e;if(m&&br(m)){let q=m[f];m[f]===void 0&&(q=null),h!=null&&h.standaloneParent&&(h==null||h.metaSync({value:q},null));const re=pu(s),ee=s.getDataType(null),se=re&&(!h||!ps(ee)&&du(h)),te=!!((P=p.execution)!=null&&P.entities.length),le=(V=p.execution)==null?void 0:V.hasEntity(r),ue=r.readsValue;if(ue){const z=(j=p.execution)==null?void 0:j.hasEntity(ue);if(se&&(!te||te&&z&&le||te&&!z&&!le))return{value:null,valueOwner:s,type:Me.Inherited,inheritanceLink:null}}if(s.readsValue){const z=(M=p.execution)==null?void 0:M.hasEntity(s.readsValue);if(se&&(!te||te&&z&&le||te&&!z&&!le))return{value:null,valueOwner:s,type:Me.Inherited,inheritanceLink:null}}return se?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:{value:h,valueOwner:s,type:((G=h==null?void 0:h.parent)==null?void 0:G.id)===(s==null?void 0:s.id)?a.type:Me.Inherited,inheritanceLink:{sources:a?[a]:[],target:s}}}return ev(s,p,i)}function RE(s,p,i=!1){var _,P,V,j,M,G;const r=yt(s),a=!!((_=p.execution)!=null&&_.entities.length),c=(P=p.execution)==null?void 0:P.hasEntity(r),e=s.readsValue;let f=null;if(e){const q=(V=p.execution)==null?void 0:V.hasEntity(e);(!a||a&&q&&c||a&&!q&&!c)&&(f=Bm(s,p,i))}const h=s.defaultValue,m=p.getValueTypePreference(s.id);if(!f&&h&&(i||m===null||m!==Me.Testing)&&(f={value:h,valueOwner:s,type:du(h)?Me.Empty:Me.DefaultValue,inheritanceLink:null}),!f||f.type===Me.DefaultValue||(f==null?void 0:f.type)===Me.Empty){const q=(j=p.persistedExecutionResults)==null?void 0:j.readValue(s.id);if(q&&!i)return{value:q,valueOwner:s,type:Me.Testing,inheritanceLink:null};const re=(M=p.localTestValues)==null?void 0:M.readValue(s.id);if(re&&!i&&(m===null||m!==Me.DefaultValue))return{value:re,valueOwner:s,type:Me.Testing,inheritanceLink:null}}const E=pu(s),b=s.getDataType(null),A=E&&(!(f!=null&&f.value)||!ps(b)&&du(f==null?void 0:f.value));if(s.readsValue){const q=(G=p.execution)==null?void 0:G.hasEntity(s.readsValue);if(A&&(!a||a&&q&&c||a&&!q&&!c))return{value:null,valueOwner:s,type:Me.Inherited,inheritanceLink:null}}return A?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:(f==null?void 0:f.inheritanceLink)||null}:!E&&(!f||f.type===Me.Inherited)&&!(f!=null&&f.inheritanceLink)?{value:null,valueOwner:s,type:s.readsValue||!(f!=null&&f.value)?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function ev(s,p,i=!1){var e,f;if(p.execution&&p.execution.hasEntity(s)&&!i){const h=(e=p.lastExecutionResults)==null?void 0:e.readValue(s.id);if(h)return{value:h,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(f=p.localTestValues)==null?void 0:f.readValue(s.id),a=p.getValueTypePreference(s.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null}:RE(s,p,i)}function Ng(s,p,i=!1){var r,a;return Lt.includes(s.parent.type)&&(r=Er(s.parent).dataType)!=null&&r.isObject()||At.includes(s.parent.type)&&(a=s.parent.getDataType(null))!=null&&a.isObject()?B_(s,p,i):RE(s,p,i)}function zVe(s,p,i=!1){var r,a;return Lt.includes(s.parent.type)&&(r=Er(s.parent).dataType)!=null&&r.isObject()||At.includes(s.parent.type)&&(a=s.parent.getDataType(null))!=null&&a.isObject()?M_(s,p,i):ev(s,p,i)}function YVe(s,p,i=!1){var E,b;if(!s.static)return null;if(p.execution){const A=(E=p.lastExecutionResults)==null?void 0:E.readValue(s.id);if(A&&!i)return{value:A,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(b=p.localTestValues)==null?void 0:b.readValue(s.id),a=p.getValueTypePreference(s.id);if(r&&!i&&(a===null||a!==Me.DefaultValue))return{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null};const c=s.defaultValue;let e=null;c&&(i||a===null||a!==Me.Testing)&&(e={value:c,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null});const f=pu(s),h=s.getDataType(null);return f&&(!(e!=null&&e.value)||!ps(h)&&du(e==null?void 0:e.value))?{value:null,valueOwner:s,type:Me.Missing,inheritanceLink:null}:kn(e==null?void 0:e.value)?{value:null,valueOwner:s,type:Me.Empty,inheritanceLink:null}:e}function JVe(s,p,i=!1){var f,h;if(p.execution&&p.execution.hasEntity(s)&&!i){const m=(f=p.lastExecutionResults)==null?void 0:f.readValue(s.id);if(m)return{value:m,valueOwner:s,type:Me.ExecutionResult,inheritanceLink:null}}const r=(h=p.localTestValues)==null?void 0:h.readValue(s.id),a=p.getValueTypePreference(s.id);if(r&&!i&&(a===null||a!==Me.DefaultValue))return{value:r,valueOwner:s,type:Me.Testing,inheritanceLink:null};const c=s.defaultValue;let e=null;return c&&(i||a===null||a!==Me.Testing)&&(e={value:c,valueOwner:s,type:Me.DefaultValue,inheritanceLink:null}),kn((e==null?void 0:e.value)||null)?{value:null,valueOwner:s,type:Me.Empty,inheritanceLink:null}:e}function Df(s,p,i=!1){switch(s.type){case d.ArgumentDeclaration:return HVe(s,p,i);case d.InputMap:return zVe(s,p,i);case d.VariableDeclaration:return zx(s,p,i);case d.VariableInstance:return ZVe(s,p,i);case d.OutputMap:return WVe(s,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return Jx(s,p,i);case d.Property:return YVe(s,p,i);case d.ValueDescriptor:return JVe(s,p,i);case d.Operation:case d.FunctionCall:case d.InternalCall:case d.Search:return qVe(s,p,i);default:return null}}function sd(s,p,i=!1){switch(s.type){case d.InputMap:return Ng(s,p,i);case d.VariableDeclaration:return IE(s,p,i);case d.VariableInstance:return Yx(s,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return Jx(s,p,i);default:return null}}function eIi(s){var p;if(s&&s.type===Me.DefaultValue&&s.value&&s.valueOwner&&(!pI.includes(s.valueOwner.type)||((p=s.valueOwner.defaultValue)==null?void 0:p.id)===s.value.id)){const i=$t(s.valueOwner.getDataType(null),s.valueOwner,s.valueOwner.project);return{type:Me.DefaultValue,value:i,valueOwner:s.valueOwner,inheritanceLink:null}}return s}function Af(s,p,i,r){let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=s.parent;return p.getVariableDeclarations().forEach(m=>{var b,A,_,P,V,j;const E=m.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===f.id){let M=a?m.defaultValue:e==null?void 0:e.readValue(m.id);M?!a&&M&&M.id===((A=m.defaultValue)==null?void 0:A.id)&&(M=$t(m.getDataType(null),m,p)):a?M=ku(m.getDataType(null),m,p,c):M=$t(m.getDataType(null),m,p);const G=oe(s,p),q=s.codeName||((_=s.extends)==null?void 0:_.codeName)||((P=s.implements[0])==null?void 0:P.codeName)||Xi(G);let re={};((j=(V=m.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(re={...re,...m.dataType.entity.getActiveRawDefaultValue()}),br(M==null?void 0:M.value)&&(re={...re,...M.value}),re[q]=i,M==null||M.metaSync({value:re},c),a||e==null||e.writeValue(m,M);return}}),c}function tv(s,p,i,r){var _,P,V,j;let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=Er(s.parent),h=f.getDataType(null);if(!(h!=null&&h.isObject()))return c;let m=a?f.defaultValue:e==null?void 0:e.readValue(f.id);m?!a&&m&&m.id===((_=f.defaultValue)==null?void 0:_.id)&&(m=$t(f.getDataType(null),f,p)):a?m=ku(f.getDataType(null),f,p,c):m=$t(f.getDataType(null),f,p);const E=oe(s,p),b=s.codeName||((P=s.declaration)==null?void 0:P.codeName)||Xi(E);let A={};if(((j=(V=f.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(A={...A,...f.dataType.entity.getActiveRawDefaultValue()}),br(m==null?void 0:m.value)&&(A={...A,...m.value}),A[b]=i,m==null||m.metaSync({value:A},c),a||e==null||e.writeValue(f,m),(i===""||i===null||i===void 0)&&s.type===d.OutputMap){const M=f.inputs.find(G=>{var q,re;return((q=G.declaration)==null?void 0:q.id)===((re=s.declaration)==null?void 0:re.id)||oe(G,p)===E});if(M){let G=a?M.defaultValue:e==null?void 0:e.readValue(M.id);G&&G.metaSync({value:null},c),a||e==null||e.removeValue(M.id)}}return c}function QVe(s,p,i){var e,f,h,m,E;let r=!1,a=null,c=null;if(i instanceof S?(r=!0,a=i,c=null):(a=null,c=i),Lt.includes(s.type)){const b=Er(s);(e=b.dataType)!=null&&e.isObject()&&b.inputs.forEach(A=>{var _,P,V,j,M,G;if(((_=A.declaration)==null?void 0:_.type)===d.Property&&A.declaration.static){let q=r?((P=A.getDefaultValue)==null?void 0:P.call(A))||null:c==null?void 0:c.readValue(A.declaration.id);q?!r&&q&&q.id===((V=A.declaration.defaultValue)==null?void 0:V.id)&&(q=$t(A.declaration.getDataType(null),A.declaration,p)):r?q=ku(A.declaration.getDataType(null),A.declaration,p,a):q=$t(A.declaration.getDataType(null),A.declaration,p),q==null||q.metaSync({value:null},a),r||c==null||c.removeValue((j=A.declaration)==null?void 0:j.id)}else if(((M=A.declaration)==null?void 0:M.type)===d.Property){let q=r?((G=A.getDefaultValue)==null?void 0:G.call(A))||null:c==null?void 0:c.readValue(A.id);q&&q.metaSync({value:null},a),r||c==null||c.removeValue(A.id)}})}else s.type===d.InputMap?((f=s.declaration)==null?void 0:f.type)===d.Property&&s.declaration.static?Af(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((h=s.declaration)==null?void 0:h.type)===d.Property&&tv(s,p,null,i):s.type===d.OutputMap?((m=s.declaration)==null?void 0:m.type)===d.Property&&s.declaration.static?Af(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((E=s.declaration)==null?void 0:E.type)===d.Property&&tv(s,p,null,i):s.type===d.Property&&s.static&&Af(s,p,null,i);return a}function XVe(s,p,i,r){var f,h,m,E,b,A,_;let a=!1,c=null,e=null;if(r instanceof S?(a=!0,c=r,e=null):(c=null,e=r),Lt.includes(p.type)){const P=Er(p);if((f=P.dataType)!=null&&f.isObject()){let V={};((m=(h=P.dataType)==null?void 0:h.entity)==null?void 0:m.type)===d.DefinitionEntity&&(V={...V,...P.dataType.entity.getActiveRawDefaultValue()});const j=br(s)?s:V;P.inputs.forEach(M=>{var G,q,re,ee,se,te;if(((G=M.declaration)==null?void 0:G.type)===d.Property&&M.declaration.static){let le=a?((q=p.getDefaultValue)==null?void 0:q.call(p))||null:e==null?void 0:e.readValue(M.declaration.id);le?!a&&le&&le.id===((re=M.declaration.defaultValue)==null?void 0:re.id)&&(le=$t(M.declaration.getDataType(null),M.declaration,i)):a?le=ku(M.declaration.getDataType(null),M.declaration,i,c):le=$t(M.declaration.getDataType(null),M.declaration,i);const ue=oe(M,i),z=M.codeName||((ee=M.declaration)==null?void 0:ee.codeName)||Xi(ue),X=j[z];le==null||le.metaSync({value:X},c),a||e==null||e.writeValue(M.declaration,le)}else if(((se=M.declaration)==null?void 0:se.type)===d.Property){let le=a?((te=p.getDefaultValue)==null?void 0:te.call(p))||null:e==null?void 0:e.readValue(M.id);le&&le.metaSync({value:null},c),a||e==null||e.removeValue(M.id)}})}}else p.type===d.InputMap?((E=p.declaration)==null?void 0:E.type)===d.Property&&p.declaration.static?Af(p.declaration,i,s,r):Lt.includes(p.parent.type)&&((b=p.declaration)==null?void 0:b.type)===d.Property&&tv(p,i,s,r):p.type===d.OutputMap?((A=p.declaration)==null?void 0:A.type)===d.Property&&p.declaration.static?Af(p.declaration,i,null,r):Lt.includes(p.parent.type)&&((_=p.declaration)==null?void 0:_.type)===d.Property&&tv(p,i,null,r):p.type===d.Property&&p.static&&Af(p,i,s,r);return c}function tIi(s,p,i){const r=cd(s,p);let a=!1,c=null,e=null;return i instanceof S?(a=!0,c=i,e=null):(c=null,e=i),r.forEach(f=>{var m;let h=a?((m=f.getDefaultValue)==null?void 0:m.call(f))||null:e==null?void 0:e.readValue(f.id);a?h==null||h.remove({ignoreUpstream:!1},c):e==null||e.removeValue(f.id),QVe(f,p,i)}),c}function iIi(s,p,i,r){const a=cd(p,i);let c=!1,e=null,f=null;return r instanceof S?(c=!0,e=r,f=null):(e=null,f=r),i.diggestedBuiltInBaseEntitiesIds.has(p.id)||a.forEach(h=>{var E,b,A,_;if(i.diggestedBuiltInBaseEntitiesIds.has(h.id))return;let m=null;if(c){const P=((E=h.getDefaultValue)==null?void 0:E.call(h))||null;P&&(i.diggestedBuiltInBaseEntitiesIds.has(P.id)||((b=P.parent)==null?void 0:b.id)!==h.id?m=P.clone(e,h):m=P)}else m=f==null?void 0:f.readValue(h.id);m?!c&&m&&m.id===((_=(A=h.getDefaultValue)==null?void 0:A.call(h))==null?void 0:_.id)&&(m=$t(h.getDataType(null),h,i)):c?(m=ku(h.getDataType(null),h,i,e),e==null||e.add(m,W.Added)):m=$t(h.getDataType(null),h,i),m==null||m.setValueAsType(null,e),m==null||m.metaSync({value:s},e),c||f==null||f.writeValue(h,m),XVe(s,h,i,r)}),e}function gf(s,p,i,r){let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=s.parent;return p.getVariableDeclarations().forEach(m=>{var b,A,_,P,V,j;const E=m.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===f.id){let M=a?m.defaultValue:e==null?void 0:e.readValue(m.id);M?!a&&M&&M.id===((A=m.defaultValue)==null?void 0:A.id)&&(M=$t(m.getDataType(null),m,p)):a?M=ku(m.getDataType(null),m,p,c):M=$t(m.getDataType(null),m,p);const G=oe(s,p),q=s.codeName||((_=s.extends)==null?void 0:_.codeName)||((P=s.implements[0])==null?void 0:P.codeName)||Xi(G);let re={};((j=(V=m.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(re={...re,...m.dataType.entity.getActiveRawDefaultValue()}),br(M==null?void 0:M.value)&&(re={...re,...M.value}),Array.isArray(i)?re[q]=(i==null?void 0:i.map(ee=>ee.toShallowJSON()))||null:re[q]=(i==null?void 0:i.toShallowJSON())||null,M==null||M.metaSync({value:re},c),a||e==null||e.writeValue(m,M);return}}),c}function iv(s,p,i,r){var _,P,V,j;let a=!1,c=null,e=null;r instanceof S?(a=!0,c=r,e=null):(c=null,e=r);const f=Er(s.parent),h=f.getDataType(null);if(!(h!=null&&h.isObject()))return c;let m=a?f.defaultValue:e==null?void 0:e.readValue(f.id);m?!a&&m&&m.id===((_=f.defaultValue)==null?void 0:_.id)&&(m=$t(f.getDataType(null),f,p)):a?m=ku(f.getDataType(null),f,p,c):m=$t(f.getDataType(null),f,p);const E=oe(s,p),b=s.codeName||((P=s.declaration)==null?void 0:P.codeName)||Xi(E);let A={};if(((j=(V=f.dataType)==null?void 0:V.entity)==null?void 0:j.type)===d.DefinitionEntity&&(A={...A,...f.dataType.entity.getActiveRawDefaultValue()}),br(m==null?void 0:m.value)&&(A={...A,...m.value}),Array.isArray(i)?A[b]=(i==null?void 0:i.map(M=>M.toShallowJSON()))||null:A[b]=(i==null?void 0:i.toShallowJSON())||null,m==null||m.metaSync({value:A},c),a||e==null||e.writeValue(f,m),i==null&&s.type===d.OutputMap){const M=f.inputs.find(G=>{var q,re;return((q=G.declaration)==null?void 0:q.id)===((re=s.declaration)==null?void 0:re.id)||oe(G,p)===E});if(M){let G=a?M.defaultValue:e==null?void 0:e.readValue(M.id);G&&(Array.isArray(i)?G==null||G.setValueAsTypeList(i,c):G==null||G.setValueAsTypeSingle(i,c)),a||e==null||e.removeValue(M.id)}}return c}function ePe(s,p,i){var r,a,c,e;return s.type===d.InputMap?((r=s.declaration)==null?void 0:r.type)===d.Property&&s.declaration.static?gf(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((a=s.declaration)==null?void 0:a.type)===d.Property&&iv(s,p,null,i):s.type===d.OutputMap?((c=s.declaration)==null?void 0:c.type)===d.Property&&s.declaration.static?gf(s.declaration,p,null,i):Lt.includes(s.parent.type)&&((e=s.declaration)==null?void 0:e.type)===d.Property&&iv(s,p,null,i):s.type===d.Property&&s.static&&gf(s,p,null,i),i}function tPe(s,p,i,r){var a,c,e,f;return p.type===d.InputMap?((a=p.declaration)==null?void 0:a.type)===d.Property&&p.declaration.static?gf(p.declaration,i,s,r):Lt.includes(p.parent.type)&&((c=p.declaration)==null?void 0:c.type)===d.Property&&iv(p,i,s,r):p.type===d.OutputMap?((e=p.declaration)==null?void 0:e.type)===d.Property&&p.declaration.static?gf(p.declaration,i,null,r):Lt.includes(p.parent.type)&&((f=p.declaration)==null?void 0:f.type)===d.Property&&iv(p,i,null,r):p.type===d.Property&&p.static&&gf(p,i,s,r),r}function rIi(s,p,i){const r=cd(s,p);let a=!1,c=null,e=null;return i instanceof S?(a=!0,c=i,e=null):(c=null,e=i),r.forEach(f=>{var m;let h=a?(m=f.getDefaultValue)==null?void 0:m.call(f):e==null?void 0:e.readValue(f.id);a?h==null||h.remove({ignoreUpstream:!1},c):e==null||e.removeValue(f.id),ePe(f,p,i)}),c}function nIi(s,p,i,r){const a=cd(p,i);let c=!1,e=null,f=null;return r instanceof S?(c=!0,e=r,f=null):(e=null,f=r),a.forEach(h=>{var E,b,A;let m=c?(E=h.getDefaultValue)==null?void 0:E.call(h):f==null?void 0:f.readValue(h.id);m?!c&&m&&m.id===((A=(b=h.getDefaultValue)==null?void 0:b.call(h))==null?void 0:A.id)&&(m=$t(h.getDataType(null),h,h.project)):c?m=ku(h.getDataType(null),h,i,e):m=$t(h.getDataType(null),h,i),Array.isArray(s)?m==null||m.setValueAsTypeList(s,e):m==null||m.setValueAsTypeSingle(s,e),m==null||m.metaSync({value:null},e),c||f==null||f.writeValue(h,m),tPe(s,h,i,r)}),e}class E1{constructor(p,i){this.extensionsRegistry=p,this.contextType=i,this.off=this.extensionsRegistry.off.bind(this.extensionsRegistry),this.on=this.extensionsRegistry.on.bind(this.extensionsRegistry),this.emit=this.extensionsRegistry.emit.bind(this.extensionsRegistry),this.emitAsync=this.extensionsRegistry.emitAsync.bind(this.extensionsRegistry),this.emitAsyncAll=this.extensionsRegistry.emitAsyncAll.bind(this.extensionsRegistry),this.emitAsyncAllSettled=this.extensionsRegistry.emitAsyncAllSettled.bind(this.extensionsRegistry),this.emitAsyncSequentially=this.extensionsRegistry.emitAsyncSequentially.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAll=this.extensionsRegistry.emitAsyncSequentiallyAll.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAllSettled=this.extensionsRegistry.emitAsyncSequentiallyAllSettled.bind(this.extensionsRegistry)}on(p,i){this.extensionsRegistry.on(p,i)}emit(p,...i){this.extensionsRegistry.emit(p,...i)}off(p,i){this.extensionsRegistry.off(p,i)}emitAsync(p,...i){return this.extensionsRegistry.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.extensionsRegistry.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.extensionsRegistry.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.extensionsRegistry.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled(p,...i)}}var Oe=(s=>(s[s.High=1]="High",s[s.Normal=5]="Normal",s[s.Low=10]="Low",s))(Oe||{}),ae=(s=>(s.Logic="logic",s.EditorGUI="editor-gui",s.GUI="gui",s.Editor="editor",s.Compile="compile",s.PublicationRun="publication-run",s))(ae||{}),_e=(s=>(s.All="*",s.OnAll="on:*",s.EmitAll="emit:*",s.ReadAll="read:*",s.WriteAll="write:*",s.UpdateAll="update:*",s.DoAll="do:*",s.OnLogicAll="on:logic:*",s.EmitLogicAll="emit:logic:*",s.ReadLogicAll="read:logic:*",s.WriteLogicAll="write:logic:*",s.UpdateLogicAll="update:logic:*",s.DoLogicAll="do:logic:*",s.OnGUIAll="on:gui:*",s.EmitGUIAll="emit:gui:*",s.ReadGUIAll="read:gui:*",s.WriteGUIAll="write:gui:*",s.UpdateGUIAll="update:gui:*",s.DoGUIAll="do:gui:*",s.OnEditorAll="on:editor:*",s.EmitEditorAll="emit:editor:*",s.ReadEditorAll="read:editor:*",s.WriteEditorAll="write:editor:*",s.UpdateEditorAll="update:editor:*",s.DoEditorAll="do:editor:*",s.OnCompileBefore="on:compile:before:DefinitionEntity",s.OnCompileDefault="on:compile:default:DefinitionEntity",s.OnCompileAfter="on:compile:after:DefinitionEntity",s.EmitCompile="emit:compile:DefinitionEntity",s.DoEditorPublish="do:editor:publish",s.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",s.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",s.UpdateGUIGlobalTheme="update:gui:global:theme",s))(_e||{});class iPe{constructor(p){R(this,"state",new Map);p&&(this.state=new Map(Object.entries(p)))}get(p){return this.state.get(p)}set(p,i){this.state.set(p,i)}delete(p){this.state.delete(p)}}class rPe extends iPe{constructor(p,i){super(i),this.parentExtension=p}}class Pe{constructor(p,i){R(this,"manifest");R(this,"module");R(this,"state");this.extensionsRegistry=p,this.state=new rPe(this,i)}}class G_ extends E1{constructor(i,r){super(i,ae.Logic);R(this,"id");this._project=r,this.id=r.id}get type(){return this._project.type}get name(){return this._project.name}get description(){return this._project.description}get version(){return this._project.version}get createdAt(){return this._project.createdAt}get previousVersion(){return this._project.previousVersion}get author(){return this._project.author}get deleted(){return this._project.deleted}get editable(){return this._project.editable}get deletable(){return this._project.deletable}get entities(){return[...this._project.entities]}get projects(){return[...this._project.projects]}get functions(){return[...this._project.functions]}get events(){return[...this._project.events]}get variableDeclarations(){return[...this._project.variableDeclarations]}get variableInstances(){return[...this._project.variableInstances]}get conditions(){return[...this._project.conditions]}get operations(){return[...this._project.operations]}get functionCalls(){return[...this._project.functionCalls]}get loops(){return[...this._project.loops]}get searches(){return[...this._project.searches]}get primitives(){return[...this._project.primitives]}get builtInBaseEntities(){return[...this._project.builtInBaseEntities]}get operationDeclarations(){return[...this._project.operationDeclarations]}get globalEventActionDescriptors(){return[...this._project.globalEventActionDescriptors]}get loopDeclarations(){return[...this._project.loopDeclarations]}get loopDeclarationsBodies(){return[...this._project.loopDeclarationsBodies]}get conditionDeclarations(){return[...this._project.conditionDeclarations]}get valueDescriptors(){return[...this._project.valueDescriptors]}get dataTypes(){return[...this._project.dataTypes]}get errors(){return[...this._project.errors]}get history(){return[...this._project.history]}get undoableStackValueIndex(){return this._project.undoableStackValueIndex}get knownVersions(){return this._project.knownVersions}get activeVersion(){return this._project.activeVersion}get initialized(){return this._project.initialized}get startedInitialization(){return this._project.startedInitialization}closePersistChangeSetsSequentially(){return this._project.closePersistChangeSetsSequentially()}persistChangeSetSequentially(i){return this._project.persistChangeSetSequentially(i)}toLatestChangeSet(i,r,a,c=!1,e="here-this"){return this._project.toLatestChangeSet(i,r,a,c,e)}addChangeSet(i){return this._project.addChangeSet(i)}discardChangeSet(i){return this._project.discardChangeSet(i)}subscribeDependents(i){return this._project.subscribeDependents(i)}unsubscribeDependents(i){return this._project.unsubscribeDependents(i)}syncDependents(i){return this._project.syncDependents(i)}onDetachedDependencyRemoved(i,r,a){return this._project.onDetachedDependencyRemoved(i,r,a)}onDetachedDependencyRestored(i,r,a){return this._project.onDetachedDependencyRestored(i,r,a)}increaseVersion(i){return this._project.increaseVersion(i)}captureVersion(){return this._project.captureVersion()}restoreVersion(i){return this._project.restoreVersion(i)}updateWithShallowTransfer(i,r){return this._project.updateWithShallowTransfer(i,r)}hydrateAncestors(){return this._project.hydrateAncestors()}afterAllChildrenInitialized(i=null){return this._project.afterAllChildrenInitialized(i)}addSelfToProject(i){return this._project.addSelfToProject(i)}get instancesList(){return[...this._project.instancesList]}isOperationDeclaration(i){return this._project.isOperationDeclaration(i)}isGlobalEventActionDescriptor(i){return this._project.isGlobalEventActionDescriptor(i)}isLoopDeclaration(i){return this._project.isLoopDeclaration(i)}isConditionDeclaration(i){return this._project.isConditionDeclaration(i)}findSubscribedBuiltInInstance(i){return this._project.findSubscribedBuiltInInstance(i)}get(i){return this._project.get(i)}getDeleted(i){return this._project.getDeleted(i)}getManaged(i){return this._project.getManaged(i)}getBuiltIn(i){return this._project.getBuiltIn(i)}findSubscribedInstanceFromReference(i){return this._project.findSubscribedInstanceFromReference(i)}findSubscribedBuiltInInstanceFromReference(i){return this._project.findSubscribedBuiltInInstanceFromReference(i)}metaSync(i,r){return this._project.metaSync(i,r)}getAllBuiltInIds(){return this._project.getAllBuiltInIds()}getAllBuiltIn(){return this._project.getAllBuiltIn()}toFlat(i){return this._project.toFlat(i)}toFlatIds(i){return this._project.toFlatIds(i)}toMeta(){return this._project.toMeta()}toJSON(i){return this._project.toJSON(i)}toJSONClone(i){return this._project.toJSONClone(i)}toReference(i){return this._project.toReference(i)}toShallowJSON(i){return this._project.toShallowJSON(i)}toFlatJSON(i){return this._project.toFlatJSON(i)}toGenerationTarget(i){return this._project.toGenerationTarget(i)}toFlatGenerationTarget(i){return this._project.toFlatGenerationTarget(i)}clearErrors(){return this._project.clearErrors()}validate(){return this._project.validate()}validateChildren(){return this._project.validateChildren()}getErrors(){return this._project.getErrors()}getShallowErrors(){return this._project.getShallowErrors()}addDefinitionEntity(i){return this._project.addDefinitionEntity(i)}addFunctionDeclaration(i){return this._project.addFunctionDeclaration(i)}addFunctionCall(i){return this._project.addFunctionCall(i)}addVariableDeclaration(i){return this._project.addVariableDeclaration(i)}addVariableInstance(i){return this._project.addVariableInstance(i)}addInstalledProject(i){return this._project.addInstalledProject(i)}addGlobalEvent(i){return this._project.addGlobalEvent(i)}addCondition(i){return this._project.addCondition(i)}addOperation(i){return this._project.addOperation(i)}addLoop(i){return this._project.addLoop(i)}addSearch(i){return this._project.addSearch(i)}removeDefinitionEntity(i){return this._project.removeDefinitionEntity(i)}removeCondition(i){return this._project.removeCondition(i)}removeOperation(i){return this._project.removeOperation(i)}removeLoop(i){return this._project.removeLoop(i)}removeSearch(i){return this._project.removeSearch(i)}removeFunctionCall(i){return this._project.removeFunctionCall(i)}removeVariableInstance(i){return this._project.removeVariableInstance(i)}removeVariableDeclaration(i){return this._project.removeVariableDeclaration(i)}removeFunctionDeclaration(i){return this._project.removeFunctionDeclaration(i)}removeInstalledProject(i){return this._project.removeInstalledProject(i)}removeGlobalEvent(i){return this._project.removeGlobalEvent(i)}removeTopLevelVariableDeclaration(i){return this._project.removeTopLevelVariableDeclaration(i)}getEntryPoints(){return this._project.getEntryPoints()}getTerminationStatements(){return this._project.getTerminationStatements()}getFunctionDeclaration(i){return this._project.getFunctionDeclaration(i)}getConditions(){return this._project.getConditions()}getOperations(){return this._project.getOperations()}getVariables(){return this._project.getVariables()}getVariableInstances(){return this._project.getVariableInstances()}getVariableDeclarations(){return this._project.getVariableDeclarations()}getLoops(){return this._project.getLoops()}getSearches(){return this._project.getSearches()}getBuiltInPersistedEntity(){return this._project.getBuiltInPersistedEntity()}requestActiveDynamicValue(i,r=!1){return this._project.requestActiveDynamicValue(i,r)}undo(){return this._project.undo()}redo(){return this._project.redo()}applyExternalChangeSet(i){return this._project.applyExternalChangeSet(i)}toFullProjectTransfer(){return this._project.toFullProjectTransfer()}}function aIi(s,p){return p instanceof G_?p:new G_(s,p)}const uh="built-in-function-implementations__",$e="operations-implementations__",ls="conditions-implementations__",Ve={UUID:"uuid",SEARCH_NODE_IMPLEMENTATION:"search-node-implementation",BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION:uh+Br.AbortExecution,BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY:uh+Br.CreatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY:uh+Br.UpdatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY:uh+Br.DeletePersistedEntity,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY:$e+Ft.Empty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY:$e+Ft.NotEmpty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL:$e+Ft.PrimitiveEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL:$e+Ft.PrimitiveNotEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST:$e+Tn.HttpRequest,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SQL:$e+no.ExecuteSQL,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY:$e+Le.Validate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT:$e+hs.Wait,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN:$e+ye.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT:$e+ye.Split,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS:$e+ye.DeleteLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS:$e+ye.DeleteFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX:$e+ye.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX:$e+ye.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS:$e+ye.ReplaceFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS:$e+ye.ReplaceLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL:$e+ye.ReplaceAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX:$e+ye.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM:$e+ye.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST:$e+ye.GetFirst,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST:$e+ye.GetLast,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND:$e+ye.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND:$e+ye.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE:$e+ye.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH:$e+ye.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS:$e+ye.GetFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS:$e+ye.GetLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE:$e+ye.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT:$e+ye.Concat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF:$e+ye.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF:$e+ye.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE:$e+ye.Unique,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN:$e+ye.Flatten,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT:$e+ye.Sort,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE:$e+ye.Shuffle,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK:$e+ye.Chunk,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START:$e+ye.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END:$e+ye.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT:$e+ye.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH:$e+H.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE:$e+H.ToLowerCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE:$e+H.ToUpperCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN:$e+H.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS:$e+ye.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL:$e+ye.ContainsAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY:$e+ye.ContainsAny,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX:$e+H.SplitAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS:$e+H.SplitAtAllSeparators,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR:$e+H.SplitAtFirstSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR:$e+H.SplitAtLastSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS:$e+H.DeleteLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS:$e+H.DeleteFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX:$e+H.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX:$e+H.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS:$e+H.ReplaceFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS:$e+H.ReplaceLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX:$e+H.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH:$e+H.ReplaceFirstMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH:$e+H.ReplaceLastMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES:$e+H.ReplaceAllMatches,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM:$e+H.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS:$e+H.GetFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS:$e+H.GetLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF:$e+H.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND:$e+H.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND:$e+H.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE:$e+H.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM:$e+H.Trim,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START:$e+H.TrimStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END:$e+H.TrimEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING:$e+H.Substring,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE:$e+H.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START:$e+H.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END:$e+H.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT:$e+H.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF:$e+H.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX:$e+H.MatchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX:$e+H.MatchAllRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX:$e+H.SearchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX:$e+H.ReplaceRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE:$e+H.NormalizeUnicode,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS:$e+H.RemoveDiacritics,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES:$e+H.CountOccurrences,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX:$e+H.EnsurePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX:$e+H.EnsureSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX:$e+H.RemovePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX:$e+H.RemoveSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION:$e+ce.Addition,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION:$e+ce.Subtraction,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION:$e+ce.Multiplication,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION:$e+ce.Division,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER:$e+ce.Remainder,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION:$e+ce.Exponentiation,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE:$e+ce.Absolute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN:$e+ce.Sign,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND:$e+ce.Round,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE:$e+ce.Negate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR:$e+ce.Floor,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL:$e+ce.Ceil,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP:$e+ce.Clamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC:$e+ce.Trunc,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS:$e+ce.RoundToDecimals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP:$e+ce.SnapToStep,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE:$e+ce.MapRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE:$e+ce.Average,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN:$e+ce.Median,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF:$e+ce.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF:$e+ce.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT:$e+ce.SquareRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT:$e+ce.CubeRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT:$e+ce.NthRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP:$e+ce.Exp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL:$e+ce.LogNatural,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10:$e+ce.Log10,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN:$e+ce.Sin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS:$e+ce.Cos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN:$e+ce.Tan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN:$e+ce.Asin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS:$e+ce.Acos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN:$e+ce.Atan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2:$e+ce.Atan2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS:$e+ce.ToRadians,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES:$e+ce.ToDegrees,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF:$e+ce.PercentOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE:$e+ce.PercentageChange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN:$e+ce.MoreThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN:$e+ce.LessThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL:$e+ce.LessThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL:$e+ce.MoreThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER:$e+nt.GenerateRandomInteger,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT:$e+nt.GenerateRandomFloat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL:$e+nt.GenerateRandomHexadecimal,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62:$e+nt.GenerateRandomBase62,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64:$e+nt.GenerateRandomBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC:$e+nt.GenerateRandomAlphanumeric,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER:$e+nt.GenerateIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4:$e+nt.GenerateRandomUUIDv4,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER:$e+nt.GenerateShortIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN:$e+nt.GenerateHexadecimalToken,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH:$e+H.StartsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH:$e+H.EndsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS:$e+H.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX:$e+H.MatchesRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP:$e+K.GetCurrentTimestamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE:$e+K.FormatDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE:$e+K.ParseDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE:$e+K.AddToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE:$e+K.SubtractFromDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES:$e+K.DifferenceBetweenDates,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE:$e+K.ToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX:$e+K.ToUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX:$e+K.FromUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING:$e+K.ToISOString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR:$e+K.GetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH:$e+K.GetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE:$e+K.GetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR:$e+K.GetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE:$e+K.GetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND:$e+K.GetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND:$e+K.GetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY:$e+K.GetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR:$e+K.GetWeekOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER:$e+K.GetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR:$e+K.GetDayOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH:$e+K.GetDaysInMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE:$e+K.GetCurrentIanaTimeZone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR:$e+K.SetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH:$e+K.SetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE:$e+K.SetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR:$e+K.SetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE:$e+K.SetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND:$e+K.SetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND:$e+K.SetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY:$e+K.SetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER:$e+K.SetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF:$e+K.StartOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF:$e+K.EndOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO:$e+K.RoundTo,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE:ls+K.IsBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER:ls+K.IsAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME:ls+K.IsSame,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE:ls+K.IsSameOrBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER:ls+K.IsSameOrAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN:ls+K.IsBetween,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID:ls+K.IsValid,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR:ls+K.IsLeapYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE:$e+K.ClampToRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF:$e+K.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF:$e+K.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW:$e+K.FromNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW:$e+K.ToNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF:$e+K.HumanizeDiff,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS:$e+K.AddBusinessDays,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY:$e+K.NextWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY:$e+K.PreviousWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC:$e+K.ToUTC,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE:$e+K.ConvertTimezone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET:$e+K.GetTimezoneOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET:$e+K.SetUTCOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY:$e+Le.ReadKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY:$e+Le.WriteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY:$e+Le.DeleteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY:$e+Le.ReadNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY:$e+Le.WriteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY:$e+Le.DeleteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY:$e+Le.WriteSafeNestedKeyRecursively,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY:ls+Le.HasKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY:ls+Le.HasNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS:ls+Le.KeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS:ls+Le.NestedKeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE:ls+Le.IsInstanceOfType,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE:$e+Le.Merge,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS:$e+Le.Keys,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES:$e+Le.Values,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES:$e+Le.Entries,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF:$e+Xe.GetTypeOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH:$e+xi.Hash,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC:$e+xi.Hmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES:$e+nt.GenerateRandomBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL:$e+xi.ConstantTimeEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2:$e+xi.DeriveKeyPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2:$e+En.HashPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2:$e+En.VerifyPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC:$e+cr.BuildJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC:$e+cr.VerifyJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE:$e+cr.DecodeJwt,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING:$e+Xe.FromBytesToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES:$e+Xe.ToBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER:$e+Xe.ToNumber,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING:$e+Xe.ToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64:$e+Xe.EncodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64:$e+Xe.DecodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL:$e+Xe.EncodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL:$e+Xe.DecodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX:$e+Xe.EncodeHex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX:$e+Xe.DecodeHex,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE:$e+vn.Parse,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY:$e+vn.Stringify};class nPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION,version:"1.0.0",description:'Implementation for the built-in function "Abort Execution". It terminates the execution of the current entity being run.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class aPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Delete Persisted Entity". It deletes the current entity as an entry in the persisted storage.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class sPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Create Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class lPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Update Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null})})}}class oPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.SEARCH_NODE_IMPLEMENTATION,version:"1.0.0",description:"Implementation for search nodes when they get executed and query data.",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Editor]});R(this,"module",{main:async(i,r)=>({error:"Search module not implemented",data:null})})}}class dPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.UUID,version:"1.0.0",description:"UUID generation module, for all contexts and runtimes",initPriority:Oe.High,permissions:[_e.All],contexts:[]});R(this,"module",IV)}}const uPe=s=>s.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class pPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY,version:"1.0.0",description:"Comparison: Empty (!value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.Empty);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=uPe(r),c=!a;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class cPe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY,version:"1.0.0",description:"Comparison: NotEmpty (!!value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.NotEmpty);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=uPe(r),c=!!a;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}const nI=class nI extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveEqual (typed equality / deep JSON equality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.PrimitiveEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const E=(c=(a=r[0])==null?void 0:a.value)==null?void 0:c.name,b=(f=(e=r[0])==null?void 0:e.value)==null?void 0:f.value,A=(m=(h=r[1])==null?void 0:h.value)==null?void 0:m.value;let _=!1;return E&&nI.primitiveSet.has(E)?_=b===A:E===fe.Untyped||E===fe.KeyValue?_=JSON.stringify(b)===JSON.stringify(A):_=!1,{value:U.Success,error:null,result:_}}catch(E){return{value:U.UnhandledError,error:E,result:null}}}})}};R(nI,"primitiveSet",new Set([fe.String,fe.Number,fe.Boolean,fe.Null,fe.Enum,fe.Date,fe.UUID]));let xg=nI;const aI=class aI extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveNotEqual (typed inequality / deep JSON inequality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Ft.PrimitiveNotEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m;try{const E=(c=(a=r[0])==null?void 0:a.value)==null?void 0:c.name,b=(f=(e=r[0])==null?void 0:e.value)==null?void 0:f.value,A=(m=(h=r[1])==null?void 0:h.value)==null?void 0:m.value;let _=!1;return E&&aI.primitiveSet.has(E)?_=b!==A:E===fe.Untyped||E===fe.KeyValue?_=JSON.stringify(b)!==JSON.stringify(A):_=!1,{value:U.Success,error:null,result:_}}catch(E){return{value:U.UnhandledError,error:E,result:null}}}})}};R(aI,"primitiveSet",new Set([fe.String,fe.Number,fe.Boolean,fe.Null,fe.Enum,fe.Date,fe.UUID]));let $g=aI;var fPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="minute",r=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g;return function(c,e,f){var h=e.prototype;f.utc=function(V){var j={date:V,utc:!0,args:arguments};return new e(j)},h.utc=function(V){var j=f(this.toDate(),{locale:this.$L,utc:!0});return V?j.add(this.utcOffset(),i):j},h.local=function(){return f(this.toDate(),{locale:this.$L,utc:!1})};var m=h.parse;h.parse=function(V){V.utc&&(this.$u=!0),this.$utils().u(V.$offset)||(this.$offset=V.$offset),m.call(this,V)};var E=h.init;h.init=function(){if(this.$u){var V=this.$d;this.$y=V.getUTCFullYear(),this.$M=V.getUTCMonth(),this.$D=V.getUTCDate(),this.$W=V.getUTCDay(),this.$H=V.getUTCHours(),this.$m=V.getUTCMinutes(),this.$s=V.getUTCSeconds(),this.$ms=V.getUTCMilliseconds()}else E.call(this)};var b=h.utcOffset;h.utcOffset=function(V,j){var M=this.$utils().u;if(M(V))return this.$u?0:M(this.$offset)?b.call(this):this.$offset;if(typeof V=="string"&&(V=function(ee){ee===void 0&&(ee="");var se=ee.match(r);if(!se)return null;var te=(""+se[0]).match(a)||["-",0,0],le=te[0],ue=60*+te[1]+ +te[2];return ue===0?0:le==="+"?ue:-ue}(V),V===null))return this;var G=Math.abs(V)<=16?60*V:V;if(G===0)return this.utc(j);var q=this.clone();if(j)return q.$offset=G,q.$u=!1,q;var re=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(q=this.local().add(G+re,i)).$offset=G,q.$x.$localOffset=re,q};var A=h.format;h.format=function(V){var j=V||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return A.call(this,j)},h.valueOf=function(){var V=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*V},h.isUTC=function(){return!!this.$u},h.toISOString=function(){return this.toDate().toISOString()},h.toString=function(){return this.toDate().toUTCString()};var _=h.toDate;h.toDate=function(V){return V==="s"&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():_.call(this)};var P=h.diff;h.diff=function(V,j,M){if(V&&this.$u===V.$u)return P.call(this,V,j,M);var G=this.local(),q=f(V).local();return P.call(G,q,j,M)}}})})(fPe);var sIi=fPe.exports;const lIi=Cs(sIi);var yPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(a,c,e){var f,h=function(A,_,P){P===void 0&&(P={});var V=new Date(A),j=function(M,G){G===void 0&&(G={});var q=G.timeZoneName||"short",re=M+"|"+q,ee=r[re];return ee||(ee=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:q}),r[re]=ee),ee}(_,P);return j.formatToParts(V)},m=function(A,_){for(var P=h(A,_),V=[],j=0;j<P.length;j+=1){var M=P[j],G=M.type,q=M.value,re=i[G];re>=0&&(V[re]=parseInt(q,10))}var ee=V[3],se=ee===24?0:ee,te=V[0]+"-"+V[1]+"-"+V[2]+" "+se+":"+V[4]+":"+V[5]+":000",le=+A;return(e.utc(te).valueOf()-(le-=le%1e3))/6e4},E=c.prototype;E.tz=function(A,_){A===void 0&&(A=f);var P,V=this.utcOffset(),j=this.toDate(),M=j.toLocaleString("en-US",{timeZone:A}),G=Math.round((j-new Date(M))/1e3/60),q=15*-Math.round(j.getTimezoneOffset()/15)-G;if(!Number(q))P=this.utcOffset(0,_);else if(P=e(M,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(q,!0),_){var re=P.utcOffset();P=P.add(V-re,"minute")}return P.$x.$timezone=A,P},E.offsetName=function(A){var _=this.$x.$timezone||e.tz.guess(),P=h(this.valueOf(),_,{timeZoneName:A}).find(function(V){return V.type.toLowerCase()==="timezonename"});return P&&P.value};var b=E.startOf;E.startOf=function(A,_){if(!this.$x||!this.$x.$timezone)return b.call(this,A,_);var P=e(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return b.call(P,A,_).tz(this.$x.$timezone,!0)},e.tz=function(A,_,P){var V=P&&_,j=P||_||f,M=m(+e(),j);if(typeof A!="string")return e(A).tz(j);var G=function(se,te,le){var ue=se-60*te*1e3,z=m(ue,le);if(te===z)return[ue,te];var X=m(ue-=60*(z-te)*1e3,le);return z===X?[ue,z]:[se-60*Math.min(z,X)*1e3,Math.max(z,X)]}(e.utc(A,V).valueOf(),M,j),q=G[0],re=G[1],ee=e(q).utcOffset(re);return ee.$x.$timezone=j,ee},e.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},e.tz.setDefault=function(A){f=A}}})})(yPe);var oIi=yPe.exports;const dIi=Cs(oIi);var hPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r,a){r.prototype.isBetween=function(c,e,f,h){var m=a(c),E=a(e),b=(h=h||"()")[0]==="(",A=h[1]===")";return(b?this.isAfter(m,f):!this.isBefore(m,f))&&(A?this.isBefore(E,f):!this.isAfter(E,f))||(b?this.isBefore(m,f):!this.isAfter(m,f))&&(A?this.isAfter(E,f):!this.isBefore(E,f))}}})})(hPe);var uIi=hPe.exports;const pIi=Cs(uIi);var mPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r){r.prototype.isSameOrAfter=function(a,c){return this.isSame(a,c)||this.isAfter(a,c)}}})})(mPe);var cIi=mPe.exports;const fIi=Cs(cIi);var TPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r){r.prototype.isSameOrBefore=function(a,c){return this.isSame(a,c)||this.isBefore(a,c)}}})})(TPe);var yIi=TPe.exports;const hIi=Cs(yIi);var vPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="week",r="year";return function(a,c,e){var f=c.prototype;f.week=function(h){if(h===void 0&&(h=null),h!==null)return this.add(7*(h-this.week()),"day");var m=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var E=e(this).startOf(r).add(1,r).date(m),b=e(this).endOf(i);if(E.isBefore(b))return 1}var A=e(this).startOf(r).date(m).startOf(i).subtract(1,"millisecond"),_=this.diff(A,i,!0);return _<0?e(this).startOf("week").week():Math.ceil(_)},f.weeks=function(h){return h===void 0&&(h=null),this.week(h)}}})})(vPe);var mIi=vPe.exports;const TIi=Cs(mIi);var EPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="day";return function(r,a,c){var e=function(m){return m.add(4-m.isoWeekday(),i)},f=a.prototype;f.isoWeekYear=function(){return e(this).year()},f.isoWeek=function(m){if(!this.$utils().u(m))return this.add(7*(m-this.isoWeek()),i);var E,b,A,_,P=e(this),V=(E=this.isoWeekYear(),b=this.$u,A=(b?c.utc:c)().year(E).startOf("year"),_=4-A.isoWeekday(),A.isoWeekday()>4&&(_+=7),A.add(_,i));return P.diff(V,"week")+1},f.isoWeekday=function(m){return this.$utils().u(m)?this.day()||7:this.day(this.day()%7?m:m-7)};var h=f.startOf;f.startOf=function(m,E){var b=this.$utils(),A=!!b.u(E)||E;return b.p(m)==="isoweek"?A?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):h.bind(this)(m,E)}}})})(EPe);var vIi=EPe.exports;const EIi=Cs(vIi);var bPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i="month",r="quarter";return function(a,c){var e=c.prototype;e.quarter=function(m){return this.$utils().u(m)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(m-1))};var f=e.add;e.add=function(m,E){return m=Number(m),this.$utils().p(E)===r?this.add(3*m,i):f.bind(this)(m,E)};var h=e.startOf;e.startOf=function(m,E){var b=this.$utils(),A=!!b.u(E)||E;if(b.p(m)===r){var _=this.quarter()-1;return A?this.month(3*_).startOf(i).startOf("day"):this.month(3*_+2).endOf(i).endOf("day")}return h.bind(this)(m,E)}}})})(bPe);var bIi=bPe.exports;const AIi=Cs(bIi);var APe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r,a){r.prototype.dayOfYear=function(c){var e=Math.round((a(this).startOf("day")-a(this).startOf("year"))/864e5)+1;return c==null?e:this.add(c-e,"day")}}})})(APe);var gIi=APe.exports;const IIi=Cs(gIi);var gPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r,a){i=i||{};var c=r.prototype,e={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function f(m,E,b,A){return c.fromToBase(m,E,b,A)}a.en.relativeTime=e,c.fromToBase=function(m,E,b,A,_){for(var P,V,j,M=b.$locale().relativeTime||e,G=i.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],q=G.length,re=0;re<q;re+=1){var ee=G[re];ee.d&&(P=A?a(m).diff(b,ee.d,!0):b.diff(m,ee.d,!0));var se=(i.rounding||Math.round)(Math.abs(P));if(j=P>0,se<=ee.r||!ee.r){se<=1&&re>0&&(ee=G[re-1]);var te=M[ee.l];_&&(se=_(""+se)),V=typeof te=="string"?te.replace("%d",se):te(se,E,ee.l,j);break}}if(E)return V;var le=j?M.future:M.past;return typeof le=="function"?le(V):le.replace("%s",V)},c.to=function(m,E){return f(m,E,this,!0)},c.from=function(m,E){return f(m,E,this)};var h=function(m){return m.$u?a.utc():a()};c.toNow=function(m){return this.to(h(this),m)},c.fromNow=function(m){return this.from(h(this),m)}}})})(gPe);var RIi=gPe.exports;const DIi=Cs(RIi);var IPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){var i,r,a=1e3,c=6e4,e=36e5,f=864e5,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,m=31536e6,E=2628e6,b=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,A={years:m,months:E,days:f,hours:e,minutes:c,seconds:a,milliseconds:1,weeks:6048e5},_=function(se){return se instanceof re},P=function(se,te,le){return new re(se,le,te.$l)},V=function(se){return r.p(se)+"s"},j=function(se){return se<0},M=function(se){return j(se)?Math.ceil(se):Math.floor(se)},G=function(se){return Math.abs(se)},q=function(se,te){return se?j(se)?{negative:!0,format:""+G(se)+te}:{negative:!1,format:""+se+te}:{negative:!1,format:""}},re=function(){function se(le,ue,z){var X=this;if(this.$d={},this.$l=z,le===void 0&&(this.$ms=0,this.parseFromMilliseconds()),ue)return P(le*A[V(ue)],this);if(typeof le=="number")return this.$ms=le,this.parseFromMilliseconds(),this;if(typeof le=="object")return Object.keys(le).forEach(function(me){X.$d[V(me)]=le[me]}),this.calMilliseconds(),this;if(typeof le=="string"){var pe=le.match(b);if(pe){var de=pe.slice(2).map(function(me){return me!=null?Number(me):0});return this.$d.years=de[0],this.$d.months=de[1],this.$d.weeks=de[2],this.$d.days=de[3],this.$d.hours=de[4],this.$d.minutes=de[5],this.$d.seconds=de[6],this.calMilliseconds(),this}}return this}var te=se.prototype;return te.calMilliseconds=function(){var le=this;this.$ms=Object.keys(this.$d).reduce(function(ue,z){return ue+(le.$d[z]||0)*A[z]},0)},te.parseFromMilliseconds=function(){var le=this.$ms;this.$d.years=M(le/m),le%=m,this.$d.months=M(le/E),le%=E,this.$d.days=M(le/f),le%=f,this.$d.hours=M(le/e),le%=e,this.$d.minutes=M(le/c),le%=c,this.$d.seconds=M(le/a),le%=a,this.$d.milliseconds=le},te.toISOString=function(){var le=q(this.$d.years,"Y"),ue=q(this.$d.months,"M"),z=+this.$d.days||0;this.$d.weeks&&(z+=7*this.$d.weeks);var X=q(z,"D"),pe=q(this.$d.hours,"H"),de=q(this.$d.minutes,"M"),me=this.$d.seconds||0;this.$d.milliseconds&&(me+=this.$d.milliseconds/1e3,me=Math.round(1e3*me)/1e3);var ve=q(me,"S"),we=le.negative||ue.negative||X.negative||pe.negative||de.negative||ve.negative,Re=pe.format||de.format||ve.format?"T":"",xe=(we?"-":"")+"P"+le.format+ue.format+X.format+Re+pe.format+de.format+ve.format;return xe==="P"||xe==="-P"?"P0D":xe},te.toJSON=function(){return this.toISOString()},te.format=function(le){var ue=le||"YYYY-MM-DDTHH:mm:ss",z={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return ue.replace(h,function(X,pe){return pe||String(z[X])})},te.as=function(le){return this.$ms/A[V(le)]},te.get=function(le){var ue=this.$ms,z=V(le);return z==="milliseconds"?ue%=1e3:ue=z==="weeks"?M(ue/A[z]):this.$d[z],ue||0},te.add=function(le,ue,z){var X;return X=ue?le*A[V(ue)]:_(le)?le.$ms:P(le,this).$ms,P(this.$ms+X*(z?-1:1),this)},te.subtract=function(le,ue){return this.add(le,ue,!0)},te.locale=function(le){var ue=this.clone();return ue.$l=le,ue},te.clone=function(){return P(this.$ms,this)},te.humanize=function(le){return i().add(this.$ms,"ms").locale(this.$l).fromNow(!le)},te.valueOf=function(){return this.asMilliseconds()},te.milliseconds=function(){return this.get("milliseconds")},te.asMilliseconds=function(){return this.as("milliseconds")},te.seconds=function(){return this.get("seconds")},te.asSeconds=function(){return this.as("seconds")},te.minutes=function(){return this.get("minutes")},te.asMinutes=function(){return this.as("minutes")},te.hours=function(){return this.get("hours")},te.asHours=function(){return this.as("hours")},te.days=function(){return this.get("days")},te.asDays=function(){return this.as("days")},te.weeks=function(){return this.get("weeks")},te.asWeeks=function(){return this.as("weeks")},te.months=function(){return this.get("months")},te.asMonths=function(){return this.as("months")},te.years=function(){return this.get("years")},te.asYears=function(){return this.as("years")},se}(),ee=function(se,te,le){return se.add(te.years()*le,"y").add(te.months()*le,"M").add(te.days()*le,"d").add(te.hours()*le,"h").add(te.minutes()*le,"m").add(te.seconds()*le,"s").add(te.milliseconds()*le,"ms")};return function(se,te,le){i=le,r=le().$utils(),le.duration=function(X,pe){var de=le.locale();return P(X,{$l:de},pe)},le.isDuration=_;var ue=te.prototype.add,z=te.prototype.subtract;te.prototype.add=function(X,pe){return _(X)?ee(this,X,1):ue.bind(this)(X,pe)},te.prototype.subtract=function(X,pe){return _(X)?ee(this,X,-1):z.bind(this)(X,pe)}}})})(IPe);var wIi=IPe.exports;const CIi=Cs(wIi);var RPe={exports:{}};(function(s,p){(function(i,r){s.exports=r()})(Yr,function(){return function(i,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(RPe);var OIi=RPe.exports;const _Ii=Cs(OIi);B.extend(lIi);B.extend(dIi);B.extend(pIi);B.extend(fIi);B.extend(hIi);B.extend(TIi);B.extend(EIi);B.extend(AIi);B.extend(IIi);B.extend(DIi);B.extend(CIi);B.extend(_Ii);const Nt=s=>B(s),Tr=s=>s.toISOString();function DPe(){return Tr(B())}function wPe(s,p){return Nt(s).format(p)}function CPe(s){return Tr(B(s))}function OPe(s){if(s==null)throw new TypeError("ToDate expects a non-null value.");if(typeof s=="string"){const p=B(s);if(!p.isValid())throw new TypeError("Invalid date string.");return p.toISOString()}if(typeof s=="number"&&Number.isFinite(s)){const p=Math.abs(s)<1e12?B.unix(s):B(s);if(!p.isValid())throw new TypeError("Invalid numeric timestamp.");return p.toISOString()}if(s instanceof Date){const p=B(s);if(!p.isValid())throw new TypeError("Invalid Date object.");return p.toISOString()}throw new TypeError("Unsupported value type for ToDate. Provide a string, number, or Date.")}function _Pe(s,p,i){return Tr(Nt(s).add(p,i))}function VPe(s,p,i){return Tr(Nt(s).subtract(p,i))}function PPe(s,p,i,r=!1){return Nt(s).diff(Nt(p),i,r)}function NPe(s){return Nt(s).unix()}function xPe(s){return Tr(B.unix(s))}function $Pe(s){return Tr(Nt(s))}function LPe(s){return Nt(s).year()}function BPe(s){return Nt(s).month()}function MPe(s){return Nt(s).date()}function GPe(s){return Nt(s).hour()}function jPe(s){return Nt(s).minute()}function kPe(s){return Nt(s).second()}function UPe(s){return Nt(s).millisecond()}function FPe(s){return Nt(s).isoWeekday()}function KPe(s){return Nt(s).week()}function qPe(s){return Nt(s).quarter()}function SPe(s){return Nt(s).dayOfYear()}function ZPe(s){return Nt(s).daysInMonth()}function HPe(s,p){return Tr(Nt(s).year(p))}function WPe(s,p){return Tr(Nt(s).month(p))}function zPe(s,p){return Tr(Nt(s).date(p))}function YPe(s,p){return Tr(Nt(s).hour(p))}function JPe(s,p){return Tr(Nt(s).minute(p))}function QPe(s,p){return Tr(Nt(s).second(p))}function XPe(s,p){return Tr(Nt(s).millisecond(p))}function eNe(s,p){return Tr(Nt(s).isoWeekday(p))}function tNe(s,p){return Tr(Nt(s).quarter(p))}function iNe(s,p){return Tr(Nt(s).startOf(p))}function rNe(s,p){return Tr(Nt(s).endOf(p))}function nNe(s,p){const i=Nt(s),r=i.startOf(p),a=i.endOf(p),c=r.valueOf()+(a.valueOf()-r.valueOf())/2;return Tr(i.valueOf()<c?r:a)}function aNe(s,p,i){return Nt(s).isBefore(Nt(p),i)}function sNe(s,p,i){return Nt(s).isAfter(Nt(p),i)}function lNe(s,p,i){return Nt(s).isSame(Nt(p),i)}function oNe(s,p,i){return Nt(s).isSameOrBefore(Nt(p),i)}function dNe(s,p,i){return Nt(s).isSameOrAfter(Nt(p),i)}function uNe(s,p,i,r,a="()"){return Nt(s).isBetween(Nt(p),Nt(i),r,a)}function pNe(s){return B(s).isValid()}function cNe(s){return Nt(s).isLeapYear()}function fNe(s,p,i){const r=Nt(s);return r.isBefore(p)?Tr(Nt(p)):r.isAfter(i)?Tr(Nt(i)):Tr(r)}function yNe(s){if(s.length===0)throw new Error("minOf requires at least one date");let p=Nt(s[0]);for(let i=1;i<s.length;i++){const r=Nt(s[i]);r.isBefore(p)&&(p=r)}return Tr(p)}function hNe(s){if(s.length===0)throw new Error("maxOf requires at least one date");let p=Nt(s[0]);for(let i=1;i<s.length;i++){const r=Nt(s[i]);r.isAfter(p)&&(p=r)}return Tr(p)}function mNe(s,p=!1){return Nt(s).fromNow(p)}function TNe(s,p=!1){return Nt(s).toNow(p)}function vNe(s,p,i=!0){const r=Nt(s).diff(Nt(p),"millisecond",!0),a=Math.abs(r),e=B.duration(a,"milliseconds").humanize();return i?r>=0?`in ${e}`:`${e} ago`:e}function ENe(s,p,i=["6","7"],r=[]){const a=m=>r.some(E=>Nt(E).isSame(m,"day")),c=m=>((m.day()+6)%7+1).toString();let e=Nt(s);const f=p>=0?1:-1;let h=Math.abs(p);for(;h>0;){e=e.add(f,"day");const m=c(e);!i.includes(m)&&!a(e)&&h--}return Tr(e)}function bNe(s,p){let i=Nt(s);const r=p;for(let a=0;a<7;a++)if(i=i.add(1,"day"),i.isoWeekday()===r)return Tr(i);return Tr(i)}function ANe(s,p){let i=Nt(s);const r=p;for(let a=0;a<7;a++)if(i=i.subtract(1,"day"),i.isoWeekday()===r)return Tr(i);return Tr(i)}const gNe="Local";function Qx(){try{const s=Intl.DateTimeFormat().resolvedOptions().timeZone;if(s&&typeof s=="string")return s}catch{}try{if(typeof process<"u"&&process.env&&process.env.TZ)return process.env.TZ}catch{}return null}function Xx(){const s=Qx();if(s)return s;throw new Error("Unable to detect current IANA timezone from host environment.")}function INe(s,p,i=!1){let r=p;if(r===gNe){const e=Qx();if(!e)throw new Error("Unable to detect current timezone from host environment.");r=e}const a=r?B.tz(s,r):Nt(s),c=i?a.utc(!0):a.utc();return Tr(c)}function RNe(s,p,i=!1){const r=Nt(s);return Tr(i?r.tz(p,!0):r.tz(p))}function DNe(s,p){const i=s===gNe?Xx():s;return Nt(p).tz(i).utcOffset()}function wNe(s,p,i=!1){return Tr(Nt(s).utcOffset(p,i))}class CNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP,version:"1.0.0",description:"Date get current timestamp operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetCurrentTimestamp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=DPe();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ONe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE,version:"1.0.0",description:"Date format operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.FormatDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=wPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _Ne extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE,version:"1.0.0",description:"Date parse operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ParseDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=CPe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE,version:"1.0.0",description:"Date add-to-date operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.AddToDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=_Pe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class PNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE,version:"1.0.0",description:"Date subtract-from-date operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SubtractFromDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=VPe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class NNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES,version:"1.0.0",description:"Date difference-between-dates operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.DifferenceBetweenDates);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2],h=a[3]??!1,m=PPe(c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VIi extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE,version:"1.0.0",description:"Date to-date operation implementation module (coerce to ISO 8601 string)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=OPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class xNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX,version:"1.0.0",description:"Date to-unix operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToUnix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=NPe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class $Ne extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX,version:"1.0.0",description:"Date from-unix operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.FromUnix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=xPe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class LNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING,version:"1.0.0",description:"Date to-iso-string operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToISOString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=$Pe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class BNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR,version:"1.0.0",description:"Date get-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=LPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class MNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH,version:"1.0.0",description:"Date get-month (0-based) operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetMonth);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=BPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class GNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE,version:"1.0.0",description:"Date get-date (day of month) operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=MPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class jNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR,version:"1.0.0",description:"Date get-hour operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetHour);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=GPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class kNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE,version:"1.0.0",description:"Date get-minute operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetMinute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=jPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class UNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND,version:"1.0.0",description:"Date get-second operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetSecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=kPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class FNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND,version:"1.0.0",description:"Date get-millisecond operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetMillisecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=UPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class KNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY,version:"1.0.0",description:"Date get-iso-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetIsoWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=FPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class qNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR,version:"1.0.0",description:"Date get-week-of-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetWeekOfYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=KPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class SNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER,version:"1.0.0",description:"Date get-quarter operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetQuarter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=qPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ZNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR,version:"1.0.0",description:"Date get-day-of-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetDayOfYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=SPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class HNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH,version:"1.0.0",description:"Date get-days-in-month operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetDaysInMonth);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=ZPe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class WNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE,version:"1.0.0",description:"Date get-current-iana-timezone operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetCurrentIanaTimeZone);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=Xx();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class zNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR,version:"1.0.0",description:"Date set-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=HPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class YNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH,version:"1.0.0",description:"Date set-month operation implementation module (0-based month)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetMonth);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=WPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class JNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE,version:"1.0.0",description:"Date set-date (day of month) operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetDate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=zPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class QNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR,version:"1.0.0",description:"Date set-hour operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetHour);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=YPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class XNe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE,version:"1.0.0",description:"Date set-minute operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetMinute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=JPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class exe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND,version:"1.0.0",description:"Date set-second operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetSecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=QPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class txe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND,version:"1.0.0",description:"Date set-millisecond operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetMillisecond);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=XPe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ixe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY,version:"1.0.0",description:"Date set-iso-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetIsoWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=eNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class rxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER,version:"1.0.0",description:"Date set-quarter operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetQuarter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=tNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class nxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF,version:"1.0.0",description:"Date start-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.StartOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=iNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class axe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF,version:"1.0.0",description:"Date end-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.EndOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=rNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class sxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO,version:"1.0.0",description:"Date round-to operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.RoundTo);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=nNe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class lxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE,version:"1.0.0",description:"Date is-before operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsBefore);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=aNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class oxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER,version:"1.0.0",description:"Date is-after operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsAfter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=sNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class dxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME,version:"1.0.0",description:"Date is-same operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsSame);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=lNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE,version:"1.0.0",description:"Date is-same-or-before operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsSameOrBefore);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=oNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class pxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER,version:"1.0.0",description:"Date is-same-or-after operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsSameOrAfter);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=dNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class cxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN,version:"1.0.0",description:"Date is-between operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsBetween);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(b=>{var A,_;return((A=b.value)==null?void 0:A.valueAsType)||((_=b.value)==null?void 0:_.value)}),c=a[0],e=a[1],f=a[2],h=a[3],m=a[4],E=uNe(c,e,f,h,m??void 0);return{value:U.Success,error:null,result:E}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class fxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID,version:"1.0.0",description:"Date is-valid operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsValid);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=pNe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class yxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR,version:"1.0.0",description:"Date is-leap-year operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.IsLeapYear);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)}),c=cNe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class hxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE,version:"1.0.0",description:"Date clamp-to-range operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ClampToRange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=fNe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class mxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF,version:"1.0.0",description:"Date min-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.MinOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),c=a.length===1&&Array.isArray(a[0])?a[0]:a,e=yNe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Txe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF,version:"1.0.0",description:"Date max-of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.MaxOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),c=a.length===1&&Array.isArray(a[0])?a[0]:a,e=hNe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class vxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW,version:"1.0.0",description:"Date from-now operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.FromNow);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),f=mNe(a,c??!1);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Exe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW,version:"1.0.0",description:"Date to-now operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToNow);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),f=TNe(a,c??!1);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class bxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF,version:"1.0.0",description:"Date humanize-diff operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.HumanizeDiff);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=vNe(a,c,e??!0);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Axe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS,version:"1.1.0",description:"Date add-business-days operation implementation module (ISO-weekend strings)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.AddBusinessDays);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2]??void 0,h=a[3]??[],m=ENe(c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class gxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY,version:"1.0.0",description:"Date next-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.NextWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),e=bNe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Ixe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY,version:"1.0.0",description:"Date previous-weekday operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.PreviousWeekday);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)}),e=ANe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Rxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC,version:"1.1.0",description:"Date to-utc operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ToUTC);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1]||void 0,f=a[2]??!1,h=INe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Dxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE,version:"1.0.0",description:"Date convert-timezone operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.ConvertTimezone);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=RNe(a,c,e??!1);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class wxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET,version:"1.0.0",description:"Date get-timezone-offset operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.GetTimezoneOffset);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=DNe(a,c);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Cxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET,version:"1.0.0",description:"Date set-utc-offset operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(K.SetUTCOffset);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),h=wNe(a,c,e??!1);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Oxe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(hs.Wait);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)})[0];return typeof c!="number"||c<0?{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"Invalid wait time provided",result:null}:(await new Promise(e=>setTimeout(e,c)),{value:U.Success,error:null,result:null})}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const PIi=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,e$=s=>s===null||["string","number","boolean"].includes(typeof s);function Wn(s,p="Input must be an array"){if(!Array.isArray(s))throw new TypeError(p);return s}function jo(s){const p=Wn(s,"Input must be an array");if(!p||p.length===0)throw new TypeError("No list provided or list is empty");return p}function t$(s){return Array.isArray(s)?s:[]}function Us(s){return Number(s)}function _xe(s){if(!s||s.length===0)throw new TypeError("No input lists provided");if(!s.every(r=>Array.isArray(r)))throw new TypeError("All inputs must be arrays");const[p,...i]=s;return i.reduce((r,a)=>r.concat(a),p)}function Vxe(s,...p){if(!Array.isArray(s))throw new TypeError("First input must be an array");if(!p.every(i=>Array.isArray(i)))throw new TypeError("All subsequent inputs must be arrays");return s.concat(...p)}function Pxe(s,p){const i=jo(s),r=Us(p);return[i.slice(0,r),i.slice(r)]}function Nxe(s){return jo(s).slice().reverse()}function xxe(s){return jo(s).slice(0,-1)}function $xe(s){return jo(s).slice(1)}function Lxe(s,p,i){const r=Wn(s),a=Us(p);if(a<0||a>r.length)throw new TypeError("Index out of bounds");return[...r.slice(0,a),i,...r.slice(a)]}function Bxe(s,p,i){const r=jo(s),a=Us(p);if(a<0||a>=r.length)throw new TypeError("Index out of bounds");const c=[...r];return c[a]=i,c}function Mxe(s,p,i){const r=jo(s),a=r.indexOf(p);if(a===-1)return r;const c=[...r];return c[a]=i,c}function Gxe(s,p,i){const r=jo(s),a=r.lastIndexOf(p);if(a===-1)return r;const c=[...r];return c[a]=i,c}function jxe(s,p,i){return jo(s).map(a=>a===p?i:a)}function kxe(s,p){const i=jo(s),r=Us(p);if(r<0||r>=i.length)throw new TypeError("Index out of bounds");return i[r]}function Uxe(s){return jo(s)[0]}function Fxe(s){const p=jo(s);return p[p.length-1]}function Kxe(s,p,...i){return[...Wn(s),p,...i]}function qxe(s,p){const i=Wn(s);return[p,...i]}function Sxe(s){return Wn(s).length}function Zxe(s,p){const i=Wn(s),r=Us(p);if(r<0||r>=i.length)throw new TypeError("Index out of bounds");return i.slice(0,r).concat(i.slice(r+1))}function Hxe(s,p){const i=Wn(s),r=Math.max(0,Us(p)??0);return i.slice(0,r)}function Wxe(s,p){const i=Wn(s),r=Math.max(0,Us(p)??0);return r===0?[]:i.slice(-r)}function zxe(s,p,i){const r=Wn(s),a=p==null?void 0:Us(p),c=i==null?void 0:Us(i);return r.slice(a,c)}function Yxe(s,p){return Wn(s).indexOf(p)}function Jxe(s,p){return Wn(s).lastIndexOf(p)}function Qxe(s){const p=Wn(s),i=[],r=new Set;for(const a of p)r.has(a)||(r.add(a),i.push(a));return i}function Xxe(s){return Wn(s).reduce((i,r)=>i.concat(r),[])}function e$e(s){const p=Wn(s);if(p.length<=1)return[...p];const i=p[0],r=typeof i=="number"&&p.every(e=>typeof e=="number"&&Number.isFinite(e)),a=typeof i=="string"&&p.every(e=>typeof e=="string");let c=null;if(r?c="number":a&&(c=p.every(f=>PIi.test(f)&&B(f).isValid())?"date":"string"),!c)throw new TypeError("All items must be of the same supported type: number, string, or ISO date string.");return c==="number"?[...p].sort((e,f)=>e-f):c==="string"?[...p].sort((e,f)=>e.localeCompare(f)):[...p].sort((e,f)=>B(e).valueOf()-B(f).valueOf())}function t$e(s){const i=[...Wn(s)];for(let r=i.length-1;r>0;r--){const a=Math.floor(h1()*(r+1));[i[r],i[a]]=[i[a],i[r]]}return i}function i$e(s,p){const i=Wn(s),r=Math.max(1,Us(p)||1),a=[];for(let c=0;c<i.length;c+=r)a.push(i.slice(c,c+r));return a}function r$e(s,p,i){const r=Wn(s),a=Math.max(0,Us(p)||0);if(r.length>=a)return[...r];const c=a-r.length;return Array(c).fill(i).concat(r)}function n$e(s,p,i){const r=Wn(s),a=Math.max(0,Us(p)||0);if(r.length>=a)return[...r];const c=a-r.length,e=Array(c).fill(i);return r.concat(e)}function a$e(s,p){const i=Wn(s),r=Math.max(0,Us(p)||0),a=[];for(let c=0;c<r;c++)a.push(...i);return a}function s$e(s,p){if(!e$(p))throw new TypeError("Contains expects the needle to be a primitive (string | number | boolean | null).");return t$(s).some(r=>r===p)}function l$e(s,p){const i=t$(s),r=Array.isArray(p)?p:[p];if(r.length===0)return!1;if(!r.every(e$))throw new TypeError("ContainsAll expects all needles to be primitives (string | number | boolean | null).");return r.every(a=>i.includes(a))}function o$e(s,p){const i=t$(s),r=Array.isArray(p)?p:[p];if(r.length===0)return!1;if(!r.every(e$))throw new TypeError("ContainsAny expects all needles to be primitives (string | number | boolean | null).");return r.some(a=>i.includes(a))}class d$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Join);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=_xe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class u$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Split);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],[f,h]=Pxe(c,e);return{value:U.Success,error:null,result:[f,h]}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class p$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Reverse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Nxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class c$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS,version:"1.0.0",description:"List delete last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.DeleteLastNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=xxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class f$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS,version:"1.0.0",description:"List delete first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.DeleteFirstNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=$xe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class y$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.AddAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Lxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class h$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Bxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class m$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS,version:"1.0.0",description:"List replace first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceFirstNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Mxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class T$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS,version:"1.0.0",description:"List replace last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceLastNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=Gxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class v$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL,version:"1.0.0",description:"List replace all operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.ReplaceAll);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2],h=jxe(c,e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class E$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.GetIndexItem);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=kxe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class b$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.GetFirst);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Uxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class A$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.GetLast);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Fxe(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class g$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Append);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a.slice(2),h=Kxe(c,e,...f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class I$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ye.Prepend);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=qxe(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class R$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH,version:"1.0.0",description:"List get length",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetLength);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(c=>{var e,f;return((e=c.value)==null?void 0:e.valueAsType)??((f=c.value)==null?void 0:f.value)});return{value:U.Success,error:null,result:Sxe(a)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class D$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX,version:"1.0.0",description:"List delete one item at index (non-mutating)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.DeleteAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Zxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class w$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS,version:"1.0.0",description:"List get first N items",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetFirstNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Hxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class C$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS,version:"1.0.0",description:"List get last N items",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetLastNItems);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Wxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class O$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE,version:"1.0.0",description:"List slice(start, end)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Slice);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=zxe(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT,version:"1.0.0",description:"List concat(base, ...others)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Concat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),[c,...e]=a,f=Vxe(c,...e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class V$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF,version:"1.0.0",description:"List listGetIndexOf(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Yxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class P$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF,version:"1.0.0",description:"List listGetLastIndexOf(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.GetLastIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Jxe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class N$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE,version:"1.0.0",description:"List unique (stable, by reference/===)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Unique);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=Qxe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class x$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN,version:"1.0.0",description:"List flatten one level",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Flatten);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=Xxe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class $$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT,version:"1.0.0",description:"List sort (non-mutating). Supports lists of strings (alphabetic), numbers (numeric), or ISO date strings (chronological).",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Sort);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=e$e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class L$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE,version:"1.0.0",description:"List shuffle (Fisher–Yates, secure RNG helper)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Shuffle);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=t$e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class B$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK,version:"1.0.0",description:"List chunk(size) -> list of lists",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Chunk);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=i$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class M$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START,version:"1.0.0",description:"List padStart(targetLength, padValue)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.PadStart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=r$e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class G$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END,version:"1.0.0",description:"List padEnd(targetLength, padValue)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.PadEnd);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=n$e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class j$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT,version:"1.0.0",description:"List repeat(count)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Repeat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=a$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class k$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS,version:"1.0.0",description:"List contains (primitive needles)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.Contains);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=s$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class U$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL,version:"1.0.0",description:"List contains all (primitive needles)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.ContainsAll);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=l$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class F$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY,version:"1.0.0",description:"List contains any (primitive needles)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ye.ContainsAny);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=o$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class NIi extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH,version:"1.0.0",description:"Returns the number of characters in a string",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.GetLength);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.length;return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class K$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Join);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a,c,e;try{const f=r.find(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.separator.id}),h=((a=f==null?void 0:f.value)==null?void 0:a.value)||"",m=r.find(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.first.id}),E=((c=m==null?void 0:m.value)==null?void 0:c.value)||"",b=r.find(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.second.id}),A=((e=b==null?void 0:b.value)==null?void 0:e.value)||"",P=r.filter(j=>{var M,G;return((G=(M=j.valueOwner)==null?void 0:M.declaration)==null?void 0:G.id)===ne.operation[H.Join].inputs.dynamicString.id}).map(j=>{var M,G;return((M=j.value)==null?void 0:M.valueAsType)||((G=j.value)==null?void 0:G.value)||""}),V=[E,A,...P].join(h);return{value:U.Success,error:null,result:V}}catch(f){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:f,result:null}}}})}}class q$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX,version:"1.0.0",description:"String split at index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f={firstPart:c.slice(0,e),secondPart:c.slice(e)};return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class S$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS,version:"1.0.0",description:"String split at all the occurrences of separators operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtAllSeparators);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=c.split(e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Z$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR,version:"1.0.0",description:"String split at the first occurrence of a separator operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtFirstSeparator);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=c.indexOf(e),h={firstPart:c.slice(0,f),secondPart:c.slice(f+e.length)};return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class H$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR,version:"1.0.0",description:"String split at the last occurrence of a separator operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.SplitAtLastSeparator);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=c.lastIndexOf(e),h={firstPart:c.slice(0,f),secondPart:c.slice(f+e.length)};return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class W$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS,version:"1.0.0",description:"String delete last number of characters operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.DeleteLastNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(0,-e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class z$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS,version:"1.0.0",description:"String delete first number of characters operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.DeleteFirstNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(0,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Y$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Reverse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const e=c.split("").reverse().join("");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class J$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ToLowerCase);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const e=c.toLowerCase();return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Q$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ToUpperCase);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const e=c.toUpperCase();return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class X$e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.DeleteAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=Math.min(f,c.length-e),m=c.slice(0,e)+c.slice(e+h);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class eLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.AddAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.slice(0,e)+f+c.slice(e);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class tLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS,version:"1.0.0",description:"String replace first operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceFirstNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1]??1,f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=f+c.slice(e);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class iLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS,version:"1.0.0",description:"String replace last operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceLastNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1]??1,f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.slice(0,-e)+f;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class rLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2]??1,h=a[3];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const m=(c.slice(0,e)||"")+h+(c.slice(e+f)||"");return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class nLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceFirstMatch);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.replace(e,f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class aLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceLastMatch);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)||((A=E.value)==null?void 0:A.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.lastIndexOf(e),m=h===-1?c:c.substring(0,h)+f+c.substring(h+e.length);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class sLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.ReplaceAllMatches);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1],f=a[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const h=c.split(e).join(f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class lLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetIndexItem);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.charAt(e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class oLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS,version:"1.0.0",description:"String get last N chars operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetLastNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(-e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class dLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS,version:"1.0.0",description:"String get first N chars operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetFirstNChars);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=c.slice(0,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.GetIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No search value provided",result:null};const f=c.indexOf(e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class pLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Append);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)||((b=m.value)==null?void 0:b.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No value to append provided",result:null};const f=a.slice(2);if(!f.every(m=>typeof m=="string"))return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"All values to append must be strings",result:null};const h=[c,e,...f].join("");return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class cLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(H.Prepend);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No string provided",result:null};const f=e+c;return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class fLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM,version:"1.0.0",description:"String trim implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Trim);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.trim();return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class yLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START,version:"1.0.0",description:"String trimStart implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.TrimStart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.trimStart();return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class hLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END,version:"1.0.0",description:"String trimEnd implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.TrimEnd);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=a.trimEnd();return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class mLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING,version:"1.0.0",description:"String substring(start, end?) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Substring);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.substring(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class TLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE,version:"1.0.0",description:"String slice(start, end?) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Slice);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.slice(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class vLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF,version:"1.0.0",description:"String lastIndexOf(search, fromIndex?) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.GetLastIndexOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.lastIndexOf(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ELe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START,version:"1.0.0",description:"String padStart(targetLength, padString?) implementation",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.PadStart);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.padStart(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class bLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END,version:"1.0.0",description:"String padEnd(targetLength, padString?) implementation",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.PadEnd);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=a.padEnd(c,e??void 0);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ALe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT,version:"1.0.0",description:"String repeat(count) implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Repeat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=a.repeat(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class gLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX,version:"1.0.0",description:"String match(regex) -> first match array or null",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.MatchRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),f=new RegExp(String(c??""),e?String(e):void 0),h=String(a??"").match(f);return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ILe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX,version:"1.0.0",description:"String matchAll(regex) -> array of matches",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.MatchAllRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(b=>{var A,_;return((A=b.value)==null?void 0:A.valueAsType)??((_=b.value)==null?void 0:_.value)}),f=e?String(e):"",h=f.includes("g")?f:f+"g",m=new RegExp(String(c??""),h),E=Array.from(String(a??"").matchAll(m),b=>Array.from(b));return{value:U.Success,error:null,result:E}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class RLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX,version:"1.0.0",description:"String search(regex) -> index or -1",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.SearchRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});let f=-1;try{const h=new RegExp(String(c??""),e?String(e):void 0);f=String(a??"").search(h)}catch{f=-1}return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class DLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX,version:"1.0.0",description:"String replace using RegExp (pattern, replacement, flags?)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.ReplaceRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)});let h=String(a??"");const m=new RegExp(String(c??""),f?String(f):void 0);return h=h.replace(m,String(e??"")),{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class wLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE,version:"1.0.0",description:"String normalize(form?) implementation module (NFC by default)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.NormalizeUnicode);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=a.normalize(c||"NFC");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const sI=class sI extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS,version:"1.0.0",description:"Remove diacritics via NFD decomposition + strip combining marks",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.RemoveDiacritics);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=String(a??"").normalize("NFD").replace(sI.COMBINING_MARKS,"");return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}};R(sI,"COMBINING_MARKS",/[\u0300-\u036f]/g);let Lg=sI;class CLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES,version:"1.0.0",description:"Count literal substring occurrences in a string",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.CountOccurrences);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=f===""?0:e.split(f).length-1;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class OLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX,version:"1.0.0",description:"Ensure string starts with given prefix (add if missing)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.EnsurePrefix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.startsWith(f)?e:f+e;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _Le extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX,version:"1.0.0",description:"Ensure string ends with given suffix (add if missing)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.EnsureSuffix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.endsWith(f)?e:e+f;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX,version:"1.0.0",description:"Remove prefix if present",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.RemovePrefix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.startsWith(f)?e.slice(f.length):e;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class PLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX,version:"1.0.0",description:"Remove suffix if present",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.RemoveSuffix);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)}),e=String(a??""),f=String(c??""),h=e.endsWith(f)?e.slice(0,-f.length):e;return{value:U.Success,error:null,result:h}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class NLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH,version:"1.0.0",description:"String startsWith(needle) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.StartsWith);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("StartsWith expects two strings.");const e=a.startsWith(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class xLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH,version:"1.0.0",description:"String endsWith(needle) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.EndsWith);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("EndsWith expects two strings.");const e=a.endsWith(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class $Le extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS,version:"1.0.0",description:"String includes(needle) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.Contains);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("Contains expects two strings.");const e=a.includes(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class LLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX,version:"1.0.0",description:"Regex test: new RegExp(pattern, flags?).test(src) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(H.MatchesRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(m=>{var E,b;return((E=m.value)==null?void 0:E.valueAsType)??((b=m.value)==null?void 0:b.value)});if(typeof a!="string"||typeof c!="string")throw new TypeError("MatchesRegex expects source and pattern to be strings.");if(!(e===void 0||typeof e=="string"))throw new TypeError("MatchesRegex flags must be a string if provided.");let f=!1;return f=new RegExp(c,e).test(a),{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}function BLe(s,p){const i=Number(s),a=10**Math.max(0,Number(p)||0);return Math.round(i*a)/a}function MLe(s,p){const i=Number(s),r=Math.abs(Number(p)||0);return r===0?i:Math.round(i/r)*r}function GLe(s,p,i){const r=Number(s),a=Number(p),c=Number(i);return Math.min(Math.max(r,a),c)}function jLe(s,p,i,r,a){const c=Number(s),e=Number(p),f=Number(i),h=Number(r),m=Number(a);if(e===f)throw new Error("Input range cannot be zero");const E=(c-e)/(f-e);return h+E*(m-h)}function kLe(...s){const p=s.map(r=>Number(r));return p.length===0?0:p.reduce((r,a)=>r+a,0)/p.length}function ULe(...s){const p=s.map(r=>Number(r)).sort((r,a)=>r-a);if(p.length===0)return 0;const i=Math.floor(p.length/2);return p.length%2?p[i]:(p[i-1]+p[i])/2}function FLe(s,p){const i=Number(s),r=Number(p);return r===0?NaN:i<0&&r%2===1?-Math.pow(-i,1/r):Math.pow(i,1/r)}function KLe(s,p){const i=Number(s),r=Number(p);return i===0?1/0:(r-i)/i*100}const $i=s=>s.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class qLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Addition);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=$i(r).reduce((e,f)=>e+f,0);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class SLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Subtraction);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=$i(r).reduce((e,f)=>e-f,0);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ZLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Multiplication);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=$i(r).reduce((e,f)=>e*f,1);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class HLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Division);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=$i(r);if(c===0)throw new Error("Division by zero is not allowed");const e=a/c;return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class WLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Remainder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=$i(r);if(c===0)throw new Error("Division by zero is not allowed");const e=a%c;return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class zLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(ce.Exponentiation);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=$i(r),e=Math.pow(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class YLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE,version:"1.0.0",description:"Number negate (unary -x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Negate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:-a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class JLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE,version:"1.0.0",description:"Number absolute (|x|)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Absolute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.abs(Number(a))}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class QLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN,version:"1.0.0",description:"Number sign (-1 | 0 | 1)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Sign);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.sign(Number(a))}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class XLe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND,version:"1.0.0",description:"Number round to nearest integer",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Round);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.round(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class e2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR,version:"1.0.0",description:"Number floor (⌊x⌋)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Floor);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.floor(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class t2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL,version:"1.0.0",description:"Number ceil (⌈x⌉)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Ceil);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.ceil(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class i2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC,version:"1.0.0",description:"Number truncation (drop fractional part)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Trunc);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.trunc(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class r2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS,version:"1.0.0",description:"Round to N decimals",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.RoundToDecimals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=BLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class n2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP,version:"1.0.0",description:"Snap a number to the nearest multiple of step (>=0 step)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.SnapToStep);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=MLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class a2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP,version:"1.0.0",description:"Clamp value to [min, max]",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Clamp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=$i(r),f=GLe(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class s2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE,version:"1.0.0",description:"Map value from [inMin,inMax] to [outMin,outMax]",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MapRange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h]=$i(r),m=jLe(a,c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class l2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE,version:"1.0.0",description:"Average(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Average);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r),c=kLe(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class o2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN,version:"1.0.0",description:"Median(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Median);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r),c=ULe(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class d2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF,version:"1.0.0",description:"Min(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MinOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r).map(Number),c=a.length?Math.min(...a):1/0;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class u2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF,version:"1.0.0",description:"Max(numbers...)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MaxOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=$i(r).map(Number),c=a.length?Math.max(...a):-1/0;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class p2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT,version:"1.0.0",description:"Square root",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.SquareRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.sqrt(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class c2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT,version:"1.0.0",description:"Cube root",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.CubeRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.cbrt(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class f2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT,version:"1.0.0",description:"Nth root (value, n)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.NthRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=FLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class y2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP,version:"1.0.0",description:"e^x",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Exp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.exp(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class h2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL,version:"1.0.0",description:"Natural log ln(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.LogNatural);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.log(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class m2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10,version:"1.0.0",description:"Log base 10",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Log10);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r),c=Number(a),e=Math.log10?Math.log10(c):Math.log(c)/Math.LN10;return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class T2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN,version:"1.0.0",description:"sin(x in radians)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Sin);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.sin(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class v2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS,version:"1.0.0",description:"cos(x in radians)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Cos);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.cos(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class E2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN,version:"1.0.0",description:"tan(x in radians)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Tan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.tan(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class b2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN,version:"1.0.0",description:"asin(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Asin);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.asin(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class A2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS,version:"1.0.0",description:"acos(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Acos);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.acos(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class g2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN,version:"1.0.0",description:"atan(x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Atan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Math.atan(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class I2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2,version:"1.0.0",description:"atan2(y, x)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.Atan2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:Math.atan2(Number(a),Number(c))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class R2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS,version:"1.0.0",description:"deg → rad",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.ToRadians);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Number(a)*Math.PI/180}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class D2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES,version:"1.0.0",description:"rad → deg",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.ToDegrees);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=$i(r);return{value:U.Success,error:null,result:Number(a)*180/Math.PI}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class w2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF,version:"1.0.0",description:"x percent of y",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.PercentOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=Number(a)/100*Number(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class j_ extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE,version:"1.0.0",description:"((new-old)/old)*100",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.PercentageChange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r),e=KLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class C2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN,version:"1.0.0",description:"a < b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.LessThan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a<c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class O2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN,version:"1.0.0",description:"a > b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MoreThan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a>c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class _2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL,version:"1.0.0",description:"a <= b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.LessThanOrEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a<=c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class V2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL,version:"1.0.0",description:"a >= b",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ce.MoreThanOrEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=$i(r);return{value:U.Success,error:null,result:a>=c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}function P2e(s,p){return function(){return s.apply(p,arguments)}}const{toString:xIi}=Object.prototype,{getPrototypeOf:i$}=Object,{iterator:b1,toStringTag:N2e}=Symbol,A1=(s=>p=>{const i=xIi.call(p);return s[i]||(s[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),ko=s=>(s=s.toLowerCase(),p=>A1(p)===s),g1=s=>p=>typeof p===s,{isArray:Mm}=Array,Dh=g1("undefined");function DE(s){return s!==null&&!Dh(s)&&s.constructor!==null&&!Dh(s.constructor)&&ys(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const x2e=ko("ArrayBuffer");function $Ii(s){let p;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?p=ArrayBuffer.isView(s):p=s&&s.buffer&&x2e(s.buffer),p}const LIi=g1("string"),ys=g1("function"),$2e=g1("number"),wE=s=>s!==null&&typeof s=="object",BIi=s=>s===!0||s===!1,cg=s=>{if(A1(s)!=="object")return!1;const p=i$(s);return(p===null||p===Object.prototype||Object.getPrototypeOf(p)===null)&&!(N2e in s)&&!(b1 in s)},MIi=s=>{if(!wE(s)||DE(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},GIi=ko("Date"),jIi=ko("File"),kIi=s=>!!(s&&typeof s.uri<"u"),UIi=s=>s&&typeof s.getParts<"u",FIi=ko("Blob"),KIi=ko("FileList"),qIi=s=>wE(s)&&ys(s.pipe);function SIi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const qk=SIi(),Sk=typeof qk.FormData<"u"?qk.FormData:void 0,ZIi=s=>{let p;return s&&(Sk&&s instanceof Sk||ys(s.append)&&((p=A1(s))==="formdata"||p==="object"&&ys(s.toString)&&s.toString()==="[object FormData]"))},HIi=ko("URLSearchParams"),[WIi,zIi,YIi,JIi]=["ReadableStream","Request","Response","Headers"].map(ko),QIi=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function CE(s,p,{allOwnKeys:i=!1}={}){if(s===null||typeof s>"u")return;let r,a;if(typeof s!="object"&&(s=[s]),Mm(s))for(r=0,a=s.length;r<a;r++)p.call(null,s[r],r,s);else{if(DE(s))return;const c=i?Object.getOwnPropertyNames(s):Object.keys(s),e=c.length;let f;for(r=0;r<e;r++)f=c[r],p.call(null,s[f],f,s)}}function L2e(s,p){if(DE(s))return null;p=p.toLowerCase();const i=Object.keys(s);let r=i.length,a;for(;r-- >0;)if(a=i[r],p===a.toLowerCase())return a;return null}const Tf=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),B2e=s=>!Dh(s)&&s!==Tf;function k_(){const{caseless:s,skipUndefined:p}=B2e(this)&&this||{},i={},r=(a,c)=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const e=s&&L2e(i,c)||c;cg(i[e])&&cg(a)?i[e]=k_(i[e],a):cg(a)?i[e]=k_({},a):Mm(a)?i[e]=a.slice():(!p||!Dh(a))&&(i[e]=a)};for(let a=0,c=arguments.length;a<c;a++)arguments[a]&&CE(arguments[a],r);return i}const XIi=(s,p,i,{allOwnKeys:r}={})=>(CE(p,(a,c)=>{i&&ys(a)?Object.defineProperty(s,c,{value:P2e(a,i),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(s,c,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),s),eRi=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),tRi=(s,p,i,r)=>{s.prototype=Object.create(p.prototype,r),Object.defineProperty(s.prototype,"constructor",{value:s,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(s,"super",{value:p.prototype}),i&&Object.assign(s.prototype,i)},iRi=(s,p,i,r)=>{let a,c,e;const f={};if(p=p||{},s==null)return p;do{for(a=Object.getOwnPropertyNames(s),c=a.length;c-- >0;)e=a[c],(!r||r(e,s,p))&&!f[e]&&(p[e]=s[e],f[e]=!0);s=i!==!1&&i$(s)}while(s&&(!i||i(s,p))&&s!==Object.prototype);return p},rRi=(s,p,i)=>{s=String(s),(i===void 0||i>s.length)&&(i=s.length),i-=p.length;const r=s.indexOf(p,i);return r!==-1&&r===i},nRi=s=>{if(!s)return null;if(Mm(s))return s;let p=s.length;if(!$2e(p))return null;const i=new Array(p);for(;p-- >0;)i[p]=s[p];return i},aRi=(s=>p=>s&&p instanceof s)(typeof Uint8Array<"u"&&i$(Uint8Array)),sRi=(s,p)=>{const r=(s&&s[b1]).call(s);let a;for(;(a=r.next())&&!a.done;){const c=a.value;p.call(s,c[0],c[1])}},lRi=(s,p)=>{let i;const r=[];for(;(i=s.exec(p))!==null;)r.push(i);return r},oRi=ko("HTMLFormElement"),dRi=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,r,a){return r.toUpperCase()+a}),Zk=(({hasOwnProperty:s})=>(p,i)=>s.call(p,i))(Object.prototype),uRi=ko("RegExp"),M2e=(s,p)=>{const i=Object.getOwnPropertyDescriptors(s),r={};CE(i,(a,c)=>{let e;(e=p(a,c,s))!==!1&&(r[c]=e||a)}),Object.defineProperties(s,r)},pRi=s=>{M2e(s,(p,i)=>{if(ys(s)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const r=s[i];if(ys(r)){if(p.enumerable=!1,"writable"in p){p.writable=!1;return}p.set||(p.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},cRi=(s,p)=>{const i={},r=a=>{a.forEach(c=>{i[c]=!0})};return Mm(s)?r(s):r(String(s).split(p)),i},fRi=()=>{},yRi=(s,p)=>s!=null&&Number.isFinite(s=+s)?s:p;function hRi(s){return!!(s&&ys(s.append)&&s[N2e]==="FormData"&&s[b1])}const mRi=s=>{const p=new Array(10),i=(r,a)=>{if(wE(r)){if(p.indexOf(r)>=0)return;if(DE(r))return r;if(!("toJSON"in r)){p[a]=r;const c=Mm(r)?[]:{};return CE(r,(e,f)=>{const h=i(e,a+1);!Dh(h)&&(c[f]=h)}),p[a]=void 0,c}}return r};return i(s,0)},TRi=ko("AsyncFunction"),vRi=s=>s&&(wE(s)||ys(s))&&ys(s.then)&&ys(s.catch),G2e=((s,p)=>s?setImmediate:p?((i,r)=>(Tf.addEventListener("message",({source:a,data:c})=>{a===Tf&&c===i&&r.length&&r.shift()()},!1),a=>{r.push(a),Tf.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",ys(Tf.postMessage)),ERi=typeof queueMicrotask<"u"?queueMicrotask.bind(Tf):typeof process<"u"&&process.nextTick||G2e,bRi=s=>s!=null&&ys(s[b1]),qe={isArray:Mm,isArrayBuffer:x2e,isBuffer:DE,isFormData:ZIi,isArrayBufferView:$Ii,isString:LIi,isNumber:$2e,isBoolean:BIi,isObject:wE,isPlainObject:cg,isEmptyObject:MIi,isReadableStream:WIi,isRequest:zIi,isResponse:YIi,isHeaders:JIi,isUndefined:Dh,isDate:GIi,isFile:jIi,isReactNativeBlob:kIi,isReactNative:UIi,isBlob:FIi,isRegExp:uRi,isFunction:ys,isStream:qIi,isURLSearchParams:HIi,isTypedArray:aRi,isFileList:KIi,forEach:CE,merge:k_,extend:XIi,trim:QIi,stripBOM:eRi,inherits:tRi,toFlatObject:iRi,kindOf:A1,kindOfTest:ko,endsWith:rRi,toArray:nRi,forEachEntry:sRi,matchAll:lRi,isHTMLForm:oRi,hasOwnProperty:Zk,hasOwnProp:Zk,reduceDescriptors:M2e,freezeMethods:pRi,toObjectSet:cRi,toCamelCase:dRi,noop:fRi,toFiniteNumber:yRi,findKey:L2e,global:Tf,isContextDefined:B2e,isSpecCompliantForm:hRi,toJSONObject:mRi,isAsyncFn:TRi,isThenable:vRi,setImmediate:G2e,asap:ERi,isIterable:bRi};class Ya extends Error{static from(p,i,r,a,c,e){const f=new Ya(p.message,i||p.code,r,a,c);return f.cause=p,f.name=p.name,p.status!=null&&f.status==null&&(f.status=p.status),e&&Object.assign(f,e),f}constructor(p,i,r,a,c){super(p),Object.defineProperty(this,"message",{value:p,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,i&&(this.code=i),r&&(this.config=r),a&&(this.request=a),c&&(this.response=c,this.status=c.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:qe.toJSONObject(this.config),code:this.code,status:this.status}}}Ya.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ya.ERR_BAD_OPTION="ERR_BAD_OPTION";Ya.ECONNABORTED="ECONNABORTED";Ya.ETIMEDOUT="ETIMEDOUT";Ya.ERR_NETWORK="ERR_NETWORK";Ya.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ya.ERR_DEPRECATED="ERR_DEPRECATED";Ya.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ya.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ya.ERR_CANCELED="ERR_CANCELED";Ya.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ya.ERR_INVALID_URL="ERR_INVALID_URL";const ir=Ya,ARi=null;function U_(s){return qe.isPlainObject(s)||qe.isArray(s)}function j2e(s){return qe.endsWith(s,"[]")?s.slice(0,-2):s}function XO(s,p,i){return s?s.concat(p).map(function(a,c){return a=j2e(a),!i&&c?"["+a+"]":a}).join(i?".":""):p}function gRi(s){return qe.isArray(s)&&!s.some(U_)}const IRi=qe.toFlatObject(qe,{},null,function(p){return/^is[A-Z]/.test(p)});function I1(s,p,i){if(!qe.isObject(s))throw new TypeError("target must be an object");p=p||new FormData,i=qe.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(V,j){return!qe.isUndefined(j[V])});const r=i.metaTokens,a=i.visitor||E,c=i.dots,e=i.indexes,h=(i.Blob||typeof Blob<"u"&&Blob)&&qe.isSpecCompliantForm(p);if(!qe.isFunction(a))throw new TypeError("visitor must be a function");function m(P){if(P===null)return"";if(qe.isDate(P))return P.toISOString();if(qe.isBoolean(P))return P.toString();if(!h&&qe.isBlob(P))throw new ir("Blob is not supported. Use a Buffer instead.");return qe.isArrayBuffer(P)||qe.isTypedArray(P)?h&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function E(P,V,j){let M=P;if(qe.isReactNative(p)&&qe.isReactNativeBlob(P))return p.append(XO(j,V,c),m(P)),!1;if(P&&!j&&typeof P=="object"){if(qe.endsWith(V,"{}"))V=r?V:V.slice(0,-2),P=JSON.stringify(P);else if(qe.isArray(P)&&gRi(P)||(qe.isFileList(P)||qe.endsWith(V,"[]"))&&(M=qe.toArray(P)))return V=j2e(V),M.forEach(function(q,re){!(qe.isUndefined(q)||q===null)&&p.append(e===!0?XO([V],re,c):e===null?V:V+"[]",m(q))}),!1}return U_(P)?!0:(p.append(XO(j,V,c),m(P)),!1)}const b=[],A=Object.assign(IRi,{defaultVisitor:E,convertValue:m,isVisitable:U_});function _(P,V){if(!qe.isUndefined(P)){if(b.indexOf(P)!==-1)throw Error("Circular reference detected in "+V.join("."));b.push(P),qe.forEach(P,function(M,G){(!(qe.isUndefined(M)||M===null)&&a.call(p,M,qe.isString(G)?G.trim():G,V,A))===!0&&_(M,V?V.concat(G):[G])}),b.pop()}}if(!qe.isObject(s))throw new TypeError("data must be an object");return _(s),p}function Hk(s){const p={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(r){return p[r]})}function r$(s,p){this._pairs=[],s&&I1(s,this,p)}const k2e=r$.prototype;k2e.append=function(p,i){this._pairs.push([p,i])};k2e.toString=function(p){const i=p?function(r){return p.call(this,r,Hk)}:Hk;return this._pairs.map(function(a){return i(a[0])+"="+i(a[1])},"").join("&")};function RRi(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function U2e(s,p,i){if(!p)return s;const r=i&&i.encode||RRi,a=qe.isFunction(i)?{serialize:i}:i,c=a&&a.serialize;let e;if(c?e=c(p,a):e=qe.isURLSearchParams(p)?p.toString():new r$(p,a).toString(r),e){const f=s.indexOf("#");f!==-1&&(s=s.slice(0,f)),s+=(s.indexOf("?")===-1?"?":"&")+e}return s}class DRi{constructor(){this.handlers=[]}use(p,i,r){return this.handlers.push({fulfilled:p,rejected:i,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(p){this.handlers[p]&&(this.handlers[p]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(p){qe.forEach(this.handlers,function(r){r!==null&&p(r)})}}const Wk=DRi,n$={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},wRi=typeof URLSearchParams<"u"?URLSearchParams:r$,CRi=typeof FormData<"u"?FormData:null,ORi=typeof Blob<"u"?Blob:null,_Ri={isBrowser:!0,classes:{URLSearchParams:wRi,FormData:CRi,Blob:ORi},protocols:["http","https","file","blob","url","data"]},a$=typeof window<"u"&&typeof document<"u",F_=typeof navigator=="object"&&navigator||void 0,VRi=a$&&(!F_||["ReactNative","NativeScript","NS"].indexOf(F_.product)<0),PRi=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),NRi=a$&&window.location.href||"http://localhost",xRi=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:a$,hasStandardBrowserEnv:VRi,hasStandardBrowserWebWorkerEnv:PRi,navigator:F_,origin:NRi},Symbol.toStringTag,{value:"Module"})),Ra={...xRi,..._Ri};function $Ri(s,p){return I1(s,new Ra.classes.URLSearchParams,{visitor:function(i,r,a,c){return Ra.isNode&&qe.isBuffer(i)?(this.append(r,i.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)},...p})}function LRi(s){return qe.matchAll(/\w+|\[(\w*)]/g,s).map(p=>p[0]==="[]"?"":p[1]||p[0])}function BRi(s){const p={},i=Object.keys(s);let r;const a=i.length;let c;for(r=0;r<a;r++)c=i[r],p[c]=s[c];return p}function F2e(s){function p(i,r,a,c){let e=i[c++];if(e==="__proto__")return!0;const f=Number.isFinite(+e),h=c>=i.length;return e=!e&&qe.isArray(a)?a.length:e,h?(qe.hasOwnProp(a,e)?a[e]=[a[e],r]:a[e]=r,!f):((!a[e]||!qe.isObject(a[e]))&&(a[e]=[]),p(i,r,a[e],c)&&qe.isArray(a[e])&&(a[e]=BRi(a[e])),!f)}if(qe.isFormData(s)&&qe.isFunction(s.entries)){const i={};return qe.forEachEntry(s,(r,a)=>{p(LRi(r),a,i,0)}),i}return null}function MRi(s,p,i){if(qe.isString(s))try{return(p||JSON.parse)(s),qe.trim(s)}catch(r){if(r.name!=="SyntaxError")throw r}return(i||JSON.stringify)(s)}const s$={transitional:n$,adapter:["xhr","http","fetch"],transformRequest:[function(p,i){const r=i.getContentType()||"",a=r.indexOf("application/json")>-1,c=qe.isObject(p);if(c&&qe.isHTMLForm(p)&&(p=new FormData(p)),qe.isFormData(p))return a?JSON.stringify(F2e(p)):p;if(qe.isArrayBuffer(p)||qe.isBuffer(p)||qe.isStream(p)||qe.isFile(p)||qe.isBlob(p)||qe.isReadableStream(p))return p;if(qe.isArrayBufferView(p))return p.buffer;if(qe.isURLSearchParams(p))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),p.toString();let f;if(c){if(r.indexOf("application/x-www-form-urlencoded")>-1)return $Ri(p,this.formSerializer).toString();if((f=qe.isFileList(p))||r.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return I1(f?{"files[]":p}:p,h&&new h,this.formSerializer)}}return c||a?(i.setContentType("application/json",!1),MRi(p)):p}],transformResponse:[function(p){const i=this.transitional||s$.transitional,r=i&&i.forcedJSONParsing,a=this.responseType==="json";if(qe.isResponse(p)||qe.isReadableStream(p))return p;if(p&&qe.isString(p)&&(r&&!this.responseType||a)){const e=!(i&&i.silentJSONParsing)&&a;try{return JSON.parse(p,this.parseReviver)}catch(f){if(e)throw f.name==="SyntaxError"?ir.from(f,ir.ERR_BAD_RESPONSE,this,null,this.response):f}}return p}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ra.classes.FormData,Blob:Ra.classes.Blob},validateStatus:function(p){return p>=200&&p<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};qe.forEach(["delete","get","head","post","put","patch"],s=>{s$.headers[s]={}});const l$=s$,GRi=qe.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),jRi=s=>{const p={};let i,r,a;return s&&s.split(`
|
|
50
50
|
`).forEach(function(e){a=e.indexOf(":"),i=e.substring(0,a).trim().toLowerCase(),r=e.substring(a+1).trim(),!(!i||p[i]&&GRi[i])&&(i==="set-cookie"?p[i]?p[i].push(r):p[i]=[r]:p[i]=p[i]?p[i]+", "+r:r)}),p},zk=Symbol("internals");function F0(s){return s&&String(s).trim().toLowerCase()}function fg(s){return s===!1||s==null?s:qe.isArray(s)?s.map(fg):String(s)}function kRi(s){const p=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=i.exec(s);)p[r[1]]=r[2];return p}const URi=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function e_(s,p,i,r,a){if(qe.isFunction(r))return r.call(this,p,i);if(a&&(p=i),!!qe.isString(p)){if(qe.isString(r))return p.indexOf(r)!==-1;if(qe.isRegExp(r))return r.test(p)}}function FRi(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(p,i,r)=>i.toUpperCase()+r)}function KRi(s,p){const i=qe.toCamelCase(" "+p);["get","set","has"].forEach(r=>{Object.defineProperty(s,r+i,{value:function(a,c,e){return this[r].call(this,p,a,c,e)},configurable:!0})})}class R1{constructor(p){p&&this.set(p)}set(p,i,r){const a=this;function c(f,h,m){const E=F0(h);if(!E)throw new Error("header name must be a non-empty string");const b=qe.findKey(a,E);(!b||a[b]===void 0||m===!0||m===void 0&&a[b]!==!1)&&(a[b||h]=fg(f))}const e=(f,h)=>qe.forEach(f,(m,E)=>c(m,E,h));if(qe.isPlainObject(p)||p instanceof this.constructor)e(p,i);else if(qe.isString(p)&&(p=p.trim())&&!URi(p))e(jRi(p),i);else if(qe.isObject(p)&&qe.isIterable(p)){let f={},h,m;for(const E of p){if(!qe.isArray(E))throw TypeError("Object iterator must return a key-value pair");f[m=E[0]]=(h=f[m])?qe.isArray(h)?[...h,E[1]]:[h,E[1]]:E[1]}e(f,i)}else p!=null&&c(i,p,r);return this}get(p,i){if(p=F0(p),p){const r=qe.findKey(this,p);if(r){const a=this[r];if(!i)return a;if(i===!0)return kRi(a);if(qe.isFunction(i))return i.call(this,a,r);if(qe.isRegExp(i))return i.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(p,i){if(p=F0(p),p){const r=qe.findKey(this,p);return!!(r&&this[r]!==void 0&&(!i||e_(this,this[r],r,i)))}return!1}delete(p,i){const r=this;let a=!1;function c(e){if(e=F0(e),e){const f=qe.findKey(r,e);f&&(!i||e_(r,r[f],f,i))&&(delete r[f],a=!0)}}return qe.isArray(p)?p.forEach(c):c(p),a}clear(p){const i=Object.keys(this);let r=i.length,a=!1;for(;r--;){const c=i[r];(!p||e_(this,this[c],c,p,!0))&&(delete this[c],a=!0)}return a}normalize(p){const i=this,r={};return qe.forEach(this,(a,c)=>{const e=qe.findKey(r,c);if(e){i[e]=fg(a),delete i[c];return}const f=p?FRi(c):String(c).trim();f!==c&&delete i[c],i[f]=fg(a),r[f]=!0}),this}concat(...p){return this.constructor.concat(this,...p)}toJSON(p){const i=Object.create(null);return qe.forEach(this,(r,a)=>{r!=null&&r!==!1&&(i[a]=p&&qe.isArray(r)?r.join(", "):r)}),i}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([p,i])=>p+": "+i).join(`
|
|
51
51
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(p){return p instanceof this?p:new this(p)}static concat(p,...i){const r=new this(p);return i.forEach(a=>r.set(a)),r}static accessor(p){const r=(this[zk]=this[zk]={accessors:{}}).accessors,a=this.prototype;function c(e){const f=F0(e);r[f]||(KRi(a,e),r[f]=!0)}return qe.isArray(p)?p.forEach(c):c(p),this}}R1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);qe.reduceDescriptors(R1.prototype,({value:s},p)=>{let i=p[0].toUpperCase()+p.slice(1);return{get:()=>s,set(r){this[i]=r}}});qe.freezeMethods(R1);const ao=R1;function t_(s,p){const i=this||l$,r=p||i,a=ao.from(r.headers);let c=r.data;return qe.forEach(s,function(f){c=f.call(i,c,a.normalize(),p?p.status:void 0)}),a.normalize(),c}function K2e(s){return!!(s&&s.__CANCEL__)}class qRi extends ir{constructor(p,i,r){super(p??"canceled",ir.ERR_CANCELED,i,r),this.name="CanceledError",this.__CANCEL__=!0}}const OE=qRi;function q2e(s,p,i){const r=i.config.validateStatus;!i.status||!r||r(i.status)?s(i):p(new ir("Request failed with status code "+i.status,[ir.ERR_BAD_REQUEST,ir.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}function SRi(s){const p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return p&&p[1]||""}function ZRi(s,p){s=s||10;const i=new Array(s),r=new Array(s);let a=0,c=0,e;return p=p!==void 0?p:1e3,function(h){const m=Date.now(),E=r[c];e||(e=m),i[a]=h,r[a]=m;let b=c,A=0;for(;b!==a;)A+=i[b++],b=b%s;if(a=(a+1)%s,a===c&&(c=(c+1)%s),m-e<p)return;const _=E&&m-E;return _?Math.round(A*1e3/_):void 0}}function HRi(s,p){let i=0,r=1e3/p,a,c;const e=(m,E=Date.now())=>{i=E,a=null,c&&(clearTimeout(c),c=null),s(...m)};return[(...m)=>{const E=Date.now(),b=E-i;b>=r?e(m,E):(a=m,c||(c=setTimeout(()=>{c=null,e(a)},r-b)))},()=>a&&e(a)]}const Bg=(s,p,i=3)=>{let r=0;const a=ZRi(50,250);return HRi(c=>{const e=c.loaded,f=c.lengthComputable?c.total:void 0,h=e-r,m=a(h),E=e<=f;r=e;const b={loaded:e,total:f,progress:f?e/f:void 0,bytes:h,rate:m||void 0,estimated:m&&f&&E?(f-e)/m:void 0,event:c,lengthComputable:f!=null,[p?"download":"upload"]:!0};s(b)},i)},Yk=(s,p)=>{const i=s!=null;return[r=>p[0]({lengthComputable:i,total:s,loaded:r}),p[1]]},Jk=s=>(...p)=>qe.asap(()=>s(...p)),WRi=Ra.hasStandardBrowserEnv?((s,p)=>i=>(i=new URL(i,Ra.origin),s.protocol===i.protocol&&s.host===i.host&&(p||s.port===i.port)))(new URL(Ra.origin),Ra.navigator&&/(msie|trident)/i.test(Ra.navigator.userAgent)):()=>!0,zRi=Ra.hasStandardBrowserEnv?{write(s,p,i,r,a,c,e){if(typeof document>"u")return;const f=[`${s}=${encodeURIComponent(p)}`];qe.isNumber(i)&&f.push(`expires=${new Date(i).toUTCString()}`),qe.isString(r)&&f.push(`path=${r}`),qe.isString(a)&&f.push(`domain=${a}`),c===!0&&f.push("secure"),qe.isString(e)&&f.push(`SameSite=${e}`),document.cookie=f.join("; ")},read(s){if(typeof document>"u")return null;const p=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return p?decodeURIComponent(p[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function YRi(s){return typeof s!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function JRi(s,p){return p?s.replace(/\/?\/$/,"")+"/"+p.replace(/^\/+/,""):s}function S2e(s,p,i){let r=!YRi(p);return s&&(r||i==!1)?JRi(s,p):p}const Qk=s=>s instanceof ao?{...s}:s;function wf(s,p){p=p||{};const i={};function r(m,E,b,A){return qe.isPlainObject(m)&&qe.isPlainObject(E)?qe.merge.call({caseless:A},m,E):qe.isPlainObject(E)?qe.merge({},E):qe.isArray(E)?E.slice():E}function a(m,E,b,A){if(qe.isUndefined(E)){if(!qe.isUndefined(m))return r(void 0,m,b,A)}else return r(m,E,b,A)}function c(m,E){if(!qe.isUndefined(E))return r(void 0,E)}function e(m,E){if(qe.isUndefined(E)){if(!qe.isUndefined(m))return r(void 0,m)}else return r(void 0,E)}function f(m,E,b){if(b in p)return r(m,E);if(b in s)return r(void 0,m)}const h={url:c,method:c,data:c,baseURL:e,transformRequest:e,transformResponse:e,paramsSerializer:e,timeout:e,timeoutMessage:e,withCredentials:e,withXSRFToken:e,adapter:e,responseType:e,xsrfCookieName:e,xsrfHeaderName:e,onUploadProgress:e,onDownloadProgress:e,decompress:e,maxContentLength:e,maxBodyLength:e,beforeRedirect:e,transport:e,httpAgent:e,httpsAgent:e,cancelToken:e,socketPath:e,responseEncoding:e,validateStatus:f,headers:(m,E,b)=>a(Qk(m),Qk(E),b,!0)};return qe.forEach(Object.keys({...s,...p}),function(E){if(E==="__proto__"||E==="constructor"||E==="prototype")return;const b=qe.hasOwnProp(h,E)?h[E]:a,A=b(s[E],p[E],E);qe.isUndefined(A)&&b!==f||(i[E]=A)}),i}const Z2e=s=>{const p=wf({},s);let{data:i,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:c,headers:e,auth:f}=p;if(p.headers=e=ao.from(e),p.url=U2e(S2e(p.baseURL,p.url,p.allowAbsoluteUrls),s.params,s.paramsSerializer),f&&e.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):""))),qe.isFormData(i)){if(Ra.hasStandardBrowserEnv||Ra.hasStandardBrowserWebWorkerEnv)e.setContentType(void 0);else if(qe.isFunction(i.getHeaders)){const h=i.getHeaders(),m=["content-type","content-length"];Object.entries(h).forEach(([E,b])=>{m.includes(E.toLowerCase())&&e.set(E,b)})}}if(Ra.hasStandardBrowserEnv&&(r&&qe.isFunction(r)&&(r=r(p)),r||r!==!1&&WRi(p.url))){const h=a&&c&&zRi.read(c);h&&e.set(a,h)}return p},QRi=typeof XMLHttpRequest<"u",XRi=QRi&&function(s){return new Promise(function(i,r){const a=Z2e(s);let c=a.data;const e=ao.from(a.headers).normalize();let{responseType:f,onUploadProgress:h,onDownloadProgress:m}=a,E,b,A,_,P;function V(){_&&_(),P&&P(),a.cancelToken&&a.cancelToken.unsubscribe(E),a.signal&&a.signal.removeEventListener("abort",E)}let j=new XMLHttpRequest;j.open(a.method.toUpperCase(),a.url,!0),j.timeout=a.timeout;function M(){if(!j)return;const q=ao.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),ee={data:!f||f==="text"||f==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:q,config:s,request:j};q2e(function(te){i(te),V()},function(te){r(te),V()},ee),j=null}"onloadend"in j?j.onloadend=M:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(M)},j.onabort=function(){j&&(r(new ir("Request aborted",ir.ECONNABORTED,s,j)),j=null)},j.onerror=function(re){const ee=re&&re.message?re.message:"Network Error",se=new ir(ee,ir.ERR_NETWORK,s,j);se.event=re||null,r(se),j=null},j.ontimeout=function(){let re=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const ee=a.transitional||n$;a.timeoutErrorMessage&&(re=a.timeoutErrorMessage),r(new ir(re,ee.clarifyTimeoutError?ir.ETIMEDOUT:ir.ECONNABORTED,s,j)),j=null},c===void 0&&e.setContentType(null),"setRequestHeader"in j&&qe.forEach(e.toJSON(),function(re,ee){j.setRequestHeader(ee,re)}),qe.isUndefined(a.withCredentials)||(j.withCredentials=!!a.withCredentials),f&&f!=="json"&&(j.responseType=a.responseType),m&&([A,P]=Bg(m,!0),j.addEventListener("progress",A)),h&&j.upload&&([b,_]=Bg(h),j.upload.addEventListener("progress",b),j.upload.addEventListener("loadend",_)),(a.cancelToken||a.signal)&&(E=q=>{j&&(r(!q||q.type?new OE(null,s,j):q),j.abort(),j=null)},a.cancelToken&&a.cancelToken.subscribe(E),a.signal&&(a.signal.aborted?E():a.signal.addEventListener("abort",E)));const G=SRi(a.url);if(G&&Ra.protocols.indexOf(G)===-1){r(new ir("Unsupported protocol "+G+":",ir.ERR_BAD_REQUEST,s));return}j.send(c||null)})},e1i=(s,p)=>{const{length:i}=s=s?s.filter(Boolean):[];if(p||i){let r=new AbortController,a;const c=function(m){if(!a){a=!0,f();const E=m instanceof Error?m:this.reason;r.abort(E instanceof ir?E:new OE(E instanceof Error?E.message:E))}};let e=p&&setTimeout(()=>{e=null,c(new ir(`timeout of ${p}ms exceeded`,ir.ETIMEDOUT))},p);const f=()=>{s&&(e&&clearTimeout(e),e=null,s.forEach(m=>{m.unsubscribe?m.unsubscribe(c):m.removeEventListener("abort",c)}),s=null)};s.forEach(m=>m.addEventListener("abort",c));const{signal:h}=r;return h.unsubscribe=()=>qe.asap(f),h}},t1i=e1i,i1i=function*(s,p){let i=s.byteLength;if(!p||i<p){yield s;return}let r=0,a;for(;r<i;)a=r+p,yield s.slice(r,a),r=a},r1i=async function*(s,p){for await(const i of n1i(s))yield*i1i(i,p)},n1i=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const p=s.getReader();try{for(;;){const{done:i,value:r}=await p.read();if(i)break;yield r}}finally{await p.cancel()}},Xk=(s,p,i,r)=>{const a=r1i(s,p);let c=0,e,f=h=>{e||(e=!0,r&&r(h))};return new ReadableStream({async pull(h){try{const{done:m,value:E}=await a.next();if(m){f(),h.close();return}let b=E.byteLength;if(i){let A=c+=b;i(A)}h.enqueue(new Uint8Array(E))}catch(m){throw f(m),m}},cancel(h){return f(h),a.return()}},{highWaterMark:2})},eU=64*1024,{isFunction:ng}=qe,a1i=(({Request:s,Response:p})=>({Request:s,Response:p}))(qe.global),{ReadableStream:tU,TextEncoder:iU}=qe.global,rU=(s,...p)=>{try{return!!s(...p)}catch{return!1}},s1i=s=>{s=qe.merge.call({skipUndefined:!0},a1i,s);const{fetch:p,Request:i,Response:r}=s,a=p?ng(p):typeof fetch=="function",c=ng(i),e=ng(r);if(!a)return!1;const f=a&&ng(tU),h=a&&(typeof iU=="function"?(P=>V=>P.encode(V))(new iU):async P=>new Uint8Array(await new i(P).arrayBuffer())),m=c&&f&&rU(()=>{let P=!1;const V=new i(Ra.origin,{body:new tU,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!V}),E=e&&f&&rU(()=>qe.isReadableStream(new r("").body)),b={stream:E&&(P=>P.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!b[P]&&(b[P]=(V,j)=>{let M=V&&V[P];if(M)return M.call(V);throw new ir(`Response type '${P}' is not supported`,ir.ERR_NOT_SUPPORT,j)})});const A=async P=>{if(P==null)return 0;if(qe.isBlob(P))return P.size;if(qe.isSpecCompliantForm(P))return(await new i(Ra.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(qe.isArrayBufferView(P)||qe.isArrayBuffer(P))return P.byteLength;if(qe.isURLSearchParams(P)&&(P=P+""),qe.isString(P))return(await h(P)).byteLength},_=async(P,V)=>{const j=qe.toFiniteNumber(P.getContentLength());return j??A(V)};return async P=>{let{url:V,method:j,data:M,signal:G,cancelToken:q,timeout:re,onDownloadProgress:ee,onUploadProgress:se,responseType:te,headers:le,withCredentials:ue="same-origin",fetchOptions:z}=Z2e(P),X=p||fetch;te=te?(te+"").toLowerCase():"text";let pe=t1i([G,q&&q.toAbortSignal()],re),de=null;const me=pe&&pe.unsubscribe&&(()=>{pe.unsubscribe()});let ve;try{if(se&&m&&j!=="get"&&j!=="head"&&(ve=await _(le,M))!==0){let Je=new i(V,{method:"POST",body:M,duplex:"half"}),Ze;if(qe.isFormData(M)&&(Ze=Je.headers.get("content-type"))&&le.setContentType(Ze),Je.body){const[et,Dt]=Yk(ve,Bg(Jk(se)));M=Xk(Je.body,eU,et,Dt)}}qe.isString(ue)||(ue=ue?"include":"omit");const we=c&&"credentials"in i.prototype,Re={...z,signal:pe,method:j.toUpperCase(),headers:le.normalize().toJSON(),body:M,duplex:"half",credentials:we?ue:void 0};de=c&&new i(V,Re);let xe=await(c?X(de,z):X(V,Re));const je=E&&(te==="stream"||te==="response");if(E&&(ee||je&&me)){const Je={};["status","statusText","headers"].forEach(jt=>{Je[jt]=xe[jt]});const Ze=qe.toFiniteNumber(xe.headers.get("content-length")),[et,Dt]=ee&&Yk(Ze,Bg(Jk(ee),!0))||[];xe=new r(Xk(xe.body,eU,et,()=>{Dt&&Dt(),me&&me()}),Je)}te=te||"text";let Se=await b[qe.findKey(b,te)||"text"](xe,P);return!je&&me&&me(),await new Promise((Je,Ze)=>{q2e(Je,Ze,{data:Se,headers:ao.from(xe.headers),status:xe.status,statusText:xe.statusText,config:P,request:de})})}catch(we){throw me&&me(),we&&we.name==="TypeError"&&/Load failed|fetch/i.test(we.message)?Object.assign(new ir("Network Error",ir.ERR_NETWORK,P,de,we&&we.response),{cause:we.cause||we}):ir.from(we,we&&we.code,P,de,we&&we.response)}}},l1i=new Map,H2e=s=>{let p=s&&s.env||{};const{fetch:i,Request:r,Response:a}=p,c=[r,a,i];let e=c.length,f=e,h,m,E=l1i;for(;f--;)h=c[f],m=E.get(h),m===void 0&&E.set(h,m=f?new Map:s1i(p)),E=m;return m};H2e();const o$={http:ARi,xhr:XRi,fetch:{get:H2e}};qe.forEach(o$,(s,p)=>{if(s){try{Object.defineProperty(s,"name",{value:p})}catch{}Object.defineProperty(s,"adapterName",{value:p})}});const nU=s=>`- ${s}`,o1i=s=>qe.isFunction(s)||s===null||s===!1;function d1i(s,p){s=qe.isArray(s)?s:[s];const{length:i}=s;let r,a;const c={};for(let e=0;e<i;e++){r=s[e];let f;if(a=r,!o1i(r)&&(a=o$[(f=String(r)).toLowerCase()],a===void 0))throw new ir(`Unknown adapter '${f}'`);if(a&&(qe.isFunction(a)||(a=a.get(p))))break;c[f||"#"+e]=a}if(!a){const e=Object.entries(c).map(([h,m])=>`adapter ${h} `+(m===!1?"is not supported by the environment":"is not available in the build"));let f=i?e.length>1?`since :
|
|
52
52
|
`+e.map(nU).join(`
|
|
@@ -535,7 +535,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
535
535
|
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),(i.readsValue||i.writesValue)&&(r.push(new De({id:`${this.id}--${Ce.InvalidObjectStructure}`,code:Ce.InvalidObjectStructure,severity:Te.Error,message:`Entity of type '${this.type}' with id '${this.id}' is not a value reading or writing entity.`})),a.push({id:Yi.EntitiesWithValues,message:_h})),{errors:r,explanations:a,modifiedData:i}}onProjectInitialized(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,new Date().toISOString(),this,!0,"on-property-received-project-initialized"))){return r?(fF(this,r),r==null||r.attemptAutoclose("on-property-received-project-initialized",this.id),this):this}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];if(r==="property-implements-field"&&(this.removeImplementation(i,a),c.push(this)),r==="property-extends-field"){const{updated:m,added:E,removed:b,affected:A}=this.remove({ignoreUpstream:!1},a);c.push(...m),e.push(...E),f.push(...b),h.push(...A)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];if(r==="property-implements-field"&&(this.addImplementation(i,a),c.push(this)),r==="property-extends-field"){const{updated:m,added:E,removed:b,affected:A}=this.restore({},a);c.push(...m),e.push(...E),f.push(...b),h.push(...A)}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){var i,r,a,c,e,f,h;return this.implements.forEach(m=>{this.project.getBuiltIn(m.id)||m.unsubscribeDependents([{entity:this,field:"property-implements-field"}])}),(r=(i=this.extends)==null?void 0:i.unsubscribeDependents)==null||r.call(i,[{entity:this,field:"property-extends-field"}]),(e=(c=(a=this.dataType)==null?void 0:a.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"property-data-type-entity-field"}]),(h=(f=this.dataType)==null?void 0:f.unsubscribeDependents)==null||h.call(f,[{entity:this,field:"property-data-type-field"}]),this.project.off(li.PROJECT_INITIALIZED,this.onProjectInitialized),this}subscribeToDependencies(){var i,r,a,c,e,f,h;return this.implements.forEach(m=>{this.project.getBuiltIn(m.id)||m.subscribeDependents([{entity:this,field:"property-implements-field"}])}),(r=(i=this.extends)==null?void 0:i.subscribeDependents)==null||r.call(i,[{entity:this,field:"property-extends-field"}]),(e=(c=(a=this.dataType)==null?void 0:a.entity)==null?void 0:c.subscribeDependents)==null||e.call(c,[{entity:this,field:"property-data-type-entity-field"}]),(h=(f=this.dataType)==null?void 0:f.subscribeDependents)==null||h.call(f,[{entity:this,field:"property-data-type-field"}]),RVi(this)&&this.project.on(li.PROJECT_INITIALIZED,this.onProjectInitialized),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new yi(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new yi(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.implements=[...this.implements],i.extends=this.extends,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent&&this.parent.type!==d.PrimitiveEntity&&this.parent.type!==d.BuiltInBaseEntity){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new yi(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.defaultValue=h.defaultValue,this.dataType=h.dataType,this.implements=[...h.implements],this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const c=ie(i.parent),e=this.project.get(c),f=this.parent;if(f&&f.id!==(e==null?void 0:e.id)&&this.removeFromParent(r),e)this.setParent(e,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${c}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.implements.forEach(c=>{const e=ie(c),f=this.project.get(e);if(f)this.addImplementation(f,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${e}" which is missing in the project`)}),this.implements.filter(c=>{const e=ie(c);return!i.implements.find(f=>ie(f)===e)}).forEach(c=>{this.removeImplementation(c,r)}),i.extends){const c=ie(i.extends),e=this.project.get(c);if(e)this.setExtends(e,r);else if(c)throw new Error(`${pr(this.type)} with id '${this.id}' has a 'extends' reference "${c}" which is missing in the project`)}else this.setExtends(null,r);if(i.dataType){const c=ie(i.dataType),e=this.project.get(c);e&&this.setDataType(e,r)}else this.setDataType(null,r);if(i.defaultValue){const c=ie(i.defaultValue),e=this.project.get(c);e&&this.setDefaultValue(e,r)}else this.setDefaultValue(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const c=ie(i.parent),e=this.project.get(c),f=this.parent;if(f&&f.id!==(e==null?void 0:e.id)&&this.removeFromParent(r),e)this.setParent(e,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${c}' that isn't found in the project`)}if((a=i.implements)==null||a.forEach(c=>{const e=ie(c),f=this.project.get(e);if(f)this.addImplementation(f,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${e}" which is missing in the project`)}),i.implements&&this.implements.filter(e=>{const f=ie(e);return!(i.implements||[]).find(h=>ie(h)===f)}).forEach(e=>{this.removeImplementation(e,r)}),i.extends){const c=ie(i.extends),e=this.project.get(c);if(e)this.setExtends(e,r);else if(c)throw new Error(`${pr(this.type)} with id '${this.id}' has a 'extends' reference "${c}" which is missing in the project`)}else i.extends===null&&this.setExtends(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null);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.implements||[]).forEach(e=>{const f=ie(e),h=this.project.get(f);if(h)this.addImplementation(h,null),i.push(h);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${f}" which is missing in the project`)}),this.initialData.extends){const e=ie(this.initialData.extends),f=this.project.get(e);if(f)this.setExtends(f,null),i.push(f);else if(e)throw new Error(`${pr(this.type)} with id '${this.id}' has a 'extends' reference "${e}" which is missing in the project`)}return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){var q;if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.initialized=!0,this.parent.type===d.DefinitionEntity&&this.parentRelationType!==Qd.AllPropertiesImplementationTarget){let re=this.index||0;const ee=this.parent.properties.filter(te=>!te.deleted&&te.id!==this.id);ee.length&&(re>ee.length+1?re=ee.length:re<0&&(re=0)),ee.find(te=>(te.index||0)===re&&!te.deleted)&&ee.filter(te=>(te.index||0)>=re&&!te.deleted).forEach(te=>{te.metaSync({index:(te.index||0)+1},i),i==null||i.add(te,W.Updated),r.push(te)}),this.metaSync({index:re},i)}if(this.defaultValue&&!this.project.diggestedBuiltInBaseEntitiesIds.has(this.id)&&this.project.diggestedBuiltInBaseEntitiesIds.has(this.defaultValue.id)){const re=this.defaultValue.clone(i,this);this.setDefaultValue(re,i)}const{updated:f,added:h,removed:m,affected:E}=this.syncWithImplementation(i);r.push(...f),a.push(...h),c.push(...m),e.push(...E);const{updated:b,added:A,removed:_,affected:P}=fF(this,i);r.push(...b),a.push(...A),c.push(..._),e.push(...P);const{updated:V,added:j,removed:M,affected:G}=this.syncWithExtension(i);return r.push(...V),a.push(...j),c.push(...M),e.push(...G),!this.project.diggestedBuiltInBaseEntitiesIds.has(this.id)&&this.project.initialized&&(this.extends&&((q=this.extends)==null?void 0:q.interactive)===!0&&(this.interactive||(this.metaSync({interactive:!0},i),r.push(this))),this.implements.every(re=>re.interactive===!0)&&(this.interactive||(this.metaSync({interactive:!0},i),r.push(this)))),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];return this.parentRelationType===Qd.AllPropertiesImplementationTarget?this.parent.setAllPropertiesImplement(this,i):this.parent.addProperty(this,i),r.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}addImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)||(this.implements.push(i),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this):(Y.Logger.warn(`[addImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this)}removeImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)&&(this.implements=this.implements.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this):(Y.Logger.warn(`[removeImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this)}setExtends(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetExtends))){var a;return this.checkCanEdit(this,r)?(((a=this.extends)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.extends=i,this.subscribeToDependencies(),r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetExtends,this.id),this):(Y.Logger.warn(`[setExtends] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetExtends,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=ge(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const r=ge(this.initialData.dataType,this.project);r.setParent(this,null),r.initChildren(i),this.dataType=r}if(this.implements=this.initialData.implements.map(r=>ge(r,this.project)),this.initialData.extends){const r=ge(this.initialData.extends,this.project);this.setExtends(r,null)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.codeName=a.codeName!==void 0?a.codeName:e.codeName,this.description=a.description!==void 0?a.description:e.description,this.abstract=a.abstract!==void 0?a.abstract:e.abstract,this.private=a.private!==void 0?a.private:e.private,this.index=a.index||(a.index!==0?e.index:0),this.static=a.static!==void 0?a.static:e.static,this.hidden=a.hidden!==void 0?a.hidden:e.hidden,this.constant=a.constant!==void 0?a.constant:e.constant,this.interactive=a.interactive!==void 0?a.interactive:e.interactive,this.required=a.required!==void 0?a.required:e.required,this.unique=a.unique!==void 0?a.unique:e.unique,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await yi.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await yi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await yi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await yi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await yi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await yi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return this.parent.type===d.DefinitionEntity&&(this.parentRelationType===Qd.AllPropertiesImplementationTarget?this.parent.removeAllPropertiesImplement(i):this.parent.removeProperty(this,i),e.push(this.parent)),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),this.defaultValue){const{updated:m,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},r);a.push(...m),c.push(...E)}if(this.dataType){const{updated:m,removed:E}=this.dataType.remove({ignoreUpstream:!0},r);a.push(...m),c.push(...E)}if(!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected)}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.defaultValue){const{updated:f}=this.defaultValue.restore({},i);a.push(...f)}if(this.dataType){const{updated:f}=this.dataType.restore({},i);a.push(...f)}return this.parent.type===d.DefinitionEntity&&(this.parentRelationType===Qd.AllPropertiesImplementationTarget?this.parent.removeAllPropertiesImplement(i):this.parent.addProperty(this,i),e.push(this.parent)),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((a=this.defaultValue)==null?void 0:a.toFlat(i))||[],...((c=this.dataType)==null?void 0:c.toFlat(i))||[],...this.parent.toFlat(i)])}toFlatIds(i=new Set){var a,c;if(i.has(this.id))return[];if(i.add(this.id),!this.parent)throw new Error(`Property with id '${this.id}' has no parent and cannot be flattened`);return[this.id,...((a=this.defaultValue)==null?void 0:a.toFlatIds(i))||[],...((c=this.dataType)==null?void 0:c.toFlatIds(i))||[],...this.parent.toFlatIds(i)]}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,index:this.index,hidden:this.hidden,private:this.private,abstract:this.abstract,required:this.required,unique:this.unique,constant:this.constant,interactive:this.interactive,static:this.static,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,unique:this.unique,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,parentRelationType:this.parentRelationType,defaultValue:((r=this.defaultValue)==null?void 0:r.toJSON(i))||null,dataType:((a=this.dataType)==null?void 0:a.toJSON(i))||null,implements:this.implements.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,index:this.index,unique:this.unique,private:this.private,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,parentRelationType:this.parentRelationType,defaultValue:((m=this.defaultValue)==null?void 0:m.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,implements:this.implements.map(b=>this.project.getBuiltIn(b.id)?b.toJSON(i.seenEntities):b.toJSONClone({...i,newId:null})),extends:(()=>{var b;return this.extends&&this.project.getBuiltIn(this.extends.id)?this.extends.toJSON():((b=this.extends)==null?void 0:b.toJSONClone({...i,newId:null}))||null})(),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,private:this.private,required:this.required,unique:this.unique,abstract:this.abstract,static:this.static,constant:this.constant,interactive:this.interactive,hidden:this.hidden,parentRelationType:this.parentRelationType,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,implements:this.implements.map(h=>h.toReference(i)),extends:((f=this.extends)==null?void 0:f.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.defaultValue)==null?void 0:a.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.implements.flatMap(e=>e.toFlatJSON(i)),...this.parent.toFlatJSON(i)])}toGenerationTarget(i=at){var a,c;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,parentRelationType:this.parentRelationType,implements:this.implements.map(e=>e.id),extends:(c=this.extends)==null?void 0:c.id,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var a,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.defaultValue)==null?void 0:a.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.implements.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,r;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),(r=this.dataType)==null||r.clearErrors(),this}validate(){return this.errors=kke(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await jke(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...((r=this.defaultValue)==null?void 0:r.getErrors())||[],...((a=this.dataType)==null?void 0:a.getErrors())||[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];if(await r.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:r});a.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:r});a.push(...c)}return a}getShallowErrors(){return this.errors}implement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"implement-self-as-property")),a=null){var E,b,A;const c=a||x.UUID.uuid(),e=yi.new(r);e.id=c,e.name=this.name,e.description=this.description,e.index=this.index,e.private=this.private,e.required=this.required,e.static=this.static,e.constant=this.constant,e.unique=this.unique,e.hidden=this.hidden,e.interactive=this.interactive,e.parent=i.toReference(),e.implements=[this.toJSON()];const f=ge(e,this.project);f.hydrateAncestors(),f.addSelfToProject(r),r==null||r.add(f,W.Added),f.initChildren(r);const h=(E=this.defaultValue)==null?void 0:E.clone(r,f,x.UUID.uuid());h&&(h.editable=!0,h.deletable=!0);const m=cF(this);if(m.result){let _=!1;if(!f.defaultValue){const P=Nr.new(r);P.value=m.value,P.name=m.name,P.parent=f.toReference();const V=ge(P,this.project);V.hydrateAncestors(),V.addSelfToProject(r),V.initChildren(r),f.setDefaultValue(V,r),_=!0}(b=this.defaultValue)==null||b.metaSync({value:m.value},r),_&&(r||(A=this.defaultValue)==null||A.captureVersion())}return r||f.captureVersion(),f}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var b,A;const e=Ur(r,this),f=a||x.UUID.uuid(),h=r||this.parent,m={hidden:!1,id:f,version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||"1",previousVersion:null,deleted:!1,type:this.type,editable:!0,deletable:!0,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,constant:this.constant,unique:this.unique,interactive:this.interactive,required:this.required,abstract:this.abstract,static:this.static,parentRelationType:this.parentRelationType,defaultValue:null,dataType:null,implements:this.implements.map(_=>_.toJSON()),extends:this.extends,parent:h.toReference()},E=nr(m,e);if(E.hydrateAncestors(),E.setParent(h,i),c&&(E.subscribe(),E.addSelfToProject(i)),E.initChildren(i),i==null||i.add(E,W.Added),this.dataType&&this.project.diggestedBuiltInBaseEntitiesIds.has(this.dataType.id))E.setDataType(e.getBuiltIn(this.dataType.id),i);else{const _=((b=this.dataType)==null?void 0:b.implement(E,i,x.UUID.uuid()))||null;_&&E.setDataType(_,i)}if(this.defaultValue){const _=(A=this.defaultValue)==null?void 0:A.clone(i,E,x.UUID.uuid(),c);E.setDefaultValue(_||null,i)}return this.implements.length&&this.implements.forEach(_=>{const P=e.get(_.id)||e.getBuiltIn(_.id);if(P){E.addImplementation(P,i);return}}),E.addSelfToProject(null),i||E.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),E}setDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetDataType,this.id),this;const a=this.dataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.dataType=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.dataType=null),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this):(Y.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType}getDefaultValue(){var c;let i=null;for(const e of this.implements){const f=e.getDefaultValue();(!i||kn(i))&&f&&(i=f)}let r=this.defaultValue;const a=(c=this.extends)==null?void 0:c.getDefaultValue();return kn(r)&&a&&!kn(a)&&(r=a),kn(r)&&i&&!kn(i)&&(r=i),r}setDefaultValue(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-default-value",this.id),this;const a=this.defaultValue;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.defaultValue=i,r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose("set-default-value",this.id),this}syncWithImplementation(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-with-implementation"))){var _,P,V,j;if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[syncWithImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose("sync-with-implementation",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];this.parent.type!==d.PrimitiveEntity&&this.interactive&&this.parent.getAllPropertiesImplements().filter(G=>G.id!==this.id).forEach(G=>{this.addImplementation(G,i)}),this.implements.find(M=>M.id===this.id)&&this.removeImplementation(this,i);let f=null,h=this.implements.filter(M=>{var ee;if(!M.dataType||!((ee=M.dataType)!=null&&ee.isResolved))return!1;const G=this.implements.filter(se=>se.id!==M.id);if(!G.length)return!0;const q=El(Sa(M.dataType),{removeDuplicates:!0,removeNulls:!0}).filter(se=>se.isResolved);return!!G.every(se=>!se.dataType||!se.dataType.isResolved?!0:El(Sa(se.dataType),{removeDuplicates:!0,removeNulls:!0}).filter(le=>le.isResolved).length>q.length)});if(h.length>1&&this.parent.type!==d.PrimitiveEntity){const M=this.parent.getAllPropertiesImplements()[0]||null;h=h.filter(G=>G.id!==(M==null?void 0:M.id))}if(!h.length&&this.parent.type!==d.PrimitiveEntity){const M=this.parent.getAllPropertiesImplements()[0]||null;M&&h.push(M)}for(const M of h)(_=M.dataType)!=null&&_.isResolved&&(f?((P=M.dataType.orChildrenGroup)!=null&&P.length&&M.dataType.implementationChooseOne||(V=M.dataType.orChildrenGroup)!=null&&V.length&&!M.dataType.implementationChooseOne)&&(f=M.dataType):f=M.dataType);if(f||this.parent.type!==d.PrimitiveEntity&&this.parent.additionalPropertiesDataType&&(f=this.parent.additionalPropertiesDataType),f&&!this.dataType){const M=f.implement(this,i,x.UUID.uuid());this.setDataType(M,i),a.push(M)}if((j=this.dataType)==null||j.merge(f,i,{implementSource:!0}),!this.defaultValue){let M=null;for(const G of this.implements){const q=G.getDefaultValue();q&&(M=q)}if(M){const G=M.clone(i,this,x.UUID.uuid(),!0);this.setDefaultValue(G,i),a.push(G)}}if(!this.defaultValue){const M=cF(this);if(M.result){const G=Nr.new(i);G.name=M.name,G.value=M.value,G.parent=this.toReference();const q=ge(G,this.project);q.hydrateAncestors(),q.addSelfToProject(i),q.initChildren(i),i==null||i.add(q,W.Added),i||q.captureVersion(),this.setDefaultValue(q,i),a.push(q)}}let m=!1,E=!1,b=!1,A=!1;return this.implements.forEach(M=>{M.required&&(m=!0),M.constant&&(b=!0),M.unique&&(E=!0),M.static&&(A=!0)}),this.metaSync({required:m||this.required,constant:b||this.constant,unique:E||this.unique,static:A||this.static},i),i==null||i.attemptAutoclose("sync-with-implementation",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncWithExtension(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-with-extension"))){var E,b,A;if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[syncWithExtension] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose("sync-with-extension",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(!this.extends)return i==null||i.attemptAutoclose("sync-with-extension",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const f={...this.extends.toMeta()};if(delete f.id,delete f.version,delete f.createdAt,delete f.previousVersion,delete f.author,delete f.index,this.metaSync(f,i),r.push(this),!this.extends.dataType)return i==null||i.attemptAutoclose("sync-with-extension",this.id),{added:[],updated:[],removed:[],affected:[],self:this};let h=!1;if(!this.dataType){const _=mr.new(i);_.parent=this.toReference();const P=ge(_,this.project);P.hydrateAncestors(),P.addSelfToProject(i),i==null||i.add(P,W.Added),P.afterAllChildrenInitialized(i),h=!0}if(di(this.dataType,this.extends.dataType).compatible||(E=this.dataType)==null||E.merge(this.extends.dataType,i),h&&(i||(b=this.dataType)==null||b.captureVersion()),this.extends.defaultValue&&!this.defaultValue){const _=this.extends.defaultValue.clone(i,this,x.UUID.uuid(),!0);this.setDefaultValue(_,i),a.push(_)}else this.extends.defaultValue?this.extends.defaultValue&&this.defaultValue&&!RFe(this.defaultValue,this.extends.defaultValue)&&(this.defaultValue.merge(this.extends.defaultValue,i),r.push(this.defaultValue)):((A=this.defaultValue)==null||A.remove({ignoreUpstream:!0},i),this.defaultValue=null,e.push(this));return i==null||i.attemptAutoclose("sync-with-extension",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}implementAsInputMap(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"implement-as-input-map")),r,a){const c=Ts.new(i);c.id=a||c.id,c.name=this.name,c.description=this.description,c.parent=r.toReference(),c.declaration=this.toJSON();const e=nr(c,this.project);if(e.hydrateAncestors(),e.addSelfToProject(i),i==null||i.add(e,W.Added),e.initChildren(i),this.dataType)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.dataType.id))e.setDataType(this.dataType,i),i==null||i.add(e,W.Affected);else{const f=this.dataType.clone(i,e);e.setDataType(f,i)}if(this.defaultValue){const f=this.defaultValue.clone(i,e);e.setDefaultValue(f,i)}return i||e.captureVersion(),i==null||i.attemptAutoclose("implement-as-input-map",this.id),e}};R(yi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(yi,"type",d.Property),R(yi,"USER_MANAGED_PARENT_TYPES",[d.DefinitionEntity]),R(yi,"PARENT_TYPES",[...yi.USER_MANAGED_PARENT_TYPES,d.PrimitiveEntity,d.BuiltInBaseEntity]),R(yi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","private","abstract","static","required","constant","unique","interactive"]),R(yi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","parentRelationType"]),R(yi,"BASE_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES,...yi.INMUTABLE_BASE_PROPERTIES]),R(yi,"MUTABLE_META_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES,"index"]),R(yi,"INMUTABLE_META_PROPERTIES",[...yi.INMUTABLE_BASE_PROPERTIES]),R(yi,"META_PROPERTIES",[...yi.MUTABLE_META_PROPERTIES,...yi.INMUTABLE_META_PROPERTIES]),R(yi,"MUTABLE_UPSTREAM_PROPERTIES",[]),R(yi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements","extends"]),R(yi,"UPSTREAM_PROPERTIES",[...yi.MUTABLE_UPSTREAM_PROPERTIES,...yi.INMUTABLE_UPSTREAM_PROPERTIES]),R(yi,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),R(yi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(yi,"DOWNSTREAM_PROPERTIES",[...yi.MUTABLE_DOWNSTREAM_PROPERTIES,...yi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(yi,"PROPERTIES",[...yi.META_PROPERTIES,...yi.UPSTREAM_PROPERTIES,...yi.DOWNSTREAM_PROPERTIES]);let Es=yi;async function Fke(s,p={}){var E,b;const i=Y.YieldTracker.from(p),r=s.implements.flatMap(A=>Zke(s,A)),a=Hke(s,s.extends),c=zke(s),e=Wke(s),f=bL(s),h=[...r,...a,...c,...e,...f],m=St(s.errors,h);await i.tick();for(const A of s.properties)await A.validateAsync({tracker:i});for(const A of s.methods)await A.validateAsync({tracker:i});for(const A of s.abstractMethods)await A.validateAsync({tracker:i});return await((E=s.allPropertiesImplement)==null?void 0:E.validateAsync({tracker:i})),await((b=s.additionalPropertiesDataType)==null?void 0:b.validateAsync({tracker:i})),m}function Kke(s){var h,m;const p=s.implements.flatMap(E=>Zke(s,E)),i=Hke(s,s.extends),r=zke(s),a=Wke(s),c=bL(s);s.properties.forEach(E=>{E.validate()}),s.methods.flatMap(E=>E.validate()),s.abstractMethods.flatMap(E=>E.validate()),(h=s.allPropertiesImplement)==null||h.validate(),(m=s.additionalPropertiesDataType)==null||m.validate();const e=[...p,...i,...r,...a,...c];return St(s.errors,e)}function qke(s,p){const i=p.properties.filter(c=>c.abstract),r=[];let a=[...s.properties];return i.forEach(c=>{const e=a.find(f=>!!f.implements.find(h=>h.id===c.id));e?a=a.filter(f=>f.id!==e.id):r.push(c)}),r}function Ske(s,p){const i=p.abstractMethods,r=[];let a=[...s.methods];return i.forEach(c=>{const e=a.find(f=>{var h;return((h=f.implements)==null?void 0:h.id)===c.id});e?a=a.filter(f=>f.id!==e.id):r.push(c)}),r}function Zke(s,p){const i=[];if(!p.abstract){const E=gt({id:s.id+"--"+be.ImplementingNonAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is implementing a non-abstract entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.ImplementingNonAbstractEntity,entity:s});return i.push(E.error),i}const r=p.properties.filter(E=>E.abstract),a=[];let c=[...s.properties];r.forEach(E=>{const b=c.find(A=>!!A.implements.find(_=>_.id===E.id));b?c=c.filter(A=>A.id!==b.id):a.push(E)}),a.length&&a.forEach(E=>{const b=gt({id:s.id+"--"+be.MissingPropertyImplementation+"--"+E.id,message:`Property "${E.name}" with id "${E.id}" of entity "${p.name}" with id "${p.id}" is not implemented when entity "${s.name}" with id "${s.id}" implements it`,severity:Te.Error,code:be.MissingPropertyImplementation,entity:s});i.push(b.error)});const e=[];let f=[...s.methods];p.abstractMethods.forEach(E=>{const b=f.find(A=>{var _;return((_=A.implements)==null?void 0:_.id)===E.id});b?f=f.filter(A=>A.id!==b.id):e.push(E)}),e.length&&e.forEach(E=>{const b=gt({id:s.id+"--"+be.MissingMethodImplementation+"--"+E.id,message:`Method "${E.name}" with id "${E.id}" of entity "${p.name}" with id "${p.id}" is not implemented when entity "${s.name}" with id "${s.id}" implements it`,severity:Te.Error,code:be.MissingMethodImplementation,entity:s});i.push(b.error)});const h=[];p.properties.forEach(E=>{const b=c.find(A=>A.name===E.name);b&&h.push([b,E])}),h.length&&h.forEach(([E])=>{const b=gt({id:s.id+"--"+Ce.PropertyOverwritesOtherSiblingWithSameName+"--"+E.id,message:`Property "${E.name}" with id "${E.id}" of entity "${s.name}" with id "${s.id}" overwrites the property with the same name from the base entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:Ce.PropertyOverwritesOtherSiblingWithSameName,entity:s});i.push(b.error)});const m=[];return p.methods.forEach(E=>{const b=f.find(A=>A.name===E.name);b&&m.push([b,E])}),m.length&&m.forEach(([E])=>{const b=gt({id:s.id+"--"+Ce.MethodOverwritesOtherSiblingWithSameName+"--"+E.id,message:`Method "${E.name}" with id "${E.id}" of entity "${s.name}" with id "${s.id}" overwrites the method with the same name from the base entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:Ce.MethodOverwritesOtherSiblingWithSameName,entity:s});i.push(b.error)}),i}function Hke(s,p){const i=[];if(!p)return i;const r=[];if(!s.abstract&&p.abstract){const c=gt({id:s.id+"--"+p.id+"--"+be.NonAbstractExtendingAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is not-abstract but is extending an abstract entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.NonAbstractExtendingAbstractEntity,entity:s,firstRelationship:p});return i.push(c.error),i}if(s.abstract&&!p.abstract){const c=gt({id:s.id+"--"+p.id+"--"+be.AbstractExtendingNonAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is abstract but is extending an non-abstract entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.AbstractExtendingNonAbstractEntity,entity:s,firstRelationship:p});return i.push(c.error),i}s.properties.forEach(c=>{const e=p.properties.find(f=>{var h;return f.name===c.name&&((h=c.extends)==null?void 0:h.id)!==f.id});c.implements.find(f=>f.id===(e==null?void 0:e.id))||e&&r.push(c)}),r.length&&r.forEach(c=>{const e=gt({id:s.id+"--"+Ce.PropertyOverwritesOtherSiblingWithSameName,message:`Property "${c.name}" with id "${c.id}" of entity "${s.name}" with id "${s.id}" overwrites the property with the same name from the extended entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:Ce.PropertyOverwritesOtherSiblingWithSameName,entity:s});i.push(e.error)});const a=[];return s.methods.forEach(c=>{var f;const e=p.methods.find(h=>{var m;return h.name===c.name&&((m=c.extends)==null?void 0:m.id)!==h.id});((f=c.implements)==null?void 0:f.id)!==(e==null?void 0:e.id)&&e&&a.push(c)}),a.length&&a.forEach(c=>{const e=gt({id:s.id+"--"+Ce.MethodOverwritesOtherSiblingWithSameName,message:`Method "${c.name}" with id "${c.id}" of entity "${s.name}" with id "${s.id}" overwrites the method with the same name from the extended entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:Ce.MethodOverwritesOtherSiblingWithSameName,entity:s});i.push(e.error)}),i}function Wke(s){const p=[];if(!s.properties.length){const i=gt({id:s.id+"--"+be.NoProperties,message:"No properties implemented",severity:Te.Warning,code:be.NoProperties,entity:s});p.push(i.error)}return p}function zke(s){const p=[];if(s.abstract){if(s.methods.length){const i=gt({id:s.id+"--"+be.AbstractEntityWithNonAbstractMethods,message:`Entity "${s.name}" with id "${s.id}" is marked as abstract but has non-abstract methods`,severity:Te.Error,code:be.AbstractEntityWithNonAbstractMethods,entity:s});p.push(i.error)}if(s.properties.some(i=>!i.abstract)){const i=gt({id:s.id+"--"+be.AbstractEntityWithNonAbstractProperties,message:`Entity "${s.name}" with id "${s.id}" is marked as abstract but has non-abstract properties`,severity:Te.Error,code:be.AbstractEntityWithNonAbstractProperties,entity:s});p.push(i.error),s.properties.forEach(r=>{if(!r.abstract){const a=gt({id:s.id+"--"+be.StaticEntityWithNonStaticProperties+"--"+r.id,message:`Property "${r.name}" with id "${r.id}" of entity "${s.name}" with id "${s.id}" is not marked as abstract but the entity is marked as abstract`,severity:Te.Error,code:be.StaticEntityWithNonStaticProperties,entity:s});p.push(a.error)}})}}else{if(s.abstractMethods.length){const i=gt({id:s.id+"--"+be.AbstractPropertyInNonAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is not marked as abstract but has abstract methods`,severity:Te.Error,code:be.AbstractPropertyInNonAbstractEntity,entity:s});p.push(i.error)}s.properties.some(i=>i.abstract)&&s.properties.forEach(i=>{if(i.abstract){const r=gt({id:s.id+"--"+be.AbstractPropertyInNonAbstractEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${s.name}" with id "${s.id}" is marked as abstract but the entity is not marked as abstract`,severity:Te.Error,code:be.AbstractPropertyInNonAbstractEntity,entity:s,firstRelationship:i});p.push(r.error)}})}return s.static&&s.properties.some(i=>!i.static)&&s.properties.forEach(i=>{if(!i.static){const r=gt({id:s.id+"--"+be.NonStaticPropertyInStaticEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${s.name}" with id "${s.id}" is not marked as static but the entity is marked as static`,severity:Te.Error,code:be.NonStaticPropertyInStaticEntity,entity:s,firstRelationship:i});p.push(r.error)}}),p}function DVi(s,p){const i=[],r=Xn(p);if(!p.abstract){const e=new Fi({id:s.id+"--"+p.id+"--"+be.ImplementingNonAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is implementing a non-abstract built-in entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.ImplementingNonAbstractEntity,entity:s,firstRelationship:p});i.push(e)}const a=s.implements.filter(e=>e.id!==p.id);if(s.abstract){const e=new Fi({id:s.id+"--"+p.id+"--"+be.AbstractEntityImplements,message:`Entity "${s.name}" with id "${s.id}" is marked as abstract and cannot implement built-in entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.AbstractEntityImplements,entity:s,firstRelationship:p});i.push(e)}if(s.static&&!p.static){const e=new Fi({id:s.id+"--"+p.id+"--"+be.StaticImplementingNonStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is marked as static and cannot implement non-static built-in entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.StaticImplementingNonStaticEntity,entity:s,firstRelationship:p});i.push(e)}if(!s.static&&p.static){const e=new Fi({id:s.id+"--"+p.id+"--"+be.NonStaticImplementingStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is not marked as static and cannot implement static built-in entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.NonStaticImplementingStaticEntity,entity:s,firstRelationship:p});i.push(e)}return a.length&&a.forEach(e=>{if(e.type===d.BuiltInBaseEntity){const f=r.filter(h=>h.id!==e.id);f.length&&f.forEach(h=>{if(h.id!==e.id){const m=new Fi({id:s.id+"--"+h.id+"--"+e.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is implementing built-in entity "${h.name}" with id "${h.id}" but also implements entity "${e.name}" with id "${e.id}" which is incompatible`,severity:Te.Error,code:be.ImplementsIncompatibleEntities,entity:s,firstRelationship:h,secondRelationship:e});i.push(m)}})}else{Xn(e).forEach(E=>{const b=r.filter(A=>A.id!==E.id);b.length&&b.forEach(A=>{if(A.id!==E.id){const _=new Fi({id:s.id+"--"+A.id+"--"+E.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is implementing built-in entity "${A.name}" with id "${A.id}" but also implements entity "${E.name}" with id "${E.id}" which is incompatible`,severity:Te.Error,code:be.ImplementsIncompatibleEntities,entity:s,firstRelationship:A,secondRelationship:E});i.push(_)}})});const h=Yd(p.ownDeclaredProperties,e.ownDeclaredProperties,Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);i.push(...h.errors);const m=Yd(p.abstractMethods,[...e.abstractMethods,...e.methods],Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameName);i.push(...m.errors)}}),C(s.extends?Xn(s.extends):[]).forEach(e=>{if(!r.find(f=>f.id===e.id)){const f=new Fi({id:s.id+"--"+p.id+"--"+e.id+"--"+be.ExtendsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is implementing built-in entity "${p.name}" with id "${p.id}" but also extends entity "${e.name}" with id "${e.id}" which is incompatible`,severity:Te.Error,code:be.ExtendsIncompatibleEntities,entity:s,firstRelationship:p,secondRelationship:e});i.push(f)}}),i}function wVi(s,p,i=!1){var m,E;const r=[],a=Xn(p);if(!s.abstract&&p.abstract){const b=gt({id:s.id+"--"+p.id+"--"+be.NonAbstractExtendingAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is not-abstract but is extending an abstract entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.NonAbstractExtendingAbstractEntity,entity:s,firstRelationship:p});r.push(b.error)}if(s.abstract&&!p.abstract){const b=gt({id:s.id+"--"+p.id+"--"+be.AbstractExtendingNonAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is abstract but is extending an non-abstract entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.AbstractExtendingNonAbstractEntity,entity:s,firstRelationship:p});r.push(b.error)}if(!s.static&&p.static){const b=gt({id:s.id+"--"+p.id+"--"+be.NonStaticExtendingStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is not static but is extending a static entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.NonStaticExtendingStaticEntity,entity:s,firstRelationship:p});r.push(b.error)}if(s.static&&!p.static){const b=gt({id:s.id+"--"+p.id+"--"+be.StaticExtendingNonStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is static but is extending an non-static entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.StaticExtendingNonStaticEntity,entity:s,firstRelationship:p});r.push(b.error)}if(!bl(p)){const b=gt({id:s.id+"--"+p.id+"--"+be.ExtendingNonInteractiveEntity,message:`Entity "${s.name}" with id "${s.id}" is extending an non-interactive entity "${p.name}" with id "${p.id}"`,severity:Te.Error,code:be.ExtendingNonInteractiveEntity,entity:s,firstRelationship:p});r.push(b.error)}if(s.extends&&((m=s.extends)==null?void 0:m.id)!==p.id)if(((E=s.extends)==null?void 0:E.type)===d.BuiltInBaseEntity){const b=a.filter(A=>{var _;return A.id!==((_=s.extends)==null?void 0:_.id)});b.length&&b.forEach(A=>{var _,P,V,j;if(A.id!==((_=s.extends)==null?void 0:_.id)){const M=gt({id:s.id+"--"+A.id+"--"+((P=s.extends)==null?void 0:P.id)+"--"+be.ExtendsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is extending built-in entity "${A.name}" with id "${A.id}" but also extends entity "${(V=s.extends)==null?void 0:V.name}" with id "${(j=s.extends)==null?void 0:j.id}" which is incompatible`,severity:Te.Error,code:be.ExtendsIncompatibleEntities,entity:s,firstRelationship:A,secondRelationship:s.extends});r.push(M.error)}})}else{Xn(s.extends).forEach(M=>{const G=a.filter(q=>q.id!==M.id);G.length&&G.forEach(q=>{if(q.id!==M.id){const re=new Fi({id:s.id+"--"+q.id+"--"+M.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is extending built-in entity "${q.name}" with id "${q.id}" but also extends or implements entity "${M.name}" with id "${M.id}" which is incompatible`,severity:Te.Error,code:be.ImplementsIncompatibleEntities,entity:s,firstRelationship:q,secondRelationship:M});r.push(re)}})});const A=!!Xn(s.extends).find(M=>M.id===p.id);let _=[...s.extends.properties];A&&(_=_.filter(M=>!p.properties.find(G=>G.id===M.id||G.name===M.name||!!M.implements.find(q=>q.id===G.id))));let P=[...s.extends.methods];A&&(P=P.filter(M=>!p.methods.find(G=>{var q;return G.id===M.id||G.name===M.name||G.id===((q=M.implements)==null?void 0:q.id)})));const V=Yd(p.ownDeclaredProperties,_,Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation,Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameName);r.push(...V.errors);const j=Yd(p.abstractMethods,P,Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation,Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameName);r.push(...j.errors)}i&&Y.Logger.log("self.implements.length",s.implements.length),s.implements.length&&s.implements.forEach(b=>{if(b.type===d.BuiltInBaseEntity){const A=a.filter(_=>_.id!==b.id);A.length&&A.forEach(_=>{if(_.id!==b.id){const P=new Fi({id:s.id+"--"+_.id+"--"+b.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is implementing built-in entity "${_.name}" with id "${_.id}" but also implements entity "${b.name}" with id "${b.id}" which is incompatible`,severity:Te.Error,code:be.ImplementsIncompatibleEntities,entity:s,firstRelationship:_,secondRelationship:b});r.push(P)}})}else{Xn(b).forEach(V=>{const j=a.filter(M=>M.id!==V.id);j.length&&j.forEach(M=>{if(M.id!==V.id){const G=new Fi({id:s.id+"--"+M.id+"--"+V.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is implementing built-in entity "${M.name}" with id "${M.id}" but also implements entity "${V.name}" with id "${V.id}" which is incompatible`,severity:Te.Error,code:be.ImplementsIncompatibleEntities,entity:s,firstRelationship:M,secondRelationship:V});r.push(G)}})});const _=Yd(p.ownDeclaredProperties,b.ownDeclaredProperties,Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);r.push(..._.errors);const P=Yd(p.abstractMethods,[...b.abstractMethods,...b.methods],Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameName);r.push(...P.errors)}});const e=Yd(s.ownDeclaredProperties,p.ownDeclaredProperties,Ce.PropertyOverwritesOtherSiblingWithSameImplementation,Ce.PropertyOverwritesOtherSiblingWithSameName);r.push(...e.errors);const f=Yd(p.methods,p.abstractMethods,Ce.MethodOverwritesOtherSiblingWithSameImplementation,Ce.MethodOverwritesOtherSiblingWithSameName);return r.push(...f.errors),C(s.extends?Xn(s.extends):[]).forEach(b=>{if(!a.find(A=>A.id===b.id)){const A=new Fi({id:s.id+"--"+p.id+"--"+b.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${s.name}" with id "${s.id}" is extending built-in entity "${p.name}" with id "${p.id}" but also extends entity "${b.name}" with id "${b.id}" which is incompatible`,severity:Te.Error,code:be.ImplementsIncompatibleEntities,entity:s,firstRelationship:p,secondRelationship:b});r.push(A)}}),r}function CVi(s){const p=[];if(s.implements.forEach(i=>{if(!i.static){const r=new Fi({id:s.id+"--"+i.id+"--"+be.StaticImplementingNonStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is static but implements entity "${i.name}" with id "${i.id}" which is non-static`,severity:Te.Error,code:be.StaticImplementingNonStaticEntity,entity:s,firstRelationship:i});p.push(r)}}),s.extends&&!s.extends.static){const i=new Fi({id:s.id+"--"+s.extends.id+"--"+be.StaticExtendingNonStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is static but extends entity "${s.extends.name}" with id "${s.extends.id}" which is non-static`,severity:Te.Error,code:be.StaticExtendingNonStaticEntity,entity:s,firstRelationship:s.extends});p.push(i)}return p}function OVi(s){const p=[];if(s.implements.length){const i=new Fi({id:s.id+"--"+be.AbstractEntityImplements,message:`Entity "${s.name}" with id "${s.id}" cannot be marked as abstract because it implements other entities`,severity:Te.Error,code:be.AbstractEntityImplements,entity:s});p.push(i)}if(s.extends&&!s.extends.abstract){const i=new Fi({id:s.id+"--"+s.extends.id+"--"+be.AbstractExtendingNonAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is abstract but extends entity "${s.extends.name}" with id "${s.extends.id}" which is non-abstract`,severity:Te.Error,code:be.AbstractExtendingNonAbstractEntity,entity:s,firstRelationship:s.extends});p.push(i)}return p}function _Vi(s){const p=[];if(s.extends&&s.extends.static){const i=new Fi({id:s.id+"--"+s.extends.id+"--"+be.NonStaticExtendingStaticEntity,message:`Entity "${s.name}" with id "${s.id}" is non-static but extends entity "${s.extends.name}" with id "${s.extends.id}" which is static`,severity:Te.Error,code:be.NonStaticExtendingStaticEntity,entity:s,firstRelationship:s.extends});p.push(i)}return p}function VVi(s){const p=[];if(s.extends&&s.extends.abstract){const i=new Fi({id:s.id+"--"+s.extends.id+"--"+be.NonAbstractExtendingAbstractEntity,message:`Entity "${s.name}" with id "${s.id}" is non-abstract but extends entity "${s.extends.name}" with id "${s.extends.id}" which is abstract`,severity:Te.Error,code:be.NonAbstractExtendingAbstractEntity,entity:s,firstRelationship:s.extends});p.push(i)}return p}function bL(s,p){const r=[...s.project.entities].filter(a=>a.id!==s.id);return QE(s,[Xi,md],r,p)}const PVi=Object.freeze(Object.defineProperty({__proto__:null,getBaseMethodsNotImplemented:Ske,getBasePropertiesNotImplemented:qke,validate:Kke,validateAsync:Fke,validateCanBecomeAbstract:OVi,validateCanBecomeNonAbstract:VVi,validateCanBecomeNonStatic:_Vi,validateCanBecomeStatic:CVi,validateCanExtendEntity:wVi,validateCanImplementEntity:DVi,validateDefinitionEntityName:bL},Symbol.toStringTag,{value:"Module"}));function NVi(s,p){const i=[],r=[];if(s.parent)if(s.id===s.parent)r.push(new De({id:`${s.id}--${s.parent}--${he.SelfReference}`,code:he.SelfReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has a reference to itself at 'parent'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`}));else{const a=p.get(s.parent);a?[d.Project,d.DataType].includes(a.type)||r.push(new De({id:`${s.id}--${s.parent}--${he.InvalidParentReference}`,code:he.InvalidParentReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has a parent reference which is of type ${a.type}, and therefore that isn't pointing to the following valid types for this reference: 'project' or 'data-type'.`})):r.push(new De({id:`${s.id}--${s.parent}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", is referencing an entity with id "${s.parent}" at 'parent' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}return s.implements&&Array.isArray(s.implements)?s.implements.forEach(a=>{if(s.id===a){r.push(new De({id:`${s.id}--${a}--${he.SelfReference}`,code:he.SelfReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has a reference to itself at one of the 'implements' references. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`}));return}const c=p.get(a);c?[d.DefinitionEntity,d.BuiltInBaseEntity].includes(c.type)?c.abstract||r.push(new De({id:`${s.id}--${a}--${he.InvalidImplementsReference}`,code:he.InvalidImplementsReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has an 'implements' reference that isn't pointing to an abstract entity.`})):r.push(new De({id:`${s.id}--${a}--${he.InvalidImplementsReference}`,code:he.InvalidImplementsReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has an 'implements' reference which is of type ${c.type}, and therefore that isn't pointing to the following valid types for this reference: 'definition-entity' or 'built-in-base-entity'.`})):r.push(new De({id:`${s.id}--${a}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", is referencing an entity with id "${a}" at 'implements' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}):r.push(new De({id:`${s.id}--${Ce.InvalidObjectStructure}`,code:Ce.InvalidObjectStructure,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has an 'implements' property that isn't an array.`})),s.extends&&Array.isArray(s.extends)&&s.extends.forEach(a=>{const c=p.get(a);c?[d.DefinitionEntity,d.BuiltInBaseEntity].includes(c.type)?c.abstract&&r.push(new De({id:`${s.id}--${a}--${he.InvalidExtendsReference}`,code:he.InvalidExtendsReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has an 'extends' reference that isn't pointing to a non-abstract entity. Did you want to use the property 'implements', which holds a list of references to absract entities, instead?`})):r.push(new De({id:`${s.id}--${a}--${he.InvalidExtendsReference}`,code:he.InvalidExtendsReference,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", has an 'extends' reference which is of type ${c.type}, and therefore that isn't pointing to the following valid types for this reference: 'definition-entity' or 'built-in-base-entity'.`})):r.push(new De({id:`${s.id}--${a}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:Te.Error,message:`Entity of type "${s.type}" with id "${s.id}", is referencing an entity with id "${a}" at 'extends' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}),{errors:r,explanations:i}}var zg=(s=>(s.Extends="extends",s.Implements="implements",s))(zg||{});const Pi=class Pi extends dn{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"name");R(this,"codeName",null);R(this,"description",null);R(this,"x");R(this,"y");R(this,"static");R(this,"abstract");R(this,"type",d.DefinitionEntity);R(this,"additionalProperties",!1);R(this,"properties",[]);R(this,"allPropertiesImplement",null);R(this,"additionalPropertiesDataType",null);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"implements",[]);R(this,"project");R(this,"errors",[]);R(this,"parent");R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"suggestedProperties",[]);R(this,"suggestedMethods",[]);this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.description=i.description,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.static=i.static,this.abstract=i.abstract}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DefinitionEntity,additionalProperties:!1,additionalPropertiesDataType:null,allPropertiesImplement:null,name:"",codeName:null,description:"",static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:null}}static fromGenerationTarget(i,r,a){const c=a===void 0?r.addChangeSet(new S(r,x.sessionAuthor,B().toISOString(),r,!0,w.CreateFromGenerationTarget)):a;let e=r;if(i.parent){const b=ie(i.parent);e=r.get(b)}const f=[];i.implements&&i.implements.forEach(b=>{f.push(r.get(b)||r.getBuiltIn(b))});let h=null;i.extends&&(h=r.get(i.extends)||r.getBuiltIn(i.extends));const m={id:i.id,version:x.UUID.uuid(),createdAt:(c==null?void 0:c.timestamp)||B().toISOString(),author:(c==null?void 0:c.author)||x.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:d.DefinitionEntity,codeName:i.codeName||null,description:i.description||null,static:i.static??!1,abstract:i.abstract??!1,additionalProperties:i.additionalProperties??!1,allPropertiesImplement:null,additionalPropertiesDataType:null,properties:[],methods:[],abstractMethods:[],extends:h,implements:f,x:0,y:0,parent:e.toReference()},E=ge(m,r);return E.hydrateAncestors(),E.setParent(e,c),E.addSelfToProject(c),c==null||c.add(E,W.Added),E.initChildren(c),c||E.captureVersion(),E}static validateGenerationTarget(i,r){var b;let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=NVi(a,r),h=Ox(a,r),m=Qr(a);e.push(...f.errors,...h,...m.errors),c.push(...f.explanations,...m.explanations);const E=a.parent?r.get(a.parent):null;if(E&&E.type===d.DataType){const A=E;A.entity&&A.entity.type===d.DefinitionEntity&&((b=A.entity.parent)==null?void 0:b.id)!==A.id&&e.push(new De({id:`${i.id}--${he.NewEntityWouldOverriteExisting}`,code:he.NewEntityWouldOverriteExisting,severity:Te.Error,message:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${A.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
|
|
536
536
|
You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
|
|
537
537
|
${fp({describe_entity:A.entity.id})}
|
|
538
|
-
Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`}))}return{errors:e,explanations:c,modifiedData:a}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.type)===d.DefinitionEntity?this.extends.allMethods:[],r=[...i].filter(c=>!i.some(e=>{var f,h;return e.id!==c.id&&(((f=e.implements)==null?void 0:f.id)===c.id||((h=e.extends)==null?void 0:h.id)===c.id)}));return C([...r,...this.implements.flatMap(c=>{const e=c.type===d.DefinitionEntity?[...c.allMethods]:[];return[...e].filter(h=>!e.some(m=>{var E,b;return m.id!==h.id&&(((E=m.implements)==null?void 0:E.id)===h.id||((b=m.extends)==null?void 0:b.id)===h.id)}))})])}get allBasePropertiesFromOriginalParents(){var c;const i=((c=this.extends)==null?void 0:c.allProperties)||[],r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C([...r,...this.implements.flatMap(e=>{const f=[...e.allProperties];return[...f].filter(m=>!f.some(E=>{var b;return E.id!==m.id&&(!!E.implements.find(A=>A.id===m.id)||((b=E.extends)==null?void 0:b.id)===m.id)}))})])}get allBasePropertiesFromExtendedAndImplementedEntities(){var c,e;const i=[...((c=this.extends)==null?void 0:c.ownDeclaredProperties)||[],...((e=this.extends)==null?void 0:e.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(f=>!f.abstract),r=[...i].filter(f=>!i.some(h=>{var m;return h.id!==f.id&&(!!h.implements.find(E=>E.id===f.id)||((m=h.extends)==null?void 0:m.id)===f.id)})),a=this.implements.reduce((f,h)=>{const m=h.implementedPropertiesFromOriginalParents,E=[...h.ownDeclaredProperties].filter(_=>!_.abstract),b=[...m,...E,...f];return[...b].filter(_=>!!!b.find(V=>{var j;return!!V.implements.find(M=>M.id===_.id)||((j=V.extends)==null?void 0:j.id)===_.id}))},[]);return C([...r,...a])}get allBaseMethodsFromExtendedAndImplementedEntities(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>r.type!==d.DefinitionEntity?[]:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[]),...this.implements.reduce((i,r)=>r.type!==d.DefinitionEntity?r.abstractMethods:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||!!E.implements.find(A=>A.id===h.id)}))},[]),...this.implements.reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return!!E.implements.find(A=>A.id===h.id)||((b=E.extends)==null?void 0:b.id)===h.id}))},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return C((this.extends?[this.extends]:[]).reduce((i,r)=>{if(r.type!==d.DefinitionEntity)return[];const a=[...r.ownDeclaredMethods,...r.extendedMethodsFromOriginalParents].filter(c=>c.type!==d.ActionDescriptor);return[...i,...a]},[]))}get implementedMethodsFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.type===d.DefinitionEntity?r.methods:[],c=[...r.abstractMethods].filter(e=>!a.find(f=>f.name===e.name));return[...a,...c,...i]},[]),...this.implements.reduce((i,r)=>[...r.abstractMethods,...i],[])].filter(i=>i.type===d.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(r=>!r.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new De({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:Te.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return r==="implements"&&(this.removeImplementation(i,a),c.push(this)),r==="extends"&&(this.setExtension(null,a),c.push(this)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return r==="implements"&&(this.addImplementation(i,a),c.push(this)),r==="extends"&&(this.setExtension(i,a),c.push(this)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{ma.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this.extends&&(ma.includes(this.extends.type)||this.extends.unsubscribeDependents([{entity:this,field:"extends"}])),this}subscribeToDependencies(){return this.implements.forEach(i=>{ma.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends&&(ma.includes(this.extends.type)||this.extends.subscribeDependents([{entity:this,field:"extends"}])),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new Pi(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new Pi(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=this.extends,i.implements=[...this.implements],i.allPropertiesImplement=this.allPropertiesImplement,i.additionalPropertiesDataType=this.additionalPropertiesDataType,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new Pi(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.properties=[...h.properties],this.methods=[...h.methods],this.abstractMethods=[...h.abstractMethods],this.extends=h.extends,this.implements=[...h.implements],this.allPropertiesImplement=h.allPropertiesImplement,this.additionalPropertiesDataType=h.additionalPropertiesDataType,this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const f=ie(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.extends){const f=ie(i.extends),h=this.project.get(f);h&&this.setExtension(h,r)}else this.setExtension(null,r);if(i.implements.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addImplementation(m,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${h}" which is missing in the project`)}),this.implements.filter(f=>{const h=ie(f);return!i.implements.find(m=>ie(m)===h)}).forEach(f=>{this.removeImplementation(f,r)}),i.methods.forEach(f=>{const h=ie(f),m=this.project.get(h);m&&this.addMethod(m,r)}),this.methods.filter(f=>{const h=ie(f);return!i.methods.find(m=>ie(m)===h)}).forEach(f=>{this.removeMethod(f,r)}),i.properties.forEach(f=>{const h=ie(f),m=this.project.get(h);m&&this.addProperty(m,r)}),this.properties.filter(f=>{const h=ie(f);return!i.properties.find(m=>ie(m)===h)}).forEach(f=>{this.removeProperty(f,r)}),i.allPropertiesImplement){const f=ie(i.allPropertiesImplement),h=this.project.get(f);h&&this.setAllPropertiesImplement(h,r)}else this.setAllPropertiesImplement(null,r);if(i.additionalPropertiesDataType){const f=ie(i.additionalPropertiesDataType),h=this.project.get(f);h&&this.setAdditionalPropertiesDataType(h,r)}else this.setAdditionalPropertiesDataType(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const c=ie(i.parent),e=this.project.get(c),f=this.parent;if(f&&f.id!==(e==null?void 0:e.id)&&this.removeFromParent(r),e)this.setParent(e,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${c}' that isn't found in the project`)}if(i.extends){const c=ie(i.extends),e=this.project.get(c);if(e)this.setExtension(e,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has an 'extends' reference "${c}" which is missing in the project`)}else i.extends===null&&this.setExtension(null,r);return(a=i.implements)==null||a.forEach(c=>{const e=ie(c),f=this.project.get(e);if(f)this.addImplementation(f,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${e}" which is missing in the project`)}),i.implements&&this.implements.filter(e=>{const f=ie(e);return!(i.implements||[]).find(h=>ie(h)===f)}).forEach(e=>{this.removeImplementation(e,r)}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.extends){const e=ie(this.initialData.extends),f=this.project.get(e);f&&(this.setExtension(f,null),f.type!==d.BuiltInBaseEntity&&i.push(f))}return this.initialData.implements.forEach(e=>{const f=ie(e),h=this.project.get(f);if(h)this.addImplementation(h,null),h.type!==d.BuiltInBaseEntity&&i.push(h);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${f}" which is missing in the project`)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];this.initialized=!0;const{updated:f,added:h,removed:m,affected:E}=this.syncImplementationProperties(i);r.push(...f),a.push(...h),c.push(...m),e.push(...E);const{updated:b,added:A,removed:_,affected:P}=this.addExtendedProperties(i);r.push(...b),a.push(...A),c.push(..._),e.push(...P);const{updated:V,added:j,removed:M}=this.removeUnrecognizedProperties(i);r.push(...V),a.push(...j),c.push(...M);const{updated:G,added:q,removed:re,affected:ee}=this.syncImplementationMethods(i);r.push(...G),a.push(...q),c.push(...re),e.push(...ee);const{updated:se,added:te,removed:le,affected:ue}=this.addExtendedMethods(i);r.push(...se),a.push(...te),c.push(...le),e.push(...ue);const{updated:z,added:X,removed:pe}=this.removeUnrecognizedMethods(i);r.push(...z),a.push(...X),c.push(...pe),this.addSuggestions(),this.properties.sort((me,ve)=>me.index-ve.index);const de=this.project.getDefinitionEntities(new Set([this.id]));if(de.some(me=>me.id!==this.id&&me.name.toLowerCase()===this.name.toLowerCase())){const me=Rh(this.name,de);this.metaSync({name:me},i)}return i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];if(this.parent.type===d.DataType){const f=this.parent;f.entity=this,r.push(f)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setExtension(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetExtension))){var a;return this.checkCanEdit(this,r)?(((a=this.extends)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.extends=i,this.subscribeToDependencies(),r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetExtension,this.id),this):(Y.Logger.warn(`[setExtension] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetExtension,this.id),this)}addImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)||(this.implements.push(i),this.subscribeToDependencies(),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this):(Y.Logger.warn(`[addImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this)}removeImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)&&(this.implements=this.implements.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this):(Y.Logger.warn(`[removeImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this)}removeProperty(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveProperty))){return this.checkCanEdit(this,r)?(this.properties.includes(i)&&(this.properties=this.properties.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveProperty,this.id),this):(Y.Logger.warn(`[removeProperty] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveProperty,this.id),this)}addMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddMethod))){return this.checkCanEdit(this,r)?(this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddMethod,this.id),this):(Y.Logger.warn(`[addMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddMethod,this.id),this)}removeMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveMethod))){return this.checkCanEdit(this,r)?(this.methods.includes(i)&&(this.methods=this.methods.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveMethod,this.id),this):(Y.Logger.warn(`[removeMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveMethod,this.id),this)}addProperty(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddProperty))){return this.checkCanEdit(this,r)?(this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddProperty,this.id),this):(Y.Logger.warn(`[addProperty] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddProperty,this.id),this)}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(r=>r.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(r=>r.id!==i.id),this}addAbstractMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddAbstractMethod))){return this.checkCanEdit(this,r)?(this.abstractMethods.includes(i)||(this.abstractMethods.push(i),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddAbstractMethod,this.id),this):(Y.Logger.warn(`[addAbstractMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddAbstractMethod,this.id),this)}removeAbstractMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAbstractMethod))){return this.checkCanEdit(this,r)?(this.abstractMethods.includes(i)&&(this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveAbstractMethod,this.id),this):(Y.Logger.warn(`[removeAbstractMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveAbstractMethod,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.properties=this.initialData.properties.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.methods=this.initialData.methods.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project)),this.implements=this.initialData.implements.map(r=>ge(r,this.project)),this.initialData.allPropertiesImplement){const r=ge(this.initialData.allPropertiesImplement,this.project);r.setParent(this,null),r.initChildren(null),this.setAllPropertiesImplement(r,i)}if(this.initialData.additionalPropertiesDataType){const r=ge(this.initialData.additionalPropertiesDataType,this.project);r.setParent(this,null),r.initChildren(null),this.setAdditionalPropertiesDataType(r,i)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}removeUnrecognizedProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-unrecognized-properties"))){const r=[],a=[],c=[],e=[];let f=[...this.properties];f=f.filter(b=>b.parent.id===this.id),f=f.filter(b=>!b.isExtendedProperty);const h=this.implementedPropertiesFromOriginalParents,m=this.getAllPropertiesImplements();return f.filter(b=>this.interactive&&!b.implements.length?!1:!b.implements.find(_=>!!h.find(P=>P.id===_.id)||!!m.find(P=>P.id===_.id))).forEach(b=>{const A=b.remove({ignoreUpstream:!1},i);c.push(...A.removed),r.push(...A.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-unrecognized-methods"))){const r=[],a=[],c=[],e=[];let f=[...this.methods];f=f.filter(m=>m.parent.id===this.id),f=f.filter(m=>!m.isExtendedMethod);const h=this.implementedMethodsFromOriginalParents;return f=f.filter(m=>this.interactive&&!m.implements?!1:!h.find(E=>{var b;return E.id===((b=m.implements)==null?void 0:b.id)})),f.forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-implementation-methods"))){const r=[],a=[],c=[],e=[],f=this.methods,h=this.implementedMethodsFromOriginalParents,m=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...f];return h.filter(b=>!m.find(_=>{var P;return((P=_.implements)==null?void 0:P.id)===b.id})).forEach(b=>{if(this.methods.find(V=>{var j;return((j=V.implements)==null?void 0:j.id)===b.id}))return;const _=this.methods.find(V=>{var re,ee;if(V.name===b.name&&!V.implements)return!0;const j=si(this,Ae.CRON_JOB),M=si(this,Ae.HTTP_ENDPOINT),G=((re=V.implements)==null?void 0:re.id)===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,q=((ee=V.implements)==null?void 0:ee.id)===ne["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(j&&!q&&!M&&G||M&&!G&&!j&&q)});if(_&&_.type===d.FunctionDeclaration){_.setImplements(b,i),_.metaSync({name:b.name},i),i==null||i.add(_,W.Updated),i==null||i.add(this,W.Updated);return}const P=b.implementAsFunctionDeclaration(i,this);a.push(P),i==null||i.add(P,W.Added),this.addMethod(P,i)}),this.methods.sort((b,A)=>b.index-A.index).forEach(b=>{b.afterAllChildrenInitialized(i)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-implementation-properties"))){const r=[],a=[],c=[],e=[],f=this.properties,h=this.implementedPropertiesFromOriginalParents.filter(E=>!this.allBasePropertiesFromExtendedAndImplementedEntities.find(A=>!!A.implements.find(_=>_.id===E.id))),m=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...f];return h.forEach(E=>{const b=m.find(V=>!!V.implements.find(j=>j.id===E.id));if(b){const{updated:V,added:j,removed:M,affected:G}=b.syncWithImplementation(i);r.push(...V),a.push(...j),c.push(...M),e.push(...G);return}if(this.properties.find(V=>!!V.implements.find(j=>j.id===E.id)))return;const _=this.properties.find(V=>V.name===E.name&&!!V.abstract&&!V.implements);if(_){_.addImplementation(E,i),_.metaSync({abstract:!1},i),_.afterAllChildrenInitialized(i);return}const P=E.implement(this,i,x.UUID.uuid());a.push(P),i==null||i.add(P,W.Added)}),this.properties.find(E=>{var b;return E.id===((b=this.allPropertiesImplement)==null?void 0:b.id)})&&this.removeAllPropertiesImplement(i),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addExtendedMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-extended-methods"))){const r=[],a=[],c=[],e=[],f=this.methods,m=this.extendedMethodsFromOriginalParents.filter(b=>b.type===d.FunctionDeclaration),E=new Set(f.filter(b=>{var A;return!!((A=b.extends)!=null&&A.id)}).map(b=>b.extends.id));return m.forEach(b=>{if(E.has(b.id))return;E.add(b.id);const A=b.clone(i,this,x.UUID.uuid());A.setExtends(b,i),A.initChildren(i),a.push(A),i==null||i.add(A,W.Added),this.addMethod(A,i)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addExtendedProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-extended-properties"))){const r=[],a=[],c=[],e=[],f=this.properties,h=this.extendedPropertiesFromOriginalParents,m=h.filter(b=>h.find(_=>!!_.implements.find(P=>P.id===b.id))?!1:!b.abstract),E=new Set(f.filter(b=>{var A;return!!((A=b.extends)!=null&&A.id)}).map(b=>b.extends.id));return m.forEach(b=>{if(E.has(b.id))return;E.add(b.id);const A=b.clone(i,this,x.UUID.uuid());A.setExtends(b,i),A.initChildren(i),a.push(A),i==null||i.add(A,W.Added),this.addProperty(A,i)}),[...this.properties].forEach(b=>{if(b.extends)return;if(m.find(_=>_.name===b.name&&_.implements.every(P=>!!b.implements.find(V=>V.id===P.id)))){const _=b.remove({ignoreUpstream:!1},i);c.push(..._.removed),r.push(..._.updated)}}),this.properties.forEach(b=>{const A=b.afterAllChildrenInitialized(i);r.push(...A.updated),e.push(...A.affected),a.push(...A.added),c.push(...A.removed)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSuggestions(){return this.implements.forEach(i=>{qke(this,i).forEach(c=>{const e=c.toJSON();e.id=`_suggestion--parent--${this.id}--${c.id}`;const f=ge(e,this.project);f.suggestion=!0,f.setParent(this,null),f.initChildren(null),this.addSuggestedProperty(f)}),Ske(this,i).forEach(c=>{const e=`_suggestion--parent--${this.id}--${c.id}`,f=c.implementAsFunctionDeclaration(null,this,e),h=ge(f,this.project);if(h.suggestion=!0,h.setParent(this,null),h.initChildren(null),this.methods=this.methods.filter(m=>m.id!==e),h.inputs.forEach(m=>{m.suggestion=!0}),h.returnStatements.length){const m=h.returnStatements[0];m.suggestion=!0,m.outputs.forEach(E=>{E.suggestion=!0})}this.addSuggestedMethod(h)})}),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this.project.subscribedDefinitionEntities.add(this.id),this}unsubscribe(){return this.project.unsubscribeInstance(this),this.project.subscribedDefinitionEntities.delete(this.id),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.codeName=a.codeName!==void 0?a.codeName:e.codeName,this.description=a.description!==void 0?a.description:e.description,this.x=a.x||e.x,this.y=a.y||e.y,this.static=a.static!==void 0?a.static:this.static,this.abstract=a.abstract!==void 0?a.abstract:this.abstract,this.additionalProperties=a.additionalProperties!==void 0?a.additionalProperties:e.additionalProperties,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await Pi.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await Pi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await Pi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await Pi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await Pi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await Pi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.parent.type===d.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===d.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const f=this.parent.setEntity(null,i);r.push(f)}return i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),this.properties.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.methods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.abstractMethods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.suggestedProperties.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.suggestedMethods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected)}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.properties.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.methods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.abstractMethods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.suggestedProperties.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.suggestedMethods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this})}toFlat(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this,...((a=this.extends)==null?void 0:a.toFlat(i))||[],...this.implements.flatMap(c=>c.toFlat(i)),...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((a=this.extends)==null?void 0:a.toFlatIds(i))||[],...this.implements.flatMap(c=>c.toFlatIds(i)),...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,additionalProperties:this.additionalProperties,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((r=this.allPropertiesImplement)==null?void 0:r.toJSON(i))||null,additionalPropertiesDataType:((a=this.additionalPropertiesDataType)==null?void 0:a.toJSON(i))||null,properties:this.properties.map(e=>e.toJSON(i)),methods:this.methods.map(e=>e.toJSON(i)),abstractMethods:this.abstractMethods.map(e=>e.toJSON(i)),implements:this.implements.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E,b,A,_;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((m=this.allPropertiesImplement)==null?void 0:m.toJSONClone(i))||null,additionalPropertiesDataType:((E=this.additionalPropertiesDataType)==null?void 0:E.toJSONClone(i))||null,properties:this.properties.map(P=>P.toJSONClone({...i,newId:null})),methods:this.methods.map(P=>P.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(P=>P.toJSONClone({...i,newId:null})),implements:this.implements.map(P=>P.type===d.BuiltInBaseEntity?P.toJSON(i.seenEntities):P.toJSONClone({...i,newId:null})),extends:((b=this.extends)==null?void 0:b.type)===d.BuiltInBaseEntity?(A=this.extends)==null?void 0:A.toJSON(i.seenEntities):(_=this.extends)==null?void 0:_.toJSONClone({...i,newId:null}),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((c=this.allPropertiesImplement)==null?void 0:c.toReference(i))||null,additionalPropertiesDataType:((e=this.additionalPropertiesDataType)==null?void 0:e.toReference(i))||null,properties:this.properties.map(h=>h.toReference(i)),methods:this.methods.map(h=>h.toReference(i)),abstractMethods:this.abstractMethods.map(h=>h.toReference(i)),implements:this.implements.map(h=>h.toReference(i)),extends:((f=this.extends)==null?void 0:f.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(f=>f.toFlatJSON(i)),...this.methods.flatMap(f=>f.toFlatJSON(i)),...this.abstractMethods.flatMap(f=>f.toFlatJSON(i)),...this.implements.flatMap(f=>f.toFlatJSON(i)),...((a=this.extends)==null?void 0:a.toFlatJSON(i))||[],...this.parent.toFlatJSON(i),...((c=this.additionalPropertiesDataType)==null?void 0:c.toFlatJSON(i))||[],...((e=this.allPropertiesImplement)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var c,e,f;const r=this.parent.type===d.Project?void 0:(c=i.seenEntityMaps)!=null&&c.has(this.parent.id)?i.seenEntityMaps.get(this.parent.id):this.parent.id;let a=this.id;return(e=i.seenEntityMaps)!=null&&e.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:(f=this.extends)==null?void 0:f.id,additionalProperties:this.additionalProperties,implements:this.implements.map(h=>h.id),parent:r}}toFlatGenerationTarget(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(f=>f.toFlatGenerationTarget(i)),...this.methods.flatMap(f=>f.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(f=>f.toFlatGenerationTarget(i)),...this.implements.filter(f=>f.type===d.DefinitionEntity).flatMap(f=>f.toFlatGenerationTarget(i)),...((a=this.extends)==null?void 0:a.toFlatGenerationTarget(i))||[],...this.parent.toFlatGenerationTarget(i),...((c=this.additionalPropertiesDataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.allPropertiesImplement)==null?void 0:e.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,r;return this.errors=[],this.properties.forEach(a=>a.clearErrors()),this.methods.forEach(a=>a.clearErrors()),this.abstractMethods.forEach(a=>a.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(r=this.allPropertiesImplement)==null||r.clearErrors(),this}validate(){return this.errors=Kke(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await Fke(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((r=this.additionalPropertiesDataType)==null?void 0:r.getErrors())||[],...((a=this.allPropertiesImplement)==null?void 0:a.getErrors())||[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.methods)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.abstractMethods)a.push(...await c.getErrorsAsync({tracker:r}));return this.additionalPropertiesDataType&&a.push(...await this.additionalPropertiesDataType.getErrorsAsync({tracker:r})),this.allPropertiesImplement&&a.push(...await this.allPropertiesImplement.getErrorsAsync({tracker:r})),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var j,M,G;const e=Ur(r,this),f=this.toJSON(),h=a||x.UUID.uuid(),m=r||this.parent;f.properties=[],f.methods=[],f.abstractMethods=[];const E=h.split("-id"),b=E[E.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.editable=!0,f.deletable=!0,f.parent=m.toReference();const A=nr(f,e);A.hydrateAncestors(),A.setParent(m,i),c&&(A.subscribe(),A.addSelfToProject(i)),A.initChildren(i),i==null||i.add(A,W.Added);const _=(j=this.properties)==null?void 0:j.map(q=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,x.UUID.uuid(),c));A.properties=_;const P=(M=this.methods)==null?void 0:M.map((q,re)=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,b+"-method-"+re+"-id",c));A.methods=P;const V=(G=this.abstractMethods)==null?void 0:G.map((q,re)=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,b+"-abstract-method-"+re+"-id",c));if(A.abstractMethods=V,this.additionalPropertiesDataType)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.additionalPropertiesDataType.id))A.setAdditionalPropertiesDataType(this.additionalPropertiesDataType,i);else{const q=this.additionalPropertiesDataType.clone(i,A,x.UUID.uuid(),c);A.setAdditionalPropertiesDataType(q,i)}if(this.allPropertiesImplement)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.allPropertiesImplement.id))A.setAllPropertiesImplement(this.allPropertiesImplement,i);else{const q=this.allPropertiesImplement.clone(i,A,x.UUID.uuid(),c);A.setAllPropertiesImplement(q,i)}return i||A.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),A}getFunctionDeclaration(i){return this.methods.find(r=>r.id===i)}implement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"implement-definition-entity")),a){const c=m1(this,i,r,a);return r==null||r.attemptAutoclose("implement-definition-entity",this.id),c}getAllPropertiesImplements(){var r;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),i.push(...((r=this.extends)==null?void 0:r.getAllPropertiesImplements())||[],...this.implements.flatMap(a=>a.getAllPropertiesImplements())),i}getAllInteractiveMethods(){var e;const i=this.implements.filter(f=>f.type===d.DefinitionEntity||f.type===d.BuiltInBaseEntity&&f.interactive),r=((e=this.extends)==null?void 0:e.getAllInteractiveMethods())||[],a=i.flatMap(f=>f.getAllInteractiveMethods());return C([...this.methods,...r,...a])}inferFromInputs(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const a=[],c=[],e=[],f=[];if(this.parent.type!==d.DataType||!this.parent.inferred)return r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const h=[];i.forEach(b=>{h.find(_=>oe(_,this.project)===oe(b,this.project))||h.push(b)});const m=this.properties.filter(b=>!b.dataType);h.forEach(b=>{var G,q,re;const A=m.find(ee=>oe(ee,this.project)===oe(b,this.project));if(!A)return;const P=Er(b.parent).getMasterInputWithValueWriterFromAllInstances(b),V=tu(P,r),j=V==null?void 0:V.clone(r,A,x.UUID.uuid(),!0);j&&((G=A.dataType)==null||G.merge(j,r),j.id!==((q=A.dataType)==null?void 0:q.id)&&j.remove({ignoreUpstream:!1},r),A.dataType&&(A.dataType.metaSync({inferred:!0,like:!0},r),A.setDataType(A.dataType,r),r==null||r.add(A,W.Affected)));let M=null;if(b.declaration&&A.id!==((re=b.declaration)==null?void 0:re.id)&&(M=b.declaration),b.setDeclaration(A,r),r==null||r.add(b,W.Updated),M){const{updated:ee,removed:se}=M.remove({ignoreUpstream:!1},r);c.push(...ee),e.push(...se)}});const E=[];return h.forEach(b=>{if(!b.declaration){E.push(b);return}}),E.length===0?(r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(E.forEach(b=>{var re,ee,se,te,le;const A=this.properties.find(ue=>oe(ue,this.project)===oe(b,this.project));if(A){if(b.setDeclaration(A,r),!A.getDataType(r)){const z=Er(b.parent).getMasterInputWithValueWriterFromAllInstances(b),X=tu(z),pe=X==null?void 0:X.clone(r,A,x.UUID.uuid(),!0);pe&&((re=A.dataType)==null||re.merge(pe,r),pe.id!==((ee=A.dataType)==null?void 0:ee.id)&&pe.remove({ignoreUpstream:!1},r),A.dataType&&(A.dataType.metaSync({inferred:!0,like:!0},r),A.setDataType(A.dataType,r),r==null||r.add(A,W.Affected)))}return}const _=oe(b,this.project),P=b.codeName||vp(b,this.project)||cs(Xi(_)),V=Es.new(r);V.parent=this.toReference(),V.index=b.index,V.name=_,V.codeName=P,V.description=b.description;const j=ge(V,this.project);j.hydrateAncestors(),j.addSelfToProject(r),r==null||r.add(j,W.Added),j.setParent(this,r),j.initChildren(r),r||j.captureVersion();const G=Er(b.parent).getMasterInputWithValueWriterFromAllInstances(b),q=tu(G);if(q&&q.id!==((se=j.dataType)==null?void 0:se.id)){const ue=q==null?void 0:q.clone(r,j,x.UUID.uuid(),!0);ue&&((te=j.dataType)==null||te.merge(ue,r),ue.id!==((le=j.dataType)==null?void 0:le.id)&&ue.remove({ignoreUpstream:!1},r),j.dataType&&(j.dataType.metaSync({inferred:!0,like:!0},r),j.setDataType(j.dataType,r),r==null||r.add(j,W.Affected)))}return this.addProperty(j,r),b.setDeclaration(j,r),r==null||r.add(b,W.Updated),j}),r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:C(a),updated:C(c),removed:C(e),affected:C(f),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(r=>{var e;if(!bv(r))return;const a=oe(r,this.project),c=r.codeName||vp(r,this.project)||cs(Xi(a));i[c]=((e=r.getDefaultValue())==null?void 0:e.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(r=>{var f;if(!bv(r))return;const a=oe(r,this.project),c=r.codeName||vp(r,this.project)||cs(Xi(a)),e=(f=this.project.requestActiveDynamicValue(r,!0))==null?void 0:f.value;i[c]=(e==null?void 0:e.value)||null}),i}setAdditionalPropertiesDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetAdditionalPropertiesDataType))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setAdditionalPropertiesDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetAdditionalPropertiesDataType,this.id),this;const a=this.additionalPropertiesDataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.additionalPropertiesDataType=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetAdditionalPropertiesDataType,this.id),this}removeAdditionalPropertiesDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAllPropertiesImplement))){return this.checkCanEdit(this,i)?(this.additionalPropertiesDataType&&(this.additionalPropertiesDataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.additionalPropertiesDataType=null),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this):(Y.Logger.warn(`[removeAdditionalPropertiesDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this)}setAllPropertiesImplement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetAllPropertiesImplement))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setAllPropertiesImplement] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetAllPropertiesImplement,this.id),this;const a=this.allPropertiesImplement;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.allPropertiesImplement=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetAllPropertiesImplement,this.id),this}removeAllPropertiesImplement(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAllPropertiesImplement))){return this.checkCanEdit(this,i)?(this.allPropertiesImplement&&(this.properties.find(r=>{var a;return r.id===((a=this.allPropertiesImplement)==null?void 0:a.id)})||this.allPropertiesImplement.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.allPropertiesImplement=null),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this):(Y.Logger.warn(`[removeAllPropertiesImplement] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this)}};R(Pi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(Pi,"type",d.DefinitionEntity),R(Pi,"USER_MANAGED_PARENT_TYPES",[d.Project,d.DataType]),R(Pi,"PARENT_TYPES",[...Pi.USER_MANAGED_PARENT_TYPES]),R(Pi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract","additionalProperties"]),R(Pi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(Pi,"BASE_PROPERTIES",[...Pi.MUTABLE_BASE_PROPERTIES,...Pi.INMUTABLE_BASE_PROPERTIES]),R(Pi,"MUTABLE_META_PROPERTIES",[...Pi.MUTABLE_BASE_PROPERTIES,"x","y"]),R(Pi,"INMUTABLE_META_PROPERTIES",[...Pi.INMUTABLE_BASE_PROPERTIES]),R(Pi,"META_PROPERTIES",[...Pi.MUTABLE_META_PROPERTIES,...Pi.INMUTABLE_META_PROPERTIES]),R(Pi,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),R(Pi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(Pi,"UPSTREAM_PROPERTIES",[...Pi.MUTABLE_UPSTREAM_PROPERTIES,...Pi.INMUTABLE_UPSTREAM_PROPERTIES]),R(Pi,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods","allPropertiesImplement","additionalPropertiesDataType"]),R(Pi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(Pi,"DOWNSTREAM_PROPERTIES",[...Pi.MUTABLE_DOWNSTREAM_PROPERTIES,...Pi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(Pi,"PROPERTIES",[...Pi.META_PROPERTIES,...Pi.UPSTREAM_PROPERTIES,...Pi.DOWNSTREAM_PROPERTIES]);let Fs=Pi;async function xVi(s,p={}){const i=Y.YieldTracker.from(p),r=[],a=St(s.errors,r);return await i.tick(),a}function $Vi(s){const p=[];return St(s.errors,p)}const lI=class lI extends $x{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"name");R(this,"description",null);R(this,"type",d.PrimitiveEntity);R(this,"static");R(this,"abstract");R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.description=i.description,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project))}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allMethods)||[],r=[...i].filter(c=>!i.some(e=>e.id!==c.id));return C(r)}get allBasePropertiesFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allProperties)||[],r=[...i].filter(c=>!i.some(e=>{var f;return e.id!==c.id&&(e.implements.find(h=>h.id===c.id)||((f=e.extends)==null?void 0:f.id)===c.id)}));return C(r)}get allBasePropertiesFromExtendedAndImplementedEntities(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||E.implements.find(A=>A.id===h.id)}))},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeBuiltInInstance(this),this}unsubscribe(){return this.project.unsubscribeBuiltInInstance(this),this}async APILoad(i=Ke,...r){return await lI.repository.APILoad(this.id,...r),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(a=>a.toFlat(i)),...this.methods.flatMap(a=>a.toFlat(i)),...this.abstractMethods.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(a=>a.toFlatIds(i)),...this.methods.flatMap(a=>a.toFlatIds(i)),...this.abstractMethods.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){var r;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:((r=this.extends)==null?void 0:r.toJSON(i))||null})}toReference(i=at){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=at){var r;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:((r=this.extends)==null?void 0:r.toReference())||null}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(a=>a.toFlatJSON(i)),...this.methods.flatMap(a=>a.toFlatJSON(i)),...this.abstractMethods.flatMap(a=>a.toFlatJSON(i))])}toGenerationTarget(i=at){var r;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:(r=this.extends)==null?void 0:r.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(a=>a.toFlatGenerationTarget(i)),...this.methods.flatMap(a=>a.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(a=>a.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=$Vi(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await xVi(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors,...this.properties.flatMap(r=>r.getErrors()),...this.methods.flatMap(r=>r.getErrors()),...this.abstractMethods.flatMap(r=>r.getErrors())]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),!this.extends||this.extends.type===d.PrimitiveEntity?i:C(i)}};R(lI,"repository",{APILoad:async(i,...r)=>null});let Fa=lI;function nr(s,p){if(!s)throw new Error("Entity is null");const i=p.get(s.id);switch(s.type){case d.LiteralValue:return i||new Nr(s,p);case d.DefinitionEntity:return i||new Fs(s,p);case d.PrimitiveEntity:return i||new Fa(s,p);case d.FunctionDeclaration:return i||new Td(s,p);case d.GlobalEvent:return i||new Op(s,p);case d.DataType:return i||new mr(s,p);case d.Property:return i||new Es(s,p);case d.FunctionCall:return i||new wp(s,p);case d.Condition:return i||new Vp(s,p);case d.Operation:return i||new Cp(s,p);case d.VariableDeclaration:return i||new Np(s,p);case d.VariableInstance:return i||new Pp(s,p);case d.OutputMap:return i||new po(s,p);case d.ArgumentDeclaration:return i||new Za(s,p);case d.InputMap:return i||new Ts(s,p);case d.Project:return i||new x(s);case d.InstalledProject:return i||new $p(s,p);case d.ActionDescriptor:return i||new Ji(s,p);case d.ReturnStatement:return i||new au(s,p);case d.Loop:return i||new _p(s,p);case d.Search:return i||new xp(s,p);case d.ValueDescriptor:return i||new bd(s,p);case d.BuiltInBaseEntity:return i||new vd(s,p);case d.InternalCall:return i||new Lp(s,p);case d.ContinueStatement:return i||new Mp(s,p);case d.BreakStatement:return i||new Bp(s,p);case d.GenericReference:return p.get(s.entityId);default:throw new Error("Invalid entity type: "+s.type)}}function ge(s,p){if(!s)throw new Error("Entity is null");const i=nr(s,p);return i.subscribe(),i}function LVi(s,p,i){if(!s)throw new Error("Entity is null");switch(s.type){case d.LiteralValue:return Nr.fromGenerationTarget(s,p,i);case d.DefinitionEntity:return Fs.fromGenerationTarget(s,p,i);case d.FunctionDeclaration:return Td.fromGenerationTarget(s,p,i);case d.GlobalEvent:return Op.fromGenerationTarget(s,p,i);case d.DataType:return mr.fromGenerationTarget(s,p,i);case d.Property:return Es.fromGenerationTarget(s,p,i);case d.FunctionCall:return wp.fromGenerationTarget(s,p,i);case d.Condition:return Vp.fromGenerationTarget(s,p,i);case d.Operation:return Cp.fromGenerationTarget(s,p,i);case d.VariableDeclaration:return Np.fromGenerationTarget(s,p,i);case d.VariableInstance:return Pp.fromGenerationTarget(s,p,i);case d.OutputMap:return po.fromGenerationTarget(s,p,i);case d.ArgumentDeclaration:return Za.fromGenerationTarget(s,p,i);case d.InputMap:return Ts.fromGenerationTarget(s,p,i);case d.InstalledProject:return $p.fromGenerationTarget(s,p,i);case d.ReturnStatement:return au.fromGenerationTarget(s,p,i);case d.Loop:return _p.fromGenerationTarget(s,p,i);case d.Search:return xp.fromGenerationTarget(s,p,i);case d.ActionDescriptor:return Ji.fromGenerationTarget(s,p,i);case d.ValueDescriptor:return bd.fromGenerationTarget(s,p,i);case d.InternalCall:return Lp.fromGenerationTarget(s,p,i);case d.ContinueStatement:return Mp.fromGenerationTarget(s,p,i);case d.BreakStatement:return Bp.fromGenerationTarget(s,p,i);default:throw new Error("Invalid entity type: "+s.type)}}const at={seenEntityMaps:new Map,seenEntities:new Set,timestamp:B().toISOString()};class Yke{constructor(){R(this,"initialData")}}const Ke={cascade:!1},Jke={APILoad:async(s,...p)=>null},BVi={APICreate:async(s,...p)=>s,APIUpdate:async(s,...p)=>s,APIDelete:async(s,...p)=>s,APIClone:async(s,...p)=>{},APILoadVersion:async(s,p,...i)=>null,...Jke};class MVi{}class Qke extends Yke{}class GVi extends Qke{}class jVi{}class kVi{}class UVi{}class AL{}class FVi extends AL{}class KVi extends AL{}class qVi{}class ly{static initReadsValue(p){if(p.initialData.readsValue&&p.initialData.readsValue.type!==d.GenericReference)p.readsValue=ge(p.initialData.readsValue,p.project);else if(p.initialData.readsValue&&p.initialData.readsValue.type===d.GenericReference){const i=Ia(p.initialData.readsValue,p.project);i&&(p.readsValue=i)}if(p.readsValue){if(Lt.includes(p.readsValue.type)){let i=p.parent;!Ir.includes(i.type)&&i.type!==d.Project&&(i=i.parent);const r=p.type===d.InputMap&&p.parent.type===d.Loop;r&&(i=p.parent.parent),p.readsValue.setParent(i,null),p.readsValue.initChildren(null),i&&i.type!==d.Project&&!r&&i.detachedChildren.includes(p)?i.replaceDetachedChild(p,p.readsValue):i&&i.type!==d.Project&&!r&&i.subscribeDetachedChild(p.readsValue)}p.readsValue.addValueReader(p,null)}return p.readsValue}}class XE{static initWritesValues(p,i){const r=p.initialData.writesValues.reduce((c,e)=>{if(e.type===d.GenericReference||p.writesValues.some(h=>h.id===e.id))return c;const f=ge(e,p.project);return f.setValueWriter(p,null),Lt.includes(f.type)&&(f.setParent(i,null),f.initChildren(null)),[...c,f]},[]),a=[...p.writesValues];return p.writesValues=C([...a,...r]),p.writesValues}}class SVi{}var li=(s=>(s.PROJECT_INITIALIZED="project-initialized",s.BEFORE_CHANGE_SET_CLOSE_BEFORE_SIDE_EFFECTS="before-change-set-close-before-side-effects",s.BEFORE_CHANGE_SET_CLOSE_AFTER_SIDE_EFFECTS="before-change-set-close-after-side-effects",s.CHANGE_SET_CLOSED_BEFORE_PERSIST="change-set-closed-before-persist",s.CHANGE_SET_PERSISTED="change-set-persisted",s.BEFORE_CHANGE_SET_PERSIST="before-change-set-persist",s.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",s.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",s.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",s.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",s.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",s.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",s.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",s.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",s.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",s))(li||{});const gL={...c$,events:new Y.Events("def-proj-static-p-ctx-events")},Xke={requestActiveDynamicValue:(s,p=!1)=>null,...gL},Bt=class Bt extends dn{constructor(i,r={...Xke,events:new Y.Events("def-proj-inst-p-ctx-events")}){super(i);R(this,"initialData");R(this,"id");R(this,"type",d.Project);R(this,"name",null);R(this,"description",null);R(this,"x");R(this,"y");R(this,"entities",[]);R(this,"projects",[]);R(this,"functions",[]);R(this,"events",[]);R(this,"variableDeclarations",[]);R(this,"variableInstances",[]);R(this,"conditions",[]);R(this,"operations",[]);R(this,"functionCalls",[]);R(this,"loops",[]);R(this,"searches",[]);R(this,"primitives",[]);R(this,"builtInBaseEntities",[]);R(this,"operationDeclarations",[]);R(this,"globalEventActionDescriptors",[]);R(this,"loopDeclarations",[]);R(this,"loopDeclarationsBodies",[]);R(this,"conditionDeclarations",[]);R(this,"valueDescriptors",[]);R(this,"dataTypes",[]);R(this,"project");R(this,"instances",{});R(this,"builtInInstances",{});R(this,"deletedInstances",{});R(this,"subscribedDefinitionEntities",new Set);R(this,"errors",[]);R(this,"references",[]);R(this,"history",[]);R(this,"undoableStackValueIndex",-1);R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"diggestedBuiltInBaseEntitiesIds",new Set);R(this,"rejectParallelCS",!1);R(this,"onPersistChangeSetSequentiallyCallback",null);R(this,"onPersistChangeSetInParallelCallback",null);R(this,"onAddChangeSetCallback",null);R(this,"onDiscardChangeSetCallback",null);if(this.parentContext=r,this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this,!Bt.UUID)throw new Error("UUID module is already initialized. Please inject a valid UUID module.")}static get UUID(){var i;return(i=this.parentContext.requestExtension("uuid"))==null?void 0:i.module}static new(i=null){return{id:Bt.UUID.uuid(),version:Bt.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||Bt.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=Qr(a);return e.push(...f.errors),c.push(...f.explanations),{errors:e,explanations:c,modifiedData:a}}get off(){return this.parentContext.events.off}get on(){return this.parentContext.events.on}get emit(){return this.parentContext.events.emit}get emitAsync(){return this.parentContext.events.emitAsync}get emitAsyncAll(){return this.parentContext.events.emitAsyncAll}get emitAsyncAllSettled(){return this.parentContext.events.emitAsyncAllSettled}get emitAsyncSequentially(){return this.parentContext.events.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.parentContext.events.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.parentContext.events.emitAsyncSequentiallyAllSettled}async closePersistChangeSetsSequentially(){Y.Logger.log("[ProjectState.closePersistChangeSetsSequentially] called");const i=this.history.find(r=>r.dirty&&!r.open&&!r.submitting);i&&(Y.Logger.log(`[ProjectState.closePersistChangeSetsSequentially] closing pending change-set ${i.id} - ${i.autoCloseActionName}`),await this.persistChangeSetSequentially(i))}async onPersistChangeSetSequentially(i){this.onPersistChangeSetSequentiallyCallback=i,Y.Logger.log("[ProjectState.onPersistChangeSetSequentially] onPersistChangeSetSequentiallyCallback has been set. Checking for pending change-sets."),await this.closePersistChangeSetsSequentially()}offPersistChangeSetSequentially(){this.onPersistChangeSetSequentiallyCallback=null}async onPersistChangeSetInParallel(i){this.onPersistChangeSetInParallelCallback=i,Y.Logger.log("[ProjectState.onPersistChangeSetInParallel] onPersistChangeSetInParallelCallback has been set. Checking for pending change-sets.");for(const r of this.history)this.persistChangeSetInParallel(r),await new Promise(a=>setTimeout(a,27))}offPersistChangeSetInParallel(){this.onPersistChangeSetInParallelCallback=null}onAddChangeSet(i){this.onAddChangeSetCallback=i}offAddChangeSet(){this.onAddChangeSetCallback=null}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}offDiscardChangeSet(){this.onDiscardChangeSetCallback=null}async persistChangeSetSequentially(i){if(Y.Logger.log(`[ProjectState.persistChangeSetSequentially] called for change-set ${i.id} - ${i.autoCloseActionName}`),!i.dirty||i.open||i.submitting){Y.Logger.log(`[ProjectState.persistChangeSetSequentially] change-set ${i.id} - ${i.autoCloseActionName} is not dirty, or is open, or is already being submitted, skipping.`);return}const r=this.history.findIndex(e=>e.id===i.id),a=this.history.slice(0,r),c=a[a.length-1];if(c!=null&&c.dirty){Y.Logger.log(`[ProjectState.persistChangeSetSequentially] lastBeforeSelf is dirty: ${c.id} - ${c.autoCloseActionName}, closing it first.`);return}this.onPersistChangeSetSequentiallyCallback&&(Y.Logger.log(`[ProjectState.persistChangeSetSequentially] invoking onPersistChangeSetSequentiallyCallback for change-set ${i.id} - ${i.autoCloseActionName}`),this.emit("before-change-set-persist",i),i.submitting=!0,(await this.onPersistChangeSetSequentiallyCallback(i)).success&&(i.dirty=!1,this.emit("change-set-persisted",i),Y.Logger.log(`[ProjectState.persistChangeSetSequentially] change-set ${i.id} - ${i.autoCloseActionName} closed successfully, checking for pending change-sets to close.`),this.closePersistChangeSetsSequentially()))}async persistChangeSetInParallel(i){if(Y.Logger.log(`[ProjectState.persistChangeSetInParallel] called for change-set ${i.id} - ${i.autoCloseActionName}`),!i.dirty||i.open||i.submitting){Y.Logger.log(`[ProjectState.persistChangeSetInParallel] change-set ${i.id} - ${i.autoCloseActionName} is not dirty, or is open, or is already being submitted, skipping.`);return}this.onPersistChangeSetInParallelCallback&&(Y.Logger.log(`[ProjectState.persistChangeSetInParallel] invoking onPersistChangeSetInParallelCallback for change-set ${i.id} - ${i.autoCloseActionName}`),this.emit("before-change-set-persist",i),i.submitting=!0,(await this.onPersistChangeSetInParallelCallback(i)).success&&(i.dirty=!1,this.emit("change-set-persisted",i)))}toLatestChangeSet(i,r,a,c=!1,e="here-this"){if(!this.history.length)return new S(this,i,r,a,c,e);const f=this.history[this.history.length-1];return f.open?f:this.addChangeSet(new S(this,i,r,a,c,e))}addChangeSet(i){var a,c;if(!this.history.length)return this.undoableStackValueIndex=$_(this.undoableStackValueIndex,this.history,i),(a=this.onAddChangeSetCallback)==null||a.call(this,i,this.undoableStackValueIndex),i;const r=this.history.find(e=>e.id===(i==null?void 0:i.id));if(r)return r;if(this.rejectParallelCS){const e=this.history.find(f=>f.open);if(e)throw Y.Logger.warn("Previous still open: ",e),Y.Logger.warn("New change set: ",i),new Error(`There is already an open change-set with id '${e.id}'${e.autoCloseActionName?` auto-close: ${e.autoCloseActionName}`:""}${e.self?` root: ${e.self.type} ${oe(e.self,this)}`:""}.`)}return this.undoableStackValueIndex=$_(this.undoableStackValueIndex,this.history,i),(c=this.onAddChangeSetCallback)==null||c.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var a;Y.Logger.log(`[ProjectState.discardChangeSet] called for change-set ${i.id} - ${i.autoCloseActionName}`);const r=this.history.findIndex(c=>c.id===(i==null?void 0:i.id));return r!==-1&&(this.history.splice(r,1),Y.Logger.log(`[ProjectState.discardChangeSet] Removed change-set ${i.id} - ${i.autoCloseActionName} from history.`),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(a=this.onDiscardChangeSetCallback)==null||a.call(this,i),i==null||i.teardown()),this}validateGeneratedUpdate(i){return{errors:[],explanations:[],modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){var r;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=Bt.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new Bt(this);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new Bt(this);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new Bt(E)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.entities=[...h.entities],this.projects=[...h.projects],this.functions=[...h.functions],this.events=[...h.events],this.variableDeclarations=[...h.variableDeclarations],this.variableInstances=[...h.variableInstances],this.conditions=[...h.conditions],this.operations=[...h.operations],this.functionCalls=[...h.functionCalls],this.loops=[...h.loops],this.searches=[...h.searches],{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){return this.checkCanEdit(this,r)?(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this):(Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this)}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){return this.checkCanEdit(this,r)?(this.metaSync(i,r),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this):(Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this)}hydrateAncestors(){const i=[],r=[],a=[],c=[];return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=null){const r=[],a=[],c=[],e=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i){const r=[],a=[],c=[],e=[];return this.subscribe(),this.subscribeToDependencies(),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get instancesList(){return Object.values(this.instances)}get builtInInstancesList(){return Object.values(this.builtInInstances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.projects=this.initialData.projects.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.variableDeclarations=this.initialData.variableDeclarations.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.variableInstances=this.initialData.variableInstances.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.conditions=this.initialData.conditions.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.operations=this.initialData.operations.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.functions=this.initialData.functions.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.events=this.initialData.events.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.functionCalls=this.initialData.functionCalls.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.loops=this.initialData.loops.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.searches=this.initialData.searches.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.subscribeInstance(this),this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}unsubscribeBuiltInInstance(i){return delete this.builtInInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.description=a.description!==void 0?a.description:e.description,this.x=a.x||e.x,this.y=a.y||e.y,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await Bt.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await Bt.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await Bt.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await Bt.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await Bt.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await Bt.repository.APILoadVersion(this.id,r,...a)}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(r=>r.toFlatIds(i)),...this.builtInBaseEntities.flatMap(r=>r.toFlatIds(i)),...this.operationDeclarations.flatMap(r=>r.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(r=>r.toFlatIds(i)),...this.loopDeclarations.flatMap(r=>r.toFlatIds(i)),...this.conditionDeclarations.flatMap(r=>r.toFlatIds(i)),...this.valueDescriptors.flatMap(r=>r.toFlatIds(i)),...this.dataTypes.flatMap(r=>r.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(r=>r.toFlat(i)),...this.builtInBaseEntities.flatMap(r=>r.toFlat(i)),...this.operationDeclarations.flatMap(r=>r.toFlat(i)),...this.globalEventActionDescriptors.flatMap(r=>r.toFlat(i)),...this.loopDeclarations.flatMap(r=>r.toFlat(i)),...this.conditionDeclarations.flatMap(r=>r.toFlat(i)),...this.valueDescriptors.flatMap(r=>r.toFlat(i)),...this.dataTypes.flatMap(r=>r.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(a=>a.toFlat(i)),...this.functions.flatMap(a=>a.toFlat(i)),...this.events.flatMap(a=>a.toFlat(i)),...this.projects.flatMap(a=>a.toFlat(i)),...this.variableDeclarations.flatMap(a=>a.toFlat(i)),...this.variableInstances.flatMap(a=>a.toFlat(i)),...this.conditions.flatMap(a=>a.toFlat(i)),...this.operations.flatMap(a=>a.toFlat(i)),...this.functionCalls.flatMap(a=>a.toFlat(i)),...this.loops.flatMap(a=>a.toFlat(i)),...this.searches.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(a=>a.toFlatIds(i)),...this.functions.flatMap(a=>a.toFlatIds(i)),...this.events.flatMap(a=>a.toFlatIds(i)),...this.projects.flatMap(a=>a.toFlatIds(i)),...this.variableDeclarations.flatMap(a=>a.toFlatIds(i)),...this.variableInstances.flatMap(a=>a.toFlatIds(i)),...this.conditions.flatMap(a=>a.toFlatIds(i)),...this.operations.flatMap(a=>a.toFlatIds(i)),...this.functionCalls.flatMap(a=>a.toFlatIds(i)),...this.loops.flatMap(a=>a.toFlatIds(i)),...this.searches.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,entities:this.entities.map(r=>r.toJSON(i)),variableDeclarations:this.variableDeclarations.map(r=>r.toJSON(i)),variableInstances:this.variableInstances.map(r=>r.toJSON(i)),conditions:this.conditions.map(r=>r.toJSON(i)),operations:this.operations.map(r=>r.toJSON(i)),loops:this.loops.map(r=>r.toJSON(i)),searches:this.searches.map(r=>r.toJSON(i)),functions:this.functions.map(r=>r.toJSON(i)),events:this.events.map(r=>r.toJSON(i)),projects:this.projects.map(r=>r.toJSON(i)),functionCalls:this.functionCalls.map(r=>r.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const r=new Map,a=new Set,c=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(e=>{if(c.includes(e)){r.set(e,e);return}r.set(e,Bt.UUID.uuid())}),a.add(this.id),{id:r.get(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,description:this.description,entities:this.entities.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),projects:this.projects.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),variableDeclarations:this.variableDeclarations.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),variableInstances:this.variableInstances.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),conditions:this.conditions.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),operations:this.operations.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),functions:this.functions.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),events:this.events.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),functionCalls:this.functionCalls.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),loops:this.loops.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),searches:this.searches.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null}))}}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+Bt.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,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,description:this.description,entities:this.entities.map(c=>c.toReference(i)),functions:this.functions.map(c=>c.toReference(i)),events:this.events.map(c=>c.toReference(i)),projects:this.projects.map(c=>c.toReference(i)),variableDeclarations:this.variableDeclarations.map(c=>c.toReference(i)),variableInstances:this.variableInstances.map(c=>c.toReference(i)),conditions:this.conditions.map(c=>c.toReference(i)),operations:this.operations.map(c=>c.toReference(i)),functionCalls:this.functionCalls.map(c=>c.toReference(i)),loops:this.loops.map(c=>c.toReference(i)),searches:this.searches.map(c=>c.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(a=>a.toFlatJSON(i)),...this.functions.flatMap(a=>a.toFlatJSON(i)),...this.events.flatMap(a=>a.toFlatJSON(i)),...this.projects.flatMap(a=>a.toFlatJSON(i)),...this.variableDeclarations.flatMap(a=>a.toFlatJSON(i)),...this.variableInstances.flatMap(a=>a.toFlatJSON(i)),...this.conditions.flatMap(a=>a.toFlatJSON(i)),...this.operations.flatMap(a=>a.toFlatJSON(i)),...this.functionCalls.flatMap(a=>a.toFlatJSON(i)),...this.loops.flatMap(a=>a.toFlatJSON(i)),...this.searches.flatMap(a=>a.toFlatJSON(i))])}toGenerationTarget(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(a=>a.toFlatGenerationTarget(i)),...this.functions.flatMap(a=>a.toFlatGenerationTarget(i)),...this.events.flatMap(a=>a.toFlatGenerationTarget(i)),...this.projects.flatMap(a=>a.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(a=>a.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(a=>a.toFlatGenerationTarget(i)),...this.conditions.flatMap(a=>a.toFlatGenerationTarget(i)),...this.operations.flatMap(a=>a.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(a=>a.toFlatGenerationTarget(i)),...this.loops.flatMap(a=>a.toFlatGenerationTarget(i)),...this.searches.flatMap(a=>a.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){return this.validateChildren(),AE([...this.errors]),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return await this.validateChildrenAsync({tracker:r}),await R_e([...this.errors]),{success:!0}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}async validateChildrenAsync(i={}){const r=Y.YieldTracker.from(i);for(let a=0;a<this.entities.length;a++)await this.entities[a].validateAsync({tracker:r});for(let a=0;a<this.projects.length;a++)await this.projects[a].validateAsync({tracker:r});for(let a=0;a<this.functions.length;a++)await this.functions[a].validateAsync({tracker:r});for(let a=0;a<this.events.length;a++)await this.events[a].validateAsync({tracker:r});for(let a=0;a<this.variableDeclarations.length;a++)await this.variableDeclarations[a].validateAsync({tracker:r});for(let a=0;a<this.variableInstances.length;a++)await this.variableInstances[a].validateAsync({tracker:r});for(let a=0;a<this.conditions.length;a++)await this.conditions[a].validateAsync({tracker:r});for(let a=0;a<this.operations.length;a++)await this.operations[a].validateAsync({tracker:r});for(let a=0;a<this.functionCalls.length;a++)await this.functionCalls[a].validateAsync({tracker:r});for(let a=0;a<this.loops.length;a++)await this.loops[a].validateAsync({tracker:r});for(let a=0;a<this.searches.length;a++)await this.searches[a].validateAsync({tracker:r})}getErrors(){return[...this.errors,...this.entities.flatMap(r=>r.getErrors()),...this.projects.flatMap(r=>r.getErrors()),...this.functions.flatMap(r=>r.getErrors()),...this.events.flatMap(r=>r.getErrors()),...this.variableDeclarations.flatMap(r=>r.getErrors()),...this.variableInstances.flatMap(r=>r.getErrors()),...this.conditions.flatMap(r=>r.getErrors()),...this.operations.flatMap(r=>r.getErrors()),...this.functionCalls.flatMap(r=>r.getErrors()),...this.loops.flatMap(r=>r.getErrors()),...this.searches.flatMap(r=>r.getErrors())]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(let c=0;c<this.entities.length;c++){const e=await this.entities[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.projects.length;c++){const e=await this.projects[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.functions.length;c++){const e=await this.functions[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.events.length;c++){const e=await this.events[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.variableDeclarations.length;c++){const e=await this.variableDeclarations[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.variableInstances.length;c++){const e=await this.variableInstances[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.conditions.length;c++){const e=await this.conditions[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.operations.length;c++){const e=await this.operations[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.functionCalls.length;c++){const e=await this.functionCalls[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.loops.length;c++){const e=await this.loops[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.searches.length;c++){const e=await this.searches[c].getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}clone(){return this}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const r=this.entities.findIndex(a=>a.id===i.id);if(r>-1){const a=this.entities[r];return this.entities.splice(r,1),a}return null}removeCondition(i){const r=this.conditions.findIndex(a=>a.id===i.id);if(r>-1){const a=this.conditions[r];return this.conditions.splice(r,1),a}return null}removeOperation(i){const r=this.operations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.operations[r];return this.operations.splice(r,1),a}return null}removeLoop(i){const r=this.loops.findIndex(a=>a.id===i.id);if(r>-1){const a=this.loops[r];return this.loops.splice(r,1),a}return null}removeSearch(i){const r=this.searches.findIndex(a=>a.id===i.id);if(r>-1){const a=this.searches[r];return this.searches.splice(r,1),a}return null}removeFunctionCall(i){const r=this.functionCalls.findIndex(a=>a.id===i.id);if(r>-1){const a=this.functionCalls[r];return this.functionCalls.splice(r,1),a}return null}removeVariableInstance(i){const r=this.variableInstances.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableInstances[r];return this.variableInstances.splice(r,1),a}return null}removeVariableDeclaration(i){const r=this.variableDeclarations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableDeclarations[r];return this.variableDeclarations.splice(r,1),a}return null}removeFunctionDeclaration(i){const r=this.functions.findIndex(a=>a.id===i.id);if(r>-1){const a=this.functions[r];return this.functions.splice(r,1),a}return null}removeInstalledProject(i){const r=this.projects.findIndex(a=>a.id===i.id);if(r>-1){const a=this.projects[r];return this.projects.splice(r,1),a}return null}removeGlobalEvent(i){const r=this.events.findIndex(a=>a.id===i.id);if(r>-1){const a=this.events[r];return this.events.splice(r,1),a}return null}removeTopLevelVariableDeclaration(i){if(i.type!==d.VariableDeclaration)return null;const r=this.variableDeclarations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableDeclarations[r];return this.variableDeclarations.splice(r,1),a}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(r=>r.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.ReturnStatement||e.type===d.ContinueStatement||e.type===d.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(r=>r.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[])]}getDefinitionEntities(i=new Set){return Array.from(this.subscribedDefinitionEntities).filter(a=>!i.has(a)).map(a=>this.get(a))}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.functionCalls.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.conditions.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.operations.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.loops.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.searches.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[])]}getVariableInstances(){return[...this.variableInstances,...this.entities.reduce((r,a)=>[...r,...a.methods.flatMap(c=>{const f=ct(c).filter(h=>h.type===d.VariableInstance);return[...r,...f]})],[]),...this.getEntryPoints().reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.functionCalls.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.conditions.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.operations.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.loops.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.searches.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[])]}getVariableDeclarations(){return C([...this.variableDeclarations,...this.entities.reduce((r,a)=>[...r,...a.methods.flatMap(c=>{const f=ct(c).filter(h=>h.type===d.VariableDeclaration);return[...r,...f]})],[]),...this.getEntryPoints().reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.functionCalls.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.conditions.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.operations.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.loops.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.searches.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),r=this.getVariableDeclarations();return i.forEach(a=>{if(!a.declaration){const c=a.initialData,e=c.declaration.entityId||c.declaration.id,f=r.find(h=>h.id===e);f&&a.setDeclaration(f)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===Ae.PERSISTED_ENTITY)||null}requestActiveDynamicValue(i,r=!1){var c,e;const a=(e=(c=this.parentContext).requestActiveDynamicValue)==null?void 0:e.call(c,i,r);if(!a&&pI.includes(i.type)){const f=i.getDefaultValue();return f?{value:f,type:Me.DefaultValue,inheritanceLink:null,valueOwner:i}:null}return a||null}requestExtension(i){if(this.parentContext.requestExtension){const r=this.parentContext.requestExtension(i);if(r&&!r.module)throw new Error(`Module ${i} is not registered properly.`);return r.module||null}return null}undo(){Y.Logger.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,Y.Logger.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],r=this.history[this.undoableStackValueIndex];return Y.Logger.log("Current change set: ",i==null?void 0:i.toJSON()),Y.Logger.log("Change set to restore: ",r==null?void 0:r.toJSON()),N_(i||"initial",r||"initial",this)}redo(){Y.Logger.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,Y.Logger.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],r=this.history[this.undoableStackValueIndex];return Y.Logger.log("Current change set: ",i==null?void 0:i.toJSON()),Y.Logger.log("Change set to restore: ",r.toJSON()),N_(i||"initial",r||"initial",this)}applyExternalChangeSet(i){const r=i.payload,a=this.addChangeSet(new S(this,i.userAuthor,i.emittedAt,this));a.ignoreNonEditable=!0,a.ignoreNonDeletable=!0;const c=r.updated[this.id];if(!c)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const e={...r.added,...r.updated,...r.removed},f=[...Object.keys(r.added),...Object.keys(r.updated),...Object.keys(r.removed)];f.forEach(m=>{var E;if(!e[m]){Y.Logger.warn(`Entity '${m}' not found in change set transfer. Cannot apply changes.`);const b=(E=this.get(m))==null?void 0:E.toShallowJSON();throw b?Y.Logger.warn("Entity in project: ",b):Y.Logger.warn("Entity not in project"),new Error(`Entity '${m}' not found in change set transfer. Cannot apply changes.`)}});const h=new Un(c,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});return h.flatRecord=e,h.order=f,h.orderEntities(),Y.Logger.log("All entities: ",h.order.map((m,E)=>`${E+1}: ${e[m].type} - ${m}`).join(`,
|
|
538
|
+
Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`}))}return{errors:e,explanations:c,modifiedData:a}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.type)===d.DefinitionEntity?this.extends.allMethods:[],r=[...i].filter(c=>!i.some(e=>{var f,h;return e.id!==c.id&&(((f=e.implements)==null?void 0:f.id)===c.id||((h=e.extends)==null?void 0:h.id)===c.id)}));return C([...r,...this.implements.flatMap(c=>{const e=c.type===d.DefinitionEntity?[...c.allMethods]:[];return[...e].filter(h=>!e.some(m=>{var E,b;return m.id!==h.id&&(((E=m.implements)==null?void 0:E.id)===h.id||((b=m.extends)==null?void 0:b.id)===h.id)}))})])}get allBasePropertiesFromOriginalParents(){var c;const i=((c=this.extends)==null?void 0:c.allProperties)||[],r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C([...r,...this.implements.flatMap(e=>{const f=[...e.allProperties];return[...f].filter(m=>!f.some(E=>{var b;return E.id!==m.id&&(!!E.implements.find(A=>A.id===m.id)||((b=E.extends)==null?void 0:b.id)===m.id)}))})])}get allBasePropertiesFromExtendedAndImplementedEntities(){var c,e;const i=[...((c=this.extends)==null?void 0:c.ownDeclaredProperties)||[],...((e=this.extends)==null?void 0:e.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(f=>!f.abstract),r=[...i].filter(f=>!i.some(h=>{var m;return h.id!==f.id&&(!!h.implements.find(E=>E.id===f.id)||((m=h.extends)==null?void 0:m.id)===f.id)})),a=this.implements.reduce((f,h)=>{const m=h.implementedPropertiesFromOriginalParents,E=[...h.ownDeclaredProperties].filter(_=>!_.abstract),b=[...m,...E,...f];return[...b].filter(_=>!!!b.find(V=>{var j;return!!V.implements.find(M=>M.id===_.id)||((j=V.extends)==null?void 0:j.id)===_.id}))},[]);return C([...r,...a])}get allBaseMethodsFromExtendedAndImplementedEntities(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>r.type!==d.DefinitionEntity?[]:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[]),...this.implements.reduce((i,r)=>r.type!==d.DefinitionEntity?r.abstractMethods:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||!!E.implements.find(A=>A.id===h.id)}))},[]),...this.implements.reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return!!E.implements.find(A=>A.id===h.id)||((b=E.extends)==null?void 0:b.id)===h.id}))},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return C((this.extends?[this.extends]:[]).reduce((i,r)=>{if(r.type!==d.DefinitionEntity)return[];const a=[...r.ownDeclaredMethods,...r.extendedMethodsFromOriginalParents].filter(c=>c.type!==d.ActionDescriptor);return[...i,...a]},[]))}get implementedMethodsFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.type===d.DefinitionEntity?r.methods:[],c=[...r.abstractMethods].filter(e=>!a.find(f=>f.name===e.name));return[...a,...c,...i]},[]),...this.implements.reduce((i,r)=>[...r.abstractMethods,...i],[])].filter(i=>i.type===d.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(r=>!r.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new De({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:Te.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return r==="implements"&&(this.removeImplementation(i,a),c.push(this)),r==="extends"&&(this.setExtension(null,a),c.push(this)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return r==="implements"&&(this.addImplementation(i,a),c.push(this)),r==="extends"&&(this.setExtension(i,a),c.push(this)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{ma.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this.extends&&(ma.includes(this.extends.type)||this.extends.unsubscribeDependents([{entity:this,field:"extends"}])),this}subscribeToDependencies(){return this.implements.forEach(i=>{ma.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends&&(ma.includes(this.extends.type)||this.extends.subscribeDependents([{entity:this,field:"extends"}])),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new Pi(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new Pi(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=this.extends,i.implements=[...this.implements],i.allPropertiesImplement=this.allPropertiesImplement,i.additionalPropertiesDataType=this.additionalPropertiesDataType,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new Pi(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.properties=[...h.properties],this.methods=[...h.methods],this.abstractMethods=[...h.abstractMethods],this.extends=h.extends,this.implements=[...h.implements],this.allPropertiesImplement=h.allPropertiesImplement,this.additionalPropertiesDataType=h.additionalPropertiesDataType,this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const f=ie(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.extends){const f=ie(i.extends),h=this.project.get(f);h&&this.setExtension(h,r)}else this.setExtension(null,r);if(i.implements.forEach(f=>{const h=ie(f),m=this.project.get(h);if(m)this.addImplementation(m,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${h}" which is missing in the project`)}),this.implements.filter(f=>{const h=ie(f);return!i.implements.find(m=>ie(m)===h)}).forEach(f=>{this.removeImplementation(f,r)}),i.methods.forEach(f=>{const h=ie(f),m=this.project.get(h);m&&this.addMethod(m,r)}),this.methods.filter(f=>{const h=ie(f);return!i.methods.find(m=>ie(m)===h)}).forEach(f=>{this.removeMethod(f,r)}),i.properties.forEach(f=>{const h=ie(f),m=this.project.get(h);m&&this.addProperty(m,r)}),this.properties.filter(f=>{const h=ie(f);return!i.properties.find(m=>ie(m)===h)}).forEach(f=>{this.removeProperty(f,r)}),i.allPropertiesImplement){const f=ie(i.allPropertiesImplement),h=this.project.get(f);h&&this.setAllPropertiesImplement(h,r)}else this.setAllPropertiesImplement(null,r);if(i.additionalPropertiesDataType){const f=ie(i.additionalPropertiesDataType),h=this.project.get(f);h&&this.setAdditionalPropertiesDataType(h,r)}else this.setAdditionalPropertiesDataType(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const c=ie(i.parent),e=this.project.get(c),f=this.parent;if(f&&f.id!==(e==null?void 0:e.id)&&this.removeFromParent(r),e)this.setParent(e,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${c}' that isn't found in the project`)}if(i.extends){const c=ie(i.extends),e=this.project.get(c);if(e)this.setExtension(e,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has an 'extends' reference "${c}" which is missing in the project`)}else i.extends===null&&this.setExtension(null,r);return(a=i.implements)==null||a.forEach(c=>{const e=ie(c),f=this.project.get(e);if(f)this.addImplementation(f,r);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${e}" which is missing in the project`)}),i.implements&&this.implements.filter(e=>{const f=ie(e);return!(i.implements||[]).find(h=>ie(h)===f)}).forEach(e=>{this.removeImplementation(e,r)}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=ie(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.extends){const e=ie(this.initialData.extends),f=this.project.get(e);f&&(this.setExtension(f,null),f.type!==d.BuiltInBaseEntity&&i.push(f))}return this.initialData.implements.forEach(e=>{const f=ie(e),h=this.project.get(f);if(h)this.addImplementation(h,null),h.type!==d.BuiltInBaseEntity&&i.push(h);else throw new Error(`${pr(this.type)} with id '${this.id}' has a 'implements' reference "${f}" which is missing in the project`)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];this.initialized=!0;const{updated:f,added:h,removed:m,affected:E}=this.syncImplementationProperties(i);r.push(...f),a.push(...h),c.push(...m),e.push(...E);const{updated:b,added:A,removed:_,affected:P}=this.addExtendedProperties(i);r.push(...b),a.push(...A),c.push(..._),e.push(...P);const{updated:V,added:j,removed:M}=this.removeUnrecognizedProperties(i);r.push(...V),a.push(...j),c.push(...M);const{updated:G,added:q,removed:re,affected:ee}=this.syncImplementationMethods(i);r.push(...G),a.push(...q),c.push(...re),e.push(...ee);const{updated:se,added:te,removed:le,affected:ue}=this.addExtendedMethods(i);r.push(...se),a.push(...te),c.push(...le),e.push(...ue);const{updated:z,added:X,removed:pe}=this.removeUnrecognizedMethods(i);r.push(...z),a.push(...X),c.push(...pe),this.addSuggestions(),this.properties.sort((me,ve)=>me.index-ve.index);const de=this.project.getDefinitionEntities(new Set([this.id]));if(de.some(me=>me.id!==this.id&&me.name.toLowerCase()===this.name.toLowerCase())){const me=Rh(this.name,de);this.metaSync({name:me},i)}return i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];if(this.parent.type===d.DataType){const f=this.parent;f.entity=this,r.push(f)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setExtension(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetExtension))){var a;return this.checkCanEdit(this,r)?(((a=this.extends)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.extends=i,this.subscribeToDependencies(),r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetExtension,this.id),this):(Y.Logger.warn(`[setExtension] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetExtension,this.id),this)}addImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)||(this.implements.push(i),this.subscribeToDependencies(),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this):(Y.Logger.warn(`[addImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this)}removeImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)&&(this.implements=this.implements.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this):(Y.Logger.warn(`[removeImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this)}removeProperty(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveProperty))){return this.checkCanEdit(this,r)?(this.properties.includes(i)&&(this.properties=this.properties.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveProperty,this.id),this):(Y.Logger.warn(`[removeProperty] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveProperty,this.id),this)}addMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddMethod))){return this.checkCanEdit(this,r)?(this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddMethod,this.id),this):(Y.Logger.warn(`[addMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddMethod,this.id),this)}removeMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveMethod))){return this.checkCanEdit(this,r)?(this.methods.includes(i)&&(this.methods=this.methods.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveMethod,this.id),this):(Y.Logger.warn(`[removeMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveMethod,this.id),this)}addProperty(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddProperty))){return this.checkCanEdit(this,r)?(this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddProperty,this.id),this):(Y.Logger.warn(`[addProperty] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddProperty,this.id),this)}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(r=>r.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(r=>r.id!==i.id),this}addAbstractMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddAbstractMethod))){return this.checkCanEdit(this,r)?(this.abstractMethods.includes(i)||(this.abstractMethods.push(i),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddAbstractMethod,this.id),this):(Y.Logger.warn(`[addAbstractMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddAbstractMethod,this.id),this)}removeAbstractMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAbstractMethod))){return this.checkCanEdit(this,r)?(this.abstractMethods.includes(i)&&(this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveAbstractMethod,this.id),this):(Y.Logger.warn(`[removeAbstractMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveAbstractMethod,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.properties=this.initialData.properties.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.methods=this.initialData.methods.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=ge(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project)),this.implements=this.initialData.implements.map(r=>ge(r,this.project)),this.initialData.allPropertiesImplement){const r=ge(this.initialData.allPropertiesImplement,this.project);r.setParent(this,null),r.initChildren(null),this.setAllPropertiesImplement(r,i)}if(this.initialData.additionalPropertiesDataType){const r=ge(this.initialData.additionalPropertiesDataType,this.project);r.setParent(this,null),r.initChildren(null),this.setAdditionalPropertiesDataType(r,i)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}removeUnrecognizedProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-unrecognized-properties"))){const r=[],a=[],c=[],e=[];let f=[...this.properties];f=f.filter(b=>b.parent.id===this.id),f=f.filter(b=>!b.isExtendedProperty);const h=this.implementedPropertiesFromOriginalParents,m=this.getAllPropertiesImplements();return f.filter(b=>this.interactive&&!b.implements.length?!1:!b.implements.find(_=>!!h.find(P=>P.id===_.id)||!!m.find(P=>P.id===_.id))).forEach(b=>{const A=b.remove({ignoreUpstream:!1},i);c.push(...A.removed),r.push(...A.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-unrecognized-methods"))){const r=[],a=[],c=[],e=[];let f=[...this.methods];f=f.filter(m=>m.parent.id===this.id),f=f.filter(m=>!m.isExtendedMethod);const h=this.implementedMethodsFromOriginalParents;return f=f.filter(m=>this.interactive&&!m.implements?!1:!h.find(E=>{var b;return E.id===((b=m.implements)==null?void 0:b.id)})),f.forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-implementation-methods"))){const r=[],a=[],c=[],e=[],f=this.methods,h=this.implementedMethodsFromOriginalParents,m=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...f];return h.filter(b=>!m.find(_=>{var P;return((P=_.implements)==null?void 0:P.id)===b.id})).forEach(b=>{if(this.methods.find(V=>{var j;return((j=V.implements)==null?void 0:j.id)===b.id}))return;const _=this.methods.find(V=>{var re,ee;if(V.name===b.name&&!V.implements)return!0;const j=si(this,Ae.CRON_JOB),M=si(this,Ae.HTTP_ENDPOINT),G=((re=V.implements)==null?void 0:re.id)===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,q=((ee=V.implements)==null?void 0:ee.id)===ne["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(j&&!q&&!M&&G||M&&!G&&!j&&q)});if(_&&_.type===d.FunctionDeclaration){_.setImplements(b,i),_.metaSync({name:b.name},i),i==null||i.add(_,W.Updated),i==null||i.add(this,W.Updated);return}const P=b.implementAsFunctionDeclaration(i,this);a.push(P),i==null||i.add(P,W.Added),this.addMethod(P,i)}),this.methods.sort((b,A)=>b.index-A.index).forEach(b=>{b.afterAllChildrenInitialized(i)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-implementation-properties"))){const r=[],a=[],c=[],e=[],f=this.properties,h=this.implementedPropertiesFromOriginalParents.filter(E=>!this.allBasePropertiesFromExtendedAndImplementedEntities.find(A=>!!A.implements.find(_=>_.id===E.id))),m=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...f];return h.forEach(E=>{const b=m.find(V=>!!V.implements.find(j=>j.id===E.id));if(b){const{updated:V,added:j,removed:M,affected:G}=b.syncWithImplementation(i);r.push(...V),a.push(...j),c.push(...M),e.push(...G);return}if(this.properties.find(V=>!!V.implements.find(j=>j.id===E.id)))return;const _=this.properties.find(V=>V.name===E.name&&!!V.abstract&&!V.implements);if(_){_.addImplementation(E,i),_.metaSync({abstract:!1},i),_.afterAllChildrenInitialized(i);return}const P=E.implement(this,i,x.UUID.uuid());a.push(P),i==null||i.add(P,W.Added)}),this.properties.find(E=>{var b;return E.id===((b=this.allPropertiesImplement)==null?void 0:b.id)})&&this.removeAllPropertiesImplement(i),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addExtendedMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-extended-methods"))){const r=[],a=[],c=[],e=[],f=this.methods,m=this.extendedMethodsFromOriginalParents.filter(b=>b.type===d.FunctionDeclaration),E=new Set(f.filter(b=>{var A;return!!((A=b.extends)!=null&&A.id)}).map(b=>b.extends.id));return m.forEach(b=>{if(E.has(b.id))return;E.add(b.id);const A=b.clone(i,this,x.UUID.uuid());A.setExtends(b,i),A.initChildren(i),a.push(A),i==null||i.add(A,W.Added),this.addMethod(A,i)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addExtendedProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-extended-properties"))){const r=[],a=[],c=[],e=[],f=this.properties,h=this.extendedPropertiesFromOriginalParents,m=h.filter(b=>h.find(_=>!!_.implements.find(P=>P.id===b.id))?!1:!b.abstract),E=new Set(f.filter(b=>{var A;return!!((A=b.extends)!=null&&A.id)}).map(b=>b.extends.id));return m.forEach(b=>{if(E.has(b.id))return;E.add(b.id);const A=b.clone(i,this,x.UUID.uuid());A.setExtends(b,i),A.initChildren(i),a.push(A),i==null||i.add(A,W.Added),this.addProperty(A,i)}),[...this.properties].forEach(b=>{if(b.extends)return;if(m.find(_=>_.name===b.name&&_.implements.every(P=>!!b.implements.find(V=>V.id===P.id)))){const _=b.remove({ignoreUpstream:!1},i);c.push(..._.removed),r.push(..._.updated)}}),this.properties.forEach(b=>{const A=b.afterAllChildrenInitialized(i);r.push(...A.updated),e.push(...A.affected),a.push(...A.added),c.push(...A.removed)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSuggestions(){return this.implements.forEach(i=>{qke(this,i).forEach(c=>{const e=c.toJSON();e.id=`_suggestion--parent--${this.id}--${c.id}`;const f=ge(e,this.project);f.suggestion=!0,f.setParent(this,null),f.initChildren(null),this.addSuggestedProperty(f)}),Ske(this,i).forEach(c=>{const e=`_suggestion--parent--${this.id}--${c.id}`,f=c.implementAsFunctionDeclaration(null,this,e),h=ge(f,this.project);if(h.suggestion=!0,h.setParent(this,null),h.initChildren(null),this.methods=this.methods.filter(m=>m.id!==e),h.inputs.forEach(m=>{m.suggestion=!0}),h.returnStatements.length){const m=h.returnStatements[0];m.suggestion=!0,m.outputs.forEach(E=>{E.suggestion=!0})}this.addSuggestedMethod(h)})}),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this.project.subscribedDefinitionEntities.add(this.id),this}unsubscribe(){return this.project.unsubscribeInstance(this),this.project.subscribedDefinitionEntities.delete(this.id),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.codeName=a.codeName!==void 0?a.codeName:e.codeName,this.description=a.description!==void 0?a.description:e.description,this.x=a.x||e.x,this.y=a.y||e.y,this.static=a.static!==void 0?a.static:this.static,this.abstract=a.abstract!==void 0?a.abstract:this.abstract,this.additionalProperties=a.additionalProperties!==void 0?a.additionalProperties:e.additionalProperties,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await Pi.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await Pi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await Pi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await Pi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await Pi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await Pi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.parent.type===d.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===d.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const f=this.parent.setEntity(null,i);r.push(f)}return i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),this.properties.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.methods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.abstractMethods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.suggestedProperties.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.suggestedMethods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected)}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.properties.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.methods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.abstractMethods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.suggestedProperties.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.suggestedMethods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this})}toFlat(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this,...((a=this.extends)==null?void 0:a.toFlat(i))||[],...this.implements.flatMap(c=>c.toFlat(i)),...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((a=this.extends)==null?void 0:a.toFlatIds(i))||[],...this.implements.flatMap(c=>c.toFlatIds(i)),...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,additionalProperties:this.additionalProperties,name:this.name}}toJSON(i=new Set){var r,a,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,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((r=this.allPropertiesImplement)==null?void 0:r.toJSON(i))||null,additionalPropertiesDataType:((a=this.additionalPropertiesDataType)==null?void 0:a.toJSON(i))||null,properties:this.properties.map(e=>e.toJSON(i)),methods:this.methods.map(e=>e.toJSON(i)),abstractMethods:this.abstractMethods.map(e=>e.toJSON(i)),implements:this.implements.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E,b,A,_;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||on(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((m=this.allPropertiesImplement)==null?void 0:m.toJSONClone(i))||null,additionalPropertiesDataType:((E=this.additionalPropertiesDataType)==null?void 0:E.toJSONClone(i))||null,properties:this.properties.map(P=>P.toJSONClone({...i,newId:null})),methods:this.methods.map(P=>P.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(P=>P.toJSONClone({...i,newId:null})),implements:this.implements.map(P=>P.type===d.BuiltInBaseEntity?P.toJSON(i.seenEntities):P.toJSONClone({...i,newId:null})),extends:((b=this.extends)==null?void 0:b.type)===d.BuiltInBaseEntity?(A=this.extends)==null?void 0:A.toJSON(i.seenEntities):(_=this.extends)==null?void 0:_.toJSONClone({...i,newId:null}),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((c=this.allPropertiesImplement)==null?void 0:c.toReference(i))||null,additionalPropertiesDataType:((e=this.additionalPropertiesDataType)==null?void 0:e.toReference(i))||null,properties:this.properties.map(h=>h.toReference(i)),methods:this.methods.map(h=>h.toReference(i)),abstractMethods:this.abstractMethods.map(h=>h.toReference(i)),implements:this.implements.map(h=>h.toReference(i)),extends:((f=this.extends)==null?void 0:f.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(f=>f.toFlatJSON(i)),...this.methods.flatMap(f=>f.toFlatJSON(i)),...this.abstractMethods.flatMap(f=>f.toFlatJSON(i)),...this.implements.flatMap(f=>f.toFlatJSON(i)),...((a=this.extends)==null?void 0:a.toFlatJSON(i))||[],...this.parent.toFlatJSON(i),...((c=this.additionalPropertiesDataType)==null?void 0:c.toFlatJSON(i))||[],...((e=this.allPropertiesImplement)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var c,e,f;const r=this.parent.type===d.Project?void 0:(c=i.seenEntityMaps)!=null&&c.has(this.parent.id)?i.seenEntityMaps.get(this.parent.id):this.parent.id;let a=this.id;return(e=i.seenEntityMaps)!=null&&e.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:(f=this.extends)==null?void 0:f.id,additionalProperties:this.additionalProperties,implements:this.implements.map(h=>h.id),parent:r}}toFlatGenerationTarget(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(f=>f.toFlatGenerationTarget(i)),...this.methods.flatMap(f=>f.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(f=>f.toFlatGenerationTarget(i)),...this.implements.filter(f=>f.type===d.DefinitionEntity).flatMap(f=>f.toFlatGenerationTarget(i)),...((a=this.extends)==null?void 0:a.toFlatGenerationTarget(i))||[],...this.parent.toFlatGenerationTarget(i),...((c=this.additionalPropertiesDataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.allPropertiesImplement)==null?void 0:e.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,r;return this.errors=[],this.properties.forEach(a=>a.clearErrors()),this.methods.forEach(a=>a.clearErrors()),this.abstractMethods.forEach(a=>a.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(r=this.allPropertiesImplement)==null||r.clearErrors(),this}validate(){return this.errors=Kke(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await Fke(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((r=this.additionalPropertiesDataType)==null?void 0:r.getErrors())||[],...((a=this.allPropertiesImplement)==null?void 0:a.getErrors())||[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.methods)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.abstractMethods)a.push(...await c.getErrorsAsync({tracker:r}));return this.additionalPropertiesDataType&&a.push(...await this.additionalPropertiesDataType.getErrorsAsync({tracker:r})),this.allPropertiesImplement&&a.push(...await this.allPropertiesImplement.getErrorsAsync({tracker:r})),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var j,M,G;const e=Ur(r,this),f=this.toJSON(),h=a||x.UUID.uuid(),m=r||this.parent;f.properties=[],f.methods=[],f.abstractMethods=[];const E=h.split("-id"),b=E[E.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.editable=!0,f.deletable=!0,f.parent=m.toReference();const A=nr(f,e);A.hydrateAncestors(),A.setParent(m,i),c&&(A.subscribe(),A.addSelfToProject(i)),A.initChildren(i),i==null||i.add(A,W.Added);const _=(j=this.properties)==null?void 0:j.map(q=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,x.UUID.uuid(),c));A.properties=_;const P=(M=this.methods)==null?void 0:M.map((q,re)=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,b+"-method-"+re+"-id",c));A.methods=P;const V=(G=this.abstractMethods)==null?void 0:G.map((q,re)=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,b+"-abstract-method-"+re+"-id",c));if(A.abstractMethods=V,this.additionalPropertiesDataType)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.additionalPropertiesDataType.id))A.setAdditionalPropertiesDataType(this.additionalPropertiesDataType,i);else{const q=this.additionalPropertiesDataType.clone(i,A,x.UUID.uuid(),c);A.setAdditionalPropertiesDataType(q,i)}if(this.allPropertiesImplement)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.allPropertiesImplement.id))A.setAllPropertiesImplement(this.allPropertiesImplement,i);else{const q=this.allPropertiesImplement.clone(i,A,x.UUID.uuid(),c);A.setAllPropertiesImplement(q,i)}return i||A.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),A}getFunctionDeclaration(i){return this.methods.find(r=>r.id===i)}implement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"implement-definition-entity")),a){const c=m1(this,i,r,a);return r==null||r.attemptAutoclose("implement-definition-entity",this.id),c}getAllPropertiesImplements(){var r;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),i.push(...((r=this.extends)==null?void 0:r.getAllPropertiesImplements())||[],...this.implements.flatMap(a=>a.getAllPropertiesImplements())),i}getAllInteractiveMethods(){var e;const i=this.implements.filter(f=>f.type===d.DefinitionEntity||f.type===d.BuiltInBaseEntity&&f.interactive),r=((e=this.extends)==null?void 0:e.getAllInteractiveMethods())||[],a=i.flatMap(f=>f.getAllInteractiveMethods());return C([...this.methods,...r,...a])}inferFromInputs(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const a=[],c=[],e=[],f=[];if(this.parent.type!==d.DataType||!this.parent.inferred)return r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const h=[];i.forEach(b=>{h.find(_=>oe(_,this.project)===oe(b,this.project))||h.push(b)});const m=this.properties.filter(b=>!b.dataType);h.forEach(b=>{var G,q,re;const A=m.find(ee=>oe(ee,this.project)===oe(b,this.project));if(!A)return;const P=Er(b.parent).getMasterInputWithValueWriterFromAllInstances(b),V=tu(P,r),j=V==null?void 0:V.clone(r,A,x.UUID.uuid(),!0);j&&((G=A.dataType)==null||G.merge(j,r),j.id!==((q=A.dataType)==null?void 0:q.id)&&j.remove({ignoreUpstream:!1},r),A.dataType&&(A.dataType.metaSync({inferred:!0,like:!0},r),A.setDataType(A.dataType,r),r==null||r.add(A,W.Affected)));let M=null;if(b.declaration&&A.id!==((re=b.declaration)==null?void 0:re.id)&&(M=b.declaration),b.setDeclaration(A,r),r==null||r.add(b,W.Updated),M){const{updated:ee,removed:se}=M.remove({ignoreUpstream:!1},r);c.push(...ee),e.push(...se)}});const E=[];return h.forEach(b=>{if(!b.declaration){E.push(b);return}}),E.length===0?(r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(E.forEach(b=>{var re,ee,se,te,le;const A=this.properties.find(ue=>oe(ue,this.project)===oe(b,this.project));if(A){if(b.setDeclaration(A,r),!A.getDataType(r)){const z=Er(b.parent).getMasterInputWithValueWriterFromAllInstances(b),X=tu(z),pe=X==null?void 0:X.clone(r,A,x.UUID.uuid(),!0);pe&&((re=A.dataType)==null||re.merge(pe,r),pe.id!==((ee=A.dataType)==null?void 0:ee.id)&&pe.remove({ignoreUpstream:!1},r),A.dataType&&(A.dataType.metaSync({inferred:!0,like:!0},r),A.setDataType(A.dataType,r),r==null||r.add(A,W.Affected)))}return}const _=oe(b,this.project),P=b.codeName||vp(b,this.project)||cs(Xi(_)),V=Es.new(r);V.parent=this.toReference(),V.index=b.index,V.name=_,V.codeName=P,V.description=b.description;const j=ge(V,this.project);j.hydrateAncestors(),j.addSelfToProject(r),r==null||r.add(j,W.Added),j.setParent(this,r),j.initChildren(r),r||j.captureVersion();const G=Er(b.parent).getMasterInputWithValueWriterFromAllInstances(b),q=tu(G);if(q&&q.id!==((se=j.dataType)==null?void 0:se.id)){const ue=q==null?void 0:q.clone(r,j,x.UUID.uuid(),!0);ue&&((te=j.dataType)==null||te.merge(ue,r),ue.id!==((le=j.dataType)==null?void 0:le.id)&&ue.remove({ignoreUpstream:!1},r),j.dataType&&(j.dataType.metaSync({inferred:!0,like:!0},r),j.setDataType(j.dataType,r),r==null||r.add(j,W.Affected)))}return this.addProperty(j,r),b.setDeclaration(j,r),r==null||r.add(b,W.Updated),j}),r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:C(a),updated:C(c),removed:C(e),affected:C(f),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(r=>{var e;if(!bv(r)||!r.defaultValue)return;const a=oe(r,this.project),c=r.codeName||vp(r,this.project)||cs(Xi(a));i[c]=((e=r.getDefaultValue())==null?void 0:e.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(r=>{var f;if(!bv(r))return;const a=oe(r,this.project),c=r.codeName||vp(r,this.project)||cs(Xi(a)),e=(f=this.project.requestActiveDynamicValue(r,!0))==null?void 0:f.value;e&&(i[c]=(e==null?void 0:e.value)||null)}),i}setAdditionalPropertiesDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetAdditionalPropertiesDataType))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setAdditionalPropertiesDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetAdditionalPropertiesDataType,this.id),this;const a=this.additionalPropertiesDataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.additionalPropertiesDataType=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetAdditionalPropertiesDataType,this.id),this}removeAdditionalPropertiesDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAllPropertiesImplement))){return this.checkCanEdit(this,i)?(this.additionalPropertiesDataType&&(this.additionalPropertiesDataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.additionalPropertiesDataType=null),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this):(Y.Logger.warn(`[removeAdditionalPropertiesDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this)}setAllPropertiesImplement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetAllPropertiesImplement))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setAllPropertiesImplement] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetAllPropertiesImplement,this.id),this;const a=this.allPropertiesImplement;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.allPropertiesImplement=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetAllPropertiesImplement,this.id),this}removeAllPropertiesImplement(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAllPropertiesImplement))){return this.checkCanEdit(this,i)?(this.allPropertiesImplement&&(this.properties.find(r=>{var a;return r.id===((a=this.allPropertiesImplement)==null?void 0:a.id)})||this.allPropertiesImplement.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.allPropertiesImplement=null),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this):(Y.Logger.warn(`[removeAllPropertiesImplement] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this)}};R(Pi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(Pi,"type",d.DefinitionEntity),R(Pi,"USER_MANAGED_PARENT_TYPES",[d.Project,d.DataType]),R(Pi,"PARENT_TYPES",[...Pi.USER_MANAGED_PARENT_TYPES]),R(Pi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract","additionalProperties"]),R(Pi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(Pi,"BASE_PROPERTIES",[...Pi.MUTABLE_BASE_PROPERTIES,...Pi.INMUTABLE_BASE_PROPERTIES]),R(Pi,"MUTABLE_META_PROPERTIES",[...Pi.MUTABLE_BASE_PROPERTIES,"x","y"]),R(Pi,"INMUTABLE_META_PROPERTIES",[...Pi.INMUTABLE_BASE_PROPERTIES]),R(Pi,"META_PROPERTIES",[...Pi.MUTABLE_META_PROPERTIES,...Pi.INMUTABLE_META_PROPERTIES]),R(Pi,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),R(Pi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(Pi,"UPSTREAM_PROPERTIES",[...Pi.MUTABLE_UPSTREAM_PROPERTIES,...Pi.INMUTABLE_UPSTREAM_PROPERTIES]),R(Pi,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods","allPropertiesImplement","additionalPropertiesDataType"]),R(Pi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(Pi,"DOWNSTREAM_PROPERTIES",[...Pi.MUTABLE_DOWNSTREAM_PROPERTIES,...Pi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(Pi,"PROPERTIES",[...Pi.META_PROPERTIES,...Pi.UPSTREAM_PROPERTIES,...Pi.DOWNSTREAM_PROPERTIES]);let Fs=Pi;async function xVi(s,p={}){const i=Y.YieldTracker.from(p),r=[],a=St(s.errors,r);return await i.tick(),a}function $Vi(s){const p=[];return St(s.errors,p)}const lI=class lI extends $x{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"name");R(this,"description",null);R(this,"type",d.PrimitiveEntity);R(this,"static");R(this,"abstract");R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.description=i.description,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(a=>{const c=ge(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=ge(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=ge(this.initialData.extends,this.project))}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allMethods)||[],r=[...i].filter(c=>!i.some(e=>e.id!==c.id));return C(r)}get allBasePropertiesFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allProperties)||[],r=[...i].filter(c=>!i.some(e=>{var f;return e.id!==c.id&&(e.implements.find(h=>h.id===c.id)||((f=e.extends)==null?void 0:f.id)===c.id)}));return C(r)}get allBasePropertiesFromExtendedAndImplementedEntities(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||E.implements.find(A=>A.id===h.id)}))},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeBuiltInInstance(this),this}unsubscribe(){return this.project.unsubscribeBuiltInInstance(this),this}async APILoad(i=Ke,...r){return await lI.repository.APILoad(this.id,...r),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(a=>a.toFlat(i)),...this.methods.flatMap(a=>a.toFlat(i)),...this.abstractMethods.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(a=>a.toFlatIds(i)),...this.methods.flatMap(a=>a.toFlatIds(i)),...this.abstractMethods.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){var r;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:((r=this.extends)==null?void 0:r.toJSON(i))||null})}toReference(i=at){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=at){var r;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:((r=this.extends)==null?void 0:r.toReference())||null}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(a=>a.toFlatJSON(i)),...this.methods.flatMap(a=>a.toFlatJSON(i)),...this.abstractMethods.flatMap(a=>a.toFlatJSON(i))])}toGenerationTarget(i=at){var r;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:(r=this.extends)==null?void 0:r.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(a=>a.toFlatGenerationTarget(i)),...this.methods.flatMap(a=>a.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(a=>a.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=$Vi(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await xVi(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors,...this.properties.flatMap(r=>r.getErrors()),...this.methods.flatMap(r=>r.getErrors()),...this.abstractMethods.flatMap(r=>r.getErrors())]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),!this.extends||this.extends.type===d.PrimitiveEntity?i:C(i)}};R(lI,"repository",{APILoad:async(i,...r)=>null});let Fa=lI;function nr(s,p){if(!s)throw new Error("Entity is null");const i=p.get(s.id);switch(s.type){case d.LiteralValue:return i||new Nr(s,p);case d.DefinitionEntity:return i||new Fs(s,p);case d.PrimitiveEntity:return i||new Fa(s,p);case d.FunctionDeclaration:return i||new Td(s,p);case d.GlobalEvent:return i||new Op(s,p);case d.DataType:return i||new mr(s,p);case d.Property:return i||new Es(s,p);case d.FunctionCall:return i||new wp(s,p);case d.Condition:return i||new Vp(s,p);case d.Operation:return i||new Cp(s,p);case d.VariableDeclaration:return i||new Np(s,p);case d.VariableInstance:return i||new Pp(s,p);case d.OutputMap:return i||new po(s,p);case d.ArgumentDeclaration:return i||new Za(s,p);case d.InputMap:return i||new Ts(s,p);case d.Project:return i||new x(s);case d.InstalledProject:return i||new $p(s,p);case d.ActionDescriptor:return i||new Ji(s,p);case d.ReturnStatement:return i||new au(s,p);case d.Loop:return i||new _p(s,p);case d.Search:return i||new xp(s,p);case d.ValueDescriptor:return i||new bd(s,p);case d.BuiltInBaseEntity:return i||new vd(s,p);case d.InternalCall:return i||new Lp(s,p);case d.ContinueStatement:return i||new Mp(s,p);case d.BreakStatement:return i||new Bp(s,p);case d.GenericReference:return p.get(s.entityId);default:throw new Error("Invalid entity type: "+s.type)}}function ge(s,p){if(!s)throw new Error("Entity is null");const i=nr(s,p);return i.subscribe(),i}function LVi(s,p,i){if(!s)throw new Error("Entity is null");switch(s.type){case d.LiteralValue:return Nr.fromGenerationTarget(s,p,i);case d.DefinitionEntity:return Fs.fromGenerationTarget(s,p,i);case d.FunctionDeclaration:return Td.fromGenerationTarget(s,p,i);case d.GlobalEvent:return Op.fromGenerationTarget(s,p,i);case d.DataType:return mr.fromGenerationTarget(s,p,i);case d.Property:return Es.fromGenerationTarget(s,p,i);case d.FunctionCall:return wp.fromGenerationTarget(s,p,i);case d.Condition:return Vp.fromGenerationTarget(s,p,i);case d.Operation:return Cp.fromGenerationTarget(s,p,i);case d.VariableDeclaration:return Np.fromGenerationTarget(s,p,i);case d.VariableInstance:return Pp.fromGenerationTarget(s,p,i);case d.OutputMap:return po.fromGenerationTarget(s,p,i);case d.ArgumentDeclaration:return Za.fromGenerationTarget(s,p,i);case d.InputMap:return Ts.fromGenerationTarget(s,p,i);case d.InstalledProject:return $p.fromGenerationTarget(s,p,i);case d.ReturnStatement:return au.fromGenerationTarget(s,p,i);case d.Loop:return _p.fromGenerationTarget(s,p,i);case d.Search:return xp.fromGenerationTarget(s,p,i);case d.ActionDescriptor:return Ji.fromGenerationTarget(s,p,i);case d.ValueDescriptor:return bd.fromGenerationTarget(s,p,i);case d.InternalCall:return Lp.fromGenerationTarget(s,p,i);case d.ContinueStatement:return Mp.fromGenerationTarget(s,p,i);case d.BreakStatement:return Bp.fromGenerationTarget(s,p,i);default:throw new Error("Invalid entity type: "+s.type)}}const at={seenEntityMaps:new Map,seenEntities:new Set,timestamp:B().toISOString()};class Yke{constructor(){R(this,"initialData")}}const Ke={cascade:!1},Jke={APILoad:async(s,...p)=>null},BVi={APICreate:async(s,...p)=>s,APIUpdate:async(s,...p)=>s,APIDelete:async(s,...p)=>s,APIClone:async(s,...p)=>{},APILoadVersion:async(s,p,...i)=>null,...Jke};class MVi{}class Qke extends Yke{}class GVi extends Qke{}class jVi{}class kVi{}class UVi{}class AL{}class FVi extends AL{}class KVi extends AL{}class qVi{}class ly{static initReadsValue(p){if(p.initialData.readsValue&&p.initialData.readsValue.type!==d.GenericReference)p.readsValue=ge(p.initialData.readsValue,p.project);else if(p.initialData.readsValue&&p.initialData.readsValue.type===d.GenericReference){const i=Ia(p.initialData.readsValue,p.project);i&&(p.readsValue=i)}if(p.readsValue){if(Lt.includes(p.readsValue.type)){let i=p.parent;!Ir.includes(i.type)&&i.type!==d.Project&&(i=i.parent);const r=p.type===d.InputMap&&p.parent.type===d.Loop;r&&(i=p.parent.parent),p.readsValue.setParent(i,null),p.readsValue.initChildren(null),i&&i.type!==d.Project&&!r&&i.detachedChildren.includes(p)?i.replaceDetachedChild(p,p.readsValue):i&&i.type!==d.Project&&!r&&i.subscribeDetachedChild(p.readsValue)}p.readsValue.addValueReader(p,null)}return p.readsValue}}class XE{static initWritesValues(p,i){const r=p.initialData.writesValues.reduce((c,e)=>{if(e.type===d.GenericReference||p.writesValues.some(h=>h.id===e.id))return c;const f=ge(e,p.project);return f.setValueWriter(p,null),Lt.includes(f.type)&&(f.setParent(i,null),f.initChildren(null)),[...c,f]},[]),a=[...p.writesValues];return p.writesValues=C([...a,...r]),p.writesValues}}class SVi{}var li=(s=>(s.PROJECT_INITIALIZED="project-initialized",s.BEFORE_CHANGE_SET_CLOSE_BEFORE_SIDE_EFFECTS="before-change-set-close-before-side-effects",s.BEFORE_CHANGE_SET_CLOSE_AFTER_SIDE_EFFECTS="before-change-set-close-after-side-effects",s.CHANGE_SET_CLOSED_BEFORE_PERSIST="change-set-closed-before-persist",s.CHANGE_SET_PERSISTED="change-set-persisted",s.BEFORE_CHANGE_SET_PERSIST="before-change-set-persist",s.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",s.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",s.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",s.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",s.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",s.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",s.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",s.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",s.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",s))(li||{});const gL={...c$,events:new Y.Events("def-proj-static-p-ctx-events")},Xke={requestActiveDynamicValue:(s,p=!1)=>null,...gL},Bt=class Bt extends dn{constructor(i,r={...Xke,events:new Y.Events("def-proj-inst-p-ctx-events")}){super(i);R(this,"initialData");R(this,"id");R(this,"type",d.Project);R(this,"name",null);R(this,"description",null);R(this,"x");R(this,"y");R(this,"entities",[]);R(this,"projects",[]);R(this,"functions",[]);R(this,"events",[]);R(this,"variableDeclarations",[]);R(this,"variableInstances",[]);R(this,"conditions",[]);R(this,"operations",[]);R(this,"functionCalls",[]);R(this,"loops",[]);R(this,"searches",[]);R(this,"primitives",[]);R(this,"builtInBaseEntities",[]);R(this,"operationDeclarations",[]);R(this,"globalEventActionDescriptors",[]);R(this,"loopDeclarations",[]);R(this,"loopDeclarationsBodies",[]);R(this,"conditionDeclarations",[]);R(this,"valueDescriptors",[]);R(this,"dataTypes",[]);R(this,"project");R(this,"instances",{});R(this,"builtInInstances",{});R(this,"deletedInstances",{});R(this,"subscribedDefinitionEntities",new Set);R(this,"errors",[]);R(this,"references",[]);R(this,"history",[]);R(this,"undoableStackValueIndex",-1);R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"diggestedBuiltInBaseEntitiesIds",new Set);R(this,"rejectParallelCS",!1);R(this,"onPersistChangeSetSequentiallyCallback",null);R(this,"onPersistChangeSetInParallelCallback",null);R(this,"onAddChangeSetCallback",null);R(this,"onDiscardChangeSetCallback",null);if(this.parentContext=r,this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this,!Bt.UUID)throw new Error("UUID module is already initialized. Please inject a valid UUID module.")}static get UUID(){var i;return(i=this.parentContext.requestExtension("uuid"))==null?void 0:i.module}static new(i=null){return{id:Bt.UUID.uuid(),version:Bt.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||Bt.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=Qr(a);return e.push(...f.errors),c.push(...f.explanations),{errors:e,explanations:c,modifiedData:a}}get off(){return this.parentContext.events.off}get on(){return this.parentContext.events.on}get emit(){return this.parentContext.events.emit}get emitAsync(){return this.parentContext.events.emitAsync}get emitAsyncAll(){return this.parentContext.events.emitAsyncAll}get emitAsyncAllSettled(){return this.parentContext.events.emitAsyncAllSettled}get emitAsyncSequentially(){return this.parentContext.events.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.parentContext.events.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.parentContext.events.emitAsyncSequentiallyAllSettled}async closePersistChangeSetsSequentially(){Y.Logger.log("[ProjectState.closePersistChangeSetsSequentially] called");const i=this.history.find(r=>r.dirty&&!r.open&&!r.submitting);i&&(Y.Logger.log(`[ProjectState.closePersistChangeSetsSequentially] closing pending change-set ${i.id} - ${i.autoCloseActionName}`),await this.persistChangeSetSequentially(i))}async onPersistChangeSetSequentially(i){this.onPersistChangeSetSequentiallyCallback=i,Y.Logger.log("[ProjectState.onPersistChangeSetSequentially] onPersistChangeSetSequentiallyCallback has been set. Checking for pending change-sets."),await this.closePersistChangeSetsSequentially()}offPersistChangeSetSequentially(){this.onPersistChangeSetSequentiallyCallback=null}async onPersistChangeSetInParallel(i){this.onPersistChangeSetInParallelCallback=i,Y.Logger.log("[ProjectState.onPersistChangeSetInParallel] onPersistChangeSetInParallelCallback has been set. Checking for pending change-sets.");for(const r of this.history)this.persistChangeSetInParallel(r),await new Promise(a=>setTimeout(a,27))}offPersistChangeSetInParallel(){this.onPersistChangeSetInParallelCallback=null}onAddChangeSet(i){this.onAddChangeSetCallback=i}offAddChangeSet(){this.onAddChangeSetCallback=null}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}offDiscardChangeSet(){this.onDiscardChangeSetCallback=null}async persistChangeSetSequentially(i){if(Y.Logger.log(`[ProjectState.persistChangeSetSequentially] called for change-set ${i.id} - ${i.autoCloseActionName}`),!i.dirty||i.open||i.submitting){Y.Logger.log(`[ProjectState.persistChangeSetSequentially] change-set ${i.id} - ${i.autoCloseActionName} is not dirty, or is open, or is already being submitted, skipping.`);return}const r=this.history.findIndex(e=>e.id===i.id),a=this.history.slice(0,r),c=a[a.length-1];if(c!=null&&c.dirty){Y.Logger.log(`[ProjectState.persistChangeSetSequentially] lastBeforeSelf is dirty: ${c.id} - ${c.autoCloseActionName}, closing it first.`);return}this.onPersistChangeSetSequentiallyCallback&&(Y.Logger.log(`[ProjectState.persistChangeSetSequentially] invoking onPersistChangeSetSequentiallyCallback for change-set ${i.id} - ${i.autoCloseActionName}`),this.emit("before-change-set-persist",i),i.submitting=!0,(await this.onPersistChangeSetSequentiallyCallback(i)).success&&(i.dirty=!1,this.emit("change-set-persisted",i),Y.Logger.log(`[ProjectState.persistChangeSetSequentially] change-set ${i.id} - ${i.autoCloseActionName} closed successfully, checking for pending change-sets to close.`),this.closePersistChangeSetsSequentially()))}async persistChangeSetInParallel(i){if(Y.Logger.log(`[ProjectState.persistChangeSetInParallel] called for change-set ${i.id} - ${i.autoCloseActionName}`),!i.dirty||i.open||i.submitting){Y.Logger.log(`[ProjectState.persistChangeSetInParallel] change-set ${i.id} - ${i.autoCloseActionName} is not dirty, or is open, or is already being submitted, skipping.`);return}this.onPersistChangeSetInParallelCallback&&(Y.Logger.log(`[ProjectState.persistChangeSetInParallel] invoking onPersistChangeSetInParallelCallback for change-set ${i.id} - ${i.autoCloseActionName}`),this.emit("before-change-set-persist",i),i.submitting=!0,(await this.onPersistChangeSetInParallelCallback(i)).success&&(i.dirty=!1,this.emit("change-set-persisted",i)))}toLatestChangeSet(i,r,a,c=!1,e="here-this"){if(!this.history.length)return new S(this,i,r,a,c,e);const f=this.history[this.history.length-1];return f.open?f:this.addChangeSet(new S(this,i,r,a,c,e))}addChangeSet(i){var a,c;if(!this.history.length)return this.undoableStackValueIndex=$_(this.undoableStackValueIndex,this.history,i),(a=this.onAddChangeSetCallback)==null||a.call(this,i,this.undoableStackValueIndex),i;const r=this.history.find(e=>e.id===(i==null?void 0:i.id));if(r)return r;if(this.rejectParallelCS){const e=this.history.find(f=>f.open);if(e)throw Y.Logger.warn("Previous still open: ",e),Y.Logger.warn("New change set: ",i),new Error(`There is already an open change-set with id '${e.id}'${e.autoCloseActionName?` auto-close: ${e.autoCloseActionName}`:""}${e.self?` root: ${e.self.type} ${oe(e.self,this)}`:""}.`)}return this.undoableStackValueIndex=$_(this.undoableStackValueIndex,this.history,i),(c=this.onAddChangeSetCallback)==null||c.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var a;Y.Logger.log(`[ProjectState.discardChangeSet] called for change-set ${i.id} - ${i.autoCloseActionName}`);const r=this.history.findIndex(c=>c.id===(i==null?void 0:i.id));return r!==-1&&(this.history.splice(r,1),Y.Logger.log(`[ProjectState.discardChangeSet] Removed change-set ${i.id} - ${i.autoCloseActionName} from history.`),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(a=this.onDiscardChangeSetCallback)==null||a.call(this,i),i==null||i.teardown()),this}validateGeneratedUpdate(i){return{errors:[],explanations:[],modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){var r;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=Bt.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new Bt(this);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new Bt(this);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,P]of A.knownVersions)E.set(_,P);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new Bt(E)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.entities=[...h.entities],this.projects=[...h.projects],this.functions=[...h.functions],this.events=[...h.events],this.variableDeclarations=[...h.variableDeclarations],this.variableInstances=[...h.variableInstances],this.conditions=[...h.conditions],this.operations=[...h.operations],this.functionCalls=[...h.functionCalls],this.loops=[...h.loops],this.searches=[...h.searches],{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){return this.checkCanEdit(this,r)?(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this):(Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this)}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){return this.checkCanEdit(this,r)?(this.metaSync(i,r),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this):(Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this)}hydrateAncestors(){const i=[],r=[],a=[],c=[];return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=null){const r=[],a=[],c=[],e=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i){const r=[],a=[],c=[],e=[];return this.subscribe(),this.subscribeToDependencies(),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get instancesList(){return Object.values(this.instances)}get builtInInstancesList(){return Object.values(this.builtInInstances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.projects=this.initialData.projects.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.variableDeclarations=this.initialData.variableDeclarations.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.variableInstances=this.initialData.variableInstances.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.conditions=this.initialData.conditions.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.operations=this.initialData.operations.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.functions=this.initialData.functions.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.events=this.initialData.events.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.functionCalls=this.initialData.functionCalls.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.loops=this.initialData.loops.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.searches=this.initialData.searches.map(r=>{const a=ge(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.subscribeInstance(this),this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}unsubscribeBuiltInInstance(i){return delete this.builtInInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=en(this,i,r),c=Xr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.description=a.description!==void 0?a.description:e.description,this.x=a.x||e.x,this.y=a.y||e.y,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await Bt.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await Bt.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await Bt.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await Bt.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await Bt.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await Bt.repository.APILoadVersion(this.id,r,...a)}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,Bt.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(r=>r.toFlatIds(i)),...this.builtInBaseEntities.flatMap(r=>r.toFlatIds(i)),...this.operationDeclarations.flatMap(r=>r.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(r=>r.toFlatIds(i)),...this.loopDeclarations.flatMap(r=>r.toFlatIds(i)),...this.conditionDeclarations.flatMap(r=>r.toFlatIds(i)),...this.valueDescriptors.flatMap(r=>r.toFlatIds(i)),...this.dataTypes.flatMap(r=>r.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(r=>r.toFlat(i)),...this.builtInBaseEntities.flatMap(r=>r.toFlat(i)),...this.operationDeclarations.flatMap(r=>r.toFlat(i)),...this.globalEventActionDescriptors.flatMap(r=>r.toFlat(i)),...this.loopDeclarations.flatMap(r=>r.toFlat(i)),...this.conditionDeclarations.flatMap(r=>r.toFlat(i)),...this.valueDescriptors.flatMap(r=>r.toFlat(i)),...this.dataTypes.flatMap(r=>r.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(a=>a.toFlat(i)),...this.functions.flatMap(a=>a.toFlat(i)),...this.events.flatMap(a=>a.toFlat(i)),...this.projects.flatMap(a=>a.toFlat(i)),...this.variableDeclarations.flatMap(a=>a.toFlat(i)),...this.variableInstances.flatMap(a=>a.toFlat(i)),...this.conditions.flatMap(a=>a.toFlat(i)),...this.operations.flatMap(a=>a.toFlat(i)),...this.functionCalls.flatMap(a=>a.toFlat(i)),...this.loops.flatMap(a=>a.toFlat(i)),...this.searches.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(a=>a.toFlatIds(i)),...this.functions.flatMap(a=>a.toFlatIds(i)),...this.events.flatMap(a=>a.toFlatIds(i)),...this.projects.flatMap(a=>a.toFlatIds(i)),...this.variableDeclarations.flatMap(a=>a.toFlatIds(i)),...this.variableInstances.flatMap(a=>a.toFlatIds(i)),...this.conditions.flatMap(a=>a.toFlatIds(i)),...this.operations.flatMap(a=>a.toFlatIds(i)),...this.functionCalls.flatMap(a=>a.toFlatIds(i)),...this.loops.flatMap(a=>a.toFlatIds(i)),...this.searches.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,entities:this.entities.map(r=>r.toJSON(i)),variableDeclarations:this.variableDeclarations.map(r=>r.toJSON(i)),variableInstances:this.variableInstances.map(r=>r.toJSON(i)),conditions:this.conditions.map(r=>r.toJSON(i)),operations:this.operations.map(r=>r.toJSON(i)),loops:this.loops.map(r=>r.toJSON(i)),searches:this.searches.map(r=>r.toJSON(i)),functions:this.functions.map(r=>r.toJSON(i)),events:this.events.map(r=>r.toJSON(i)),projects:this.projects.map(r=>r.toJSON(i)),functionCalls:this.functionCalls.map(r=>r.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const r=new Map,a=new Set,c=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(e=>{if(c.includes(e)){r.set(e,e);return}r.set(e,Bt.UUID.uuid())}),a.add(this.id),{id:r.get(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,description:this.description,entities:this.entities.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),projects:this.projects.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),variableDeclarations:this.variableDeclarations.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),variableInstances:this.variableInstances.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),conditions:this.conditions.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),operations:this.operations.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),functions:this.functions.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),events:this.events.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),functionCalls:this.functionCalls.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),loops:this.loops.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),searches:this.searches.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null}))}}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+Bt.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,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,description:this.description,entities:this.entities.map(c=>c.toReference(i)),functions:this.functions.map(c=>c.toReference(i)),events:this.events.map(c=>c.toReference(i)),projects:this.projects.map(c=>c.toReference(i)),variableDeclarations:this.variableDeclarations.map(c=>c.toReference(i)),variableInstances:this.variableInstances.map(c=>c.toReference(i)),conditions:this.conditions.map(c=>c.toReference(i)),operations:this.operations.map(c=>c.toReference(i)),functionCalls:this.functionCalls.map(c=>c.toReference(i)),loops:this.loops.map(c=>c.toReference(i)),searches:this.searches.map(c=>c.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(a=>a.toFlatJSON(i)),...this.functions.flatMap(a=>a.toFlatJSON(i)),...this.events.flatMap(a=>a.toFlatJSON(i)),...this.projects.flatMap(a=>a.toFlatJSON(i)),...this.variableDeclarations.flatMap(a=>a.toFlatJSON(i)),...this.variableInstances.flatMap(a=>a.toFlatJSON(i)),...this.conditions.flatMap(a=>a.toFlatJSON(i)),...this.operations.flatMap(a=>a.toFlatJSON(i)),...this.functionCalls.flatMap(a=>a.toFlatJSON(i)),...this.loops.flatMap(a=>a.toFlatJSON(i)),...this.searches.flatMap(a=>a.toFlatJSON(i))])}toGenerationTarget(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(a=>a.toFlatGenerationTarget(i)),...this.functions.flatMap(a=>a.toFlatGenerationTarget(i)),...this.events.flatMap(a=>a.toFlatGenerationTarget(i)),...this.projects.flatMap(a=>a.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(a=>a.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(a=>a.toFlatGenerationTarget(i)),...this.conditions.flatMap(a=>a.toFlatGenerationTarget(i)),...this.operations.flatMap(a=>a.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(a=>a.toFlatGenerationTarget(i)),...this.loops.flatMap(a=>a.toFlatGenerationTarget(i)),...this.searches.flatMap(a=>a.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){return this.validateChildren(),AE([...this.errors]),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return await this.validateChildrenAsync({tracker:r}),await R_e([...this.errors]),{success:!0}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}async validateChildrenAsync(i={}){const r=Y.YieldTracker.from(i);for(let a=0;a<this.entities.length;a++)await this.entities[a].validateAsync({tracker:r});for(let a=0;a<this.projects.length;a++)await this.projects[a].validateAsync({tracker:r});for(let a=0;a<this.functions.length;a++)await this.functions[a].validateAsync({tracker:r});for(let a=0;a<this.events.length;a++)await this.events[a].validateAsync({tracker:r});for(let a=0;a<this.variableDeclarations.length;a++)await this.variableDeclarations[a].validateAsync({tracker:r});for(let a=0;a<this.variableInstances.length;a++)await this.variableInstances[a].validateAsync({tracker:r});for(let a=0;a<this.conditions.length;a++)await this.conditions[a].validateAsync({tracker:r});for(let a=0;a<this.operations.length;a++)await this.operations[a].validateAsync({tracker:r});for(let a=0;a<this.functionCalls.length;a++)await this.functionCalls[a].validateAsync({tracker:r});for(let a=0;a<this.loops.length;a++)await this.loops[a].validateAsync({tracker:r});for(let a=0;a<this.searches.length;a++)await this.searches[a].validateAsync({tracker:r})}getErrors(){return[...this.errors,...this.entities.flatMap(r=>r.getErrors()),...this.projects.flatMap(r=>r.getErrors()),...this.functions.flatMap(r=>r.getErrors()),...this.events.flatMap(r=>r.getErrors()),...this.variableDeclarations.flatMap(r=>r.getErrors()),...this.variableInstances.flatMap(r=>r.getErrors()),...this.conditions.flatMap(r=>r.getErrors()),...this.operations.flatMap(r=>r.getErrors()),...this.functionCalls.flatMap(r=>r.getErrors()),...this.loops.flatMap(r=>r.getErrors()),...this.searches.flatMap(r=>r.getErrors())]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(let c=0;c<this.entities.length;c++){const e=await this.entities[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.projects.length;c++){const e=await this.projects[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.functions.length;c++){const e=await this.functions[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.events.length;c++){const e=await this.events[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.variableDeclarations.length;c++){const e=await this.variableDeclarations[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.variableInstances.length;c++){const e=await this.variableInstances[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.conditions.length;c++){const e=await this.conditions[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.operations.length;c++){const e=await this.operations[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.functionCalls.length;c++){const e=await this.functionCalls[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.loops.length;c++){const e=await this.loops[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.searches.length;c++){const e=await this.searches[c].getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}clone(){return this}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const r=this.entities.findIndex(a=>a.id===i.id);if(r>-1){const a=this.entities[r];return this.entities.splice(r,1),a}return null}removeCondition(i){const r=this.conditions.findIndex(a=>a.id===i.id);if(r>-1){const a=this.conditions[r];return this.conditions.splice(r,1),a}return null}removeOperation(i){const r=this.operations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.operations[r];return this.operations.splice(r,1),a}return null}removeLoop(i){const r=this.loops.findIndex(a=>a.id===i.id);if(r>-1){const a=this.loops[r];return this.loops.splice(r,1),a}return null}removeSearch(i){const r=this.searches.findIndex(a=>a.id===i.id);if(r>-1){const a=this.searches[r];return this.searches.splice(r,1),a}return null}removeFunctionCall(i){const r=this.functionCalls.findIndex(a=>a.id===i.id);if(r>-1){const a=this.functionCalls[r];return this.functionCalls.splice(r,1),a}return null}removeVariableInstance(i){const r=this.variableInstances.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableInstances[r];return this.variableInstances.splice(r,1),a}return null}removeVariableDeclaration(i){const r=this.variableDeclarations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableDeclarations[r];return this.variableDeclarations.splice(r,1),a}return null}removeFunctionDeclaration(i){const r=this.functions.findIndex(a=>a.id===i.id);if(r>-1){const a=this.functions[r];return this.functions.splice(r,1),a}return null}removeInstalledProject(i){const r=this.projects.findIndex(a=>a.id===i.id);if(r>-1){const a=this.projects[r];return this.projects.splice(r,1),a}return null}removeGlobalEvent(i){const r=this.events.findIndex(a=>a.id===i.id);if(r>-1){const a=this.events[r];return this.events.splice(r,1),a}return null}removeTopLevelVariableDeclaration(i){if(i.type!==d.VariableDeclaration)return null;const r=this.variableDeclarations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableDeclarations[r];return this.variableDeclarations.splice(r,1),a}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(r=>r.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.ReturnStatement||e.type===d.ContinueStatement||e.type===d.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(r=>r.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[])]}getDefinitionEntities(i=new Set){return Array.from(this.subscribedDefinitionEntities).filter(a=>!i.has(a)).map(a=>this.get(a))}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.functionCalls.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.conditions.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.operations.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.loops.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[]),...this.searches.reduce((r,a)=>{const c=ur(a);return[...r,...c]},[])]}getVariableInstances(){return[...this.variableInstances,...this.entities.reduce((r,a)=>[...r,...a.methods.flatMap(c=>{const f=ct(c).filter(h=>h.type===d.VariableInstance);return[...r,...f]})],[]),...this.getEntryPoints().reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.functionCalls.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.conditions.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.operations.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.loops.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.searches.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[])]}getVariableDeclarations(){return C([...this.variableDeclarations,...this.entities.reduce((r,a)=>[...r,...a.methods.flatMap(c=>{const f=ct(c).filter(h=>h.type===d.VariableDeclaration);return[...r,...f]})],[]),...this.getEntryPoints().reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.functionCalls.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.conditions.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.operations.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.loops.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.searches.reduce((r,a)=>{const e=ur(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.searches.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.functionCalls.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.conditions.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.operations.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.loops.reduce((r,a)=>{const c=ct(a);return[...r,...c.filter(e=>e.type===d.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),r=this.getVariableDeclarations();return i.forEach(a=>{if(!a.declaration){const c=a.initialData,e=c.declaration.entityId||c.declaration.id,f=r.find(h=>h.id===e);f&&a.setDeclaration(f)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===Ae.PERSISTED_ENTITY)||null}requestActiveDynamicValue(i,r=!1){var c,e;const a=(e=(c=this.parentContext).requestActiveDynamicValue)==null?void 0:e.call(c,i,r);if(!a&&pI.includes(i.type)){const f=i.getDefaultValue();return f?{value:f,type:Me.DefaultValue,inheritanceLink:null,valueOwner:i}:null}return a||null}requestExtension(i){if(this.parentContext.requestExtension){const r=this.parentContext.requestExtension(i);if(r&&!r.module)throw new Error(`Module ${i} is not registered properly.`);return r.module||null}return null}undo(){Y.Logger.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,Y.Logger.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],r=this.history[this.undoableStackValueIndex];return Y.Logger.log("Current change set: ",i==null?void 0:i.toJSON()),Y.Logger.log("Change set to restore: ",r==null?void 0:r.toJSON()),N_(i||"initial",r||"initial",this)}redo(){Y.Logger.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,Y.Logger.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],r=this.history[this.undoableStackValueIndex];return Y.Logger.log("Current change set: ",i==null?void 0:i.toJSON()),Y.Logger.log("Change set to restore: ",r.toJSON()),N_(i||"initial",r||"initial",this)}applyExternalChangeSet(i){const r=i.payload,a=this.addChangeSet(new S(this,i.userAuthor,i.emittedAt,this));a.ignoreNonEditable=!0,a.ignoreNonDeletable=!0;const c=r.updated[this.id];if(!c)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const e={...r.added,...r.updated,...r.removed},f=[...Object.keys(r.added),...Object.keys(r.updated),...Object.keys(r.removed)];f.forEach(m=>{var E;if(!e[m]){Y.Logger.warn(`Entity '${m}' not found in change set transfer. Cannot apply changes.`);const b=(E=this.get(m))==null?void 0:E.toShallowJSON();throw b?Y.Logger.warn("Entity in project: ",b):Y.Logger.warn("Entity not in project"),new Error(`Entity '${m}' not found in change set transfer. Cannot apply changes.`)}});const h=new Un(c,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});return h.flatRecord=e,h.order=f,h.orderEntities(),Y.Logger.log("All entities: ",h.order.map((m,E)=>`${E+1}: ${e[m].type} - ${m}`).join(`,
|
|
539
539
|
`)),Y.Logger.log("Persisting new additions"),h.visit(async(m,E)=>{if(r.added[m.id]){Y.Logger.log("Adding: ",m.id);try{const b=ge(m,this);if(b.hydrateAncestors(),b.addSelfToProject(a),a.add(b,W.Added),a||b.captureVersion(),!this.get(m.id))throw new Error(`Entity ${m.id} was not added to the project`)}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),Y.Logger.log("Persisting updates"),h.visit(async(m,E)=>{if(r.updated[m.id]){Y.Logger.log("Updating: ",m.id);try{const b=this.get(m.id);b?(b.updateWithShallowTransfer(m,a),a.add(b,W.Updated),a||b.captureVersion()):Y.Logger.warn(`Active version of ${m.id} not found when applying external changes`)}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),Y.Logger.log("Persisting removals"),h.visit(async(m,E)=>{if(r.removed[m.id]){Y.Logger.log("Removing: ",m.id);try{const b=this.get(m.id);b&&(b.remove({ignoreUpstream:!1},a),a.add(b,W.Removed),a||b.captureVersion())}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),a.open=!1,a}toBuiltInShallowRecord(){const i={};return Object.values(this.builtInInstances).forEach(r=>{const a=r.toShallowJSON();i[r.id]=a}),i}toShallowRecord(){const i={};return Object.values(this.instances).forEach(r=>{const a=r.toShallowJSON();i[r.id]=a}),i}toFullProjectTransfer(i){const r={shallowErrors:!1,...i},a=new Un(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});a.flatRecord={};for(const f of Object.values(this.instances))this.diggestedBuiltInBaseEntitiesIds.has(f.id)||(a.flatRecord[f.id]=f);a.order=Object.keys(a.flatRecord),a.orderEntities();const c={},e=[];return a.visit(f=>{try{const h=f.toShallowJSON();c[f.id]=h,e.push(f.id)}catch(h){if(Y.Logger.error(`[toFullProjectTransfer] Error serializing ${f.type} ${f.id}`,h),!r.shallowErrors)throw h}}),{order:e,size:e.length,record:c}}async toFullProjectTransferAsync(i={}){const r={shallowErrors:!1,...i},a=Y.YieldTracker.from(r),c=new Un(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});c.flatRecord={};for(const h of Object.values(this.instances))await a.tick(),!this.diggestedBuiltInBaseEntitiesIds.has(h.id)&&(c.flatRecord[h.id]=h);c.order=Object.keys(c.flatRecord);const e=[];if(r.seenEntityMaps)for(const h of c.order){const m=r.seenEntityMaps.get(h)??h;this.diggestedBuiltInBaseEntitiesIds.has(m)}await c.orderEntitiesAsync({tracker:a});const f={};return await c.visitAsync(async h=>{try{if(this.diggestedBuiltInBaseEntitiesIds.has(h.id))return;const m=h.toShallowJSON({seenEntityMaps:r.seenEntityMaps});r.resetVersionOptions&&(m.version=Bt.UUID.uuid(),m.createdAt=r.resetVersionOptions.commonTimestamp||B().toISOString(),m.author=r.resetVersionOptions.author||Bt.sessionAuthor||"1",m.previousVersion=null),f[m.id]=m,e.push(m.id),r!=null&&r.onVisit&&await r.onVisit(m)}catch(m){if(Y.Logger.error(`[toFullProjectTransferAsync] Error serializing ${h.type} ${h.id}`,m),!r.shallowErrors)throw m}},{tracker:a}),{order:e,size:e.length,record:f}}async toFullProjectGenerationTargetAsync(i={}){const r={shallowErrors:!1,...i},a=Y.YieldTracker.from(r),c=new Un(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});c.flatRecord={};for(const h of Object.values(this.instances))await a.tick(),!this.diggestedBuiltInBaseEntitiesIds.has(h.id)&&(c.flatRecord[h.id]=h);c.order=Object.keys(c.flatRecord);const e=[];if(r.seenEntityMaps)for(const h of c.order){const m=r.seenEntityMaps.get(h)??h;this.diggestedBuiltInBaseEntitiesIds.has(m)}await c.orderEntitiesAsync({tracker:a});const f={};return await c.visitAsync(async h=>{try{if(this.diggestedBuiltInBaseEntitiesIds.has(h.id))return;const m=h.toGenerationTarget({seenEntityMaps:r.seenEntityMaps});f[m.id]=m,e.push(m.id),r!=null&&r.onVisit&&await r.onVisit(m)}catch(m){if(Y.Logger.error(`[toFullProjectTransferAsync] Error serializing ${h.type} ${h.id}`,m),!r.shallowErrors)throw m}},{tracker:a}),{order:e,size:e.length,record:f}}};R(Bt,"parentContext",gL),R(Bt,"sessionAuthor","1"),R(Bt,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(Bt,"type",d.Project),R(Bt,"USER_MANAGED_PARENT_TYPES",[]),R(Bt,"PARENT_TYPES",[...Bt.USER_MANAGED_PARENT_TYPES]),R(Bt,"MUTABLE_BASE_PROPERTIES",["name","description"]),R(Bt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(Bt,"BASE_PROPERTIES",[...Bt.MUTABLE_BASE_PROPERTIES,...Bt.INMUTABLE_BASE_PROPERTIES]),R(Bt,"MUTABLE_META_PROPERTIES",[...Bt.MUTABLE_BASE_PROPERTIES,"x","y"]),R(Bt,"INMUTABLE_META_PROPERTIES",[...Bt.INMUTABLE_BASE_PROPERTIES]),R(Bt,"META_PROPERTIES",[...Bt.MUTABLE_META_PROPERTIES,...Bt.INMUTABLE_META_PROPERTIES]),R(Bt,"MUTABLE_UPSTREAM_PROPERTIES",[]),R(Bt,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),R(Bt,"UPSTREAM_PROPERTIES",[...Bt.MUTABLE_UPSTREAM_PROPERTIES,...Bt.INMUTABLE_UPSTREAM_PROPERTIES]),R(Bt,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),R(Bt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(Bt,"DOWNSTREAM_PROPERTIES",[...Bt.MUTABLE_DOWNSTREAM_PROPERTIES,...Bt.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(Bt,"PROPERTIES",[...Bt.META_PROPERTIES,...Bt.UPSTREAM_PROPERTIES,...Bt.DOWNSTREAM_PROPERTIES]);let x=Bt;class ZVi extends Ji{constructor(p){super(dE,p)}}class HVi extends Ji{constructor(i){super(rm,i);R(this,"autoexecutable",!0)}getEntityToMatchInputMap(i){return i.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(i){return i.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(i){return i.outputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id})||null}getEntityToMatch(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-entity-to-match-validate-data"))){var e;const a=((e=this.project.requestActiveDynamicValue(i))==null?void 0:e.value)||null,c=a==null?void 0:a.valueAsTypeSingle;return r==null||r.attemptAutoclose("get-entity-to-match-validate-data",this.id),c}syncOperationInstance(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-operation-instance-validate-data"))){const a=[],c=[],e=[],f=[],h=this.getEntityToMatchInputMap(i);if(h){const{added:b,updated:A,removed:_,affected:P}=this.syncEntityToMatchInputMapDataType(h,r);a.push(...A),c.push(...b),e.push(..._),f.push(...P)}const m=this.getDataToValidateInputMap(i);if(m){const{added:b,updated:A,removed:_,affected:P}=this.syncDataToValidateInputMapDataType(m,r);a.push(...A),c.push(...b),e.push(..._),f.push(...P)}const E=this.getOutputDataOutputMap(i);if(E){const{added:b,updated:A,removed:_,affected:P}=this.syncOutputDataOutputMapDataType(E,r);a.push(...A),c.push(...b),e.push(..._),f.push(...P)}return r==null||r.attemptAutoclose("sync-operation-instance-validate-data",this.id),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:i}}syncEntityToMatchInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-entity-to-match-input-map-data-type"))){var E,b,A,_,P,V,j,M,G,q,re,ee,se,te,le,ue,z,X;const a=[],c=[],e=[],f=[];if(((E=i.declaration)==null?void 0:E.id)!==ne.operation[Le.Validate].inputs.entityToMatch.id)return r==null||r.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=((b=this.project.requestActiveDynamicValue(i))==null?void 0:b.value)||null,m=h==null?void 0:h.valueAsTypeSingle;if(!i.dataType){const pe={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,parentRelationType:null,options:((A=i.declaration.dataType)==null?void 0:A.options)||null,implementationChooseOne:((_=i.declaration.dataType)==null?void 0:_.implementationChooseOne)||!1,staticEntities:((P=i.declaration.dataType)==null?void 0:P.staticEntities)??null,interactiveEntities:((V=i.declaration.dataType)==null?void 0:V.interactiveEntities)??null,actionEntities:((j=i.declaration.dataType)==null?void 0:j.actionEntities)??null,index:((M=i.declaration.dataType)==null?void 0:M.index)??null,isList:((G=i.declaration.dataType)==null?void 0:G.isList)||!1,foreignKeyAllowed:((q=i.declaration.dataType)==null?void 0:q.foreignKeyAllowed)??null,andChildrenGroup:null,orChildrenGroup:null,foreignKeyRef:null,asType:!0,entity:(m==null?void 0:m.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},de=ge(pe,i.project);de.hydrateAncestors(),de.addSelfToProject(r),r==null||r.add(de,W.Added),de.setParent(i,r),de.initChildren(r),de.setEntity(m,r),a.push(de),i.setDataType(de,r),r||de.captureVersion()}return(z=i.dataType)==null||z.metaSync({inferred:!0,like:!1,asType:!0,options:((re=i.declaration.dataType)==null?void 0:re.options)||null,implementationChooseOne:((ee=i.declaration.dataType)==null?void 0:ee.implementationChooseOne)||!1,staticEntities:((se=i.declaration.dataType)==null?void 0:se.staticEntities)??null,interactiveEntities:((te=i.declaration.dataType)==null?void 0:te.interactiveEntities)??null,actionEntities:((le=i.declaration.dataType)==null?void 0:le.actionEntities)??null,isList:((ue=i.declaration.dataType)==null?void 0:ue.isList)||!1},r),(X=i.dataType)==null||X.setEntity(m,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}syncDataToValidateInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-data-to-validate-input-map-data-type"))){var b,A,_;const a=[],c=[],e=[],f=[];if(((b=i.declaration)==null?void 0:b.id)!==ne.operation[Le.Validate].inputs.dataToValidate.id)return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=this.getEntityToMatchInputMap(i.parent);if(!h)return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(h,r))return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!i.dataType){const P={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,index:null,parentRelationType:null,options:null,implementationChooseOne:!1,foreignKeyAllowed:null,isList:!1,foreignKeyRef:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,asType:!1,entity:null,like:!0,inferred:!0,parent:i.toReference()},V=ge(P,i.project);V.hydrateAncestors(),V.addSelfToProject(r),r==null||r.add(V,W.Added),V.setParent(i,r),V.initChildren(r),a.push(V),i.setDataType(V,r),r||V.captureVersion()}(A=i.dataType)==null||A.metaSync({inferred:!0,like:!0,asType:!1},r);const E=this.getEntityToMatch(h,r);return(_=i.dataType)==null||_.setEntity(E,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}syncOutputDataOutputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-output-data-output-map-data-type"))){var A,_,P,V;const a=[],c=[],e=[],f=[];if(((A=i.declaration)==null?void 0:A.id)!==ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id)return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=this.getEntityToMatchInputMap(i.parent);if(!h)return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(h,r))return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const E=((_=this.project.requestActiveDynamicValue(h))==null?void 0:_.value)||null,b=(E==null?void 0:E.valueAsTypeSingle)||null;if(!i.dataType){const j={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,parentRelationType:null,options:null,foreignKeyRef:null,implementationChooseOne:!1,foreignKeyAllowed:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:(b==null?void 0:b.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},M=ge(j,i.project);M.hydrateAncestors(),M.addSelfToProject(r),r==null||r.add(M,W.Added),M.setParent(i,r),M.initChildren(r),M.setEntity(b,r),a.push(M),i.setDataType(M,r),r||M.captureVersion()}return(P=i.dataType)==null||P.metaSync({inferred:!0,like:!0,asType:!1},r),(V=i.dataType)==null||V.setEntity(b,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}inferInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-input-map-data-type-validate-data"))){var c,e,f;if(((c=i.declaration)==null?void 0:c.id)===ne.operation[Le.Validate].inputs.entityToMatch.id){const{added:h,updated:m,removed:E,affected:b}=r?this.syncEntityToMatchInputMapDataType(i,r):{added:[],updated:[],removed:[],affected:[]};return r==null||r.attemptAutoclose("infer-input-map-data-type",this.id),{updated:C(m),added:C(h),removed:C(E),affected:C(b),self:i.dataType}}if(((e=i.declaration)==null?void 0:e.id)===ne.operation[Le.Validate].inputs.dataToValidate.id){const{added:h,updated:m,removed:E,affected:b}=this.syncDataToValidateInputMapDataType(i,r);return r==null||r.attemptAutoclose("infer-input-map-data-type",this.id),{updated:C(m),added:C(h),removed:C(E),affected:C(b),self:i.dataType}}const a=(f=i.declaration)==null?void 0:f.getDataType(r);if(a&&a.isResolved)return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:a};if(i.readsValue){const h=tu(i.readsValue,r);return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:h}}return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:null}}inferOutputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-output-map-data-type-validate-data"))){var a;if(((a=i.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id){const{added:c,updated:e,removed:f,affected:h}=this.syncOutputDataOutputMapDataType(i,r);return r==null||r.attemptAutoclose("infer-output-map-data-type-validate-data",this.id),{updated:C(e),added:C(c),removed:C(f),affected:C(h),self:i.dataType}}return{updated:[],added:[],removed:[],affected:[],self:null}}}class WVi extends Ji{constructor(p){super(hP,p)}}class zVi extends Ji{constructor(p){super(mP,p)}}class YVi extends Ji{constructor(p){super(TP,p)}}class JVi extends Ji{constructor(p){super(zI,p)}}class QVi extends Ji{constructor(p){super(yI,p)}}class XVi extends Ji{constructor(p){super(Rv,p)}}function eUe(s){const p=[new DVe(s),new ZVi(s),new HVi(s),new JVi(s),new WVi(s),new YVi(s),new zVi(s),new QVi(s),new XVi(s)];return kN.forEach(i=>{p.some(r=>r.id===i.id)||p.push(new Ji(i,s))}),p.forEach(i=>{i.initChildren(null),s.subscribeBuiltInInstance(i)}),s.operationDeclarations=p,p}const ePi=[];function tUe(s){const p=[new vVe(s),new AVe(s),new IVe(s),new RVe(s)];return px.forEach(i=>{!p.some(r=>r.id===i.id)&&!ePi.includes(i.id)&&p.push(new vd(i,s))}),p.forEach(i=>{s.subscribeBuiltInInstance(i)}),s.builtInBaseEntities=p,p}function iUe(s){const p=[new Fa(Ee,s),new Fa(pt,s),new Fa(Ne,s),new Fa(Va,s),new Fa(Rt,s),new Fa(xt,s),new Fa(ut,s),new Fa(yo,s),new Fa(sr,s)];return p.forEach(i=>{s.subscribeBuiltInInstance(i)}),s.primitives=p,p}function rUe(s){const p=[new Ji(f1,s)];return p.forEach(i=>{i.initChildren(null),s.subscribeBuiltInInstance(i)}),s.globalEventActionDescriptors=p,p}function nUe(s){const p=[new Ji(bE,s),new Ji(Qf,s),new Ji(vE,s),new Ji(Cm,s),new Ji(Om,s),new Ji(HR,s)];p.forEach(r=>{r.initChildren(null),s.subscribeBuiltInInstance(r)}),s.loopDeclarations=p;const i=[new Ji(r1,s),new Ji(EE,s),new Ji(JR,s),new Ji(ZN,s),new Ji(zN,s),new Ji(WR,s)];return i.forEach(r=>{r.initChildren(null),s.subscribeBuiltInInstance(r)}),s.loopDeclarationsBodies=i,p}function aUe(s){const p=[new bd(vx,s)];return p.forEach(i=>{i.initChildren(null),s.subscribeBuiltInInstance(i)}),s.valueDescriptors=p,p}function sUe(s){const p=[new Ji(fx,s),new Ji(cx,s),new Ji(yx,s),new Ji(hx,s)];return mx.forEach(i=>{p.some(r=>r.id===i.id)||p.push(new Ji(i,s))}),p.forEach(i=>{i.initChildren(null),s.subscribeBuiltInInstance(i)}),s.conditionDeclarations=p,p}function jT(s){return s&&typeof s.then=="function"}function tPi(s,p){const i=new Un(s[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),r=s.map(c=>c.id),a={};return s.forEach(c=>{a[c.id]=c}),i.order=r,i.flatRecord=a,i.orderEntities(),i.order.map(c=>i.flatRecord[c])}function iPi(s,p){const i=new Un(Object.values(s)[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),r=Object.keys(s);return i.order=r,i.flatRecord=s,i.orderEntities(),i.order}async function rPi(s,p){const i=Y.YieldTracker.from(p),r=new Un(s[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),a=s.map(e=>e.id),c={};for(const e of s)c[e.id]=e,await i.tick();return r.order=a,r.flatRecord=c,await r.orderEntitiesAsync({tracker:i}),r.order.map(e=>r.flatRecord[e])}async function nPi(s,p){const i=Y.YieldTracker.from(p),r=new Un(Object.values(s)[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),a=Object.keys(s);return r.order=a,r.flatRecord=s,await r.orderEntitiesAsync({tracker:i}),r.order}class Un{constructor(p,i={}){R(this,"order",[]);R(this,"flatRecord",{});R(this,"allBuiltInEntityIds");R(this,"onGoingVisits",{});R(this,"cachedReferences",{});if(i.allBuiltInEntityIds&&(this.allBuiltInEntityIds=i.allBuiltInEntityIds),!p)return;const r={asyncInitialOrder:!1,...i};r.asyncInitialOrder?this.flattenAsync(p).then(()=>{this.orderEntitiesAsync({...r}).then(()=>{var a;(a=r.onOrdered)==null||a.call(r)})}):(this.flatten(p),this.orderEntities())}flatten(p){this.allBuiltInEntityIds||(this.allBuiltInEntityIds=new Set(sD()));const i=C(Ue(p,new Set(this.allBuiltInEntityIds),{ignoreBuiltInBaseEntities:!0,diggestedBuiltInBaseEntitiesIds:this.allBuiltInEntityIds})),r=new Set;for(const a of i)this.flatRecord[a.id]=a,r.add(a.id);this.order=Array.from(r)}async flattenAsync(p,i={}){const r=Y.YieldTracker.from(i);this.allBuiltInEntityIds||(this.allBuiltInEntityIds=await lD({tracker:r}));const a=await gp(await ke(p,new Set(this.allBuiltInEntityIds),{ignoreBuiltInBaseEntities:!0,diggestedBuiltInBaseEntitiesIds:this.allBuiltInEntityIds,tracker:r}),{tracker:r}),c=new Set;for(const e of a)this.flatRecord[e.id]=e,c.add(e.id),await r.tick();this.order=Array.from(c)}moveEntityAfterDependencies(p){const i=this.cachedReferences[p.id]||lo(p,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});this.cachedReferences[p.id]=i;const{upstream:r}=i;for(const a of Object.keys(r)){const c=this.order.indexOf(a),e=this.order.indexOf(p.id);if(c>e)return this.order.splice(e,1),this.order.splice(c,0,p.id),!0}return!1}orderEntities(){let p=!1;for(let i=0;i<this.order.length;i++){const r=this.order[i],a=this.flatRecord[r];if(a||Y.Logger.warn(`Entity with id ${r} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(a)){p=!0;break}}p&&this.orderEntities()}async orderEntitiesAsync(p={}){let i=!1;const r=Y.YieldTracker.from(p);for(let a=0;a<this.order.length;a++){const c=this.order[a],e=this.flatRecord[c];if(e||Y.Logger.warn(`Entity with id ${c} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(e)){i=!0;break}await r.tick()}i&&await this.orderEntitiesAsync({tracker:r})}getUpstreamOngoingDependenciesVisits(p,i){const r=this.cachedReferences[p]||lo(this.flatRecord[p],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});this.cachedReferences[p]=r;const{upstream:a}=r,c={};return Object.entries(this.onGoingVisits[i]||{}).forEach(([e,f])=>{Object.keys(a).includes(e)&&(c[e]=f)}),c}getDownstreamOngoingDependenciesVisits(p,i){const r=Object.keys(this.onGoingVisits[i]||{}),a=new Set(r.flatMap(e=>{const f=this.cachedReferences[e]||lo(this.flatRecord[e],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});return this.cachedReferences[e]=f,Object.keys(f.downstream)})),c={};return Array.from(a).forEach(e=>{e===p&&(c[e]=this.onGoingVisits[i][e])}),c}async settlePromises(p,i){const r=Object.values(p);r.length&&await Promise.all(r),Object.keys(p).forEach(a=>{delete this.onGoingVisits[i][a]})}visit(p){const i=this.order;for(const r of i)p(this.flatRecord[r],this.flatRecord);return this}reverseVisit(p){const i=this.order.slice().reverse();for(const r of i)p(this.flatRecord[r],this.flatRecord);return this}async visitAsync(p,i={}){const{parallelise:r}={parallelise:!0,...i},a=Y.YieldTracker.from(i),c=this.order;if(!r){for(const f of c){const h=p(this.flatRecord[f],this.flatRecord);jT(h)&&await h,await a.tick()}return this}const e=Math.random().toString(36).substring(7);this.onGoingVisits[e]={};for(const f of c){const h=this.getUpstreamOngoingDependenciesVisits(f,e);Object.keys(h).length&&await this.settlePromises(h,e);const m=p(this.flatRecord[f],this.flatRecord);jT(m)&&(this.onGoingVisits[e][f]=m),await a.tick()}return await this.settlePromises(this.onGoingVisits[e],e),this.onGoingVisits[e]={},this}async reverseVisitAsync(p,i={}){const{parallelise:r}={parallelise:!0,...i},a=Y.YieldTracker.from(i),c=this.order.slice().reverse();if(!r){for(const f of c){const h=p(this.flatRecord[f],this.flatRecord);jT(h)&&await h,await a.tick()}return this}const e=Math.random().toString(36).substring(7);this.onGoingVisits[e]={};for(const f of c){const h=this.getDownstreamOngoingDependenciesVisits(f,e);Object.keys(h).length&&await this.settlePromises(h,e);const m=p(this.flatRecord[f],this.flatRecord);jT(m)&&(this.onGoingVisits[e][f]=m),await a.tick()}return await this.settlePromises(this.onGoingVisits[e],e),this.onGoingVisits[e]={},this}}const bf={},sg={},yv={empty:!1,enrich:!0,mock:!1,ignoreCache:!1,onFetch:async()=>null,manuallyInit:!1};function lUe(s,p={enrich:!0,shallowErrors:!1},i){const r={enrich:!0,shallowErrors:!1,...p},{enrich:a,shallowErrors:c}=r,e=s.project,f=s.record,h=eD(s.project,{shallowErrors:c},i);h.instances[e.id]=h;const m=new Un(e,{allBuiltInEntityIds:h.diggestedBuiltInBaseEntitiesIds}),E=new Set;f[e.id]=e,E.add(e.id);const b=B().toISOString();Object.values(f).forEach(_=>{!_||m.allBuiltInEntityIds.has(_.id)||E.add(_.id)}),m.order=Array.from(E),m.flatRecord=f,m.orderEntities();const A=a?h.addChangeSet(new S(h,x.sessionAuthor,b,h,!0,"project-init-from-fetch-result")):null;return m.visit(_=>{if(_.id===h.id)return;const P=ge(_,h);try{P.hydrateAncestors(),P.addSelfToProject(null);const V=lo(_);Object.keys(V.downstream).forEach(j=>{const M=h.get(j);M&&M.hydrateAncestors()})}catch(V){if(c)Y.Logger.error("Error hydrating ancestors: ",V);else throw V}}),a?(m.visit(_=>{if(_.id===h.id)return;const P=h.get(_.id);if(P)try{P.afterAllChildrenInitialized(A),P.captureVersion()}catch(V){if(c)Y.Logger.error("Error in afterAllChildrenInitialized: ",V);else throw V}}),h.afterAllChildrenInitialized(A),h.subscribe(),h.captureVersion()):(Uu(h,b).forEach(P=>{P.remove({ignoreUpstream:!0},null)}),m.visit(P=>{if(P.id===h.id)return;const V=h.get(P.id);V&&(V.initialized=!0,V.captureVersion())}),h.initialized=!0,h.subscribe(),h.captureVersion()),h.initialized=!0,h.emit(li.PROJECT_INITIALIZED,h,A),A==null||A.attemptAutoclose("project-init-from-fetch-result",h.id),h}async function aPi(s,p={enrich:!0,shallowErrors:!1,yieldEvery:100},i){const r={enrich:!0,shallowErrors:!1,yieldEvery:100,...p},{enrich:a,shallowErrors:c,yieldEvery:e}=r,f=Y.YieldTracker.from({yieldEvery:e}),h=s.project,m=s.record,E=await tD(s.project,{shallowErrors:c,tracker:f},i);E.instances[h.id]=E;const b=new Un(void 0,{allBuiltInEntityIds:E.diggestedBuiltInBaseEntitiesIds});await b.flattenAsync(h,{tracker:f}),await b.orderEntitiesAsync({tracker:f});const A=new Set;m[h.id]=h,A.add(h.id);const _=B().toISOString();for(const[V,j]of Object.entries(m))!j||b.allBuiltInEntityIds.has(j.id)||(A.add(j.id),await f.tick());b.order=Array.from(A),b.flatRecord=m,await b.orderEntitiesAsync({tracker:f});const P=a?E.addChangeSet(new S(E,x.sessionAuthor,_,E,!0,"project-init-from-fetch-result")):null;if(await b.visitAsync(V=>{if(V.id===E.id)return;const j=ge(V,E);try{j.hydrateAncestors(),j.addSelfToProject(null);const M=lo(V);Object.keys(M.downstream).forEach(G=>{const q=E.get(G);q&&q.hydrateAncestors()})}catch(M){if(c)Y.Logger.error("Error hydrating ancestors: ",M);else throw Y.Logger.log("Error hydrating ancestors: ",M),M}},{tracker:f}),a){try{await b.visitAsync(V=>{if(V.id===E.id)return;const j=E.get(V.id);j&&(j.afterAllChildrenInitialized(P),j.captureVersion())},{tracker:f})}catch(V){if(c)Y.Logger.error("Error in afterAllChildrenInitialized: ",V);else throw Y.Logger.log("Error in afterAllChildrenInitialized: ",V),V}E.afterAllChildrenInitialized(P),E.subscribe(),E.captureVersion()}else Uu(E,_).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),await b.visitAsync(j=>{if(j.id===E.id)return;const M=E.get(j.id);M&&(M.initialized=!0,M.captureVersion())},{tracker:f}),E.initialized=!0,E.subscribe(),E.captureVersion();return E.initialized=!0,E.emit(li.PROJECT_INITIALIZED,E,P),P==null||P.attemptAutoclose("project-init-from-fetch-result",E.id),E}async function sPi(s,p=yv){const i={...yv,...p};if(i.empty)return{data:{project:{id:s.id,deletable:!0,editable:!0,type:d.Project,version:x.UUID.uuid(),createdAt:B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]},record:{}}};if(i.mock){const a={...E2};return a.id=s.id,{data:{project:a,record:{}}}}return Y.Logger.log("Fetching project from external API"),new Promise(async a=>{try{if(i.onFetch){const c=await i.onFetch(s.id);if(c){a({data:c});return}}else a({data:null})}catch(c){Y.Logger.error("Error fetching project: ",c),a({data:null})}})}function eD(s,p={shallowErrors:!1},i){const r=new x(s,i);iUe(r),tUe(r),eUe(r),rUe(r),nUe(r),aUe(r),sUe(r);const a=p.allBuiltInIds??new Set([...r.getAllBuiltInIds(),...sD()]);return r.diggestedBuiltInBaseEntitiesIds=a,a.forEach(c=>{if(!r.builtInInstances[c]&&r.instances[c])r.builtInInstances[c]=r.instances[c],delete r.instances[c];else if(!r.builtInInstances[c]&&!p.shallowErrors)throw new Error(`Built in entity was not properly initialized: ${c}`)}),r.instances[r.id]=r,r.activeVersion=!0,r}async function tD(s,p={shallowErrors:!1},i){const r=Y.YieldTracker.from(p),a=new x(s,i);iUe(a),tUe(a),await Y.yieldToEventLoop(),eUe(a),await Y.yieldToEventLoop(),rUe(a),nUe(a),aUe(a),sUe(a),await Y.yieldToEventLoop();const c=p.allBuiltInIds??new Set([...a.getAllBuiltInIds(),...await lD()]);a.diggestedBuiltInBaseEntitiesIds=c;for(const e of c){if(!a.builtInInstances[e]&&a.instances[e])a.builtInInstances[e]=a.instances[e],delete a.instances[e];else if(!a.builtInInstances[e]&&!p.shallowErrors)throw new Error(`Built in entity was not properly initialized: ${e}`);a.instances[e]&&delete a.instances[e],await r.tick()}return a.instances[a.id]=a,a.activeVersion=!0,a}function Uu(s,p){return s.instancesList.filter(r=>B(r.createdAt).isAfter(B(p)||!!r.previousVersion))}function lPi(s,{enrich:p,shallowErrors:i,...r}={enrich:!0,shallowErrors:!1},a){var _,P;const c=new Map,e=new Map;Object.keys(s.instances).forEach(V=>{if(s.diggestedBuiltInBaseEntitiesIds.has(V)){c.set(V,V),e.set(V,V);return}const j=s.get(V);if(!yD(j,{...s.instances,...s.builtInInstances}).every(re=>!s.diggestedBuiltInBaseEntitiesIds.has(re))){c.set(V,V),e.set(V,V);return}const q=x.UUID.uuid();c.set(V,q),e.set(q,V)});const f=((_=r.resetVersionOptions)==null?void 0:_.commonTimestamp)??B().toISOString(),h=s.toShallowJSON({seenEntityMaps:c});h.previousVersion=null,h.createdAt=f,h.version=x.UUID.uuid(),h.author=((P=r.resetVersionOptions)==null?void 0:P.author)??(x.sessionAuthor||"1");const m=eD(h,{shallowErrors:i,allBuiltInIds:s.diggestedBuiltInBaseEntitiesIds},a);m.instances[m.id]=m;const E=p?m.addChangeSet(new S(m,x.sessionAuthor,f,m,!0,"project-clone")):null,b=new Un(s,{allBuiltInEntityIds:s.diggestedBuiltInBaseEntitiesIds}),A=wL(b.flatRecord,c);return b.visit(V=>{var q;const j=V.toShallowJSON({seenEntityMaps:c});j.previousVersion=null,j.createdAt=f,j.version=x.UUID.uuid(),j.author=((q=r.resetVersionOptions)==null?void 0:q.author)??(x.sessionAuthor||"1");const M=lo(j,A);if(Object.keys(M.upstream).length){let re=!1;if(Object.keys(M.upstream).forEach(ee=>{if(!re&&(!m.get(ee)||m.getDeleted(ee))){re=!0;return}}),re)return}const G=ge(j,m);G.hydrateAncestors(),G.addSelfToProject(E),E==null||E.add(G,W.Added),r.onVisit&&r.onVisit(j)}),p?(b.visit(V=>{if(V.id===m.id)return;const j=m.get(c.get(V.id));j&&(j.afterAllChildrenInitialized(E),j.captureVersion())}),m.afterAllChildrenInitialized(E),m.subscribe(),m.captureVersion()):(Uu(m,f).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),b.visit(j=>{if(j.id===m.id)return;const M=m.get(j.id);M&&(M.initialized=!0,M.captureVersion())}),m.initialized=!0,m.subscribe(),m.captureVersion()),m.instancesList.forEach(V=>{V.previousVersion=null}),E==null||E.attemptAutoclose("project-clone",m.id),{project:m,maps:c}}async function oPi(s,{shallowErrors:p,...i}={shallowErrors:!1,yieldEvery:100}){var m,E;const r=Y.YieldTracker.from(i),a=new Map,c=new Map;Object.keys(s.instances).forEach(b=>{if(s.diggestedBuiltInBaseEntitiesIds.has(b)){a.set(b,b),c.set(b,b);return}const A=x.UUID.uuid();a.set(b,A),c.set(A,b)});const e=((m=i.resetVersionOptions)==null?void 0:m.commonTimestamp)??B().toISOString(),f=s.toShallowJSON({seenEntityMaps:a});f.previousVersion=null,f.createdAt=e,f.version=x.UUID.uuid(),f.author=((E=i.resetVersionOptions)==null?void 0:E.author)??(x.sessionAuthor||"1");const h=await s.toFullProjectTransferAsync({tracker:r,seenEntityMaps:a,resetVersionOptions:i.resetVersionOptions,onVisit:i.onVisit});return{project:f,record:h.record,order:h.order,maps:a}}async function dPi(s,{enrich:p,shallowErrors:i,...r}={enrich:!0,shallowErrors:!1,yieldEvery:100},a){var P,V;const c=Y.YieldTracker.from(r),e=new Map,f=new Map;for(const j of Object.keys(s.instances)){if(s.diggestedBuiltInBaseEntitiesIds.has(j)){e.set(j,j),f.set(j,j),await c.tick();continue}const M=x.UUID.uuid();e.set(j,M),f.set(M,j),await c.tick()}const h=((P=r.resetVersionOptions)==null?void 0:P.commonTimestamp)??B().toISOString(),m=s.toShallowJSON({seenEntityMaps:e});m.previousVersion=null,m.createdAt=h,m.version=x.UUID.uuid(),m.author=((V=r.resetVersionOptions)==null?void 0:V.author)??(x.sessionAuthor||"1");const E=await tD(m,{shallowErrors:i,tracker:c},a);E.diggestedBuiltInBaseEntitiesIds=s.diggestedBuiltInBaseEntitiesIds,E.instances[E.id]=E;const b=p?E.addChangeSet(new S(E,x.sessionAuthor,h,E,!0,"project-clone")):null,A=new Un(void 0,{allBuiltInEntityIds:s.diggestedBuiltInBaseEntitiesIds}),_=await s.toFullProjectTransferAsync({tracker:c,seenEntityMaps:e,resetVersionOptions:r.resetVersionOptions,onVisit:r.onVisit,shallowErrors:i});A.flatRecord=_.record,A.order=_.order,await A.visitAsync(j=>{var re;if(s.diggestedBuiltInBaseEntitiesIds.has(j.id))return;const M=j;M.previousVersion=null,M.createdAt=h,M.version=x.UUID.uuid(),M.author=((re=r.resetVersionOptions)==null?void 0:re.author)??(x.sessionAuthor||"1");const G=lo(M,A.flatRecord);if(Object.keys(G.upstream).length){let ee=!1;if(Object.keys(G.upstream).forEach(se=>{if(!ee&&(!E.get(se)||E.getDeleted(se))){ee=!0;return}}),ee)return}const q=ge(M,E);q.hydrateAncestors(),q.addSelfToProject(b),b==null||b.add(q,W.Added)},{tracker:c}),p?(await A.visitAsync(j=>{if(j.id===E.id||s.diggestedBuiltInBaseEntitiesIds.has(j.id))return;const M=E.get(e.get(j.id));M&&(M.afterAllChildrenInitialized(b),M.captureVersion())},{tracker:c}),E.afterAllChildrenInitialized(b),E.subscribe(),E.captureVersion()):(Uu(E,h).forEach(M=>{M.remove({ignoreUpstream:!0},null)}),await A.visitAsync(M=>{if(M.id===E.id)return;const G=E.get(M.id);G&&(G.initialized=!0,G.captureVersion())},{tracker:c}),E.initialized=!0,E.subscribe(),E.captureVersion());for(const j of E.instancesList)j.previousVersion=null,await c.tick();return b==null||b.attemptAutoclose("project-clone",E.id),{project:E,maps:e}}function uPi(s,p,i=p.addChangeSet(new S(p,x.sessionAuthor,B().toISOString(),p,!0,w.AfterAllChildrenInitialized)),{enrich:r,shallowErrors:a,...c}={shallowErrors:!1,enrich:!0}){var A,_;const e=new Map,f=new Map;Object.keys(s.instances).forEach(P=>{if(s.diggestedBuiltInBaseEntitiesIds.has(P)){e.set(P,P),f.set(P,P);return}if(P===s.id){e.set(P,p.id),f.set(p.id,P);return}const V=s.get(P);if(!yD(V,{...s.instances,...s.builtInInstances}).every(q=>!s.diggestedBuiltInBaseEntitiesIds.has(q))){e.set(P,P),f.set(P,P);return}const G=x.UUID.uuid();e.set(P,G),f.set(G,P)});const h=((A=c.resetVersionOptions)==null?void 0:A.commonTimestamp)??B().toISOString(),m=s.toShallowJSON({seenEntityMaps:e});m.previousVersion=null,m.createdAt=h,m.version=x.UUID.uuid(),m.author=((_=c.resetVersionOptions)==null?void 0:_.author)??(x.sessionAuthor||"1");const E=new Un(s,{allBuiltInEntityIds:s.diggestedBuiltInBaseEntitiesIds}),b=wL(E.flatRecord,e);return E.visit(P=>{var M;if(P.id===p.id)return;const V=P.toShallowJSON({seenEntityMaps:e});V.previousVersion=null,V.createdAt=h,V.version=x.UUID.uuid(),V.author=((M=c.resetVersionOptions)==null?void 0:M.author)??(x.sessionAuthor||"1");const j=lo(V,b);if(Object.keys(j.upstream).length){let G=!1;if(Object.keys(j.upstream).forEach(q=>{if(!G&&(!p.get(q)||p.getDeleted(q))){G=!0;return}}),G)return}try{const G=ge(V,p);G.hydrateAncestors(),G.addSelfToProject(i),i==null||i.add(G,W.Added),c.onVisit&&c.onVisit(V)}catch(G){if(a)Y.Logger.error("Error cloning entity onto existing project: ",G);else throw Y.Logger.log("Error cloning entity onto existing project: ",G),G}}),r?(E.visit(P=>{if(P.id===p.id)return;const V=p.get(e.get(P.id));V&&(V.afterAllChildrenInitialized(i),V.previousVersion=null,V.captureVersion())}),p.afterAllChildrenInitialized(i),p.subscribe(),p.captureVersion()):(Uu(p,h).forEach(V=>{V.remove({ignoreUpstream:!0},null)}),E.visit(V=>{if(V.id===p.id)return;const j=p.get(V.id);j&&(j.initialized=!0,j.previousVersion=null,j.captureVersion())}),p.initialized=!0,p.subscribe(),p.captureVersion()),p.afterAllChildrenInitialized(i),p.captureVersion(),{project:p,maps:e,changeSet:i}}async function pPi(s,p,i=p.addChangeSet(new S(p,x.sessionAuthor,B().toISOString(),p,!0,w.AfterAllChildrenInitialized)),{enrich:r,shallowErrors:a,...c}={enrich:!0,shallowErrors:!1,yieldEvery:100}){var _,P;const e=Y.YieldTracker.from(c),f=new Map,h=new Map;for(const V of Object.keys(s.instances)){if(s.diggestedBuiltInBaseEntitiesIds.has(V)){f.set(V,V),h.set(V,V),await e.tick();continue}if(V===s.id){f.set(V,p.id),h.set(p.id,V),await e.tick();continue}const j=x.UUID.uuid();f.set(V,j),h.set(j,V),await e.tick()}const m=((_=c.resetVersionOptions)==null?void 0:_.commonTimestamp)??B().toISOString(),E=s.toShallowJSON({seenEntityMaps:f});E.previousVersion=null,E.createdAt=m,E.version=x.UUID.uuid(),E.author=((P=c.resetVersionOptions)==null?void 0:P.author)??(x.sessionAuthor||"1"),p.diggestedBuiltInBaseEntitiesIds=s.diggestedBuiltInBaseEntitiesIds;const b=new Un(void 0,{allBuiltInEntityIds:s.diggestedBuiltInBaseEntitiesIds}),A=await s.toFullProjectTransferAsync({tracker:e,seenEntityMaps:f,resetVersionOptions:c.resetVersionOptions,onVisit:c.onVisit,shallowErrors:a});return b.flatRecord=A.record,b.order=A.order,await b.visitAsync(V=>{var G;if(s.diggestedBuiltInBaseEntitiesIds.has(V.id)||V.id===p.id)return;const j=V;j.previousVersion=null,j.createdAt=m,j.version=x.UUID.uuid(),j.author=((G=c.resetVersionOptions)==null?void 0:G.author)??(x.sessionAuthor||"1");const M=lo(j,b.flatRecord);if(Object.keys(M.upstream).length){let q=!1;if(Object.keys(M.upstream).forEach(re=>{if(!q&&(!p.get(re)||p.getDeleted(re))){q=!0;return}}),q)return}try{const q=ge(j,p);q.hydrateAncestors(),q.addSelfToProject(i),i==null||i.add(q,W.Added)}catch(q){if(a)Y.Logger.error("Error cloning entity onto existing project: ",q);else throw Y.Logger.log("Error cloning entity onto existing project: ",q),q}},{tracker:e}),r?(await b.visitAsync(V=>{if(V.id===p.id||s.diggestedBuiltInBaseEntitiesIds.has(V.id))return;const j=p.get(f.get(V.id));j&&(j.afterAllChildrenInitialized(i),j.previousVersion=null,j.captureVersion())},{tracker:e}),p.afterAllChildrenInitialized(i),p.subscribe(),p.captureVersion()):(Uu(p,m).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),await b.visitAsync(j=>{if(j.id===p.id)return;const M=p.get(j.id);M&&(M.initialized=!0,M.previousVersion=null,M.captureVersion())},{tracker:e}),p.initialized=!0,p.subscribe(),p.captureVersion()),p.afterAllChildrenInitialized(i),p.captureVersion(),{project:p,maps:f,changeSet:i}}function oUe(s,{enrich:p,shallowErrors:i}={enrich:!0,shallowErrors:!1},r){const a=eD(s,{shallowErrors:i},r);a.activeVersion=!0;const c=B().toISOString(),e=p?a.addChangeSet(new S(a,x.sessionAuthor,c,a,!0,"project-init")):null;e&&(e.type=y1.Automatic);const f=new Un(s,{allBuiltInEntityIds:a.diggestedBuiltInBaseEntitiesIds});return f.visit(h=>{const m=ge(h,a);m.hydrateAncestors(),m.addSelfToProject(e)}),p?(f.visit(h=>{if(h.id===a.id)return;const m=a.get(h.id);m&&(m.afterAllChildrenInitialized(e),m.captureVersion())}),a.afterAllChildrenInitialized(e),a.subscribe(),a.captureVersion()):(Uu(a,c).forEach(m=>{m.remove({ignoreUpstream:!0},null)}),f.visit(m=>{if(m.id===a.id)return;const E=a.get(m.id);E&&(E.initialized=!0,E.captureVersion())}),a.initialized=!0,a.subscribe(),a.captureVersion()),a.initialized=!0,a.emit(li.PROJECT_INITIALIZED,a,e),e==null||e.attemptAutoclose("project-init",a.id),a}async function cPi(s,{enrich:p,shallowErrors:i,yieldEvery:r}={enrich:!0,shallowErrors:!1,yieldEvery:100},a){const c=Y.YieldTracker.from({yieldEvery:r}),e=await tD(s,{shallowErrors:i,tracker:c},a),f=B().toISOString(),h=p?e.addChangeSet(new S(e,x.sessionAuthor,f,e,!0,"project-init")):null;h&&(h.type=y1.Automatic);const m=new Un(void 0,{allBuiltInEntityIds:e.diggestedBuiltInBaseEntitiesIds});return await m.flattenAsync(s,{tracker:c}),await m.orderEntitiesAsync({tracker:c}),await m.visitAsync(E=>{const b=ge(E,e);b.hydrateAncestors(),b.addSelfToProject(h)},{tracker:c}),p?(await m.visitAsync(E=>{if(E.id===e.id)return;const b=e.get(E.id);b&&(b.afterAllChildrenInitialized(h),b.captureVersion())},{tracker:c}),e.afterAllChildrenInitialized(h),e.subscribe(),e.captureVersion()):(Uu(e,f).forEach(b=>{b.remove({ignoreUpstream:!0},null)}),await m.visitAsync(b=>{if(b.id===e.id)return;const A=e.get(b.id);A&&(A.initialized=!0,A.captureVersion())},{tracker:c}),e.initialized=!0,e.subscribe(),e.captureVersion()),e.initialized=!0,e.emit(li.PROJECT_INITIALIZED,e,h),h==null||h.attemptAutoclose("project-init",e.id),e}async function fPi(s,p=yv,i){const r={...yv,...p};if(s.id&&bf[s.id]&&!r.ignoreCache)return bf[s.id];if(s.id&&sg[s.id]&&!r.ignoreCache)return await sg[s.id],bf[s.id];const a=sPi(s,r);s.id&&(sg[s.id]=a);const c=await a;if(c.data){let e;return r.mock?e=oUe(E2,{enrich:!!r.enrich},i):c.data instanceof x?e=c.data:e=lUe(c.data,{enrich:!!r.enrich},i),bf[s.id]=e,s.id&&delete sg[s.id],e}return null}function yPi(s){return bf[s.id]&&delete bf[s.id],null}const hv=Tt([He(),_a(),hr(),nu()]),dUe=$m([sn.CurrentDateAndTime,sn.Random,sn.Unique]),iD=st({type:dUe,rangeStart:hv.nullable(),rangeEnd:hv.nullable()}),eb=iD.extend({type:rt(sn.Random),rangeStart:hv,rangeEnd:hv}),uUe=iD.extend({type:rt(sn.Unique),rangeStart:ms(),rangeEnd:ms()}),pUe=iD.extend({type:rt(sn.CurrentDateAndTime),rangeStart:ms(),rangeEnd:ms()}),rD=eb.extend({rangeStart:_a().nullable(),rangeEnd:_a().nullable()}),cUe=rD.extend({rangeStart:_a(),rangeEnd:ms()}),fUe=rD.extend({rangeStart:ms(),rangeEnd:_a()}),yUe=rD.extend({rangeStart:_a(),rangeEnd:_a()}),nD=eb.extend({rangeStart:_a().nullable(),rangeEnd:_a().nullable()}),hUe=nD.extend({rangeStart:_a(),rangeEnd:ms()}),mUe=nD.extend({rangeStart:ms(),rangeEnd:_a()}),TUe=nD.extend({rangeStart:_a(),rangeEnd:_a()}),aD=eb.extend({rangeStart:nu().nullable(),rangeEnd:nu().nullable()}),vUe=aD.extend({rangeStart:nu(),rangeEnd:ms()}),EUe=aD.extend({rangeStart:ms(),rangeEnd:nu()}),bUe=aD.extend({rangeStart:nu(),rangeEnd:nu()}),AUe=eb.extend({rangeStart:ms(),rangeEnd:ms()}),gUe=Tt([hUe,mUe,TUe]),IUe=Tt([cUe,fUe,yUe]),RUe=Tt([vUe,EUe,bUe,pUe]),hPi=Tt([gUe,IUe,RUe,uUe,AUe]);function sD(){const s=new Set;return new Set(Ex.flatMap(i=>Ue(i,s)).map(i=>i.id))}function Fo(s){return[...s.calledByEntry||[],...s.calledByError||[],...s.calledBySuccess||[]].filter(p=>p.type!==d.GenericReference)}function DUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[s,...s.inputs.flatMap(r=>Ue(r,p,i)),...s.dataType?Ue(s.dataType,p,i):[],...s.error?Ue(s.error,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function wUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[s,...s.defaultValue?Ue(s.defaultValue,p):[],...s.writesValues.flatMap(r=>Ue(r,p,i)),...s.implements.flatMap(r=>Ue(r,p,i)),...s.dataType?Ue(s.dataType,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function CUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[s,...s.outputs.flatMap(r=>Ue(r,p,i)),...s.throws?Ue(s.throws,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...s.readsValue?Ue(s.readsValue,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function OUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[s,...(s.properties||[]).flatMap(r=>Ue(r,p,i)),...(s.methods||[]).flatMap(r=>Ue(r,p,i)),...(s.abstractMethods||[]).flatMap(r=>Ue(r,p,i)),...s.allPropertiesImplement?Ue(s.allPropertiesImplement,p,i):[],...s.additionalPropertiesDataType?Ue(s.additionalPropertiesDataType,p,i):[],...s.extends?Ue(s.extends,p,i):[]]}function _Ue(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Condition)throw new Error("Entity must be a condition to be flattened");return[s,...(s.andChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(s.orChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function VUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[s,...s.outputs.flatMap(r=>Ue(r,p,i)),...s.readsValue?Ue(s.readsValue,p,i):[],...s.throws?Ue(s.throws,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function PUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[s,...s.extends?Ue(s.extends,p,i):[],...(s.implements||[]).flatMap(r=>Ue(r,p,i)),...(s.properties||[]).flatMap(r=>Ue(r,p,i)),...(s.methods||[]).flatMap(r=>Ue(r,p,i)),...(s.abstractMethods||[]).flatMap(r=>Ue(r,p,i)),...s.allPropertiesImplement?Ue(s.allPropertiesImplement,p,i):[],...s.additionalPropertiesDataType?Ue(s.additionalPropertiesDataType,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function NUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.DataType)throw new Error("Entity must be a data type to be flattened");return[s,...(s.andChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(s.orChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...s.entity?Ue(s.entity,p,i):[],...s.foreignKeyRef?Ue(s.foreignKeyRef,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function xUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[s,...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...s.error?Ue(s.error,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function $Ue(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[s,...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.calls||[]).flatMap(r=>Ue(r,p,i)),...s.dataType?Ue(s.dataType,p,i):[],...s.implements?Ue(s.implements,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function LUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[s,...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.calls||[]).flatMap(r=>Ue(r,p,i)),...s.implements?Ue(s.implements,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function BUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.InputMap)throw new Error("Entity must be an input map to be flattened");return[s,...s.readsValue?Ue(s.readsValue,p,i):[],...s.declaration?Ue(s.declaration,p,i):[],...s.defaultValue?Ue(s.defaultValue,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function MUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[s,...(s.functions||[]).flatMap(r=>Ue(r,p,i)),...(s.events||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function GUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[s,...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.error?Ue(s.error,p,i):[],...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function jUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[s,...s.valueAsTypeSingle?Ue(s.valueAsTypeSingle,p,i):[],...s.valueAsTypeList&&Array.isArray(s.valueAsTypeList)?s.valueAsTypeList.flatMap(r=>Ue(r,p,i)):[],...s.parent?Ue(s.parent,p,i):[]]}function kUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Loop)throw new Error("Entity must be a loop to be flattened");return[s,...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...s.error?Ue(s.error,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...s.body?Ue(s.body,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function UUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Operation)throw new Error("Entity must be an operation to be flattened");return[s,...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.error?Ue(s.error,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function FUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.OutputMap)throw new Error("Entity must be an output map to be flattened");return[s,...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.declaration?Ue(s.declaration,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function KUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[s,...(s.properties||[]).flatMap(r=>Ue(r,p,i)),...(s.methods||[]).flatMap(r=>Ue(r,p,i)),...(s.abstractMethods||[]).flatMap(r=>Ue(r,p,i))]}function qUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Project)throw new Error("Entity must be a project to be flattened");return[s,...(s.entities||[]).flatMap(r=>Ue(r,p,i)),...(s.functions||[]).flatMap(r=>Ue(r,p,i)),...(s.events||[]).flatMap(r=>Ue(r,p,i)),...(s.projects||[]).flatMap(r=>Ue(r,p,i)),...(s.variableDeclarations||[]).flatMap(r=>Ue(r,p,i)),...(s.variableInstances||[]).flatMap(r=>Ue(r,p,i)),...(s.operations||[]).flatMap(r=>Ue(r,p,i)),...(s.conditions||[]).flatMap(r=>Ue(r,p,i)),...(s.functionCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.projects||[]).flatMap(r=>Ue(r,p,i)),...(s.loops||[]).flatMap(r=>Ue(r,p,i)),...(s.searches||[]).flatMap(r=>Ue(r,p,i))]}function SUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Property)throw new Error("Entity must be a property to be flattened");return[s,...s.defaultValue?Ue(s.defaultValue,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function ZUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[s,...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...s.throws?Ue(s.throws,p,i):[],...s.readsValue?Ue(s.readsValue,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function HUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Search)throw new Error("Entity must be a search to be flattened");return[s,...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.inputsDeclarations||[]).flatMap(r=>Ue(r,p,i)),...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...s.error?Ue(s.error,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.parent?Ue(s.parent,p,i):[]]}function WUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[s,...s.defaultValue?Ue(s.defaultValue,p,i):[],...s.dataType?Ue(s.dataType,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function zUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[s,...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...(s.internalCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.readsValue?Ue(s.readsValue,p,i):[],...s.defaultValue?Ue(s.defaultValue,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.dataType?Ue(s.dataType,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function YUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[s,...(s.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.inputs||[]).flatMap(r=>Ue(r,p,i)),...(s.outputs||[]).flatMap(r=>Ue(r,p,i)),...(s.internalCalls||[]).flatMap(r=>Ue(r,p,i)),...(s.writesValues||[]).flatMap(r=>Ue(r,p,i)),...s.readsValue?Ue(s.readsValue,p,i):[],...s.defaultValue?Ue(s.defaultValue,p,i):[],...(Fo(s)||[]).flatMap(r=>Ue(r,p,i)),...s.declaration?Ue(s.declaration,p,i):[],...s.parent?Ue(s.parent,p,i):[]]}function Ue(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(!s)throw new Error("Entity must be defined to be flattened");if(s.type===d.GenericReference)return[];const r=i.ignoreBuiltInBaseEntities?i.diggestedBuiltInBaseEntitiesIds??new Set(sD()):new Set;if(i.diggestedBuiltInBaseEntitiesIds=r,i.ignoreBuiltInBaseEntities&&(ma.includes(s.type)||r.has(s.id)))return[];if(p.has(s.id))return[];switch(s.type){case d.FunctionCall:return xUe(s,p,i);case d.Operation:return UUe(s,p,i);case d.Condition:return _Ue(s,p,i);case d.Loop:return kUe(s,p,i);case d.Search:return HUe(s,p,i);case d.GlobalEvent:return LUe(s,p,i);case d.ReturnStatement:return ZUe(s,p,i);case d.ContinueStatement:return VUe(s,p,i);case d.BreakStatement:return CUe(s,p,i);case d.VariableDeclaration:return zUe(s,p,i);case d.DefinitionEntity:return PUe(s,p,i);case d.FunctionDeclaration:return $Ue(s,p,i);case d.Project:return qUe(s,p,i);case d.ActionDescriptor:return DUe(s,p,i);case d.ArgumentDeclaration:return wUe(s,p,i);case d.ValueDescriptor:return WUe(s,p,i);case d.InputMap:return BUe(s,p,i);case d.OutputMap:return FUe(s,p,i);case d.DataType:return NUe(s,p,i);case d.InstalledProject:return MUe(s,p,i);case d.InternalCall:return GUe(s,p,i);case d.LiteralValue:return jUe(s,p,i);case d.Property:return SUe(s,p,i);case d.VariableInstance:return YUe(s,p,i);case d.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:OUe(s,p,i);case d.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:KUe(s,p,i)}return[]}async function lD(s={}){const p=new Set,i=Y.YieldTracker.from(s),r=new Set;for(const a of Ex){const c=await ke(a,p,{ignoreBuiltInBaseEntities:!1,tracker:i});for(const e of c)r.add(e.id),await i.tick()}return r}function Ko(s){return[...s.calledByEntry||[],...s.calledByError||[],...s.calledBySuccess||[]].filter(p=>p.type!==d.GenericReference)}async function JUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.inputs)a.push(...await ke(e,p,c));return s.dataType&&a.push(...await ke(s.dataType,p,c)),s.error&&a.push(...await ke(s.error,p,c)),s.parent&&a.push(...await ke(s.parent,p,c)),a}async function QUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,s.dataType&&a.push(...await ke(s.dataType,p,c)),s.parent&&a.push(...await ke(s.parent,p,c)),s.defaultValue&&a.push(...await ke(s.defaultValue,p,c));for(const e of s.writesValues||[])a.push(...await ke(e,p,c));for(const e of s.implements||[])a.push(...await ke(e,p,c));return a}async function XUe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.BreakStatement)throw new Error("Entity must be a break statement to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.outputs)a.push(...await ke(f,p,c));s.parent&&a.push(...await ke(s.parent,p,c)),s.throws&&a.push(...await ke(s.throws,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.readsValue&&a.push(...await ke(s.readsValue,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));return a}async function eFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.properties||[])a.push(...await ke(e,p,c));for(const e of s.methods||[])a.push(...await ke(e,p,c));for(const e of s.abstractMethods||[])a.push(...await ke(e,p,c));return s.allPropertiesImplement&&a.push(...await ke(s.allPropertiesImplement,p,c)),s.additionalPropertiesDataType&&a.push(...await ke(s.additionalPropertiesDataType,p,c)),s.extends&&a.push(...await ke(s.extends,p,c)),a}async function tFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Condition)throw new Error("Entity must be a condition to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,s.andChildrenGroup&&Array.isArray(s.andChildrenGroup))for(const f of s.andChildrenGroup)a.push(...await ke(f,p,c));if(s.orChildrenGroup&&Array.isArray(s.orChildrenGroup))for(const f of s.orChildrenGroup)a.push(...await ke(f,p,c));for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function iFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.outputs)a.push(...await ke(f,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),s.throws&&a.push(...await ke(s.throws,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.readsValue&&a.push(...await ke(s.readsValue,p,c)),a}async function rFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.properties)a.push(...await ke(e,p,c));for(const e of s.methods)a.push(...await ke(e,p,c));for(const e of s.abstractMethods)a.push(...await ke(e,p,c));for(const e of s.implements)a.push(...await ke(e,p,c));return s.extends&&a.push(...await ke(s.extends,p,c)),s.parent&&a.push(...await ke(s.parent,p,c)),s.additionalPropertiesDataType&&a.push(...await ke(s.additionalPropertiesDataType,p,c)),s.allPropertiesImplement&&a.push(...await ke(s.allPropertiesImplement,p,c)),a}async function nFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.DataType)throw new Error("Entity must be a data type to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,s.parent&&a.push(...await ke(s.parent,p,c)),s.foreignKeyRef&&a.push(...await ke(s.foreignKeyRef,p,c)),s.entity&&a.push(...await ke(s.entity,p,c)),s.orChildrenGroup)for(const e of s.orChildrenGroup)a.push(...await ke(e,p,c));if(s.andChildrenGroup)for(const e of s.andChildrenGroup)a.push(...await ke(e,p,c));return a}async function aFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.FunctionCall)throw new Error("Entity must be a function call to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function sFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,s.parent&&a.push(...await ke(s.parent,p,c)),s.implements&&a.push(...await ke(s.implements,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c));for(const e of s.inputs)a.push(...await ke(e,p,c));for(const e of s.calls)a.push(...await ke(e,p,c));return a}async function lFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.GlobalEvent)throw new Error("Entity must be a global event to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,s.parent&&a.push(...await ke(s.parent,p,c)),s.implements&&a.push(...await ke(s.implements,p,c));for(const e of s.inputs)a.push(...await ke(e,p,c));for(const e of s.calls)a.push(...await ke(e,p,c));return a}async function oFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.InputMap)throw new Error("Entity must be an input map to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,s.parent&&a.push(...await ke(s.parent,p,c)),s.declaration&&a.push(...await ke(s.declaration,p,c)),s.readsValue&&a.push(...await ke(s.readsValue,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.defaultValue&&a.push(...await ke(s.defaultValue,p,c)),a}async function dFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.InstalledProject)throw new Error("Entity must be an installed project to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.functions)a.push(...await ke(e,p,c));for(const e of s.events)a.push(...await ke(e,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function uFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.InternalCall)throw new Error("Entity must be an internal call to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function pFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.LiteralValue)throw new Error("Entity must be a literal value to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,s.valueAsTypeSingle&&a.push(...await ke(s.valueAsTypeSingle,p,c)),s.valueAsTypeList&&Array.isArray(s.valueAsTypeList))for(const e of s.valueAsTypeList)a.push(...await ke(e,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function cFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Loop)throw new Error("Entity must be a loop to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),s.body&&a.push(...await ke(s.body,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),a}async function fFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Operation)throw new Error("Entity must be an operation to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function yFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.OutputMap)throw new Error("Entity must be an output map to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.writesValues)a.push(...await ke(e,p,c));return s.declaration&&a.push(...await ke(s.declaration,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.parent&&a.push(...await ke(s.parent,p,c)),a}async function hFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.properties)a.push(...await ke(e,p,c));for(const e of s.methods)a.push(...await ke(e,p,c));for(const e of s.abstractMethods)a.push(...await ke(e,p,c));return a}async function mFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Project)throw new Error("Entity must be a project to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of s.entities)a.push(...await ke(e,p,c));for(const e of s.functions)a.push(...await ke(e,p,c));for(const e of s.events)a.push(...await ke(e,p,c));for(const e of s.projects)a.push(...await ke(e,p,c));for(const e of s.variableDeclarations)a.push(...await ke(e,p,c));for(const e of s.variableInstances)a.push(...await ke(e,p,c));for(const e of s.operations)a.push(...await ke(e,p,c));for(const e of s.conditions)a.push(...await ke(e,p,c));for(const e of s.functionCalls)a.push(...await ke(e,p,c));for(const e of s.projects)a.push(...await ke(e,p,c));for(const e of s.loops)a.push(...await ke(e,p,c));for(const e of s.searches)a.push(...await ke(e,p,c));return a}async function TFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Property)throw new Error("Entity must be a property to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,s.defaultValue&&a.push(...await ke(s.defaultValue,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.parent&&a.push(...await ke(s.parent,p,c)),a}async function vFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.outputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.throws&&a.push(...await ke(s.throws,p,c)),s.readsValue&&a.push(...await ke(s.readsValue,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function EFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.Search)throw new Error("Entity must be a search to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c));for(const f of s.inputsDeclarations)a.push(...await ke(f,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function bFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,s.defaultValue&&a.push(...await ke(s.defaultValue,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.parent&&a.push(...await ke(s.parent,p,c)),a}async function AFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c)),s.dataType&&a.push(...await ke(s.dataType,p,c)),s.readsValue&&a.push(...await ke(s.readsValue,p,c)),s.defaultValue&&a.push(...await ke(s.defaultValue,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));for(const f of s.internalCalls)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),a}async function gFe(s,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(s.id))return[];if(p.add(s.id),s.type!==d.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");const r=Y.YieldTracker.from(i),a=[s];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of s.inputs)a.push(...await ke(f,p,c));for(const f of s.outputs)a.push(...await ke(f,p,c));s.error&&a.push(...await ke(s.error,p,c)),s.readsValue&&a.push(...await ke(s.readsValue,p,c)),s.defaultValue&&a.push(...await ke(s.defaultValue,p,c));const e=Ko(s);for(const f of e)a.push(...await ke(f,p,c));for(const f of s.successCalls)a.push(...await ke(f,p,c));for(const f of s.errorCalls)a.push(...await ke(f,p,c));for(const f of s.writesValues)a.push(...await ke(f,p,c));for(const f of s.internalCalls)a.push(...await ke(f,p,c));return s.parent&&a.push(...await ke(s.parent,p,c)),s.declaration&&a.push(...await ke(s.declaration,p,c)),a}async function ke(s,p=new Set,i={ignoreBuiltInBaseEntities:!1,yieldEvery:100}){const r={...i,ignoreBuiltInBaseEntities:i.ignoreBuiltInBaseEntities??!1};if(!s)throw new Error("Entity must be defined to be flattened");if(s.type===d.GenericReference)return[];const a=Y.YieldTracker.from(r);r.tracker=a,r.yieldEvery!==void 0&&delete r.yieldEvery;const c=r.ignoreBuiltInBaseEntities?r.diggestedBuiltInBaseEntitiesIds??new Set(await lD(r)):new Set;if(r.diggestedBuiltInBaseEntitiesIds=c,r.ignoreBuiltInBaseEntities&&(ma.includes(s.type)||c.has(s.id)))return[];if(p.has(s.id))return[];switch(s.type){case d.FunctionCall:return aFe(s,p,r);case d.Operation:return fFe(s,p,r);case d.Condition:return tFe(s,p,r);case d.Loop:return cFe(s,p,r);case d.Search:return EFe(s,p,r);case d.GlobalEvent:return lFe(s,p,r);case d.ReturnStatement:return vFe(s,p,r);case d.ContinueStatement:return iFe(s,p,r);case d.BreakStatement:return XUe(s,p,r);case d.VariableDeclaration:return AFe(s,p,r);case d.DefinitionEntity:return rFe(s,p,r);case d.FunctionDeclaration:return sFe(s,p,r);case d.Project:return mFe(s,p,r);case d.ActionDescriptor:return JUe(s,p,r);case d.ArgumentDeclaration:return QUe(s,p,r);case d.ValueDescriptor:return bFe(s,p,r);case d.InputMap:return oFe(s,p,r);case d.OutputMap:return yFe(s,p,r);case d.DataType:return nFe(s,p,r);case d.InstalledProject:return dFe(s,p,r);case d.InternalCall:return uFe(s,p,r);case d.LiteralValue:return pFe(s,p,r);case d.Property:return TFe(s,p,r);case d.VariableInstance:return gFe(s,p,r);case d.BuiltInBaseEntity:return r.ignoreBuiltInBaseEntities?[]:eFe(s,p,r);case d.PrimitiveEntity:return r.ignoreBuiltInBaseEntities?[]:hFe(s,p,r)}return[]}function IFe(s){return s==null||s===""}function mPi(s){return s===null}function kn(s){return s!=null&&s.valueAsType?!1:IFe(s==null?void 0:s.value)}function du(s){return s?s.valueAsType===null&&s.value===null:!1}function RFe(s,p){if(s===p||!s&&!p)return!0;if(!s||!p||s.name===fe.EntityTemplate&&p.name!==fe.EntityTemplate||p.name===fe.EntityTemplate&&s.name!==fe.EntityTemplate)return!1;if(s.name===fe.ActionDescriptor&&p.name!==fe.ActionDescriptor||p.name===fe.ActionDescriptor&&s.name!==fe.ActionDescriptor)return!1;if(s.valueAsTypeSingle&&!p.valueAsTypeSingle||p.valueAsTypeSingle&&!s.valueAsTypeSingle)return!1;if(s.valueAsTypeList&&!p.valueAsTypeList||p.valueAsTypeList&&!s.valueAsTypeList)return!1;if(s.valueAsTypeSingle&&p.valueAsTypeSingle){if(s.valueAsTypeSingle.id!==p.valueAsTypeSingle.id)return!1}else if(s.valueAsTypeList&&p.valueAsTypeList){if(s.valueAsTypeList.length!==p.valueAsTypeList.length)return!1;for(let i=0;i<s.valueAsTypeList.length;i++)if(s.valueAsTypeList[i].id!==p.valueAsTypeList[i].id)return!1}else if(!s.valueAsType&&!p.valueAsType&&s.value!==p.value)return!1;return!0}function DFe(s,p,i){if(!i)throw new Error("[checkIsRowTransformerUpToDate] 'lastPublishedEntityVersion' argument is required");if(!p)throw new Error("[checkIsRowTransformerUpToDate] 'entity' argument is required");if(!s)throw new Error("[checkIsRowTransformerUpToDate] 'newestOpenRowTransformer' argument is required");let r=!0;const a=s.methods.find(c=>{var e;return((e=c.implements)==null?void 0:e.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id});if(a?(cn(i).forEach(c=>{const e=a.inputs.find(f=>f.name===c.name);e&&di(e.getDataType(null),c.getDataType(null)).compatible||(r=!1)}),a.returnStatements.forEach(c=>{!c.dataType||!c.dataType.entity||c.dataType.entity.type!==d.DefinitionEntity?r=!1:XT(c.dataType.entity,p)||(r=!1)})):r=!1,r===null||r){const c=s.methods.find(e=>{var f;return((f=e.implements)==null?void 0:f.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});c?(cn(p).forEach(e=>{const f=c.inputs.find(h=>h.name===e.name);f&&di(f.getDataType(null),e.getDataType(null)).compatible||(r=!1)}),c.returnStatements.forEach(e=>{!e.dataType||!e.dataType.entity||e.dataType.entity.type!==d.DefinitionEntity?r=!1:XT(e.dataType.entity,i)||(r=!1)})):r=!1}return{isPreexistingRowTransformerUpToDate:r}}function wFe(s,p,i){const r={changesSinceLastPublication:!1,rowTransformerNeeded:!1,newRowTransformerNeeded:!1,newestOpenRowTransformer:null,newRequiredProperties:[],newNonRequiredProperties:[],deletedProperties:[],lastPublishedEntityVersion:null,updatedEntityVersion:i,propChanges:new Map,isPreexistingRowTransformerUpToDate:null,extendedEntities:[]},c=s.entities.filter(M=>{var re;if(M.id===i.id)return!1;let G=!1,q=M;for(;q;){if(((re=q.extends)==null?void 0:re.id)===i.id){G=!0;break}if(q.extends&&q.extends.type===d.DefinitionEntity)q=q.extends;else break}return G}).map(M=>wFe(s,p,M));if(!p)return{...r,changesSinceLastPublication:!0,extendedEntities:c};const e=p.get(i.id);if(!e)return{...r,changesSinceLastPublication:!0,extendedEntities:c};const f=p.entities.filter(M=>si(M,Ae.SQL_ROW_TRANSFORMER)),m=s.entities.filter(M=>{var ee;if(!si(M,Ae.SQL_ROW_TRANSFORMER)||f.find(se=>se.id===M.id))return!1;const q=M.properties.find(se=>!!se.implements.find(te=>ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id===te.id));if(!q)return!1;const re=(ee=q.defaultValue)==null?void 0:ee.valueAsType;return re?re.id===i.id:!1}).sort((M,G)=>B(M.createdAt).isAfter(B(G.createdAt))?-1:1)[0]||null,E=new Map;let b=!1;const A=cn(i).filter(M=>cn(e).find(re=>re.id===M.id)?!1:!ps(M.getDataType(null))),_=cn(i).filter(M=>cn(e).find(re=>re.id===M.id)?!1:!!ps(M.getDataType(null))),P=cn(e).filter(M=>!cn(i).find(q=>q.id===M.id));cn(i).filter(M=>{var z,X,pe,de,me,ve,we,Re,xe,je,Se;const G=cn(e).find(Je=>Je.id===M.id);let q=!1;if(!G)return!1;const re=Sa(M.dataType,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on current property '${M.name}' (${M.id}). 'andChildrenGroup' with more than one child is not supported for SQL column properties.`),ee=Sa(G.dataType,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on last published property '${M.name}' (${M.id}). 'andChildrenGroup' with more than one child is not supported for SQL column properties.`),se=_g(re,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on current property '${M.name}' (${M.id}). 'orChildrenGroup' with multiple non-null children is not supported for SQL column properties.`),te=_g(ee,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on last published property '${M.name}' (${M.id}). 'orChildrenGroup' with multiple non-null children is not supported for SQL column properties.`);if(((z=se==null?void 0:se.foreignKeyRef)==null?void 0:z.id)!==((X=te==null?void 0:te.foreignKeyRef)==null?void 0:X.id)){const Je=se==null?void 0:se.foreignKeyRef,Ze=te==null?void 0:te.foreignKeyRef;E.set(M.id,{...E.get(M.id)||{},newForeignKeyRef:Je||void 0,oldForeignKeyRef:Ze||void 0,property:M,oldProperty:G}),q=!0,b=!0}else((pe=se==null?void 0:se.entity)==null?void 0:pe.id)!==((de=te==null?void 0:te.entity)==null?void 0:de.id)&&(((me=se==null?void 0:se.entity)==null?void 0:me.id)===ne["primitive-entity"].string.id||((ve=te==null?void 0:te.entity)==null?void 0:ve.id)===ne["primitive-entity"].date.id&&((we=se==null?void 0:se.entity)==null?void 0:we.id)===ne["primitive-entity"].number.id?E.set(M.id,{...E.get(M.id)||{},castableDataTypeEntity:{fromId:((Re=te==null?void 0:te.entity)==null?void 0:Re.id)||"",toId:((xe=se==null?void 0:se.entity)==null?void 0:xe.id)||""},property:M,oldProperty:G}):(E.set(M.id,{...E.get(M.id)||{property:M},nonCastableDataTypeEntity:{fromId:((je=te==null?void 0:te.entity)==null?void 0:je.id)||"",toId:((Se=se==null?void 0:se.entity)==null?void 0:Se.id)||""},property:M,oldProperty:G}),b=!0),q=!0);M.name!==(G==null?void 0:G.name)&&(E.set(M.id,{...E.get(M.id)||{},nameChange:{from:(G==null?void 0:G.name)||"",to:M.name},property:M,oldProperty:G}),q=!0);const le=ps(G.getDataType(null)),ue=ps(M.getDataType(null));return ue!==le&&(E.set(M.id,{...E.get(M.id)||{},requiredChange:{from:!le,to:!ue},property:M,oldProperty:G}),ue||(b=!0),q=!0),q}),A.length>0&&(b=!0);let V=null;m&&b&&(V=DFe(m,i,e).isPreexistingRowTransformerUpToDate);const j=i.name!==e.name?{from:e.name,to:i.name}:void 0;return{...r,changesSinceLastPublication:E.size>0||!!P.length||!!A.length||!!_.length||b,rowTransformerNeeded:b,newestOpenRowTransformer:m,nameChange:j,newRequiredProperties:A,newNonRequiredProperties:_,deletedProperties:P,lastPublishedEntityVersion:e,propChanges:E,newRowTransformerNeeded:b&&!m,isPreexistingRowTransformerUpToDate:V,extendedEntities:c}}function IL(s,p,i,r,a){if(!s)throw new Error("[addDifferencesToRowTransformer] 'project' argument is required");if(!p)throw new Error("[addDifferencesToRowTransformer] 'transformer' argument is required");if(!i)throw new Error("[addDifferencesToRowTransformer] 'newEntityState' argument is required");if(!r)throw new Error("[addDifferencesToRowTransformer] 'oldEntityState' argument is required");const c=cn(i),e=cn(r);p.afterAllChildrenInitialized(a);const f=p.methods.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),h=p.methods.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});if(!f)throw new Error("[addDifferencesToRowTransformer] The 'up' transformer trigger is missing from the parent");if(!h)throw new Error("[addDifferencesToRowTransformer] The 'down' transformer trigger is missing from the parent");e.forEach(m=>{var j;const E=f.inputs.find(M=>M.name===m.name),b=m.getDataType(null);let A=E,_,P=!1,V=!1;if(E)A.editable=!0;else{const M=Za.new(a);M.parent=f.toReference(),M.name=m.name,M.index=m.index,M.implements=[...m.implements.map(q=>q.toJSON())];const G=ge(M,s);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),P=!0,A=G}if(!A.dataType||A.dataType&&s.diggestedBuiltInBaseEntitiesIds.has(A.dataType.id)){const M=mr.new(a);M.parent=A.toReference();const G=ge(M,s);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),V=!0,_=G}else _=A.dataType,_.editable=!0;b&&_.merge(m.getDataType(null),a),_.metaSync({editable:!1,deletable:!1},a),A.metaSync({editable:!1,deletable:!1},a),V&&(a||(j=A.dataType)==null||j.captureVersion()),P&&(a||A.captureVersion())}),[...f.inputs].forEach(m=>{e.find(b=>b.name===m.name)||(m.editable=!0,m.remove({ignoreUpstream:!1},a),m.editable=!1)}),[...f.returnStatements].forEach(m=>{var b,A,_;let E=!1;if(!m.dataType||m.dataType&&s.diggestedBuiltInBaseEntitiesIds.has(m.dataType.id)){const P=mr.new(a);P.entity=i.toReference(),P.parent=m.toReference();const V=ge(P,s);V.hydrateAncestors(),a.add(V,W.Added),V.addSelfToProject(a),V.initChildren(a),E=!0}(!((b=m.dataType)!=null&&b.entity)||m.dataType.entity.type!==d.DefinitionEntity||m.dataType.entity.parent.id!==m.dataType.id)&&(i.clone(a,m.dataType),E=!0),gx((A=m.dataType)==null?void 0:A.entity,i,a),m.afterAllChildrenInitialized(a),m.outputs.forEach(P=>{const V=f.inputs.find(j=>oe(P,s)===oe(j,s));P.setValueWriter(V,a),V==null||V.addValueReader(P,a)}),E&&(a||(_=m.dataType)==null||_.captureVersion())}),c.forEach(m=>{var M,G;let E=!1,b=!1;const A=(M=m.knownVersions)==null?void 0:M.get(m.previousVersion),_=h.inputs.find(q=>q.name===m.name||!!A&&A.name===q.name),P=m.getDataType(null);let V=_,j;if(_)V.editable=!0,V.metaSync({name:m.name,codeName:m.codeName,description:m.description},a);else{const q=Za.new(a);q.parent=h.toReference(),q.name=m.name,q.codeName=m.codeName,q.description=m.description,q.index=m.index,q.implements=[m.toJSON(),...m.implements.map(ee=>ee.toJSON())];const re=ge(q,s);re.hydrateAncestors(),re.addSelfToProject(a),a.add(re,W.Added),re.initChildren(a),E=!0,V=re}if(V.dataType)j=V.dataType,j.editable=!0,j.merge(V.dataType,a);else{const q=mr.new(a);q.parent=V.toReference();const re=ge(q,s);re.hydrateAncestors(),re.addSelfToProject(a),a.add(re,W.Added),re.initChildren(a),b=!0,j=re}P&&j.merge(m.getDataType(null),a),j.metaSync({editable:!1,deletable:!1},a),V.metaSync({editable:!1,deletable:!1},a),b&&(a||(G=V.dataType)==null||G.captureVersion()),E&&(a||V.captureVersion())}),[...h.inputs].forEach(m=>{c.find(b=>{var _;if(b.name===m.name)return!0;const A=(_=b.knownVersions)==null?void 0:_.get(b.previousVersion);if(A&&A.name===m.name)return!0})||(m.editable=!0,m.remove({ignoreUpstream:!1},a),m.editable=!1)}),[...h.returnStatements].forEach(m=>{var A,_,P,V,j;let E=!1;if(!m.dataType||m.dataType&&s.diggestedBuiltInBaseEntitiesIds.has(m.dataType.id)){const M=mr.new(a);M.parent=m.toReference();const G=ge(M,s);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),E=!0}let b=(A=m.dataType)==null?void 0:A.entity;(!b||(b==null?void 0:b.id)===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id)&&(Y.Logger.log("Cloning old entity state into new project with data-ype as parent: ",(_=m.dataType)==null?void 0:_.id," from new project: ",((P=m.dataType)==null?void 0:P.project.version)===s.version&&((V=m.dataType)==null?void 0:V.project.entities.length)===3),b=r.clone(a,m.dataType)),m.dataType.setEntity(b,a),m.afterAllChildrenInitialized(a),m.outputs.forEach(M=>{const G=h.inputs.find(q=>oe(M,s)===oe(q,s));M.setValueWriter(G,a),G==null||G.addValueReader(M,a)}),E&&(a||(j=m.dataType)==null||j.captureVersion())})}function CFe(s,p,i,r,a={}){var M;const c=s.getBuiltIn(Ae.SQL_ROW_TRANSFORMER),e=Rh(oe(p,s)+" row transformer",s.entities),f=c.implement(e,r),h=f.ownDeclaredProperties.find(G=>{var q;return(q=G.implements)==null?void 0:q.find(re=>re.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id)}),m=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),E=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});if(!h||!m||!E)throw new Error("Cannot find definition property on the new row transformer entity");if(h.defaultValue)h.defaultValue.setValueAsTypeSingle(p,r);else{const G=Nr.new(r);G.name=fe.EntityTemplate,G.valueAsTypeSingle=p.toJSON(),G.parent=h.toReference();const q=ge(G,s);q.hydrateAncestors(),q.addSelfToProject(r),r.add(q,W.Added),q.initChildren(r),r||q.captureVersion()}IL(s,f,p,i,r),Y.Logger.log("BEFORE - changeSet.listAdded",r.listAdded.map(G=>{var re,ee,se,te,le,ue,z;const q=s.get(G.id);return q?oe(q,s):G.type===d.InputMap?"(not found) "+G.type+" "+G.id+" - declaration: "+((re=G.declaration)==null?void 0:re.type)+" "+((ee=G.declaration)==null?void 0:ee.id)+' "'+((se=G.declaration)==null?void 0:se.name)+`"
|
|
540
540
|
parent: `+((le=(te=G.parent)==null?void 0:te.parent)==null?void 0:le.id)+" - "+((z=(ue=G.parent)==null?void 0:ue.parent)==null?void 0:z.name):"(not found) "+G.type+" "+G.id})),Y.Logger.log("AFTER - changeSet.listAdded",r.listAdded.map(G=>{var re,ee,se,te,le,ue,z;const q=s.get(G.id);return q?q.type+' "'+oe(q,s)+'" ('+q.id+")":G.type===d.InputMap?"(not found) "+G.type+" ("+G.id+") - declaration: "+((re=G.declaration)==null?void 0:re.type)+" ("+((ee=G.declaration)==null?void 0:ee.id)+') "'+((se=G.declaration)==null?void 0:se.name)+`"
|
|
541
541
|
parent: "`+((le=(te=G.parent)==null?void 0:te.parent)==null?void 0:le.name)+'" ('+((z=(ue=G.parent)==null?void 0:ue.parent)==null?void 0:z.id)+")":"(not found) "+G.type+" "+G.id})),Y.Logger.log("-----------------"),Y.Logger.log("Old properties: ",cn(i).map(G=>G.name+" ("+G.id+")")),Y.Logger.log("New properties: ",cn(p).map(G=>G.name+" ("+G.id+")"));const b=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),A=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});Y.Logger.log(`
|