"use strict";
var import_Button = require("../Button.css");
const jsxRuntime = require("react/jsx-runtime");
const antd = require("antd");
const React = require("react");
const kit_Icon = require("./Icon.cjs");
const kit_internal_ConditionalWrapper = require("./internal/ConditionalWrapper.cjs");
const kit_Theme_UI = require("./Theme/UI.cjs");
require("./Theme/themeUtils.cjs");
require("./Theme/themes.cjs");
const kit_Tooltip = require("./Tooltip.cjs");
const base = "Button_base_dd0d6";
const selected = "Button_selected_dd0d6";
const content = "Button_content_dd0d6";
const icon = "Button_icon_dd0d6";
const children = "Button_children_dd0d6";
const column = "Button_column_dd0d6";
const circle = "Button_circle_dd0d6";
const status = "Button_status_dd0d6";
const css = {
  base,
  selected,
  content,
  icon,
  children,
  column,
  circle,
  "ant-btn-sm": "Button_ant-btn-sm_dd0d6",
  status
};
const Button = React.forwardRef(
  ({
    size = "middle",
    tooltip = "",
    className,
    // do not include className in {...props} below.
    hideChildren = false,
    children: children2,
    icon: icon2,
    loading,
    column: column2,
    ...props
  }, ref) => {
    const {
      themeSettings: { className: themeClass }
    } = kit_Theme_UI.useTheme();
    const classes = [css.base, themeClass];
    if (className)
      classes.push(className);
    if (props.selected)
      classes.push(css.selected);
    if (column2)
      classes.push(css.column);
    if (props.shape === "circle")
      classes.push(css.circle);
    if (props.status)
      classes.push(css.status);
    if (loading) {
      icon2 = /* @__PURE__ */ jsxRuntime.jsx(kit_Icon.default, { decorative: true, name: "spinner" });
      children2 = "Loading";
    }
    return /* @__PURE__ */ jsxRuntime.jsx(
      kit_internal_ConditionalWrapper.ConditionalWrapper,
      {
        condition: tooltip.length > 0,
        wrapper: (children22) => /* @__PURE__ */ jsxRuntime.jsx(kit_Tooltip, { content: tooltip, children: children22 }),
        children: /* @__PURE__ */ jsxRuntime.jsx(
          antd.Button,
          {
            className: classes.join(" "),
            ref,
            size,
            style: {
              backgroundColor: props.status ? `var(--theme-status-${props.status}` : void 0,
              borderColor: props.status ? "transparent" : void 0,
              color: props.status ? `var(--theme-status-${props.status}-on-strong` : void 0
            },
            tabIndex: props.disabled ? -1 : 0,
            ...props,
            children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: css.content, children: [
              icon2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: css.icon, children: icon2 }),
              !hideChildren && children2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: css.children, children: children2 })
            ] })
          }
        )
      }
    );
  }
);
module.exports = Button;
