'use strict';

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

var vue = require('vue');
var index = require('../../../dot/index.js');

"use strict";
const _hoisted_1 = {
  key: 1,
  class: "me-badge-dot"
};
var script = /* @__PURE__ */ vue.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 = vue.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 = vue.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" ? (vue.openBlock(), vue.createElementBlock(
        vue.Fragment,
        { key: 0 },
        [
          __props.type === "normal" ? (vue.openBlock(), vue.createElementBlock(
            "span",
            {
              key: 0,
              class: "menuBadge",
              style: vue.normalizeStyle(badgeStyle.value)
            },
            [
              vue.createElementVNode(
                "span",
                null,
                vue.toDisplayString(getText.value),
                1
                /* TEXT */
              )
            ],
            4
            /* STYLE */
          )) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
            vue.createVNode(vue.unref(index.MeDot), {
              color: badgeStyle.value.backgroundColor
            }, null, 8, ["color"])
          ]))
        ],
        64
        /* STABLE_FRAGMENT */
      )) : vue.createCommentVNode("v-if", true);
    };
  }
});

exports.default = script;
//# sourceMappingURL=badge.vue2.js.map
