@adaas/a-concept 0.3.2 → 0.3.3

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.
@@ -738,6 +738,12 @@ declare class A_Meta<_StorageItems extends Record<any, any> = any, _SerializedTy
738
738
  * @returns
739
739
  */
740
740
  from(meta: A_Meta<_StorageItems>): A_Meta<_StorageItems>;
741
+ /**
742
+ * Allows to create a copy of the meta object with the same values, this is needed to ensure that when we inherit meta from the parent component, we create a copy of it, not a reference to the same object. This allows us to modify the meta of the child component without affecting the meta of the parent component.
743
+ *
744
+ * @returns
745
+ */
746
+ clone(): A_Meta<_StorageItems>;
741
747
  /**
742
748
  * Method to set values in the map
743
749
  *
@@ -813,7 +819,18 @@ declare class A_Meta<_StorageItems extends Record<any, any> = any, _SerializedTy
813
819
  * Method to clear the map
814
820
  */
815
821
  clear(): void;
822
+ /**
823
+ * Method to convert the meta to an array of key-value pairs
824
+ *
825
+ * @returns
826
+ */
816
827
  toArray(): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
828
+ /**
829
+ * Helper method to recursively convert the meta object to a JSON-compatible format. It handles nested A_Meta instances, Maps, Arrays, and plain objects.
830
+ *
831
+ * @param value
832
+ * @returns
833
+ */
817
834
  protected recursiveToJSON(value: any): any;
818
835
  /**
819
836
  * Serializes the meta to a JSON object
@@ -3330,7 +3347,27 @@ declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentTy
3330
3347
  * Provide the fragment name in PascalCase to retrieve its constructor
3331
3348
  */
3332
3349
  name: string): A_TYPES__Fragment_Constructor<T>;
3333
- resolveConstructor<T extends A_TYPES__A_DependencyInjectable>(name: string): A_TYPES__Entity_Constructor<T> | A_TYPES__Component_Constructor<T> | A_TYPES__Fragment_Constructor<T> | undefined;
3350
+ resolveConstructor<T extends A_Component>(
3351
+ /**
3352
+ * Provide the component constructor or its name to retrieve its constructor
3353
+ */
3354
+ component: A_TYPES__Ctor<T>): A_TYPES__Component_Constructor<T> | undefined;
3355
+ resolveConstructor<T extends A_Entity>(
3356
+ /**
3357
+ * Provide the entity constructor or its name to retrieve its constructor
3358
+ */
3359
+ entity: A_TYPES__Ctor<T>): A_TYPES__Entity_Constructor<T> | undefined;
3360
+ resolveConstructor<T extends A_Fragment>(
3361
+ /**
3362
+ * Provide the fragment constructor or its name to retrieve its constructor
3363
+ */
3364
+ fragment: A_TYPES__Ctor<T>): A_TYPES__Fragment_Constructor<T> | undefined;
3365
+ resolveConstructor<T extends A_Error>(
3366
+ /**
3367
+ * Provide the error constructor or its name to retrieve its constructor
3368
+ */
3369
+ error: A_TYPES__Ctor<T>): A_TYPES__Error_Constructor<T> | undefined;
3370
+ 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;
3334
3371
  /**
3335
3372
  * This method should resolve all instances of the components, or entities within the scope, by provided parent class
3336
3373
  * So in case of providing a base class it should return all instances that extends this base class
@@ -4200,11 +4237,11 @@ declare class A_Context {
4200
4237
  * Get meta for the specific entity class by constructor.
4201
4238
  */
4202
4239
  entity: A_TYPES__Entity_Constructor): T;
