'use strict';

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

var vue = require('vue');
var elementPlus = require('element-plus');
var svg = require('@element-plus/icons-vue');
var vueRouter = require('vue-router');
var screenfull = require('screenfull');
var vueI18n = require('vue-i18n');
var pinia = require('pinia');
require('../../../../../stores/index.js');
require('../../../../../utils/index.js');
require('../../../../../api/index.js');
var index = require('../../../../../locale/index.js');
require('../../../../../hooks/index.js');
var mitt = require('../../../../../utils/mitt.js');
var Push = require('push.js');
var routesList = require('../../../../../stores/routesList.js');
var userInfo = require('../../../../../stores/userInfo.js');
var themeConfig = require('../../../../../stores/themeConfig.js');
var useDialogEvents = require('../../../../../hooks/composables/useDialogEvents.js');
var storage = require('../../../../../utils/storage.js');
var index$1 = require('../../../../../api/base/index.js');
var signalR = require('../../../../../utils/signalR.js');
var uploadfileurl = require('../../../../../utils/uploadfileurl.js');
var request = require('../../../../../utils/request.js');

const _hoisted_1 = { class: "layout-navbars-breadcrumb-user-icon" };
const _hoisted_2 = ["title"];
const _hoisted_3 = { class: "layout-navbars-breadcrumb-user-icon" };
const _hoisted_4 = { class: "flex items-center" };
const _hoisted_5 = { class: "mr-2" };
const _hoisted_6 = { style: { "margin-left": "10px" } };
const _hoisted_7 = ["title"];
const _hoisted_8 = { class: "layout-navbars-breadcrumb-user-icon" };
const _hoisted_9 = ["title"];
const _hoisted_10 = { class: "layout-navbars-breadcrumb-user-link" };
const _hoisted_11 = ["src"];
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "user",
  setup(__props) {
    const UserNews = vue.defineAsyncComponent(() => Promise.resolve().then(function () { return require('./userNews.vue.js'); }));
    const UpgradeInfo = vue.defineAsyncComponent(() => Promise.resolve().then(function () { return require('./upgradeInfo.vue.js'); }));
    const routeStores = routesList.useRoutesList();
    const { locale, t } = vueI18n.useI18n();
    const router = vueRouter.useRouter();
    const stores = userInfo.useUserInfo();
    const storesThemeConfig = themeConfig.useThemeConfig();
    const { userInfos } = pinia.storeToRefs(stores);
    const { themeConfig: themeConfig$1 } = pinia.storeToRefs(storesThemeConfig);
    const upgradeInfoRef = vue.ref();
    const currentCountryCode = vue.ref(index.getCountryCode(themeConfig$1.value.globalI18n));
    const state = vue.reactive({
      isScreenfull: false,
      disabledI18n: "zh-cn",
      disabledSize: "large",
      noticeList: [],
      // 站内信列表
      tagsRefsIndex: 0,
      tagsViewList: [],
      tagsViewRoutesList: []
    });
    const events = useDialogEvents.useFormEvents();
    const layoutUserFlexNum = vue.computed(() => {
      let num = "";
      const { layout, isClassicSplitMenu } = themeConfig$1.value;
      const layoutArr = ["defaults", "columns"];
      if (layoutArr.includes(layout) || layout === "classic" && !isClassicSplitMenu) num = "1";
      else num = "";
      return num;
    });
    const hasUnreadNotice = vue.computed(() => {
      return state.noticeList.some((r) => r.readStatus == void 0 || r.readStatus == 0);
    });
    const onScreenfullClick = () => {
      if (!screenfull.isEnabled) {
        elementPlus.ElMessage.warning("\u6682\u4E0D\u4E0D\u652F\u6301\u5168\u5C4F");
        return false;
      }
      screenfull.toggle();
      screenfull.on("change", () => {
        if (screenfull.isFullscreen) state.isScreenfull = true;
        else state.isScreenfull = false;
      });
    };
    const onLayoutSetingClick = () => {
      mitt.default.emit("openSettingsDrawer");
    };
    const onHandleCommandClick = (path) => {
      if (path === "clearCache") {
        storage.Session.clear();
        storage.Local.clear();
        window.location.reload();
      } else if (path === "lockScreen") {
        storage.Local.remove("themeConfig");
        themeConfig$1.value.isLockScreen = true;
        themeConfig$1.value.lockScreenTime = 1;
        storage.Local.set("themeConfig", themeConfig$1.value);
      } else if (path === "logOut") {
        elementPlus.ElMessageBox({
          closeOnClickModal: false,
          closeOnPressEscape: false,
          title: t("message.user.logOutTitle"),
          message: t("message.user.logOutMessage"),
          type: "warning",
          showCancelButton: true,
          confirmButtonText: t("message.user.logOutConfirm"),
          cancelButtonText: t("message.user.logOutCancel"),
          // buttonSize: 'default',
          beforeClose: async (action, instance, done) => {
            if (action === "confirm") {
              instance.confirmButtonLoading = true;
              instance.confirmButtonText = t("message.user.logOutExit");
              try {
                await index$1.useBaseApi("sysAuth").post(null, "logout");
              } catch (error) {
                console.error(error);
              }
              instance.confirmButtonLoading = false;
              done();
            } else {
              done();
            }
          }
        }).then(async () => {
          await signalR.signalR.stop();
          request.clearAccessTokens();
        }).catch(() => {
        });
      } else {
        router.push(path);
      }
    };
    const onSearchClick = () => {
      events.onFormDialogOpen({
        name: "searchFormMenu"
      });
    };
    const onOnlineUserClick = () => {
      events.onFormDialogOpen({
        name: "onlineUsers"
      });
    };
    const onComponentSizeChange = (size) => {
      storage.Local.remove("themeConfig");
      themeConfig$1.value.globalComponentSize = size;
      storage.Local.set("themeConfig", themeConfig$1.value);
      initI18nOrSize("globalComponentSize", "disabledSize");
    };
    const onLanguageChange = async (lang) => {
      storage.Local.remove("themeConfig");
      themeConfig$1.value.globalI18n = lang;
      storage.Local.set("themeConfig", themeConfig$1.value);
      currentCountryCode.value = index.getCountryCode(lang);
      locale.value = lang;
      events.onFormDialogOpen({
        name: "setFBrowserTitle"
      });
      initI18nOrSize("globalI18n", "disabledI18n");
      refreshCurrentTabpage();
      await index$1.useBaseApi("sysCommon").post(null, "setCulture/?culture=" + lang);
    };
    const onChatClick = () => {
      router.push({
        path: "/llm/aiChat"
      });
    };
    const refreshCurrentTabpage = () => {
      mitt.default.emit("onCurrentContextmenuClick", { ...routeStores.currentRoute, contextMenuClickId: 0 });
    };
    const initI18nOrSize = (value, attr) => {
      state[attr] = storage.Local.get("themeConfig")[value];
    };
    vue.onMounted(async () => {
      var _a, _b;
      if (storage.Local.get("themeConfig")) {
        initI18nOrSize("globalComponentSize", "disabledSize");
        initI18nOrSize("globalI18n", "disabledI18n");
      }
      if (Push.Permission.GRANTED) {
        Push.Permission.request(void 0, void 0);
      }
      document.addEventListener("visibilitychange", () => {
        if (!document.hidden) {
          Push.clear();
        }
      });
      var res = await index$1.useBaseApi("sysNotice").get(null, "unReadList");
      state.noticeList = (_a = res.data.result) != null ? _a : [];
      signalR.signalR.on("PublicNotice", receiveNotice);
      var res1 = await index$1.useBaseApi("sysUpgrade").get(null, "lastUnRead");
      if (res1.data.result != null) {
        (_b = upgradeInfoRef.value) == null ? void 0 : _b.openDialog(res1.data.result);
      }
      await changePassword();
    });
    const receiveNotice = (msg) => {
      state.noticeList.unshift(msg);
      elementPlus.ElNotification({
        title: "\u63D0\u793A",
        message: "\u60A8\u6709\u4E00\u6761\u65B0\u6D88\u606F...",
        type: "info",
        position: "bottom-right"
      });
      Push.create("\u63D0\u793A", {
        body: "\u4F60\u6709\u4E00\u6761\u65B0\u7684\u6D88\u606F",
        icon: "logo.png",
        // public目录下的
        timeout: 4500
        // 通知显示时间，单位为毫秒
      });
    };
    const changePassword = async () => {
      var _a, _b;
      if (userInfos.value.accountType == 999) return;
      if (themeConfig$1.value.forceChangePassword == void 0) {
        while (themeConfig$1.value.forceChangePassword != void 0) {
          await new Promise((resolve) => setTimeout(resolve, 100));
        }
      }
      const enabledForceChangePassword = (_a = themeConfig$1.value.forceChangePassword) != null ? _a : false;
      if (enabledForceChangePassword && !userInfos.value.lastChangePasswordTime) {
        events.onFormDialogOpen({
          name: "changePassword"
        });
        return;
      }
      const passwordExpirationTime = (_b = themeConfig$1.value.passwordExpirationTime) != null ? _b : 0;
      if (passwordExpirationTime > 0) {
        const res = await index$1.useBaseApi("sysUser").post(null, "verifyPwdExpirationTime");
        if (!res.data.result) {
          events.onFormDialogOpen({
            name: "changePassword"
          });
        }
      }
    };
    return (_ctx, _cache) => {
      const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
      const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
      const _component_el_dropdown = vue.resolveComponent("el-dropdown");
      const _component_ele_ChatDotRound = vue.resolveComponent("ele-ChatDotRound");
      const _component_el_icon = vue.resolveComponent("el-icon");
      const _component_ele_Search = vue.resolveComponent("ele-Search");
      const _component_ele_Bell = vue.resolveComponent("ele-Bell");
      const _component_el_badge = vue.resolveComponent("el-badge");
      const _component_el_popover = vue.resolveComponent("el-popover");
      const _component_ele_User = vue.resolveComponent("ele-User");
      const _component_el_tooltip = vue.resolveComponent("el-tooltip");
      const _component_ele_ArrowDown = vue.resolveComponent("ele-ArrowDown");
      return vue.openBlock(), vue.createElementBlock(
        "div",
        {
          class: "layout-navbars-breadcrumb-user pr15",
          style: vue.normalizeStyle({ flex: layoutUserFlexNum.value })
        },
        [
          vue.renderSlot(_ctx.$slots, "user-before"),
          vue.createVNode(_component_el_dropdown, {
            "show-timeout": 70,
            "hide-timeout": 50,
            trigger: "click",
            onCommand: onComponentSizeChange
          }, {
            dropdown: vue.withCtx(() => [
              vue.createVNode(_component_el_dropdown_menu, null, {
                default: vue.withCtx(() => [
                  vue.createVNode(_component_el_dropdown_item, {
                    command: "large",
                    disabled: state.disabledSize === "large"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.user.dropdownLarge")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["disabled"]),
                  vue.createVNode(_component_el_dropdown_item, {
                    command: "default",
                    disabled: state.disabledSize === "default"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.user.dropdownDefault")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["disabled"]),
                  vue.createVNode(_component_el_dropdown_item, {
                    command: "small",
                    disabled: state.disabledSize === "small"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.user.dropdownSmall")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["disabled"])
                ]),
                _: 1
                /* STABLE */
              })
            ]),
            default: vue.withCtx(() => [
              vue.createElementVNode("div", _hoisted_1, [
                vue.createElementVNode("i", {
                  class: "iconfont icon-ziti",
                  title: _ctx.$t("message.user.title0")
                }, null, 8, _hoisted_2)
              ])
            ]),
            _: 1
            /* STABLE */
          }),
          vue.unref(themeConfig$1).i18NSwitch ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
            key: 0,
            "show-timeout": 70,
            "hide-timeout": 50,
            trigger: "click",
            onCommand: onLanguageChange
          }, {
            dropdown: vue.withCtx(() => [
              vue.createVNode(_component_el_dropdown_menu, null, {
                default: vue.withCtx(() => [
                  (vue.openBlock(true), vue.createElementBlock(
                    vue.Fragment,
                    null,
                    vue.renderList(vue.unref(index.languageList), (value, key) => {
                      return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
                        key,
                        command: key,
                        disabled: state.disabledI18n === key
                      }, {
                        default: vue.withCtx(() => [
                          vue.createElementVNode("div", _hoisted_4, [
                            vue.createElementVNode("div", _hoisted_5, [
                              vue.createElementVNode(
                                "span",
                                {
                                  class: vue.normalizeClass(`fi fi-${vue.unref(index.getCountryCode)(key)}`)
                                },
                                null,
                                2
                                /* CLASS */
                              )
                            ]),
                            vue.createElementVNode(
                              "div",
                              _hoisted_6,
                              vue.toDisplayString(value),
                              1
                              /* TEXT */
                            )
                          ])
                        ]),
                        _: 2
                        /* DYNAMIC */
                      }, 1032, ["command", "disabled"]);
                    }),
                    128
                    /* KEYED_FRAGMENT */
                  ))
                ]),
                _: 1
                /* STABLE */
              })
            ]),
            default: vue.withCtx(() => [
              vue.createElementVNode("div", _hoisted_3, [
                vue.createElementVNode(
                  "span",
                  {
                    class: vue.normalizeClass(`fi fi-${currentCountryCode.value}`)
                  },
                  null,
                  2
                  /* CLASS */
                )
              ])
            ]),
            _: 1
            /* STABLE */
          })) : vue.createCommentVNode("v-if", true),
          vue.createElementVNode("div", {
            class: "layout-navbars-breadcrumb-user-icon",
            onClick: onChatClick
          }, [
            vue.createVNode(_component_el_icon, {
              title: _ctx.$t("message.user.chat")
            }, {
              default: vue.withCtx(() => [
                vue.createVNode(_component_ele_ChatDotRound)
              ]),
              _: 1
              /* STABLE */
            }, 8, ["title"])
          ]),
          vue.createElementVNode("div", {
            class: "layout-navbars-breadcrumb-user-icon",
            onClick: onSearchClick
          }, [
            vue.createVNode(_component_el_icon, {
              title: _ctx.$t("message.user.title2")
            }, {
              default: vue.withCtx(() => [
                vue.createVNode(_component_ele_Search)
              ]),
              _: 1
              /* STABLE */
            }, 8, ["title"])
          ]),
          vue.createElementVNode("div", {
            class: "layout-navbars-breadcrumb-user-icon",
            onClick: onLayoutSetingClick
          }, [
            vue.createElementVNode("i", {
              class: "icon-skin iconfont",
              title: _ctx.$t("message.user.title3")
            }, null, 8, _hoisted_7)
          ]),
          vue.createElementVNode("div", _hoisted_8, [
            vue.createVNode(_component_el_popover, {
              placement: "bottom",
              trigger: "hover",
              transition: "el-zoom-in-top",
              width: 400,
              persistent: false
            }, {
              reference: vue.withCtx(() => [
                vue.createVNode(_component_el_badge, { "is-dot": hasUnreadNotice.value }, {
                  default: vue.withCtx(() => [
                    vue.createVNode(_component_el_icon, {
                      title: _ctx.$t("message.user.title4")
                    }, {
                      default: vue.withCtx(() => [
                        vue.createVNode(_component_ele_Bell)
                      ]),
                      _: 1
                      /* STABLE */
                    }, 8, ["title"])
                  ]),
                  _: 1
                  /* STABLE */
                }, 8, ["is-dot"])
              ]),
              default: vue.withCtx(() => [
                vue.createVNode(vue.unref(UserNews), {
                  noticeList: state.noticeList
                }, null, 8, ["noticeList"])
              ]),
              _: 1
              /* STABLE */
            })
          ]),
          vue.createElementVNode("div", {
            class: "layout-navbars-breadcrumb-user-icon",
            onClick: onScreenfullClick
          }, [
            vue.createElementVNode("i", {
              class: vue.normalizeClass(["iconfont", !state.isScreenfull ? "icon-fullscreen" : "icon-tuichuquanping"]),
              title: state.isScreenfull ? _ctx.$t("message.user.title6") : _ctx.$t("message.user.title5")
            }, null, 10, _hoisted_9)
          ]),
          vue.createElementVNode("div", {
            class: "layout-navbars-breadcrumb-user-icon mr10",
            onClick: onOnlineUserClick
          }, [
            vue.createVNode(_component_el_icon, {
              title: _ctx.$t("message.list.onlineUser")
            }, {
              default: vue.withCtx(() => [
                vue.createVNode(_component_ele_User)
              ]),
              _: 1
              /* STABLE */
            }, 8, ["title"])
          ]),
          _ctx.$slots["user-dropdown"] ? vue.renderSlot(_ctx.$slots, "user-dropdown", { key: 1 }, () => [
            vue.renderSlot(_ctx.$slots, "user-dropdown")
          ]) : (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
            key: 2,
            "show-timeout": 70,
            "hide-timeout": 50,
            size: "large",
            onCommand: onHandleCommandClick
          }, {
            dropdown: vue.withCtx(() => [
              vue.createVNode(_component_el_dropdown_menu, null, {
                default: vue.withCtx(() => [
                  vue.createCommentVNode(` <el-dropdown-item command="/dashboard/home">{{ $t('message.user.dropdown1') }}</el-dropdown-item> `),
                  vue.createVNode(_component_el_dropdown_item, {
                    icon: vue.unref(svg.Avatar),
                    command: "/system/userCenter"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.user.dropdown2")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["icon"]),
                  vue.createVNode(_component_el_dropdown_item, {
                    icon: vue.unref(svg.Loading),
                    command: "clearCache"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.user.dropdown3")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["icon"]),
                  vue.createVNode(_component_el_dropdown_item, {
                    icon: vue.unref(svg.Lock),
                    divided: "",
                    command: "lockScreen"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.layout.threeIsLockScreen")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["icon"]),
                  vue.createVNode(_component_el_dropdown_item, {
                    icon: vue.unref(svg.CircleCloseFilled),
                    divided: "",
                    command: "logOut"
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(_ctx.$t("message.user.dropdown5")),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["icon"])
                ]),
                _: 1
                /* STABLE */
              })
            ]),
            default: vue.withCtx(() => [
              vue.createElementVNode("span", _hoisted_10, [
                vue.createVNode(_component_el_tooltip, {
                  effect: "dark",
                  placement: "left"
                }, {
                  content: vue.withCtx(() => [
                    vue.createTextVNode(
                      vue.toDisplayString(_ctx.$t("message.list.account")) + "\uFF1A" + vue.toDisplayString(vue.unref(userInfos).account),
                      1
                      /* TEXT */
                    ),
                    _cache[0] || (_cache[0] = vue.createElementVNode(
                      "br",
                      null,
                      null,
                      -1
                      /* CACHED */
                    )),
                    vue.createTextVNode(
                      " " + vue.toDisplayString(_ctx.$t("message.list.realName")) + "\uFF1A" + vue.toDisplayString(vue.unref(userInfos).realName),
                      1
                      /* TEXT */
                    ),
                    _cache[1] || (_cache[1] = vue.createElementVNode(
                      "br",
                      null,
                      null,
                      -1
                      /* CACHED */
                    )),
                    vue.createTextVNode(
                      " " + vue.toDisplayString(_ctx.$t("message.list.phone")) + "\uFF1A" + vue.toDisplayString(vue.unref(userInfos).phone),
                      1
                      /* TEXT */
                    ),
                    _cache[2] || (_cache[2] = vue.createElementVNode(
                      "br",
                      null,
                      null,
                      -1
                      /* CACHED */
                    )),
                    vue.createTextVNode(
                      " " + vue.toDisplayString(_ctx.$t("message.list.email")) + "\uFF1A" + vue.toDisplayString(vue.unref(userInfos).email),
                      1
                      /* TEXT */
                    ),
                    _cache[3] || (_cache[3] = vue.createElementVNode(
                      "br",
                      null,
                      null,
                      -1
                      /* CACHED */
                    )),
                    vue.createTextVNode(
                      " " + vue.toDisplayString(_ctx.$t("message.list.orgName")) + "\uFF1A" + vue.toDisplayString(vue.unref(userInfos).orgName),
                      1
                      /* TEXT */
                    ),
                    _cache[4] || (_cache[4] = vue.createElementVNode(
                      "br",
                      null,
                      null,
                      -1
                      /* CACHED */
                    )),
                    vue.createTextVNode(
                      " " + vue.toDisplayString(_ctx.$t("message.list.positionText")) + "\uFF1A" + vue.toDisplayString(vue.unref(userInfos).posName),
                      1
                      /* TEXT */
                    ),
                    _cache[5] || (_cache[5] = vue.createElementVNode(
                      "br",
                      null,
                      null,
                      -1
                      /* CACHED */
                    ))
                  ]),
                  default: vue.withCtx(() => [
                    vue.createElementVNode("img", {
                      src: vue.unref(uploadfileurl.showFileUrl)(vue.unref(userInfos).avatar),
                      class: "layout-navbars-breadcrumb-user-link-photo mr5"
                    }, null, 8, _hoisted_11)
                  ]),
                  _: 1
                  /* STABLE */
                }),
                vue.createTextVNode(
                  " " + vue.toDisplayString(vue.unref(userInfos).realName == "" ? vue.unref(userInfos).account : vue.unref(userInfos).realName) + " ",
                  1
                  /* TEXT */
                ),
                vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
                  default: vue.withCtx(() => [
                    vue.createVNode(_component_ele_ArrowDown)
                  ]),
                  _: 1
                  /* STABLE */
                })
              ])
            ]),
            _: 1
            /* STABLE */
          })),
          vue.createCommentVNode(' <Search ref="searchRef" /> '),
          vue.createCommentVNode(' <OnlineUser ref="onlineUserRef" /> '),
          vue.createCommentVNode(' <ChangePassword ref="changePasswordRef" /> '),
          vue.createVNode(
            vue.unref(UpgradeInfo),
            {
              ref_key: "upgradeInfoRef",
              ref: upgradeInfoRef
            },
            null,
            512
            /* NEED_PATCH */
          ),
          vue.renderSlot(_ctx.$slots, "user-after")
        ],
        4
        /* STYLE */
      );
    };
  }
});

exports.default = _sfc_main;
