"use strict";
const common_vendor = require("../../../../../common/vendor.js");
require("../../../../adapter-vue.js");
const common_assets = require("../../../../../common/assets.js");
const TUIKit_utils_documentLink = require("../../../../utils/documentLink.js");
const TUIKit_constant = require("../../../../constant.js");
const TUIKit_utils_env = require("../../../../utils/env.js");
const TUIKit_components_TUIChat_utils_utils = require("../../utils/utils.js");
const TUIKit_components_TUIChat_offlinePushInfoManager_index = require("../../offlinePushInfoManager/index.js");
const TUIKit_components_TUIChat_config = require("../../config.js");
if (!Math) {
  (Icon + ToolbarItemContainer)();
}
const ToolbarItemContainer = () => "../toolbar-item-container/index.js";
const Icon = () => "../../../common/Icon.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  props: {
    starTotal: {
      type: Number,
      default: 5
    }
  },
  emits: ["onDialogPopupShowOrHide"],
  setup(__props, { emit: __emit }) {
    const evaluateIcon = TUIKit_components_TUIChat_config.ChatConfig.getTheme() === "dark" ? common_assets.evaluateIconDark : common_assets.evaluateIconLight;
    const props = __props;
    const emits = __emit;
    const container = common_vendor.ref();
    const starList = common_vendor.ref(props.starTotal);
    const currentStarIndex = common_vendor.ref(-1);
    const comment = common_vendor.ref("");
    const currentConversation = common_vendor.ref();
    common_vendor.Jt.watch(common_vendor.o.CONV, {
      currentConversation: (conversation) => {
        currentConversation.value = conversation;
      }
    });
    const isEvaluateValid = common_vendor.computed(() => comment.value.length || currentStarIndex.value >= 0);
    const onDialogShow = () => {
      emits("onDialogPopupShowOrHide", true);
    };
    const onDialogClose = () => {
      resetEvaluate();
      emits("onDialogPopupShowOrHide", false);
    };
    const openLink = () => {
      var _a, _b;
      if (TUIKit_utils_env.isPC || TUIKit_utils_env.isH5) {
        window.open((_b = (_a = TUIKit_utils_documentLink.Link) == null ? void 0 : _a.customMessage) == null ? void 0 : _b.url);
      }
    };
    const closeDialog = () => {
      var _a;
      (_a = container == null ? void 0 : container.value) == null ? void 0 : _a.toggleDialogDisplay(false);
    };
    const resetEvaluate = () => {
      currentStarIndex.value = -1;
      comment.value = "";
    };
    const selectStar = (starIndex) => {
      if (currentStarIndex.value === starIndex) {
        currentStarIndex.value = currentStarIndex.value - 1;
      } else {
        currentStarIndex.value = starIndex;
      }
    };
    const submitEvaluate = () => {
      var _a, _b, _c, _d, _e, _f;
      if (currentStarIndex.value < 0 && !comment.value.length) {
        return;
      }
      const payload = {
        data: JSON.stringify({
          businessID: TUIKit_constant.CHAT_MSG_CUSTOM_TYPE.EVALUATE,
          version: 1,
          score: currentStarIndex.value + 1,
          comment: comment.value
        }),
        description: "对本次的服务评价",
        extension: "对本次的服务评价"
      };
      const options = {
        to: ((_b = (_a = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _a.groupProfile) == null ? void 0 : _b.groupID) || ((_d = (_c = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _c.userProfile) == null ? void 0 : _d.userID),
        conversationType: (_e = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _e.type,
        payload,
        needReadReceipt: TUIKit_components_TUIChat_utils_utils.isEnabledMessageReadReceiptGlobal()
      };
      const offlinePushInfoCreateParams = {
        conversation: currentConversation.value,
        payload: options.payload,
        messageType: common_vendor.qt.TYPES.MSG_CUSTOM
      };
      const sendMessageOptions = {
        offlinePushInfo: TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams)
      };
      common_vendor.Qt.sendCustomMessage(options, sendMessageOptions);
      (_f = container == null ? void 0 : container.value) == null ? void 0 : _f.toggleDialogDisplay(false);
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("Evaluate.请对本次服务进行评价")),
        b: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-header-content"),
        c: !common_vendor.unref(TUIKit_utils_env.isPC)
      }, !common_vendor.unref(TUIKit_utils_env.isPC) ? {
        d: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("关闭")),
        e: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-header-close"),
        f: common_vendor.o$1(closeDialog)
      } : {}, {
        g: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-header"),
        h: common_vendor.f(common_vendor.unref(starList), (item, index, i0) => {
          return common_vendor.e({
            a: index <= common_vendor.unref(currentStarIndex)
          }, index <= common_vendor.unref(currentStarIndex) ? {
            b: "74e4698c-1-" + i0 + ",74e4698c-0",
            c: common_vendor.p({
              file: common_vendor.unref(common_assets.star),
              width: common_vendor.unref(TUIKit_utils_env.isPC) ? "20px" : "30px",
              height: common_vendor.unref(TUIKit_utils_env.isPC) ? "20px" : "30px"
            })
          } : {
            d: "74e4698c-2-" + i0 + ",74e4698c-0",
            e: common_vendor.p({
              file: common_vendor.unref(common_assets.starIcon),
              width: common_vendor.unref(TUIKit_utils_env.isPC) ? "20px" : "30px",
              height: common_vendor.unref(TUIKit_utils_env.isPC) ? "20px" : "30px"
            })
          }, {
            f: index,
            g: common_vendor.o$1(($event) => selectStar(index), index)
          });
        }),
        i: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-content-list-item"),
        j: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-content-list"),
        k: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-content-text"),
        l: common_vendor.unref(comment),
        m: common_vendor.o$1(($event) => common_vendor.isRef(comment) ? comment.value = $event.detail.value : null),
        n: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("Evaluate.提交评价")),
        o: common_vendor.n(common_vendor.unref(isEvaluateValid) ? "btn-valid" : "btn-invalid"),
        p: common_vendor.o$1(submitEvaluate),
        q: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-content-button"),
        r: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-content"),
        s: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("Evaluate.服务评价工具")),
        t: common_vendor.t("(" + common_vendor.unref(common_vendor.Wt).t("Evaluate.使用")),
        v: common_vendor.t(common_vendor.unref(common_vendor.Wt).t(`Evaluate.${common_vendor.unref(TUIKit_utils_documentLink.Link).customMessage.label}`)),
        w: common_vendor.o$1(($event) => openLink(common_vendor.unref(TUIKit_utils_documentLink.Link).customMessage)),
        x: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("Evaluate.搭建") + ")"),
        y: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5-adv"),
        z: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "evaluate-h5"),
        A: common_vendor.sr(container, "74e4698c-0", {
          "k": "container"
        }),
        B: common_vendor.o$1(onDialogShow),
        C: common_vendor.o$1(onDialogClose),
        D: common_vendor.p({
          iconFile: common_vendor.unref(evaluateIcon),
          title: "评价",
          needBottomPopup: true,
          iconWidth: common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? "26px" : "20px",
          iconHeight: common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? "26px" : "20px"
        })
      });
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-74e4698c"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/message-input-toolbar/evaluate/index.js.map
