@elyx-code/project-logic-tree 0.0.6841 → 0.0.6843
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 +3 -3
- package/dist/index.js +9 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -45,13 +45,13 @@ You can attach new logic to the existing 'global-event' but creating a new calla
|
|
|
45
45
|
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 q(this.project,N.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){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.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 bi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.dataType=this.dataType,i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent&&this.parent.type!==d.BuiltInBaseEntity&&this.parent.type!==d.PrimitiveEntity){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){var h;const r=[],a=[],c=[],e=[];if(this.version===i)return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};if(!this.knownVersions){const m=new Map;for(const[E,b]of this.knownVersions||new Map){if(m.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[g,_]of b.knownVersions)m.set(g,_);b.knownVersions=null}}let f=(h=this.knownVersions)==null?void 0:h.get(i);if(!f){const m=await this.APILoadVersion({},i);if(!m)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);f=new bi(m,this.project)}return this.metaSync(f.toShallowJSON(),null),this.previousVersion=f.previousVersion,this.version=f.version,this.createdAt=f.createdAt,this.author=f.author,this.deleted=f.deleted,this.inputs=f.inputs,this.dataType=f.dataType,this.error=f.error,this.parent=f.parent,{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return z.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=X(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&(this.removeFromParent(r),this.parent=null),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.error||this.setError(null,r),i.inputs.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addInput(e,r),e.setParent(this,r))}),[...this.inputs].forEach(a=>{i.inputs.find(e=>X(e)===a.id)||(this.removeInput(a,r),a.removeFromParent(r))}),i.dataType){const a=X(i.dataType),c=this.project.get(a);c&&this.setDataType(c,r)}else this.setDataType(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){if(!this.checkCanEdit(this,r))return z.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 a=X(i.parent),c=this.project.get(a),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&(this.removeFromParent(r),this.parent=null),c)this.setParent(c,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 '${a}' that isn't found in the project`)}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=X(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'`);return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return z.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,this.inputs.sort((f,h)=>f.index-h.index),this.captureVersion(),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];return this.parent?(this.parent.type===d.DefinitionEntity?(this.parent.addAbstractMethod(this,i),e.push(this.parent)):this.parent.type===d.DataType&&(this.parent.setEntity(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}):(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 q(this.project,N.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}initChildren(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.dataType&&(this.dataType=Ae(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),this.inputs=this.initialData.inputs.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.error&&(this.error=Ae(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(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Wr(this,i,r),c=Hr(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,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=Se,...r){return await bi.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await bi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await bi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await bi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await bi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await bi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return z.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),e.push(this.parent)):this.parent.type===d.DefinitionEntity&&(this.parent.removeAbstractMethod(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return z.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.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:g}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...g)}),this.inputs.forEach(m=>{const E=m.remove({ignoreUpstream:!0},r);a.push(...E.updated),c.push(...E.removed)}),this.dataType){const{updated:m,removed:E}=this.dataType.remove({ignoreUpstream:!0},r);a.push(...m),c.push(...E)}if(this.error){const m=this.error.remove({ignoreUpstream:!0},r);a.push(...m.updated),c.push(...m.removed)}if(this.parent&&!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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return z.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.inputs.forEach(f=>{const h=f.restore({},i);a.push(...h.updated)}),this.dataType){const{updated:f}=this.dataType.restore({},i);a.push(...f)}if(this.error){const f=this.error.restore({},i);a.push(...f.updated)}return 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.dataType)==null?void 0:a.toFlat(i))||[],...this.inputs.flatMap(c=>c.toFlat(i))])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((a=this.dataType)==null?void 0:a.toFlatIds(i))||[],...this.inputs.flatMap(c=>c.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,outputName:this.outputName,outputDescription:this.outputDescription,index:this.index,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,outputName:this.outputName,outputDescription:this.outputDescription,index:this.index,dataType:((r=this.dataType)==null?void 0:r.toJSON(i))||null,error:((a=this.error)==null?void 0:a.toJSON(i))||null,inputs:this.inputs.map(e=>e.toJSON(i)),parent:((c=this.parent)==null?void 0:c.toReference())||null})}toJSONClone(i=nt){var a,c,e,f,h,m,E,b;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||Xr(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:N.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,codeName:this.codeName,description:this.description,outputName:this.outputName,outputDescription:this.outputDescription,index:this.index,dataType:((m=this.dataType)==null?void 0:m.toJSONClone({...i,newId:null}))||null,error:((E=this.error)==null?void 0:E.toJSONClone({...i,newId:null}))||null,inputs:this.inputs.map(g=>g.toJSONClone({...i,newId:null})),parent:((b=this.parent)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=nt){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+N.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=nt){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,codeName:this.codeName,description:this.description,outputName:this.outputName,outputDescription:this.outputDescription,index:this.index,dataType:((c=this.dataType)==null?void 0:c.toReference(i))||null,error:((e=this.error)==null?void 0:e.toReference(i))||null,inputs:this.inputs.map(h=>h.toReference(i)),parent:((f=this.parent)==null?void 0:f.toReference(i))||null}}toFlatJSON(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((a=this.dataType)==null?void 0:a.toFlatJSON(i))||[],...this.inputs.flatMap(c=>c.toFlatJSON(i))])}toGenerationTarget(i=nt){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,codeName:this.codeName,description:this.description,type:this.type,parent:((c=this.parent)==null?void 0:c.id)||void 0,outputName:this.outputName,outputDescription:this.outputDescription,index:this.index}}toFlatGenerationTarget(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((a=this.dataType)==null?void 0:a.toFlatGenerationTarget(i))||[],...this.inputs.flatMap(c=>c.toFlatGenerationTarget(i))])}implementAsGlobalEvent(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"implement-as-global-event")),r,a){const c=r||this.project,e=a||N.UUID.uuid(),f=N.UUID.uuid(),h={id:e,version:f,createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.GlobalEvent,name:this.name,description:this.description,inputs:[],calls:[],collapsed:!1,implements:this.toJSON(),parent:(c==null?void 0:c.toReference())||null,x:0,y:0},m=Ae(h,this.project);if(m.setParent(c,i),m.initChildren(i),i==null||i.add(m,W.Added),m.hydrateAncestors(),m.addSelfToProject(i),this.inputs.map(E=>E.implementAsArgumentDeclaration(i,m)),this.dataType&&this.dataType.entity&&this.dataType.entity.type===d.DefinitionEntity&&this.dataType.entity.properties.length){const E=N.UUID.uuid(),b=N.UUID.uuid(),g={id:N.UUID.uuid(),type:d.GenericReference,version:f,entityType:d.GlobalEvent,entityId:e},_={id:N.UUID.uuid(),type:d.GenericReference,version:f,entityType:d.GlobalEvent,entityId:e},$=this.dataType.toJSONClone(),L={id:E,version:b,createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ReturnStatement,outputs:[],throws:null,calledBySuccess:[],calledByError:[],calledByEntry:[_],defaultValue:null,dataType:$,readsValue:null,parent:g,x:0,y:0},j=Ae(L,this.project);j.setParent(m,i),j.initChildren(i),i==null||i.add(j,W.Added),j.hydrateAncestors(),j.addSelfToProject(i),this.dataType.entity.properties.map((k,G)=>{var ae;const H={id:N.UUID.uuid(),type:d.GenericReference,entityId:E,version:b,entityType:d.ReturnStatement},ie={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,name:k.name,codeName:k.codeName,description:k.description,readsValue:null,defaultValue:null,declaration:k.toJSON(),index:G,parent:H},ee=Ae(ie,this.project);ee.setParent(j,i),ee.initChildren(i),i==null||i.add(ee,W.Added),ee.hydrateAncestors(),ee.addSelfToProject(i);const ue=((ae=k.dataType)==null?void 0:ae.clone(i,ee))||null;ue&&(i==null||i.add(ue,W.Added)),ee.setDataType(ue,i)})}return i==null||i.attemptAutoclose("implement-as-function-declaration",this.id),m}implementAsFunctionDeclaration(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"implement-as-function-declaration")),r,a){let c=r?Br(r,this):this.project;const e=r||this.project,f=a||N.UUID.uuid(),h=N.UUID.uuid(),m=td.new(i);if(m.id=f,m.version=h,m.parent=(e==null?void 0:e.toReference())||null,m.codeName=this.codeName,m.name=this.name,m.description=this.description,m.implements=this.toJSON(),e.type===d.DefinitionEntity){let g=this.index||0;const _=e.methods.filter($=>!$.deleted);_.length&&(g>=_.length?g=_.length:g<0?g=0:_.filter($=>($.index||0)>=g).forEach($=>{$.metaSync({index:($.index||0)+1},i),i==null||i.add($,W.Updated)})),m.index=g}const E=Ae(m,c);E.hydrateAncestors(),E.setParent(e,i),i==null||i.add(E,W.Added),E.addSelfToProject(i),E.initChildren(i);const b=[];return this.dataType&&(this.dataType.entity&&(this.dataType.entity.type===d.DefinitionEntity||this.dataType.entity.type===d.BuiltInBaseEntity)&&this.dataType.entity.properties.length?b.push(this.dataType):(this.dataType.orChildrenGroup||[]).forEach(g=>{g.entity&&(g.entity.type===d.DefinitionEntity||g.entity.type===d.BuiltInBaseEntity)&&g.entity.properties.length&&b.push(g)})),b.forEach(g=>{const _=N.UUID.uuid(),$=N.UUID.uuid(),L={id:N.UUID.uuid(),type:d.GenericReference,version:h,entityType:d.FunctionDeclaration,entityId:f},j={id:N.UUID.uuid(),type:d.GenericReference,version:h,entityType:d.FunctionDeclaration,entityId:f},k=Sd.new(i);k.id=_,k.version=$,k.parent=L,k.calledByEntry=[j];const G=Ae(k,c);G.hydrateAncestors(),G.setParent(E,i),G.addSelfToProject(i),i==null||i.add(G,W.Added),G.initChildren(i),this.project.diggestedBuiltInBaseEntitiesIds.has(g.id)?G.setDataType(c.getBuiltIn(g.id),i):g.clone(i,G),G.afterAllChildrenInitialized(i)}),i==null||i.attemptAutoclose("implement-as-function-declaration",this.id),E}implementAsLoop(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"implement-as-loop")),r,a){const c=r||this.project,e=a||N.UUID.uuid(),f=N.UUID.uuid(),h={catchesError:!1,id:e,version:f,createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Loop,writesValues:[],declaration:this.toJSON(),inputs:[],outputs:[],error:null,dataType:null,successCalls:[],errorCalls:[],calledByEntry:[],calledByError:[],calledBySuccess:[],body:null,x:0,y:0,parent:c.toReference()},m=Ae(h,this.project);return m.hydrateAncestors(),m.setParent(c,i),i==null||i.add(m,W.Added),m.addSelfToProject(i),m.initChildren(i),c===this.project&&this.project.addLoop(m),i==null||i.attemptAutoclose("implement-as-loop",this.id),m}implementAsOperation(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"implement-as-operation")),r,a){const c=r||this.project,e=a||N.UUID.uuid(),f=N.UUID.uuid(),h={catchesError:!1,id:e,version:f,createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Operation,writesValues:[],declaration:this.toJSON(),inputs:[],outputs:[],error:null,successCalls:[],errorCalls:[],calledByEntry:[],calledByError:[],calledBySuccess:[],x:0,y:0,parent:c.toReference()},m=Ae(h,this.project);return m.hydrateAncestors(),m.setParent(c,i),i==null||i.add(m,W.Added),m.addSelfToProject(i),m.initChildren(i),c===this.project&&this.project.addOperation(m),i==null||i.attemptAutoclose("implement-as-operation",this.id),m}implementAsCondition(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"implement-as-condition")),r,a){const c=r||this.project,e=a||N.UUID.uuid(),f=N.UUID.uuid(),h={id:e,version:f,createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Condition,index:null,andChildrenGroup:null,orChildrenGroup:null,declaration:this.toJSON(),inputs:[],successCalls:[],errorCalls:[],calledByEntry:[],calledByError:[],calledBySuccess:[],x:0,y:0,parent:c.toReference()},m=Ae(h,this.project);return m.hydrateAncestors(),m.setParent(c,i),i==null||i.add(m,W.Added),m.addSelfToProject(i),m.initChildren(i),c===this.project&&this.project.addCondition(m),i==null||i.attemptAutoclose("implement-as-condition",this.id),m}clearErrors(){var i,r;return this.errors=[],this.inputs.forEach(a=>a.clearErrors()),(i=this.dataType)==null||i.clearErrors(),(r=this.error)==null||r.clearErrors(),this}validate(){return this.errors=T_e(this),{success:!0}}async validateAsync(i={}){const r=z.YieldTracker.from(i);return this.errors=await m_e(this,{tracker:r}),{success:!0}}getErrors(){var r;return[...this.errors,...((r=this.dataType)==null?void 0:r.getErrors())||[],...this.inputs.flatMap(a=>a.getErrors())]}async getErrorsAsync(i={}){const r=z.YieldTracker.from(i),a=[...this.errors];if(await r.tick(),this.dataType){const c=await this.dataType.getErrorsAsync({tracker:r});a.push(...c)}for(const c of this.inputs){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var $,L;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;const e=Br(r,this),f=this.toJSON(),h=a||N.UUID.uuid();f.inputs=[],f.dataType=null,f.error=null;const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=N.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=Yi(f,e);r?b.setParent(r,i):this.parent&&b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,W.Added);const g=($=this.dataType)==null?void 0:$.clone(i,b,N.UUID.uuid(),c);b.setDataType(g||null,i);const _=(L=this.inputs)==null?void 0:L.map((j,k)=>j.clone(i,b,E+"-argument-value-descriptor-"+k+"-id",c));return b.inputs=_,this.error&&(b.error=this.error.clone(i,b,E+"-error-action-descriptor-id",c)),i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}addInput(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.AddInput))){if(this.id==="base-up-sql-row-transformer")throw new Error("Cannot modify built-in entity");return this.checkCanEdit(this,r)?(this.inputs.find(a=>a.id===i.id)||(this.inputs.push(i),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.AddInput,this.id),this):(z.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)}removeInput(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveInput))){return this.checkCanEdit(this,r)?(this.inputs.find(a=>a.id===i.id)&&(this.inputs=this.inputs.filter(a=>a.id!==i.id),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.RemoveInput,this.id),this):(z.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)}setError(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SetErrorEntity))){if(!this.checkCanEdit(this,r))return z.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}setDataType(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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):(z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}createInternalCall(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"create-internal")),r,a={}){const c={catchesError:!1,id:a.id||N.UUID.uuid(),version:a.version||N.UUID.uuid(),createdAt:a.createdAt||(i==null?void 0:i.timestamp)||B().toISOString(),author:a.author||N.sessionAuthor||"1",previousVersion:a.previousVersion||null,deleted:a.deleted||!1,deletable:!0,editable:!0,type:d.InternalCall,writesValues:[],parent:r.toReference(),successCalls:a.successCalls||[],errorCalls:a.errorCalls||[],inputs:a.inputs||[],outputs:a.outputs||[],error:a.error||null,calledBySuccess:a.calledBySuccess||[],calledByError:a.calledByError||[],calledByEntry:a.calledByEntry||[],declaration:this.toShallowJSON(),index:r.internalCalls.length},e=Ae(c,this.project);return e.hydrateAncestors(),i==null||i.add(e,W.Added),e.addSelfToProject(i),e.setParent(r,i),e.initChildren(i),e.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("create-internal",this.id),e}getUniqueOutputProperties(){const i=[];return this.dataType&&this.dataType.entity&&this.dataType.entity.type===d.DefinitionEntity&&this.dataType.entity.properties.length?this.dataType.entity.properties:i}};R(bi,"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(bi,"type",d.ActionDescriptor),R(bi,"USER_MANAGED_PARENT_TYPES",[d.DefinitionEntity,d.DataType]),R(bi,"PARENT_TYPES",[...bi.USER_MANAGED_PARENT_TYPES,d.PrimitiveEntity,d.BuiltInBaseEntity]),R(bi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","index","outputName","outputDescription"]),R(bi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(bi,"BASE_PROPERTIES",[...bi.MUTABLE_BASE_PROPERTIES,...bi.INMUTABLE_BASE_PROPERTIES]),R(bi,"MUTABLE_META_PROPERTIES",[...bi.MUTABLE_BASE_PROPERTIES]),R(bi,"INMUTABLE_META_PROPERTIES",[...bi.INMUTABLE_BASE_PROPERTIES]),R(bi,"META_PROPERTIES",[...bi.MUTABLE_META_PROPERTIES,...bi.INMUTABLE_META_PROPERTIES]),R(bi,"MUTABLE_UPSTREAM_PROPERTIES",[]),R(bi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(bi,"UPSTREAM_PROPERTIES",[...bi.MUTABLE_UPSTREAM_PROPERTIES,...bi.INMUTABLE_UPSTREAM_PROPERTIES]),R(bi,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","outputs"]),R(bi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(bi,"DOWNSTREAM_PROPERTIES",[...bi.MUTABLE_DOWNSTREAM_PROPERTIES,...bi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(bi,"PROPERTIES",[...bi.META_PROPERTIES,...bi.UPSTREAM_PROPERTIES,...bi.DOWNSTREAM_PROPERTIES]);let ki=bi;var v_e=(l=>(l.Parent="loop-parent-field",l.LoopDataTypeEntity="loop-data-type-entity-field",l.LoopDataType="loop-data-type-field",l.LoopBodyDataTypeEntity="loop-body-data-type-entity-field",l.LoopBodyDataType="loop-body-data-type-field",l))(v_e||{});const Jt=class Jt extends Qr{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"x");R(this,"y");R(this,"type",d.Loop);R(this,"catchesError",!1);R(this,"declaration");R(this,"writesValues",[]);R(this,"dataType",null);R(this,"inputs",[]);R(this,"outputs",[]);R(this,"successCalls",[]);R(this,"errorCalls",[]);R(this,"error",null);R(this,"body");R(this,"calledBySuccess",[]);R(this,"calledByError",[]);R(this,"calledByEntry",[]);R(this,"parent");R(this,"detachedChildren",[]);R(this,"errors",[]);R(this,"project");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.catchesError=i.catchesError||!1}static new(i=null){return{id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Loop,writesValues:[],catchesError:!1,declaration:null,inputs:[],outputs:[],dataType:null,error:null,body:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(i,r){let a=r;if(i.parent){const g=X(i.parent);a=r.get(g)}const c=X(i.declaration),e=r.get(c),f=(i.calledByEntry||[]).map(g=>{const _=X(g);return r.get(_)}),h=(i.calledBySuccess||[]).map(g=>{const _=X(g);return r.get(_)}),m=(i.calledByError||[]).map(g=>{const _=X(g);return r.get(_)}),E={id:i.id,version:N.UUID.uuid(),createdAt:B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Loop,writesValues:[],dataType:null,catchesError:i.catchesError||!1,declaration:e.toJSON(),calledByEntry:f.map(g=>g.toReference()),calledBySuccess:h.map(g=>g.toReference()),calledByError:m.map(g=>g.toReference()),errorCalls:[],successCalls:[],inputs:[],outputs:[],body:null,error:null,x:0,y:0,parent:a.toReference()},b=Ae(E,r);return b.hydrateAncestors(),b.setParent(a,null),b}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=wn(a,{parent:{list:!1,types:[...vr,d.Project],optional:!0},declaration:{list:!1,types:[d.ActionDescriptor]}},r);c.push(...f.explanations),a=f.modifiedData;const h=Zr(a);if(e.push(...f.errors,...h.errors),c.push(...h.explanations),!i.declaration)e.push(new Re({id:`${i.id}--${we.InvalidObjectStructure}`,code:we.InvalidObjectStructure,severity:me.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.Loop}' entities.`})),c.push({id:Ji.AllOperationActionDescriptors,message:Cg(r)});else if(!r.get(i.declaration))e.push(new Re({id:`${i.id}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:me.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.Loop}' entities.`})),c.push({id:Ji.AllOperationActionDescriptors,message:Cg(r)});else{const E=Qje(i.declaration,r);e.push(...E.errors),c.push(...E.explanations)}return{errors:e,explanations:c,modifiedData:a}}get currentIterationNumberArgumentDeclaration(){var a;const i=(a=re[d.Loop][this.declaration.id].body.inputs.iterationNumber)==null?void 0:a.id;return this.body.inputs.find(c=>!!c.implements.find(e=>e.id===i)||c.name===Jt.CURRENT_ITERATION_NUMBER_ARG_NAME)}get currentValueArgumentDeclaration(){var a;if(this.declaration.id===pt.ManualFlow||this.declaration.id===pt.Counted)return null;const i=(a=re[d.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:a.id;return this.body.inputs.find(c=>!!c.implements.find(e=>e.id===i)||c.name===Jt.CURRENT_VALUE_ARG_NAME)||null}get continueStatements(){return yt(this.body).filter(a=>a.type===d.ContinueStatement&&a.parent.id===this.id)}get breakStatements(){return yt(this.body).filter(a=>a.type===d.BreakStatement&&a.parent.id===this.id)}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new Re({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:me.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.
|
|
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 q(this.project,N.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,g,_,$;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"}]),($=(_=(g=this.body)==null?void 0:g.dataType)==null?void 0:_.unsubscribeDependents)==null||$.call(_,[{entity:this,field:"loop-body-data-type-field"}]),this}subscribeToDependencies(){var i,r,a,c,e,f,h,m,E,b,g,_,$;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"}]),($=(_=(g=this.body)==null?void 0:g.dataType)==null?void 0:_.subscribeDependents)==null||$.call(_,[{entity:this,field:"loop-body-data-type-field"}]),this}increaseVersion(i){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.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 Jt(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.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.dataType=this.dataType,i.parent=this.parent,this}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){var h;const r=[],a=[],c=[],e=[];if(this.version===i)return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};if(!this.knownVersions){const m=new Map;for(const[E,b]of this.knownVersions||new Map){if(m.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[g,_]of b.knownVersions)m.set(g,_);b.knownVersions=null}}let f=(h=this.knownVersions)==null?void 0:h.get(i);if(!f){const m=await this.APILoadVersion({},i);if(!m)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);f=new Jt(m,this.project)}return this.metaSync(f.toShallowJSON(),null),this.previousVersion=f.previousVersion,this.version=f.version,this.createdAt=f.createdAt,this.author=f.author,this.deleted=f.deleted,this.inputs=f.inputs,this.outputs=f.outputs,this.error=f.error,this.successCalls=f.successCalls,this.errorCalls=f.errorCalls,this.declaration=f.declaration,this.body=f.body,this.calledByEntry=f.calledByEntry,this.calledBySuccess=f.calledBySuccess,this.calledByError=f.calledByError,this.dataType=f.dataType,this.parent=f.parent,{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return z.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=X(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=X(i.declaration),c=this.project.get(a);c&&this.setDeclaration(c)}if(i.calledByEntry.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addEntryCaller(e,r),e.addCall(this,r))}),[...this.calledByEntry].forEach(a=>{i.calledByEntry.find(e=>X(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledBySuccess.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addSuccessCaller(e,r),e.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(a=>{i.calledBySuccess.find(e=>X(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.calledByError.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addErrorCaller(e,r),e.addErrorCall(this,r))}),[...this.calledByError].forEach(a=>{i.calledByError.find(e=>X(e)===a.id)||(this.removeCaller(a,r),a.removeCall(this,r))}),i.dataType){const a=X(i.dataType),c=this.project.get(a);c&&this.setDataType(c,r)}else this.setDataType(null,r);return i.outputs.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addOutput(e,r),e.setParent(this,r))}),[...this.outputs].forEach(a=>{i.outputs.find(e=>X(e)===a.id)||(this.removeOutput(a,r),a.removeFromParent(r))}),i.inputs.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addInput(e,r),e.setParent(this,r))}),[...this.inputs].forEach(a=>{i.inputs.find(e=>X(e)===a.id)||(this.removeInput(a,r),a.removeFromParent(r))}),i.writesValues.forEach(a=>{const c=X(a),e=this.project.get(c);e&&(this.addValueReader(e,r),e.setValueWriter(this,r))}),[...this.writesValues].forEach(a=>{i.writesValues.find(e=>X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return z.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=X(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=X(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=X(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=>X(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=X(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=>X(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=X(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=>X(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=X(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=X(this.initialData.declaration),f=this.project.get(e);f&&(this.setDeclaration(f),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=X(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=X(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return z.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 g,_;return(E.index??((g=E.declaration)==null?void 0:g.index))-(b.index??((_=b.declaration)==null?void 0:_.index))}),this.outputs.sort((E,b)=>{var g,_;return(E.index??((g=E.declaration)==null?void 0:g.index))-(b.index??((_=b.declaration)==null?void 0:_.index))}),this.captureVersion(),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 q(this.project,N.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveInput))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}addErrorCall(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(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 q(this.project,N.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&&Tt(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 q(this.project,N.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&&Tt(this,r),r==null||r.attemptAutoclose(w.RemoveCall,this.id),this}removeCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SetErrorEntity))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.declaration=Ae(this.initialData.declaration,this.project),this.initialData.dataType){const r=Ae(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=Ae(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=fn(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=Ae(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=fn(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=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.outputs=this.initialData.outputs.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.body&&(this.body=Ae(this.initialData.body,this.project),this.body.setParent(this,null),this.body.initChildren(i)),this.initialData.error&&(this.error=Ae(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(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Wr(this,i,r),c=Hr(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=Se,...r){return await Jt.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await Jt.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await Jt.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await Jt.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await Jt.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await Jt.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return z.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:g}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...g)}),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return z.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=nt){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||Xr(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:N.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=nt){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+N.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=nt){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=nt){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=mx(this),{success:!0}}async validateAsync(i={}){const r=z.YieldTracker.from(i);return this.errors=await h_e(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=z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var $,L;const e=Br(r,this),f=this.toJSON(),h=a||N.UUID.uuid();f.inputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=N.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=Yi(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 g=($=this.inputs)==null?void 0:$.map((j,k)=>j.clone(i,b,E+"-input-map-"+k+"-id",c));b.inputs=g;const _=(L=this.outputs)==null?void 0:L.map((j,k)=>j.clone(i,b,E+"-output-map-"+k+"-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==null||i.attemptAutoclose(w.CloneEntity,this.id),b}getVariableInstances(){return this.body?sr(this.body).filter(a=>a.type===d.VariableInstance):[]}addReturnStatement(i){return Ft.includes(this.parent.type)&&this.parent.addReturnStatement(i),this}removeReturnStatement(i){return Ft.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||se(h,this.project)===se(e,this.project)&&si(h.dataType,e.dataType))||i.push(e)})}),C(i)}syncTerminationStatements(i=this.project.addChangeSet(new q(this.project,N.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(g=>{var _;return!g.deleted&&!((_=g.declaration)!=null&&_.deleted)}),b=f.filter(g=>!E.find(_=>se(g,this.project)===se(_,this.project)&&si(g.dataType,_.dataType)));b.length&&(r.push(m),i==null||i.add(m,W.Updated)),b.forEach(g=>{const _=g.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 q(this.project,N.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"sync-body-arguments-declarations"))){var L,j,k,G,H,ie;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,ue)=>ee.index-ue.index),((k=(j=(L=this.body)==null?void 0:L.dataType)==null?void 0:j.entity)==null?void 0:k.id)!==re["primitive-entity"].void.id&&!b.find(ue=>{var ae,de,ce,ne,le,Q,oe;return ue.id!==((ae=this.currentIterationNumberArgumentDeclaration)==null?void 0:ae.id)&&ue.id!==((de=this.currentValueArgumentDeclaration)==null?void 0:de.id)&&((ne=(ce=ue.dataType)==null?void 0:ce.entity)==null?void 0:ne.id)===((oe=(Q=(le=this.body)==null?void 0:le.dataType)==null?void 0:Q.entity)==null?void 0:oe.id)})){let ue=0;this.currentIterationNumberArgumentDeclaration&&ue++,this.currentValueArgumentDeclaration&&ue++;const ae=Na.new(i);ae.name="Aggregate result",ae.description="Aggretated list of all previously outputted values from each iteration",ae.constant=!0,ae.index=ue,ae.required=!1,ae.parent=this.body.toReference();const de=Ae(ae,this.project);if(de.hydrateAncestors(),de.addSelfToProject(i),i==null||i.add(de,W.Added),a.push(de),de.setParent(this.body,i),de.initChildren(i),!de.dataType&&((G=this.body)!=null&&G.dataType)){const ce=mr.new(i);ce.parent=de.toReference();const ne=Ae(ce,this.project);ne.hydrateAncestors(),ne.addSelfToProject(i),a.push(ne),ne.setParent(de,i),ne.initChildren(i),ne.merge((H=this.body)==null?void 0:H.dataType,i),ne.setEntity((ie=this.body)==null?void 0:ie.dataType.entity,i),i==null||i.add(ne,W.Added)}}const{updated:g,added:_,removed:$}=this.removeExtraBodyArgumentDeclarations(i);return r.push(...g),a.push(..._),c.push(...$),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 q(this.project,N.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,k,G;const g=b.outputs.filter(H=>{var ie;return!H.deleted&&!((ie=H.declaration)!=null&&ie.deleted)}),_=g.filter(H=>!H.declaration&&!!H.readsValue),$=g.filter(H=>!H.declaration&&!H.readsValue);let L=(((G=(k=(j=this.body)==null?void 0:j.dataType)==null?void 0:k.entity)==null?void 0:G.properties)||[]).filter(H=>!g.find(ie=>{var ee,ue;return!ie.deleted&&!((ee=ie.declaration)!=null&&ee.deleted)&&((ue=ie.declaration)==null?void 0:ue.id)===H.id}));_.forEach(H=>{const ie=H.getDataType(i);if(H.readsValue){const ee=se(H.readsValue,this.project),ue=L.find(ae=>se(ae,this.project)===ee&&si(ae.dataType,ie));if(ue){H.setDeclaration(ue,i),r.push(H),L=L.filter(ae=>ae!==ue);return}}}),$.forEach(H=>{const ie=H.getDataType(i),ee=L.find(ue=>si(ue.dataType,ie));if(ee){H.setDeclaration(ee,i),r.push(H),L=L.filter(ue=>ue!==ee);return}}),g.forEach(H=>{const ie=L.find(ee=>se(ee,this.project)===se(H,this.project));H.declaration&&!L.includes(H.declaration)&&ie&&(H.setDeclaration(ie,i),r.push(H),L=L.filter(ee=>ee!==ie))})}),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"sync-outputs-properties"))){var $,L,j,k,G,H,ie,ee,ue,ae,de,ce,ne,le,Q,oe,Ee,Te,Ve,Le,$e;const r=[],a=[],c=[],e=[],f=[...this.breakStatements,...this.continueStatements];if(!f.every(ke=>ke.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};if(!(($=this.body)!=null&&$.dataType)){const ke=mr.new(i);ke.parent=this.body.toReference(),ke.inferred=!0;const Ke=Ae(ke,this.project);Ke.hydrateAncestors(),Ke.addSelfToProject(i),i==null||i.add(Ke,W.Added),Ke.initChildren(i),a.push(Ke)}const h=f.find(ke=>!!ke.readsValue);if(h){const ke=(L=h.readsValue)==null?void 0:L.getDataType(i);ke&&((k=(j=this.body)==null?void 0:j.dataType)==null||k.merge(ke,i))}const m=this.getUniqueInputMaps();let E=(H=(G=this.body)==null?void 0:G.dataType)==null?void 0:H.entity;if(m.length&&(!E||E.id===re["primitive-entity"].void.id)){const ke=Ds.new(i);ke.parent=((ie=this.body)==null?void 0:ie.dataType).toReference(),ke.name=`${se(this,this.project)} output definition`,ke.description=`The definition of the output data type of the loop '${se(this,this.project)}'`;const Ke=Ae(ke,this.project);Ke.setParent((ee=this.body)==null?void 0:ee.dataType,i),Ke.hydrateAncestors(),i==null||i.add(Ke,W.Added),Ke.addSelfToProject(i),Ke.initChildren(i),a.push(Ke),E=Ke,(ae=(ue=this.body)==null?void 0:ue.dataType)==null||ae.metaSync({inferred:!0},i)}const b=(E==null?void 0:E.properties)||[];(ce=(de=this.body)==null?void 0:de.dataType)!=null&&ce.inferred&&((le=(ne=this.body)==null?void 0:ne.dataType.entity)==null?void 0:le.type)===d.DefinitionEntity&&(m.forEach(ke=>{var Xt,tr,nr,Xn,nn;const Ke=ke.getDataType(i);let rt=b.find(ji=>se(ji,this.project)===se(ke,this.project)&&si(ji.dataType,ke.dataType));if(!rt){const ji=ts.new(i);ji.name=se(ke,this.project),ji.description=`Aggretated list of all previously outputted values from each iteration by the output '${se(ke,this.project)}'`,ji.index=ke.index,ji.required=((Xt=ke.declaration)==null?void 0:Xt.required)||!1,ji.parent=((nr=(tr=this.body)==null?void 0:tr.dataType)==null?void 0:nr.entity).toReference();const ar=Ae(ji,this.project);ar.hydrateAncestors(),ar.setParent((nn=(Xn=this.body)==null?void 0:Xn.dataType)==null?void 0:nn.entity,i),ar.addSelfToProject(i),i==null||i.add(ar,W.Added),ar.initChildren(i),a.push(ar),rt=ar}rt.index!==ke.index&&(rt.metaSync({index:ke.index},i),r.push(rt));let Et=rt.getDataType(i);if(Ke)if(!Et||!si(Et,Ke)){if(!Et){const ji=Ke.clone(i,rt);i==null||i.add(ji,W.Added),ji.addSelfToProject(i),Et=ji,a.push(ji),r.push(rt)}Et.merge(Ke,i),Et.metaSync({isList:!0},i)}else Et.isList||(Et.metaSync({isList:!0},i),r.push(Et));if(!Ke&&!Et){const ji={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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:rt.toReference()},ar=Ae(ji,this.project);ar.metaSync({isList:!0},i),ar.setParent(rt,i),ar.initChildren(i),i==null||i.add(ar,W.Added),ar.addSelfToProject(i),a.push(ar)}}),this.reAttachAllTerminationInputMapsToDeclarations(i)),(oe=(Q=this.body)==null?void 0:Q.dataType)!=null&&oe.inferred&&((Te=(Ee=this.body)==null?void 0:Ee.dataType.entity)==null?void 0:Te.type)===d.DefinitionEntity&&b.filter(Ke=>!m.find(rt=>se(Ke,this.project)===se(rt,this.project))).forEach(Ke=>{if(!(i!=null&&i.hasRemoved(Ke.id))&&!Ke.deleted){const{updated:Je,removed:rt}=Ke.remove({ignoreUpstream:!1},i);r.push(...Je),c.push(...rt)}}),f.forEach(ke=>{ke.outputs.filter(Je=>{var rt;return!Je.deleted&&!((rt=Je.declaration)!=null&&rt.deleted)}).forEach(Je=>{var Rt,Et,Xt;if(!(((Xt=(Et=(Rt=this.body)==null?void 0:Rt.dataType)==null?void 0:Et.entity)==null?void 0:Xt.properties)||[]).find(tr=>{var nr;return((nr=Je.declaration)==null?void 0:nr.id)===tr.id})&&!(i!=null&&i.hasRemoved(Je.id))&&!Je.deleted){const{updated:tr,removed:nr}=Je.remove({ignoreUpstream:!1},i);r.push(...tr),c.push(...nr)}})});const g=this.getUniqueInputMaps();if(f.every(ke=>!ke.readsValue)&&!g.length){const ke=this.project.getBuiltIn(re["primitive-entity"].void.id);(Le=(Ve=this.body)==null?void 0:Ve.dataType)==null||Le.setEntity(ke,i),r.push(($e=this.body)==null?void 0:$e.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SyncOutputs))){var E,b,g;const r=[],a=[],c=[],e=[],f=((g=(b=(E=this.body)==null?void 0:E.dataType)==null?void 0:b.entity)==null?void 0:g.properties)||[],h=this.outputs;return f.forEach(_=>{var j;let L=h.find(k=>{var G,H;return((G=k.declaration)==null?void 0:G.id)===_.id&&si((H=k.declaration)==null?void 0:H.dataType,_.dataType)});if(L)((j=L.declaration)==null?void 0:j.id)!==_.id&&(L.setDeclaration(_,i),r.push(L));else{const k={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,index:_.index,declaration:_.toJSON(),writesValues:[],parent:this.toReference()},G=Ae(k,this.project);G.setParent(this,i),G.initChildren(i),i==null||i.add(G,W.Added),G.addSelfToProject(i),a.push(G),L=G}L.index!==_.index&&(L.metaSync({index:_.index},i),r.push(L))}),h.filter(_=>!f.find(L=>{var j;return((j=_.declaration)==null?void 0:j.id)===L.id})).forEach(_=>{const{updated:$,removed:L}=_.remove({ignoreUpstream:!1},i);r.push(...$),c.push(...L)}),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"create-current-iteration-number-argument-declaration"))){const r=[],a=[],c=[],e=[];let h=this.body.inputs.find(g=>{var _;return g.name===Jt.CURRENT_ITERATION_NUMBER_ARG_NAME||g.id===((_=this.currentIterationNumberArgumentDeclaration)==null?void 0:_.id)});const m=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!h){const g={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:Jt.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:[]},_=Ae(g,this.project);_.setParent(this.body,i),_.initChildren(i),i==null||i.add(_,W.Added),_.addSelfToProject(i),a.push(_),h=_}!h.index&&h.index!==0&&(h.metaSync({index:0},i),r.push(h)),(!h.implements||!h.implements.find(g=>g.id===m.id))&&(h.addImplementation(m,i),r.push(h));let b=h.getDataType(i);if(!b){const g={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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()},_=Ae(g,this.project);_.setParent(h,i),_.initChildren(i),i==null||i.add(_,W.Added),_.addSelfToProject(i),a.push(_),b=_}if(!b.entity||b.entity.type!==d.PrimitiveEntity||b.entity.name!==ye.Number||b.entity.id!==re["primitive-entity"].number.id){const g=this.project.getBuiltIn(re["primitive-entity"].number.id);b.setEntity(g,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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"remove-extra-body-argument-declarations"))){const r=[],a=[],c=[],e=[];return this.body.inputs.filter(m=>{var E,b,g,_,$,L,j,k;return m===this.currentIterationNumberArgumentDeclaration||m===this.currentValueArgumentDeclaration?!1:((g=(b=(E=this.body)==null?void 0:E.dataType)==null?void 0:b.entity)==null?void 0:g.id)===re["primitive-entity"].void.id?!0:(($=(_=m.dataType)==null?void 0:_.entity)==null?void 0:$.id)!==((k=(j=(L=this.body)==null?void 0:L.dataType)==null?void 0:j.entity)==null?void 0:k.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"create-current-value-input-based-on-input-map"))){var E,b,g,_,$,L,j,k,G;const r=[],a=[],c=[],e=[];switch(this.declaration.id){case pt.List:{const H=this.body.inputs.find(ue=>!!ue.implements.find(ae=>ae.id===re[d.Loop][pt.List].body.inputs.currentValue.id)),ie=this.inputs.find(ue=>{var ae;return((ae=ue.declaration)==null?void 0:ae.id)===re[d.Loop][pt.List].inputs.list.id});if(!ie)break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(H){ee&&!H.implements.find(ce=>ce.id===ee.id)&&(H.addImplementation(ee,i),r.push(H));let ae=H.getDataType(i);if(!ae){const ce={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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()},ne=Ae(ce,this.project);ne.setParent(this.currentValueArgumentDeclaration,i),ne.initChildren(i),i==null||i.add(ne,W.Added),ne.addSelfToProject(i),a.push(ne),ae=ne}const de=ie.getDataType(i);ae.merge(de,i),ae.metaSync({isList:!1},i)}else{const ue={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:Jt.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()},ae=Ae(ue,this.project);ae.setParent(this.body,i),ae.initChildren(i),i==null||i.add(ae,W.Added),ae.addSelfToProject(i),ee&&!ae.implements.find(de=>de.id===ee.id)&&(ae.addImplementation(ee,i),r.push(ae)),a.push(ae)}break}case pt.ManualFlow:break;case pt.Counted:break;case pt.ObjectKeys:{const H=this.body.inputs.find(ue=>!!ue.implements.find(ae=>ae.id===re[d.Loop][pt.ObjectKeys].body.inputs.currentValue.id));if(!this.inputs.find(ue=>{var ae;return((ae=ue.declaration)==null?void 0:ae.id)===re[d.Loop][pt.ObjectKeys].inputs.object.id}))break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(H){ee&&!H.implements.find(de=>de.id===ee.id)&&(H.addImplementation(ee),r.push(H));let ae=H.getDataType(i);if(ae){const de=this.project.getBuiltIn(re["primitive-entity"].string.id);((g=ae.entity)==null?void 0:g.id)!==de.id&&(ae.setEntity(de,i),r.push(ae))}else{const de={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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()},ce=Ae(de,this.project);ce.setParent(this.currentValueArgumentDeclaration,i),ce.initChildren(i),i==null||i.add(ce,W.Added),ce.addSelfToProject(i),ae=ce}}else{const ue={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:Jt.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()},ae=Ae(ue,this.project);ae.setParent(this.body,i),ae.initChildren(i),i==null||i.add(ae,W.Added),ae.addSelfToProject(i),ee&&!ae.implements.find(de=>de.id===ee.id)&&(ae.addImplementation(ee,i),r.push(ae)),a.push(ae)}break}case pt.ObjectValues:{const H=this.body.inputs.find(ue=>!!ue.implements.find(ae=>ae.id===re[d.Loop][pt.ObjectValues].body.inputs.currentValue.id)),ie=this.inputs.find(ue=>{var ae;return((ae=ue.declaration)==null?void 0:ae.id)===re[d.Loop][pt.ObjectValues].inputs.object.id});if(!ie)break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(H){ee&&!H.implements.find(de=>de.id===ee.id)&&(H.addImplementation(ee,i),r.push(H));let ae=H.getDataType(i);if(ae){const de=ie.getDataType(i),ce=((L=de==null?void 0:de.entity)==null?void 0:L.properties)||[];(j=ae.orChildrenGroup)==null||j.forEach(ne=>{const{updated:le,removed:Q}=ne.remove({ignoreUpstream:!1},i);r.push(...le),c.push(...Q)}),ce.forEach(ne=>{if(!ne.getDataType(i)){const Q={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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:We.OrDataTypeGroup,parent:ae.toReference()},oe=Ae(Q,this.project);oe.setParent(ae,i),oe.initChildren(i),i==null||i.add(oe,W.Added),oe.addSelfToProject(i),a.push(oe)}})}else{const de={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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()},ce=Ae(de,this.project);ce.setParent(this.currentValueArgumentDeclaration,i),ce.initChildren(i),i==null||i.add(ce,W.Added),ce.addSelfToProject(i),ae=ce;const ne=ie.getDataType(i);((($=ne==null?void 0:ne.entity)==null?void 0:$.properties)||[]).forEach(Q=>{if(!Q.getDataType(i)){const Ee={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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:We.OrDataTypeGroup,parent:ce.toReference()},Te=Ae(Ee,this.project);Te.setParent(ce,i),Te.initChildren(i),i==null||i.add(Te,W.Added),Te.addSelfToProject(i),a.push(Te)}})}}else{const ue={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:Jt.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()},ae=Ae(ue,this.project);ae.setParent(this.body,i),ae.initChildren(i),i==null||i.add(ae,W.Added),ae.addSelfToProject(i),ee&&!ae.implements.find(de=>de.id===ee.id)&&(ae.addImplementation(ee,i),r.push(ae)),a.push(ae)}break}case pt.String:{const H=this.body.inputs.find(ue=>!!ue.implements.find(ae=>ae.id===re[d.Loop][pt.String].body.inputs.currentValue.id));if(!this.inputs.find(ue=>{var ae;return((ae=ue.declaration)==null?void 0:ae.id)===re[d.Loop][pt.String].inputs.string.id}))break;const ee=this.getCurrentValueBuiltInValueDescriptor();if(H){ee&&!H.implements.find(de=>de.id===ee.id)&&(H.addImplementation(ee,i),r.push(H));let ae=H.getDataType(i);if(ae){const de=this.project.getBuiltIn(re["primitive-entity"].string.id);((G=ae.entity)==null?void 0:G.id)!==de.id&&(ae.setEntity(de,i),r.push(ae))}else{const de={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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:(k=this.currentValueArgumentDeclaration)==null?void 0:k.toReference()},ce=Ae(de,this.project);ce.setParent(this.currentValueArgumentDeclaration,i),ce.initChildren(i),i==null||i.add(ce,W.Added),ce.addSelfToProject(i),a.push(ce),ae=ce}}else{const ue={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ArgumentDeclaration,name:Jt.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()},ae=Ae(ue,this.project);ae.setParent(this.body,i),ae.initChildren(i),i==null||i.add(ae,W.Added),ae.addSelfToProject(i),ee&&!ae.implements.find(de=>de.id===ee.id)&&(ae.addImplementation(ee,i),r.push(ae)),a.push(ae)}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 q(this.project,N.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:g}=this.createCurrentValueInputBasedOnInputMap(i);return r.push(...E),a.push(...b),c.push(...g),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"sync-input-maps"))){const r=[],a=[],c=[],e=[];switch(this.declaration.id){case pt.List:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===re[d.Loop]["list-loop"].inputs.list.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==re[d.Loop]["list-loop"].inputs.list.id){const m=this.project.get(re[d.Loop]["list-loop"].inputs.list.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(re[d.Loop]["list-loop"].inputs.list.id),E={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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=Ae(E,this.project);b.setParent(this,i),b.initChildren(i),i==null||i.add(b,W.Added),b.addSelfToProject(i),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==re[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 pt.ManualFlow:{this.inputs.forEach(f=>{f.remove({ignoreUpstream:!1},i),c.push(f)});break}case pt.Counted:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===re[d.Loop]["counted-loop"].inputs.number.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==re[d.Loop]["counted-loop"].inputs.number.id){const m=this.project.get(re[d.Loop]["counted-loop"].inputs.number.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(re[d.Loop]["counted-loop"].inputs.number.id),E={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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=Ae(E,this.project);b.setParent(this,i),b.initChildren(i),i==null||i.add(b,W.Added),b.addSelfToProject(i),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==re[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 pt.ObjectKeys:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===re[d.Loop]["object-keys-loop"].inputs.object.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==re[d.Loop]["object-keys-loop"].inputs.object.id){const m=this.project.get(re[d.Loop]["object-keys-loop"].inputs.object.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(re[d.Loop]["object-keys-loop"].inputs.object.id),E={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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=Ae(E,this.project);b.setParent(this,i),b.initChildren(i),i==null||i.add(b,W.Added),b.addSelfToProject(i),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==re[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 pt.ObjectValues:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===re[d.Loop]["object-values-loop"].inputs.object.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==re[d.Loop]["object-values-loop"].inputs.object.id){const m=this.project.get(re[d.Loop]["object-values-loop"].inputs.object.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(re[d.Loop]["object-values-loop"].inputs.object.id),E={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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=Ae(E,this.project);b.setParent(this,i),b.initChildren(i),i==null||i.add(b,W.Added),b.addSelfToProject(i),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==re[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 pt.String:{let f=null;if(this.inputs.forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)===re[d.Loop]["string-loop"].inputs.string.id?f=m:(m.remove({ignoreUpstream:!1},i),c.push(m))}),f){if(f.declaration.id!==re[d.Loop]["string-loop"].inputs.string.id){const m=this.project.get(re[d.Loop]["string-loop"].inputs.string.id);f.setDeclaration(m,i),r.push(f)}}else{const m=this.project.get(re[d.Loop]["string-loop"].inputs.string.id),E={dataType:null,id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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=Ae(E,this.project);b.setParent(this,i),b.initChildren(i),i==null||i.add(b,W.Added),b.addSelfToProject(i),a.push(b)}[...this.inputs].forEach(m=>{var E;((E=m.declaration)==null?void 0:E.id)!==re[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 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 pt.List:return re[d.Loop]["list-loop"].inputs.list.id;case pt.ObjectKeys:return re[d.Loop]["object-keys-loop"].inputs.object.id;case pt.ObjectValues:return re[d.Loop]["object-values-loop"].inputs.object.id;case pt.String:return re[d.Loop]["string-loop"].inputs.string.id;case pt.Counted:return re[d.Loop]["counted-loop"].inputs.number.id;default:return null}}getCurrentValueBuiltInValueDescriptor(){var r;if(this.declaration.id===pt.ManualFlow||this.declaration.id===pt.Counted)return null;const i=(r=re[d.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:r.id;return i?this.project.get(i):null}getCurrentIterationNumberBuiltInValueDescriptor(){const i=re[d.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(i)}syncBody(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"sync-body"))){var m;const r=[],a=[],c=[],e=[],f=re[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=Ae(E,this.project);b.setParent(this,i),b.initChildren(i),i==null||i.add(b,W.Added),b.addSelfToProject(i),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,g,_,$,L,j,k,G,H,ie,ee,ue,ae,de,ce,ne,le,Q,oe,Ee,Te,Ve,Le,$e,ke;if((!this.body||!((b=this.body)!=null&&b.dataType)||!((g=this.body)!=null&&g.dataType.entity))&&this.id)return!1;const i=[pt.List,pt.ObjectKeys,pt.ObjectValues,pt.String],r=this.body.inputs.find(Ke=>Ke.implements.find(Je=>Je.id===re[d.Loop][this.declaration.id].body.inputs.iterationNumber.id))||null,a=this.body.inputs.find(Ke=>Ke.implements.find(Je=>{var rt;return Je.id===((rt=re[d.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:rt.id)}))||null;if(!r||i.includes(this.declaration.id)&&!a)return!1;const c=[...this.breakStatements,...this.continueStatements];if(((L=($=(_=this.body)==null?void 0:_.dataType)==null?void 0:$.entity)==null?void 0:L.id)!==re["primitive-entity"].void.id){if(!this.body.inputs.find(Je=>{var rt,Rt,Et,Xt,tr;return((Rt=(rt=Je.dataType)==null?void 0:rt.entity)==null?void 0:Rt.id)===((tr=(Xt=(Et=this.body)==null?void 0:Et.dataType)==null?void 0:Xt.entity)==null?void 0:tr.id)})||((G=(k=(j=this.body)==null?void 0:j.dataType)==null?void 0:k.entity)==null?void 0:G.type)===d.DefinitionEntity&&(!((ie=(H=this.body)==null?void 0:H.dataType)==null?void 0:ie.entity).properties.every(Rt=>this.outputs.find(Et=>{var Xt;return((Xt=Et.declaration)==null?void 0:Xt.id)===Rt.id}))||!c.every(Rt=>{var nr,Xn;const Et=Rt.outputs.filter(nn=>!nn.deleted),Xt=((Xn=(nr=this.body)==null?void 0:nr.dataType)==null?void 0:Xn.entity).properties.every(nn=>Et.find(ji=>{var ar;return((ar=ji.declaration)==null?void 0:ar.id)===nn.id})),tr=Et.every(nn=>{var ji,ar;return((ar=(ji=this.body)==null?void 0:ji.dataType)==null?void 0:ar.entity).properties.find(Io=>{var Ro;return Io.id===((Ro=nn.declaration)==null?void 0:Ro.id)})});return Xt&&tr})))return!1}else if(this.body.inputs.find(rt=>{var Rt,Et,Xt,tr,nr;return((Et=(Rt=rt.dataType)==null?void 0:Rt.entity)==null?void 0:Et.id)===((nr=(tr=(Xt=this.body)==null?void 0:Xt.dataType)==null?void 0:tr.entity)==null?void 0:nr.id)})||this.outputs.length>0||![...this.breakStatements,...this.continueStatements].every(rt=>rt.outputs.filter(Rt=>!Rt.deleted).length===0))return!1;if([pt.List,pt.Counted,pt.ObjectKeys,pt.ObjectValues,pt.String].includes(this.declaration.id)){if(this.inputs.length!==1)return!1;const Ke=this.inputs[0],Je=this.getValueInputMapDeclarationId();if(((ee=Ke.declaration)==null?void 0:ee.id)!==Je)return!1}else if(this.inputs.length>0)return!1;if((ae=(ue=this.body)==null?void 0:ue.dataType)!=null&&ae.inferred){const Ke=this.getUniqueInputMaps();if(c.every(Et=>!Et.readsValue)&&!Ke.length&&((ne=(ce=(de=this.body)==null?void 0:de.dataType)==null?void 0:ce.entity)==null?void 0:ne.id)!==re["primitive-entity"].void.id)return!1;const rt=c.find(Et=>Et.readsValue),Rt=(oe=(Q=(le=rt==null?void 0:rt.readsValue)==null?void 0:le.getDataType(null))==null?void 0:Q.entity)==null?void 0:oe.id;if(Rt&&Rt!==((Ve=(Te=(Ee=this.body)==null?void 0:Ee.dataType)==null?void 0:Te.entity)==null?void 0:Ve.id))return!1}const f=((ke=($e=(Le=this.body)==null?void 0:Le.dataType)==null?void 0:$e.entity)==null?void 0:ke.properties)||[],h=this.outputs,m=f.every(Ke=>h.find(Je=>{var rt;return((rt=Je.declaration)==null?void 0:rt.id)===Ke.id})),E=h.every(Ke=>f.find(Je=>{var rt;return Je.id===((rt=Ke.declaration)==null?void 0:rt.id)}));return!(!m||!E)}syncFromDataType(i=this.project.addChangeSet(new q(this.project,N.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:g}=this.syncBodyArgumentsDeclarations(i);r.push(...E),a.push(...b),c.push(...g);const{updated:_,added:$,removed:L}=this.syncBodyInputIndexes(i);r.push(..._),a.push(...$),c.push(...L);const{updated:j,added:k,removed:G}=this.syncOutputMaps(i);return r.push(...j),a.push(...k),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 q(this.project,N.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:g}=this.syncInputMaps(i);r.push(...E),a.push(...b),c.push(...g);const{updated:_,added:$,removed:L}=this.syncTerminationStatements(i);r.push(..._),a.push(...$),c.push(...L);const{updated:j,added:k,removed:G}=this.syncFromDataType(i);return r.push(...j),a.push(...k),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 q(this.project,N.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SetDataType))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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 q(this.project,N.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):(z.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 q(this.project,N.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(Jt,"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(Jt,"type",d.Loop),R(Jt,"USER_MANAGED_PARENT_TYPES",[...vr,d.Project]),R(Jt,"PARENT_TYPES",[...ki.USER_MANAGED_PARENT_TYPES]),R(Jt,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),R(Jt,"CURRENT_VALUE_ARG_NAME","Current value"),R(Jt,"MUTABLE_BASE_PROPERTIES",["catchesError"]),R(Jt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(Jt,"BASE_PROPERTIES",[...Jt.MUTABLE_BASE_PROPERTIES,...Jt.INMUTABLE_BASE_PROPERTIES]),R(Jt,"MUTABLE_META_PROPERTIES",[...Jt.MUTABLE_BASE_PROPERTIES,"x","y"]),R(Jt,"INMUTABLE_META_PROPERTIES",[...Jt.INMUTABLE_BASE_PROPERTIES]),R(Jt,"META_PROPERTIES",[...Jt.MUTABLE_META_PROPERTIES,...Jt.INMUTABLE_META_PROPERTIES]),R(Jt,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),R(Jt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration","dataType"]),R(Jt,"UPSTREAM_PROPERTIES",[...Jt.MUTABLE_UPSTREAM_PROPERTIES,...Jt.INMUTABLE_UPSTREAM_PROPERTIES]),R(Jt,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","successCalls","errorCalls","error","breakStatements","continueStatements"]),R(Jt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(Jt,"DOWNSTREAM_PROPERTIES",[...Jt.MUTABLE_DOWNSTREAM_PROPERTIES,...Jt.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(Jt,"PROPERTIES",[...Jt.META_PROPERTIES,...Jt.UPSTREAM_PROPERTIES,...Jt.DOWNSTREAM_PROPERTIES]);let fp=Jt;async function E_e(l,p={}){const i=z.YieldTracker.from(p),r=da(l),a=ua(l),c=[...r,...a],e=kt(l.errors,c);await i.tick();for(const f of l.inputs)await f.validateAsync({tracker:i});return e}function b_e(l){l.inputs.forEach(a=>a.validate());const p=da(l),i=ua(l),r=[...p,...i];return kt(l.errors,r)}const $Ai=Object.freeze(Object.defineProperty({__proto__:null,validate:b_e,validateAsync:E_e},Symbol.toStringTag,{value:"Module"}));var A_e=(l=>(l.Parent="parent",l))(A_e||{});const xi=class xi extends Qr{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:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||N.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){var g,_;let a=r;if(i.parent){const $=X(i.parent);a=r.get($)}const c=(i.calledByEntry||[]).map($=>{const L=X($);return r.get(L)}),e=(i.calledBySuccess||[]).map($=>{const L=X($);return r.get(L)}),f=(i.calledByError||[]).map($=>{const L=X($);return r.get(L)});let h;if(i.declaration){const $=X(i.declaration);h=r.get($)}let m=null;a&&a.type===d.Condition&&(((g=a.declaration)==null?void 0:g.id)===Ir.Or?m=(a.orChildrenGroup||[]).length:((_=a.declaration)==null?void 0:_.id)===Ir.And&&(m=(a.andChildrenGroup||[]).length));const E={id:i.id,version:N.UUID.uuid(),createdAt:B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Condition,index:m,declaration:h.toJSON(),andChildrenGroup:[],orChildrenGroup:[],calledByEntry:c.map($=>$.toReference()),calledBySuccess:e.map($=>$.toReference()),calledByError:f.map($=>$.toReference()),errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:a.toReference()},b=Ae(E,r);return b.hydrateAncestors(),b.setParent(a,null),b}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=wn(a,{parent:{list:!1,types:[...vr,d.Project],optional:!0}},r);c.push(...f.explanations),a=f.modifiedData;const h=Zr(a);if(e.push(...f.errors,...h.errors),c.push(...h.explanations),!i.declaration)e.push(new Re({id:`${i.id}--${we.InvalidObjectStructure}`,code:we.InvalidObjectStructure,severity:me.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:Ji.AllConditionActionDescriptors,message:_g(r)});else if(!r.get(i.declaration))e.push(new Re({id:`${i.id}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:me.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:Ji.AllConditionActionDescriptors,message:_g(r)});else{const E=Xje(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 Re({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:me.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
|
-
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 q(this.project,N.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){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.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 xi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.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,this}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){var h;const r=[],a=[],c=[],e=[];if(this.version===i)return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};if(!this.knownVersions){const m=new Map;for(const[E,b]of this.knownVersions||new Map){if(m.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[g,_]of b.knownVersions)m.set(g,_);b.knownVersions=null}}let f=(h=this.knownVersions)==null?void 0:h.get(i);if(!f){const m=await this.APILoadVersion({},i);if(!m)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);f=new xi(m,this.project)}return this.metaSync(f.toShallowJSON(),null),this.previousVersion=f.previousVersion,this.version=f.version,this.createdAt=f.createdAt,this.author=f.author,this.deleted=f.deleted,this.inputs=f.inputs,this.declaration=f.declaration,this.andChildrenGroup=f.andChildrenGroup,this.orChildrenGroup=f.orChildrenGroup,this.successCalls=f.successCalls,this.errorCalls=f.errorCalls,this.calledBySuccess=f.calledBySuccess,this.calledByError=f.calledByError,this.calledByEntry=f.calledByEntry,this.parent=f.parent,{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){var a,c;if(!this.checkCanEdit(this,r))return z.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=X(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=X(i.declaration),f=this.project.get(e);f&&this.setDeclaration(f)}return(a=i.andChildrenGroup)==null||a.forEach(e=>{const f=X(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=>X(m)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const f=X(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=>X(m)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),i.calledByEntry.forEach(e=>{const f=X(e),h=this.project.get(f);h&&(this.addEntryCaller(h,r),h.addCall(this,r))}),[...this.calledByEntry].forEach(e=>{i.calledByEntry.find(h=>X(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),i.calledBySuccess.forEach(e=>{const f=X(e),h=this.project.get(f);h&&(this.addSuccessCaller(h,r),h.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(e=>{i.calledBySuccess.find(h=>X(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),i.calledByError.forEach(e=>{const f=X(e),h=this.project.get(f);h&&(this.addErrorCaller(h,r),h.addErrorCall(this,r))}),[...this.calledByError].forEach(e=>{i.calledByError.find(h=>X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return z.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=X(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=X(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=X(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=>X(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=X(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=>X(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=X(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=>X(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=X(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=X(this.initialData.declaration),f=this.project.get(e);f&&(this.setDeclaration(f),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=X(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=X(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){var E,b;if(!this.checkCanEdit(this,i))return z.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 g=this.index||0;const _=(this.parent.declaration.id===Ir.And?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(L=>!L.deleted&&L.id!==this.id);_.length&&(g>_.length+1?g=_.length:g<0&&(g=0)),_.find(L=>(L.index||0)===g&&!L.deleted)&&_.filter(L=>(L.index||0)>=g&&!L.deleted).forEach(L=>{L.metaSync({index:(L.index||0)+1},i),i==null||i.add(L,W.Updated),r.push(L)}),this.metaSync({index:g},i)}(E=this.andChildrenGroup)!=null&&E.length&&this.andChildrenGroup.sort((g,_)=>(g.index||0)-(_.index||0)),(b=this.orChildrenGroup)!=null&&b.length&&this.orChildrenGroup.sort((g,_)=>(g.index||0)-(_.index||0)),this.inputs.sort((g,_)=>{var $,L;return(g.index??(($=g.declaration)==null?void 0:$.index))-(_.index??((L=_.declaration)==null?void 0:L.index))});const{updated:f,added:h,removed:m}=this.syncInputs(i);return r.push(...f),a.push(...h),c.push(...m),this.captureVersion(),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 q(this.project,N.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===Ir.And?this.parent.addToAndGroup(this,i):this.parent.declaration.id===Ir.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveInput))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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):(z.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 q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}addErrorCall(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(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 q(this.project,N.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&&Tt(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 q(this.project,N.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&&Tt(this,r),r==null||r.attemptAutoclose(w.RemoveCall,this.id),this}removeCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}setParent(i,r=this.project.addChangeSet(new q(this.project,N.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveChildGroup))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.declaration=Ae(this.initialData.declaration,this.project),this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a})),this.successCalls=this.initialData.successCalls.map(r=>{const a=Ae(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=fn(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=Ae(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=fn(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=Ae(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(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Wr(this,i,r),c=Hr(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=Se,...r){return await xi.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await xi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await xi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await xi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await xi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await xi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){var f;if(!this.checkCanEdit(this,i))return z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return z.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:g}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...g)}),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return z.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=nt){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||Xr(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:N.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=nt){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+N.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=nt){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=nt){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=b_e(this),{success:!0}}async validateAsync(i={}){const r=z.YieldTracker.from(i);return this.errors=await E_e(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=z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var L,j,k;const e=Br(r,this),f=this.toJSON(),h=a||N.UUID.uuid();f.inputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=N.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=Yi(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 g=(L=this.andChildrenGroup)==null?void 0:L.map(G=>G.clone(i,b,N.UUID.uuid(),c)),_=(j=this.orChildrenGroup)==null?void 0:j.map(G=>G.clone(i,b,N.UUID.uuid(),c));b.andChildrenGroup=g||null,b.orChildrenGroup=_||null;const $=(k=this.inputs)==null?void 0:k.map((G,H)=>G.clone(i,b,E+"-input-map-"+H+"-id",c));return b.inputs=$,i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}addToAndGroup(i,r=this.project.addChangeSet(new q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return z.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(g=>g.declaration===h.declaration&&g!==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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SyncInputs))){if(!this.checkCanEdit(this,i))return z.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===M.FixedArguments&&!this.inputs.find(g=>g.declaration.id===b.id));this.inputs.sort((b,g)=>b.index-g.index),f.forEach(b=>{this.inputs.forEach($=>{$.index>=b.index&&$.metaSync({index:$.index+1},i)});const g={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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()},_=Ae(g,this.project);_.setParent(this,i),_.initChildren(i),i==null||i.add(_,W.Added),_.addSelfToProject(i)}),this.inputs.sort((b,g)=>b.index-g.index);const{updated:h,added:m,removed:E}=this.removeUnrecognizedInputs(i);return r.push(...h),a.push(...m),c.push(...E),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 q(this.project,N.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(xi,"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(xi,"type",d.Condition),R(xi,"USER_MANAGED_PARENT_TYPES",[...vr,d.Project,d.Condition]),R(xi,"PARENT_TYPES",[...xi.USER_MANAGED_PARENT_TYPES]),R(xi,"MUTABLE_BASE_PROPERTIES",["operator"]),R(xi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","index"]),R(xi,"BASE_PROPERTIES",[...xi.MUTABLE_BASE_PROPERTIES,...xi.INMUTABLE_BASE_PROPERTIES]),R(xi,"MUTABLE_META_PROPERTIES",["x","y"]),R(xi,"INMUTABLE_META_PROPERTIES",[...xi.INMUTABLE_BASE_PROPERTIES]),R(xi,"META_PROPERTIES",[...xi.MUTABLE_META_PROPERTIES,...xi.INMUTABLE_META_PROPERTIES]),R(xi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","parent"]),R(xi,"INMUTABLE_UPSTREAM_PROPERTIES",[]),R(xi,"UPSTREAM_PROPERTIES",[...xi.MUTABLE_UPSTREAM_PROPERTIES,...xi.INMUTABLE_UPSTREAM_PROPERTIES]),R(xi,"MUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup","successCalls","errorCalls","inputsDeclarations","inputs"]),R(xi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(xi,"DOWNSTREAM_PROPERTIES",[...xi.MUTABLE_DOWNSTREAM_PROPERTIES,...xi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(xi,"PROPERTIES",[...xi.META_PROPERTIES,...xi.UPSTREAM_PROPERTIES,...xi.DOWNSTREAM_PROPERTIES]);let yp=xi;async function LAi(l,p={}){const i=z.YieldTracker.from(p),r=[],a=kt(l.errors,r);return await i.tick(),a}function BAi(l){const p=[];return kt(l.errors,p)}async function g_e(l,p={}){const i=z.YieldTracker.from(p),r=[],a=kt(l.errors,r);return await i.tick(),a}function I_e(l){const p=[];return kt(l.errors,p)}const MAi=Object.freeze(Object.defineProperty({__proto__:null,validate:I_e,validateAsync:g_e},Symbol.toStringTag,{value:"Module"}));function GAi(l,p){const i=[],r=[];if(l.parent)if(l.parent){const a=p.get(l.parent);a?Nr.USER_MANAGED_PARENT_TYPES.includes(a.type)||r.push(new Re({id:`${l.id}--${l.parent}--${he.InvalidParentReference}`,code:he.InvalidParentReference,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 Re({id:`${l.id}--${l.parent}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.id}", is referencing an entity with id "${l.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 Re({id:`${l.id}--${we.InvalidObjectStructure}`,code:we.InvalidObjectStructure,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 Re({id:`${l.id}--${we.InvalidObjectStructure}`,code:we.InvalidObjectStructure,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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(l.valueAsTypeSingle){const a=[],c=[],e=l.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=N1(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 Re({id:`${l.id}--${f}--${he.InvalidImplementsReference}`,code:he.InvalidImplementsReference,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 Re({id:`${l.id}--${f}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 R_e=(l=>(l.ValueAsTypeSingle="value-as-type-single",l.ValueAsTypeList="value-as-type-list",l))(R_e||{});const pi=class pi extends Qr{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:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||N.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){const a=X(i.parent),c=r.get(a);let e=null,f=null;i.valueAsTypeList?Array.isArray(i.valueAsTypeList)&&(f=i.valueAsTypeList.map(E=>r.get(E)||r.getBuiltIn(E))):i.valueAsTypeSingle&&(e=r.get(i.valueAsTypeSingle)||r.getBuiltIn(i.valueAsTypeSingle));const h={id:i.id,version:N.UUID.uuid(),createdAt:B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:i.name,autogeneration:i.autogeneration,valueAsTypeSingle:e,valueAsTypeList:f,value:i.value||null,parent:c.toReference()},m=Ae(h,r);return m.setParent(c,null),m}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=GAi(a,r),h=Zr(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&&!tl(this.parent.parent))}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new Re({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:me.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.
|
|
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 q(this.project,N.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){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.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 xi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.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,this}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){var h;const r=[],a=[],c=[],e=[];if(this.version===i)return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};if(!this.knownVersions){const m=new Map;for(const[E,b]of this.knownVersions||new Map){if(m.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[g,_]of b.knownVersions)m.set(g,_);b.knownVersions=null}}let f=(h=this.knownVersions)==null?void 0:h.get(i);if(!f){const m=await this.APILoadVersion({},i);if(!m)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);f=new xi(m,this.project)}return this.metaSync(f.toShallowJSON(),null),this.previousVersion=f.previousVersion,this.version=f.version,this.createdAt=f.createdAt,this.author=f.author,this.deleted=f.deleted,this.inputs=f.inputs,this.declaration=f.declaration,this.andChildrenGroup=f.andChildrenGroup,this.orChildrenGroup=f.orChildrenGroup,this.successCalls=f.successCalls,this.errorCalls=f.errorCalls,this.calledBySuccess=f.calledBySuccess,this.calledByError=f.calledByError,this.calledByEntry=f.calledByEntry,this.parent=f.parent,{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){var a,c;if(!this.checkCanEdit(this,r))return z.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=X(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=X(i.declaration),f=this.project.get(e);f&&this.setDeclaration(f)}return(a=i.andChildrenGroup)==null||a.forEach(e=>{const f=X(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=>X(m)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const f=X(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=>X(m)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),i.calledByEntry.forEach(e=>{const f=X(e),h=this.project.get(f);h&&(this.addEntryCaller(h,r),h.addCall(this,r))}),[...this.calledByEntry].forEach(e=>{i.calledByEntry.find(h=>X(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),i.calledBySuccess.forEach(e=>{const f=X(e),h=this.project.get(f);h&&(this.addSuccessCaller(h,r),h.addSuccessCall(this,r))}),[...this.calledBySuccess].forEach(e=>{i.calledBySuccess.find(h=>X(h)===e.id)||(this.removeCaller(e,r),e.removeCall(this,r))}),i.calledByError.forEach(e=>{const f=X(e),h=this.project.get(f);h&&(this.addErrorCaller(h,r),h.addErrorCall(this,r))}),[...this.calledByError].forEach(e=>{i.calledByError.find(h=>X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a,c,e;if(!this.checkCanEdit(this,r))return z.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=X(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=X(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=X(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=>X(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(c=i.calledBySuccess)==null||c.forEach(f=>{const h=X(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=>X(E)===f.id))||(this.removeCaller(f,r),f.removeCall(this,r))}),(e=i.calledByError)==null||e.forEach(f=>{const h=X(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=>X(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=X(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=X(this.initialData.declaration),f=this.project.get(e);f&&(this.setDeclaration(f),i.push(f))}return this.initialData.calledByEntry.forEach(e=>{const f=X(e),h=this.project.get(f);h&&this.addEntryCaller(h,null)}),this.initialData.calledBySuccess.forEach(e=>{const f=X(e),h=this.project.get(f);h&&this.addSuccessCaller(h,null)}),this.initialData.calledByError.forEach(e=>{const f=X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){var E,b;if(!this.checkCanEdit(this,i))return z.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 g=this.index||0;const _=(this.parent.declaration.id===Ir.And?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(L=>!L.deleted&&L.id!==this.id);_.length&&(g>_.length+1?g=_.length:g<0&&(g=0)),_.find(L=>(L.index||0)===g&&!L.deleted)&&_.filter(L=>(L.index||0)>=g&&!L.deleted).forEach(L=>{L.metaSync({index:(L.index||0)+1},i),i==null||i.add(L,W.Updated),r.push(L)}),this.metaSync({index:g},i)}(E=this.andChildrenGroup)!=null&&E.length&&this.andChildrenGroup.sort((g,_)=>(g.index||0)-(_.index||0)),(b=this.orChildrenGroup)!=null&&b.length&&this.orChildrenGroup.sort((g,_)=>(g.index||0)-(_.index||0)),this.inputs.sort((g,_)=>{var $,L;return(g.index??(($=g.declaration)==null?void 0:$.index))-(_.index??((L=_.declaration)==null?void 0:L.index))});const{updated:f,added:h,removed:m}=this.syncInputs(i);return r.push(...f),a.push(...h),c.push(...m),this.captureVersion(),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 q(this.project,N.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===Ir.And?this.parent.addToAndGroup(this,i):this.parent.declaration.id===Ir.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveInput))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.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):(z.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 q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddSuccessCaller,this.id),this):this}addErrorCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddErrorCaller,this.id),this):this}addEntryCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r)),r==null||r.attemptAutoclose(w.AddEntryCaller,this.id),this):this}addErrorCall(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(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 q(this.project,N.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&&Tt(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 q(this.project,N.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&&Tt(this,r),r==null||r.attemptAutoclose(w.RemoveCall,this.id),this}removeCaller(i,r=this.project.addChangeSet(new q(this.project,N.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&&Tt(this,r),r==null||r.attemptAutoclose(w.RemoveCaller,this.id),this):this}setParent(i,r=this.project.addChangeSet(new q(this.project,N.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveChildGroup))){if(!this.checkCanEdit(this,r))return z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.declaration=Ae(this.initialData.declaration,this.project),this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a})),this.successCalls=this.initialData.successCalls.map(r=>{const a=Ae(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=fn(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=Ae(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=fn(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=Ae(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(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Wr(this,i,r),c=Hr(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=Se,...r){return await xi.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await xi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await xi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await xi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await xi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await xi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){var f;if(!this.checkCanEdit(this,i))return z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return z.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:g}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...g)}),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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return z.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=nt){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||Xr(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:N.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=nt){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+N.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=nt){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=nt){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=b_e(this),{success:!0}}async validateAsync(i={}){const r=z.YieldTracker.from(i);return this.errors=await E_e(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=z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var L,j,k;const e=Br(r,this),f=this.toJSON(),h=a||N.UUID.uuid();f.inputs=[];const m=h.split("-id"),E=m[m.length-1||0]||h;f.id=h,f.version=N.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=Yi(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 g=(L=this.andChildrenGroup)==null?void 0:L.map(G=>G.clone(i,b,N.UUID.uuid(),c)),_=(j=this.orChildrenGroup)==null?void 0:j.map(G=>G.clone(i,b,N.UUID.uuid(),c));b.andChildrenGroup=g||null,b.orChildrenGroup=_||null;const $=(k=this.inputs)==null?void 0:k.map((G,H)=>G.clone(i,b,E+"-input-map-"+H+"-id",c));return b.inputs=$,i==null||i.attemptAutoclose(w.CloneEntity,this.id),b}addToAndGroup(i,r=this.project.addChangeSet(new q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return z.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(g=>g.declaration===h.declaration&&g!==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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.SyncInputs))){if(!this.checkCanEdit(this,i))return z.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===M.FixedArguments&&!this.inputs.find(g=>g.declaration.id===b.id));this.inputs.sort((b,g)=>b.index-g.index),f.forEach(b=>{this.inputs.forEach($=>{$.index>=b.index&&$.metaSync({index:$.index+1},i)});const g={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:N.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()},_=Ae(g,this.project);_.setParent(this,i),_.initChildren(i),i==null||i.add(_,W.Added),_.addSelfToProject(i)}),this.inputs.sort((b,g)=>b.index-g.index);const{updated:h,added:m,removed:E}=this.removeUnrecognizedInputs(i);return r.push(...h),a.push(...m),c.push(...E),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 q(this.project,N.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(xi,"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(xi,"type",d.Condition),R(xi,"USER_MANAGED_PARENT_TYPES",[...vr,d.Project,d.Condition]),R(xi,"PARENT_TYPES",[...xi.USER_MANAGED_PARENT_TYPES]),R(xi,"MUTABLE_BASE_PROPERTIES",["operator"]),R(xi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","index"]),R(xi,"BASE_PROPERTIES",[...xi.MUTABLE_BASE_PROPERTIES,...xi.INMUTABLE_BASE_PROPERTIES]),R(xi,"MUTABLE_META_PROPERTIES",["x","y"]),R(xi,"INMUTABLE_META_PROPERTIES",[...xi.INMUTABLE_BASE_PROPERTIES]),R(xi,"META_PROPERTIES",[...xi.MUTABLE_META_PROPERTIES,...xi.INMUTABLE_META_PROPERTIES]),R(xi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","parent"]),R(xi,"INMUTABLE_UPSTREAM_PROPERTIES",[]),R(xi,"UPSTREAM_PROPERTIES",[...xi.MUTABLE_UPSTREAM_PROPERTIES,...xi.INMUTABLE_UPSTREAM_PROPERTIES]),R(xi,"MUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup","successCalls","errorCalls","inputsDeclarations","inputs"]),R(xi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(xi,"DOWNSTREAM_PROPERTIES",[...xi.MUTABLE_DOWNSTREAM_PROPERTIES,...xi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(xi,"PROPERTIES",[...xi.META_PROPERTIES,...xi.UPSTREAM_PROPERTIES,...xi.DOWNSTREAM_PROPERTIES]);let yp=xi;async function LAi(l,p={}){const i=z.YieldTracker.from(p),r=[],a=kt(l.errors,r);return await i.tick(),a}function BAi(l){const p=[];return kt(l.errors,p)}async function g_e(l,p={}){const i=z.YieldTracker.from(p),r=[],a=kt(l.errors,r);return await i.tick(),a}function I_e(l){const p=[];return kt(l.errors,p)}const MAi=Object.freeze(Object.defineProperty({__proto__:null,validate:I_e,validateAsync:g_e},Symbol.toStringTag,{value:"Module"}));function GAi(l,p){const i=[],r=[];if(l.parent)if(l.parent){const a=p.get(l.parent);a?Nr.USER_MANAGED_PARENT_TYPES.includes(a.type)||r.push(new Re({id:`${l.id}--${l.parent}--${he.InvalidParentReference}`,code:he.InvalidParentReference,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 Re({id:`${l.id}--${l.parent}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.id}", is referencing an entity with id "${l.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 Re({id:`${l.id}--${we.InvalidObjectStructure}`,code:we.InvalidObjectStructure,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 Re({id:`${l.id}--${we.InvalidObjectStructure}`,code:we.InvalidObjectStructure,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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(l.valueAsTypeSingle){const a=[],c=[],e=l.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=N1(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 Re({id:`${l.id}--${f}--${he.InvalidImplementsReference}`,code:he.InvalidImplementsReference,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 Re({id:`${l.id}--${f}--${he.ReferencedEntityNotFound}`,code:he.ReferencedEntityNotFound,severity:me.Error,message:`Entity of type "${l.type}" with id "${l.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 R_e=(l=>(l.ValueAsTypeSingle="value-as-type-single",l.ValueAsTypeList="value-as-type-list",l))(R_e||{});const pi=class pi extends Qr{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:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||N.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){const a=X(i.parent),c=r.get(a);let e=null,f=null;i.valueAsTypeList?Array.isArray(i.valueAsTypeList)&&(f=i.valueAsTypeList.map(E=>r.get(E)||r.getBuiltIn(E))):i.valueAsTypeSingle&&(e=r.get(i.valueAsTypeSingle)||r.getBuiltIn(i.valueAsTypeSingle));const h={id:i.id,version:N.UUID.uuid(),createdAt:B().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:i.name,autogeneration:i.autogeneration,valueAsTypeSingle:e,valueAsTypeList:f,value:i.value||null,parent:c.toReference()},m=Ae(h,r);return m.setParent(c,null),m}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));(a.valueAsTypeList||a.valueAsTypeSingle)&&(a.name=ye.EntityTemplate);const c=[],e=[],f=GAi(a,r),h=Zr(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&&!tl(this.parent.parent))}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new Re({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:me.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
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 q(this.project,N.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){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=N.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);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.valueAsTypeSingle=this.valueAsTypeSingle,i.valueAsTypeList=this.valueAsTypeList?[...this.valueAsTypeList]:this.valueAsTypeList,i.parent=this.parent,this}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){var h;const r=[],a=[],c=[],e=[];if(this.version===i)return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this};if(!this.knownVersions){const m=new Map;for(const[E,b]of this.knownVersions||new Map){if(m.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[g,_]of b.knownVersions)m.set(g,_);b.knownVersions=null}}let f=(h=this.knownVersions)==null?void 0:h.get(i);if(!f){const m=await this.APILoadVersion({},i);if(!m)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);f=new pi(m,this.project)}return this.metaSync(f.toShallowJSON(),null),this.previousVersion=f.previousVersion,this.version=f.version,this.createdAt=f.createdAt,this.author=f.author,this.deleted=f.deleted,this.valueAsTypeSingle=f.valueAsTypeSingle,this.parent=f.parent,{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return z.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=X(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=X(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=X(a),e=this.project.get(c);e&&this.addValueAsTypeToList(e,r)}),[...this.valueAsTypeList].forEach(a=>{(i.valueAsTypeList||[]).find(e=>X(e)===a.id)||this.removeValueAsTypeFromList(a,r)}),this.setValueAsTypeSingle(null,r),this.metaSync({value:null},r);else if(i.valueAsTypeSingle){const a=X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){if(!this.checkCanEdit(this,r))return z.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=X(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=X(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=X(a),e=this.project.get(c);e&&this.addValueAsTypeToList(e,r)}),[...this.valueAsTypeList].forEach(a=>{(i.valueAsTypeList||[]).find(e=>X(e)===a.id)||this.removeValueAsTypeFromList(a,r)}),this.setValueAsTypeSingle(null,r),this.metaSync({value:null},r);else if(i.valueAsTypeSingle){const a=X(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=X(this.initialData.parent),f=this.project.get(e);if(z.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating parent reference '${e}' for entity with id '${this.id}'`),f)z.Logger.log(`[LiteralValueState.hydrateAncestors] Setting parent reference '${f.id}' for entity with id '${this.id}'`),this.setParent(f,null),i.push(f);else throw z.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=X(this.initialData.standaloneParent),f=this.project.get(e);if(z.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating standalone parent reference '${e}' for entity with id '${this.id}'`),f)z.Logger.log(`[LiteralValueState.hydrateAncestors] Setting standalone parent reference '${f.id}' for entity with id '${this.id}'`),this.setStandaloneParent(f,null);else throw z.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 z.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=X(e),h=this.project.get(f);h&&this.valueAsTypeList.push(h)});else if(this.initialData.valueAsTypeSingle){const e=X(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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return z.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,this.captureVersion(),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 q(this.project,N.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 q(this.project,N.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 q(this.project,N.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 q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.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):(z.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 q(this.project,N.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=X(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(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Wr(this,i,r),c=Hr(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=Se,...r){return await pi.repository.APILoad(this.id,...r),this}async APICreate(i=Se,...r){return await pi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Se,...r){return await pi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Se,...r){return await pi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Se,...r){return await pi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Se,r,...a){return await pi.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return z.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):Zg.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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return z.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:g}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...g)}),!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 q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return z.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=nt){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||Xr(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:N.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=nt){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+N.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=nt){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=nt){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=I_e(this),{success:!0}}async validateAsync(i={}){const r=z.YieldTracker.from(i);return this.errors=await g_e(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors]}async getErrorsAsync(i={}){const r=z.YieldTracker.from(i),a=[...this.errors];return await r.tick(),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new q(this.project,N.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){const e=Br(r,this),f=this.toJSON(),h=a||N.UUID.uuid();f.id=h,f.version=N.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=Yi(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==null||i.attemptAutoclose(w.CloneEntity,this.id),m}merge(i,r=this.project.addChangeSet(new q(this.project,N.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(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.LiteralValue),R(pi,"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(pi,"USER_MANAGED_STANDALONE_PARENT_TYPES",[...qg]),R(pi,"PARENT_TYPES",[...pi.USER_MANAGED_PARENT_TYPES]),R(pi,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),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]),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",["valueAsTypeSingle","valueAsTypeList"]),R(pi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(pi,"UPSTREAM_PROPERTIES",[...pi.MUTABLE_UPSTREAM_PROPERTIES,...pi.INMUTABLE_UPSTREAM_PROPERTIES]),R(pi,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),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 Nr=pi;function Bf(l){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const i=new Uint8Array(l);return crypto.getRandomValues(i),i}const{randomBytes:p}=require("crypto");return p(l)}function D_e(l,p){const i=p-l+1,a=zR()*i;return Math.floor(a)+l}function w_e(){const l=Bf(4);return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0}function zR(){return w_e()/2**32}function Tx(l){const p=Bf(l);return Array.from(p).map(i=>i.toString(16).padStart(2,"0")).join("")}const c_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function vx(l){let p="";const i=Bf(l);for(let r=0;r<l;r++)p+=c_[i[r]%c_.length];return p}function C_e(l){const p=Bf(l);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 Ex(l){return vx(l)}function bx(l,p=c_){let i="";const r=Bf(l);for(let a=0;a<l;a++)i+=p[r[a]%p.length];return i}function np(){const l=Bf(16);l[6]=l[6]&15|64,l[8]=l[8]&63|128;const p=Array.from(l).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 O_e(){return bx(6)}function __e(){return Tx(32)}const jAi=63,UAi=/^[a-z][a-z0-9-]*[a-z0-9]$/;function kAi(l){return l.length>=1&&l.length<=jAi&&UAi.test(l)&&!l.includes("--")}function*FAi(){yield"";const l="abcdefghijklmnopqrstuvwxyz";for(let p=1;;p++){const i=new Array(p).fill(0);let r=!1;for(;!r;){yield i.map(a=>l[a]).join("");for(let a=p-1;a>=0&&(i[a]++,!(i[a]<l.length));a--)i[a]=0,a===0&&(r=!0)}}}function KAi(l,p){const i=new Set(l.map(a=>a.toLowerCase())),r=p>0?"secondary-db":"main";for(const a of FAi()){const c=a?`${r}-${a}`:r;if(kAi(c)&&!i.has(c))return c}throw new Error("Unable to generate identifier")}function V_e(l,p){switch(l.id){case re["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=l.project.entities.filter(h=>!!h.implements.find(m=>m.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),r=i.find(h=>{const m=h.properties.find(g=>g.implements.find(_=>_.id===re["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(g=>g.id===re["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:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:ye.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:m==null?void 0:m.toReference()},g=Ae(b,l.project);return g.setParent(m,p),g.initChildren(p),p==null||p.add(g,W.Added),g.addSelfToProject(p),{newEntities:[g]}}return{newEntities:[]}}else if(r)return{newEntities:[]};const a=l.project.get(re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),c=YR(a,"Main database",p);if(c.errors.length>0)return{newEntities:[]};const e=c.properties.find(h=>h.implements.find(m=>m.id===re["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:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:ye.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},m=Ae(h,l.project);m.setParent(e,p),m.initChildren(p),p==null||p.add(m,W.Added),m.addSelfToProject(p)}return{newEntities:[c]}}}return{newEntities:[]}}function P_e(l,p){const i=[],r=[],a=[],c=[];return l.implements.filter(f=>f.type===d.BuiltInBaseEntity).forEach(f=>{var h,m,E,b,g;switch(f.id){case re["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const _=l.project.entities.filter(G=>G.implements.find(H=>H.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let $=_.find(G=>!!G.properties.find(H=>{var ie;return H.implements.find(ee=>ee.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((ie=H.getDefaultValue())==null?void 0:ie.value)===!0}));if(!$&&_.length)$=_[0];else if(!$&&!_.length){$=l.project.getBuiltIn(re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",p);const H=$.properties.find(ie=>ie.implements.find(ee=>ee.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));(h=H==null?void 0:H.defaultValue)==null||h.metaSync({value:!0},p),r.push($)}const L=l.properties.find(G=>G.implements.find(H=>H.id===re["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id));if(L&&!(L!=null&&L.defaultValue)){const G={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:N.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:ye.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:($==null?void 0:$.toJSON())||null,valueAsTypeList:null,parent:L==null?void 0:L.toReference()},H=Ae(G,l.project);H.hydrateAncestors(),H.setParent(L,p),H.addSelfToProject(p),p==null||p.add(H,W.Added),H.initChildren(p),(L==null?void 0:L.defaultValue).setValueAsTypeSingle($||null,p),r.push(H);return}else L!=null&&L.defaultValue&&!(L!=null&&L.defaultValue.valueAsTypeSingle)&&(L==null||L.defaultValue.setValueAsTypeSingle($||null,p));const j=l.properties.find(G=>G.implements.find(H=>H.id===re["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.primaryKey.id));if(!j)throw new Error(`[handleAfterEntityImplementationSideEffects] Primary key property not found for implemented base entity ${re["built-in-base-entity"]}`);if(!j.dataType){const G=mr.new(p);G.parent=j.toReference();const H=Ae(G,l.project);H.hydrateAncestors(),H.setParent(j,p),H.addSelfToProject(p),p==null||p.add(H,W.Added),H.initChildren(p)}const k=l.project.getBuiltIn(re["primitive-entity"].number.id);(m=j.dataType)==null||m.setEntity(k,p);return}case re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id:{const _=l.project.entities.filter(ie=>ie.implements.find(ee=>ee.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)&&ie.id!==l.id),$=_.map(ie=>{var ae;const ee=ie.properties.find(de=>de.implements.find(ce=>ce.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));return(ae=ee==null?void 0:ee.getDefaultValue())==null?void 0:ae.value}).filter(ie=>!!ie),L=l.properties.find(ie=>ie.implements.find(ee=>ee.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));if(!_.find(ie=>!!ie.properties.find(ee=>{var ue;return ee.implements.find(ae=>ae.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((ue=ee.getDefaultValue())==null?void 0:ue.value)===!0}))){const ie=l.properties.find(ee=>ee.implements.find(ue=>ue.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));if(!ie)throw new Error("Default boolean property not found for relational database entity with id: "+l.id);if(!(ie!=null&&ie.defaultValue)){const ee=Nr.new(p);ee.parent=ie.toReference();const ue=Ae(ee,l.project);ue.hydrateAncestors(),ue.setParent(ie,p),ue.addSelfToProject(p),p==null||p.add(ue,W.Added),ue.initChildren(p)}(E=ie==null?void 0:ie.defaultValue)==null||E.metaSync({value:!0},p)}if(!L)throw new Error("Identifier property not found for relational database entity with id: "+l.id);if(!(L!=null&&L.defaultValue)){const ie=Nr.new(p);ie.parent=L.toReference();const ee=Ae(ie,l.project);ee.hydrateAncestors(),ee.setParent(L,p),ee.addSelfToProject(p),ee.initChildren(p),p==null||p.add(ee,W.Added)}const k=KAi($,_.length);(b=L.defaultValue)==null||b.metaSync({value:k},p);const G=l.properties.find(ie=>ie.implements.find(ee=>ee.id===re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.password.id));if(!G)throw new Error(`[handleAfterEntityImplementationSideEffects] Password property not found for implemented base entity ${re["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id} with id ${l.id}`);if(!G.defaultValue){const ie=Nr.new(p);ie.parent=G.toReference();const ee=Ae(ie,l.project);ee.hydrateAncestors(),ee.setParent(G,p),ee.addSelfToProject(p),ee.initChildren(p),p==null||p.add(ee,W.Added),r.push(ee)}const H=Ex(24);(g=G.defaultValue)==null||g.metaSync({value:H},p);return}case re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id:{const _=l.properties.find(k=>k.implements.find(G=>G.id===re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.time.id));if(!_)throw new Error(`[handleAfterEntityImplementationSideEffects] Time property not found for implemented base entity ${re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${l.id}`);let $=_.defaultValue||null;if(!$){const k=Nr.new(p);k.parent=_.toReference(),k.name=ye.Date,k.id=N.UUID.uuid(),$=Ae(k,l.project),$.hydrateAncestors(),$.setParent(_,p),$.addSelfToProject(p),$.initChildren(p),p==null||p.add($,W.Added)}$.metaSync({value:new Date().toISOString()},p),$.metaSync({editable:!1,deletable:!1},p),_.metaSync({editable:!1,deletable:!1},p);const L=l.properties.find(k=>k.implements.find(G=>G.id===re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id));if(!L)throw new Error(`[handleAfterEntityImplementationSideEffects] Definition property not found for implemented base entity ${re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${l.id}`);let j=L.defaultValue||null;if(!j){const k=Nr.new(p);k.name=ye.EntityTemplate,k.parent=L.toReference(),k.id=N.UUID.uuid(),j=Ae(k,l.project),j.hydrateAncestors(),j.setParent(L,p),j.addSelfToProject(p),j.initChildren(p),p==null||p.add(j,W.Added)}}}}),{self:l,updated:C(i),added:C(r),removed:C(a),affected:C(c)}}function YR(l,p,i,r){const a=r||N.UUID.uuid(),c=Ds.new(i);c.id=a,c.name=p,c.static=l.static,c.implements=[l.toJSON()],c.parent=l.project.toReference(),c.static=l.static,V_e(l,i);const e=Ae(c,l.project);return e.hydrateAncestors(),i==null||i.add(e,W.Added),e.addSelfToProject(i),e.initChildren(i),P_e(e,i),e.afterAllChildrenInitialized(i),e}function Ax(l,p){return p.entities.find(a=>{const c=a.properties,e=c.map(b=>b.name),f=l.every(b=>e.includes(b)),h=e.filter(b=>!l.includes(b)),m=c.every(b=>!h.includes(b.name)||!b.required);return f&&m})||null}function N_e(l,p,i,r=We.OrDataTypeGroup){const a=[],c=[],e=[],f=[],h=N.UUID.uuid(),m=mr.new(i);m.id=h,m.parent=p.toReference(),m.like=!0,m.parentRelationType=r;const E=Ae(m,l.project);return c.push(E),E.setParent(p,i),E.initChildren(i),i==null||i.add(E,W.Added),E.setEntity(l,i),E.addSelfToProject(i),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:E}}function gx(l,p,i,r,a){var m,E,b,g,_,$,L,j;const c=[],e=[],f=[],h=[];switch(typeof l){case"string":let k=!1;const G=new Date(l);if(G instanceof Date&&!isNaN(G.valueOf())&&(k=!0),k){const H=p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Date].id);p.setEntity(H,r);break}else{const H=p.project.getBuiltIn(re[d.PrimitiveEntity][ye.String].id);p.setEntity(H,r);break}case"number":p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Number].id),r);break;case"boolean":p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Boolean].id),r);break;case"object":if(l===null){p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Null].id),r);break}else if(Array.isArray(l))if(p.metaSync({isList:!0},r),l.length>0){const H=l.slice(0,5).filter(ee=>ee!==void 0);if(H.every(ee=>typeof ee==typeof H[0])&&(typeof H[0]!="object"||H[0]===null))switch(typeof H[0]){case"string":p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.String].id),r);break;case"number":p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Number].id),r);break;case"boolean":p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Boolean].id),r);break;case"object":p.setEntity(p.project.getBuiltIn(re[d.PrimitiveEntity][ye.Null].id),r);break}else{const ee=[];let ue=!1;H.forEach(de=>{var ce,ne,le,Q;if(Array.isArray(de)&&(ue=!0),typeof de=="object"&&!Array.isArray(de)&&de!==null){const oe=UA(de,p.project,{...i,id:N.UUID.uuid()},r,a);oe.hasCreated&&ee.push((ce=oe.changeSet)==null?void 0:ce.self),c.push(...(ne=oe.changeSet)==null?void 0:ne.updated),e.push(...(le=oe.changeSet)==null?void 0:le.added),f.push(...(Q=oe.changeSet)==null?void 0:Q.removed)}});const ae=C(ee);if(!ae.length&&!ue){H.forEach(de=>{const ce=mr.new(r);ce.parentRelationType=We.OrDataTypeGroup,ce.parent=p.toReference();const ne=Ae(ce,p.project);switch(ne.setParent(p,r),ne.initChildren(r),r==null||r.add(ne,W.Added),ne.addSelfToProject(r),typeof de){case"string":ne.setEntity(ne.project.getBuiltIn(re[d.PrimitiveEntity][ye.String].id),r);break;case"number":ne.setEntity(ne.project.getBuiltIn(re[d.PrimitiveEntity][ye.Number].id),r);break;case"boolean":ne.setEntity(ne.project.getBuiltIn(re[d.PrimitiveEntity][ye.Boolean].id),r);break;case"object":ne.setEntity(ne.project.getBuiltIn(re[d.PrimitiveEntity][ye.Null].id),r);break}});break}else ae.length===1&&!ue?p.setEntity(ae[0],r):H.forEach(de=>{if(typeof de=="object"&&!Array.isArray(de)&&de!==null){const ce=Ax(Object.keys(de),p.project);if(ce){const ne=N_e(ce||ae[0],p,r,We.OrDataTypeGroup);c.push(...ne.updated),e.push(...ne.added),f.push(...ne.removed)}}else{const ce=mr.new(r);ce.parentRelationType=We.OrDataTypeGroup,ce.parent=p.toReference();const ne=Ae(ce,p.project);ne.setParent(p,r),ne.initChildren(r),r==null||r.add(ne,W.Added),ne.addSelfToProject(r);const le=gx(de,ne,{...i,id:N.UUID.uuid()},r,a);c.push(...le.updated),e.push(...le.added),f.push(...le.removed)}})}}else{const H=UA(l[0],p.project,{...i},r,a);p.setEntity((m=H.changeSet)==null?void 0:m.self,r),c.push(...(E=H.changeSet)==null?void 0:E.updated),e.push(...(b=H.changeSet)==null?void 0:b.added),f.push(...(g=H.changeSet)==null?void 0:g.removed);break}else{const H=UA(l,p.project,{...i},r,a);p.setEntity((_=H.changeSet)==null?void 0:_.self,r),c.push(...($=H.changeSet)==null?void 0:$.updated),e.push(...(L=H.changeSet)==null?void 0:L.added),f.push(...(j=H.changeSet)==null?void 0:j.removed);break}}return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:p}}function UA(l,p,i,r,a){const c=[],e=[],f=[],h=[],m=Object.keys(l),E=Ax(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||N.UUID.uuid(),version:N.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:N.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()},$=Ae(_,p);return $.setParent(p,r),$.initChildren(r),r==null||r.add($,W.Added),$.addSelfToProject(r),e.push($),m.forEach((L,j)=>{const k=N.UUID.uuid(),G=ts.new(r);G.id=k,G.name=L,G.codeName=L,G.parent=$.toReference(),G.index=j,G.required=!0,G.interactive=!0;const H=Ae(G,p);H.setParent($,r),H.initChildren(r),r==null||r.add(H,W.Added),H.addSelfToProject(r),e.push(H);const ie=l[L],ee=N.UUID.uuid(),ue=mr.new(r);ue.id=ee,ue.parent=H.toReference(),ue.like=!0,ue.isList=!1;const ae=Ae(ue,p);ae.setParent(H,r),ae.initChildren(r),r==null||r.add(ae,W.Added),ae.addSelfToProject(r),e.push(ae);const de=gx(ie,ae,{...i,name:L,id:N.UUID.uuid()},r,a||$);c.push(...de.updated),e.push(...de.added),f.push(...de.removed)}),{hasCreated:!0,changeSet:{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:$}}}function $d(l,p,i,r){const a=[];return!l.length||!p.length?{errors:a,overlap:!1}:(l.length>p.length?l.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(g=>g.id===b.id)):((m=h.implements)==null?void 0:m.id)===((E=c.implements)==null?void 0:E.id)});if(e){const h=new Si({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:me.Error,code:r,entity:c,firstRelationship:e});a.push(h)}if(f){const h=new Si({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:me.Error,code:i,entity:c,firstRelationship:f});a.push(h)}}):p.forEach(c=>{var h;const e=l.find(m=>m.name===c.name),f=l.find(m=>{var E,b;return m.implements&&Array.isArray(m.implements)?m.implements.some(g=>!!c.implements.find(_=>_.id===g.id)):((E=m.implements)==null?void 0:E.id)===((b=c.implements)==null?void 0:b.id)});if(e){const m=new Si({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:me.Error,code:r,entity:e,firstRelationship:c});a.push(m)}if(f){const m=new Si({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:me.Error,code:i,entity:f,firstRelationship:c});a.push(m)}}),{errors:a,overlap:!!a.length})}function SAi(l,p){return l.abstract||(l.properties.forEach(r=>{r.abstract||r.metaSync({abstract:!0},p)}),Object.values(l.detachedDependents).forEach(r=>{r.field===Z$.EntityField&&r.entity.remove({ignoreUpstream:!1},p)}),l.metaSync({abstract:!0},p)),l}function qAi(l,p){return l.abstract&&(l.properties.forEach(r=>{r.abstract&&r.metaSync({abstract:!1},p)}),Object.values(l.detachedDependents).forEach(r=>{(r.field===Vg.Implements||r.field===Vg.Extends)&&r.entity.onDetachedDependencyRemoved(l,r.field,p)}),l.metaSync({abstract:!1},p)),l}function ZAi(l,p){return l.static||(l.properties.forEach(r=>{r.static||r.metaSync({static:!0},p)}),l.metaSync({static:!0},p)),l}function HAi(l,p){return l.static&&l.metaSync({static:!1},p),l}const xT=class xT extends cx{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=Ae(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=Ae(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=Ae(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.initialData.allPropertiesImplement){const a=Ae(this.initialData.allPropertiesImplement,this.project);a.setParent(this,null),a.initChildren(null),this.allPropertiesImplement=a}if(this.initialData.additionalPropertiesDataType){const a=Ae(this.initialData.additionalPropertiesDataType,this.project);a.setParent(this,null),a.initChildren(null),this.additionalPropertiesDataType=a}this.initialData.extends&&(this.extends=Ae(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(g=>g.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=Se,...r){return await xT.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=nt){return{id:this.id+"--"+N.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=nt){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=nt){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=BAi(this),{success:!0}}async validateAsync(i={}){const r=z.YieldTracker.from(i);return this.errors=await LAi(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=z.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 q(this.project,N.sessionAuthor,B().toISOString(),null,!0,"implement-built-in-base-entity")),a){const c=YR(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 xT&&i.push(...this.extends.getAllInteractiveMethods())}return C(i)}};R(xT,"repository",{APILoad:async(i,...r)=>null});let qd=xT;class x_e extends qd{constructor(i){super(bn,i);R(this,"initialData");R(this,"id",Ie.PERSISTED_ENTITY);R(this,"version","1");R(this,"name",Ie.PERSISTED_ENTITY);R(this,"description",bn.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",bn.abstract);R(this,"static",bn.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=bn,this.project=i,this.id=bn.id,this.version=bn.version,this.name=bn.name,this.static=bn.static,this.abstract=bn.abstract,this.properties=this.initialData.properties.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.methods=this.initialData.methods.map(r=>{const a=Ae(r,this.project);return a.parent=this,a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=Ae(r,this.project);return a.parent=this,a}),this.initialData.extends&&(this.extends=Ae(this.initialData.extends,this.project))}}var ya=(l=>(l.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",l.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",l.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",l))(ya||{});function Ix(l,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 Si({id:l.id+"--string-value-must-not-have-spaces",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value cannot contain spaces.`,severity:me.Error,code:"string-value-must-not-have-spaces",entity:l});i.push(a)}return{errors:i,override:r.replace(/\s/g,"-")}}function $_e(l,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 Si({id:l.id+"--string-value-must-not-have-spaces",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:me.Error,code:"string-value-must-not-have-spaces",entity:l});i.push(a)}if(r.includes("-")){const a=new Si({id:l.id+"--string-value-must-not-have-dashes",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:me.Error,code:"string-value-must-not-have-dashes",entity:l});i.push(a)}return{errors:i,override:r.replace(/\s|-/g,"_")}}var id=(l=>(l.StatusCodeMustBeNumber="status-code-must-be-number",l.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",l))(id||{});function L_e(l,p){const i=[];if(typeof p!="number"){const r=new Si({id:l.id+"--status-code-must-be-number",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value must be a number.`,severity:me.Error,code:"status-code-must-be-number",entity:l});return i.push(r),{errors:i,override:p}}if(p<100){const r=new Si({id:l.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:me.Error,code:"status-code-must-be-between-100-and-599",entity:l});i.push(r)}if(p>599){const r=new Si({id:l.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:me.Error,code:"status-code-must-be-between-100-and-599",entity:l});i.push(r)}return{errors:i,override:p}}class B_e extends qd{constructor(i){var e,f;super(Za,i);R(this,"initialData");R(this,"id",Ie.PERSISTED_ENTITY);R(this,"version","1");R(this,"name",Ie.PERSISTED_ENTITY);R(this,"description",Za.description);R(this,"type",d.BuiltInBaseEntity);R(this,"abstract",Za.abstract);R(this,"static",Za.static);R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=Za,this.project=i,this.id=Za.id,this.version=Za.version,this.name=Za.name,this.static=Za.static,this.abstract=Za.abstract,this.properties=this.initialData.properties.map(h=>{const m=Ae(h,this.project);return m.setParent(this,null),m.initChildren(null),m}),this.methods=this.initialData.methods.map(h=>{const m=Ae(h,this.project);return m.parent=this,m}),this.abstractMethods=this.initialData.abstractMethods.map(h=>{const m=Ae(h,this.project);return m.parent=this,m}),this.initialData.extends&&(this.extends=Ae(this.initialData.extends,this.project));const r=this.properties.find(h=>h.id===re["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=(h,m)=>{const E=Ix(h,m);if(h.project.entities.filter(g=>Wi(g,Ie.HTTP_ENDPOINT)&&g.id!==h.parent.id).map(g=>{const _=g.properties.find(j=>j.implements.find(k=>k.id===re["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(!_)throw new Error("Path property not found in endpoint entity "+g.name+" ("+g.id+")");const $=_.getDefaultValue();return($==null?void 0:$.value)||""}).includes(m)){const g=new Si({id:h.id+"--"+ya.MustBeUniqueAmongSameEntities,message:`Entity of type ${h.type} with id "${h.id}" has an invalid value "${m}". The value must be unique among all endpoint paths.`,severity:me.Error,code:ya.MustBeUniqueAmongSameEntities,entity:h});E.errors.push(g)}return E};const a=this.abstractMethods.find(h=>h.id===re["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!a)throw new Error("Handler method not found in endpoint entity");const c=(((f=(e=a.dataType)==null?void 0:e.entity)==null?void 0:f.properties)||[]).find(h=>h.id===re["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.dataType.entity.properties.statusCode.id);if(!c)throw new Error("Status code output not found in handler method");c._codeNativeValueValidation=(h,m)=>L_e(h,m)}}class M_e extends ki{constructor(i){super(So,i);R(this,"id",Hi.Parallel);R(this,"name",Hi.Parallel);R(this,"description","Programmatically execute a list of actions one after the other");R(this,"version","1");R(this,"autoexecutable",!0);R(this,"type",d.ActionDescriptor);R(this,"inputs",[]);R(this,"dataType",null);R(this,"error",null);R(this,"project");this.project=i,this.inputs=So.inputs.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.dataType=Ae(So.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=So.error?Ae(So.error,this.project):null}}class G_e extends ki{constructor(i){super(bs,i);R(this,"id",bs.id);R(this,"name",bs.name);R(this,"description",bs.description);R(this,"version",bs.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=bs.inputs.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.dataType=Ae(bs.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=bs.error?Ae(bs.error,this.project):null}}class j_e extends ki{constructor(i){super(Ju,i);R(this,"id",Hi.Sequential);R(this,"name",Hi.Sequential);R(this,"description","Programmatically execute a list of actions one after the other");R(this,"version","1");R(this,"autoexecutable",!0);R(this,"type",d.ActionDescriptor);R(this,"inputs",[]);R(this,"dataType",null);R(this,"error",null);R(this,"project");this.project=i,this.inputs=Ju.inputs.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(null),a}),this.dataType=Ae(Ju.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=Ju.error?Ae(Ju.error,this.project):null}}var Ya=(l=>(l.UUIDMustBeString="uuid-must-be-string",l.UUIDMustBeValidFormat="uuid-must-be-valid-format",l.UUIDMustNotContainSpaces="uuid-must-not-contain-spaces",l))(Ya||{});function WAi(l,p){const i=[];if(typeof p!="string"){const a=new Si({id:l.id+"--uuid-must-be-string",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value must be text.`,severity:me.Error,code:"uuid-must-be-string",entity:l});return i.push(a),{errors:i,override:p}}const r=Ix(l,p);if(r.errors.length>0)return i.push(...r.errors),{errors:i,override:p};if(!px(p)){const a=new Si({id:l.id+"--uuid-must-be-valid-format",message:`Entity of type ${l.type} with id "${l.id}" has an invalid value "${p}". The value must be a valid UUID format. Eg: "123e4567-e89b-12d3-a456-426614174000".`,severity:me.Error,code:"uuid-must-be-valid-format",entity:l});i.push(a)}return{errors:i,override:p}}var Me=(l=>(l.Inherited="inherited",l.DefaultValue="default-value",l.Missing="missing",l.Empty="empty",l.AutoCalculated="auto-calculated",l.QueuedAutocalculation="queued-autocalculation",l.External="external",l.Testing="testing",l.ExecutionResult="execution-result",l))(Me||{});const U_e={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function hT(l,p){return{...U_e,id:l,project:p}}class mT{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=rVe(e,f,this.project);h?i[a]=h:delete p[a]}catch(f){z.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=Yi(i,this.project);else{const c={id:N.UUID.uuid(),version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.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:Wc(p.getDataType(null))};a=Yi(c,this.project)}a.standalone=!0,a.initialData.standaloneParent||z.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 gr(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)}function Rx(l){if(Array.isArray(l))return l.map(h=>typeof h=="number"?h:e(h)?Number(h):String(h));const p=[];let i=0,r="",a=!1,c=null;for(;i<l.length;){const h=l[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<l.length){r+=l[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 JR(l,p,i){if(l==null)return i;const r=Rx(p);let a=l;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 zAi=new Set(["__proto__","prototype","constructor"]);function k_e(l){return typeof l=="string"&&zAi.has(l)}function YAi(l,p,i,r){const{createMissing:a=!0,coerce:c=!0}=r??{};if(l==null||typeof l!="object")throw new TypeError("set(...) expects a non-null object as target.");const e=Rx(p);if(e.length===0)throw new Error("set(...) path must not be empty.");let f=l;for(let h=0;h<e.length;h++){const m=e[h];if(k_e(m))throw new Error(`Refusing to set unsafe key "${String(m)}" on object.`);const E=h===e.length-1,g=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,l}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]=g?[]:{}}else{const $=f[m],L=$!==null&&typeof $=="object",j=Array.isArray($);if(g){if(!j){if(!c)throw new Error(`set(...) expected an array at "${String(m)}" but found non-array (coerce=false).`);f[m]=[]}}else if(!L||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 l}function Dx(l,p,i,r){const a=Rx(p);if(a.length===0)return l;function c(e,f){const h=a[f],m=f===a.length-1;if(r==="strict-set"||r==="strict-delete"){if(k_e(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 g=typeof a[f+1]=="number",_=c(g?[]:{},f+1);return E[h]=_,E}return E[h]=c(b,f+1),E}if(l==null&&r==="safe-set"){const e=typeof a[0]=="number";return c(e?[]:{},0)}return c(l,0)}const AU=Symbol("missing"),JAi=l=>l!=null&&typeof l=="object";function XR(l,p){if(typeof l!="string")throw new TypeError(`${p} expects the key to be a string.`);return l}function Em(l,p){if(typeof l!="string"&&!Array.isArray(l))throw new TypeError(`${p} expects the path to be string or array.`);return l}function Mf(l,p){if(!gr(l))throw new TypeError(`${p} expects the first argument to be an object.`);return l??{}}function F_e(l,p){const i=XR(p,"ReadKey");return(l??{})[i]}function K_e(l,p,i){const r=XR(p,"WriteKey");if(l&&typeof l=="object"){const a=Array.isArray(l)?[...l]:{...l};return a[r]=i,a}return{[r]:i}}function S_e(l,p){if(!l||typeof l!="object")return{};const i=String(p),{[i]:r,...a}=l;return a}function q_e(l,p,i){const r=Mf(l,"ReadNestedKey"),a=Em(p,"ReadNestedKey");return JR(r,a,i)}function Z_e(l,p,i){const r=Mf(l,"WriteNestedKey"),a=Em(p,"WriteNestedKey");return Dx(r,a,i,"strict-set")}function H_e(l,p,i){const r=Mf(l,"WriteSafeNestedKeyRecursively"),a=Em(p,"WriteSafeNestedKeyRecursively");return Dx(r,a,i,"safe-set")}function W_e(l,p){const i=Mf(l,"DeleteNestedKey"),r=Em(p,"DeleteNestedKey");return Dx(i,r,null,"strict-delete")}function z_e(l,p){const i=XR(p,"HasKey"),r=l;return r!=null&&JAi(r)&&Object.prototype.hasOwnProperty.call(r,i)}function Y_e(l,p,i){const r=XR(p,"KeyValueEquals");return l==null||typeof l!="object"?!1:l[r]===i}function J_e(l,p){const i=l,r=Em(p,"HasNestedKey");return JR(i,r,AU)!==AU}function X_e(l,p,i){const r=Em(p,"NestedKeyValueEquals");return JR(l,r)===i}function Q_e(...l){const p={};for(let i=0;i<l.length;i++){const r=l[i];if(r!=null){if(!gr(r))throw new TypeError("MergeObjects expects every argument to be an object (or null/undefined).");Object.assign(p,r)}}return p}function eVe(l){const p=Mf(l,"ObjectKeys");return Object.keys(p)}function tVe(l){const p=Mf(l,"ObjectValues");return Object.values(p)}function iVe(l){const p=Mf(l,"ObjectEntries");return Object.entries(p)}function XAi(l){return{execution:null,project:l,localTestValues:hT("local-test-values",l),resolvedValues:hT("resolved-values",l),persistedExecutionResults:hT("persisted-execution-results",l),lastExecutionResults:hT("last-execution-results",l),getValueTypePreference:()=>null,setValueTypePreference:()=>{}}}function wu(l,p,i,r){var f;let a;if(((f=l==null?void 0:l.entity)==null?void 0:f.type)===d.PrimitiveEntity)switch(l.entity.name){case ye.EntityTemplate:a=ye.EntityTemplate;break;case ye.String:a=ye.String;break;case ye.Number:a=ye.Number;break;case ye.Boolean:a=ye.Boolean;break;case ye.Null:a=ye.Null;break;case ye.Enum:a=ye.Enum;break;case ye.KeyValue:a=ye.KeyValue;break;case ye.Untyped:a=ye.Untyped;break;case ye.KeyValue:a=ye.KeyValue;break;case ye.Date:a=ye.Date;break;case ye.UUID:a=ye.UUID;break;case ye.File:a=ye.File;break;case ye.Void:a=ye.Void;break;case ye.ActionDescriptor:a=ye.ActionDescriptor;break;case ye.Bytes:a=ye.Bytes;break;default:throw new Error(`Primitive type ${se(l.entity,i)} is not supported`)}else a=ye.Untyped;const c=Nr.new(r);c.name=a,c.parent=p.toReference();const e=Ae(c,i);return e.hydrateAncestors(),r==null||r.add(e,W.Added),e.addSelfToProject(r),e.initChildren(r),e}function Jo(l,p,i=new Set){var r,a,c;if(i.has(l.id))return[];if(i.add(l.id),_t.includes(l.type)){const e=yr(l);return C([e,...[e].flatMap(f=>Jo(f,p,i))])}else if(l.type===d.OutputMap){if(_t.includes(l.parent.type)&&((r=l.declaration)==null?void 0:r.type)===d.Property&&l.declaration.static)return C([l,l.declaration,...[l,l.declaration].flatMap(e=>Jo(e,p,i))])}else if(l.type===d.InputMap&&_t.includes(l.parent.type)&&((a=l.declaration)==null?void 0:a.type)===d.Property&&(c=l.declaration)!=null&&c.static)return C([l.declaration,...[l.declaration].flatMap(e=>Jo(e,p,i))]);return[l]}function rVe(l,p,i){return l}function bm(l,p,i=!1){const r=l.readsValue;let a=null;const c=lf(r,p,i);if(c){const e={sources:[c],target:l};a={value:c.value,valueOwner:l,type:Me.Inherited,inheritanceLink:e}}return a}function xt(l,p,i){var f;if(!p)return null;let r;if(((f=l==null?void 0:l.entity)==null?void 0:f.type)===d.PrimitiveEntity)switch(l.entity.name){case ye.EntityTemplate:r=ye.EntityTemplate;break;case ye.String:r=ye.String;break;case ye.Number:r=ye.Number;break;case ye.Boolean:r=ye.Boolean;break;case ye.Null:r=ye.Null;break;case ye.Enum:r=ye.Enum;break;case ye.KeyValue:r=ye.KeyValue;break;case ye.Untyped:r=ye.Untyped;break;case ye.KeyValue:r=ye.KeyValue;break;case ye.Date:r=ye.Date;break;case ye.UUID:r=ye.UUID;break;case ye.File:r=ye.File;break;case ye.Void:r=ye.Void;break;case ye.ActionDescriptor:r=ye.ActionDescriptor;break;case ye.Bytes:r=ye.Bytes;break;default:throw new Error(`Primitive type ${se(l.entity,i)} is not supported`)}else r=ye.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 nVe(l,p,i=!1){var c,e;if(p.execution&&p.execution.hasEntity(l)&&!i){const f=(c=p.lastExecutionResults)==null?void 0:c.readValue(l.id);if(f)return{value:f,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=(e=p.localTestValues)==null?void 0:e.readValue(l.id),a=p.getValueTypePreference(l.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:l,type:Me.Testing,inheritanceLink:null}:{value:null,valueOwner:l,type:Me.QueuedAutocalculation,inheritanceLink:null}}function kA(l,p,i,r=!1){var e,f;const a={...l},c=p.type===d.VariableDeclaration?p.inputs:Dt.includes(p.type)?p.outputs:[];if(!c||c.length===0)return a;for(const h of c){if(!xE(h))continue;const m=BT(h,i,r);if(m&&m.value){const E=se(h,i.project),b=h.codeName||((e=h.declaration)==null?void 0:e.codeName)||ir(E);a[b]=Pn((m==null?void 0:m.value)||null)?a[b]:(f=m==null?void 0:m.value)==null?void 0:f.value}}return a}function TT(l,p,i,r=!1){var e,f;const a={...l},c=p.inputs;if(!c)return a;for(const h of c){if(!xE(h))continue;const m=rE(h,i,r);if(m&&m.value){const E=se(h,i.project),b=h.codeName||((e=h.declaration)==null?void 0:e.codeName)||ir(E);a[b]=(f=m==null?void 0:m.value)==null?void 0:f.value}}return a}function aVe(l,p,i=!1){var E,b,g,_,$,L,j,k;let r={};if(((b=(E=l.getDataType(null))==null?void 0:E.entity)==null?void 0:b.type)===d.DefinitionEntity&&(r={...r,...((g=l.getDataType(null))==null?void 0:g.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(l)&&!i){const G=(_=p.lastExecutionResults)==null?void 0:_.readValue(l.id);if(G){if(gr(G.value)){const ie={...r,...G.value},ee={...TT(ie,l,p,i)};G.metaSync({value:ee},null)}return{value:G,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}}const a=!!(($=p.execution)!=null&&$.entities.length),c=(L=p.execution)==null?void 0:L.hasEntity(l),e=l.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(l,p,i),f&&f.value&&gr(f.value.value))){const ie={...r,...f.value.value},ee={...TT(ie,l,p,i)};f.value.metaSync({value:ee},null)}}const h=l.defaultValue,m=p.getValueTypePreference(l.id);if(!f&&h){const G=h;if(G&&G.value===null&&G.autogeneration){const H=J1(G);if(G.metaSync({value:H},null),gr(H)){const ie={...TT(H,l,p,i)};G.metaSync({value:ie},null)}}(i||m===null||m!==Me.Testing)&&(f={value:G,valueOwner:l,type:Pn(G)?l.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=(k=p.localTestValues)==null?void 0:k.readValue(l.id);if(G){if(gr(G.value)){const H={...r,...G.value},ie={...TT(H,l,p,i)};G.metaSync({value:ie},null)}return{value:G,valueOwner:l,type:Me.Testing,inheritanceLink:null}}}return Pn((f==null?void 0:f.value)||null)?{value:null,valueOwner:l,type:l.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function wx(l,p,i=!1){var e,f,h,m,E,b,g,_,$;let r={};if(((f=(e=l.getDataType(null))==null?void 0:e.entity)==null?void 0:f.type)===d.DefinitionEntity&&(r={...r,...((h=l.getDataType(null))==null?void 0:h.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(l)&&!i){const L=(m=p.lastExecutionResults)==null?void 0:m.readValue(l.id);if(L){if(gr(L.value)){const k={...r,...L.value},G=kA(k,l,p,i);L==null||L.metaSync({value:G},null)}return{value:L,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}}const a=(E=p.localTestValues)==null?void 0:E.readValue(l.id),c=p.getValueTypePreference(l.id);if(a&&!i&&(c===null||c!==Me.DefaultValue)){if(gr(a.value)){const j={...r,...a.value},k=kA(j,l,p,i);a.metaSync({value:k},null)}return{value:a,valueOwner:l,type:Me.Testing,inheritanceLink:null}}if((b=l.getDataType(null))!=null&&b.entity&&((_=(g=l.getDataType(null))==null?void 0:g.entity)==null?void 0:_.type)===d.DefinitionEntity&&(($=l.getDataType(null))!=null&&$.isObject())){const L=xt(l.dataType,l,p.project),j=kA(r,l,p,i);return L==null||L.metaSync({value:j},null),{value:L,valueOwner:l,type:Me.DefaultValue,inheritanceLink:null}}return null}function iE(l,p,i=!1){var E,b,g,_,$;if((E=l.dataType)!=null&&E.isObject())return aVe(l,p,i);const r=ht(l),a=!!((b=p.execution)!=null&&b.entities.length),c=(g=p.execution)==null?void 0:g.hasEntity(r),e=l.readsValue;let f=null;if(e){const L=(_=p.execution)==null?void 0:_.hasEntity(e);(!a||a&&L&&c||a&&!L&&!c)&&(f=bm(l,p,i))}const h=l.defaultValue,m=p.getValueTypePreference(l.id);if(!f&&h){const L=h;if(L&&L.value===null&&L.autogeneration){const j=J1(L);L.metaSync({value:j},null)}(i||m===null||m!==Me.Testing)&&(f={value:L,valueOwner:l,type:Pn(L)?l.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 L=($=p.localTestValues)==null?void 0:$.readValue(l.id);if(L)return{value:L,valueOwner:l,type:Me.Testing,inheritanceLink:null}}return Pn((f==null?void 0:f.value)||null)?{value:null,valueOwner:l,type:l.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function Cx(l,p,i=!1){var e,f,h;if((e=l.dataType)!=null&&e.isObject())return wx(l,p);if(p.execution&&p.execution.hasEntity(l)&&!i){const m=(f=p.lastExecutionResults)==null?void 0:f.readValue(l.id);if(m)return{value:m,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=(h=p.localTestValues)==null?void 0:h.readValue(l.id),a=p.getValueTypePreference(l.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:l,type:Me.Testing,inheritanceLink:null}:iE(l,p,i)}function Ox(l,p,i=!1){var g,_,$,L;const r=!!((g=p.execution)!=null&&g.entities.length),a=(_=p.execution)==null?void 0:_.hasEntity(l);let c=null;const e=l.readsValue;if(e){const j=($=p.execution)==null?void 0:$.hasEntity(e);(!r||r&&j&&a||r&&!j&&!a)&&(c=bm(l,p,i))}const f=l.declaration;if(!c&&f){const j=iE(f,p);j&&j.value&&(c=j)}const h=p.getValueTypePreference(l.id);if(!c||(c.type===Me.DefaultValue||c.type===Me.External)&&!i||h===null||h!==Me.DefaultValue){const j=(L=p.localTestValues)==null?void 0:L.readValue(l.id);if(j)return{value:j,valueOwner:l,type:Me.Testing,inheritanceLink:null}}const m=ad(l),E=l.getDataType(null);return m&&a&&(!(c!=null&&c.value)||!_a(E)&&rd(c==null?void 0:c.value))?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:a&&!m&&Pn((c==null?void 0:c.value)||null)?{value:null,valueOwner:l,type:l.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:c||{value:null,valueOwner:l,type:Me.External,inheritanceLink:null}}function sVe(l,p,i=!1){return Cx(l.declaration,p,i)}function lVe(l,p,i=!1){var g,_,$,L;if(!i&&p.execution&&p.execution.hasEntity(l)){const j=(g=p.lastExecutionResults)==null?void 0:g.readValue(l.id);if(j)return{value:j,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=ht(l),a=l.parent.type===d.FunctionDeclaration&&l.parent.parent.type===d.Loop?l.parent:null,c=!!((_=p.execution)!=null&&_.hasEntity(r))||!!a&&!!(($=p.execution)!=null&&$.hasEntity(a));let e=null;const f=l.defaultValue,h=p.getValueTypePreference(l.id);if(f){const j=f||null;if(j&&j.value===null&&j.autogeneration){const k=J1(j);j.metaSync({value:k},null)}(i||h===null||h!==Me.Testing)&&(e={value:j,valueOwner:l,type:Pn(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=(L=p.localTestValues)==null?void 0:L.readValue(l.id),k=p.getValueTypePreference(l.id);if(j&&!i&&(k===null||k!==Me.DefaultValue))return{value:j,valueOwner:l,type:Me.Testing,inheritanceLink:null}}const m=ad(l),E=l.getDataType(null);let b=m&&c&&(!(e!=null&&e.value)||!_a(E)&&rd(e==null?void 0:e.value));return r.type===d.Loop&&c&&(b=!1),b?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:c&&!m&&Pn((e==null?void 0:e.value)||null)?{value:null,valueOwner:l,type:Me.Empty,inheritanceLink:null}:e||{value:null,valueOwner:l,type:Me.External,inheritanceLink:null}}function _x(l,p,i=!1){var _,$,L,j,k,G;if((_=l.getDataType(null))!=null&&_.isObject())return wx(l,p);if(p.execution&&p.execution.hasEntity(l)&&!i){const H=($=p.lastExecutionResults)==null?void 0:$.readValue(l.id);if(H)return{value:H,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=ht(l),a=!!((L=p.execution)!=null&&L.entities.length),c=(j=p.execution)==null?void 0:j.hasEntity(r),e=l.readsValue;let f=null;if(e){const H=(k=p.execution)==null?void 0:k.hasEntity(e);(!a||a&&H&&c||a&&!H&&!c)&&(f=bm(l,p,i))}const h=l.defaultValue,m=p.getValueTypePreference(l.id);if(!f&&h){const H=h;(i||m===null||m!==Me.Testing)&&(f={value:H,valueOwner:l,type:Me.DefaultValue,inheritanceLink:null})}if(!f||(f.type===Me.DefaultValue||f.type===Me.External)&&!i||m===null||m!==Me.DefaultValue){const H=(G=p.localTestValues)==null?void 0:G.readValue(l.id);if(H)return{value:H,valueOwner:l,type:Me.Testing,inheritanceLink:null}}const E=ad(l),b=l.getDataType(null);return E&&(!(f!=null&&f.value)||!_a(b)&&rd(f==null?void 0:f.value))?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:!E&&Pn((f==null?void 0:f.value)||null)?{value:null,valueOwner:l,type:l.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function oVe(l,p,i=!1){var f,h,m,E,b,g,_,$,L,j,k,G,H;if(p.execution&&p.execution.hasEntity(l)&&!i){const ie=(f=p.lastExecutionResults)==null?void 0:f.readValue(l.id);if(ie)return{value:ie,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=Ip(l);if(lp.includes(r.type)){const ie=lf(r,p,i),ee=l.codeName||((h=l.declaration)==null?void 0:h.codeName)||ir(se(l,p.project));if(ie!=null&&ie.value&&gr(ie.value.value)){const ue=ie.value.value[ee],ae=xt(l.getDataType(null),l,p.project);return ae==null||ae.metaSync({value:ue},null),{value:ae,valueOwner:l,type:!_t.includes(r.type)&&ie.type===Me.Empty?Me.QueuedAutocalculation:ie.type,inheritanceLink:{sources:[ie],target:l}}}return{value:null,valueOwner:l,type:_t.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)===Sx.Running;if((b=p.persistedExecutionResults)!=null&&b.values[l.id]&&!a&&!c&&!i){const ie=(g=p.persistedExecutionResults)==null?void 0:g.readValue(l.id);if((ie==null?void 0:ie.value)!==null||(ie==null?void 0:ie.valueAsType)!==null)return{value:ie,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const e=l.parent;if(!e)throw new Error(`Couldn't find the parent that generates the output ${l.id}`);switch(e.type){case d.VariableInstance:{const ee=Ox(e,p,i);if(ee&&ee.value){const ae=l.declaration;if(gr(ee.value.value)){const de=ee.value.value[ae.name],ce=xt(((_=l.declaration)==null?void 0:_.dataType)||null,l,p.project);return ce==null||ce.metaSync({value:de},null),{value:ce,valueOwner:l,type:Me.Inherited,inheritanceLink:{sources:[ee],target:l}}}}const ue=xt((($=l.declaration)==null?void 0:$.dataType)||null,l,p.project);return ue==null||ue.metaSync({value:null},null),{value:ue,valueOwner:l,type:Me.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:l}}}case d.VariableDeclaration:{const ee=iE(e,p,i);if(ee&&ee.value){const ae=l.declaration;if(gr(ee.value.value)){const de=ee.value.value[ae.name],ce=xt(((L=l.declaration)==null?void 0:L.dataType)||null,l,p.project);return ce==null||ce.metaSync({value:de},null),{value:ce,valueOwner:l,type:Me.Inherited,inheritanceLink:{sources:[ee],target:l}}}}const ue=xt(((j=l.declaration)==null?void 0:j.dataType)||null,l,p.project);return ue==null||ue.metaSync({value:null},null),{value:ue,valueOwner:l,type:Me.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:l}}}case d.Operation:{const ie=e.outputs.map(ue=>{var ae,de;if((ae=p.persistedExecutionResults)!=null&&ae.values[ue.id]){const ce=(de=p.persistedExecutionResults)==null?void 0:de.values[ue.id];if(ce.value!==null||ce.valueAsType!==null)return{value:ce,valueOwner:ue,type:Me.ExecutionResult,inheritanceLink:null}}}).filter(ue=>!!ue),ee=xt(((k=l.declaration)==null?void 0:k.dataType)||null,l,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:l,type:Me.QueuedAutocalculation,inheritanceLink:ie.length?{sources:ie,target:l}:null}}case d.FunctionCall:{const ie=e.inputs.map(ue=>ug(ue,p,i)).filter(ue=>!!ue),ee=xt(((G=l.declaration)==null?void 0:G.dataType)||null,l,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:l,type:Me.QueuedAutocalculation,inheritanceLink:ie.length?{sources:ie,target:l}:null}}case d.Loop:{const ie=e.inputs.map(ue=>ug(ue,p,i)).filter(ue=>!!ue),ee=xt(((H=l.declaration)==null?void 0:H.dataType)||null,l,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:l,type:Me.QueuedAutocalculation,inheritanceLink:ie.length?{sources:ie,target:l}:null}}case d.Search:return{value:null,valueOwner:l,type:Me.QueuedAutocalculation,inheritanceLink:null}}return null}function f_(l,p,i=!1){var b,g,_;if(![...Dt,..._t].includes(l.parent.type)||!xE(l))return null;if(((b=l.declaration)==null?void 0:b.type)===d.Property&&l.declaration.static)return lf(l.declaration,p);const r=rE(l,p,i);if(r&&r.type!==Me.Empty&&r.type!==Me.Missing)return r;const a=yr(l.parent),c=Fo(a,p,i),e=l.codeName||((g=l.declaration)==null?void 0:g.codeName)||ir(se(l,p.project)),f=xt(l.getDataType(null),l,p.project),h=ad(l),m=(_=c==null?void 0:c.value)==null?void 0:_.value;if(m&&gr(m)){let $=m[e];m[e]===void 0&&($=null),f==null||f.metaSync({value:$},null);const L=ad(l),j=l.getDataType(null);return L&&(!f||!_a(j)&&rd(f))?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:{value:f,valueOwner:l,type:c.type,inheritanceLink:{sources:c?[c]:[],target:l}}}return h?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:{value:null,valueOwner:l,type:l.readsValue?Me.Inherited:Me.Empty,inheritanceLink:null}}function y_(l,p,i=!1){var b,g,_,$,L,j,k,G;if(![...Dt,..._t].includes(l.parent.type)||!xE(l))return null;if(((b=l.declaration)==null?void 0:b.type)===d.Property&&l.declaration.static)return lf(l.declaration,p,i);const r=Dt.includes(l.parent.type)?l.parent:yr(l.parent),a=lf(r,p,i);let c=l;r.type===d.VariableDeclaration&&(c=(l.parent===r?l:r.inputs.find(ie=>{var ee,ue;return((ee=ie.declaration)==null?void 0:ee.id)===((ue=l.declaration)==null?void 0:ue.id)}))||l);const e=BT(c,p,i),f=l.codeName||((g=l.declaration)==null?void 0:g.codeName)||ir(se(l,p.project)),h=(r.type===d.VariableDeclaration,l.defaultValue||xt(l.getDataType(null),l,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&&gr(m)){let H=m[f];return m[f]===void 0&&(H=null),h==null||h.metaSync({value:H},null),{value:h,valueOwner:l,type:a.type,inheritanceLink:{sources:a?[a]:[],target:l}}}if(e&&e.type!==Me.Empty&&e.type!==Me.Missing)return e;if(m&&gr(m)){let H=m[f];m[f]===void 0&&(H=null),h!=null&&h.standaloneParent&&(h==null||h.metaSync({value:H},null));const ie=ad(l),ee=l.getDataType(null),ue=ie&&(!h||!_a(ee)&&rd(h)),ae=!!(($=p.execution)!=null&&$.entities.length),de=(L=p.execution)==null?void 0:L.hasEntity(r),ce=r.readsValue;if(ce){const ne=(j=p.execution)==null?void 0:j.hasEntity(ce);if(ue&&(!ae||ae&&ne&&de||ae&&!ne&&!de))return{value:null,valueOwner:l,type:Me.Inherited,inheritanceLink:null}}if(l.readsValue){const ne=(k=p.execution)==null?void 0:k.hasEntity(l.readsValue);if(ue&&(!ae||ae&&ne&&de||ae&&!ne&&!de))return{value:null,valueOwner:l,type:Me.Inherited,inheritanceLink:null}}return ue?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:{value:h,valueOwner:l,type:((G=h==null?void 0:h.parent)==null?void 0:G.id)===(l==null?void 0:l.id)?a.type:Me.Inherited,inheritanceLink:{sources:a?[a]:[],target:l}}}return BT(l,p,i)}function rE(l,p,i=!1){var _,$,L,j,k,G;const r=ht(l),a=!!((_=p.execution)!=null&&_.entities.length),c=($=p.execution)==null?void 0:$.hasEntity(r),e=l.readsValue;let f=null;if(e){const H=(L=p.execution)==null?void 0:L.hasEntity(e);(!a||a&&H&&c||a&&!H&&!c)&&(f=bm(l,p,i))}const h=l.defaultValue,m=p.getValueTypePreference(l.id);if(!f&&h&&(i||m===null||m!==Me.Testing)&&(f={value:h,valueOwner:l,type:rd(h)?Me.Empty:Me.DefaultValue,inheritanceLink:null}),!f||f.type===Me.DefaultValue||(f==null?void 0:f.type)===Me.Empty){const H=(j=p.persistedExecutionResults)==null?void 0:j.readValue(l.id);if(H&&!i)return{value:H,valueOwner:l,type:Me.Testing,inheritanceLink:null};const ie=(k=p.localTestValues)==null?void 0:k.readValue(l.id);if(ie&&!i&&(m===null||m!==Me.DefaultValue))return{value:ie,valueOwner:l,type:Me.Testing,inheritanceLink:null}}const E=ad(l),b=l.getDataType(null),g=E&&(!(f!=null&&f.value)||!_a(b)&&rd(f==null?void 0:f.value));if(l.readsValue){const H=(G=p.execution)==null?void 0:G.hasEntity(l.readsValue);if(g&&(!a||a&&H&&c||a&&!H&&!c))return{value:null,valueOwner:l,type:Me.Inherited,inheritanceLink:null}}return g?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:(f==null?void 0:f.inheritanceLink)||null}:!E&&(!f||f.type===Me.Inherited)&&!(f!=null&&f.inheritanceLink)?{value:null,valueOwner:l,type:l.readsValue||!(f!=null&&f.value)?Me.Inherited:Me.Empty,inheritanceLink:null}:f}function BT(l,p,i=!1){var e,f;if(p.execution&&p.execution.hasEntity(l)&&!i){const h=(e=p.lastExecutionResults)==null?void 0:e.readValue(l.id);if(h)return{value:h,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=(f=p.localTestValues)==null?void 0:f.readValue(l.id),a=p.getValueTypePreference(l.id);return r&&!i&&(a===null||a!==Me.DefaultValue)?{value:r,valueOwner:l,type:Me.Testing,inheritanceLink:null}:rE(l,p,i)}function ug(l,p,i=!1){var r,a;return _t.includes(l.parent.type)&&(r=yr(l.parent).dataType)!=null&&r.isObject()||Dt.includes(l.parent.type)&&(a=l.parent.getDataType(null))!=null&&a.isObject()?f_(l,p,i):rE(l,p,i)}function dVe(l,p,i=!1){var r,a;return _t.includes(l.parent.type)&&(r=yr(l.parent).dataType)!=null&&r.isObject()||Dt.includes(l.parent.type)&&(a=l.parent.getDataType(null))!=null&&a.isObject()?y_(l,p,i):BT(l,p,i)}function uVe(l,p,i=!1){var E,b;if(!l.static)return null;if(p.execution){const g=(E=p.lastExecutionResults)==null?void 0:E.readValue(l.id);if(g&&!i)return{value:g,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=(b=p.localTestValues)==null?void 0:b.readValue(l.id),a=p.getValueTypePreference(l.id);if(r&&!i&&(a===null||a!==Me.DefaultValue))return{value:r,valueOwner:l,type:Me.Testing,inheritanceLink:null};const c=l.defaultValue;let e=null;c&&(i||a===null||a!==Me.Testing)&&(e={value:c,valueOwner:l,type:Me.DefaultValue,inheritanceLink:null});const f=ad(l),h=l.getDataType(null);return f&&(!(e!=null&&e.value)||!_a(h)&&rd(e==null?void 0:e.value))?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:Pn(e==null?void 0:e.value)?{value:null,valueOwner:l,type:Me.Empty,inheritanceLink:null}:e}function pVe(l,p,i=!1){var E,b;if(p.execution&&p.execution.hasEntity(l)&&!i){const g=(E=p.lastExecutionResults)==null?void 0:E.readValue(l.id);if(g)return{value:g,valueOwner:l,type:Me.ExecutionResult,inheritanceLink:null}}const r=(b=p.localTestValues)==null?void 0:b.readValue(l.id),a=p.getValueTypePreference(l.id);if(r&&!i&&(a===null||a!==Me.DefaultValue))return{value:r,valueOwner:l,type:Me.Testing,inheritanceLink:null};const c=l.defaultValue;let e=null;c&&(i||a===null||a!==Me.Testing)&&(e={value:c,valueOwner:l,type:Me.DefaultValue,inheritanceLink:null});const f=ad(l),h=l.getDataType(null);return f&&(!(e!=null&&e.value)||!_a(h)&&rd(e==null?void 0:e.value))?{value:null,valueOwner:l,type:Me.Missing,inheritanceLink:null}:Pn((e==null?void 0:e.value)||null)?{value:null,valueOwner:l,type:Me.Empty,inheritanceLink:null}:e}function lf(l,p,i=!1){switch(l.type){case d.ArgumentDeclaration:return lVe(l,p,i);case d.InputMap:return dVe(l,p,i);case d.VariableDeclaration:return Cx(l,p,i);case d.VariableInstance:return sVe(l,p,i);case d.OutputMap:return oVe(l,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return _x(l,p,i);case d.Property:return uVe(l,p,i);case d.ValueDescriptor:return pVe(l,p,i);case d.Operation:case d.FunctionCall:case d.InternalCall:case d.Search:return nVe(l,p,i);default:return null}}function Fo(l,p,i=!1){switch(l.type){case d.InputMap:return ug(l,p,i);case d.VariableDeclaration:return iE(l,p,i);case d.VariableInstance:return Ox(l,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return _x(l,p,i);default:return null}}function QAi(l){var p;if(l&&l.type===Me.DefaultValue&&l.value&&l.valueOwner&&(!Zg.includes(l.valueOwner.type)||((p=l.valueOwner.defaultValue)==null?void 0:p.id)===l.value.id)){const i=xt(l.valueOwner.getDataType(null),l.valueOwner,l.valueOwner.project);return{type:Me.DefaultValue,value:i,valueOwner:l.valueOwner,inheritanceLink:null}}return l}function tf(l,p,i,r){let a=!1,c=null,e=null;r instanceof q?(a=!0,c=r,e=null):(c=null,e=r);const f=l.parent;return p.getVariableDeclarations().forEach(m=>{var b,g,_,$,L,j;const E=m.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===f.id){let k=a?m.defaultValue:e==null?void 0:e.readValue(m.id);k?!a&&k&&k.id===((g=m.defaultValue)==null?void 0:g.id)&&(k=xt(m.getDataType(null),m,p)):a?k=wu(m.getDataType(null),m,p,c):k=xt(m.getDataType(null),m,p);const G=se(l,p),H=l.codeName||((_=l.extends)==null?void 0:_.codeName)||(($=l.implements[0])==null?void 0:$.codeName)||ir(G);let ie={};((j=(L=m.dataType)==null?void 0:L.entity)==null?void 0:j.type)===d.DefinitionEntity&&(ie={...ie,...m.dataType.entity.getActiveRawDefaultValue()}),gr(k==null?void 0:k.value)&&(ie={...ie,...k.value}),ie[H]=i,k==null||k.metaSync({value:ie},c),a||e==null||e.writeValue(m,k);return}}),c}function MT(l,p,i,r){var _,$,L,j;let a=!1,c=null,e=null;r instanceof q?(a=!0,c=r,e=null):(c=null,e=r);const f=yr(l.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=xt(f.getDataType(null),f,p)):a?m=wu(f.getDataType(null),f,p,c):m=xt(f.getDataType(null),f,p);const E=se(l,p),b=l.codeName||(($=l.declaration)==null?void 0:$.codeName)||ir(E);let g={};if(((j=(L=f.dataType)==null?void 0:L.entity)==null?void 0:j.type)===d.DefinitionEntity&&(g={...g,...f.dataType.entity.getActiveRawDefaultValue()}),gr(m==null?void 0:m.value)&&(g={...g,...m.value}),g[b]=i,m==null||m.metaSync({value:g},c),a||e==null||e.writeValue(f,m),(i===""||i===null||i===void 0)&&l.type===d.OutputMap){const k=f.inputs.find(G=>{var H,ie;return((H=G.declaration)==null?void 0:H.id)===((ie=l.declaration)==null?void 0:ie.id)||se(G,p)===E});if(k){let G=a?k.defaultValue:e==null?void 0:e.readValue(k.id);G&&G.metaSync({value:null},c),a||e==null||e.removeValue(k.id)}}return c}function cVe(l,p,i){var e,f,h,m,E;let r=!1,a=null,c=null;if(i instanceof q?(r=!0,a=i,c=null):(a=null,c=i),_t.includes(l.type)){const b=yr(l);(e=b.dataType)!=null&&e.isObject()&&b.inputs.forEach(g=>{var _,$,L,j,k,G;if(((_=g.declaration)==null?void 0:_.type)===d.Property&&g.declaration.static){let H=r?(($=g.getDefaultValue)==null?void 0:$.call(g))||null:c==null?void 0:c.readValue(g.declaration.id);H?!r&&H&&H.id===((L=g.declaration.defaultValue)==null?void 0:L.id)&&(H=xt(g.declaration.getDataType(null),g.declaration,p)):r?H=wu(g.declaration.getDataType(null),g.declaration,p,a):H=xt(g.declaration.getDataType(null),g.declaration,p),H==null||H.metaSync({value:null},a),r||c==null||c.removeValue((j=g.declaration)==null?void 0:j.id)}else if(((k=g.declaration)==null?void 0:k.type)===d.Property){let H=r?((G=g.getDefaultValue)==null?void 0:G.call(g))||null:c==null?void 0:c.readValue(g.id);H&&H.metaSync({value:null},a),r||c==null||c.removeValue(g.id)}})}else l.type===d.InputMap?((f=l.declaration)==null?void 0:f.type)===d.Property&&l.declaration.static?tf(l.declaration,p,null,i):_t.includes(l.parent.type)&&((h=l.declaration)==null?void 0:h.type)===d.Property&&MT(l,p,null,i):l.type===d.OutputMap?((m=l.declaration)==null?void 0:m.type)===d.Property&&l.declaration.static?tf(l.declaration,p,null,i):_t.includes(l.parent.type)&&((E=l.declaration)==null?void 0:E.type)===d.Property&&MT(l,p,null,i):l.type===d.Property&&l.static&&tf(l,p,null,i);return a}function fVe(l,p,i,r){var f,h,m,E,b,g,_;let a=!1,c=null,e=null;if(r instanceof q?(a=!0,c=r,e=null):(c=null,e=r),_t.includes(p.type)){const $=yr(p);if((f=$.dataType)!=null&&f.isObject()){let L={};((m=(h=$.dataType)==null?void 0:h.entity)==null?void 0:m.type)===d.DefinitionEntity&&(L={...L,...$.dataType.entity.getActiveRawDefaultValue()});const j=gr(l)?l:L;$.inputs.forEach(k=>{var G,H,ie,ee,ue,ae;if(((G=k.declaration)==null?void 0:G.type)===d.Property&&k.declaration.static){let de=a?((H=p.getDefaultValue)==null?void 0:H.call(p))||null:e==null?void 0:e.readValue(k.declaration.id);de?!a&&de&&de.id===((ie=k.declaration.defaultValue)==null?void 0:ie.id)&&(de=xt(k.declaration.getDataType(null),k.declaration,i)):a?de=wu(k.declaration.getDataType(null),k.declaration,i,c):de=xt(k.declaration.getDataType(null),k.declaration,i);const ce=se(k,i),ne=k.codeName||((ee=k.declaration)==null?void 0:ee.codeName)||ir(ce),le=j[ne];de==null||de.metaSync({value:le},c),a||e==null||e.writeValue(k.declaration,de)}else if(((ue=k.declaration)==null?void 0:ue.type)===d.Property){let de=a?((ae=p.getDefaultValue)==null?void 0:ae.call(p))||null:e==null?void 0:e.readValue(k.id);de&&de.metaSync({value:null},c),a||e==null||e.removeValue(k.id)}})}}else p.type===d.InputMap?((E=p.declaration)==null?void 0:E.type)===d.Property&&p.declaration.static?tf(p.declaration,i,l,r):_t.includes(p.parent.type)&&((b=p.declaration)==null?void 0:b.type)===d.Property&&MT(p,i,l,r):p.type===d.OutputMap?((g=p.declaration)==null?void 0:g.type)===d.Property&&p.declaration.static?tf(p.declaration,i,null,r):_t.includes(p.parent.type)&&((_=p.declaration)==null?void 0:_.type)===d.Property&&MT(p,i,null,r):p.type===d.Property&&p.static&&tf(p,i,l,r);return c}function egi(l,p,i){const r=Jo(l,p);let a=!1,c=null,e=null;return i instanceof q?(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),cVe(f,p,i)}),c}function tgi(l,p,i,r){const a=Jo(p,i);let c=!1,e=null,f=null;return r instanceof q?(c=!0,e=r,f=null):(e=null,f=r),i.diggestedBuiltInBaseEntitiesIds.has(p.id)||a.forEach(h=>{var E,b,g,_;if(i.diggestedBuiltInBaseEntitiesIds.has(h.id))return;let m=null;if(c){const $=((E=h.getDefaultValue)==null?void 0:E.call(h))||null;$&&(i.diggestedBuiltInBaseEntitiesIds.has($.id)||((b=$.parent)==null?void 0:b.id)!==h.id?m=$.clone(e,h):m=$)}else m=f==null?void 0:f.readValue(h.id);m?!c&&m&&m.id===((_=(g=h.getDefaultValue)==null?void 0:g.call(h))==null?void 0:_.id)&&(m=xt(h.getDataType(null),h,i)):c?(m=wu(h.getDataType(null),h,i,e),e==null||e.add(m,W.Added)):m=xt(h.getDataType(null),h,i),m==null||m.setValueAsType(null,e),m==null||m.metaSync({value:l},e),c||f==null||f.writeValue(h,m),fVe(l,h,i,r)}),e}function rf(l,p,i,r){let a=!1,c=null,e=null;r instanceof q?(a=!0,c=r,e=null):(c=null,e=r);const f=l.parent;return p.getVariableDeclarations().forEach(m=>{var b,g,_,$,L,j;const E=m.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===f.id){let k=a?m.defaultValue:e==null?void 0:e.readValue(m.id);k?!a&&k&&k.id===((g=m.defaultValue)==null?void 0:g.id)&&(k=xt(m.getDataType(null),m,p)):a?k=wu(m.getDataType(null),m,p,c):k=xt(m.getDataType(null),m,p);const G=se(l,p),H=l.codeName||((_=l.extends)==null?void 0:_.codeName)||(($=l.implements[0])==null?void 0:$.codeName)||ir(G);let ie={};((j=(L=m.dataType)==null?void 0:L.entity)==null?void 0:j.type)===d.DefinitionEntity&&(ie={...ie,...m.dataType.entity.getActiveRawDefaultValue()}),gr(k==null?void 0:k.value)&&(ie={...ie,...k.value}),Array.isArray(i)?ie[H]=(i==null?void 0:i.map(ee=>ee.toShallowJSON()))||null:ie[H]=(i==null?void 0:i.toShallowJSON())||null,k==null||k.metaSync({value:ie},c),a||e==null||e.writeValue(m,k);return}}),c}function GT(l,p,i,r){var _,$,L,j;let a=!1,c=null,e=null;r instanceof q?(a=!0,c=r,e=null):(c=null,e=r);const f=yr(l.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=xt(f.getDataType(null),f,p)):a?m=wu(f.getDataType(null),f,p,c):m=xt(f.getDataType(null),f,p);const E=se(l,p),b=l.codeName||(($=l.declaration)==null?void 0:$.codeName)||ir(E);let g={};if(((j=(L=f.dataType)==null?void 0:L.entity)==null?void 0:j.type)===d.DefinitionEntity&&(g={...g,...f.dataType.entity.getActiveRawDefaultValue()}),gr(m==null?void 0:m.value)&&(g={...g,...m.value}),Array.isArray(i)?g[b]=(i==null?void 0:i.map(k=>k.toShallowJSON()))||null:g[b]=(i==null?void 0:i.toShallowJSON())||null,m==null||m.metaSync({value:g},c),a||e==null||e.writeValue(f,m),i==null&&l.type===d.OutputMap){const k=f.inputs.find(G=>{var H,ie;return((H=G.declaration)==null?void 0:H.id)===((ie=l.declaration)==null?void 0:ie.id)||se(G,p)===E});if(k){let G=a?k.defaultValue:e==null?void 0:e.readValue(k.id);G&&(Array.isArray(i)?G==null||G.setValueAsTypeList(i,c):G==null||G.setValueAsTypeSingle(i,c)),a||e==null||e.removeValue(k.id)}}return c}function yVe(l,p,i){var r,a,c,e;return l.type===d.InputMap?((r=l.declaration)==null?void 0:r.type)===d.Property&&l.declaration.static?rf(l.declaration,p,null,i):_t.includes(l.parent.type)&&((a=l.declaration)==null?void 0:a.type)===d.Property&>(l,p,null,i):l.type===d.OutputMap?((c=l.declaration)==null?void 0:c.type)===d.Property&&l.declaration.static?rf(l.declaration,p,null,i):_t.includes(l.parent.type)&&((e=l.declaration)==null?void 0:e.type)===d.Property&>(l,p,null,i):l.type===d.Property&&l.static&&rf(l,p,null,i),i}function hVe(l,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?rf(p.declaration,i,l,r):_t.includes(p.parent.type)&&((c=p.declaration)==null?void 0:c.type)===d.Property&>(p,i,l,r):p.type===d.OutputMap?((e=p.declaration)==null?void 0:e.type)===d.Property&&p.declaration.static?rf(p.declaration,i,null,r):_t.includes(p.parent.type)&&((f=p.declaration)==null?void 0:f.type)===d.Property&>(p,i,null,r):p.type===d.Property&&p.static&&rf(p,i,l,r),r}function igi(l,p,i){const r=Jo(l,p);let a=!1,c=null,e=null;return i instanceof q?(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),yVe(f,p,i)}),c}function rgi(l,p,i,r){const a=Jo(p,i);let c=!1,e=null,f=null;return r instanceof q?(c=!0,e=r,f=null):(e=null,f=r),a.forEach(h=>{var E,b,g;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===((g=(b=h.getDefaultValue)==null?void 0:b.call(h))==null?void 0:g.id)&&(m=xt(h.getDataType(null),h,h.project)):c?m=wu(h.getDataType(null),h,i,e):m=xt(h.getDataType(null),h,i),Array.isArray(l)?m==null||m.setValueAsTypeList(l,e):m==null||m.setValueAsTypeSingle(l,e),m==null||m.metaSync({value:null},e),c||f==null||f.writeValue(h,m),hVe(l,h,i,r)}),e}class QR{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 De=(l=>(l[l.High=1]="High",l[l.Normal=5]="Normal",l[l.Low=10]="Low",l))(De||{}),te=(l=>(l.Logic="logic",l.EditorGUI="editor-gui",l.GUI="gui",l.Editor="editor",l.Compile="compile",l.PublicationRun="publication-run",l))(te||{}),Ce=(l=>(l.All="*",l.OnAll="on:*",l.EmitAll="emit:*",l.ReadAll="read:*",l.WriteAll="write:*",l.UpdateAll="update:*",l.DoAll="do:*",l.OnLogicAll="on:logic:*",l.EmitLogicAll="emit:logic:*",l.ReadLogicAll="read:logic:*",l.WriteLogicAll="write:logic:*",l.UpdateLogicAll="update:logic:*",l.DoLogicAll="do:logic:*",l.OnGUIAll="on:gui:*",l.EmitGUIAll="emit:gui:*",l.ReadGUIAll="read:gui:*",l.WriteGUIAll="write:gui:*",l.UpdateGUIAll="update:gui:*",l.DoGUIAll="do:gui:*",l.OnEditorAll="on:editor:*",l.EmitEditorAll="emit:editor:*",l.ReadEditorAll="read:editor:*",l.WriteEditorAll="write:editor:*",l.UpdateEditorAll="update:editor:*",l.DoEditorAll="do:editor:*",l.OnCompileBefore="on:compile:before:DefinitionEntity",l.OnCompileDefault="on:compile:default:DefinitionEntity",l.OnCompileAfter="on:compile:after:DefinitionEntity",l.EmitCompile="emit:compile:DefinitionEntity",l.DoEditorPublish="do:editor:publish",l.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",l.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",l.UpdateGUIGlobalTheme="update:gui:global:theme",l))(Ce||{});class mVe{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 TVe extends mVe{constructor(p,i){super(i),this.parentExtension=p}}class _e{constructor(p,i){R(this,"manifest");R(this,"module");R(this,"state");this.extensionsRegistry=p,this.state=new TVe(this,i)}}class h_ extends QR{constructor(i,r){super(i,te.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 ngi(l,p){return p instanceof h_?p:new h_(l,p)}const Wy="built-in-function-implementations__",Ne="operations-implementations__",qa="conditions-implementations__",Oe={UUID:"uuid",SEARCH_NODE_IMPLEMENTATION:"search-node-implementation",BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION:Wy+Vr.AbortExecution,BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY:Wy+Vr.CreatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY:Wy+Vr.UpdatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY:Wy+Vr.DeletePersistedEntity,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY:Ne+Gt.Empty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY:Ne+Gt.NotEmpty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL:Ne+Gt.PrimitiveEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL:Ne+Gt.PrimitiveNotEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST:Ne+na.HttpRequest,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY:Ne+xe.Validate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL:Ne+Hi.Sequential,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL:Ne+Hi.Parallel,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT:Ne+Hi.Wait,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN:Ne+fe.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT:Ne+fe.Split,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS:Ne+fe.DeleteLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS:Ne+fe.DeleteFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX:Ne+fe.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX:Ne+fe.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS:Ne+fe.ReplaceFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS:Ne+fe.ReplaceLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL:Ne+fe.ReplaceAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX:Ne+fe.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM:Ne+fe.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST:Ne+fe.GetFirst,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST:Ne+fe.GetLast,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND:Ne+fe.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND:Ne+fe.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE:Ne+fe.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH:Ne+fe.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS:Ne+fe.GetFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS:Ne+fe.GetLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE:Ne+fe.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT:Ne+fe.Concat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF:Ne+fe.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF:Ne+fe.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE:Ne+fe.Unique,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN:Ne+fe.Flatten,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT:Ne+fe.Sort,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE:Ne+fe.Shuffle,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK:Ne+fe.Chunk,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START:Ne+fe.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END:Ne+fe.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT:Ne+fe.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH:Ne+Z.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE:Ne+Z.ToLowerCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE:Ne+Z.ToUpperCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN:Ne+Z.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS:Ne+fe.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL:Ne+fe.ContainsAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY:Ne+fe.ContainsAny,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX:Ne+Z.SplitAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS:Ne+Z.SplitAtAllSeparators,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR:Ne+Z.SplitAtFirstSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR:Ne+Z.SplitAtLastSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS:Ne+Z.DeleteLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS:Ne+Z.DeleteFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX:Ne+Z.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX:Ne+Z.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS:Ne+Z.ReplaceFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS:Ne+Z.ReplaceLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX:Ne+Z.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH:Ne+Z.ReplaceFirstMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH:Ne+Z.ReplaceLastMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES:Ne+Z.ReplaceAllMatches,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM:Ne+Z.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS:Ne+Z.GetFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS:Ne+Z.GetLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF:Ne+Z.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND:Ne+Z.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND:Ne+Z.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE:Ne+Z.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM:Ne+Z.Trim,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START:Ne+Z.TrimStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END:Ne+Z.TrimEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING:Ne+Z.Substring,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE:Ne+Z.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START:Ne+Z.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END:Ne+Z.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT:Ne+Z.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF:Ne+Z.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX:Ne+Z.MatchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX:Ne+Z.MatchAllRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX:Ne+Z.SearchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX:Ne+Z.ReplaceRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE:Ne+Z.NormalizeUnicode,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS:Ne+Z.RemoveDiacritics,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES:Ne+Z.CountOccurrences,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX:Ne+Z.EnsurePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX:Ne+Z.EnsureSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX:Ne+Z.RemovePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX:Ne+Z.RemoveSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION:Ne+pe.Addition,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION:Ne+pe.Subtraction,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION:Ne+pe.Multiplication,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION:Ne+pe.Division,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER:Ne+pe.Remainder,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION:Ne+pe.Exponentiation,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE:Ne+pe.Absolute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN:Ne+pe.Sign,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND:Ne+pe.Round,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE:Ne+pe.Negate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR:Ne+pe.Floor,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL:Ne+pe.Ceil,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP:Ne+pe.Clamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC:Ne+pe.Trunc,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS:Ne+pe.RoundToDecimals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP:Ne+pe.SnapToStep,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE:Ne+pe.MapRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE:Ne+pe.Average,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN:Ne+pe.Median,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF:Ne+pe.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF:Ne+pe.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT:Ne+pe.SquareRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT:Ne+pe.CubeRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT:Ne+pe.NthRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP:Ne+pe.Exp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL:Ne+pe.LogNatural,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10:Ne+pe.Log10,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN:Ne+pe.Sin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS:Ne+pe.Cos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN:Ne+pe.Tan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN:Ne+pe.Asin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS:Ne+pe.Acos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN:Ne+pe.Atan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2:Ne+pe.Atan2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS:Ne+pe.ToRadians,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES:Ne+pe.ToDegrees,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF:Ne+pe.PercentOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE:Ne+pe.PercentageChange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN:Ne+pe.MoreThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN:Ne+pe.LessThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL:Ne+pe.LessThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL:Ne+pe.MoreThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER:Ne+it.GenerateRandomInteger,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT:Ne+it.GenerateRandomFloat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL:Ne+it.GenerateRandomHexadecimal,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62:Ne+it.GenerateRandomBase62,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64:Ne+it.GenerateRandomBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC:Ne+it.GenerateRandomAlphanumeric,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER:Ne+it.GenerateIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4:Ne+it.GenerateRandomUUIDv4,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER:Ne+it.GenerateShortIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN:Ne+it.GenerateHexadecimalToken,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH:Ne+Z.StartsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH:Ne+Z.EndsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS:Ne+Z.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX:Ne+Z.MatchesRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP:Ne+K.GetCurrentTimestamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE:Ne+K.FormatDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE:Ne+K.ParseDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE:Ne+K.AddToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE:Ne+K.SubtractFromDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES:Ne+K.DifferenceBetweenDates,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE:Ne+K.ToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX:Ne+K.ToUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX:Ne+K.FromUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING:Ne+K.ToISOString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR:Ne+K.GetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH:Ne+K.GetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE:Ne+K.GetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR:Ne+K.GetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE:Ne+K.GetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND:Ne+K.GetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND:Ne+K.GetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY:Ne+K.GetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR:Ne+K.GetWeekOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER:Ne+K.GetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR:Ne+K.GetDayOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH:Ne+K.GetDaysInMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE:Ne+K.GetCurrentIanaTimeZone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR:Ne+K.SetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH:Ne+K.SetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE:Ne+K.SetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR:Ne+K.SetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE:Ne+K.SetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND:Ne+K.SetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND:Ne+K.SetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY:Ne+K.SetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER:Ne+K.SetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF:Ne+K.StartOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF:Ne+K.EndOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO:Ne+K.RoundTo,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE:qa+K.IsBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER:qa+K.IsAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME:qa+K.IsSame,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE:qa+K.IsSameOrBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER:qa+K.IsSameOrAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN:qa+K.IsBetween,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID:qa+K.IsValid,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR:qa+K.IsLeapYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE:Ne+K.ClampToRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF:Ne+K.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF:Ne+K.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW:Ne+K.FromNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW:Ne+K.ToNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF:Ne+K.HumanizeDiff,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS:Ne+K.AddBusinessDays,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY:Ne+K.NextWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY:Ne+K.PreviousWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC:Ne+K.ToUTC,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE:Ne+K.ConvertTimezone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET:Ne+K.GetTimezoneOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET:Ne+K.SetUTCOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY:Ne+xe.ReadKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY:Ne+xe.WriteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY:Ne+xe.DeleteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY:Ne+xe.ReadNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY:Ne+xe.WriteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY:Ne+xe.DeleteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY:Ne+xe.WriteSafeNestedKeyRecursively,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY:qa+xe.HasKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY:qa+xe.HasNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS:qa+xe.KeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS:qa+xe.NestedKeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE:qa+xe.IsInstanceOfType,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE:Ne+xe.Merge,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS:Ne+xe.Keys,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES:Ne+xe.Values,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES:Ne+xe.Entries,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF:Ne+Xe.GetTypeOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH:Ne+yi.Hash,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC:Ne+yi.Hmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES:Ne+it.GenerateRandomBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL:Ne+yi.ConstantTimeEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2:Ne+yi.DeriveKeyPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2:Ne+dn.HashPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2:Ne+dn.VerifyPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC:Ne+dr.BuildJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC:Ne+dr.VerifyJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE:Ne+dr.DecodeJwt,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING:Ne+Xe.FromBytesToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES:Ne+Xe.ToBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER:Ne+Xe.ToNumber,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING:Ne+Xe.ToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64:Ne+Xe.EncodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64:Ne+Xe.DecodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL:Ne+Xe.EncodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL:Ne+Xe.DecodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX:Ne+Xe.EncodeHex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX:Ne+Xe.DecodeHex,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE:Ne+on.Parse,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY:Ne+on.Stringify};class vVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.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 EVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.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 bVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.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 AVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.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 gVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.SEARCH_NODE_IMPLEMENTATION,version:"1.0.0",description:"Implementation for search nodes when they get executed and query data.",initPriority:De.High,permissions:[Ce.All],contexts:[te.Editor]});R(this,"module",{main:async(i,r)=>({error:"Search module not implemented",data:null})})}}class IVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.UUID,version:"1.0.0",description:"UUID generation module, for all contexts and runtimes",initPriority:De.High,permissions:[Ce.All],contexts:[]});R(this,"module",X_)}}const RVe=l=>l.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class DVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY,version:"1.0.0",description:"Comparison: Empty (!value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(Gt.Empty);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=RVe(r),c=!a;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class wVe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY,version:"1.0.0",description:"Comparison: NotEmpty (!!value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(Gt.NotEmpty);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=RVe(r),c=!!a;return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}const jg=class jg extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveEqual (typed equality / deep JSON equality)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(Gt.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,g=(m=(h=r[1])==null?void 0:h.value)==null?void 0:m.value;let _=!1;return E&&jg.primitiveSet.has(E)?_=b===g:E===ye.Untyped||E===ye.KeyValue?_=JSON.stringify(b)===JSON.stringify(g):_=!1,{value:U.Success,error:null,result:_}}catch(E){return{value:U.UnhandledError,error:E,result:null}}}})}};R(jg,"primitiveSet",new Set([ye.String,ye.Number,ye.Boolean,ye.Null,ye.Enum,ye.Date,ye.UUID]));let pg=jg;const Ug=class Ug extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveNotEqual (typed inequality / deep JSON inequality)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(Gt.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,g=(m=(h=r[1])==null?void 0:h.value)==null?void 0:m.value;let _=!1;return E&&Ug.primitiveSet.has(E)?_=b!==g:E===ye.Untyped||E===ye.KeyValue?_=JSON.stringify(b)!==JSON.stringify(g):_=!1,{value:U.Success,error:null,result:_}}catch(E){return{value:U.UnhandledError,error:E,result:null}}}})}};R(Ug,"primitiveSet",new Set([ye.String,ye.Number,ye.Boolean,ye.Null,ye.Enum,ye.Date,ye.UUID]));let cg=Ug;var CVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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(L){var j={date:L,utc:!0,args:arguments};return new e(j)},h.utc=function(L){var j=f(this.toDate(),{locale:this.$L,utc:!0});return L?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(L){L.utc&&(this.$u=!0),this.$utils().u(L.$offset)||(this.$offset=L.$offset),m.call(this,L)};var E=h.init;h.init=function(){if(this.$u){var L=this.$d;this.$y=L.getUTCFullYear(),this.$M=L.getUTCMonth(),this.$D=L.getUTCDate(),this.$W=L.getUTCDay(),this.$H=L.getUTCHours(),this.$m=L.getUTCMinutes(),this.$s=L.getUTCSeconds(),this.$ms=L.getUTCMilliseconds()}else E.call(this)};var b=h.utcOffset;h.utcOffset=function(L,j){var k=this.$utils().u;if(k(L))return this.$u?0:k(this.$offset)?b.call(this):this.$offset;if(typeof L=="string"&&(L=function(ee){ee===void 0&&(ee="");var ue=ee.match(r);if(!ue)return null;var ae=(""+ue[0]).match(a)||["-",0,0],de=ae[0],ce=60*+ae[1]+ +ae[2];return ce===0?0:de==="+"?ce:-ce}(L),L===null))return this;var G=Math.abs(L)<=16?60*L:L;if(G===0)return this.utc(j);var H=this.clone();if(j)return H.$offset=G,H.$u=!1,H;var ie=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(H=this.local().add(G+ie,i)).$offset=G,H.$x.$localOffset=ie,H};var g=h.format;h.format=function(L){var j=L||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return g.call(this,j)},h.valueOf=function(){var L=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*L},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(L){return L==="s"&&this.$offset?f(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():_.call(this)};var $=h.diff;h.diff=function(L,j,k){if(L&&this.$u===L.$u)return $.call(this,L,j,k);var G=this.local(),H=f(L).local();return $.call(G,H,j,k)}}})})(CVe);var agi=CVe.exports;const sgi=ds(agi);var OVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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(g,_,$){$===void 0&&($={});var L=new Date(g),j=function(k,G){G===void 0&&(G={});var H=G.timeZoneName||"short",ie=k+"|"+H,ee=r[ie];return ee||(ee=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:k,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:H}),r[ie]=ee),ee}(_,$);return j.formatToParts(L)},m=function(g,_){for(var $=h(g,_),L=[],j=0;j<$.length;j+=1){var k=$[j],G=k.type,H=k.value,ie=i[G];ie>=0&&(L[ie]=parseInt(H,10))}var ee=L[3],ue=ee===24?0:ee,ae=L[0]+"-"+L[1]+"-"+L[2]+" "+ue+":"+L[4]+":"+L[5]+":000",de=+g;return(e.utc(ae).valueOf()-(de-=de%1e3))/6e4},E=c.prototype;E.tz=function(g,_){g===void 0&&(g=f);var $,L=this.utcOffset(),j=this.toDate(),k=j.toLocaleString("en-US",{timeZone:g}),G=Math.round((j-new Date(k))/1e3/60),H=15*-Math.round(j.getTimezoneOffset()/15)-G;if(!Number(H))$=this.utcOffset(0,_);else if($=e(k,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(H,!0),_){var ie=$.utcOffset();$=$.add(L-ie,"minute")}return $.$x.$timezone=g,$},E.offsetName=function(g){var _=this.$x.$timezone||e.tz.guess(),$=h(this.valueOf(),_,{timeZoneName:g}).find(function(L){return L.type.toLowerCase()==="timezonename"});return $&&$.value};var b=E.startOf;E.startOf=function(g,_){if(!this.$x||!this.$x.$timezone)return b.call(this,g,_);var $=e(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return b.call($,g,_).tz(this.$x.$timezone,!0)},e.tz=function(g,_,$){var L=$&&_,j=$||_||f,k=m(+e(),j);if(typeof g!="string")return e(g).tz(j);var G=function(ue,ae,de){var ce=ue-60*ae*1e3,ne=m(ce,de);if(ae===ne)return[ce,ae];var le=m(ce-=60*(ne-ae)*1e3,de);return ne===le?[ce,ne]:[ue-60*Math.min(ne,le)*1e3,Math.max(ne,le)]}(e.utc(g,L).valueOf(),k,j),H=G[0],ie=G[1],ee=e(H).utcOffset(ie);return ee.$x.$timezone=j,ee},e.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},e.tz.setDefault=function(g){f=g}}})})(OVe);var lgi=OVe.exports;const ogi=ds(lgi);var _Ve={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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]==="(",g=h[1]===")";return(b?this.isAfter(m,f):!this.isBefore(m,f))&&(g?this.isBefore(E,f):!this.isAfter(E,f))||(b?this.isBefore(m,f):!this.isAfter(m,f))&&(g?this.isAfter(E,f):!this.isBefore(E,f))}}})})(_Ve);var dgi=_Ve.exports;const ugi=ds(dgi);var VVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,function(){return function(i,r){r.prototype.isSameOrAfter=function(a,c){return this.isSame(a,c)||this.isAfter(a,c)}}})})(VVe);var pgi=VVe.exports;const cgi=ds(pgi);var PVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,function(){return function(i,r){r.prototype.isSameOrBefore=function(a,c){return this.isSame(a,c)||this.isBefore(a,c)}}})})(PVe);var fgi=PVe.exports;const ygi=ds(fgi);var NVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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 g=e(this).startOf(r).date(m).startOf(i).subtract(1,"millisecond"),_=this.diff(g,i,!0);return _<0?e(this).startOf("week").week():Math.ceil(_)},f.weeks=function(h){return h===void 0&&(h=null),this.week(h)}}})})(NVe);var hgi=NVe.exports;const mgi=ds(hgi);var xVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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,g,_,$=e(this),L=(E=this.isoWeekYear(),b=this.$u,g=(b?c.utc:c)().year(E).startOf("year"),_=4-g.isoWeekday(),g.isoWeekday()>4&&(_+=7),g.add(_,i));return $.diff(L,"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(),g=!!b.u(E)||E;return b.p(m)==="isoweek"?g?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)}}})})(xVe);var Tgi=xVe.exports;const vgi=ds(Tgi);var $Ve={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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(),g=!!b.u(E)||E;if(b.p(m)===r){var _=this.quarter()-1;return g?this.month(3*_).startOf(i).startOf("day"):this.month(3*_+2).endOf(i).endOf("day")}return h.bind(this)(m,E)}}})})($Ve);var Egi=$Ve.exports;const bgi=ds(Egi);var LVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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")}}})})(LVe);var Agi=LVe.exports;const ggi=ds(Agi);var BVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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,g){return c.fromToBase(m,E,b,g)}a.en.relativeTime=e,c.fromToBase=function(m,E,b,g,_){for(var $,L,j,k=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"}],H=G.length,ie=0;ie<H;ie+=1){var ee=G[ie];ee.d&&($=g?a(m).diff(b,ee.d,!0):b.diff(m,ee.d,!0));var ue=(i.rounding||Math.round)(Math.abs($));if(j=$>0,ue<=ee.r||!ee.r){ue<=1&&ie>0&&(ee=G[ie-1]);var ae=k[ee.l];_&&(ue=_(""+ue)),L=typeof ae=="string"?ae.replace("%d",ue):ae(ue,E,ee.l,j);break}}if(E)return L;var de=j?k.future:k.past;return typeof de=="function"?de(L):de.replace("%s",L)},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)}}})})(BVe);var Igi=BVe.exports;const Rgi=ds(Igi);var MVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,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)?)?$/,g={years:m,months:E,days:f,hours:e,minutes:c,seconds:a,milliseconds:1,weeks:6048e5},_=function(ue){return ue instanceof ie},$=function(ue,ae,de){return new ie(ue,de,ae.$l)},L=function(ue){return r.p(ue)+"s"},j=function(ue){return ue<0},k=function(ue){return j(ue)?Math.ceil(ue):Math.floor(ue)},G=function(ue){return Math.abs(ue)},H=function(ue,ae){return ue?j(ue)?{negative:!0,format:""+G(ue)+ae}:{negative:!1,format:""+ue+ae}:{negative:!1,format:""}},ie=function(){function ue(de,ce,ne){var le=this;if(this.$d={},this.$l=ne,de===void 0&&(this.$ms=0,this.parseFromMilliseconds()),ce)return $(de*g[L(ce)],this);if(typeof de=="number")return this.$ms=de,this.parseFromMilliseconds(),this;if(typeof de=="object")return Object.keys(de).forEach(function(Ee){le.$d[L(Ee)]=de[Ee]}),this.calMilliseconds(),this;if(typeof de=="string"){var Q=de.match(b);if(Q){var oe=Q.slice(2).map(function(Ee){return Ee!=null?Number(Ee):0});return this.$d.years=oe[0],this.$d.months=oe[1],this.$d.weeks=oe[2],this.$d.days=oe[3],this.$d.hours=oe[4],this.$d.minutes=oe[5],this.$d.seconds=oe[6],this.calMilliseconds(),this}}return this}var ae=ue.prototype;return ae.calMilliseconds=function(){var de=this;this.$ms=Object.keys(this.$d).reduce(function(ce,ne){return ce+(de.$d[ne]||0)*g[ne]},0)},ae.parseFromMilliseconds=function(){var de=this.$ms;this.$d.years=k(de/m),de%=m,this.$d.months=k(de/E),de%=E,this.$d.days=k(de/f),de%=f,this.$d.hours=k(de/e),de%=e,this.$d.minutes=k(de/c),de%=c,this.$d.seconds=k(de/a),de%=a,this.$d.milliseconds=de},ae.toISOString=function(){var de=H(this.$d.years,"Y"),ce=H(this.$d.months,"M"),ne=+this.$d.days||0;this.$d.weeks&&(ne+=7*this.$d.weeks);var le=H(ne,"D"),Q=H(this.$d.hours,"H"),oe=H(this.$d.minutes,"M"),Ee=this.$d.seconds||0;this.$d.milliseconds&&(Ee+=this.$d.milliseconds/1e3,Ee=Math.round(1e3*Ee)/1e3);var Te=H(Ee,"S"),Ve=de.negative||ce.negative||le.negative||Q.negative||oe.negative||Te.negative,Le=Q.format||oe.format||Te.format?"T":"",$e=(Ve?"-":"")+"P"+de.format+ce.format+le.format+Le+Q.format+oe.format+Te.format;return $e==="P"||$e==="-P"?"P0D":$e},ae.toJSON=function(){return this.toISOString()},ae.format=function(de){var ce=de||"YYYY-MM-DDTHH:mm:ss",ne={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 ce.replace(h,function(le,Q){return Q||String(ne[le])})},ae.as=function(de){return this.$ms/g[L(de)]},ae.get=function(de){var ce=this.$ms,ne=L(de);return ne==="milliseconds"?ce%=1e3:ce=ne==="weeks"?k(ce/g[ne]):this.$d[ne],ce||0},ae.add=function(de,ce,ne){var le;return le=ce?de*g[L(ce)]:_(de)?de.$ms:$(de,this).$ms,$(this.$ms+le*(ne?-1:1),this)},ae.subtract=function(de,ce){return this.add(de,ce,!0)},ae.locale=function(de){var ce=this.clone();return ce.$l=de,ce},ae.clone=function(){return $(this.$ms,this)},ae.humanize=function(de){return i().add(this.$ms,"ms").locale(this.$l).fromNow(!de)},ae.valueOf=function(){return this.asMilliseconds()},ae.milliseconds=function(){return this.get("milliseconds")},ae.asMilliseconds=function(){return this.as("milliseconds")},ae.seconds=function(){return this.get("seconds")},ae.asSeconds=function(){return this.as("seconds")},ae.minutes=function(){return this.get("minutes")},ae.asMinutes=function(){return this.as("minutes")},ae.hours=function(){return this.get("hours")},ae.asHours=function(){return this.as("hours")},ae.days=function(){return this.get("days")},ae.asDays=function(){return this.as("days")},ae.weeks=function(){return this.get("weeks")},ae.asWeeks=function(){return this.as("weeks")},ae.months=function(){return this.get("months")},ae.asMonths=function(){return this.as("months")},ae.years=function(){return this.get("years")},ae.asYears=function(){return this.as("years")},ue}(),ee=function(ue,ae,de){return ue.add(ae.years()*de,"y").add(ae.months()*de,"M").add(ae.days()*de,"d").add(ae.hours()*de,"h").add(ae.minutes()*de,"m").add(ae.seconds()*de,"s").add(ae.milliseconds()*de,"ms")};return function(ue,ae,de){i=de,r=de().$utils(),de.duration=function(le,Q){var oe=de.locale();return $(le,{$l:oe},Q)},de.isDuration=_;var ce=ae.prototype.add,ne=ae.prototype.subtract;ae.prototype.add=function(le,Q){return _(le)?ee(this,le,1):ce.bind(this)(le,Q)},ae.prototype.subtract=function(le,Q){return _(le)?ee(this,le,-1):ne.bind(this)(le,Q)}}})})(MVe);var Dgi=MVe.exports;const wgi=ds(Dgi);var GVe={exports:{}};(function(l,p){(function(i,r){l.exports=r()})(Sr,function(){return function(i,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(GVe);var Cgi=GVe.exports;const Ogi=ds(Cgi);B.extend(sgi);B.extend(ogi);B.extend(ugi);B.extend(cgi);B.extend(ygi);B.extend(mgi);B.extend(vgi);B.extend(bgi);B.extend(ggi);B.extend(Rgi);B.extend(wgi);B.extend(Ogi);const Vt=l=>B(l),cr=l=>l.toISOString();function jVe(){return cr(B())}function UVe(l,p){return Vt(l).format(p)}function kVe(l){return cr(B(l))}function FVe(l){if(l==null)throw new TypeError("ToDate expects a non-null value.");if(typeof l=="string"){const p=B(l);if(!p.isValid())throw new TypeError("Invalid date string.");return p.toISOString()}if(typeof l=="number"&&Number.isFinite(l)){const p=Math.abs(l)<1e12?B.unix(l):B(l);if(!p.isValid())throw new TypeError("Invalid numeric timestamp.");return p.toISOString()}if(l instanceof Date){const p=B(l);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 KVe(l,p,i){return cr(Vt(l).add(p,i))}function SVe(l,p,i){return cr(Vt(l).subtract(p,i))}function qVe(l,p,i,r=!1){return Vt(l).diff(Vt(p),i,r)}function ZVe(l){return Vt(l).unix()}function HVe(l){return cr(B.unix(l))}function WVe(l){return cr(Vt(l))}function zVe(l){return Vt(l).year()}function YVe(l){return Vt(l).month()}function JVe(l){return Vt(l).date()}function XVe(l){return Vt(l).hour()}function QVe(l){return Vt(l).minute()}function ePe(l){return Vt(l).second()}function tPe(l){return Vt(l).millisecond()}function iPe(l){return Vt(l).isoWeekday()}function rPe(l){return Vt(l).week()}function nPe(l){return Vt(l).quarter()}function aPe(l){return Vt(l).dayOfYear()}function sPe(l){return Vt(l).daysInMonth()}function lPe(l,p){return cr(Vt(l).year(p))}function oPe(l,p){return cr(Vt(l).month(p))}function dPe(l,p){return cr(Vt(l).date(p))}function uPe(l,p){return cr(Vt(l).hour(p))}function pPe(l,p){return cr(Vt(l).minute(p))}function cPe(l,p){return cr(Vt(l).second(p))}function fPe(l,p){return cr(Vt(l).millisecond(p))}function yPe(l,p){return cr(Vt(l).isoWeekday(p))}function hPe(l,p){return cr(Vt(l).quarter(p))}function mPe(l,p){return cr(Vt(l).startOf(p))}function TPe(l,p){return cr(Vt(l).endOf(p))}function vPe(l,p){const i=Vt(l),r=i.startOf(p),a=i.endOf(p),c=r.valueOf()+(a.valueOf()-r.valueOf())/2;return cr(i.valueOf()<c?r:a)}function EPe(l,p,i){return Vt(l).isBefore(Vt(p),i)}function bPe(l,p,i){return Vt(l).isAfter(Vt(p),i)}function APe(l,p,i){return Vt(l).isSame(Vt(p),i)}function gPe(l,p,i){return Vt(l).isSameOrBefore(Vt(p),i)}function IPe(l,p,i){return Vt(l).isSameOrAfter(Vt(p),i)}function RPe(l,p,i,r,a="()"){return Vt(l).isBetween(Vt(p),Vt(i),r,a)}function DPe(l){return B(l).isValid()}function wPe(l){return Vt(l).isLeapYear()}function CPe(l,p,i){const r=Vt(l);return r.isBefore(p)?cr(Vt(p)):r.isAfter(i)?cr(Vt(i)):cr(r)}function OPe(l){if(l.length===0)throw new Error("minOf requires at least one date");let p=Vt(l[0]);for(let i=1;i<l.length;i++){const r=Vt(l[i]);r.isBefore(p)&&(p=r)}return cr(p)}function _Pe(l){if(l.length===0)throw new Error("maxOf requires at least one date");let p=Vt(l[0]);for(let i=1;i<l.length;i++){const r=Vt(l[i]);r.isAfter(p)&&(p=r)}return cr(p)}function VPe(l,p=!1){return Vt(l).fromNow(p)}function PPe(l,p=!1){return Vt(l).toNow(p)}function NPe(l,p,i=!0){const r=Vt(l).diff(Vt(p),"millisecond",!0),a=Math.abs(r),e=B.duration(a,"milliseconds").humanize();return i?r>=0?`in ${e}`:`${e} ago`:e}function xPe(l,p,i=["6","7"],r=[]){const a=m=>r.some(E=>Vt(E).isSame(m,"day")),c=m=>((m.day()+6)%7+1).toString();let e=Vt(l);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 cr(e)}function $Pe(l,p){let i=Vt(l);const r=p;for(let a=0;a<7;a++)if(i=i.add(1,"day"),i.isoWeekday()===r)return cr(i);return cr(i)}function LPe(l,p){let i=Vt(l);const r=p;for(let a=0;a<7;a++)if(i=i.subtract(1,"day"),i.isoWeekday()===r)return cr(i);return cr(i)}const BPe="Local";function Vx(){try{const l=Intl.DateTimeFormat().resolvedOptions().timeZone;if(l&&typeof l=="string")return l}catch{}try{if(typeof process<"u"&&process.env&&process.env.TZ)return process.env.TZ}catch{}return null}function Px(){const l=Vx();if(l)return l;throw new Error("Unable to detect current IANA timezone from host environment.")}function MPe(l,p,i=!1){let r=p;if(r===BPe){const e=Vx();if(!e)throw new Error("Unable to detect current timezone from host environment.");r=e}const a=r?B.tz(l,r):Vt(l),c=i?a.utc(!0):a.utc();return cr(c)}function GPe(l,p,i=!1){const r=Vt(l);return cr(i?r.tz(p,!0):r.tz(p))}function jPe(l,p){const i=l===BPe?Px():l;return Vt(p).tz(i).utcOffset()}function UPe(l,p,i=!1){return cr(Vt(l).utcOffset(p,i))}class kPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP,version:"1.0.0",description:"Date get current timestamp operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=jVe();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 FPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE,version:"1.0.0",description:"Date format operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=UVe(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 KPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE,version:"1.0.0",description:"Date parse operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=kVe(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 SPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE,version:"1.0.0",description:"Date add-to-date operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=KVe(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 qPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE,version:"1.0.0",description:"Date subtract-from-date operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=SVe(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 ZPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES,version:"1.0.0",description:"Date difference-between-dates operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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,g;return((b=E.value)==null?void 0:b.valueAsType)||((g=E.value)==null?void 0:g.value)}),c=a[0],e=a[1],f=a[2],h=a[3]??!1,m=qVe(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 _gi extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE,version:"1.0.0",description:"Date to-date operation implementation module (coerce to ISO 8601 string)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=FVe(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 HPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX,version:"1.0.0",description:"Date to-unix operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=ZVe(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 WPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX,version:"1.0.0",description:"Date from-unix operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=HVe(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 zPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING,version:"1.0.0",description:"Date to-iso-string operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=WVe(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 YPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR,version:"1.0.0",description:"Date get-year operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=zVe(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 JPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH,version:"1.0.0",description:"Date get-month (0-based) operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=YVe(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 XPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE,version:"1.0.0",description:"Date get-date (day of month) operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=JVe(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 QPe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR,version:"1.0.0",description:"Date get-hour operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=XVe(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 eNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE,version:"1.0.0",description:"Date get-minute operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=QVe(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 tNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND,version:"1.0.0",description:"Date get-second operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=ePe(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 iNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND,version:"1.0.0",description:"Date get-millisecond operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=tPe(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 rNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY,version:"1.0.0",description:"Date get-iso-weekday operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=iPe(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 nNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR,version:"1.0.0",description:"Date get-week-of-year operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=rPe(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 aNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER,version:"1.0.0",description:"Date get-quarter operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=nPe(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 _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR,version:"1.0.0",description:"Date get-day-of-year operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=aPe(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 lNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH,version:"1.0.0",description:"Date get-days-in-month operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=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 oNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE,version:"1.0.0",description:"Date get-current-iana-timezone operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=Px();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 dNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR,version:"1.0.0",description:"Date set-year operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=lPe(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 uNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH,version:"1.0.0",description:"Date set-month operation implementation module (0-based month)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=oPe(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 pNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE,version:"1.0.0",description:"Date set-date (day of month) operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=dPe(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 cNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR,version:"1.0.0",description:"Date set-hour operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=uPe(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 fNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE,version:"1.0.0",description:"Date set-minute operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=pPe(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 _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND,version:"1.0.0",description:"Date set-second operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=cPe(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 hNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND,version:"1.0.0",description:"Date set-millisecond operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=fPe(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 mNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY,version:"1.0.0",description:"Date set-iso-weekday operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=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 TNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER,version:"1.0.0",description:"Date set-quarter operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=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 vNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF,version:"1.0.0",description:"Date start-of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=mPe(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 ENe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF,version:"1.0.0",description:"Date end-of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=TPe(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 bNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO,version:"1.0.0",description:"Date round-to operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=vPe(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 ANe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE,version:"1.0.0",description:"Date is-before operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=EPe(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 gNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER,version:"1.0.0",description:"Date is-after operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=bPe(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 INe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME,version:"1.0.0",description:"Date is-same operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=APe(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 RNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE,version:"1.0.0",description:"Date is-same-or-before operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=gPe(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 DNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER,version:"1.0.0",description:"Date is-same-or-after operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=IPe(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 wNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN,version:"1.0.0",description:"Date is-between operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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 g,_;return((g=b.value)==null?void 0:g.valueAsType)||((_=b.value)==null?void 0:_.value)}),c=a[0],e=a[1],f=a[2],h=a[3],m=a[4],E=RPe(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 CNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID,version:"1.0.0",description:"Date is-valid operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=DPe(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 ONe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR,version:"1.0.0",description:"Date is-leap-year operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=wPe(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 _Ne extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE,version:"1.0.0",description:"Date clamp-to-range operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=CPe(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 VNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF,version:"1.0.0",description:"Date min-of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=OPe(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 PNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF,version:"1.0.0",description:"Date max-of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=_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 NNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW,version:"1.0.0",description:"Date from-now operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=VPe(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 xNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW,version:"1.0.0",description:"Date to-now operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=PPe(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 $Ne extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF,version:"1.0.0",description:"Date humanize-diff operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=NPe(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 LNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS,version:"1.1.0",description:"Date add-business-days operation implementation module (ISO-weekend strings)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)}),c=a[0],e=a[1],f=a[2]??void 0,h=a[3]??[],m=xPe(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 BNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY,version:"1.0.0",description:"Date next-weekday operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=$Pe(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 MNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY,version:"1.0.0",description:"Date previous-weekday operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=LPe(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 GNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC,version:"1.1.0",description:"Date to-utc operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=MPe(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 jNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE,version:"1.0.0",description:"Date convert-timezone operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=GPe(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 UNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET,version:"1.0.0",description:"Date get-timezone-offset operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=jPe(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 kNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET,version:"1.0.0",description:"Date set-utc-offset operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.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=UPe(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 FNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL,version:"1.0.0",description:"Execution parallel operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Hi.Parallel);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(b=>{var g,_;return((g=b.value)==null?void 0:g.valueAsType)||((_=b.value)==null?void 0:_.value)})[0];if(!c)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No list of action entities provided",result:null};if(!Array.isArray(c))return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"Invalid input value. Expected a list of action entities",result:null};const f=this.extensionsRegistry.requestContexts(this,[te.Editor])[0],m=c.map(b=>{const g=new ip(f.logic,[b],b,null,this.extensionsRegistry);return g.inheritValuesFromContext(f),g}).map(b=>b.execute()),E=await Promise.all(m);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 KNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL,version:"1.0.0",description:"Execution sequential operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Hi.Sequential);a&&(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(!c)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"No list of action entities provided",result:null};if(!Array.isArray(c))return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:"Invalid input value. Expected a list of action entities",result:null};const e=[];for(let f=0;f<c.length;f++){const h=c[f],E=this.extensionsRegistry.requestContexts(this,[te.Editor])[0],b=new ip(E.logic,[h],h,null,this.extensionsRegistry);b.inheritValuesFromContext(E);const g=await b.execute();e.push(g)}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 SNe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Hi.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 Vgi=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,Nx=l=>l===null||["string","number","boolean"].includes(typeof l);function Gn(l,p="Input must be an array"){if(!Array.isArray(l))throw new TypeError(p);return l}function vo(l){const p=Gn(l,"Input must be an array");if(!p||p.length===0)throw new TypeError("No list provided or list is empty");return p}function xx(l){return Array.isArray(l)?l:[]}function Is(l){return Number(l)}function qNe(l){if(!l||l.length===0)throw new TypeError("No input lists provided");if(!l.every(r=>Array.isArray(r)))throw new TypeError("All inputs must be arrays");const[p,...i]=l;return i.reduce((r,a)=>r.concat(a),p)}function ZNe(l,...p){if(!Array.isArray(l))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 l.concat(...p)}function HNe(l,p){const i=vo(l),r=Is(p);return[i.slice(0,r),i.slice(r)]}function WNe(l){return vo(l).slice().reverse()}function zNe(l){return vo(l).slice(0,-1)}function YNe(l){return vo(l).slice(1)}function JNe(l,p,i){const r=Gn(l),a=Is(p);if(a<0||a>r.length)throw new TypeError("Index out of bounds");return[...r.slice(0,a),i,...r.slice(a)]}function XNe(l,p,i){const r=vo(l),a=Is(p);if(a<0||a>=r.length)throw new TypeError("Index out of bounds");const c=[...r];return c[a]=i,c}function QNe(l,p,i){const r=vo(l),a=r.indexOf(p);if(a===-1)return r;const c=[...r];return c[a]=i,c}function exe(l,p,i){const r=vo(l),a=r.lastIndexOf(p);if(a===-1)return r;const c=[...r];return c[a]=i,c}function txe(l,p,i){return vo(l).map(a=>a===p?i:a)}function ixe(l,p){const i=vo(l),r=Is(p);if(r<0||r>=i.length)throw new TypeError("Index out of bounds");return i[r]}function rxe(l){return vo(l)[0]}function nxe(l){const p=vo(l);return p[p.length-1]}function axe(l,p,...i){return[...Gn(l),p,...i]}function sxe(l,p){const i=Gn(l);return[p,...i]}function lxe(l){return Gn(l).length}function oxe(l,p){const i=Gn(l),r=Is(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 dxe(l,p){const i=Gn(l),r=Math.max(0,Is(p)??0);return i.slice(0,r)}function uxe(l,p){const i=Gn(l),r=Math.max(0,Is(p)??0);return r===0?[]:i.slice(-r)}function pxe(l,p,i){const r=Gn(l),a=p==null?void 0:Is(p),c=i==null?void 0:Is(i);return r.slice(a,c)}function cxe(l,p){return Gn(l).indexOf(p)}function fxe(l,p){return Gn(l).lastIndexOf(p)}function yxe(l){const p=Gn(l),i=[],r=new Set;for(const a of p)r.has(a)||(r.add(a),i.push(a));return i}function hxe(l){return Gn(l).reduce((i,r)=>i.concat(r),[])}function mxe(l){const p=Gn(l);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=>Vgi.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 Txe(l){const i=[...Gn(l)];for(let r=i.length-1;r>0;r--){const a=Math.floor(zR()*(r+1));[i[r],i[a]]=[i[a],i[r]]}return i}function vxe(l,p){const i=Gn(l),r=Math.max(1,Is(p)||1),a=[];for(let c=0;c<i.length;c+=r)a.push(i.slice(c,c+r));return a}function Exe(l,p,i){const r=Gn(l),a=Math.max(0,Is(p)||0);if(r.length>=a)return[...r];const c=a-r.length;return Array(c).fill(i).concat(r)}function bxe(l,p,i){const r=Gn(l),a=Math.max(0,Is(p)||0);if(r.length>=a)return[...r];const c=a-r.length,e=Array(c).fill(i);return r.concat(e)}function Axe(l,p){const i=Gn(l),r=Math.max(0,Is(p)||0),a=[];for(let c=0;c<r;c++)a.push(...i);return a}function gxe(l,p){if(!Nx(p))throw new TypeError("Contains expects the needle to be a primitive (string | number | boolean | null).");return xx(l).some(r=>r===p)}function Ixe(l,p){const i=xx(l),r=Array.isArray(p)?p:[p];if(r.length===0)return!1;if(!r.every(Nx))throw new TypeError("ContainsAll expects all needles to be primitives (string | number | boolean | null).");return r.every(a=>i.includes(a))}function Rxe(l,p){const i=xx(l),r=Array.isArray(p)?p:[p];if(r.length===0)return!1;if(!r.every(Nx))throw new TypeError("ContainsAny expects all needles to be primitives (string | number | boolean | null).");return r.some(a=>i.includes(a))}class Dxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=qNe(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 wxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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]=HNe(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 Cxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=WNe(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 Oxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS,version:"1.0.0",description:"List delete last operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=zNe(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 _xe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS,version:"1.0.0",description:"List delete first operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=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 Vxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=JNe(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 _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=XNe(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 Nxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS,version:"1.0.0",description:"List replace first operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=QNe(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 xxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS,version:"1.0.0",description:"List replace last operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=exe(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 $xe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL,version:"1.0.0",description:"List replace all operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=txe(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 Lxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=ixe(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 Bxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=rxe(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 Mxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=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 Gxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=axe(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 jxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(fe.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=sxe(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 Uxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH,version:"1.0.0",description:"List get length",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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:lxe(a)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class kxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX,version:"1.0.0",description:"List delete one item at index (non-mutating)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=oxe(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 Fxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS,version:"1.0.0",description:"List get first N items",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=dxe(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 Kxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS,version:"1.0.0",description:"List get last N items",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=uxe(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 Sxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE,version:"1.0.0",description:"List slice(start, end)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=pxe(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 qxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT,version:"1.0.0",description:"List concat(base, ...others)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=ZNe(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 Zxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF,version:"1.0.0",description:"List listGetIndexOf(value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=cxe(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 Hxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF,version:"1.0.0",description:"List listGetLastIndexOf(value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=fxe(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 Wxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE,version:"1.0.0",description:"List unique (stable, by reference/===)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=yxe(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 zxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN,version:"1.0.0",description:"List flatten one level",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=hxe(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 _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=mxe(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 Jxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE,version:"1.0.0",description:"List shuffle (Fisher–Yates, secure RNG helper)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=Txe(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 Xxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK,version:"1.0.0",description:"List chunk(size) -> list of lists",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=vxe(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 Qxe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START,version:"1.0.0",description:"List padStart(targetLength, padValue)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=Exe(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$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END,version:"1.0.0",description:"List padEnd(targetLength, padValue)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=bxe(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 t$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT,version:"1.0.0",description:"List repeat(count)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=Axe(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 i$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS,version:"1.0.0",description:"List contains (primitive needles)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=gxe(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 r$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL,version:"1.0.0",description:"List contains all (primitive needles)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=Ixe(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 _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY,version:"1.0.0",description:"List contains any (primitive needles)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(fe.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=Rxe(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 Pgi extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH,version:"1.0.0",description:"Returns the number of characters in a string",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 a$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 k,G;return((G=(k=j.valueOwner)==null?void 0:k.declaration)==null?void 0:G.id)===re.operation[Z.Join].inputs.separator.id}),h=((a=f==null?void 0:f.value)==null?void 0:a.value)||"",m=r.find(j=>{var k,G;return((G=(k=j.valueOwner)==null?void 0:k.declaration)==null?void 0:G.id)===re.operation[Z.Join].inputs.first.id}),E=((c=m==null?void 0:m.value)==null?void 0:c.value)||"",b=r.find(j=>{var k,G;return((G=(k=j.valueOwner)==null?void 0:k.declaration)==null?void 0:G.id)===re.operation[Z.Join].inputs.second.id}),g=((e=b==null?void 0:b.value)==null?void 0:e.value)||"",$=r.filter(j=>{var k,G;return((G=(k=j.valueOwner)==null?void 0:k.declaration)==null?void 0:G.id)===re.operation[Z.Join].inputs.dynamicString.id}).map(j=>{var k,G;return((k=j.value)==null?void 0:k.valueAsType)||((G=j.value)==null?void 0:G.value)||""}),L=[E,g,...$].join(h);return{value:U.Success,error:null,result:L}}catch(f){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:f,result:null}}}})}}class s$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX,version:"1.0.0",description:"String split at index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 l$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 o$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 d$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 u$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS,version:"1.0.0",description:"String delete last number of characters operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 p$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS,version:"1.0.0",description:"String delete first number of characters operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 c$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 f$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 y$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 h$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.DeleteAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)||((g=E.value)==null?void 0:g.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 m$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 T$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS,version:"1.0.0",description:"String replace first operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 v$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS,version:"1.0.0",description:"String replace last operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 E$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.ReplaceAtIndex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)||((g=E.value)==null?void 0:g.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 b$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 A$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.ReplaceLastMatch);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)||((g=E.value)==null?void 0:g.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 g$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 I$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 R$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS,version:"1.0.0",description:"String get last N chars operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 D$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS,version:"1.0.0",description:"String get first N chars operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 w$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 C$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 O$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Z.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 _$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM,version:"1.0.0",description:"String trim implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 V$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START,version:"1.0.0",description:"String trimStart implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 P$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END,version:"1.0.0",description:"String trimEnd implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 N$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING,version:"1.0.0",description:"String substring(start, end?) implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 x$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE,version:"1.0.0",description:"String slice(start, end?) implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 $$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF,version:"1.0.0",description:"String lastIndexOf(search, fromIndex?) implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 L$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START,version:"1.0.0",description:"String padStart(targetLength, padString?) implementation",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 B$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END,version:"1.0.0",description:"String padEnd(targetLength, padString?) implementation",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 M$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT,version:"1.0.0",description:"String repeat(count) implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 G$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX,version:"1.0.0",description:"String match(regex) -> first match array or null",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 j$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX,version:"1.0.0",description:"String matchAll(regex) -> array of matches",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.MatchAllRegex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=r.map(b=>{var g,_;return((g=b.value)==null?void 0:g.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 U$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX,version:"1.0.0",description:"String search(regex) -> index or -1",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 k$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX,version:"1.0.0",description:"String replace using RegExp (pattern, replacement, flags?)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.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 F$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE,version:"1.0.0",description:"String normalize(form?) implementation module (NFC by default)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 kg=class kg extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS,version:"1.0.0",description:"Remove diacritics via NFD decomposition + strip combining marks",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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(kg.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(kg,"COMBINING_MARKS",/[\u0300-\u036f]/g);let fg=kg;class K$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES,version:"1.0.0",description:"Count literal substring occurrences in a string",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 S$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX,version:"1.0.0",description:"Ensure string starts with given prefix (add if missing)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 q$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX,version:"1.0.0",description:"Ensure string ends with given suffix (add if missing)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 Z$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX,version:"1.0.0",description:"Remove prefix if present",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 H$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX,version:"1.0.0",description:"Remove suffix if present",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 W$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH,version:"1.0.0",description:"String startsWith(needle) -> boolean",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 z$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH,version:"1.0.0",description:"String endsWith(needle) -> boolean",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 Y$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS,version:"1.0.0",description:"String includes(needle) -> boolean",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 J$e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX,version:"1.0.0",description:"Regex test: new RegExp(pattern, flags?).test(src) -> boolean",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Z.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 X$e(l,p){const i=Number(l),a=10**Math.max(0,Number(p)||0);return Math.round(i*a)/a}function Q$e(l,p){const i=Number(l),r=Math.abs(Number(p)||0);return r===0?i:Math.round(i/r)*r}function eLe(l,p,i){const r=Number(l),a=Number(p),c=Number(i);return Math.min(Math.max(r,a),c)}function tLe(l,p,i,r,a){const c=Number(l),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 iLe(...l){const p=l.map(r=>Number(r));return p.length===0?0:p.reduce((r,a)=>r+a,0)/p.length}function rLe(...l){const p=l.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 nLe(l,p){const i=Number(l),r=Number(p);return r===0?NaN:i<0&&r%2===1?-Math.pow(-i,1/r):Math.pow(i,1/r)}function aLe(l,p){const i=Number(l),r=Number(p);return i===0?1/0:(r-i)/i*100}const hi=l=>l.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class sLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(pe.Addition);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=hi(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 lLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(pe.Subtraction);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=hi(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 oLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(pe.Multiplication);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=hi(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 dLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(pe.Division);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=hi(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 uLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(pe.Remainder);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=hi(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 pLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(pe.Exponentiation);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=hi(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 cLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE,version:"1.0.0",description:"Number negate (unary -x)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Negate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(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 fLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE,version:"1.0.0",description:"Number absolute (|x|)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Absolute);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(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 yLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN,version:"1.0.0",description:"Number sign (-1 | 0 | 1)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Sign);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(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 hLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND,version:"1.0.0",description:"Number round to nearest integer",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Round);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.round(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class mLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR,version:"1.0.0",description:"Number floor (⌊x⌋)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Floor);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.floor(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class TLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL,version:"1.0.0",description:"Number ceil (⌈x⌉)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Ceil);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.ceil(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class vLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC,version:"1.0.0",description:"Number truncation (drop fractional part)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Trunc);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.trunc(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class ELe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS,version:"1.0.0",description:"Round to N decimals",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.RoundToDecimals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r),e=X$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class bLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.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:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.SnapToStep);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r),e=Q$e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class ALe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP,version:"1.0.0",description:"Clamp value to [min, max]",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Clamp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=hi(r),f=eLe(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class gLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE,version:"1.0.0",description:"Map value from [inMin,inMax] to [outMin,outMax]",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.MapRange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h]=hi(r),m=tLe(a,c,e,f,h);return{value:U.Success,error:null,result:m}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class ILe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE,version:"1.0.0",description:"Average(numbers...)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Average);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=hi(r),c=iLe(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class RLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN,version:"1.0.0",description:"Median(numbers...)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Median);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=hi(r),c=rLe(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class DLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF,version:"1.0.0",description:"Min(numbers...)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.MinOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=hi(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 wLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF,version:"1.0.0",description:"Max(numbers...)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.MaxOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=hi(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 CLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT,version:"1.0.0",description:"Square root",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.SquareRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.sqrt(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class OLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT,version:"1.0.0",description:"Cube root",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.CubeRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.cbrt(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class _Le extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT,version:"1.0.0",description:"Nth root (value, n)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.NthRoot);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r),e=nLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class VLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP,version:"1.0.0",description:"e^x",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Exp);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.exp(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class PLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL,version:"1.0.0",description:"Natural log ln(x)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.LogNatural);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.log(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class NLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10,version:"1.0.0",description:"Log base 10",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Log10);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(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 xLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN,version:"1.0.0",description:"sin(x in radians)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Sin);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.sin(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class $Le extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS,version:"1.0.0",description:"cos(x in radians)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Cos);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.cos(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class LLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN,version:"1.0.0",description:"tan(x in radians)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Tan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.tan(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class BLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN,version:"1.0.0",description:"asin(x)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Asin);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.asin(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class MLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS,version:"1.0.0",description:"acos(x)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Acos);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.acos(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class GLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN,version:"1.0.0",description:"atan(x)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Atan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Math.atan(Number(a))}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class jLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2,version:"1.0.0",description:"atan2(y, x)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.Atan2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(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 ULe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS,version:"1.0.0",description:"deg → rad",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.ToRadians);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Number(a)*Math.PI/180}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class kLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES,version:"1.0.0",description:"rad → deg",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.ToDegrees);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=hi(r);return{value:U.Success,error:null,result:Number(a)*180/Math.PI}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class FLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF,version:"1.0.0",description:"x percent of y",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.PercentOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(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 m_ extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE,version:"1.0.0",description:"((new-old)/old)*100",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.PercentageChange);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r),e=aLe(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class KLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN,version:"1.0.0",description:"a < b",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.LessThan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r);return{value:U.Success,error:null,result:a<c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class SLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN,version:"1.0.0",description:"a > b",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.MoreThan);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r);return{value:U.Success,error:null,result:a>c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class qLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL,version:"1.0.0",description:"a <= b",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.LessThanOrEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r);return{value:U.Success,error:null,result:a<=c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class ZLe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL,version:"1.0.0",description:"a >= b",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(pe.MoreThanOrEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=hi(r);return{value:U.Success,error:null,result:a>=c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}function HLe(l,p){return function(){return l.apply(p,arguments)}}const{toString:Ngi}=Object.prototype,{getPrototypeOf:$x}=Object,{iterator:e1,toStringTag:WLe}=Symbol,t1=(l=>p=>{const i=Ngi.call(p);return l[i]||(l[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Eo=l=>(l=l.toLowerCase(),p=>t1(p)===l),i1=l=>p=>typeof p===l,{isArray:Am}=Array,oh=i1("undefined");function nE(l){return l!==null&&!oh(l)&&l.constructor!==null&&!oh(l.constructor)&&Ja(l.constructor.isBuffer)&&l.constructor.isBuffer(l)}const zLe=Eo("ArrayBuffer");function xgi(l){let p;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?p=ArrayBuffer.isView(l):p=l&&l.buffer&&zLe(l.buffer),p}const $gi=i1("string"),Ja=i1("function"),YLe=i1("number"),aE=l=>l!==null&&typeof l=="object",Lgi=l=>l===!0||l===!1,FA=l=>{if(t1(l)!=="object")return!1;const p=$x(l);return(p===null||p===Object.prototype||Object.getPrototypeOf(p)===null)&&!(WLe in l)&&!(e1 in l)},Bgi=l=>{if(!aE(l)||nE(l))return!1;try{return Object.keys(l).length===0&&Object.getPrototypeOf(l)===Object.prototype}catch{return!1}},Mgi=Eo("Date"),Ggi=Eo("File"),jgi=Eo("Blob"),Ugi=Eo("FileList"),kgi=l=>aE(l)&&Ja(l.pipe),Fgi=l=>{let p;return l&&(typeof FormData=="function"&&l instanceof FormData||Ja(l.append)&&((p=t1(l))==="formdata"||p==="object"&&Ja(l.toString)&&l.toString()==="[object FormData]"))},Kgi=Eo("URLSearchParams"),[Sgi,qgi,Zgi,Hgi]=["ReadableStream","Request","Response","Headers"].map(Eo),Wgi=l=>l.trim?l.trim():l.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function sE(l,p,{allOwnKeys:i=!1}={}){if(l===null||typeof l>"u")return;let r,a;if(typeof l!="object"&&(l=[l]),Am(l))for(r=0,a=l.length;r<a;r++)p.call(null,l[r],r,l);else{if(nE(l))return;const c=i?Object.getOwnPropertyNames(l):Object.keys(l),e=c.length;let f;for(r=0;r<e;r++)f=c[r],p.call(null,l[f],f,l)}}function JLe(l,p){if(nE(l))return null;p=p.toLowerCase();const i=Object.keys(l);let r=i.length,a;for(;r-- >0;)if(a=i[r],p===a.toLowerCase())return a;return null}const Xc=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),XLe=l=>!oh(l)&&l!==Xc;function T_(){const{caseless:l,skipUndefined:p}=XLe(this)&&this||{},i={},r=(a,c)=>{const e=l&&JLe(i,c)||c;FA(i[e])&&FA(a)?i[e]=T_(i[e],a):FA(a)?i[e]=T_({},a):Am(a)?i[e]=a.slice():(!p||!oh(a))&&(i[e]=a)};for(let a=0,c=arguments.length;a<c;a++)arguments[a]&&sE(arguments[a],r);return i}const zgi=(l,p,i,{allOwnKeys:r}={})=>(sE(p,(a,c)=>{i&&Ja(a)?l[c]=HLe(a,i):l[c]=a},{allOwnKeys:r}),l),Ygi=l=>(l.charCodeAt(0)===65279&&(l=l.slice(1)),l),Jgi=(l,p,i,r)=>{l.prototype=Object.create(p.prototype,r),l.prototype.constructor=l,Object.defineProperty(l,"super",{value:p.prototype}),i&&Object.assign(l.prototype,i)},Xgi=(l,p,i,r)=>{let a,c,e;const f={};if(p=p||{},l==null)return p;do{for(a=Object.getOwnPropertyNames(l),c=a.length;c-- >0;)e=a[c],(!r||r(e,l,p))&&!f[e]&&(p[e]=l[e],f[e]=!0);l=i!==!1&&$x(l)}while(l&&(!i||i(l,p))&&l!==Object.prototype);return p},Qgi=(l,p,i)=>{l=String(l),(i===void 0||i>l.length)&&(i=l.length),i-=p.length;const r=l.indexOf(p,i);return r!==-1&&r===i},eIi=l=>{if(!l)return null;if(Am(l))return l;let p=l.length;if(!YLe(p))return null;const i=new Array(p);for(;p-- >0;)i[p]=l[p];return i},tIi=(l=>p=>l&&p instanceof l)(typeof Uint8Array<"u"&&$x(Uint8Array)),iIi=(l,p)=>{const r=(l&&l[e1]).call(l);let a;for(;(a=r.next())&&!a.done;){const c=a.value;p.call(l,c[0],c[1])}},rIi=(l,p)=>{let i;const r=[];for(;(i=l.exec(p))!==null;)r.push(i);return r},nIi=Eo("HTMLFormElement"),aIi=l=>l.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,r,a){return r.toUpperCase()+a}),gU=(({hasOwnProperty:l})=>(p,i)=>l.call(p,i))(Object.prototype),sIi=Eo("RegExp"),QLe=(l,p)=>{const i=Object.getOwnPropertyDescriptors(l),r={};sE(i,(a,c)=>{let e;(e=p(a,c,l))!==!1&&(r[c]=e||a)}),Object.defineProperties(l,r)},lIi=l=>{QLe(l,(p,i)=>{if(Ja(l)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const r=l[i];if(Ja(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+"'")})}})},oIi=(l,p)=>{const i={},r=a=>{a.forEach(c=>{i[c]=!0})};return Am(l)?r(l):r(String(l).split(p)),i},dIi=()=>{},uIi=(l,p)=>l!=null&&Number.isFinite(l=+l)?l:p;function pIi(l){return!!(l&&Ja(l.append)&&l[WLe]==="FormData"&&l[e1])}const cIi=l=>{const p=new Array(10),i=(r,a)=>{if(aE(r)){if(p.indexOf(r)>=0)return;if(nE(r))return r;if(!("toJSON"in r)){p[a]=r;const c=Am(r)?[]:{};return sE(r,(e,f)=>{const h=i(e,a+1);!oh(h)&&(c[f]=h)}),p[a]=void 0,c}}return r};return i(l,0)},fIi=Eo("AsyncFunction"),yIi=l=>l&&(aE(l)||Ja(l))&&Ja(l.then)&&Ja(l.catch),e2e=((l,p)=>l?setImmediate:p?((i,r)=>(Xc.addEventListener("message",({source:a,data:c})=>{a===Xc&&c===i&&r.length&&r.shift()()},!1),a=>{r.push(a),Xc.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",Ja(Xc.postMessage)),hIi=typeof queueMicrotask<"u"?queueMicrotask.bind(Xc):typeof process<"u"&&process.nextTick||e2e,mIi=l=>l!=null&&Ja(l[e1]),qe={isArray:Am,isArrayBuffer:zLe,isBuffer:nE,isFormData:Fgi,isArrayBufferView:xgi,isString:$gi,isNumber:YLe,isBoolean:Lgi,isObject:aE,isPlainObject:FA,isEmptyObject:Bgi,isReadableStream:Sgi,isRequest:qgi,isResponse:Zgi,isHeaders:Hgi,isUndefined:oh,isDate:Mgi,isFile:Ggi,isBlob:jgi,isRegExp:sIi,isFunction:Ja,isStream:kgi,isURLSearchParams:Kgi,isTypedArray:tIi,isFileList:Ugi,forEach:sE,merge:T_,extend:zgi,trim:Wgi,stripBOM:Ygi,inherits:Jgi,toFlatObject:Xgi,kindOf:t1,kindOfTest:Eo,endsWith:Qgi,toArray:eIi,forEachEntry:iIi,matchAll:rIi,isHTMLForm:nIi,hasOwnProperty:gU,hasOwnProp:gU,reduceDescriptors:QLe,freezeMethods:lIi,toObjectSet:oIi,toCamelCase:aIi,noop:dIi,toFiniteNumber:uIi,findKey:JLe,global:Xc,isContextDefined:XLe,isSpecCompliantForm:pIi,toJSONObject:cIi,isAsyncFn:fIi,isThenable:yIi,setImmediate:e2e,asap:hIi,isIterable:mIi};function fi(l,p,i,r,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=l,this.name="AxiosError",p&&(this.code=p),i&&(this.config=i),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}qe.inherits(fi,Error,{toJSON:function(){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}}});const t2e=fi.prototype,i2e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(l=>{i2e[l]={value:l}});Object.defineProperties(fi,i2e);Object.defineProperty(t2e,"isAxiosError",{value:!0});fi.from=(l,p,i,r,a,c)=>{const e=Object.create(t2e);qe.toFlatObject(l,e,function(E){return E!==Error.prototype},m=>m!=="isAxiosError");const f=l&&l.message?l.message:"Error",h=p==null&&l?l.code:p;return fi.call(e,f,h,i,r,a),l&&e.cause==null&&Object.defineProperty(e,"cause",{value:l,configurable:!0}),e.name=l&&l.name||"Error",c&&Object.assign(e,c),e};const TIi=null;function v_(l){return qe.isPlainObject(l)||qe.isArray(l)}function r2e(l){return qe.endsWith(l,"[]")?l.slice(0,-2):l}function IU(l,p,i){return l?l.concat(p).map(function(a,c){return a=r2e(a),!i&&c?"["+a+"]":a}).join(i?".":""):p}function vIi(l){return qe.isArray(l)&&!l.some(v_)}const EIi=qe.toFlatObject(qe,{},null,function(p){return/^is[A-Z]/.test(p)});function r1(l,p,i){if(!qe.isObject(l))throw new TypeError("target must be an object");p=p||new FormData,i=qe.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(L,j){return!qe.isUndefined(j[L])});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($){if($===null)return"";if(qe.isDate($))return $.toISOString();if(qe.isBoolean($))return $.toString();if(!h&&qe.isBlob($))throw new fi("Blob is not supported. Use a Buffer instead.");return qe.isArrayBuffer($)||qe.isTypedArray($)?h&&typeof Blob=="function"?new Blob([$]):Buffer.from($):$}function E($,L,j){let k=$;if($&&!j&&typeof $=="object"){if(qe.endsWith(L,"{}"))L=r?L:L.slice(0,-2),$=JSON.stringify($);else if(qe.isArray($)&&vIi($)||(qe.isFileList($)||qe.endsWith(L,"[]"))&&(k=qe.toArray($)))return L=r2e(L),k.forEach(function(H,ie){!(qe.isUndefined(H)||H===null)&&p.append(e===!0?IU([L],ie,c):e===null?L:L+"[]",m(H))}),!1}return v_($)?!0:(p.append(IU(j,L,c),m($)),!1)}const b=[],g=Object.assign(EIi,{defaultVisitor:E,convertValue:m,isVisitable:v_});function _($,L){if(!qe.isUndefined($)){if(b.indexOf($)!==-1)throw Error("Circular reference detected in "+L.join("."));b.push($),qe.forEach($,function(k,G){(!(qe.isUndefined(k)||k===null)&&a.call(p,k,qe.isString(G)?G.trim():G,L,g))===!0&&_(k,L?L.concat(G):[G])}),b.pop()}}if(!qe.isObject(l))throw new TypeError("data must be an object");return _(l),p}function RU(l){const p={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(l).replace(/[!'()~]|%20|%00/g,function(r){return p[r]})}function Lx(l,p){this._pairs=[],l&&r1(l,this,p)}const n2e=Lx.prototype;n2e.append=function(p,i){this._pairs.push([p,i])};n2e.toString=function(p){const i=p?function(r){return p.call(this,r,RU)}:RU;return this._pairs.map(function(a){return i(a[0])+"="+i(a[1])},"").join("&")};function bIi(l){return encodeURIComponent(l).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function a2e(l,p,i){if(!p)return l;const r=i&&i.encode||bIi;qe.isFunction(i)&&(i={serialize:i});const a=i&&i.serialize;let c;if(a?c=a(p,i):c=qe.isURLSearchParams(p)?p.toString():new Lx(p,i).toString(r),c){const e=l.indexOf("#");e!==-1&&(l=l.slice(0,e)),l+=(l.indexOf("?")===-1?"?":"&")+c}return l}class AIi{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 DU=AIi,s2e={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gIi=typeof URLSearchParams<"u"?URLSearchParams:Lx,IIi=typeof FormData<"u"?FormData:null,RIi=typeof Blob<"u"?Blob:null,DIi={isBrowser:!0,classes:{URLSearchParams:gIi,FormData:IIi,Blob:RIi},protocols:["http","https","file","blob","url","data"]},Bx=typeof window<"u"&&typeof document<"u",E_=typeof navigator=="object"&&navigator||void 0,wIi=Bx&&(!E_||["ReactNative","NativeScript","NS"].indexOf(E_.product)<0),CIi=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),OIi=Bx&&window.location.href||"http://localhost",_Ii=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Bx,hasStandardBrowserEnv:wIi,hasStandardBrowserWebWorkerEnv:CIi,navigator:E_,origin:OIi},Symbol.toStringTag,{value:"Module"})),ca={..._Ii,...DIi};function VIi(l,p){return r1(l,new ca.classes.URLSearchParams,{visitor:function(i,r,a,c){return ca.isNode&&qe.isBuffer(i)?(this.append(r,i.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)},...p})}function PIi(l){return qe.matchAll(/\w+|\[(\w*)]/g,l).map(p=>p[0]==="[]"?"":p[1]||p[0])}function NIi(l){const p={},i=Object.keys(l);let r;const a=i.length;let c;for(r=0;r<a;r++)c=i[r],p[c]=l[c];return p}function l2e(l){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]=NIi(a[e])),!f)}if(qe.isFormData(l)&&qe.isFunction(l.entries)){const i={};return qe.forEachEntry(l,(r,a)=>{p(PIi(r),a,i,0)}),i}return null}function xIi(l,p,i){if(qe.isString(l))try{return(p||JSON.parse)(l),qe.trim(l)}catch(r){if(r.name!=="SyntaxError")throw r}return(i||JSON.stringify)(l)}const Mx={transitional:s2e,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(l2e(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 VIi(p,this.formSerializer).toString();if((f=qe.isFileList(p))||r.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return r1(f?{"files[]":p}:p,h&&new h,this.formSerializer)}}return c||a?(i.setContentType("application/json",!1),xIi(p)):p}],transformResponse:[function(p){const i=this.transitional||Mx.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"?fi.from(f,fi.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:ca.classes.FormData,Blob:ca.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"],l=>{Mx.headers[l]={}});const Gx=Mx,$Ii=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"]),LIi=l=>{const p={};let i,r,a;return l&&l.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]&&$Ii[i])&&(i==="set-cookie"?p[i]?p[i].push(r):p[i]=[r]:p[i]=p[i]?p[i]+", "+r:r)}),p},wU=Symbol("internals");function w0(l){return l&&String(l).trim().toLowerCase()}function KA(l){return l===!1||l==null?l:qe.isArray(l)?l.map(KA):String(l)}function BIi(l){const p=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=i.exec(l);)p[r[1]]=r[2];return p}const MIi=l=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(l.trim());function xO(l,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 GIi(l){return l.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(p,i,r)=>i.toUpperCase()+r)}function jIi(l,p){const i=qe.toCamelCase(" "+p);["get","set","has"].forEach(r=>{Object.defineProperty(l,r+i,{value:function(a,c,e){return this[r].call(this,p,a,c,e)},configurable:!0})})}class n1{constructor(p){p&&this.set(p)}set(p,i,r){const a=this;function c(f,h,m){const E=w0(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]=KA(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())&&!MIi(p))e(LIi(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=w0(p),p){const r=qe.findKey(this,p);if(r){const a=this[r];if(!i)return a;if(i===!0)return BIi(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=w0(p),p){const r=qe.findKey(this,p);return!!(r&&this[r]!==void 0&&(!i||xO(this,this[r],r,i)))}return!1}delete(p,i){const r=this;let a=!1;function c(e){if(e=w0(e),e){const f=qe.findKey(r,e);f&&(!i||xO(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||xO(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]=KA(a),delete i[c];return}const f=p?GIi(c):String(c).trim();f!==c&&delete i[c],i[f]=KA(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[wU]=this[wU]={accessors:{}}).accessors,a=this.prototype;function c(e){const f=w0(e);r[f]||(jIi(a,e),r[f]=!0)}return qe.isArray(p)?p.forEach(c):c(p),this}}n1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);qe.reduceDescriptors(n1.prototype,({value:l},p)=>{let i=p[0].toUpperCase()+p.slice(1);return{get:()=>l,set(r){this[i]=r}}});qe.freezeMethods(n1);const Gl=n1;function $O(l,p){const i=this||Gx,r=p||i,a=Gl.from(r.headers);let c=r.data;return qe.forEach(l,function(f){c=f.call(i,c,a.normalize(),p?p.status:void 0)}),a.normalize(),c}function o2e(l){return!!(l&&l.__CANCEL__)}function gm(l,p,i){fi.call(this,l??"canceled",fi.ERR_CANCELED,p,i),this.name="CanceledError"}qe.inherits(gm,fi,{__CANCEL__:!0});function d2e(l,p,i){const r=i.config.validateStatus;!i.status||!r||r(i.status)?l(i):p(new fi("Request failed with status code "+i.status,[fi.ERR_BAD_REQUEST,fi.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}function UIi(l){const p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l);return p&&p[1]||""}function kIi(l,p){l=l||10;const i=new Array(l),r=new Array(l);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,g=0;for(;b!==a;)g+=i[b++],b=b%l;if(a=(a+1)%l,a===c&&(c=(c+1)%l),m-e<p)return;const _=E&&m-E;return _?Math.round(g*1e3/_):void 0}}function FIi(l,p){let i=0,r=1e3/p,a,c;const e=(m,E=Date.now())=>{i=E,a=null,c&&(clearTimeout(c),c=null),l(...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 yg=(l,p,i=3)=>{let r=0;const a=kIi(50,250);return FIi(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};l(b)},i)},CU=(l,p)=>{const i=l!=null;return[r=>p[0]({lengthComputable:i,total:l,loaded:r}),p[1]]},OU=l=>(...p)=>qe.asap(()=>l(...p)),KIi=ca.hasStandardBrowserEnv?((l,p)=>i=>(i=new URL(i,ca.origin),l.protocol===i.protocol&&l.host===i.host&&(p||l.port===i.port)))(new URL(ca.origin),ca.navigator&&/(msie|trident)/i.test(ca.navigator.userAgent)):()=>!0,SIi=ca.hasStandardBrowserEnv?{write(l,p,i,r,a,c,e){if(typeof document>"u")return;const f=[`${l}=${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(l){if(typeof document>"u")return null;const p=document.cookie.match(new RegExp("(?:^|; )"+l+"=([^;]*)"));return p?decodeURIComponent(p[1]):null},remove(l){this.write(l,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function qIi(l){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(l)}function ZIi(l,p){return p?l.replace(/\/?\/$/,"")+"/"+p.replace(/^\/+/,""):l}function u2e(l,p,i){let r=!qIi(p);return l&&(r||i==!1)?ZIi(l,p):p}const _U=l=>l instanceof Gl?{...l}:l;function of(l,p){p=p||{};const i={};function r(m,E,b,g){return qe.isPlainObject(m)&&qe.isPlainObject(E)?qe.merge.call({caseless:g},m,E):qe.isPlainObject(E)?qe.merge({},E):qe.isArray(E)?E.slice():E}function a(m,E,b,g){if(qe.isUndefined(E)){if(!qe.isUndefined(m))return r(void 0,m,b,g)}else return r(m,E,b,g)}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 l)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(_U(m),_U(E),b,!0)};return qe.forEach(Object.keys({...l,...p}),function(E){const b=h[E]||a,g=b(l[E],p[E],E);qe.isUndefined(g)&&b!==f||(i[E]=g)}),i}const p2e=l=>{const p=of({},l);let{data:i,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:c,headers:e,auth:f}=p;if(p.headers=e=Gl.from(e),p.url=a2e(u2e(p.baseURL,p.url,p.allowAbsoluteUrls),l.params,l.paramsSerializer),f&&e.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):""))),qe.isFormData(i)){if(ca.hasStandardBrowserEnv||ca.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(ca.hasStandardBrowserEnv&&(r&&qe.isFunction(r)&&(r=r(p)),r||r!==!1&&KIi(p.url))){const h=a&&c&&SIi.read(c);h&&e.set(a,h)}return p},HIi=typeof XMLHttpRequest<"u",WIi=HIi&&function(l){return new Promise(function(i,r){const a=p2e(l);let c=a.data;const e=Gl.from(a.headers).normalize();let{responseType:f,onUploadProgress:h,onDownloadProgress:m}=a,E,b,g,_,$;function L(){_&&_(),$&&$(),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 k(){if(!j)return;const H=Gl.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),ee={data:!f||f==="text"||f==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:H,config:l,request:j};d2e(function(ae){i(ae),L()},function(ae){r(ae),L()},ee),j=null}"onloadend"in j?j.onloadend=k:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(k)},j.onabort=function(){j&&(r(new fi("Request aborted",fi.ECONNABORTED,l,j)),j=null)},j.onerror=function(ie){const ee=ie&&ie.message?ie.message:"Network Error",ue=new fi(ee,fi.ERR_NETWORK,l,j);ue.event=ie||null,r(ue),j=null},j.ontimeout=function(){let ie=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const ee=a.transitional||s2e;a.timeoutErrorMessage&&(ie=a.timeoutErrorMessage),r(new fi(ie,ee.clarifyTimeoutError?fi.ETIMEDOUT:fi.ECONNABORTED,l,j)),j=null},c===void 0&&e.setContentType(null),"setRequestHeader"in j&&qe.forEach(e.toJSON(),function(ie,ee){j.setRequestHeader(ee,ie)}),qe.isUndefined(a.withCredentials)||(j.withCredentials=!!a.withCredentials),f&&f!=="json"&&(j.responseType=a.responseType),m&&([g,$]=yg(m,!0),j.addEventListener("progress",g)),h&&j.upload&&([b,_]=yg(h),j.upload.addEventListener("progress",b),j.upload.addEventListener("loadend",_)),(a.cancelToken||a.signal)&&(E=H=>{j&&(r(!H||H.type?new gm(null,l,j):H),j.abort(),j=null)},a.cancelToken&&a.cancelToken.subscribe(E),a.signal&&(a.signal.aborted?E():a.signal.addEventListener("abort",E)));const G=UIi(a.url);if(G&&ca.protocols.indexOf(G)===-1){r(new fi("Unsupported protocol "+G+":",fi.ERR_BAD_REQUEST,l));return}j.send(c||null)})},zIi=(l,p)=>{const{length:i}=l=l?l.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 fi?E:new gm(E instanceof Error?E.message:E))}};let e=p&&setTimeout(()=>{e=null,c(new fi(`timeout ${p} of ms exceeded`,fi.ETIMEDOUT))},p);const f=()=>{l&&(e&&clearTimeout(e),e=null,l.forEach(m=>{m.unsubscribe?m.unsubscribe(c):m.removeEventListener("abort",c)}),l=null)};l.forEach(m=>m.addEventListener("abort",c));const{signal:h}=r;return h.unsubscribe=()=>qe.asap(f),h}},YIi=zIi,JIi=function*(l,p){let i=l.byteLength;if(!p||i<p){yield l;return}let r=0,a;for(;r<i;)a=r+p,yield l.slice(r,a),r=a},XIi=async function*(l,p){for await(const i of QIi(l))yield*JIi(i,p)},QIi=async function*(l){if(l[Symbol.asyncIterator]){yield*l;return}const p=l.getReader();try{for(;;){const{done:i,value:r}=await p.read();if(i)break;yield r}}finally{await p.cancel()}},VU=(l,p,i,r)=>{const a=XIi(l,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 g=c+=b;i(g)}h.enqueue(new Uint8Array(E))}catch(m){throw f(m),m}},cancel(h){return f(h),a.return()}},{highWaterMark:2})},PU=64*1024,{isFunction:$A}=qe,eRi=(({Request:l,Response:p})=>({Request:l,Response:p}))(qe.global),{ReadableStream:NU,TextEncoder:xU}=qe.global,$U=(l,...p)=>{try{return!!l(...p)}catch{return!1}},tRi=l=>{l=qe.merge.call({skipUndefined:!0},eRi,l);const{fetch:p,Request:i,Response:r}=l,a=p?$A(p):typeof fetch=="function",c=$A(i),e=$A(r);if(!a)return!1;const f=a&&$A(NU),h=a&&(typeof xU=="function"?($=>L=>$.encode(L))(new xU):async $=>new Uint8Array(await new i($).arrayBuffer())),m=c&&f&&$U(()=>{let $=!1;const L=new i(ca.origin,{body:new NU,method:"POST",get duplex(){return $=!0,"half"}}).headers.has("Content-Type");return $&&!L}),E=e&&f&&$U(()=>qe.isReadableStream(new r("").body)),b={stream:E&&($=>$.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach($=>{!b[$]&&(b[$]=(L,j)=>{let k=L&&L[$];if(k)return k.call(L);throw new fi(`Response type '${$}' is not supported`,fi.ERR_NOT_SUPPORT,j)})});const g=async $=>{if($==null)return 0;if(qe.isBlob($))return $.size;if(qe.isSpecCompliantForm($))return(await new i(ca.origin,{method:"POST",body:$}).arrayBuffer()).byteLength;if(qe.isArrayBufferView($)||qe.isArrayBuffer($))return $.byteLength;if(qe.isURLSearchParams($)&&($=$+""),qe.isString($))return(await h($)).byteLength},_=async($,L)=>{const j=qe.toFiniteNumber($.getContentLength());return j??g(L)};return async $=>{let{url:L,method:j,data:k,signal:G,cancelToken:H,timeout:ie,onDownloadProgress:ee,onUploadProgress:ue,responseType:ae,headers:de,withCredentials:ce="same-origin",fetchOptions:ne}=p2e($),le=p||fetch;ae=ae?(ae+"").toLowerCase():"text";let Q=YIi([G,H&&H.toAbortSignal()],ie),oe=null;const Ee=Q&&Q.unsubscribe&&(()=>{Q.unsubscribe()});let Te;try{if(ue&&m&&j!=="get"&&j!=="head"&&(Te=await _(de,k))!==0){let Je=new i(L,{method:"POST",body:k,duplex:"half"}),rt;if(qe.isFormData(k)&&(rt=Je.headers.get("content-type"))&&de.setContentType(rt),Je.body){const[Rt,Et]=CU(Te,yg(OU(ue)));k=VU(Je.body,PU,Rt,Et)}}qe.isString(ce)||(ce=ce?"include":"omit");const Ve=c&&"credentials"in i.prototype,Le={...ne,signal:Q,method:j.toUpperCase(),headers:de.normalize().toJSON(),body:k,duplex:"half",credentials:Ve?ce:void 0};oe=c&&new i(L,Le);let $e=await(c?le(oe,ne):le(L,Le));const ke=E&&(ae==="stream"||ae==="response");if(E&&(ee||ke&&Ee)){const Je={};["status","statusText","headers"].forEach(Xt=>{Je[Xt]=$e[Xt]});const rt=qe.toFiniteNumber($e.headers.get("content-length")),[Rt,Et]=ee&&CU(rt,yg(OU(ee),!0))||[];$e=new r(VU($e.body,PU,Rt,()=>{Et&&Et(),Ee&&Ee()}),Je)}ae=ae||"text";let Ke=await b[qe.findKey(b,ae)||"text"]($e,$);return!ke&&Ee&&Ee(),await new Promise((Je,rt)=>{d2e(Je,rt,{data:Ke,headers:Gl.from($e.headers),status:$e.status,statusText:$e.statusText,config:$,request:oe})})}catch(Ve){throw Ee&&Ee(),Ve&&Ve.name==="TypeError"&&/Load failed|fetch/i.test(Ve.message)?Object.assign(new fi("Network Error",fi.ERR_NETWORK,$,oe),{cause:Ve.cause||Ve}):fi.from(Ve,Ve&&Ve.code,$,oe)}}},iRi=new Map,c2e=l=>{let p=l&&l.env||{};const{fetch:i,Request:r,Response:a}=p,c=[r,a,i];let e=c.length,f=e,h,m,E=iRi;for(;f--;)h=c[f],m=E.get(h),m===void 0&&E.set(h,m=f?new Map:tRi(p)),E=m;return m};c2e();const jx={http:TIi,xhr:WIi,fetch:{get:c2e}};qe.forEach(jx,(l,p)=>{if(l){try{Object.defineProperty(l,"name",{value:p})}catch{}Object.defineProperty(l,"adapterName",{value:p})}});const LU=l=>`- ${l}`,rRi=l=>qe.isFunction(l)||l===null||l===!1;function nRi(l,p){l=qe.isArray(l)?l:[l];const{length:i}=l;let r,a;const c={};for(let e=0;e<i;e++){r=l[e];let f;if(a=r,!rRi(r)&&(a=jx[(f=String(r)).toLowerCase()],a===void 0))throw new fi(`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(LU).join(`
|
|
53
53
|
`):" "+LU(e[0]):"as no adapter specified";throw new fi("There is no suitable adapter to dispatch the request "+f,"ERR_NOT_SUPPORT")}return a}const f2e={getAdapter:nRi,adapters:jx};function LO(l){if(l.cancelToken&&l.cancelToken.throwIfRequested(),l.signal&&l.signal.aborted)throw new gm(null,l)}function BU(l){return LO(l),l.headers=Gl.from(l.headers),l.data=$O.call(l,l.transformRequest),["post","put","patch"].indexOf(l.method)!==-1&&l.headers.setContentType("application/x-www-form-urlencoded",!1),f2e.getAdapter(l.adapter||Gx.adapter,l)(l).then(function(r){return LO(l),r.data=$O.call(l,l.transformResponse,r),r.headers=Gl.from(r.headers),r},function(r){return o2e(r)||(LO(l),r&&r.response&&(r.response.data=$O.call(l,l.transformResponse,r.response),r.response.headers=Gl.from(r.response.headers))),Promise.reject(r)})}const y2e="1.13.2",a1={};["object","boolean","number","function","string","symbol"].forEach((l,p)=>{a1[l]=function(r){return typeof r===l||"a"+(p<1?"n ":" ")+l}});const MU={};a1.transitional=function(p,i,r){function a(c,e){return"[Axios v"+y2e+"] Transitional option '"+c+"'"+e+(r?". "+r:"")}return(c,e,f)=>{if(p===!1)throw new fi(a(e," has been removed"+(i?" in "+i:"")),fi.ERR_DEPRECATED);return i&&!MU[e]&&(MU[e]=!0,console.warn(a(e," has been deprecated since v"+i+" and will be removed in the near future"))),p?p(c,e,f):!0}};a1.spelling=function(p){return(i,r)=>(console.warn(`${r} is likely a misspelling of ${p}`),!0)};function aRi(l,p,i){if(typeof l!="object")throw new fi("options must be an object",fi.ERR_BAD_OPTION_VALUE);const r=Object.keys(l);let a=r.length;for(;a-- >0;){const c=r[a],e=p[c];if(e){const f=l[c],h=f===void 0||e(f,c,l);if(h!==!0)throw new fi("option "+c+" must be "+h,fi.ERR_BAD_OPTION_VALUE);continue}if(i!==!0)throw new fi("Unknown option "+c,fi.ERR_BAD_OPTION)}}const SA={assertOptions:aRi,validators:a1},jo=SA.validators;class hg{constructor(p){this.defaults=p||{},this.interceptors={request:new DU,response:new DU}}async request(p,i){try{return await this._request(p,i)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const c=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?c&&!String(r.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
54
|
-
`+c):r.stack=c}catch{}}throw r}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=of(this.defaults,i);const{transitional:r,paramsSerializer:a,headers:c}=i;r!==void 0&&SA.assertOptions(r,{silentJSONParsing:jo.transitional(jo.boolean),forcedJSONParsing:jo.transitional(jo.boolean),clarifyTimeoutError:jo.transitional(jo.boolean)},!1),a!=null&&(qe.isFunction(a)?i.paramsSerializer={serialize:a}:SA.assertOptions(a,{encode:jo.function,serialize:jo.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),SA.assertOptions(i,{baseUrl:jo.spelling("baseURL"),withXsrfToken:jo.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&qe.merge(c.common,c[i.method]);c&&qe.forEach(["delete","get","head","post","put","patch","common"],$=>{delete c[$]}),i.headers=Gl.concat(e,c);const f=[];let h=!0;this.interceptors.request.forEach(function(L){typeof L.runWhen=="function"&&L.runWhen(i)===!1||(h=h&&L.synchronous,f.unshift(L.fulfilled,L.rejected))});const m=[];this.interceptors.response.forEach(function(L){m.push(L.fulfilled,L.rejected)});let E,b=0,g;if(!h){const $=[BU.bind(this),void 0];for($.unshift(...f),$.push(...m),g=$.length,E=Promise.resolve(i);b<g;)E=E.then($[b++],$[b++]);return E}g=f.length;let _=i;for(;b<g;){const $=f[b++],L=f[b++];try{_=$(_)}catch(j){L.call(this,j);break}}try{E=BU.call(this,_)}catch($){return Promise.reject($)}for(b=0,g=m.length;b<g;)E=E.then(m[b++],m[b++]);return E}getUri(p){p=of(this.defaults,p);const i=u2e(p.baseURL,p.url,p.allowAbsoluteUrls);return a2e(i,p.params,p.paramsSerializer)}}qe.forEach(["delete","get","head","options"],function(p){hg.prototype[p]=function(i,r){return this.request(of(r||{},{method:p,url:i,data:(r||{}).data}))}});qe.forEach(["post","put","patch"],function(p){function i(r){return function(c,e,f){return this.request(of(f||{},{method:p,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}hg.prototype[p]=i(),hg.prototype[p+"Form"]=i(!0)});const qA=hg;class Ux{constructor(p){if(typeof p!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const r=this;this.promise.then(a=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](a);r._listeners=null}),this.promise.then=a=>{let c;const e=new Promise(f=>{r.subscribe(f),c=f}).then(a);return e.cancel=function(){r.unsubscribe(c)},e},p(function(c,e,f){r.reason||(r.reason=new gm(c,e,f),i(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(p){if(this.reason){p(this.reason);return}this._listeners?this._listeners.push(p):this._listeners=[p]}unsubscribe(p){if(!this._listeners)return;const i=this._listeners.indexOf(p);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const p=new AbortController,i=r=>{p.abort(r)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new Ux(function(a){p=a}),cancel:p}}}const sRi=Ux;function lRi(l){return function(i){return l.apply(null,i)}}function oRi(l){return qe.isObject(l)&&l.isAxiosError===!0}const b_={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(b_).forEach(([l,p])=>{b_[p]=l});const dRi=b_;function h2e(l){const p=new qA(l),i=HLe(qA.prototype.request,p);return qe.extend(i,qA.prototype,p,{allOwnKeys:!0}),qe.extend(i,p,null,{allOwnKeys:!0}),i.create=function(a){return h2e(of(l,a))},i}const Nn=h2e(Gx);Nn.Axios=qA;Nn.CanceledError=gm;Nn.CancelToken=sRi;Nn.isCancel=o2e;Nn.VERSION=y2e;Nn.toFormData=r1;Nn.AxiosError=fi;Nn.Cancel=Nn.CanceledError;Nn.all=function(p){return Promise.all(p)};Nn.spread=lRi;Nn.isAxiosError=oRi;Nn.mergeConfig=of;Nn.AxiosHeaders=Gl;Nn.formToJSON=l=>l2e(qe.isHTMLForm(l)?new FormData(l):l);Nn.getAdapter=f2e.getAdapter;Nn.HttpStatusCode=dRi;Nn.default=Nn;const uRi=Nn;class m2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(na.HttpRequest);a&&(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[3]||{},e={method:a[0],url:a[1],params:a[2],headers:c,data:a[4]};z.Logger.log("Axios request config: ",e);const f=await uRi(e);return{value:U.Success,error:null,result:{status:f.status,headers:f.headers,data:f.data}}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class T2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.Validate);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)});z.Logger.log("Inputs for entity validation: ",a);const e=Y1(a[1]).safeParse(a[0]);return e.success?{value:U.Success,error:null,result:{data:a[0]}}:{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e.error.errors,result:null}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const Ba=l=>l.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class v2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.ReadKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ba(r),e=F_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class E2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.WriteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=K_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class b2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.DeleteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ba(r),e=S_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class A2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.ReadNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=q_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class g2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY,version:"1.0.0",description:"Entity write-nested-key operation implementation module (immutable, no auto-create)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.WriteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=Z_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class I2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY,version:"1.0.0",description:"Entity write-safe-nested-key-recursively operation implementation module (immutable, auto-create)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.WriteSafeNestedKeyRecursively);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=H_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class R2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.DeleteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ba(r),e=W_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class D2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.HasKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ba(r),e=z_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class w2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.KeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=Y_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class C2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.HasNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ba(r),e=J_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class O2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.NestedKeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=X_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class _2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.IsInstanceOfType);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m,E,b,g,_;try{const $=((c=(a=r[0])==null?void 0:a.value)==null?void 0:c.parent)||((f=(e=r[0])==null?void 0:e.value)==null?void 0:f.standaloneParent),L=(m=(h=r[0])==null?void 0:h.value)==null?void 0:m.value,j=(b=(E=r[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!L)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!j)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!$)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(j.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const k=$.getDataType(null);if(((g=k==null?void 0:k.entity)==null?void 0:g.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let G=!1;return((_=k==null?void 0:k.entity)==null?void 0:_.id)!==(j==null?void 0:j.id)?G=!1:Y1(k==null?void 0:k.entity).safeParse(L).success?G=!0:G=!1,{value:U.Success,error:null,result:G}}catch($){return{value:U.UnhandledError,error:$,result:null}}}})}}class V2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Merge);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=Ba(r),c=Q_e(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class P2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Keys);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ba(r),c=eVe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class N2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Values);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ba(r),c=tVe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class x2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Entries);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ba(r),c=iVe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}let As=null;try{As=require("crypto")}catch{}const DT=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:As&&As.webcrypto?As.webcrypto:null,ap=DT?DT.subtle:null;function jT(l){const p=new ArrayBuffer(l.byteLength);return new Uint8Array(p).set(l),p}function rn(l,p="utf8"){if(l instanceof Uint8Array)return l;const i=String(l);if(p==="utf8"){if(typeof TextEncoder<"u")return new TextEncoder().encode(i);if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"utf8"))}else if(p==="hex"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"hex"))}else if(p==="base64"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"base64"))}else if(p==="base64url"){const r=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(r,"base64"));const a=typeof atob=="function"?atob(r):"",c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function bo(l,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(l);if(typeof Buffer<"u")return Buffer.from(l).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(l).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(l).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(l).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const $2e=l=>rn(l,"base64"),L2e=(l,p)=>{const i=l instanceof Uint8Array?l:rn(String(l),p||"utf8");return bo(i,"base64")},dh=(l,p)=>{const i=l instanceof Uint8Array?l:rn(String(l),p||"utf8");return bo(i,"base64url")},df=l=>rn(l,"base64url"),B2e=(l,p)=>{const i=l instanceof Uint8Array?l:rn(String(l),p||"utf8");return bo(i,"hex")},M2e=l=>rn(l,"hex");function kx(l){if(DT&&DT.getRandomValues){const p=new Uint8Array(l);return DT.getRandomValues(p),p}if(As&&As.randomBytes)return new Uint8Array(As.randomBytes(l));throw new Error("Secure random not available")}function s1(l,p){if(!(l instanceof Uint8Array)||!(p instanceof Uint8Array)||l.length!==p.length)return!1;let i=0;for(let r=0;r<l.length;r++)i|=l[r]^p[r];return i===0}function G2e(l,p,i,r){if((typeof l!="string"||typeof p!="string")&&typeof l!="string"&&typeof p!="string")throw new Error("Invalid input types");const a=i??"utf8",c=r??"utf8",e=rn(l??"",a),f=rn(p??"",c);return s1(e,f)}async function j2e(l,p){if(ap){const i=await ap.digest({name:l},jT(p));return new Uint8Array(i)}if(As){const i=l.replace("SHA-","sha"),r=As.createHash(i);return r.update(Buffer.from(p)),new Uint8Array(r.digest())}throw new Error("Hash not available")}async function U2e(l,p,i,r){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const a=String(l??"SHA-256"),c=i??"utf8",e=r??"base64url",f=rn(p??"",c),h=await j2e(a,f);return bo(h,e)}async function l1(l,p,i){if(ap){const r=await ap.importKey("raw",jT(p),{name:"HMAC",hash:{name:l}},!1,["sign"]),a=await ap.sign("HMAC",r,jT(i));return new Uint8Array(a)}if(As){const r=`sha${l.split("-")[1]}`,a=As.createHmac(r,Buffer.from(p));return a.update(Buffer.from(i)),new Uint8Array(a.digest())}throw new Error("HMAC not available")}async function k2e(l,p,i,r,a,c){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),f=r??"utf8",h=a??"utf8",m=c??"base64url",E=rn(l??"",f),b=rn(p??"",h),g=await l1(e,E,b);return bo(g,m)}async function o1(l,p,{iterations:i,length:r,hashAlg:a="SHA-256"}){if(ap){const c=await ap.importKey("raw",jT(l),"PBKDF2",!1,["deriveBits"]),e=await ap.deriveBits({name:"PBKDF2",salt:jT(p),iterations:i,hash:a},c,r*8);return new Uint8Array(e)}if(As){const c=a==="SHA-512"?"sha512":"sha256";return await new Promise((e,f)=>{As.pbkdf2(Buffer.from(l),Buffer.from(p),i,r,c,(h,m)=>{h?f(h):e(new Uint8Array(m))})})}throw new Error("PBKDF2 not available")}async function F2e(l,p,i,r,a,c,e,f){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const h=c??"utf8",m=e??"utf8",E=f??"base64url",b=Math.max(1,Number(i)||21e4),g=Math.max(1,Number(r)||32),_=a??"SHA-256",$=rn(l??"",h),L=rn(p??"",m),j=await o1($,L,{iterations:b,length:g,hashAlg:_});return bo(j,E)}async function K2e(l,p=kx(16),i=21e4,r=32,a="SHA-256"){const c=rn(l,"utf8"),e=await o1(c,p,{iterations:i,length:r,hashAlg:a}),f=dh(p),h=dh(e);return`pbkdf2$${a.toLowerCase()}$${i}$${f}$${h}`}async function S2e(l,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const r=i[1].toLowerCase(),a=parseInt(i[2],10),c=df(i[3]),e=df(i[4]),f=r.includes("512")?"SHA-512":"SHA-256",h=await o1(rn(l,"utf8"),c,{iterations:a,length:e.length,hashAlg:f});return s1(h,e)}async function q2e(l,p,i,r,a,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,f=i!=null?Math.max(1,Number(i)||0):void 0,h=r??void 0,m=c??"base64url",E=a!=null?rn(a,m):void 0;return await K2e(String(l??""),E,e,f,h)}function GU(l){return dh(rn(JSON.stringify(l),"utf8"))}function mg(l){try{return JSON.parse(bo(df(l),"utf8"))}catch{return null}}async function Z2e(l,p,{alg:i="HS256",includeIat:r=!0,expiresInSeconds:a,notBeforeSeconds:c,issuer:e,subject:f,audience:h,jwtid:m,header:E={}}={}){const b={alg:i,typ:"JWT",...E},g=Math.floor(Date.now()/1e3),_={...l||{}};r&&(_.iat=g),typeof a=="number"&&(_.exp=g+a),typeof c=="number"&&(_.nbf=g+c),e&&(_.iss=e),f&&(_.sub=f),h&&(_.aud=h),m&&(_.jti=m);const $=GU(b),L=GU(_),j=rn(`${$}.${L}`,"utf8"),G=await l1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,j),H=dh(G);return`${$}.${L}.${H}`}async function H2e(l,p,i,r,a,c,e,f,h,m,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(l!=null&&typeof l!="object")throw new Error("Invalid input type for payload; expected object");if(E!=null&&typeof E!="object")throw new Error("Invalid input type for header; expected object");if(m!=null&&typeof m!="string")throw new Error("Invalid input type for jwtid; expected string");if(e!=null&&typeof e!="string")throw new Error("Invalid input type for issuer; expected string");if(f!=null&&typeof f!="string")throw new Error("Invalid input type for subject; expected string");if(h!=null&&typeof h!="string"&&!Array.isArray(h))throw new Error("Invalid input type for audience; expected string or string[]");const _=rn(p??"",b??"utf8");return await Z2e(l??{},_,{alg:i??"HS256",includeIat:r==null?!0:!!r,expiresInSeconds:a!=null?Number(a):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:f??void 0,audience:h??void 0,jwtid:m??void 0,header:E??void 0})}async function W2e(l,p,{alg:i="HS256",issuer:r,audience:a,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[f,h,m]=String(l).split(".");if(!f||!h||!m)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=mg(f),b=mg(h);if(!E||!b)return{valid:!1,header:E,payload:b,reason:"Bad base64/json"};if(E.alg!==i)return{valid:!1,header:E,payload:b,reason:"Alg mismatch"};const g=rn(`${f}.${h}`,"utf8"),$=await l1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,g),L=df(m);if(!s1($,L))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const j=Math.floor(Date.now()/1e3),k=Math.max(0,Number(e)||0);if(b.nbf!=null&&j+k<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&j-k>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(r&&b.iss!==r)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(a){const G=b.aud;if(!(Array.isArray(G)?G.includes(a):G===a))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&j-Number(b.iat)>Number(c)+k?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(f){return{valid:!1,header:null,payload:null,reason:String((f==null?void 0:f.message)??f)}}}async function z2e(l,p,i,r,a,c,e,f){if(typeof l!="string")throw new Error("Invalid input type for token; expected string");if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(typeof r!="string")throw new Error("Invalid input type for issuer; expected string");if(a!=null&&typeof a!="string")throw new Error("Invalid input type for audience; expected string");const m=rn(p??"",f??"utf8");return await W2e(String(l??""),m,{alg:i??"HS256",issuer:r??void 0,audience:a??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function Y2e(l){const[p,i,r]=String(l).split(".");return{header:p?mg(p):null,payload:i?mg(i):null,signature:r?df(r):new Uint8Array}}function J2e(l,p){if(!l)throw new Error("Token is required for decoding");if(typeof l!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:r,payload:a,signature:c}=Y2e(String(l??"")),e=bo(c,i);return{header:r,payload:a,signature:e}}class X2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(it.GenerateRandomBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)}),e=Math.max(0,Number(a)||0),f=c??"base64url",h=kx(e),m=bo(h,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 Q2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomInteger);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=D_e(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 eBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomFloat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=zR();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 tBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomHexadecimal);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=Tx(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 iBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomBase62);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=vx(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 rBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomBase64);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=C_e(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 nBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomAlphanumeric);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=Ex(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 aBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateIdentifier);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=bx(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 sBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomUUIDv4);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=np();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 lBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{z.Logger.log("Initializing Random Generate Short Identifier Module");const r=i.find(a=>a.contextType===te.Logic);if(r){z.Logger.log("Project state found, setting up operation");const a=r.get(it.GenerateShortIdentifier);a?(z.Logger.log("Operation found, setting autoexecutable and implementation"),a.autoexecutable=!0,a.implementation=this.module.main):z.Logger.warn("Operation generate-short-identifier not found in project state")}else z.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,r)=>{try{const a=O_e();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 oBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateHexadecimalToken);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=__e();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}}}})}}function pRi(l){let p;if(l===null?p="null":Array.isArray(l)?p="array":p=typeof l,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class dBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Xe.GetTypeOf);a&&(a.autoexecutable=!0,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{value:U.Success,error:null,result:pRi(c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.ToString);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);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 pBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.ToNumber);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=Number(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 cBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.ToBytes);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=rn(a,c||"utf8");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 fBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.FromBytesToString);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=bo(a,c||"utf8");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 yBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.EncodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:L2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class hBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.DecodeBase64);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=$2e(String(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 mBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.EncodeBase64Url);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=dh(a,c||"utf8");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 TBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.DecodeBase64Url);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=df(String(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 vBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.EncodeHex);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=B2e(a,c||"utf8");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 EBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.DecodeHex);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=M2e(String(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 bBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.Hash);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:U2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ABe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.Hmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)});return{value:U.Success,error:null,result:k2e(c,e,a,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class gBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.ConstantTimeEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:G2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class IBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.DeriveKeyPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(g=>{var _,$;return((_=g.value)==null?void 0:_.valueAsType)??(($=g.value)==null?void 0:$.value)});return{value:U.Success,error:null,result:F2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class RBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(on.Parse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a;try{const c=(a=r[0].value)==null?void 0:a.value;if(typeof c!="string")throw new Error(`Invalid input type for JSON.parse operation: expected string, got ${typeof c}`);const e=JSON.parse(c);return{value:U.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:c,result:null}}}})}}class DBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(on.Stringify);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a,c;try{const e=(a=r[0].value)==null?void 0:a.value,f=(c=r[1].value)==null?void 0:c.value;if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error(`Invalid input type for JSON.stringify operation: expected object or array, got ${typeof e}`);if(!f&&f!==0){const m=JSON.stringify(e);return{value:U.Success,error:null,result:m}}const h=JSON.stringify(e,null,f);return{value:U.Success,error:null,result:h}}catch(e){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e,result:null}}}})}}class wBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dr.BuildJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b,g,_,$,L]=r.map(j=>{var k,G;return((k=j.value)==null?void 0:k.valueAsType)??((G=j.value)==null?void 0:G.value)});return{value:U.Success,error:null,result:await H2e(a,c,e,f,h,m,E,b,g,_,$,L)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class CBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dr.VerifyJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(g=>{var _,$;return((_=g.value)==null?void 0:_.valueAsType)??(($=g.value)==null?void 0:$.value)});return{value:U.Success,error:null,result:await z2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class OBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dr.DecodeJwt);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:J2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _Be extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dn.HashPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)});return{value:U.Success,error:null,result:await q2e(a,c,e,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dn.VerifyPasswordPBKDF2);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=await S2e(String(a??""),String(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_ extends QR{constructor(p,i,r=i.projectId){super(p,te.Editor),this._editor=i,this.id=r}get ready(){return this._editor.ready}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branch(){return this._editor.branch}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(p){this._editor.undoableStackValueIndex=p}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}getRefreshToken(){return this._editor.getRefreshToken()}removeValueByOwnerId(p){return this._editor.removeValueByOwnerId(p)}removeValue(p){return this._editor.removeValue(p)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(p,i){return this._editor.initTest(p,i)}removeTest(p){return this._editor.removeTest(p)}async copyEntities(p,i={}){return this._editor.copyEntities(p,i)}resolveInitialChildrenPositions(p,i,r){return this._editor.resolveInitialChildrenPositions(p,i,r)}publish(){return this._editor.publish()}loadGivenPublication(p){return this._editor.loadGivenPublication(p)}validateProjectState(p){return this._editor.validateProjectState(p)}requestActiveDynamicValue(p,i=!1){return this._editor.requestActiveDynamicValue(p,i)}getValueTypePreference(p){return this._editor.getValueTypePreference(p)}setValueTypePreference(p,i){return this._editor.setValueTypePreference(p,i)}implementFeature(p){return this._editor.implementFeature(p)}}function cRi(l,p){return p instanceof A_?p:new A_(l,p)}class g_ extends QR{constructor(p,i){super(p,te.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get projectVersion(){return this._publicationRun.projectVersion}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function fRi(l,p){return p instanceof g_?p:new g_(l,p)}function yRi(l){l.register(new IVe(l)),l.register(new gVe(l)),l.register(new vVe(l)),l.register(new bVe(l)),l.register(new AVe(l)),l.register(new EVe(l)),l.register(new sLe(l)),l.register(new lLe(l)),l.register(new oLe(l)),l.register(new uLe(l)),l.register(new dLe(l)),l.register(new pLe(l)),l.register(new Q2e(l)),l.register(new eBe(l)),l.register(new tBe(l)),l.register(new iBe(l)),l.register(new rBe(l)),l.register(new nBe(l)),l.register(new aBe(l)),l.register(new sBe(l)),l.register(new lBe(l)),l.register(new oBe(l)),l.register(new a$e(l)),l.register(new s$e(l)),l.register(new l$e(l)),l.register(new o$e(l)),l.register(new d$e(l)),l.register(new u$e(l)),l.register(new p$e(l)),l.register(new c$e(l)),l.register(new f$e(l)),l.register(new y$e(l)),l.register(new h$e(l)),l.register(new m$e(l)),l.register(new T$e(l)),l.register(new v$e(l)),l.register(new E$e(l)),l.register(new b$e(l)),l.register(new A$e(l)),l.register(new g$e(l)),l.register(new I$e(l)),l.register(new w$e(l)),l.register(new C$e(l)),l.register(new O$e(l)),l.register(new Dxe(l)),l.register(new wxe(l)),l.register(new Cxe(l)),l.register(new Oxe(l)),l.register(new _xe(l)),l.register(new Vxe(l)),l.register(new Pxe(l)),l.register(new Nxe(l)),l.register(new xxe(l)),l.register(new Lxe(l)),l.register(new Bxe(l)),l.register(new Mxe(l)),l.register(new Gxe(l)),l.register(new jxe(l)),l.register(new FNe(l)),l.register(new KNe(l)),l.register(new SNe(l)),l.register(new T2e(l)),l.register(new m2e(l)),l.register(new kPe(l)),l.register(new FPe(l)),l.register(new KPe(l)),l.register(new SPe(l)),l.register(new qPe(l)),l.register(new ZPe(l)),l.register(new HPe(l)),l.register(new WPe(l)),l.register(new zPe(l)),l.register(new oNe(l)),l.register(new jNe(l)),l.register(new UNe(l)),l.register(new kNe(l)),l.register(new YPe(l)),l.register(new JPe(l)),l.register(new XPe(l)),l.register(new QPe(l)),l.register(new eNe(l)),l.register(new tNe(l)),l.register(new iNe(l)),l.register(new rNe(l)),l.register(new nNe(l)),l.register(new aNe(l)),l.register(new sNe(l)),l.register(new lNe(l)),l.register(new dNe(l)),l.register(new uNe(l)),l.register(new pNe(l)),l.register(new cNe(l)),l.register(new fNe(l)),l.register(new yNe(l)),l.register(new hNe(l)),l.register(new mNe(l)),l.register(new TNe(l)),l.register(new vNe(l)),l.register(new ENe(l)),l.register(new bNe(l)),l.register(new _Ne(l)),l.register(new VNe(l)),l.register(new PNe(l)),l.register(new ANe(l)),l.register(new gNe(l)),l.register(new INe(l)),l.register(new RNe(l)),l.register(new DNe(l)),l.register(new wNe(l)),l.register(new CNe(l)),l.register(new ONe(l)),l.register(new A2e(l)),l.register(new g2e(l)),l.register(new I2e(l)),l.register(new R2e(l)),l.register(new v2e(l)),l.register(new E2e(l)),l.register(new b2e(l)),l.register(new D2e(l)),l.register(new C2e(l)),l.register(new _2e(l)),l.register(new w2e(l)),l.register(new O2e(l)),l.register(new V2e(l)),l.register(new x2e(l)),l.register(new P2e(l)),l.register(new N2e(l)),l.register(new Uxe(l)),l.register(new Sxe(l)),l.register(new qxe(l)),l.register(new Wxe(l)),l.register(new zxe(l)),l.register(new Yxe(l)),l.register(new Jxe(l)),l.register(new Xxe(l)),l.register(new Qxe(l)),l.register(new e$e(l)),l.register(new t$e(l)),l.register(new Zxe(l)),l.register(new Hxe(l)),l.register(new Fxe(l)),l.register(new Kxe(l)),l.register(new kxe(l)),l.register(new $xe(l)),l.register(new r$e(l)),l.register(new n$e(l)),l.register(new i$e(l)),l.register(new fLe(l)),l.register(new MLe(l)),l.register(new BLe(l)),l.register(new GLe(l)),l.register(new jLe(l)),l.register(new mLe(l)),l.register(new TLe(l)),l.register(new ILe(l)),l.register(new ALe(l)),l.register(new $Le(l)),l.register(new OLe(l)),l.register(new VLe(l)),l.register(new NLe(l)),l.register(new PLe(l)),l.register(new gLe(l)),l.register(new DLe(l)),l.register(new wLe(l)),l.register(new RLe(l)),l.register(new cLe(l)),l.register(new vLe(l)),l.register(new _Le(l)),l.register(new FLe(l)),l.register(new m_(l)),l.register(new hLe(l)),l.register(new ELe(l)),l.register(new yLe(l)),l.register(new xLe(l)),l.register(new bLe(l)),l.register(new CLe(l)),l.register(new LLe(l)),l.register(new kLe(l)),l.register(new ULe(l)),l.register(new KLe(l)),l.register(new m_(l)),l.register(new qLe(l)),l.register(new SLe(l)),l.register(new ZLe(l)),l.register(new K$e(l)),l.register(new S$e(l)),l.register(new q$e(l)),l.register(new V$e(l)),l.register(new D$e(l)),l.register(new $$e(l)),l.register(new G$e(l)),l.register(new R$e(l)),l.register(new j$e(l)),l.register(new F$e(l)),l.register(new B$e(l)),l.register(new L$e(l)),l.register(new fg(l)),l.register(new Z$e(l)),l.register(new H$e(l)),l.register(new M$e(l)),l.register(new k$e(l)),l.register(new U$e(l)),l.register(new x$e(l)),l.register(new N$e(l)),l.register(new P$e(l)),l.register(new _$e(l)),l.register(new Y$e(l)),l.register(new z$e(l)),l.register(new J$e(l)),l.register(new W$e(l)),l.register(new LNe(l)),l.register(new NNe(l)),l.register(new $Ne(l)),l.register(new BNe(l)),l.register(new MNe(l)),l.register(new xNe(l)),l.register(new GNe(l)),l.register(new dBe(l)),l.register(new hBe(l)),l.register(new TBe(l)),l.register(new EBe(l)),l.register(new yBe(l)),l.register(new mBe(l)),l.register(new vBe(l)),l.register(new fBe(l)),l.register(new cBe(l)),l.register(new pBe(l)),l.register(new uBe(l)),l.register(new RBe(l)),l.register(new DBe(l)),l.register(new gBe(l)),l.register(new IBe(l)),l.register(new X2e(l)),l.register(new bBe(l)),l.register(new ABe(l)),l.register(new CBe(l)),l.register(new wBe(l)),l.register(new OBe(l)),l.register(new _Be(l)),l.register(new VBe(l)),l.register(new DVe(l)),l.register(new wVe(l)),l.register(new pg(l)),l.register(new cg(l))}class Fx{constructor(p=new z.Events("extensions-registry-fallback-events")){R(this,"extensionsRegistry",new Map);R(this,"initialized",new Set);R(this,"initializedContexts",new Set);R(this,"onResolveEditorContextCallback",()=>null);R(this,"onResolveProjectLogicContextCallback",()=>null);R(this,"onResolveEditorGUIContextCallback",()=>null);R(this,"onResolveGUIContextCallback",()=>null);R(this,"onResolveCompileContextCallback",()=>null);R(this,"onResolvePublicationRunContextCallback",()=>null);this.events=p,this.off=this.events.off.bind(this.events),this.on=this.events.on.bind(this.events),this.emit=this.events.emit.bind(this.events),this.emitAsync=this.events.emitAsync.bind(this.events),this.emitAsyncAll=this.events.emitAsyncAll.bind(this.events),this.emitAsyncAllSettled=this.events.emitAsyncAllSettled.bind(this.events),this.emitAsyncSequentially=this.events.emitAsyncSequentially.bind(this.events),this.emitAsyncSequentiallyAll=this.events.emitAsyncSequentiallyAll.bind(this.events),this.emitAsyncSequentiallyAllSettled=this.events.emitAsyncSequentiallyAllSettled.bind(this.events)}onResolveEditorContext(p){this.onResolveEditorContextCallback=p}onResolveProjectLogicContext(p){this.onResolveProjectLogicContextCallback=p}onResolveGUIContext(p){this.onResolveGUIContextCallback=p}onResolveEditorGUIContext(p){this.onResolveEditorGUIContextCallback=p}onResolveCompileContext(p){this.onResolveCompileContextCallback=p}onResolvePublicationRunContext(p){this.onResolvePublicationRunContextCallback=p}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((p,i)=>(p.manifest.initPriority||De.Normal)-(i.manifest.initPriority||De.Normal))}async setup(){yRi(this),z.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case te.Editor:return this.onResolveEditorContextCallback();case te.Logic:return this.onResolveProjectLogicContextCallback();case te.EditorGUI:return this.onResolveEditorGUIContextCallback();case te.Compile:return this.onResolveCompileContextCallback();case te.PublicationRun:return this.onResolvePublicationRunContextCallback();case te.GUI:return this.onResolveGUIContextCallback();case te.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const r=[];i.length===0&&(i=p.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&r.push(c)}return r}requestExtension(p){const i=this.extensionsRegistry.get(p);if(i)return i;throw new Error(`Unknown extension: ${p}`)}register(p){this.extensionsRegistry.set(p.manifest.id,p)}async initAll(){var p,i;for(const r of this.extensionInOrder)if(r.module.init&&!this.initialized.has(r.manifest.id)){const a=r.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(p=r.module).init)==null?void 0:i.call(p,a)),this.initialized.add(r.manifest.id))}else!r.module.init&&!this.initialized.has(r.manifest.id)&&this.initialized.add(r.manifest.id)}async initForReady(){z.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){z.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await p.module.init(i),this.initialized.add(p.manifest.id)):z.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(z.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):z.Logger.log(`Skipping initialization of ${p.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const p of[...this.extensionInOrder].reverse())p.module.destroy&&await p.module.destroy();this.events.destroy()}on(p,i){this.events.on(p,i)}emit(p,...i){this.events.emit(p,...i)}off(p,i){this.events.off(p,i)}emitAsync(p,...i){return this.events.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.events.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.events.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.events.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.events.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.events.emitAsyncSequentiallyAllSettled(p,...i)}async contextAvailable(p){if(this.initializedContexts.has(p)){z.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case te.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case te.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}z.Logger.log(`Context ${p} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(p){return window.localStorage.getItem("dynamic-value-type-preference--"+p)||null}setValueTypePreference(p,i){window.localStorage.setItem("dynamic-value-type-preference--"+p,(i==null?void 0:i.toString())||""),this.emit(p,{})}}let LA=null;const Kx={requestExtension:l=>(LA||(LA=new Fx,LA.setup()),LA.requestExtension(l))},Zu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var Sx=(l=>(l.FinishedSuccess="finished-success",l.FinishedError="finished-error",l.Running="running",l.Paused="paused",l.Stopped="stopped",l.NotStarted="not-started",l))(Sx||{});const PBe={...Kx,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class ip extends z.Events{constructor(i,r,a,c=null,e=PBe){super();R(this,"project");R(this,"entryPoint");R(this,"state","not-started");R(this,"events",new z.Events("fe-exec-inst-events"));R(this,"entities",[]);R(this,"parentExecution",null);R(this,"executing",[]);R(this,"executed",[]);R(this,"skipped",[]);R(this,"scheduled",[]);R(this,"localTestValues");R(this,"resolvedValues");R(this,"persistedExecutionResults");R(this,"lastExecutionResults");R(this,"onAddToSkippedListCallback",null);R(this,"onRemoveFromSkippedListCallback",null);R(this,"onAddEntityCallback",null);R(this,"onRemoveEntityCallback",null);R(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=r,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new mT(N.UUID.uuid(),this.project),this.resolvedValues=new mT(N.UUID.uuid(),this.project),this.persistedExecutionResults=new mT(N.UUID.uuid(),this.project),this.lastExecutionResults=new mT(N.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),hr.includes(i.type)&&yt(i).forEach(r=>this.skip(r))))}async schedule(i,r,a){if(this.hasExecuted(i))return null;if(Ft.includes(i.type))return this.executeBranch(i,a,r);if(Pr.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,r);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,r){const a=[];return[...Nt,...Ft].includes(r.type)?a.push(...r.inputs):Dt.includes(r.type)&&a.push(...r.outputs),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Ft.includes(r.type)&&(f=i.find(m=>{var E;return((E=m.valueOwner.declaration)==null?void 0:E.id)===e.id})),f){const m=(h=f.value)==null?void 0:h.clone(null);return m==null||m.setStandaloneParent(e,null),{...f,valueOwner:e,value:m||null,inheritanceLink:{sources:[f],target:e}}}return pn.includes(e.type)?Fo(e,this.valueResolutionContext):lf(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=Jo(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(E=>{var _,$,L;if(E.id===(f==null?void 0:f.valueOwner.id))return;const b=xt(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(_=f==null?void 0:f.value)==null?void 0:_.value},null),b==null||b.setValueAsTypeList((($=f==null?void 0:f.value)==null?void 0:$.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((L=f==null?void 0:f.value)==null?void 0:L.valueAsTypeSingle)||null);const g={...f,valueOwner:E,value:b};m.push(g)}),[...e,...m]},[]).sort((e,f)=>e.valueOwner.index-f.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,r,a,c={}){var f,h;const e={...Zu,...c};try{let m={value:U.Success,error:null,result:null};if(r.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(Vr).includes(i.declaration.id)){const E=this.parentContext.requestExtension(Wy+i.declaration.id).module.main;E?m=await E(i,r):z.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{m=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let E=null;if(m.error){z.Logger.warn("Raw error executing entity: ",m.error);const b=(f=i.error)==null?void 0:f.getDataType(null),g=xt(b||null,i.error,a);b!=null&&b.asType?g==null||g.setValueAsTypeSingle(m.error):g==null||g.metaSync({value:m.error},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:g}}return{value:m.value,entity:i,error:E,result:{value:m.result||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}return{...m,entity:i}}catch(m){z.Logger.warn("Internal call execution error: ",m);let E=null;if(i.error){const b=(h=i.error)==null?void 0:h.getDataType(null),g=xt(b,i.error,a);b!=null&&b.asType?g==null||g.setValueAsTypeSingle(m):g==null||g.metaSync({value:m},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:g}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,r,a){var c,e;try{let f={value:U.Success,error:null,result:null};r.sort((b,g)=>b.valueOwner.index-g.valueOwner.index),i.declaration.implementation&&(f=await i.declaration.implementation(i,r));let h=null;if(f.error&&i.error){z.Logger.warn("Raw error executing entity: ",f.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,g=xt(b,i.error,a);b!=null&&b.asType?g==null||g.setValueAsTypeSingle(f.error):g==null||g.metaSync({value:f.error},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:g}}const m=i==null?void 0:i.getDataType(null),E=xt(m,i,a);return m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f.result):E==null||E.metaSync({value:f.result},null),{value:f.value,entity:i,error:h,result:{value:E||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(f){z.Logger.warn("Operation execution error: ",f);let h=null;if(i.error){const m=(e=i.error)==null?void 0:e.getDataType(null),E=xt(m,i.error,a);m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f):E==null||E.metaSync({value:f},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:h,result:null}}}async executeSearch(i,r,a){var c;try{let e={value:U.Success,error:null,result:null};const f=await(await this.parentContext.requestExtension(Oe.SEARCH_NODE_IMPLEMENTATION)).module.main(i,r),h=i==null?void 0:i.getDataType(null),m=xt(h,i,a);return m==null||m.metaSync({value:f},null),f.error?{value:U.UnhandledError,entity:i,error:{valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:m},result:null}:{value:e.value,entity:i,error:null,result:{value:m,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(e){if(z.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const f=(c=i.error)==null?void 0:c.getDataType(null),h=xt(f,i.error,a);return h==null||h.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:h},result:null}}}async executeLoop(i,r,a,c={}){var f,h,m,E,b,g;const e={...Zu,...c};try{let _={value:U.Success,error:null,result:null};const $=r.map(ie=>{var ee,ue;return((ee=ie==null?void 0:ie.value)==null?void 0:ee.valueAsType)||((ue=ie==null?void 0:ie.value)==null?void 0:ue.value)});let L={};i.getUniqueInputMaps().forEach(ie=>{const ee=i.body.inputs.find(ce=>se(ce,a)===se(ie,a)),ue=ie==null?void 0:ie.getDataType(null),ae=xt(ue,ee,a);ue!=null&&ue.asType?ae==null||ae.setValueAsTypeList([]):ae==null||ae.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,ae);const de={value:ae,valueOwner:ee,type:Me.ExecutionResult,inheritanceLink:null};L[ee.id]=de});let k={value:U.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case re.loop["counted-loop"].id:{const ie=$[0];let ee=1;for(;ee<=ie&&ee<=50;){const ue=i.body.inputs.map(ae=>{if(ae===i.currentIterationNumberArgumentDeclaration){const de=i.currentIterationNumberArgumentDeclaration.getDataType(null),ce=Wc(de),ne=this.lastExecutionResults.readValue(ae.id);if(ne){ne.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ae,ne);const Ee={value:ne,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return L[ae.id]=Ee,Ee}const le={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:ae.toReference()},Q=Yi(le,a);this.lastExecutionResults.writeValue(ae,Q);const oe={value:Q,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return L[ae.id]=oe,oe}else return L[ae.id]}).filter(ae=>!!ae);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(k.results||[]).forEach(ae=>{var le,Q,oe,Ee;if(ae.valueOwner.type!==d.InputMap||Dt.includes(ae.valueOwner.parent.type))return;const de=i.body.inputs.find(Te=>se(Te,a)===se(ae.valueOwner,a)),ne=[...((Q=(le=L==null?void 0:L[de.id])==null?void 0:le.value)==null?void 0:Q.value)||[],((oe=ae==null?void 0:ae.value)==null?void 0:oe.value)||null];(Ee=L[de.id].value)==null||Ee.metaSync({value:ne},null),this.lastExecutionResults.writeValue(de,L[de.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["manual-flow-loop"].id:{let ie=1;for(;ie<=50;){const ee=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(ue.id);if(ae){ae.metaSync({value:ie},null),this.lastExecutionResults.writeValue(ue,ae);const le={value:ae,valueOwner:ue,type:Me.ExecutionResult,inheritanceLink:null};return L[ue.id]=le,le}const de=i.currentIterationNumberArgumentDeclaration.getDataType(null),ce=xt(de,ue,a);return ce==null||ce.metaSync({value:ie},null),this.lastExecutionResults.writeValue(ue,ce),{value:ce,valueOwner:ue,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ue.id]}).filter(ue=>!!ue);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(k.results||[]).forEach(ue=>{var ne,le,Q;if(ue.valueOwner.type!==d.InputMap||Dt.includes(ue.valueOwner.parent.type))return;const ae=i.body.inputs.find(oe=>se(oe,a)===se(ue.valueOwner,a)),ce=[...(ne=L[ae.id].value)==null?void 0:ne.value,((le=ue.value)==null?void 0:le.value)||null];(Q=L[ae.id].value)==null||Q.metaSync({value:ce},null),this.lastExecutionResults.writeValue(ae,L[ae.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ie++}break}case re.loop["list-loop"].id:{const ie=$[0];let ee=1;const ue=ie;for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["object-keys-loop"].id:{const ie=$[0];let ee=1;const ue=ie?Object.keys(ie):[];for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["object-values-loop"].id:{const ie=$[0];let ee=1;const ue=ie?Object.values(ie):[];for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["string-loop"].id:{const ie=$[0];let ee=1;const ue=ie.split("");for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}}if(_={value:[U.CaughtError,U.Return].includes(k.value)?k.value:U.Success,error:((h=(f=k.error)==null?void 0:f.value)==null?void 0:h.value)||null,result:((E=(m=k==null?void 0:k.result)==null?void 0:m.value)==null?void 0:E.value)||null},_.error&&i.error){const ie=(b=i.error)==null?void 0:b.getDataType(null),ee=xt(ie||null,i.error,a);ie!=null&&ie.asType?ee==null||ee.setValueAsTypeSingle(_.error):ee==null||ee.metaSync({value:_.error},null);const ue={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:ee};return{value:_.value,entity:i,error:ue,result:null}}const G=i==null?void 0:i.getDataType(null),H=xt(G,i,a);return G!=null&&G.asType?H==null||H.setValueAsTypeSingle(_.result):H==null||H.metaSync({value:_.result},null),{value:_.value,entity:i,error:null,result:{value:H||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(_){if(z.Logger.warn("Error executing loop: ",_),i.error){const $=(g=i.error)==null?void 0:g.getDataType(null),L=xt($,i.error,a);return $!=null&&$.asType?L==null||L.setValueAsTypeSingle(_):L==null||L.metaSync({value:_},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:L},result:null}}else return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,r,a,c={}){var f,h,m,E,b,g,_,$,L,j,k,G,H,ie,ee,ue,ae,de,ce,ne,le,Q,oe,Ee,Te,Ve;const e={...Zu,...c};try{const Le=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let $e=null;if(Le.error&&i.error){z.Logger.warn("Raw error executing entity: ",Le.error);const rt=(f=i.error)==null?void 0:f.getDataType(null),Rt=xt(rt||null,i.error,a);rt!=null&&rt.asType?(m=(h=Le.error)==null?void 0:h.value)!=null&&m.valueAsTypeSingle?Rt==null||Rt.setValueAsTypeSingle((b=(E=Le.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(_=(g=Le.error)==null?void 0:g.value)!=null&&_.valueAsTypeList&&Array.isArray((L=($=Le.error)==null?void 0:$.value)==null?void 0:L.valueAsTypeList)&&(Rt==null||Rt.setValueAsTypeList((k=(j=Le.error)==null?void 0:j.value)==null?void 0:k.valueAsTypeList)):Rt==null||Rt.metaSync({value:(H=(G=Le.error)==null?void 0:G.value)==null?void 0:H.value},null),$e={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:Rt}}let ke=U.Success;Le.value===U.UnhandledError&&(i.catchesError||i.errorCalls.length?ke=U.CaughtError:ke=U.UnhandledError);const Ke=i==null?void 0:i.getDataType(null),Je=xt(Ke,i,a);return Ke!=null&&Ke.asType?(ee=(ie=Le.result)==null?void 0:ie.value)!=null&&ee.valueAsTypeSingle?Je==null||Je.setValueAsTypeSingle((ae=(ue=Le.result)==null?void 0:ue.value)==null?void 0:ae.valueAsTypeSingle):(ce=(de=Le.result)==null?void 0:de.value)!=null&&ce.valueAsTypeList&&Array.isArray((le=(ne=Le.result)==null?void 0:ne.value)==null?void 0:le.valueAsTypeList)&&(Je==null||Je.setValueAsTypeList((oe=(Q=Le.result)==null?void 0:Q.value)==null?void 0:oe.valueAsTypeList)):Je==null||Je.metaSync({value:((Te=(Ee=Le.result)==null?void 0:Ee.value)==null?void 0:Te.value)||null},null),{value:ke,entity:i,error:$e,result:{value:Je||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(Le){if(!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const $e=(Ve=i.error)==null?void 0:Ve.getDataType(null),ke=xt($e,i.error,a);return $e!=null&&$e.asType?ke==null||ke.setValueAsTypeSingle(Le):ke==null||ke.metaSync({value:Le},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:ke},result:null}}}async executeCondition(i,r){var c,e,f,h;let a=!1;switch(i.declaration.id){case un.BooleanIsTrue:{const m=(e=(c=r[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof m!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=m===!0;break}case un.BooleanIsFalse:{const m=(h=(f=r[0])==null?void 0:f.value)==null?void 0:h.value;if(typeof m!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=m===!1;break}case Ir.And:{a=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).every(E=>E);break}case Ir.Or:{a=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?U.Success:U.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,r,a,c={}){const e={...Zu,...c,onBeforeEntityExecution:(m,E,b)=>{var g;return((g=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:g.call(c,m,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(m,E,b)=>{var g;return((g=c==null?void 0:c.onEntityExecuted)==null?void 0:g.call(c,m,E,{...b,detached:!0}))||Promise.resolve()}},f=new ip(a,[i,...Bg(i)],i,this,this.parentContext);return f.inheritValuesFromContext(this),await f.execute(e,r)}async executeFullFunctionDeclarationLogic(i,r,a={}){const c={...Zu,...a},e=Bg(i);e.forEach(m=>{this.addEntity(m)}),e.reduce((m,E)=>Dt.includes(E.type)?[...m,...E.outputs]:Nt.includes(E.type)&&E.type!==d.Condition?[...m,...E.outputs,...E.inputs]:E.type===d.Condition?[...m,...E.inputs]:m,[]).forEach(m=>{this.lastExecutionResults.removeValue(m.id)});const h=await this.executeBranch(i,c,r);return{...h||{},value:(h==null?void 0:h.value)||U.Success,entity:i,error:(h==null?void 0:h.error)||null,result:(h==null?void 0:h.result)||null}}static async executeEntryPointEntity(i,r){return{value:U.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,r){var f,h,m,E,b,g,_;if((f=i.throws)!=null&&f.readsValue){const $=Fo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Fo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(c,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=e[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Return,entity:i,error:null,result:a}}async executeContinueStatement(i,r){var f,h,m,E,b,g,_;if((f=i.throws)!=null&&f.readsValue){const $=Fo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Fo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(c,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=e[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Continue,entity:i,error:null,result:a}}async executeBreakStatement(i,r){var f,h,m,E,b,g,_;if((f=i.throws)!=null&&f.readsValue){const $=Fo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Fo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(c,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=e[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Break,entity:i,error:null,result:a}}async executeVariable(i,r){var h,m,E,b,g,_;let a=Fo(i,this.valueResolutionContext);const c=yr(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let $={};if(((h=e==null?void 0:e.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...e.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(e,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:c,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(c,a.value),c.inputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,a==null?void 0:a.value);const f=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=f[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Success,entity:i,error:null,result:a}}mergeValues(i,r){const a=[];for(let c=0;c<r.length;c++)i!=null&&i[c]?a.push(i[c]):a.push(r[c]);return a}async executeEntity(i,r=[],a={}){var f,h,m,E,b,g,_,$,L,j,k;const c={...Zu,...a},e={detached:!1};switch(i.type){case d.Condition:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((f=c.onBeforeEntityExecution)==null?void 0:f.call(c,i,G,e)),this.executeCondition(i,G)}case d.InternalCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((h=c.onBeforeEntityExecution)==null?void 0:h.call(c,i,G,e)),this.executeInternalCall(i,G,this.project)}case d.Operation:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,G,e)),ip.executeOperation(i,G,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,r);case d.FunctionCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,G,e)),this.executeFunctionCall(i,G,this.project)}case d.FunctionDeclaration:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,G,e)),ip.executeEntryPointEntity(i,G)}case d.Search:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((g=c.onBeforeEntityExecution)==null?void 0:g.call(c,i,G,e)),this.executeSearch(i,G,this.project)}case d.Loop:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((_=c.onBeforeEntityExecution)==null?void 0:_.call(c,i,G,e)),this.executeLoop(i,G,this.project,c)}case d.ReturnStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await(($=c.onBeforeEntityExecution)==null?void 0:$.call(c,i,G,e)),this.executeReturnStatement(i,G)}case d.ContinueStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((L=c.onBeforeEntityExecution)==null?void 0:L.call(c,i,G,e)),this.executeContinueStatement(i,G)}case d.BreakStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((j=c.onBeforeEntityExecution)==null?void 0:j.call(c,i,G,e)),this.executeBreakStatement(i,G)}case d.GlobalEvent:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((k=c.onBeforeEntityExecution)==null?void 0:k.call(c,i,G,e)),ip.executeEntryPointEntity(i,G)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var a,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((a=i.result)!=null&&a.valueOwner))return;const r=Jo((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?r.forEach(f=>{var h;this.lastExecutionResults.writeValue(f,(h=i.result)==null?void 0:h.value)}):r.forEach(f=>{this.lastExecutionResults.removeValue(f.id)})}async executeBranch(i,r={},a=[]){var m;const c={...Zu,...r},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const h=await this.executeEntity(i,a,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(h),await((m=c.onEntityExecuted)==null?void 0:m.call(c,i,h,e)),h.value===U.Success){const E=(i.successCalls||i.calls||[]).filter(L=>this.hasEntity(L));(i.errorCalls||[]).forEach(L=>{this.skip(L)});let g=[];const _=(await Promise.all(E.map(L=>this.schedule(L,[],c)))).filter(L=>!!L),$=_.filter(L=>!!L).find(L=>L.value===U.CaughtError||L.value===U.Return||L.value===U.Break||L.value===U.Continue);return $||(g=[...g,..._],h)}else if(h.value===U.CaughtError||h.value===U.ConditionNotMet){const E=(i.errorCalls||[]).filter(L=>this.hasEntity(L));(i.successCalls||i.calls||[]).forEach(L=>{this.skip(L)});let g=[];const _=(await Promise.all(E.map(L=>this.schedule(L,[],c)))).filter(L=>!!L),$=_.filter(L=>!!L).find(L=>L.value===U.CaughtError||L.value===U.UnhandledError||L.value===U.Return||L.value===U.Break||L.value===U.Continue);return $||(g=[...g,..._],h)}else{if(h.value===U.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),hr.includes(h.entity.type)&&yt(h.entity).forEach(E=>{this.skip(E)}),h;if(h.value===U.Return)return h;if(h.value===U.Break)return h;if(h.value===U.Continue)return h}return h}async execute(i={},r=[]){const a={...Zu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,a,r);return this.state="finished-success",c}addEntity(i){var r;this.entities.includes(i)||(this.entities.push(i),(r=this.onAddEntityCallback)==null||r.call(this,i,{}))}async addEntityAsync(i,r={}){var a;this.entities.includes(i)||(this.entities.push(i),await((a=this.onAddEntityCallback)==null?void 0:a.call(this,i,r)))}addEntities(i){i.forEach(r=>this.addEntity(r))}async addEntitiesAsync(i,r={}){const a=z.YieldTracker.from(r),c=[];for(const e of i)c.push(this.addEntityAsync(e,r)),await a.tick();await Promise.all(c)}removeEntity(i){var r;if(i!==this.entryPoint){const a=this.entities.indexOf(i);a>-1&&(this.entities.splice(a,1),(r=this.onRemoveEntityCallback)==null||r.call(this,i,{}))}}hasEntity(i){var c,e,f;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((f=(e=i.parent)==null?void 0:e.parent)==null?void 0:f.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const r=ht(i);if(!r)return!1;const a=r.type===d.Loop&&i.parent===r.body?r.body:null;return a?this.entities.includes(a)||this.entities.includes(r):this.entities.includes(r)}removeScheduled(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const r=this.project.get(i);return r?this.hasEntity(r):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAbortExecution(i){this.onAbortExecutionCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}addToScheduledList(i){this.scheduled.includes(i)||this.scheduled.push(i)}removeFromScheduledList(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}removeFromExecutingList(i){var a;const r=this.executing.indexOf(i);r>-1&&(this.executing.splice(r,1),(a=this.onAbortExecutionCallback)==null||a.call(this,i,{}))}removeFromAlreadyExecutedList(i){const r=this.executed.indexOf(i);r>-1&&this.executed.splice(r,1)}removeFromSkippedList(i){var a;const r=this.skipped.indexOf(i);r>-1&&(this.skipped.splice(r,1),(a=this.onRemoveFromSkippedListCallback)==null||a.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var r;this.skipped.includes(i)||(this.skipped.push(i),(r=this.onAddToSkippedListCallback)==null||r.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,r){this.parentContext.setValueTypePreference(i,r),this.emit(i,{})}}function hRi(l){var p,i;if(l.isList)return"list";if(((p=l.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=l.entity)==null?void 0:i.name){case ye.Number:return"number";case ye.String:return"text";case ye.Boolean:return"boolean";case ye.UUID:return"uuid";case ye.Date:return"date-time";default:return"definition-entity"}}const Wa={[d.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[d.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[d.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[d.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[d.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[d.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[d.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[d.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[d.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[d.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[d.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[d.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[d.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[d.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[d.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[d.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[d.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[d.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[d.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[d.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[d.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[d.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function qx(l){const p=Z1(l);if(!p){const r=vh(l);if(r.includes(Ie.HTTP_ENDPOINT))return"HTTP endpoint";if(r.includes(Ie.PERSISTED_ENTITY))return"Persisted entity";if(r.includes(Ie.CRON_JOB))return"Scheduled execution";if(r.includes(Ie.RELATIONAL_DATABASE))return"Relational database"}if(p){let r="Extension of "+se(p,p.project)+" entity",a=Yo(r);const c=vh(l);return c.includes(Ie.HTTP_ENDPOINT)?"HTTP endpoint"+(a?", "+a:""):c.includes(Ie.PERSISTED_ENTITY)?"Persisted entity"+(a?", "+a:""):c.includes(Ie.CRON_JOB)?"Scheduled execution"+(a?", "+a:""):c.includes(Ie.RELATIONAL_DATABASE)?"Relational database"+(a?", "+a:""):r}let i="";return l.abstract&&(i="Template "),l.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function NBe(l){return l.parent.type===d.DefinitionEntity||l.parent.type===d.InstalledProject?"Internal action of "+se(l.parent,l.project):l.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function Zx(l){return cL(l)?NBe(l):"Custom trigger"}function mRi(l){var p;switch(l.type){case d.DefinitionEntity:return qx(l);case d.FunctionDeclaration:return Zx(l)}return(p=Wa[l.type])==null?void 0:p.singular}function TRi(l){var p;switch(l.type){case d.DefinitionEntity:return qx(l);case d.FunctionDeclaration:return Zx(l)}return(p=Wa[l.type])==null?void 0:p.singular}const Hx=4e4,Wx=280,vRi=300,zx=65,zy=32,Xy=39,xBe=26,$Be=49,Tg=44,ERi=35,ZA=52,Yx=10,Ko=Yx*2,vg=38,HA=90,Eg=270,LBe=Hx/2+120,BBe=Hx/2+180;function Jx(l){let i=zy+Tg+vg+Yx;const r=[...l.inputs];return r.length&&(i+=Ko,r.forEach(()=>{i+=xBe})),{height:i,width:280}}function MBe(l){let i=zx;const r=[];if([d.DefinitionEntity].includes(l.type)){const h=[...l.suggestedProperties||[],...l.properties||[]];h.length&&(i+=Ko,h.forEach(m=>{i+=m.static?$Be:Xy}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(l.type)){const h=[...(l==null?void 0:l.suggestedMethods)||[],...l.methods||[],...l.functions||[],...l.body?[l.body]:[]];h.length&&(i+=Ko,h.forEach(m=>{const E=Jx(m);i+=E.height}))}Nt.includes(l.type)?(_t.includes(l.type)?r.push(...(l.usedInputs||[]).flatMap(h=>[h])||[]):r.push(...(l.inputs||[]).flatMap(h=>[h])||[]),l.error&&(i+=ZA)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)?(r.push(...l.outputs||[]),l.throws&&(i+=ZA)):l.type===d.Condition&&(r.push(l.inputs[0]),l.inputs[1]&&r.push(l.inputs[1]));const a=r.length;a&&(i+=a*Xy,i+=Ko);const c=[];if(l.type===d.FunctionDeclaration||l.type===d.GlobalEvent?c.push(...l.inputs||[]):Nt.includes(l.type)&&(_t.includes(l.type)?c.push(...l.usedOutputs||[]):c.push(...l.outputs||[])),_t.includes(l.type)){l.readsValue&&(i+=Ko,i+=Tg),l.writesValues.length&&(i+=Ko,i+=Tg),l.internalCalls.length&&l.usedInternalCalls.forEach(()=>i+=ZA+Ko);const h=l.getDataType(null);(!h||h.inferred)&&(i+=vg)}const e=c.length;return e&&(i+=e*Xy,i+=Ko),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)&&(i+=vg),{height:i,width:280}}function GBe(l){let p=0;if(l.parent.type!==d.DefinitionEntity)return{offset:p};const i=l.parent,r=i.methods.findIndex(c=>c.id===l.id);return i.methods.slice(0,r).forEach(c=>{const e=Jx(c);p+=e.height}),(i.properties.length||i.suggestedProperties.length)&&(p+=Ko,i.suggestedProperties.forEach(()=>{p+=Xy}),i.properties.forEach(()=>{p+=Xy})),{offset:p}}function lE(l){return`${l.split("-").map((r,a)=>a===0?r.charAt(0).toUpperCase()+r.slice(1):r.toLowerCase()).join(" ")}.`}function bRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case be.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case be.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case be.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case be.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case we.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case we.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case be.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case be.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case we.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case be.NoProperties:return"This entity has no properties, so it doesn't do anything";case be.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case be.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case be.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case be.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case be.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case be.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case be.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case be.PropertyImplementsNonAbstact:return"This property implements a non-template property";case be.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case be.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case be.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case be.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case be.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case we.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case we.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case we.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case we.UnreachableEntity:return"This entity is unreachable";case be.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case be.AbstractEntityImplements:return"This template entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case be.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case be.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case be.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case be.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case be.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case be.MissingRequiredValue:return"This action is missing a required value";case be.NoPrimaryKeyProperty:return"This entity has no primary key property";case be.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case be.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case be.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case be.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case be.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case be.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case be.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case we.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case we.EmptyName:return"This entity has no name";case we.InvalidObjectStructure:return"This entity has an invalid structure";case we.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case we.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case we.MissingCaller:return"This action is missing a caller";case we.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case we.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case we.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case we.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case we.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case id.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case id.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case Ya.UUIDMustBeString:return`UUID must be a string, eg: "${np()}"`;case Ya.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${np()}"`;case Ya.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${np()}"`;case ya.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ya.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ya.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return lE(l.code)}}function ARi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case be.IncorrectEntityImplementation:return"Incorrect implementation";case be.IncorrectMethodImplementation:return"Incorrect action implementation";case be.IncorrectPropertyImplementation:return"Incorrect property implementation";case be.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case we.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case we.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case be.MissingMethodImplementation:return"Missing action";case be.MissingPropertyImplementation:return"Missing property";case we.NameNotUniqueInScope:return"Duplicate name";case be.NoProperties:return"No properties";case be.NonStaticPropertyInStaticEntity:return"Non-static property";case be.StaticEntityWithNonStaticProperties:return"Non-static properties";case be.ReadingFromIncompatibleType:return"Read from different type";case be.WritingToIncompatibleType:return"Write to different type";case be.ScopeWithoutLogic:return"No logic";case be.NonStaticPropertyImplementsStatic:return"Invalid static property";case be.PropertyImplementsIncompatibleType:return"Incompatible data type";case be.PropertyImplementsNonAbstact:return"Non-template property";case be.StaticPropertyImplementsNonStatic:return"Non-static property";case be.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case be.VariableHasInputsAndInternalCall:return"Bad internal call";case be.VariableHasOutputsAndInternalCall:return"Bad internal call";case be.VariableIsCalledAndHasInternalCall:return"Bad internal call";case we.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case we.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case we.InternalCallParentMissingDataType:return"Parent has no data type";case we.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case we.UnreachableEntity:return"Unreachable entity";case be.DisconnectedCallableEntity:return"Disconnected entity";case be.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case be.InvalidPropertiesCombination:return"Invalid properties combination";case be.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case be.ExtendsIncompatibleEntities:return"Extends incompatible entities";case be.ImplementingNonAbstractEntity:return"Implementing non-template entity";case be.ImplementsIncompatibleEntities:return"Implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case be.MissingRequiredValue:return"Missing required value";case be.NoPrimaryKeyProperty:return"No primary key property";case be.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case be.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case be.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case be.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case be.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case be.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case be.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case we.EmptyName:return"Empty name";case we.InvalidObjectStructure:return"Invalid object structure";case we.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case we.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case we.MissingCaller:return"Missing caller";case we.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case we.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case we.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case we.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case we.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case id.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case id.StatusCodeMustBeNumber:return"HTTP status code must be a number";case Ya.UUIDMustBeString:return"UUID must be a string";case Ya.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case Ya.UUIDMustBeValidFormat:return"UUID must be in a valid format";case ya.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ya.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ya.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return lE(l.code)}}function gRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${se(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${se(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements template`;case be.IncorrectMethodImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template`;case be.IncorrectPropertyImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template`;case be.AbstractMethodInNonAbstractEntity:return`${se(l.entity,l.entity.project)} can't be a template`;case be.AbstractPropertyInNonAbstractEntity:return`${se(l.entity,l.entity.project)} can't be a template`;case we.MethodOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites action`;case we.PropertyOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites property`;case be.MissingMethodImplementation:return`${se(l.entity,l.entity.project)} is missing action`;case be.MissingPropertyImplementation:return`${se(l.entity,l.entity.project)} is missing property`;case we.NameNotUniqueInScope:return`${se(l.entity,l.entity.project)} name is not unique`;case be.NoProperties:return`${se(l.entity,l.entity.project)} has no properties`;case be.NonStaticPropertyInStaticEntity:return`${se(l.entity,l.entity.project)} has non-static property`;case be.StaticEntityWithNonStaticProperties:return`${se(l.entity,l.entity.project)} has non-static properties`;case be.ReadingFromIncompatibleType:return`${se(l.entity,l.entity.project)} reads from different type`;case be.WritingToIncompatibleType:return`${se(l.entity,l.entity.project)} writes to different type`;case be.ScopeWithoutLogic:return`${se(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${se(l.entity,l.entity.project)} has invalid static property`;case be.PropertyImplementsIncompatibleType:return`${se(l.entity,l.entity.project)} has incompatible data type`;case be.PropertyImplementsNonAbstact:return`${se(l.entity,l.entity.project)} has non-template property`;case be.StaticPropertyImplementsNonStatic:return`${se(l.entity,l.entity.project)} has non-static property`;case be.VariableCallsOthersAndHasInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasInputsAndInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasOutputsAndInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case be.VariableIsCalledAndHasInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case we.InternalCallDeclarationIsInvalidType:return`${se(l.entity,l.entity.project)} has declaration that is not an action`;case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has declaration that is not found in parent`;case we.InternalCallParentDeclarationEntityInvalidType:return`${se(l.entity,l.entity.project)} has invalid parent declaration type`;case we.InternalCallParentMissingDataType:return`${se(l.entity,l.entity.project)}'s parent has no data type`;case we.InternalCallDeclarationNotInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has declaration that is not in parent`;case we.UnreachableEntity:return`${se(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${se(l.entity,l.entity.project)} is not executed by any entity`;case be.AbstractEntityImplements:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${se(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${se(l.entity,l.entity.project)} has invalid properties combination`;case be.ExtendingNonInteractiveEntity:return`${se(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${se(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${se(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${se(l.entity,l.entity.project)} is missing termination on some branches`;case be.LastCalledEntityMustBeReturnEntity:return`${se(l.entity,l.entity.project)}'s last called entity must be a termination node`;case be.MissingRequiredValue:return`${se(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${se(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${se(l.entity,l.entity.project)} extends a template entity`;case be.NonStaticExtendingStaticEntity:return`${se(l.entity,l.entity.project)} extends a static entity`;case be.NonStaticImplementingStaticEntity:return`${se(l.entity,l.entity.project)} implements a static entity`;case be.StaticExtendingNonStaticEntity:return`${se(l.entity,l.entity.project)} extends a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${se(l.entity,l.entity.project)} implements a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${se(l.entity,l.entity.project)} reads a value and has internal call`;case be.VariableWritesValuesAndInternalCall:return`${se(l.entity,l.entity.project)} writes values and has internal call`;case we.EmptyName:return`${Wa[l.entity.type]} has no name`;case we.InvalidObjectStructure:return`${se(l.entity,l.entity.project)} has invalid structure`;case we.LoopBodyFunctionOverwrite:return`${se(l.entity,l.entity.project)}'s loop body action overwrites an action`;case we.MethodOverwritesBaseMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites base action`;case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MissingCaller:return`${se(l.entity,l.entity.project)} is missing a caller`;case we.NameAsResolvedCodeNameNotUniqueInScope:return`${se(l.entity,l.entity.project)} has a name not unique in the scope`;case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${se(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case we.NameMustStartWithLetterOrUnderscore:return`${se(l.entity,l.entity.project)} name must start with letter or underscore`;case we.NoOverlapWithImplementedSignature:return`${se(l.entity,l.entity.project)} has no overlap with implemented signature`;case we.PropertyOverwritesBasePropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites base property`;case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.ReaderWriterIncompatibleDataType:return`${se(l.entity,l.entity.project)} has reader/writer with incompatible data type`;case id.StatusCodeMustBeBetween100And599:return`${se(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case id.StatusCodeMustBeNumber:return`${se(l.entity,l.entity.project)} HTTP status code must be a number`;case Ya.UUIDMustBeString:return`${se(l.entity,l.entity.project)} UUID must be a string`;case Ya.UUIDMustNotContainSpaces:return`${se(l.entity,l.entity.project)} UUID must not contain spaces`;case Ya.UUIDMustBeValidFormat:return`${se(l.entity,l.entity.project)} UUID must be in a valid format`;case ya.MustBeUniqueAmongSameEntities:return`${se(l.entity,l.entity.project)} value must be unique among the same kind`;case ya.StringValueMustNotHaveDashes:return`${se(l.entity,l.entity.project)} value must not contain dashes`;case ya.StringValueMustNotHaveSpaces:return`${se(l.entity,l.entity.project)} value must not contain spaces`;default:return`${se(l.entity,l.entity.project)} Error: ${lE(l.code)}`}}function IRi(l){var p,i,r,a;switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${se(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${se(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template entity`;case be.IncorrectMethodImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template action it's based on`;case be.IncorrectPropertyImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template property it's based on`;case be.AbstractMethodInNonAbstractEntity:return`${se(l.entity,l.entity.project)} is a template action in a non-template entity`;case be.AbstractPropertyInNonAbstractEntity:return`${se(l.entity,l.entity.project)} is a template property in a non-template entity`;case we.MethodOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites an action in the template entity`;case we.PropertyOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites a property in the template entity`;case be.MissingMethodImplementation:return`${se(l.entity,l.entity.project)} is missing an action implementation from the template entity`;case be.MissingPropertyImplementation:return`${se(l.entity,l.entity.project)} is missing a property implementation from the template entity`;case we.NameNotUniqueInScope:return`${se(l.entity,l.entity.project)} has a duplicate name in the same scope`;case be.NoProperties:return`${se(l.entity,l.entity.project)} has no properties, so it doesn't do anything`;case be.NonStaticPropertyInStaticEntity:return`${se(l.entity,l.entity.project)} has a non-static property in a static entity`;case be.StaticEntityWithNonStaticProperties:return`${se(l.entity,l.entity.project)} has non-static properties in a static entity`;case be.ReadingFromIncompatibleType:return`${se(l.entity,l.entity.project)} reads data from a value of a different data type`;case be.WritingToIncompatibleType:return`${se(l.entity,l.entity.project)} writes data to a value of a different data type`;case be.ScopeWithoutLogic:return`${se(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${se(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.PropertyImplementsIncompatibleType:return`${se(l.entity,l.entity.project)} implements a property of a different data type`;case be.PropertyImplementsNonAbstact:return`${se(l.entity,l.entity.project)} implements a non-template property`;case be.StaticPropertyImplementsNonStatic:return`${se(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.VariableCallsOthersAndHasInternalCall:return`${se(l.entity,l.entity.project)} calls other entities while being used to execute internal logic`;case be.VariableHasInputsAndInternalCall:return`${se(l.entity,l.entity.project)} has inputs while being used to execute internal logic`;case be.VariableHasOutputsAndInternalCall:return`${se(l.entity,l.entity.project)} has outputs while being used to execute internal logic`;case be.VariableIsCalledAndHasInternalCall:return`${se(l.entity,l.entity.project)} is called while being used to execute internal logic`;case we.InternalCallDeclarationIsInvalidType:return`${se(l.entity,l.entity.project)} has a declaration that is not an action`;case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has a declaration that is not found in ${(p=l.entity.parent.getDataType(null))!=null&&p.entity?se((i=l.entity.parent.getDataType(null))==null?void 0:i.entity,l.entity.project):"the variable's data-type entity"}`;case we.InternalCallParentDeclarationEntityInvalidType:return`${se(l.entity,l.entity.project)} is part of a variable whos data-type entity can't have actions`;case we.InternalCallParentMissingDataType:return`${se(l.entity,l.entity.project)} is part of a variable with no data-type entity`;case we.InternalCallDeclarationNotInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has a declaration doesn't belong to ${(r=l.entity.parent.getDataType(null))!=null&&r.entity?se((a=l.entity.parent.getDataType(null))==null?void 0:a.entity,l.entity.project):"the variable's data-type entity"}`;case we.UnreachableEntity:return`${se(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${se(l.entity,l.entity.project)} is disconnected and won't be executed by anything after publishing`;case be.AbstractEntityImplements:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${se(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${se(l.entity,l.entity.project)} has an invalid combination of properties`;case be.ExtendingNonInteractiveEntity:return`${se(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${se(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${se(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${se(l.entity,l.entity.project)} has branches that don't terminate`;case be.LastCalledEntityMustBeReturnEntity:return`${se(l.entity,l.entity.project)} must end with a termination node`;case be.MissingRequiredValue:return`${se(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${se(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${se(l.entity,l.entity.project)} is a non-template entity extending a template entity`;case be.NonStaticExtendingStaticEntity:return`${se(l.entity,l.entity.project)} is a non-static entity extending a static entity`;case be.NonStaticImplementingStaticEntity:return`${se(l.entity,l.entity.project)} is a non-static entity implementing a static entity`;case be.StaticExtendingNonStaticEntity:return`${se(l.entity,l.entity.project)} is a static entity extending a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${se(l.entity,l.entity.project)} is a static entity implementing a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${se(l.entity,l.entity.project)} reads a value and has an internal call`;case be.VariableWritesValuesAndInternalCall:return`${se(l.entity,l.entity.project)} writes values and has an internal call`;case we.EmptyName:return`${Wa[l.entity.type]} has no name`;case we.InvalidObjectStructure:return`${se(l.entity,l.entity.project)} has an invalid structure`;case we.LoopBodyFunctionOverwrite:return`${se(l.entity,l.entity.project)}'s loop body action overwrites`;case we.MethodOverwritesBaseMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites a base action with same implementation`;case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MissingCaller:return`${se(l.entity,l.entity.project)} is missing a caller`;case we.NameAsResolvedCodeNameNotUniqueInScope:return`${se(l.entity,l.entity.project)} has a name that is not unique in the scope`;case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${se(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case we.NameMustStartWithLetterOrUnderscore:return`${se(l.entity,l.entity.project)} name must start with letter or underscore`;case we.NoOverlapWithImplementedSignature:return`${se(l.entity,l.entity.project)} has no overlap with implemented signature`;case we.PropertyOverwritesBasePropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites a base property with same implementation`;case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.ReaderWriterIncompatibleDataType:return`${se(l.entity,l.entity.project)} has a reader/writer with incompatible data type`;case id.StatusCodeMustBeBetween100And599:return`${se(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case id.StatusCodeMustBeNumber:return`${se(l.entity,l.entity.project)} HTTP status code must be a number, between 100 and 599`;case Ya.UUIDMustBeString:return`${se(l.entity,l.entity.project)} UUID must be a string, eg: "${np()}"`;case Ya.UUIDMustNotContainSpaces:return`${se(l.entity,l.entity.project)} UUID must not contain spaces, eg: "${np()}"`;case Ya.UUIDMustBeValidFormat:return`${se(l.entity,l.entity.project)} UUID must be in a valid format. Eg: "${np()}"`;case ya.MustBeUniqueAmongSameEntities:return`${se(l.entity,l.entity.project)} value must be unique among the same kind`;case ya.StringValueMustNotHaveDashes:return`${se(l.entity,l.entity.project)} value must not contain dashes`;case ya.StringValueMustNotHaveSpaces:return`${se(l.entity,l.entity.project)} value must not contain spaces`;default:return`${se(l.entity,l.entity.project)} Error: ${lE(l.code)}`}}function Xx(l){const p=(l||"").startsWith("error-caller-only--");switch(p?l.replace("error-caller-only--",""):l){case ai.CallIsInHigherScope:return"In a higher scope";case ai.CallIsInLowerScope:return"In a lower scope";case ai.CallerIsInHigherScope:return"Caller is in a higher scope";case ai.CallerIsInLowerScope:return"Caller is in a lower scope";case ai.CannotBeCalledByChildren:return"Cannot be called by children";case ai.CannotCallAncestor:return"Cannot call ancestor";case ai.CannotConnectToItself:return"Cannot connect to itself";case ai.CannotReadMoreThanOneValue:return"Cannot read more than one value";case ai.CannotReadValueFromChildren:return"Cannot read value from entities executed after itself";case ai.CannotWriteValueToAncestor:return"Cannot write value to ancestor";case zT.Suggestion:return"Suggestion";case ai.ContinueOrBreakStatementCalledFromOutsideLoop:return"Cannot be called from outside loop";case ai.DataTypesNotCompatible:return"Data types not compatible";case ai.ElementInLoopBodyCallingOutsideLoop:return"Cannot call outside loop";case ai.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees:return"Error cannot be connected to success branch";case ai.ExecutionsAlreadyConnected:return"Executions already connected";case ai.IsNotValueReadingEntity:return"Is not a value reading entity";case ai.IsNotValueWrittingEntity:return"Is not a value writting entity";case ai.NotInScope:return"Not in a compatible scope";case ai.OtherIncompatibleScopeReason:return"Incompatible scope";case ai.SiblingInternalCallAlreadyUsedInParentVariable:return"Internal call already used in parent variable";case ai.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees:return"Success cannot be connected to error branch";case ai.ValuesAlreadyConnected:return"Values already connected";case ai.CannotInteractWithInputInVariableWithInternalCalls:return"Cannot interact with input in variable with internal calls";case ai.CannotInteractWithOutputInVariableWithInternalCalls:return"Cannot interact with output in variable with internal calls";case zT.CanvasGloballyDisabled:return"Canvas is globally disabled";case ai.PropertyIsConstantItsValueCantBeReset:return"Property is constant, its value can't be reset";case ai.CannotWriteValueOfGlobalVariableDeclaration:return"Cannot write value of global variable declaration";case ai.CannotReSetValueOfConstantVariable:return"Cannot re-set value of constant variable";case ai.CannotConnectToOwnNode:return"It is part of the same node";case ai.CalledByErrorMustBePassThroughCallable:return"Called by error must be pass-through callable";case ai.CannotChangeScopeBecauseItCallsOtherEntities:return"Cannot change scope because it calls other entities in its current scope";case ai.CannotChangeScopeBecauseItIsCalledByOtherEntities:return"Cannot change scope because it is called by other entities in its current scope";case ai.VariableDeclarationCannotBeMovedToLowerScopeBecauseInstancesUsage:return"Variable declaration cannot be moved to lower scope because its instances are used in the current or different incompatible lower scope";case ai.CalledBySourceMustBeCallerEntity:return"Not a caller type";case ai.CalledByErrorCannotBeConnectedToEntitiesCalledByOwnSuccessBranch:return"Already connected to the success branch from a common origin caller";case ai.CalledBySuccessCannotBeConnectedToEntitiesCalledByOwnErrorBranch:return"Already connected to the error branch from a common origin caller";case ai.RedundantCall:return"Redundant call. Already connected further down the execution path";case ai.CannotBeCalledBeforeDeclaration:return"Cannot be called before declaration";case ai.CannotBeCalledInParallelBranchToDeclaration:return"Cannot be called in parallel branch to declaration";case ai.CannotBeHigherScopeThanDeclaration:return"Cannot be in a higher scope than declaration";case ai.CannotCallGlobalVariableDeclaration:return"Cannot call global variable declaration";case ai.EntityAlreadyCalledBySuccessCannotBeConnectedToUnrelatedErrorBranch:return p?"Cannot connect error: Already connected to a success branch from a common origin caller":"Already connected to a success branch from a common origin caller";default:return Lf(l||"")}}function RRi(l,p){const i=[...l,...p],r=Array.from(new Set(i));return{hasChanged:r.length!==l.length,reasons:r}}function DRi(l,p){const i=l.filter(a=>!p.includes(a));return{hasChanged:i.length!==l.length,reasons:i}}function wRi(l,p){return l.find(i=>i.entity.id===p)||null}function jU(l){return l.filter((p,i)=>l.indexOf(p)===i)}class En{constructor(p,i,r=null,a){R(this,"ids",[]);R(this,"entity");R(this,"entityCardHeight");R(this,"entityCardWidth");R(this,"index");R(this,"childEntities",[]);R(this,"children",[]);R(this,"parents",[]);R(this,"calculationEntryPoint");R(this,"_onlyEntities",null);R(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=r||this,this._changeSet=a||null,this===this.calculationEntryPoint&&!a)throw new Error("Change-set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,r){const a=LBe-Eg-Wx,c=BBe-HA-zx;p.type===d.Project?(p.x=a,p.y=c):p.metaSync({x:p.x||a,y:p.y||c},i);const e=new En(p,0,null,i);e.calculationEntryPoint=e,e._onlyEntities=r||[],e.ids=["0"];const f=[];e.next(m=>{f.push(...m)}),En.recursivelyAssembleChildrenAreas(f),e.resolveChildrenOverlaps();const h=e.flattenChildEntities();return e._onlyEntities?h.filter(m=>{var E;return(E=e._onlyEntities)==null?void 0:E.includes(m)}):h}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(r=>{r.next(a=>{i.push(...a)})}),i.length>0&&En.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities||[]}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(p){this.calculationEntryPoint._changeSet=p}findAreaInChildrenFromEntity(p){if(this.entity===p)return this;const i=this.children.find(a=>a.entity===p);return i||this.children.reduce((a,c)=>a||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,r=i.find(c=>c.entity===p);return r||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=En.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(r=>`${r}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=kl(this.entity,!0);if(this.entity.type===d.Project){const i=[],r=[],a=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){r.push(e);return}else if(Ft.includes(e.type)){a.push(e);return}i.push(e)});const c=i.sort((e,f)=>{const h=!!Ng(e,f).length,m=kl(e),E=kl(f);return h?0:m.length&&!E.length?-1:!m.length&&E.length?1:0}).filter(e=>!Ac(e).length);this.childEntities=[...r,...a,...c]}else{const i=[],r=[],a=[],c=[],e=[];hr.includes(this.entity.type)&&K1(this.entity).forEach(m=>{if(_t.includes(m.type)){a.push(m);return}const E=ht(m);i.push(E)}),vr.includes(this.entity.type)&&r.push(...this.entity.detachedChildren);const f=p.filter(h=>{const m=i.includes(h);return m||a.includes(h)||r.includes(h)?!1:_t.includes(h.type)?(a.push(h),!1):Pr.includes(h.type)&&!m?(c.push(h),!1):h.type===d.DefinitionEntity?(e.push(h),!1):!0});i.sort((h,m)=>Ml(h,m)?-1:0),c.sort((h,m)=>Ml(h,m)?-1:0),a.sort((h,m)=>W_(h,m)?1:W_(m,h)?-1:0),this.childEntities=[...e,...i,...c,...f,...a,...r]}}calculateCardSize(){const p=MBe(this.entity);this.entityCardWidth=p.width,this.entityCardHeight=p.height}static getBoundriesOfTwoAreas(p,i){return{top:Math.min(p.top,i.top),left:Math.min(p.left,i.left),bottom:Math.max(p.bottom,i.bottom),right:Math.max(p.right,i.right)}}static getBoundriedOfCombinedAreas(p,i){const r=p.filter(c=>!i.includes(c));return r.reduce((c,e)=>i.includes(e)?c:En.getBoundriesOfTwoAreas(c,e.fullBranchArea),r[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,f)=>En.getBoundriesOfTwoAreas(e,f),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],r=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,f)=>En.getBoundriesOfTwoAreas(e,f),r)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>En.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(a=>a.fullBranchArea).reduce((a,c)=>En.getBoundriesOfTwoAreas(a,c),p)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const p=this.ownEntityArea;return{top:p.top,left:p.left,bottom:p.bottom+HA,right:p.right+Eg}}static filterOutRepeatedAreas(p){return p.filter((i,r)=>p.indexOf(i)===r)}getEarliestId(p,i){const r=p.split("-"),a=i.split("-");return r.length<a.length?p:r.length>a.length?i:r.reduce((e,f,h)=>f<a[h]?p:i,p)}getEarliestLevel(){return this.ids.reduce((r,a)=>this.getEarliestId(r,a),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const r=this.parents.reduce((a,c)=>c.getEarliestLevel()>a.getEarliestLevel()?c:a,this.parents[0]).countColumns();return p+=r,p}getLatestId(p,i){if(p===i)return p;const r=p.split("-"),a=i.split("-");return r.length<a.length?i:r.length>a.length?p:r.reduce((e,f,h)=>f>a[h]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((r,a)=>this.getLatestId(r,a),this.ids[0]).split("-").length}smoothPosition(){const p=this.flattenSiblings();if(!p.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(r=>{r!==this.calculationEntryPoint&&r.shiftDownAlone(i)})}else if([...Ft].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(r=>!this.parents.includes(r));i.length?i.every(a=>{const c=this.countColumns(),e=a.countColumns();return c>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(p,i){if(p.includes(this))return p;this.move(this.entity,{y:this.entity.y+i});let r=[...p,this];return this.children.forEach(a=>{if(En.getEarliestParentInChain(a)!==this)return;const e=wRi(r,a.entity.id);r=En.filterOutRepeatedAreas([...r]),e||(r=r.filter(h=>h!==a));const f=a.shiftDownUntilAny(r,i);r.push(...f)}),r}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(r=>{const a=En.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);En.getEarliestParentInChain(r)===this&&r.shiftRightUntilAny(a,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const a=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(a,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+zy,h={top:f,left:e.left,bottom:f,right:e.right};return En.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-zy;this.shiftDownAlone(r)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+zy,h={top:f,left:e.left,bottom:f,right:e.right};return En.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-zy;return this.shiftDownAlone(r),r}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(r=>{const a=r.adjustVerticallyToAvoidOverlaps();i.push(...a)}),p.forEach(r=>{r.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((r,a)=>{if(!r.ids.length)return-1;if(!a.ids.length)return 1;const c=r.ids.sort((f,h)=>f.length<h.length?-1:0),e=a.ids.sort((f,h)=>f.length<h.length?-1:0);return c[0].length-e[0].length})[0]),i}flattenEarlierSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.slice(0,a.children.indexOf(this)).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.filter(f=>f!==this).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r,...r.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((r,a)=>p.has(a.entity.id)?r:(p.add(a.entity.id),[...r,a,...a.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(a=>a.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,r)=>{const a=r.children.indexOf(this),c=r.children.slice(a+1);return[...i,...c]},[]);return jU(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((r,a)=>[...r,...a.getLowerAreas()],[]);return jU([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const r=En.getEarliestParentInChain(this).children[this.index-1];if(!r)return p;const a=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...a,...c,r],m=C(e.flatMap(_=>Ng(this.entity,_.entity))).filter(_=>_.id!==this.entity.id).map(_=>this.findAreaFromEntity(_)).filter(_=>!!_),E=this.getFullAreaUntilAny(m),b=r.getFullAreaUntilAny(m),g=e.reduce((_,$)=>$===this||$.fullBranchArea.left!==E.left?_:Math.max(_,$.fullBranchArea.bottom),b.bottom);if(E.top<g){const _=g-E.top+HA;return this.shiftDownUntilAny(p,_)}return p}move(p,i){this.onlyEntities.includes(p)&&p.metaSync(i,this.changeSet)}addChild(p){const i=this.childEntities[p];let r=null;i.x&&i.y?r=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),r||(r=new En(i,p,this.calculationEntryPoint));const a=this.ownEntityPlusBufferArea;this.children.includes(r)||(this.children.push(r),r.addParent(this));const c=r.fullBranchArea;if(c.left<a.right){const e=a.right-c.left;r.shiftRight(e)}return r}flattenChildEntities(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r.entity,...r.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((r,a)=>{const c=this.addChild(a);c&&i.push(c)}),p(i)}}async function CRi(l,p,i={}){var f;const r=z.YieldTracker.from(i),a=[],c=[];for(const h of l.instancesList){if(!cf.includes(h.type)||((f=ht(h))==null?void 0:f.id)!==h.id)continue;let m=Zt(h,l);if(!m){console.log("No top scope owner for instance: ",h," in project: ",l);continue}if(!(Ft.includes(m.type)&&m.collapsed&&m.id!==h.id)){for(;m.parent&&m.parent!==l;)m=m.parent,Ft.includes(m.type)&&m.collapsed&&(m.id,h.id);i.forceAll?(h.x=0,h.y=0,c.push(h)):!h.x||!h.y?c.push(h):a.push(h),await r.tick()}}console.log("Layout generation - calculating positions for entities without coordinates... FORCE: ",i.forceAll||!1),console.log(`
|
|
54
|
+
`+c):r.stack=c}catch{}}throw r}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=of(this.defaults,i);const{transitional:r,paramsSerializer:a,headers:c}=i;r!==void 0&&SA.assertOptions(r,{silentJSONParsing:jo.transitional(jo.boolean),forcedJSONParsing:jo.transitional(jo.boolean),clarifyTimeoutError:jo.transitional(jo.boolean)},!1),a!=null&&(qe.isFunction(a)?i.paramsSerializer={serialize:a}:SA.assertOptions(a,{encode:jo.function,serialize:jo.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),SA.assertOptions(i,{baseUrl:jo.spelling("baseURL"),withXsrfToken:jo.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&qe.merge(c.common,c[i.method]);c&&qe.forEach(["delete","get","head","post","put","patch","common"],$=>{delete c[$]}),i.headers=Gl.concat(e,c);const f=[];let h=!0;this.interceptors.request.forEach(function(L){typeof L.runWhen=="function"&&L.runWhen(i)===!1||(h=h&&L.synchronous,f.unshift(L.fulfilled,L.rejected))});const m=[];this.interceptors.response.forEach(function(L){m.push(L.fulfilled,L.rejected)});let E,b=0,g;if(!h){const $=[BU.bind(this),void 0];for($.unshift(...f),$.push(...m),g=$.length,E=Promise.resolve(i);b<g;)E=E.then($[b++],$[b++]);return E}g=f.length;let _=i;for(;b<g;){const $=f[b++],L=f[b++];try{_=$(_)}catch(j){L.call(this,j);break}}try{E=BU.call(this,_)}catch($){return Promise.reject($)}for(b=0,g=m.length;b<g;)E=E.then(m[b++],m[b++]);return E}getUri(p){p=of(this.defaults,p);const i=u2e(p.baseURL,p.url,p.allowAbsoluteUrls);return a2e(i,p.params,p.paramsSerializer)}}qe.forEach(["delete","get","head","options"],function(p){hg.prototype[p]=function(i,r){return this.request(of(r||{},{method:p,url:i,data:(r||{}).data}))}});qe.forEach(["post","put","patch"],function(p){function i(r){return function(c,e,f){return this.request(of(f||{},{method:p,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}hg.prototype[p]=i(),hg.prototype[p+"Form"]=i(!0)});const qA=hg;class Ux{constructor(p){if(typeof p!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const r=this;this.promise.then(a=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](a);r._listeners=null}),this.promise.then=a=>{let c;const e=new Promise(f=>{r.subscribe(f),c=f}).then(a);return e.cancel=function(){r.unsubscribe(c)},e},p(function(c,e,f){r.reason||(r.reason=new gm(c,e,f),i(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(p){if(this.reason){p(this.reason);return}this._listeners?this._listeners.push(p):this._listeners=[p]}unsubscribe(p){if(!this._listeners)return;const i=this._listeners.indexOf(p);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const p=new AbortController,i=r=>{p.abort(r)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new Ux(function(a){p=a}),cancel:p}}}const sRi=Ux;function lRi(l){return function(i){return l.apply(null,i)}}function oRi(l){return qe.isObject(l)&&l.isAxiosError===!0}const b_={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(b_).forEach(([l,p])=>{b_[p]=l});const dRi=b_;function h2e(l){const p=new qA(l),i=HLe(qA.prototype.request,p);return qe.extend(i,qA.prototype,p,{allOwnKeys:!0}),qe.extend(i,p,null,{allOwnKeys:!0}),i.create=function(a){return h2e(of(l,a))},i}const Nn=h2e(Gx);Nn.Axios=qA;Nn.CanceledError=gm;Nn.CancelToken=sRi;Nn.isCancel=o2e;Nn.VERSION=y2e;Nn.toFormData=r1;Nn.AxiosError=fi;Nn.Cancel=Nn.CanceledError;Nn.all=function(p){return Promise.all(p)};Nn.spread=lRi;Nn.isAxiosError=oRi;Nn.mergeConfig=of;Nn.AxiosHeaders=Gl;Nn.formToJSON=l=>l2e(qe.isHTMLForm(l)?new FormData(l):l);Nn.getAdapter=f2e.getAdapter;Nn.HttpStatusCode=dRi;Nn.default=Nn;const uRi=Nn;class m2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(na.HttpRequest);a&&(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[3]||{},e={method:a[0],url:a[1],params:a[2],headers:c,data:a[4]};z.Logger.log("Axios request config: ",e);const f=await uRi(e);return{value:U.Success,error:null,result:{status:f.status,headers:f.headers,data:f.data}}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class T2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.Validate);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)});z.Logger.log("Inputs for entity validation: ",a);const e=Y1(a[1]).safeParse(a[0]);return e.success?{value:U.Success,error:null,result:{data:a[0]}}:{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e.error.errors,result:null}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const Ba=l=>l.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class v2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.ReadKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ba(r),e=F_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class E2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.WriteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=K_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class b2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.DeleteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ba(r),e=S_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class A2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.ReadNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=q_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class g2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY,version:"1.0.0",description:"Entity write-nested-key operation implementation module (immutable, no auto-create)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.WriteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=Z_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class I2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY,version:"1.0.0",description:"Entity write-safe-nested-key-recursively operation implementation module (immutable, auto-create)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.WriteSafeNestedKeyRecursively);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=H_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class R2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(xe.DeleteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ba(r),e=W_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class D2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.HasKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ba(r),e=z_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class w2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.KeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=Y_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class C2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.HasNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ba(r),e=J_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class O2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.NestedKeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ba(r),f=X_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class _2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(xe.IsInstanceOfType);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m,E,b,g,_;try{const $=((c=(a=r[0])==null?void 0:a.value)==null?void 0:c.parent)||((f=(e=r[0])==null?void 0:e.value)==null?void 0:f.standaloneParent),L=(m=(h=r[0])==null?void 0:h.value)==null?void 0:m.value,j=(b=(E=r[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!L)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!j)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!$)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(j.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const k=$.getDataType(null);if(((g=k==null?void 0:k.entity)==null?void 0:g.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let G=!1;return((_=k==null?void 0:k.entity)==null?void 0:_.id)!==(j==null?void 0:j.id)?G=!1:Y1(k==null?void 0:k.entity).safeParse(L).success?G=!0:G=!1,{value:U.Success,error:null,result:G}}catch($){return{value:U.UnhandledError,error:$,result:null}}}})}}class V2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Merge);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=Ba(r),c=Q_e(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class P2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Keys);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ba(r),c=eVe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class N2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Values);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ba(r),c=tVe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class x2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic);if(!r)return;const a=r.get(xe.Entries);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ba(r),c=iVe(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}let As=null;try{As=require("crypto")}catch{}const DT=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:As&&As.webcrypto?As.webcrypto:null,ap=DT?DT.subtle:null;function jT(l){const p=new ArrayBuffer(l.byteLength);return new Uint8Array(p).set(l),p}function rn(l,p="utf8"){if(l instanceof Uint8Array)return l;const i=String(l);if(p==="utf8"){if(typeof TextEncoder<"u")return new TextEncoder().encode(i);if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"utf8"))}else if(p==="hex"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"hex"))}else if(p==="base64"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"base64"))}else if(p==="base64url"){const r=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(r,"base64"));const a=typeof atob=="function"?atob(r):"",c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function bo(l,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(l);if(typeof Buffer<"u")return Buffer.from(l).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(l).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(l).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(l).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const $2e=l=>rn(l,"base64"),L2e=(l,p)=>{const i=l instanceof Uint8Array?l:rn(String(l),p||"utf8");return bo(i,"base64")},dh=(l,p)=>{const i=l instanceof Uint8Array?l:rn(String(l),p||"utf8");return bo(i,"base64url")},df=l=>rn(l,"base64url"),B2e=(l,p)=>{const i=l instanceof Uint8Array?l:rn(String(l),p||"utf8");return bo(i,"hex")},M2e=l=>rn(l,"hex");function kx(l){if(DT&&DT.getRandomValues){const p=new Uint8Array(l);return DT.getRandomValues(p),p}if(As&&As.randomBytes)return new Uint8Array(As.randomBytes(l));throw new Error("Secure random not available")}function s1(l,p){if(!(l instanceof Uint8Array)||!(p instanceof Uint8Array)||l.length!==p.length)return!1;let i=0;for(let r=0;r<l.length;r++)i|=l[r]^p[r];return i===0}function G2e(l,p,i,r){if((typeof l!="string"||typeof p!="string")&&typeof l!="string"&&typeof p!="string")throw new Error("Invalid input types");const a=i??"utf8",c=r??"utf8",e=rn(l??"",a),f=rn(p??"",c);return s1(e,f)}async function j2e(l,p){if(ap){const i=await ap.digest({name:l},jT(p));return new Uint8Array(i)}if(As){const i=l.replace("SHA-","sha"),r=As.createHash(i);return r.update(Buffer.from(p)),new Uint8Array(r.digest())}throw new Error("Hash not available")}async function U2e(l,p,i,r){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const a=String(l??"SHA-256"),c=i??"utf8",e=r??"base64url",f=rn(p??"",c),h=await j2e(a,f);return bo(h,e)}async function l1(l,p,i){if(ap){const r=await ap.importKey("raw",jT(p),{name:"HMAC",hash:{name:l}},!1,["sign"]),a=await ap.sign("HMAC",r,jT(i));return new Uint8Array(a)}if(As){const r=`sha${l.split("-")[1]}`,a=As.createHmac(r,Buffer.from(p));return a.update(Buffer.from(i)),new Uint8Array(a.digest())}throw new Error("HMAC not available")}async function k2e(l,p,i,r,a,c){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),f=r??"utf8",h=a??"utf8",m=c??"base64url",E=rn(l??"",f),b=rn(p??"",h),g=await l1(e,E,b);return bo(g,m)}async function o1(l,p,{iterations:i,length:r,hashAlg:a="SHA-256"}){if(ap){const c=await ap.importKey("raw",jT(l),"PBKDF2",!1,["deriveBits"]),e=await ap.deriveBits({name:"PBKDF2",salt:jT(p),iterations:i,hash:a},c,r*8);return new Uint8Array(e)}if(As){const c=a==="SHA-512"?"sha512":"sha256";return await new Promise((e,f)=>{As.pbkdf2(Buffer.from(l),Buffer.from(p),i,r,c,(h,m)=>{h?f(h):e(new Uint8Array(m))})})}throw new Error("PBKDF2 not available")}async function F2e(l,p,i,r,a,c,e,f){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const h=c??"utf8",m=e??"utf8",E=f??"base64url",b=Math.max(1,Number(i)||21e4),g=Math.max(1,Number(r)||32),_=a??"SHA-256",$=rn(l??"",h),L=rn(p??"",m),j=await o1($,L,{iterations:b,length:g,hashAlg:_});return bo(j,E)}async function K2e(l,p=kx(16),i=21e4,r=32,a="SHA-256"){const c=rn(l,"utf8"),e=await o1(c,p,{iterations:i,length:r,hashAlg:a}),f=dh(p),h=dh(e);return`pbkdf2$${a.toLowerCase()}$${i}$${f}$${h}`}async function S2e(l,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const r=i[1].toLowerCase(),a=parseInt(i[2],10),c=df(i[3]),e=df(i[4]),f=r.includes("512")?"SHA-512":"SHA-256",h=await o1(rn(l,"utf8"),c,{iterations:a,length:e.length,hashAlg:f});return s1(h,e)}async function q2e(l,p,i,r,a,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,f=i!=null?Math.max(1,Number(i)||0):void 0,h=r??void 0,m=c??"base64url",E=a!=null?rn(a,m):void 0;return await K2e(String(l??""),E,e,f,h)}function GU(l){return dh(rn(JSON.stringify(l),"utf8"))}function mg(l){try{return JSON.parse(bo(df(l),"utf8"))}catch{return null}}async function Z2e(l,p,{alg:i="HS256",includeIat:r=!0,expiresInSeconds:a,notBeforeSeconds:c,issuer:e,subject:f,audience:h,jwtid:m,header:E={}}={}){const b={alg:i,typ:"JWT",...E},g=Math.floor(Date.now()/1e3),_={...l||{}};r&&(_.iat=g),typeof a=="number"&&(_.exp=g+a),typeof c=="number"&&(_.nbf=g+c),e&&(_.iss=e),f&&(_.sub=f),h&&(_.aud=h),m&&(_.jti=m);const $=GU(b),L=GU(_),j=rn(`${$}.${L}`,"utf8"),G=await l1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,j),H=dh(G);return`${$}.${L}.${H}`}async function H2e(l,p,i,r,a,c,e,f,h,m,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(l!=null&&typeof l!="object")throw new Error("Invalid input type for payload; expected object");if(E!=null&&typeof E!="object")throw new Error("Invalid input type for header; expected object");if(m!=null&&typeof m!="string")throw new Error("Invalid input type for jwtid; expected string");if(e!=null&&typeof e!="string")throw new Error("Invalid input type for issuer; expected string");if(f!=null&&typeof f!="string")throw new Error("Invalid input type for subject; expected string");if(h!=null&&typeof h!="string"&&!Array.isArray(h))throw new Error("Invalid input type for audience; expected string or string[]");const _=rn(p??"",b??"utf8");return await Z2e(l??{},_,{alg:i??"HS256",includeIat:r==null?!0:!!r,expiresInSeconds:a!=null?Number(a):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:f??void 0,audience:h??void 0,jwtid:m??void 0,header:E??void 0})}async function W2e(l,p,{alg:i="HS256",issuer:r,audience:a,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[f,h,m]=String(l).split(".");if(!f||!h||!m)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=mg(f),b=mg(h);if(!E||!b)return{valid:!1,header:E,payload:b,reason:"Bad base64/json"};if(E.alg!==i)return{valid:!1,header:E,payload:b,reason:"Alg mismatch"};const g=rn(`${f}.${h}`,"utf8"),$=await l1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,g),L=df(m);if(!s1($,L))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const j=Math.floor(Date.now()/1e3),k=Math.max(0,Number(e)||0);if(b.nbf!=null&&j+k<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&j-k>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(r&&b.iss!==r)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(a){const G=b.aud;if(!(Array.isArray(G)?G.includes(a):G===a))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&j-Number(b.iat)>Number(c)+k?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(f){return{valid:!1,header:null,payload:null,reason:String((f==null?void 0:f.message)??f)}}}async function z2e(l,p,i,r,a,c,e,f){if(typeof l!="string")throw new Error("Invalid input type for token; expected string");if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(typeof r!="string")throw new Error("Invalid input type for issuer; expected string");if(a!=null&&typeof a!="string")throw new Error("Invalid input type for audience; expected string");const m=rn(p??"",f??"utf8");return await W2e(String(l??""),m,{alg:i??"HS256",issuer:r??void 0,audience:a??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function Y2e(l){const[p,i,r]=String(l).split(".");return{header:p?mg(p):null,payload:i?mg(i):null,signature:r?df(r):new Uint8Array}}function J2e(l,p){if(!l)throw new Error("Token is required for decoding");if(typeof l!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:r,payload:a,signature:c}=Y2e(String(l??"")),e=bo(c,i);return{header:r,payload:a,signature:e}}class X2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(it.GenerateRandomBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)}),e=Math.max(0,Number(a)||0),f=c??"base64url",h=kx(e),m=bo(h,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 Q2e extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomInteger);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=D_e(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 eBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomFloat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=zR();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 tBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomHexadecimal);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=Tx(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 iBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomBase62);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=vx(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 rBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomBase64);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=C_e(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 nBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomAlphanumeric);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=Ex(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 aBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateIdentifier);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=bx(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 sBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateRandomUUIDv4);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=np();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 lBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{z.Logger.log("Initializing Random Generate Short Identifier Module");const r=i.find(a=>a.contextType===te.Logic);if(r){z.Logger.log("Project state found, setting up operation");const a=r.get(it.GenerateShortIdentifier);a?(z.Logger.log("Operation found, setting autoexecutable and implementation"),a.autoexecutable=!0,a.implementation=this.module.main):z.Logger.warn("Operation generate-short-identifier not found in project state")}else z.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,r)=>{try{const a=O_e();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 oBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(it.GenerateHexadecimalToken);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=__e();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}}}})}}function pRi(l){let p;if(l===null?p="null":Array.isArray(l)?p="array":p=typeof l,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class dBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(Xe.GetTypeOf);a&&(a.autoexecutable=!0,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{value:U.Success,error:null,result:pRi(c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.ToString);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);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 pBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.ToNumber);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=Number(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 cBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.ToBytes);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=rn(a,c||"utf8");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 fBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.FromBytesToString);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=bo(a,c||"utf8");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 yBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.EncodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:L2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class hBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.DecodeBase64);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=$2e(String(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 mBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.EncodeBase64Url);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=dh(a,c||"utf8");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 TBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.DecodeBase64Url);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=df(String(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 vBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.EncodeHex);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=B2e(a,c||"utf8");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 EBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(Xe.DecodeHex);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=M2e(String(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 bBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.Hash);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:U2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class ABe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.Hmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)});return{value:U.Success,error:null,result:k2e(c,e,a,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class gBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.ConstantTimeEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:G2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class IBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(yi.DeriveKeyPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(g=>{var _,$;return((_=g.value)==null?void 0:_.valueAsType)??(($=g.value)==null?void 0:$.value)});return{value:U.Success,error:null,result:F2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class RBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(on.Parse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a;try{const c=(a=r[0].value)==null?void 0:a.value;if(typeof c!="string")throw new Error(`Invalid input type for JSON.parse operation: expected string, got ${typeof c}`);const e=JSON.parse(c);return{value:U.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:c,result:null}}}})}}class DBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===te.Logic);if(r){const a=r.get(on.Stringify);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a,c;try{const e=(a=r[0].value)==null?void 0:a.value,f=(c=r[1].value)==null?void 0:c.value;if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error(`Invalid input type for JSON.stringify operation: expected object or array, got ${typeof e}`);if(!f&&f!==0){const m=JSON.stringify(e);return{value:U.Success,error:null,result:m}}const h=JSON.stringify(e,null,f);return{value:U.Success,error:null,result:h}}catch(e){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e,result:null}}}})}}class wBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dr.BuildJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b,g,_,$,L]=r.map(j=>{var k,G;return((k=j.value)==null?void 0:k.valueAsType)??((G=j.value)==null?void 0:G.value)});return{value:U.Success,error:null,result:await H2e(a,c,e,f,h,m,E,b,g,_,$,L)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class CBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dr.VerifyJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(g=>{var _,$;return((_=g.value)==null?void 0:_.valueAsType)??(($=g.value)==null?void 0:$.value)});return{value:U.Success,error:null,result:await z2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class OBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dr.DecodeJwt);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:J2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class _Be extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dn.HashPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,g;return((b=E.value)==null?void 0:b.valueAsType)??((g=E.value)==null?void 0:g.value)});return{value:U.Success,error:null,result:await q2e(a,c,e,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class VBe extends _e{constructor(){super(...arguments);R(this,"manifest",{id:Oe.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:De.High,permissions:[Ce.All],contexts:[te.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===te.Logic),a=r==null?void 0:r.get(dn.VerifyPasswordPBKDF2);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=await S2e(String(a??""),String(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_ extends QR{constructor(p,i,r=i.projectId){super(p,te.Editor),this._editor=i,this.id=r}get ready(){return this._editor.ready}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branch(){return this._editor.branch}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(p){this._editor.undoableStackValueIndex=p}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}getRefreshToken(){return this._editor.getRefreshToken()}removeValueByOwnerId(p){return this._editor.removeValueByOwnerId(p)}removeValue(p){return this._editor.removeValue(p)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(p,i){return this._editor.initTest(p,i)}removeTest(p){return this._editor.removeTest(p)}async copyEntities(p,i={}){return this._editor.copyEntities(p,i)}resolveInitialChildrenPositions(p,i,r){return this._editor.resolveInitialChildrenPositions(p,i,r)}publish(){return this._editor.publish()}loadGivenPublication(p){return this._editor.loadGivenPublication(p)}validateProjectState(p){return this._editor.validateProjectState(p)}requestActiveDynamicValue(p,i=!1){return this._editor.requestActiveDynamicValue(p,i)}getValueTypePreference(p){return this._editor.getValueTypePreference(p)}setValueTypePreference(p,i){return this._editor.setValueTypePreference(p,i)}implementFeature(p){return this._editor.implementFeature(p)}}function cRi(l,p){return p instanceof A_?p:new A_(l,p)}class g_ extends QR{constructor(p,i){super(p,te.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get projectVersion(){return this._publicationRun.projectVersion}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function fRi(l,p){return p instanceof g_?p:new g_(l,p)}function yRi(l){l.register(new IVe(l)),l.register(new gVe(l)),l.register(new vVe(l)),l.register(new bVe(l)),l.register(new AVe(l)),l.register(new EVe(l)),l.register(new sLe(l)),l.register(new lLe(l)),l.register(new oLe(l)),l.register(new uLe(l)),l.register(new dLe(l)),l.register(new pLe(l)),l.register(new Q2e(l)),l.register(new eBe(l)),l.register(new tBe(l)),l.register(new iBe(l)),l.register(new rBe(l)),l.register(new nBe(l)),l.register(new aBe(l)),l.register(new sBe(l)),l.register(new lBe(l)),l.register(new oBe(l)),l.register(new a$e(l)),l.register(new s$e(l)),l.register(new l$e(l)),l.register(new o$e(l)),l.register(new d$e(l)),l.register(new u$e(l)),l.register(new p$e(l)),l.register(new c$e(l)),l.register(new f$e(l)),l.register(new y$e(l)),l.register(new h$e(l)),l.register(new m$e(l)),l.register(new T$e(l)),l.register(new v$e(l)),l.register(new E$e(l)),l.register(new b$e(l)),l.register(new A$e(l)),l.register(new g$e(l)),l.register(new I$e(l)),l.register(new w$e(l)),l.register(new C$e(l)),l.register(new O$e(l)),l.register(new Dxe(l)),l.register(new wxe(l)),l.register(new Cxe(l)),l.register(new Oxe(l)),l.register(new _xe(l)),l.register(new Vxe(l)),l.register(new Pxe(l)),l.register(new Nxe(l)),l.register(new xxe(l)),l.register(new Lxe(l)),l.register(new Bxe(l)),l.register(new Mxe(l)),l.register(new Gxe(l)),l.register(new jxe(l)),l.register(new FNe(l)),l.register(new KNe(l)),l.register(new SNe(l)),l.register(new T2e(l)),l.register(new m2e(l)),l.register(new kPe(l)),l.register(new FPe(l)),l.register(new KPe(l)),l.register(new SPe(l)),l.register(new qPe(l)),l.register(new ZPe(l)),l.register(new HPe(l)),l.register(new WPe(l)),l.register(new zPe(l)),l.register(new oNe(l)),l.register(new jNe(l)),l.register(new UNe(l)),l.register(new kNe(l)),l.register(new YPe(l)),l.register(new JPe(l)),l.register(new XPe(l)),l.register(new QPe(l)),l.register(new eNe(l)),l.register(new tNe(l)),l.register(new iNe(l)),l.register(new rNe(l)),l.register(new nNe(l)),l.register(new aNe(l)),l.register(new sNe(l)),l.register(new lNe(l)),l.register(new dNe(l)),l.register(new uNe(l)),l.register(new pNe(l)),l.register(new cNe(l)),l.register(new fNe(l)),l.register(new yNe(l)),l.register(new hNe(l)),l.register(new mNe(l)),l.register(new TNe(l)),l.register(new vNe(l)),l.register(new ENe(l)),l.register(new bNe(l)),l.register(new _Ne(l)),l.register(new VNe(l)),l.register(new PNe(l)),l.register(new ANe(l)),l.register(new gNe(l)),l.register(new INe(l)),l.register(new RNe(l)),l.register(new DNe(l)),l.register(new wNe(l)),l.register(new CNe(l)),l.register(new ONe(l)),l.register(new A2e(l)),l.register(new g2e(l)),l.register(new I2e(l)),l.register(new R2e(l)),l.register(new v2e(l)),l.register(new E2e(l)),l.register(new b2e(l)),l.register(new D2e(l)),l.register(new C2e(l)),l.register(new _2e(l)),l.register(new w2e(l)),l.register(new O2e(l)),l.register(new V2e(l)),l.register(new x2e(l)),l.register(new P2e(l)),l.register(new N2e(l)),l.register(new Uxe(l)),l.register(new Sxe(l)),l.register(new qxe(l)),l.register(new Wxe(l)),l.register(new zxe(l)),l.register(new Yxe(l)),l.register(new Jxe(l)),l.register(new Xxe(l)),l.register(new Qxe(l)),l.register(new e$e(l)),l.register(new t$e(l)),l.register(new Zxe(l)),l.register(new Hxe(l)),l.register(new Fxe(l)),l.register(new Kxe(l)),l.register(new kxe(l)),l.register(new $xe(l)),l.register(new r$e(l)),l.register(new n$e(l)),l.register(new i$e(l)),l.register(new fLe(l)),l.register(new MLe(l)),l.register(new BLe(l)),l.register(new GLe(l)),l.register(new jLe(l)),l.register(new mLe(l)),l.register(new TLe(l)),l.register(new ILe(l)),l.register(new ALe(l)),l.register(new $Le(l)),l.register(new OLe(l)),l.register(new VLe(l)),l.register(new NLe(l)),l.register(new PLe(l)),l.register(new gLe(l)),l.register(new DLe(l)),l.register(new wLe(l)),l.register(new RLe(l)),l.register(new cLe(l)),l.register(new vLe(l)),l.register(new _Le(l)),l.register(new FLe(l)),l.register(new m_(l)),l.register(new hLe(l)),l.register(new ELe(l)),l.register(new yLe(l)),l.register(new xLe(l)),l.register(new bLe(l)),l.register(new CLe(l)),l.register(new LLe(l)),l.register(new kLe(l)),l.register(new ULe(l)),l.register(new KLe(l)),l.register(new m_(l)),l.register(new qLe(l)),l.register(new SLe(l)),l.register(new ZLe(l)),l.register(new K$e(l)),l.register(new S$e(l)),l.register(new q$e(l)),l.register(new V$e(l)),l.register(new D$e(l)),l.register(new $$e(l)),l.register(new G$e(l)),l.register(new R$e(l)),l.register(new j$e(l)),l.register(new F$e(l)),l.register(new B$e(l)),l.register(new L$e(l)),l.register(new fg(l)),l.register(new Z$e(l)),l.register(new H$e(l)),l.register(new M$e(l)),l.register(new k$e(l)),l.register(new U$e(l)),l.register(new x$e(l)),l.register(new N$e(l)),l.register(new P$e(l)),l.register(new _$e(l)),l.register(new Y$e(l)),l.register(new z$e(l)),l.register(new J$e(l)),l.register(new W$e(l)),l.register(new LNe(l)),l.register(new NNe(l)),l.register(new $Ne(l)),l.register(new BNe(l)),l.register(new MNe(l)),l.register(new xNe(l)),l.register(new GNe(l)),l.register(new dBe(l)),l.register(new hBe(l)),l.register(new TBe(l)),l.register(new EBe(l)),l.register(new yBe(l)),l.register(new mBe(l)),l.register(new vBe(l)),l.register(new fBe(l)),l.register(new cBe(l)),l.register(new pBe(l)),l.register(new uBe(l)),l.register(new RBe(l)),l.register(new DBe(l)),l.register(new gBe(l)),l.register(new IBe(l)),l.register(new X2e(l)),l.register(new bBe(l)),l.register(new ABe(l)),l.register(new CBe(l)),l.register(new wBe(l)),l.register(new OBe(l)),l.register(new _Be(l)),l.register(new VBe(l)),l.register(new DVe(l)),l.register(new wVe(l)),l.register(new pg(l)),l.register(new cg(l))}class Fx{constructor(p=new z.Events("extensions-registry-fallback-events")){R(this,"extensionsRegistry",new Map);R(this,"initialized",new Set);R(this,"initializedContexts",new Set);R(this,"onResolveEditorContextCallback",()=>null);R(this,"onResolveProjectLogicContextCallback",()=>null);R(this,"onResolveEditorGUIContextCallback",()=>null);R(this,"onResolveGUIContextCallback",()=>null);R(this,"onResolveCompileContextCallback",()=>null);R(this,"onResolvePublicationRunContextCallback",()=>null);this.events=p,this.off=this.events.off.bind(this.events),this.on=this.events.on.bind(this.events),this.emit=this.events.emit.bind(this.events),this.emitAsync=this.events.emitAsync.bind(this.events),this.emitAsyncAll=this.events.emitAsyncAll.bind(this.events),this.emitAsyncAllSettled=this.events.emitAsyncAllSettled.bind(this.events),this.emitAsyncSequentially=this.events.emitAsyncSequentially.bind(this.events),this.emitAsyncSequentiallyAll=this.events.emitAsyncSequentiallyAll.bind(this.events),this.emitAsyncSequentiallyAllSettled=this.events.emitAsyncSequentiallyAllSettled.bind(this.events)}onResolveEditorContext(p){this.onResolveEditorContextCallback=p}onResolveProjectLogicContext(p){this.onResolveProjectLogicContextCallback=p}onResolveGUIContext(p){this.onResolveGUIContextCallback=p}onResolveEditorGUIContext(p){this.onResolveEditorGUIContextCallback=p}onResolveCompileContext(p){this.onResolveCompileContextCallback=p}onResolvePublicationRunContext(p){this.onResolvePublicationRunContextCallback=p}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((p,i)=>(p.manifest.initPriority||De.Normal)-(i.manifest.initPriority||De.Normal))}async setup(){yRi(this),z.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case te.Editor:return this.onResolveEditorContextCallback();case te.Logic:return this.onResolveProjectLogicContextCallback();case te.EditorGUI:return this.onResolveEditorGUIContextCallback();case te.Compile:return this.onResolveCompileContextCallback();case te.PublicationRun:return this.onResolvePublicationRunContextCallback();case te.GUI:return this.onResolveGUIContextCallback();case te.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const r=[];i.length===0&&(i=p.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&r.push(c)}return r}requestExtension(p){const i=this.extensionsRegistry.get(p);if(i)return i;throw new Error(`Unknown extension: ${p}`)}register(p){this.extensionsRegistry.set(p.manifest.id,p)}async initAll(){var p,i;for(const r of this.extensionInOrder)if(r.module.init&&!this.initialized.has(r.manifest.id)){const a=r.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(p=r.module).init)==null?void 0:i.call(p,a)),this.initialized.add(r.manifest.id))}else!r.module.init&&!this.initialized.has(r.manifest.id)&&this.initialized.add(r.manifest.id)}async initForReady(){z.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){z.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await p.module.init(i),this.initialized.add(p.manifest.id)):z.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(z.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):z.Logger.log(`Skipping initialization of ${p.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const p of[...this.extensionInOrder].reverse())p.module.destroy&&await p.module.destroy();this.events.destroy()}on(p,i){this.events.on(p,i)}emit(p,...i){this.events.emit(p,...i)}off(p,i){this.events.off(p,i)}emitAsync(p,...i){return this.events.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.events.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.events.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.events.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.events.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.events.emitAsyncSequentiallyAllSettled(p,...i)}async contextAvailable(p){if(this.initializedContexts.has(p)){z.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case te.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case te.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}z.Logger.log(`Context ${p} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(p){return window.localStorage.getItem("dynamic-value-type-preference--"+p)||null}setValueTypePreference(p,i){window.localStorage.setItem("dynamic-value-type-preference--"+p,(i==null?void 0:i.toString())||""),this.emit(p,{})}}let LA=null;const Kx={requestExtension:l=>(LA||(LA=new Fx,LA.setup()),LA.requestExtension(l))},Zu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var Sx=(l=>(l.FinishedSuccess="finished-success",l.FinishedError="finished-error",l.Running="running",l.Paused="paused",l.Stopped="stopped",l.NotStarted="not-started",l))(Sx||{});const PBe={...Kx,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class ip extends z.Events{constructor(i,r,a,c=null,e=PBe){super();R(this,"project");R(this,"entryPoint");R(this,"state","not-started");R(this,"events",new z.Events("fe-exec-inst-events"));R(this,"entities",[]);R(this,"parentExecution",null);R(this,"executing",[]);R(this,"executed",[]);R(this,"skipped",[]);R(this,"scheduled",[]);R(this,"localTestValues");R(this,"resolvedValues");R(this,"persistedExecutionResults");R(this,"lastExecutionResults");R(this,"onAddToSkippedListCallback",null);R(this,"onRemoveFromSkippedListCallback",null);R(this,"onAddEntityCallback",null);R(this,"onRemoveEntityCallback",null);R(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=r,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new mT(N.UUID.uuid(),this.project),this.resolvedValues=new mT(N.UUID.uuid(),this.project),this.persistedExecutionResults=new mT(N.UUID.uuid(),this.project),this.lastExecutionResults=new mT(N.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),hr.includes(i.type)&&yt(i).forEach(r=>this.skip(r))))}async schedule(i,r,a){if(this.hasExecuted(i))return null;if(Ft.includes(i.type))return this.executeBranch(i,a,r);if(Pr.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,r);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,r){const a=[];return[...Nt,...Ft].includes(r.type)?a.push(...r.inputs):Dt.includes(r.type)&&a.push(...r.outputs),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Ft.includes(r.type)&&(f=i.find(m=>{var E;return((E=m.valueOwner.declaration)==null?void 0:E.id)===e.id})),f){const m=(h=f.value)==null?void 0:h.clone(null);return m==null||m.setStandaloneParent(e,null),{...f,valueOwner:e,value:m||null,inheritanceLink:{sources:[f],target:e}}}return pn.includes(e.type)?Fo(e,this.valueResolutionContext):lf(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=Jo(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(E=>{var _,$,L;if(E.id===(f==null?void 0:f.valueOwner.id))return;const b=xt(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(_=f==null?void 0:f.value)==null?void 0:_.value},null),b==null||b.setValueAsTypeList((($=f==null?void 0:f.value)==null?void 0:$.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((L=f==null?void 0:f.value)==null?void 0:L.valueAsTypeSingle)||null);const g={...f,valueOwner:E,value:b};m.push(g)}),[...e,...m]},[]).sort((e,f)=>e.valueOwner.index-f.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,r,a,c={}){var f,h;const e={...Zu,...c};try{let m={value:U.Success,error:null,result:null};if(r.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(Vr).includes(i.declaration.id)){const E=this.parentContext.requestExtension(Wy+i.declaration.id).module.main;E?m=await E(i,r):z.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{m=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let E=null;if(m.error){z.Logger.warn("Raw error executing entity: ",m.error);const b=(f=i.error)==null?void 0:f.getDataType(null),g=xt(b||null,i.error,a);b!=null&&b.asType?g==null||g.setValueAsTypeSingle(m.error):g==null||g.metaSync({value:m.error},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:g}}return{value:m.value,entity:i,error:E,result:{value:m.result||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}return{...m,entity:i}}catch(m){z.Logger.warn("Internal call execution error: ",m);let E=null;if(i.error){const b=(h=i.error)==null?void 0:h.getDataType(null),g=xt(b,i.error,a);b!=null&&b.asType?g==null||g.setValueAsTypeSingle(m):g==null||g.metaSync({value:m},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:g}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,r,a){var c,e;try{let f={value:U.Success,error:null,result:null};r.sort((b,g)=>b.valueOwner.index-g.valueOwner.index),i.declaration.implementation&&(f=await i.declaration.implementation(i,r));let h=null;if(f.error&&i.error){z.Logger.warn("Raw error executing entity: ",f.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,g=xt(b,i.error,a);b!=null&&b.asType?g==null||g.setValueAsTypeSingle(f.error):g==null||g.metaSync({value:f.error},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:g}}const m=i==null?void 0:i.getDataType(null),E=xt(m,i,a);return m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f.result):E==null||E.metaSync({value:f.result},null),{value:f.value,entity:i,error:h,result:{value:E||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(f){z.Logger.warn("Operation execution error: ",f);let h=null;if(i.error){const m=(e=i.error)==null?void 0:e.getDataType(null),E=xt(m,i.error,a);m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f):E==null||E.metaSync({value:f},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:h,result:null}}}async executeSearch(i,r,a){var c;try{let e={value:U.Success,error:null,result:null};const f=await(await this.parentContext.requestExtension(Oe.SEARCH_NODE_IMPLEMENTATION)).module.main(i,r),h=i==null?void 0:i.getDataType(null),m=xt(h,i,a);return m==null||m.metaSync({value:f},null),f.error?{value:U.UnhandledError,entity:i,error:{valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:m},result:null}:{value:e.value,entity:i,error:null,result:{value:m,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(e){if(z.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const f=(c=i.error)==null?void 0:c.getDataType(null),h=xt(f,i.error,a);return h==null||h.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:h},result:null}}}async executeLoop(i,r,a,c={}){var f,h,m,E,b,g;const e={...Zu,...c};try{let _={value:U.Success,error:null,result:null};const $=r.map(ie=>{var ee,ue;return((ee=ie==null?void 0:ie.value)==null?void 0:ee.valueAsType)||((ue=ie==null?void 0:ie.value)==null?void 0:ue.value)});let L={};i.getUniqueInputMaps().forEach(ie=>{const ee=i.body.inputs.find(ce=>se(ce,a)===se(ie,a)),ue=ie==null?void 0:ie.getDataType(null),ae=xt(ue,ee,a);ue!=null&&ue.asType?ae==null||ae.setValueAsTypeList([]):ae==null||ae.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,ae);const de={value:ae,valueOwner:ee,type:Me.ExecutionResult,inheritanceLink:null};L[ee.id]=de});let k={value:U.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case re.loop["counted-loop"].id:{const ie=$[0];let ee=1;for(;ee<=ie&&ee<=50;){const ue=i.body.inputs.map(ae=>{if(ae===i.currentIterationNumberArgumentDeclaration){const de=i.currentIterationNumberArgumentDeclaration.getDataType(null),ce=Wc(de),ne=this.lastExecutionResults.readValue(ae.id);if(ne){ne.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ae,ne);const Ee={value:ne,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return L[ae.id]=Ee,Ee}const le={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:ae.toReference()},Q=Yi(le,a);this.lastExecutionResults.writeValue(ae,Q);const oe={value:Q,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return L[ae.id]=oe,oe}else return L[ae.id]}).filter(ae=>!!ae);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(k.results||[]).forEach(ae=>{var le,Q,oe,Ee;if(ae.valueOwner.type!==d.InputMap||Dt.includes(ae.valueOwner.parent.type))return;const de=i.body.inputs.find(Te=>se(Te,a)===se(ae.valueOwner,a)),ne=[...((Q=(le=L==null?void 0:L[de.id])==null?void 0:le.value)==null?void 0:Q.value)||[],((oe=ae==null?void 0:ae.value)==null?void 0:oe.value)||null];(Ee=L[de.id].value)==null||Ee.metaSync({value:ne},null),this.lastExecutionResults.writeValue(de,L[de.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["manual-flow-loop"].id:{let ie=1;for(;ie<=50;){const ee=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ae=this.lastExecutionResults.readValue(ue.id);if(ae){ae.metaSync({value:ie},null),this.lastExecutionResults.writeValue(ue,ae);const le={value:ae,valueOwner:ue,type:Me.ExecutionResult,inheritanceLink:null};return L[ue.id]=le,le}const de=i.currentIterationNumberArgumentDeclaration.getDataType(null),ce=xt(de,ue,a);return ce==null||ce.metaSync({value:ie},null),this.lastExecutionResults.writeValue(ue,ce),{value:ce,valueOwner:ue,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ue.id]}).filter(ue=>!!ue);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(k.results||[]).forEach(ue=>{var ne,le,Q;if(ue.valueOwner.type!==d.InputMap||Dt.includes(ue.valueOwner.parent.type))return;const ae=i.body.inputs.find(oe=>se(oe,a)===se(ue.valueOwner,a)),ce=[...(ne=L[ae.id].value)==null?void 0:ne.value,((le=ue.value)==null?void 0:le.value)||null];(Q=L[ae.id].value)==null||Q.metaSync({value:ce},null),this.lastExecutionResults.writeValue(ae,L[ae.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ie++}break}case re.loop["list-loop"].id:{const ie=$[0];let ee=1;const ue=ie;for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["object-keys-loop"].id:{const ie=$[0];let ee=1;const ue=ie?Object.keys(ie):[];for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["object-values-loop"].id:{const ie=$[0];let ee=1;const ue=ie?Object.values(ie):[];for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}case re.loop["string-loop"].id:{const ie=$[0];let ee=1;const ue=ie.split("");for(let ae=0;ae<ue.length;ae++){const de=ue[ae],ce=i.body.inputs.map(ne=>{if(ne===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(ne.id);if(le)return le.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,le),{value:le,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Q=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=xt(Q,ne,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(ne===i.currentValueArgumentDeclaration){const le=i.currentValueArgumentDeclaration.getDataType(null),Q=Wc(le),oe=this.lastExecutionResults.readValue(ne.id);if(oe)return oe.metaSync({value:de},null),this.lastExecutionResults.writeValue(ne,oe),{value:oe,valueOwner:ne,type:Me.ExecutionResult,inheritanceLink:null};const Ee={id:N.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:N.UUID.uuid(),createdAt:new Date().toISOString(),author:N.sessionAuthor,deleted:!1,previousVersion:null,value:de,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Q,standaloneParent:ne.toReference()},Te=Yi(Ee,a);return this.lastExecutionResults.writeValue(ne,Te),{value:Te,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return L[ne.id]}).filter(ne=>!!ne);if(k=await this.executeFullFunctionDeclarationLogic(i.body,ce,e),(k.results||[]).forEach(ne=>{var Ee,Te,Ve;if(ne.valueOwner.type!==d.InputMap||Dt.includes(ne.valueOwner.parent.type))return;const le=i.body.inputs.find(Le=>se(Le,a)===se(ne.valueOwner,a)),oe=[...(Ee=L[le.id].value)==null?void 0:Ee.value,((Te=ne.value)==null?void 0:Te.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:oe},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[U.CaughtError,U.Break,U.Return].includes(k.value))break;ee++}break}}if(_={value:[U.CaughtError,U.Return].includes(k.value)?k.value:U.Success,error:((h=(f=k.error)==null?void 0:f.value)==null?void 0:h.value)||null,result:((E=(m=k==null?void 0:k.result)==null?void 0:m.value)==null?void 0:E.value)||null},_.error&&i.error){const ie=(b=i.error)==null?void 0:b.getDataType(null),ee=xt(ie||null,i.error,a);ie!=null&&ie.asType?ee==null||ee.setValueAsTypeSingle(_.error):ee==null||ee.metaSync({value:_.error},null);const ue={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:ee};return{value:_.value,entity:i,error:ue,result:null}}const G=i==null?void 0:i.getDataType(null),H=xt(G,i,a);return G!=null&&G.asType?H==null||H.setValueAsTypeSingle(_.result):H==null||H.metaSync({value:_.result},null),{value:_.value,entity:i,error:null,result:{value:H||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(_){if(z.Logger.warn("Error executing loop: ",_),i.error){const $=(g=i.error)==null?void 0:g.getDataType(null),L=xt($,i.error,a);return $!=null&&$.asType?L==null||L.setValueAsTypeSingle(_):L==null||L.metaSync({value:_},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:L},result:null}}else return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,r,a,c={}){var f,h,m,E,b,g,_,$,L,j,k,G,H,ie,ee,ue,ae,de,ce,ne,le,Q,oe,Ee,Te,Ve;const e={...Zu,...c};try{const Le=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let $e=null;if(Le.error&&i.error){z.Logger.warn("Raw error executing entity: ",Le.error);const rt=(f=i.error)==null?void 0:f.getDataType(null),Rt=xt(rt||null,i.error,a);rt!=null&&rt.asType?(m=(h=Le.error)==null?void 0:h.value)!=null&&m.valueAsTypeSingle?Rt==null||Rt.setValueAsTypeSingle((b=(E=Le.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(_=(g=Le.error)==null?void 0:g.value)!=null&&_.valueAsTypeList&&Array.isArray((L=($=Le.error)==null?void 0:$.value)==null?void 0:L.valueAsTypeList)&&(Rt==null||Rt.setValueAsTypeList((k=(j=Le.error)==null?void 0:j.value)==null?void 0:k.valueAsTypeList)):Rt==null||Rt.metaSync({value:(H=(G=Le.error)==null?void 0:G.value)==null?void 0:H.value},null),$e={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:Rt}}let ke=U.Success;Le.value===U.UnhandledError&&(i.catchesError||i.errorCalls.length?ke=U.CaughtError:ke=U.UnhandledError);const Ke=i==null?void 0:i.getDataType(null),Je=xt(Ke,i,a);return Ke!=null&&Ke.asType?(ee=(ie=Le.result)==null?void 0:ie.value)!=null&&ee.valueAsTypeSingle?Je==null||Je.setValueAsTypeSingle((ae=(ue=Le.result)==null?void 0:ue.value)==null?void 0:ae.valueAsTypeSingle):(ce=(de=Le.result)==null?void 0:de.value)!=null&&ce.valueAsTypeList&&Array.isArray((le=(ne=Le.result)==null?void 0:ne.value)==null?void 0:le.valueAsTypeList)&&(Je==null||Je.setValueAsTypeList((oe=(Q=Le.result)==null?void 0:Q.value)==null?void 0:oe.valueAsTypeList)):Je==null||Je.metaSync({value:((Te=(Ee=Le.result)==null?void 0:Ee.value)==null?void 0:Te.value)||null},null),{value:ke,entity:i,error:$e,result:{value:Je||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(Le){if(!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const $e=(Ve=i.error)==null?void 0:Ve.getDataType(null),ke=xt($e,i.error,a);return $e!=null&&$e.asType?ke==null||ke.setValueAsTypeSingle(Le):ke==null||ke.metaSync({value:Le},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:ke},result:null}}}async executeCondition(i,r){var c,e,f,h;let a=!1;switch(i.declaration.id){case un.BooleanIsTrue:{const m=(e=(c=r[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof m!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=m===!0;break}case un.BooleanIsFalse:{const m=(h=(f=r[0])==null?void 0:f.value)==null?void 0:h.value;if(typeof m!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=m===!1;break}case Ir.And:{a=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).every(E=>E);break}case Ir.Or:{a=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?U.Success:U.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,r,a,c={}){const e={...Zu,...c,onBeforeEntityExecution:(m,E,b)=>{var g;return((g=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:g.call(c,m,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(m,E,b)=>{var g;return((g=c==null?void 0:c.onEntityExecuted)==null?void 0:g.call(c,m,E,{...b,detached:!0}))||Promise.resolve()}},f=new ip(a,[i,...Bg(i)],i,this,this.parentContext);return f.inheritValuesFromContext(this),await f.execute(e,r)}async executeFullFunctionDeclarationLogic(i,r,a={}){const c={...Zu,...a},e=Bg(i);e.forEach(m=>{this.addEntity(m)}),e.reduce((m,E)=>Dt.includes(E.type)?[...m,...E.outputs]:Nt.includes(E.type)&&E.type!==d.Condition?[...m,...E.outputs,...E.inputs]:E.type===d.Condition?[...m,...E.inputs]:m,[]).forEach(m=>{this.lastExecutionResults.removeValue(m.id)});const h=await this.executeBranch(i,c,r);return{...h||{},value:(h==null?void 0:h.value)||U.Success,entity:i,error:(h==null?void 0:h.error)||null,result:(h==null?void 0:h.result)||null}}static async executeEntryPointEntity(i,r){return{value:U.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,r){var f,h,m,E,b,g,_;if((f=i.throws)!=null&&f.readsValue){const $=Fo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Fo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(c,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=e[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Return,entity:i,error:null,result:a}}async executeContinueStatement(i,r){var f,h,m,E,b,g,_;if((f=i.throws)!=null&&f.readsValue){const $=Fo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Fo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(c,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=e[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Continue,entity:i,error:null,result:a}}async executeBreakStatement(i,r){var f,h,m,E,b,g,_;if((f=i.throws)!=null&&f.readsValue){const $=Fo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let a=Fo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(c,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=e[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Break,entity:i,error:null,result:a}}async executeVariable(i,r){var h,m,E,b,g,_;let a=Fo(i,this.valueResolutionContext);const c=yr(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let $={};if(((h=e==null?void 0:e.entity)==null?void 0:h.type)===d.DefinitionEntity&&($={...$,...e.entity.getActiveRawDefaultValue()}),a!=null&&a.value)gr((m=a==null?void 0:a.value)==null?void 0:m.value)&&($={...$,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:$},null);else{const L=xt(e,i,this.project);L==null||L.metaSync({value:$},null),a={valueOwner:c,type:Me.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(c,a.value),c.inputs.forEach(L=>{var j,k;if(((j=L.declaration)==null?void 0:j.type)===d.Property&&L.declaration.static){const G=this.lastExecutionResults.readValue(L.declaration.id),H=se(L,this.project),ie=L.codeName||((k=L.declaration)==null?void 0:k.codeName)||ir(H);if(G)G.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,G);else{const ee=xt(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[ie]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,a==null?void 0:a.value);const f=(b=a==null?void 0:a.value)!=null&&b.value&&gr((g=a.value)==null?void 0:g.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map($=>{var G;const L=$.codeName||((G=$.declaration)==null?void 0:G.codeName)||ir(se($,this.project)),j=f[L],k=xt($.getDataType(null),$,this.project);k==null||k.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Success,entity:i,error:null,result:a}}mergeValues(i,r){const a=[];for(let c=0;c<r.length;c++)i!=null&&i[c]?a.push(i[c]):a.push(r[c]);return a}async executeEntity(i,r=[],a={}){var f,h,m,E,b,g,_,$,L,j,k;const c={...Zu,...a},e={detached:!1};switch(i.type){case d.Condition:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((f=c.onBeforeEntityExecution)==null?void 0:f.call(c,i,G,e)),this.executeCondition(i,G)}case d.InternalCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((h=c.onBeforeEntityExecution)==null?void 0:h.call(c,i,G,e)),this.executeInternalCall(i,G,this.project)}case d.Operation:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,G,e)),ip.executeOperation(i,G,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,r);case d.FunctionCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,G,e)),this.executeFunctionCall(i,G,this.project)}case d.FunctionDeclaration:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,G,e)),ip.executeEntryPointEntity(i,G)}case d.Search:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((g=c.onBeforeEntityExecution)==null?void 0:g.call(c,i,G,e)),this.executeSearch(i,G,this.project)}case d.Loop:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((_=c.onBeforeEntityExecution)==null?void 0:_.call(c,i,G,e)),this.executeLoop(i,G,this.project,c)}case d.ReturnStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await(($=c.onBeforeEntityExecution)==null?void 0:$.call(c,i,G,e)),this.executeReturnStatement(i,G)}case d.ContinueStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((L=c.onBeforeEntityExecution)==null?void 0:L.call(c,i,G,e)),this.executeContinueStatement(i,G)}case d.BreakStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((j=c.onBeforeEntityExecution)==null?void 0:j.call(c,i,G,e)),this.executeBreakStatement(i,G)}case d.GlobalEvent:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((k=c.onBeforeEntityExecution)==null?void 0:k.call(c,i,G,e)),ip.executeEntryPointEntity(i,G)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var a,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((a=i.result)!=null&&a.valueOwner))return;const r=Jo((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?r.forEach(f=>{var h;this.lastExecutionResults.writeValue(f,(h=i.result)==null?void 0:h.value)}):r.forEach(f=>{this.lastExecutionResults.removeValue(f.id)})}async executeBranch(i,r={},a=[]){var m;const c={...Zu,...r},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const h=await this.executeEntity(i,a,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(h),await((m=c.onEntityExecuted)==null?void 0:m.call(c,i,h,e)),h.value===U.Success){const E=(i.successCalls||i.calls||[]).filter(L=>this.hasEntity(L));(i.errorCalls||[]).forEach(L=>{this.skip(L)});let g=[];const _=(await Promise.all(E.map(L=>this.schedule(L,[],c)))).filter(L=>!!L),$=_.filter(L=>!!L).find(L=>L.value===U.CaughtError||L.value===U.Return||L.value===U.Break||L.value===U.Continue);return $||(g=[...g,..._],h)}else if(h.value===U.CaughtError||h.value===U.ConditionNotMet){const E=(i.errorCalls||[]).filter(L=>this.hasEntity(L));(i.successCalls||i.calls||[]).forEach(L=>{this.skip(L)});let g=[];const _=(await Promise.all(E.map(L=>this.schedule(L,[],c)))).filter(L=>!!L),$=_.filter(L=>!!L).find(L=>L.value===U.CaughtError||L.value===U.UnhandledError||L.value===U.Return||L.value===U.Break||L.value===U.Continue);return $||(g=[...g,..._],h)}else{if(h.value===U.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),hr.includes(h.entity.type)&&yt(h.entity).forEach(E=>{this.skip(E)}),h;if(h.value===U.Return)return h;if(h.value===U.Break)return h;if(h.value===U.Continue)return h}return h}async execute(i={},r=[]){const a={...Zu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,a,r);return this.state="finished-success",c}addEntity(i){var r;this.entities.includes(i)||(this.entities.push(i),(r=this.onAddEntityCallback)==null||r.call(this,i,{}))}async addEntityAsync(i,r={}){var a;this.entities.includes(i)||(this.entities.push(i),await((a=this.onAddEntityCallback)==null?void 0:a.call(this,i,r)))}addEntities(i){i.forEach(r=>this.addEntity(r))}async addEntitiesAsync(i,r={}){const a=z.YieldTracker.from(r),c=[];for(const e of i)c.push(this.addEntityAsync(e,r)),await a.tick();await Promise.all(c)}removeEntity(i){var r;if(i!==this.entryPoint){const a=this.entities.indexOf(i);a>-1&&(this.entities.splice(a,1),(r=this.onRemoveEntityCallback)==null||r.call(this,i,{}))}}hasEntity(i){var c,e,f;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((f=(e=i.parent)==null?void 0:e.parent)==null?void 0:f.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const r=ht(i);if(!r)return!1;const a=r.type===d.Loop&&i.parent===r.body?r.body:null;return a?this.entities.includes(a)||this.entities.includes(r):this.entities.includes(r)}removeScheduled(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const r=this.project.get(i);return r?this.hasEntity(r):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAbortExecution(i){this.onAbortExecutionCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}addToScheduledList(i){this.scheduled.includes(i)||this.scheduled.push(i)}removeFromScheduledList(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}removeFromExecutingList(i){var a;const r=this.executing.indexOf(i);r>-1&&(this.executing.splice(r,1),(a=this.onAbortExecutionCallback)==null||a.call(this,i,{}))}removeFromAlreadyExecutedList(i){const r=this.executed.indexOf(i);r>-1&&this.executed.splice(r,1)}removeFromSkippedList(i){var a;const r=this.skipped.indexOf(i);r>-1&&(this.skipped.splice(r,1),(a=this.onRemoveFromSkippedListCallback)==null||a.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var r;this.skipped.includes(i)||(this.skipped.push(i),(r=this.onAddToSkippedListCallback)==null||r.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,r){this.parentContext.setValueTypePreference(i,r),this.emit(i,{})}}function hRi(l){var p,i;if(l.isList)return"list";if(((p=l.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=l.entity)==null?void 0:i.name){case ye.Number:return"number";case ye.String:return"text";case ye.Boolean:return"boolean";case ye.UUID:return"uuid";case ye.Date:return"date-time";default:return"definition-entity"}}const Wa={[d.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[d.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[d.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[d.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[d.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[d.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[d.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[d.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[d.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[d.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[d.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[d.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[d.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[d.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[d.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[d.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[d.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[d.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[d.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[d.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[d.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[d.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function qx(l){const p=Z1(l);if(!p){const r=vh(l);if(r.includes(Ie.HTTP_ENDPOINT))return"HTTP endpoint";if(r.includes(Ie.PERSISTED_ENTITY))return"Persisted entity";if(r.includes(Ie.CRON_JOB))return"Scheduled execution";if(r.includes(Ie.RELATIONAL_DATABASE))return"Relational database"}if(p){let r="Extension of "+se(p,p.project)+" entity",a=Yo(r);const c=vh(l);return c.includes(Ie.HTTP_ENDPOINT)?"HTTP endpoint"+(a?", "+a:""):c.includes(Ie.PERSISTED_ENTITY)?"Persisted entity"+(a?", "+a:""):c.includes(Ie.CRON_JOB)?"Scheduled execution"+(a?", "+a:""):c.includes(Ie.RELATIONAL_DATABASE)?"Relational database"+(a?", "+a:""):r}let i="";return l.abstract&&(i="Template "),l.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function NBe(l){return l.parent.type===d.DefinitionEntity||l.parent.type===d.InstalledProject?"Internal action of "+se(l.parent,l.project):l.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function Zx(l){return cL(l)?NBe(l):"Custom trigger"}function mRi(l){var p;switch(l.type){case d.DefinitionEntity:return qx(l);case d.FunctionDeclaration:return Zx(l)}return(p=Wa[l.type])==null?void 0:p.singular}function TRi(l){var p;switch(l.type){case d.DefinitionEntity:return qx(l);case d.FunctionDeclaration:return Zx(l)}return(p=Wa[l.type])==null?void 0:p.singular}const Hx=4e4,Wx=280,vRi=300,zx=65,zy=32,Xy=39,xBe=26,$Be=49,Tg=44,ERi=35,ZA=52,Yx=10,Ko=Yx*2,vg=38,HA=90,Eg=270,LBe=Hx/2+120,BBe=Hx/2+180;function Jx(l){let i=zy+Tg+vg+Yx;const r=[...l.inputs];return r.length&&(i+=Ko,r.forEach(()=>{i+=xBe})),{height:i,width:280}}function MBe(l){let i=zx;const r=[];if([d.DefinitionEntity].includes(l.type)){const h=[...l.suggestedProperties||[],...l.properties||[]];h.length&&(i+=Ko,h.forEach(m=>{i+=m.static?$Be:Xy}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(l.type)){const h=[...(l==null?void 0:l.suggestedMethods)||[],...l.methods||[],...l.functions||[],...l.body?[l.body]:[]];h.length&&(i+=Ko,h.forEach(m=>{const E=Jx(m);i+=E.height}))}Nt.includes(l.type)?(_t.includes(l.type)?r.push(...(l.usedInputs||[]).flatMap(h=>[h])||[]):r.push(...(l.inputs||[]).flatMap(h=>[h])||[]),l.error&&(i+=ZA)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)?(r.push(...l.outputs||[]),l.throws&&(i+=ZA)):l.type===d.Condition&&(r.push(l.inputs[0]),l.inputs[1]&&r.push(l.inputs[1]));const a=r.length;a&&(i+=a*Xy,i+=Ko);const c=[];if(l.type===d.FunctionDeclaration||l.type===d.GlobalEvent?c.push(...l.inputs||[]):Nt.includes(l.type)&&(_t.includes(l.type)?c.push(...l.usedOutputs||[]):c.push(...l.outputs||[])),_t.includes(l.type)){l.readsValue&&(i+=Ko,i+=Tg),l.writesValues.length&&(i+=Ko,i+=Tg),l.internalCalls.length&&l.usedInternalCalls.forEach(()=>i+=ZA+Ko);const h=l.getDataType(null);(!h||h.inferred)&&(i+=vg)}const e=c.length;return e&&(i+=e*Xy,i+=Ko),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)&&(i+=vg),{height:i,width:280}}function GBe(l){let p=0;if(l.parent.type!==d.DefinitionEntity)return{offset:p};const i=l.parent,r=i.methods.findIndex(c=>c.id===l.id);return i.methods.slice(0,r).forEach(c=>{const e=Jx(c);p+=e.height}),(i.properties.length||i.suggestedProperties.length)&&(p+=Ko,i.suggestedProperties.forEach(()=>{p+=Xy}),i.properties.forEach(()=>{p+=Xy})),{offset:p}}function lE(l){return`${l.split("-").map((r,a)=>a===0?r.charAt(0).toUpperCase()+r.slice(1):r.toLowerCase()).join(" ")}.`}function bRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case be.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case be.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case be.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case be.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case we.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case we.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case be.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case be.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case we.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case be.NoProperties:return"This entity has no properties, so it doesn't do anything";case be.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case be.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case be.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case be.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case be.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case be.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case be.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case be.PropertyImplementsNonAbstact:return"This property implements a non-template property";case be.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case be.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case be.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case be.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case be.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case we.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case we.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case we.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case we.UnreachableEntity:return"This entity is unreachable";case be.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case be.AbstractEntityImplements:return"This template entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case be.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case be.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case be.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case be.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case be.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case be.MissingRequiredValue:return"This action is missing a required value";case be.NoPrimaryKeyProperty:return"This entity has no primary key property";case be.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case be.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case be.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case be.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case be.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case be.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case be.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case we.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case we.EmptyName:return"This entity has no name";case we.InvalidObjectStructure:return"This entity has an invalid structure";case we.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case we.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case we.MissingCaller:return"This action is missing a caller";case we.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case we.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case we.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case we.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case we.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case id.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case id.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case Ya.UUIDMustBeString:return`UUID must be a string, eg: "${np()}"`;case Ya.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${np()}"`;case Ya.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${np()}"`;case ya.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ya.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ya.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return lE(l.code)}}function ARi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case be.IncorrectEntityImplementation:return"Incorrect implementation";case be.IncorrectMethodImplementation:return"Incorrect action implementation";case be.IncorrectPropertyImplementation:return"Incorrect property implementation";case be.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case we.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case we.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case be.MissingMethodImplementation:return"Missing action";case be.MissingPropertyImplementation:return"Missing property";case we.NameNotUniqueInScope:return"Duplicate name";case be.NoProperties:return"No properties";case be.NonStaticPropertyInStaticEntity:return"Non-static property";case be.StaticEntityWithNonStaticProperties:return"Non-static properties";case be.ReadingFromIncompatibleType:return"Read from different type";case be.WritingToIncompatibleType:return"Write to different type";case be.ScopeWithoutLogic:return"No logic";case be.NonStaticPropertyImplementsStatic:return"Invalid static property";case be.PropertyImplementsIncompatibleType:return"Incompatible data type";case be.PropertyImplementsNonAbstact:return"Non-template property";case be.StaticPropertyImplementsNonStatic:return"Non-static property";case be.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case be.VariableHasInputsAndInternalCall:return"Bad internal call";case be.VariableHasOutputsAndInternalCall:return"Bad internal call";case be.VariableIsCalledAndHasInternalCall:return"Bad internal call";case we.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case we.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case we.InternalCallParentMissingDataType:return"Parent has no data type";case we.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case we.UnreachableEntity:return"Unreachable entity";case be.DisconnectedCallableEntity:return"Disconnected entity";case be.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case be.InvalidPropertiesCombination:return"Invalid properties combination";case be.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case be.ExtendsIncompatibleEntities:return"Extends incompatible entities";case be.ImplementingNonAbstractEntity:return"Implementing non-template entity";case be.ImplementsIncompatibleEntities:return"Implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case be.MissingRequiredValue:return"Missing required value";case be.NoPrimaryKeyProperty:return"No primary key property";case be.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case be.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case be.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case be.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case be.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case be.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case be.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case we.EmptyName:return"Empty name";case we.InvalidObjectStructure:return"Invalid object structure";case we.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case we.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case we.MissingCaller:return"Missing caller";case we.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case we.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case we.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case we.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case we.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case id.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case id.StatusCodeMustBeNumber:return"HTTP status code must be a number";case Ya.UUIDMustBeString:return"UUID must be a string";case Ya.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case Ya.UUIDMustBeValidFormat:return"UUID must be in a valid format";case ya.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case ya.StringValueMustNotHaveDashes:return"This value must not contain dashes";case ya.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return lE(l.code)}}function gRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${se(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${se(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements template`;case be.IncorrectMethodImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template`;case be.IncorrectPropertyImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template`;case be.AbstractMethodInNonAbstractEntity:return`${se(l.entity,l.entity.project)} can't be a template`;case be.AbstractPropertyInNonAbstractEntity:return`${se(l.entity,l.entity.project)} can't be a template`;case we.MethodOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites action`;case we.PropertyOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites property`;case be.MissingMethodImplementation:return`${se(l.entity,l.entity.project)} is missing action`;case be.MissingPropertyImplementation:return`${se(l.entity,l.entity.project)} is missing property`;case we.NameNotUniqueInScope:return`${se(l.entity,l.entity.project)} name is not unique`;case be.NoProperties:return`${se(l.entity,l.entity.project)} has no properties`;case be.NonStaticPropertyInStaticEntity:return`${se(l.entity,l.entity.project)} has non-static property`;case be.StaticEntityWithNonStaticProperties:return`${se(l.entity,l.entity.project)} has non-static properties`;case be.ReadingFromIncompatibleType:return`${se(l.entity,l.entity.project)} reads from different type`;case be.WritingToIncompatibleType:return`${se(l.entity,l.entity.project)} writes to different type`;case be.ScopeWithoutLogic:return`${se(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${se(l.entity,l.entity.project)} has invalid static property`;case be.PropertyImplementsIncompatibleType:return`${se(l.entity,l.entity.project)} has incompatible data type`;case be.PropertyImplementsNonAbstact:return`${se(l.entity,l.entity.project)} has non-template property`;case be.StaticPropertyImplementsNonStatic:return`${se(l.entity,l.entity.project)} has non-static property`;case be.VariableCallsOthersAndHasInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasInputsAndInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasOutputsAndInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case be.VariableIsCalledAndHasInternalCall:return`${se(l.entity,l.entity.project)} has bad internal call`;case we.InternalCallDeclarationIsInvalidType:return`${se(l.entity,l.entity.project)} has declaration that is not an action`;case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has declaration that is not found in parent`;case we.InternalCallParentDeclarationEntityInvalidType:return`${se(l.entity,l.entity.project)} has invalid parent declaration type`;case we.InternalCallParentMissingDataType:return`${se(l.entity,l.entity.project)}'s parent has no data type`;case we.InternalCallDeclarationNotInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has declaration that is not in parent`;case we.UnreachableEntity:return`${se(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${se(l.entity,l.entity.project)} is not executed by any entity`;case be.AbstractEntityImplements:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${se(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${se(l.entity,l.entity.project)} has invalid properties combination`;case be.ExtendingNonInteractiveEntity:return`${se(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${se(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${se(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${se(l.entity,l.entity.project)} is missing termination on some branches`;case be.LastCalledEntityMustBeReturnEntity:return`${se(l.entity,l.entity.project)}'s last called entity must be a termination node`;case be.MissingRequiredValue:return`${se(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${se(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${se(l.entity,l.entity.project)} extends a template entity`;case be.NonStaticExtendingStaticEntity:return`${se(l.entity,l.entity.project)} extends a static entity`;case be.NonStaticImplementingStaticEntity:return`${se(l.entity,l.entity.project)} implements a static entity`;case be.StaticExtendingNonStaticEntity:return`${se(l.entity,l.entity.project)} extends a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${se(l.entity,l.entity.project)} implements a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${se(l.entity,l.entity.project)} reads a value and has internal call`;case be.VariableWritesValuesAndInternalCall:return`${se(l.entity,l.entity.project)} writes values and has internal call`;case we.EmptyName:return`${Wa[l.entity.type]} has no name`;case we.InvalidObjectStructure:return`${se(l.entity,l.entity.project)} has invalid structure`;case we.LoopBodyFunctionOverwrite:return`${se(l.entity,l.entity.project)}'s loop body action overwrites an action`;case we.MethodOverwritesBaseMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites base action`;case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MissingCaller:return`${se(l.entity,l.entity.project)} is missing a caller`;case we.NameAsResolvedCodeNameNotUniqueInScope:return`${se(l.entity,l.entity.project)} has a name not unique in the scope`;case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${se(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case we.NameMustStartWithLetterOrUnderscore:return`${se(l.entity,l.entity.project)} name must start with letter or underscore`;case we.NoOverlapWithImplementedSignature:return`${se(l.entity,l.entity.project)} has no overlap with implemented signature`;case we.PropertyOverwritesBasePropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites base property`;case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.ReaderWriterIncompatibleDataType:return`${se(l.entity,l.entity.project)} has reader/writer with incompatible data type`;case id.StatusCodeMustBeBetween100And599:return`${se(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case id.StatusCodeMustBeNumber:return`${se(l.entity,l.entity.project)} HTTP status code must be a number`;case Ya.UUIDMustBeString:return`${se(l.entity,l.entity.project)} UUID must be a string`;case Ya.UUIDMustNotContainSpaces:return`${se(l.entity,l.entity.project)} UUID must not contain spaces`;case Ya.UUIDMustBeValidFormat:return`${se(l.entity,l.entity.project)} UUID must be in a valid format`;case ya.MustBeUniqueAmongSameEntities:return`${se(l.entity,l.entity.project)} value must be unique among the same kind`;case ya.StringValueMustNotHaveDashes:return`${se(l.entity,l.entity.project)} value must not contain dashes`;case ya.StringValueMustNotHaveSpaces:return`${se(l.entity,l.entity.project)} value must not contain spaces`;default:return`${se(l.entity,l.entity.project)} Error: ${lE(l.code)}`}}function IRi(l){var p,i,r,a;switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${se(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${se(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template entity`;case be.IncorrectMethodImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template action it's based on`;case be.IncorrectPropertyImplementation:return`${se(l.entity,l.entity.project)} incorrectly implements the template property it's based on`;case be.AbstractMethodInNonAbstractEntity:return`${se(l.entity,l.entity.project)} is a template action in a non-template entity`;case be.AbstractPropertyInNonAbstractEntity:return`${se(l.entity,l.entity.project)} is a template property in a non-template entity`;case we.MethodOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites an action in the template entity`;case we.PropertyOverwritesOtherSiblingWithSameName:return`${se(l.entity,l.entity.project)} overwrites a property in the template entity`;case be.MissingMethodImplementation:return`${se(l.entity,l.entity.project)} is missing an action implementation from the template entity`;case be.MissingPropertyImplementation:return`${se(l.entity,l.entity.project)} is missing a property implementation from the template entity`;case we.NameNotUniqueInScope:return`${se(l.entity,l.entity.project)} has a duplicate name in the same scope`;case be.NoProperties:return`${se(l.entity,l.entity.project)} has no properties, so it doesn't do anything`;case be.NonStaticPropertyInStaticEntity:return`${se(l.entity,l.entity.project)} has a non-static property in a static entity`;case be.StaticEntityWithNonStaticProperties:return`${se(l.entity,l.entity.project)} has non-static properties in a static entity`;case be.ReadingFromIncompatibleType:return`${se(l.entity,l.entity.project)} reads data from a value of a different data type`;case be.WritingToIncompatibleType:return`${se(l.entity,l.entity.project)} writes data to a value of a different data type`;case be.ScopeWithoutLogic:return`${se(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${se(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.PropertyImplementsIncompatibleType:return`${se(l.entity,l.entity.project)} implements a property of a different data type`;case be.PropertyImplementsNonAbstact:return`${se(l.entity,l.entity.project)} implements a non-template property`;case be.StaticPropertyImplementsNonStatic:return`${se(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.VariableCallsOthersAndHasInternalCall:return`${se(l.entity,l.entity.project)} calls other entities while being used to execute internal logic`;case be.VariableHasInputsAndInternalCall:return`${se(l.entity,l.entity.project)} has inputs while being used to execute internal logic`;case be.VariableHasOutputsAndInternalCall:return`${se(l.entity,l.entity.project)} has outputs while being used to execute internal logic`;case be.VariableIsCalledAndHasInternalCall:return`${se(l.entity,l.entity.project)} is called while being used to execute internal logic`;case we.InternalCallDeclarationIsInvalidType:return`${se(l.entity,l.entity.project)} has a declaration that is not an action`;case we.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has a declaration that is not found in ${(p=l.entity.parent.getDataType(null))!=null&&p.entity?se((i=l.entity.parent.getDataType(null))==null?void 0:i.entity,l.entity.project):"the variable's data-type entity"}`;case we.InternalCallParentDeclarationEntityInvalidType:return`${se(l.entity,l.entity.project)} is part of a variable whos data-type entity can't have actions`;case we.InternalCallParentMissingDataType:return`${se(l.entity,l.entity.project)} is part of a variable with no data-type entity`;case we.InternalCallDeclarationNotInParentDatatypeEntity:return`${se(l.entity,l.entity.project)} has a declaration doesn't belong to ${(r=l.entity.parent.getDataType(null))!=null&&r.entity?se((a=l.entity.parent.getDataType(null))==null?void 0:a.entity,l.entity.project):"the variable's data-type entity"}`;case we.UnreachableEntity:return`${se(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${se(l.entity,l.entity.project)} is disconnected and won't be executed by anything after publishing`;case be.AbstractEntityImplements:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${se(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${se(l.entity,l.entity.project)} has an invalid combination of properties`;case be.ExtendingNonInteractiveEntity:return`${se(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${se(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${se(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${se(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${se(l.entity,l.entity.project)} has branches that don't terminate`;case be.LastCalledEntityMustBeReturnEntity:return`${se(l.entity,l.entity.project)} must end with a termination node`;case be.MissingRequiredValue:return`${se(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${se(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${se(l.entity,l.entity.project)} is a non-template entity extending a template entity`;case be.NonStaticExtendingStaticEntity:return`${se(l.entity,l.entity.project)} is a non-static entity extending a static entity`;case be.NonStaticImplementingStaticEntity:return`${se(l.entity,l.entity.project)} is a non-static entity implementing a static entity`;case be.StaticExtendingNonStaticEntity:return`${se(l.entity,l.entity.project)} is a static entity extending a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${se(l.entity,l.entity.project)} is a static entity implementing a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${se(l.entity,l.entity.project)} reads a value and has an internal call`;case be.VariableWritesValuesAndInternalCall:return`${se(l.entity,l.entity.project)} writes values and has an internal call`;case we.EmptyName:return`${Wa[l.entity.type]} has no name`;case we.InvalidObjectStructure:return`${se(l.entity,l.entity.project)} has an invalid structure`;case we.LoopBodyFunctionOverwrite:return`${se(l.entity,l.entity.project)}'s loop body action overwrites`;case we.MethodOverwritesBaseMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites a base action with same implementation`;case we.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another action with same implementation`;case we.MissingCaller:return`${se(l.entity,l.entity.project)} is missing a caller`;case we.NameAsResolvedCodeNameNotUniqueInScope:return`${se(l.entity,l.entity.project)} has a name that is not unique in the scope`;case we.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${se(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case we.NameMustStartWithLetterOrUnderscore:return`${se(l.entity,l.entity.project)} name must start with letter or underscore`;case we.NoOverlapWithImplementedSignature:return`${se(l.entity,l.entity.project)} has no overlap with implemented signature`;case we.PropertyOverwritesBasePropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites a base property with same implementation`;case we.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${se(l.entity,l.entity.project)} overwrites another property with same implementation`;case we.ReaderWriterIncompatibleDataType:return`${se(l.entity,l.entity.project)} has a reader/writer with incompatible data type`;case id.StatusCodeMustBeBetween100And599:return`${se(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case id.StatusCodeMustBeNumber:return`${se(l.entity,l.entity.project)} HTTP status code must be a number, between 100 and 599`;case Ya.UUIDMustBeString:return`${se(l.entity,l.entity.project)} UUID must be a string, eg: "${np()}"`;case Ya.UUIDMustNotContainSpaces:return`${se(l.entity,l.entity.project)} UUID must not contain spaces, eg: "${np()}"`;case Ya.UUIDMustBeValidFormat:return`${se(l.entity,l.entity.project)} UUID must be in a valid format. Eg: "${np()}"`;case ya.MustBeUniqueAmongSameEntities:return`${se(l.entity,l.entity.project)} value must be unique among the same kind`;case ya.StringValueMustNotHaveDashes:return`${se(l.entity,l.entity.project)} value must not contain dashes`;case ya.StringValueMustNotHaveSpaces:return`${se(l.entity,l.entity.project)} value must not contain spaces`;default:return`${se(l.entity,l.entity.project)} Error: ${lE(l.code)}`}}function Xx(l){const p=(l||"").startsWith("error-caller-only--");switch(p?l.replace("error-caller-only--",""):l){case ai.CallIsInHigherScope:return"In a higher scope";case ai.CallIsInLowerScope:return"In a lower scope";case ai.CallerIsInHigherScope:return"Caller is in a higher scope";case ai.CallerIsInLowerScope:return"Caller is in a lower scope";case ai.CannotBeCalledByChildren:return"Cannot be called by children";case ai.CannotCallAncestor:return"Cannot call ancestor";case ai.CannotConnectToItself:return"Cannot connect to itself";case ai.CannotReadMoreThanOneValue:return"Cannot read more than one value";case ai.CannotReadValueFromChildren:return"Cannot read value from entities executed after itself";case ai.CannotWriteValueToAncestor:return"Cannot write value to ancestor";case zT.Suggestion:return"Suggestion";case ai.ContinueOrBreakStatementCalledFromOutsideLoop:return"Cannot be called from outside loop";case ai.DataTypesNotCompatible:return"Data types not compatible";case ai.ElementInLoopBodyCallingOutsideLoop:return"Cannot call outside loop";case ai.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees:return"Error cannot be connected to success branch";case ai.ExecutionsAlreadyConnected:return"Executions already connected";case ai.IsNotValueReadingEntity:return"Is not a value reading entity";case ai.IsNotValueWrittingEntity:return"Is not a value writting entity";case ai.NotInScope:return"Not in a compatible scope";case ai.OtherIncompatibleScopeReason:return"Incompatible scope";case ai.SiblingInternalCallAlreadyUsedInParentVariable:return"Internal call already used in parent variable";case ai.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees:return"Success cannot be connected to error branch";case ai.ValuesAlreadyConnected:return"Values already connected";case ai.CannotInteractWithInputInVariableWithInternalCalls:return"Cannot interact with input in variable with internal calls";case ai.CannotInteractWithOutputInVariableWithInternalCalls:return"Cannot interact with output in variable with internal calls";case zT.CanvasGloballyDisabled:return"Canvas is globally disabled";case ai.PropertyIsConstantItsValueCantBeReset:return"Property is constant, its value can't be reset";case ai.CannotWriteValueOfGlobalVariableDeclaration:return"Cannot write value of global variable declaration";case ai.CannotReSetValueOfConstantVariable:return"Cannot re-set value of constant variable";case ai.CannotConnectToOwnNode:return"It is part of the same node";case ai.CalledByErrorMustBePassThroughCallable:return"Called by error must be pass-through callable";case ai.CannotChangeScopeBecauseItCallsOtherEntities:return"Cannot change scope because it calls other entities in its current scope";case ai.CannotChangeScopeBecauseItIsCalledByOtherEntities:return"Cannot change scope because it is called by other entities in its current scope";case ai.VariableDeclarationCannotBeMovedToLowerScopeBecauseInstancesUsage:return"Variable declaration cannot be moved to lower scope because its instances are used in the current or different incompatible lower scope";case ai.CalledBySourceMustBeCallerEntity:return"Not a caller type";case ai.CalledByErrorCannotBeConnectedToEntitiesCalledByOwnSuccessBranch:return"Already connected to the success branch from a common origin caller";case ai.CalledBySuccessCannotBeConnectedToEntitiesCalledByOwnErrorBranch:return"Already connected to the error branch from a common origin caller";case ai.RedundantCall:return"Redundant call. Already connected further down the execution path";case ai.CannotBeCalledBeforeDeclaration:return"Cannot be called before declaration";case ai.CannotBeCalledInParallelBranchToDeclaration:return"Cannot be called in parallel branch to declaration";case ai.CannotBeHigherScopeThanDeclaration:return"Cannot be in a higher scope than declaration";case ai.CannotCallGlobalVariableDeclaration:return"Cannot call global variable declaration";case ai.EntityAlreadyCalledBySuccessCannotBeConnectedToUnrelatedErrorBranch:return p?"Cannot connect error: Already connected to a success branch from a common origin caller":"Already connected to a success branch from a common origin caller";default:return Lf(l||"")}}function RRi(l,p){const i=[...l,...p],r=Array.from(new Set(i));return{hasChanged:r.length!==l.length,reasons:r}}function DRi(l,p){const i=l.filter(a=>!p.includes(a));return{hasChanged:i.length!==l.length,reasons:i}}function wRi(l,p){return l.find(i=>i.entity.id===p)||null}function jU(l){return l.filter((p,i)=>l.indexOf(p)===i)}class En{constructor(p,i,r=null,a){R(this,"ids",[]);R(this,"entity");R(this,"entityCardHeight");R(this,"entityCardWidth");R(this,"index");R(this,"childEntities",[]);R(this,"children",[]);R(this,"parents",[]);R(this,"calculationEntryPoint");R(this,"_onlyEntities",null);R(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=r||this,this._changeSet=a||null,this===this.calculationEntryPoint&&!a)throw new Error("Change-set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,r){const a=LBe-Eg-Wx,c=BBe-HA-zx;p.type===d.Project?(p.x=a,p.y=c):p.metaSync({x:p.x||a,y:p.y||c},i);const e=new En(p,0,null,i);e.calculationEntryPoint=e,e._onlyEntities=r||[],e.ids=["0"];const f=[];e.next(m=>{f.push(...m)}),En.recursivelyAssembleChildrenAreas(f),e.resolveChildrenOverlaps();const h=e.flattenChildEntities();return e._onlyEntities?h.filter(m=>{var E;return(E=e._onlyEntities)==null?void 0:E.includes(m)}):h}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(r=>{r.next(a=>{i.push(...a)})}),i.length>0&&En.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities||[]}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(p){this.calculationEntryPoint._changeSet=p}findAreaInChildrenFromEntity(p){if(this.entity===p)return this;const i=this.children.find(a=>a.entity===p);return i||this.children.reduce((a,c)=>a||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,r=i.find(c=>c.entity===p);return r||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=En.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(r=>`${r}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=kl(this.entity,!0);if(this.entity.type===d.Project){const i=[],r=[],a=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){r.push(e);return}else if(Ft.includes(e.type)){a.push(e);return}i.push(e)});const c=i.sort((e,f)=>{const h=!!Ng(e,f).length,m=kl(e),E=kl(f);return h?0:m.length&&!E.length?-1:!m.length&&E.length?1:0}).filter(e=>!Ac(e).length);this.childEntities=[...r,...a,...c]}else{const i=[],r=[],a=[],c=[],e=[];hr.includes(this.entity.type)&&K1(this.entity).forEach(m=>{if(_t.includes(m.type)){a.push(m);return}const E=ht(m);i.push(E)}),vr.includes(this.entity.type)&&r.push(...this.entity.detachedChildren);const f=p.filter(h=>{const m=i.includes(h);return m||a.includes(h)||r.includes(h)?!1:_t.includes(h.type)?(a.push(h),!1):Pr.includes(h.type)&&!m?(c.push(h),!1):h.type===d.DefinitionEntity?(e.push(h),!1):!0});i.sort((h,m)=>Ml(h,m)?-1:0),c.sort((h,m)=>Ml(h,m)?-1:0),a.sort((h,m)=>W_(h,m)?1:W_(m,h)?-1:0),this.childEntities=[...e,...i,...c,...f,...a,...r]}}calculateCardSize(){const p=MBe(this.entity);this.entityCardWidth=p.width,this.entityCardHeight=p.height}static getBoundriesOfTwoAreas(p,i){return{top:Math.min(p.top,i.top),left:Math.min(p.left,i.left),bottom:Math.max(p.bottom,i.bottom),right:Math.max(p.right,i.right)}}static getBoundriedOfCombinedAreas(p,i){const r=p.filter(c=>!i.includes(c));return r.reduce((c,e)=>i.includes(e)?c:En.getBoundriesOfTwoAreas(c,e.fullBranchArea),r[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,f)=>En.getBoundriesOfTwoAreas(e,f),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],r=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,f)=>En.getBoundriesOfTwoAreas(e,f),r)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>En.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(a=>a.fullBranchArea).reduce((a,c)=>En.getBoundriesOfTwoAreas(a,c),p)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const p=this.ownEntityArea;return{top:p.top,left:p.left,bottom:p.bottom+HA,right:p.right+Eg}}static filterOutRepeatedAreas(p){return p.filter((i,r)=>p.indexOf(i)===r)}getEarliestId(p,i){const r=p.split("-"),a=i.split("-");return r.length<a.length?p:r.length>a.length?i:r.reduce((e,f,h)=>f<a[h]?p:i,p)}getEarliestLevel(){return this.ids.reduce((r,a)=>this.getEarliestId(r,a),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const r=this.parents.reduce((a,c)=>c.getEarliestLevel()>a.getEarliestLevel()?c:a,this.parents[0]).countColumns();return p+=r,p}getLatestId(p,i){if(p===i)return p;const r=p.split("-"),a=i.split("-");return r.length<a.length?i:r.length>a.length?p:r.reduce((e,f,h)=>f>a[h]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((r,a)=>this.getLatestId(r,a),this.ids[0]).split("-").length}smoothPosition(){const p=this.flattenSiblings();if(!p.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(r=>{r!==this.calculationEntryPoint&&r.shiftDownAlone(i)})}else if([...Ft].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(r=>!this.parents.includes(r));i.length?i.every(a=>{const c=this.countColumns(),e=a.countColumns();return c>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(p,i){if(p.includes(this))return p;this.move(this.entity,{y:this.entity.y+i});let r=[...p,this];return this.children.forEach(a=>{if(En.getEarliestParentInChain(a)!==this)return;const e=wRi(r,a.entity.id);r=En.filterOutRepeatedAreas([...r]),e||(r=r.filter(h=>h!==a));const f=a.shiftDownUntilAny(r,i);r.push(...f)}),r}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(r=>{const a=En.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);En.getEarliestParentInChain(r)===this&&r.shiftRightUntilAny(a,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const a=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(a,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+zy,h={top:f,left:e.left,bottom:f,right:e.right};return En.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-zy;this.shiftDownAlone(r)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+zy,h={top:f,left:e.left,bottom:f,right:e.right};return En.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-zy;return this.shiftDownAlone(r),r}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(r=>{const a=r.adjustVerticallyToAvoidOverlaps();i.push(...a)}),p.forEach(r=>{r.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((r,a)=>{if(!r.ids.length)return-1;if(!a.ids.length)return 1;const c=r.ids.sort((f,h)=>f.length<h.length?-1:0),e=a.ids.sort((f,h)=>f.length<h.length?-1:0);return c[0].length-e[0].length})[0]),i}flattenEarlierSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.slice(0,a.children.indexOf(this)).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.filter(f=>f!==this).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r,...r.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((r,a)=>p.has(a.entity.id)?r:(p.add(a.entity.id),[...r,a,...a.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(a=>a.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,r)=>{const a=r.children.indexOf(this),c=r.children.slice(a+1);return[...i,...c]},[]);return jU(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((r,a)=>[...r,...a.getLowerAreas()],[]);return jU([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const r=En.getEarliestParentInChain(this).children[this.index-1];if(!r)return p;const a=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...a,...c,r],m=C(e.flatMap(_=>Ng(this.entity,_.entity))).filter(_=>_.id!==this.entity.id).map(_=>this.findAreaFromEntity(_)).filter(_=>!!_),E=this.getFullAreaUntilAny(m),b=r.getFullAreaUntilAny(m),g=e.reduce((_,$)=>$===this||$.fullBranchArea.left!==E.left?_:Math.max(_,$.fullBranchArea.bottom),b.bottom);if(E.top<g){const _=g-E.top+HA;return this.shiftDownUntilAny(p,_)}return p}move(p,i){if(this.onlyEntities.includes(p)){if(!this.changeSet)throw new Error("Change set is not defined for this area, cannot move entity");p.metaSync(i,this.changeSet)}}addChild(p){const i=this.childEntities[p];let r=null;i.x&&i.y?r=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),r||(r=new En(i,p,this.calculationEntryPoint));const a=this.ownEntityPlusBufferArea;this.children.includes(r)||(this.children.push(r),r.addParent(this));const c=r.fullBranchArea;if(c.left<a.right){const e=a.right-c.left;r.shiftRight(e)}return r}flattenChildEntities(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r.entity,...r.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((r,a)=>{const c=this.addChild(a);c&&i.push(c)}),p(i)}}async function CRi(l,p,i={}){var f;const r=z.YieldTracker.from(i),a=[],c=[];for(const h of l.instancesList){if(!cf.includes(h.type)||((f=ht(h))==null?void 0:f.id)!==h.id)continue;let m=Zt(h,l);if(!m){console.log("No top scope owner for instance: ",h," in project: ",l);continue}if(!(Ft.includes(m.type)&&m.collapsed&&m.id!==h.id)){for(;m.parent&&m.parent!==l;)m=m.parent,Ft.includes(m.type)&&m.collapsed&&(m.id,h.id);i.forceAll?(h.x=0,h.y=0,c.push(h)):!h.x||!h.y?c.push(h):a.push(h),await r.tick()}}console.log("Layout generation - calculating positions for entities without coordinates... FORCE: ",i.forceAll||!1),console.log(`
|
|
55
55
|
- ${c.map((h,m)=>`${m+1}. ${h.x}, ${h.y} | ${h.type} (${h.id}) ${se(h,h.project)}`).join(`
|
|
56
56
|
- `)}`);const e=await kd([...a,...En.autoGenerateLayout(l,p,c)]);return console.log(`After move:
|
|
57
57
|
- ${c.map((h,m)=>`${m+1}. ${h.x}, ${h.y} | ${h.type} (${h.id}) ${se(h,h.project)}`).join(`
|
|
@@ -481,7 +481,7 @@ parent: `+((de=(ae=G.parent)==null?void 0:ae.parent)==null?void 0:de.id)+" - "+(
|
|
|
481
481
|
parent: "`+((de=(ae=G.parent)==null?void 0:ae.parent)==null?void 0:de.name)+'" ('+((ne=(ce=G.parent)==null?void 0:ce.parent)==null?void 0:ne.id)+")":"(not found) "+G.type+" "+G.id})),z.Logger.log("-----------------"),z.Logger.log("Old properties: ",Vn(i).map(G=>G.name+" ("+G.id+")")),z.Logger.log("New properties: ",Vn(p).map(G=>G.name+" ("+G.id+")"));const b=f.methods.find(G=>{var H;return((H=G.implements)==null?void 0:H.id)===re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),g=f.methods.find(G=>{var H;return((H=G.implements)==null?void 0:H.id)===re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});z.Logger.log(`
|
|
482
482
|
Up inputs: `,b==null?void 0:b.inputs.map(G=>G.name+" ("+G.id+")")),z.Logger.log("Up method return statements:",b==null?void 0:b.returnStatements[0].outputs.map(G=>se(G,l)+" ("+G.id+")")),z.Logger.log(`
|
|
483
483
|
Down inputs: `,g==null?void 0:g.inputs.map(G=>G.name+" ("+G.id+")")),z.Logger.log("Down method return statements:",g==null?void 0:g.returnStatements[0].outputs.map(G=>se(G,l)+" ("+G.id+")"));const _=LFe(r.listAdded.map(G=>l.get(G.id))),$=a.x||0,L=a.y||0,j=600;return _.forEach((G,H)=>{var ae;const ie=(G.x===0?p.x+j*(H+1):G.x)+$,ee=p.y-800;let ue=(G.y===0?ee:G.y)+L;G.type===d.ReturnStatement&&((ae=G.parent)==null?void 0:ae.id)===E.id&&(ue+=800+70),G.metaSync({x:ie,y:ue},r)}),(k=h.defaultValue)==null||k.metaSync({editable:!1,deletable:!1},r),h.metaSync({editable:!1,deletable:!1},r),f}function aVi(l,p,i,r={}){const{updatedEntityVersion:a,newestOpenRowTransformer:c,lastPublishedEntityVersion:e}=p;return c?(X$(l,c,a,e,i),{rowTransformer:c}):{rowTransformer:Zke(l,a,e,i,r)}}function Hke(l,p={}){var h,m,E,b,g,_,$,L,j,k;const i={startEntity:l,visitedIds:new Set,order:new Map,lines:[],options:{indentSize:p.indentSize??2,maxDepth:p.maxDepth??50}};if(!Sg.includes(l.type))return`Error: Entity ${l.id} is not an executable entity. Found type: ${l.type}`;let r=l,a="",c="";if(l.type===d.FunctionDeclaration)if(((h=l.parent)==null?void 0:h.type)===d.DefinitionEntity)if(Wi(l.parent,Ie.CRON_JOB)){a="Cron Job ",r=l.parent;const G=(m=l.parent.properties)==null?void 0:m.find(ie=>{var ee;return!!((ee=ie.implements)!=null&&ee.find(ue=>ue.id===re["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.properties.expression.id))}),H=(E=G==null?void 0:G.defaultValue)==null?void 0:E.value;H&&(c+=` [Schedule: ${H}] `)}else if(Wi(l.parent,Ie.HTTP_ENDPOINT)){a="HTTP Endpoint ",r=l.parent;const G=(b=l.parent.properties)==null?void 0:b.find(ue=>{var ae;return!!((ae=ue.implements)!=null&&ae.find(de=>de.id===re["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id))}),H=(g=G==null?void 0:G.defaultValue)==null?void 0:g.value;H&&(c+=` [${H.toUpperCase()}]`);const ie=(_=l.parent.properties)==null?void 0:_.find(ue=>{var ae;return!!((ae=ue.implements)!=null&&ae.find(de=>de.id===re["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id))}),ee=($=ie==null?void 0:ie.defaultValue)==null?void 0:$.value;ee&&(c+=` ${ee} `)}else Wi(l.parent,Ie.SQL_ROW_TRANSFORMER)&&(a="SQL Row Transformer (SQL migration)",r=l.parent,((L=l.implements)==null?void 0:L.id)===re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id?c=" - UP method":((j=l.implements)==null?void 0:j.id)===re["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id&&(c=" - DOWN method"));else((k=l.parent)==null?void 0:k.type)===d.Loop&&(a="body of Loop ",r=l.parent);i.lines.push(`CONTEXT: Logic Flow for ${a}"${se(r,r.project)}" (${r.id})${c}`),i.lines.push("");const e=new cn;return[l,...yt(l)].forEach(G=>{e.flatRecord[G.id]=G,e.order.push(G.id)}),e.orderEntities(),e.visit(G=>{i.order.set(G.id,i.order.size+1)}),zu(l,0,0,i,{onPrefix:p.onPrefix,onMissingValue:p.onMissingValue}),i.lines.join(`
|
|
484
|
-
`)}function zu(l,p,i,r,a={}){var b;if(p>r.options.maxDepth){ii(r,p,i,"... [MAX DEPTH REACHED]");return}let c=p,e=i;const f=[..."calls"in l&&Array.isArray(l.calls)?l.calls:[],..."successCalls"in l&&Array.isArray(l.successCalls)?l.successCalls:[],..."errorCalls"in l&&Array.isArray(l.errorCalls)?l.errorCalls:[]],h=f.length>0,m="errorCalls"in l&&Array.isArray(l.errorCalls)&&l.errorCalls.length>0,E="successCalls"in l&&Array.isArray(l.successCalls)&&l.successCalls.length>0;if(r.visitedIds.add(l.id),Z_(l,c,e,r,a),l.type===d.InternalCall){const g=se(l.parent,l.project),_=l.parent.id,$=l.parent.type,L=`${$?`${$} `:""}"${g}" (${_})`;ii(r,c+1,e+1,`Part of state instance of parent: ${L}`)}if(lp.includes(l.type)&&ii(r,c+1,h?e+1:e,`Error handling: ${l.catchesError?"YES (catches)":"NO (can throw)"}`),H_(l,c+1,h?e+1:e,r,a),oVi(l,c+1,h?e+1:e,r,a),l.type===d.Loop&&(ii(r,c+1,e+1,"LOOP BODY:"),l.body?zu(l.body,c+1,e+1,r,{onPrefix:a.onPrefix,onMissingValue:a.onMissingValue}):ii(r,c+1,e+1,"(Empty Body)")),((b=r.startEntity)==null?void 0:b.id)===l.id&&!f.length&&(ii(r,c,e," │ "),ii(r,c,e," ▼"),ii(r,c,e,"(Empty Logic Flow. No calls yet)")),"calls"in l&&Array.isArray(l.calls)&&l.calls.length>0){const g=l.calls,$=g.length>1?"PARALLEL ":"";g.forEach((L,j)=>{const k=j===g.length-1&&!m&&!E;let G=k?" └──> ":" ├──> ";const ie=`CALL #${r.order.get(L.id)||0} `;if(r.visitedIds.has(L.id)){ii(r,c,e," │ ");const ee=se(L,L.project);ii(r,c,e,`${G}${$}${ie}[MERGE/JOIN] Connects to (already rendered) Node: "${ee}" (${L.id})`);return}if(k)G=" ▼",ii(r,c,e," │ "),ii(r,c,e,G),zu(L,c,e,r,{onPrefix:a.onPrefix,onMissingValue:a.onMissingValue});else{ii(r,c,e," │ ");const ue=`${gT(c,e)}${G}${$}${ie}`;zu(L,c+1,e+1,r,{externalPrefix:ue,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}})}if("errorCalls"in l&&Array.isArray(l.errorCalls)&&l.errorCalls.length>0){const g=l.errorCalls,$=g.length>1?"PARALLEL ":"";let L="ON ERROR";l.type===d.Condition&&(L="IF FALSE"),l.errorCalls.forEach((j,k)=>{const G=k===g.length-1&&!E;let H=G?" └──> ":" ├──> ";const ee=`CALL #${r.order.get(j.id)||0} `;if(r.visitedIds.has(j.id)){ii(r,c,e," │ ");const ue=se(j,j.project);ii(r,c,e,`${H}${$}${ee}${L} [MERGE/JOIN] Connects to existing Node (already rendered): "${ue}" (${j.id})`);return}if(G)H=" ▼",ii(r,c,e," │ "),ii(r,c,e,H),zu(j,c,e,r,{onPrefix:a.onPrefix,onMissingValue:a.onMissingValue});else{ii(r,c,e," │ ");const ae=`${gT(c,e)}${H}${$}${ee}${L} `;zu(j,c+1,e+1,r,{externalPrefix:ae,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}})}if("successCalls"in l&&Array.isArray(l.successCalls)&&l.successCalls.length>0){const g=l.successCalls,$=g.length>1?"PARALLEL ":"";let L="ON SUCCESS";l.type===d.Condition&&(L="IF TRUE"),g.forEach((j,k)=>{const G=k===g.length-1;let H=G?" └──> ":" ├──> ";const ee=`CALL #${r.order.get(j.id)||0} `;if(r.visitedIds.has(j.id)){const ue=se(j,j.project);ii(r,c,e," │ "),ii(r,c,e,`${H}${$}${ee}${L} [MERGE/JOIN] Connects to existing Node (already rendered): "${ue}" (${j.id})`);return}if(G){H=" ▼",ii(r,c,e," │ "),ii(r,c,e,H);const ae=`${gT(c,e)}${$}${ee}${L} `;zu(j,c,e,r,{externalPrefix:ae,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}else{ii(r,c,e," │ ");const ae=`${gT(c,e)}${H}${$}${ee}${L} `;zu(j,c+1,e+1,r,{externalPrefix:ae,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}})}}function gT(l,p){let i="";for(let r=0;r<l;r++)r<p?i+=" │ ":i+=" ";return i}function ii(l,p,i,r){l.lines.push(`${gT(p,i)}${r}`)}function sVi(l,p){l.lines.push(p)}function lVi(l,p,i,r,a={}){var c,e;((c=l.declaration)==null?void 0:c.id)===re.condition["condition-group-and"].id?(ii(r,p,i,"NESTED AND (all conditions must be true)"),(l.andChildrenGroup||[]).forEach((f,h)=>{Z_(f,p+1,i,r,{onPrefix:a.onPrefix}),H_(f,p+1,i,r,a),h===(l.andChildrenGroup||[]).length-1||ii(r,p,i,"AND")})):((e=l.declaration)==null?void 0:e.id)===re.condition["condition-group-or"].id&&(ii(r,p,i,"NESTED OR (at least one condition must be true)"),(l.orChildrenGroup||[]).forEach((f,h)=>{Z_(f,p+1,i,r,{onPrefix:a.onPrefix}),H_(f,p+1,i,r,a),h===(l.orChildrenGroup||[]).length-1||ii(r,p,i,"OR")}))}function Z_(l,p,i,r,a={}){var E,b;const c=se(l,l.project);let e=Wa[l.type].shortSingular;switch(l.type){case d.FunctionDeclaration:e="Function Entry";break;case d.GlobalEvent:e="Function Entry";break;case d.Operation:e="Operation";break;case d.Condition:e="Condition";break;case d.Loop:e="Loop";break;case d.ReturnStatement:e="Return";break;case d.ContinueStatement:e="Continue";break;case d.BreakStatement:e="Break";break;case d.FunctionCall:e="Function Call";break;case d.InternalCall:e="Instance method Call";break;case d.VariableDeclaration:e="Variable Declaration";break;case d.VariableInstance:e="Variable Instance";break;case d.Search:e="DB Search";break}const h=`${a.onPrefix?a.onPrefix(l):""}[${e}] "${c}" (${l.id})`;let m=!1;if(Pr.includes(l.type)&&(l.calledByEntry.some(g=>g.calls.length>1)&&(m=!0),l.calledBySuccess.some(g=>g.successCalls.length>1)&&(m=!0),l.calledByError.some(g=>g.errorCalls.length>1)&&(m=!0)),typeof a.externalPrefix=="string")sVi(r,a.externalPrefix+h);else{const g=r.order.get(l.id)||0;let _=`${m?"PARALLEL ":""}CALL #${g} `;(l.type===d.Condition&&((E=l.parent)==null?void 0:E.type)===d.Condition||l.type===d.FunctionDeclaration&&((b=l.parent)==null?void 0:b.type)===d.Loop)&&(_=""),ii(r,p,i,`${_}${h}`)}if("description"in l&&l.description){const g=l.description.replace(/[\r\n]+/g," ").substring(0,100),_=l.description.length>100;g&&ii(r,p+1,i+1,`NOTE: "${g}${_?"...":""}"`)}l.type===d.Search&&"query"in l?ii(r,p+1,i+1,`QUERY: \`${(l.query||"").replace("{{::","{{::input-map-value:")}\``):l.type===d.Condition&&(l.declaration.id===re.condition["condition-group-and"].id||l.declaration.id===re.condition["condition-group-or"].id)&&lVi(l,p+1,i+1,r)}function H_(l,p,i,r,a={}){const c=a.onPrefix?a.onPrefix(l):"";if(Ft.includes(l.type)){l.inputs.length>0&&(ii(r,p,i,"INPUTS:"),l.inputs.forEach(E=>{const b=a.onPrefix?a.onPrefix(E):"",g=se(E,E.project),_=Xu(E,{prefix:`- ${b}"${g}" (${E.id}) Default value:`});ii(r,p+1,i,_),E.writesValues.length&&(ii(r,p+2,i,"WRITES:"),E.writesValues.forEach($=>{const L=se($,l.project);let j="";if($.type===d.InputMap){const k=$.parent,G=se(k,l.project);j=`${$.type}: "${L}" (${$.id}) of ${k.type}: "${G}"`}else j=`${$.type}: "${L}" (${$.id})`;ii(r,p+3,i,`-> ${j}`)}))}));return}if(pn.includes(l.type)&&(!Dt.includes(l.type)||!l.throws)){const m=Xu(l,{prefix:`${c}Main value assignment <-`});ii(r,p,i,m)}if(Dt.includes(l.type)){const m=l;if(m.throws){const E=a.onPrefix?a.onPrefix(l):"",b=Xu(m.throws,{prefix:`${E}"${se(m.throws,m.throws.project)}" (${m.throws.id}) THROWS ERROR value <-`});ii(r,p,i,b)}}const e=[];if(Nt.includes(l.type))e.push(...l.inputs||[]);else if(Dt.includes(l.type)){const m=l;e.push(...m.outputs||[])}e.sort((m,E)=>m.index-E.index);const f=e.filter(m=>ZT(m)),h=e.filter(m=>(!!m.readsValue||!!m.defaultValue)&&!ZT(m));if(h.length>0){let m="INPUTS";[..._t,...Dt].includes(l.type)&&(m="PROPERTIES ASSIGNED"),ii(r,p,i,`${m}:`),h.forEach(E=>{const b=a.onPrefix?a.onPrefix(E):"",g=Xu(E,{prefix:`${b}<-`});ii(r,p,i,` - "${se(E,E.project)}" (${E.id}) ${g}`)})}f.length>0&&(h.length||ii(r,p,i,"INPUTS:"),f.forEach(m=>{const E=a.onPrefix?a.onPrefix(m):"",b=Xu(m,{prefix:`${E}<-`,onMissingValue:a.onMissingValue,onPrefix:a.onPrefix});ii(r,p,i,` - "${se(m,m.project)}" (${m.id}) ${b}`)}))}function oVi(l,p,i,r,a={}){var c;if(Ki.includes(l.type)&&l.writesValues.length){let e="Writes values to";Nt.includes(l.type)?e="OUTPUT Full returned value read by":_t.includes(l.type)&&(e="OUTPUT Main (full) value written to"),ii(r,p,i,`${e}:`),l.writesValues.forEach(f=>{const h=se(f,l.project);let m="";if(f.type===d.InputMap){const E=f.parent,b=se(E,l.project);m=`${f.type}: "${h}" (${f.id}) of ${E.type}: "${b}"`}else m=`${f.type}: "${h}" (${f.id})`;ii(r,p+1,i,`-> ${m}`)})}lp.includes(l.type)&&(l.error&&(((c=l.error)==null?void 0:c.writesValues)||[]).length>0&&(ii(r,p,i,"CAUGHT ERROR value read by:"),l.error.writesValues.forEach(f=>{const h=se(f,l.project);let m="";if(f.type===d.InputMap){const E=f.parent,b=se(E,l.project);m=`${f.type}: "${h}" (${f.id}) of ${E.type}: "${b}"`}else m=`${f.type}: "${h}" (${f.id})`;ii(r,p+2,i,`-> ${m}`)})),l.outputs.length&&l.outputs.some(e=>e.writesValues.length>0)&&(ii(r,p,i,"DESTRUCT RETURNED PROPERTIES (from main outputted value):"),l.outputs.forEach(e=>{if(e.writesValues.length===0)return;const f=a.onPrefix?a.onPrefix(e):"",h=se(e,e.project);ii(r,p+1,i,`- ${f}"${h}" (${e.id}) WRITES:`),e.writesValues.forEach(m=>{const E=se(m,l.project);let b="";if(m.type===d.InputMap){const g=m.parent,_=se(g,l.project);b=`${m.type}: "${E}" (${m.id}) of ${g.type}: "${_}"`}else b=`${m.type}: "${E}" (${m.id})`;ii(r,p+2,i,`-> ${b}`)})})))}function dVi(l,p={nested:!1,omitTopLevelType:!1,firstLabel:"name",omitIdsFor:[],omitTypesFor:[],metadataIndent:1,ownMetadataIndent:1,omitFields:[],onlyFields:[]},i={}){const r={nested:p.nested??!1,omitTopLevelType:p.omitTopLevelType??!1,firstLabel:p.firstLabel??"name",omitIdsFor:p.omitIdsFor??[],omitTypesFor:p.omitTypesFor??[],metadataIndent:p.metadataIndent??1,omitFields:p.omitFields??[],onlyFields:p.onlyFields??[]},a=[...l.entities.reduce((f,h)=>{const m=h.methods.filter(E=>!E.extends);return[...f,...m]},[]),...l.functions,...l.events];let c="";const e=ei(l,{...r,nested:!0,omitTopLevelType:!1,firstLabel:r.firstLabel,omitIdsFor:r.omitIdsFor,omitTypesFor:r.omitTypesFor,metadataIndent:r.metadataIndent,omitFields:r.omitFields,onlyFields:r.onlyFields,onPrefix:p.onPrefix});if(c+=v1(e,i),a.length>0){const f=i.newLinesBetweenItems??3;c+=`
|
|
484
|
+
`)}function zu(l,p,i,r,a={}){var b;if(p>r.options.maxDepth){ii(r,p,i,"... [MAX DEPTH REACHED]");return}let c=p,e=i;const f=[..."calls"in l&&Array.isArray(l.calls)?l.calls:[],..."successCalls"in l&&Array.isArray(l.successCalls)?l.successCalls:[],..."errorCalls"in l&&Array.isArray(l.errorCalls)?l.errorCalls:[]],h=f.length>0,m="errorCalls"in l&&Array.isArray(l.errorCalls)&&l.errorCalls.length>0,E="successCalls"in l&&Array.isArray(l.successCalls)&&l.successCalls.length>0;if(r.visitedIds.add(l.id),Z_(l,c,e,r,a),l.type===d.InternalCall){const g=se(l.parent,l.project),_=l.parent.id,$=l.parent.type,L=`${$?`${$} `:""}"${g}" (${_})`;ii(r,c+1,h?e+1:e,`Part of state instance of parent: ${L}`)}if(lp.includes(l.type)&&ii(r,c+1,h?e+1:e,`Error handling: ${l.catchesError?"YES (catches)":"NO (can throw)"}`),H_(l,c+1,h?e+1:e,r,a),oVi(l,c+1,h?e+1:e,r,a),l.type===d.Loop&&(ii(r,c+1,e+1,"LOOP BODY:"),l.body?zu(l.body,c+1,e+1,r,{onPrefix:a.onPrefix,onMissingValue:a.onMissingValue}):ii(r,c+1,e+1,"(Empty Body)")),((b=r.startEntity)==null?void 0:b.id)===l.id&&!f.length&&(ii(r,c,e," │ "),ii(r,c,e," ▼"),ii(r,c,e,"(Empty Logic Flow. No calls yet)")),"calls"in l&&Array.isArray(l.calls)&&l.calls.length>0){const g=l.calls,$=g.length>1?"PARALLEL ":"";g.forEach((L,j)=>{const k=j===g.length-1&&!m&&!E;let G=k?" └──> ":" ├──> ";const ie=`CALL #${r.order.get(L.id)||0} `;if(r.visitedIds.has(L.id)){ii(r,c,e," │ ");const ee=se(L,L.project);ii(r,c,e,`${G}${$}${ie}[MERGE/JOIN] Connects to (already rendered) Node: "${ee}" (${L.id})`);return}if(k)G=" ▼",ii(r,c,e," │ "),ii(r,c,e,G),zu(L,c,e,r,{onPrefix:a.onPrefix,onMissingValue:a.onMissingValue});else{ii(r,c,e," │ ");const ue=`${gT(c,e)}${G}${$}${ie}`;zu(L,c+1,e+1,r,{externalPrefix:ue,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}})}if("errorCalls"in l&&Array.isArray(l.errorCalls)&&l.errorCalls.length>0){const g=l.errorCalls,$=g.length>1?"PARALLEL ":"";let L="ON ERROR";l.type===d.Condition&&(L="IF FALSE"),l.errorCalls.forEach((j,k)=>{const G=k===g.length-1&&!E;let H=G?" └──> ":" ├──> ";const ee=`CALL #${r.order.get(j.id)||0} `;if(r.visitedIds.has(j.id)){ii(r,c,e," │ ");const ue=se(j,j.project);ii(r,c,e,`${H}${$}${ee}${L} [MERGE/JOIN] Connects to existing Node (already rendered): "${ue}" (${j.id})`);return}if(G)H=" ▼",ii(r,c,e," │ "),ii(r,c,e,H),zu(j,c,e,r,{onPrefix:a.onPrefix,onMissingValue:a.onMissingValue});else{ii(r,c,e," │ ");const ae=`${gT(c,e)}${H}${$}${ee}${L} `;zu(j,c+1,e+1,r,{externalPrefix:ae,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}})}if("successCalls"in l&&Array.isArray(l.successCalls)&&l.successCalls.length>0){const g=l.successCalls,$=g.length>1?"PARALLEL ":"";let L="ON SUCCESS";l.type===d.Condition&&(L="IF TRUE"),g.forEach((j,k)=>{const G=k===g.length-1;let H=G?" └──> ":" ├──> ";const ee=`CALL #${r.order.get(j.id)||0} `;if(r.visitedIds.has(j.id)){const ue=se(j,j.project);ii(r,c,e," │ "),ii(r,c,e,`${H}${$}${ee}${L} [MERGE/JOIN] Connects to existing Node (already rendered): "${ue}" (${j.id})`);return}if(G){H=" ▼",ii(r,c,e," │ "),ii(r,c,e,H);const ae=`${gT(c,e)}${$}${ee}${L} `;zu(j,c,e,r,{externalPrefix:ae,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}else{ii(r,c,e," │ ");const ae=`${gT(c,e)}${H}${$}${ee}${L} `;zu(j,c+1,e+1,r,{externalPrefix:ae,onPrefix:a.onPrefix,onMissingValue:a.onMissingValue})}})}}function gT(l,p){let i="";for(let r=0;r<l;r++)r<p?i+=" │ ":i+=" ";return i}function ii(l,p,i,r){l.lines.push(`${gT(p,i)}${r}`)}function sVi(l,p){l.lines.push(p)}function lVi(l,p,i,r,a={}){var c,e;((c=l.declaration)==null?void 0:c.id)===re.condition["condition-group-and"].id?(ii(r,p,i,"NESTED AND (all conditions must be true)"),(l.andChildrenGroup||[]).forEach((f,h)=>{Z_(f,p+1,i,r,{onPrefix:a.onPrefix}),H_(f,p+1,i,r,a),h===(l.andChildrenGroup||[]).length-1||ii(r,p,i,"AND")})):((e=l.declaration)==null?void 0:e.id)===re.condition["condition-group-or"].id&&(ii(r,p,i,"NESTED OR (at least one condition must be true)"),(l.orChildrenGroup||[]).forEach((f,h)=>{Z_(f,p+1,i,r,{onPrefix:a.onPrefix}),H_(f,p+1,i,r,a),h===(l.orChildrenGroup||[]).length-1||ii(r,p,i,"OR")}))}function Z_(l,p,i,r,a={}){var E,b;const c=se(l,l.project);let e=Wa[l.type].shortSingular;switch(l.type){case d.FunctionDeclaration:e="Function Entry";break;case d.GlobalEvent:e="Function Entry";break;case d.Operation:e="Operation";break;case d.Condition:e="Condition";break;case d.Loop:e="Loop";break;case d.ReturnStatement:e="Return";break;case d.ContinueStatement:e="Continue";break;case d.BreakStatement:e="Break";break;case d.FunctionCall:e="Function Call";break;case d.InternalCall:e="Instance method Call";break;case d.VariableDeclaration:e="Variable Declaration";break;case d.VariableInstance:e="Variable Instance";break;case d.Search:e="DB Search";break}const h=`${a.onPrefix?a.onPrefix(l):""}[${e}] "${c}" (${l.id})`;let m=!1;if(Pr.includes(l.type)&&(l.calledByEntry.some(g=>g.calls.length>1)&&(m=!0),l.calledBySuccess.some(g=>g.successCalls.length>1)&&(m=!0),l.calledByError.some(g=>g.errorCalls.length>1)&&(m=!0)),typeof a.externalPrefix=="string")sVi(r,a.externalPrefix+h);else{const g=r.order.get(l.id)||0;let _=`${m?"PARALLEL ":""}CALL #${g} `;(l.type===d.Condition&&((E=l.parent)==null?void 0:E.type)===d.Condition||l.type===d.FunctionDeclaration&&((b=l.parent)==null?void 0:b.type)===d.Loop)&&(_=""),ii(r,p,i,`${_}${h}`)}if("description"in l&&l.description){const g=l.description.replace(/[\r\n]+/g," ").substring(0,100),_=l.description.length>100;g&&ii(r,p+1,i+1,`NOTE: "${g}${_?"...":""}"`)}l.type===d.Search&&"query"in l?ii(r,p+1,i+1,`QUERY: \`${(l.query||"").replace("{{::","{{::input-map-value:")}\``):l.type===d.Condition&&(l.declaration.id===re.condition["condition-group-and"].id||l.declaration.id===re.condition["condition-group-or"].id)&&lVi(l,p+1,i+1,r)}function H_(l,p,i,r,a={}){const c=a.onPrefix?a.onPrefix(l):"";if(Ft.includes(l.type)){l.inputs.length>0&&(ii(r,p,i,"INPUTS:"),l.inputs.forEach(E=>{const b=a.onPrefix?a.onPrefix(E):"",g=se(E,E.project),_=Xu(E,{prefix:`- ${b}"${g}" (${E.id}) Default value:`});ii(r,p+1,i,_),E.writesValues.length&&(ii(r,p+2,i,"WRITES:"),E.writesValues.forEach($=>{const L=se($,l.project);let j="";if($.type===d.InputMap){const k=$.parent,G=se(k,l.project);j=`${$.type}: "${L}" (${$.id}) of ${k.type}: "${G}"`}else j=`${$.type}: "${L}" (${$.id})`;ii(r,p+3,i,`-> ${j}`)}))}));return}if(pn.includes(l.type)&&(!Dt.includes(l.type)||!l.throws)){const m=Xu(l,{prefix:`${c}Main value assignment <-`});ii(r,p,i,m)}if(Dt.includes(l.type)){const m=l;if(m.throws){const E=a.onPrefix?a.onPrefix(l):"",b=Xu(m.throws,{prefix:`${E}"${se(m.throws,m.throws.project)}" (${m.throws.id}) THROWS ERROR value <-`});ii(r,p,i,b)}}const e=[];if(Nt.includes(l.type))e.push(...l.inputs||[]);else if(Dt.includes(l.type)){const m=l;e.push(...m.outputs||[])}e.sort((m,E)=>m.index-E.index);const f=e.filter(m=>ZT(m)),h=e.filter(m=>(!!m.readsValue||!!m.defaultValue)&&!ZT(m));if(h.length>0){let m="INPUTS";[..._t,...Dt].includes(l.type)&&(m="PROPERTIES ASSIGNED"),ii(r,p,i,`${m}:`),h.forEach(E=>{const b=a.onPrefix?a.onPrefix(E):"",g=Xu(E,{prefix:`${b}<-`});ii(r,p,i,` - "${se(E,E.project)}" (${E.id}) ${g}`)})}f.length>0&&(h.length||ii(r,p,i,"INPUTS:"),f.forEach(m=>{const E=a.onPrefix?a.onPrefix(m):"",b=Xu(m,{prefix:`${E}<-`,onMissingValue:a.onMissingValue,onPrefix:a.onPrefix});ii(r,p,i,` - "${se(m,m.project)}" (${m.id}) ${b}`)}))}function oVi(l,p,i,r,a={}){var c;if(Ki.includes(l.type)&&l.writesValues.length){let e="Writes values to";Nt.includes(l.type)?e="OUTPUT Full returned value read by":_t.includes(l.type)&&(e="OUTPUT Main (full) value written to"),ii(r,p,i,`${e}:`),l.writesValues.forEach(f=>{const h=se(f,l.project);let m="";if(f.type===d.InputMap){const E=f.parent,b=se(E,l.project);m=`${f.type}: "${h}" (${f.id}) of ${E.type}: "${b}"`}else m=`${f.type}: "${h}" (${f.id})`;ii(r,p+1,i,`-> ${m}`)})}lp.includes(l.type)&&(l.error&&(((c=l.error)==null?void 0:c.writesValues)||[]).length>0&&(ii(r,p,i,"CAUGHT ERROR value read by:"),l.error.writesValues.forEach(f=>{const h=se(f,l.project);let m="";if(f.type===d.InputMap){const E=f.parent,b=se(E,l.project);m=`${f.type}: "${h}" (${f.id}) of ${E.type}: "${b}"`}else m=`${f.type}: "${h}" (${f.id})`;ii(r,p+2,i,`-> ${m}`)})),l.outputs.length&&l.outputs.some(e=>e.writesValues.length>0)&&(ii(r,p,i,"DESTRUCT RETURNED PROPERTIES (from main outputted value):"),l.outputs.forEach(e=>{if(e.writesValues.length===0)return;const f=a.onPrefix?a.onPrefix(e):"",h=se(e,e.project);ii(r,p+1,i,`- ${f}"${h}" (${e.id}) WRITES:`),e.writesValues.forEach(m=>{const E=se(m,l.project);let b="";if(m.type===d.InputMap){const g=m.parent,_=se(g,l.project);b=`${m.type}: "${E}" (${m.id}) of ${g.type}: "${_}"`}else b=`${m.type}: "${E}" (${m.id})`;ii(r,p+2,i,`-> ${b}`)})})))}function dVi(l,p={nested:!1,omitTopLevelType:!1,firstLabel:"name",omitIdsFor:[],omitTypesFor:[],metadataIndent:1,ownMetadataIndent:1,omitFields:[],onlyFields:[]},i={}){const r={nested:p.nested??!1,omitTopLevelType:p.omitTopLevelType??!1,firstLabel:p.firstLabel??"name",omitIdsFor:p.omitIdsFor??[],omitTypesFor:p.omitTypesFor??[],metadataIndent:p.metadataIndent??1,omitFields:p.omitFields??[],onlyFields:p.onlyFields??[]},a=[...l.entities.reduce((f,h)=>{const m=h.methods.filter(E=>!E.extends);return[...f,...m]},[]),...l.functions,...l.events];let c="";const e=ei(l,{...r,nested:!0,omitTopLevelType:!1,firstLabel:r.firstLabel,omitIdsFor:r.omitIdsFor,omitTypesFor:r.omitTypesFor,metadataIndent:r.metadataIndent,omitFields:r.omitFields,onlyFields:r.onlyFields,onPrefix:p.onPrefix});if(c+=v1(e,i),a.length>0){const f=i.newLinesBetweenItems??3;c+=`
|
|
485
485
|
`.repeat(f),c+=`GLOBAL ENTRY POINTS CALL-STACKS:
|
|
486
486
|
|
|
487
487
|
`;for(let h=0;h<a.length;h++){const m=a[h],E=Hke(m,{onPrefix:p.onPrefix});c+=E,h<a.length-1&&(c+=`
|