@adaas/a-concept 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -78
- package/benchmarks/feature-chaining.bench.ts +465 -0
- package/benchmarks/feature-lifecycle.bench.ts +245 -0
- package/benchmarks/feature-optimize.bench.ts +205 -0
- package/benchmarks/feature-profiling.bench.ts +415 -0
- package/benchmarks/feature-template.bench.ts +211 -0
- package/benchmarks/helpers.ts +97 -0
- package/benchmarks/run-all.ts +58 -0
- package/benchmarks/scope-resolve.bench.ts +245 -0
- package/benchmarks/step-manager.bench.ts +146 -0
- package/dist/browser/index.d.mts +72 -3
- package/dist/browser/index.mjs +2 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/index.cjs +244 -87
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +72 -3
- package/dist/node/index.d.ts +72 -3
- package/dist/node/index.mjs +244 -87
- package/dist/node/index.mjs.map +1 -1
- package/package.json +11 -1
- package/src/lib/A-Context/A-Context.class.ts +155 -60
- package/src/lib/A-Entity/A-Entity.class.ts +3 -3
- package/src/lib/A-Feature/A-Feature.class.ts +46 -41
- package/src/lib/A-Feature/A-Feature.types.ts +6 -10
- package/src/lib/A-Meta/A-Meta.class.ts +18 -3
- package/src/lib/A-Scope/A-Scope.class.ts +98 -5
- package/tests/A-Feature.test.ts +101 -0
- package/tsconfig.json +1 -0
package/dist/browser/index.d.mts
CHANGED
|
@@ -783,6 +783,11 @@ declare class A_Meta<_StorageItems extends Record<any, any> = any, _SerializedTy
|
|
|
783
783
|
* @param key
|
|
784
784
|
* @returns
|
|
785
785
|
*/
|
|
786
|
+
/**
|
|
787
|
+
* Cache for compiled RegExp instances keyed by their string source.
|
|
788
|
+
* Avoids re-compiling the same regex pattern on every find() call.
|
|
789
|
+
*/
|
|
790
|
+
private _regExpCache?;
|
|
786
791
|
private convertToRegExp;
|
|
787
792
|
/**
|
|
788
793
|
* Method to find values in the map by name.
|
|
@@ -1079,7 +1084,7 @@ declare class A_Entity<_ConstructorType extends A_TYPES__Entity_Init = A_TYPES__
|
|
|
1079
1084
|
* @param lifecycleMethod
|
|
1080
1085
|
* @param args
|
|
1081
1086
|
*/
|
|
1082
|
-
call(feature: string, scope?: A_Scope): any;
|
|
1087
|
+
call(feature: string, scope?: A_Scope): Promise<any> | void;
|
|
1083
1088
|
/**
|
|
1084
1089
|
* The default method that can be called and extended to load entity data.
|
|
1085
1090
|
*/
|
|
@@ -1487,8 +1492,10 @@ type A_TYPES__FeatureAvailableComponents = InstanceType<A_TYPES__FeatureAvailabl
|
|
|
1487
1492
|
type A_TYPES__FeatureAvailableConstructors = A_TYPES__Component_Constructor | A_TYPES__Entity_Constructor | A_TYPES__Container_Constructor;
|
|
1488
1493
|
/**
|
|
1489
1494
|
* Indicates a type of Feature Define decorator
|
|
1495
|
+
*
|
|
1496
|
+
* [!] Uses a single generic descriptor to support both sync and async methods
|
|
1490
1497
|
*/
|
|
1491
|
-
type A_TYPES__FeatureDefineDecoratorDescriptor = TypedPropertyDescriptor<(...args: any[]) => any
|
|
1498
|
+
type A_TYPES__FeatureDefineDecoratorDescriptor = TypedPropertyDescriptor<(...args: any[]) => any>;
|
|
1492
1499
|
/**
|
|
1493
1500
|
* Describes additional configuration properties to be used in Feature Define decorator
|
|
1494
1501
|
*/
|
|
@@ -1549,8 +1556,10 @@ type A_TYPES__FeatureDefineDecoratorMeta = {
|
|
|
1549
1556
|
};
|
|
1550
1557
|
/**
|
|
1551
1558
|
* Descriptor type for A_Extend decorator
|
|
1559
|
+
*
|
|
1560
|
+
* [!] Uses a single generic descriptor to support both sync and async methods
|
|
1552
1561
|
*/
|
|
1553
|
-
type A_TYPES__FeatureExtendDecoratorDescriptor = TypedPropertyDescriptor<(
|
|
1562
|
+
type A_TYPES__FeatureExtendDecoratorDescriptor = TypedPropertyDescriptor<(...args: any[]) => any>;
|
|
1554
1563
|
/**
|
|
1555
1564
|
* Target type for A_Extend decorator
|
|
1556
1565
|
*
|
|
@@ -2004,6 +2013,7 @@ declare class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES_
|
|
|
2004
2013
|
* Process stages one by one, ensuring each stage completes before starting the next
|
|
2005
2014
|
*/
|
|
2006
2015
|
private processStagesSequentially;
|
|
2016
|
+
private createStageError;
|
|
2007
2017
|
/**
|
|
2008
2018
|
* This method moves the feature to the next stage
|
|
2009
2019
|
*
|
|
@@ -2978,6 +2988,15 @@ type A_TYPES_ScopeDependentComponents = A_Component | A_Entity | A_Fragment | A_
|
|
|
2978
2988
|
type A_TYPES_ScopeIndependentComponents = A_Error | A_Scope | A_Caller;
|
|
2979
2989
|
|
|
2980
2990
|
declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentType extends A_TYPES__Component_Constructor[] = A_TYPES__Component_Constructor[], _ErrorType extends A_TYPES__Error_Constructor[] = A_TYPES__Error_Constructor[], _EntityType extends A_TYPES__Entity_Constructor[] = A_TYPES__Entity_Constructor[], _FragmentType extends A_Fragment[] = A_Fragment[]> {
|
|
2991
|
+
/**
|
|
2992
|
+
* Auto-incrementing counter for generating unique scope IDs.
|
|
2993
|
+
*/
|
|
2994
|
+
private static _nextUid;
|
|
2995
|
+
/**
|
|
2996
|
+
* Unique numeric ID for this scope instance. Used as a cache key discriminator
|
|
2997
|
+
* to prevent collisions between scopes with the same name or version.
|
|
2998
|
+
*/
|
|
2999
|
+
readonly uid: number;
|
|
2981
3000
|
/**
|
|
2982
3001
|
* Scope Name uses for identification and logging purposes
|
|
2983
3002
|
*/
|
|
@@ -2992,6 +3011,20 @@ declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentTy
|
|
|
2992
3011
|
* throughout the execution pipeline or within running containers.
|
|
2993
3012
|
*/
|
|
2994
3013
|
protected _meta: A_Meta<_MetaItems>;
|
|
3014
|
+
/**
|
|
3015
|
+
* Monotonically increasing version counter. Incremented on every mutation
|
|
3016
|
+
* (register, deregister, import, deimport, inherit, destroy) so that
|
|
3017
|
+
* external caches (e.g. A_Context feature-extension cache) can detect
|
|
3018
|
+
* staleness cheaply via numeric comparison.
|
|
3019
|
+
*/
|
|
3020
|
+
protected _version: number;
|
|
3021
|
+
/**
|
|
3022
|
+
* Cache for resolveConstructor results (both positive and negative).
|
|
3023
|
+
* Key = constructor name (string) or constructor reference toString.
|
|
3024
|
+
* Value = resolved constructor or `null` for negative results.
|
|
3025
|
+
* Invalidated by incrementing _version (cache is cleared on bump).
|
|
3026
|
+
*/
|
|
3027
|
+
protected _resolveConstructorCache: Map<string | Function, Function | null>;
|
|
2995
3028
|
/**
|
|
2996
3029
|
* A set of allowed components, A set of constructors that are allowed in the scope
|
|
2997
3030
|
*
|
|
@@ -3053,6 +3086,11 @@ declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentTy
|
|
|
3053
3086
|
* Returns a list of Constructors for A-Errors that are available in the scope
|
|
3054
3087
|
*/
|
|
3055
3088
|
get allowedErrors(): Set<_ErrorType[number]>;
|
|
3089
|
+
/**
|
|
3090
|
+
* Returns the current version of the scope. Each mutation increments the version,
|
|
3091
|
+
* allowing external caches to detect staleness via numeric comparison.
|
|
3092
|
+
*/
|
|
3093
|
+
get version(): number;
|
|
3056
3094
|
/**
|
|
3057
3095
|
* Returns an Array of entities registered in the scope
|
|
3058
3096
|
*
|
|
@@ -3089,6 +3127,11 @@ declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentTy
|
|
|
3089
3127
|
* @returns
|
|
3090
3128
|
*/
|
|
3091
3129
|
get parent(): A_Scope | undefined;
|
|
3130
|
+
/**
|
|
3131
|
+
* Increments the scope version and clears internal caches.
|
|
3132
|
+
* Must be called on every scope mutation (register, deregister, import, deimport, inherit, destroy).
|
|
3133
|
+
*/
|
|
3134
|
+
protected bumpVersion(): void;
|
|
3092
3135
|
/**
|
|
3093
3136
|
* A_Scope is a unique A-Concept Structure that allows to operate with A-Concept Primitives and Models in a specific context and with specific rules.
|
|
3094
3137
|
* It refers to the visibility and accessibility of :
|
|
@@ -3388,6 +3431,11 @@ declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentTy
|
|
|
3388
3431
|
*/
|
|
3389
3432
|
error: A_TYPES__Ctor<T>): A_TYPES__Error_Constructor<T> | undefined;
|
|
3390
3433
|
resolveConstructor<T extends A_TYPES__A_DependencyInjectable>(name: string | A_TYPES__Ctor<T>): A_TYPES__Entity_Constructor<T> | A_TYPES__Component_Constructor<T> | A_TYPES__Fragment_Constructor<T> | undefined;
|
|
3434
|
+
/**
|
|
3435
|
+
* Internal uncached implementation of resolveConstructor for string names.
|
|
3436
|
+
* Separated to allow the public method to wrap with caching.
|
|
3437
|
+
*/
|
|
3438
|
+
private _resolveConstructorUncached;
|
|
3391
3439
|
/**
|
|
3392
3440
|
* This method should resolve all instances of the components, or entities within the scope, by provided parent class
|
|
3393
3441
|
* So in case of providing a base class it should return all instances that extends this base class
|
|
@@ -4151,6 +4199,23 @@ declare class A_Context {
|
|
|
4151
4199
|
* Meta provides to store extra information about the class behavior and configuration.
|
|
4152
4200
|
*/
|
|
4153
4201
|
protected _metaStorage: Map<A_TYPES__MetaLinkedComponentConstructors, A_Meta>;
|
|
4202
|
+
/**
|
|
4203
|
+
* Monotonically increasing version counter for _metaStorage.
|
|
4204
|
+
* Incremented whenever a new entry is added to _metaStorage so that
|
|
4205
|
+
* caches depending on meta content can detect staleness.
|
|
4206
|
+
*/
|
|
4207
|
+
protected _metaVersion: number;
|
|
4208
|
+
/**
|
|
4209
|
+
* Cache for featureExtensions results.
|
|
4210
|
+
* Key format: `${featureName}::${componentConstructorName}::${scopeVersion}::${metaVersion}`
|
|
4211
|
+
* Automatically invalidated when scope version or meta version changes.
|
|
4212
|
+
*/
|
|
4213
|
+
protected _featureExtensionsCache: Map<string, Array<A_TYPES__A_StageStep>>;
|
|
4214
|
+
/**
|
|
4215
|
+
* Maximum number of entries in the featureExtensions cache.
|
|
4216
|
+
* When exceeded, the entire cache is cleared to prevent unbounded growth.
|
|
4217
|
+
*/
|
|
4218
|
+
protected static readonly FEATURE_EXTENSIONS_CACHE_MAX_SIZE = 1024;
|
|
4154
4219
|
protected _globals: Map<string, any>;
|
|
4155
4220
|
/**
|
|
4156
4221
|
* Private constructor to enforce singleton pattern.
|
|
@@ -4408,6 +4473,10 @@ declare class A_Context {
|
|
|
4408
4473
|
/**
|
|
4409
4474
|
* method helps to filter steps in a way that only the most derived classes are kept.
|
|
4410
4475
|
*
|
|
4476
|
+
* Optimized: Uses a pre-built constructor→class map and single-pass prototype chain
|
|
4477
|
+
* walk to eliminate parent classes in O(n·d) where d is inheritance depth,
|
|
4478
|
+
* instead of the previous O(n²) with isPrototypeOf checks.
|
|
4479
|
+
*
|
|
4411
4480
|
* @param scope
|
|
4412
4481
|
* @param items
|
|
4413
4482
|
* @returns
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var k=class{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};var xe=(i=>(i.INITIALIZED="INITIALIZED",i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.INTERRUPTED="INTERRUPTED",i.FAILED="FAILED",i))(xe||{});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 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 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("@"),[i,a,_]=r.split(":"),A=_.includes(".")?_.split(".")[0]:void 0,l=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=i||c.root.name,this._entity=a,this._id=l,this._version=n,this._shard=A;}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)?j.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)?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)&&!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 Z={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},Ie="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 W={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=[W.A_CONCEPT_NAME,W.A_CONCEPT_ROOT_SCOPE,W.A_CONCEPT_ENVIRONMENT,W.A_CONCEPT_RUNTIME_ENVIRONMENT,W.A_CONCEPT_ROOT_FOLDER,W.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 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(M.A_ERROR_DEFAULT_DESCRIPTION)||Ie}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(Z.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=Z.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=Z.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(Z.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new o(Z.VALIDATION_ERROR,"A-Error title cannot be empty.")}};var q=class extends y{};q.ValidationError="A-Entity Validation Error";var be=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(be||{}),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(o){return function(e){return c.setMeta(e,new o),e}}var d=class o{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 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 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 Ye=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Ye||{});var J=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 A=n?.get(_.handler)||[];t.push({..._,args:A});});}),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 B=class extends Error{};B.CallerInitializationError="Unable to initialize A-Caller";var K=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(...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,A=_.get(i)||[];A[r].resolutionStrategy={create:true,args:o},_.set(i,A),c.meta(e).set(a,_);}}function _e(){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 ce(){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 pe(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,A=_.get(i)||[];A[r].resolutionStrategy={parent:o},_.set(i,A),c.meta(e).set(a,_);}}function ue(){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 Ae(){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 le(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 A=c.meta(t).get(_)||new d,l=A.get(a)||[];l[n].resolutionStrategy={query:{...l[n].resolutionStrategy.query,...o},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 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,$)}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,K)}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 J}static isEntityMetaInstance(e){return e instanceof V}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,k)||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 de(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,A=o.name||t,l=o.invoke||false;_.set(t,{name:`${e.constructor.name}.${A}`,handler:t,invoke:l,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(l)T.apply(this,h);else return T.apply(this,h);if(typeof this.call=="function"&&l)return this.call(A)},r}}function me(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",_="",A="",l="",T=[],h=[],I=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=Fe(o,T,h,t),a=o.behavior||a,I=o.throwOnError!==void 0?o.throwOnError:I,_=s.isArray(o.before)?new RegExp(`^${o.before.join("|").replace(/\./g,"\\.")}$`).source:o.before instanceof RegExp?o.before.source:"",A=s.isArray(o.after)?new RegExp(`^${o.after.join("|").replace(/\./g,"\\.")}$`).source:o.after instanceof RegExp?o.after.source:"",l=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 O=c.meta(e).get(F),X=c.meta(e),U=X.get(F)?new d().from(X.get(F)):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(i.source)||[]],we=o&&typeof o=="object"&&!s.isRegExp(o)&&o.name||t;for(let[H,re]of U.entries()){let ge=re.findIndex(Ce=>Ce.handler===t);if(H!==i.source&&ge!==-1){let Pe=String(H).match(/\\\.\s*([^\\.$]+)\$$/);(Pe?Pe[1]:null)===we&&(re.splice(ge,1),re.length===0?U.delete(H):U.set(H,re));}}let ye=te.findIndex(H=>H.handler===t),he={name:i.source,handler:t,behavior:a,before:_,after:A,throwOnError:I,override:l};ye!==-1?te[ye]=he:te.push(he),U.set(i.source,te),c.meta(e).set(F,U);}}function Fe(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 De=(a=>(a.PROCESSING="PROCESSING",a.COMPLETED="COMPLETED",a.FAILED="FAILED",a.SKIPPED="SKIPPED",a.INITIALIZED="INITIALIZED",a.ABORTED="ABORTED",a))(De||{});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,i=e.resolve(r)||this.feature.scope.resolve(r);if(!i)throw new L(L.CompileError,`Unable to resolve component ${r.name} from scope ${e.name}`);if(!i[n])throw new L(L.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(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 Q=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 i=t.get(n)||0;this._uniqueIdMap.set(r,`${n}#${i}`),t.set(n,i+1);}else this._uniqueIdMap.set(r,n);}}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some((n,i)=>{if(t===i||!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(i=>this.ID(i)===r);return new ee(e,n)})}};var b=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 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(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new K(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new Q(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 K(e.component);let n=c.allocate(this);n.inherit(t||r);let i=c.featureTemplate(this._name,this._caller.component,n);this._SM=new Q(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(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,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: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(([i,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,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),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(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 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(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(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 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=J;break}case s.isContainerConstructor(e):{n=e,i=J;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=V;break}case s.isFragmentInstance(e):{n=e.constructor,i=N;break}case s.isFragmentConstructor(e):{n=e,i=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],i=N;break}default:{n=e,i=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 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(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 F=Array.from(A).reverse().find(O=>u.isInheritedFrom(T,O)&&O!==T);if(F&&_.delete(`${u.getComponentName(F)}.${I.handler}`),I.override){let O=new RegExp(I.override);for(let[X,U]of _)(O.test(X)||O.test(U.handler))&&_.delete(X);}_.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 i=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&&i.delete(`${u.getComponentName(h)}.${T.handler}`),i.set(`${u.getComponentName(A)}.${T.handler}`,{dependency:new Y(A),...T});}));return r.filterToMostDerived(a,Array.from(i.values()))}static reset(){let e=o.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(o,e={}){return function(t,r,n){let i=u.getComponentName(t);if(!o)throw new z(z.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${i}'.`);if(!s.isConstructorAvailableForAbstraction(t))throw new z(z.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 A=`CONCEPT_ABSTRACTION::${o}`,l=_.get(a)?new d().from(_.get(a)):new d,T=[...l.get(A)||[]],h=T.findIndex(F=>F.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 ve=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(ve||{}),Ne=(e=>(e.LIFECYCLE="a-component-extensions",e))(Ne||{});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 Oe(o,e){if(!o)throw new R(R.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 R(R.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 A=c.meta(t).get(_)||new d,l=A.get(a)||[];l[n]=o instanceof Y?o:new Y(o,e),A.set(a,l),c.meta(t).set(_,A);}}
|
|
2
|
-
export{
|
|
1
|
+
var U=class{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};var Ne=(o=>(o.INITIALIZED="INITIALIZED",o.PROCESSING="PROCESSING",o.COMPLETED="COMPLETED",o.INTERRUPTED="INTERRUPTED",o.FAILED="FAILED",o))(Ne||{});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 V=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 h=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 O=class O{static isASEID(e){return this.regexp.test(e)}static compare(e,t){if(!e||!t)return false;if(h.isString(e)&&this.isASEID(e)===false)throw new Error(`Invalid ASEID format provided: ${e}`);if(h.isString(t)&&this.isASEID(t)===false)throw new Error(`Invalid ASEID format provided: ${t}`);let r=e instanceof O?e:new O(e),n=t instanceof O?t:new O(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 V.hashString(this.toString())}getInitializer(e){switch(true){case h.isString(e):return this.fromString;case h.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(":"),d=_.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=d;}fromObject(e){this._concept=e.concept?O.isASEID(e.concept)?new O(e.concept).id:e.concept:c.concept,this._scope=e.scope?h.isNumber(e.scope)?V.formatWithLeadingZeros(e.scope):O.isASEID(e.scope)?new O(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=h.isNumber(e.id)?V.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(h.isString(e)&&!O.isASEID(e)):throw new Error("Invalid ASEID format provided");case(h.isObject(e)&&!e.id):throw new Error("ASEID id is required");case(h.isObject(e)&&!e.entity):throw new Error("ASEID entity is required")}}};O.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 I=O;var ne={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},xe="If you see this error please let us know.";var pe=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 oe={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"},Ae=[oe.A_CONCEPT_NAME,oe.A_CONCEPT_ROOT_SCOPE,oe.A_CONCEPT_ENVIRONMENT,oe.A_CONCEPT_RUNTIME_ENVIRONMENT,oe.A_CONCEPT_ROOT_FOLDER,oe.A_ERROR_DEFAULT_DESCRIPTION];var k=class extends pe{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];}),Ae.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);}),Ae.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 h.isErrorSerializedType(e):super(e.message);break;case(h.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(h.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(h.isString(e)&&!t):super(e);break;case(h.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(k.A_ERROR_DEFAULT_DESCRIPTION)||xe}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(h.isString(e)&&!t):return this.fromMessage;case(h.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case h.isErrorSerializedType(e):return this.fromJSON;case h.isErrorConstructorType(e):return this.fromConstructor;default:throw new i(ne.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=ne.UNEXPECTED_ERROR,this._aseid=new I({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=ne.UNEXPECTED_ERROR,this._aseid=new I({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 I(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 I({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?h.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new I({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(ne.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new i(ne.VALIDATION_ERROR,"A-Error title cannot be empty.")}};var ee=class extends y{};ee.ValidationError="A-Entity Validation Error";var Fe=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(Fe||{}),ue={SAVE:"_A_Entity__Save",DESTROY:"_A_Entity__Destroy",LOAD:"_A_Entity__Load"};var M=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"&&I.isASEID(e)}isASEIDInstance(e){return e instanceof I}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 ee(ee.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new I({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||V.generateTimeId()})}call(e,t){return new Y({name:e,component:this,scope:t}).process(t)}load(e){return this.call(ue.LOAD,e)}destroy(e){return this.call(ue.DESTROY,e)}save(e){return this.call(ue.SAVE,e)}fromASEID(e){e instanceof I?this.aseid=e:this.aseid=new I(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new I(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};function me(i){return function(e){return c.setMeta(e,new i),e}}var A=class i{constructor(){this.meta=new Map;}static Define(e){return me(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){if(e instanceof RegExp)return e;this._regExpCache||(this._regExpCache=new Map);let t=this._regExpCache.get(e);return t||(t=new RegExp(e),this._regExpCache.set(e,t)),t}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 G=class extends A{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};var z=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 Y({name:e,component:this}).process(t)}};var ve=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(ve||{});var Z=class extends A{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 d=n?.get(_.handler)||[];t.push({..._,args:d});});}),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 te=class extends Error{};te.CallerInitializationError="Unable to initialize A-Caller";var W=class{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!s.isAllowedForFeatureCall(e))throw new te(`[${te.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 Ee(...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 A,d=_.get(o)||[];d[r].resolutionStrategy={create:true,args:i},_.set(o,d),c.meta(e).set(a,_);}}function fe(){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 A,_=a.get(n)||[];_[t].resolutionStrategy={flat:true},a.set(n,_),c.meta(i).set(o,a);}}function Te(){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 A,_=a.get(n)||[];_[t].resolutionStrategy={load:true},a.set(n,_),c.meta(i).set(o,a);}}function Se(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 A,d=_.get(o)||[];d[r].resolutionStrategy={parent:i},_.set(o,d),c.meta(e).set(a,_);}}function he(){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 A,_=a.get(n)||[];_[t].resolutionStrategy={require:true},a.set(n,_),c.meta(i).set(o,a);}}function ye(){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 A,_=a.get(n)||[];_[t].resolutionStrategy={pagination:{..._[t].resolutionStrategy.pagination,count:-1}},a.set(n,_),c.meta(i).set(o,a);}}function ge(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 d=c.meta(t).get(_)||new A,l=d.get(a)||[];l[n].resolutionStrategy={query:{...l[n].resolutionStrategy.query,...i},pagination:{...l[n].resolutionStrategy.pagination,...e}},d.set(a,l),c.meta(t).set(_,d);}}var x=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 he}static get Loaded(){return Te}static get Default(){return Ee}static get Parent(){return Se}static get Flat(){return fe}static get All(){return ye}static get Query(){return ge}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,z)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,F)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,U)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,M)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Error)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,W)}static isDependencyConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isDependencyInstance(e){return e instanceof x}static isContainerInstance(e){return e instanceof z}static isComponentInstance(e){return e instanceof F}static isFeatureInstance(e){return e instanceof Y}static isFragmentInstance(e){return e instanceof U}static isEntityInstance(e){return e instanceof M}static isScopeInstance(e){return e instanceof v}static isErrorInstance(e){return e instanceof Error}static isComponentMetaInstance(e){return e instanceof R}static isContainerMetaInstance(e){return e instanceof Z}static isEntityMetaInstance(e){return e instanceof G}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,U)||i.isEntityConstructor(e)||u.isInheritedFrom(e,M)}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.isASEID(e.aseid)}static isPromiseInstance(e){return e instanceof Promise}};function Ce(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 A,d=i.name||t,l=i.invoke||false;_.set(t,{name:`${e.constructor.name}.${d}`,handler:t,invoke:l,template:i.template&&i.template.length?i.template.map(T=>({...T,before:T.before||"",after:T.after||"",behavior:T.behavior||"sync",throwOnError:true,override:T.override||""})):[]}),c.meta(e.constructor).set(a,_);let S=r.value;return r.value=function(...T){if(l)S.apply(this,T);else return S.apply(this,T);if(typeof this.call=="function"&&l)return this.call(d)},r}}function Pe(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",_="",d="",l="",S=[],T=[],w=true,N;switch(true){case s.isEntityInstance(e):N="a-component-extensions";break;case s.isContainerInstance(e):N="a-container-extensions";break;case s.isComponentInstance(e):N="a-component-extensions";break}switch(true){case s.isRegExp(i):o=i;break;case(!!i&&typeof i=="object"):Array.isArray(i.scope)?S=i.scope:i.scope&&typeof i.scope=="object"&&(Array.isArray(i.scope.include)&&(S=i.scope.include),Array.isArray(i.scope.exclude)&&(T=i.scope.exclude)),o=Oe(i,S,T,t),a=i.behavior||a,w=i.throwOnError!==void 0?i.throwOnError:w,_=s.isArray(i.before)?new RegExp(`^${i.before.join("|").replace(/\./g,"\\.")}$`).source:i.before instanceof RegExp?i.before.source:"",d=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 X=c.meta(e).get(N),_e=c.meta(e),$=_e.get(N)?new A().from(_e.get(N)):new A;if(X&&X.size()&&X.has(t)&&X.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 Q=[...$.get(o.source)||[]],P=i&&typeof i=="object"&&!s.isRegExp(i)&&i.name||t;for(let[L,q]of $.entries()){let B=q.findIndex(se=>se.handler===t);if(L!==o.source&&B!==-1){let H=String(L).match(/\\\.\s*([^\\.$]+)\$$/);(H?H[1]:null)===P&&(q.splice(B,1),q.length===0?$.delete(L):$.set(L,q));}}let C=Q.findIndex(L=>L.handler===t),ce={name:o.source,handler:t,behavior:a,before:_,after:d,throwOnError:w,override:l};C!==-1?Q[C]=ce:Q.push(ce),$.set(o.source,Q),c.meta(e).set(N,$);}}function Oe(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 Me=(a=>(a.PROCESSING="PROCESSING",a.COMPLETED="COMPLETED",a.FAILED="FAILED",a.SKIPPED="SKIPPED",a.INITIALIZED="INITIALIZED",a.ABORTED="ABORTED",a))(Me||{});var K=class extends y{static get CompileError(){return "Unable to compile A-Stage"}};K.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var ae=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 K(K.CompileError,`Unable to resolve component ${r.name} from scope ${e.name}`);if(!o[n])throw new K(K.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(d){let l=new y(d);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 re=class extends y{};re.CircularDependencyError="A-StepManager Circular Dependency Error";var ie=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 ae(e,n)})}};var Y=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 Ce}static get Extend(){return Pe}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 v)))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 W(e.component||new F),c.allocate(this).inherit(t||r),this._SM=new ie(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 W(e.component);let n=c.allocate(this);n.inherit(t||r);let o=c.featureTemplate(this._name,this._caller.component,n);this._SM=new ie(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){for(;r<e.length;){if(this.state==="INTERRUPTED")return;let n=e[r],o;try{o=n.process(t);}catch(a){throw this.createStageError(a,n)}if(s.isPromiseInstance(o))return o.then(()=>{if(this.state!=="INTERRUPTED")return this.processStagesSequentially(e,t,r+1)}).catch(a=>{throw this.createStageError(a,n)});r++;}this.state!=="INTERRUPTED"&&this.completed();}createStageError(e,t){return this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${t.name}.`,stage:t,originalError:e})),new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${t.name}.`,stage:t,originalError:e})}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 v?t:void 0):(n=new i({name:t,component:e}),o=r instanceof v?r:void 0);let a=o||this.scope;n._caller=this._caller;let _=n.process(a);return s.isPromiseInstance(_)?_.catch(d=>{throw d}):_}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};var F=class{call(e,t){return new Y({name:e,component:this}).process(t)}};var Ie=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(Ie||{});var R=class extends A{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 d=n?.get(_.handler)||[];t.push({..._,args:d});});}),t}};var de=class de{constructor(e,t){this.uid=de._nextUid++;this._meta=new A;this._version=0;this._resolveConstructorCache=new Map;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 version(){return this._version}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}bumpVersion(){this._version++,this._resolveConstructorCache.clear();}*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),this.bumpVersion();}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.bumpVersion(),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.bumpVersion());}),this}deimport(...e){return e.forEach(t=>{this._imports.has(t)&&(this._imports.delete(t),this.bumpVersion());}),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)&&I.compare(l.aseid,e.query.aseid)):Object.keys(e.query).length>0&&(t=t.filter(l=>{let S=e.query;return S?Object.entries(S).every(([T,w])=>l[T]===w):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),d=t.slice(a,_);return d.length===1&&n!==-1?d[0]:d.length?d:void 0}resolveConstructor(e){switch(true){case s.isComponentConstructor(e):return Array.from(this.allowedComponents).find(n=>u.isInheritedFrom(n,e));case s.isEntityConstructor(e):return Array.from(this.allowedEntities).find(n=>u.isInheritedFrom(n,e));case s.isFragmentConstructor(e):return Array.from(this.allowedFragments).find(n=>u.isInheritedFrom(n,e));case s.isErrorConstructor(e):return Array.from(this.allowedErrors).find(n=>u.isInheritedFrom(n,e))}if(!s.isString(e))throw new E(E.ResolutionError,`Invalid constructor name provided: ${e}`);let t=e;if(this._resolveConstructorCache.has(t)){let n=this._resolveConstructorCache.get(t);return n===null?void 0:n}let r=this._resolveConstructorUncached(e);return this._resolveConstructorCache.set(t,r??null),r}_resolveConstructorUncached(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 x(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 F:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e),this.bumpVersion();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),this.bumpVersion();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),this.bumpVersion();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),this.bumpVersion();break}case s.isComponentConstructor(e):{this.allowedComponents.has(e)||(this.allowedComponents.add(e),this.bumpVersion());break}case s.isFragmentConstructor(e):{this.allowedFragments.has(e)||(this.allowedFragments.add(e),this.bumpVersion());break}case s.isEntityConstructor(e):{this.allowedEntities.has(e)||(this.allowedEntities.add(e),this.bumpVersion());break}case s.isErrorConstructor(e):{this.allowedErrors.has(e)||(this.allowedErrors.add(e),this.bumpVersion());break}default:if(e instanceof M)throw new E(E.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof U)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 F:{this._components.delete(e.constructor),c.deregister(e);let r=e.constructor;this._components.has(r)||this.allowedComponents.delete(r),this.bumpVersion();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),this.bumpVersion();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),this.bumpVersion();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),this.bumpVersion();break}case s.isComponentConstructor(e):{this.allowedComponents.delete(e),this.bumpVersion();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));}),this.bumpVersion();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));}),this.bumpVersion();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));}),this.bumpVersion();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(" -> "));}};de._nextUid=0;var v=de;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 D=class D{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;this._metaVersion=0;this._featureExtensionsCache=new Map;this._globals=new Map;let e=String(k.A_CONCEPT_ROOT_SCOPE)||"root";this._root=new v({name:e});}static get concept(){return k.A_CONCEPT_NAME||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){return k.A_CONCEPT_RUNTIME_ENVIRONMENT}static getInstance(){return D._instance||(D._instance=new D),D._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 v(t||{name:r+"-scope"},t);return o.isInheritedFrom(D.root)||o.inherit(D.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=Z;break}case s.isContainerConstructor(e):{n=e,o=Z;break}case s.isComponentInstance(e):{n=e.constructor,o=R;break}case s.isComponentConstructor(e):{n=e,o=R;break}case s.isEntityInstance(e):{n=e.constructor,o=R;break}case s.isEntityConstructor(e):{n=e,o=G;break}case s.isFragmentInstance(e):{n=e.constructor,o=R;break}case s.isFragmentConstructor(e):{n=e,o=G;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=R;break}default:{n=e,o=A;break}}if(!r._metaStorage.has(n)){let a,_=n;for(;!a;){let d=Object.getPrototypeOf(_);if(!d)break;a=r._metaStorage.get(d),_=d;}a||(a=new o),r._metaStorage.set(n,a.clone()),r._metaVersion++;}return r._metaStorage.get(n)}static setMeta(e,t){let r=D.getInstance(),n=D.meta(e),o=typeof e=="function"?e:e.constructor;r._metaStorage.set(o,n?t.from(n):t),r._metaVersion++;}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)){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 ${u.getComponentName(t)} 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();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 ${u.getComponentName(t)} is not allowed for feature definition.`);let o=typeof t=="function"?t:t.constructor,a=r.parent||r,_=`${String(e)}::${o.name}::s${a.uid}v${a.version}::m${n._metaVersion}`,d=n._featureExtensionsCache.get(_);if(d)return d;let l=u.getClassInheritanceChain(t).filter(P=>P!==F&&P!==z&&P!==M).map(P=>`${P.name}.${e}`),S=new Map,T=new Set,w=new Map,N=new Map,X=P=>{let C=w.get(P);return C===void 0&&(C=u.getComponentName(P),w.set(P,C)),C},_e=P=>{let C=N.get(P);return C||(C=new x(P),N.set(P,C)),C},$=[];for(let[P,C]of n._metaStorage)r.has(P)&&(s.isComponentMetaInstance(C)||s.isContainerMetaInstance(C))&&$.push([P,C]);for(let P of l)for(let[C,ce]of $){T.add(C);let L=ce.extensions(P);for(let q=0;q<L.length;q++){let B=L[q],se=Array.from(T).reverse().find(H=>u.isInheritedFrom(C,H)&&H!==C);if(se&&S.delete(`${X(se)}.${B.handler}`),B.override){let H=new RegExp(B.override);for(let[le,De]of S)(H.test(le)||H.test(De.handler))&&S.delete(le);}S.set(`${X(C)}.${B.handler}`,{dependency:_e(C),...B});}}let Q=n.filterToMostDerived(r,Array.from(S.values()));return n._featureExtensionsCache.size>=D.FEATURE_EXTENSIONS_CACHE_MAX_SIZE&&n._featureExtensionsCache.clear(),n._featureExtensionsCache.set(_,Q),Q}filterToMostDerived(e,t){if(t.length<=1)return t;let r=new Map,n=new Set;for(let _ of t){let d=_.dependency.name;r.has(d)||r.set(d,e.resolveConstructor(d)),n.add(d);}let o=new Set,a=new Map;for(let[_,d]of r)d&&a.set(d,_);for(let[_,d]of r){if(!d)continue;let l=Object.getPrototypeOf(d.prototype);for(;l&&l!==Object.prototype;){let S=l.constructor,T=a.get(S);T&&T!==_&&n.has(T)&&o.add(T),l=Object.getPrototypeOf(l);}}return t.filter(_=>!o.has(_.dependency.name))}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 M:r="a-component-features";break;case t instanceof z:r="a-container-features";break;case t instanceof F: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[d,l]of r._metaStorage)a.has(d)&&(s.isComponentMetaInstance(l)||s.isContainerMetaInstance(l))&&(_.add(d),l.abstractions(e).forEach(S=>{let T=Array.from(_).reverse().find(w=>u.isInheritedFrom(d,w)&&w!==d);T&&o.delete(`${u.getComponentName(T)}.${S.handler}`),o.set(`${u.getComponentName(d)}.${S.handler}`,{dependency:new x(d),...S});}));return r.filterToMostDerived(a,Array.from(o.values()))}static reset(){let e=D.getInstance();e._registry=new WeakMap,e._featureExtensionsCache.clear(),e._metaVersion++;let t=String(k.A_CONCEPT_ROOT_SCOPE)||"root";e._root=new v({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)}};D.FEATURE_EXTENSIONS_CACHE_MAX_SIZE=1024;var c=D;var J=class extends y{};J.AbstractionExtensionError="Unable to extend abstraction execution";function be(i,e={}){return function(t,r,n){let o=u.getComponentName(t);if(!i)throw new J(J.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${o}'.`);if(!s.isConstructorAvailableForAbstraction(t))throw new J(J.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 d=`CONCEPT_ABSTRACTION::${i}`,l=_.get(a)?new A().from(_.get(a)):new A,S=[...l.get(d)||[]],T=S.findIndex(N=>N.handler===r),w={name:d,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:""};T!==-1?S[T]=w:S.push(w),l.set(d,S),c.meta(t).set(a,l);}}var b=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 Y({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return be}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 Re=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(Re||{}),ke=(e=>(e.LIFECYCLE="a-component-extensions",e))(ke||{});var Ye=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 b.Extend("load",e)}static Publish(e){return b.Extend("publish")}static Deploy(e){return b.Extend("deploy",e)}static Build(e){return b.Extend("build",e)}static Run(e){return b.Extend("run",e)}static Start(e){return b.Extend("start",e)}static Stop(e){return b.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 b({name:"load",containers:this._containers}).process(e);}async run(e){await new b({name:"run",containers:this._containers}).process(e);}async start(e){await new b({name:"start",containers:this._containers}).process(e);}async stop(e){await new b({name:"stop",containers:this._containers}).process(e);}async build(e){await new b({name:"build",containers:this._containers}).process(e);}async deploy(e){await new b({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new b({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new Y({name:e,component:t}).process()}};var we=class extends A{constructor(t){super();this.containers=t;}};var j=class extends y{};j.InvalidInjectionTarget="Invalid target for A-Inject decorator",j.MissingInjectionTarget="Missing target for A-Inject decorator";function je(i,e){if(!i)throw new j(j.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 j(j.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 d=c.meta(t).get(_)||new A,l=d.get(a)||[];l[n]=i instanceof x?i:new x(i,e),d.set(a,l),c.meta(t).set(_,d);}}
|
|
2
|
+
export{I as ASEID,b as A_Abstraction,J as A_AbstractionError,be as A_Abstraction_Extend,h as A_BasicTypeGuards,k as A_CONCEPT_ENV,oe as A_CONSTANTS__DEFAULT_ENV_VARIABLES,Ae as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,ne as A_CONSTANTS__ERROR_CODES,xe as A_CONSTANTS__ERROR_DESCRIPTION,W as A_Caller,te as A_CallerError,u as A_CommonHelper,F as A_Component,R as A_ComponentMeta,Ye as A_Concept,we as A_ConceptMeta,z as A_Container,Z as A_ContainerMeta,c as A_Context,p as A_ContextError,x as A_Dependency,f as A_DependencyError,ye as A_Dependency_All,Ee as A_Dependency_Default,fe as A_Dependency_Flat,Te as A_Dependency_Load,Se as A_Dependency_Parent,ge as A_Dependency_Query,he as A_Dependency_Require,M as A_Entity,ee as A_EntityError,G as A_EntityMeta,y as A_Error,Y as A_Feature,m as A_FeatureError,Ce as A_Feature_Define,Pe as A_Feature_Extend,g as A_FormatterHelper,U as A_Fragment,V as A_IdentityHelper,je as A_Inject,j as A_InjectError,A as A_Meta,me as A_MetaDecorator,v as A_Scope,E as A_ScopeError,ae as A_Stage,K as A_StageError,re as A_StepManagerError,ie as A_StepsManager,Me as A_TYPES__A_Stage_Status,Ie as A_TYPES__ComponentMetaKey,Re as A_TYPES__ConceptAbstractions,ke as A_TYPES__ConceptMetaKey,ve as A_TYPES__ContainerMetaKey,ue as A_TYPES__EntityFeatures,Fe as A_TYPES__EntityMetaKey,Ne as A_TYPES__FeatureState,s as A_TypeGuards};//# sourceMappingURL=index.mjs.map
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|