<?php
defined( 'ABSPATH' ) || exit;

/**
 * Base class for all Jalpi Page Builder element renderers.
 *
 * Each element type (heading, text, image, etc.) extends this class and
 * implements render().  The Jalpi_Renderer dispatches to elements via a
 * type-keyed registry populated at boot time.
 */
abstract class Jalpi_Element {

    /**
     * Return the element type key (e.g. 'heading', 'text', 'image-carousel').
     * Must match the value used in the node's 'type' field.
     */
    abstract public static function type(): string;

    /**
     * Render the node to HTML.
     *
     * @param  array       $node     The JSON node data.
     * @param  Jalpi_Renderer $renderer The renderer instance — use its public API
     *                               to add CSS rules, resolve dynamic tags, etc.
     * @return string  HTML output.
     */
    abstract public function render( array $node, Jalpi_Renderer $renderer ): string;
}
