"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[4927,7308],{77308(e,t,n){n.r(t),n.d(t,{default:()=>r,normalizePluginIcon:()=>i.k});var a=n(37270),s=n(7380),i=n(2600);const r=(0,a.connect)(function(e){return{isMobileView:(0,s.w3)(e)}})(i.A)},2600(e,t,n){n.d(t,{A:()=>u,k:()=>p}),n(43617),n(81975),n(93991),n(94985),n(80569);var a=n(71633),s=n.n(a),i=n(36418),r=n(14778),l=n(81444),o=n(19513),c=n(63155);function p(e,t=""){return e?(0,c.AY)(e)?{url:e}:e.startsWith("/")?{url:`${"/"===t?"":t}${e}`}:`icon ${e}`:"icon icon-power-plug-outline"}class u extends i.PureComponent{constructor(e){super(e),this.buttonRefs=new Map}getVisibleTabs(){return[...this.props.tabs.filter(e=>!1!==e.display),...this.props.pluginTabs?.filter(e=>!1!==e.display)||[]]}handleClick=(e,t)=>{t.preventDefault(),this.props.updateTab(e.name),t.target.closest(".settings-modal")?.classList.add("display--content")};handleKeyDown=(e,t)=>{if(!(0,o.e)(t,l.Ay.KeyCodes.UP)&&!(0,o.e)(t,l.Ay.KeyCodes.DOWN))return;t.preventDefault();const n=this.getVisibleTabs();if(0===n.length)return;const a=n.findIndex(t=>t.name===e.name);if(-1===a)return;let s;s=(0,o.e)(t,l.Ay.KeyCodes.UP)?a>0?a-1:n.length-1:a<n.length-1?a+1:0;const i=n[s];this.props.updateTab(i.name);const r=this.buttonRefs.get(i.name);r&&r.focus()};renderTab(e){const t=`${e.name}_li`,n=this.props.activeTab===e.name;let a;return a="string"==typeof e.icon?i.createElement("i",{className:e.icon,title:e.iconTitle}):i.createElement("img",{src:e.icon.url,alt:e.iconTitle,className:"icon"}),i.createElement(i.Fragment,{key:t},e.newGroup&&i.createElement("hr",null),i.createElement("button",{"data-testid":`${e.name}-tab-button`,ref:t=>{t?this.buttonRefs.set(e.name,t):this.buttonRefs.delete(e.name)},id:`${e.name}Button`,className:s()("cursor--pointer style--none nav-pills__tab",{active:n}),onClick:this.handleClick.bind(null,e),onKeyDown:this.handleKeyDown.bind(null,e),"aria-label":e.uiName.toLowerCase(),role:"tab","aria-selected":n,tabIndex:n||this.props.isMobileView?0:-1,"aria-controls":`${e.name}Settings`},a,e.uiName))}render(){const e=this.props.tabs.filter(e=>!1!==e.display).map(e=>this.renderTab(e));let t;if(this.props.pluginTabs?.length){const e=this.props.pluginTabs.filter(e=>!1!==e.display);e.length&&(t=i.createElement(i.Fragment,null,i.createElement("hr",null),i.createElement("div",{role:"group","aria-labelledby":"settingsSidebar_pluginSection_header"},i.createElement("div",{key:"plugin preferences heading",role:"heading",className:"header","aria-level":3,id:"settingsSidebar_pluginSection_header"},i.createElement(r.FormattedMessage,{id:"userSettingsModal.pluginPreferences.header",defaultMessage:"PLUGIN PREFERENCES"})),e.map(e=>this.renderTab(e)))))}return i.createElement("div",{id:"tabList",className:"nav nav-pills nav-stacked",role:"tablist","aria-orientation":"vertical"},i.createElement("div",{role:"group"},e),t)}}}}]);
//# sourceMappingURL=7308.a27ee4b43eea0b40ec8d.js.map