"use strict";
const common_vendor = require("../../../../../common/vendor.js");
require("../../../../adapter-vue.js");
const TUIKit_utils_env = require("../../../../utils/env.js");
const TUIKit_components_TUIChat_config = require("../../config.js");
if (!Math) {
  (Icon + BottomPopup)();
}
const Icon = () => "../../../common/Icon.js";
const BottomPopup = () => "../../../common/BottomPopup/index.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  props: {
    iconFile: {
      type: String,
      required: true
    },
    title: {
      type: String,
      default: ""
    },
    needDialog: {
      type: Boolean,
      default: true
    },
    iconWidth: {
      type: String,
      default: "20px"
    },
    iconHeight: {
      type: String,
      default: "20px"
    },
    // Whether to display the bottom popup dialog on mobile devices
    // Invalid on PC
    needBottomPopup: {
      type: Boolean,
      default: false
    }
  },
  emits: ["onIconClick", "onDialogClose", "onDialogShow"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const isDark = common_vendor.ref(TUIKit_components_TUIChat_config.ChatConfig.getTheme() === "dark");
    const showDialog = common_vendor.ref(false);
    const toolbarItemRef = common_vendor.ref();
    const dialogRef = common_vendor.ref();
    const toggleToolbarItem = () => {
      emits("onIconClick", dialogRef);
      if (TUIKit_utils_env.isPC) {
        common_vendor.O.listen({
          domRefs: toolbarItemRef.value,
          handler: closeToolbarItem
        });
      }
      if (!props.needDialog) {
        return;
      }
      toggleDialogDisplay(!showDialog.value);
    };
    const closeToolbarItem = () => {
      showDialog.value = false;
      emits("onDialogClose", dialogRef);
    };
    const toggleDialogDisplay = (showStatus) => {
      if (showDialog.value === showStatus) {
        return;
      }
      showDialog.value = showStatus;
      switch (showStatus) {
        case true:
          emits("onDialogShow", dialogRef);
          break;
        case false:
          emits("onDialogClose", dialogRef);
      }
    };
    const onPopupClose = () => {
      showDialog.value = false;
    };
    __expose({
      toggleDialogDisplay
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          file: props.iconFile,
          width: props.iconWidth,
          height: props.iconHeight
        }),
        b: common_vendor.n(common_vendor.unref(TUIKit_utils_env.isUniFrameWork) && "toolbar-item-container-uni-icon"),
        c: common_vendor.o$1(toggleToolbarItem),
        d: common_vendor.unref(TUIKit_utils_env.isUniFrameWork)
      }, common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? {
        e: common_vendor.t(props.title)
      } : {}, {
        f: props.needBottomPopup && !common_vendor.unref(TUIKit_utils_env.isPC)
      }, props.needBottomPopup && !common_vendor.unref(TUIKit_utils_env.isPC) ? {
        g: common_vendor.o$1(() => {
        }),
        h: common_vendor.o$1(onPopupClose),
        i: common_vendor.p({
          show: common_vendor.unref(showDialog)
        })
      } : {}, {
        j: common_vendor.unref(showDialog),
        k: common_vendor.n(common_vendor.unref(isDark) && "toolbar-item-container-dialog-dark"),
        l: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "toolbar-item-container-h5-dialog"),
        m: common_vendor.n(common_vendor.unref(TUIKit_utils_env.isUniFrameWork) && "toolbar-item-container-uni-dialog"),
        n: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "toolbar-item-container-h5"),
        o: common_vendor.n(common_vendor.unref(TUIKit_utils_env.isUniFrameWork) && "toolbar-item-container-uni")
      });
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bf58df78"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/message-input-toolbar/toolbar-item-container/index.js.map
