"use client"
/**
* AskLeoButton — chart-card Leo CTA (outline sm, duotone star + label).
*
* Default `onClick` toggles the Ask Leo sidebar (`useAskLeo`). Pass `onClick`
* to override (e.g. inline draft on the new-question composer).
*
* @see charts-overview.tsx — ChartCard header (canonical usage)
* @see AGENTS.md / charts-overview file header — Ask Leo icon guideline
*/
import * as React from "react"
import { AskLeoShortcutKbds, useAskLeo } from "@/components/ask-leo-sidebar"
import { Button } from "@/components/ui/button"
import { LeoIcon } from "@/components/ui/leo-icon"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
import { cn } from "@/lib/utils"
export interface AskLeoButtonProps {
/** Matches chart card header (`sm`) or page header actions (`lg`, e.g. Save question). */
size?: "sm" | "lg"
/** When true, hides the text label (chart selector variant). */
iconOnly?: boolean
/** Button label. Default `"Ask Leo"`. */
label?: string
/** Overrides sidebar toggle — use for route-local Leo actions. */
onClick?: () => void
disabled?: boolean
"aria-busy"?: boolean
/** Accessible name; defaults to `label`. */
ariaLabel?: string
/** Shown instead of `label` when `aria-busy` is true. */
busyLabel?: string
/** Tooltip body before shortcut chips. Defaults to `label`. */
tooltipLabel?: string
/** When false, tooltip omits ⌘⌥K hints (non-sidebar actions). Default true. */
showShortcut?: boolean
/**
* Animated Leo star (`LeoIcon` ambient). Defaults to true when `size="lg"`.
* Chart cards keep the static duotone glyph (`size="sm"`).
*/
animatedStar?: boolean
className?: string
}
export function AskLeoButton({
size = "sm",
iconOnly = false,
label = "Ask Leo",
onClick: onClickProp,
disabled = false,
"aria-busy": ariaBusy,
ariaLabel,
busyLabel,
tooltipLabel,
showShortcut = true,
animatedStar,
className,
}: AskLeoButtonProps) {
const { toggle } = useAskLeo()
const displayLabel = ariaBusy && busyLabel ? busyLabel : label
const tipText = tooltipLabel ?? label
const useAnimatedStar = animatedStar ?? size === "lg"
const leoFillClass =
"[--leo-icon-fill:var(--brand-color-dark)] dark:[--leo-icon-fill:var(--brand-color-light)]"
const starMark = useAnimatedStar ? (
) : (
)
return (
{tipText}
{showShortcut ? : null}
)
}