<?php

declare(strict_types=1);

namespace Australcode\Rewards\Frontend;

defined( 'ABSPATH' ) || exit;

/**
 * Gutenberg duals of the customer-facing shortcodes (theme-builder canon:
 * every frontend surface ships as shortcode + block so FSE themes and
 * builders that consume blocks can embed it natively). Rendering is shared
 * with the Shortcodes class — single source of markup.
 */
final class Blocks {

	public function __construct( private readonly Shortcodes $shortcodes ) {
	}

	public function register(): void {
		add_action( 'init', array( $this, 'register_blocks' ) );
	}

	public function register_blocks(): void {
		register_block_type(
			ACRWD_PATH . 'assets/blocks/balance',
			array( 'render_callback' => array( $this->shortcodes, 'render_balance' ) )
		);
		register_block_type(
			ACRWD_PATH . 'assets/blocks/history',
			array( 'render_callback' => array( $this->shortcodes, 'render_history' ) )
		);
		register_block_type(
			ACRWD_PATH . 'assets/blocks/earn-message',
			array( 'render_callback' => array( $this->shortcodes, 'render_earn_message' ) )
		);
		register_block_type(
			ACRWD_PATH . 'assets/blocks/redeem',
			array( 'render_callback' => array( $this->shortcodes, 'render_redeem' ) )
		);
	}
}
