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B,QAAQ,CAAA;AAC1D,IAAA,IAAI,QAAA,EAAU;AACV,MAAA,QAAA,CAAS,MAAA,GAAS,GAAA;AAAA,IACtB,CAAA,MAAO;AACH,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,IAAI,QAAA,CAAS,KAAK,IAAA,CAAK,KAAA,CAAM,QAAA,EAAU,CAAC,CAAA;AAAA,IAChE;AAAA,EACJ;AAEJ;AA1Ja,WAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,WAAA,CAAA","file":"AreHTMLNode.mjs","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n    namespace: 'a-are-html',\n    description: 'AreHTMLNode represents a node in the HTML structure. It extends the base AreNode and includes properties and methods specific to HTML nodes, such as handling attributes, directives, events, and styles.'\n})\nexport class AreHTMLNode extends AreNode {\n    /**\n     * When set, this node is a *static island* root: its entire inner subtree\n     * was detected (at tokenize time) to contain no ARE-reactive constructs —\n     * no interpolations, no dynamic attributes and only standard HTML tags.\n     *\n     * Instead of being exploded into one child AreNode per element/text node,\n     * the inner markup is preserved verbatim here and materialised in a single\n     * pass by the interpreter (browser-parsed `innerHTML` / cached `<template>`\n     * clone). The node's OWN attributes (including any dynamic `:`/`@`/`$` on\n     * the island root) still compile and stay reactive as usual.\n     */\n    protected _staticInnerHTML?: string;\n\n    /**\n     * Actual node type. \n     * By default it's a tag name\n     */\n    get tag(): string {\n        return this.aseid.entity;\n    }\n\n    /**\n     * The verbatim inner markup captured when this node was identified as a\n     * static island, or `undefined` for ordinary (per-node) nodes.\n     */\n    get staticInnerHTML(): string | undefined {\n        return this._staticInnerHTML;\n    }\n\n    /**\n     * Whether this node is a static-island root (see `_staticInnerHTML`).\n     */\n    get isStaticIsland(): boolean {\n        return this._staticInnerHTML !== undefined;\n    }\n\n    /**\n     * Marks this node as a static-island root, capturing the verbatim inner\n     * markup to be materialised in one shot by the interpreter. Called by the\n     * tokenizer when the node's inner content is detected to be fully static.\n     */\n    markStatic(innerHTML: string): void {\n        this._staticInnerHTML = innerHTML;\n    }\n\n    /**\n     * Deep-clone the node. Overridden to carry over the static-island marker\n     * (`_staticInnerHTML`), which lives on AreHTMLNode and is therefore NOT\n     * copied by the base AreNode.clone(). Without this, cloning a directive\n     * template ($if/$for) that wraps a static island (e.g. `<span $if>★</span>`)\n     * would drop the captured inner markup and render an empty element. The\n     * base clone() recurses via each child's polymorphic clone(), so nested\n     * island children are preserved automatically through this override.\n     */\n    clone<T extends AreNode = AreNode>(this: T): T {\n        const cloned = super.clone() as unknown as AreHTMLNode;\n        const self = this as unknown as AreHTMLNode;\n\n        if (self._staticInnerHTML !== undefined)\n            cloned.markStatic(self._staticInnerHTML);\n\n        return cloned as unknown as T;\n    }\n\n    /**\n     * Clone the node while transferring its existing scope to the clone (used by\n     * the $if/$for directives to turn the original node into a lightweight group\n     * container). Overridden for the same reason as `clone()`: the static-island\n     * marker must survive so a directive applied to an island root keeps its\n     * inner markup.\n     */\n    cloneWithScope<T extends AreNode = AreNode>(this: T): T {\n        const cloned = super.cloneWithScope() as unknown as AreHTMLNode;\n        const self = this as unknown as AreHTMLNode;\n\n        if (self._staticInnerHTML !== undefined)\n            cloned.markStatic(self._staticInnerHTML);\n\n        return cloned as unknown as T;\n    }\n\n    /**\n      * The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.\n      * \n      * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n      */\n    get staticAttributes(): AreStaticAttribute[] {\n        return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n    }\n    /**\n     * The binding attributes defined for the node, which are typically used to represent dynamic properties or characteristics of the node that can change based on the context or state. These attributes are usually defined in the template with a specific syntax (e.g., `:prop=\"value\"` or `v-bind:prop=\"value\"`) and are reactive, meaning that they will update automatically when the underlying data changes.\n     * \n     * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n     */\n    get bindings(): AreBindingAttribute[] {\n        return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n    }\n    /**\n     * The directive attributes defined for the node, which are typically used to represent special instructions or behaviors that should be applied to the node. These attributes are usually defined in the template with a specific syntax (e.g., `v-if=\"condition\"` or `v-for=\"item in list\"`) and are processed by the rendering engine to apply the corresponding logic or behavior to the node.\n     * \n     * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n     */\n    get directives(): AreDirectiveAttribute[] {\n        /**\n         * 1. get all registered directives for the node\n         */\n        const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n        /**\n         * 2. Order them in the way that defined in the meta\n         * \n         *   Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n         */\n\n        return directives.filter(d => d.component).sort((a, b) => {\n            const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n            const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n            const aPriority = aMeta.priority ?? 0;\n            const bPriority = bMeta.priority ?? 0;\n\n            return bPriority - aPriority;\n        });\n    }\n    /**\n     * The event attributes defined for the node, which are typically used to represent event listeners or handlers that should be attached to the node. These attributes are usually defined in the template with a specific syntax (e.g., `@click=\"handleClick\"` or `v-on:click=\"handleClick\"`) and are processed by the rendering engine to attach the corresponding event listeners to the node.\n     * \n     * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n     */\n    get events(): AreEventAttribute[] {\n        return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n    }\n    /**\n     * The styles defined for the node, which can include inline styles or styles defined in a separate stylesheet that are applied to the node. These styles can be used to control the visual appearance of the node and can be defined using standard CSS syntax.\n     */\n    get styles(): AreStyle {\n        return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n    }\n\n    /**\n     * Registers or updates the component-scoped CSS string for this node.\n     * Called by the @Are.Styles-decorated method on the associated component.\n     * A new AreStyle fragment is registered in scope on first call; subsequent\n     * calls update the existing fragment in-place.\n     */\n    setStyles(css: string): void {\n        const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n        if (existing) {\n            existing.styles = css;\n        } else {\n            this.scope.register(new AreStyle(css, this.aseid.toString()));\n        }\n    }\n\n}"]}