4203
- static meta<T extends A_EntityMeta>(
4240
+ static meta<T extends A_EntityMeta, E extends A_Entity>(
4204
4241
  /**
4205
4242
  * Get meta for the specific entity instance.
4206
4243
  */
4207
- entity: A_Entity): T;
4244
+ entity: E): T;
4208
4245
  static meta<T extends A_ComponentMeta>(
4209
4246
  /**
4210
4247
  * Get meta for the specific component class by constructor.
@@ -1,3 +1,3 @@
1
- var R=class{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};var be=(i=>(i.INITIALIZED="INITIALIZED",i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.INTERRUPTED="INTERRUPTED",i.FAILED="FAILED",i))(be||{});var g=class{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};var k=class{static generateTimeId(e={timestamp:new Date,random:Math.random().toString(36).slice(2,8)}){let t=e.timestamp.getTime().toString(36),r=e.random;return `${t}-${r}`}static parseTimeId(e){let[t,r]=e.split("-");return {timestamp:new Date(parseInt(t,36)),random:r}}static formatWithLeadingZeros(e,t=10){return String(e).padStart(t+1,"0").slice(-t)}static removeLeadingZeros(e){return String(Number(e))}static hashString(e){let t=0,r,n;if(e.length===0)return t.toString();for(r=0;r<e.length;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t.toString()}};var S=class o{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static isArray(e){return Array.isArray(e)}static isErrorConstructorType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&o.isString(e.aseid)}static isScopeInstance(e){return !!e&&typeof e=="object"&&"name"in e&&"aseid"in e}};var F=class F{static isASEID(e){return this.regexp.test(e)}static compare(e,t){if(!e||!t)return false;if(S.isString(e)&&this.isASEID(e)===false)throw new Error(`Invalid ASEID format provided: ${e}`);if(S.isString(t)&&this.isASEID(t)===false)throw new Error(`Invalid ASEID format provided: ${t}`);let r=e instanceof F?e:new F(e),n=t instanceof F?t:new F(t);return r.toString()===n.toString()}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||c.concept}get scope(){return this._scope||c.root.name}get entity(){return this._entity}get id(){return this._id}get version(){return this._version}get shard(){return this._shard}get hash(){return k.hashString(this.toString())}getInitializer(e){switch(true){case S.isString(e):return this.fromString;case S.isObject(e):return this.fromObject;default:throw new Error("Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[i,a,_]=r.split(":"),l=_.includes(".")?_.split(".")[0]:void 0,A=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=i||c.root.name,this._entity=a,this._id=A,this._version=n,this._shard=l;}fromObject(e){this._concept=e.concept?F.isASEID(e.concept)?new F(e.concept).id:e.concept:c.concept,this._scope=e.scope?S.isNumber(e.scope)?k.formatWithLeadingZeros(e.scope):F.isASEID(e.scope)?new F(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=S.isNumber(e.id)?k.formatWithLeadingZeros(e.id):e.id,this._version=e.version,this._shard=e.shard;}toString(){return `${this.concept}@${this.scope}:${this.entity}:${this.shard?this.shard+"."+this.id:this.id}${this.version?"@"+this.version:""}`}toJSON(){return {concept:this._concept,scope:this._scope,entity:this._entity,id:this._id,version:this._version,shard:this._shard}}verifyInput(e){switch(true){case(S.isString(e)&&!F.isASEID(e)):throw new Error("Invalid ASEID format provided");case(S.isObject(e)&&!e.id):throw new Error("ASEID id is required");case(S.isObject(e)&&!e.entity):throw new Error("ASEID entity is required")}}};F.regexp=new RegExp("^[a-z|A-Z|0-9|-]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|\\.|-]+(@v[0-9|\\.]+|@lts)?$");var C=F;var H={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},ge="If you see this error please let us know.";var re=class{static get A_CONCEPT_NAME(){return "a-concept"}static get A_CONCEPT_ROOT_SCOPE(){return "root"}static get A_CONCEPT_ENVIRONMENT(){return "development"}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "unknown"}static get A_CONCEPT_ROOT_FOLDER(){return "/app"}static get A_ERROR_DEFAULT_DESCRIPTION(){return "If you see this error please let us know."}static get(e){return this[e]}static set(e,t){this[e]=t;}static getAll(){return {}}static getAllKeys(){return []}};var Z={A_CONCEPT_NAME:"A_CONCEPT_NAME",A_CONCEPT_ROOT_SCOPE:"A_CONCEPT_ROOT_SCOPE",A_CONCEPT_ENVIRONMENT:"A_CONCEPT_ENVIRONMENT",A_CONCEPT_RUNTIME_ENVIRONMENT:"A_CONCEPT_RUNTIME_ENVIRONMENT",A_CONCEPT_ROOT_FOLDER:"A_CONCEPT_ROOT_FOLDER",A_ERROR_DEFAULT_DESCRIPTION:"A_ERROR_DEFAULT_DESCRIPTION"},ne=[Z.A_CONCEPT_NAME,Z.A_CONCEPT_ROOT_SCOPE,Z.A_CONCEPT_ENVIRONMENT,Z.A_CONCEPT_RUNTIME_ENVIRONMENT,Z.A_CONCEPT_ROOT_FOLDER,Z.A_ERROR_DEFAULT_DESCRIPTION];var O=class extends re{static get A_CONCEPT_ENVIRONMENT(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ENVIRONMENT||super.A_CONCEPT_ENVIRONMENT}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "browser"}static get A_CONCEPT_NAME(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_NAME||super.A_CONCEPT_NAME}static get A_CONCEPT_ROOT_FOLDER(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_FOLDER||super.A_CONCEPT_ROOT_FOLDER}static get A_CONCEPT_ROOT_SCOPE(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_SCOPE||super.A_CONCEPT_ROOT_SCOPE}static get A_ERROR_DEFAULT_DESCRIPTION(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_ERROR_DEFAULT_DESCRIPTION||super.A_ERROR_DEFAULT_DESCRIPTION}static get(e){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.[e]||this[e]}static set(e,t){window.__A_CONCEPT_ENVIRONMENT_ENV__||(window.__A_CONCEPT_ENVIRONMENT_ENV__={}),window.__A_CONCEPT_ENVIRONMENT_ENV__[e]=t;}static getAll(){let e={};return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e[t]=window.__A_CONCEPT_ENVIRONMENT_ENV__[t];}),ne.forEach(t=>{e[t]=this.get(t);}),e}static getAllKeys(){let e=new Set;return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e.add(t);}),ne.forEach(t=>{e.add(t);}),Array.from(e)}};var y=class o extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof o:return e;case e instanceof Error:super(e.message);break;case S.isErrorSerializedType(e):super(e.message);break;case(S.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(S.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(S.isString(e)&&!t):super(e);break;case(S.isString(e)&&!!t):super(`[${e}]: ${t}`);break;default:super("An unknown error occurred.");}this.getInitializer(e,t).call(this,e,t);}get aseid(){return this._aseid}get title(){return this._title}get message(){return super.message}get code(){return this._code||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||String(O.A_ERROR_DEFAULT_DESCRIPTION)||ge}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(S.isString(e)&&!t):return this.fromMessage;case(S.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case S.isErrorSerializedType(e):return this.fromJSON;case S.isErrorConstructorType(e):return this.fromConstructor;default:throw new o(H.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromJSON(e){this._aseid=new C(e.aseid),super.message=e.message,this._title=e.title,this._code=e.code,this._scope=e.scope,this._description=e.description,this._originalError=e.originalError?new o(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromConstructor(e){if(this.validateTitle(e.title),this._title=e.title,this._code=e.code,this._scope=e.scope?S.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._description=e.description,this._link=e.link,e.originalError instanceof o){let t=e.originalError;for(;t.originalError instanceof o;)t=t.originalError;this._originalError=t.originalError||t;}else this._originalError=e.originalError;}toJSON(){return {aseid:this.aseid.toString(),title:this.title,code:this.code,type:this.type,message:this.message,link:this.link,scope:this.scope,description:this.description,originalError:this.originalError?.message}}validateTitle(e){if(e.length>60)throw new o(H.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new o(H.VALIDATION_ERROR,"A-Error title cannot be empty.")}};var K=class extends y{};K.ValidationError="A-Entity Validation Error";var v=class{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e){this.getInitializer(e).call(this,e);}get id(){return this.aseid.id}isStringASEID(e){return typeof e=="string"&&C.isASEID(e)}isASEIDInstance(e){return e instanceof C}isSerializedObject(e){return !!e&&typeof e=="object"&&"aseid"in e}isConstructorProps(e){return !!e&&typeof e=="object"&&!("aseid"in e)}getInitializer(e){if(!e)return this.fromUndefined;if(this.isStringASEID(e))return this.fromASEID;if(this.isASEIDInstance(e))return this.fromASEID;if(this.isSerializedObject(e))return this.fromJSON;if(this.isConstructorProps(e))return this.fromNew;throw new K(K.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new C({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||k.generateTimeId()})}async call(e,t){return await new I({name:e,component:this,scope:t}).process(t)}async load(e){return this.call("load",e)}async destroy(e){return this.call("destroy",e)}async save(e){return this.call("save",e)}fromASEID(e){e instanceof C?this.aseid=e:this.aseid=new C(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new C(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};function oe(o){return function(e){return c.setMeta(e,new o),e}}var d=class o{constructor(){this.meta=new Map;}static Define(e){return oe(e)}[Symbol.iterator](){let e=this.meta.entries();return {next:()=>e.next()}}from(e){return this.meta=new Map(e.meta),this}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof o:return e.toJSON();case e instanceof Map:let t={};for(let[n,i]of e.entries())t[String(n)]=this.recursiveToJSON(i);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,i]of Object.entries(e))r[n]=this.recursiveToJSON(i);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};var Ce=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(Ce||{}),Ye=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(Ye||{});var z=class extends d{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};var j=class{get name(){return this.config?.name||this.constructor.name}get scope(){return c.scope(this)}constructor(e={}){this.config=e,c.allocate(this,this.config);}async call(e,t){return await new I({name:e,component:this}).process(t)}};var Pe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Pe||{});var U=class extends d{injections(e){return this.get("a-container-injections")?.get(e)||[]}features(){return this.get("a-container-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-container-abstractions"),n=this.get("a-container-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,a])=>{a.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,i])=>{i.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}};var m=class extends y{fromConstructor(e){super.fromConstructor(e),this.stage=e.stage;}};m.Interruption="Feature Interrupted",m.FeatureInitializationError="Unable to initialize A-Feature",m.FeatureProcessingError="Error occurred during A-Feature processing",m.FeatureDefinitionError="Unable to define A-Feature",m.FeatureExtensionError="Unable to extend A-Feature";var u=class{static resolve(){return new Promise(e=>e())}static isInheritedFrom(e,t){let r=e;for(;r;){if(r===t)return true;r=Object.getPrototypeOf(r);}return false}static getParentClasses(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=[];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getClassInheritanceChain(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=typeof e=="function"?[e]:[e.constructor];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getParentClass(e){return Object.getPrototypeOf(e)}static omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(i,a){let _=a[0];a.length===1?delete i[_]:i[_]!==void 0&&typeof i[_]=="object"&&n(i[_],a.slice(1));}return t.forEach(i=>{let a=i.split(".");n(r,a);}),r}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static deepMerge(e,t,r=new Map){if(this.isObject(e)&&this.isObject(t))for(let n in t)this.isObject(t[n])?(e[n]||(e[n]={}),r.has(t[n])?e[n]=r.get(t[n]):(r.set(t[n],{}),this.deepMerge(e[n],t[n],r))):e[n]=t[n];return e}static deepClone(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(t=>this.deepClone(t));if(typeof e=="function")return e;if(e instanceof Object){let t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=this.deepClone(e[r]));return t}throw new Error("Unable to clone the object. Unsupported type.")}static deepCloneAndMerge(e,t){if(t==null&&e==null)return e;if(e==null&&t)return this.deepClone(t);if(typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(r=>this.deepCloneAndMerge(r,t));if(typeof e=="function")return e;if(e instanceof Object){let r={};for(let n in e)t[n]!==null&&t[n]!==void 0?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(e[n]);for(let n in t)e[n]!==void 0&&e[n]!==null?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(t[n]);return r}throw new Error("Unable to clone the object. Unsupported type.")}static getComponentName(e){let t="Unknown",r="Anonymous";if(e==null)return t;if(typeof e=="string")return e||t;if(typeof e=="symbol")try{return e.toString()}catch{return t}if(Array.isArray(e))return e.length===0?t:this.getComponentName(e[0]);if(typeof e=="function"){let n=e;if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name)return String(n.constructor.name);try{let a=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(a)return a[1]||a[2]||a[3]||r}catch{}return r}if(typeof e=="object"){let n=e;if(n.type)return this.getComponentName(n.type);if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name&&n.constructor.name!=="Object")return String(n.constructor.name);try{let i=n.toString();if(typeof i=="string"&&i!=="[object Object]")return i}catch{}return r}try{return String(e)}catch{return t}}};var q=class extends Error{};q.CallerInitializationError="Unable to initialize A-Caller";var V=class{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!s.isAllowedForFeatureCall(e))throw new q(`[${q.CallerInitializationError}]: Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};var f=class extends y{};f.InvalidDependencyTarget="Invalid Dependency Target",f.InvalidLoadTarget="Invalid Load Target",f.InvalidLoadPath="Invalid Load Path",f.InvalidDefaultTarget="Invalid Default Target",f.ResolutionParametersError="Dependency Resolution Parameters Error";function ie(...o){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,l=_.get(i)||[];l[r].resolutionStrategy={create:true,args:o},_.set(i,l),c.meta(e).set(a,_);}}function se(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={flat:true},a.set(n,_),c.meta(o).set(i,a);}}function ae(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={load:true},a.set(n,_),c.meta(o).set(i,a);}}function _e(o=-1){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,l=_.get(i)||[];l[r].resolutionStrategy={parent:o},_.set(i,l),c.meta(e).set(a,_);}}function ce(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={require:true},a.set(n,_),c.meta(o).set(i,a);}}function pe(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={pagination:{..._[t].resolutionStrategy.pagination,count:-1}},a.set(n,_),c.meta(o).set(i,a);}}function ue(o,e){return function(t,r,n){let i=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof t} (${i})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,A=l.get(a)||[];A[n].resolutionStrategy={query:{...A[n].resolutionStrategy.query,...o},pagination:{...A[n].resolutionStrategy.pagination,...e}},l.set(a,A),c.meta(t).set(_,l);}}var Y=class{constructor(e,t){this._defaultPagination={count:1,from:"start"};this._defaultResolutionStrategy={require:false,load:false,parent:0,flat:false,create:false,args:[],query:{},pagination:this._defaultPagination};this._name=typeof e=="string"?e:u.getComponentName(e),this._target=typeof e=="string"?void 0:e,this.resolutionStrategy=t||{},this.initCheck();}static get Required(){return ce}static get Loaded(){return ae}static get Default(){return ie}static get Parent(){return _e}static get Flat(){return se}static get All(){return pe}static get Query(){return ue}get flat(){return this._resolutionStrategy.flat}get require(){return this._resolutionStrategy.require}get load(){return this._resolutionStrategy.load}get all(){return this._resolutionStrategy.pagination.count!==1||Object.keys(this._resolutionStrategy.query).length>0}get parent(){return this._resolutionStrategy.parent}get create(){return this._resolutionStrategy.create}get args(){return this._resolutionStrategy.args}get query(){return this._resolutionStrategy.query}get pagination(){return this._resolutionStrategy.pagination}get name(){return this._name}get target(){return this._target}get resolutionStrategy(){return this._resolutionStrategy}set resolutionStrategy(e){this._resolutionStrategy={...this._defaultResolutionStrategy,...this._resolutionStrategy,...e,pagination:{...this._defaultPagination,...(this._resolutionStrategy||{}).pagination,...e.pagination||{}}};}initCheck(){if(!this._resolutionStrategy)throw new f(f.ResolutionParametersError,`Resolution strategy parameters are not provided for dependency: ${this._name}`);return this}toJSON(){return {name:this._name,all:this.all,require:this.require,load:this.load,parent:this.parent,flat:this.flat,create:this.create,args:this.args,query:this.query,pagination:this.pagination}}};var s=class o{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isArray(e){return Array.isArray(e)}static isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static isFunction(e){return typeof e=="function"}static isUndefined(e){return typeof e>"u"}static isRegExp(e){return e instanceof RegExp}static isContainerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,j)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,w)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Error)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,I)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,V)}static isDependencyConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isDependencyInstance(e){return e instanceof Y}static isContainerInstance(e){return e instanceof j}static isComponentInstance(e){return e instanceof w}static isFeatureInstance(e){return e instanceof I}static isFragmentInstance(e){return e instanceof R}static isEntityInstance(e){return e instanceof v}static isScopeInstance(e){return e instanceof x}static isErrorInstance(e){return e instanceof Error}static isComponentMetaInstance(e){return e instanceof N}static isContainerMetaInstance(e){return e instanceof U}static isEntityMetaInstance(e){return e instanceof z}static hasASEID(e){return e&&typeof e=="object"&&"aseid"in e&&(o.isEntityInstance(e)||o.isErrorInstance(e))}static isConstructorAllowedForScopeAllocation(e){return o.isContainerConstructor(e)||o.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return o.isContainerInstance(e)||o.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return o.isContainerInstance(e)||o.isComponentInstance(e)}static isTargetAvailableForInjection(e){return o.isComponentConstructor(e)||o.isComponentInstance(e)||o.isContainerInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureCall(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return o.isComponentInstance(e)||o.isContainerInstance(e)||o.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return o.isContainerInstance(e)||o.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return o.isFragmentConstructor(e)||u.isInheritedFrom(e,R)||o.isEntityConstructor(e)||u.isInheritedFrom(e,v)}static isErrorConstructorType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&C.isASEID(e.aseid)}static isPromiseInstance(e){return e instanceof Promise}};function le(o={}){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureDefinition(e))throw new m(m.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let i=c.meta(e.constructor),a;switch(true){case s.isEntityInstance(e):a="a-component-features";break;case s.isContainerInstance(e):a="a-container-features";break;case s.isComponentInstance(e):a="a-component-features";break}let _=i.get(a)||new d,l=o.name||t,A=o.invoke||false;_.set(t,{name:`${e.constructor.name}.${l}`,handler:t,invoke:A,template:o.template&&o.template.length?o.template.map(h=>({...h,before:h.before||"",after:h.after||"",behavior:h.behavior||"sync",throwOnError:true,override:h.override||""})):[]}),c.meta(e.constructor).set(a,_);let T=r.value;return r.value=function(...h){if(A)T.apply(this,h);else return T.apply(this,h);if(typeof this.call=="function"&&A)return this.call(l)},r}}function Ae(o){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureExtension(e))throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let i,a="sync",_="",l="",A="",T=[],h=[],b=true,D;switch(true){case s.isEntityInstance(e):D="a-component-extensions";break;case s.isContainerInstance(e):D="a-container-extensions";break;case s.isComponentInstance(e):D="a-component-extensions";break}switch(true){case s.isRegExp(o):i=o;break;case(!!o&&typeof o=="object"):Array.isArray(o.scope)?T=o.scope:o.scope&&typeof o.scope=="object"&&(Array.isArray(o.scope.include)&&(T=o.scope.include),Array.isArray(o.scope.exclude)&&(h=o.scope.exclude)),i=we(o,T,h,t),a=o.behavior||a,b=o.throwOnError!==void 0?o.throwOnError:b,_=s.isArray(o.before)?new RegExp(`^${o.before.join("|").replace(/\./g,"\\.")}$`).source:o.before instanceof RegExp?o.before.source:"",l=s.isArray(o.after)?new RegExp(`^${o.after.join("|").replace(/\./g,"\\.")}$`).source:o.after instanceof RegExp?o.after.source:"",A=s.isArray(o.override)?new RegExp(`^${o.override.join("|").replace(/\./g,"\\.")}$`).source:o.override instanceof RegExp?o.override.source:"";break;default:i=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let J=c.meta(e).get(D),Te=c.meta(e),G=Te.get(D)?new d().from(Te.get(D)):new d;if(J&&J.size()&&J.has(t)&&J.get(t).invoke)throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be used on the method "${t}" because it is already defined as a Feature with "invoke" set to true. Please remove the A-Feature-Extend decorator or set "invoke" to false in the A-Feature decorator.`);let ee=[...G.get(i.source)||[]];for(let[Q,te]of G.entries()){let he=te.findIndex(Ie=>Ie.handler===t);Q!==i.source&&he!==-1&&(te.splice(he,1),te.length===0?G.delete(Q):G.set(Q,te));}let Se=ee.findIndex(Q=>Q.handler===t),ye={name:i.source,handler:t,behavior:a,before:_,after:l,throwOnError:b,override:A};Se!==-1?ee[Se]=ye:ee.push(ye),G.set(i.source,ee),c.meta(e).set(D,G);}}function we(o,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",i=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",a=o.scope?`^${i}${n}\\.${o.name||r}$`:`.*\\.${o.name||r}$`;return new RegExp(a)}var xe=(a=>(a.PROCESSING="PROCESSING",a.COMPLETED="COMPLETED",a.FAILED="FAILED",a.SKIPPED="SKIPPED",a.INITIALIZED="INITIALIZED",a.ABORTED="ABORTED",a))(xe||{});var $=class extends y{static get CompileError(){return "Unable to compile A-Stage"}};$.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var X=class{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}getStepArgs(e,t){let r=t.dependency.target||e.resolveConstructor(t.dependency.name);return c.meta(r).injections(t.handler).map(n=>{switch(true){case s.isCallerConstructor(n.target):return this._feature.caller.component;case s.isFeatureConstructor(n.target):return this._feature;default:return e.resolve(n)}})}getStepComponent(e,t){let{dependency:r,handler:n}=t,i=e.resolve(r)||this.feature.scope.resolve(r);if(!i)throw new $($.CompileError,`Unable to resolve component ${r.name} from scope ${e.name}`);if(!i[n])throw new $($.CompileError,`Handler ${n} not found in ${i.constructor.name}`);return i}callStepHandler(e,t){let r=this.getStepComponent(t,e),n=this.getStepArgs(t,e);return {handler:r[e.handler].bind(r),params:n}}skip(){this._status="SKIPPED";}process(e){let t=s.isScopeInstance(e)?e:this._feature.scope;if(!this.isProcessed){this._status="PROCESSING";let{handler:r,params:n}=this.callStepHandler(this._definition,t),i=r(...n);if(s.isPromiseInstance(i))return new Promise(async(a,_)=>{try{return await i,this.completed(),a()}catch(l){let A=new y(l);return this.failed(A),this._definition.throwOnError?a():_(A)}});this.completed();}}completed(){this._status="COMPLETED";}failed(e){this._error=new y(e),this._status="FAILED";}toJSON(){return {name:this.name,status:this.status}}toString(){return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`}};var B=class extends y{};B.CircularDependencyError="A-StepManager Circular Dependency Error";var W=class{constructor(e){this._isBuilt=false;this.entities=this.prepareSteps(e),this.graph=new Map,this.visited=new Set,this.tempMark=new Set,this.sortedEntities=[];}prepareSteps(e){return e.map(t=>({...t,behavior:t.behavior||"sync",before:t.before||"",after:t.after||"",override:t.override||"",throwOnError:false}))}ID(e){return `${e.dependency.name}.${e.handler}`}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some(n=>n.override?new RegExp(n.override).test(this.ID(e)):false)),this.entities.forEach(e=>this.graph.set(this.ID(e),new Set)),this.entities.forEach(e=>{let t=this.ID(e);e.before&&this.matchEntities(t,e.before).forEach(n=>{this.graph.has(n)||this.graph.set(n,new Set),this.graph.get(n).add(t);}),e.after&&this.matchEntities(t,e.after).forEach(n=>{this.graph.has(t)||this.graph.set(t,new Set),this.graph.get(t).add(n);});}));}matchEntities(e,t){let r=new RegExp(t);return this.entities.filter(n=>r.test(this.ID(n))&&this.ID(n)!==e).map(n=>this.ID(n))}visit(e){this.tempMark.has(e)||this.visited.has(e)||(this.tempMark.add(e),(this.graph.get(e)||[]).forEach(t=>this.visit(t)),this.tempMark.delete(e),this.visited.add(e),this.sortedEntities.push(e));}toSortedArray(){return this.buildGraph(),this.entities.forEach(e=>{this.visited.has(this.ID(e))||this.visit(this.ID(e));}),this.sortedEntities}toStages(e){return this.toSortedArray().map(r=>{let n=this.entities.find(i=>this.ID(i)===r);return new X(e,n)})}};var I=class o{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return le}static get Extend(){return Ae}get name(){return this._name}get error(){return this._error}get state(){return this._state}get index(){return this._index}get stage(){return this._current}get caller(){return this._caller}get scope(){return c.scope(this)}get size(){return this._stages.length}get isDone(){return !this.stage||this._index>=this._stages.length}get isProcessed(){return this.state==="COMPLETED"||this.state==="FAILED"||this.state==="INTERRUPTED"}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._stages[this._index],this._index++,{value:this._current,done:false})}}validateParams(e){if(!e||typeof e!="object")throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}getInitializer(e){switch(true){case !("template"in e):return this.fromComponent;case "template"in e:return this.fromTemplate;default:throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}}fromTemplate(e){if(!e.template||!Array.isArray(e.template))throw new m(m.FeatureInitializationError,`Invalid A-Feature template provided of type: ${typeof e.template} with value: ${JSON.stringify(e.template).slice(0,100)}...`);if(!e.component&&(!e.scope||!(e.scope instanceof x)))throw new m(m.FeatureInitializationError,`Invalid A-Feature scope provided of type: ${typeof e.scope} with value: ${JSON.stringify(e.scope).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{e.component&&(t=c.scope(e.component));}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new W(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!s.isAllowedForFeatureDefinition(e.component))throw new m(m.FeatureInitializationError,`Invalid A-Feature component provided of type: ${typeof e.component} with value: ${JSON.stringify(e.component).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{t=c.scope(e.component);}catch(a){if(!r)throw a}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component);let n=c.allocate(this);n.inherit(t||r);let i=c.featureTemplate(this._name,this._caller.component,n);this._SM=new W(i),this._stages=this._SM.toStages(this),this._current=this._stages[0];}process(e){try{if(this.isProcessed)return;this._state="PROCESSING";let t=Array.from(this);return this.processStagesSequentially(t,e,0)}catch(t){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:t}))}}processStagesSequentially(e,t,r){try{if(this.state==="INTERRUPTED")return;if(r>=e.length){this.completed();return}let n=e[r],i=n.process(t);return s.isPromiseInstance(i)?i.then(()=>{if(this.state!=="INTERRUPTED")return this.processStagesSequentially(e,t,r+1)}).catch(a=>{throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${n.name}.`,stage:n,originalError:a}))}):this.processStagesSequentially(e,t,r+1)}catch(n){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:n}))}}next(e){let t=this._stages.indexOf(e);this._index=t+1,this._index>=this._stages.length&&this.completed();}completed(){this.isProcessed||this.state!=="INTERRUPTED"&&(this._state="COMPLETED",this.scope.destroy());}failed(e){return this.isProcessed?this._error:(this._state="FAILED",this._error=e,this.scope.destroy(),this._error)}interrupt(e){if(this.isProcessed)return this._error;switch(this._state="INTERRUPTED",true){case s.isString(e):this._error=new m(m.Interruption,e);break;case s.isErrorInstance(e):this._error=new m({code:m.Interruption,title:e.title||"Feature Interrupted",description:e.description||e.message,stage:this.stage,originalError:e});break;default:this._error=new m(m.Interruption,"Feature was interrupted");break}return this.scope.destroy(),this._error}chain(e,t,r){let n,i;e instanceof o?(n=e,i=t instanceof x?t:void 0):(n=new o({name:t,component:e}),i=r instanceof x?r:void 0);let a=i||this.scope;n._caller=this._caller;let _=n.process(a);return s.isPromiseInstance(_)?_.catch(l=>{throw l}):_}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};var w=class{call(e,t){return new I({name:e,component:this}).process(t)}};var de=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(de||{});var N=class extends d{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,i])=>{i.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-component-abstractions"),n=this.get("a-component-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,a])=>{a.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}};var x=class{constructor(e,t){this._meta=new d;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this._imports=new Set;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get imports(){return Array.from(this._imports.values())}get parent(){return this._parent}*parents(){let e=this._parent;for(;e;)yield e,e=e._parent;}parentOffset(e){let t=this;for(;e<=-1&&t;)t=t.parent,e++;return t}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new E(E.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>c.deregister(e)),this._fragments.forEach(e=>c.deregister(e)),this._entities.forEach(e=>c.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this._imports.clear(),this.issuer()&&c.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return c.issuer(this)}inherit(e){if(!e)throw new E(E.InitializationError,"Invalid parent scope provided");if(e===this)throw new E(E.CircularInheritanceError,`Unable to inherit scope ${this.name} from itself`);if(e===this._parent)return this;let t=this.checkCircularInheritance(e);if(t)throw new E(E.CircularInheritanceError,`Circular inheritance detected: ${[...t,e.name].join(" -> ")}`);return this._parent=e,this}import(...e){return e.forEach(t=>{if(t===this)throw new E(E.CircularImportError,`Unable to import scope ${this.name} into itself`);this._imports.has(t)||this._imports.add(t);}),this}deimport(...e){return e.forEach(t=>{this._imports.has(t)&&this._imports.delete(t);}),this}has(e){let t=this.hasFlat(e);if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}hasFlat(e){let t=false;switch(true){case s.isScopeConstructor(e):return true;case s.isString(e):{Array.from(this.allowedComponents).find(_=>_.name===e)&&(t=true),Array.from(this.allowedFragments).find(_=>_.name===e)&&(t=true),Array.from(this.allowedEntities).find(_=>_.name===e)&&(t=true),Array.from(this.allowedErrors).find(_=>_.name===e)&&(t=true);break}case s.isComponentConstructor(e):{t=this.isAllowedComponent(e)||!![...this.allowedComponents].find(r=>u.isInheritedFrom(r,e));break}case s.isEntityConstructor(e):{t=this.isAllowedEntity(e)||!![...this.allowedEntities].find(r=>u.isInheritedFrom(r,e));break}case s.isFragmentConstructor(e):{t=this.isAllowedFragment(e)||!![...this.allowedFragments].find(r=>u.isInheritedFrom(r,e));break}case s.isErrorConstructor(e):{t=this.isAllowedError(e)||!![...this.allowedErrors].find(r=>u.isInheritedFrom(r,e));break}case(this.issuer()&&(this.issuer().constructor===e||u.isInheritedFrom(this.issuer().constructor,e))):{t=true;break}}return t}resolveDependency(e){let t=[],r=this.parentOffset(e.parent)||this;switch(true){case(e.flat&&!e.all):{let A=r.resolveFlatOnce(e.target||e.name);A&&(t=[A]);break}case(e.flat&&e.all):{t=r.resolveFlatAll(e.target||e.name);break}case(!e.flat&&!e.all):{let A=r.resolveOnce(e.target||e.name);A&&(t=[A]);break}case(!e.flat&&e.all):{t=r.resolveAll(e.target||e.name);break}default:t=[];}if(e.create&&!t.length&&s.isAllowedForDependencyDefaultCreation(e.target)){let A=new e.target(...e.args);r.register(A),t.push(A);}if(e.require&&!t.length)throw new E(E.ResolutionError,`Dependency ${e.name} is required but could not be resolved in scope ${r.name}`);e.query.aseid?t=t.filter(A=>s.hasASEID(A)&&C.compare(A.aseid,e.query.aseid)):Object.keys(e.query).length>0&&(t=t.filter(A=>{let T=e.query;return T?Object.entries(T).every(([h,b])=>A[h]===b):true}));let n=e.pagination.count,i=e.pagination.from,a=i==="end"?n===-1?0:Math.max(t.length-n,0):0,_=i==="end"||n===-1?t.length:Math.min(n,t.length),l=t.slice(a,_);return l.length===1&&n!==-1?l[0]:l.length?l:void 0}resolveConstructor(e){let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===g.toPascalCase(e));if(t)return t;{let i=Array.from(this.allowedComponents).find(a=>{let _=a;for(;_;){if(_.name===e||_.name===g.toPascalCase(e))return true;_=Object.getPrototypeOf(_);}return false});if(i)return i}let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.entity===e||i.entity===g.toKebabCase(e));if(r)return r;{let i=Array.from(this.allowedEntities).find(a=>u.isInheritedFrom(a,e));if(i)return i}let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===g.toPascalCase(e));if(n)return n;{let i=Array.from(this.allowedFragments).find(a=>u.isInheritedFrom(a,e));if(i)return i}for(let i of this._imports){let a=i.resolveConstructor(e);if(a)return a}if(this._parent)return this._parent.resolveConstructor(e)}resolveAll(e){let t=new Set;this.resolveFlatAll(e).forEach(i=>t.add(i)),this._imports.forEach(i=>{i.has(e)&&i.resolveFlatAll(e).forEach(_=>t.add(_));});let n=this._parent;for(;n&&n.has(e);)n.resolveAll(e).forEach(a=>t.add(a)),n=n._parent;return Array.from(t)}resolveFlatAll(e){let t=[];switch(true){case s.isComponentConstructor(e):{this.allowedComponents.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isFragmentConstructor(e):{this.allowedFragments.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isEntityConstructor(e):{this.entities.forEach(r=>{u.isInheritedFrom(r.constructor,e)&&t.push(r);});break}case s.isString(e):{let r=this.resolveConstructor(e);if(!s.isComponentConstructor(r)&&!s.isEntityConstructor(r)&&!s.isFragmentConstructor(r))throw new E(E.ResolutionError,`Unable to resolve all instances for name: ${e} in scope ${this.name} as no matching component, entity or fragment constructor found`);if(r){let n=this.resolveAll(r);n&&t.push(...n);}break}default:throw new E(E.ResolutionError,`Invalid parameter provided to resolveAll method: ${e} in scope ${this.name}`)}return t}resolve(e){let t=s.isDependencyInstance(e)?e:new Y(e);return this.resolveDependency(t)}resolveOnce(e){let t=this.resolveFlatOnce(e);if(!t){for(let r of this._imports)if(r.has(e)){let n=r.resolveFlatOnce(e);if(n)return n}}return !t&&this.parent?this.parent.resolveOnce(e):t}resolveFlat(e){return this.resolveFlatOnce(e)}resolveFlatOnce(e){let t,r=u.getComponentName(e);if(!(!e||!this.has(e))){switch(true){case s.isString(e):{t=this.resolveByName(e);break}case s.isConstructorAllowedForScopeAllocation(e):{t=this.resolveIssuer(e);break}case s.isScopeConstructor(e):{t=this.resolveScope(e);break}case s.isEntityConstructor(e):{t=this.resolveEntity(e);break}case s.isFragmentConstructor(e):{t=this.resolveFragment(e);break}case s.isComponentConstructor(e):{t=this.resolveComponent(e);break}case s.isErrorConstructor(e):{t=this.resolveError(e);break}default:throw new E(E.ResolutionError,`Injected Component ${r} not found in the scope`)}return t}}resolveByName(e){let t=Array.from(this.allowedComponents).find(a=>a.name===e||a.name===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.entity===e||a.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(a=>a.name===e||a.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let i=Array.from(this.allowedErrors).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.code===e||a.code===g.toKebabCase(e));if(i)return this.resolveOnce(i)}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t}resolveEntity(e){return this.entities.find(t=>t instanceof e)}resolveError(e){return this.errors.find(t=>t instanceof e)}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}default:return}}resolveScope(e){return this}resolveComponent(e){switch(true){case(this.allowedComponents.has(e)&&this._components.has(e)):return this._components.get(e);case(this.allowedComponents.has(e)&&!this._components.has(e)):{let n=(c.meta(e).get("a-component-injections")?.get("constructor")||[]).map(a=>this.resolve(a)),i=new e(...n);return this.register(i),this._components.get(e)}case(!this.allowedComponents.has(e)&&Array.from(this.allowedComponents).some(t=>u.isInheritedFrom(t,e))):{let t=Array.from(this.allowedComponents).find(r=>u.isInheritedFrom(r,e));return this.resolveComponent(t)}default:return}}register(e){switch(true){case e instanceof w:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e);break}case(s.isEntityInstance(e)&&!this._entities.has(e.aseid.toString())):{this.allowedEntities.has(e.constructor)||this.allowedEntities.add(e.constructor),this._entities.set(e.aseid.toString(),e),c.register(this,e);break}case s.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),c.register(this,e);break}case s.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),c.register(this,e);break}case s.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case s.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case s.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof v)throw new E(E.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof R)throw new E(E.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new E(E.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof w:{this._components.delete(e.constructor),c.deregister(e);let r=e.constructor;this._components.has(r)||this.allowedComponents.delete(r);break}case s.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),c.deregister(e);let r=e.constructor;Array.from(this._entities.values()).some(i=>i instanceof r)||this.allowedEntities.delete(r);break}case s.isFragmentInstance(e):{this._fragments.delete(e.constructor),c.deregister(e);let r=e.constructor;Array.from(this._fragments.values()).some(i=>i instanceof r)||this.allowedFragments.delete(r);break}case s.isErrorInstance(e):{this._errors.delete(e.code),c.deregister(e);let r=e.constructor;Array.from(this._errors.values()).some(i=>i instanceof r)||this.allowedErrors.delete(r);break}case s.isComponentConstructor(e):{this.allowedComponents.delete(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.delete(e),Array.from(this._fragments.entries()).forEach(([r,n])=>{u.isInheritedFrom(r,e)&&(this._fragments.delete(r),c.deregister(n));});break}case s.isEntityConstructor(e):{this.allowedEntities.delete(e),Array.from(this._entities.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._entities.delete(r),c.deregister(n));});break}case s.isErrorConstructor(e):{this.allowedErrors.delete(e),Array.from(this._errors.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._errors.delete(r),c.deregister(n));});break}default:let t=u.getComponentName(e);throw new E(E.DeregistrationError,`Cannot deregister ${t} from the scope ${this.name}`)}}toJSON(){return this.fragments.reduce((e,t)=>{let r=t.toJSON();return {...e,[r.name]:r}},{})}isAllowedComponent(e){return s.isComponentConstructor(e)&&this.allowedComponents.has(e)}isAllowedEntity(e){return s.isEntityConstructor(e)&&this.allowedEntities.has(e)}isAllowedFragment(e){return s.isFragmentConstructor(e)&&this.allowedFragments.has(e)}isAllowedError(e){return s.isErrorConstructor(e)&&this.allowedErrors.has(e)}isInheritedFrom(e){let t=this;for(;t;){if(t===e)return true;t=t._parent;}return false}checkCircularInheritance(e){let t=[],r=this._parent;for(;r;){if(t.push(r.name),r===e)return t;r=r._parent;}return false}printInheritanceChain(){let e=[],t=this;for(;t;)e.push(t.name),t=t._parent;console.log(e.join(" -> "));}};var E=class extends y{};E.InitializationError="A-Scope Initialization Error",E.ConstructorError="Unable to construct A-Scope instance",E.ResolutionError="A-Scope Resolution Error",E.RegistrationError="A-Scope Registration Error",E.CircularInheritanceError="A-Scope Circular Inheritance Error",E.CircularImportError="A-Scope Circular Import Error",E.DeregistrationError="A-Scope Deregistration Error";var p=class extends y{};p.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",p.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",p.InvalidMetaParameterError="Invalid parameter provided to get meta",p.InvalidScopeParameterError="Invalid parameter provided to get scope",p.ScopeNotFoundError="Scope not found",p.InvalidFeatureParameterError="Invalid parameter provided to get feature",p.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",p.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",p.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",p.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",p.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",p.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",p.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",p.InvalidInjectionParameterError="Invalid parameter provided to get injections",p.InvalidExtensionParameterError="Invalid parameter provided to get extensions",p.InvalidRegisterParameterError="Invalid parameter provided to register component",p.InvalidComponentParameterError="Invalid component provided",p.ComponentNotRegisteredError="Component not registered in the context",p.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var c=class o{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;this._globals=new Map;let e=String(O.A_CONCEPT_ROOT_SCOPE)||"root";this._root=new x({name:e});}static get concept(){return O.A_CONCEPT_NAME||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){return O.A_CONCEPT_RUNTIME_ENVIRONMENT}static getInstance(){return o._instance||(o._instance=new o),o._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new p(p.NotAllowedForScopeAllocationError,`Component ${r} is not allowed for scope allocation.`);return n._scopeStorage.set(t,e),e}static deregister(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new p(p.ComponentNotRegisteredError,`Unable to deregister component. Component ${t} is not registered.`);r._scopeStorage.delete(e);}static allocate(e,t){let r=u.getComponentName(e);if(!this.isAllowedForScopeAllocation(e))throw new p(p.NotAllowedForScopeAllocationError,`Component of type ${r} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);let n=this.getInstance();if(n._registry.has(e))throw new p(p.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let i=s.isScopeInstance(t)?t:new x(t||{name:r+"-scope"},t);return i.isInheritedFrom(o.root)||i.inherit(o.root),n._registry.set(e,i),n._scopeIssuers.set(i,e),i}static deallocate(e){let t=this.getInstance(),r=s.isScopeInstance(e)?e:t._registry.get(e);if(!r)return;let n=s.isComponentInstance(e)?e:this.issuer(r);n&&t._registry.delete(n),r&&t._scopeIssuers.delete(r);}static meta(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidMetaParameterError,"Invalid parameter provided to get meta. Parameter cannot be null or undefined.");if(!(this.isAllowedForMeta(e)||this.isAllowedForMetaConstructor(e)||s.isString(e)||s.isFunction(e)))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component of type ${t} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);let n,i;switch(true){case s.isContainerInstance(e):{n=e.constructor,i=U;break}case s.isContainerConstructor(e):{n=e,i=U;break}case s.isComponentInstance(e):{n=e.constructor,i=N;break}case s.isComponentConstructor(e):{n=e,i=N;break}case s.isEntityInstance(e):{n=e.constructor,i=N;break}case s.isEntityConstructor(e):{n=e,i=z;break}case s.isFragmentInstance(e):{n=e.constructor,i=N;break}case s.isFragmentConstructor(e):{n=e,i=z;break}case typeof e=="string":{let a=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===g.toKebabCase(e)||_.name===g.toPascalCase(e));if(!(a&&a.length))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=a[0],i=N;break}default:{n=e,i=d;break}}if(!r._metaStorage.has(n)){let a,_=n;for(;!a;){let l=Object.getPrototypeOf(_);if(!l)break;a=r._metaStorage.get(l),_=l;}a||(a=new i),r._metaStorage.set(n,new i().from(a));}return r._metaStorage.get(n)}static setMeta(e,t){let r=o.getInstance(),n=o.meta(e),i=typeof e=="function"?e:e.constructor;r._metaStorage.set(i,n?t.from(n):t);}static issuer(e){let t=this.getInstance();if(!e)throw new p(p.InvalidComponentParameterError,"Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.");return t._scopeIssuers.get(e)}static scope(e){let t=e?.constructor?.name||String(e),r=this.getInstance();if(!e)throw new p(p.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed for scope allocation.`);switch(true){case this.isAllowedToBeRegistered(e):if(!r._scopeStorage.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`);return r._scopeStorage.get(e);case this.isAllowedForScopeAllocation(e):if(!r._registry.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`);return r._registry.get(e);default:throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed to be registered.`)}}static featureTemplate(e,t,r=this.scope(t)){let n=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureTemplateParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);return [...this.featureDefinition(e,t),...this.featureExtensions(e,t,r)]}static featureExtensions(e,t,r){let n=this.getInstance(),i=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${i} is not allowed for feature definition.`);let a=u.getClassInheritanceChain(t).filter(A=>A!==w&&A!==j&&A!==v).map(A=>`${A.name}.${e}`),_=new Map,l=new Set;for(let A of a)for(let[T,h]of n._metaStorage)r.has(T)&&(s.isComponentMetaInstance(h)||s.isContainerMetaInstance(h))&&(l.add(T),h.extensions(A).forEach(b=>{let D=Array.from(l).reverse().find(J=>u.isInheritedFrom(T,J)&&J!==T);D&&_.delete(`${u.getComponentName(D)}.${b.handler}`),_.set(`${u.getComponentName(T)}.${b.handler}`,{dependency:new Y(T),...b});}));return n.filterToMostDerived(r,Array.from(_.values()))}filterToMostDerived(e,t){return t.filter(r=>{let n=e.resolveConstructor(r.dependency.name);return !t.some(a=>{if(a===r)return false;let _=e.resolveConstructor(a.dependency.name);return !n||!_?false:n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");switch(true){case t instanceof v:r="a-component-features";break;case t instanceof j:r="a-container-features";break;case t instanceof w:r="a-component-features";break;default:throw new p(p.InvalidFeatureTemplateParameterError,`A-Feature cannot be defined on the ${t} level`)}return [...this.meta(t)?.get(r)?.get(e)?.template||[]]}static abstractionTemplate(e,t){let r=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionTemplateParameterError,`Unable to get feature template. Component of type ${r} is not allowed for feature definition.`);return [...this.abstractionExtensions(e,t)]}static abstractionExtensions(e,t){let r=this.getInstance(),n=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let i=new Map,a=this.scope(t),_=new Set;for(let[l,A]of r._metaStorage)a.has(l)&&(s.isComponentMetaInstance(A)||s.isContainerMetaInstance(A))&&(_.add(l),A.abstractions(e).forEach(T=>{let h=Array.from(_).reverse().find(b=>u.isInheritedFrom(l,b)&&b!==l);h&&i.delete(`${u.getComponentName(h)}.${T.handler}`),i.set(`${u.getComponentName(l)}.${T.handler}`,{dependency:new Y(l),...T});}));return r.filterToMostDerived(a,Array.from(i.values()))}static reset(){let e=o.getInstance();e._registry=new WeakMap;let t=String(O.A_CONCEPT_ROOT_SCOPE)||"root";e._root=new x({name:t});}static isAllowedForScopeAllocation(e){return s.isContainerInstance(e)||s.isFeatureInstance(e)||s.isEntityInstance(e)}static isAllowedToBeRegistered(e){return s.isEntityInstance(e)||s.isComponentInstance(e)||s.isFragmentInstance(e)||s.isErrorInstance(e)}static isAllowedForMeta(e){return s.isContainerInstance(e)||s.isComponentInstance(e)||s.isEntityInstance(e)}static isAllowedForMetaConstructor(e){return s.isContainerConstructor(e)||s.isComponentConstructor(e)||s.isEntityConstructor(e)}};var L=class extends y{};L.AbstractionExtensionError="Unable to extend abstraction execution";function me(o,e={}){return function(t,r,n){let i=u.getComponentName(t);if(!o)throw new L(L.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${i}'.`);if(!s.isConstructorAvailableForAbstraction(t))throw new L(L.AbstractionExtensionError,`Unable to extend Abstraction '${o}' for '${i}'. Only A-Containers and A-Components can extend Abstractions.`);let a,_=c.meta(t);switch(true){case(s.isContainerConstructor(t)||s.isContainerInstance(t)):a="a-container-abstractions";break;case(s.isComponentConstructor(t)||s.isComponentInstance(t)):a="a-component-abstractions";break}let l=`CONCEPT_ABSTRACTION::${o}`,A=_.get(a)?new d().from(_.get(a)):new d,T=[...A.get(l)||[]],h=T.findIndex(D=>D.handler===r),b={name:l,handler:r,behavior:e.behavior||"sync",throwOnError:e.throwOnError!==void 0?e.throwOnError:true,before:s.isArray(e.before)?new RegExp(`^${e.before.join("|").replace(/\./g,"\\.")}$`).source:e.before instanceof RegExp?e.before.source:"",after:s.isArray(e.after)?new RegExp(`^${e.after.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:"",override:s.isArray(e.override)?new RegExp(`^${e.override.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:""};h!==-1?T[h]=b:T.push(b),A.set(l,T),c.meta(t).set(a,A);}}var P=class{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=c.abstractionTemplate(this._name,t);return new I({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return me}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false})}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};var De=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(De||{}),Fe=(e=>(e.LIFECYCLE="a-component-extensions",e))(Fe||{});var Ee=class{constructor(e){this.props=e;this._name=e.name||c.root.name,e.components&&e.components.length&&e.components.forEach(t=>this.scope.register(t)),e.fragments&&e.fragments.length&&e.fragments.forEach(t=>this.scope.register(t)),e.entities&&e.entities.length&&e.entities.forEach(t=>this.scope.register(t)),this._containers=e.containers||[];}static Load(e){return P.Extend("load",e)}static Publish(e){return P.Extend("publish")}static Deploy(e){return P.Extend("deploy",e)}static Build(e){return P.Extend("build",e)}static Run(e){return P.Extend("run",e)}static Start(e){return P.Extend("start",e)}static Stop(e){return P.Extend("stop",e)}get name(){return c.root.name}get scope(){return c.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new P({name:"load",containers:this._containers}).process(e);}async run(e){await new P({name:"run",containers:this._containers}).process(e);}async start(e){await new P({name:"start",containers:this._containers}).process(e);}async stop(e){await new P({name:"stop",containers:this._containers}).process(e);}async build(e){await new P({name:"build",containers:this._containers}).process(e);}async deploy(e){await new P({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new P({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new I({name:e,component:t}).process()}};var fe=class extends d{constructor(t){super();this.containers=t;}};var M=class extends y{};M.InvalidInjectionTarget="Invalid target for A-Inject decorator",M.MissingInjectionTarget="Missing target for A-Inject decorator";function ve(o,e){if(!o)throw new M(M.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let i=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new M(M.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${i})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,A=l.get(a)||[];A[n]=o instanceof Y?o:new Y(o,e),l.set(a,A),c.meta(t).set(_,l);}}
2
- export{C as ASEID,P as A_Abstraction,L as A_AbstractionError,me as A_Abstraction_Extend,S as A_BasicTypeGuards,O as A_CONCEPT_ENV,Z as A_CONSTANTS__DEFAULT_ENV_VARIABLES,ne as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,H as A_CONSTANTS__ERROR_CODES,ge as A_CONSTANTS__ERROR_DESCRIPTION,V as A_Caller,q as A_CallerError,u as A_CommonHelper,w as A_Component,N as A_ComponentMeta,Ee as A_Concept,fe as A_ConceptMeta,j as A_Container,U as A_ContainerMeta,c as A_Context,p as A_ContextError,Y as A_Dependency,f as A_DependencyError,pe as A_Dependency_All,ie as A_Dependency_Default,se as A_Dependency_Flat,ae as A_Dependency_Load,_e as A_Dependency_Parent,ue as A_Dependency_Query,ce as A_Dependency_Require,v as A_Entity,K as A_EntityError,z as A_EntityMeta,y as A_Error,I as A_Feature,m as A_FeatureError,le as A_Feature_Define,Ae as A_Feature_Extend,g as A_FormatterHelper,R as A_Fragment,k as A_IdentityHelper,ve as A_Inject,M as A_InjectError,d as A_Meta,oe as A_MetaDecorator,x as A_Scope,E as A_ScopeError,X as A_Stage,$ as A_StageError,B as A_StepManagerError,W as A_StepsManager,xe as A_TYPES__A_Stage_Status,de as A_TYPES__ComponentMetaKey,De as A_TYPES__ConceptAbstractions,Fe as A_TYPES__ConceptMetaKey,Pe as A_TYPES__ContainerMetaKey,Ye as A_TYPES__EntityFeatures,Ce as A_TYPES__EntityMetaKey,be as A_TYPES__FeatureState,s as A_TypeGuards};//# sourceMappingURL=index.mjs.map
1
+ var R=class{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};var be=(i=>(i.INITIALIZED="INITIALIZED",i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.INTERRUPTED="INTERRUPTED",i.FAILED="FAILED",i))(be||{});var g=class{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};var k=class{static generateTimeId(e={timestamp:new Date,random:Math.random().toString(36).slice(2,8)}){let t=e.timestamp.getTime().toString(36),r=e.random;return `${t}-${r}`}static parseTimeId(e){let[t,r]=e.split("-");return {timestamp:new Date(parseInt(t,36)),random:r}}static formatWithLeadingZeros(e,t=10){return String(e).padStart(t+1,"0").slice(-t)}static removeLeadingZeros(e){return String(Number(e))}static hashString(e){let t=0,r,n;if(e.length===0)return t.toString();for(r=0;r<e.length;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t.toString()}};var S=class o{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static isArray(e){return Array.isArray(e)}static isErrorConstructorType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&o.isString(e.aseid)}static isScopeInstance(e){return !!e&&typeof e=="object"&&"name"in e&&"aseid"in e}};var D=class D{static isASEID(e){return this.regexp.test(e)}static compare(e,t){if(!e||!t)return false;if(S.isString(e)&&this.isASEID(e)===false)throw new Error(`Invalid ASEID format provided: ${e}`);if(S.isString(t)&&this.isASEID(t)===false)throw new Error(`Invalid ASEID format provided: ${t}`);let r=e instanceof D?e:new D(e),n=t instanceof D?t:new D(t);return r.toString()===n.toString()}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||c.concept}get scope(){return this._scope||c.root.name}get entity(){return this._entity}get id(){return this._id}get version(){return this._version}get shard(){return this._shard}get hash(){return k.hashString(this.toString())}getInitializer(e){switch(true){case S.isString(e):return this.fromString;case S.isObject(e):return this.fromObject;default:throw new Error("Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[i,a,_]=r.split(":"),l=_.includes(".")?_.split(".")[0]:void 0,A=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=i||c.root.name,this._entity=a,this._id=A,this._version=n,this._shard=l;}fromObject(e){this._concept=e.concept?D.isASEID(e.concept)?new D(e.concept).id:e.concept:c.concept,this._scope=e.scope?S.isNumber(e.scope)?k.formatWithLeadingZeros(e.scope):D.isASEID(e.scope)?new D(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=S.isNumber(e.id)?k.formatWithLeadingZeros(e.id):e.id,this._version=e.version,this._shard=e.shard;}toString(){return `${this.concept}@${this.scope}:${this.entity}:${this.shard?this.shard+"."+this.id:this.id}${this.version?"@"+this.version:""}`}toJSON(){return {concept:this._concept,scope:this._scope,entity:this._entity,id:this._id,version:this._version,shard:this._shard}}verifyInput(e){switch(true){case(S.isString(e)&&!D.isASEID(e)):throw new Error("Invalid ASEID format provided");case(S.isObject(e)&&!e.id):throw new Error("ASEID id is required");case(S.isObject(e)&&!e.entity):throw new Error("ASEID entity is required")}}};D.regexp=new RegExp("^[a-z|A-Z|0-9|-]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|\\.|-]+(@v[0-9|\\.]+|@lts)?$");var C=D;var H={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},ge="If you see this error please let us know.";var re=class{static get A_CONCEPT_NAME(){return "a-concept"}static get A_CONCEPT_ROOT_SCOPE(){return "root"}static get A_CONCEPT_ENVIRONMENT(){return "development"}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "unknown"}static get A_CONCEPT_ROOT_FOLDER(){return "/app"}static get A_ERROR_DEFAULT_DESCRIPTION(){return "If you see this error please let us know."}static get(e){return this[e]}static set(e,t){this[e]=t;}static getAll(){return {}}static getAllKeys(){return []}};var Z={A_CONCEPT_NAME:"A_CONCEPT_NAME",A_CONCEPT_ROOT_SCOPE:"A_CONCEPT_ROOT_SCOPE",A_CONCEPT_ENVIRONMENT:"A_CONCEPT_ENVIRONMENT",A_CONCEPT_RUNTIME_ENVIRONMENT:"A_CONCEPT_RUNTIME_ENVIRONMENT",A_CONCEPT_ROOT_FOLDER:"A_CONCEPT_ROOT_FOLDER",A_ERROR_DEFAULT_DESCRIPTION:"A_ERROR_DEFAULT_DESCRIPTION"},ne=[Z.A_CONCEPT_NAME,Z.A_CONCEPT_ROOT_SCOPE,Z.A_CONCEPT_ENVIRONMENT,Z.A_CONCEPT_RUNTIME_ENVIRONMENT,Z.A_CONCEPT_ROOT_FOLDER,Z.A_ERROR_DEFAULT_DESCRIPTION];var O=class extends re{static get A_CONCEPT_ENVIRONMENT(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ENVIRONMENT||super.A_CONCEPT_ENVIRONMENT}static get A_CONCEPT_RUNTIME_ENVIRONMENT(){return "browser"}static get A_CONCEPT_NAME(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_NAME||super.A_CONCEPT_NAME}static get A_CONCEPT_ROOT_FOLDER(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_FOLDER||super.A_CONCEPT_ROOT_FOLDER}static get A_CONCEPT_ROOT_SCOPE(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_CONCEPT_ROOT_SCOPE||super.A_CONCEPT_ROOT_SCOPE}static get A_ERROR_DEFAULT_DESCRIPTION(){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.A_ERROR_DEFAULT_DESCRIPTION||super.A_ERROR_DEFAULT_DESCRIPTION}static get(e){return window.__A_CONCEPT_ENVIRONMENT_ENV__?.[e]||this[e]}static set(e,t){window.__A_CONCEPT_ENVIRONMENT_ENV__||(window.__A_CONCEPT_ENVIRONMENT_ENV__={}),window.__A_CONCEPT_ENVIRONMENT_ENV__[e]=t;}static getAll(){let e={};return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e[t]=window.__A_CONCEPT_ENVIRONMENT_ENV__[t];}),ne.forEach(t=>{e[t]=this.get(t);}),e}static getAllKeys(){let e=new Set;return window.__A_CONCEPT_ENVIRONMENT_ENV__&&Object.keys(window.__A_CONCEPT_ENVIRONMENT_ENV__).forEach(t=>{e.add(t);}),ne.forEach(t=>{e.add(t);}),Array.from(e)}};var y=class o extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof o:return e;case e instanceof Error:super(e.message);break;case S.isErrorSerializedType(e):super(e.message);break;case(S.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(S.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(S.isString(e)&&!t):super(e);break;case(S.isString(e)&&!!t):super(`[${e}]: ${t}`);break;default:super("An unknown error occurred.");}this.getInitializer(e,t).call(this,e,t);}get aseid(){return this._aseid}get title(){return this._title}get message(){return super.message}get code(){return this._code||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||String(O.A_ERROR_DEFAULT_DESCRIPTION)||ge}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(S.isString(e)&&!t):return this.fromMessage;case(S.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case S.isErrorSerializedType(e):return this.fromJSON;case S.isErrorConstructorType(e):return this.fromConstructor;default:throw new o(H.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromJSON(e){this._aseid=new C(e.aseid),super.message=e.message,this._title=e.title,this._code=e.code,this._scope=e.scope,this._description=e.description,this._originalError=e.originalError?new o(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromConstructor(e){if(this.validateTitle(e.title),this._title=e.title,this._code=e.code,this._scope=e.scope?S.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new C({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._description=e.description,this._link=e.link,e.originalError instanceof o){let t=e.originalError;for(;t.originalError instanceof o;)t=t.originalError;this._originalError=t.originalError||t;}else this._originalError=e.originalError;}toJSON(){return {aseid:this.aseid.toString(),title:this.title,code:this.code,type:this.type,message:this.message,link:this.link,scope:this.scope,description:this.description,originalError:this.originalError?.message}}validateTitle(e){if(e.length>60)throw new o(H.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new o(H.VALIDATION_ERROR,"A-Error title cannot be empty.")}};var K=class extends y{};K.ValidationError="A-Entity Validation Error";var v=class{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e){this.getInitializer(e).call(this,e);}get id(){return this.aseid.id}isStringASEID(e){return typeof e=="string"&&C.isASEID(e)}isASEIDInstance(e){return e instanceof C}isSerializedObject(e){return !!e&&typeof e=="object"&&"aseid"in e}isConstructorProps(e){return !!e&&typeof e=="object"&&!("aseid"in e)}getInitializer(e){if(!e)return this.fromUndefined;if(this.isStringASEID(e))return this.fromASEID;if(this.isASEIDInstance(e))return this.fromASEID;if(this.isSerializedObject(e))return this.fromJSON;if(this.isConstructorProps(e))return this.fromNew;throw new K(K.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new C({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||k.generateTimeId()})}async call(e,t){return await new I({name:e,component:this,scope:t}).process(t)}async load(e){return this.call("load",e)}async destroy(e){return this.call("destroy",e)}async save(e){return this.call("save",e)}fromASEID(e){e instanceof C?this.aseid=e:this.aseid=new C(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new C(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};function oe(o){return function(e){return c.setMeta(e,new o),e}}var d=class o{constructor(){this.meta=new Map;}static Define(e){return oe(e)}[Symbol.iterator](){let e=this.meta.entries();return {next:()=>e.next()}}from(e){return this.meta=new Map(e.meta),this}clone(){let e=this.constructor,t=new e;return t.meta=new Map(this.meta),t}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof o:return e.toJSON();case e instanceof Map:let t={};for(let[n,i]of e.entries())t[String(n)]=this.recursiveToJSON(i);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,i]of Object.entries(e))r[n]=this.recursiveToJSON(i);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};var Ce=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(Ce||{}),Ye=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(Ye||{});var z=class extends d{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};var j=class{get name(){return this.config?.name||this.constructor.name}get scope(){return c.scope(this)}constructor(e={}){this.config=e,c.allocate(this,this.config);}async call(e,t){return await new I({name:e,component:this}).process(t)}};var Pe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Pe||{});var U=class extends d{injections(e){return this.get("a-container-injections")?.get(e)||[]}features(){return this.get("a-container-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-container-abstractions"),n=this.get("a-container-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,a])=>{a.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,i])=>{i.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}};var m=class extends y{fromConstructor(e){super.fromConstructor(e),this.stage=e.stage;}};m.Interruption="Feature Interrupted",m.FeatureInitializationError="Unable to initialize A-Feature",m.FeatureProcessingError="Error occurred during A-Feature processing",m.FeatureDefinitionError="Unable to define A-Feature",m.FeatureExtensionError="Unable to extend A-Feature";var u=class{static resolve(){return new Promise(e=>e())}static isInheritedFrom(e,t){let r=e;for(;r;){if(r===t)return true;r=Object.getPrototypeOf(r);}return false}static getParentClasses(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=[];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getClassInheritanceChain(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=typeof e=="function"?[e]:[e.constructor];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getParentClass(e){return Object.getPrototypeOf(e)}static omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(i,a){let _=a[0];a.length===1?delete i[_]:i[_]!==void 0&&typeof i[_]=="object"&&n(i[_],a.slice(1));}return t.forEach(i=>{let a=i.split(".");n(r,a);}),r}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static deepMerge(e,t,r=new Map){if(this.isObject(e)&&this.isObject(t))for(let n in t)this.isObject(t[n])?(e[n]||(e[n]={}),r.has(t[n])?e[n]=r.get(t[n]):(r.set(t[n],{}),this.deepMerge(e[n],t[n],r))):e[n]=t[n];return e}static deepClone(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(t=>this.deepClone(t));if(typeof e=="function")return e;if(e instanceof Object){let t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=this.deepClone(e[r]));return t}throw new Error("Unable to clone the object. Unsupported type.")}static deepCloneAndMerge(e,t){if(t==null&&e==null)return e;if(e==null&&t)return this.deepClone(t);if(typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(r=>this.deepCloneAndMerge(r,t));if(typeof e=="function")return e;if(e instanceof Object){let r={};for(let n in e)t[n]!==null&&t[n]!==void 0?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(e[n]);for(let n in t)e[n]!==void 0&&e[n]!==null?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(t[n]);return r}throw new Error("Unable to clone the object. Unsupported type.")}static getComponentName(e){let t="Unknown",r="Anonymous";if(e==null)return t;if(typeof e=="string")return e||t;if(typeof e=="symbol")try{return e.toString()}catch{return t}if(Array.isArray(e))return e.length===0?t:this.getComponentName(e[0]);if(typeof e=="function"){let n=e;if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name)return String(n.constructor.name);try{let a=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(a)return a[1]||a[2]||a[3]||r}catch{}return r}if(typeof e=="object"){let n=e;if(n.type)return this.getComponentName(n.type);if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name&&n.constructor.name!=="Object")return String(n.constructor.name);try{let i=n.toString();if(typeof i=="string"&&i!=="[object Object]")return i}catch{}return r}try{return String(e)}catch{return t}}};var q=class extends Error{};q.CallerInitializationError="Unable to initialize A-Caller";var V=class{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!s.isAllowedForFeatureCall(e))throw new q(`[${q.CallerInitializationError}]: Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};var f=class extends y{};f.InvalidDependencyTarget="Invalid Dependency Target",f.InvalidLoadTarget="Invalid Load Target",f.InvalidLoadPath="Invalid Load Path",f.InvalidDefaultTarget="Invalid Default Target",f.ResolutionParametersError="Dependency Resolution Parameters Error";function ie(...o){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,l=_.get(i)||[];l[r].resolutionStrategy={create:true,args:o},_.set(i,l),c.meta(e).set(a,_);}}function se(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={flat:true},a.set(n,_),c.meta(o).set(i,a);}}function ae(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={load:true},a.set(n,_),c.meta(o).set(i,a);}}function _e(o=-1){return function(e,t,r){let n=u.getComponentName(e);if(!s.isTargetAvailableForInjection(e))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",a;switch(true){case(s.isComponentConstructor(e)||s.isComponentInstance(e)):a="a-component-injections";break;case s.isContainerInstance(e):a="a-container-injections";break;case s.isEntityInstance(e):a="a-component-injections";break}let _=c.meta(e).get(a)||new d,l=_.get(i)||[];l[r].resolutionStrategy={parent:o},_.set(i,l),c.meta(e).set(a,_);}}function ce(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={require:true},a.set(n,_),c.meta(o).set(i,a);}}function pe(){return function(o,e,t){let r=u.getComponentName(o);if(!s.isTargetAvailableForInjection(o))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof o} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(s.isComponentConstructor(o)||s.isComponentInstance(o)):i="a-component-injections";break;case s.isContainerInstance(o):i="a-container-injections";break;case s.isEntityInstance(o):i="a-component-injections";break}let a=c.meta(o).get(i)||new d,_=a.get(n)||[];_[t].resolutionStrategy={pagination:{..._[t].resolutionStrategy.pagination,count:-1}},a.set(n,_),c.meta(o).set(i,a);}}function ue(o,e){return function(t,r,n){let i=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new f(f.InvalidDependencyTarget,`A-All cannot be used on the target of type ${typeof t} (${i})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,A=l.get(a)||[];A[n].resolutionStrategy={query:{...A[n].resolutionStrategy.query,...o},pagination:{...A[n].resolutionStrategy.pagination,...e}},l.set(a,A),c.meta(t).set(_,l);}}var Y=class{constructor(e,t){this._defaultPagination={count:1,from:"start"};this._defaultResolutionStrategy={require:false,load:false,parent:0,flat:false,create:false,args:[],query:{},pagination:this._defaultPagination};this._name=typeof e=="string"?e:u.getComponentName(e),this._target=typeof e=="string"?void 0:e,this.resolutionStrategy=t||{},this.initCheck();}static get Required(){return ce}static get Loaded(){return ae}static get Default(){return ie}static get Parent(){return _e}static get Flat(){return se}static get All(){return pe}static get Query(){return ue}get flat(){return this._resolutionStrategy.flat}get require(){return this._resolutionStrategy.require}get load(){return this._resolutionStrategy.load}get all(){return this._resolutionStrategy.pagination.count!==1||Object.keys(this._resolutionStrategy.query).length>0}get parent(){return this._resolutionStrategy.parent}get create(){return this._resolutionStrategy.create}get args(){return this._resolutionStrategy.args}get query(){return this._resolutionStrategy.query}get pagination(){return this._resolutionStrategy.pagination}get name(){return this._name}get target(){return this._target}get resolutionStrategy(){return this._resolutionStrategy}set resolutionStrategy(e){this._resolutionStrategy={...this._defaultResolutionStrategy,...this._resolutionStrategy,...e,pagination:{...this._defaultPagination,...(this._resolutionStrategy||{}).pagination,...e.pagination||{}}};}initCheck(){if(!this._resolutionStrategy)throw new f(f.ResolutionParametersError,`Resolution strategy parameters are not provided for dependency: ${this._name}`);return this}toJSON(){return {name:this._name,all:this.all,require:this.require,load:this.load,parent:this.parent,flat:this.flat,create:this.create,args:this.args,query:this.query,pagination:this.pagination}}};var s=class o{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isArray(e){return Array.isArray(e)}static isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static isFunction(e){return typeof e=="function"}static isUndefined(e){return typeof e>"u"}static isRegExp(e){return e instanceof RegExp}static isContainerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,j)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,w)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Error)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,I)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,V)}static isDependencyConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isDependencyInstance(e){return e instanceof Y}static isContainerInstance(e){return e instanceof j}static isComponentInstance(e){return e instanceof w}static isFeatureInstance(e){return e instanceof I}static isFragmentInstance(e){return e instanceof R}static isEntityInstance(e){return e instanceof v}static isScopeInstance(e){return e instanceof x}static isErrorInstance(e){return e instanceof Error}static isComponentMetaInstance(e){return e instanceof N}static isContainerMetaInstance(e){return e instanceof U}static isEntityMetaInstance(e){return e instanceof z}static hasASEID(e){return e&&typeof e=="object"&&"aseid"in e&&(o.isEntityInstance(e)||o.isErrorInstance(e))}static isConstructorAllowedForScopeAllocation(e){return o.isContainerConstructor(e)||o.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return o.isContainerInstance(e)||o.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return o.isContainerInstance(e)||o.isComponentInstance(e)}static isTargetAvailableForInjection(e){return o.isComponentConstructor(e)||o.isComponentInstance(e)||o.isContainerInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureCall(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return o.isComponentInstance(e)||o.isContainerInstance(e)||o.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return o.isContainerInstance(e)||o.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return o.isFragmentConstructor(e)||u.isInheritedFrom(e,R)||o.isEntityConstructor(e)||u.isInheritedFrom(e,v)}static isErrorConstructorType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&o.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&C.isASEID(e.aseid)}static isPromiseInstance(e){return e instanceof Promise}};function le(o={}){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureDefinition(e))throw new m(m.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let i=c.meta(e.constructor),a;switch(true){case s.isEntityInstance(e):a="a-component-features";break;case s.isContainerInstance(e):a="a-container-features";break;case s.isComponentInstance(e):a="a-component-features";break}let _=i.get(a)||new d,l=o.name||t,A=o.invoke||false;_.set(t,{name:`${e.constructor.name}.${l}`,handler:t,invoke:A,template:o.template&&o.template.length?o.template.map(h=>({...h,before:h.before||"",after:h.after||"",behavior:h.behavior||"sync",throwOnError:true,override:h.override||""})):[]}),c.meta(e.constructor).set(a,_);let T=r.value;return r.value=function(...h){if(A)T.apply(this,h);else return T.apply(this,h);if(typeof this.call=="function"&&A)return this.call(l)},r}}function Ae(o){return function(e,t,r){let n=u.getComponentName(e);if(!s.isAllowedForFeatureExtension(e))throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let i,a="sync",_="",l="",A="",T=[],h=[],b=true,F;switch(true){case s.isEntityInstance(e):F="a-component-extensions";break;case s.isContainerInstance(e):F="a-container-extensions";break;case s.isComponentInstance(e):F="a-component-extensions";break}switch(true){case s.isRegExp(o):i=o;break;case(!!o&&typeof o=="object"):Array.isArray(o.scope)?T=o.scope:o.scope&&typeof o.scope=="object"&&(Array.isArray(o.scope.include)&&(T=o.scope.include),Array.isArray(o.scope.exclude)&&(h=o.scope.exclude)),i=we(o,T,h,t),a=o.behavior||a,b=o.throwOnError!==void 0?o.throwOnError:b,_=s.isArray(o.before)?new RegExp(`^${o.before.join("|").replace(/\./g,"\\.")}$`).source:o.before instanceof RegExp?o.before.source:"",l=s.isArray(o.after)?new RegExp(`^${o.after.join("|").replace(/\./g,"\\.")}$`).source:o.after instanceof RegExp?o.after.source:"",A=s.isArray(o.override)?new RegExp(`^${o.override.join("|").replace(/\./g,"\\.")}$`).source:o.override instanceof RegExp?o.override.source:"";break;default:i=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let J=c.meta(e).get(F),Te=c.meta(e),G=Te.get(F)?new d().from(Te.get(F)):new d;if(J&&J.size()&&J.has(t)&&J.get(t).invoke)throw new m(m.FeatureExtensionError,`A-Feature-Extend cannot be used on the method "${t}" because it is already defined as a Feature with "invoke" set to true. Please remove the A-Feature-Extend decorator or set "invoke" to false in the A-Feature decorator.`);let ee=[...G.get(i.source)||[]];for(let[Q,te]of G.entries()){let he=te.findIndex(Ie=>Ie.handler===t);Q!==i.source&&he!==-1&&(te.splice(he,1),te.length===0?G.delete(Q):G.set(Q,te));}let Se=ee.findIndex(Q=>Q.handler===t),ye={name:i.source,handler:t,behavior:a,before:_,after:l,throwOnError:b,override:A};Se!==-1?ee[Se]=ye:ee.push(ye),G.set(i.source,ee),c.meta(e).set(F,G);}}function we(o,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",i=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",a=o.scope?`^${i}${n}\\.${o.name||r}$`:`.*\\.${o.name||r}$`;return new RegExp(a)}var xe=(a=>(a.PROCESSING="PROCESSING",a.COMPLETED="COMPLETED",a.FAILED="FAILED",a.SKIPPED="SKIPPED",a.INITIALIZED="INITIALIZED",a.ABORTED="ABORTED",a))(xe||{});var $=class extends y{static get CompileError(){return "Unable to compile A-Stage"}};$.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var X=class{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}getStepArgs(e,t){let r=t.dependency.target||e.resolveConstructor(t.dependency.name);return c.meta(r).injections(t.handler).map(n=>{switch(true){case s.isCallerConstructor(n.target):return this._feature.caller.component;case s.isFeatureConstructor(n.target):return this._feature;default:return e.resolve(n)}})}getStepComponent(e,t){let{dependency:r,handler:n}=t,i=e.resolve(r)||this.feature.scope.resolve(r);if(!i)throw new $($.CompileError,`Unable to resolve component ${r.name} from scope ${e.name}`);if(!i[n])throw new $($.CompileError,`Handler ${n} not found in ${i.constructor.name}`);return i}callStepHandler(e,t){let r=this.getStepComponent(t,e),n=this.getStepArgs(t,e);return {handler:r[e.handler].bind(r),params:n}}skip(){this._status="SKIPPED";}process(e){let t=s.isScopeInstance(e)?e:this._feature.scope;if(!this.isProcessed){this._status="PROCESSING";let{handler:r,params:n}=this.callStepHandler(this._definition,t),i=r(...n);if(s.isPromiseInstance(i))return new Promise(async(a,_)=>{try{return await i,this.completed(),a()}catch(l){let A=new y(l);return this.failed(A),this._definition.throwOnError?a():_(A)}});this.completed();}}completed(){this._status="COMPLETED";}failed(e){this._error=new y(e),this._status="FAILED";}toJSON(){return {name:this.name,status:this.status}}toString(){return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`}};var B=class extends y{};B.CircularDependencyError="A-StepManager Circular Dependency Error";var W=class{constructor(e){this._isBuilt=false;this.entities=this.prepareSteps(e),this.graph=new Map,this.visited=new Set,this.tempMark=new Set,this.sortedEntities=[];}prepareSteps(e){return e.map(t=>({...t,behavior:t.behavior||"sync",before:t.before||"",after:t.after||"",override:t.override||"",throwOnError:false}))}ID(e){return `${e.dependency.name}.${e.handler}`}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some(n=>n.override?new RegExp(n.override).test(this.ID(e)):false)),this.entities.forEach(e=>this.graph.set(this.ID(e),new Set)),this.entities.forEach(e=>{let t=this.ID(e);e.before&&this.matchEntities(t,e.before).forEach(n=>{this.graph.has(n)||this.graph.set(n,new Set),this.graph.get(n).add(t);}),e.after&&this.matchEntities(t,e.after).forEach(n=>{this.graph.has(t)||this.graph.set(t,new Set),this.graph.get(t).add(n);});}));}matchEntities(e,t){let r=new RegExp(t);return this.entities.filter(n=>r.test(this.ID(n))&&this.ID(n)!==e).map(n=>this.ID(n))}visit(e){this.tempMark.has(e)||this.visited.has(e)||(this.tempMark.add(e),(this.graph.get(e)||[]).forEach(t=>this.visit(t)),this.tempMark.delete(e),this.visited.add(e),this.sortedEntities.push(e));}toSortedArray(){return this.buildGraph(),this.entities.forEach(e=>{this.visited.has(this.ID(e))||this.visit(this.ID(e));}),this.sortedEntities}toStages(e){return this.toSortedArray().map(r=>{let n=this.entities.find(i=>this.ID(i)===r);return new X(e,n)})}};var I=class o{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return le}static get Extend(){return Ae}get name(){return this._name}get error(){return this._error}get state(){return this._state}get index(){return this._index}get stage(){return this._current}get caller(){return this._caller}get scope(){return c.scope(this)}get size(){return this._stages.length}get isDone(){return !this.stage||this._index>=this._stages.length}get isProcessed(){return this.state==="COMPLETED"||this.state==="FAILED"||this.state==="INTERRUPTED"}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._stages[this._index],this._index++,{value:this._current,done:false})}}validateParams(e){if(!e||typeof e!="object")throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}getInitializer(e){switch(true){case !("template"in e):return this.fromComponent;case "template"in e:return this.fromTemplate;default:throw new m(m.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}}fromTemplate(e){if(!e.template||!Array.isArray(e.template))throw new m(m.FeatureInitializationError,`Invalid A-Feature template provided of type: ${typeof e.template} with value: ${JSON.stringify(e.template).slice(0,100)}...`);if(!e.component&&(!e.scope||!(e.scope instanceof x)))throw new m(m.FeatureInitializationError,`Invalid A-Feature scope provided of type: ${typeof e.scope} with value: ${JSON.stringify(e.scope).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{e.component&&(t=c.scope(e.component));}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new W(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!s.isAllowedForFeatureDefinition(e.component))throw new m(m.FeatureInitializationError,`Invalid A-Feature component provided of type: ${typeof e.component} with value: ${JSON.stringify(e.component).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{t=c.scope(e.component);}catch(a){if(!r)throw a}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component);let n=c.allocate(this);n.inherit(t||r);let i=c.featureTemplate(this._name,this._caller.component,n);this._SM=new W(i),this._stages=this._SM.toStages(this),this._current=this._stages[0];}process(e){try{if(this.isProcessed)return;this._state="PROCESSING";let t=Array.from(this);return this.processStagesSequentially(t,e,0)}catch(t){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:t}))}}processStagesSequentially(e,t,r){try{if(this.state==="INTERRUPTED")return;if(r>=e.length){this.completed();return}let n=e[r],i=n.process(t);return s.isPromiseInstance(i)?i.then(()=>{if(this.state!=="INTERRUPTED")return this.processStagesSequentially(e,t,r+1)}).catch(a=>{throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${n.name}.`,stage:n,originalError:a}))}):this.processStagesSequentially(e,t,r+1)}catch(n){throw this.failed(new m({title:m.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:n}))}}next(e){let t=this._stages.indexOf(e);this._index=t+1,this._index>=this._stages.length&&this.completed();}completed(){this.isProcessed||this.state!=="INTERRUPTED"&&(this._state="COMPLETED",this.scope.destroy());}failed(e){return this.isProcessed?this._error:(this._state="FAILED",this._error=e,this.scope.destroy(),this._error)}interrupt(e){if(this.isProcessed)return this._error;switch(this._state="INTERRUPTED",true){case s.isString(e):this._error=new m(m.Interruption,e);break;case s.isErrorInstance(e):this._error=new m({code:m.Interruption,title:e.title||"Feature Interrupted",description:e.description||e.message,stage:this.stage,originalError:e});break;default:this._error=new m(m.Interruption,"Feature was interrupted");break}return this.scope.destroy(),this._error}chain(e,t,r){let n,i;e instanceof o?(n=e,i=t instanceof x?t:void 0):(n=new o({name:t,component:e}),i=r instanceof x?r:void 0);let a=i||this.scope;n._caller=this._caller;let _=n.process(a);return s.isPromiseInstance(_)?_.catch(l=>{throw l}):_}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};var w=class{call(e,t){return new I({name:e,component:this}).process(t)}};var de=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(de||{});var N=class extends d{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,i])=>{i.forEach(a=>{t.push({name:a.name,handler:a.handler,behavior:a.behavior,before:a.before||"",after:a.after||"",throwOnError:a.throwOnError||true,override:""});});}),t}features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-component-abstractions"),n=this.get("a-component-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,a])=>{a.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}};var x=class{constructor(e,t){this._meta=new d;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this._imports=new Set;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get imports(){return Array.from(this._imports.values())}get parent(){return this._parent}*parents(){let e=this._parent;for(;e;)yield e,e=e._parent;}parentOffset(e){let t=this;for(;e<=-1&&t;)t=t.parent,e++;return t}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new E(E.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>c.deregister(e)),this._fragments.forEach(e=>c.deregister(e)),this._entities.forEach(e=>c.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this._imports.clear(),this.issuer()&&c.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return c.issuer(this)}inherit(e){if(!e)throw new E(E.InitializationError,"Invalid parent scope provided");if(e===this)throw new E(E.CircularInheritanceError,`Unable to inherit scope ${this.name} from itself`);if(e===this._parent)return this;let t=this.checkCircularInheritance(e);if(t)throw new E(E.CircularInheritanceError,`Circular inheritance detected: ${[...t,e.name].join(" -> ")}`);return this._parent=e,this}import(...e){return e.forEach(t=>{if(t===this)throw new E(E.CircularImportError,`Unable to import scope ${this.name} into itself`);this._imports.has(t)||this._imports.add(t);}),this}deimport(...e){return e.forEach(t=>{this._imports.has(t)&&this._imports.delete(t);}),this}has(e){let t=this.hasFlat(e);if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}hasFlat(e){let t=false;switch(true){case s.isScopeConstructor(e):return true;case s.isString(e):{Array.from(this.allowedComponents).find(_=>_.name===e)&&(t=true),Array.from(this.allowedFragments).find(_=>_.name===e)&&(t=true),Array.from(this.allowedEntities).find(_=>_.name===e)&&(t=true),Array.from(this.allowedErrors).find(_=>_.name===e)&&(t=true);break}case s.isComponentConstructor(e):{t=this.isAllowedComponent(e)||!![...this.allowedComponents].find(r=>u.isInheritedFrom(r,e));break}case s.isEntityConstructor(e):{t=this.isAllowedEntity(e)||!![...this.allowedEntities].find(r=>u.isInheritedFrom(r,e));break}case s.isFragmentConstructor(e):{t=this.isAllowedFragment(e)||!![...this.allowedFragments].find(r=>u.isInheritedFrom(r,e));break}case s.isErrorConstructor(e):{t=this.isAllowedError(e)||!![...this.allowedErrors].find(r=>u.isInheritedFrom(r,e));break}case(this.issuer()&&(this.issuer().constructor===e||u.isInheritedFrom(this.issuer().constructor,e))):{t=true;break}}return t}resolveDependency(e){let t=[],r=this.parentOffset(e.parent)||this;switch(true){case(e.flat&&!e.all):{let A=r.resolveFlatOnce(e.target||e.name);A&&(t=[A]);break}case(e.flat&&e.all):{t=r.resolveFlatAll(e.target||e.name);break}case(!e.flat&&!e.all):{let A=r.resolveOnce(e.target||e.name);A&&(t=[A]);break}case(!e.flat&&e.all):{t=r.resolveAll(e.target||e.name);break}default:t=[];}if(e.create&&!t.length&&s.isAllowedForDependencyDefaultCreation(e.target)){let A=new e.target(...e.args);r.register(A),t.push(A);}if(e.require&&!t.length)throw new E(E.ResolutionError,`Dependency ${e.name} is required but could not be resolved in scope ${r.name}`);e.query.aseid?t=t.filter(A=>s.hasASEID(A)&&C.compare(A.aseid,e.query.aseid)):Object.keys(e.query).length>0&&(t=t.filter(A=>{let T=e.query;return T?Object.entries(T).every(([h,b])=>A[h]===b):true}));let n=e.pagination.count,i=e.pagination.from,a=i==="end"?n===-1?0:Math.max(t.length-n,0):0,_=i==="end"||n===-1?t.length:Math.min(n,t.length),l=t.slice(a,_);return l.length===1&&n!==-1?l[0]:l.length?l:void 0}resolveConstructor(e){switch(true){case s.isComponentConstructor(e):return Array.from(this.allowedComponents).find(i=>u.isInheritedFrom(i,e));case s.isEntityConstructor(e):return Array.from(this.allowedEntities).find(i=>u.isInheritedFrom(i,e));case s.isFragmentConstructor(e):return Array.from(this.allowedFragments).find(i=>u.isInheritedFrom(i,e));case s.isErrorConstructor(e):return Array.from(this.allowedErrors).find(i=>u.isInheritedFrom(i,e))}if(!s.isString(e))throw new E(E.ResolutionError,`Invalid constructor name provided: ${e}`);let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===g.toPascalCase(e));if(t)return t;{let i=Array.from(this.allowedComponents).find(a=>{let _=a;for(;_;){if(_.name===e||_.name===g.toPascalCase(e))return true;_=Object.getPrototypeOf(_);}return false});if(i)return i}let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.entity===e||i.entity===g.toKebabCase(e));if(r)return r;{let i=Array.from(this.allowedEntities).find(a=>u.isInheritedFrom(a,e));if(i)return i}let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===g.toPascalCase(e));if(n)return n;{let i=Array.from(this.allowedFragments).find(a=>u.isInheritedFrom(a,e));if(i)return i}for(let i of this._imports){let a=i.resolveConstructor(e);if(a)return a}if(this._parent)return this._parent.resolveConstructor(e)}resolveAll(e){let t=new Set;this.resolveFlatAll(e).forEach(i=>t.add(i)),this._imports.forEach(i=>{i.has(e)&&i.resolveFlatAll(e).forEach(_=>t.add(_));});let n=this._parent;for(;n&&n.has(e);)n.resolveAll(e).forEach(a=>t.add(a)),n=n._parent;return Array.from(t)}resolveFlatAll(e){let t=[];switch(true){case s.isComponentConstructor(e):{this.allowedComponents.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isFragmentConstructor(e):{this.allowedFragments.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolveOnce(r);n&&t.push(n);}});break}case s.isEntityConstructor(e):{this.entities.forEach(r=>{u.isInheritedFrom(r.constructor,e)&&t.push(r);});break}case s.isString(e):{let r=this.resolveConstructor(e);if(!s.isComponentConstructor(r)&&!s.isEntityConstructor(r)&&!s.isFragmentConstructor(r))throw new E(E.ResolutionError,`Unable to resolve all instances for name: ${e} in scope ${this.name} as no matching component, entity or fragment constructor found`);if(r){let n=this.resolveAll(r);n&&t.push(...n);}break}default:throw new E(E.ResolutionError,`Invalid parameter provided to resolveAll method: ${e} in scope ${this.name}`)}return t}resolve(e){let t=s.isDependencyInstance(e)?e:new Y(e);return this.resolveDependency(t)}resolveOnce(e){let t=this.resolveFlatOnce(e);if(!t){for(let r of this._imports)if(r.has(e)){let n=r.resolveFlatOnce(e);if(n)return n}}return !t&&this.parent?this.parent.resolveOnce(e):t}resolveFlat(e){return this.resolveFlatOnce(e)}resolveFlatOnce(e){let t,r=u.getComponentName(e);if(!(!e||!this.has(e))){switch(true){case s.isString(e):{t=this.resolveByName(e);break}case s.isConstructorAllowedForScopeAllocation(e):{t=this.resolveIssuer(e);break}case s.isScopeConstructor(e):{t=this.resolveScope(e);break}case s.isEntityConstructor(e):{t=this.resolveEntity(e);break}case s.isFragmentConstructor(e):{t=this.resolveFragment(e);break}case s.isComponentConstructor(e):{t=this.resolveComponent(e);break}case s.isErrorConstructor(e):{t=this.resolveError(e);break}default:throw new E(E.ResolutionError,`Injected Component ${r} not found in the scope`)}return t}}resolveByName(e){let t=Array.from(this.allowedComponents).find(a=>a.name===e||a.name===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.entity===e||a.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(a=>a.name===e||a.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let i=Array.from(this.allowedErrors).find(a=>a.name===e||a.name===g.toPascalCase(e)||a.code===e||a.code===g.toKebabCase(e));if(i)return this.resolveOnce(i)}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t}resolveEntity(e){return this.entities.find(t=>t instanceof e)}resolveError(e){return this.errors.find(t=>t instanceof e)}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}default:return}}resolveScope(e){return this}resolveComponent(e){switch(true){case(this.allowedComponents.has(e)&&this._components.has(e)):return this._components.get(e);case(this.allowedComponents.has(e)&&!this._components.has(e)):{let n=(c.meta(e).get("a-component-injections")?.get("constructor")||[]).map(a=>this.resolve(a)),i=new e(...n);return this.register(i),this._components.get(e)}case(!this.allowedComponents.has(e)&&Array.from(this.allowedComponents).some(t=>u.isInheritedFrom(t,e))):{let t=Array.from(this.allowedComponents).find(r=>u.isInheritedFrom(r,e));return this.resolveComponent(t)}default:return}}register(e){switch(true){case e instanceof w:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e);break}case(s.isEntityInstance(e)&&!this._entities.has(e.aseid.toString())):{this.allowedEntities.has(e.constructor)||this.allowedEntities.add(e.constructor),this._entities.set(e.aseid.toString(),e),c.register(this,e);break}case s.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),c.register(this,e);break}case s.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),c.register(this,e);break}case s.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case s.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case s.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof v)throw new E(E.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof R)throw new E(E.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new E(E.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof w:{this._components.delete(e.constructor),c.deregister(e);let r=e.constructor;this._components.has(r)||this.allowedComponents.delete(r);break}case s.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),c.deregister(e);let r=e.constructor;Array.from(this._entities.values()).some(i=>i instanceof r)||this.allowedEntities.delete(r);break}case s.isFragmentInstance(e):{this._fragments.delete(e.constructor),c.deregister(e);let r=e.constructor;Array.from(this._fragments.values()).some(i=>i instanceof r)||this.allowedFragments.delete(r);break}case s.isErrorInstance(e):{this._errors.delete(e.code),c.deregister(e);let r=e.constructor;Array.from(this._errors.values()).some(i=>i instanceof r)||this.allowedErrors.delete(r);break}case s.isComponentConstructor(e):{this.allowedComponents.delete(e);break}case s.isFragmentConstructor(e):{this.allowedFragments.delete(e),Array.from(this._fragments.entries()).forEach(([r,n])=>{u.isInheritedFrom(r,e)&&(this._fragments.delete(r),c.deregister(n));});break}case s.isEntityConstructor(e):{this.allowedEntities.delete(e),Array.from(this._entities.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._entities.delete(r),c.deregister(n));});break}case s.isErrorConstructor(e):{this.allowedErrors.delete(e),Array.from(this._errors.entries()).forEach(([r,n])=>{u.isInheritedFrom(n.constructor,e)&&(this._errors.delete(r),c.deregister(n));});break}default:let t=u.getComponentName(e);throw new E(E.DeregistrationError,`Cannot deregister ${t} from the scope ${this.name}`)}}toJSON(){return this.fragments.reduce((e,t)=>{let r=t.toJSON();return {...e,[r.name]:r}},{})}isAllowedComponent(e){return s.isComponentConstructor(e)&&this.allowedComponents.has(e)}isAllowedEntity(e){return s.isEntityConstructor(e)&&this.allowedEntities.has(e)}isAllowedFragment(e){return s.isFragmentConstructor(e)&&this.allowedFragments.has(e)}isAllowedError(e){return s.isErrorConstructor(e)&&this.allowedErrors.has(e)}isInheritedFrom(e){let t=this;for(;t;){if(t===e)return true;t=t._parent;}return false}checkCircularInheritance(e){let t=[],r=this._parent;for(;r;){if(t.push(r.name),r===e)return t;r=r._parent;}return false}printInheritanceChain(){let e=[],t=this;for(;t;)e.push(t.name),t=t._parent;console.log(e.join(" -> "));}};var E=class extends y{};E.InitializationError="A-Scope Initialization Error",E.ConstructorError="Unable to construct A-Scope instance",E.ResolutionError="A-Scope Resolution Error",E.RegistrationError="A-Scope Registration Error",E.CircularInheritanceError="A-Scope Circular Inheritance Error",E.CircularImportError="A-Scope Circular Import Error",E.DeregistrationError="A-Scope Deregistration Error";var p=class extends y{};p.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",p.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",p.InvalidMetaParameterError="Invalid parameter provided to get meta",p.InvalidScopeParameterError="Invalid parameter provided to get scope",p.ScopeNotFoundError="Scope not found",p.InvalidFeatureParameterError="Invalid parameter provided to get feature",p.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",p.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",p.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",p.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",p.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",p.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",p.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",p.InvalidInjectionParameterError="Invalid parameter provided to get injections",p.InvalidExtensionParameterError="Invalid parameter provided to get extensions",p.InvalidRegisterParameterError="Invalid parameter provided to register component",p.InvalidComponentParameterError="Invalid component provided",p.ComponentNotRegisteredError="Component not registered in the context",p.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var c=class o{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;this._globals=new Map;let e=String(O.A_CONCEPT_ROOT_SCOPE)||"root";this._root=new x({name:e});}static get concept(){return O.A_CONCEPT_NAME||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){return O.A_CONCEPT_RUNTIME_ENVIRONMENT}static getInstance(){return o._instance||(o._instance=new o),o._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new p(p.NotAllowedForScopeAllocationError,`Component ${r} is not allowed for scope allocation.`);return n._scopeStorage.set(t,e),e}static deregister(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new p(p.ComponentNotRegisteredError,`Unable to deregister component. Component ${t} is not registered.`);r._scopeStorage.delete(e);}static allocate(e,t){let r=u.getComponentName(e);if(!this.isAllowedForScopeAllocation(e))throw new p(p.NotAllowedForScopeAllocationError,`Component of type ${r} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);let n=this.getInstance();if(n._registry.has(e))throw new p(p.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let i=s.isScopeInstance(t)?t:new x(t||{name:r+"-scope"},t);return i.isInheritedFrom(o.root)||i.inherit(o.root),n._registry.set(e,i),n._scopeIssuers.set(i,e),i}static deallocate(e){let t=this.getInstance(),r=s.isScopeInstance(e)?e:t._registry.get(e);if(!r)return;let n=s.isComponentInstance(e)?e:this.issuer(r);n&&t._registry.delete(n),r&&t._scopeIssuers.delete(r);}static meta(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new p(p.InvalidMetaParameterError,"Invalid parameter provided to get meta. Parameter cannot be null or undefined.");if(!(this.isAllowedForMeta(e)||this.isAllowedForMetaConstructor(e)||s.isString(e)||s.isFunction(e)))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component of type ${t} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);let n,i;switch(true){case s.isContainerInstance(e):{n=e.constructor,i=U;break}case s.isContainerConstructor(e):{n=e,i=U;break}case s.isComponentInstance(e):{n=e.constructor,i=N;break}case s.isComponentConstructor(e):{n=e,i=N;break}case s.isEntityInstance(e):{n=e.constructor,i=N;break}case s.isEntityConstructor(e):{n=e,i=z;break}case s.isFragmentInstance(e):{n=e.constructor,i=N;break}case s.isFragmentConstructor(e):{n=e,i=z;break}case typeof e=="string":{let a=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===g.toKebabCase(e)||_.name===g.toPascalCase(e));if(!(a&&a.length))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=a[0],i=N;break}default:{n=e,i=d;break}}if(!r._metaStorage.has(n)){let a,_=n;for(;!a;){let l=Object.getPrototypeOf(_);if(!l)break;a=r._metaStorage.get(l),_=l;}a||(a=new i),r._metaStorage.set(n,a.clone());}return r._metaStorage.get(n)}static setMeta(e,t){let r=o.getInstance(),n=o.meta(e),i=typeof e=="function"?e:e.constructor;r._metaStorage.set(i,n?t.from(n):t);}static issuer(e){let t=this.getInstance();if(!e)throw new p(p.InvalidComponentParameterError,"Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.");return t._scopeIssuers.get(e)}static scope(e){let t=e?.constructor?.name||String(e),r=this.getInstance();if(!e)throw new p(p.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed for scope allocation.`);switch(true){case this.isAllowedToBeRegistered(e):if(!r._scopeStorage.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`);return r._scopeStorage.get(e);case this.isAllowedForScopeAllocation(e):if(!r._registry.has(e))throw new p(p.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`);return r._registry.get(e);default:throw new p(p.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed to be registered.`)}}static featureTemplate(e,t,r=this.scope(t)){let n=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureTemplateParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);return [...this.featureDefinition(e,t),...this.featureExtensions(e,t,r)]}static featureExtensions(e,t,r){let n=this.getInstance(),i=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!s.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${i} is not allowed for feature definition.`);let a=u.getClassInheritanceChain(t).filter(A=>A!==w&&A!==j&&A!==v).map(A=>`${A.name}.${e}`),_=new Map,l=new Set;for(let A of a)for(let[T,h]of n._metaStorage)r.has(T)&&(s.isComponentMetaInstance(h)||s.isContainerMetaInstance(h))&&(l.add(T),h.extensions(A).forEach(b=>{let F=Array.from(l).reverse().find(J=>u.isInheritedFrom(T,J)&&J!==T);F&&_.delete(`${u.getComponentName(F)}.${b.handler}`),_.set(`${u.getComponentName(T)}.${b.handler}`,{dependency:new Y(T),...b});}));return n.filterToMostDerived(r,Array.from(_.values()))}filterToMostDerived(e,t){return t.filter(r=>{let n=e.resolveConstructor(r.dependency.name);return !t.some(a=>{if(a===r)return false;let _=e.resolveConstructor(a.dependency.name);return !n||!_?false:n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");switch(true){case t instanceof v:r="a-component-features";break;case t instanceof j:r="a-container-features";break;case t instanceof w:r="a-component-features";break;default:throw new p(p.InvalidFeatureTemplateParameterError,`A-Feature cannot be defined on the ${t} level`)}return [...this.meta(t)?.get(r)?.get(e)?.template||[]]}static abstractionTemplate(e,t){let r=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionTemplateParameterError,`Unable to get feature template. Component of type ${r} is not allowed for feature definition.`);return [...this.abstractionExtensions(e,t)]}static abstractionExtensions(e,t){let r=this.getInstance(),n=u.getComponentName(t);if(!t)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!s.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let i=new Map,a=this.scope(t),_=new Set;for(let[l,A]of r._metaStorage)a.has(l)&&(s.isComponentMetaInstance(A)||s.isContainerMetaInstance(A))&&(_.add(l),A.abstractions(e).forEach(T=>{let h=Array.from(_).reverse().find(b=>u.isInheritedFrom(l,b)&&b!==l);h&&i.delete(`${u.getComponentName(h)}.${T.handler}`),i.set(`${u.getComponentName(l)}.${T.handler}`,{dependency:new Y(l),...T});}));return r.filterToMostDerived(a,Array.from(i.values()))}static reset(){let e=o.getInstance();e._registry=new WeakMap;let t=String(O.A_CONCEPT_ROOT_SCOPE)||"root";e._root=new x({name:t});}static isAllowedForScopeAllocation(e){return s.isContainerInstance(e)||s.isFeatureInstance(e)||s.isEntityInstance(e)}static isAllowedToBeRegistered(e){return s.isEntityInstance(e)||s.isComponentInstance(e)||s.isFragmentInstance(e)||s.isErrorInstance(e)}static isAllowedForMeta(e){return s.isContainerInstance(e)||s.isComponentInstance(e)||s.isEntityInstance(e)}static isAllowedForMetaConstructor(e){return s.isContainerConstructor(e)||s.isComponentConstructor(e)||s.isEntityConstructor(e)}};var L=class extends y{};L.AbstractionExtensionError="Unable to extend abstraction execution";function me(o,e={}){return function(t,r,n){let i=u.getComponentName(t);if(!o)throw new L(L.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${i}'.`);if(!s.isConstructorAvailableForAbstraction(t))throw new L(L.AbstractionExtensionError,`Unable to extend Abstraction '${o}' for '${i}'. Only A-Containers and A-Components can extend Abstractions.`);let a,_=c.meta(t);switch(true){case(s.isContainerConstructor(t)||s.isContainerInstance(t)):a="a-container-abstractions";break;case(s.isComponentConstructor(t)||s.isComponentInstance(t)):a="a-component-abstractions";break}let l=`CONCEPT_ABSTRACTION::${o}`,A=_.get(a)?new d().from(_.get(a)):new d,T=[...A.get(l)||[]],h=T.findIndex(F=>F.handler===r),b={name:l,handler:r,behavior:e.behavior||"sync",throwOnError:e.throwOnError!==void 0?e.throwOnError:true,before:s.isArray(e.before)?new RegExp(`^${e.before.join("|").replace(/\./g,"\\.")}$`).source:e.before instanceof RegExp?e.before.source:"",after:s.isArray(e.after)?new RegExp(`^${e.after.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:"",override:s.isArray(e.override)?new RegExp(`^${e.override.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:""};h!==-1?T[h]=b:T.push(b),A.set(l,T),c.meta(t).set(a,A);}}var P=class{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=c.abstractionTemplate(this._name,t);return new I({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return me}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false})}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};var Fe=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(Fe||{}),De=(e=>(e.LIFECYCLE="a-component-extensions",e))(De||{});var Ee=class{constructor(e){this.props=e;this._name=e.name||c.root.name,e.components&&e.components.length&&e.components.forEach(t=>this.scope.register(t)),e.fragments&&e.fragments.length&&e.fragments.forEach(t=>this.scope.register(t)),e.entities&&e.entities.length&&e.entities.forEach(t=>this.scope.register(t)),this._containers=e.containers||[];}static Load(e){return P.Extend("load",e)}static Publish(e){return P.Extend("publish")}static Deploy(e){return P.Extend("deploy",e)}static Build(e){return P.Extend("build",e)}static Run(e){return P.Extend("run",e)}static Start(e){return P.Extend("start",e)}static Stop(e){return P.Extend("stop",e)}get name(){return c.root.name}get scope(){return c.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new P({name:"load",containers:this._containers}).process(e);}async run(e){await new P({name:"run",containers:this._containers}).process(e);}async start(e){await new P({name:"start",containers:this._containers}).process(e);}async stop(e){await new P({name:"stop",containers:this._containers}).process(e);}async build(e){await new P({name:"build",containers:this._containers}).process(e);}async deploy(e){await new P({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new P({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new I({name:e,component:t}).process()}};var fe=class extends d{constructor(t){super();this.containers=t;}};var M=class extends y{};M.InvalidInjectionTarget="Invalid target for A-Inject decorator",M.MissingInjectionTarget="Missing target for A-Inject decorator";function ve(o,e){if(!o)throw new M(M.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let i=u.getComponentName(t);if(!s.isTargetAvailableForInjection(t))throw new M(M.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${i})`);let a=r?String(r):"constructor",_;switch(true){case(s.isComponentConstructor(t)||s.isComponentInstance(t)):_="a-component-injections";break;case s.isContainerInstance(t):_="a-container-injections";break;case s.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,A=l.get(a)||[];A[n]=o instanceof Y?o:new Y(o,e),l.set(a,A),c.meta(t).set(_,l);}}
2
+ export{C as ASEID,P as A_Abstraction,L as A_AbstractionError,me as A_Abstraction_Extend,S as A_BasicTypeGuards,O as A_CONCEPT_ENV,Z as A_CONSTANTS__DEFAULT_ENV_VARIABLES,ne as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,H as A_CONSTANTS__ERROR_CODES,ge as A_CONSTANTS__ERROR_DESCRIPTION,V as A_Caller,q as A_CallerError,u as A_CommonHelper,w as A_Component,N as A_ComponentMeta,Ee as A_Concept,fe as A_ConceptMeta,j as A_Container,U as A_ContainerMeta,c as A_Context,p as A_ContextError,Y as A_Dependency,f as A_DependencyError,pe as A_Dependency_All,ie as A_Dependency_Default,se as A_Dependency_Flat,ae as A_Dependency_Load,_e as A_Dependency_Parent,ue as A_Dependency_Query,ce as A_Dependency_Require,v as A_Entity,K as A_EntityError,z as A_EntityMeta,y as A_Error,I as A_Feature,m as A_FeatureError,le as A_Feature_Define,Ae as A_Feature_Extend,g as A_FormatterHelper,R as A_Fragment,k as A_IdentityHelper,ve as A_Inject,M as A_InjectError,d as A_Meta,oe as A_MetaDecorator,x as A_Scope,E as A_ScopeError,X as A_Stage,$ as A_StageError,B as A_StepManagerError,W as A_StepsManager,xe as A_TYPES__A_Stage_Status,de as A_TYPES__ComponentMetaKey,Fe as A_TYPES__ConceptAbstractions,De as A_TYPES__ConceptMetaKey,Pe as A_TYPES__ContainerMetaKey,Ye as A_TYPES__EntityFeatures,Ce as A_TYPES__EntityMetaKey,be as A_TYPES__FeatureState,s as A_TypeGuards};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map