![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /opt/mattermost/client/ |
Upload File : |
"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[5977,9163],{83469:(e,t,s)=>{s.d(t,{OA:()=>o,_D:()=>n,n:()=>r});var i=s(17085),a=s(7430);function n(e){return(t,s)=>{const n=(0,a.WR)(s());return t(i.BX(n,!0,e))}}function r(){return(e,t)=>{const s=(0,a.WR)(t());return e(i.BX(s,!1))}}function o(){return(e,t)=>{const s=(0,a.WR)(t());return e(i.OA(s))}}},61544:(e,t,s)=>{s.r(t),s.d(t,{default:()=>p});var i=s(23453),a=s(7380),n=(s(4290),s(97023)),r=s.n(n),o=s(14778),l=s(78451),c=s(19513),d=s(85873);function u(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class m extends r().PureComponent{constructor(e){super(e),u(this,"handleClick",((e,t)=>{var s;t.preventDefault(),this.props.updateTab(e.name),null===(s=t.target.closest(".settings-modal"))||void 0===s||s.classList.add("display--content")})),u(this,"handleKeyUp",((e,t)=>{(0,c.e)(t,l.Ay.KeyCodes.UP)?e>0&&(this.props.updateTab(this.props.tabs[e-1].name),(0,d.b6)(this.buttonRefs[e-1].current)):(0,c.e)(t,l.Ay.KeyCodes.DOWN)&&e<this.props.tabs.length-1&&(this.props.updateTab(this.props.tabs[e+1].name),(0,d.b6)(this.buttonRefs[e+1].current))})),this.buttonRefs=this.props.tabs.map((()=>r().createRef()))}renderTab(e,t){const s="".concat(e.name,"_li"),i=this.props.activeTab===e.name;let a,n="";return i&&(n="active"),a="string"==typeof e.icon?r().createElement("i",{className:e.icon,title:e.iconTitle}):r().createElement("img",{src:e.icon.url,alt:e.iconTitle,className:"icon"}),r().createElement("li",{id:"".concat(e.name,"Li"),key:s,className:n,role:"presentation"},r().createElement("button",{ref:this.buttonRefs[t],id:"".concat(e.name,"Button"),className:"cursor--pointer style--none",onClick:this.handleClick.bind(null,e),onKeyUp:this.handleKeyUp.bind(null,t),"aria-label":e.uiName.toLowerCase(),role:"tab","aria-selected":i,tabIndex:i||this.props.isMobileView?0:-1},a,e.uiName))}render(){var e;const t=this.props.tabs.map(((e,t)=>this.renderTab(e,t)));let s;return null!==(e=this.props.pluginTabs)&&void 0!==e&&e.length&&(s=r().createElement(r().Fragment,null,r().createElement("hr",null),r().createElement("li",{key:"plugin preferences heading",role:"heading",className:"header"},r().createElement(o.FormattedMessage,{id:"userSettingsModal.pluginPreferences.header",defaultMessage:"PLUGIN PREFERENCES"})),this.props.pluginTabs.map(((e,t)=>this.renderTab(e,t))))),r().createElement("div",null,r().createElement("ul",{id:"tabList",className:"nav nav-pills nav-stacked",role:"tablist","aria-orientation":"vertical"},t,s))}}const p=(0,i.connect)((function(e){return{isMobileView:(0,a.w3)(e)}}))(m)},75977:(e,t,s)=>{s.r(t),s.d(t,{default:()=>Ui});var i=s(62688),a=s.n(i),n=(s(12401),s(4290),s(97023)),r=s.n(n),o=s(34529),l=s(51565),c=s.n(l),d=s(14778),u=s(17461),m=s(61544),p=(s(10844),s(23453)),h=s(52602),g=s(35631),f=s(17085),E=s(26614),v=s(77440),b=s(7430),S=s(78451),y=(s(43813),s(91767)),M=(s(17046),s(71633)),N=s.n(M),A=s(12026),T=s(85873);function _(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class C extends r().PureComponent{constructor(){super(...arguments),_(this,"edit",null),_(this,"getEdit",(e=>{this.edit=e})),_(this,"handleClick",(e=>{this.props.isDisabled||(e.preventDefault(),this.props.updateSection(this.props.section))}))}focus(){(0,T.b6)(this.edit)}render(){let e;return e=this.props.isDisabled?this.props.collapsedEditButtonWhenDisabled?this.props.collapsedEditButtonWhenDisabled:null:r().createElement("button",{ref:this.getEdit,id:this.props.section+"Edit",className:"color--link style--none section-min__edit",onClick:this.handleClick,"aria-labelledby":this.props.section+"Title "+this.props.section+"Edit","aria-expanded":!1},r().createElement(A.A,null),r().createElement(d.FormattedMessage,{id:"setting_item_min.edit",defaultMessage:"Edit"})),r().createElement("div",{className:N()("section-min",{isDisabled:this.props.isDisabled}),onClick:this.handleClick},r().createElement("div",{className:"secion-min__header"},r().createElement("h4",{id:this.props.section+"Title",className:N()("section-min__title",{isDisabled:this.props.isDisabled})},this.props.title),e),r().createElement("div",{id:this.props.section+"Desc",className:N()("section-min__describe",{isDisabled:this.props.isDisabled})},this.props.describe))}}_(C,"propTypes",{title:a().node.isRequired,isDisabled:a().bool,section:a().string.isRequired,updateSection:a().func.isRequired,describe:a().node,collapsedEditButtonWhenDisabled:a().node});var k=s(59171);const w=e=>{let{active:t,areAllSectionsInactive:s,section:i,max:a,updateSection:o,title:l,isDisabled:c,describe:d,collapsedEditButtonWhenDisabled:u}=e;const m=(0,n.useRef)(null);return(0,k.A)((()=>{var e;!t&&s&&(null===(e=m.current)||void 0===e||e.focus())}),[t]),t?r().createElement(r().Fragment,null,a):r().createElement(C,{ref:m,title:l,updateSection:o,describe:d,section:i,isDisabled:c,collapsedEditButtonWhenDisabled:u})};w.propTypes={active:a().bool.isRequired,areAllSectionsInactive:a().bool.isRequired,section:a().string.isRequired,max:a().node,updateSection:a().func.isRequired,title:a().node,isDisabled:a().bool,describe:a().node,collapsedEditButtonWhenDisabled:a().node};const I=r().memo(w);var R=s(14309),P=s(19513);function O(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class D extends r().PureComponent{constructor(e){super(e),O(this,"onKeyDown",(e=>{const t=e.target;this.props.shiftEnter&&(0,P.e)(e,S.Ay.KeyCodes.ENTER)&&e.shiftKey||!0!==this.props.disableEnterSubmit&&(0,P.e)(e,S.Ay.KeyCodes.ENTER)&&this.props.submit&&"SELECT"!==t.tagName&&t.parentElement&&"react-select__input"!==t.parentElement.className&&!t.classList.contains("btn-tertiary")&&this.settingList.current&&this.settingList.current.contains(t)&&this.handleSubmit(e)})),O(this,"handleSubmit",(e=>{e.preventDefault(),this.props.setting&&this.props.submit?this.props.submit(this.props.setting):this.props.submit&&this.props.submit()})),O(this,"handleUpdateSection",(e=>{this.props.updateSection&&this.props.updateSection(this.props.section),e.preventDefault()})),this.settingList=r().createRef()}componentDidMount(){if(this.settingList.current){const e=this.settingList.current.querySelectorAll('.btn:not(.save-button):not(.btn-tertiary), input.form-control, input[type="radio"][checked], input[type="checkbox"], select, textarea, [tabindex]:not([tabindex="-1"])');e.length>0?(0,T.b6)(e[0]):(0,T.b6)(this.settingList.current)}document.addEventListener("keydown",this.onKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.onKeyDown)}render(){let e=null;this.props.clientError&&(e=r().createElement("div",{className:"form-group"},r().createElement("label",{id:"clientError",className:"col-sm-12 has-error"},this.props.clientError)));let t=null;this.props.serverError&&(t=r().createElement("div",{className:"form-group"},r().createElement("label",{id:"serverError",className:"col-sm-12 has-error"},this.props.serverError)));let s=null,i="setting-list__hint";"top"===this.props.infoPosition&&(i="pb-3"),this.props.extraInfo&&(s=r().createElement("div",{id:"extraInfo",className:i},this.props.extraInfo));let a=null;this.props.submit&&(a=r().createElement(R.A,{defaultMessage:this.props.saveButtonText,saving:this.props.saving,disabled:this.props.saving,onClick:this.handleSubmit,btnClass:this.props.saveButtonClassName}));const n=this.props.inputs;let o;this.props.title&&(o=r().createElement("h4",{id:"settingTitle",className:"col-sm-12 section-title"},this.props.title));let l,c=r().createElement("div",{className:"setting-list-item"},n,s);return"top"===this.props.infoPosition&&(c=r().createElement("div",null,s,n)),l=this.props.cancelButtonText?this.props.cancelButtonText:r().createElement(d.FormattedMessage,{id:"setting_item_max.cancel",defaultMessage:"Cancel"}),r().createElement("section",{className:"section-max form-horizontal ".concat(this.props.containerStyle)},o,this.props.extraContentBeforeSettingList,r().createElement("div",{className:N()("sectionContent",{"col-sm-12":this.props.isFullWidth,"col-sm-10 col-sm-offset-2":!this.props.isFullWidth})},r().createElement("div",{tabIndex:-1,ref:this.settingList,className:"setting-list"},c,r().createElement("div",{className:"setting-list-item"},r().createElement("hr",null),this.props.submitExtra,t,e,a,r().createElement("button",{id:"cancelSetting",className:"btn btn-tertiary",onClick:this.handleUpdateSection},l)))))}}O(D,"defaultProps",{infoPosition:"bottom",saving:!1,section:"",containerStyle:""});var F=s(4715),L=s(57898);function x(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class U extends r().PureComponent{constructor(e){super(e),x(this,"handleOnChange",(e=>{const t=e.currentTarget.value;this.setState({joinLeaveState:t}),(0,T.b6)(e.currentTarget)})),x(this,"handleUpdateSection",(e=>{e||this.setState({joinLeaveState:this.props.joinLeave}),this.props.onUpdateSection(e)})),x(this,"handleSubmit",(()=>{const{actions:e,userId:t,onUpdateSection:s}=this.props,i={category:L.pm.CATEGORY_ADVANCED_SETTINGS,user_id:t,name:L.pm.ADVANCED_FILTER_JOIN_LEAVE,value:this.state.joinLeaveState};e.savePreferences(t,[i]),s()})),this.state={joinLeaveState:e.joinLeave},this.minRef=r().createRef()}focusEditButton(){var e;null===(e=this.minRef.current)||void 0===e||e.focus()}componentDidUpdate(e){e.active&&!this.props.active&&this.props.areAllSectionsInactive&&this.focusEditButton()}render(){const{joinLeaveState:e}=this.state;return this.props.active?r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.joinLeaveTitle",defaultMessage:"Enable Join/Leave Messages"}),inputs:[r().createElement("fieldset",{key:"joinLeaveSetting"},r().createElement("legend",{className:"form-legend hidden-label"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.joinLeaveTitle",defaultMessage:"Enable Join/Leave Messages"})),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"joinLeaveOn",type:"radio",value:"true",name:S.bo.JOIN_LEAVE,checked:"true"===e,onChange:this.handleOnChange}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.on",defaultMessage:"On"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"joinLeaveOff",type:"radio",value:"false",name:S.bo.JOIN_LEAVE,checked:"false"===e,onChange:this.handleOnChange}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.off",defaultMessage:"Off"})),r().createElement("br",null)),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.joinLeaveDesc",defaultMessage:'When "On", System Messages saying a user has joined or left a channel will be visible. When "Off", the System Messages about joining or leaving a channel will be hidden. A message will still show up when you are added to a channel, so you can receive a notification.'})))],setting:S.bo.JOIN_LEAVE,submit:this.handleSubmit,saving:this.state.isSaving,serverError:this.state.serverError,updateSection:this.handleUpdateSection}):r().createElement(C,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.joinLeaveTitle",defaultMessage:"Enable Join/Leave Messages"}),describe:this.props.renderOnOffLabel(e),section:S.bo.JOIN_LEAVE,updateSection:this.handleUpdateSection,ref:this.minRef})}}const B=(0,p.connect)((function(e,t){const s="true"===(0,E.zj)(e).EnableJoinLeaveMessageByDefault,i=t.adminMode&&t.userPreferences?t.userPreferences:void 0;return{userId:t.adminMode?t.userId:(0,b.WR)(e),joinLeave:(0,v.Jt)(e,L.pm.CATEGORY_ADVANCED_SETTINGS,L.pm.ADVANCED_FILTER_JOIN_LEAVE,s.toString(),i)}}),(function(e){return{actions:(0,h.bindActionCreators)({savePreferences:g.SF},e)}}))(U);function j(e){const t=(0,n.useRef)(null),s=(0,n.useRef)(!1);if((0,n.useEffect)((()=>{var i;s.current&&!e.active&&e.areAllSectionsInactive&&(null===(i=t.current)||void 0===i||i.focus())})),(0,n.useEffect)((()=>{s.current=e.active}),[e.active]),!e.performanceDebuggingEnabled)return null;let i;return i=e.active?r().createElement(G,e):r().createElement(q,Object.assign({},e,{ref:t})),r().createElement(r().Fragment,null,i,r().createElement("div",{className:"divider-light"}))}s(29206),j.propTypes={adminMode:a().bool,userId:a().string.isRequired,active:a().bool.isRequired,areAllSectionsInactive:a().bool.isRequired,onUpdateSection:a().func.isRequired};const q=r().forwardRef(((e,t)=>{let s,i=0;return e.disableClientPlugins&&(i+=1),e.disableTelemetry&&(i+=1),e.disableTypingMessages&&(i+=1),s=0===i?r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.noneEnabled",defaultMessage:"No settings enabled"}):r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.settingsEnabled",defaultMessage:"{count, number} {count, plural, one {setting} other {settings}} enabled",values:{count:i}}),r().createElement(C,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.title",defaultMessage:"Performance Debugging"}),describe:s,section:S.bo.PERFORMANCE_DEBUGGING,updateSection:e.onUpdateSection,ref:t})}));function G(e){const[t,s]=(0,n.useState)(e.disableClientPlugins),[i,a]=(0,n.useState)(e.disableTelemetry),[o,l]=(0,n.useState)(e.disableTypingMessages),c=(0,n.useCallback)((()=>{if(!e.userId)return;const s=[];t!==e.disableClientPlugins&&s.push({user_id:e.userId,category:L.pm.CATEGORY_PERFORMANCE_DEBUGGING,name:L.pm.NAME_DISABLE_CLIENT_PLUGINS,value:t.toString()}),i!==e.disableTelemetry&&s.push({user_id:e.userId,category:L.pm.CATEGORY_PERFORMANCE_DEBUGGING,name:L.pm.NAME_DISABLE_TELEMETRY,value:i.toString()}),o!==e.disableTypingMessages&&s.push({user_id:e.userId,category:L.pm.CATEGORY_PERFORMANCE_DEBUGGING,name:L.pm.NAME_DISABLE_TYPING_MESSAGES,value:o.toString()}),0!==s.length&&e.userId&&e.savePreferences(e.userId,s),e.onUpdateSection("")}),[e.userId,e.onUpdateSection,e.savePreferences,t,i,o]);return r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.title",defaultMessage:"Performance Debugging"}),inputs:[r().createElement("fieldset",{key:"settings"},r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:t,onChange:e=>{s(e.target.checked)}}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.disableClientPlugins",defaultMessage:"Disable Client-side Plugins"}))),r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:i,onChange:e=>{a(e.target.checked)}}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.disableTelemetry",defaultMessage:"Disable telemetry events sent from the client"}))),r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:o,onChange:e=>{l(e.target.checked)}}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.disableTypingMessages",defaultMessage:'Disable "User is typing..." messages'}))),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.info1",defaultMessage:"You may enable these settings temporarily to help isolate performance issues while debugging. We don't recommend leaving these settings enabled for an extended period of time as they can negatively impact your user experience."}),r().createElement("br",null),r().createElement("br",null),r().createElement(d.FormattedMessage,{id:"user.settings.advance.performance.info2",defaultMessage:"You may need to refresh the page before these settings take effect."})))],submit:c,updateSection:e.onUpdateSection})}q.propTypes={adminMode:a().bool,userId:a().string.isRequired,active:a().bool.isRequired,areAllSectionsInactive:a().bool.isRequired,onUpdateSection:a().func.isRequired},G.propTypes={adminMode:a().bool,userId:a().string.isRequired,active:a().bool.isRequired,areAllSectionsInactive:a().bool.isRequired,onUpdateSection:a().func.isRequired};const W={savePreferences:g.SF},Y=(0,p.connect)((function(e,t){const s=t.adminMode&&t.userId?(0,v.oE)(e,t.userId):void 0;return{userId:t.adminMode?t.userId:(0,b.WR)(e),disableClientPlugins:(0,v.Jz)(e,L.pm.CATEGORY_PERFORMANCE_DEBUGGING,L.pm.NAME_DISABLE_CLIENT_PLUGINS,void 0,s),disableTelemetry:(0,v.Jz)(e,L.pm.CATEGORY_PERFORMANCE_DEBUGGING,L.pm.NAME_DISABLE_TELEMETRY,void 0,s),disableTypingMessages:(0,v.Jz)(e,L.pm.CATEGORY_PERFORMANCE_DEBUGGING,L.pm.NAME_DISABLE_TYPING_MESSAGES,void 0,s),performanceDebuggingEnabled:(0,E.iy)(e)}}),W)(j);function H(e){return r().createElement("div",{className:"userSettingDesktopHeader"},r().createElement("h3",{id:e.id,className:"tab-header"},e.text),e.info&&r().createElement("div",{className:"userSettingDesktopHeaderInfo"},e.info))}H.propTypes={id:a().string,text:a().node.isRequired,info:a().node};const V=e=>{let{text:t,closeModal:s,collapseModal:i}=e;const a=(0,d.useIntl)();return r().createElement("div",{className:"modal-header"},r().createElement("button",{id:"closeButton",type:"button",className:"close","data-dismiss":"modal",onClick:s},r().createElement("span",{"aria-hidden":"true"},"×")),r().createElement("h4",{className:"modal-title"},r().createElement("div",{className:"modal-back"},r().createElement("i",{className:"fa fa-angle-left","aria-label":a.formatMessage({id:"generic_icons.collapse",defaultMessage:"Collapse Icon"}),onClick:i})),t))};V.propTypes={text:a().node.isRequired,closeModal:a().func.isRequired,collapseModal:a().func.isRequired};const K=V;function z(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function J(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?z(Object(s),!0).forEach((function(t){$(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):z(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function $(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class X extends r().PureComponent{constructor(e){super(e),$(this,"getStateFromProps",(()=>({settings:{send_on_ctrl_enter:this.props.sendOnCtrlEnter,code_block_ctrl_enter:this.props.codeBlockOnCtrlEnter,formatting:this.props.formatting,join_leave:this.props.joinLeave,sync_drafts:this.props.syncDrafts,[S.pm.UNREAD_SCROLL_POSITION]:this.props.unreadScrollPosition},isSaving:!1,showDeactivateAccountModal:!1,serverError:""}))),$(this,"updateSetting",((e,t,s)=>{const i=this.state.settings;i[e]=t,this.setState((e=>J(J({},e),i))),(0,T.b6)(null==s?void 0:s.currentTarget)})),$(this,"handleSubmit",(async e=>{if(!this.props.user)return;const t=[],{actions:s,user:i}=this.props,a=i.id;(Array.isArray(e)?e:[e]).forEach((e=>{t.push({user_id:a,category:S.Ay.Preferences.CATEGORY_ADVANCED_SETTINGS,name:e,value:this.state.settings[e]})})),this.setState({isSaving:!0}),await s.savePreferences(a,t),this.handleUpdateSection("")})),$(this,"handleDeactivateAccountSubmit",(async()=>{const e=this.props.user.id;this.setState({isSaving:!0}),this.props.actions.updateUserActive(e,!1).then((e=>{let{error:t}=e;t&&this.setState({serverError:t.message})}));const{data:t,error:s}=await this.props.actions.revokeAllSessionsForUser(e);t?(0,y.BN)():s&&this.setState({serverError:s.message})})),$(this,"handleShowDeactivateAccountModal",(()=>{this.setState({showDeactivateAccountModal:!0})})),$(this,"handleHideDeactivateAccountModal",(()=>{this.setState({showDeactivateAccountModal:!1})})),$(this,"handleUpdateSection",(e=>{e||this.setState(this.getStateFromProps()),this.setState({isSaving:!1}),this.props.updateSection(e)})),$(this,"getCtrlSendText",(()=>{const e=(0,d.defineMessages)({default:{id:"user.settings.advance.sendDesc",defaultMessage:"When enabled, CTRL + ENTER will send the message and ENTER inserts a new line."},mac:{id:"user.settings.advance.sendDesc.mac",defaultMessage:"When enabled, ⌘ + ENTER will send the message and ENTER inserts a new line."}}),t=(0,d.defineMessages)({default:{id:"user.settings.advance.sendTitle",defaultMessage:"Send Messages on CTRL+ENTER"},mac:{id:"user.settings.advance.sendTitle.mac",defaultMessage:"Send Messages on ⌘+ENTER"}});return(0,F.cX)()?{ctrlSendTitle:t.mac,ctrlSendDesc:e.mac}:{ctrlSendTitle:t.default,ctrlSendDesc:e.default}})),$(this,"renderFormattingSection",(()=>{const e="formatting"===this.props.activeSection;let t=null;return e&&(t=r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.formattingTitle",defaultMessage:"Enable Post Formatting"}),inputs:[r().createElement("fieldset",{key:"formattingSetting"},r().createElement("legend",{className:"form-legend hidden-label"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.formattingTitle",defaultMessage:"Enable Post Formatting"})),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"postFormattingOn",type:"radio",name:"formatting",checked:"false"!==this.state.settings.formatting,onChange:this.updateSetting.bind(this,"formatting","true")}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.on",defaultMessage:"On"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"postFormattingOff",type:"radio",name:"formatting",checked:"false"===this.state.settings.formatting,onChange:this.updateSetting.bind(this,"formatting","false")}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.off",defaultMessage:"Off"})),r().createElement("br",null)),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.formattingDesc",defaultMessage:"If enabled, posts will be formatted to create links, show emoji, style the text, and add line breaks. By default, this setting is enabled."})))],submit:this.handleSubmit.bind(this,["formatting"]),saving:this.state.isSaving,serverError:this.state.serverError,updateSection:this.handleUpdateSection})),r().createElement(I,{active:e,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.formattingTitle",defaultMessage:"Enable Post Formatting"}),describe:this.renderOnOffLabel(this.state.settings.formatting),section:"formatting",updateSection:this.handleUpdateSection,max:t})})),$(this,"renderUnreadScrollPositionSection",(()=>{const e=this.props.activeSection===S.pm.UNREAD_SCROLL_POSITION;let t=null;return e&&(t=r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.unreadScrollPositionTitle",defaultMessage:"Scroll position when viewing an unread channel"}),inputs:[r().createElement("fieldset",{key:"unreadScrollPositionSetting"},r().createElement("legend",{className:"form-legend hidden-label"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.unreadScrollPositionTitle",defaultMessage:"Scroll position when viewing an unread channel"})),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"unreadPositionStartFromLeftOff",type:"radio",name:"unreadScrollPosition",checked:this.state.settings.unread_scroll_position===S.pm.UNREAD_SCROLL_POSITION_START_FROM_LEFT,onChange:this.updateSetting.bind(this,S.pm.UNREAD_SCROLL_POSITION,S.pm.UNREAD_SCROLL_POSITION_START_FROM_LEFT)}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.startFromLeftOff",defaultMessage:"Start me where I left off"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"unreadPositionStartFromNewest",type:"radio",name:"unreadScrollPosition",checked:this.state.settings.unread_scroll_position===S.pm.UNREAD_SCROLL_POSITION_START_FROM_NEWEST,onChange:this.updateSetting.bind(this,S.pm.UNREAD_SCROLL_POSITION,S.pm.UNREAD_SCROLL_POSITION_START_FROM_NEWEST)}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.startFromNewest",defaultMessage:"Start me at the newest message"})),r().createElement("br",null)),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.unreadScrollPositionDesc",defaultMessage:"Choose your scroll position when you view an unread channel. Channels will always be marked as read when viewed."})))],submit:this.handleSubmit.bind(this,[S.pm.UNREAD_SCROLL_POSITION]),saving:this.state.isSaving,serverError:this.state.serverError,updateSection:this.handleUpdateSection})),r().createElement(I,{active:e,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.unreadScrollPositionTitle",defaultMessage:"Scroll position when viewing an unread channel"}),describe:this.renderUnreadScrollPositionLabel(this.state.settings[S.pm.UNREAD_SCROLL_POSITION]),section:S.pm.UNREAD_SCROLL_POSITION,updateSection:this.handleUpdateSection,max:t})})),$(this,"renderSyncDraftsSection",(()=>{const e=this.props.activeSection===S.bo.SYNC_DRAFTS;let t=null;return e&&(t=r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.syncDrafts.Title",defaultMessage:"Allow message drafts to sync with the server"}),inputs:[r().createElement("fieldset",{key:"syncDraftsSetting"},r().createElement("legend",{className:"form-legend hidden-label"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.syncDrafts.Title",defaultMessage:"Allow message drafts to sync with the server"})),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"syncDraftsOn",type:"radio",name:"syncDrafts",checked:"false"!==this.state.settings.sync_drafts,onChange:this.updateSetting.bind(this,"sync_drafts","true")}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.on",defaultMessage:"On"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"syncDraftsOff",type:"radio",name:"syncDrafts",checked:"false"===this.state.settings.sync_drafts,onChange:this.updateSetting.bind(this,"sync_drafts","false")}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.off",defaultMessage:"Off"})),r().createElement("br",null)),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.advance.syncDrafts.Desc",defaultMessage:"When enabled, message drafts are synced with the server so they can be accessed from any device. When disabled, message drafts are only saved locally on the device where they are composed."})))],setting:S.bo.SYNC_DRAFTS,submit:this.handleSubmit.bind(this,["sync_drafts"]),saving:this.state.isSaving,serverError:this.state.serverError,updateSection:this.handleUpdateSection})),r().createElement(I,{active:e,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.syncDrafts.Title",defaultMessage:"Allow message drafts to sync with the server"}),describe:this.renderOnOffLabel(this.state.settings.sync_drafts),section:S.bo.SYNC_DRAFTS,updateSection:this.handleUpdateSection,max:t})})),$(this,"renderCtrlSendSection",(()=>{const e="advancedCtrlSend"===this.props.activeSection,t=this.state.serverError||null,{ctrlSendTitle:s,ctrlSendDesc:i}=this.getCtrlSendText();let a=null;if(e){const e=["true"===this.state.settings.send_on_ctrl_enter,"false"===this.state.settings.send_on_ctrl_enter&&"true"===this.state.settings.code_block_ctrl_enter,"false"===this.state.settings.send_on_ctrl_enter&&"false"===this.state.settings.code_block_ctrl_enter],n=[r().createElement("fieldset",{key:"ctrlSendSetting"},r().createElement("legend",{className:"form-legend hidden-label"},r().createElement(d.FormattedMessage,s)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"ctrlSendOn",type:"radio",name:"sendOnCtrlEnter",checked:e[0],onChange:e=>{this.updateSetting("send_on_ctrl_enter","true"),this.updateSetting("code_block_ctrl_enter","true"),(0,T.b6)(e.currentTarget)}}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.onForAllMessages",defaultMessage:"On for all messages"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"ctrlSendOnForCode",type:"radio",name:"sendOnCtrlEnter",checked:e[1],onChange:e=>{this.updateSetting("send_on_ctrl_enter","false"),this.updateSetting("code_block_ctrl_enter","true"),(0,T.b6)(e.currentTarget)}}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.onForCode",defaultMessage:"On only for code blocks starting with ```"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"ctrlSendOff",type:"radio",name:"sendOnCtrlEnter",checked:e[2],onChange:e=>{this.updateSetting("send_on_ctrl_enter","false"),this.updateSetting("code_block_ctrl_enter","false"),(0,T.b6)(e.currentTarget)}}),r().createElement(d.FormattedMessage,{id:"user.settings.advance.off",defaultMessage:"Off"})),r().createElement("br",null)),r().createElement("div",null,r().createElement("br",null),r().createElement(d.FormattedMessage,i)))];a=r().createElement(D,{title:r().createElement(d.FormattedMessage,s),inputs:n,submit:this.handleSubmit.bind(this,["send_on_ctrl_enter","code_block_ctrl_enter"]),saving:this.state.isSaving,serverError:t,updateSection:this.handleUpdateSection})}return r().createElement(I,{active:e,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,s),describe:this.renderCtrlEnterLabel(),section:"advancedCtrlSend",updateSection:this.handleUpdateSection,max:a})})),this.state=this.getStateFromProps()}renderOnOffLabel(e){return"false"===e?r().createElement(d.FormattedMessage,{id:"user.settings.advance.off",defaultMessage:"Off"}):r().createElement(d.FormattedMessage,{id:"user.settings.advance.on",defaultMessage:"On"})}renderUnreadScrollPositionLabel(e){return e===S.pm.UNREAD_SCROLL_POSITION_START_FROM_LEFT?r().createElement(d.FormattedMessage,{id:"user.settings.advance.startFromLeftOff",defaultMessage:"Start me where I left off"}):r().createElement(d.FormattedMessage,{id:"user.settings.advance.startFromNewest",defaultMessage:"Start me at the newest message"})}renderCtrlEnterLabel(){const e=this.state.settings.send_on_ctrl_enter,t=this.state.settings.code_block_ctrl_enter;return"false"===e&&"false"===t?r().createElement(d.FormattedMessage,{id:"user.settings.advance.off",defaultMessage:"Off"}):"true"===e&&"true"===t?r().createElement(d.FormattedMessage,{id:"user.settings.advance.onForAllMessages",defaultMessage:"On for all messages"}):r().createElement(d.FormattedMessage,{id:"user.settings.advance.onForCode",defaultMessage:"On only for code blocks starting with ```"})}render(){const e=this.renderCtrlSendSection(),t=this.renderFormattingSection();let s=null;t&&(s=r().createElement("div",{className:"divider-light"}));let i="",a="";if(""===this.props.user.auth_service&&this.props.enableUserDeactivation&&!this.props.adminMode){const e="deactivateAccount"===this.props.activeSection;let t=null;e&&(t=r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.deactivateAccountTitle",defaultMessage:"Deactivate Account"}),inputs:[r().createElement("div",{key:"formattingSetting"},r().createElement("div",null,r().createElement("br",null),r().createElement(d.FormattedMessage,{id:"user.settings.advance.deactivateDesc",defaultMessage:"Deactivating your account removes your ability to log in to this server and disables all email and mobile notifications. To reactivate your account, contact your System Administrator."})))],saveButtonText:"Deactivate",saveButtonClassName:"btn-danger",setting:"deactivateAccount",submit:this.handleShowDeactivateAccountModal,saving:this.state.isSaving,serverError:this.state.serverError,updateSection:this.handleUpdateSection})),i=r().createElement(I,{active:e,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.deactivateAccountTitle",defaultMessage:"Deactivate Account"}),describe:r().createElement(d.FormattedMessage,{id:"user.settings.advance.deactivateDescShort",defaultMessage:"Click 'Edit' to deactivate your account"}),section:"deactivateAccount",updateSection:this.handleUpdateSection,max:t});const s="btn btn-danger",n=r().createElement(d.FormattedMessage,{id:"user.settings.advance.deactivate_member_modal.deactivateButton",defaultMessage:"Yes, deactivate my account"});a=r().createElement(u.A,{show:this.state.showDeactivateAccountModal,title:r().createElement(d.FormattedMessage,{id:"user.settings.advance.confirmDeactivateAccountTitle",defaultMessage:"Confirm Deactivation"}),message:r().createElement(d.FormattedMessage,{id:"user.settings.advance.confirmDeactivateDesc",defaultMessage:"Are you sure you want to deactivate your account? This can only be reversed by your System Administrator."}),confirmButtonClass:s,confirmButtonText:n,onConfirm:this.handleDeactivateAccountSubmit,onCancel:this.handleHideDeactivateAccountModal})}const n=this.renderUnreadScrollPositionSection();let o=null;n&&(o=r().createElement("div",{className:"divider-light"}));let l=null,c=null;return this.props.syncedDraftsAreAllowed&&(l=this.renderSyncDraftsSection(),l&&(c=r().createElement("div",{className:"divider-light"}))),r().createElement("div",null,r().createElement(K,{closeModal:this.props.closeModal,collapseModal:this.props.collapseModal,text:r().createElement(d.FormattedMessage,{id:"user.settings.advance.title",defaultMessage:"Advanced Settings"})}),r().createElement("div",{className:"user-settings"},r().createElement(H,{text:r().createElement(d.FormattedMessage,{id:"user.settings.advance.title",defaultMessage:"Advanced Settings"})}),r().createElement("div",{className:"divider-dark first"}),e,s,t,r().createElement("div",{className:"divider-light"}),r().createElement(B,{active:this.props.activeSection===S.bo.JOIN_LEAVE,areAllSectionsInactive:""===this.props.activeSection,onUpdateSection:this.handleUpdateSection,renderOnOffLabel:this.renderOnOffLabel,adminMode:this.props.adminMode,userPreferences:this.props.userPreferences,userId:this.props.user.id}),r().createElement(Y,{active:this.props.activeSection===S.bo.PERFORMANCE_DEBUGGING,onUpdateSection:this.handleUpdateSection,areAllSectionsInactive:""===this.props.activeSection,adminMode:this.props.adminMode,userId:this.props.user.id}),o,n,c,l,s,i,r().createElement("div",{className:"divider-dark"}),a))}}const Q=(0,v.dI)("getAdvancedSettingsCategory",S.pm.CATEGORY_ADVANCED_SETTINGS),Z=(0,p.connect)((function(){const e=(0,v.cK)("getAdvancedSettingsCategory",S.pm.CATEGORY_ADVANCED_SETTINGS);return(t,s)=>{const i=(0,E.zj)(t),a="true"===i.EnableUserDeactivation,n="true"===i.EnableJoinLeaveMessageByDefault,r=s.adminMode&&s.userPreferences?s.userPreferences:void 0;return{advancedSettingsCategory:r?e(t,s.user.id):Q(t),sendOnCtrlEnter:(0,v.Jt)(t,S.pm.CATEGORY_ADVANCED_SETTINGS,"send_on_ctrl_enter","false",r),codeBlockOnCtrlEnter:(0,v.Jt)(t,S.pm.CATEGORY_ADVANCED_SETTINGS,"code_block_ctrl_enter","true",r),formatting:(0,v.Jt)(t,S.pm.CATEGORY_ADVANCED_SETTINGS,"formatting","true",r),joinLeave:(0,v.Jt)(t,S.pm.CATEGORY_ADVANCED_SETTINGS,"join_leave",n.toString(),r),syncDrafts:(0,v.Jt)(t,S.pm.CATEGORY_ADVANCED_SETTINGS,"sync_drafts","true",r),user:s.adminMode&&s.user?s.user:(0,b.HW)(t),unreadScrollPosition:(0,v.z0)(t,r),enableUserDeactivation:a,syncedDraftsAreAllowed:(0,v.p2)(t)}}}),(function(e){return{actions:(0,h.bindActionCreators)({savePreferences:g.SF,updateUserActive:f.tS,revokeAllSessionsForUser:f.V_},e)}}))(X);var ee=s(56121),te=s(84407),se=s(90926),ie=s(90239),ae=s(24994),ne=s(90478),re=s(62757),oe=s.n(re),le=s(59671),ce=s(14776),de=s(79751),ue=s(17518),me=s(63324),pe=s(87131),he=s(61295);function ge(e){return r().createElement(r().Fragment,null,r().createElement("label",{className:"custom-label"},e.label),r().createElement(he.A,{id:e.id,value:e.value,onChange:t=>{var s;null===(s=e.onChange)||void 0===s||s.call(e,e.id,t)}}))}function fe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function Ee(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?fe(Object(s),!0).forEach((function(t){ve(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):fe(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function ve(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}ge.propTypes={id:a().string.isRequired,label:a().node.isRequired,value:a().string.isRequired,onChange:a().func};const be=(0,d.defineMessages)({sidebarBg:{id:"user.settings.custom_theme.sidebarBg",defaultMessage:"Sidebar BG"},sidebarText:{id:"user.settings.custom_theme.sidebarText",defaultMessage:"Sidebar Text"},sidebarHeaderBg:{id:"user.settings.custom_theme.sidebarHeaderBg",defaultMessage:"Sidebar Header BG"},sidebarTeamBarBg:{id:"user.settings.custom_theme.sidebarTeamBarBg",defaultMessage:"Team Sidebar BG"},sidebarHeaderTextColor:{id:"user.settings.custom_theme.sidebarHeaderTextColor",defaultMessage:"Sidebar Header Text"},sidebarUnreadText:{id:"user.settings.custom_theme.sidebarUnreadText",defaultMessage:"Sidebar Unread Text"},sidebarTextHoverBg:{id:"user.settings.custom_theme.sidebarTextHoverBg",defaultMessage:"Sidebar Text Hover BG"},sidebarTextActiveBorder:{id:"user.settings.custom_theme.sidebarTextActiveBorder",defaultMessage:"Sidebar Text Active Border"},sidebarTextActiveColor:{id:"user.settings.custom_theme.sidebarTextActiveColor",defaultMessage:"Sidebar Text Active Color"},onlineIndicator:{id:"user.settings.custom_theme.onlineIndicator",defaultMessage:"Online Indicator"},awayIndicator:{id:"user.settings.custom_theme.awayIndicator",defaultMessage:"Away Indicator"},dndIndicator:{id:"user.settings.custom_theme.dndIndicator",defaultMessage:"Do Not Disturb Indicator"},mentionBg:{id:"user.settings.custom_theme.mentionBg",defaultMessage:"Mention Jewel BG"},mentionColor:{id:"user.settings.custom_theme.mentionColor",defaultMessage:"Mention Jewel Text"},centerChannelBg:{id:"user.settings.custom_theme.centerChannelBg",defaultMessage:"Center Channel BG"},centerChannelColor:{id:"user.settings.custom_theme.centerChannelColor",defaultMessage:"Center Channel Text"},newMessageSeparator:{id:"user.settings.custom_theme.newMessageSeparator",defaultMessage:"New Message Separator"},linkColor:{id:"user.settings.custom_theme.linkColor",defaultMessage:"Link Color"},buttonBg:{id:"user.settings.custom_theme.buttonBg",defaultMessage:"Button BG"},buttonColor:{id:"user.settings.custom_theme.buttonColor",defaultMessage:"Button Text"},errorTextColor:{id:"user.settings.custom_theme.errorTextColor",defaultMessage:"Error Text Color"},mentionHighlightBg:{id:"user.settings.custom_theme.mentionHighlightBg",defaultMessage:"Mention Highlight BG"},mentionHighlightLink:{id:"user.settings.custom_theme.mentionHighlightLink",defaultMessage:"Mention Highlight Link"},codeTheme:{id:"user.settings.custom_theme.codeTheme",defaultMessage:"Code Theme"}});class Se extends r().PureComponent{constructor(e){super(e),ve(this,"handleColorChange",((e,t)=>{const{updateTheme:s,theme:i}=this.props;if(i[e]!==t){const a=Ee(Ee({},i),{},{type:"custom",[e]:t});"mentionBg"===e&&(a.mentionBj=t),s(a);const n=this.setCopyTheme(a);this.setState({copyTheme:n})}})),ve(this,"pasteBoxChange",(e=>{let t,s="";if(s=window.clipboardData&&window.clipboardData.getData?window.clipboardData.getData("Text"):e.clipboardData.getData("Text"),0!==s.length){try{t=JSON.parse(s)}catch(e){return}t=(0,me._1)(t),this.setState({copyTheme:JSON.stringify(t)}),t.type="custom",this.props.updateTheme(t)}})),ve(this,"onChangeHandle",(e=>e.stopPropagation())),ve(this,"selectTheme",(()=>{var e,t;null===(e=this.textareaRef.current)||void 0===e||e.focus(),null===(t=this.textareaRef.current)||void 0===t||t.setSelectionRange(0,this.state.copyTheme.length)})),ve(this,"toggleSidebarStyles",(e=>{var t;e.preventDefault(),null===(t=this.sidebarStylesHeaderRef.current)||void 0===t||t.classList.toggle("open"),this.toggleSection(this.sidebarStylesRef.current)})),ve(this,"toggleCenterChannelStyles",(e=>{var t;e.preventDefault(),null===(t=this.centerChannelStylesHeaderRef.current)||void 0===t||t.classList.toggle("open"),this.toggleSection(this.centerChannelStylesRef.current)})),ve(this,"toggleLinkAndButtonStyles",(e=>{var t;e.preventDefault(),null===(t=this.linkAndButtonStylesHeaderRef.current)||void 0===t||t.classList.toggle("open"),this.toggleSection(this.linkAndButtonStylesRef.current)})),ve(this,"onCodeThemeChange",(e=>{const t=Ee(Ee({},this.props.theme),{},{type:"custom",codeTheme:e.target.value});this.props.updateTheme(t)})),ve(this,"copyTheme",(()=>{this.selectTheme(),document.execCommand("copy"),this.showCopySuccess()})),ve(this,"showCopySuccess",(()=>{const e=document.querySelector(".copy-theme-success");e&&(e.style.display="inline-block",setTimeout((()=>{e.style.display="none"}),3e3))})),this.textareaRef=(0,n.createRef)(),this.sidebarStylesHeaderRef=(0,n.createRef)(),this.centerChannelStylesHeaderRef=(0,n.createRef)(),this.linkAndButtonStylesHeaderRef=(0,n.createRef)(),this.sidebarStylesRef=(0,n.createRef)(),this.centerChannelStylesRef=(0,n.createRef)(),this.linkAndButtonStylesRef=(0,n.createRef)();const t=this.setCopyTheme(this.props.theme);this.state={copyTheme:t}}setCopyTheme(e){const t=Object.assign({},e);return delete t.type,delete t.image,JSON.stringify(t)}toggleSection(e){e&&(e.classList.toggle("open"),e.ontransitionend=()=>{e.classList.contains("open")?e.style.overflowY="inherit":e.style.overflowY="hidden"})}render(){const{intl:e,theme:t}=this.props,s=[],i=[],a=[];S.Ay.THEME_ELEMENTS.forEach(((e,n)=>{if("codeTheme"===e.id){var o;const s=[];let a="";null===(o=e.themes)||void 0===o||o.forEach(((i,n)=>{i.id===t[e.id]&&(a=i.iconURL),s.push(r().createElement("option",{key:"code-theme-key"+n,value:i.id},i.uiName))})),i.push(r().createElement("div",{className:"col-sm-6 form-group",key:"custom-theme-key"+n},r().createElement("label",{className:"custom-label",htmlFor:"codeThemeSelect"},r().createElement(d.FormattedMessage,be[e.id])),r().createElement("div",{className:"input-group theme-group group--code dropdown",id:e.id},r().createElement("select",{id:"codeThemeSelect",className:"form-control",defaultValue:t[e.id],onChange:this.onCodeThemeChange},s),r().createElement(pe.A,{title:r().createElement("div",{className:"code-popover"},r().createElement("img",{width:"200",alt:"code theme image",src:a}))},r().createElement("span",{className:"input-group-addon"},r().createElement("img",{alt:"code theme image",src:a}))))))}else if("centerChannelElements"===e.group)i.push(r().createElement("div",{className:"col-sm-6 form-group element",key:"custom-theme-key"+n},r().createElement(ge,{id:e.id,label:r().createElement(d.FormattedMessage,be[e.id]),value:t[e.id]||"",onChange:this.handleColorChange})));else if("sidebarElements"===e.group){let i=t[e.id];i||"mentionBg"!==e.id||(i=t.mentionBj),s.push(r().createElement("div",{className:"col-sm-6 form-group element",key:"custom-theme-key"+n},r().createElement(ge,{id:e.id,label:r().createElement(d.FormattedMessage,be[e.id]),value:i||"",onChange:this.handleColorChange})))}else a.push(r().createElement("div",{className:"col-sm-6 form-group element",key:"custom-theme-key"+n},r().createElement(ge,{id:e.id,label:r().createElement(d.FormattedMessage,be[e.id]),value:t[e.id]||"",onChange:this.handleColorChange})))}));const n=r().createElement("div",{className:"col-sm-12"},r().createElement("label",{className:"custom-label",htmlFor:"pasteBox"},r().createElement(d.FormattedMessage,{id:"user.settings.custom_theme.copyPaste",defaultMessage:"Copy to share or paste theme colors here:"})),r().createElement("textarea",{ref:this.textareaRef,className:"form-control",id:"pasteBox",value:this.state.copyTheme,onCopy:this.showCopySuccess,onPaste:this.pasteBoxChange,onChange:this.onChangeHandle,onClick:this.selectTheme}),r().createElement("div",{className:"mt-3"},r().createElement("button",{className:"btn btn-tertiary",onClick:this.copyTheme},r().createElement(d.FormattedMessage,{id:"user.settings.custom_theme.copyThemeColors",defaultMessage:"Copy Theme Colors"})),r().createElement("span",{className:"alert alert-success copy-theme-success",role:"alert",style:{display:"none"}},r().createElement(d.FormattedMessage,{id:"user.settings.custom_theme.copied",defaultMessage:"✔ Copied"}))));return r().createElement("div",{className:"appearance-section pt-2"},r().createElement("div",{className:"theme-elements row"},r().createElement("div",{ref:this.sidebarStylesHeaderRef,id:"sidebarStyles",className:"theme-elements__header",onClick:this.toggleSidebarStyles},r().createElement(d.FormattedMessage,{id:"user.settings.custom_theme.sidebarTitle",defaultMessage:"Sidebar Styles"}),r().createElement("div",{className:"header__icon"},r().createElement("i",{className:"fa fa-plus",title:e.formatMessage({id:"generic_icons.expand",defaultMessage:"Expand Icon"})}),r().createElement("i",{className:"fa fa-minus",title:e.formatMessage({id:"generic_icons.collapse",defaultMessage:"Collapse Icon"})}))),r().createElement("div",{ref:this.sidebarStylesRef,className:"theme-elements__body"},s)),r().createElement("div",{className:"theme-elements row"},r().createElement("div",{ref:this.centerChannelStylesHeaderRef,id:"centerChannelStyles",className:"theme-elements__header",onClick:this.toggleCenterChannelStyles},r().createElement(d.FormattedMessage,{id:"user.settings.custom_theme.centerChannelTitle",defaultMessage:"Center Channel Styles"}),r().createElement("div",{className:"header__icon"},r().createElement("i",{className:"fa fa-plus",title:e.formatMessage({id:"generic_icons.expand",defaultMessage:"Expand Icon"})}),r().createElement("i",{className:"fa fa-minus",title:e.formatMessage({id:"generic_icons.collapse",defaultMessage:"Collapse Icon"})}))),r().createElement("div",{ref:this.centerChannelStylesRef,id:"centerChannelStyles",className:"theme-elements__body"},i)),r().createElement("div",{className:"theme-elements row"},r().createElement("div",{ref:this.linkAndButtonStylesHeaderRef,id:"linkAndButtonsStyles",className:"theme-elements__header",onClick:this.toggleLinkAndButtonStyles},r().createElement(d.FormattedMessage,{id:"user.settings.custom_theme.linkButtonTitle",defaultMessage:"Link and Button Styles"}),r().createElement("div",{className:"header__icon"},r().createElement("i",{className:"fa fa-plus",title:e.formatMessage({id:"generic_icons.expand",defaultMessage:"Expand Icon"})}),r().createElement("i",{className:"fa fa-minus",title:e.formatMessage({id:"generic_icons.collapse",defaultMessage:"Collapse Icon"})}))),r().createElement("div",{ref:this.linkAndButtonStylesRef,className:"theme-elements__body"},a)),r().createElement("div",{className:"row mt-3"},n))}}const ye=(0,d.injectIntl)(Se);function Me(e){let{themeName:t,themeKey:s,sidebarBg:i="#174AB5",sidebarText:a="#86A1D9",sidebarUnreadText:n="white",onlineIndicator:o="#3DB887",awayIndicator:l="#FFBC1F",dndIndicator:c="#D24B4E",centerChannelColor:d="#E0E1E3",centerChannelBg:u="white",newMessageSeparator:m="#1C58D9",buttonBg:p="#15B7B7"}=e;return r().createElement("svg",{width:"112",height:"86",viewBox:"0 0 112 86",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"".concat(s,"-theme-icon"),role:"img"},r().createElement("title",{id:"".concat(s,"-theme-icon")},"".concat(t," theme icon")),r().createElement("rect",{style:{fill:u},x:"0",y:"0",width:"112",height:"86"}),r().createElement("g",null,r().createElement("rect",{style:{fill:u},x:"50",y:"-1",width:"63",height:"88"}),r().createElement("g",null,r().createElement("rect",{style:{fill:d},x:"55",y:"75",width:"52",height:"6",rx:"3"}),r().createElement("rect",{style:{fill:u},x:"56",y:"76",width:"50",height:"4",rx:"2"})),r().createElement("rect",{style:{fill:p},x:"71",y:"65",width:"22",height:"5",rx:"2.5"}),r().createElement("rect",{style:{fill:m},x:"50",y:"32",width:"62",height:"1"}),r().createElement("g",{style:{fill:d}},r().createElement("rect",{x:"55",y:"5",width:"52",height:"4",rx:"2"}),r().createElement("rect",{x:"55",y:"14",width:"52",height:"4",rx:"2"}),r().createElement("rect",{x:"55",y:"23",width:"52",height:"4",rx:"2"}),r().createElement("rect",{x:"55",y:"38",width:"52",height:"4",rx:"2"}),r().createElement("rect",{x:"55",y:"47",width:"52",height:"4",rx:"2"}),r().createElement("rect",{x:"55",y:"56",width:"52",height:"4",rx:"2"}))),r().createElement("g",null,r().createElement("rect",{style:{fill:i},x:"-1",y:"-1",width:"51",height:"88"}),r().createElement("g",{style:{fill:a}},r().createElement("circle",{cx:"7",cy:"61",r:"2"}),r().createElement("circle",{cx:"7",cy:"70",r:"2"}),r().createElement("circle",{cx:"7",cy:"43",r:"2"}),r().createElement("circle",{cx:"7",cy:"34",r:"2"}),r().createElement("circle",{cx:"7",cy:"16",r:"2"}),r().createElement("circle",{cx:"7",cy:"7",r:"2"}),r().createElement("rect",{x:"11",y:"5",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"14",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"32",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"41",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"50",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"59",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"68",width:"28",height:"4",rx:"2"}),r().createElement("rect",{x:"11",y:"77",width:"28",height:"4",rx:"2"})),r().createElement("circle",{style:{fill:c},cx:"7",cy:"79",r:"2"}),r().createElement("circle",{style:{fill:l},cx:"7",cy:"52",r:"2"}),r().createElement("circle",{style:{fill:o},cx:"7",cy:"25",r:"2"}),r().createElement("g",{style:{fill:n}},r().createElement("circle",{cx:"43",cy:"25",r:"2"}),r().createElement("rect",{x:"11",y:"23",width:"28",height:"4",rx:"2"}))))}s(76685),s(3188),s(59297),Me.propTypes={themeName:a().string,themeKey:a().string.isRequired,sidebarBg:a().string.isRequired,sidebarText:a().string.isRequired,sidebarUnreadText:a().string.isRequired,onlineIndicator:a().string.isRequired,awayIndicator:a().string.isRequired,dndIndicator:a().string.isRequired,centerChannelColor:a().string.isRequired,centerChannelBg:a().string.isRequired,newMessageSeparator:a().string.isRequired,buttonBg:a().string.isRequired};const Ne=Me,Ae=e=>{let{theme:t,updateTheme:s,allowedThemes:i=[]}=e;const a=[],n=i.length>1||i[0]&&i[0].trim().length>0;for(const e in L.pm.THEMES)if(Object.hasOwn(L.pm.THEMES,e)){var o;if(n&&i.indexOf(e)<0)continue;const l=Object.assign({},L.pm.THEMES[e]);let c="";l.type===t.type&&(c="active"),a.push(r().createElement("div",{className:"col-xs-6 col-sm-3 premade-themes",key:"premade-theme-key"+e},r().createElement("div",{id:"premadeTheme".concat(null===(o=l.type)||void 0===o?void 0:o.replace(" ","")),className:c,onClick:()=>s(l)},r().createElement("label",null,r().createElement(Ne,{themeKey:e,themeName:l.type,sidebarBg:l.sidebarBg,sidebarText:(0,me.Q)(l.sidebarText,.48),sidebarUnreadText:l.sidebarUnreadText,onlineIndicator:l.onlineIndicator,awayIndicator:l.awayIndicator,dndIndicator:l.dndIndicator,centerChannelColor:(0,me.Q)(l.centerChannelColor,.16),centerChannelBg:l.centerChannelBg,newMessageSeparator:l.newMessageSeparator,buttonBg:l.buttonBg}),r().createElement("div",{className:"theme-label"},(0,T.Sn)(l.type||""))))))}return r().createElement("div",{className:"row appearance-section"},r().createElement("div",{className:"clearfix"},a))};Ae.propTypes={updateTheme:a().func.isRequired,allowedThemes:a().arrayOf(a().string).isRequired};const Te=Ae,_e=(0,p.connect)((function(e){const t=(0,E.zj)(e);return{allowedThemes:t.AllowedThemes&&t.AllowedThemes.split(",")||[]}}))(Te);function Ce(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function ke(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Ce(Object(s),!0).forEach((function(t){we(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ce(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function we(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Ie extends r().PureComponent{constructor(e){super(e),we(this,"submitTheme",(async()=>{var e,t;const s=this.state.applyToAllTeams?"":this.props.currentTeamId;this.setState({isSaving:!0}),await this.props.actions.saveTheme(s,this.state.theme),this.state.applyToAllTeams&&await this.props.actions.deleteTeamSpecificThemes(),null===(e=(t=this.props).setRequireConfirm)||void 0===e||e.call(t,!1),this.originalTheme=Object.assign({},this.state.theme),this.props.updateSection(""),this.setState({isSaving:!1})})),we(this,"updateTheme",(e=>{var t,s;let i=this.state.theme.length===e.length;if(!i)for(const t in e)if(Object.hasOwn(e,t)&&this.state.theme[t]!==e[t]){i=!0;break}null===(t=(s=this.props).setRequireConfirm)||void 0===t||t.call(s,i),this.setState({theme:e}),(0,T.AZ)(e)})),we(this,"updateType",(e=>this.setState({type:e}))),we(this,"resetFields",(()=>{var e,t;const s=this.getStateFromProps();s.serverError="",this.setState(s),(0,T.AZ)(s.theme),null===(e=(t=this.props).setRequireConfirm)||void 0===e||e.call(t,!1)})),we(this,"handleUpdateSection",(e=>this.props.updateSection(e))),this.state=ke(ke({},this.getStateFromProps(e)),{},{isSaving:!1,serverError:""}),this.originalTheme=Object.assign({},this.state.theme),this.minRef=r().createRef()}componentDidUpdate(e){e.selected&&!this.props.selected&&this.resetFields(),e.selected&&!this.props.selected&&this.props.areAllSectionsInactive&&this.focusEditButton()}componentWillUnmount(){this.props.selected&&(0,T.AZ)(this.props.theme)}getStateFromProps(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props;const t=ke({},e.theme);return t.codeTheme||(t.codeTheme=S.YM.DEFAULT_CODE_THEME),{theme:t,type:t.type||"premade",showAllTeamsCheckbox:e.showAllTeamsCheckbox,applyToAllTeams:e.applyToAllTeams,serverError:"",isSaving:!1}}focusEditButton(){var e;null===(e=this.minRef.current)||void 0===e||e.focus()}render(){let e;this.state.serverError&&(e=this.state.serverError);const t="custom"===this.state.type;let s,i,a;if(t&&this.props.allowCustomThemes?s=r().createElement("div",{key:"customThemeChooser"},r().createElement(ye,{theme:this.state.theme,updateTheme:this.updateTheme})):i=r().createElement("div",{key:"premadeThemeChooser"},r().createElement("br",null),r().createElement(_e,{theme:this.state.theme,updateTheme:this.updateTheme})),this.props.selected){const n=[];this.props.allowCustomThemes&&n.push(r().createElement("div",{className:"radio",key:"premadeThemeColorLabel"},r().createElement("label",null,r().createElement("input",{id:"standardThemes",type:"radio",name:"theme",checked:!t,onChange:this.updateType.bind(this,"premade")}),r().createElement(d.FormattedMessage,{id:"user.settings.display.theme.themeColors",defaultMessage:"Theme Colors"})),r().createElement("br",null))),n.push(i),this.props.allowCustomThemes&&(n.push(r().createElement("div",{className:"radio",key:"customThemeColorLabel"},r().createElement("label",null,r().createElement("input",{id:"customThemes",type:"radio",name:"theme",checked:t,onChange:this.updateType.bind(this,"custom")}),r().createElement(d.FormattedMessage,{id:"user.settings.display.theme.customTheme",defaultMessage:"Custom Theme"})))),n.push(s),n.push(r().createElement("div",{key:"otherThemes"},r().createElement("br",null),r().createElement(ue.A,{id:"otherThemes",href:"http://docs.mattermost.com/help/settings/theme-colors.html#custom-theme-examples",location:"user_settings_theme"},r().createElement(d.FormattedMessage,{id:"user.settings.display.theme.otherThemes",defaultMessage:"See other themes"})))));let o=null;this.state.showAllTeamsCheckbox&&(o=r().createElement("div",{className:"checkbox user-settings__submit-checkbox"},r().createElement("label",null,r().createElement("input",{id:"applyThemeToAllTeams",type:"checkbox",checked:this.state.applyToAllTeams,onChange:e=>this.setState({applyToAllTeams:e.target.checked})}),r().createElement(d.FormattedMessage,{id:"user.settings.display.theme.applyToAllTeams",defaultMessage:"Apply new theme to all my teams"})))),a=r().createElement(D,{inputs:n,submitExtra:o,submit:this.submitTheme,disableEnterSubmit:!0,saving:this.state.isSaving,serverError:e,isFullWidth:!0,updateSection:this.handleUpdateSection})}else a=r().createElement(C,{title:r().createElement(d.FormattedMessage,{id:"user.settings.display.theme.title",defaultMessage:"Theme"}),describe:r().createElement(d.FormattedMessage,{id:"user.settings.display.theme.describe",defaultMessage:"Open to manage your theme"}),section:"theme",updateSection:this.handleUpdateSection,ref:this.minRef});return a}}const Re=(0,p.connect)((function(e){return{currentTeamId:(0,ce.Sy)(e),theme:(0,v.O4)(e),applyToAllTeams:(0,v.m3)(e).length<=1,showAllTeamsCheckbox:(0,ce.aw)(e)>1}}),(function(e){return{actions:(0,h.bindActionCreators)({saveTheme:g.hy,deleteTeamSpecificThemes:g.Hp,openModal:de.q},e)}}))(Ie);var Pe=s(90327),Oe=(s(74883),s(6251));function De(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function Fe(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?De(Object(s),!0).forEach((function(t){Le(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):De(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function Le(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class xe extends r().PureComponent{constructor(e){super(e),Le(this,"handleContainerKeyDown",(e=>{const t=document.querySelector(".modal-body");(0,P.e)(e,S.Ay.KeyCodes.ESCAPE)&&this.state.openMenu&&(null==t||t.classList.remove("no-scroll"),this.setState({openMenu:!1}),e.stopPropagation())})),Le(this,"handleKeyDown",(e=>{const t=document.querySelector(".modal-body");(0,P.e)(e,S.Ay.KeyCodes.ENTER)&&(null==t||t.classList.add("no-scroll"),this.setState({openMenu:!0}))})),Le(this,"setLanguage",(e=>{e&&"value"in e&&this.setState({locale:e.value,selectedOption:e})})),Le(this,"changeLanguage",(()=>{this.props.user.locale===this.state.locale?this.props.updateSection(""):this.submitUser(Fe(Fe({},this.props.user),{},{locale:this.state.locale}))})),Le(this,"submitUser",(e=>{this.setState({isSaving:!0}),(this.props.adminMode?this.props.actions.patchUser:this.props.actions.updateMe)(e).then((e=>{if("data"in e)this.setState({isSaving:!1});else if("error"in e){let t;const{error:s}=e;t=s instanceof Error?s.message:s,this.setState({serverError:t,isSaving:!1})}}))})),Le(this,"handleMenuClose",(()=>{const e=document.querySelector(".modal-body");e&&e.classList.remove("no-scroll"),this.setState({openMenu:!1})})),Le(this,"handleMenuOpen",(()=>{const e=document.querySelector(".modal-body");e&&e.classList.add("no-scroll"),this.setState({openMenu:!0})}));const t=e.locale,s={value:e.locales[t].value,label:e.locales[t].name};this.reactSelectContainer=r().createRef(),this.state={locale:e.locale,selectedOption:s,isSaving:!1,openMenu:!1}}componentDidMount(){const e=this.reactSelectContainer.current;e&&e.addEventListener("keydown",this.handleContainerKeyDown)}componentWillUnmount(){this.reactSelectContainer.current&&this.reactSelectContainer.current.removeEventListener("keydown",this.handleContainerKeyDown)}render(){const{intl:e,locales:t}=this.props;let s;this.state.serverError&&(s=r().createElement("label",{className:"has-error"},this.state.serverError));const i=[];Object.keys(t).map((e=>({value:t[e].value,name:t[e].name,order:t[e].order}))).sort(((e,t)=>e.order-t.order)).forEach((e=>{i.push({value:e.value,label:e.name})}));const a={menuPortal:e=>Fe(Fe({},e),{},{zIndex:9999})},n=e.formatMessage({id:"user.settings.languages.dropdown.arialabel",defaultMessage:"Dropdown selector to change the interface language"}),o=r().createElement("div",{key:"changeLanguage"},r().createElement("br",null),r().createElement("label",{"aria-label":n,className:"control-label",id:"changeInterfaceLanguageLabel",htmlFor:"displayLanguage"},r().createElement(d.FormattedMessage,{id:"user.settings.languages.change",defaultMessage:"Change interface language"})),r().createElement("div",{ref:this.reactSelectContainer,className:"pt-2"},r().createElement(Oe.Ay,{className:"react-select react-select-top",classNamePrefix:"react-select",id:"displayLanguage",menuIsOpen:this.state.openMenu,menuPortalTarget:document.body,styles:a,options:i,clearable:!1,onChange:this.setLanguage,onKeyDown:this.handleKeyDown,value:this.state.selectedOption,onMenuClose:this.handleMenuClose,onMenuOpen:this.handleMenuOpen,"aria-labelledby":"changeInterfaceLanguageLabel"}),s),r().createElement("div",null,r().createElement("br",null),r().createElement(d.FormattedMessage,{id:"user.settings.languages.promote1",defaultMessage:"Select which language Mattermost displays in the user interface."}),r().createElement("p",null),r().createElement(d.FormattedMessage,{id:"user.settings.languages.promote2",defaultMessage:"Would you like to help with translations? Join the <link>Mattermost Translation Server</link> to contribute.",values:{link:e=>r().createElement(ue.A,{href:"http://translate.mattermost.com",location:"manage_languages"},e)}})));return r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.display.language",defaultMessage:"Language"}),submit:this.changeLanguage,saving:this.state.isSaving,inputs:[o],updateSection:this.props.updateSection})}}Le(xe,"propTypes",{locale:a().string.isRequired,updateSection:a().func.isRequired,actions:a().shape({updateMe:a().func.isRequired,patchUser:a().func.isRequired}).isRequired,adminMode:a().bool});const Ue=(0,d.injectIntl)(xe),Be=(0,p.connect)((function(e){return{locales:(0,ne.kG)(e)}}),(function(e){return{actions:(0,h.bindActionCreators)({updateMe:f.Me,patchUser:f.WJ},e)}}))(Ue);function je(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function qe(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?je(Object(s),!0).forEach((function(t){Ge(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):je(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function Ge(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class We extends r().PureComponent{constructor(e){super(e),Ge(this,"onChange",(e=>{e&&"value"in e&&this.setState({manualTimezone:e.value,selectedOption:e})})),Ge(this,"timezoneNotChanged",(()=>{const{useAutomaticTimezone:e,automaticTimezone:t,manualTimezone:s}=this.state,{useAutomaticTimezone:i,automaticTimezone:a,manualTimezone:n}=this.props;return e===i&&t===a&&s===n})),Ge(this,"changeTimezone",(()=>{this.timezoneNotChanged()?this.props.updateSection(""):this.submitUser()})),Ge(this,"submitUser",(()=>{const{user:e}=this.props,{useAutomaticTimezone:t,automaticTimezone:s,manualTimezone:i}=this.state,a={useAutomaticTimezone:t.toString(),automaticTimezone:s,manualTimezone:i},n=qe(qe({},e),{},{timezone:a});(this.props.adminMode?this.props.actions.patchUser:this.props.actions.updateMe)(n).then((e=>{if("data"in e)this.props.updateSection("");else if("error"in e){const{error:t}=e;let s;s=t instanceof Error?t.message:t,this.setState({serverError:s,isSaving:!1})}}))})),Ge(this,"handleAutomaticTimezone",(e=>{const t=e.target.checked;let s,i,a="";t?(a=(0,Pe.C7)(),s=(0,ae.Ug)(this.props.timezones,a),i=a):(s=(0,ae.Ug)(this.props.timezones,(0,Pe.C7)()),i=(0,Pe.C7)(),this.setState({manualTimezone:(0,Pe.C7)()})),this.setState({useAutomaticTimezone:t,automaticTimezone:a,selectedOption:{label:s,value:i}})})),this.state={useAutomaticTimezone:e.useAutomaticTimezone,automaticTimezone:e.automaticTimezone,manualTimezone:e.manualTimezone,isSaving:!1,openMenu:!1,selectedOption:{label:e.timezoneLabel,value:e.useAutomaticTimezone?e.automaticTimezone:e.manualTimezone}}}render(){const{timezones:e}=this.props,{useAutomaticTimezone:t}=this.state;let s,i=0;const a=this.props.timezones.map((e=>{var t;return e.utc[i]===(null===(t=s)||void 0===t?void 0:t.utc[i])?i++:i=0===i?i:0,s=e,{value:e.utc[i],label:e.text}}));let n;this.state.serverError&&(n=r().createElement("label",{className:"has-error"},this.state.serverError));const o=[],l={menuPortal:e=>qe(qe({},e),{},{zIndex:9999})},c=0===e.length,u=r().createElement("div",{className:"checkbox",key:1},r().createElement("label",null,r().createElement("input",{id:"automaticTimezoneInput",type:"checkbox",checked:t,onChange:this.handleAutomaticTimezone,disabled:c}),r().createElement(d.FormattedMessage,{id:"user.settings.timezones.automatic",defaultMessage:"Automatic"}))),m=r().createElement("div",{className:"pt-2",key:2},r().createElement(Oe.Ay,{className:"react-select react-select-top",classNamePrefix:"react-select",id:"displayTimezone",menuPortalTarget:document.body,styles:l,options:a,clearable:!1,onChange:this.onChange,value:this.state.selectedOption,"aria-labelledby":"changeInterfaceTimezoneLabel",isDisabled:t}),n);return o.push(u),o.push(m),o.push(r().createElement("div",{key:3},r().createElement("br",null),r().createElement(d.FormattedMessage,{id:"user.settings.timezones.promote",defaultMessage:"Select the time zone used for timestamps in the user interface and email notifications."}))),r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.display.timezone",defaultMessage:"Timezone"}),containerStyle:"timezone-container",submit:this.changeTimezone,saving:this.state.isSaving,inputs:o,updateSection:this.props.updateSection})}}Ge(We,"propTypes",{updateSection:a().func.isRequired,useAutomaticTimezone:a().bool.isRequired,automaticTimezone:a().string.isRequired,manualTimezone:a().string.isRequired,timezones:a().array.isRequired,timezoneLabel:a().string.isRequired,actions:a().shape({updateMe:a().func.isRequired,patchUser:a().func.isRequired}).isRequired,adminMode:a().bool});const Ye=(0,p.connect)((function(e){const t=(0,ie.nQ)(e);return{timezones:ee,timezoneLabel:t}}),(function(e){return{actions:(0,h.bindActionCreators)({updateMe:f.Me,patchUser:f.WJ},e)}}))(We);function He(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function Ve(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?He(Object(s),!0).forEach((function(t){Ke(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):He(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function Ke(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const ze=S.Ay.Preferences;function Je(e){return{militaryTime:e.militaryTime,teammateNameDisplay:e.teammateNameDisplay,availabilityStatusOnPosts:e.availabilityStatusOnPosts,channelDisplayMode:e.channelDisplayMode,messageDisplay:e.messageDisplay,colorizeUsernames:e.colorizeUsernames,collapseDisplay:e.collapseDisplay,collapsedReplyThreads:e.collapsedReplyThreads,linkPreviewDisplay:e.linkPreviewDisplay,lastActiveDisplay:e.lastActiveDisplay.toString(),oneClickReactionsOnPosts:e.oneClickReactionsOnPosts,clickToReply:e.clickToReply}}class $e extends r().PureComponent{constructor(e){super(e),Ke(this,"submitLastActive",(()=>{const{user:e,actions:t}=this.props,{lastActiveDisplay:s}=this.state,i=Ve(Ve({},e),{},{props:Ve(Ve({},e.props),{},{show_last_active:s})});(this.props.adminMode?t.patchUser:t.updateMe)(i).then((e=>{if("data"in e)this.props.updateSection("");else if("error"in e){const{error:t}=e;let s;s=t instanceof Error?t.message:t,this.setState({serverError:s,isSaving:!1})}}))})),Ke(this,"handleSubmit",(async()=>{const e=this.props.user.id,t={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.USE_MILITARY_TIME,value:this.state.militaryTime},s={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.AVAILABILITY_STATUS_ON_POSTS,value:this.state.availabilityStatusOnPosts},i={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.NAME_NAME_FORMAT,value:this.state.teammateNameDisplay},a={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.CHANNEL_DISPLAY_MODE,value:this.state.channelDisplayMode},n={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.MESSAGE_DISPLAY,value:this.state.messageDisplay},r={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.COLORIZE_USERNAMES,value:this.state.colorizeUsernames},o={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.COLLAPSE_DISPLAY,value:this.state.collapseDisplay},l={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.COLLAPSED_REPLY_THREADS,value:this.state.collapsedReplyThreads},c={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.LINK_PREVIEW_DISPLAY,value:this.state.linkPreviewDisplay},d={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.ONE_CLICK_REACTIONS_ENABLED,value:this.state.oneClickReactionsOnPosts},u={user_id:e,category:ze.CATEGORY_DISPLAY_SETTINGS,name:ze.CLICK_TO_REPLY,value:this.state.clickToReply};this.setState({isSaving:!0});const m=[t,a,n,l,u,o,c,i,s,d,r];this.trackChangeIfNecessary(l,this.props.collapsedReplyThreads),await this.props.actions.savePreferences(e,m),this.updateSection("")})),Ke(this,"handleClockRadio",(e=>{this.setState({militaryTime:e})})),Ke(this,"handleTeammateNameDisplayRadio",(e=>{this.setState({teammateNameDisplay:e})})),Ke(this,"handleAvailabilityStatusRadio",(e=>{this.setState({availabilityStatusOnPosts:e})})),Ke(this,"handleOneClickReactionsRadio",(e=>{this.setState({oneClickReactionsOnPosts:e})})),Ke(this,"handleClickToReplyRadio",(e=>{this.setState({clickToReply:e})})),Ke(this,"updateSection",(e=>{this.updateState(),this.props.updateSection(e)})),Ke(this,"updateState",(()=>{const e=Je(this.props);oe()(e,this.state)||this.setState(e),this.setState({isSaving:!1})})),this.state=Ve(Ve({},Je(e)),{},{isSaving:!1}),this.prevSections={theme:"dummySectionName",clock:"theme",linkpreview:"clock",message_display:"linkpreview",channel_display_mode:"message_display",languages:"channel_display_mode"}}componentDidMount(){const{actions:e,shouldAutoUpdateTimezone:t}=this.props;t&&e.autoUpdateTimezone((0,Pe.C7)())}componentDidUpdate(e){this.props.teammateNameDisplay!==e.teammateNameDisplay&&this.updateState()}trackChangeIfNecessary(e,t){const s={field:"display."+e.name,value:e.value};e.value!==t&&(0,le.sx)("settings","user_settings_update",s)}handleChannelDisplayModeRadio(e){this.setState({channelDisplayMode:e})}handlemessageDisplayRadio(e){this.setState({messageDisplay:e})}handleCollapseRadio(e){this.setState({collapseDisplay:e})}handleCollapseReplyThreadsRadio(e){this.setState({collapsedReplyThreads:e})}handleLastActiveRadio(e){this.setState({lastActiveDisplay:e})}handleLinkPreviewRadio(e){this.setState({linkPreviewDisplay:e})}handleOnChange(e,t){this.setState(Ve({},t)),(0,T.b6)(e.currentTarget)}createSection(e){var t,s;const{section:i,display:a,value:n,title:o,firstOption:l,secondOption:c,thirdOption:u,description:m,disabled:p,onSubmit:h}=e;let g=null,f=h||this.handleSubmit;const E=r().createElement(d.FormattedMessage,{id:l.radionButtonText.label.id,defaultMessage:l.radionButtonText.label.defaultMessage});let v,b;null!==(t=l.radionButtonText.more)&&void 0!==t&&t.id&&(v=": ",b=r().createElement("span",{className:"font-weight--normal"},r().createElement(d.FormattedMessage,{id:l.radionButtonText.more.id,defaultMessage:l.radionButtonText.more.defaultMessage})));const S=r().createElement(d.FormattedMessage,{id:c.radionButtonText.label.id,defaultMessage:c.radionButtonText.label.defaultMessage});let y,M;null!==(s=c.radionButtonText.more)&&void 0!==s&&s.id&&(y=r().createElement("span",{className:"font-weight--normal"},r().createElement(d.FormattedMessage,{id:c.radionButtonText.more.id,defaultMessage:c.radionButtonText.more.defaultMessage}))),u&&(M=r().createElement(d.FormattedMessage,{id:u.radionButtonText.label.id,defaultMessage:u.radionButtonText.label.defaultMessage}));const N=r().createElement(d.FormattedMessage,{id:o.id,defaultMessage:o.defaultMessage}),A=r().createElement(d.FormattedMessage,{id:m.id,defaultMessage:m.defaultMessage}),T=this.props.activeSection===i;let _,C=null;if(T){const e=[!1,!1,!1];let t;n===l.value?(e[0]=!0,t=l.childOption):n===c.value?(e[1]=!0,t=c.childOption):(e[2]=!0,u&&(t=u.childOption));const s=i+"Format",o=i+"UserDisplay",m={[a]:l.value},h={[a]:c.value};let T,_;if(u&&M){const t={[a]:u.value};T=r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:s+"C",type:"radio",name:s,checked:e[2],onChange:e=>this.handleOnChange(e,t)}),M),r().createElement("br",null))}if(t){const e=t.display;_=r().createElement("div",{className:"checkbox"},r().createElement("hr",null),r().createElement("label",null,r().createElement("input",{id:s+"childOption",type:"checkbox",name:t.label.id,checked:"true"===t.value,onChange:t=>{this.handleOnChange(t,{[e]:t.target.checked?"true":"false"})}}),r().createElement(d.FormattedMessage,{id:t.label.id,defaultMessage:t.label.defaultMessage}),v,r().createElement("span",{className:"font-weight--normal"},r().createElement(d.FormattedMessage,{id:t.more.id,defaultMessage:t.more.defaultMessage}))),r().createElement("br",null))}let k=[r().createElement("fieldset",{key:o},r().createElement("legend",{className:"form-legend hidden-label"},N),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:s+"A",type:"radio",name:s,checked:e[0],onChange:e=>this.handleOnChange(e,m)}),E,v,b),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:s+"B",type:"radio",name:s,checked:e[1],onChange:e=>this.handleOnChange(e,h)}),S,v,y),r().createElement("br",null)),T,r().createElement("div",null,r().createElement("br",null),A),_)];"teammateNameDisplay"===a&&p&&(g=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.display.teammateNameDisplay",defaultMessage:"This field is handled through your System Administrator. If you want to change it, you need to do so through your System Administrator."})),f=null,k=[]),C=r().createElement(D,{title:N,inputs:k,submit:f,saving:this.state.isSaving,serverError:this.state.serverError,extraInfo:g,updateSection:this.updateSection})}return _=n===l.value?E:n===c.value?S:M,r().createElement("div",null,r().createElement(I,{active:T,areAllSectionsInactive:""===this.props.activeSection,title:N,describe:_,section:i,updateSection:this.updateSection,max:C}),r().createElement("div",{className:"divider-dark"}))}render(){const e=this.createSection({section:"collapse",display:"collapseDisplay",value:this.state.collapseDisplay,defaultDisplay:"false",title:(0,d.defineMessage)({id:"user.settings.display.collapseDisplay",defaultMessage:"Default Appearance of Image Previews"}),firstOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.collapseOn",defaultMessage:"Expanded"})}},secondOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.collapseOff",defaultMessage:"Collapsed"})}},description:(0,d.defineMessage)({id:"user.settings.display.collapseDesc",defaultMessage:"Set whether previews of image links and image attachment thumbnails show as expanded or collapsed by default. This setting can also be controlled using the slash commands /expand and /collapse."})});let t=null;this.props.enableLinkPreviews?(t=this.createSection({section:"linkpreview",display:"linkPreviewDisplay",value:this.state.linkPreviewDisplay,defaultDisplay:"true",title:(0,d.defineMessage)({id:"user.settings.display.linkPreviewDisplay",defaultMessage:"Website Link Previews"}),firstOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.linkPreviewOn",defaultMessage:"On"})}},secondOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.linkPreviewOff",defaultMessage:"Off"})}},description:(0,d.defineMessage)({id:"user.settings.display.linkPreviewDesc",defaultMessage:"When available, the first web link in a message will show a preview of the website content below the message."})}),this.prevSections.message_display="linkpreview"):this.prevSections.message_display=this.prevSections.linkpreview;let s=null;this.props.lastActiveTimeEnabled&&(s=this.createSection({section:"lastactive",display:"lastActiveDisplay",value:this.state.lastActiveDisplay,defaultDisplay:"true",title:(0,d.defineMessage)({id:"user.settings.display.lastActiveDisplay",defaultMessage:"Share last active time"}),firstOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.lastActiveOn",defaultMessage:"On"})}},secondOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.lastActiveOff",defaultMessage:"Off"})}},description:(0,d.defineMessage)({id:"user.settings.display.lastActiveDesc",defaultMessage:"When enabled, other users will see when you were last active."}),onSubmit:this.submitLastActive}));const i=this.createSection({section:"clock",display:"militaryTime",value:this.state.militaryTime,defaultDisplay:"false",title:(0,d.defineMessage)({id:"user.settings.display.clockDisplay",defaultMessage:"Clock Display"}),firstOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.normalClock",defaultMessage:"12-hour clock (example: 4:00 PM)"})}},secondOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.militaryClock",defaultMessage:"24-hour clock (example: 16:00)"})}},description:(0,d.defineMessage)({id:"user.settings.display.preferTime",defaultMessage:"Select how you prefer time displayed."})}),a=this.createSection({section:ze.NAME_NAME_FORMAT,display:"teammateNameDisplay",value:this.props.lockTeammateNameDisplay?this.props.configTeammateNameDisplay:this.state.teammateNameDisplay,defaultDisplay:this.props.configTeammateNameDisplay,title:(0,d.defineMessage)({id:"user.settings.display.teammateNameDisplayTitle",defaultMessage:"Teammate Name Display"}),firstOption:{value:S.Ay.TEAMMATE_NAME_DISPLAY.SHOW_USERNAME,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.teammateNameDisplayUsername",defaultMessage:"Show username"})}},secondOption:{value:S.Ay.TEAMMATE_NAME_DISPLAY.SHOW_NICKNAME_FULLNAME,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.teammateNameDisplayNicknameFullname",defaultMessage:"Show nickname if one exists, otherwise show first and last name"})}},thirdOption:{value:S.Ay.TEAMMATE_NAME_DISPLAY.SHOW_FULLNAME,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.teammateNameDisplayFullname",defaultMessage:"Show first and last name"})}},description:(0,d.defineMessage)({id:"user.settings.display.teammateNameDisplayDescription",defaultMessage:"Set how to display other user's names in posts and the Direct Messages list."}),disabled:this.props.lockTeammateNameDisplay}),n=this.createSection({section:"availabilityStatus",display:"availabilityStatusOnPosts",value:this.state.availabilityStatusOnPosts,defaultDisplay:"true",title:(0,d.defineMessage)({id:"user.settings.display.availabilityStatusOnPostsTitle",defaultMessage:"Show user availability on posts"}),firstOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.sidebar.on",defaultMessage:"On"})}},secondOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.sidebar.off",defaultMessage:"Off"})}},description:(0,d.defineMessage)({id:"user.settings.display.availabilityStatusOnPostsDescription",defaultMessage:"When enabled, online availability is displayed on profile images in the message list."})});let o;if(!this.props.shouldAutoUpdateTimezone){const e=this.props.userTimezone,t="timezone"===this.props.activeSection;let s=null;t&&(s=r().createElement(Ye,{user:this.props.user,useAutomaticTimezone:Boolean(e.useAutomaticTimezone),automaticTimezone:e.automaticTimezone,manualTimezone:e.manualTimezone,updateSection:this.updateSection,adminMode:this.props.adminMode})),o=r().createElement("div",null,r().createElement(I,{active:t,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.display.timezone",defaultMessage:"Timezone"}),describe:this.props.timezoneLabel,section:"timezone",updateSection:this.updateSection,max:s}),r().createElement("div",{className:"divider-dark"}))}const l=this.createSection({section:ze.MESSAGE_DISPLAY,display:"messageDisplay",value:this.state.messageDisplay,defaultDisplay:ze.MESSAGE_DISPLAY_CLEAN,title:(0,d.defineMessage)({id:"user.settings.display.messageDisplayTitle",defaultMessage:"Message Display"}),firstOption:{value:ze.MESSAGE_DISPLAY_CLEAN,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.messageDisplayClean",defaultMessage:"Standard"}),more:(0,d.defineMessage)({id:"user.settings.display.messageDisplayCleanDes",defaultMessage:"Easy to scan and read."})}},secondOption:{value:ze.MESSAGE_DISPLAY_COMPACT,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.messageDisplayCompact",defaultMessage:"Compact"}),more:(0,d.defineMessage)({id:"user.settings.display.messageDisplayCompactDes",defaultMessage:"Fit as many messages on the screen as we can."})},childOption:{label:(0,d.defineMessage)({id:"user.settings.display.colorize",defaultMessage:"Colorize usernames"}),value:this.state.colorizeUsernames,display:"colorizeUsernames",more:(0,d.defineMessage)({id:"user.settings.display.colorizeDes",defaultMessage:"Use colors to distinguish users in compact mode"})}},description:(0,d.defineMessage)({id:"user.settings.display.messageDisplayDescription",defaultMessage:"Select how messages in a channel should be displayed."})});let c;this.props.collapsedReplyThreadsAllowUserPreference&&(c=this.createSection({section:ze.COLLAPSED_REPLY_THREADS,display:"collapsedReplyThreads",value:this.state.collapsedReplyThreads,defaultDisplay:ze.COLLAPSED_REPLY_THREADS_FALLBACK_DEFAULT,title:(0,d.defineMessage)({id:"user.settings.display.collapsedReplyThreadsTitle",defaultMessage:"Threaded Discussions"}),firstOption:{value:ze.COLLAPSED_REPLY_THREADS_ON,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.collapsedReplyThreadsOn",defaultMessage:"On"})}},secondOption:{value:ze.COLLAPSED_REPLY_THREADS_OFF,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.collapsedReplyThreadsOff",defaultMessage:"Off"})}},description:(0,d.defineMessage)({id:"user.settings.display.collapsedReplyThreadsDescription",defaultMessage:"When enabled, reply messages are not shown in the channel and you'll be notified about threads you're following in the \"Threads\" view."})}));const u=this.createSection({section:ze.CLICK_TO_REPLY,display:"clickToReply",value:this.state.clickToReply,defaultDisplay:"true",title:(0,d.defineMessage)({id:"user.settings.display.clickToReply",defaultMessage:"Click to open threads"}),firstOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.sidebar.on",defaultMessage:"On"})}},secondOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.sidebar.off",defaultMessage:"Off"})}},description:(0,d.defineMessage)({id:"user.settings.display.clickToReplyDescription",defaultMessage:"When enabled, click anywhere on a message to open the reply thread."})}),m=this.createSection({section:ze.CHANNEL_DISPLAY_MODE,display:"channelDisplayMode",value:this.state.channelDisplayMode,defaultDisplay:ze.CHANNEL_DISPLAY_MODE_FULL_SCREEN,title:(0,d.defineMessage)({id:"user.settings.display.channelDisplayTitle",defaultMessage:"Channel Display"}),firstOption:{value:ze.CHANNEL_DISPLAY_MODE_FULL_SCREEN,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.fullScreen",defaultMessage:"Full width"})}},secondOption:{value:ze.CHANNEL_DISPLAY_MODE_CENTERED,radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.display.fixedWidthCentered",defaultMessage:"Fixed width, centered"})}},description:(0,d.defineMessage)({id:"user.settings.display.channeldisplaymode",defaultMessage:"Select the width of the center channel."})});let p;const h=this.props.userLocale,g=(0,ne.vL)(h).name;let f,E;return p=r().createElement("div",null,r().createElement(I,{active:"languages"===this.props.activeSection,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.display.language",defaultMessage:"Language"}),describe:g,section:"languages",updateSection:this.updateSection,max:r().createElement(Be,{user:this.props.user,locale:h,updateSection:this.updateSection,adminMode:this.props.adminMode})}),r().createElement("div",{className:"divider-dark"})),1===Object.keys(this.props.locales).length&&(p=null),this.props.enableThemeSelection&&!this.props.adminMode&&(f=r().createElement("div",null,r().createElement(Re,{selected:"theme"===this.props.activeSection,areAllSectionsInactive:""===this.props.activeSection,updateSection:this.updateSection,setRequireConfirm:this.props.setRequireConfirm,allowCustomThemes:this.props.allowCustomThemes}),r().createElement("div",{className:"divider-dark"}))),this.props.emojiPickerEnabled&&(E=this.createSection({section:ze.ONE_CLICK_REACTIONS_ENABLED,display:"oneClickReactionsOnPosts",value:this.state.oneClickReactionsOnPosts,defaultDisplay:"true",title:(0,d.defineMessage)({id:"user.settings.display.oneClickReactionsOnPostsTitle",defaultMessage:"Quick reactions on messages"}),firstOption:{value:"true",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.sidebar.on",defaultMessage:"On"})}},secondOption:{value:"false",radionButtonText:{label:(0,d.defineMessage)({id:"user.settings.sidebar.off",defaultMessage:"Off"})}},description:(0,d.defineMessage)({id:"user.settings.display.oneClickReactionsOnPostsDescription",defaultMessage:"When enabled, you can react in one-click with recently used reactions when hovering over a message."})})),r().createElement("div",{id:"displaySettings"},r().createElement(K,{closeModal:this.props.closeModal,collapseModal:this.props.collapseModal,text:r().createElement(d.FormattedMessage,{id:"user.settings.display.title",defaultMessage:"Display Settings"})}),r().createElement("div",{className:"user-settings"},r().createElement(H,{id:"displaySettingsTitle",text:r().createElement(d.FormattedMessage,{id:"user.settings.display.title",defaultMessage:"Display Settings"})}),r().createElement("div",{className:"divider-dark first"}),f,c,i,a,n,s,o,t,e,l,u,m,E,p))}}Ke($e,"propTypes",{adminMode:a().bool,updateSection:a().func.isRequired,activeSection:a().string,closeModal:a().func.isRequired,collapseModal:a().func.isRequired,setRequireConfirm:a().func,timezones:a().array.isRequired,allowCustomThemes:a().bool.isRequired,enableLinkPreviews:a().bool.isRequired,userLocale:a().string.isRequired,enableThemeSelection:a().bool.isRequired,configTeammateNameDisplay:a().string.isRequired,shouldAutoUpdateTimezone:a().oneOfType([a().bool,a().string]).isRequired,lockTeammateNameDisplay:a().bool.isRequired,militaryTime:a().string.isRequired,teammateNameDisplay:a().string.isRequired,availabilityStatusOnPosts:a().string.isRequired,channelDisplayMode:a().string.isRequired,messageDisplay:a().string.isRequired,colorizeUsernames:a().string.isRequired,collapseDisplay:a().string.isRequired,collapsedReplyThreads:a().string.isRequired,collapsedReplyThreadsAllowUserPreference:a().bool.isRequired,clickToReply:a().string.isRequired,linkPreviewDisplay:a().string.isRequired});const Xe=(0,p.connect)((function(){return(e,t)=>{var s;const i=(0,E.zj)(e),a=(0,b.WR)(e),n=t.adminMode?(0,ie.zx)(t.user):(0,ie.GR)(e),r=n&&n.useAutomaticTimezone&&!n.automaticTimezone,o=!n||r,l=t.adminMode?(0,ie.YU)((0,ae.os)(n)):(0,ie.nQ)(e),c="true"===i.AllowCustomThemes,d="true"===i.EnableLinkPreviews,u="true"===i.EnableThemeSelection,m="true"===(0,E.Ay)(e).LockTeammateNameDisplay&&"true"===i.LockTeammateNameDisplay,p=i.TeammateNameDisplay,h="true"===i.EnableEmojiPicker,g="true"===i.EnableLastActiveTime,f=t.adminMode&&t.userPreferences?t.userPreferences:void 0;let y=!0;"false"===(null===(s=(t.adminMode?t.user:(0,b.wz)(e,a)).props)||void 0===s?void 0:s.show_last_active)&&(y=!1);let M=t.user.locale;return(0,ne.IU)(e,M)||(M=i.DefaultClientLocale),{lockTeammateNameDisplay:m,allowCustomThemes:c,configTeammateNameDisplay:p,enableLinkPreviews:d,locales:(0,ne.kG)(e),userLocale:M,enableThemeSelection:u,timezones:ee,timezoneLabel:l,userTimezone:n,shouldAutoUpdateTimezone:o,availabilityStatusOnPosts:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.AVAILABILITY_STATUS_ON_POSTS,S.pm.AVAILABILITY_STATUS_ON_POSTS_DEFAULT,f),militaryTime:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.USE_MILITARY_TIME,S.pm.USE_MILITARY_TIME_DEFAULT,f),teammateNameDisplay:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.NAME_NAME_FORMAT,p,f),channelDisplayMode:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.CHANNEL_DISPLAY_MODE,S.pm.CHANNEL_DISPLAY_MODE_DEFAULT,f),messageDisplay:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.MESSAGE_DISPLAY,S.pm.MESSAGE_DISPLAY_DEFAULT,f),colorizeUsernames:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.COLORIZE_USERNAMES,S.pm.COLORIZE_USERNAMES_DEFAULT,f),collapseDisplay:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.COLLAPSE_DISPLAY,S.pm.COLLAPSE_DISPLAY_DEFAULT,f),collapsedReplyThreadsAllowUserPreference:(0,v.Vu)(e)&&(0,E.zj)(e).CollapsedThreads!==te.$I.ALWAYS_ON,collapsedReplyThreads:(0,v.QD)(e),clickToReply:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.CLICK_TO_REPLY,S.pm.CLICK_TO_REPLY_DEFAULT,f),linkPreviewDisplay:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.LINK_PREVIEW_DISPLAY,S.pm.LINK_PREVIEW_DISPLAY_DEFAULT,f),oneClickReactionsOnPosts:(0,v.Jt)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.ONE_CLICK_REACTIONS_ENABLED,S.pm.ONE_CLICK_REACTIONS_ENABLED_DEFAULT,f),emojiPickerEnabled:h,lastActiveDisplay:y,lastActiveTimeEnabled:g}}}),(function(e){return{actions:(0,h.bindActionCreators)({autoUpdateTimezone:se.o,savePreferences:g.SF,updateMe:f.Me,patchUser:f.WJ},e)}}))($e);s(83931);var Qe=s(1418),Ze=s(84013),et=s(7380),tt=(s(57406),s(55448),s(40693)),st=s(78546),it=(s(60473),s(36169),s(85990)),at=s(55476),nt=s(68124);function rt(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function ot(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class lt extends n.Component{constructor(e){super(e),ot(this,"handleCancel",(e=>{var t,s;this.setState({removeSrc:!1,setDefaultSrc:!1}),null===(t=(s=this.props).updateSection)||void 0===t||t.call(s,e)})),ot(this,"handleFileSelected",(()=>{this.confirmButton.current&&this.confirmButton.current.focus()})),ot(this,"handleSave",(e=>{var t,s;if(e.preventDefault(),!this.props.loadingPicture)if(this.state.removeSrc)null===(t=(s=this.props).onRemove)||void 0===t||t.call(s);else if(this.state.setDefaultSrc){var i,a;null===(i=(a=this.props).onSetDefault)||void 0===i||i.call(a)}else{var n,r;null===(n=(r=this.props).onSubmit)||void 0===n||n.call(r)}})),ot(this,"handleRemoveSrc",(e=>{e.preventDefault(),this.setState({removeSrc:!0}),this.focusFirstElement()})),ot(this,"handleSetDefaultSrc",(e=>{e.preventDefault(),this.setState({setDefaultSrc:!0}),this.focusFirstElement()})),ot(this,"handleFileChange",(e=>{var t,s;this.setState({removeSrc:!1,setDefaultSrc:!1}),null===(t=(s=this.props).onFileChange)||void 0===t||t.call(s,e)})),ot(this,"handleInputFile",(()=>{this.selectInput.current&&(this.selectInput.current.value="",this.selectInput.current.click())})),ot(this,"setPicture",(e=>{if(e){this.previewBlob=URL.createObjectURL(e);const t=new FileReader;t.onload=e=>{const t=nt.hM(e.target.result),s=nt.R6(t);this.setState({image:this.previewBlob,orientationStyles:s})},t.readAsArrayBuffer(e)}})),ot(this,"renderImg",(()=>{const e=this.props.imageContext;if(this.props.file){const t=function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?rt(Object(s),!0).forEach((function(t){ot(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):rt(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}({backgroundImage:"url("+this.state.image+")"},this.state.orientationStyles);return r().createElement("div",{className:"".concat(e,"-img-preview")},r().createElement("div",{className:"img-preview__image"},r().createElement("div",{style:t,className:"".concat(e,"-img-preview")})))}if(this.state.setDefaultSrc)return r().createElement("img",{className:"".concat(e,"-img"),alt:"".concat(e," image"),src:this.props.defaultImageSrc});if(this.props.src&&!this.state.removeSrc){var t;const s=r().createElement("img",{className:"".concat(e,"-img"),alt:"".concat(e," image"),src:this.props.src});if(!this.props.onRemove&&!this.props.onSetDefault)return s;let i,a;return this.props.onRemove?(i=r().createElement(d.FormattedMessage,{id:"setting_picture.remove",defaultMessage:"Remove This Icon"}),a=this.handleRemoveSrc):this.props.onSetDefault&&(i=r().createElement(d.FormattedMessage,{id:"setting_picture.remove_profile_picture",defaultMessage:"Remove Profile Picture"}),a=this.handleSetDefaultSrc),r().createElement("div",{className:"".concat(e,"-img__container")},r().createElement("div",{className:"img-preview__image","aria-hidden":!0},s),r().createElement(pe.A,{title:null!==(t=i)&&void 0!==t?t:"",disabled:!i},r().createElement("button",{"data-testid":"removeSettingPicture",className:"".concat(e,"-img__remove"),onClick:a},r().createElement("span",{"aria-hidden":!0},"×"),r().createElement("span",{className:"sr-only"},i))))}return null})),this.settingList=(0,n.createRef)(),this.selectInput=(0,n.createRef)(),this.confirmButton=(0,n.createRef)(),this.previewBlob=null,this.state={image:null,removeSrc:!1,setDefaultSrc:!1}}focusFirstElement(){var e;null===(e=this.settingList.current)||void 0===e||e.focus()}componentDidMount(){this.focusFirstElement(),this.selectInput.current&&this.selectInput.current.addEventListener("input",this.handleFileSelected)}componentDidUpdate(e){this.props.file&&e.file!==this.props.file&&this.setPicture(this.props.file)}componentWillUnmount(){this.previewBlob&&URL.revokeObjectURL(this.previewBlob),this.selectInput.current&&this.selectInput.current.removeEventListener("input",this.handleFileSelected)}render(){const e=this.renderImg();let t,s,i="btn",a=!1;return this.props.submitActive||this.state.removeSrc||this.state.setDefaultSrc?i+=" btn-primary":(i+=" btn-inactive disabled",a=!0),e&&(t=r().createElement("li",{className:"setting-list-item",role:"presentation"},e)),this.props.onSubmit&&(s=r().createElement("span",null,r().createElement("input",{"data-testid":"uploadPicture",ref:this.selectInput,className:"hidden",accept:S.YM.ACCEPT_STATIC_IMAGE,type:"file",onChange:this.handleFileChange,disabled:this.props.loadingPicture,"aria-hidden":!0,tabIndex:-1}),r().createElement("button",{"data-testid":"inputSettingPictureButton",className:"btn btn-primary btn-file",disabled:this.props.loadingPicture,onClick:this.handleInputFile,"aria-label":(0,T.Vw)({id:"setting_picture.select",defaultMessage:"Select"})},r().createElement(d.FormattedMessage,{id:"setting_picture.select",defaultMessage:"Select"})),r().createElement("button",{tabIndex:a?-1:0,"data-testid":"saveSettingPicture",disabled:a,ref:this.confirmButton,className:i,onClick:this.handleSave,"aria-label":this.props.loadingPicture?(0,T.Vw)({id:"setting_picture.uploading",defaultMessage:"Uploading..."}):(0,T.Vw)({id:"setting_picture.save",defaultMessage:"Save"})},r().createElement(at.A,{loading:this.props.loadingPicture,text:(0,d.defineMessage)({id:"setting_picture.uploading",defaultMessage:"Uploading..."})},r().createElement(d.FormattedMessage,{id:"setting_picture.save",defaultMessage:"Save"}))))),r().createElement("section",{className:"section-max form-horizontal"},r().createElement("h4",{className:"col-xs-12 section-title"},this.props.title),r().createElement("div",{className:"col-sm-10 col-sm-offset-2"},r().createElement("div",{className:"setting-list",ref:this.settingList,tabIndex:-1,"aria-label":this.props.title,"aria-describedby":"setting-picture__helptext"},t,r().createElement("div",{id:"setting-picture__helptext",className:"setting-list-item pt-3"},this.props.helpText),r().createElement("div",{className:"setting-list-item"},r().createElement("hr",null),r().createElement(it.A,{errors:[this.props.clientError,this.props.serverError],type:"modal"}),s,r().createElement("button",{"data-testid":"cancelSettingPicture",className:"btn btn-tertiary theme ml-2",onClick:this.handleCancel,"aria-label":(0,T.Vw)({id:"setting_picture.cancel",defaultMessage:"Cancel"})},r().createElement(d.FormattedMessage,{id:"setting_picture.cancel",defaultMessage:"Cancel"}))))))}}function ct(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function dt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(s),!0).forEach((function(t){ut(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ct(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function ut(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}ot(lt,"defaultProps",{imageContext:"profile"});const mt=(0,d.defineMessages)({usernameReserved:{id:"user.settings.general.usernameReserved",defaultMessage:"This username is reserved, please choose a new one."},usernameGroupNameUniqueness:{id:"user.settings.general.usernameGroupNameUniqueness",defaultMessage:"This username conflicts with an existing group name."},usernameRestrictions:{id:"user.settings.general.usernameRestrictions",defaultMessage:"Username must begin with a letter, and contain between {min} to {max} lowercase characters made up of numbers, letters, and the symbols '.', '-', and '_'."},validEmail:{id:"user.settings.general.validEmail",defaultMessage:"Please enter a valid email address."},emailMatch:{id:"user.settings.general.emailMatch",defaultMessage:"The new emails you entered do not match."},incorrectPassword:{id:"user.settings.general.incorrectPassword",defaultMessage:"Your password is incorrect."},emptyPassword:{id:"user.settings.general.emptyPassword",defaultMessage:"Please enter your current password."},validImage:{id:"user.settings.general.validImage",defaultMessage:"Only BMP, JPG, JPEG, or PNG images may be used for profile pictures"},imageTooLarge:{id:"user.settings.general.imageTooLarge",defaultMessage:"Unable to upload profile image. File is too large."},uploadImage:{id:"user.settings.general.uploadImage",defaultMessage:"Click 'Edit' to upload an image."},uploadImageMobile:{id:"user.settings.general.mobile.uploadImage",defaultMessage:"Click to upload an image"},fullName:{id:"user.settings.general.fullName",defaultMessage:"Full Name"},nickname:{id:"user.settings.general.nickname",defaultMessage:"Nickname"},username:{id:"user.settings.general.username",defaultMessage:"Username"},profilePicture:{id:"user.settings.general.profilePicture",defaultMessage:"Profile Picture"},close:{id:"user.settings.general.close",defaultMessage:"Close"},position:{id:"user.settings.general.position",defaultMessage:"Position"}});class pt extends n.PureComponent{constructor(e){super(e),ut(this,"submitActive",!1),ut(this,"handleEmailResend",(e=>{this.setState({resendStatus:"sending",showSpinner:!0}),this.props.actions.sendVerificationEmail(e).then((e=>{let{data:t,error:s}=e;t?this.setState({resendStatus:"success"}):s&&this.setState({resendStatus:"failure"})}))})),ut(this,"createEmailResendLink",(e=>r().createElement("span",{className:"resend-verification-wrapper"},r().createElement(at.A,{loading:this.state.showSpinner,text:(0,d.defineMessage)({id:"user.settings.general.sending",defaultMessage:"Sending"})},r().createElement("a",{onClick:()=>{this.handleEmailResend(e),setTimeout((()=>{this.setState({showSpinner:!1})}),500)}},r().createElement(d.FormattedMessage,{id:"user.settings.general.sendAgain",defaultMessage:"Send again"})))))),ut(this,"submitUsername",(()=>{const e=Object.assign({},this.props.user),t=this.state.username.trim().toLowerCase(),{formatMessage:s}=this.props.intl,i=T.Bs(t);if(i){let e;return e=i.id===S.vJ.RESERVED_NAME?{clientError:s(mt.usernameReserved),serverError:""}:{clientError:s(mt.usernameRestrictions,{min:S.YM.MIN_USERNAME_LENGTH,max:S.YM.MAX_USERNAME_LENGTH}),serverError:""},void this.setState(e)}e.username!==t?(e.username=t,(0,le.sx)("settings","user_settings_update",{field:"username"}),this.submitUser(e,!1)):this.updateSection("")})),ut(this,"submitNickname",(()=>{const e=Object.assign({},this.props.user),t=this.state.nickname.trim();e.nickname!==t?(e.nickname=t,(0,le.sx)("settings","user_settings_update",{field:"nickname"}),this.submitUser(e,!1)):this.updateSection("")})),ut(this,"submitName",(()=>{const e=Object.assign({},this.props.user),t=this.state.firstName.trim(),s=this.state.lastName.trim();e.first_name!==t||e.last_name!==s?(e.first_name=t,e.last_name=s,(0,le.sx)("settings","user_settings_update",{field:"fullname"}),this.submitUser(e,!1)):this.updateSection("")})),ut(this,"submitEmail",(()=>{const e=Object.assign({},this.props.user),t=this.state.email.trim().toLowerCase(),s=this.state.confirmEmail.trim().toLowerCase(),i=this.state.currentPassword,{formatMessage:a}=this.props.intl;t!==e.email||""!==s&&s!==e.email?""!==t&&(0,st.xf)(t)?t===s?""!==i?(e.email=t,e.password=i,(0,le.sx)("settings","user_settings_update",{field:"email"}),this.submitUser(e,!0)):this.setState({emailError:a(mt.emptyPassword),clientError:"",serverError:""}):this.setState({emailError:a(mt.emailMatch),clientError:"",serverError:""}):this.setState({emailError:a(mt.validEmail),clientError:"",serverError:""}):this.updateSection("")})),ut(this,"submitUser",((e,t)=>{const{formatMessage:s}=this.props.intl;this.setState({sectionIsSaving:!0}),this.props.actions.updateMe(e).then((e=>{let{data:i,error:a}=e;if(i)this.updateSection(""),this.props.requireEmailVerification&&t&&(this.props.actions.clearErrors(),this.props.actions.logError({message:S.Xu.EMAIL_VERIFICATION_REQUIRED,type:S.cn.SUCCESS},!0));else if(a){let e;e=a.server_error_id&&"api.user.check_user_password.invalid.app_error"===a.server_error_id?s(mt.incorrectPassword):"app.user.group_name_conflict"===a.server_error_id?s(mt.usernameGroupNameUniqueness):a.message?a.message:a,this.setState({serverError:e,emailError:"",clientError:"",sectionIsSaving:!1})}}))})),ut(this,"setDefaultProfilePicture",(async()=>{try{await this.props.actions.setDefaultProfileImage(this.props.user.id),this.updateSection(""),this.submitActive=!1}catch(e){let t;t=e.message?e.message:e,this.setState({serverError:t,emailError:"",clientError:"",sectionIsSaving:!1})}})),ut(this,"submitPicture",(()=>{if(!this.state.pictureFile)return;if(!this.submitActive)return;(0,le.sx)("settings","user_settings_update",{field:"picture"});const{formatMessage:e}=this.props.intl,t=this.state.pictureFile;S.je.includes(t.type)?t.size>this.props.maxFileSize?this.setState({clientError:e(mt.imageTooLarge),serverError:""}):(this.setState({loadingPicture:!0}),this.props.actions.uploadProfileImage(this.props.user.id,t).then((e=>{let{data:t,error:s}=e;if(t)this.updateSection(""),this.submitActive=!1;else if(s){const e=this.setupInitialState(this.props);e.serverError=s.message,this.setState(e)}}))):this.setState({clientError:e(mt.validImage),serverError:""})})),ut(this,"submitPosition",(()=>{const e=Object.assign({},this.props.user),t=this.state.position.trim();e.position!==t?(e.position=t,(0,le.sx)("settings","user_settings_update",{field:"position"}),this.submitUser(e,!1)):this.updateSection("")})),ut(this,"submitAttribute",(async e=>{var t;const s=e[0],i=null===(t=this.state.customAttributeValues)||void 0===t?void 0:t[s];null!=i&&((0,le.sx)("settings","user_settings_update",{field:"customAttributeValues-"+s}),this.setState({sectionIsSaving:!0}),this.props.actions.saveCustomProfileAttribute(this.props.user.id,s,i).then((e=>{let{data:t,error:s}=e;if(t)this.updateSection(""),this.setState({customAttributeValues:dt(dt({},this.state.customAttributeValues),t)});else if(s){const e=s;this.setState({serverError:e,emailError:"",clientError:"",sectionIsSaving:!1})}})))})),ut(this,"updateUsername",(e=>{this.setState({username:e.target.value})})),ut(this,"updateFirstName",(e=>{this.setState({firstName:e.target.value})})),ut(this,"updateLastName",(e=>{this.setState({lastName:e.target.value})})),ut(this,"updateNickname",(e=>{this.setState({nickname:e.target.value})})),ut(this,"updatePosition",(e=>{this.setState({position:e.target.value})})),ut(this,"updateEmail",(e=>{this.setState({email:e.target.value})})),ut(this,"updateConfirmEmail",(e=>{this.setState({confirmEmail:e.target.value})})),ut(this,"updateCurrentPassword",(e=>{this.setState({currentPassword:e.target.value})})),ut(this,"updatePicture",(e=>{e.target.files&&e.target.files[0]?(this.setState({pictureFile:e.target.files[0]}),this.submitActive=!0,this.setState({clientError:null})):this.setState({pictureFile:null})})),ut(this,"updateAttribute",(e=>{const t=Object.assign({},this.state.customAttributeValues);t[e.target.id.substring(e.target.id.indexOf("_")+1)]=e.target.value,this.setState({customAttributeValues:t})})),ut(this,"updateSection",(e=>{this.setState(Object.assign({},this.setupInitialState(this.props),{clientError:"",serverError:"",emailError:"",sectionIsSaving:!1})),this.submitActive=!1,this.props.updateSection(e)})),ut(this,"createNameSection",(()=>{const e=this.props.user,{formatMessage:t}=this.props.intl,s="name"===this.props.activeSection;let i=null;if(s){const e=[];let s,a=null;if(this.props.user.auth_service===S.YM.LDAP_SERVICE&&(this.props.ldapFirstNameAttributeSet||this.props.ldapLastNameAttributeSet)||this.props.user.auth_service===S.YM.SAML_SERVICE&&(this.props.samlFirstNameAttributeSet||this.props.samlLastNameAttributeSet)||S.YM.OAUTH_SERVICES.includes(this.props.user.auth_service))s=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.field_handled_externally",defaultMessage:"This field is handled through your login provider. If you want to change it, you need to do so through your login provider."}));else{e.push(r().createElement("div",{key:"firstNameSetting",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"firstName"},r().createElement(d.FormattedMessage,{id:"user.settings.general.firstName",defaultMessage:"First Name"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"firstName",autoFocus:!0,className:"form-control",type:"text",onChange:this.updateFirstName,maxLength:S.YM.MAX_FIRSTNAME_LENGTH,value:this.state.firstName,onFocus:T.G8,"aria-label":t({id:"user.settings.general.firstName",defaultMessage:"First Name"})})))),e.push(r().createElement("div",{key:"lastNameSetting",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"lastName"},r().createElement(d.FormattedMessage,{id:"user.settings.general.lastName",defaultMessage:"Last Name"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"lastName",className:"form-control",type:"text",onChange:this.updateLastName,maxLength:S.YM.MAX_LASTNAME_LENGTH,value:this.state.lastName,"aria-label":t({id:"user.settings.general.lastName",defaultMessage:"Last Name"})}))));const i=e=>{e.preventDefault(),this.updateSection(""),this.props.updateTab("notifications")},n=r().createElement("a",{href:"#",onClick:i.bind(this)},r().createElement(d.FormattedMessage,{id:"user.settings.general.notificationsLink",defaultMessage:"Notifications"}));s=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.notificationsExtra",defaultMessage:"By default, you will receive mention notifications when someone types your first name. Go to {notify} settings to change this default.",values:{notify:n}})),a=this.submitName}i=r().createElement(D,{title:t(mt.fullName),inputs:e,submit:a,saving:this.state.sectionIsSaving,serverError:this.state.serverError,clientError:this.state.clientError,updateSection:this.updateSection,extraInfo:s})}let a="";return e.first_name&&e.last_name?a=e.first_name+" "+e.last_name:e.first_name?a=e.first_name:e.last_name?a=e.last_name:(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.emptyName",defaultMessage:"Click 'Edit' to add your full name"}),this.props.isMobileView&&(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.mobile.emptyName",defaultMessage:"Click to add your full name"}))),r().createElement(I,{active:s,areAllSectionsInactive:""===this.props.activeSection,title:t(mt.fullName),describe:a,section:"name",updateSection:this.updateSection,max:i})})),ut(this,"createNicknameSection",(()=>{const e=this.props.user,{formatMessage:t}=this.props.intl,s="nickname"===this.props.activeSection;let i=null;if(s){const e=[];let s,a=null;if("ldap"===this.props.user.auth_service&&this.props.ldapNicknameAttributeSet||this.props.user.auth_service===S.YM.SAML_SERVICE&&this.props.samlNicknameAttributeSet)s=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.field_handled_externally",defaultMessage:"This field is handled through your login provider. If you want to change it, you need to do so through your login provider."}));else{let i=r().createElement(d.FormattedMessage,{id:"user.settings.general.nickname",defaultMessage:"Nickname"});this.props.isMobileView&&(i=""),e.push(r().createElement("div",{key:"nicknameSetting",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label"},i),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"nickname",autoFocus:!0,className:"form-control",type:"text",onChange:this.updateNickname,value:this.state.nickname,maxLength:S.YM.MAX_NICKNAME_LENGTH,autoCapitalize:"off","aria-label":t({id:"user.settings.general.nickname",defaultMessage:"Nickname"})})))),s=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.nicknameExtra",defaultMessage:"Use Nickname for a name you might be called that is different from your first name and username. This is most often used when two or more people have similar sounding names and usernames."})),a=this.submitNickname}i=r().createElement(D,{title:t(mt.nickname),inputs:e,submit:a,saving:this.state.sectionIsSaving,serverError:this.state.serverError,clientError:this.state.clientError,updateSection:this.updateSection,extraInfo:s})}let a="";return e.nickname?a=e.nickname:(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.emptyNickname",defaultMessage:"Click 'Edit' to add a nickname"}),this.props.isMobileView&&(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.mobile.emptyNickname",defaultMessage:"Click to add a nickname"}))),r().createElement(I,{active:s,areAllSectionsInactive:""===this.props.activeSection,title:t(mt.nickname),describe:a,section:"nickname",updateSection:this.updateSection,max:i})})),ut(this,"createUsernameSection",(()=>{const{formatMessage:e}=this.props.intl,t="username"===this.props.activeSection;let s=null;if(t){const t=[];let i,a=null;if(""===this.props.user.auth_service){let s=r().createElement(d.FormattedMessage,{id:"user.settings.general.username",defaultMessage:"Username"});this.props.isMobileView&&(s=""),t.push(r().createElement("div",{key:"usernameSetting",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label"},s),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"username",autoFocus:!0,maxLength:S.YM.MAX_USERNAME_LENGTH,className:"form-control",type:"text",onChange:this.updateUsername,value:this.state.username,autoCapitalize:"off",onFocus:T.G8,"aria-label":e({id:"user.settings.general.username",defaultMessage:"Username"})})))),i=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.usernameInfo",defaultMessage:"Pick something easy for teammates to recognize and recall."})),a=this.submitUsername}else i=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.field_handled_externally",defaultMessage:"This field is handled through your login provider. If you want to change it, you need to do so through your login provider."}));s=r().createElement(D,{title:e(mt.username),inputs:t,submit:a,saving:this.state.sectionIsSaving,serverError:this.state.serverError,clientError:this.state.clientError,updateSection:this.updateSection,extraInfo:i})}return r().createElement(I,{active:t,areAllSectionsInactive:""===this.props.activeSection,title:e(mt.username),describe:this.props.user.username,section:"username",updateSection:this.updateSection,max:s})})),ut(this,"createPositionSection",(()=>{const e=this.props.user,{formatMessage:t}=this.props.intl,s="position"===this.props.activeSection;let i=null;if(s){const e=[];let s,a=null;if(this.props.user.auth_service===S.YM.LDAP_SERVICE&&this.props.ldapPositionAttributeSet||this.props.user.auth_service===S.YM.SAML_SERVICE&&this.props.samlPositionAttributeSet)s=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.field_handled_externally",defaultMessage:"This field is handled through your login provider. If you want to change it, you need to do so through your login provider."}));else{let i=r().createElement(d.FormattedMessage,{id:"user.settings.general.position",defaultMessage:"Position"});this.props.isMobileView&&(i=""),e.push(r().createElement("div",{key:"positionSetting",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label"},i),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"position",autoFocus:!0,className:"form-control",type:"text",onChange:this.updatePosition,value:this.state.position,maxLength:S.YM.MAX_POSITION_LENGTH,autoCapitalize:"off",onFocus:T.G8,"aria-label":t({id:"user.settings.general.position",defaultMessage:"Position"})})))),s=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.positionExtra",defaultMessage:"Use Position for your role or job title. This will be shown in your profile popover."})),a=this.submitPosition}i=r().createElement(D,{title:t(mt.position),inputs:e,submit:a,saving:this.state.sectionIsSaving,serverError:this.state.serverError,clientError:this.state.clientError,updateSection:this.updateSection,extraInfo:s})}let a="";return e.position?a=e.position:(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.emptyPosition",defaultMessage:"Click 'Edit' to add your job title / position"}),this.props.isMobileView&&(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.mobile.emptyPosition",defaultMessage:"Click to add your job title / position"}))),r().createElement(I,{active:s,areAllSectionsInactive:""===this.props.activeSection,title:t(mt.position),describe:a,section:"position",updateSection:this.updateSection,max:i})})),ut(this,"createCustomAttributeSection",(()=>{if(null==this.props.customProfileAttributeFields)return r().createElement(r().Fragment,null);const e=Object.values(this.props.customProfileAttributeFields).map((e=>{var t,s;const i=null!==(t=null===(s=this.state.customAttributeValues)||void 0===s?void 0:s[e.id])&&void 0!==t?t:"",a="customAttribute_"+e.id,n=this.props.activeSection===a;let o=null;if(n){const t=[];let s=e.name;this.props.isMobileView&&(s=""),t.push(r().createElement("div",{key:a,className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label"},s),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:a,autoFocus:!0,className:"form-control",type:"text",onChange:this.updateAttribute,value:i,maxLength:S.YM.MAX_CUSTOM_ATTRIBUTE_LENGTH,autoCapitalize:"off",onFocus:T.G8,"aria-label":e.name}))));const n=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.attributeExtra",defaultMessage:"This will be shown in your profile popover."}));o=r().createElement(D,{key:"settingItemMax_"+e.id,title:e.name,inputs:t,submit:this.submitAttribute.bind(this,[e.id]),saving:this.state.sectionIsSaving,serverError:this.state.serverError,clientError:this.state.clientError,updateSection:this.updateSection,extraInfo:n})}let l="";return i?l=i:(l=r().createElement(d.FormattedMessage,{id:"user.settings.general.emptyAttribute",defaultMessage:"Click 'Edit' to add your custom attribute"}),this.props.isMobileView&&(l=r().createElement(d.FormattedMessage,{id:"user.settings.general.mobile.emptyAttribute",defaultMessage:"Click to add your custom attribute"}))),r().createElement("div",{key:a},r().createElement(I,{key:"settingItem_"+e.id,active:n,areAllSectionsInactive:""===this.props.activeSection,title:e.name,describe:l,section:a,updateSection:this.updateSection,max:o}),r().createElement("div",{className:"divider-dark"}))}));return r().createElement(r().Fragment,null,e)})),ut(this,"createPictureSection",(()=>{const e=this.props.user,{formatMessage:t}=this.props.intl,s="picture"===this.props.activeSection;let i=null;if(s){let s=null,a=null,n=null,o=null;this.props.user.auth_service!==S.YM.LDAP_SERVICE&&this.props.user.auth_service!==S.YM.SAML_SERVICE||!this.props.ldapPictureAttributeSet?(s=this.submitPicture,a=e.last_picture_update>0?this.setDefaultProfilePicture:null,o=T.RG(e.id,e.last_picture_update),n=r().createElement(d.FormattedMessage,{id:"setting_picture.help.profile",defaultMessage:"Upload a picture in BMP, JPG, JPEG, or PNG format. Maximum file size: {max}",values:{max:T.O1(this.props.maxFileSize)}})):n=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.general.field_handled_externally",defaultMessage:"This field is handled through your login provider. If you want to change it, you need to do so through your login provider."})),i=r().createElement(lt,{title:t(mt.profilePicture),onSubmit:s,onSetDefault:a,src:o,defaultImageSrc:T.mY(e.id),serverError:this.state.serverError,clientError:this.state.clientError,updateSection:e=>{this.updateSection(""),e.preventDefault()},file:this.state.pictureFile,onFileChange:this.updatePicture,submitActive:this.submitActive,loadingPicture:this.state.loadingPicture,maxFileSize:this.props.maxFileSize,helpText:n})}let a=t(mt.uploadImage);return this.props.isMobileView&&(a=t(mt.uploadImageMobile)),e.last_picture_update>0&&(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.imageUpdated",defaultMessage:"Image last updated {date}",values:{date:r().createElement(d.FormattedDate,{value:new Date(e.last_picture_update),day:"2-digit",month:"short",year:"numeric"})}})),r().createElement(I,{active:s,areAllSectionsInactive:""===this.props.activeSection,title:t(mt.profilePicture),describe:a,section:"picture",updateSection:this.updateSection,max:i})})),this.state=this.setupInitialState(e)}componentDidMount(){if(this.props.enableCustomProfileAttributes){const e=async()=>{const e=await tt.mT.getUserCustomProfileAttributesValues(this.props.user.id);this.setState({customAttributeValues:e})};this.props.actions.getCustomProfileAttributeFields(),e()}}setupInitialState(e){const t=e.user;let s={};return void 0!==this.state&&(s=this.state.customAttributeValues),{username:t.username,firstName:t.first_name,lastName:t.last_name,nickname:t.nickname,position:t.position,originalEmail:t.email,email:"",confirmEmail:"",currentPassword:"",pictureFile:null,loadingPicture:!1,sectionIsSaving:!1,showSpinner:!1,serverError:"",customAttributeValues:s}}createEmailSection(){const{formatMessage:e}=this.props.intl,t="email"===this.props.activeSection;let s=null;if(t){const t=this.props.requireEmailVerification,i=[];let a=r().createElement(d.FormattedMessage,{id:"user.settings.general.emailHelp1",defaultMessage:"Email is used for sign-in, notifications, and password reset. Email requires verification if changed."});t||(a=r().createElement(d.FormattedMessage,{id:"user.settings.general.emailHelp3",defaultMessage:"Email is used for sign-in, notifications, and password reset."}));let n=null;""===this.props.user.auth_service?(i.push(r().createElement("div",{key:"currentEmailSetting"},r().createElement("div",{className:"form-group"},r().createElement("span",{className:"as-bs-label col-sm-5 control-label"},r().createElement(d.FormattedMessage,{id:"user.settings.general.currentEmail",defaultMessage:"Current Email"})),r().createElement("div",{className:"col-sm-7"},r().createElement("span",{className:"as-bs-label control-label word-break--all text-left"},this.state.originalEmail))))),i.push(r().createElement("div",{key:"emailSetting"},r().createElement("div",{className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"primaryEmail"},r().createElement(d.FormattedMessage,{id:"user.settings.general.newEmail",defaultMessage:"New Email"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{autoFocus:!0,id:"primaryEmail",className:"form-control",type:"email",onChange:this.updateEmail,maxLength:S.YM.MAX_EMAIL_LENGTH,value:this.state.email,"aria-label":e({id:"user.settings.general.newEmail",defaultMessage:"New Email"})}))))),i.push(r().createElement("div",{key:"confirmEmailSetting"},r().createElement("div",{className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"confirmEmail"},r().createElement(d.FormattedMessage,{id:"user.settings.general.confirmEmail",defaultMessage:"Confirm Email"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"confirmEmail",className:"form-control",type:"email",onChange:this.updateConfirmEmail,maxLength:S.YM.MAX_EMAIL_LENGTH,value:this.state.confirmEmail,"aria-label":e({id:"user.settings.general.confirmEmail",defaultMessage:"Confirm Email"})}))))),i.push(r().createElement("div",{key:"currentPassword"},r().createElement("div",{className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"currentPassword"},r().createElement(d.FormattedMessage,{id:"user.settings.general.currentPassword",defaultMessage:"Current Password"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"currentPassword",className:"form-control",type:"password",onChange:this.updateCurrentPassword,value:this.state.currentPassword,"aria-label":e({id:"user.settings.general.currentPassword",defaultMessage:"Current Password"})}))),a)),n=this.submitEmail):this.props.user.auth_service===S.YM.GITLAB_SERVICE?i.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"setting-list__hint pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.general.emailGitlabCantUpdate",defaultMessage:"Login occurs through GitLab. Email cannot be updated. Email address used for notifications is {email}.",values:{email:this.state.originalEmail}})),a)):this.props.user.auth_service===S.YM.GOOGLE_SERVICE?i.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"setting-list__hint pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.general.emailGoogleCantUpdate",defaultMessage:"Login occurs through Google Apps. Email cannot be updated. Email address used for notifications is {email}.",values:{email:this.state.originalEmail}})),a)):this.props.user.auth_service===S.YM.OFFICE365_SERVICE?i.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"setting-list__hint pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.general.emailOffice365CantUpdate",defaultMessage:"Login occurs through Entra ID. Email cannot be updated. Email address used for notifications is {email}.",values:{email:this.state.originalEmail}})),a)):this.props.user.auth_service===S.YM.OPENID_SERVICE?i.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"setting-list__hint pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.general.emailOpenIdCantUpdate",defaultMessage:"Login occurs through OpenID Connect. Email cannot be updated. Email address used for notifications is {email}.",values:{email:this.state.originalEmail}})),a)):this.props.user.auth_service===S.YM.LDAP_SERVICE?i.push(r().createElement("div",{key:"oauthEmailInfo",className:"pb-2"},r().createElement("div",{className:"setting-list__hint pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.general.emailLdapCantUpdate",defaultMessage:"Login occurs through AD/LDAP. Email cannot be updated. Email address used for notifications is {email}.",values:{email:this.state.originalEmail}})))):this.props.user.auth_service===S.YM.SAML_SERVICE&&i.push(r().createElement("div",{key:"oauthEmailInfo",className:"pb-2"},r().createElement("div",{className:"setting-list__hint pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.general.emailSamlCantUpdate",defaultMessage:"Login occurs through SAML. Email cannot be updated. Email address used for notifications is {email}.",values:{email:this.state.originalEmail}})),a)),s=r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.general.email",defaultMessage:"Email"}),inputs:i,submit:n,saving:this.state.sectionIsSaving,serverError:this.state.serverError,clientError:this.state.emailError,updateSection:this.updateSection})}let i="";return""===this.props.user.auth_service?i=this.props.user.email:this.props.user.auth_service===S.YM.GITLAB_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.general.loginGitlab",defaultMessage:"Login done through GitLab ({email})",values:{email:this.state.originalEmail}}):this.props.user.auth_service===S.YM.GOOGLE_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.general.loginGoogle",defaultMessage:"Login done through Google Apps ({email})",values:{email:this.state.originalEmail}}):this.props.user.auth_service===S.YM.OFFICE365_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.general.loginOffice365",defaultMessage:"Login done through Entra ID ({email})",values:{email:this.state.originalEmail}}):this.props.user.auth_service===S.YM.LDAP_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.general.loginLdap",defaultMessage:"Login done through AD/LDAP ({email})",values:{email:this.state.originalEmail}}):this.props.user.auth_service===S.YM.SAML_SERVICE&&(i=r().createElement(d.FormattedMessage,{id:"user.settings.general.loginSaml",defaultMessage:"Login done through SAML ({email})",values:{email:this.state.originalEmail}})),r().createElement(I,{active:t,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.general.email",defaultMessage:"Email"}),describe:i,section:"email",updateSection:this.updateSection,max:s})}render(){const e=this.createNameSection(),t=this.createNicknameSection(),s=this.createUsernameSection(),i=this.createPositionSection(),a=this.createEmailSection(),n=this.createCustomAttributeSection(),o=this.createPictureSection();return r().createElement("div",{id:"generalSettings"},r().createElement(K,{closeModal:this.props.closeModal,collapseModal:this.props.collapseModal,text:r().createElement(d.FormattedMessage,{id:"user.settings.modal.profile",defaultMessage:"Profile"})}),r().createElement("div",{className:"user-settings"},r().createElement(H,{id:"generalSettingsTitle",text:r().createElement(d.FormattedMessage,{id:"user.settings.modal.profile",defaultMessage:"Profile"})}),r().createElement("div",{className:"divider-dark first"}),e,r().createElement("div",{className:"divider-light"}),s,r().createElement("div",{className:"divider-light"}),t,r().createElement("div",{className:"divider-light"}),i,r().createElement("div",{className:"divider-light"}),a,r().createElement("div",{className:"divider-light"}),n,o,r().createElement("div",{className:"divider-dark"})))}}ut(pt,"propTypes",{updateSection:a().func.isRequired,updateTab:a().func.isRequired,activeSection:a().string,closeModal:a().func.isRequired,collapseModal:a().func.isRequired,isMobileView:a().bool.isRequired,maxFileSize:a().number.isRequired,actions:a().shape({logError:a().func.isRequired,clearErrors:a().func.isRequired,updateMe:a().func.isRequired,sendVerificationEmail:a().func.isRequired,setDefaultProfileImage:a().func.isRequired,uploadProfileImage:a().func.isRequired,saveCustomProfileAttribute:a().func.isRequired,getCustomProfileAttributeFields:a().func.isRequired}).isRequired,requireEmailVerification:a().bool,ldapFirstNameAttributeSet:a().bool,ldapLastNameAttributeSet:a().bool,samlFirstNameAttributeSet:a().bool,samlLastNameAttributeSet:a().bool,ldapNicknameAttributeSet:a().bool,samlNicknameAttributeSet:a().bool,ldapPositionAttributeSet:a().bool,samlPositionAttributeSet:a().bool,ldapPictureAttributeSet:a().bool,enableCustomProfileAttributes:a().bool.isRequired});const ht=(0,d.injectIntl)(pt),gt=(0,p.connect)((function(e){const t=(0,E.zj)(e),s=(0,E.A1)(e),i="true"===t.RequireEmailVerification,a=parseInt(t.MaxFileSize,10),n="true"===t.LdapFirstNameAttributeSet,r="true"===t.LdapLastNameAttributeSet,o="true"===t.SamlFirstNameAttributeSet,l="true"===t.SamlLastNameAttributeSet,c="true"===t.LdapNicknameAttributeSet,d="true"===t.SamlNicknameAttributeSet,u="true"===t.SamlPositionAttributeSet,m="true"===t.LdapPositionAttributeSet,p="true"===t.LdapPictureAttributeSet,h="true"===(0,E.Y6)(e,"CustomProfileAttributes");return{isMobileView:(0,et.w3)(e),requireEmailVerification:i,maxFileSize:a,customProfileAttributeFields:s,ldapFirstNameAttributeSet:n,ldapLastNameAttributeSet:r,samlFirstNameAttributeSet:o,samlLastNameAttributeSet:l,ldapNicknameAttributeSet:c,samlNicknameAttributeSet:d,samlPositionAttributeSet:u,ldapPositionAttributeSet:m,ldapPictureAttributeSet:p,enableCustomProfileAttributes:h}}),(function(e){return{actions:(0,h.bindActionCreators)({logError:Qe.vV,clearErrors:Qe.x8,updateMe:f.Me,sendVerificationEmail:f.kH,setDefaultProfileImage:f.Ae,uploadProfileImage:f.OB,saveCustomProfileAttribute:f.Ah,getCustomProfileAttributeFields:Ze.MG},e)}}))(ht);var ft=s(45955),Et=s(148),vt=s(52231),bt=s(96729),St=s(85406),yt=s(66276),Mt=s(3289),Nt=s(36003),At=s(28580),Tt=s(24867);function _t(){const e=(0,d.useIntl)(),t=(0,n.useCallback)((()=>{window.open("https://mattermost.com/pl/manage-notifications","_blank","noopener,noreferrer")}),[]);return r().createElement("div",{className:"extraContentBeforeSettingList"},r().createElement(Tt.A,{type:"danger",title:e.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDenied.title",defaultMessage:"Browser notification permission was denied"}),text:e.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDenied.message",defaultMessage:"You're missing important message and call notifications from Mattermost. To start receiving notifications, please enable notifications for Mattermost in your browser settings."}),tertiaryButton:{text:e.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDenied.button",defaultMessage:"How to enable notifications"}),onClick:t}}))}var Ct=s(73170);function kt(e){const t=(0,d.useIntl)(),s=(0,n.useCallback)((async()=>{const t=await(0,Ct.mT)();t&&e.onCtaButtonClick(t)}),[e.onCtaButtonClick]);return r().createElement("div",{className:"extraContentBeforeSettingList"},r().createElement(Tt.A,{type:"danger",title:t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionNeverGranted.title",defaultMessage:"Browser notifications are disabled"}),text:t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionNeverGranted.message",defaultMessage:"You're missing important message and call notifications from Mattermost. Mattermost notifications are disabled by this browser."}),primaryButton:{text:t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionNeverGranted.button",defaultMessage:"Enable notifications"}),onClick:s}}))}function wt(){const e=(0,d.useIntl)(),t=(0,n.useCallback)((async()=>{window.open("https://mattermost.com/pl/pc-web-requirements","_blank","noopener,noreferrer")}),[]);return r().createElement("div",{className:"extraContentBeforeSettingList"},r().createElement(Tt.A,{type:"danger",title:e.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionUnsupported.title",defaultMessage:"Browser notifications unsupported"}),text:e.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionUnsupported.message",defaultMessage:"You're missing important message and call notifications from Mattermost. To start receiving notifications, please update to a supported browser."}),tertiaryButton:{text:e.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionUnsupported.button",defaultMessage:"Update your browser"}),onClick:t}}))}function It(e){const t=(0,d.useIntl)(),[s,i]=(0,n.useState)(!1),a=(0,n.useCallback)((()=>{window.open("https://mattermost.com/pl/manage-notifications","_blank","noopener,noreferrer")}),[]),o=s?t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDeniedDesktop.titleDenied",defaultMessage:"Desktop notifications permission was denied"}):t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDeniedDesktop.title",defaultMessage:"Desktop notifications permission required"}),l=s?t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDeniedDesktop.messageDenied",defaultMessage:"Notifications for this Mattermost server are blocked. To receive notifications, please enable them manually."}):t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDeniedDesktop.message",defaultMessage:"You're missing important message and call notifications from Mattermost. To start receiving them, please enable them manually."});return r().createElement("div",{className:"extraContentBeforeSettingList"},r().createElement(Tt.A,{type:"danger",title:o,text:l,primaryButton:{text:t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDeniedDesktop.checkPermissionButton",defaultMessage:"Check permission"}),onClick:async function(){await e.requestDesktopNotificationPermission()===Ct.yv&&i(!0)},disabled:s},tertiaryButton:{text:t.formatMessage({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionDenied.instructionButton",defaultMessage:"How to enable notifications"}),onClick:a}}))}function Rt(){const e=(0,Ct.Ml)(),[t,s]=(0,n.useState)((0,Ct.hH)()),[i,a]=(0,At.L)();return e?i===Ct.yv?r().createElement(It,{requestDesktopNotificationPermission:a}):e&&t===Ct.s$?r().createElement(kt,{onCtaButtonClick:function(e){s(e)}}):e&&t===Ct.yv?r().createElement(_t,null):null:r().createElement(wt,null)}kt.propTypes={onCtaButtonClick:a().func.isRequired},It.propTypes={requestDesktopNotificationPermission:a().func.isRequired};var Pt=s(67416);function Ot(){const{formatMessage:e}=(0,d.useIntl)(),[t]=(0,At.L)();return(0,Ct.Ml)()?(0,Ct.hH)()===Ct.s$||(0,Ct.hH)()===Ct.yv||t===Ct.yv?r().createElement(Pt.A,{size:"sm",variant:"dangerDim",icon:"alert-outline",text:e({id:"user.settings.notifications.desktopAndMobile.notificationSection.permissionIssueTag",defaultMessage:"Permission required"})}):null:r().createElement(Pt.A,{size:"sm",variant:"danger",icon:"alert-outline",text:e({id:"user.settings.notifications.desktopAndMobile.notificationSection.noPermissionIssueTag",defaultMessage:"Not supported"})})}function Dt(e){let{active:t,updateSection:s,onSubmit:i,onCancel:a,saving:o,error:l,setParentState:c,areAllSectionsInactive:u,isCollapsedThreadsEnabled:m,desktopActivity:p,sendPushNotifications:h,pushActivity:g,pushStatus:f,desktopThreads:E,pushThreads:v,desktopAndMobileSettingsDifferent:b}=e;const y=(0,n.useRef)(null),M=(0,n.useRef)(t);(0,n.useEffect)((()=>{var e;M.current&&!t&&u&&(null===(e=y.current)||void 0===e||e.focus()),M.current=t}),[t,u]);const N=(0,n.useCallback)((e=>{const t=e.target.value;c("desktopActivity",t)}),[c]),A=(0,n.useCallback)((e=>{const t=e.target.checked?S.DB.ALL:S.DB.MENTION;c("desktopThreads",t)}),[c]),T=(0,n.useCallback)((e=>{const t=e.target.checked;c("desktopAndMobileSettingsDifferent",t)}),[c]),_=(0,n.useCallback)((e=>{e&&"value"in e&&c("pushActivity",e.value)}),[c]),k=(0,n.useCallback)((e=>{const t=e.target.checked?S.DB.ALL:S.DB.MENTION;c("pushThreads",t)}),[c]),w=(0,n.useCallback)((e=>{e&&"value"in e&&c("pushStatus",e.value)}),[c]),I=(0,n.useMemo)((()=>{const e=[],t=r().createElement("fieldset",{id:"sendDesktopNotificationsSection",key:"sendDesktopNotificationsSection"},r().createElement("legend",{className:"form-legend"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.sendDesktopNotificationFor",defaultMessage:"Send notifications for:"})),Lt.map((e=>r().createElement("div",{key:e.value,className:"radio"},r().createElement("label",null,r().createElement("input",{type:"radio",checked:p===e.value,value:e.value,onChange:N}),e.label)))));if(e.push(t),function(e,t){return!!e&&(t!==S.DB.ALL&&t!==S.DB.NONE)}(m,p)){const t=r().createElement(n.Fragment,{key:"desktopThreadNotificationSection"},r().createElement("br",null),r().createElement("div",{className:"checkbox single-checkbox"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:E===S.DB.ALL,onChange:A}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.notifyForDesktopthreads",defaultMessage:"Notify me about replies to threads I'm following"}))));e.push(t)}if(h){const t=r().createElement(n.Fragment,{key:"differentMobileNotificationsSection"},r().createElement("hr",null),r().createElement("div",{className:"checkbox single-checkbox"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:b,onChange:T}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.differentMobileNotificationsTitle",defaultMessage:"Use different settings for my mobile devices"}))));e.push(t)}if(function(e,t){return!!e&&!!t}(h,b)){const t=r().createElement(r().Fragment,{key:"sendMobileNotificationsSection"},r().createElement("br",null),r().createElement("label",{id:"sendMobileNotificationsLabel",htmlFor:"sendMobileNotificationsSelectInput",className:"singleSelectLabel"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.sendMobileNotificationsFor",defaultMessage:"Send mobile notifications for:"})),r().createElement(Oe.Ay,{inputId:"sendMobileNotificationsSelectInput","aria-labelledby":"sendMobileNotificationsLabel",className:"react-select singleSelect",classNamePrefix:"react-select",options:Lt,clearable:!1,isClearable:!1,isSearchable:!1,components:{IndicatorSeparator:Ft},value:xt(g),onChange:_}));e.push(t)}if(function(e,t,s,i){return!!e&&(!!t&&(!!s&&(i!==S.DB.ALL&&i!==S.DB.NONE)))}(h,m,b,g)){const t=r().createElement(n.Fragment,{key:"threadNotificationSection"},r().createElement("br",null),r().createElement("div",{className:"checkbox single-checkbox"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:v===S.DB.ALL,onChange:k}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.notifyForMobilethreads",defaultMessage:"Notify me on mobile about replies to threads I'm following"}))));e.push(t)}if(function(e,t,s,i){return!!e&&(!t||!s||(i?s!==S.DB.NONE:t!==S.DB.NONE))}(h,p,g,b)){const t=r().createElement(r().Fragment,{key:"triggerMobileNotificationsSection"},r().createElement("br",null),r().createElement("label",{id:"pushMobileNotificationsLabel",htmlFor:"pushMobileNotificationSelectInput",className:"singleSelectLabel"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.pushNotification",defaultMessage:"Trigger mobile notifications when I am:"})),r().createElement(Oe.Ay,{inputId:"pushMobileNotificationSelectInput","aria-labelledby":"pushMobileNotificationsLabel",className:"react-select singleSelect",classNamePrefix:"react-select",options:Ut,clearable:!1,isClearable:!1,isSearchable:!1,components:{IndicatorSeparator:Ft},value:Bt(f),onChange:w}));e.push(t)}if(!h){const t=r().createElement(r().Fragment,null,r().createElement("br",null),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.pushNotificationsDisabled",defaultMessage:"Mobile push notifications haven't been enabled by your system administrator."}));e.push(t)}return e}),[p,N,m,E,A,h,b,T,g,_,v,k,f,w]);return t?r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.title",defaultMessage:"Desktop and mobile notifications"}),inputs:I,submit:i,saving:o,serverError:l,updateSection:function(e){s(e)},extraContentBeforeSettingList:r().createElement(Rt,null)}):r().createElement(C,{ref:y,title:r().createElement(r().Fragment,null,r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.title",defaultMessage:"Desktop and mobile notifications"}),r().createElement(Ot,null)),describe:jt(p,g),section:S.Y$.DESKTOP_AND_MOBILE,updateSection:function(e){s(e),a()}})}function Ft(){return null}const Lt=[{label:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.allNewMessages",defaultMessage:"All new messages"}),value:S.DB.ALL},{label:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.onlyMentions",defaultMessage:"Mentions, direct messages, and group messages"}),value:S.DB.MENTION},{label:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.nothing",defaultMessage:"Nothing"}),value:S.DB.NONE}];function xt(e){if(!e)return Lt[1];return Lt.find((t=>t.value===e))||Lt[1]}const Ut=[{label:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.online",defaultMessage:"Online, away, or offline"}),value:S.Ay.UserStatuses.ONLINE},{label:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.away",defaultMessage:"Away or offline"}),value:S.Ay.UserStatuses.AWAY},{label:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.offline",defaultMessage:"Offline"}),value:S.Ay.UserStatuses.OFFLINE}];function Bt(e){if(!e)return Ut[2];return Ut.find((t=>t.value===e))||Ut[2]}function jt(e,t){if(e===S.DB.ALL){if(t===S.DB.ALL)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.allForDesktopAndMobile",defaultMessage:"All new messages"});if(t===S.DB.MENTION)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.allDesktopButMobileMentions",defaultMessage:"All new messages on desktop; mentions, direct messages, and group messages on mobile"});if(t===S.DB.NONE)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.allDesktopButMobileNone",defaultMessage:"All new messages on desktop; never on mobile"})}else if(e===S.DB.MENTION){if(t===S.DB.ALL)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.mentionsDesktopButMobileAll",defaultMessage:"Mentions, direct messages, and group messages on desktop; all new messages on mobile"});if(t===S.DB.MENTION)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.mentionsForDesktopAndMobile",defaultMessage:"Mentions, direct messages, and group messages"});if(t===S.DB.NONE)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.mentionsForDesktopButMobileNone",defaultMessage:"Mentions, direct messages, and group messages on desktop; never on mobile"})}else if(e===S.DB.NONE){if(t===S.DB.ALL)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.noneDesktopButMobileAll",defaultMessage:"Never on desktop; all new messages on mobile"});if(t===S.DB.MENTION)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.noneDesktopButMobileMentions",defaultMessage:"Never on desktop; mentions, direct messages, and group messages on mobile"});if(t===S.DB.NONE)return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.noneForDesktopAndMobile",defaultMessage:"Never"})}return r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopAndMobile.noValidSettings",defaultMessage:"Configure desktop and mobile settings"})}const qt=(0,n.memo)(Dt);function Gt(e){let{active:t,updateSection:s,onSubmit:i,onCancel:a,saving:o,error:l,setParentState:c,areAllSectionsInactive:u,desktopSound:m,desktopNotificationSound:p,isCallsRingingEnabled:h,callsDesktopSound:g,callsNotificationSound:f}=e;const E=(0,d.useIntl)(),v=(0,n.useRef)(null),b=(0,n.useRef)(t);(0,n.useEffect)((()=>{var e;b.current&&!t&&u&&(null===(e=v.current)||void 0===e||e.focus()),b.current=t}),[t,u]);const y=(0,n.useCallback)((e=>{const t=e.target.checked?"true":"false";c("desktopSound",t),"false"===t&&(0,Nt.$c)()}),[c]),M=(0,n.useCallback)((e=>{const t=e.target.checked?"true":"false";c("callsDesktopSound",t),"false"===t&&(0,Nt.$c)()}),[c]),N=(0,n.useCallback)((e=>{(0,Nt.$c)(),e&&"value"in e&&(c("desktopNotificationSound",e.value),(0,Nt.Yx)(e.value))}),[c]),A=(0,n.useCallback)((e=>{(0,Nt.$c)(),e&&"value"in e&&(c("callsNotificationSound",e.value),(0,Nt.n_)(e.value))}),[c]),T=(0,n.useMemo)((()=>{const e=[],t="true"===m,s=r().createElement(n.Fragment,{key:"messageSoundSection"},r().createElement("div",{className:"checkbox inlineCheckboxSelect"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:"true"===m,onChange:y}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.messageNotificationSound",defaultMessage:"Message notification sound"})),r().createElement(Oe.Ay,{id:"messageNotificationSoundSelect",inputId:"messageNotificationSoundSelectInput",className:"react-select inlineSelect",classNamePrefix:"react-select",options:Nt.Il,clearable:!1,isClearable:!1,isSearchable:!1,isDisabled:!t,placeholder:E.formatMessage({id:"user.settings.notifications.desktopNotificationSound.soundSelectPlaceholder",defaultMessage:"Select a sound"}),components:{IndicatorSeparator:Wt},value:(0,Nt.ed)(p),onChange:N})));if(e.push(s),h){const t="true"===g,s=r().createElement(n.Fragment,{key:"callSoundSection"},r().createElement("br",null),r().createElement("div",{className:"checkbox inlineCheckboxSelect"},r().createElement("label",null,r().createElement("input",{type:"checkbox",checked:t,onChange:M}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.incomingCallSound",defaultMessage:"Incoming call sound"})),r().createElement(Oe.Ay,{id:"incomingCallSoundNotificationSelect",inputId:"incomingCallSoundNotificationSelectInput",className:"react-select inlineSelect",classNamePrefix:"react-select",options:Nt.s5,clearable:!1,isClearable:!1,isSearchable:!1,isDisabled:!t,components:{IndicatorSeparator:Wt},placeholder:E.formatMessage({id:"user.settings.notifications.desktopNotificationSound.soundSelectPlaceholder",defaultMessage:"Select a sound"}),value:(0,Nt.rP)(f),onChange:A})));e.push(s)}return e}),[m,y,N,p,h,g,M,f,A]);return t?r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSounds.title",defaultMessage:"Desktop notification sounds"}),inputs:T,submit:function(){(0,Nt.$c)(),i()},saving:o,serverError:l,updateSection:function(e){(0,Nt.$c)(),s(e)}}):r().createElement(C,{ref:v,title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSounds.title",defaultMessage:"Desktop notification sounds"}),describe:Yt(h,m,p,g,f),section:S.Y$.DESKTOP_NOTIFICATION_SOUND,updateSection:function(e){(0,Nt.$c)(),s(e),a()}})}function Wt(){return null}function Yt(e,t,s,i,a){const n=Nt.x.includes(s),o=Nt.zJ.includes(a);let l=null;e&&o&&(l="true"===i);let c=null;return n&&(c="true"===t),null!==c&&null!==l?c&&l?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.hasDesktopAndCallsSound",defaultMessage:'"{desktopSound}" for messages, "{callsSound}" for calls',values:{desktopSound:s,callsSound:a}}):!c&&l?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.noDesktopAndhasCallsSound",defaultMessage:'No sound for messages, "{callsSound}" for calls',values:{callsSound:a}}):c&&!l?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.hasDesktopAndNoCallsSound",defaultMessage:'"{desktopSound}" for messages, no sound for calls',values:{desktopSound:s}}):r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.noDesktopAndNoCallsSound",defaultMessage:"No sound"}):null!==c&&null===l?c?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.hasDesktopSound",defaultMessage:'"{desktopSound}" for messages',values:{desktopSound:s}}):r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.noDesktopSound",defaultMessage:"No sound"}):r().createElement(d.FormattedMessage,{id:"user.settings.notifications.desktopNotificationSound.noValidSound",defaultMessage:"Configure desktop notification sounds"})}Gt.propTypes={active:a().bool.isRequired,updateSection:a().func.isRequired,onSubmit:a().func.isRequired,onCancel:a().func.isRequired,saving:a().bool.isRequired,error:a().string.isRequired,setParentState:a().func.isRequired,areAllSectionsInactive:a().bool.isRequired};const Ht=(0,n.memo)(Gt);var Vt=s(3569);function Kt(e,t,s){const{INTERVAL_NEVER:i,INTERVAL_IMMEDIATE:a,INTERVAL_FIFTEEN_MINUTES:n,INTERVAL_HOUR:r}=L.pm,o=[a,i];return e?t&&-1===[a,i,n,r].indexOf(s)?n:t||-1!==o.indexOf(s)?e&&s===i?a:s:a:i}function zt(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Jt extends r().PureComponent{constructor(e){super(e),zt(this,"handleChange",(e=>{const t=e.currentTarget.getAttribute("data-enable-email"),s=parseInt(e.currentTarget.getAttribute("data-email-interval"),10);this.setState({enableEmail:"true"===t,newInterval:s}),(0,T.b6)(e.currentTarget),this.props.onChange(t)})),zt(this,"handleThreadsOnChange",(e=>{const t=e.target.checked?S.DB.ALL:S.DB.MENTION;this.props.setParentState("emailThreads",t)})),zt(this,"handleSubmit",(async()=>{const{newInterval:e}=this.state;if(this.props.emailInterval===e&&this.props.enableEmail===this.state.enableEmail)this.props.updateSection("");else{const{currentUserId:t,actions:s}=this.props,i={user_id:t,category:S.pm.CATEGORY_NOTIFICATIONS,name:S.pm.EMAIL_INTERVAL,value:e.toString()};await s.savePreferences(t,[i])}this.props.onSubmit()})),zt(this,"handleUpdateSection",(e=>{e?this.props.updateSection(e):(this.props.updateSection(""),this.setState({enableEmail:this.props.enableEmail,newInterval:this.props.emailInterval}),this.props.onCancel())})),zt(this,"renderMinSettingView",(()=>{const{enableEmail:e,sendEmailNotifications:t}=this.props,{newInterval:s}=this.state;let i;if(t)if(e)switch(s){case S.pm.INTERVAL_IMMEDIATE:i=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.immediately",defaultMessage:"Immediately"});break;case S.pm.INTERVAL_HOUR:i=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.everyHour",defaultMessage:"Every hour"});break;case S.pm.INTERVAL_FIFTEEN_MINUTES:i=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.everyXMinutes",defaultMessage:"Every {count, plural, one {minute} other {{count, number} minutes}}",values:{count:s/60}});break;default:i=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.never",defaultMessage:"Never"})}else i=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.never",defaultMessage:"Never"});else i=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.disabled",defaultMessage:"Email notifications are not enabled"});return r().createElement(C,{ref:this.editButtonRef,title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.emailNotifications",defaultMessage:"Email notifications"}),describe:i,section:"email",updateSection:this.handleUpdateSection})})),zt(this,"renderMaxSettingView",(()=>{if(!this.props.sendEmailNotifications)return r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.emailNotifications",defaultMessage:"Email notifications"}),inputs:[r().createElement("div",{key:"oauthEmailInfo",className:"pt-2"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.disabled_long",defaultMessage:"Email notifications have not been enabled by your System Administrator."}))],serverError:this.props.error,section:"email",updateSection:this.handleUpdateSection});const{newInterval:e}=this.state;let t=null,s=null;this.props.enableEmailBatching&&(t=r().createElement("fieldset",null,r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"emailNotificationMinutes",type:"radio",name:"emailNotifications",checked:e===S.pm.INTERVAL_FIFTEEN_MINUTES,"data-enable-email":"true","data-email-interval":S.pm.INTERVAL_FIFTEEN_MINUTES,onChange:this.handleChange}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.everyXMinutes",defaultMessage:"Every {count, plural, one {minute} other {{count, number} minutes}}",values:{count:S.pm.INTERVAL_FIFTEEN_MINUTES/60}}))),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"emailNotificationHour",type:"radio",name:"emailNotifications",checked:e===S.pm.INTERVAL_HOUR,"data-enable-email":"true","data-email-interval":S.pm.INTERVAL_HOUR,onChange:this.handleChange}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.everyHour",defaultMessage:"Every hour"})))),s=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.emailBatchingInfo",defaultMessage:"Notifications received over the time period selected are combined and sent in a single email."}));let i=null;return this.props.isCollapsedThreadsEnabled&&this.props.enableEmail&&(i=r().createElement(r().Fragment,{key:"userNotificationEmailThreadsOptions"},r().createElement("hr",null),r().createElement("fieldset",null,r().createElement("div",{className:"checkbox single-checkbox"},r().createElement("label",null,r().createElement("input",{id:"desktopThreadsNotificationAllActivity",type:"checkbox",name:"desktopThreadsNotificationLevel",checked:this.props.threads===S.DB.ALL,onChange:this.handleThreadsOnChange}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.notifyForthreads",defaultMessage:"Notify me about replies to threads I’m following"})))))),r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.emailNotifications",defaultMessage:"Email notifications"}),inputs:[r().createElement("fieldset",{key:"userNotificationEmailOptions"},r().createElement("legend",{className:"form-legend"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.send",defaultMessage:"Send email notifications"})),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"emailNotificationImmediately",type:"radio",name:"emailNotifications",checked:e===S.pm.INTERVAL_IMMEDIATE,"data-enable-email":"true","data-email-interval":S.pm.INTERVAL_IMMEDIATE,onChange:this.handleChange}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.immediately",defaultMessage:"Immediately"}))),t,r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"emailNotificationNever",type:"radio",name:"emailNotifications",checked:e===S.pm.INTERVAL_NEVER,"data-enable-email":"false","data-email-interval":S.pm.INTERVAL_NEVER,onChange:this.handleChange}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.email.never",defaultMessage:"Never"}))),r().createElement("div",{className:"mt-3"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.emailInfo",defaultMessage:"Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."})," ",s)),i],submit:this.handleSubmit,saving:this.props.saving,serverError:this.props.error,updateSection:this.handleUpdateSection})}));const{emailInterval:t,enableEmail:s,enableEmailBatching:i,sendEmailNotifications:a,active:n}=e;this.state={active:n,emailInterval:t,enableEmail:s,enableEmailBatching:i,sendEmailNotifications:a,newInterval:Kt(s&&a,i,t)},this.editButtonRef=r().createRef()}static getDerivedStateFromProps(e,t){const{emailInterval:s,enableEmail:i,enableEmailBatching:a,sendEmailNotifications:n,active:r}=e;return r&&!t.active||n!==t.sendEmailNotifications||a!==t.enableEmailBatching||s!==t.emailInterval||r!==t.active?{active:r,emailInterval:s,enableEmail:i,enableEmailBatching:a,sendEmailNotifications:n,newInterval:Kt(i&&n,a,s)}:null}focusEditButton(){var e;null===(e=this.editButtonRef.current)||void 0===e||e.focus()}componentDidUpdate(e){e.active&&!this.props.active&&this.props.areAllSectionsInactive&&this.focusEditButton()}render(){return this.props.active?this.renderMaxSettingView():this.renderMinSettingView()}}zt(Jt,"propTypes",{active:a().bool.isRequired,updateSection:a().func.isRequired,onSubmit:a().func.isRequired,onCancel:a().func.isRequired,saving:a().bool,error:a().string,setParentState:a().func.isRequired,areAllSectionsInactive:a().bool.isRequired,isCollapsedThreadsEnabled:a().bool.isRequired,enableEmail:a().bool.isRequired,onChange:a().func.isRequired,threads:a().string.isRequired,currentUserId:a().string.isRequired,emailInterval:a().number.isRequired,sendEmailNotifications:a().bool.isRequired,enableEmailBatching:a().bool.isRequired,actions:a().shape({savePreferences:a().func.isRequired}).isRequired});const $t=(0,p.connect)((function(e){const t=(0,E.zj)(e),s=parseInt((0,v.Jt)(e,L.pm.CATEGORY_NOTIFICATIONS,L.pm.EMAIL_INTERVAL,L.pm.INTERVAL_NOT_SET.toString()),10);return{currentUserId:(0,Vt.WR)(e),emailInterval:s,enableEmailBatching:"true"===t.EnableEmailBatching,sendEmailNotifications:"true"===t.SendEmailNotifications}}),(function(e){return{actions:(0,h.bindActionCreators)({savePreferences:g.SF},e)}}))(Jt);var Xt=s(5986);function Qt(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Zt extends r().PureComponent{constructor(){super(...arguments),Qt(this,"handleAutoResponderChecked",(e=>{this.props.setParentState("autoResponderActive",e.target.checked)})),Qt(this,"onMessageChanged",(e=>{this.props.setParentState("autoResponderMessage",e.target.value)}))}render(){const{autoResponderActive:e,autoResponderMessage:t}=this.props;let s;this.props.error&&(s=r().createElement("label",{className:"has-error"},this.props.error));const i=[],a=r().createElement("div",{id:"autoResponderCheckbox",key:"autoResponderCheckbox",className:"checkbox"},r().createElement("label",null,r().createElement("input",{id:"autoResponderActive",type:"checkbox",checked:e,onChange:this.handleAutoResponderChecked}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.autoResponderEnabled",defaultMessage:"Enabled"}))),n=r().createElement("div",{id:"autoResponderMessage",key:"autoResponderMessage"},r().createElement("div",{className:"pt-2"},r().createElement(Xt.A,{style:{resize:"none"},id:"autoResponderMessageInput",className:"form-control",rows:5,placeholder:(0,d.defineMessage)({id:"user.settings.notifications.autoResponderPlaceholder",defaultMessage:"Message"}),value:t,maxLength:200,onChange:this.onMessageChanged}),s));return i.push(a),e&&i.push(n),i.push(r().createElement("div",{key:"autoResponderHint",className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.autoResponderHint",defaultMessage:"Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications."}))),r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.autoResponder",defaultMessage:"Automatic direct message replies"}),shiftEnter:!0,submit:this.props.submit,saving:this.props.saving,inputs:i,updateSection:this.props.updateSection})}}var es=s(21363),ts=s(99424);const ss={marginTop:20},is=e=>{let{adminMode:t=!1}=e;const s=(0,d.useIntl)(),[i,a]=(0,n.useState)("idle"),o=(0,n.useRef)(!1),l=(0,n.useRef)(),[c]=(0,ts.v)("https://mattermost.com/pl/troubleshoot-notifications"),u=(0,n.useCallback)((()=>{window.open(c)}),[c]),m=(0,n.useCallback)((async()=>{if(o.current)return;o.current=!0;let e=!1;l.current=setTimeout((()=>{e=!0,a("sending")}),500);const t=await(0,es.yg)();clearTimeout(l.current);const s=()=>{"OK"===t.status?a("sent"):(console.error(t),a("error")),l.current=setTimeout((()=>{o.current=!1,a("idle")}),3e3)};e?l.current=setTimeout(s,500):s()}),[]);(0,n.useEffect)((()=>()=>{clearTimeout(l.current)}),[]);const p=(0,n.useMemo)((()=>{let e,t,a;switch(i){case"idle":e=s.formatMessage({id:"user_settings.notifications.test_notification.send_button.send",defaultMessage:"Send a test notification"});break;case"sending":e=s.formatMessage({id:"user_settings.notifications.test_notification.send_button.sending",defaultMessage:"Sending a test notification"}),a=!0;break;case"sent":e=s.formatMessage({id:"user_settings.notifications.test_notification.send_button.sent",defaultMessage:"Test notification sent"}),t="icon-check";break;case"error":e=s.formatMessage({id:"user_settings.notifications.test_notification.send_button.error",defaultMessage:"Error sending test notification"}),t="icon-alert-outline"}return{onClick:m,text:e,leadingIcon:t,loading:a}}),[i,s,m]),h=(0,n.useMemo)((()=>({onClick:u,text:s.formatMessage({id:"user_settings.notifications.test_notification.go_to_docs",defaultMessage:"Troubleshooting docs"}),trailingIcon:"icon-open-in-new"})),[s,u]);return t?null:r().createElement(r().Fragment,null,r().createElement("div",{className:"divider-light"}),r().createElement("div",{style:ss},r().createElement(Tt.A,{text:s.formatMessage({id:"user_settings.notifications.test_notification.body",defaultMessage:"Not receiving notifications? Start by sending a test notification to all your devices to check if they’re working as expected. If issues persist, explore ways to solve them with troubleshooting steps."}),title:s.formatMessage({id:"user_settings.notifications.test_notification.title",defaultMessage:"Troubleshooting notifications"}),primaryButton:p,tertiaryButton:h,type:"hint"})))};is.propTypes={adminMode:a().bool};const as=is;function ns(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function rs(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?ns(Object(s),!0).forEach((function(t){os(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ns(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function os(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const ls=/\s+/g,cs=/,/g;function ds(e){let t=S.DB.MENTION,s=S.DB.ALL,i=S.DB.ALL,a=S.DB.ALL,n="true",r="true",o=Nt.x[0],l="Calm",c="never",d="true",u=S.DB.MENTION,m=S.Ay.UserStatuses.AWAY,p=!1,h=e.intl.formatMessage({id:"user.settings.notifications.autoResponderDefault",defaultMessage:"Hello, I am out of office and unable to respond to messages."}),g=!0;var f,E;e.user.notify_props&&(e.user.notify_props.desktop&&(t=e.user.notify_props.desktop),e.user.notify_props.desktop_threads&&(s=e.user.notify_props.desktop_threads),e.user.notify_props.push_threads&&(i=e.user.notify_props.push_threads),e.user.notify_props.email_threads&&(a=e.user.notify_props.email_threads),e.user.notify_props.desktop_sound&&(n=e.user.notify_props.desktop_sound),e.user.notify_props.calls_desktop_sound&&(r=e.user.notify_props.calls_desktop_sound),e.user.notify_props.desktop_notification_sound&&(o=e.user.notify_props.desktop_notification_sound),e.user.notify_props.calls_notification_sound&&(l=e.user.notify_props.calls_notification_sound),e.user.notify_props.comments&&(c=e.user.notify_props.comments),e.user.notify_props.email&&(d=e.user.notify_props.email),e.user.notify_props.push&&(u=e.user.notify_props.push),e.user.notify_props.push_status&&(m=e.user.notify_props.push_status),e.user.notify_props.auto_responder_active&&(p="true"===e.user.notify_props.auto_responder_active),e.user.notify_props.auto_responder_message&&(h=e.user.notify_props.auto_responder_message),e.user.notify_props.desktop&&e.user.notify_props.push&&(g=function(e,t,s,i,a){return!(e&&t&&s&&i)||(!(ps.includes(e)&&ps.includes(t)&&ps.includes(s)&&ps.includes(i))||(e!==t||!!a&&s!==i))}(e.user.notify_props.desktop,e.user.notify_props.push,null===(f=e.user.notify_props)||void 0===f?void 0:f.desktop_threads,null===(E=e.user.notify_props)||void 0===E?void 0:E.push_threads,e.isCollapsedThreadsEnabled)));let v=!1,b=!1,y=!1,M=!1;const N=[],A=[];if(e.user.notify_props){var T,_,C,k,w,I;if((null===(T=e.user.notify_props)||void 0===T||null===(_=T.mention_keys)||void 0===_?void 0:_.length)>0){const t=e.user.notify_props.mention_keys.split(",").filter((e=>e.length>0));t.forEach((t=>{t!==e.user.username&&t!=="@".concat(e.user.username)&&N.push({label:t,value:t})})),v=t.includes(e.user.username),M=N.length>0}(null===(C=e.user.notify_props)||void 0===C||null===(k=C.highlight_keys)||void 0===k?void 0:k.length)>0&&e.user.notify_props.highlight_keys.split(",").filter((e=>e.length>0)).forEach((e=>{A.push({label:e,value:e})})),b="true"===(null===(w=e.user.notify_props)||void 0===w?void 0:w.first_name),y="true"===(null===(I=e.user.notify_props)||void 0===I?void 0:I.channel)}return{desktopActivity:t,desktopThreads:s,pushThreads:i,emailThreads:a,enableEmail:d,pushActivity:u,pushStatus:m,desktopSound:n,callsDesktopSound:r,desktopNotificationSound:o,callsNotificationSound:l,usernameKey:v,customKeysWithNotification:N,isCustomKeysWithNotificationInputChecked:M,customKeysWithNotificationInputValue:"",customKeysWithHighlight:A,customKeysWithHighlightInputValue:"",firstNameKey:b,channelKey:y,autoResponderActive:p,autoResponderMessage:h,notifyCommentsLevel:c,isSaving:!1,serverError:"",desktopAndMobileSettingsDifferent:g}}class us extends r().PureComponent{constructor(e){super(e),os(this,"handleSubmit",(async()=>{var e;const t=rs({},this.props.user.notify_props);t.email=this.state.enableEmail,t.desktop_sound=this.state.desktopSound,t.calls_desktop_sound=this.state.callsDesktopSound,t.desktop_notification_sound=this.state.desktopNotificationSound,t.calls_notification_sound=this.state.callsNotificationSound,t.desktop=this.state.desktopActivity,t.desktop_threads=this.state.desktopThreads,t.email_threads=this.state.emailThreads,t.push_status=this.state.pushStatus,t.comments=this.state.notifyCommentsLevel,t.auto_responder_active=this.state.autoResponderActive?"true":"false",t.auto_responder_message=this.state.autoResponderMessage,t.first_name=this.state.firstNameKey?"true":"false",t.channel=this.state.channelKey?"true":"false",this.state.desktopAndMobileSettingsDifferent?(t.push=this.state.pushActivity,t.push_threads=this.state.pushThreads):(t.push=this.state.desktopActivity,t.push_threads=this.state.desktopThreads),t.auto_responder_message&&""!==t.auto_responder_message||(t.auto_responder_message=this.props.intl.formatMessage({id:"user.settings.notifications.autoResponderDefault",defaultMessage:"Hello, I am out of office and unable to respond to messages."}));const s=[];this.state.usernameKey&&s.push(this.props.user.username),this.state.isCustomKeysWithNotificationInputChecked&&this.state.customKeysWithNotification.length>0&&this.state.customKeysWithNotification.forEach((e=>{s.push(e.value)})),t.mention_keys=s.join(",");const i=[];let a,n;if(this.state.customKeysWithHighlight.length>0&&this.state.customKeysWithHighlight.forEach((e=>{i.push(e.value)})),t.highlight_keys=i.join(","),(null===(e=this.props.user.notify_props)||void 0===e?void 0:e.highlight_keys)!==t.highlight_keys&&t.highlight_keys.length>0&&(0,le.AC)(yt.TrackPassiveKeywordsFeature,yt.TrackPassiveKeywordsEvent),this.setState({isSaving:!0}),(0,Nt.$c)(),this.props.adminMode){const e=rs(rs({},this.props.user),{},{notify_props:t}),s=await this.props.patchUser(e);a=s.data,n=s.error}else{const e=await this.props.updateMe({notify_props:t});a=e.data,n=e.error}a?(this.handleUpdateSection(""),this.setState(ds(this.props))):n?this.setState({serverError:n.message,isSaving:!1}):this.setState({serverError:"",isSaving:!1})})),os(this,"handleCancel",(()=>{this.setState(ds(this.props)),(0,Nt.$c)()})),os(this,"handleUpdateSection",(e=>{e?this.props.updateSection(e):this.props.updateSection(""),this.setState({isSaving:!1}),this.handleCancel()})),os(this,"setStateValue",((e,t)=>{const s={};s[e]=t,this.setState((e=>rs(rs({},e),s)))})),os(this,"handleNotifyCommentsRadio",((e,t)=>{this.setState({notifyCommentsLevel:e}),(0,T.b6)(null==t?void 0:t.currentTarget)})),os(this,"handleEmailRadio",(e=>{this.setState({enableEmail:e})})),os(this,"handleChangeForUsernameKeyCheckbox",(e=>{const{target:{checked:t}}=e;this.setState({usernameKey:t})})),os(this,"handleChangeForFirstNameKeyCheckbox",(e=>{const{target:{checked:t}}=e;this.setState({firstNameKey:t})})),os(this,"handleChangeForChannelKeyCheckbox",(e=>{const{target:{checked:t}}=e;this.setState({channelKey:t})})),os(this,"handleChangeForCustomKeysWithNotificationCheckbox",(e=>{const{target:{checked:t}}=e;this.setState({isCustomKeysWithNotificationInputChecked:t})})),os(this,"handleChangeForCustomKeysWithNotificationInput",(e=>{if(e&&Array.isArray(e)&&e.length>0){!1===this.state.isCustomKeysWithNotificationInputChecked&&this.setState({isCustomKeysWithNotificationInputChecked:!0});const t=e.map((e=>{const t=e.value.trim().replace(ls,"");return{value:t,label:t}})).filter((e=>e.value.length>0));this.setState({customKeysWithNotification:t})}else this.setState({isCustomKeysWithNotificationInputChecked:!1,customKeysWithNotification:[]})})),os(this,"updateCustomKeysWithNotificationWithInputValue",(e=>{const t=[...this.state.customKeysWithNotification,{value:e,label:e}];this.setState({customKeysWithNotification:t,customKeysWithNotificationInputValue:""}),this.state.isCustomKeysWithNotificationInputChecked||this.setState({isCustomKeysWithNotificationInputChecked:!0})})),os(this,"handleOnKeydownForCustomKeysWithNotificationInput",(e=>{if(e.key===S.Ay.KeyCodes.COMMA[0]||e.key===S.Ay.KeyCodes.TAB[0]){var t,s,i,a;const e=null!==(t=null===(s=this.state.customKeysWithNotificationInputValue)||void 0===s||null===(i=s.trim())||void 0===i||null===(a=i.replace(ls,""))||void 0===a?void 0:a.replace(cs,""))&&void 0!==t?t:"";e.length>0&&this.updateCustomKeysWithNotificationWithInputValue(e)}})),os(this,"handleChangeForCustomKeysWithNotificationInputValue",(e=>{if(!e.includes(S.Ay.KeyCodes.COMMA[0])){const t=e.trim().replace(ls,"");this.setState({customKeysWithNotificationInputValue:t})}})),os(this,"handleBlurForCustomKeysWithNotificationInput",(()=>{var e,t,s,i;const a=null!==(e=null===(t=this.state.customKeysWithNotificationInputValue)||void 0===t||null===(s=t.trim())||void 0===s||null===(i=s.replace(ls,""))||void 0===i?void 0:i.replace(cs,""))&&void 0!==e?e:"";a.length>0&&this.updateCustomKeysWithNotificationWithInputValue(a)})),os(this,"handleChangeForCustomKeysWithHighlightInput",(e=>{if(e&&Array.isArray(e)&&e.length>0){const t=e.map((e=>{const t=e.value.trim();return{value:t,label:t}})).filter((e=>e.value.length>0));this.setState({customKeysWithHighlight:t})}else this.setState({customKeysWithHighlight:[]})})),os(this,"handleChangeForCustomKeysWithHighlightInputValue",(e=>{e.includes(S.Ay.KeyCodes.COMMA[0])||this.setState({customKeysWithHighlightInputValue:e})})),os(this,"updateCustomKeysWithHighlightWithInputValue",(e=>{var t,s;const i=null!==(t=null==e||null===(s=e.trim())||void 0===s?void 0:s.replace(cs,""))&&void 0!==t?t:"";if(i.length>0){const e=[...this.state.customKeysWithHighlight,{value:i,label:i}];this.setState({customKeysWithHighlight:e,customKeysWithHighlightInputValue:""})}})),os(this,"handleBlurForCustomKeysWithHighlightInput",(()=>{this.updateCustomKeysWithHighlightWithInputValue(this.state.customKeysWithHighlightInputValue)})),os(this,"handleOnKeydownForCustomKeysWithHighlightInput",(e=>{e.key!==S.Ay.KeyCodes.COMMA[0]&&e.key!==S.Ay.KeyCodes.TAB[0]||this.updateCustomKeysWithHighlightWithInputValue(this.state.customKeysWithHighlightInputValue)})),os(this,"handleCloseSettingsModal",(()=>{this.props.closeModal()})),os(this,"createKeywordsWithNotificationSection",(()=>{const e=this.state.serverError,t=this.props.user,s=this.props.activeSection===S.Y$.KEYWORDS_MENTIONS;let i=null;if(s){const s=[];t.first_name&&s.push(r().createElement("div",{key:"userNotificationFirstNameOption"},r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{id:"notificationTriggerFirst",type:"checkbox",checked:this.state.firstNameKey,onChange:this.handleChangeForFirstNameKeyCheckbox}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.sensitiveName",defaultMessage:'Your case-sensitive first name "{first_name}"',values:{first_name:t.first_name}}))))),s.push(r().createElement("div",{key:"userNotificationUsernameOption"},r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{id:"notificationTriggerUsername",type:"checkbox",checked:this.state.usernameKey,onChange:this.handleChangeForUsernameKeyCheckbox}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.sensitiveUsername",defaultMessage:'Your non case-sensitive username "{username}"',values:{username:t.username}}))))),s.push(r().createElement("div",{key:"userNotificationChannelOption"},r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{id:"notificationTriggerShouts",type:"checkbox",checked:this.state.channelKey,onChange:this.handleChangeForChannelKeyCheckbox}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.channelWide",defaultMessage:'Channel-wide mentions "@channel", "@all", "@here"'}))))),s.push(r().createElement("div",{key:"userNotificationCustomOption",className:"customKeywordsWithNotificationSubsection"},r().createElement("div",{className:"checkbox"},r().createElement("label",null,r().createElement("input",{id:"notificationTriggerCustom",type:"checkbox",checked:this.state.isCustomKeysWithNotificationInputChecked,onChange:this.handleChangeForCustomKeysWithNotificationCheckbox}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.sensitiveCustomWords",defaultMessage:"Other non case-sensitive words, press Tab or use commas to separate keywords:"}))),r().createElement(bt.Ay,{inputId:"notificationTriggerCustomText",autoFocus:!0,isClearable:!1,isMulti:!0,styles:ms,placeholder:"",components:{DropdownIndicator:()=>null,Menu:()=>null,MenuList:()=>null},"aria-labelledby":"notificationTriggerCustom",onChange:this.handleChangeForCustomKeysWithNotificationInput,value:this.state.customKeysWithNotification,inputValue:this.state.customKeysWithNotificationInputValue,onInputChange:this.handleChangeForCustomKeysWithNotificationInputValue,onBlur:this.handleBlurForCustomKeysWithNotificationInput,onKeyDown:this.handleOnKeydownForCustomKeysWithNotificationInput})));const a=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.keywordsWithNotification.extraInfo",defaultMessage:'Notifications are triggered when someone sends a message that includes your username ("@{username}") or any of the options selected above.',values:{username:t.username}});i=r().createElement(D,{title:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithNotification.title",defaultMessage:"Keywords that trigger notifications"}),inputs:s,submit:this.handleSubmit,saving:this.state.isSaving,serverError:e,extraInfo:a,updateSection:this.handleUpdateSection})}const a=["@"+t.username];if(this.state.firstNameKey&&a.push(t.first_name),this.state.usernameKey&&a.push(t.username),this.state.channelKey&&(a.push("@channel"),a.push("@all"),a.push("@here")),this.state.customKeysWithNotification.length>0){const e=this.state.customKeysWithNotification.map((e=>e.value));a.push(...e)}const n=a.filter((e=>0!==e.trim().length)).map((e=>'"'.concat(e,'"'))).join(", ");return r().createElement(I,{title:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithNotification.title",defaultMessage:"Keywords that trigger notifications"}),section:S.Y$.KEYWORDS_MENTIONS,active:s,areAllSectionsInactive:""===this.props.activeSection,describe:n,updateSection:this.handleUpdateSection,max:i})})),os(this,"createKeywordsWithHighlightSection",(()=>{const e=this.props.activeSection===S.Y$.KEYWORDS_HIGHLIGHT;let t=null;if(e){const e=[r().createElement("div",{key:"userNotificationHighlightOption",className:"customKeywordsWithNotificationSubsection"},r().createElement("label",{htmlFor:"mentionKeysWithHighlightInput"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.keywordsWithHighlight.inputTitle",defaultMessage:"Enter non case-sensitive keywords, press Tab or use commas to separate them:"})),r().createElement(bt.Ay,{inputId:"mentionKeysWithHighlightInput",autoFocus:!0,isClearable:!1,isMulti:!0,styles:ms,placeholder:"",components:{DropdownIndicator:()=>null,Menu:()=>null,MenuList:()=>null},"aria-labelledby":"mentionKeysWithHighlightInput",onChange:this.handleChangeForCustomKeysWithHighlightInput,value:this.state.customKeysWithHighlight,inputValue:this.state.customKeysWithHighlightInputValue,onInputChange:this.handleChangeForCustomKeysWithHighlightInputValue,onBlur:this.handleBlurForCustomKeysWithHighlightInput,onKeyDown:this.handleOnKeydownForCustomKeysWithHighlightInput}))],s=r().createElement(d.FormattedMessage,{id:"user.settings.notifications.keywordsWithHighlight.extraInfo",defaultMessage:"These keywords will be shown to you with a highlight when anyone sends a message that includes them."});t=r().createElement(D,{title:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.title",defaultMessage:"Keywords that get highlighted (without notifications)"}),inputs:e,submit:this.handleSubmit,saving:this.state.isSaving,serverError:this.state.serverError,extraInfo:s,updateSection:this.handleUpdateSection})}let s=this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.none",defaultMessage:"None"});!this.props.isEnterpriseOrCloudOrSKUStarterFree&&this.props.isEnterpriseReady&&this.state.customKeysWithHighlight.length>0&&(s=this.state.customKeysWithHighlight.map((e=>e.value)).map((e=>'"'.concat(e,'"'))).join(", "));const i=r().createElement(Mt.A,{blocked:this.props.isEnterpriseOrCloudOrSKUStarterFree&&this.props.isEnterpriseReady,feature:S.W0.HIGHLIGHT_WITHOUT_NOTIFICATION,minimumPlanRequiredForFeature:S.gS.Professional,tooltipTitle:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.disabledTooltipTitle",defaultMessage:"Professional feature"}),tooltipMessageBlocked:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.disabledTooltipMessage",defaultMessage:"This feature is available on the Professional plan"}),titleAdminPreTrial:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.userModal.titleAdminPreTrial",defaultMessage:"Highlight keywords without notifications with Mattermost Professional"}),messageAdminPreTrial:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.userModal.messageAdminPreTrial",defaultMessage:"Get the ability to passively highlight keywords that you care about. Upgrade to Professional plan to unlock this feature."}),titleAdminPostTrial:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.userModal.titleAdminPostTrial",defaultMessage:"Highlight keywords without notifications with Mattermost Professional"}),messageAdminPostTrial:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.userModal.messageAdminPostTrial",defaultMessage:"Get the ability to passively highlight keywords that you care about. Upgrade to Professional plan to unlock this feature."}),titleEndUser:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.userModal.titleEndUser",defaultMessage:"Highlight keywords without notifications with Mattermost Professional"}),messageEndUser:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.userModal.messageEndUser",defaultMessage:"Get the ability to passively highlight keywords that you care about.{br}{br}Request your admin to upgrade to Mattermost Professional to access this feature."},{br:r().createElement("br",null)}),ctaExtraContent:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.keywordsWithHighlight.professional",defaultMessage:"Professional"}),clickCallback:this.handleCloseSettingsModal});return r().createElement(I,{title:this.props.intl.formatMessage({id:"user.settings.notifications.keywordsWithHighlight.title",defaultMessage:"Keywords that get highlighted (without notifications)"}),section:S.Y$.KEYWORDS_HIGHLIGHT,active:e,areAllSectionsInactive:""===this.props.activeSection,describe:s,updateSection:this.handleUpdateSection,max:t,isDisabled:this.props.isEnterpriseOrCloudOrSKUStarterFree&&this.props.isEnterpriseReady,collapsedEditButtonWhenDisabled:i})})),os(this,"createCommentsSection",(()=>{const e=this.state.serverError;let t,s=null;if(this.props.activeSection===S.Y$.REPLY_NOTIFCATIONS){const t=[!1,!1,!1];"never"===this.state.notifyCommentsLevel?t[2]=!0:"root"===this.state.notifyCommentsLevel?t[1]=!0:t[0]=!0;const i=[];i.push(r().createElement("fieldset",{key:"userNotificationLevelOption"},r().createElement("legend",{className:"form-legend hidden-label"},r().createElement(d.FormattedMessage,{id:"user.settings.notifications.comments",defaultMessage:"Reply notifications"})),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"notificationCommentsAny",type:"radio",name:"commentsNotificationLevel",checked:t[0],onChange:this.handleNotifyCommentsRadio.bind(this,"any")}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsAny",defaultMessage:"Trigger notifications on messages in reply threads that I start or participate in"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"notificationCommentsRoot",type:"radio",name:"commentsNotificationLevel",checked:t[1],onChange:this.handleNotifyCommentsRadio.bind(this,"root")}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsRoot",defaultMessage:"Trigger notifications on messages in threads that I start"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{id:"notificationCommentsNever",type:"radio",name:"commentsNotificationLevel",checked:t[2],onChange:this.handleNotifyCommentsRadio.bind(this,"never")}),r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsNever",defaultMessage:"Do not trigger notifications on messages in reply threads unless I'm mentioned"})))));const a=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsInfo",defaultMessage:"In addition to notifications for when you're mentioned, select if you would like to receive notifications on reply threads."}));s=r().createElement(D,{title:this.props.intl.formatMessage({id:"user.settings.notifications.comments",defaultMessage:"Reply notifications"}),extraInfo:a,inputs:i,submit:this.handleSubmit,saving:this.state.isSaving,serverError:e,updateSection:this.handleUpdateSection})}return t="never"===this.state.notifyCommentsLevel?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsNever",defaultMessage:"Do not trigger notifications on messages in reply threads unless I'm mentioned"}):"root"===this.state.notifyCommentsLevel?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsRoot",defaultMessage:"Trigger notifications on messages in threads that I start"}):r().createElement(d.FormattedMessage,{id:"user.settings.notifications.commentsAny",defaultMessage:"Trigger notifications on messages in reply threads that I start or participate in"}),r().createElement(I,{title:this.props.intl.formatMessage({id:"user.settings.notifications.comments",defaultMessage:"Reply notifications"}),active:this.props.activeSection===S.Y$.REPLY_NOTIFCATIONS,describe:t,section:S.Y$.REPLY_NOTIFCATIONS,updateSection:this.handleUpdateSection,max:s,areAllSectionsInactive:""===this.props.activeSection})})),os(this,"createAutoResponderSection",(()=>{const e=this.state.autoResponderActive?r().createElement(d.FormattedMessage,{id:"user.settings.notifications.autoResponderEnabled",defaultMessage:"Enabled"}):r().createElement(d.FormattedMessage,{id:"user.settings.notifications.autoResponderDisabled",defaultMessage:"Disabled"});return r().createElement(I,{active:this.props.activeSection===S.Y$.AUTO_RESPONDER,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.autoResponder",defaultMessage:"Automatic direct message replies"}),describe:e,section:S.Y$.AUTO_RESPONDER,updateSection:this.handleUpdateSection,max:r().createElement("div",null,r().createElement(Zt,{autoResponderActive:this.state.autoResponderActive,autoResponderMessage:this.state.autoResponderMessage||"",updateSection:this.handleUpdateSection,setParentState:this.setStateValue,submit:this.handleSubmit,error:this.state.serverError,saving:this.state.isSaving}),r().createElement("div",{className:"divider-dark"}))})})),this.state=ds(e)}render(){const e=this.createKeywordsWithNotificationSection(),t=this.createKeywordsWithHighlightSection(),s=this.createCommentsSection(),i=this.createAutoResponderSection(),a=""===this.props.activeSection;return r().createElement("div",{id:"notificationSettings"},r().createElement(K,{closeModal:this.props.closeModal,collapseModal:this.props.collapseModal,text:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.title",defaultMessage:"Notification settings"})}),r().createElement("div",{className:"user-settings"},r().createElement(H,{id:"notificationSettingsTitle",text:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.header",defaultMessage:"Notifications"}),info:r().createElement(d.FormattedMessage,{id:"user.settings.notifications.learnMore",defaultMessage:"<a>Learn more about notifications</a>",values:{a:e=>r().createElement(ue.A,{location:"user_settings_notifications",href:"https://mattermost.com/pl/about-notifications",className:"btn btn-link"},r().createElement(St.LightbulbOutlineIcon,{className:"circular-border"}),r().createElement("span",null,e))}})}),r().createElement("div",{className:"divider-dark first"}),r().createElement(qt,{active:this.props.activeSection===S.Y$.DESKTOP_AND_MOBILE,updateSection:this.handleUpdateSection,onSubmit:this.handleSubmit,onCancel:this.handleCancel,saving:this.state.isSaving,error:this.state.serverError,setParentState:this.setStateValue,areAllSectionsInactive:a,isCollapsedThreadsEnabled:this.props.isCollapsedThreadsEnabled,desktopActivity:this.state.desktopActivity,pushActivity:this.state.pushActivity,sendPushNotifications:this.props.sendPushNotifications,pushStatus:this.state.pushStatus,desktopThreads:this.state.desktopThreads,pushThreads:this.state.pushThreads,desktopAndMobileSettingsDifferent:this.state.desktopAndMobileSettingsDifferent}),r().createElement("div",{className:"divider-light"}),r().createElement(Ht,{active:this.props.activeSection===S.Y$.DESKTOP_NOTIFICATION_SOUND,updateSection:this.handleUpdateSection,onSubmit:this.handleSubmit,onCancel:this.handleCancel,saving:this.state.isSaving,error:this.state.serverError,setParentState:this.setStateValue,areAllSectionsInactive:a,desktopSound:this.state.desktopSound,desktopNotificationSound:this.state.desktopNotificationSound,isCallsRingingEnabled:this.props.isCallsRingingEnabled,callsDesktopSound:this.state.callsDesktopSound,callsNotificationSound:this.state.callsNotificationSound}),r().createElement("div",{className:"divider-light"}),r().createElement($t,{active:this.props.activeSection===S.Y$.EMAIL,updateSection:this.handleUpdateSection,onSubmit:this.handleSubmit,onCancel:this.handleCancel,saving:this.state.isSaving,error:this.state.serverError,setParentState:this.setStateValue,areAllSectionsInactive:a,isCollapsedThreadsEnabled:this.props.isCollapsedThreadsEnabled,enableEmail:"true"===this.state.enableEmail,onChange:this.handleEmailRadio,threads:this.state.emailThreads||""}),r().createElement("div",{className:"divider-light"}),e,!this.props.isEnterpriseOrCloudOrSKUStarterFree&&this.props.isEnterpriseReady&&r().createElement(r().Fragment,null,r().createElement("div",{className:"divider-light"}),t),r().createElement("div",{className:"divider-light"}),!this.props.isCollapsedThreadsEnabled&&r().createElement(r().Fragment,null,r().createElement("div",{className:"divider-light"}),s),this.props.enableAutoResponder&&r().createElement(r().Fragment,null,r().createElement("div",{className:"divider-light"}),i),this.props.isEnterpriseOrCloudOrSKUStarterFree&&this.props.isEnterpriseReady&&r().createElement(r().Fragment,null,r().createElement("div",{className:"divider-light"}),t),r().createElement(as,{adminMode:this.props.adminMode})))}}os(us,"defaultProps",{activeSection:""});const ms={container:e=>rs(rs({},e),{},{marginBlockStart:"10px"}),control:e=>rs(rs({},e),{},{backgroundColor:"var(--center-channel-bg)",border:"1px solid rgba(var(--center-channel-color-rgb), 0.16);",":hover":{borderColor:"rgba(var(--center-channel-color-rgb), 0.48);"}}),multiValue:e=>rs(rs({},e),{},{background:"rgba(var(--center-channel-color-rgb), 0.08)"}),multiValueLabel:e=>rs(rs({},e),{},{color:"var(--center-channel-color);"}),input:e=>rs(rs({},e),{},{color:"var(--center-channel-color)"}),indicatorSeparator:e=>rs(rs({},e),{},{display:"none"}),multiValueRemove:e=>rs(rs({},e),{},{cursor:"pointer",color:"rgba(var(--center-channel-color-rgb),0.32);",":hover":{backgroundColor:"rgba(var(--center-channel-color-rgb), 0.16)",color:"rgba(var(--center-channel-color-rgb), 0.56);"}})},ps=Object.values(S.DB),hs=(0,d.injectIntl)(us),gs={updateMe:f.Me,patchUser:f.WJ},fs=(0,p.connect)(((e,t)=>{const s=(0,E.zj)(e),i="true"===s.SendPushNotifications,a="true"===s.ExperimentalEnableAutomaticReplies,n=(0,E.Ay)(e),r=(0,ft.Pd)(e),o="true"===s.BuildEnterpriseReady;return{sendPushNotifications:i,enableAutoResponder:a,isCollapsedThreadsEnabled:t.adminMode&&t.userPreferences?(0,v.UH)(e,t.userPreferences):(0,v.WW)(e),isCallsRingingEnabled:(0,Et.zu)(e,"0.17.0")&&(0,Et.pt)(e),isEnterpriseOrCloudOrSKUStarterFree:(0,vt.hr)(n,r,o),isEnterpriseReady:o}}),gs)(hs);var Es=s(83040);const vs=e=>{let{action:t}=e;const s=(0,n.useMemo)((()=>t?{text:t.text,title:t.title,primaryButton:{onClick:null==t?void 0:t.onClick,text:null==t?void 0:t.buttonText}}:{text:"",title:""}),[t]);return t?r().createElement("div",{className:"pluginActionContainer"},r().createElement(Tt.A,s)):null};function bs(e){return"pp_".concat(e).slice(0,32)}var Ss=s(18515);const ys={mentionHighlight:!1},Ms=e=>{let{selectedValue:t,name:s,option:i,onSelected:a}=e;const o=(0,n.useCallback)((()=>a(i.value)),[i.value]);return r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{type:"radio",name:s,checked:t===i.value,onChange:o}),i.text),r().createElement("br",null),i.helpText&&r().createElement(Ss.A,{message:i.helpText,options:ys}))};Ms.propTypes={selectedValue:a().string.isRequired,name:a().string.isRequired,onSelected:a().func.isRequired};const Ns=Ms,As=e=>{let{setting:t,pluginId:s,informChange:i}=e;const a=(0,p.useSelector)((e=>(0,v.Jt)(e,bs(s),t.name,t.default))),[o,l]=(0,n.useState)(a),c=(0,n.useCallback)((e=>{l(e),i(t.name,e)}),[t.name]);return r().createElement("fieldset",{key:t.name},r().createElement("legend",{className:"form-legend hidden-label"},t.title||t.name),t.options.map((e=>r().createElement(Ns,{key:e.value,name:t.name,option:e,selectedValue:o,onSelected:c}))),t.helpText&&r().createElement("div",{className:"mt-5"},r().createElement(Ss.A,{message:t.helpText,options:{mentionHighlight:!1}})))};As.propTypes={pluginId:a().string.isRequired,informChange:a().func.isRequired};const Ts=As,_s=e=>{let{pluginId:t,section:s,activeSection:i,updateSection:a}=e;const o=(0,p.useDispatch)(),l=(0,p.useSelector)(b.WR),c=(0,p.useSelector)((e=>(0,v.Jt)(e,bs(t),s.settings[0].name,s.settings[0].default))),d=(0,n.useRef)({}),u=(0,n.useMemo)((()=>{const e=s.settings[0];var t;if("radio"===e.type)return null===(t=e.options.find((e=>e.value===c)))||void 0===t?void 0:t.text}),[s,c]),m=(0,n.useCallback)(((e,t)=>{d.current[e]=t}),[]),h=(0,n.useCallback)((async()=>{const e=[];for(const s of Object.keys(d.current))e.push({user_id:l,category:bs(t),name:s,value:d.current[s]});var i;e.length&&(o((0,g.SF)(l,e)),null===(i=s.onSubmit)||void 0===i||i.call(s,d.current)),a("")}),[t,o,s.onSubmit]);(0,n.useEffect)((()=>{i!==s.title&&(d.current={})}),[i,s.title]);const f=[];for(const e of s.settings)if("radio"===e.type)f.push(r().createElement(Ts,{key:e.name,setting:e,informChange:m,pluginId:t}));else if("custom"===e.type){const s=e.component,i=r().createElement(Es.A,{key:e.name,pluginId:t},r().createElement(s,{informChange:m}));f.push(i)}return f.length?s.title===i?r().createElement(D,{title:s.title,inputs:f,submit:h,updateSection:a}):r().createElement(C,{section:s.title,title:s.title,updateSection:a,describe:u,isDisabled:s.disabled}):null};_s.propTypes={pluginId:a().string.isRequired,updateSection:a().func.isRequired,activeSection:a().string.isRequired};const Cs=_s,ks=e=>{let{activeSection:t,closeModal:s,collapseModal:i,settings:a,updateSection:n}=e;const o=(0,d.useIntl)().formatMessage({id:"user.settings.plugins.title",defaultMessage:"{pluginName} Settings"},{pluginName:a.uiName});return r().createElement("div",null,r().createElement(K,{closeModal:s,collapseModal:i,text:o}),r().createElement("div",{className:"user-settings"},r().createElement(H,{text:o}),r().createElement(vs,{action:a.action}),r().createElement("div",{className:"divider-dark first"}),a.sections.map((e=>{let s;if("component"in e){const t=e.component;s=r().createElement(Es.A,{pluginId:a.id},r().createElement(t,null))}else s=r().createElement(Cs,{pluginId:a.id,activeSection:t,section:e,updateSection:n});return r().createElement(r().Fragment,{key:e.title},s,r().createElement("div",{className:"divider-light"}))})),r().createElement("div",{className:"divider-dark"})))};ks.propTypes={updateSection:a().func.isRequired,activeSection:a().string.isRequired,closeModal:a().func.isRequired,collapseModal:a().func.isRequired};const ws=ks;var Is=s(12966),Rs=s(79342),Ps=s(81911),Os=s(43957),Ds=s(1396);const Fs=e=>{let{actions:{getUserAudits:t},currentUserId:s,onHide:i,userAudits:a}=e;const[l,c]=(0,n.useState)(!0),u=(0,n.useCallback)((()=>{c(!1)}),[]);let m;return(0,n.useEffect)((()=>{t(s,0,200)}),[]),m=0===a.length?r().createElement(Ds.A,null):r().createElement(Os.A,{audits:a,showIp:!0,showSession:!0}),r().createElement(o.Modal,{dialogClassName:"a11y__modal modal--scroll access-history-modal",show:l,onHide:u,onExited:i,bsSize:"large",role:"none","aria-labelledby":"accessHistoryModalLabel"},r().createElement(o.Modal.Header,{closeButton:!0},r().createElement(o.Modal.Title,{componentClass:"h1",id:"accessHistoryModalLabel"},r().createElement(d.FormattedMessage,{id:"access_history.title",defaultMessage:"Access History"}))),r().createElement(o.Modal.Body,null,m),r().createElement(o.Modal.Footer,{className:"modal-footer--invisible"},r().createElement("button",{id:"closeModalButton",type:"button",className:"btn btn-tertiary"},r().createElement(d.FormattedMessage,{id:"general_button.close",defaultMessage:"Close"}))))};Fs.propTypes={onHide:a().func.isRequired,actions:a().shape({getUserAudits:a().func.isRequired}).isRequired,userAudits:a().array.isRequired,currentUserId:a().string.isRequired};const Ls=r().memo(Fs),xs=(0,p.connect)((function(e){return{currentUserId:(0,b.WR)(e),userAudits:(0,b.Qb)(e)||[]}}),(function(e){return{actions:(0,h.bindActionCreators)({getUserAudits:f.Qb},e)}}))(Ls);var Us=s(69657),Bs=(s(76409),s(45036));function js(e){const t=(0,d.useIntl)();return r().createElement("i",{className:e.devicePicture,title:(0,Bs.H6)(t.formatMessage,e.deviceTitle)})}function qs(e){const{locale:t,currentSession:s,handleMoreInfo:i,moreInfo:a}=e;if(a){const e=new Date(s.create_at);return r().createElement("div",null,r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"activity_log.firstTime",defaultMessage:"First time active: {date}, {time}",values:{date:r().createElement(d.FormattedDate,{value:e,day:"2-digit",month:(0,Bs.FS)(t),year:"numeric"}),time:r().createElement(d.FormattedTime,{value:e,hour:"2-digit",minute:"2-digit"})}})),r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"activity_log.os",defaultMessage:"OS: {os}",values:{os:s.props.os}})),r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"activity_log.browser",defaultMessage:"Browser: {browser}",values:{browser:s.props.browser}})),r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"activity_log.sessionId",defaultMessage:"Session ID: {id}",values:{id:s.id}})))}return r().createElement("a",{className:"theme",href:"#",onClick:i},r().createElement(d.FormattedMessage,{id:"activity_log.moreInfo",defaultMessage:"More info"}))}function Gs(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}js.propTypes={devicePicture:a().string},qs.propTypes={locale:a().string.isRequired,handleMoreInfo:a().func.isRequired,moreInfo:a().bool.isRequired};class Ws extends r().PureComponent{constructor(e){super(e),Gs(this,"handleMoreInfo",(()=>{this.setState({moreInfo:!0})})),Gs(this,"submitRevoke",(e=>{this.props.submitRevoke(this.props.currentSession.id,e)})),Gs(this,"isMobileSession",(e=>Boolean(e.device_id&&(e.device_id.includes("apple")||e.device_id.includes("android"))))),Gs(this,"mobileSessionInfo",(e=>{let t,s,i;return e.device_id.includes("apple")?(s="fa fa-apple",i=Ys.appleIcon,t=r().createElement(d.FormattedMessage,{id:"activity_log_modal.iphoneNativeClassicApp",defaultMessage:"iPhone Native Classic App"}),e.device_id.includes(L.Bz.PUSH_NOTIFY_APPLE_REACT_NATIVE)&&(t=r().createElement(d.FormattedMessage,{id:"activity_log_modal.iphoneNativeApp",defaultMessage:"iPhone Native App"}))):e.device_id.includes("android")&&(s="fa fa-android",i=Ys.androidIcon,t=r().createElement(d.FormattedMessage,{id:"activity_log_modal.androidNativeClassicApp",defaultMessage:"Android Native Classic App"}),e.device_id.includes(L.Bz.PUSH_NOTIFY_ANDROID_REACT_NATIVE)&&(t=r().createElement(d.FormattedMessage,{id:"activity_log_modal.androidNativeApp",defaultMessage:"Android Native App"}))),{devicePicture:s,deviceTitle:i,devicePlatform:t}})),this.state={moreInfo:!1}}render(){const{index:e,locale:t,currentSession:s}=this.props,i=new Date(s.last_activity_at);let a=s.props.platform,n="",o="";if(this.isMobileSession(s)){const e=this.mobileSessionInfo(s);n=e.devicePicture,a=e.devicePlatform,o=e.deviceTitle||o}else"Windows"===s.props.platform?(n="fa fa-windows",o=Ys.windowsIcon):"Macintosh"===s.props.platform||"iPhone"===s.props.platform?(n="fa fa-apple",o=Ys.appleIcon):"Linux"===s.props.platform?s.props.os.indexOf("Android")>=0?(a=r().createElement(d.FormattedMessage,{id:"activity_log_modal.android",defaultMessage:"Android"}),n="fa fa-android",o=Ys.androidIcon):(n="fa fa-linux",o=Ys.linuxIcon):-1!==s.props.os.indexOf("Linux")&&(n="fa fa-linux",o=Ys.linuxIcon),-1!==s.props.browser.indexOf("Desktop App")&&(a=r().createElement(d.FormattedMessage,{id:"activity_log_modal.desktop",defaultMessage:"Native Desktop App"}));return r().createElement("div",{key:"activityLogEntryKey"+e,className:"activity-log__table"},r().createElement("div",{className:"activity-log__report"},r().createElement("div",{className:"report__platform"},r().createElement(js,{devicePicture:n,deviceTitle:o}),a),r().createElement("div",{className:"report__info"},r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"activity_log.lastActivity",defaultMessage:"Last activity: {date}, {time}",values:{date:r().createElement(d.FormattedDate,{value:i,day:"2-digit",month:(0,Bs.FS)(t),year:"numeric"}),time:r().createElement(d.FormattedTime,{value:i,hour:"2-digit",minute:"2-digit"})}})),r().createElement(qs,{locale:t,currentSession:s,moreInfo:this.state.moreInfo,handleMoreInfo:this.handleMoreInfo}))),r().createElement("div",{className:"activity-log__action"},r().createElement("button",{onClick:this.submitRevoke,className:"btn btn-primary"},r().createElement(d.FormattedMessage,{id:"activity_log.logout",defaultMessage:"Log Out"}))))}}Gs(Ws,"propTypes",{index:a().number.isRequired,locale:a().string.isRequired,submitRevoke:a().func.isRequired});const Ys=(0,d.defineMessages)({androidIcon:{id:"device_icons.android",defaultMessage:"Android Icon"},appleIcon:{id:"device_icons.apple",defaultMessage:"Apple Icon"},linuxIcon:{id:"device_icons.linux",defaultMessage:"Linux Icon"},windowsIcon:{id:"device_icons.windows",defaultMessage:"Windows Icon"}});function Hs(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class Vs extends r().PureComponent{constructor(e){super(e),Hs(this,"submitRevoke",((e,t)=>{var s;t.preventDefault();const i=null===(s=t.target)||void 0===s?void 0:s.closest(".modal-content");null==i||i.classList.add("animation--highlight"),setTimeout((()=>{null==i||i.classList.remove("animation--highlight")}),1500),this.props.actions.revokeSession(this.props.currentUserId,e).then((()=>{this.props.actions.getSessions(this.props.currentUserId)}))})),Hs(this,"onShow",(()=>{this.props.actions.getSessions(this.props.currentUserId)})),Hs(this,"onHide",(()=>{this.setState({show:!1})})),this.state={show:!0}}componentDidMount(){this.onShow()}render(){const e=this.props.sessions.reduce(((e,t,s)=>("UserAccessToken"===t.props.type||e.push(r().createElement(Ws,{key:t.id,index:s,locale:this.props.locale,currentSession:t,submitRevoke:this.submitRevoke})),e)),[]),t=r().createElement("form",{role:"form"},e);return r().createElement(o.Modal,{dialogClassName:"a11y__modal modal--scroll",show:this.state.show,onHide:this.onHide,onExited:this.props.onHide,bsSize:"large",role:"none","aria-labelledby":"activityLogModalLabel"},r().createElement(o.Modal.Header,{closeButton:!0},r().createElement(o.Modal.Title,{componentClass:"h1",id:"activityLogModalLabel"},r().createElement(d.FormattedMessage,{id:"activity_log.activeSessions",defaultMessage:"Active Sessions"}))),r().createElement(o.Modal.Body,null,r().createElement("p",{className:"session-help-text"},r().createElement(d.FormattedMessage,{id:"activity_log.sessionsDescription",defaultMessage:"Sessions are created when you log in through a new browser on a device. Sessions let you use Mattermost without having to log in again for a time period specified by the system administrator. To end the session sooner, use the 'Log Out' button."})),t),r().createElement(o.Modal.Footer,{className:"modal-footer--invisible"},r().createElement("button",{id:"closeModalButton",type:"button",className:"btn btn-tertiary"},r().createElement(d.FormattedMessage,{id:"general_button.close",defaultMessage:"Close"}))))}}Hs(Vs,"propTypes",{actions:a().shape({getSessions:a().func.isRequired,revokeSession:a().func.isRequired}).isRequired,onHide:a().func.isRequired,locale:a().string.isRequired,sessions:a().array.isRequired,currentUserId:a().string.isRequired});const Ks=(0,p.connect)((function(e){return{currentUserId:(0,b.WR)(e),sessions:(0,b.XF)(e),locale:(0,Us.k)(e)}}),(function(e){return{actions:(0,h.bindActionCreators)({getSessions:f.S5,revokeSession:f.T$},e)}}))(Vs);var zs=s(12762),Js=s(83984),$s=s(79135),Xs=s(83469),Qs=s(83007);function Zs(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class ei extends r().PureComponent{constructor(e){super(e),Zs(this,"setupMfa",(e=>{e.preventDefault(),(0,Qs.J)().push("/mfa/setup")})),Zs(this,"removeMfa",(async e=>{e.preventDefault();const{error:t}=await this.props.actions.deactivateMfa();t?this.setState({serverError:t.message}):this.props.mfaEnforced?(0,Qs.J)().push("/mfa/setup"):(this.props.updateSection(""),this.setState({serverError:null}))})),Zs(this,"renderTitle",(()=>r().createElement(d.FormattedMessage,{id:"user.settings.mfa.title",defaultMessage:"Multi-factor Authentication"}))),Zs(this,"renderDescription",(()=>this.props.mfaActive?r().createElement(d.FormattedMessage,{id:"user.settings.security.active",defaultMessage:"Active"}):r().createElement(d.FormattedMessage,{id:"user.settings.security.inactive",defaultMessage:"Inactive"}))),Zs(this,"renderContent",(()=>{let e;if(this.props.mfaActive){let t;t=this.props.mfaEnforced?r().createElement(d.FormattedMessage,{id:"user.settings.mfa.reset",defaultMessage:"Reset MFA on Account"}):r().createElement(d.FormattedMessage,{id:"user.settings.mfa.remove",defaultMessage:"Remove MFA from Account"}),e=r().createElement("a",{className:"btn btn-primary",href:"#",onClick:this.removeMfa},t)}else e=r().createElement("a",{className:"btn btn-primary",href:"#",onClick:this.setupMfa},r().createElement(d.FormattedMessage,{id:"user.settings.mfa.add",defaultMessage:"Add MFA to Account"}));return r().createElement("div",{className:"pt-2"},e,r().createElement("br",null))})),Zs(this,"renderHelpText",(()=>this.props.mfaActive?this.props.mfaEnforced?r().createElement(d.FormattedMessage,{id:"user.settings.mfa.requiredHelp",defaultMessage:"Multi-factor authentication is required on this server. Resetting is only recommended when you need to switch code generation to a new mobile device. You will be required to set it up again immediately."}):r().createElement(d.FormattedMessage,{id:"user.settings.mfa.removeHelp",defaultMessage:"Removing multi-factor authentication means you will no longer require a phone-based passcode to sign-in to your account."}):r().createElement(d.FormattedMessage,{id:"user.settings.mfa.addHelp",defaultMessage:"Adding multi-factor authentication will make your account more secure by requiring a code from your mobile phone each time you sign in."}))),this.state={serverError:null},this.minRef=r().createRef()}focusEditButton(){var e;null===(e=this.minRef.current)||void 0===e||e.focus()}componentDidUpdate(e){e.active&&!this.props.active&&this.props.areAllSectionsInactive&&this.focusEditButton()}render(){const e=this.renderTitle();return this.props.mfaAvailable?this.props.active?r().createElement(D,{title:e,inputs:this.renderContent(),extraInfo:this.renderHelpText(),serverError:this.state.serverError,updateSection:this.props.updateSection}):r().createElement(C,{title:e,describe:this.renderDescription(),section:"mfa",updateSection:this.props.updateSection,ref:this.minRef}):null}}const ti=(0,p.connect)((function(e){const t=(0,E.Ay)(e),s=(0,E.zj)(e),i=t&&"true"===t.IsLicensed&&"true"===t.MFA,a="true"===s.EnableMultifactorAuthentication,n=i&&"true"===s.EnforceMultifactorAuthentication,r=(0,b.HW)(e);let o=!1,l=!1;return r&&(o=r.mfa_active,l=a&&(""===r.auth_service||r.auth_service===S.Ay.LDAP_SERVICE)),{mfaActive:o,mfaAvailable:l,mfaEnforced:n}}),(function(e){return{actions:(0,h.bindActionCreators)({deactivateMfa:Xs.n},e)}}))(ei);var si=s(87064);function ii(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const ai="creating",ni="created",ri="not_creating";class oi extends r().PureComponent{constructor(e){super(e),ii(this,"startCreatingToken",(()=>{this.setState({tokenCreationState:ai})})),ii(this,"stopCreatingToken",(()=>{this.setState({tokenCreationState:ri,saving:!1})})),ii(this,"handleCreateToken",(async()=>{this.handleCancelConfirm();const e=this.newtokendescriptionRef?this.newtokendescriptionRef.current.value:"";if(""===e)return void this.setState({tokenError:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.nameRequired",defaultMessage:"Please enter a description."})});this.setState({tokenError:"",saving:!0}),this.props.setRequireConfirm(!0,this.confirmCopyToken);const t=this.props.user?this.props.user.id:"",{data:s,error:i}=await this.props.actions.createUserAccessToken(t,e);s&&this.state.tokenCreationState===ai?this.setState({tokenCreationState:ni,newToken:s,saving:!1}):i&&this.setState({serverError:i.message,saving:!1})})),ii(this,"confirmCopyToken",(e=>{this.setState({showConfirmModal:!0,confirmTitle:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmCopyTitle",defaultMessage:"Copied Your Token?"}),confirmMessage:e=>r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmCopyMessage",defaultMessage:"Make sure you have copied and saved the access token below. You won't be able to see it again!"}),r().createElement("br",null),r().createElement("br",null),e.tokenCreationState===ai?r().createElement("div",null,r().createElement("strong",{className:"word-break--all"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.token",defaultMessage:"Access Token: "})),r().createElement(d.FormattedMessage,{id:"user.settings.tokens.tokenLoading",defaultMessage:"Loading..."})):r().createElement("strong",{className:"word-break--all"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.token",defaultMessage:"Access Token: "}),e.newToken.token)),confirmButton:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmCopyButton",defaultMessage:"Yes, I have copied the token"}),confirmComplete:()=>{this.handleCancelConfirm(),e()},confirmHideCancel:!0})})),ii(this,"handleCancelConfirm",(()=>{this.setState({showConfirmModal:!1,confirmTitle:null,confirmMessage:null,confirmButton:null,confirmComplete:null,confirmHideCancel:!1})})),ii(this,"confirmCreateToken",(()=>{Rs.FV(this.props.user.roles)?this.setState({showConfirmModal:!0,confirmTitle:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmCreateTitle",defaultMessage:"Create System Admin Personal Access Token"}),confirmMessage:()=>r().createElement("div",{className:"alert alert-danger"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmCreateMessage",defaultMessage:"You are generating a personal access token with System Admin permissions. Are you sure want to create this token?"})),confirmButton:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmCreateButton",defaultMessage:"Yes, Create"}),confirmComplete:()=>{this.handleCreateToken(),(0,le.sx)("settings","system_admin_create_user_access_token")}}):this.handleCreateToken()})),ii(this,"saveTokenKeyPress",(e=>{P.e(e,S.YM.KeyCodes.ENTER)&&this.confirmCreateToken()})),ii(this,"confirmRevokeToken",(e=>{const t=this.props.userAccessTokens[e];this.setState({showConfirmModal:!0,confirmTitle:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmDeleteTitle",defaultMessage:"Delete Token?"}),confirmMessage:()=>r().createElement("div",{className:"alert alert-danger"},r().createElement("p",null,r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmDelete.description",defaultMessage:"Any integrations using this token will no longer be able to access the Mattermost API. You cannot undo this action."})),r().createElement("p",null,r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmDelete.confirmation",defaultMessage:"Are you sure you want to delete the <b>{description}</b> token?",values:{description:t.description,b:e=>r().createElement("b",null,e)}}))),confirmButton:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.confirmDeleteButton",defaultMessage:"Yes, Delete"}),confirmComplete:()=>{this.revokeToken(e),(0,le.sx)("settings","revoke_user_access_token")}})})),ii(this,"revokeToken",(async e=>{const{error:t}=await this.props.actions.revokeUserAccessToken(e);t&&this.setState({serverError:t.message}),this.handleCancelConfirm()})),ii(this,"activateToken",(async e=>{const{error:t}=await this.props.actions.enableUserAccessToken(e);t?this.setState({serverError:t.message}):(0,le.sx)("settings","activate_user_access_token")})),ii(this,"deactivateToken",(async e=>{const{error:t}=await this.props.actions.disableUserAccessToken(e);t?this.setState({serverError:t.message}):(0,le.sx)("settings","deactivate_user_access_token")})),this.state={active:this.props.active,showConfirmModal:!1,newToken:null,tokenCreationState:ri,tokenError:"",serverError:null,saving:!1},this.newtokendescriptionRef=r().createRef(),this.minRef=r().createRef()}componentDidUpdate(e){e.active&&!this.props.active&&this.props.areAllSectionsInactive&&this.focusEditButton()}componentDidMount(){this.props.actions.clearUserAccessTokens();const e=this.props.user?this.props.user.id:"";this.props.actions.getUserAccessTokensForUser(e,0,200)}static getDerivedStateFromProps(e,t){return!e.active&&t.active?{active:e.active,showConfirmModal:!1,newToken:null,tokenCreationState:ri,tokenError:"",serverError:null,saving:!1}:{active:e.active}}focusEditButton(){var e;null===(e=this.minRef.current)||void 0===e||e.focus()}render(){let e="";if(!this.props.active){const e=r().createElement(d.FormattedMessage,{id:"user.settings.tokens.clickToEdit",defaultMessage:"Click 'Edit' to manage your personal access tokens"});return r().createElement(C,{title:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.title",defaultMessage:"Personal Access Tokens"}),describe:e,section:"tokens",updateSection:this.props.updateSection,ref:this.minRef})}const t=[];let s,i,a;Object.values(this.props.userAccessTokens).forEach((e=>{if(this.state.newToken&&this.state.newToken.id===e.id)return;let s,i;e.is_active?s=r().createElement("a",{id:e.id+"_deactivate",href:"#",onClick:t=>{t.preventDefault(),this.deactivateToken(e.id)}},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.deactivate",defaultMessage:"Disable"})):(i=r().createElement("span",{className:"has-error setting-box__inline-error"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.deactivatedWarning",defaultMessage:"(Disabled)"})),s=r().createElement("a",{id:e.id+"_activate",href:"#",onClick:t=>{t.preventDefault(),this.activateToken(e.id)}},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.activate",defaultMessage:"Enable"}))),t.push(r().createElement("div",{key:e.id,className:"setting-box__item"},r().createElement("div",{className:"whitespace--nowrap overflow--ellipsis"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.tokenDesc",defaultMessage:"Token Description: "}),e.description,i),r().createElement("div",{className:"setting-box__token-id whitespace--nowrap overflow--ellipsis"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.tokenId",defaultMessage:"Token ID: "}),e.id),r().createElement("div",null,s," - ",r().createElement("a",{id:e.id+"_delete",href:"#",onClick:t=>{t.preventDefault(),this.confirmRevokeToken(e.id)}},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.delete",defaultMessage:"Delete"}))),r().createElement("hr",{className:"mb-3 mt-3"})))})),0===t.length&&(s=r().createElement(d.FormattedMessage,{key:"notokens",id:"user.settings.tokens.userAccessTokensNone",defaultMessage:"No personal access tokens."})),i=(0,F.Fr)()?r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.tokens.description_mobile",defaultMessage:"<linkTokens>Personal access tokens</linkTokens> function similarly to session tokens and can be used by integrations to <linkAPI>authenticate against the REST API</linkAPI>. Create new tokens on your desktop.",values:{linkTokens:e=>r().createElement(ue.A,{href:S.i3.PERSONAL_ACCESS_TOKENS,location:"user_access_token_section"},e),linkAPI:e=>r().createElement(ue.A,{href:"https://api.mattermost.com/#tag/authentication",location:"user_access_token_section"},e)}})):r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.tokens.description",defaultMessage:"<linkTokens>Personal access tokens</linkTokens> function similarly to session tokens and can be used by integrations to <linkAPI>authenticate against the REST API</linkAPI>.",values:{linkTokens:e=>r().createElement(ue.A,{href:S.i3.PERSONAL_ACCESS_TOKENS,location:"user_access_token_section"},e),linkAPI:e=>r().createElement(ue.A,{href:"https://api.mattermost.com/#tag/authentication",location:"user_access_token_section"},e)}})),this.state.tokenCreationState===ai?a=r().createElement("div",{className:"pl-3"},r().createElement("div",{className:"row"},r().createElement("label",{className:"col-sm-auto control-label pr-3",htmlFor:"newTokenDescription"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.name",defaultMessage:"Token Description: "})),r().createElement("div",{className:"col-sm-5"},r().createElement("input",{id:"newTokenDescription",autoFocus:!0,ref:this.newtokendescriptionRef,className:"form-control",type:"text",maxLength:64,onKeyPress:this.saveTokenKeyPress}))),r().createElement("div",null,r().createElement("div",{className:"pt-3"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.nameHelp",defaultMessage:"Enter a description for your token to remember what it does."})),r().createElement("div",null,r().createElement("label",{id:"clientError",className:"has-error mt-2 mb-2"},this.state.tokenError)),r().createElement(R.A,{savingMessage:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.save",defaultMessage:"Save"}),saving:this.state.saving,onClick:this.confirmCreateToken}),r().createElement("button",{className:"btn btn-tertiary",onClick:this.stopCreatingToken},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.cancel",defaultMessage:"Cancel"})))):this.state.tokenCreationState===ni?(0===t.length&&(e=" hidden"),a=r().createElement("div",{className:"alert alert-warning"},r().createElement(si.A,{additionalClassName:"mr-2"}),r().createElement(d.FormattedMessage,{id:"user.settings.tokens.copy",defaultMessage:"Please copy the access token below. You won't be able to see it again!"}),r().createElement("br",null),r().createElement("br",null),r().createElement("div",{className:"whitespace--nowrap overflow--ellipsis"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.name",defaultMessage:"Token Description: "}),this.state.newToken.description),r().createElement("div",{className:"whitespace--nowrap overflow--ellipsis"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.id",defaultMessage:"Token ID: "}),this.state.newToken.id),r().createElement("strong",{className:"word-break--all"},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.token",defaultMessage:"Access Token: "}),this.state.newToken.token))):a=r().createElement("a",{className:"btn btn-primary",href:"#",onClick:this.startCreatingToken},r().createElement(d.FormattedMessage,{id:"user.settings.tokens.create",defaultMessage:"Create Token"}));const n=[];return n.push(r().createElement("div",{key:"tokensSetting",className:"pt-2"},r().createElement("div",{key:"tokenList"},r().createElement("div",{className:"alert alert-transparent"+e},t,s),a))),r().createElement("div",null,r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.tokens.title",defaultMessage:"Personal Access Tokens"}),inputs:n,extraInfo:i,infoPosition:"top",serverError:this.state.serverError,updateSection:this.props.updateSection,isFullWidth:!0,saving:this.state.saving,cancelButtonText:r().createElement(d.FormattedMessage,{id:"user.settings.security.close",defaultMessage:"Close"})}),r().createElement(u.A,{title:this.state.confirmTitle,message:this.state.confirmMessage?this.state.confirmMessage(this.state):null,confirmButtonText:this.state.confirmButton,show:this.state.showConfirmModal,onConfirm:this.state.confirmComplete||(()=>null),onCancel:this.handleCancelConfirm,hideCancel:this.state.confirmHideCancel}))}}ii(oi,"propTypes",{active:a().bool,areAllSectionsInactive:a().bool.isRequired,updateSection:a().func.isRequired,userAccessTokens:a().objectOf(a().shape({description:a().string.isRequired,id:a().string.isRequired,is_active:a().bool.isRequired})).isRequired,setRequireConfirm:a().func.isRequired,actions:a().shape({getUserAccessTokensForUser:a().func.isRequired,createUserAccessToken:a().func.isRequired,revokeUserAccessToken:a().func.isRequired,enableUserAccessToken:a().func.isRequired,disableUserAccessToken:a().func.isRequired,clearUserAccessTokens:a().func.isRequired}).isRequired});const li=(0,p.connect)((function(e){return{userAccessTokens:e.entities.users.myUserAccessTokens}}),(function(e){return{actions:(0,h.bindActionCreators)({getUserAccessTokensForUser:f.GA,createUserAccessToken:f.NE,revokeUserAccessToken:f.XE,enableUserAccessToken:f.Yp,disableUserAccessToken:f.$q,clearUserAccessTokens:f.TH},e)}}))(oi);function ci(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const di="password",ui="signin",mi="apps",pi="tokens";class hi extends r().PureComponent{constructor(e){super(e),ci(this,"loadAuthorizedOAuthApps",(async()=>{const e=await this.props.actions.getAuthorizedOAuthApps();if("data"in e){const{data:t}=e;this.setState({authorizedApps:t,serverError:null})}else if("error"in e){const{error:t}=e;this.setState({serverError:t.message})}})),ci(this,"submitPassword",(async()=>{const e=this.props.user,t=this.state.currentPassword,s=this.state.newPassword,i=this.state.confirmPassword;if(""===t)return void this.setState({passwordError:this.props.intl.formatMessage({id:"user.settings.security.currentPasswordError",defaultMessage:"Please enter your current password."}),serverError:""});const{valid:a,error:n}=(0,$s.s)(s,this.props.passwordConfig);if(!a&&n)return void this.setState({passwordError:n,serverError:""});if(s!==i){const e=Object.assign(this.getDefaultState(),{passwordError:this.props.intl.formatMessage({id:"user.settings.security.passwordMatchError",defaultMessage:"The new passwords you entered do not match."}),serverError:""});return void this.setState(e)}this.setState({savingPassword:!0});const r=await this.props.actions.updateUserPassword(e.id,t,s);if("data"in r)this.props.updateSection(""),this.props.actions.getMe(),this.setState(this.getDefaultState());else if("error"in r){const{error:e}=r,t=this.getDefaultState();e.message?t.serverError=e.message:t.serverError=e,t.passwordError="",this.setState(t)}})),ci(this,"updateCurrentPassword",(e=>{this.setState({currentPassword:e.target.value})})),ci(this,"updateNewPassword",(e=>{this.setState({newPassword:e.target.value})})),ci(this,"updateConfirmPassword",(e=>{this.setState({confirmPassword:e.target.value})})),ci(this,"deauthorizeApp",(async e=>{e.preventDefault();const t=e.currentTarget.getAttribute("data-app"),s=await this.props.actions.deauthorizeOAuthApp(t);if("data"in s){const e=this.state.authorizedApps.filter((e=>e.id!==t));this.setState({authorizedApps:e,serverError:null})}else if("error"in s){const{error:e}=s;this.setState({serverError:e.message})}})),ci(this,"handleUpdateSection",(e=>{if(e)this.props.updateSection(e);else{switch(this.props.activeSection){case"mfa":case ui:case pi:case mi:this.setState({serverError:null});break;case di:this.setState({currentPassword:"",newPassword:"",confirmPassword:"",serverError:null,passwordError:null})}this.props.updateSection("")}})),ci(this,"createPasswordSection",(()=>{const e=[];let t;const s=this.props.activeSection===di;let i,a=null;if(s&&(""===this.props.user.auth_service?(t=this.submitPassword,e.push(r().createElement("div",{key:"currentPasswordUpdateForm",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"currentPassword"},r().createElement(d.FormattedMessage,{id:"user.settings.security.currentPassword",defaultMessage:"Current Password"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"currentPassword",autoFocus:!0,className:"form-control",type:"password",onChange:this.updateCurrentPassword,value:this.state.currentPassword,"aria-label":this.props.intl.formatMessage({id:"user.settings.security.currentPassword",defaultMessage:"Current Password"})})))),e.push(r().createElement("div",{key:"newPasswordUpdateForm",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"newPassword"},r().createElement(d.FormattedMessage,{id:"user.settings.security.newPassword",defaultMessage:"New Password"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"newPassword",className:"form-control",type:"password",onChange:this.updateNewPassword,value:this.state.newPassword,"aria-label":this.props.intl.formatMessage({id:"user.settings.security.newPassword",defaultMessage:"New Password"})})))),e.push(r().createElement("div",{key:"retypeNewPasswordUpdateForm",className:"form-group"},r().createElement("label",{className:"col-sm-5 control-label",htmlFor:"confirmPassword"},r().createElement(d.FormattedMessage,{id:"user.settings.security.retypePassword",defaultMessage:"Retype New Password"})),r().createElement("div",{className:"col-sm-7"},r().createElement("input",{id:"confirmPassword",className:"form-control",type:"password",onChange:this.updateConfirmPassword,value:this.state.confirmPassword,"aria-label":this.props.intl.formatMessage({id:"user.settings.security.retypePassword",defaultMessage:"Retype New Password"})}))))):this.props.user.auth_service===S.Ay.GITLAB_SERVICE?e.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.security.passwordGitlabCantUpdate",defaultMessage:"Login occurs through GitLab. Password cannot be updated."})))):this.props.user.auth_service===S.Ay.LDAP_SERVICE?e.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.security.passwordLdapCantUpdate",defaultMessage:"Login occurs through AD/LDAP. Password cannot be updated."})))):this.props.user.auth_service===S.Ay.SAML_SERVICE?e.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.security.passwordSamlCantUpdate",defaultMessage:"This field is handled through your login provider. If you want to change it, you need to do so through your login provider."})))):this.props.user.auth_service===S.Ay.GOOGLE_SERVICE?e.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.security.passwordGoogleCantUpdate",defaultMessage:"Login occurs through Google Apps. Password cannot be updated."})))):this.props.user.auth_service===S.Ay.OFFICE365_SERVICE&&e.push(r().createElement("div",{key:"oauthEmailInfo",className:"form-group"},r().createElement("div",{className:"pb-3"},r().createElement(d.FormattedMessage,{id:"user.settings.security.passwordOffice365CantUpdate",defaultMessage:"Login occurs through Entra ID. Password cannot be updated."})))),a=r().createElement(D,{title:r().createElement(d.FormattedMessage,{id:"user.settings.security.password",defaultMessage:"Password"}),inputs:e,submit:t,saving:this.state.savingPassword,serverError:this.state.serverError,clientError:this.state.passwordError,updateSection:this.handleUpdateSection})),""===this.props.user.auth_service){const e=new Date(this.props.user.last_password_update);i=r().createElement(d.FormattedMessage,{id:"user.settings.security.lastUpdated",defaultMessage:"Last updated {date} at {time}",values:{date:r().createElement(d.FormattedDate,{value:e,day:"2-digit",month:"short",year:"numeric"}),time:r().createElement(d.FormattedTime,{value:e,hour12:!this.props.militaryTime,hour:"2-digit",minute:"2-digit"})}})}else this.props.user.auth_service===S.Ay.GITLAB_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.loginGitlab",defaultMessage:"Login done through GitLab"}):this.props.user.auth_service===S.Ay.LDAP_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.loginLdap",defaultMessage:"Login done through AD/LDAP"}):this.props.user.auth_service===S.Ay.SAML_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.loginSaml",defaultMessage:"Login done through SAML"}):this.props.user.auth_service===S.Ay.GOOGLE_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.loginGoogle",defaultMessage:"Login done through Google Apps"}):this.props.user.auth_service===S.Ay.OFFICE365_SERVICE&&(i=r().createElement(d.FormattedMessage,{id:"user.settings.security.loginOffice365",defaultMessage:"Login done through Entra ID"}));return r().createElement(I,{active:s,areAllSectionsInactive:""===this.props.activeSection,title:r().createElement(d.FormattedMessage,{id:"user.settings.security.password",defaultMessage:"Password"}),describe:i,section:di,updateSection:this.handleUpdateSection,max:a})})),ci(this,"createSignInSection",(()=>{const e=this.props.user,t=this.props.activeSection===ui;let s=null;if(t){let t,i,a,n,o,l,c;if(""===e.auth_service)this.props.enableSignUpWithGitLab&&(i=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:"/claim/email_to_oauth?email="+encodeURIComponent(e.email)+"&old_type="+e.auth_service+"&new_type="+S.Ay.GITLAB_SERVICE},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchGitlab",defaultMessage:"Switch to Using GitLab SSO"})),r().createElement("br",null))),this.props.enableSignUpWithGoogle&&(a=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:"/claim/email_to_oauth?email="+encodeURIComponent(e.email)+"&old_type="+e.auth_service+"&new_type="+S.Ay.GOOGLE_SERVICE},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchGoogle",defaultMessage:"Switch to Using Google SSO"})),r().createElement("br",null))),this.props.enableSignUpWithOffice365&&(n=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:"/claim/email_to_oauth?email="+encodeURIComponent(e.email)+"&old_type="+e.auth_service+"&new_type="+S.Ay.OFFICE365_SERVICE},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchOffice365",defaultMessage:"Switch to Using Entra ID SSO"})),r().createElement("br",null))),this.props.enableSignUpWithOpenId&&(o=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:"/claim/email_to_oauth?email="+encodeURIComponent(e.email)+"&old_type="+e.auth_service+"&new_type="+S.Ay.OPENID_SERVICE},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchOpenId",defaultMessage:"Switch to Using OpenID SSO"})),r().createElement("br",null))),this.props.enableLdap&&(l=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:"/claim/email_to_ldap?email="+encodeURIComponent(e.email)},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchLdap",defaultMessage:"Switch to Using AD/LDAP"})),r().createElement("br",null))),this.props.enableSaml&&(c=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:"/claim/email_to_oauth?email="+encodeURIComponent(e.email)+"&old_type="+e.auth_service+"&new_type="+S.Ay.SAML_SERVICE},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchSaml",defaultMessage:"Switch to Using SAML SSO"})),r().createElement("br",null)));else if(this.props.allowedToSwitchToEmail){let s;s=e.auth_service===S.Ay.LDAP_SERVICE?"/claim/ldap_to_email?email="+encodeURIComponent(e.email):"/claim/oauth_to_email?email="+encodeURIComponent(e.email)+"&old_type="+e.auth_service,t=r().createElement("div",{className:"pb-3"},r().createElement(Ps.Link,{className:"btn btn-primary",to:s},r().createElement(d.FormattedMessage,{id:"user.settings.security.switchEmail",defaultMessage:"Switch to Using Email and Password"})),r().createElement("br",null))}const u=[];u.push(r().createElement("div",{key:"userSignInOption"},t,i,a,n,o,l,c));const m=r().createElement("span",null,r().createElement(d.FormattedMessage,{id:"user.settings.security.oneSignin",defaultMessage:"You may only have one sign-in method at a time. Switching sign-in method will send an email notifying you if the change was successful."}));s=r().createElement(D,{title:this.props.intl.formatMessage({id:"user.settings.security.method",defaultMessage:"Sign-in Method"}),extraInfo:m,inputs:u,serverError:this.state.serverError,updateSection:this.handleUpdateSection})}let i=r().createElement(d.FormattedMessage,{id:"user.settings.security.emailPwd",defaultMessage:"Email and Password"});return this.props.user.auth_service===S.Ay.GITLAB_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.gitlab",defaultMessage:"GitLab"}):this.props.user.auth_service===S.Ay.GOOGLE_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.google",defaultMessage:"Google"}):this.props.user.auth_service===S.Ay.OFFICE365_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.office365",defaultMessage:"Entra ID"}):this.props.user.auth_service===S.Ay.OPENID_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.openid",defaultMessage:"OpenID"}):this.props.user.auth_service===S.Ay.LDAP_SERVICE?i=r().createElement(d.FormattedMessage,{id:"user.settings.security.ldap",defaultMessage:"AD/LDAP"}):this.props.user.auth_service===S.Ay.SAML_SERVICE&&(i=r().createElement(d.FormattedMessage,{id:"user.settings.security.saml",defaultMessage:"SAML"})),r().createElement(I,{active:t,areAllSectionsInactive:""===this.props.activeSection,title:this.props.intl.formatMessage({id:"user.settings.security.method",defaultMessage:"Sign-in Method"}),describe:i,section:ui,updateSection:this.handleUpdateSection,max:s})})),ci(this,"createOAuthAppsSection",(()=>{const e=this.props.activeSection===mi;let t=null;if(e){let e;e=this.state.authorizedApps&&this.state.authorizedApps.length>0?this.state.authorizedApps.map((e=>{const t=r().createElement(ue.A,{href:e.homepage,location:"user_settings_security"},e.homepage);return r().createElement("div",{key:e.id,className:"pb-3 authorized-app"},r().createElement("div",{className:"col-sm-10"},r().createElement("div",{className:"authorized-app__name"},e.name,r().createElement("span",{className:"authorized-app__url"}," -"," ",t)),r().createElement("div",{className:"authorized-app__description"},e.description),r().createElement("div",{className:"authorized-app__deauthorize"},r().createElement("a",{href:"#","data-app":e.id,onClick:this.deauthorizeApp},r().createElement(d.FormattedMessage,{id:"user.settings.security.deauthorize",defaultMessage:"Deauthorize"})))),r().createElement("div",{className:"col-sm-2 pull-right"},r().createElement("img",{alt:e.name,src:e.icon_url||Js})),r().createElement("br",null))})):r().createElement("div",{className:"pb-3 authorized-app"},r().createElement("div",{className:"setting-list__hint"},r().createElement(d.FormattedMessage,{id:"user.settings.security.noApps",defaultMessage:"No OAuth 2.0 Applications are authorized."})));const s=[];let i,a;Array.isArray(e)&&(i="authorized-apps__wrapper",a=r().createElement("div",{className:"authorized-apps__help"},r().createElement(d.FormattedMessage,{id:"user.settings.security.oauthAppsHelp",defaultMessage:"Applications act on your behalf to access your data based on the permissions you grant them."}))),s.push(r().createElement("div",{className:i,key:"authorizedApps"},e));const n=r().createElement("div",null,r().createElement(d.FormattedMessage,{id:"user.settings.security.oauthApps",defaultMessage:"OAuth 2.0 Applications"}),a);t=r().createElement(D,{title:n,inputs:s,serverError:this.state.serverError,updateSection:this.handleUpdateSection,isFullWidth:!0,cancelButtonText:r().createElement(d.FormattedMessage,{id:"user.settings.security.close",defaultMessage:"Close"})})}return r().createElement(I,{active:e,areAllSectionsInactive:""===this.props.activeSection,title:this.props.intl.formatMessage({id:"user.settings.security.oauthApps",defaultMessage:"OAuth 2.0 Applications"}),describe:r().createElement(d.FormattedMessage,{id:"user.settings.security.oauthAppsDescription",defaultMessage:"Click 'Edit' to manage your OAuth 2.0 Applications"}),section:mi,updateSection:this.handleUpdateSection,max:t})})),this.state=this.getDefaultState()}getDefaultState(){return{currentPassword:"",newPassword:"",confirmPassword:"",passwordError:"",serverError:"",tokenError:"",authService:this.props.user.auth_service,savingPassword:!1,authorizedApps:[]}}componentDidMount(){this.props.enableOAuthServiceProvider&&this.loadAuthorizedOAuthApps()}render(){const e=this.props.user,t=this.createPasswordSection();let s,i,a,n=0;return n=this.props.enableSignUpWithGitLab?n+1:n,n=this.props.enableSignUpWithGoogle?n+1:n,n=this.props.enableSignUpWithOffice365?n+1:n,n=this.props.enableSignUpWithOpenId?n+1:n,n=this.props.enableLdap?n+1:n,n=this.props.enableSaml?n+1:n,(this.props.allowedToSwitchToEmail||""===e.auth_service)&&n>0&&this.props.experimentalEnableAuthenticationTransfer&&(s=this.createSignInSection()),this.props.enableOAuthServiceProvider&&(i=this.createOAuthAppsSection()),this.props.canUseAccessTokens&&(a=r().createElement(li,{user:this.props.user,active:this.props.activeSection===pi,areAllSectionsInactive:""===this.props.activeSection,updateSection:this.handleUpdateSection,setRequireConfirm:this.props.setRequireConfirm})),r().createElement("div",null,r().createElement(K,{closeModal:this.props.closeModal,collapseModal:this.props.collapseModal,text:r().createElement(d.FormattedMessage,{id:"user.settings.security.title",defaultMessage:"Security Settings"})}),r().createElement("div",{className:"user-settings"},r().createElement(H,{text:r().createElement(d.FormattedMessage,{id:"user.settings.security.title",defaultMessage:"Security Settings"})}),r().createElement("div",{className:"divider-dark first"}),t,r().createElement("div",{className:"divider-light"}),r().createElement(ti,{active:"mfa"===this.props.activeSection,areAllSectionsInactive:""===this.props.activeSection,updateSection:this.handleUpdateSection}),r().createElement("div",{className:"divider-light"}),i,r().createElement("div",{className:"divider-light"}),a,r().createElement("div",{className:"divider-light"}),s,r().createElement("div",{className:"divider-dark"}),r().createElement("br",null),r().createElement(zs.A,{className:"security-links color--link",modalId:"access_history",dialogType:xs,id:"viewAccessHistory"},r().createElement("i",{className:"fa fa-clock-o",title:this.props.intl.formatMessage({id:"user.settings.security.viewHistory.icon",defaultMessage:"Access History Icon"})}),r().createElement(d.FormattedMessage,{id:"user.settings.security.viewHistory",defaultMessage:"View Access History"})),r().createElement(zs.A,{className:"security-links color--link mt-2",modalId:"activity_log",dialogType:Ks,id:"viewAndLogOutOfActiveSessions"},r().createElement("i",{className:"fa fa-clock-o",title:this.props.intl.formatMessage({id:"user.settings.security.logoutActiveSessions.icon",defaultMessage:"Active Sessions Icon"})}),r().createElement(d.FormattedMessage,{id:"user.settings.security.logoutActiveSessions",defaultMessage:"View and Log Out of Active Sessions"}))))}}ci(hi,"propTypes",{activeSection:a().string,updateSection:a().func.isRequired,closeModal:a().func.isRequired,collapseModal:a().func.isRequired,setRequireConfirm:a().func.isRequired,canUseAccessTokens:a().bool.isRequired,enableOAuthServiceProvider:a().bool.isRequired,allowedToSwitchToEmail:a().bool.isRequired,enableSignUpWithGitLab:a().bool.isRequired,enableSignUpWithGoogle:a().bool.isRequired,enableSignUpWithOpenId:a().bool.isRequired,enableLdap:a().bool.isRequired,enableSaml:a().bool.isRequired,enableSignUpWithOffice365:a().bool.isRequired,experimentalEnableAuthenticationTransfer:a().bool.isRequired,militaryTime:a().bool.isRequired,actions:a().shape({getMe:a().func.isRequired,updateUserPassword:a().func.isRequired,getAuthorizedOAuthApps:a().func.isRequired,deauthorizeOAuthApp:a().func.isRequired}).isRequired});const gi=(0,d.injectIntl)(hi),fi=(0,p.connect)((function(e,t){const s=(0,E.zj)(e),i="true"===s.EnableUserAccessTokens,a=Rs.DA(t.user.roles)||Rs.FV(t.user.roles);return{canUseAccessTokens:i&&a,enableOAuthServiceProvider:"true"===s.EnableOAuthServiceProvider,allowedToSwitchToEmail:"true"===s.EnableSignUpWithEmail&&("true"===s.EnableSignInWithEmail||"true"===s.EnableSignInWithUsername),enableSignUpWithGitLab:"true"===s.EnableSignUpWithGitLab,enableSignUpWithGoogle:"true"===s.EnableSignUpWithGoogle,enableSignUpWithOpenId:"true"===s.EnableSignUpWithOpenId,enableLdap:"true"===s.EnableLdap,enableSaml:"true"===s.EnableSaml,enableSignUpWithOffice365:"true"===s.EnableSignUpWithOffice365,experimentalEnableAuthenticationTransfer:"true"===s.ExperimentalEnableAuthenticationTransfer,passwordConfig:(0,E.OG)(e),militaryTime:(0,v.Jz)(e,S.pm.CATEGORY_DISPLAY_SETTINGS,S.pm.USE_MILITARY_TIME,!1)}}),(function(e){return{actions:(0,h.bindActionCreators)({getMe:f.jp,updateUserPassword:f.ej,getAuthorizedOAuthApps:Is.Zy,deauthorizeOAuthApp:Is.ni},e)}}))(gi);function Ei(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function vi(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Ei(Object(s),!0).forEach((function(t){bi(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ei(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function bi(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const Si=[{value:10,label:"10"},{value:15,label:"15"},{value:20,label:"20"},{value:40,label:"40"}];class yi extends r().PureComponent{constructor(e){super(e),bi(this,"handleChange",(e=>{e&&"value"in e&&this.setState({limit:e})})),bi(this,"handleSubmit",(async()=>{this.props.userId&&(this.setState({isSaving:!0}),await this.props.savePreferences(this.props.userId,[{user_id:this.props.userId,category:L.pm.CATEGORY_SIDEBAR_SETTINGS,name:L.pm.LIMIT_VISIBLE_DMS_GMS,value:this.state.limit.value.toString()}]),this.setState({isSaving:!1}),this.props.updateSection(""))})),bi(this,"renderDescription",(()=>r().createElement("span",null,this.state.limit.label))),this.state={active:!1,limit:{value:20,label:"20"},isSaving:!1},this.minRef=r().createRef()}static getDerivedStateFromProps(e,t){return e.active!==t.active?e.active&&!t.active?{limit:Si.find((t=>t.value===e.dmGmLimit)),active:e.active}:{active:e.active}:e.active?null:{limit:Si.find((t=>t.value===e.dmGmLimit))}}focusEditButton(){var e;null===(e=this.minRef.current)||void 0===e||e.focus()}componentDidUpdate(e){e.active&&!this.props.active&&this.props.areAllSectionsInactive&&this.focusEditButton()}render(){const e=r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.limitVisibleGMsDMsTitle",defaultMessage:"Number of direct messages to show"});return this.props.active?r().createElement(D,{title:e,inputs:r().createElement("fieldset",null,r().createElement("legend",{className:"form-legend hidden-label"},e),r().createElement(Oe.Ay,{className:"react-select",classNamePrefix:"react-select",id:"limitVisibleGMsDMs",options:Si,clearable:!1,onChange:this.handleChange,value:this.state.limit,isSearchable:!1,menuPortalTarget:document.body,styles:Mi}),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.limitVisibleGMsDMsDesc",defaultMessage:"You can also change these settings in the direct messages sidebar menu."}))),submit:this.handleSubmit,saving:this.state.isSaving,updateSection:this.props.updateSection}):r().createElement(C,{title:e,describe:this.renderDescription(),section:"limitVisibleGMsDMs",updateSection:this.props.updateSection,ref:this.minRef})}}const Mi={menuPortal:e=>vi(vi({},e),{},{zIndex:9999})},Ni={savePreferences:g.SF},Ai=(0,p.connect)((function(e,t){const s=t.adminMode&&t.userPreferences?t.userPreferences:void 0;return{userId:t.adminMode?t.userId:(0,b.WR)(e),dmGmLimit:(0,v.pR)(e,s)}}),Ni)(yi);function Ti(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class _i extends r().PureComponent{constructor(e){super(e),Ti(this,"handleChange",(e=>{this.setState({checked:"true"===e.target.value}),(0,T.b6)(e.target)})),Ti(this,"handleSubmit",(async()=>{this.props.userId&&(this.setState({isSaving:!0}),await this.props.savePreferences(this.props.userId,[{user_id:this.props.userId,category:L.pm.CATEGORY_SIDEBAR_SETTINGS,name:L.pm.SHOW_UNREAD_SECTION,value:this.state.checked.toString()}]),this.setState({isSaving:!1}),this.props.updateSection(""))})),Ti(this,"renderDescription",(()=>this.props.showUnreadsCategory?r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.on",defaultMessage:"On"}):r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.off",defaultMessage:"Off"}))),this.state={active:!1,checked:!1,isSaving:!1},this.minRef=r().createRef()}static getDerivedStateFromProps(e,t){return e.active!==t.active?e.active&&!t.active?{checked:e.showUnreadsCategory,active:e.active}:{active:e.active}:null}focusEditButton(){var e;null===(e=this.minRef.current)||void 0===e||e.focus()}componentDidUpdate(e){e.active&&!this.props.active&&this.props.areAllSectionsInactive&&this.focusEditButton()}render(){const e=r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.showUnreadsCategoryTitle",defaultMessage:"Group unread channels separately"});return this.props.active?r().createElement(D,{title:e,inputs:r().createElement("fieldset",null,r().createElement("legend",{className:"form-legend hidden-label"},e),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{"data-testid":"showUnreadsCategoryOn",type:"radio",name:"showUnreadsCategory",checked:this.state.checked,onChange:()=>this.setState({checked:!0})}),r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.on",defaultMessage:"On"})),r().createElement("br",null)),r().createElement("div",{className:"radio"},r().createElement("label",null,r().createElement("input",{"data-testid":"showUnreadsCategoryOff",type:"radio",name:"showUnreadsCategory",checked:!this.state.checked,onChange:()=>this.setState({checked:!1})}),r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.off",defaultMessage:"Off"})),r().createElement("br",null)),r().createElement("div",{className:"mt-5"},r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.showUnreadsCategoryDesc",defaultMessage:"When enabled, all unread channels and direct messages will be grouped together in the sidebar."}))),submit:this.handleSubmit,saving:this.state.isSaving,updateSection:this.props.updateSection}):r().createElement(C,{title:e,describe:this.renderDescription(),section:"showUnreadsCategory",updateSection:this.props.updateSection,ref:this.minRef})}}const Ci={savePreferences:g.SF},ki=(0,p.connect)((function(e,t){const s=t.adminMode&&t.userPreferences?t.userPreferences:void 0;return{userId:t.adminMode?t.userId:(0,b.WR)(e),showUnreadsCategory:(0,v.pE)(e,s)}}),Ci)(_i);function wi(e){return r().createElement("div",null,r().createElement(K,{closeModal:e.closeModal,collapseModal:e.collapseModal,text:r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.title",defaultMessage:"Sidebar Settings"})}),r().createElement("div",{id:"sidebarTitle",className:"user-settings"},r().createElement(H,{text:r().createElement(d.FormattedMessage,{id:"user.settings.sidebar.title",defaultMessage:"Sidebar Settings"})}),r().createElement("div",{className:"divider-dark first"}),r().createElement(ki,{active:"showUnreadsCategory"===e.activeSection,updateSection:e.updateSection,areAllSectionsInactive:""===e.activeSection,adminMode:e.adminMode,userId:e.userId,userPreferences:e.userPreferences}),r().createElement("div",{className:"divider-dark"}),r().createElement(Ai,{active:"limitVisibleGMsDMs"===e.activeSection,updateSection:e.updateSection,areAllSectionsInactive:""===e.activeSection,adminMode:e.adminMode,userId:e.userId,userPreferences:e.userPreferences}),r().createElement("div",{className:"divider-dark"})))}wi.propTypes={updateSection:a().func.isRequired,activeSection:a().string.isRequired,closeModal:a().func.isRequired,collapseModal:a().func.isRequired,adminMode:a().bool,userId:a().string.isRequired};const Ii=wi;function Ri(e){return"profile"===e.activeTab?r().createElement("div",null,r().createElement(gt,{user:e.user,activeSection:e.activeSection,updateSection:e.updateSection,updateTab:e.updateTab,closeModal:e.closeModal,collapseModal:e.collapseModal})):"security"===e.activeTab?r().createElement("div",null,r().createElement(fi,{user:e.user,activeSection:e.activeSection,updateSection:e.updateSection,closeModal:e.closeModal,collapseModal:e.collapseModal,setRequireConfirm:e.setRequireConfirm})):"notifications"===e.activeTab?r().createElement("div",null,r().createElement(fs,{user:e.user,activeSection:e.activeSection,updateSection:e.updateSection,closeModal:e.closeModal,collapseModal:e.collapseModal,adminMode:e.adminMode,userPreferences:e.userPreferences})):"display"===e.activeTab?r().createElement("div",null,r().createElement(Xe,{user:e.user,activeSection:e.activeSection,updateSection:e.updateSection,closeModal:e.closeModal,collapseModal:e.collapseModal,setRequireConfirm:e.setRequireConfirm,adminMode:e.adminMode,userPreferences:e.userPreferences})):"sidebar"===e.activeTab?r().createElement("div",null,r().createElement(Ii,{activeSection:e.activeSection,updateSection:e.updateSection,closeModal:e.closeModal,collapseModal:e.collapseModal,adminMode:e.adminMode,userId:e.user.id,userPreferences:e.userPreferences})):"advanced"===e.activeTab?r().createElement("div",null,r().createElement(Z,{activeSection:e.activeSection,updateSection:e.updateSection,closeModal:e.closeModal,collapseModal:e.collapseModal,adminMode:e.adminMode,user:e.user,userPreferences:e.userPreferences})):e.activeTab&&e.pluginSettings[e.activeTab]?r().createElement("div",null,r().createElement(ws,{activeSection:e.activeSection,updateSection:e.updateSection,closeModal:e.closeModal,collapseModal:e.collapseModal,settings:e.pluginSettings[e.activeTab]})):null}Ri.propTypes={activeTab:a().string,activeSection:a().string.isRequired,updateSection:a().func.isRequired,updateTab:a().func.isRequired,closeModal:a().func.isRequired,collapseModal:a().func.isRequired,setRequireConfirm:a().func.isRequired,adminMode:a().bool};var Pi=s(53654);const Oi=e=>{let{loading:t,children:s,className:i,onLoaded:a}=e;const[o,l]=(0,n.useState)(!1);return(0,n.useEffect)((()=>{setTimeout((()=>{l(!0)}),1e3)}),[]),(0,n.useEffect)((()=>{!t&&o&&a()}),[t,o,a]),t||!o?r().createElement("div",{className:"SmartLoader ".concat(i)},s):null};Oi.propTypes={loading:a().bool.isRequired,children:a().node.isRequired,className:a().string,onLoaded:a().func.isRequired};const Di=Oi;var Fi=s(63155);function Li(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class xi extends r().PureComponent{constructor(e){var t;super(e),Li(this,"handleResend",(e=>{this.setState({resendStatus:"sending"}),this.props.actions.sendVerificationEmail(e).then((e=>{let{data:t,error:s}=e;t?this.setState({resendStatus:"success"}):s&&this.setState({resendStatus:"failure"})}))})),Li(this,"setLoadingFinished",(()=>{this.setState({loading:!1})})),Li(this,"handleKeyDown",(e=>{(0,P.r)(e)&&e.shiftKey&&(0,P.e)(e,S.Ay.KeyCodes.A)&&(e.preventDefault(),this.handleHide())})),Li(this,"handleHide",(()=>{this.requireConfirm?this.showConfirmModal((()=>this.handleHide())):((0,Nt.$c)(),this.setState({show:!1}))})),Li(this,"handleHidden",(()=>{this.setState({active_tab:this.props.isContentProductSettings?"notifications":"profile",active_section:""}),this.props.onExited()})),Li(this,"handleCollapse",(()=>{c().findDOMNode(this.modalBodyRef.current).closest(".modal-dialog").classList.remove("display--content"),this.setState({active_tab:"",active_section:""})})),Li(this,"handleConfirm",(()=>{this.setState({showConfirmModal:!1,enforceFocus:!0}),this.requireConfirm=!1,this.customConfirmAction=null,this.afterConfirm&&(this.afterConfirm(),this.afterConfirm=null)})),Li(this,"handleCancelConfirmation",(()=>{this.setState({showConfirmModal:!1,enforceFocus:!0}),this.afterConfirm=null})),Li(this,"showConfirmModal",(e=>{e&&(this.afterConfirm=e),this.customConfirmAction?this.customConfirmAction(this.handleConfirm):this.setState({showConfirmModal:!0,enforceFocus:!1})})),Li(this,"closeModal",(()=>{this.requireConfirm?this.showConfirmModal(this.closeModal):this.handleHide()})),Li(this,"collapseModal",(()=>{this.requireConfirm?this.showConfirmModal(this.collapseModal):this.handleCollapse()})),Li(this,"updateTab",((e,t)=>{!t&&this.requireConfirm?this.showConfirmModal((()=>this.updateTab(e,!0))):this.setState({active_tab:e,active_section:""})})),Li(this,"updateSection",((e,t)=>{!t&&this.requireConfirm?this.showConfirmModal((()=>this.updateSection(e,!0))):this.setState({active_section:null!=e?e:""})})),Li(this,"getUserSettingsTabs",(()=>[{name:"notifications",uiName:this.props.intl.formatMessage({id:"user.settings.modal.notifications",defaultMessage:"Notifications"}),icon:"icon icon-bell-outline",iconTitle:this.props.intl.formatMessage({id:"user.settings.notifications.icon",defaultMessage:"Notification Settings Icon"})},{name:"display",uiName:this.props.intl.formatMessage({id:"user.settings.modal.display",defaultMessage:"Display"}),icon:"icon icon-eye-outline",iconTitle:this.props.intl.formatMessage({id:"user.settings.display.icon",defaultMessage:"Display Settings Icon"})},{name:"sidebar",uiName:this.props.intl.formatMessage({id:"user.settings.modal.sidebar",defaultMessage:"Sidebar"}),icon:"icon icon-dock-left",iconTitle:this.props.intl.formatMessage({id:"user.settings.sidebar.icon",defaultMessage:"Sidebar Settings Icon"})},{name:"advanced",uiName:this.props.intl.formatMessage({id:"user.settings.modal.advanced",defaultMessage:"Advanced"}),icon:"icon icon-tune",iconTitle:this.props.intl.formatMessage({id:"user.settings.advance.icon",defaultMessage:"Advanced Settings Icon"})}])),Li(this,"getProfileSettingsTab",(()=>[{name:"profile",uiName:this.props.intl.formatMessage({id:"user.settings.modal.profile",defaultMessage:"Profile"}),icon:"icon icon-settings-outline",iconTitle:this.props.intl.formatMessage({id:"user.settings.profile.icon",defaultMessage:"Profile Settings Icon"})},{name:"security",uiName:this.props.intl.formatMessage({id:"user.settings.modal.security",defaultMessage:"Security"}),icon:"icon icon-lock-outline",iconTitle:this.props.intl.formatMessage({id:"user.settings.security.icon",defaultMessage:"Security Settings Icon"})}])),Li(this,"getPluginsSettingsTab",(()=>Object.values(this.props.pluginSettings).map((e=>{const t=e.icon?"icon ".concat(e.icon):"icon icon-power-plug-outline",s=e.icon&&((0,Fi.AY)(e.icon)||e.icon.startsWith("/"));return{name:e.id,uiName:e.uiName,icon:s?{url:e.icon}:t,iconTitle:e.uiName}})))),this.state={active_tab:null!==(t=e.activeTab)&&void 0!==t?t:e.isContentProductSettings?"notifications":"profile",active_section:"",showConfirmModal:!1,enforceFocus:!0,show:!0,resendStatus:"",loading:!1},this.requireConfirm=!1,this.customConfirmAction=null,this.afterConfirm=null,this.modalBodyRef=r().createRef()}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown),this.props.adminMode&&this.props.userID&&(this.setState({loading:!0}),this.props.userPreferences||this.props.actions.getUserPreferences(this.props.userID),this.props.user||this.props.actions.getUser(this.props.userID)),this.props.adminMode||this.setState({loading:!1})}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(e,t){this.state.active_tab!==t.active_tab&&(c().findDOMNode(this.modalBodyRef.current).scrollTop=0)}render(){const{formatMessage:e}=this.props.intl;let t;return t=this.props.adminMode&&this.props.user?e({id:"userSettings.adminMode.modal_header",defaultMessage:"{userDisplayName}'s Settings"},{userDisplayName:(0,T.Mn)(this.props.user)}):this.props.isContentProductSettings?e({id:"global_header.productSettings",defaultMessage:"Settings"}):e({id:"user.settings.modal.title",defaultMessage:"Profile"}),r().createElement(o.Modal,{id:"accountSettingsModal",dialogClassName:"a11y__modal settings-modal",show:this.state.show,onHide:this.handleHide,onExited:this.handleHidden,enforceFocus:this.state.enforceFocus,"aria-label":t,role:"none"},r().createElement(o.Modal.Header,{id:"accountSettingsHeader",closeButton:!0},r().createElement(o.Modal.Title,{componentClass:"h1",id:"accountSettingsModalLabel"},t),this.props.adminMode&&r().createElement("div",{className:"adminModeBadge"},r().createElement(d.FormattedMessage,{id:"userSettings.adminMode.admin_mode_badge",defaultMessage:"Admin Mode"}))),r().createElement(o.Modal.Body,{ref:this.modalBodyRef},this.props.adminMode&&r().createElement(Di,{loading:this.props.adminMode&&(!this.props.userPreferences||!this.props.user),className:"loadingIndicator",onLoaded:this.setLoadingFinished},r().createElement(Pi.A,null)),!this.state.loading&&this.props.user&&r().createElement("div",{className:"settings-table"},r().createElement("div",{className:"settings-links"},r().createElement(m.default,{tabs:this.props.isContentProductSettings?this.getUserSettingsTabs():this.getProfileSettingsTab(),pluginTabs:this.props.isContentProductSettings?this.getPluginsSettingsTab():[],activeTab:this.state.active_tab,updateTab:this.updateTab})),r().createElement("div",{className:"settings-content minimize-settings"},r().createElement(Ri,{activeTab:this.state.active_tab,activeSection:this.state.active_section,updateSection:this.updateSection,updateTab:this.updateTab,closeModal:this.closeModal,collapseModal:this.collapseModal,setRequireConfirm:(e,t)=>{this.requireConfirm=e,this.customConfirmAction=t},pluginSettings:this.props.pluginSettings,user:this.props.user,adminMode:this.props.adminMode,userPreferences:this.props.userPreferences})))),r().createElement(u.A,{title:e({id:"user.settings.modal.confirmTitle",defaultMessage:"Discard Changes?"}),message:e({id:"user.settings.modal.confirmMsg",defaultMessage:"You have unsaved changes, are you sure you want to discard them?"}),confirmButtonText:e({id:"user.settings.modal.confirmBtns",defaultMessage:"Yes, Discard"}),show:this.state.showConfirmModal,onConfirm:this.handleConfirm,onCancel:this.handleCancelConfirmation}))}}Li(xi,"propTypes",{userID:a().string,adminMode:a().bool,isContentProductSettings:a().bool.isRequired,activeTab:a().string,onExited:a().func.isRequired,actions:a().shape({sendVerificationEmail:a().func.isRequired,getUserPreferences:a().func.isRequired,getUser:a().func.isRequired}).isRequired});const Ui=(0,d.injectIntl)(xi)}}]); //# sourceMappingURL=5977.3e836e5e6150a3e7a19d.js.map