require('../assets/NcUserStatusIcon-DAVSJFhS.css'); "use strict"; const axios = require("@nextcloud/axios"); const router = require("@nextcloud/router"); const capabilities = require("@nextcloud/capabilities"); const _l10n = require("./_l10n-CjO_W5Dt.cjs"); const _pluginVue2_normalizer = require("./_plugin-vue2_normalizer-V0q-tHlQ.cjs"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const axios__default = /* @__PURE__ */ _interopDefault(axios); const onlineSvg = '\n\n \n\n'; const awaySvg = '\n\n \n \n\n'; const dndSvg = '\n\n \n \n \n\n'; const invisibleSvg = '\n\n \n \n\n'; _l10n.register(_l10n.t10); const getUserStatusText = (status) => { switch (status) { case "away": return _l10n.t("away"); case "busy": return _l10n.t("busy"); case "dnd": return _l10n.t("do not disturb"); case "online": return _l10n.t("online"); case "invisible": return _l10n.t("invisible"); case "offline": return _l10n.t("offline"); default: return status; } }; _l10n.register(_l10n.t48); const _sfc_main = { name: "NcUserStatusIcon", props: { /** * Set the user id to fetch the status */ user: { type: String, default: null }, /** * Set the status * * @type {'online' | 'away' | 'busy' | 'dnd' | 'invisible' | 'offline'} */ status: { type: String, default: null, validator: (value) => [ "online", "away", "busy", "dnd", "invisible", "offline" ].includes(value) }, /** * Set the `aria-hidden` attribute * * @type {'true' | 'false'} */ ariaHidden: { type: String, default: null, validator: (value) => [ "true", "false" ].includes(value) } }, data() { return { fetchedUserStatus: null }; }, computed: { activeStatus() { return this.status ?? this.fetchedUserStatus; }, activeSvg() { const matchSvg = { online: onlineSvg, away: awaySvg, busy: awaySvg, dnd: dndSvg, invisible: invisibleSvg, offline: invisibleSvg }; return matchSvg[this.activeStatus] ?? null; }, ariaLabel() { if (this.ariaHidden === "true") { return null; } return _l10n.t("User status: {status}", { status: getUserStatusText(this.activeStatus) }); } }, watch: { user: { immediate: true, async handler(user, _oldUser) { if (!user || !capabilities.getCapabilities()?.user_status?.enabled) { this.fetchedUserStatus = null; return; } try { const { data } = await axios__default.default.get(router.generateOcsUrl("/apps/user_status/api/v1/statuses/{user}", { user })); this.fetchedUserStatus = data.ocs?.data?.status; } catch (error) { this.fetchedUserStatus = null; } } } } }; var _sfc_render = function render() { var _vm = this, _c = _vm._self._c; return _vm.activeStatus ? _c("span", { staticClass: "user-status-icon", class: { "user-status-icon--invisible": ["invisible", "offline"].includes(_vm.status) }, attrs: { "role": "img", "aria-hidden": _vm.ariaHidden, "aria-label": _vm.ariaLabel }, domProps: { "innerHTML": _vm._s(_vm.activeSvg) } }) : _vm._e(); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "0555d8d0" ); const NcUserStatusIcon = __component__.exports; exports.NcUserStatusIcon = NcUserStatusIcon; exports.getUserStatusText = getUserStatusText;