@adaas/a-concept 0.3.3 → 0.3.5

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.
@@ -856,11 +856,11 @@ declare enum A_TYPES__EntityMetaKey {
856
856
  ABSTRACTIONS = "a-component-abstractions",
857
857
  INJECTIONS = "a-component-injections"
858
858
  }
859
- declare enum A_TYPES__EntityFeatures {
860
- SAVE = "save",
861
- DESTROY = "destroy",
862
- LOAD = "load"
863
- }
859
+ declare const A_TYPES__EntityFeatures: {
860
+ readonly SAVE: "_A_Entity__Save";
861
+ readonly DESTROY: "_A_Entity__Destroy";
862
+ readonly LOAD: "_A_Entity__Load";
863
+ };
864
864
 
865
865
  /**
866
866
  * Entity interface
@@ -924,6 +924,7 @@ type A_TYPES__EntityMeta = {
924
924
  [Key: string]: A_TYPES__A_InjectDecorator_Meta;
925
925
  }>;
926
926
  };
927
+ type A_TYPES__EntityFeatureNames = typeof A_TYPES__EntityFeatures[keyof typeof A_TYPES__EntityFeatures];
927
928
 
928
929
  /**
929
930
  * A_Entity is another abstraction that describes all major participants in the system business logic.
@@ -1082,15 +1083,15 @@ declare class A_Entity<_ConstructorType extends A_TYPES__Entity_Init = A_TYPES__
1082
1083
  /**
1083
1084
  * The default method that can be called and extended to load entity data.
1084
1085
  */
1085
- load(scope?: A_Scope): Promise<any>;
1086
+ load(scope?: A_Scope): Promise<void> | void;
1086
1087
  /**
1087
1088
  * The default method that can be called and extended to destroy entity data.
1088
1089
  */
1089
- destroy(scope?: A_Scope): Promise<any>;
1090
+ destroy(scope?: A_Scope): Promise<void> | void;
1090
1091
  /**
1091
1092
  * The default method that can be called and extended to save entity data.
1092
1093
  */
1093
- save(scope?: A_Scope): Promise<any>;
1094
+ save(scope?: A_Scope): Promise<void> | void;
1094
1095
  /**
1095
1096
  * Create a new entity from ASEID string or instance
1096
1097
  * [!] Executed when the constructor is called with a string or ASEID instance that represents the ASEID
@@ -1146,7 +1147,7 @@ declare class A_Entity<_ConstructorType extends A_TYPES__Entity_Init = A_TYPES__
1146
1147
  toString(): string;
1147
1148
  }
1148
1149
 
1149
- declare class A_EntityMeta extends A_Meta<A_TYPES__EntityMeta> {
1150
+ declare class A_EntityMeta<T extends A_TYPES__EntityMeta = A_TYPES__EntityMeta> extends A_Meta<T> {
1150
1151
  /**
1151
1152
  * Returns all features defined in the Container
1152
1153
  *
@@ -1782,10 +1783,29 @@ declare class A_StepsManager {
1782
1783
  visited: Set<string>;
1783
1784
  tempMark: Set<string>;
1784
1785
  sortedEntities: string[];
1786
+ /**
1787
+ * Maps each step instance to a unique ID.
1788
+ * Duplicate steps (same dependency.name + handler) get indexed suffixes (e.g., #1, #2).
1789
+ */
1790
+ private _uniqueIdMap;
1785
1791
  private _isBuilt;
1786
1792
  constructor(entities: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>);
1787
1793
  private prepareSteps;
1794
+ /**
1795
+ * Returns the base (non-unique) ID for a step: `dependency.name.handler`
1796
+ */
1797
+ private baseID;
1798
+ /**
1799
+ * Returns the unique ID assigned to a specific step instance.
1800
+ * Falls back to baseID if not yet assigned.
1801
+ */
1788
1802
  private ID;
1803
+ /**
1804
+ * Assigns unique IDs to all steps.
1805
+ * Duplicate base IDs get an index suffix (#0, #1, ...).
1806
+ * Steps with unique base IDs keep their original ID (no suffix).
1807
+ */
1808
+ private assignUniqueIds;
1789
1809
  private buildGraph;
1790
1810
  private matchEntities;
1791
1811
  private visit;
@@ -2861,7 +2881,7 @@ declare class A_Container {
2861
2881
  scope?: A_Scope): Promise<void>;
2862
2882
  }
2863
2883
 
2864
- declare class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
2884
+ declare class A_ContainerMeta<T extends A_TYPES__ContainerMeta = A_TYPES__ContainerMeta> extends A_Meta<T> {
2865
2885
  /**
2866
2886
  * Allows to get all the injections for a given handler
2867
2887
  *
@@ -3729,6 +3749,11 @@ declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentTy
3729
3749
  * Provide an entity instance to deregister it in the scope
3730
3750
  */
3731
3751
  entity: A_Entity): void;
3752
+ deregister<T extends A_TYPES__A_DependencyInjectable>(
3753
+ /**
3754
+ * Provide an entity instance to register it in the scope
3755
+ */
3756
+ component: T): void;
3732
3757
  /**
3733
3758
  * This method is useful when you want to serialize the scope to JSON
3734
3759
  *
@@ -4247,7 +4272,7 @@ declare class A_Context {
4247
4272
  * Get meta for the specific component class by constructor.
4248
4273
  */
4249
4274
  component: A_TYPES__Component_Constructor): T;
