'use client';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useToast = useToast;
exports.toast = toast;
const sonner_1 = require("sonner");
const DEFAULT_DURATION = 10000;
function toast({ title, description, variant, ...rest }) {
    const message = title ?? '';
    const options = {
        description,
        ...rest
    };
    let id;
    switch (variant) {
        case 'success':
            options.duration = DEFAULT_DURATION;
            id = sonner_1.toast.success(message, options);
            break;
        case 'destructive':
            options.duration = DEFAULT_DURATION;
            id = sonner_1.toast.error(message, options);
            break;
        default:
            options.duration = DEFAULT_DURATION;
            id = (0, sonner_1.toast)(message, options);
            break;
    }
    return {
        id,
        dismiss: () => sonner_1.toast.dismiss(id),
        update: (props) => {
            (0, sonner_1.toast)(props.title ?? message, {
                id,
                description: props.description ?? description,
                ...rest
            });
        }
    };
}
/**
 * Backward-compatible hook that wraps Sonner's toast API.
 *
 * Returns the same shape as the original Radix-based useToast:
 * - `toast()` to create a toast
 * - `dismiss()` to dismiss a toast by id (or all if no id)
 * - `toasts` array (always empty -- Sonner manages its own state internally)
 */
function useToast() {
    return {
        toast,
        dismiss: (toastId) => {
            if (toastId !== undefined) {
                sonner_1.toast.dismiss(toastId);
            }
            else {
                sonner_1.toast.dismiss();
            }
        },
        toasts: []
    };
}
