'use strict';

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

var vue = require('vue');
var antDesignVue = require('ant-design-vue');
require('../../index.js');
require('../../../utils/index.js');
var lodashEs = require('lodash-es');
var button = require('./button.js');
var createNamespace = require('../../../utils/create-namespace.js');
var index = require('../../icon/index.js');

"use strict";
const _hoisted_1 = { key: 0 };
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlButton" },
  __name: "button",
  props: button.buttonProps,
  emits: ["mouseenter", "mouseleave"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const bem = createNamespace.createNamespace("button");
    const attrs = vue.useAttrs();
    const btnRef = vue.ref();
    const isHovered = vue.ref(false);
    const getBindValue = vue.computed(() => {
      return lodashEs.omit({ ...attrs }, ["class"]);
    });
    const handleHover = (v) => {
      emits(v ? "mouseenter" : "mouseleave");
      if (props.useCustomStyle) {
        isHovered.value = v;
      }
    };
    const customStyle = vue.computed(() => {
      if (!props.useCustomStyle) return {};
      const baseStyle = {
        border: `1px solid var(--btn-gray-bg)`,
        "box-shadow": `0 2px 0 rgba(0, 0, 0, 0.02)`
      };
      if (props.disabled) {
        return {
          color: "#c9cdd4",
          "border-color": "var(--color-border)",
          "background-color": "rgba(0, 0, 0, 0.04)",
          "box-shadow": "none"
        };
      } else if (isHovered.value) {
        return {
          ...baseStyle,
          "background-color": props.hoverBgColor || `var(--btn-gray-bg-hover)`,
          color: props.hoverColor || `var(--color-text)`
        };
      } else {
        return {
          ...baseStyle,
          "background-color": props.bgColor || `var(--btn-gray-bg)`,
          color: props.color || `var(--color-text)`
        };
      }
    });
    const blur = () => {
      btnRef.value.blur();
    };
    __expose({ blur });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Button), vue.mergeProps({
        ref_key: "btnRef",
        ref: btnRef,
        class: [
          vue.unref(bem).b(),
          _ctx.useCustomStyle ? vue.unref(bem).is("btn-custom") : "",
          _ctx.isBlock ? vue.unref(bem).is("block") : ""
        ]
      }, getBindValue.value, {
        type: _ctx.useCustomStyle ? "primary" : _ctx.type,
        disabled: _ctx.disabled,
        style: { gap: `${props.iconSpace}px`, ...customStyle.value },
        onMouseenter: _cache[0] || (_cache[0] = ($event) => handleHover(true)),
        onMouseleave: _cache[1] || (_cache[1] = ($event) => handleHover(false))
      }), vue.createSlots({
        default: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "default", {}, () => [
            _ctx.label ? (vue.openBlock(), vue.createElementBlock(
              "span",
              _hoisted_1,
              vue.toDisplayString(_ctx.label),
              1
              /* TEXT */
            )) : vue.createCommentVNode("v-if", true)
          ])
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        props.icon.iconName || _ctx.$slots.icon ? {
          name: "icon",
          fn: vue.withCtx(() => [
            _ctx.$slots.icon ? vue.renderSlot(_ctx.$slots, "icon", { key: 0 }) : (vue.openBlock(), vue.createBlock(vue.unref(index.LlIcon), {
              key: 1,
              style: vue.normalizeStyle({ order: _ctx.iconDirection === "left" ? 0 : 1 }),
              "icon-name": _ctx.icon.iconName,
              color: _ctx.icon.color,
              size: _ctx.icon.size
            }, null, 8, ["style", "icon-name", "color", "size"]))
          ]),
          key: "0"
        } : void 0
      ]), 1040, ["class", "type", "disabled", "style"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=button.vue2.js.map
