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A,IAAA,CAAK,IAAA,CAAK,oBAAA,CAAqB,QAAA,EAAU,KAAA,IAAS,KAAK,KAAK,CAAA;AAAA,EAChE;AACJ;AAnBI,eAAA,CAAA;AAAA,EAHC,QAAQ,MAAA,CAAO;AAAA,IACZ,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EA7IQ,YAAA,CA8IT,SAAA,EAAA,SAAA,EAAA,CAAA,CAAA;AA9IS,YAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,OAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,YAAA,CAAA","file":"AreAttribute.entity.mjs","sourcesContent":["import { A_Context, A_Entity, A_Feature, A_Scope, ASEID } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport type { AreNode } from \"@adaas/are/node/AreNode.entity\";\nimport { AreAttributeFeatures } from \"./AreAttribute.constants\";\nimport { AreAttribute_Init, AreAttribute_Serialized } from \"./AreAttribute.types\";\n\n\n\n@A_Frame.Define({\n    namespace: 'A-ARE',\n    description: 'Represents an HTML attribute within the A-Concept Rendering Engine (ARE) framework, encapsulating the attribute\\'s name, raw content, evaluated value, and associated features for initialization, transformation, compilation, updating, and validation.'\n})\nexport class AreAttribute extends A_Entity<AreAttribute_Init, AreAttribute_Serialized> {\n\n    static get concept(): string {\n        return 'are';\n    }\n\n    /**\n     * Property name (e.g. \"label\")\n     */\n    name!: string;\n    /**\n     * Full raw attribute (e.g. ' :label=\"buttonLabel\" ')\n     */\n    raw!: string;\n    /**\n     * Attribute content (e.g. \"buttonLabel\")\n     * Example: For a directive like `v-if=\"condition\"`, the raw value is \"condition\", but the content would be \"condition\" without the quotes, and the value would be the result of evaluating \"condition\" in the current scope.\n     */\n    content!: string;\n    /**\n     * The evaluated value of the attribute, which can be different from the raw value depending on the context and type of the attribute. For example, for a directive like `v-if=\"condition\"`, the raw value is \"condition\", but the evaluated value would be the result of evaluating \"condition\" in the current scope.\n     */\n    value!: any;\n    /**\n     * The prefix of the attribute, for example for ':label' it would be ':', for 'v-if' it would be 'v-'. This can be used to determine the type of the attribute and how to process it.\n     */\n    prefix!: string;\n    /**\n     * The scope where the attribute is defined, which can be used to access other entities and features within the same scope. This is particularly useful for attributes that need to interact with other parts of the scene or component, as it allows them to access shared data and functionality without needing to pass it explicitly through parameters.\n     */\n    get scope() {\n        return A_Context.scope(this);\n    }\n    /**\n     * The owner node of the attribute, which is the node that the attribute is attached to. This can be used to access the properties and features of the owner node, as well as to determine the context in which the attribute is being used. For example, if the attribute is attached to a button element, the owner would be that button node, and the attribute could use this information to modify the button's behavior or appearance based on its content and context.\n     */\n    get owner(): AreNode {\n        return this.scope.issuer() as AreNode;\n    }\n\n    /**\n     * Initializes the attribute based on the provided properties. This method is called when a new attribute is created and should set up the attribute's state based on the provided properties. It can also be used to generate a unique ASEID for the attribute based on its name and content, which can be used for caching and identification purposes within the ARE framework.\n     * \n     * @param newEntity \n     */\n    fromNew(newEntity: AreAttribute_Init): void {\n        // const identity = {\n        //     name: newEntity.name,\n        //     prefix: newEntity.prefix,\n        //     content: newEntity.content,\n        // };\n\n        // const id = A_UtilsHelper.hash(identity);\n\n        this.aseid = this.generateASEID({\n            entity: newEntity.name,\n            // id: id,\n        });\n\n        this.name = newEntity.name;\n        this.prefix = newEntity.prefix;\n        this.raw = newEntity.raw;\n        this.content = newEntity.content;\n    }\n\n    /**\n     * Reconstructs the attribute from its serialized (runtime-free) form, restoring its identity and static description.\n     *\n     * Restored: `aseid`, `name`, `raw`, `content` and `prefix`.\n     * Not restored: the evaluated `value`, which is derived from `content` against the live scope and is re-evaluated when the attribute is interpreted again.\n     *\n     * @param serialized the serialized representation produced by `toJSON()`.\n     */\n    fromJSON(serialized: AreAttribute_Serialized): void {\n        this.aseid = new ASEID(serialized.aseid);\n\n        this.name = serialized.name;\n        this.prefix = serialized.prefix;\n        this.raw = serialized.raw;\n        this.content = serialized.content;\n    }\n    // =====================================================================================\n    // ------------------------------- Attribute Methods ------------------------------\n    // =====================================================================================\n    /**\n     * Creates a clone of the current attribute instance. This method can be used to create a new instance of the attribute with the same properties and state as the original, which can be useful in scenarios where you want to reuse an attribute's configuration or create variations of it without modifying the original instance.\n     * \n     * @returns \n     */\n    clone(): this {\n        return new (this.constructor as new (init: AreAttribute_Init) => this)({\n            name: this.name,\n            raw: this.raw,\n            content: this.content,\n            prefix: this.prefix,\n        });\n    }\n\n    /**\n     * Serializes the attribute into its structural (runtime-free) form.\n     *\n     * Kept (static / structural): `aseid`, `name`, `raw`, `content` and `prefix`.\n     * Dropped (runtime-only): the evaluated `value`, which is derived from `content` against the live scope and must be re-evaluated when the attribute is interpreted again.\n     *\n     * @returns the serialized, runtime-free representation of the attribute.\n     */\n    toJSON(): AreAttribute_Serialized {\n        return {\n            aseid: this.aseid.toString(),\n            name: this.name,\n            raw: this.raw,\n            content: this.content,\n            prefix: this.prefix,\n        };\n    }\n    // =====================================================================================\n    // ------------------------------- Attribute Lifecycle ------------------------------\n    // =====================================================================================\n    /**\n     * Initializes the attribute. This method is called when the attribute is first created and should set up any necessary state or perform any initial processing based on the provided content and context. It can also be used to validate the attribute's content and throw errors if it is invalid.\n     * \n     * @param scope \n     */\n    init(scope?: A_Scope) {\n        this.call(AreAttributeFeatures.Init, scope || this.scope);\n    }\n    /**\n     * Generates all rendering instructions for the attribute. This method is called during the compilation phase of the ARE component and should return an array of instructions that describe how to render the attribute based on its content and context. The instructions can include details such as which DOM properties to set, which events to listen for, and how to update the attribute when the underlying data changes.\n     * \n     * @param scope \n     */\n    transform(scope?: A_Scope) {\n        this.call(AreAttributeFeatures.Transform, scope || this.scope);\n    }\n    /**\n     * Compiles the attribute. This method should transform attribute details into a set of SceneInstructions. It may also modify attribute value, since this field is editable during runtime.\n     * \n     * @param scope \n     */\n    @A_Frame.Define({\n        description: \"Compile the attribute. This method should transform attribute details into a set of SceneInstructions. It may also modify attribute value, since this field is editable during runtime.\",\n    })\n    compile(scope?: A_Scope) {\n        this.call(AreAttributeFeatures.Compile, scope || this.scope);\n    }\n    /**\n     * Updates the attribute based on changes in the store or other dependencies. This method is called during the update phase of the ARE component and should perform any necessary updates to the attribute based on changes in the underlying data or context. This can include tasks such as updating DOM properties, re-evaluating expressions, or modifying event listeners to ensure that the attribute remains in sync with the current state of the application.\n     * \n     * @param scope \n     */\n    update(scope?: A_Scope) {\n        this.call(AreAttributeFeatures.Update, scope || this.scope);\n    }\n    /**\n     * Validates the attribute's content and context. This method is called during the validation phase of the ARE component and should check whether the attribute's content is valid based on its expected format, type, or other constraints. If the content is invalid, this method should throw an error with a descriptive message to help developers identify and fix the issue.\n     * \n     * @param scope \n     */\n    validate(scope?: A_Scope): void {\n        this.call(AreAttributeFeatures.Validate, scope || this.scope);\n    }\n}"]}