"use client"; import * as React from "react"; import { TargetIcon } from "@phosphor-icons/react"; import { Button, PanelSurface, Tooltip, TooltipContent, TooltipTrigger, } from "@repo/ui"; import { Moon, Redo2, Sun, Undo2, ZoomIn, ZoomOut } from "lucide-react"; import type { ToolcraftPanelState, ToolcraftState } from "../../state/types"; import { PanelContainer } from "../panel-host/panel-host"; import { useToolcraftPanelBinding } from "../panel-host/use-toolcraft-panel-binding"; import type { PanelPlacement, PanelStateChange } from "../panel-host/panel-host-types"; import { useToolcraftTheme } from "./theme-runtime"; import { useToolcraftCommittedSelector } from "./toolcraft-selectors"; import { useToolcraftDispatch } from "./use-toolcraft"; export type ToolbarPanelProps = { className?: string; framed?: boolean; onPanelStateChange?: PanelStateChange; panelPlacement?: PanelPlacement; panelState?: ToolcraftPanelState; }; type ToolbarIconButtonProps = { active?: boolean; children: React.ReactNode; className?: string; disabled?: boolean; label: string; onClick?: () => void; }; const toolbarIconButtonSize = "icon"; const desktopToolbarTightButtonGapClassName = "-mr-px"; const selectCanUndo = (state: ToolcraftState) => state.history.undo.length > 0; const selectCanRedo = (state: ToolcraftState) => state.history.redo.length > 0; const selectToolbar = (state: ToolcraftState) => state.schema.toolbar; const selectCommittedZoom = (state: ToolcraftState) => state.canvas.zoom; function cn(...classNames: Array): string { return classNames.filter(Boolean).join(" "); } function ToolbarDivider(): React.JSX.Element { return (