"use client";
import * as React from 'react';
import { Loader2, X } from 'lucide-react';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { Slot } from '@radix-ui/react-slot';
import { cva } from 'class-variance-authority';
import { jsxs, jsx } from 'react/jsx-runtime';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
__name(cn, "cn");
var buttonVariants = cva(
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
        destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
        outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
        secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
        ghost: "hover:bg-accent hover:text-accent-foreground",
        link: "text-primary underline-offset-4 hover:underline",
        // Keep the additional Hanzo variants for backward compatibility
        primary: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
        linkFG: "text-primary underline-offset-4 hover:underline",
        linkMuted: "text-muted-foreground underline-offset-4 hover:underline hover:text-foreground"
      },
      size: {
        default: "h-9 px-4 py-2",
        sm: "h-8 rounded-md px-3 text-xs",
        lg: "h-10 rounded-md px-8",
        icon: "h-9 w-9"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
);
var Button = React.forwardRef(
  ({ className, variant, size, asChild = false, isLoading = false, children, ...props }, ref) => {
    const Comp = asChild ? Slot : "button";
    return /* @__PURE__ */ jsxs(
      Comp,
      {
        className: cn(buttonVariants({ variant, size, className })),
        ref,
        ...props,
        children: [
          isLoading ? /* @__PURE__ */ jsx(
            Loader2,
            {
              className: cn("h-4 w-4 animate-spin", size !== "icon" && "mr-2")
            }
          ) : null,
          isLoading && size === "icon" ? null : children
        ]
      }
    );
  }
);
Button.displayName = "Button";
var MessageDock = React.forwardRef(
  ({ className, messages, onClose, position = "bottom-right", ...props }, ref) => {
    const positionClasses = {
      top: "top-4 left-1/2 -translate-x-1/2",
      bottom: "bottom-4 left-1/2 -translate-x-1/2",
      "top-right": "top-4 right-4",
      "bottom-right": "bottom-4 right-4"
    };
    return /* @__PURE__ */ jsx(
      "div",
      {
        ref,
        className: cn(
          "fixed z-50 flex flex-col gap-2",
          positionClasses[position],
          className
        ),
        ...props,
        children: messages.map((message) => /* @__PURE__ */ jsx(
          "div",
          {
            className: cn(
              "min-w-[300px] rounded-lg border p-4 shadow-lg",
              message.type === "success" && "border-green-500 bg-green-50 dark:bg-green-950",
              message.type === "warning" && "border-yellow-500 bg-yellow-50 dark:bg-yellow-950",
              message.type === "error" && "border-red-500 bg-red-50 dark:bg-red-950",
              message.type === "info" && "border-blue-500 bg-blue-50 dark:bg-blue-950",
              !message.type && "bg-background"
            ),
            children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
              /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
                /* @__PURE__ */ jsx("h4", { className: "font-medium", children: message.title }),
                message.description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: message.description })
              ] }),
              onClose && /* @__PURE__ */ jsx(
                Button,
                {
                  variant: "ghost",
                  size: "icon",
                  className: "h-6 w-6",
                  onClick: () => onClose(message.id),
                  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
                }
              )
            ] })
          },
          message.id
        ))
      }
    );
  }
);
MessageDock.displayName = "MessageDock";

export { MessageDock };
