import { defineComponent, ref, computed, resolveComponent, createElementBlock, openBlock, Fragment, createCommentVNode, createBlock, normalizeClass, unref, withCtx, createVNode, normalizeStyle } from 'vue';
import '../../../utils/index.mjs';
import { iconBaseProProps } from './icon-base-pro.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlIconBasePro" },
  __name: "icon-base-pro",
  props: iconBaseProProps,
  emits: ["click"],
  setup(__props, { emit: __emit }) {
    const bem = createNamespace("icon-base-pro");
    const props = __props;
    const emits = __emit;
    const btnRef = ref();
    const isHover = ref(false);
    const btnClass = computed(() => {
      const isDefault = props.iconType === "default" || !props.iconType;
      const typeClass = isDefault ? bem.is("default") : bem.is("primary");
      const disabledClass = props.disabled ? isDefault ? bem.is("default-disable") : bem.is("primary-disable") : "";
      const labelClass = props.label ? bem.is("label") : "";
      const getSizeClass = () => {
        switch (props.size) {
          case "large":
            return "large";
          case "middle":
            return "middle";
          case "small":
            return "small";
          default:
            "custom";
        }
      };
      const sizeClass = bem.is(getSizeClass());
      return `${props.class} ${bem.b()} ${typeClass} ${disabledClass} ${sizeClass} ${labelClass}`;
    });
    const btnStyle = computed(() => {
      return {
        "background-color": isHover.value ? props.hoverBgColor : props.bgColor,
        ...typeof props.size === "number" ? { width: props.size + "px", height: props.size + "px" } : {}
      };
    });
    const iconStyle = computed(() => ({
      transform: `scale(${isHover.value ? props.hoverScale : 1})`
    }));
    const onClick = () => {
      emits("click");
      btnRef.value?.blur();
    };
    const handleHover = (bool) => {
      isHover.value = bool;
    };
    return (_ctx, _cache) => {
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_ll_button = resolveComponent("ll-button");
      const _component_ll_tooltip = resolveComponent("ll-tooltip");
      return openBlock(), createElementBlock(
        Fragment,
        null,
        [
          createCommentVNode(" \u6709\u6587\u5B57\u63D0\u793A\u5F39\u7A97 "),
          _ctx.showTip ? (openBlock(), createBlock(_component_ll_tooltip, {
            key: 0,
            tip: _ctx.tipText,
            "is-white-bg": _ctx.isWhiteBg,
            arrow: _ctx.arrow,
            class: normalizeClass([unref(bem).e("tooltip"), _ctx.tooltipClass])
          }, {
            default: withCtx(() => [
              createVNode(_component_ll_button, {
                ref_key: "btnRef",
                ref: btnRef,
                type: "text",
                disabled: _ctx.disabled,
                class: normalizeClass(`${btnClass.value}`),
                style: normalizeStyle(btnStyle.value),
                label: _ctx.label,
                "icon-space": 8,
                onClick,
                onMouseenter: _cache[0] || (_cache[0] = ($event) => handleHover(true)),
                onMouseleave: _cache[1] || (_cache[1] = ($event) => handleHover(false))
              }, {
                icon: withCtx(() => [
                  createVNode(_component_ll_icon, {
                    style: normalizeStyle(iconStyle.value),
                    "icon-name": _ctx.iconName,
                    size: _ctx.iconSize
                  }, null, 8, ["style", "icon-name", "size"])
                ]),
                _: 1
                /* STABLE */
              }, 8, ["disabled", "class", "style", "label"])
            ]),
            _: 1
            /* STABLE */
          }, 8, ["tip", "is-white-bg", "arrow", "class"])) : (openBlock(), createElementBlock(
            Fragment,
            { key: 1 },
            [
              createCommentVNode(" \u6CA1\u6709\u6587\u5B57\u63D0\u793A\u5F39\u7A97 "),
              createVNode(_component_ll_button, {
                ref_key: "btnRef",
                ref: btnRef,
                type: "text",
                disabled: _ctx.disabled,
                class: normalizeClass(`${btnClass.value}`),
                style: normalizeStyle(btnStyle.value),
                label: _ctx.label,
                "icon-space": 8,
                onClick,
                onMouseenter: _cache[2] || (_cache[2] = ($event) => handleHover(true)),
                onMouseleave: _cache[3] || (_cache[3] = ($event) => handleHover(false))
              }, {
                icon: withCtx(() => [
                  createVNode(_component_ll_icon, {
                    style: normalizeStyle(iconStyle.value),
                    "icon-name": _ctx.iconName,
                    size: _ctx.iconSize
                  }, null, 8, ["style", "icon-name", "size"])
                ]),
                _: 1
                /* STABLE */
              }, 8, ["disabled", "class", "style", "label"])
            ],
            2112
            /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
          ))
        ],
        2112
        /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=icon-base-pro.vue2.mjs.map
