"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[7107],{77107:(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});var a=n(23615),i=n.n(a),s=(n(61418),n(32081),n(40895),n(92189),n(60042)),r=n.n(s),o=n(36549),l=n(84390),d=n.n(l),c=n(72060),p=n(48332),u=n(6098),m=n(1514),h=n(57580),f=n(83398),D=n(13653),b=n(66475),_=n(23712),y=n(1065),g=n(35887),O=n(70174);function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function E(e){for(var t=1;t{(0,g.p)(e,_.default.KeyCodes.ESCAPE)&&(this.state.isPopperOpen?this.handlePopperOpenState(!1):this.props.onExited())})),k(this,"formatDate",(e=>o.DateTime.fromJSDate(e).toFormat("yyyy-MM-dd"))),k(this,"getText",(()=>({modalHeaderText:d().createElement(c.FormattedMessage,{id:"dnd_custom_time_picker_modal.defaultMsg",defaultMessage:"Disable notifications until"}),confirmButtonText:d().createElement(c.FormattedMessage,{id:"dnd_custom_time_picker_modal.submitButton",defaultMessage:"Disable Notifications"})}))),k(this,"handleConfirm",(async()=>{if(this.state.isPopperOpen)return;const e=parseInt(this.state.selectedTime.split(":")[0],10),t=parseInt(this.state.selectedTime.split(":")[1],10),n=new Date(this.state.selectedDate);n.setHours(e,t),n{this.setState(E({isPopperOpen:!1,selectedDate:e},this.makeTimeMenuList(e)))})),k(this,"makeTimeMenuList",(e=>{const t=[];let n=0,a=0;const i=this.props.currentDate;this.formatDate(i)===this.formatDate(e)&&(n=i.getHours(),a=i.getMinutes(),a>20?(n++,a=0):a=30);for(let e=n;e<24;e++)for(let n=a/30;n<2;n++){const a=e.toString().padStart(2,"0")+":"+(30*n).toString().padStart(2,"0");t.push(a)}return{timeMenuList:t,selectedTime:t[0]}})),k(this,"handlePopperOpenState",(e=>{this.setState({isPopperOpen:e})}));const{currentDate:t}=this.props,n=new Date(t);23===t.getHours()&&t.getMinutes()>20&&n.setDate(t.getDate()+1),this.state=E(E({selectedDate:n,dayPickerStartDate:n},this.makeTimeMenuList(n)),{},{isPopperOpen:!1,popperElement:null})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}render(){const{modalHeaderText:e,confirmButtonText:t}=this.getText(),{timeMenuList:n,selectedTime:a,selectedDate:i,dayPickerStartDate:s,isPopperOpen:o}=this.state,l=n.map((e=>d().createElement(D.Z.ItemAction,{id:"dndTime_dropdown_".concat(e),key:e,text:e,ariaLabel:"".concat(e," hours"),onClick:()=>{this.setState({selectedTime:e}),document.dispatchEvent(new CustomEvent(_.sp.FOCUS,{detail:{target:this.buttonRef.current,keyboardOnly:!0}}))}},e))),y=d().createElement(p.ZP,{icon:"calendar-outline",onClick:()=>this.handlePopperOpenState(!0),className:"dateTime__calendar-icon",size:"sm","aria-haspopup":"grid"}),g={initialFocus:o,mode:"single",selected:i,onDayClick:this.handleDaySelection,disabled:[{before:s}],showOutsideDays:!0};return d().createElement(m.default,{theme:this.props.theme},d().createElement(u.$E,{compassDesign:!0,ariaLabel:(0,O._u)({id:"dnd_custom_time_picker_modal.defaultMsg",defaultMessage:"Disable notifications until"}),onExited:this.props.onExited,modalHeaderText:e,confirmButtonText:t,handleConfirm:this.handleConfirm,handleEnterKeyPress:this.handleConfirm,id:"dndCustomTimePickerModal",className:"DndModal modal-overflow",tabIndex:-1,keyboardEscape:!1},d().createElement("div",{className:"DndModal__content"},d().createElement(h.Z,{isPopperOpen:o,handlePopperOpenState:this.handlePopperOpenState,locale:this.props.locale,datePickerProps:g},d().createElement(f.Z,{value:this.formatDate(i),readOnly:!0,id:"DndModal__calendar-input",className:r()("DndModal__calendar-input",{"popper-open":o}),label:(0,O._u)({id:"dnd_custom_time_picker_modal.date",defaultMessage:"Date"}),onClick:()=>this.handlePopperOpenState(!0),tabIndex:-1,inputPrefix:y})),d().createElement(b.Z,{id:"dropdown-no-caret",stopPropagationOnToggle:!0},d().createElement("button",{className:"DndModal__input",type:"button",ref:this.buttonRef},d().createElement("div",{className:"DndModal__input__label"},d().createElement(c.FormattedMessage,{id:"dnd_custom_time_picker_modal.time",defaultMessage:"Time"})),d().createElement("i",{className:"icon icon--no-spacing icon-clock-outline icon--xs icon-14"}),d().createElement("span",null,a)),d().createElement(D.Z,{openLeft:!1,ariaLabel:"Clear custom status after"},l)))))}}k(w,"propTypes",{onExited:i().func.isRequired,userId:i().string.isRequired,currentDate:i().instanceOf(Date).isRequired,locale:i().string.isRequired,actions:i().shape({setStatus:i().func.isRequired}).isRequired})}}]); //# sourceMappingURL=7107.8e918ccd20f175716590.js.map