4250
- static meta<T extends A_ComponentMeta, S extends A_Component>(
4275
+ static meta<T extends A_ComponentMeta<any>, S extends A_Component>(
4251
4276
  /**
4252
4277
  * Get meta for the specific component instance.
4253
4278
  */
@@ -5000,4 +5025,4 @@ declare const A_CONSTANTS__DEFAULT_ENV_VARIABLES: {
5000
5025
  type A_TYPES__ConceptENVVariables = (typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES)[keyof typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES][];
5001
5026
  declare const A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY: readonly ["A_CONCEPT_NAME", "A_CONCEPT_ROOT_SCOPE", "A_CONCEPT_ENVIRONMENT", "A_CONCEPT_RUNTIME_ENVIRONMENT", "A_CONCEPT_ROOT_FOLDER", "A_ERROR_DEFAULT_DESCRIPTION"];
5002
5027
 
5003
- export { ASEID, A_Abstraction, A_AbstractionError, A_Abstraction_Extend, A_BasicTypeGuards, A_CONCEPT_ENV, A_CONSTANTS__DEFAULT_ENV_VARIABLES, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_CONSTANTS__ERROR_CODES, A_CONSTANTS__ERROR_DESCRIPTION, A_Caller, A_CallerError, A_CommonHelper, A_Component, A_ComponentMeta, A_Concept, A_ConceptMeta, A_Container, A_ContainerMeta, A_Context, A_ContextError, A_Dependency, A_DependencyError, A_Dependency_All, A_Dependency_Default, A_Dependency_Flat, A_Dependency_Load, A_Dependency_Parent, A_Dependency_Query, A_Dependency_Require, A_Entity, A_EntityError, A_EntityMeta, A_Error, A_Feature, A_FeatureError, A_Feature_Define, A_Feature_Extend, A_FormatterHelper, A_Fragment, type A_ID_TYPES__TimeId_Parts, A_IdentityHelper, A_Inject, A_InjectError, A_Meta, A_MetaDecorator, A_Scope, A_ScopeError, A_Stage, A_StageError, A_StepManagerError, A_StepsManager, type A_TYPES_ScopeDependentComponents, type A_TYPES_ScopeIndependentComponents, type A_TYPES_StageExecutionBehavior, type A_TYPES__ASEID_Constructor, type A_TYPES__ASEID_ConstructorConfig, type A_TYPES__ASEID_JSON, type A_TYPES__A_DependencyConstructor, type A_TYPES__A_DependencyInjectable, type A_TYPES__A_DependencyResolutionStrategy, type A_TYPES__A_DependencyResolutionType, type A_TYPES__A_Dependency_AllDecoratorReturn, type A_TYPES__A_Dependency_DefaultDecoratorReturn, type A_TYPES__A_Dependency_EntityInjectionPagination, type A_TYPES__A_Dependency_EntityInjectionQuery, type A_TYPES__A_Dependency_EntityResolutionConfig, type A_TYPES__A_Dependency_FlatDecoratorReturn, type A_TYPES__A_Dependency_LoadDecoratorReturn, type A_TYPES__A_Dependency_ParentDecoratorReturn, type A_TYPES__A_Dependency_QueryDecoratorReturn, type A_TYPES__A_Dependency_QueryTarget, type A_TYPES__A_Dependency_RequireDecoratorReturn, type A_TYPES__A_Dependency_Serialized, type A_TYPES__A_InjectDecoratorDescriptor, type A_TYPES__A_InjectDecoratorReturn, type A_TYPES__A_InjectDecorator_Meta, type A_TYPES__A_StageStep, type A_TYPES__A_StageStepProcessingExtraParams, A_TYPES__A_Stage_Status, type A_TYPES__AbstractionAvailableComponents, type A_TYPES__AbstractionDecoratorConfig, type A_TYPES__AbstractionDecoratorDescriptor, type A_TYPES__Abstraction_Constructor, type A_TYPES__Abstraction_Init, type A_TYPES__Abstraction_Serialized, type A_TYPES__CallerComponent, type A_TYPES__Caller_Constructor, type A_TYPES__Caller_Init, type A_TYPES__Caller_Serialized, type A_TYPES__ComponentMeta, type A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey, type A_TYPES__Component_Constructor, type A_TYPES__Component_Init, type A_TYPES__Component_Serialized, type A_TYPES__ConceptAbstraction, type A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptAbstractions, type A_TYPES__ConceptENVVariables, A_TYPES__ConceptMetaKey, type A_TYPES__Concept_Constructor, type A_TYPES__Concept_Init, type A_TYPES__Concept_Serialized, type A_TYPES__ContainerMeta, type A_TYPES__ContainerMetaExtension, A_TYPES__ContainerMetaKey, type A_TYPES__Container_Constructor, type A_TYPES__Container_Init, type A_TYPES__Container_Serialized, type A_TYPES__ContextEnvironment, type A_TYPES__Ctor, type A_TYPES__DeepPartial, type A_TYPES__Dictionary, A_TYPES__EntityFeatures, type A_TYPES__EntityMeta, A_TYPES__EntityMetaKey, type A_TYPES__Entity_Constructor, type A_TYPES__Entity_Init, type A_TYPES__Entity_Serialized, type A_TYPES__Error_Constructor, type A_TYPES__Error_Init, type A_TYPES__Error_Serialized, type A_TYPES__ExtractNested, type A_TYPES__ExtractProperties, type A_TYPES__FeatureAvailableComponents, type A_TYPES__FeatureAvailableConstructors, type A_TYPES__FeatureDefineDecoratorConfig, type A_TYPES__FeatureDefineDecoratorDescriptor, type A_TYPES__FeatureDefineDecoratorMeta, type A_TYPES__FeatureDefineDecoratorTarget, type A_TYPES__FeatureDefineDecoratorTemplateItem, type A_TYPES__FeatureError_Init, type A_TYPES__FeatureExtendDecoratorConfig, type A_TYPES__FeatureExtendDecoratorDescriptor, type A_TYPES__FeatureExtendDecoratorMeta, type A_TYPES__FeatureExtendDecoratorScopeConfig, type A_TYPES__FeatureExtendDecoratorScopeItem, type A_TYPES__FeatureExtendDecoratorTarget, type A_TYPES__FeatureExtendableMeta, A_TYPES__FeatureState, type A_TYPES__Feature_Constructor, type A_TYPES__Feature_Init, type A_TYPES__Feature_InitWithComponent, type A_TYPES__Feature_InitWithTemplate, type A_TYPES__Feature_Serialized, type A_TYPES__Fragment_Constructor, type A_TYPES__Fragment_Init, type A_TYPES__Fragment_Serialized, type A_TYPES__IEntity, type A_TYPES__InjectableTargets, type A_TYPES__MetaLinkedComponentConstructors, type A_TYPES__MetaLinkedComponents, type A_TYPES__Meta_Constructor, type A_TYPES__NonObjectPaths, type A_TYPES__ObjectKeyEnum, type A_TYPES__Paths, type A_TYPES__PathsToObject, type A_TYPES__Required, type A_TYPES__ScopeConfig, type A_TYPES__ScopeLinkedComponents, type A_TYPES__ScopeLinkedConstructors, type A_TYPES__Scope_Constructor, type A_TYPES__Scope_Init, type A_TYPES__Scope_Serialized, type A_TYPES__Stage_Serialized, type A_TYPES__UnionToIntersection, A_TypeGuards };
5028
+ export { ASEID, A_Abstraction, A_AbstractionError, A_Abstraction_Extend, A_BasicTypeGuards, A_CONCEPT_ENV, A_CONSTANTS__DEFAULT_ENV_VARIABLES, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_CONSTANTS__ERROR_CODES, A_CONSTANTS__ERROR_DESCRIPTION, A_Caller, A_CallerError, A_CommonHelper, A_Component, A_ComponentMeta, A_Concept, A_ConceptMeta, A_Container, A_ContainerMeta, A_Context, A_ContextError, A_Dependency, A_DependencyError, A_Dependency_All, A_Dependency_Default, A_Dependency_Flat, A_Dependency_Load, A_Dependency_Parent, A_Dependency_Query, A_Dependency_Require, A_Entity, A_EntityError, A_EntityMeta, A_Error, A_Feature, A_FeatureError, A_Feature_Define, A_Feature_Extend, A_FormatterHelper, A_Fragment, type A_ID_TYPES__TimeId_Parts, A_IdentityHelper, A_Inject, A_InjectError, A_Meta, A_MetaDecorator, A_Scope, A_ScopeError, A_Stage, A_StageError, A_StepManagerError, A_StepsManager, type A_TYPES_ScopeDependentComponents, type A_TYPES_ScopeIndependentComponents, type A_TYPES_StageExecutionBehavior, type A_TYPES__ASEID_Constructor, type A_TYPES__ASEID_ConstructorConfig, type A_TYPES__ASEID_JSON, type A_TYPES__A_DependencyConstructor, type A_TYPES__A_DependencyInjectable, type A_TYPES__A_DependencyResolutionStrategy, type A_TYPES__A_DependencyResolutionType, type A_TYPES__A_Dependency_AllDecoratorReturn, type A_TYPES__A_Dependency_DefaultDecoratorReturn, type A_TYPES__A_Dependency_EntityInjectionPagination, type A_TYPES__A_Dependency_EntityInjectionQuery, type A_TYPES__A_Dependency_EntityResolutionConfig, type A_TYPES__A_Dependency_FlatDecoratorReturn, type A_TYPES__A_Dependency_LoadDecoratorReturn, type A_TYPES__A_Dependency_ParentDecoratorReturn, type A_TYPES__A_Dependency_QueryDecoratorReturn, type A_TYPES__A_Dependency_QueryTarget, type A_TYPES__A_Dependency_RequireDecoratorReturn, type A_TYPES__A_Dependency_Serialized, type A_TYPES__A_InjectDecoratorDescriptor, type A_TYPES__A_InjectDecoratorReturn, type A_TYPES__A_InjectDecorator_Meta, type A_TYPES__A_StageStep, type A_TYPES__A_StageStepProcessingExtraParams, A_TYPES__A_Stage_Status, type A_TYPES__AbstractionAvailableComponents, type A_TYPES__AbstractionDecoratorConfig, type A_TYPES__AbstractionDecoratorDescriptor, type A_TYPES__Abstraction_Constructor, type A_TYPES__Abstraction_Init, type A_TYPES__Abstraction_Serialized, type A_TYPES__CallerComponent, type A_TYPES__Caller_Constructor, type A_TYPES__Caller_Init, type A_TYPES__Caller_Serialized, type A_TYPES__ComponentMeta, type A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey, type A_TYPES__Component_Constructor, type A_TYPES__Component_Init, type A_TYPES__Component_Serialized, type A_TYPES__ConceptAbstraction, type A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptAbstractions, type A_TYPES__ConceptENVVariables, A_TYPES__ConceptMetaKey, type A_TYPES__Concept_Constructor, type A_TYPES__Concept_Init, type A_TYPES__Concept_Serialized, type A_TYPES__ContainerMeta, type A_TYPES__ContainerMetaExtension, A_TYPES__ContainerMetaKey, type A_TYPES__Container_Constructor, type A_TYPES__Container_Init, type A_TYPES__Container_Serialized, type A_TYPES__ContextEnvironment, type A_TYPES__Ctor, type A_TYPES__DeepPartial, type A_TYPES__Dictionary, type A_TYPES__EntityFeatureNames, A_TYPES__EntityFeatures, type A_TYPES__EntityMeta, A_TYPES__EntityMetaKey, type A_TYPES__Entity_Constructor, type A_TYPES__Entity_Init, type A_TYPES__Entity_Serialized, type A_TYPES__Error_Constructor, type A_TYPES__Error_Init, type A_TYPES__Error_Serialized, type A_TYPES__ExtractNested, type A_TYPES__ExtractProperties, type A_TYPES__FeatureAvailableComponents, type A_TYPES__FeatureAvailableConstructors, type A_TYPES__FeatureDefineDecoratorConfig, type A_TYPES__FeatureDefineDecoratorDescriptor, type A_TYPES__FeatureDefineDecoratorMeta, type A_TYPES__FeatureDefineDecoratorTarget, type A_TYPES__FeatureDefineDecoratorTemplateItem, type A_TYPES__FeatureError_Init, type A_TYPES__FeatureExtendDecoratorConfig, type A_TYPES__FeatureExtendDecoratorDescriptor, type A_TYPES__FeatureExtendDecoratorMeta, type A_TYPES__FeatureExtendDecoratorScopeConfig, type A_TYPES__FeatureExtendDecoratorScopeItem, type A_TYPES__FeatureExtendDecoratorTarget, type A_TYPES__FeatureExtendableMeta, A_TYPES__FeatureState, type A_TYPES__Feature_Constructor, type A_TYPES__Feature_Init, type A_TYPES__Feature_InitWithComponent, type A_TYPES__Feature_InitWithTemplate, type A_TYPES__Feature_Serialized, type A_TYPES__Fragment_Constructor, type A_TYPES__Fragment_Init, type A_TYPES__Fragment_Serialized, type A_TYPES__IEntity, type A_TYPES__InjectableTargets, type A_TYPES__MetaLinkedComponentConstructors, type A_TYPES__MetaLinkedComponents, type A_TYPES__Meta_Constructor, type A_TYPES__NonObjectPaths, type A_TYPES__ObjectKeyEnum, type A_TYPES__Paths, type A_TYPES__PathsToObject, type A_TYPES__Required, type A_TYPES__ScopeConfig, type A_TYPES__ScopeLinkedComponents, type A_TYPES__ScopeLinkedConstructors, type A_TYPES__Scope_Constructor, type A_TYPES__Scope_Init, type A_TYPES__Scope_Serialized, type A_TYPES__Stage_Serialized, type A_TYPES__UnionToIntersection, A_TypeGuards };
@@ -1,3 +1,3 @@
1
- var R=class{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};var be=(i=>(i.INITIALIZED="INITIALIZED",i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.INTERRUPTED="INTERRUPTED",i.FAILED="FAILED",i))(be||{});var g=class{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};var k=class{static generateTimeId(e={timestamp:new Date,random:Math.random().toString(36).slice(2,8)}){let t=e.timestamp.getTime().toString(36),r=e.random;return `${t}-${r}`}static parseTimeId(e){let[t,r]=e.split("-");return {timestamp:new Date(parseInt(t,36)),random:r}}static formatWithLeadingZeros(e,t=10){return String(e).padStart(t+1,"0").slice(-t)}static removeLeadingZeros(e){return String(Number(e))}static hashString(e){let t=0,r,n;if(e.length===0)return t.toString();for(r=0;r<e.length;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t.toString()}};var S=class o{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static isArray(e){return Array.isArray(e)}static isErrorConstructorType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&o.isString(e.aseid)}static isScopeInstance(e){return !!e&&typeof e=="object"&&"name"in e&&"aseid"in e}};var D=class D{static isASEID(e){return this.regexp.test(e)}static compare(e,t){if(!e||!t)return false;if(S.isString(e)&&this.isASEID(e)===false)throw new Error(`Invalid ASEID format provided: ${e}`);if(S.isString(t)&&this.isASEID(t)===false)throw new Error(`Invalid ASEID format provided: ${t}`);let r=e instanceof D?e:new D(e),n=t instanceof D?t:new D(t);return r.toString()===n.toString()}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||c.concept}get scope(){return this._scope||c.root.name}get entity(){return this._entity}get id(){return this._id}get version(){return this._version}get shard(){return this._shard}get hash(){return k.hashString(this.toString())}getInitializer(e){switch(true){case S.isString(e):return this.fromString;case S.isObject(e):return this.fromObject;default:throw new Error("Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[i,a,_]=r.split(":"),l=_.includes(".")?_.split(".")[0]:void 0,A=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=i||c.root.name,this._entity=a,this._id=A,this._version=n,this._shard=l;}fromObject(e){this._concept=e.concept?D.isASEID(e.concept)?new D(e.concept).id:e.concept:c.concept,this._scope=e.scope?S.isNumber(e.scope)?k.formatWithLeadingZeros(e.scope):D.isASEID(e.scope)?new D(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=S.isNumber(e.id)?k.formatWithLeadingZeros(e.id):e.id,this._version=e.version,this._shard=e.shard;}toString(){return `${this.concept}@${this.scope}:${this.entity}:${this.shard?this.shard+"."+this.id:this.id}${this.version?"@"+this.version:""}`}toJSON(){return {concept:this._concept,scope:this._scope,entity:this._entity,id:this._id,version:this._version,shard:this._shard}}verifyInput(e){switch(true){case(S.isString(e)&&!D.isASEID(e)):throw new Error("Invalid ASEID format provided");case(S.isObject(e)&&!e.id):throw new Error("ASEID id is required");case(S.isObject(e)&&!e.entity):throw new Error("ASEID entity is required")}}};D.regexp=new RegExp("^[a-z|A-Z|0-9|-]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|\\.|-]+(@v[0-9|\\.]+|@lts)?$");var C=D;var H={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},ge="If you see this error please let us know.";var re=class{static get A_CONCEPT_NAME(){return "a-concept"}static get A_CONCEPT_ROOT_SCOPE(){return "root"}static get A_CONCEPT_ENVIRONMENT(){return "development"}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "unknown"}static get A_CONCEPT_ROOT_FOLDER(){return "/app"}static get A_ERROR_DEFAULT_DESCRIPTION(){return "If you see this error please let us know."}static get(e){return this[e]}static set(e,t){this[e]=t;}static getAll(){return {}}static getAllKeys(){return []}};var Z={A_CONCEPT_NAME:"A_CONCEPT_NAME",A_CONCEPT_ROOT_SCOPE:"A_CONCEPT_ROOT_SCOPE",A_CONCEPT_ENVIRONMENT:"A_CONCEPT_ENVIRONMENT",A_CONCEPT_RUNTIME_ENVIRONMENT:"A_CONCEPT_RUNTIME_ENVIRONMENT",A_CONCEPT_ROOT_FOLDER:"A_CONCEPT_ROOT_FOLDER",A_ERROR_DEFAULT_DESCRIPTION:"A_ERROR_DEFAULT_DESCRIPTION"},ne=[Z.A_CONCEPT_NAME,Z.A_CONCEPT_ROOT_SCOPE,Z.A_CONCEPT_ENVIRONMENT,Z.A_CONCEPT_RUNTIME_ENVIRONMENT,Z.A_CONCEPT_ROOT_FOLDER,Z.A_ERROR_DEFAULT_DESCRIPTION];var O=class extends re{static get A_CONCEPT_ENVIRONMENT(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ENVIRONMENT||super.A_CONCEPT_ENVIRONMENT}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "browser"}static get A_CONCEPT_NAME(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_NAME||super.A_CONCEPT_NAME}static get A_CONCEPT_ROOT_FOLDER(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_FOLDER||super.A_CONCEPT_ROOT_FOLDER}static get A_CONCEPT_ROOT_SCOPE(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_SCOPE||super.A_CONCEPT_ROOT_SCOPE}static get A_ERROR_DEFAULT_DESCRIPTION(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_ERROR_DEFAULT_DESCRIPTION||super.A_ERROR_DEFAULT_DESCRIPTION}static get(e){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.[e]||this[e]}static set(e,t){window.__A_CONCEPT_ENVIRONMENT_ENV__||(window.__A_CONCEPT_ENVIRONMENT_ENV__={}),window.__A_CONCEPT_ENVIRONMENT_ENV__[e]=t;}static getAll(){let e={};return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e[t]=window.__A_CONCEPT_ENVIRONMENT_ENV__[t];}),ne.forEach(t=>{e[t]=this.get(t);}),e}static getAllKeys(){let e=new Set;return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e.add(t);}),ne.forEach(t=>{e.add(t);}),Array.from(e)}};var y=class o extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof o:return e;case e instanceof Error:super(e.message);break;case S.isErrorSerializedType(e):super(e.message);break;case(S.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(S.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(S.isString(e)&&!t):super(e);break;case(S.isString(e)&&!!t):super(`[${e}]: ${t}`);break;default:super("An unknown error occurred.");}this.getInitializer(e,t).call(this,e,t);}get aseid(){return this._aseid}get title(){return this._title}get message(){return super.message}get code(){return this._code||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||String(O.A_ERROR_DEFAULT_DESCRIPTION)||ge}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(S.isString(e)&&!t):return this.fromMessage;case(S.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case S.isErrorSerializedType(e):return this.fromJSON;case S.isErrorConstructorType(e):return this.fromConstructor;default:throw new o(H.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromJSON(e){this._aseid=new C(e.aseid),super.message=e.message,this._title=e.title,this._code=e.code,this._scope=e.scope,this._description=e.description,this._originalError=e.originalError?new o(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromConstructor(e){if(this.validateTitle(e.title),this._title=e.title,this._code=e.code,this._scope=e.scope?S.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._description=e.description,this._link=e.link,e.originalError instanceof o){let t=e.originalError;for(;t.originalError instanceof o;)t=t.originalError;this._originalError=t.originalError||t;}else this._originalError=e.originalError;}toJSON(){return {aseid:this.aseid.toString(),title:this.title,code:this.code,type:this.type,message:this.message,link:this.link,scope:this.scope,description:this.description,originalError:this.originalError?.message}}validateTitle(e){if(e.length>60)throw new o(H.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new o(H.VALIDATION_ERROR,"A-Error title cannot be empty.")}};var K=class extends y{};K.ValidationError="A-Entity Validation Error";var v=class{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e){this.getInitializer(e).call(this,e);}get id(){return this.aseid.id}isStringASEID(e){return typeof e=="string"&&C.isASEID(e)}isASEIDInstance(e){return e instanceof C}isSerializedObject(e){return !!e&&typeof e=="object"&&"aseid"in e}isConstructorProps(e){return !!e&&typeof e=="object"&&!("aseid"in e)}getInitializer(e){if(!e)return this.fromUndefined;if(this.isStringASEID(e))return this.fromASEID;if(this.isASEIDInstance(e))return this.fromASEID;if(this.isSerializedObject(e))return this.fromJSON;if(this.isConstructorProps(e))return this.fromNew;throw new K(K.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new C({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||k.generateTimeId()})}async call(e,t){return await new I({name:e,component:this,scope:t}).process(t)}async load(e){return this.call("load",e)}async destroy(e){return this.call("destroy",e)}async save(e){return this.call("save",e)}fromASEID(e){e instanceof C?this.aseid=e:this.aseid=new C(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new C(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};function oe(o){return function(e){return c.setMeta(e,new o),e}}var d=class o{constructor(){this.meta=new Map;}static Define(e){return oe(e)}[Symbol.iterator](){let e=this.meta.entries();return {next:()=>e.next()}}from(e){return this.meta=new Map(e.meta),this}clone(){let e=this.constructor,t=new e;return t.meta=new Map(this.meta),t}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof o:return e.toJSON();case e instanceof Map:let t={};for(let[n,i]of e.entries())t[String(n)]=this.recursiveToJSON(i);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,i]of Object.entries(e))r[n]=this.recursiveToJSON(i);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};var Ce=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(Ce||{}),Ye=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(Ye||{});var z=class extends d{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};var j=class{get name(){return this.config?.name||this.constructor.name}get scope(){return c.scope(this)}constructor(e={}){this.config=e,c.allocate(this,this.config);}async call(e,t){return await new I({name:e,component:this}).process(t)}};var Pe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Pe||{});var U=class extends d{injections(e){return this.get("a-container-injections")?.get(e)||[]}features(){return this.get("a-container-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-container-abstractions"),n=this.get("a-container-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,a])=>{a.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,i])=>{i.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}};var m=class extends y{fromConstructor(e){super.fromConstructor(e),this.stage=e.stage;}};m.Interruption="Feature Interrupted",m.FeatureInitializationError="Unable to initialize A-Feature",m.FeatureProcessingError="Error occurred during A-Feature processing",m.FeatureDefinitionError="Unable to define A-Feature",m.FeatureExtensionError="Unable to extend A-Feature";var u=class{static resolve(){return new Promise(e=>e())}static isInheritedFrom(e,t){let r=e;for(;r;){if(r===t)return true;r=Object.getPrototypeOf(r);}return false}static getParentClasses(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=[];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getClassInheritanceChain(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=typeof e=="function"?[e]:[e.constructor];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getParentClass(e){return Object.getPrototypeOf(e)}static omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(i,a){let _=a[0];a.length===1?delete i[_]:i[_]!==void 0&&typeof i[_]=="object"&&n(i[_],a.slice(1));}return t.forEach(i=>{let a=i.split(".");n(r,a);}),r}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static deepMerge(e,t,r=new Map){if(this.isObject(e)&&this.isObject(t))for(let n in t)this.isObject(t[n])?(e[n]||(e[n]={}),r.has(t[n])?e[n]=r.get(t[n]):(r.set(t[n],{}),this.deepMerge(e[n],t[n],r))):e[n]=t[n];return e}static deepClone(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(t=>this.deepClone(t));if(typeof e=="function")return e;if(e instanceof Object){let t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=this.deepClone(e[r]));return t}throw new Error("Unable to clone the object. Unsupported type.")}static deepCloneAndMerge(e,t){if(t==null&&e==null)return e;if(e==null&&t)return this.deepClone(t);if(typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(r=>this.deepCloneAndMerge(r,t));if(typeof e=="function")return e;if(e instanceof Object){let r={};for(let n in e)t[n]!==null&&t[n]!==void 0?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(e[n]);for(let n in t)e[n]!==void 0&&e[n]!==null?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(t[n]);return r}throw new Error("Unable to clone the object. Unsupported type.")}static getComponentName(e){let t="Unknown",r="Anonymous";if(e==null)return t;if(typeof e=="string")return e||t;if(typeof e=="symbol")try{return e.toString()}catch{return t}if(Array.isArray(e))return e.length===0?t:this.getComponentName(e[0]);if(typeof e=="function"){let n=e;if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name)return String(n.constructor.name);try{let a=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(a)return a[1]||a[2]||a[3]||r}catch{}return r}if(typeof e=="object"){let n=e;if(n.type)return this.getComponentName(n.type);if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name&&n.constructor.name!=="Object")return String(n.constructor.name);try{let i=n.toString();if(typeof i=="string"&&i!=="[object Object]")return i}catch{}return r}try{return String(e)}catch{return t}}};var q=class extends Error{};q.CallerInitializationError="Unable to initialize A-Caller";var V=class{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!s.isAllowedForFeatureCall(e))throw new q(`[${q.CallerInitializationError}]: Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};var f=class extends y{};f.InvalidDependencyTarget="Invalid Dependency Target",f.InvalidLoadTarget="Invalid Load Target",f.InvalidLoadPath="Invalid Load Path",f.InvalidDefaultTarget="Invalid Default Target",f.ResolutionParametersError="Dependency Resolution Parameters Error";function ie(...o){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,l=_.get(i)||[];l[r].resolutionStrategy={create:true,args:o},_.set(i,l),c.meta(e).set(a,_);}}function se(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={flat:true},a.set(n,_),c.meta(o).set(i,a);}}function ae(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={load:true},a.set(n,_),c.meta(o).set(i,a);}}function _e(o=-1){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,l=_.get(i)||[];l[r].resolutionStrategy={parent:o},_.set(i,l),c.meta(e).set(a,_);}}function ce(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={require:true},a.set(n,_),c.meta(o).set(i,a);}}function pe(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={pagination:{..._[t].resolutionStrategy.pagination,count:-1}},a.set(n,_),c.meta(o).set(i,a);}}function ue(o,e){return function(t,r,n){let i=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof t} (${i})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,A=l.get(a)||[];A[n].resolutionStrategy={query:{...A[n].resolutionStrategy.query,...o},pagination:{...A[n].resolutionStrategy.pagination,...e}},l.set(a,A),c.meta(t).set(_,l);}}var Y=class{constructor(e,t){this._defaultPagination={count:1,from:"start"};this._defaultResolutionStrategy={require:false,load:false,parent:0,flat:false,create:false,args:[],query:{},pagination:this._defaultPagination};this._name=typeof e=="string"?e:u.getComponentName(e),this._target=typeof e=="string"?void 0:e,this.resolutionStrategy=t||{},this.initCheck();}static get Required(){return ce}static get Loaded(){return ae}static get Default(){return ie}static get Parent(){return _e}static get Flat(){return se}static get All(){return pe}static get Query(){return ue}get flat(){return this._resolutionStrategy.flat}get require(){return this._resolutionStrategy.require}get load(){return this._resolutionStrategy.load}get all(){return this._resolutionStrategy.pagination.count!==1||Object.keys(this._resolutionStrategy.query).length>0}get parent(){return this._resolutionStrategy.parent}get create(){return this._resolutionStrategy.create}get args(){return this._resolutionStrategy.args}get query(){return this._resolutionStrategy.query}get pagination(){return this._resolutionStrategy.pagination}get name(){return this._name}get target(){return this._target}get resolutionStrategy(){return this._resolutionStrategy}set resolutionStrategy(e){this._resolutionStrategy={...this._defaultResolutionStrategy,...this._resolutionStrategy,...e,pagination:{...this._defaultPagination,...(this._resolutionStrategy||{}).pagination,...e.pagination||{}}};}initCheck(){if(!this._resolutionStrategy)throw new f(f.ResolutionParametersError,`Resolution strategy parameters are not provided for dependency: ${this._name}`);return this}toJSON(){return {name:this._name,all:this.all,require:this.require,load:this.load,parent:this.parent,flat:this.flat,create:this.create,args:this.args,query:this.query,pagination:this.pagination}}};var s=class o{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isArray(e){return Array.isArray(e)}static isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static isFunction(e){return typeof e=="function"}static isUndefined(e){return typeof e>"u"}static isRegExp(e){return e instanceof RegExp}static isContainerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,j)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,w)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Error)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,I)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,V)}static isDependencyConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isDependencyInstance(e){return e instanceof Y}static isContainerInstance(e){return e instanceof j}static isComponentInstance(e){return e instanceof w}static isFeatureInstance(e){return e instanceof I}static isFragmentInstance(e){return e instanceof R}static isEntityInstance(e){return e instanceof v}static isScopeInstance(e){return e instanceof x}static isErrorInstance(e){return e instanceof Error}static isComponentMetaInstance(e){return e instanceof N}static isContainerMetaInstance(e){return e instanceof U}static isEntityMetaInstance(e){return e instanceof z}static hasASEID(e){return e&&typeof e=="object"&&"aseid"in e&&(o.isEntityInstance(e)||o.isErrorInstance(e))}static isConstructorAllowedForScopeAllocation(e){return o.isContainerConstructor(e)||o.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return o.isContainerInstance(e)||o.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return o.isContainerInstance(e)||o.isComponentInstance(e)}static isTargetAvailableForInjection(e){return o.isComponentConstructor(e)||o.isComponentInstance(e)||o.isContainerInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureCall(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return o.isComponentInstance(e)||o.isContainerInstance(e)||o.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return o.isContainerInstance(e)||o.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return o.isFragmentConstructor(e)||u.isInheritedFrom(e,R)||o.isEntityConstructor(e)||u.isInheritedFrom(e,v)}static isErrorConstructorType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&C.isASEID(e.aseid)}static isPromiseInstance(e){return e instanceof Promise}};function le(o={}){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureDefinition(e))throw new m(m.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let i=c.meta(e.constructor),a;switch(true){case s.isEntityInstance(e):a="a-component-features";break;case s.isContainerInstance(e):a="a-container-features";break;case s.isComponentInstance(e):a="a-component-features";break}let _=i.get(a)||new d,l=o.name||t,A=o.invoke||false;_.set(t,{name:`${e.constructor.name}.${l}`,handler:t,invoke:A,template:o.template&&o.template.length?o.template.map(h=>({...h,before:h.before||"",after:h.after||"",behavior:h.behavior||"sync",throwOnError:true,override:h.override||""})):[]}),c.meta(e.constructor).set(a,_);let T=r.value;return r.value=function(...h){if(A)T.apply(this,h);else return T.apply(this,h);if(typeof this.call=="function"&&A)return this.call(l)},r}}function Ae(o){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureExtension(e))throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let i,a="sync",_="",l="",A="",T=[],h=[],b=true,F;switch(true){case s.isEntityInstance(e):F="a-component-extensions";break;case s.isContainerInstance(e):F="a-container-extensions";break;case s.isComponentInstance(e):F="a-component-extensions";break}switch(true){case s.isRegExp(o):i=o;break;case(!!o&&typeof o=="object"):Array.isArray(o.scope)?T=o.scope:o.scope&&typeof o.scope=="object"&&(Array.isArray(o.scope.include)&&(T=o.scope.include),Array.isArray(o.scope.exclude)&&(h=o.scope.exclude)),i=we(o,T,h,t),a=o.behavior||a,b=o.throwOnError!==void 0?o.throwOnError:b,_=s.isArray(o.before)?new RegExp(`^${o.before.join("|").replace(/\./g,"\\.")}$`).source:o.before instanceof RegExp?o.before.source:"",l=s.isArray(o.after)?new RegExp(`^${o.after.join("|").replace(/\./g,"\\.")}$`).source:o.after instanceof RegExp?o.after.source:"",A=s.isArray(o.override)?new RegExp(`^${o.override.join("|").replace(/\./g,"\\.")}$`).source:o.override instanceof RegExp?o.override.source:"";break;default:i=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let J=c.meta(e).get(F),Te=c.meta(e),G=Te.get(F)?new d().from(Te.get(F)):new d;if(J&&J.size()&&J.has(t)&&J.get(t).invoke)throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be used on the method "${t}" because it is already defined as a Feature with "invoke" set to true. Please remove the A-Feature-Extend decorator or set "invoke" to false in the A-Feature decorator.`);let ee=[...G.get(i.source)||[]];for(let[Q,te]of G.entries()){let he=te.findIndex(Ie=>Ie.handler===t);Q!==i.source&&he!==-1&&(te.splice(he,1),te.length===0?G.delete(Q):G.set(Q,te));}let Se=ee.findIndex(Q=>Q.handler===t),ye={name:i.source,handler:t,behavior:a,before:_,after:l,throwOnError:b,override:A};Se!==-1?ee[Se]=ye:ee.push(ye),G.set(i.source,ee),c.meta(e).set(F,G);}}function we(o,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",i=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",a=o.scope?`^${i}${n}\\.${o.name||r}$`:`.*\\.${o.name||r}$`;return new RegExp(a)}var xe=(a=>(a.PROCESSING="PROCESSING",a.COMPLETED="COMPLETED",a.FAILED="FAILED",a.SKIPPED="SKIPPED",a.INITIALIZED="INITIALIZED",a.ABORTED="ABORTED",a))(xe||{});var $=class extends y{static get CompileError(){return "Unable to compile A-Stage"}};$.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var X=class{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}getStepArgs(e,t){let r=t.dependency.target||e.resolveConstructor(t.dependency.name);return c.meta(r).injections(t.handler).map(n=>{switch(true){case s.isCallerConstructor(n.target):return this._feature.caller.component;case s.isFeatureConstructor(n.target):return this._feature;default:return e.resolve(n)}})}getStepComponent(e,t){let{dependency:r,handler:n}=t,i=e.resolve(r)||this.feature.scope.resolve(r);if(!i)throw new $($.CompileError,`Unable to resolve component ${r.name} from scope ${e.name}`);if(!i[n])throw new $($.CompileError,`Handler ${n} not found in ${i.constructor.name}`);return i}callStepHandler(e,t){let r=this.getStepComponent(t,e),n=this.getStepArgs(t,e);return {handler:r[e.handler].bind(r),params:n}}skip(){this._status="SKIPPED";}process(e){let t=s.isScopeInstance(e)?e:this._feature.scope;if(!this.isProcessed){this._status="PROCESSING";let{handler:r,params:n}=this.callStepHandler(this._definition,t),i=r(...n);if(s.isPromiseInstance(i))return new Promise(async(a,_)=>{try{return await i,this.completed(),a()}catch(l){let A=new y(l);return this.failed(A),this._definition.throwOnError?a():_(A)}});this.completed();}}completed(){this._status="COMPLETED";}failed(e){this._error=new y(e),this._status="FAILED";}toJSON(){return {name:this.name,status:this.status}}toString(){return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`}};var B=class extends y{};B.CircularDependencyError="A-StepManager Circular Dependency Error";var W=class{constructor(e){this._isBuilt=false;this.entities=this.prepareSteps(e),this.graph=new Map,this.visited=new Set,this.tempMark=new Set,this.sortedEntities=[];}prepareSteps(e){return e.map(t=>({...t,behavior:t.behavior||"sync",before:t.before||"",after:t.after||"",override:t.override||"",throwOnError:false}))}ID(e){return `${e.dependency.name}.${e.handler}`}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some(n=>n.override?new RegExp(n.override).test(this.ID(e)):false)),this.entities.forEach(e=>this.graph.set(this.ID(e),new Set)),this.entities.forEach(e=>{let t=this.ID(e);e.before&&this.matchEntities(t,e.before).forEach(n=>{this.graph.has(n)||this.graph.set(n,new Set),this.graph.get(n).add(t);}),e.after&&this.matchEntities(t,e.after).forEach(n=>{this.graph.has(t)||this.graph.set(t,new Set),this.graph.get(t).add(n);});}));}matchEntities(e,t){let r=new RegExp(t);return this.entities.filter(n=>r.test(this.ID(n))&&this.ID(n)!==e).map(n=>this.ID(n))}visit(e){this.tempMark.has(e)||this.visited.has(e)||(this.tempMark.add(e),(this.graph.get(e)||[]).forEach(t=>this.visit(t)),this.tempMark.delete(e),this.visited.add(e),this.sortedEntities.push(e));}toSortedArray(){return this.buildGraph(),this.entities.forEach(e=>{this.visited.has(this.ID(e))||this.visit(this.ID(e));}),this.sortedEntities}toStages(e){return this.toSortedArray().map(r=>{let n=this.entities.find(i=>this.ID(i)===r);return new X(e,n)})}};var I=class o{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return le}static get Extend(){return Ae}get name(){return this._name}get error(){return this._error}get state(){return this._state}get index(){return this._index}get stage(){return this._current}get caller(){return this._caller}get scope(){return c.scope(this)}get size(){return this._stages.length}get isDone(){return !this.stage||this._index>=this._stages.length}get isProcessed(){return this.state==="COMPLETED"||this.state==="FAILED"||this.state==="INTERRUPTED"}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._stages[this._index],this._index++,{value:this._current,done:false})}}validateParams(e){if(!e||typeof e!="object")throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}getInitializer(e){switch(true){case !("template"in e):return this.fromComponent;case "template"in e:return this.fromTemplate;default:throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}}fromTemplate(e){if(!e.template||!Array.isArray(e.template))throw new m(m.FeatureInitializationError,`Invalid A-Feature template provided of type: ${typeof e.template} with value: ${JSON.stringify(e.template).slice(0,100)}...`);if(!e.component&&(!e.scope||!(e.scope instanceof x)))throw new m(m.FeatureInitializationError,`Invalid A-Feature scope provided of type: ${typeof e.scope} with value: ${JSON.stringify(e.scope).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{e.component&&(t=c.scope(e.component));}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new W(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!s.isAllowedForFeatureDefinition(e.component))throw new m(m.FeatureInitializationError,`Invalid A-Feature component provided of type: ${typeof e.component} with value: ${JSON.stringify(e.component).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{t=c.scope(e.component);}catch(a){if(!r)throw a}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component);let n=c.allocate(this);n.inherit(t||r);let i=c.featureTemplate(this._name,this._caller.component,n);this._SM=new W(i),this._stages=this._SM.toStages(this),this._current=this._stages[0];}process(e){try{if(this.isProcessed)return;this._state="PROCESSING";let t=Array.from(this);return this.processStagesSequentially(t,e,0)}catch(t){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:t}))}}processStagesSequentially(e,t,r){try{if(this.state==="INTERRUPTED")return;if(r>=e.length){this.completed();return}let n=e[r],i=n.process(t);return s.isPromiseInstance(i)?i.then(()=>{if(this.state!=="INTERRUPTED")return this.processStagesSequentially(e,t,r+1)}).catch(a=>{throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${n.name}.`,stage:n,originalError:a}))}):this.processStagesSequentially(e,t,r+1)}catch(n){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:n}))}}next(e){let t=this._stages.indexOf(e);this._index=t+1,this._index>=this._stages.length&&this.completed();}completed(){this.isProcessed||this.state!=="INTERRUPTED"&&(this._state="COMPLETED",this.scope.destroy());}failed(e){return this.isProcessed?this._error:(this._state="FAILED",this._error=e,this.scope.destroy(),this._error)}interrupt(e){if(this.isProcessed)return this._error;switch(this._state="INTERRUPTED",true){case s.isString(e):this._error=new m(m.Interruption,e);break;case s.isErrorInstance(e):this._error=new m({code:m.Interruption,title:e.title||"Feature Interrupted",description:e.description||e.message,stage:this.stage,originalError:e});break;default:this._error=new m(m.Interruption,"Feature was interrupted");break}return this.scope.destroy(),this._error}chain(e,t,r){let n,i;e instanceof o?(n=e,i=t instanceof x?t:void 0):(n=new o({name:t,component:e}),i=r instanceof x?r:void 0);let a=i||this.scope;n._caller=this._caller;let _=n.process(a);return s.isPromiseInstance(_)?_.catch(l=>{throw l}):_}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};var w=class{call(e,t){return new I({name:e,component:this}).process(t)}};var de=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(de||{});var N=class extends d{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,i])=>{i.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-component-abstractions"),n=this.get("a-component-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,a])=>{a.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}};var x=class{constructor(e,t){this._meta=new d;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this._imports=new Set;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get imports(){return Array.from(this._imports.values())}get parent(){return this._parent}*parents(){let e=this._parent;for(;e;)yield e,e=e._parent;}parentOffset(e){let t=this;for(;e<=-1&&t;)t=t.parent,e++;return t}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new E(E.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>c.deregister(e)),this._fragments.forEach(e=>c.deregister(e)),this._entities.forEach(e=>c.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this._imports.clear(),this.issuer()&&c.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return c.issuer(this)}inherit(e){if(!e)throw new E(E.InitializationError,"Invalid parent scope provided");if(e===this)throw new E(E.CircularInheritanceError,`Unable to inherit scope ${this.name} from itself`);if(e===this._parent)return this;let t=this.checkCircularInheritance(e);if(t)throw new E(E.CircularInheritanceError,`Circular inheritance detected: ${[...t,e.name].join(" -> ")}`);return this._parent=e,this}import(...e){return e.forEach(t=>{if(t===this)throw new E(E.CircularImportError,`Unable to import scope ${this.name} into itself`);this._imports.has(t)||this._imports.add(t);}),this}deimport(...e){return e.forEach(t=>{this._imports.has(t)&&this._imports.delete(t);}),this}has(e){let t=this.hasFlat(e);if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}hasFlat(e){let t=false;switch(true){case s.isScopeConstructor(e):return true;case s.isString(e):{Array.from(this.allowedComponents).find(_=>_.name===e)&&(t=true),Array.from(this.allowedFragments).find(_=>_.name===e)&&(t=true),Array.from(this.allowedEntities).find(_=>_.name===e)&&(t=true),Array.from(this.allowedErrors).find(_=>_.name===e)&&(t=true);break}case s.isComponentConstructor(e):{t=this.isAllowedComponent(e)||!![...this.allowedComponents].find(r=>u.isInheritedFrom(r,e));break}case s.isEntityConstructor(e):{t=this.isAllowedEntity(e)||!![...this.allowedEntities].find(r=>u.isInheritedFrom(r,e));break}case s.isFragmentConstructor(e):{t=this.isAllowedFragment(e)||!![...this.allowedFragments].find(r=>u.isInheritedFrom(r,e));break}case s.isErrorConstructor(e):{t=this.isAllowedError(e)||!![...this.allowedErrors].find(r=>u.isInheritedFrom(r,e));break}case(this.issuer()&&(this.issuer().constructor===e||u.isInheritedFrom(this.issuer().constructor,e))):{t=true;break}}return t}resolveDependency(e){let t=[],r=this.parentOffset(e.parent)||this;switch(true){case(e.flat&&!e.all):{let A=r.resolveFlatOnce(e.target||e.name);A&&(t=[A]);break}case(e.flat&&e.all):{t=r.resolveFlatAll(e.target||e.name);break}case(!e.flat&&!e.all):{let A=r.resolveOnce(e.target||e.name);A&&(t=[A]);break}case(!e.flat&&e.all):{t=r.resolveAll(e.target||e.name);break}default:t=[];}if(e.create&&!t.length&&s.isAllowedForDependencyDefaultCreation(e.target)){let A=new e.target(...e.args);r.register(A),t.push(A);}if(e.require&&!t.length)throw new E(E.ResolutionError,`Dependency ${e.name} is required but could not be resolved in scope ${r.name}`);e.query.aseid?t=t.filter(A=>s.hasASEID(A)&&C.compare(A.aseid,e.query.aseid)):Object.keys(e.query).length>0&&(t=t.filter(A=>{let T=e.query;return T?Object.entries(T).every(([h,b])=>A[h]===b):true}));let n=e.pagination.count,i=e.pagination.from,a=i==="end"?n===-1?0:Math.max(t.length-n,0):0,_=i==="end"||n===-1?t.length:Math.min(n,t.length),l=t.slice(a,_);return l.length===1&&n!==-1?l[0]:l.length?l:void 0}resolveConstructor(e){switch(true){case s.isComponentConstructor(e):return Array.from(this.allowedComponents).find(i=>u.isInheritedFrom(i,e));case s.isEntityConstructor(e):return Array.from(this.allowedEntities).find(i=>u.isInheritedFrom(i,e));case s.isFragmentConstructor(e):return Array.from(this.allowedFragments).find(i=>u.isInheritedFrom(i,e));case s.isErrorConstructor(e):return Array.from(this.allowedErrors).find(i=>u.isInheritedFrom(i,e))}if(!s.isString(e))throw new E(E.ResolutionError,`Invalid constructor name provided: ${e}`);let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===g.toPascalCase(e));if(t)return t;{let i=Array.from(this.allowedComponents).find(a=>{let _=a;for(;_;){if(_.name===e||_.name===g.toPascalCase(e))return true;_=Object.getPrototypeOf(_);}return false});if(i)return i}let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.entity===e||i.entity===g.toKebabCase(e));if(r)return r;{let i=Array.from(this.allowedEntities).find(a=>u.isInheritedFrom(a,e));if(i)return i}let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===g.toPascalCase(e));if(n)return n;{let i=Array.from(this.allowedFragments).find(a=>u.isInheritedFrom(a,e));if(i)return i}for(let i of this._imports){let a=i.resolveConstructor(e);if(a)return a}if(this._parent)return this._parent.resolveConstructor(e)}resolveAll(e){let t=new Set;this.resolveFlatAll(e).forEach(i=>t.add(i)),this._imports.forEach(i=>{i.has(e)&&i.resolveFlatAll(e).forEach(_=>t.add(_));});let n=this._parent;for(;n&&n.has(e);)n.resolveAll(e).forEach(a=>t.add(a)),n=n._parent;return Array.from(t)}resolveFlatAll(e){let t=[];switch(true){case s.isComponentConstructor(e):{this.allowedComponents.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isFragmentConstructor(e):{this.allowedFragments.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isEntityConstructor(e):{this.entities.forEach(r=>{u.isInheritedFrom(r.constructor,e)&&t.push(r);});break}case s.isString(e):{let r=this.resolveConstructor(e);if(!s.isComponentConstructor(r)&&!s.isEntityConstructor(r)&&!s.isFragmentConstructor(r))throw new E(E.ResolutionError,`Unable to resolve all instances for name: ${e} in scope ${this.name} as no matching component, entity or fragment constructor found`);if(r){let n=this.resolveAll(r);n&&t.push(...n);}break}default:throw new E(E.ResolutionError,`Invalid parameter provided to resolveAll method: ${e} in scope ${this.name}`)}return t}resolve(e){let t=s.isDependencyInstance(e)?e:new Y(e);return this.resolveDependency(t)}resolveOnce(e){let t=this.resolveFlatOnce(e);if(!t){for(let r of this._imports)if(r.has(e)){let n=r.resolveFlatOnce(e);if(n)return n}}return !t&&this.parent?this.parent.resolveOnce(e):t}resolveFlat(e){return this.resolveFlatOnce(e)}resolveFlatOnce(e){let t,r=u.getComponentName(e);if(!(!e||!this.has(e))){switch(true){case s.isString(e):{t=this.resolveByName(e);break}case s.isConstructorAllowedForScopeAllocation(e):{t=this.resolveIssuer(e);break}case s.isScopeConstructor(e):{t=this.resolveScope(e);break}case s.isEntityConstructor(e):{t=this.resolveEntity(e);break}case s.isFragmentConstructor(e):{t=this.resolveFragment(e);break}case s.isComponentConstructor(e):{t=this.resolveComponent(e);break}case s.isErrorConstructor(e):{t=this.resolveError(e);break}default:throw new E(E.ResolutionError,`Injected Component ${r} not found in the scope`)}return t}}resolveByName(e){let t=Array.from(this.allowedComponents).find(a=>a.name===e||a.name===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.entity===e||a.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(a=>a.name===e||a.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let i=Array.from(this.allowedErrors).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.code===e||a.code===g.toKebabCase(e));if(i)return this.resolveOnce(i)}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t}resolveEntity(e){return this.entities.find(t=>t instanceof e)}resolveError(e){return this.errors.find(t=>t instanceof e)}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}default:return}}resolveScope(e){return this}resolveComponent(e){switch(true){case(this.allowedComponents.has(e)&&this._components.has(e)):return this._components.get(e);case(this.allowedComponents.has(e)&&!this._components.has(e)):{let n=(c.meta(e).get("a-component-injections")?.get("constructor")||[]).map(a=>this.resolve(a)),i=new e(...n);return this.register(i),this._components.get(e)}case(!this.allowedComponents.has(e)&&Array.from(this.allowedComponents).some(t=>u.isInheritedFrom(t,e))):{let t=Array.from(this.allowedComponents).find(r=>u.isInheritedFrom(r,e));return this.resolveComponent(t)}default:return}}register(e){switch(true){case e instanceof w:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e);break}case(s.isEntityInstance(e)&&!this._entities.has(e.aseid.toString())):{this.allowedEntities.has(e.constructor)||this.allowedEntities.add(e.constructor),this._entities.set(e.aseid.toString(),e),c.register(this,e);break}case s.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),c.register(this,e);break}case s.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),c.register(this,e);break}case s.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case s.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case s.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof v)throw new E(E.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof R)throw new E(E.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new E(E.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof w:{this._components.delete(e.constructor),c.deregister(e);let r=e.constructor;this._components.has(r)||this.allowedComponents.delete(r);break}case s.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),c.deregister(e);let r=e.constructor;Array.from(this._entities.values()).some(i=>i instanceof r)||this.allowedEntities.delete(r);break}case s.isFragmentInstance(e):{this._fragments.delete(e.constructor),c.deregister(e);let r=e.constructor;Array.from(this._fragments.values()).some(i=>i instanceof r)||this.allowedFragments.delete(r);break}case s.isErrorInstance(e):{this._errors.delete(e.code),c.deregister(e);let r=e.constructor;Array.from(this._errors.values()).some(i=>i instanceof r)||this.allowedErrors.delete(r);break}case s.isComponentConstructor(e):{this.allowedComponents.delete(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.delete(e),Array.from(this._fragments.entries()).forEach(([r,n])=>{u.isInheritedFrom(r,e)&&(this._fragments.delete(r),c.deregister(n));});break}case s.isEntityConstructor(e):{this.allowedEntities.delete(e),Array.from(this._entities.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._entities.delete(r),c.deregister(n));});break}case s.isErrorConstructor(e):{this.allowedErrors.delete(e),Array.from(this._errors.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._errors.delete(r),c.deregister(n));});break}default:let t=u.getComponentName(e);throw new E(E.DeregistrationError,`Cannot deregister ${t} from the scope ${this.name}`)}}toJSON(){return this.fragments.reduce((e,t)=>{let r=t.toJSON();return {...e,[r.name]:r}},{})}isAllowedComponent(e){return s.isComponentConstructor(e)&&this.allowedComponents.has(e)}isAllowedEntity(e){return s.isEntityConstructor(e)&&this.allowedEntities.has(e)}isAllowedFragment(e){return s.isFragmentConstructor(e)&&this.allowedFragments.has(e)}isAllowedError(e){return s.isErrorConstructor(e)&&this.allowedErrors.has(e)}isInheritedFrom(e){let t=this;for(;t;){if(t===e)return true;t=t._parent;}return false}checkCircularInheritance(e){let t=[],r=this._parent;for(;r;){if(t.push(r.name),r===e)return t;r=r._parent;}return false}printInheritanceChain(){let e=[],t=this;for(;t;)e.push(t.name),t=t._parent;console.log(e.join(" -> "));}};var E=class extends y{};E.InitializationError="A-Scope Initialization Error",E.ConstructorError="Unable to construct A-Scope instance",E.ResolutionError="A-Scope Resolution Error",E.RegistrationError="A-Scope Registration Error",E.CircularInheritanceError="A-Scope Circular Inheritance Error",E.CircularImportError="A-Scope Circular Import Error",E.DeregistrationError="A-Scope Deregistration Error";var p=class extends y{};p.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",p.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",p.InvalidMetaParameterError="Invalid parameter provided to get meta",p.InvalidScopeParameterError="Invalid parameter provided to get scope",p.ScopeNotFoundError="Scope not found",p.InvalidFeatureParameterError="Invalid parameter provided to get feature",p.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",p.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",p.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",p.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",p.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",p.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",p.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",p.InvalidInjectionParameterError="Invalid parameter provided to get injections",p.InvalidExtensionParameterError="Invalid parameter provided to get extensions",p.InvalidRegisterParameterError="Invalid parameter provided to register component",p.InvalidComponentParameterError="Invalid component provided",p.ComponentNotRegisteredError="Component not registered in the context",p.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var c=class o{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;this._globals=new Map;let e=String(O.A_CONCEPT_ROOT_SCOPE)||"root";this._root=new x({name:e});}static get concept(){return O.A_CONCEPT_NAME||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){return O.A_CONCEPT_RUNTIME_ENVIRONMENT}static getInstance(){return o._instance||(o._instance=new o),o._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new p(p.NotAllowedForScopeAllocationError,`Component ${r} is not allowed for scope allocation.`);return n._scopeStorage.set(t,e),e}static deregister(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new p(p.ComponentNotRegisteredError,`Unable to deregister component. Component ${t} is not registered.`);r._scopeStorage.delete(e);}static allocate(e,t){let r=u.getComponentName(e);if(!this.isAllowedForScopeAllocation(e))throw new p(p.NotAllowedForScopeAllocationError,`Component of type ${r} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);let n=this.getInstance();if(n._registry.has(e))throw new p(p.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let i=s.isScopeInstance(t)?t:new x(t||{name:r+"-scope"},t);return i.isInheritedFrom(o.root)||i.inherit(o.root),n._registry.set(e,i),n._scopeIssuers.set(i,e),i}static deallocate(e){let t=this.getInstance(),r=s.isScopeInstance(e)?e:t._registry.get(e);if(!r)return;let n=s.isComponentInstance(e)?e:this.issuer(r);n&&t._registry.delete(n),r&&t._scopeIssuers.delete(r);}static meta(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidMetaParameterError,"Invalid parameter provided to get meta. Parameter cannot be null or undefined.");if(!(this.isAllowedForMeta(e)||this.isAllowedForMetaConstructor(e)||s.isString(e)||s.isFunction(e)))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component of type ${t} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);let n,i;switch(true){case s.isContainerInstance(e):{n=e.constructor,i=U;break}case s.isContainerConstructor(e):{n=e,i=U;break}case s.isComponentInstance(e):{n=e.constructor,i=N;break}case s.isComponentConstructor(e):{n=e,i=N;break}case s.isEntityInstance(e):{n=e.constructor,i=N;break}case s.isEntityConstructor(e):{n=e,i=z;break}case s.isFragmentInstance(e):{n=e.constructor,i=N;break}case s.isFragmentConstructor(e):{n=e,i=z;break}case typeof e=="string":{let a=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===g.toKebabCase(e)||_.name===g.toPascalCase(e));if(!(a&&a.length))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=a[0],i=N;break}default:{n=e,i=d;break}}if(!r._metaStorage.has(n)){let a,_=n;for(;!a;){let l=Object.getPrototypeOf(_);if(!l)break;a=r._metaStorage.get(l),_=l;}a||(a=new i),r._metaStorage.set(n,a.clone());}return r._metaStorage.get(n)}static setMeta(e,t){let r=o.getInstance(),n=o.meta(e),i=typeof e=="function"?e:e.constructor;r._metaStorage.set(i,n?t.from(n):t);}static issuer(e){let t=this.getInstance();if(!e)throw new p(p.InvalidComponentParameterError,"Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.");return t._scopeIssuers.get(e)}static scope(e){let t=e?.constructor?.name||String(e),r=this.getInstance();if(!e)throw new p(p.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed for scope allocation.`);switch(true){case this.isAllowedToBeRegistered(e):if(!r._scopeStorage.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`);return r._scopeStorage.get(e);case this.isAllowedForScopeAllocation(e):if(!r._registry.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`);return r._registry.get(e);default:throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed to be registered.`)}}static featureTemplate(e,t,r=this.scope(t)){let n=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureTemplateParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);return [...this.featureDefinition(e,t),...this.featureExtensions(e,t,r)]}static featureExtensions(e,t,r){let n=this.getInstance(),i=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${i} is not allowed for feature definition.`);let a=u.getClassInheritanceChain(t).filter(A=>A!==w&&A!==j&&A!==v).map(A=>`${A.name}.${e}`),_=new Map,l=new Set;for(let A of a)for(let[T,h]of n._metaStorage)r.has(T)&&(s.isComponentMetaInstance(h)||s.isContainerMetaInstance(h))&&(l.add(T),h.extensions(A).forEach(b=>{let F=Array.from(l).reverse().find(J=>u.isInheritedFrom(T,J)&&J!==T);F&&_.delete(`${u.getComponentName(F)}.${b.handler}`),_.set(`${u.getComponentName(T)}.${b.handler}`,{dependency:new Y(T),...b});}));return n.filterToMostDerived(r,Array.from(_.values()))}filterToMostDerived(e,t){return t.filter(r=>{let n=e.resolveConstructor(r.dependency.name);return !t.some(a=>{if(a===r)return false;let _=e.resolveConstructor(a.dependency.name);return !n||!_?false:n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");switch(true){case t instanceof v:r="a-component-features";break;case t instanceof j:r="a-container-features";break;case t instanceof w:r="a-component-features";break;default:throw new p(p.InvalidFeatureTemplateParameterError,`A-Feature cannot be defined on the ${t} level`)}return [...this.meta(t)?.get(r)?.get(e)?.template||[]]}static abstractionTemplate(e,t){let r=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionTemplateParameterError,`Unable to get feature template. Component of type ${r} is not allowed for feature definition.`);return [...this.abstractionExtensions(e,t)]}static abstractionExtensions(e,t){let r=this.getInstance(),n=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let i=new Map,a=this.scope(t),_=new Set;for(let[l,A]of r._metaStorage)a.has(l)&&(s.isComponentMetaInstance(A)||s.isContainerMetaInstance(A))&&(_.add(l),A.abstractions(e).forEach(T=>{let h=Array.from(_).reverse().find(b=>u.isInheritedFrom(l,b)&&b!==l);h&&i.delete(`${u.getComponentName(h)}.${T.handler}`),i.set(`${u.getComponentName(l)}.${T.handler}`,{dependency:new Y(l),...T});}));return r.filterToMostDerived(a,Array.from(i.values()))}static reset(){let e=o.getInstance();e._registry=new WeakMap;let t=String(O.A_CONCEPT_ROOT_SCOPE)||"root";e._root=new x({name:t});}static isAllowedForScopeAllocation(e){return s.isContainerInstance(e)||s.isFeatureInstance(e)||s.isEntityInstance(e)}static isAllowedToBeRegistered(e){return s.isEntityInstance(e)||s.isComponentInstance(e)||s.isFragmentInstance(e)||s.isErrorInstance(e)}static isAllowedForMeta(e){return s.isContainerInstance(e)||s.isComponentInstance(e)||s.isEntityInstance(e)}static isAllowedForMetaConstructor(e){return s.isContainerConstructor(e)||s.isComponentConstructor(e)||s.isEntityConstructor(e)}};var L=class extends y{};L.AbstractionExtensionError="Unable to extend abstraction execution";function me(o,e={}){return function(t,r,n){let i=u.getComponentName(t);if(!o)throw new L(L.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${i}'.`);if(!s.isConstructorAvailableForAbstraction(t))throw new L(L.AbstractionExtensionError,`Unable to extend Abstraction '${o}' for '${i}'. Only A-Containers and A-Components can extend Abstractions.`);let a,_=c.meta(t);switch(true){case(s.isContainerConstructor(t)||s.isContainerInstance(t)):a="a-container-abstractions";break;case(s.isComponentConstructor(t)||s.isComponentInstance(t)):a="a-component-abstractions";break}let l=`CONCEPT_ABSTRACTION::${o}`,A=_.get(a)?new d().from(_.get(a)):new d,T=[...A.get(l)||[]],h=T.findIndex(F=>F.handler===r),b={name:l,handler:r,behavior:e.behavior||"sync",throwOnError:e.throwOnError!==void 0?e.throwOnError:true,before:s.isArray(e.before)?new RegExp(`^${e.before.join("|").replace(/\./g,"\\.")}$`).source:e.before instanceof RegExp?e.before.source:"",after:s.isArray(e.after)?new RegExp(`^${e.after.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:"",override:s.isArray(e.override)?new RegExp(`^${e.override.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:""};h!==-1?T[h]=b:T.push(b),A.set(l,T),c.meta(t).set(a,A);}}var P=class{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=c.abstractionTemplate(this._name,t);return new I({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return me}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false})}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};var Fe=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(Fe||{}),De=(e=>(e.LIFECYCLE="a-component-extensions",e))(De||{});var Ee=class{constructor(e){this.props=e;this._name=e.name||c.root.name,e.components&&e.components.length&&e.components.forEach(t=>this.scope.register(t)),e.fragments&&e.fragments.length&&e.fragments.forEach(t=>this.scope.register(t)),e.entities&&e.entities.length&&e.entities.forEach(t=>this.scope.register(t)),this._containers=e.containers||[];}static Load(e){return P.Extend("load",e)}static Publish(e){return P.Extend("publish")}static Deploy(e){return P.Extend("deploy",e)}static Build(e){return P.Extend("build",e)}static Run(e){return P.Extend("run",e)}static Start(e){return P.Extend("start",e)}static Stop(e){return P.Extend("stop",e)}get name(){return c.root.name}get scope(){return c.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new P({name:"load",containers:this._containers}).process(e);}async run(e){await new P({name:"run",containers:this._containers}).process(e);}async start(e){await new P({name:"start",containers:this._containers}).process(e);}async stop(e){await new P({name:"stop",containers:this._containers}).process(e);}async build(e){await new P({name:"build",containers:this._containers}).process(e);}async deploy(e){await new P({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new P({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new I({name:e,component:t}).process()}};var fe=class extends d{constructor(t){super();this.containers=t;}};var M=class extends y{};M.InvalidInjectionTarget="Invalid target for A-Inject decorator",M.MissingInjectionTarget="Missing target for A-Inject decorator";function ve(o,e){if(!o)throw new M(M.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let i=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new M(M.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${i})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,A=l.get(a)||[];A[n]=o instanceof Y?o:new Y(o,e),l.set(a,A),c.meta(t).set(_,l);}}
2
- export{C as ASEID,P as A_Abstraction,L as A_AbstractionError,me as A_Abstraction_Extend,S as A_BasicTypeGuards,O as A_CONCEPT_ENV,Z as A_CONSTANTS__DEFAULT_ENV_VARIABLES,ne as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,H as A_CONSTANTS__ERROR_CODES,ge as A_CONSTANTS__ERROR_DESCRIPTION,V as A_Caller,q as A_CallerError,u as A_CommonHelper,w as A_Component,N as A_ComponentMeta,Ee as A_Concept,fe as A_ConceptMeta,j as A_Container,U as A_ContainerMeta,c as A_Context,p as A_ContextError,Y as A_Dependency,f as A_DependencyError,pe as A_Dependency_All,ie as A_Dependency_Default,se as A_Dependency_Flat,ae as A_Dependency_Load,_e as A_Dependency_Parent,ue as A_Dependency_Query,ce as A_Dependency_Require,v as A_Entity,K as A_EntityError,z as A_EntityMeta,y as A_Error,I as A_Feature,m as A_FeatureError,le as A_Feature_Define,Ae as A_Feature_Extend,g as A_FormatterHelper,R as A_Fragment,k as A_IdentityHelper,ve as A_Inject,M as A_InjectError,d as A_Meta,oe as A_MetaDecorator,x as A_Scope,E as A_ScopeError,X as A_Stage,$ as A_StageError,B as A_StepManagerError,W as A_StepsManager,xe as A_TYPES__A_Stage_Status,de as A_TYPES__ComponentMetaKey,Fe as A_TYPES__ConceptAbstractions,De as A_TYPES__ConceptMetaKey,Pe as A_TYPES__ContainerMetaKey,Ye as A_TYPES__EntityFeatures,Ce as A_TYPES__EntityMetaKey,be as A_TYPES__FeatureState,s as A_TypeGuards};//# sourceMappingURL=index.mjs.map
1
+ var k=class{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};var Ye=(o=>(o.INITIALIZED="INITIALIZED",o.PROCESSING="PROCESSING",o.COMPLETED="COMPLETED",o.INTERRUPTED="INTERRUPTED",o.FAILED="FAILED",o))(Ye||{});var g=class{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};var j=class{static generateTimeId(e={timestamp:new Date,random:Math.random().toString(36).slice(2,8)}){let t=e.timestamp.getTime().toString(36),r=e.random;return `${t}-${r}`}static parseTimeId(e){let[t,r]=e.split("-");return {timestamp:new Date(parseInt(t,36)),random:r}}static formatWithLeadingZeros(e,t=10){return String(e).padStart(t+1,"0").slice(-t)}static removeLeadingZeros(e){return String(Number(e))}static hashString(e){let t=0,r,n;if(e.length===0)return t.toString();for(r=0;r<e.length;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t.toString()}};var S=class i{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static isArray(e){return Array.isArray(e)}static isErrorConstructorType(e){return !!e&&i.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&i.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&i.isString(e.aseid)}static isScopeInstance(e){return !!e&&typeof e=="object"&&"name"in e&&"aseid"in e}};var F=class F{static isASEID(e){return this.regexp.test(e)}static compare(e,t){if(!e||!t)return false;if(S.isString(e)&&this.isASEID(e)===false)throw new Error(`Invalid ASEID format provided: ${e}`);if(S.isString(t)&&this.isASEID(t)===false)throw new Error(`Invalid ASEID format provided: ${t}`);let r=e instanceof F?e:new F(e),n=t instanceof F?t:new F(t);return r.toString()===n.toString()}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||c.concept}get scope(){return this._scope||c.root.name}get entity(){return this._entity}get id(){return this._id}get version(){return this._version}get shard(){return this._shard}get hash(){return j.hashString(this.toString())}getInitializer(e){switch(true){case S.isString(e):return this.fromString;case S.isObject(e):return this.fromObject;default:throw new Error("Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[o,a,_]=r.split(":"),A=_.includes(".")?_.split(".")[0]:void 0,l=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=o||c.root.name,this._entity=a,this._id=l,this._version=n,this._shard=A;}fromObject(e){this._concept=e.concept?F.isASEID(e.concept)?new F(e.concept).id:e.concept:c.concept,this._scope=e.scope?S.isNumber(e.scope)?j.formatWithLeadingZeros(e.scope):F.isASEID(e.scope)?new F(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=S.isNumber(e.id)?j.formatWithLeadingZeros(e.id):e.id,this._version=e.version,this._shard=e.shard;}toString(){return `${this.concept}@${this.scope}:${this.entity}:${this.shard?this.shard+"."+this.id:this.id}${this.version?"@"+this.version:""}`}toJSON(){return {concept:this._concept,scope:this._scope,entity:this._entity,id:this._id,version:this._version,shard:this._shard}}verifyInput(e){switch(true){case(S.isString(e)&&!F.isASEID(e)):throw new Error("Invalid ASEID format provided");case(S.isObject(e)&&!e.id):throw new Error("ASEID id is required");case(S.isObject(e)&&!e.entity):throw new Error("ASEID entity is required")}}};F.regexp=new RegExp("^[a-z|A-Z|0-9|-]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|\\.|-]+(@v[0-9|\\.]+|@lts)?$");var C=F;var H={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},Ce="If you see this error please let us know.";var ne=class{static get A_CONCEPT_NAME(){return "a-concept"}static get A_CONCEPT_ROOT_SCOPE(){return "root"}static get A_CONCEPT_ENVIRONMENT(){return "development"}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "unknown"}static get A_CONCEPT_ROOT_FOLDER(){return "/app"}static get A_ERROR_DEFAULT_DESCRIPTION(){return "If you see this error please let us know."}static get(e){return this[e]}static set(e,t){this[e]=t;}static getAll(){return {}}static getAllKeys(){return []}};var Z={A_CONCEPT_NAME:"A_CONCEPT_NAME",A_CONCEPT_ROOT_SCOPE:"A_CONCEPT_ROOT_SCOPE",A_CONCEPT_ENVIRONMENT:"A_CONCEPT_ENVIRONMENT",A_CONCEPT_RUNTIME_ENVIRONMENT:"A_CONCEPT_RUNTIME_ENVIRONMENT",A_CONCEPT_ROOT_FOLDER:"A_CONCEPT_ROOT_FOLDER",A_ERROR_DEFAULT_DESCRIPTION:"A_ERROR_DEFAULT_DESCRIPTION"},ie=[Z.A_CONCEPT_NAME,Z.A_CONCEPT_ROOT_SCOPE,Z.A_CONCEPT_ENVIRONMENT,Z.A_CONCEPT_RUNTIME_ENVIRONMENT,Z.A_CONCEPT_ROOT_FOLDER,Z.A_ERROR_DEFAULT_DESCRIPTION];var M=class extends ne{static get A_CONCEPT_ENVIRONMENT(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ENVIRONMENT||super.A_CONCEPT_ENVIRONMENT}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "browser"}static get A_CONCEPT_NAME(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_NAME||super.A_CONCEPT_NAME}static get A_CONCEPT_ROOT_FOLDER(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_FOLDER||super.A_CONCEPT_ROOT_FOLDER}static get A_CONCEPT_ROOT_SCOPE(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_SCOPE||super.A_CONCEPT_ROOT_SCOPE}static get A_ERROR_DEFAULT_DESCRIPTION(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_ERROR_DEFAULT_DESCRIPTION||super.A_ERROR_DEFAULT_DESCRIPTION}static get(e){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.[e]||this[e]}static set(e,t){window.__A_CONCEPT_ENVIRONMENT_ENV__||(window.__A_CONCEPT_ENVIRONMENT_ENV__={}),window.__A_CONCEPT_ENVIRONMENT_ENV__[e]=t;}static getAll(){let e={};return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e[t]=window.__A_CONCEPT_ENVIRONMENT_ENV__[t];}),ie.forEach(t=>{e[t]=this.get(t);}),e}static getAllKeys(){let e=new Set;return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e.add(t);}),ie.forEach(t=>{e.add(t);}),Array.from(e)}};var y=class i extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof i:return e;case e instanceof Error:super(e.message);break;case S.isErrorSerializedType(e):super(e.message);break;case(S.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(S.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(S.isString(e)&&!t):super(e);break;case(S.isString(e)&&!!t):super(`[${e}]: ${t}`);break;default:super("An unknown error occurred.");}this.getInitializer(e,t).call(this,e,t);}get aseid(){return this._aseid}get title(){return this._title}get message(){return super.message}get code(){return this._code||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||String(M.A_ERROR_DEFAULT_DESCRIPTION)||Ce}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(S.isString(e)&&!t):return this.fromMessage;case(S.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case S.isErrorSerializedType(e):return this.fromJSON;case S.isErrorConstructorType(e):return this.fromConstructor;default:throw new i(H.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromJSON(e){this._aseid=new C(e.aseid),super.message=e.message,this._title=e.title,this._code=e.code,this._scope=e.scope,this._description=e.description,this._originalError=e.originalError?new i(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromConstructor(e){if(this.validateTitle(e.title),this._title=e.title,this._code=e.code,this._scope=e.scope?S.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._description=e.description,this._link=e.link,e.originalError instanceof i){let t=e.originalError;for(;t.originalError instanceof i;)t=t.originalError;this._originalError=t.originalError||t;}else this._originalError=e.originalError;}toJSON(){return {aseid:this.aseid.toString(),title:this.title,code:this.code,type:this.type,message:this.message,link:this.link,scope:this.scope,description:this.description,originalError:this.originalError?.message}}validateTitle(e){if(e.length>60)throw new i(H.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new i(H.VALIDATION_ERROR,"A-Error title cannot be empty.")}};var q=class extends y{};q.ValidationError="A-Entity Validation Error";var Pe=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(Pe||{}),oe={SAVE:"_A_Entity__Save",DESTROY:"_A_Entity__Destroy",LOAD:"_A_Entity__Load"};var v=class{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e){this.getInitializer(e).call(this,e);}get id(){return this.aseid.id}isStringASEID(e){return typeof e=="string"&&C.isASEID(e)}isASEIDInstance(e){return e instanceof C}isSerializedObject(e){return !!e&&typeof e=="object"&&"aseid"in e}isConstructorProps(e){return !!e&&typeof e=="object"&&!("aseid"in e)}getInitializer(e){if(!e)return this.fromUndefined;if(this.isStringASEID(e))return this.fromASEID;if(this.isASEIDInstance(e))return this.fromASEID;if(this.isSerializedObject(e))return this.fromJSON;if(this.isConstructorProps(e))return this.fromNew;throw new q(q.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new C({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||j.generateTimeId()})}async call(e,t){return await new b({name:e,component:this,scope:t}).process(t)}load(e){return this.call(oe.LOAD,e)}destroy(e){return this.call(oe.DESTROY,e)}save(e){return this.call(oe.SAVE,e)}fromASEID(e){e instanceof C?this.aseid=e:this.aseid=new C(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new C(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};function se(i){return function(e){return c.setMeta(e,new i),e}}var d=class i{constructor(){this.meta=new Map;}static Define(e){return se(e)}[Symbol.iterator](){let e=this.meta.entries();return {next:()=>e.next()}}from(e){return this.meta=new Map(e.meta),this}clone(){let e=this.constructor,t=new e;return t.meta=new Map(this.meta),t}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof i:return e.toJSON();case e instanceof Map:let t={};for(let[n,o]of e.entries())t[String(n)]=this.recursiveToJSON(o);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,o]of Object.entries(e))r[n]=this.recursiveToJSON(o);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};var V=class extends d{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};var $=class{get name(){return this.config?.name||this.constructor.name}get scope(){return c.scope(this)}constructor(e={}){this.config=e,c.allocate(this,this.config);}async call(e,t){return await new b({name:e,component:this}).process(t)}};var Ie=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Ie||{});var K=class extends d{injections(e){return this.get("a-container-injections")?.get(e)||[]}features(){return this.get("a-container-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-container-abstractions"),n=this.get("a-container-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([o,a])=>{a.forEach(_=>{let A=n?.get(_.handler)||[];t.push({..._,args:A});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,o])=>{o.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}};var m=class extends y{fromConstructor(e){super.fromConstructor(e),this.stage=e.stage;}};m.Interruption="Feature Interrupted",m.FeatureInitializationError="Unable to initialize A-Feature",m.FeatureProcessingError="Error occurred during A-Feature processing",m.FeatureDefinitionError="Unable to define A-Feature",m.FeatureExtensionError="Unable to extend A-Feature";var u=class{static resolve(){return new Promise(e=>e())}static isInheritedFrom(e,t){let r=e;for(;r;){if(r===t)return true;r=Object.getPrototypeOf(r);}return false}static getParentClasses(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=[];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getClassInheritanceChain(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=typeof e=="function"?[e]:[e.constructor];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getParentClass(e){return Object.getPrototypeOf(e)}static omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(o,a){let _=a[0];a.length===1?delete o[_]:o[_]!==void 0&&typeof o[_]=="object"&&n(o[_],a.slice(1));}return t.forEach(o=>{let a=o.split(".");n(r,a);}),r}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static deepMerge(e,t,r=new Map){if(this.isObject(e)&&this.isObject(t))for(let n in t)this.isObject(t[n])?(e[n]||(e[n]={}),r.has(t[n])?e[n]=r.get(t[n]):(r.set(t[n],{}),this.deepMerge(e[n],t[n],r))):e[n]=t[n];return e}static deepClone(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(t=>this.deepClone(t));if(typeof e=="function")return e;if(e instanceof Object){let t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=this.deepClone(e[r]));return t}throw new Error("Unable to clone the object. Unsupported type.")}static deepCloneAndMerge(e,t){if(t==null&&e==null)return e;if(e==null&&t)return this.deepClone(t);if(typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(r=>this.deepCloneAndMerge(r,t));if(typeof e=="function")return e;if(e instanceof Object){let r={};for(let n in e)t[n]!==null&&t[n]!==void 0?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(e[n]);for(let n in t)e[n]!==void 0&&e[n]!==null?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(t[n]);return r}throw new Error("Unable to clone the object. Unsupported type.")}static getComponentName(e){let t="Unknown",r="Anonymous";if(e==null)return t;if(typeof e=="string")return e||t;if(typeof e=="symbol")try{return e.toString()}catch{return t}if(Array.isArray(e))return e.length===0?t:this.getComponentName(e[0]);if(typeof e=="function"){let n=e;if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name)return String(n.constructor.name);try{let a=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(a)return a[1]||a[2]||a[3]||r}catch{}return r}if(typeof e=="object"){let n=e;if(n.type)return this.getComponentName(n.type);if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name&&n.constructor.name!=="Object")return String(n.constructor.name);try{let o=n.toString();if(typeof o=="string"&&o!=="[object Object]")return o}catch{}return r}try{return String(e)}catch{return t}}};var B=class extends Error{};B.CallerInitializationError="Unable to initialize A-Caller";var J=class{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!s.isAllowedForFeatureCall(e))throw new B(`[${B.CallerInitializationError}]: Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};var f=class extends y{};f.InvalidDependencyTarget="Invalid Dependency Target",f.InvalidLoadTarget="Invalid Load Target",f.InvalidLoadPath="Invalid Load Path",f.InvalidDefaultTarget="Invalid Default Target",f.ResolutionParametersError="Dependency Resolution Parameters Error";function ae(...i){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let o=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,A=_.get(o)||[];A[r].resolutionStrategy={create:true,args:i},_.set(o,A),c.meta(e).set(a,_);}}function _e(){return function(i,e,t){let r=u.getComponentName(i);if(!s.isTargetAvailableForInjection(i))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof i} (${r})`);let n=e?String(e):"constructor",o;switch(true){case(s.isComponentConstructor(i)||s.isComponentInstance(i)):o="a-component-injections";break;case s.isContainerInstance(i):o="a-container-injections";break;case s.isEntityInstance(i):o="a-component-injections";break}let a=c.meta(i).get(o)||new d,_=a.get(n)||[];_[t].resolutionStrategy={flat:true},a.set(n,_),c.meta(i).set(o,a);}}function ce(){return function(i,e,t){let r=u.getComponentName(i);if(!s.isTargetAvailableForInjection(i))throw new f(f.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof i} (${r})`);let n=e?String(e):"constructor",o;switch(true){case(s.isComponentConstructor(i)||s.isComponentInstance(i)):o="a-component-injections";break;case s.isContainerInstance(i):o="a-container-injections";break;case s.isEntityInstance(i):o="a-component-injections";break}let a=c.meta(i).get(o)||new d,_=a.get(n)||[];_[t].resolutionStrategy={load:true},a.set(n,_),c.meta(i).set(o,a);}}function pe(i=-1){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof e} (${n})`);let o=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,A=_.get(o)||[];A[r].resolutionStrategy={parent:i},_.set(o,A),c.meta(e).set(a,_);}}function ue(){return function(i,e,t){let r=u.getComponentName(i);if(!s.isTargetAvailableForInjection(i))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof i} (${r})`);let n=e?String(e):"constructor",o;switch(true){case(s.isComponentConstructor(i)||s.isComponentInstance(i)):o="a-component-injections";break;case s.isContainerInstance(i):o="a-container-injections";break;case s.isEntityInstance(i):o="a-component-injections";break}let a=c.meta(i).get(o)||new d,_=a.get(n)||[];_[t].resolutionStrategy={require:true},a.set(n,_),c.meta(i).set(o,a);}}function Ae(){return function(i,e,t){let r=u.getComponentName(i);if(!s.isTargetAvailableForInjection(i))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof i} (${r})`);let n=e?String(e):"constructor",o;switch(true){case(s.isComponentConstructor(i)||s.isComponentInstance(i)):o="a-component-injections";break;case s.isContainerInstance(i):o="a-container-injections";break;case s.isEntityInstance(i):o="a-component-injections";break}let a=c.meta(i).get(o)||new d,_=a.get(n)||[];_[t].resolutionStrategy={pagination:{..._[t].resolutionStrategy.pagination,count:-1}},a.set(n,_),c.meta(i).set(o,a);}}function le(i,e){return function(t,r,n){let o=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof t} (${o})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let A=c.meta(t).get(_)||new d,l=A.get(a)||[];l[n].resolutionStrategy={query:{...l[n].resolutionStrategy.query,...i},pagination:{...l[n].resolutionStrategy.pagination,...e}},A.set(a,l),c.meta(t).set(_,A);}}var Y=class{constructor(e,t){this._defaultPagination={count:1,from:"start"};this._defaultResolutionStrategy={require:false,load:false,parent:0,flat:false,create:false,args:[],query:{},pagination:this._defaultPagination};this._name=typeof e=="string"?e:u.getComponentName(e),this._target=typeof e=="string"?void 0:e,this.resolutionStrategy=t||{},this.initCheck();}static get Required(){return ue}static get Loaded(){return ce}static get Default(){return ae}static get Parent(){return pe}static get Flat(){return _e}static get All(){return Ae}static get Query(){return le}get flat(){return this._resolutionStrategy.flat}get require(){return this._resolutionStrategy.require}get load(){return this._resolutionStrategy.load}get all(){return this._resolutionStrategy.pagination.count!==1||Object.keys(this._resolutionStrategy.query).length>0}get parent(){return this._resolutionStrategy.parent}get create(){return this._resolutionStrategy.create}get args(){return this._resolutionStrategy.args}get query(){return this._resolutionStrategy.query}get pagination(){return this._resolutionStrategy.pagination}get name(){return this._name}get target(){return this._target}get resolutionStrategy(){return this._resolutionStrategy}set resolutionStrategy(e){this._resolutionStrategy={...this._defaultResolutionStrategy,...this._resolutionStrategy,...e,pagination:{...this._defaultPagination,...(this._resolutionStrategy||{}).pagination,...e.pagination||{}}};}initCheck(){if(!this._resolutionStrategy)throw new f(f.ResolutionParametersError,`Resolution strategy parameters are not provided for dependency: ${this._name}`);return this}toJSON(){return {name:this._name,all:this.all,require:this.require,load:this.load,parent:this.parent,flat:this.flat,create:this.create,args:this.args,query:this.query,pagination:this.pagination}}};var s=class i{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isArray(e){return Array.isArray(e)}static isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static isFunction(e){return typeof e=="function"}static isUndefined(e){return typeof e>"u"}static isRegExp(e){return e instanceof RegExp}static isContainerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,$)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,w)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,k)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Error)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,b)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,J)}static isDependencyConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isDependencyInstance(e){return e instanceof Y}static isContainerInstance(e){return e instanceof $}static isComponentInstance(e){return e instanceof w}static isFeatureInstance(e){return e instanceof b}static isFragmentInstance(e){return e instanceof k}static isEntityInstance(e){return e instanceof v}static isScopeInstance(e){return e instanceof x}static isErrorInstance(e){return e instanceof Error}static isComponentMetaInstance(e){return e instanceof N}static isContainerMetaInstance(e){return e instanceof K}static isEntityMetaInstance(e){return e instanceof V}static hasASEID(e){return e&&typeof e=="object"&&"aseid"in e&&(i.isEntityInstance(e)||i.isErrorInstance(e))}static isConstructorAllowedForScopeAllocation(e){return i.isContainerConstructor(e)||i.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return i.isContainerInstance(e)||i.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return i.isContainerInstance(e)||i.isComponentInstance(e)}static isTargetAvailableForInjection(e){return i.isComponentConstructor(e)||i.isComponentInstance(e)||i.isContainerInstance(e)||i.isEntityInstance(e)}static isAllowedForFeatureCall(e){return i.isContainerInstance(e)||i.isComponentInstance(e)||i.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return i.isContainerInstance(e)||i.isComponentInstance(e)||i.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return i.isComponentInstance(e)||i.isContainerInstance(e)||i.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return i.isContainerInstance(e)||i.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return i.isFragmentConstructor(e)||u.isInheritedFrom(e,k)||i.isEntityConstructor(e)||u.isInheritedFrom(e,v)}static isErrorConstructorType(e){return !!e&&i.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&i.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&C.isASEID(e.aseid)}static isPromiseInstance(e){return e instanceof Promise}};function de(i={}){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureDefinition(e))throw new m(m.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let o=c.meta(e.constructor),a;switch(true){case s.isEntityInstance(e):a="a-component-features";break;case s.isContainerInstance(e):a="a-container-features";break;case s.isComponentInstance(e):a="a-component-features";break}let _=o.get(a)||new d,A=i.name||t,l=i.invoke||false;_.set(t,{name:`${e.constructor.name}.${A}`,handler:t,invoke:l,template:i.template&&i.template.length?i.template.map(h=>({...h,before:h.before||"",after:h.after||"",behavior:h.behavior||"sync",throwOnError:true,override:h.override||""})):[]}),c.meta(e.constructor).set(a,_);let T=r.value;return r.value=function(...h){if(l)T.apply(this,h);else return T.apply(this,h);if(typeof this.call=="function"&&l)return this.call(A)},r}}function me(i){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureExtension(e))throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let o,a="sync",_="",A="",l="",T=[],h=[],I=true,D;switch(true){case s.isEntityInstance(e):D="a-component-extensions";break;case s.isContainerInstance(e):D="a-container-extensions";break;case s.isComponentInstance(e):D="a-component-extensions";break}switch(true){case s.isRegExp(i):o=i;break;case(!!i&&typeof i=="object"):Array.isArray(i.scope)?T=i.scope:i.scope&&typeof i.scope=="object"&&(Array.isArray(i.scope.include)&&(T=i.scope.include),Array.isArray(i.scope.exclude)&&(h=i.scope.exclude)),o=we(i,T,h,t),a=i.behavior||a,I=i.throwOnError!==void 0?i.throwOnError:I,_=s.isArray(i.before)?new RegExp(`^${i.before.join("|").replace(/\./g,"\\.")}$`).source:i.before instanceof RegExp?i.before.source:"",A=s.isArray(i.after)?new RegExp(`^${i.after.join("|").replace(/\./g,"\\.")}$`).source:i.after instanceof RegExp?i.after.source:"",l=s.isArray(i.override)?new RegExp(`^${i.override.join("|").replace(/\./g,"\\.")}$`).source:i.override instanceof RegExp?i.override.source:"";break;default:o=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let O=c.meta(e).get(D),Q=c.meta(e),U=Q.get(D)?new d().from(Q.get(D)):new d;if(O&&O.size()&&O.has(t)&&O.get(t).invoke)throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be used on the method "${t}" because it is already defined as a Feature with "invoke" set to true. Please remove the A-Feature-Extend decorator or set "invoke" to false in the A-Feature decorator.`);let te=[...U.get(o.source)||[]];for(let[X,re]of U.entries()){let ge=re.findIndex(be=>be.handler===t);X!==o.source&&ge!==-1&&(re.splice(ge,1),re.length===0?U.delete(X):U.set(X,re));}let ye=te.findIndex(X=>X.handler===t),he={name:o.source,handler:t,behavior:a,before:_,after:A,throwOnError:I,override:l};ye!==-1?te[ye]=he:te.push(he),U.set(o.source,te),c.meta(e).set(D,U);}}function we(i,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",o=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",a=i.scope?`^${o}${n}\\.${i.name||r}$`:`.*\\.${i.name||r}$`;return new RegExp(a)}var xe=(a=>(a.PROCESSING="PROCESSING",a.COMPLETED="COMPLETED",a.FAILED="FAILED",a.SKIPPED="SKIPPED",a.INITIALIZED="INITIALIZED",a.ABORTED="ABORTED",a))(xe||{});var L=class extends y{static get CompileError(){return "Unable to compile A-Stage"}};L.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var ee=class{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}getStepArgs(e,t){let r=t.dependency.target||e.resolveConstructor(t.dependency.name);return c.meta(r).injections(t.handler).map(n=>{switch(true){case s.isCallerConstructor(n.target):return this._feature.caller.component;case s.isFeatureConstructor(n.target):return this._feature;default:return e.resolve(n)}})}getStepComponent(e,t){let{dependency:r,handler:n}=t,o=e.resolve(r)||this.feature.scope.resolve(r);if(!o)throw new L(L.CompileError,`Unable to resolve component ${r.name} from scope ${e.name}`);if(!o[n])throw new L(L.CompileError,`Handler ${n} not found in ${o.constructor.name}`);return o}callStepHandler(e,t){let r=this.getStepComponent(t,e),n=this.getStepArgs(t,e);return {handler:r[e.handler].bind(r),params:n}}skip(){this._status="SKIPPED";}process(e){let t=s.isScopeInstance(e)?e:this._feature.scope;if(!this.isProcessed){this._status="PROCESSING";let{handler:r,params:n}=this.callStepHandler(this._definition,t),o=r(...n);if(s.isPromiseInstance(o))return new Promise(async(a,_)=>{try{return await o,this.completed(),a()}catch(A){let l=new y(A);return this.failed(l),this._definition.throwOnError?a():_(l)}});this.completed();}}completed(){this._status="COMPLETED";}failed(e){this._error=new y(e),this._status="FAILED";}toJSON(){return {name:this.name,status:this.status}}toString(){return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`}};var G=class extends y{};G.CircularDependencyError="A-StepManager Circular Dependency Error";var W=class{constructor(e){this._uniqueIdMap=new Map;this._isBuilt=false;this.entities=this.prepareSteps(e),this.graph=new Map,this.visited=new Set,this.tempMark=new Set,this.sortedEntities=[],this.assignUniqueIds();}prepareSteps(e){return e.map(t=>({...t,behavior:t.behavior||"sync",before:t.before||"",after:t.after||"",override:t.override||"",throwOnError:false}))}baseID(e){return `${e.dependency.name}.${e.handler}`}ID(e){return this._uniqueIdMap.get(e)||this.baseID(e)}assignUniqueIds(){let e=new Map;for(let r of this.entities){let n=this.baseID(r);e.set(n,(e.get(n)||0)+1);}let t=new Map;for(let r of this.entities){let n=this.baseID(r);if(e.get(n)>1){let o=t.get(n)||0;this._uniqueIdMap.set(r,`${n}#${o}`),t.set(n,o+1);}else this._uniqueIdMap.set(r,n);}}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some((n,o)=>{if(t===o||!n.override)return false;let a=new RegExp(n.override);return a.test(this.baseID(e))||a.test(e.handler)})),this._uniqueIdMap.clear(),this.assignUniqueIds(),this.entities.forEach(e=>this.graph.set(this.ID(e),new Set)),this.entities.forEach(e=>{let t=this.ID(e);e.before&&this.matchEntities(t,e.before).forEach(n=>{this.graph.has(n)||this.graph.set(n,new Set),this.graph.get(n).add(t);}),e.after&&this.matchEntities(t,e.after).forEach(n=>{this.graph.has(t)||this.graph.set(t,new Set),this.graph.get(t).add(n);});}));}matchEntities(e,t){let r=new RegExp(t);return this.entities.filter(n=>r.test(this.baseID(n))&&this.ID(n)!==e).map(n=>this.ID(n))}visit(e){this.tempMark.has(e)||this.visited.has(e)||(this.tempMark.add(e),(this.graph.get(e)||[]).forEach(t=>this.visit(t)),this.tempMark.delete(e),this.visited.add(e),this.sortedEntities.push(e));}toSortedArray(){return this.buildGraph(),this.entities.forEach(e=>{this.visited.has(this.ID(e))||this.visit(this.ID(e));}),this.sortedEntities}toStages(e){return this.toSortedArray().map(r=>{let n=this.entities.find(o=>this.ID(o)===r);return new ee(e,n)})}};var b=class i{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return de}static get Extend(){return me}get name(){return this._name}get error(){return this._error}get state(){return this._state}get index(){return this._index}get stage(){return this._current}get caller(){return this._caller}get scope(){return c.scope(this)}get size(){return this._stages.length}get isDone(){return !this.stage||this._index>=this._stages.length}get isProcessed(){return this.state==="COMPLETED"||this.state==="FAILED"||this.state==="INTERRUPTED"}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._stages[this._index],this._index++,{value:this._current,done:false})}}validateParams(e){if(!e||typeof e!="object")throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}getInitializer(e){switch(true){case !("template"in e):return this.fromComponent;case "template"in e:return this.fromTemplate;default:throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}}fromTemplate(e){if(!e.template||!Array.isArray(e.template))throw new m(m.FeatureInitializationError,`Invalid A-Feature template provided of type: ${typeof e.template} with value: ${JSON.stringify(e.template).slice(0,100)}...`);if(!e.component&&(!e.scope||!(e.scope instanceof x)))throw new m(m.FeatureInitializationError,`Invalid A-Feature scope provided of type: ${typeof e.scope} with value: ${JSON.stringify(e.scope).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{e.component&&(t=c.scope(e.component));}catch(o){if(!r)throw o}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new J(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new W(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!s.isAllowedForFeatureDefinition(e.component))throw new m(m.FeatureInitializationError,`Invalid A-Feature component provided of type: ${typeof e.component} with value: ${JSON.stringify(e.component).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{t=c.scope(e.component);}catch(a){if(!r)throw a}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new J(e.component);let n=c.allocate(this);n.inherit(t||r);let o=c.featureTemplate(this._name,this._caller.component,n);this._SM=new W(o),this._stages=this._SM.toStages(this),this._current=this._stages[0];}process(e){try{if(this.isProcessed)return;this._state="PROCESSING";let t=Array.from(this);return this.processStagesSequentially(t,e,0)}catch(t){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:t}))}}processStagesSequentially(e,t,r){try{if(this.state==="INTERRUPTED")return;if(r>=e.length){this.completed();return}let n=e[r],o=n.process(t);return s.isPromiseInstance(o)?o.then(()=>{if(this.state!=="INTERRUPTED")return this.processStagesSequentially(e,t,r+1)}).catch(a=>{throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${n.name}.`,stage:n,originalError:a}))}):this.processStagesSequentially(e,t,r+1)}catch(n){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:n}))}}next(e){let t=this._stages.indexOf(e);this._index=t+1,this._index>=this._stages.length&&this.completed();}completed(){this.isProcessed||this.state!=="INTERRUPTED"&&(this._state="COMPLETED",this.scope.destroy());}failed(e){return this.isProcessed?this._error:(this._state="FAILED",this._error=e,this.scope.destroy(),this._error)}interrupt(e){if(this.isProcessed)return this._error;switch(this._state="INTERRUPTED",true){case s.isString(e):this._error=new m(m.Interruption,e);break;case s.isErrorInstance(e):this._error=new m({code:m.Interruption,title:e.title||"Feature Interrupted",description:e.description||e.message,stage:this.stage,originalError:e});break;default:this._error=new m(m.Interruption,"Feature was interrupted");break}return this.scope.destroy(),this._error}chain(e,t,r){let n,o;e instanceof i?(n=e,o=t instanceof x?t:void 0):(n=new i({name:t,component:e}),o=r instanceof x?r:void 0);let a=o||this.scope;n._caller=this._caller;let _=n.process(a);return s.isPromiseInstance(_)?_.catch(A=>{throw A}):_}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};var w=class{call(e,t){return new b({name:e,component:this}).process(t)}};var Ee=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(Ee||{});var N=class extends d{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,o])=>{o.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:a.override||""});});}),t}features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-component-abstractions"),n=this.get("a-component-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([o,a])=>{a.forEach(_=>{let A=n?.get(_.handler)||[];t.push({..._,args:A});});}),t}};var x=class{constructor(e,t){this._meta=new d;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this._imports=new Set;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get imports(){return Array.from(this._imports.values())}get parent(){return this._parent}*parents(){let e=this._parent;for(;e;)yield e,e=e._parent;}parentOffset(e){let t=this;for(;e<=-1&&t;)t=t.parent,e++;return t}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new E(E.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>c.deregister(e)),this._fragments.forEach(e=>c.deregister(e)),this._entities.forEach(e=>c.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this._imports.clear(),this.issuer()&&c.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return c.issuer(this)}inherit(e){if(!e)throw new E(E.InitializationError,"Invalid parent scope provided");if(e===this)throw new E(E.CircularInheritanceError,`Unable to inherit scope ${this.name} from itself`);if(e===this._parent)return this;let t=this.checkCircularInheritance(e);if(t)throw new E(E.CircularInheritanceError,`Circular inheritance detected: ${[...t,e.name].join(" -> ")}`);return this._parent=e,this}import(...e){return e.forEach(t=>{if(t===this)throw new E(E.CircularImportError,`Unable to import scope ${this.name} into itself`);this._imports.has(t)||this._imports.add(t);}),this}deimport(...e){return e.forEach(t=>{this._imports.has(t)&&this._imports.delete(t);}),this}has(e){let t=this.hasFlat(e);if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}hasFlat(e){let t=false;switch(true){case s.isScopeConstructor(e):return true;case s.isString(e):{Array.from(this.allowedComponents).find(_=>_.name===e)&&(t=true),Array.from(this.allowedFragments).find(_=>_.name===e)&&(t=true),Array.from(this.allowedEntities).find(_=>_.name===e)&&(t=true),Array.from(this.allowedErrors).find(_=>_.name===e)&&(t=true);break}case s.isComponentConstructor(e):{t=this.isAllowedComponent(e)||!![...this.allowedComponents].find(r=>u.isInheritedFrom(r,e));break}case s.isEntityConstructor(e):{t=this.isAllowedEntity(e)||!![...this.allowedEntities].find(r=>u.isInheritedFrom(r,e));break}case s.isFragmentConstructor(e):{t=this.isAllowedFragment(e)||!![...this.allowedFragments].find(r=>u.isInheritedFrom(r,e));break}case s.isErrorConstructor(e):{t=this.isAllowedError(e)||!![...this.allowedErrors].find(r=>u.isInheritedFrom(r,e));break}case(this.issuer()&&(this.issuer().constructor===e||u.isInheritedFrom(this.issuer().constructor,e))):{t=true;break}}return t}resolveDependency(e){let t=[],r=this.parentOffset(e.parent)||this;switch(true){case(e.flat&&!e.all):{let l=r.resolveFlatOnce(e.target||e.name);l&&(t=[l]);break}case(e.flat&&e.all):{t=r.resolveFlatAll(e.target||e.name);break}case(!e.flat&&!e.all):{let l=r.resolveOnce(e.target||e.name);l&&(t=[l]);break}case(!e.flat&&e.all):{t=r.resolveAll(e.target||e.name);break}default:t=[];}if(e.create&&!t.length&&s.isAllowedForDependencyDefaultCreation(e.target)){let l=new e.target(...e.args);r.register(l),t.push(l);}if(e.require&&!t.length)throw new E(E.ResolutionError,`Dependency ${e.name} is required but could not be resolved in scope ${r.name}`);e.query.aseid?t=t.filter(l=>s.hasASEID(l)&&C.compare(l.aseid,e.query.aseid)):Object.keys(e.query).length>0&&(t=t.filter(l=>{let T=e.query;return T?Object.entries(T).every(([h,I])=>l[h]===I):true}));let n=e.pagination.count,o=e.pagination.from,a=o==="end"?n===-1?0:Math.max(t.length-n,0):0,_=o==="end"||n===-1?t.length:Math.min(n,t.length),A=t.slice(a,_);return A.length===1&&n!==-1?A[0]:A.length?A:void 0}resolveConstructor(e){switch(true){case s.isComponentConstructor(e):return Array.from(this.allowedComponents).find(o=>u.isInheritedFrom(o,e));case s.isEntityConstructor(e):return Array.from(this.allowedEntities).find(o=>u.isInheritedFrom(o,e));case s.isFragmentConstructor(e):return Array.from(this.allowedFragments).find(o=>u.isInheritedFrom(o,e));case s.isErrorConstructor(e):return Array.from(this.allowedErrors).find(o=>u.isInheritedFrom(o,e))}if(!s.isString(e))throw new E(E.ResolutionError,`Invalid constructor name provided: ${e}`);let t=Array.from(this.allowedComponents).find(o=>o.name===e||o.name===g.toPascalCase(e));if(t)return t;{let o=Array.from(this.allowedComponents).find(a=>{let _=a;for(;_;){if(_.name===e||_.name===g.toPascalCase(e))return true;_=Object.getPrototypeOf(_);}return false});if(o)return o}let r=Array.from(this.allowedEntities).find(o=>o.name===e||o.name===g.toPascalCase(e)||o.entity===e||o.entity===g.toKebabCase(e));if(r)return r;{let o=Array.from(this.allowedEntities).find(a=>u.isInheritedFrom(a,e));if(o)return o}let n=Array.from(this.allowedFragments).find(o=>o.name===e||o.name===g.toPascalCase(e));if(n)return n;{let o=Array.from(this.allowedFragments).find(a=>u.isInheritedFrom(a,e));if(o)return o}for(let o of this._imports){let a=o.resolveConstructor(e);if(a)return a}if(this._parent)return this._parent.resolveConstructor(e)}resolveAll(e){let t=new Set;this.resolveFlatAll(e).forEach(o=>t.add(o)),this._imports.forEach(o=>{o.has(e)&&o.resolveFlatAll(e).forEach(_=>t.add(_));});let n=this._parent;for(;n&&n.has(e);)n.resolveAll(e).forEach(a=>t.add(a)),n=n._parent;return Array.from(t)}resolveFlatAll(e){let t=[];switch(true){case s.isComponentConstructor(e):{this.allowedComponents.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isFragmentConstructor(e):{this.allowedFragments.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isEntityConstructor(e):{this.entities.forEach(r=>{u.isInheritedFrom(r.constructor,e)&&t.push(r);});break}case s.isString(e):{let r=this.resolveConstructor(e);if(!s.isComponentConstructor(r)&&!s.isEntityConstructor(r)&&!s.isFragmentConstructor(r))throw new E(E.ResolutionError,`Unable to resolve all instances for name: ${e} in scope ${this.name} as no matching component, entity or fragment constructor found`);if(r){let n=this.resolveAll(r);n&&t.push(...n);}break}default:throw new E(E.ResolutionError,`Invalid parameter provided to resolveAll method: ${e} in scope ${this.name}`)}return t}resolve(e){let t=s.isDependencyInstance(e)?e:new Y(e);return this.resolveDependency(t)}resolveOnce(e){let t=this.resolveFlatOnce(e);if(!t){for(let r of this._imports)if(r.has(e)){let n=r.resolveFlatOnce(e);if(n)return n}}return !t&&this.parent?this.parent.resolveOnce(e):t}resolveFlat(e){return this.resolveFlatOnce(e)}resolveFlatOnce(e){let t,r=u.getComponentName(e);if(!(!e||!this.has(e))){switch(true){case s.isString(e):{t=this.resolveByName(e);break}case s.isConstructorAllowedForScopeAllocation(e):{t=this.resolveIssuer(e);break}case s.isScopeConstructor(e):{t=this.resolveScope(e);break}case s.isEntityConstructor(e):{t=this.resolveEntity(e);break}case s.isFragmentConstructor(e):{t=this.resolveFragment(e);break}case s.isComponentConstructor(e):{t=this.resolveComponent(e);break}case s.isErrorConstructor(e):{t=this.resolveError(e);break}default:throw new E(E.ResolutionError,`Injected Component ${r} not found in the scope`)}return t}}resolveByName(e){let t=Array.from(this.allowedComponents).find(a=>a.name===e||a.name===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.entity===e||a.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(a=>a.name===e||a.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let o=Array.from(this.allowedErrors).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.code===e||a.code===g.toKebabCase(e));if(o)return this.resolveOnce(o)}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t}resolveEntity(e){return this.entities.find(t=>t instanceof e)}resolveError(e){return this.errors.find(t=>t instanceof e)}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}default:return}}resolveScope(e){return this}resolveComponent(e){switch(true){case(this.allowedComponents.has(e)&&this._components.has(e)):return this._components.get(e);case(this.allowedComponents.has(e)&&!this._components.has(e)):{let n=(c.meta(e).get("a-component-injections")?.get("constructor")||[]).map(a=>this.resolve(a)),o=new e(...n);return this.register(o),this._components.get(e)}case(!this.allowedComponents.has(e)&&Array.from(this.allowedComponents).some(t=>u.isInheritedFrom(t,e))):{let t=Array.from(this.allowedComponents).find(r=>u.isInheritedFrom(r,e));return this.resolveComponent(t)}default:return}}register(e){switch(true){case e instanceof w:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e);break}case(s.isEntityInstance(e)&&!this._entities.has(e.aseid.toString())):{this.allowedEntities.has(e.constructor)||this.allowedEntities.add(e.constructor),this._entities.set(e.aseid.toString(),e),c.register(this,e);break}case s.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),c.register(this,e);break}case s.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),c.register(this,e);break}case s.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case s.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case s.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof v)throw new E(E.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof k)throw new E(E.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new E(E.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof w:{this._components.delete(e.constructor),c.deregister(e);let r=e.constructor;this._components.has(r)||this.allowedComponents.delete(r);break}case s.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),c.deregister(e);let r=e.constructor;Array.from(this._entities.values()).some(o=>o instanceof r)||this.allowedEntities.delete(r);break}case s.isFragmentInstance(e):{this._fragments.delete(e.constructor),c.deregister(e);let r=e.constructor;Array.from(this._fragments.values()).some(o=>o instanceof r)||this.allowedFragments.delete(r);break}case s.isErrorInstance(e):{this._errors.delete(e.code),c.deregister(e);let r=e.constructor;Array.from(this._errors.values()).some(o=>o instanceof r)||this.allowedErrors.delete(r);break}case s.isComponentConstructor(e):{this.allowedComponents.delete(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.delete(e),Array.from(this._fragments.entries()).forEach(([r,n])=>{u.isInheritedFrom(r,e)&&(this._fragments.delete(r),c.deregister(n));});break}case s.isEntityConstructor(e):{this.allowedEntities.delete(e),Array.from(this._entities.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._entities.delete(r),c.deregister(n));});break}case s.isErrorConstructor(e):{this.allowedErrors.delete(e),Array.from(this._errors.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._errors.delete(r),c.deregister(n));});break}default:let t=u.getComponentName(e);throw new E(E.DeregistrationError,`Cannot deregister ${t} from the scope ${this.name}`)}}toJSON(){return this.fragments.reduce((e,t)=>{let r=t.toJSON();return {...e,[r.name]:r}},{})}isAllowedComponent(e){return s.isComponentConstructor(e)&&this.allowedComponents.has(e)}isAllowedEntity(e){return s.isEntityConstructor(e)&&this.allowedEntities.has(e)}isAllowedFragment(e){return s.isFragmentConstructor(e)&&this.allowedFragments.has(e)}isAllowedError(e){return s.isErrorConstructor(e)&&this.allowedErrors.has(e)}isInheritedFrom(e){let t=this;for(;t;){if(t===e)return true;t=t._parent;}return false}checkCircularInheritance(e){let t=[],r=this._parent;for(;r;){if(t.push(r.name),r===e)return t;r=r._parent;}return false}printInheritanceChain(){let e=[],t=this;for(;t;)e.push(t.name),t=t._parent;console.log(e.join(" -> "));}};var E=class extends y{};E.InitializationError="A-Scope Initialization Error",E.ConstructorError="Unable to construct A-Scope instance",E.ResolutionError="A-Scope Resolution Error",E.RegistrationError="A-Scope Registration Error",E.CircularInheritanceError="A-Scope Circular Inheritance Error",E.CircularImportError="A-Scope Circular Import Error",E.DeregistrationError="A-Scope Deregistration Error";var p=class extends y{};p.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",p.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",p.InvalidMetaParameterError="Invalid parameter provided to get meta",p.InvalidScopeParameterError="Invalid parameter provided to get scope",p.ScopeNotFoundError="Scope not found",p.InvalidFeatureParameterError="Invalid parameter provided to get feature",p.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",p.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",p.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",p.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",p.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",p.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",p.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",p.InvalidInjectionParameterError="Invalid parameter provided to get injections",p.InvalidExtensionParameterError="Invalid parameter provided to get extensions",p.InvalidRegisterParameterError="Invalid parameter provided to register component",p.InvalidComponentParameterError="Invalid component provided",p.ComponentNotRegisteredError="Component not registered in the context",p.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var c=class i{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;this._globals=new Map;let e=String(M.A_CONCEPT_ROOT_SCOPE)||"root";this._root=new x({name:e});}static get concept(){return M.A_CONCEPT_NAME||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){return M.A_CONCEPT_RUNTIME_ENVIRONMENT}static getInstance(){return i._instance||(i._instance=new i),i._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new p(p.NotAllowedForScopeAllocationError,`Component ${r} is not allowed for scope allocation.`);return n._scopeStorage.set(t,e),e}static deregister(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new p(p.ComponentNotRegisteredError,`Unable to deregister component. Component ${t} is not registered.`);r._scopeStorage.delete(e);}static allocate(e,t){let r=u.getComponentName(e);if(!this.isAllowedForScopeAllocation(e))throw new p(p.NotAllowedForScopeAllocationError,`Component of type ${r} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);let n=this.getInstance();if(n._registry.has(e))throw new p(p.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let o=s.isScopeInstance(t)?t:new x(t||{name:r+"-scope"},t);return o.isInheritedFrom(i.root)||o.inherit(i.root),n._registry.set(e,o),n._scopeIssuers.set(o,e),o}static deallocate(e){let t=this.getInstance(),r=s.isScopeInstance(e)?e:t._registry.get(e);if(!r)return;let n=s.isComponentInstance(e)?e:this.issuer(r);n&&t._registry.delete(n),r&&t._scopeIssuers.delete(r);}static meta(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidMetaParameterError,"Invalid parameter provided to get meta. Parameter cannot be null or undefined.");if(!(this.isAllowedForMeta(e)||this.isAllowedForMetaConstructor(e)||s.isString(e)||s.isFunction(e)))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component of type ${t} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);let n,o;switch(true){case s.isContainerInstance(e):{n=e.constructor,o=K;break}case s.isContainerConstructor(e):{n=e,o=K;break}case s.isComponentInstance(e):{n=e.constructor,o=N;break}case s.isComponentConstructor(e):{n=e,o=N;break}case s.isEntityInstance(e):{n=e.constructor,o=N;break}case s.isEntityConstructor(e):{n=e,o=V;break}case s.isFragmentInstance(e):{n=e.constructor,o=N;break}case s.isFragmentConstructor(e):{n=e,o=V;break}case typeof e=="string":{let a=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===g.toKebabCase(e)||_.name===g.toPascalCase(e));if(!(a&&a.length))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=a[0],o=N;break}default:{n=e,o=d;break}}if(!r._metaStorage.has(n)){let a,_=n;for(;!a;){let A=Object.getPrototypeOf(_);if(!A)break;a=r._metaStorage.get(A),_=A;}a||(a=new o),r._metaStorage.set(n,a.clone());}return r._metaStorage.get(n)}static setMeta(e,t){let r=i.getInstance(),n=i.meta(e),o=typeof e=="function"?e:e.constructor;r._metaStorage.set(o,n?t.from(n):t);}static issuer(e){let t=this.getInstance();if(!e)throw new p(p.InvalidComponentParameterError,"Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.");return t._scopeIssuers.get(e)}static scope(e){let t=e?.constructor?.name||String(e),r=this.getInstance();if(!e)throw new p(p.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed for scope allocation.`);switch(true){case this.isAllowedToBeRegistered(e):if(!r._scopeStorage.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`);return r._scopeStorage.get(e);case this.isAllowedForScopeAllocation(e):if(!r._registry.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`);return r._registry.get(e);default:throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed to be registered.`)}}static featureTemplate(e,t,r=this.scope(t)){let n=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureTemplateParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);return [...this.featureDefinition(e,t),...this.featureExtensions(e,t,r)]}static featureExtensions(e,t,r){let n=this.getInstance(),o=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${o} is not allowed for feature definition.`);let a=u.getClassInheritanceChain(t).filter(l=>l!==w&&l!==$&&l!==v).map(l=>`${l.name}.${e}`),_=new Map,A=new Set;for(let l of a)for(let[T,h]of n._metaStorage)r.has(T)&&(s.isComponentMetaInstance(h)||s.isContainerMetaInstance(h))&&(A.add(T),h.extensions(l).forEach(I=>{let D=Array.from(A).reverse().find(O=>u.isInheritedFrom(T,O)&&O!==T);if(D&&_.delete(`${u.getComponentName(D)}.${I.handler}`),I.override){let O=new RegExp(I.override);for(let[Q,U]of _)(O.test(Q)||O.test(U.handler))&&_.delete(Q);}_.set(`${u.getComponentName(T)}.${I.handler}`,{dependency:new Y(T),...I});}));return n.filterToMostDerived(r,Array.from(_.values()))}filterToMostDerived(e,t){return t.filter(r=>{let n=e.resolveConstructor(r.dependency.name);return !t.some(a=>{if(a===r)return false;let _=e.resolveConstructor(a.dependency.name);return !n||!_?false:n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");switch(true){case t instanceof v:r="a-component-features";break;case t instanceof $:r="a-container-features";break;case t instanceof w:r="a-component-features";break;default:throw new p(p.InvalidFeatureTemplateParameterError,`A-Feature cannot be defined on the ${t} level`)}return [...this.meta(t)?.get(r)?.get(e)?.template||[]]}static abstractionTemplate(e,t){let r=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionTemplateParameterError,`Unable to get feature template. Component of type ${r} is not allowed for feature definition.`);return [...this.abstractionExtensions(e,t)]}static abstractionExtensions(e,t){let r=this.getInstance(),n=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let o=new Map,a=this.scope(t),_=new Set;for(let[A,l]of r._metaStorage)a.has(A)&&(s.isComponentMetaInstance(l)||s.isContainerMetaInstance(l))&&(_.add(A),l.abstractions(e).forEach(T=>{let h=Array.from(_).reverse().find(I=>u.isInheritedFrom(A,I)&&I!==A);h&&o.delete(`${u.getComponentName(h)}.${T.handler}`),o.set(`${u.getComponentName(A)}.${T.handler}`,{dependency:new Y(A),...T});}));return r.filterToMostDerived(a,Array.from(o.values()))}static reset(){let e=i.getInstance();e._registry=new WeakMap;let t=String(M.A_CONCEPT_ROOT_SCOPE)||"root";e._root=new x({name:t});}static isAllowedForScopeAllocation(e){return s.isContainerInstance(e)||s.isFeatureInstance(e)||s.isEntityInstance(e)}static isAllowedToBeRegistered(e){return s.isEntityInstance(e)||s.isComponentInstance(e)||s.isFragmentInstance(e)||s.isErrorInstance(e)}static isAllowedForMeta(e){return s.isContainerInstance(e)||s.isComponentInstance(e)||s.isEntityInstance(e)}static isAllowedForMetaConstructor(e){return s.isContainerConstructor(e)||s.isComponentConstructor(e)||s.isEntityConstructor(e)}};var z=class extends y{};z.AbstractionExtensionError="Unable to extend abstraction execution";function fe(i,e={}){return function(t,r,n){let o=u.getComponentName(t);if(!i)throw new z(z.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${o}'.`);if(!s.isConstructorAvailableForAbstraction(t))throw new z(z.AbstractionExtensionError,`Unable to extend Abstraction '${i}' for '${o}'. Only A-Containers and A-Components can extend Abstractions.`);let a,_=c.meta(t);switch(true){case(s.isContainerConstructor(t)||s.isContainerInstance(t)):a="a-container-abstractions";break;case(s.isComponentConstructor(t)||s.isComponentInstance(t)):a="a-component-abstractions";break}let A=`CONCEPT_ABSTRACTION::${i}`,l=_.get(a)?new d().from(_.get(a)):new d,T=[...l.get(A)||[]],h=T.findIndex(D=>D.handler===r),I={name:A,handler:r,behavior:e.behavior||"sync",throwOnError:e.throwOnError!==void 0?e.throwOnError:true,before:s.isArray(e.before)?new RegExp(`^${e.before.join("|").replace(/\./g,"\\.")}$`).source:e.before instanceof RegExp?e.before.source:"",after:s.isArray(e.after)?new RegExp(`^${e.after.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:"",override:s.isArray(e.override)?new RegExp(`^${e.override.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:""};h!==-1?T[h]=I:T.push(I),l.set(A,T),c.meta(t).set(a,l);}}var P=class{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=c.abstractionTemplate(this._name,t);return new b({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return fe}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false})}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};var De=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(De||{}),Fe=(e=>(e.LIFECYCLE="a-component-extensions",e))(Fe||{});var Te=class{constructor(e){this.props=e;this._name=e.name||c.root.name,e.components&&e.components.length&&e.components.forEach(t=>this.scope.register(t)),e.fragments&&e.fragments.length&&e.fragments.forEach(t=>this.scope.register(t)),e.entities&&e.entities.length&&e.entities.forEach(t=>this.scope.register(t)),this._containers=e.containers||[];}static Load(e){return P.Extend("load",e)}static Publish(e){return P.Extend("publish")}static Deploy(e){return P.Extend("deploy",e)}static Build(e){return P.Extend("build",e)}static Run(e){return P.Extend("run",e)}static Start(e){return P.Extend("start",e)}static Stop(e){return P.Extend("stop",e)}get name(){return c.root.name}get scope(){return c.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new P({name:"load",containers:this._containers}).process(e);}async run(e){await new P({name:"run",containers:this._containers}).process(e);}async start(e){await new P({name:"start",containers:this._containers}).process(e);}async stop(e){await new P({name:"stop",containers:this._containers}).process(e);}async build(e){await new P({name:"build",containers:this._containers}).process(e);}async deploy(e){await new P({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new P({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new b({name:e,component:t}).process()}};var Se=class extends d{constructor(t){super();this.containers=t;}};var R=class extends y{};R.InvalidInjectionTarget="Invalid target for A-Inject decorator",R.MissingInjectionTarget="Missing target for A-Inject decorator";function ve(i,e){if(!i)throw new R(R.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let o=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new R(R.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${o})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let A=c.meta(t).get(_)||new d,l=A.get(a)||[];l[n]=i instanceof Y?i:new Y(i,e),A.set(a,l),c.meta(t).set(_,A);}}
2
+ export{C as ASEID,P as A_Abstraction,z as A_AbstractionError,fe as A_Abstraction_Extend,S as A_BasicTypeGuards,M as A_CONCEPT_ENV,Z as A_CONSTANTS__DEFAULT_ENV_VARIABLES,ie as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,H as A_CONSTANTS__ERROR_CODES,Ce as A_CONSTANTS__ERROR_DESCRIPTION,J as A_Caller,B as A_CallerError,u as A_CommonHelper,w as A_Component,N as A_ComponentMeta,Te as A_Concept,Se as A_ConceptMeta,$ as A_Container,K as A_ContainerMeta,c as A_Context,p as A_ContextError,Y as A_Dependency,f as A_DependencyError,Ae as A_Dependency_All,ae as A_Dependency_Default,_e as A_Dependency_Flat,ce as A_Dependency_Load,pe as A_Dependency_Parent,le as A_Dependency_Query,ue as A_Dependency_Require,v as A_Entity,q as A_EntityError,V as A_EntityMeta,y as A_Error,b as A_Feature,m as A_FeatureError,de as A_Feature_Define,me as A_Feature_Extend,g as A_FormatterHelper,k as A_Fragment,j as A_IdentityHelper,ve as A_Inject,R as A_InjectError,d as A_Meta,se as A_MetaDecorator,x as A_Scope,E as A_ScopeError,ee as A_Stage,L as A_StageError,G as A_StepManagerError,W as A_StepsManager,xe as A_TYPES__A_Stage_Status,Ee as A_TYPES__ComponentMetaKey,De as A_TYPES__ConceptAbstractions,Fe as A_TYPES__ConceptMetaKey,Ie as A_TYPES__ContainerMetaKey,oe as A_TYPES__EntityFeatures,Pe as A_TYPES__EntityMetaKey,Ye as A_TYPES__FeatureState,s as A_TypeGuards};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map