import { defineComponent, ref, computed, createVNode } from 'vue';
import '../../../utils/index.mjs';
import { Tooltip } from '../../tooltip/index.mjs';
import { Badge } from '../../badge/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import { floatButtonProps } from './props.mjs';
import Content from './FloatButtonContent.mjs';
import { useInjectFloatButtonGroupContext } from './context.mjs';
import { floatButtonPrefixCls } from './constants.mjs';
import { initDefaultProps } from '../../../utils/vue/initDefaultProps.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import { devWarning } from '../../../utils/log.mjs';

var 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 {
        type = "default",
        shape = "circle",
        description = (_a = slots.description) == null ? void 0 : _a.call(slots),
        tooltip,
        badge = {},
        ...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(Badge, badge, {
          default: () => [createVNode("div", {
            "class": `${prefixCls.value}-body`
          }, [createVNode(Content, {
            "prefixCls": prefixCls.value
          }, {
            icon: slots.icon,
            description: () => description
          })])]
        })
      });
      if (process.env.NODE_ENV !== "production") {
        devWarning(!(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", {
        "ref": floatButtonRef,
        ...attrs,
        ...restProps,
        "class": classString
      }, [buttonNode]) : createVNode("button", {
        "ref": floatButtonRef,
        ...attrs,
        ...restProps,
        "class": classString,
        "type": "button"
      }, [buttonNode]));
    };
  }
});

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