'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
var index$1 = require('../../tooltip/index.cjs');
var index$2 = require('../../badge/index.cjs');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index = require('../style/index.cjs');
var props = require('./props.cjs');
var FloatButtonContent = require('./FloatButtonContent.cjs');
var context = require('./context.cjs');
var constants = require('./constants.cjs');
var initDefaultProps = require('../../../utils/vue/initDefaultProps.cjs');
var _class = require('../../../utils/dom/class.cjs');
var log = require('../../../utils/log.cjs');

var floatButton = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AFloatButton",
  inheritAttrs: false,
  props: initDefaultProps.initDefaultProps(props.floatButtonProps(), {
    type: "default",
    shape: "circle"
  }),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject.default(constants.floatButtonPrefixCls, props);
    const [wrapSSR, hashId] = index.default(prefixCls);
    const {
      shape: groupShape
    } = context.useInjectFloatButtonGroupContext();
    const floatButtonRef = vue.ref(null);
    const mergeShape = vue.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 = _class.classNames(prefixCls.value, `${prefixCls.value}-${type}`, `${prefixCls.value}-${mergeShape.value}`, {
        [`${prefixCls.value}-rtl`]: direction.value === "rtl"
      }, attrs.class, hashId.value);
      const buttonNode = vue.createVNode(index$1.Tooltip, {
        "placement": "left"
      }, {
        title: slots.tooltip || tooltip ? () => slots.tooltip && slots.tooltip() || tooltip : void 0,
        default: () => vue.createVNode(index$2.Badge, badge, {
          default: () => [vue.createVNode("div", {
            "class": `${prefixCls.value}-body`
          }, [vue.createVNode(FloatButtonContent.default, {
            "prefixCls": prefixCls.value
          }, {
            icon: slots.icon,
            description: () => description
          })])]
        })
      });
      if (process.env.NODE_ENV !== "production") {
        log.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 ? vue.createVNode("a", {
        "ref": floatButtonRef,
        ...attrs,
        ...restProps,
        "class": classString
      }, [buttonNode]) : vue.createVNode("button", {
        "ref": floatButtonRef,
        ...attrs,
        ...restProps,
        "class": classString,
        "type": "button"
      }, [buttonNode]));
    };
  }
});

exports.default = floatButton;
//# sourceMappingURL=FloatButton.cjs.map
