<?php
// pages/components/hide_notification.php
// HTMX endpoint to dismiss a notification by ID

require_once BEEZUI_ROOT . '/components/bootstrap.php';

$id = isset($_REQUEST['id']) ? (string)$_REQUEST['id'] : null;
$dismissed = true;
if (isset($_REQUEST['dismissed'])) {
    $d = $_REQUEST['dismissed'];
    $dismissed = !($d === '0' || $d === 'false');
}

if ($id) {
    try {
        \Components\Data\DataRegistry::config()->setNotificationDismissed($id, $dismissed);
    } catch (\Throwable $e) {
        // ignore
    }
}

// Return empty string as it's intended to be swapped with outerHTML to remove the notification
echo '';
return;
