/**
 * BoostBot Admin Notice Dismissal Handler
 *
 * Handles AJAX-based dismissal of BoostBot admin notices.
 * Enqueued via admin_enqueue_scripts in class-boostbot.php.
 *
 * @package BoostBot
 * @since 2.2.17
 */
(function () {
    if (typeof document === 'undefined') return;

    var notices = [
        { id: 'boostbot-reg-notice', action: 'boostbot_dismiss_reg_notice' },
        { id: 'boostbot-spam-alert-notice', action: 'boostbot_dismiss_spam_alert' },
        { id: 'boostbot-low-credits-notice', action: 'boostbot_dismiss_low_credits' },
        { id: 'boostbot-connection-error-notice', action: 'boostbot_dismiss_connection_error' }
    ];

    document.addEventListener('DOMContentLoaded', function () {
        notices.forEach(function (cfg) {
            var el = document.getElementById(cfg.id);
            if (!el) return;
            el.addEventListener('click', function (e) {
                if (e.target.classList.contains('notice-dismiss')) {
                    var nonce = el.dataset.nonce || '';
                    fetch(window.ajaxurl + '?action=' + cfg.action + '&_wpnonce=' + nonce);
                }
            });
        });
    });
})();
