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

use Components\Ui\EmailPreviewer;

$pageKey = 'email_preview';

// Read params
$url = (string) mh_get('url', '', 'string');
$device = (string) mh_get('device', 'desktop', 'string');

// Basic sanitation for initial URL
$safeUrl = '';
if ($url !== '') {
    $u = filter_var($url, FILTER_VALIDATE_URL);
    if ($u && ((strpos($u, 'http://') === 0) || (strpos($u, 'https://') === 0))) {
        $safeUrl = $u;
    }
}



ob_start();
?>
<div>
    <?php
    echo EmailPreviewer::render([
        'url' => $safeUrl,
        'device' => $device,
        'id_prefix' => 'page-ep',
    ]);
    ?>
</div>
<?php
$content = ob_get_clean();
echo layout($pageKey, $content);
