import { defineComponent, ref, watchEffect, openBlock, createElementBlock, unref, createElementVNode, toDisplayString, createCommentVNode, Fragment, renderList, createVNode } from "vue";
import "../../../../adapter-vue.mjs";
import { TUITranslateService } from "@tencentcloud/chat-uikit-engine";
import { JSONToObject, isUrl } from "../../../../utils/type-check.mjs";
import { CHAT_MSG_CUSTOM_TYPE } from "../../../../constant.mjs";
import Icon from "../../../common/Icon.vue.mjs";
import starLightIcon from "../../../../assets/icon/star-light.png.mjs";
const _hoisted_1 = { class: "custom" };
const _hoisted_2 = { key: 0 };
const _hoisted_3 = ["href"];
const _hoisted_4 = { key: 0 };
const _hoisted_5 = ["href"];
const _hoisted_6 = { key: 1 };
const _hoisted_7 = {
  key: 1,
  class: "evaluate"
};
const _hoisted_8 = { class: "evaluate-list" };
const _hoisted_9 = ["src"];
const _hoisted_10 = {
  key: 3,
  class: "textLink"
};
const _hoisted_11 = ["href"];
const _hoisted_12 = ["innerHTML"];
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "message-custom",
  props: {
    messageItem: { default: void 0 },
    content: { default: void 0 }
  },
  setup(__props) {
    const props = __props;
    const custom = ref();
    const message = ref();
    const extension = ref();
    const isCustom = ref({
      businessID: ""
    });
    watchEffect(() => {
      custom.value = props.content;
      message.value = props.messageItem;
      const { payload } = props.messageItem;
      isCustom.value = payload.data || "";
      isCustom.value = JSONToObject(payload.data);
      if (payload.data === CHAT_MSG_CUSTOM_TYPE.SERVICE) {
        extension.value = JSONToObject(payload.extension);
      }
    });
    const openLink = (url) => {
      window.open(url);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        unref(isCustom).businessID === unref(CHAT_MSG_CUSTOM_TYPE).SERVICE ? (openBlock(), createElementBlock("div", _hoisted_2, [
          createElementVNode("h1", null, [
            createElementVNode("label", null, toDisplayString(unref(extension).title), 1),
            unref(extension).hyperlinks_text ? (openBlock(), createElementBlock("a", {
              key: 0,
              href: unref(extension).hyperlinks_text.value,
              target: "view_window"
            }, toDisplayString(unref(extension).hyperlinks_text.key), 9, _hoisted_3)) : createCommentVNode("", true)
          ]),
          unref(extension).item && unref(extension).item.length > 0 ? (openBlock(), createElementBlock("ul", _hoisted_4, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(unref(extension).item, (item, index) => {
              return openBlock(), createElementBlock("li", { key: index }, [
                unref(isUrl)(item.value) ? (openBlock(), createElementBlock("a", {
                  key: 0,
                  href: item.value,
                  target: "view_window"
                }, toDisplayString(item.key), 9, _hoisted_5)) : (openBlock(), createElementBlock("p", _hoisted_6, toDisplayString(item.key), 1))
              ]);
            }), 128))
          ])) : createCommentVNode("", true),
          createElementVNode("article", null, toDisplayString(unref(extension).description), 1)
        ])) : unref(isCustom).businessID === unref(CHAT_MSG_CUSTOM_TYPE).EVALUATE ? (openBlock(), createElementBlock("div", _hoisted_7, [
          createElementVNode("h1", null, toDisplayString(unref(TUITranslateService).t("message.custom.对本次服务评价")), 1),
          createElementVNode("ul", _hoisted_8, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(Math.max(unref(isCustom).score, 0), (item, index) => {
              return openBlock(), createElementBlock("li", {
                key: index,
                class: "evaluate-list-item"
              }, [
                createVNode(Icon, {
                  file: unref(starLightIcon),
                  class: "file-icon"
                }, null, 8, ["file"])
              ]);
            }), 128))
          ]),
          createElementVNode("article", null, toDisplayString(unref(isCustom).comment), 1)
        ])) : unref(isCustom).businessID === unref(CHAT_MSG_CUSTOM_TYPE).ORDER ? (openBlock(), createElementBlock("div", {
          key: 2,
          class: "order",
          onClick: _cache[0] || (_cache[0] = ($event) => openLink(unref(isCustom).link))
        }, [
          createElementVNode("img", {
            src: unref(isCustom).imageUrl
          }, null, 8, _hoisted_9),
          createElementVNode("main", null, [
            createElementVNode("h1", null, toDisplayString(unref(isCustom).title), 1),
            createElementVNode("p", null, toDisplayString(unref(isCustom).description), 1),
            createElementVNode("span", null, toDisplayString(unref(isCustom).price), 1)
          ])
        ])) : unref(isCustom).businessID === unref(CHAT_MSG_CUSTOM_TYPE).LINK ? (openBlock(), createElementBlock("div", _hoisted_10, [
          createElementVNode("p", null, toDisplayString(unref(isCustom).text), 1),
          createElementVNode("a", {
            href: unref(isCustom).link,
            target: "view_window"
          }, toDisplayString(unref(TUITranslateService).t("message.custom.查看详情>>")), 9, _hoisted_11)
        ])) : (openBlock(), createElementBlock("span", {
          key: 4,
          innerHTML: _ctx.content.custom
        }, null, 8, _hoisted_12))
      ]);
    };
  }
});
export {
  _sfc_main as default
};
