<?php
/**
 * HTML artifact rendering service.
 *
 * @package EntryFoundry
 */

namespace EntryFoundry\Core\Services\Render;

use EntryFoundry\Core\Views\Render\TemplateView;

/**
 * Writes the shared view as a standalone HTML artifact.
 */
final class HtmlRenderer {
	/**
	 * Shared template view.
	 *
	 * @var TemplateView
	 */
	private $view;

	/**
	 * Initialize the HTML renderer.
	 *
	 * @param TemplateView $view Shared template view.
	 */
	public function __construct( TemplateView $view ) {
		$this->view = $view;
	}

	/**
	 * Render HTML in memory.
	 *
	 * @param array<string, mixed> $template Validated template.
	 * @return string
	 */
	public function render( array $template ) {
		return $this->view->render( $template );
	}

	/**
	 * Return CSS that the browser entry point must enqueue.
	 *
	 * @param array<string, mixed> $template Validated template.
	 * @return string
	 */
	public function styles( array $template ) {
		return $this->view->render_css( $template, true );
	}
}
