import { defineComponent, computed, openBlock, createElementBlock, Fragment, normalizeStyle, createElementVNode, toDisplayString, createVNode, unref, createCommentVNode } from 'vue';
import { MeDot } from '../../../dot/index.mjs';

"use strict";
const _hoisted_1 = {
  key: 1,
  class: "me-badge-dot"
};
var script = /* @__PURE__ */ defineComponent({
  __name: "badge",
  props: {
    type: { type: String, required: false, default: "normal" },
    color: { type: String, required: false, default: "danger" },
    text: { type: String, required: false },
    meta: { type: Object, required: true }
  },
  setup(__props) {
    const props = __props;
    const getText = computed(() => {
      const isNan = Number.isNaN(Number(props.text));
      if (isNan) {
        return props.text?.slice(0, 3);
      } else {
        return Number(props.text) > 99 ? "99+" : props.text;
      }
    });
    const badgeStyle = computed(() => {
      let bgColor = "";
      if (["primary", "success", "warning", "info", "danger"].includes(props.color)) {
        bgColor = `var(--me-${props.color}-color)`;
      } else {
        bgColor = props.color;
      }
      return {
        backgroundColor: bgColor
      };
    });
    return (_ctx, _cache) => {
      return __props.meta.badge || __props.meta.badgeType == "dot" ? (openBlock(), createElementBlock(
        Fragment,
        { key: 0 },
        [
          __props.type === "normal" ? (openBlock(), createElementBlock(
            "span",
            {
              key: 0,
              class: "menuBadge",
              style: normalizeStyle(badgeStyle.value)
            },
            [
              createElementVNode(
                "span",
                null,
                toDisplayString(getText.value),
                1
                /* TEXT */
              )
            ],
            4
            /* STYLE */
          )) : (openBlock(), createElementBlock("div", _hoisted_1, [
            createVNode(unref(MeDot), {
              color: badgeStyle.value.backgroundColor
            }, null, 8, ["color"])
          ]))
        ],
        64
        /* STABLE_FRAGMENT */
      )) : createCommentVNode("v-if", true);
    };
  }
});

export { script as default };
//# sourceMappingURL=badge.vue2.mjs.map
