/*! For license information please see user_status-menu.js.LICENSE.txt */ !function(){var e,n,r,s={1296:function(e,n,r){"use strict";var s=r(20144),a=r(45994),o=r(79753),i=r(79954),u=r(78595),c=r(20296),l=r.n(c),d=r(4820);function m(t,e,n,r,s,a,o){try{var i=t[a](o),u=i.value}catch(t){return void n(t)}i.done?e(u):Promise.resolve(u).then(r,s)}var f=function(){var t,e=(t=regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(0,o.generateOcsUrl)("apps/user_status/api/v1/heartbeat?format=json"),t.next=3,d.default.put(n,{status:e?"away":"online"});case 3:return r=t.sent,t.abrupt("return",r.data);case 5:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,s){var a=t.apply(e,n);function o(t){m(a,r,s,o,i,"next",t)}function i(t){m(a,r,s,o,i,"throw",t)}o(void 0)}))});return function(t){return e.apply(this,arguments)}}(),p=r(84387);function v(t,e,n,r,s,a,o){try{var i=t[a](o),u=i.value}catch(t){return void n(t)}i.done?e(u):Promise.resolve(u).then(r,s)}var h=(0,i.j)("user_status","profileEnabled",!1).profileEnabled,g={name:"UserStatus",components:{SetStatusModal:function(){return Promise.all([r.e(7874),r.e(8299)]).then(r.bind(r,78369))}},mixins:[p.Z],props:{inline:{type:Boolean,default:!1}},data:function(){return{displayName:(0,a.ts)().displayName,heartbeatInterval:null,isAway:!1,isModalOpen:!1,loadingProfilePage:!1,mouseMoveListener:null,profileEnabled:h,setAwayTimeout:null}},computed:{elementTag:function(){return this.inline?"div":"li"},profilePageLink:function(){return this.profileEnabled?(0,o.generateUrl)("/u/{userId}",{userId:(0,a.ts)().uid}):null}},mounted:function(){var t=this;(0,u.Ld)("settings:display-name:updated",this.handleDisplayNameUpdate),(0,u.Ld)("settings:profile-enabled:updated",this.handleProfileEnabledUpdate),this.$store.dispatch("loadStatusFromInitialState"),OC.config.session_keepalive&&(this.heartbeatInterval=setInterval(this._backgroundHeartbeat.bind(this),3e5),this.setAwayTimeout=function(){t.isAway=!0},this.mouseMoveListener=l()((function(){var e=t.isAway;t.isAway=!1,clearTimeout(t.setAwayTimeout),setTimeout(t.setAwayTimeout,12e4),e&&t._backgroundHeartbeat()}),2e3,!0),window.addEventListener("mousemove",this.mouseMoveListener,{capture:!0,passive:!0}),this._backgroundHeartbeat()),(0,u.Ld)("user_status:status.updated",this.handleUserStatusUpdated)},beforeDestroy:function(){(0,u.r1)("settings:display-name:updated",this.handleDisplayNameUpdate),(0,u.r1)("settings:profile-enabled:updated",this.handleProfileEnabledUpdate),window.removeEventListener("mouseMove",this.mouseMoveListener),clearInterval(this.heartbeatInterval),(0,u.r1)("user_status:status.updated",this.handleUserStatusUpdated)},methods:{handleDisplayNameUpdate:function(t){this.displayName=t},handleProfileEnabledUpdate:function(t){this.profileEnabled=t},loadProfilePage:function(){this.profileEnabled&&(this.loadingProfilePage=!0)},openModal:function(){this.isModalOpen=!0},closeModal:function(){this.isModalOpen=!1},_backgroundHeartbeat:function(){var t,e=this;return(t=regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,f(e.isAway);case 3:if(null==(n=t.sent)||!n.userId){t.next=8;break}e.$store.dispatch("setStatusFromHeartbeat",n),t.next=10;break;case 8:return t.next=10,e.$store.dispatch("reFetchStatusFromServer");case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(0),console.debug("Failed sending heartbeat, got: "+(null===(r=t.t0.response)||void 0===r?void 0:r.status));case 15:case"end":return t.stop()}}),t,null,[[0,12]])})),function(){var e=this,n=arguments;return new Promise((function(r,s){var a=t.apply(e,n);function o(t){v(a,r,s,o,i,"next",t)}function i(t){v(a,r,s,o,i,"throw",t)}o(void 0)}))})()},handleUserStatusUpdated:function(t){OC.getCurrentUser().uid===t.userId&&this.$store.dispatch("setStatusFromObject",{status:t.status,icon:t.icon,message:t.message})}}},A=g,b=r(93379),j=r.n(b),y=r(7795),w=r.n(y),C=r(90569),x=r.n(C),_=r(3565),k=r.n(_),S=r(19216),P=r.n(S),O=r(44589),I=r.n(O),D=r(48199),M={};M.styleTagTransform=I(),M.setAttributes=k(),M.insert=x().bind(null,"head"),M.domAPI=w(),M.insertStyleElement=P(),j()(D.Z,M),D.Z&&D.Z.locals&&D.Z.locals;var U=(0,r(51900).Z)(A,(function(){var t=this,e=t._self._c;return e(t.elementTag,{tag:"component"},[e("div",{staticClass:"user-status-menu-item"},[t.inline?t._e():e("a",{staticClass:"user-status-menu-item__header",attrs:{href:t.profilePageLink},on:{click:t.loadProfilePage}},[e("div",{staticClass:"user-status-menu-item__header-content"},[e("div",{staticClass:"user-status-menu-item__header-content-displayname"},[t._v(t._s(t.displayName))]),t._v(" "),t.loadingProfilePage?e("div",{staticClass:"icon-loading-small"}):e("div",{staticClass:"user-status-menu-item__header-content-placeholder"})]),t._v(" "),t.profileEnabled?e("div",[t._v("\n\t\t\t\t"+t._s(t.t("user_status","View profile"))+"\n\t\t\t")]):t._e()]),t._v(" "),e(t.inline?"button":"a",{tag:"toggle",staticClass:"user-status-menu-item__toggle",class:{"user-status-menu-item__toggle--inline":t.inline},attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),e.stopPropagation(),t.openModal.apply(null,arguments)}}},[e("span",{staticClass:"user-status-menu-item__toggle-icon",class:t.statusIcon}),t._v("\n\t\t\t"+t._s(t.visibleMessage)+"\n\t\t")])],1),t._v(" "),t.isModalOpen?e("SetStatusModal",{on:{close:t.closeModal}}):t._e()],1)}),[],!1,null,"4d14b4f8",null),E=U.exports,R=r(20629);function T(t,e,n,r,s,a,o){try{var i=t[a](o),u=i.value}catch(t){return void n(t)}i.done?e(u):Promise.resolve(u).then(r,s)}var z=function(){var t,e=(t=regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=(0,o.generateOcsUrl)("apps/user_status/api/v1/predefined_statuses?format=json"),t.next=3,d.default.get(e);case 3:return n=t.sent,t.abrupt("return",n.data.ocs.data);case 5:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,s){var a=t.apply(e,n);function o(t){T(a,r,s,o,i,"next",t)}function i(t){T(a,r,s,o,i,"throw",t)}o(void 0)}))});return function(){return e.apply(this,arguments)}}();function B(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return F(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?F(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,s=function(){};return{s:s,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,i=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){i=!0,a=t},f:function(){try{o||null==n.return||n.return()}finally{if(i)throw a}}}}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0)){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,z();case 5:s=e.sent,a=B(s);try{for(a.s();!(o=a.n()).done;)i=o.value,r("addPredefinedStatus",i)}catch(t){a.e(t)}finally{a.f()}case 8:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,s){var a=e.apply(t,n);function o(t){$(a,r,s,o,i,"next",t)}function i(t){$(a,r,s,o,i,"throw",t)}o(void 0)}))})();var e}},N={state:{predefinedStatuses:[]},mutations:{addPredefinedStatus:function(t,e){t.predefinedStatuses.push(e)}},getters:{},actions:L};function Z(t,e,n,r,s,a,o){try{var i=t[a](o),u=i.value}catch(t){return void n(t)}i.done?e(u):Promise.resolve(u).then(r,s)}function q(t){return function(){var e=this,n=arguments;return new Promise((function(r,s){var a=t.apply(e,n);function o(t){Z(a,r,s,o,i,"next",t)}function i(t){Z(a,r,s,o,i,"throw",t)}o(void 0)}))}}var H=function(){var t=q(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=(0,o.generateOcsUrl)("apps/user_status/api/v1/user_status"),t.next=3,d.default.get(e);case 3:return n=t.sent,t.abrupt("return",n.data.ocs.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),G=function(){var t=q(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(0,o.generateOcsUrl)("apps/user_status/api/v1/user_status/status"),t.next=3,d.default.put(n,{statusType:e});case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Q=function(){var t=q(regeneratorRuntime.mark((function t(e){var n,r,s=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:null,r=(0,o.generateOcsUrl)("apps/user_status/api/v1/user_status/message/predefined?format=json"),t.next=4,d.default.put(r,{messageId:e,clearAt:n});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),W=function(){var t=q(regeneratorRuntime.mark((function t(e){var n,r,s,a=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:null,r=a.length>2&&void 0!==a[2]?a[2]:null,s=(0,o.generateOcsUrl)("apps/user_status/api/v1/user_status/message/custom?format=json"),t.next=5,d.default.put(s,{message:e,statusIcon:n,clearAt:r});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),J=function(){var t=q(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=(0,o.generateOcsUrl)("apps/user_status/api/v1/user_status/message?format=json"),t.next=3,d.default.delete(e);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),K=r(64039),V=r(80351),X=r.n(V),Y=function(t){if(null===t)return null;var e=(0,K.n)();if("period"===t.type)return e.setSeconds(e.getSeconds()+t.time),Math.floor(e.getTime()/1e3);if("end-of"===t.type)switch(t.time){case"day":case"week":return Number(X()(e).endOf(t.time).format("X"))}return"_time"===t.type?t.time:null};function tt(t,e,n,r,s,a,o){try{var i=t[a](o),u=i.value}catch(t){return void n(t)}i.done?e(u):Promise.resolve(u).then(r,s)}function et(t){return function(){var e=this,n=arguments;return new Promise((function(r,s){var a=t.apply(e,n);function o(t){tt(a,r,s,o,i,"next",t)}function i(t){tt(a,r,s,o,i,"throw",t)}o(void 0)}))}}var nt={state:{status:null,statusIsUserDefined:null,message:null,icon:null,clearAt:null,messageIsPredefined:null,messageId:null},mutations:{setStatus:function(t,e){var n=e.statusType;t.status=n,t.statusIsUserDefined=!0},setPredefinedMessage:function(t,e){var n=e.messageId,r=e.clearAt,s=e.message,a=e.icon;t.messageId=n,t.messageIsPredefined=!0,t.message=s,t.icon=a,t.clearAt=r},setCustomMessage:function(t,e){var n=e.message,r=e.icon,s=e.clearAt;t.messageId=null,t.messageIsPredefined=!1,t.message=n,t.icon=r,t.clearAt=s},clearMessage:function(t){t.messageId=null,t.messageIsPredefined=!1,t.message=null,t.icon=null,t.clearAt=null},loadStatusFromServer:function(t,e){var n=e.status,r=e.statusIsUserDefined,s=e.message,a=e.icon,o=e.clearAt,i=e.messageIsPredefined,u=e.messageId;t.status=n,t.message=s,t.icon=a,void 0!==r&&(t.statusIsUserDefined=r),void 0!==o&&(t.clearAt=o),void 0!==i&&(t.messageIsPredefined=i),void 0!==u&&(t.messageId=u)}},getters:{},actions:{setStatus:function(t,e){return et(regeneratorRuntime.mark((function n(){var r,s,o,i;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=t.commit,o=t.state,i=e.statusType,n.next=4,G(i);case 4:s("setStatus",{statusType:i}),(0,u.j8)("user_status:status.updated",{status:o.status,message:o.message,icon:o.icon,clearAt:o.clearAt,userId:null===(r=(0,a.ts)())||void 0===r?void 0:r.uid});case 6:case"end":return n.stop()}}),n)})))()},setStatusFromObject:function(t,e){return et(regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=t.commit,t.state,r("loadStatusFromServer",e);case 2:case"end":return n.stop()}}),n)})))()},setPredefinedMessage:function(t,e){return et(regeneratorRuntime.mark((function n(){var r,s,o,i,c,l,d,m,f,p;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=t.commit,o=t.rootState,i=t.state,c=e.messageId,l=e.clearAt,d=Y(l),n.next=5,Q(c,d);case 5:m=o.predefinedStatuses.predefinedStatuses.find((function(t){return t.id===c})),f=m.message,p=m.icon,s("setPredefinedMessage",{messageId:c,clearAt:d,message:f,icon:p}),(0,u.j8)("user_status:status.updated",{status:i.status,message:i.message,icon:i.icon,clearAt:i.clearAt,userId:null===(r=(0,a.ts)())||void 0===r?void 0:r.uid});case 9:case"end":return n.stop()}}),n)})))()},setCustomMessage:function(t,e){return et(regeneratorRuntime.mark((function n(){var r,s,o,i,c,l,d;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=t.commit,o=t.state,i=e.message,c=e.icon,l=e.clearAt,d=Y(l),n.next=5,W(i,c,d);case 5:s("setCustomMessage",{message:i,icon:c,clearAt:d}),(0,u.j8)("user_status:status.updated",{status:o.status,message:o.message,icon:o.icon,clearAt:o.clearAt,userId:null===(r=(0,a.ts)())||void 0===r?void 0:r.uid});case 7:case"end":return n.stop()}}),n)})))()},clearMessage:function(t){return et(regeneratorRuntime.mark((function e(){var n,r,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.commit,s=t.state,e.next=3,J();case 3:r("clearMessage"),(0,u.j8)("user_status:status.updated",{status:s.status,message:s.message,icon:s.icon,clearAt:s.clearAt,userId:null===(n=(0,a.ts)())||void 0===n?void 0:n.uid});case 5:case"end":return e.stop()}}),e)})))()},reFetchStatusFromServer:function(t){return et(regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.commit,e.next=3,H();case 3:r=e.sent,n("loadStatusFromServer",r);case 5:case"end":return e.stop()}}),e)})))()},setStatusFromHeartbeat:function(t,e){return et(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(0,t.commit)("loadStatusFromServer",e);case 2:case"end":return n.stop()}}),n)})))()},loadStatusFromInitialState:function(t){(0,t.commit)("loadStatusFromServer",(0,i.j)("user_status","status"))}}};s.ZP.use(R.ZP);var rt=new R.yh({modules:{predefinedStatuses:N,userStatus:nt},strict:!0}),st=r(75925),at=r.n(st);r.nc=btoa((0,a.IH)()),s.ZP.prototype.t=t,s.ZP.prototype.$t=t;var ot=document.getElementById("avatardiv-menu"),it=(0,i.j)("user_status","status"),ut={preloadedUserStatus:{message:it.message,icon:it.icon,status:it.status},user:ot.dataset.user,displayName:ot.dataset.displayname,disableMenu:!0,disableTooltip:!0};new(s.ZP.extend(at()))({propsData:ut}).$mount("#avatardiv-menu"),new s.ZP({el:'li[data-id="user_status-menuitem"]',name:"UserStatusRoot",render:function(t){return t(E)},store:rt}),document.addEventListener("DOMContentLoaded",(function(){OCA.Dashboard&&OCA.Dashboard.registerStatus("status",(function(t){return new(s.ZP.extend(E))({propsData:{inline:!0},store:rt}).$mount(t)}))}))},84387:function(t,e,n){"use strict";var r=n(20629),s=n(26932);function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function o(t,e,n,r,s,a,o){try{var i=t[a](o),u=i.value}catch(t){return void n(t)}i.done?e(u):Promise.resolve(u).then(r,s)}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function u(t){for(var e=1;e