import { defineComponent, ref, computed, createVNode, mergeProps } from 'vue';
import classNames from '../_util/classNames.mjs';
import Tooltip from '../tooltip/index.mjs';
import '../hooks/index.mjs';
import warning from '../_util/warning.mjs';
import '../_util/props-util/index.mjs';
import useStyle from './style/index.mjs';
import { floatButtonProps } from './interface.mjs';
import FloatButtonContent from './FloatButtonContent.mjs';
import { useInjectFloatButtonGroupContext } from './context.mjs';
import initDefaultProps from '../_util/props-util/initDefaultProps.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';

const floatButtonPrefixCls = "float-btn";
const FloatButton = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AFloatButton",
  inheritAttrs: false,
  props: initDefaultProps(floatButtonProps(), {
    type: "default",
    shape: "circle"
  }),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject(floatButtonPrefixCls, props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const {
      shape: groupShape
    } = useInjectFloatButtonGroupContext();
    const floatButtonRef = ref(null);
    const mergeShape = computed(() => {
      return (groupShape == null ? void 0 : groupShape.value) || props.shape;
    });
    return () => {
      var _a;
      const {
        prefixCls: customPrefixCls,
        type = "default",
        shape = "circle",
        description = (_a = slots.description) == null ? void 0 : _a.call(slots),
        tooltip,
        ...restProps
      } = props;
      const classString = classNames(prefixCls.value, `${prefixCls.value}-${type}`, `${prefixCls.value}-${mergeShape.value}`, {
        [`${prefixCls.value}-rtl`]: direction.value === "rtl"
      }, attrs.class, hashId.value);
      const buttonNode = createVNode(Tooltip, {
        "placement": "left"
      }, {
        title: slots.tooltip || tooltip ? () => slots.tooltip && slots.tooltip() || tooltip : void 0,
        default: () => createVNode("div", {
          "class": `${prefixCls.value}-body`
        }, [createVNode(FloatButtonContent, {
          "prefixCls": prefixCls.value
        }, {
          icon: slots.icon,
          description: () => description
        })])
      });
      if (process.env.NODE_ENV !== "production") {
        warning(!(shape === "circle" && description), "FloatButton", "supported only when `shape` is `square`. Due to narrow space for text, short sentence is recommended.");
      }
      return wrapSSR(props.href ? createVNode("a", mergeProps({
        "ref": floatButtonRef
      }, attrs, restProps, {
        "class": classString
      }), [buttonNode]) : createVNode("button", mergeProps({
        "ref": floatButtonRef
      }, attrs, restProps, {
        "class": classString,
        "type": "button"
      }), [buttonNode]));
    };
  }
});

export { FloatButton as default, floatButtonPrefixCls };
//# sourceMappingURL=FloatButton.mjs.map
