import { jsx } from "react/jsx-runtime";
import * as React from "react";
import { cva } from "class-variance-authority";
import { cn } from "../../lib/utils.js";
import { useInverseTheme, SUBTLE_ICON_COLOR, Notice } from "../Notice/notice.js";
const SUBTLE_CONTAINER = {
  neutral: "bg-muted border border-border",
  info: "bg-info-subtle border border-[var(--info-hover)]",
  success: "bg-success-subtle border border-[var(--success-hover)]",
  warning: "bg-warning-subtle border border-[var(--warning-hover)]",
  error: "bg-error-subtle border border-[var(--error-hover)]"
};
const SOLID_HUE_BG = {
  info: "bg-info",
  success: "bg-success",
  warning: "bg-warning",
  error: "bg-error"
};
const SOLID_HUE_THEME = {
  info: "dark",
  success: "dark",
  warning: "light",
  error: "dark"
};
const alertVariants = cva("w-full overflow-hidden", {
  variants: {
    placement: {
      inline: "rounded-md",
      fixed: "rounded-none border-none"
    }
  },
  defaultVariants: { placement: "inline" }
});
const Alert = React.forwardRef(
  ({
    variant = "neutral",
    appearance = "subtle",
    placement,
    title,
    description,
    endContent,
    dismissible = true,
    onDismiss,
    className,
    ...props
  }, ref) => {
    const inverseTheme = useInverseTheme();
    const isSolid = appearance === "solid";
    const iconClassName = !isSolid ? SUBTLE_ICON_COLOR[variant] : void 0;
    const isCritical = variant === "error" || variant === "warning";
    const liveRole = isCritical ? "alert" : "status";
    const liveLevel = isCritical ? "assertive" : "polite";
    const noticeEl = /* @__PURE__ */ jsx(
      Notice,
      {
        variant,
        title,
        description,
        endContent,
        dismissible,
        onDismiss,
        iconClassName,
        className: placement === "fixed" ? "px-[var(--layout-space-loose)]" : void 0
      }
    );
    if (!isSolid) {
      return /* @__PURE__ */ jsx(
        "div",
        {
          ref,
          role: liveRole,
          "aria-live": liveLevel,
          className: cn(alertVariants({ placement }), SUBTLE_CONTAINER[variant], className),
          ...props,
          children: noticeEl
        }
      );
    }
    if (variant === "neutral") {
      return /* @__PURE__ */ jsx(
        "div",
        {
          ref,
          role: liveRole,
          "aria-live": liveLevel,
          "data-theme": inverseTheme,
          className: cn(alertVariants({ placement }), "bg-surface-raised text-foreground", className),
          ...props,
          children: noticeEl
        }
      );
    }
    return /* @__PURE__ */ jsx(
      "div",
      {
        ref,
        role: liveRole,
        "aria-live": liveLevel,
        className: cn(alertVariants({ placement }), SOLID_HUE_BG[variant], className),
        ...props,
        children: /* @__PURE__ */ jsx("div", { "data-theme": SOLID_HUE_THEME[variant], className: "text-foreground", children: noticeEl })
      }
    );
  }
);
Alert.displayName = "Alert";
const alertMeta = {
  component: "Alert",
  family: 2,
  // List item(對齊 alert.spec.md frontmatter family: 2)
  variants: {
    neutral: { purpose: "中性提示(系統公告、非緊急說明);無情緒色" },
    info: { purpose: "資訊性提示(版本更新、流程說明);藍色 hue" },
    success: { purpose: "成功狀態的持久性宣告(綁定生效、付款完成需保留確認)" },
    warning: { purpose: "警告但非阻斷(方案到期、需更新付款方式);最高頻" },
    error: { purpose: "錯誤但非阻斷(系統錯誤可重試、API 失敗摘要);aria-live=assertive" }
  },
  sizes: {},
  states: ["default"],
  // 2026-06-11 R2:Alert 本體無互動 state(spec L183 明文無 disabled;dismiss 互動屬內部 Button),
  tokens: {
    bg: ["bg-error", "bg-error-subtle", "bg-info", "bg-info-subtle", "bg-muted", "bg-success", "bg-success-subtle", "bg-surface-raised", "bg-warning", "bg-warning-subtle"],
    fg: ["text-foreground"],
    ring: []
  },
  defaultVariant: "neutral"
};
export {
  Alert,
  alertMeta,
  alertVariants
};
//# sourceMappingURL=alert.js.map
