<?php
// pages/components/calendar_view.php
require_once BEEZUI_ROOT . '/components/index.php';

use Components\Data\DataRegistry;
use Components\Ui\Calendar;

$state = Calendar::resolveStateFromRequest();
$events = DataRegistry::calendarEvents()->events($state);
$options = Calendar::resolveActionOptions($state);

if (isset($_GET['format']) && $_GET['format'] === 'json') {
    header('Content-Type: application/json');
    echo json_encode(Calendar::buildPayload($state, $events, $options), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    exit;
}

echo Calendar::renderBody($state, $events, $options);
