"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[4414],{44414(e,t,r){r.r(t),r.d(t,{default:()=>b});var s=r(37270),a=r(32446),i=r(17085),n=r(26614),o=r(77440),c=r(69410),l=(r(15724),r(5673),r(30164),r(21279),r(36418)),m=r(14778),d=r(14891),g=r(78546),u=r(91767),f=r(35439),h=r(1396),v=r(3708),p=r(87064),E=r(53654),T=r(83007),_=r(81444),S=r(27768),A=r(62975);class M extends l.PureComponent{constructor(e){super(e),this.state={customTermsOfServiceId:"",customTermsOfServiceText:"",loading:!0,loadingAgree:!1,loadingDisagree:!1,serverError:null},this.formattedText=(0,g.el)(t=>(0,A.vX)(t,{},e.emojiMap))}componentDidMount(){this.props.termsEnabled?this.getTermsOfService():u.tc()}getTermsOfService=async()=>{this.setState({customTermsOfServiceId:"",customTermsOfServiceText:"",loading:!0});const{data:e}=await this.props.actions.getTermsOfService();e?this.setState({customTermsOfServiceId:e.id,customTermsOfServiceText:e.text,loading:!1}):u.BN(`/login?extra=${_.YM.GET_TERMS_ERROR}`)};handleLogoutClick=e=>{e.preventDefault(),u.BN("/login")};handleAcceptTerms=()=>{this.setState({loadingAgree:!0,serverError:null}),this.registerUserAction(!0,()=>{const e=new URLSearchParams(this.props.location?.search).get("redirect_to");e&&e.match(/^\/([^/]|$)/)?(0,T.J)().push(e):this.props.onboardingFlowEnabled?(0,T.J)().push("/"):u.tc()})};handleRejectTerms=()=>{this.setState({loadingDisagree:!0,serverError:null}),this.registerUserAction(!1,()=>{u.BN(`/login?extra=${_.YM.TERMS_REJECTED}`)})};registerUserAction=async(e,t)=>{const{data:r}=await this.props.actions.updateMyTermsOfServiceStatus(this.state.customTermsOfServiceId,e);r?t(r):this.setState({loadingAgree:!1,loadingDisagree:!1,serverError:l.createElement(m.FormattedMessage,{id:"terms_of_service.api_error",defaultMessage:"Unable to complete the request. If this issue persists, contact your System Administrator."})})};render(){if(this.state.loading)return l.createElement(h.A,null);let e="terms-of-service__markdown";return this.state.serverError?e+=" terms-of-service-error__height--fill":e+=" terms-of-service__height--fill",l.createElement("div",{className:"signup-page-container"},l.createElement(f.default,null),l.createElement("div",{className:"signup-header"},l.createElement("a",{href:"#",onClick:this.handleLogoutClick},l.createElement(v.A,null),l.createElement(m.FormattedMessage,{id:"web.header.logout",defaultMessage:"Logout"}))),l.createElement("div",{className:"signup-team__container terms-of-service__container"},l.createElement("div",{className:e},l.createElement("div",{className:"medium-center","data-testid":"termsOfService"},(0,S.A)(this.formattedText(this.state.customTermsOfServiceText),{mentions:!1}))),l.createElement("div",{className:"terms-of-service__footer medium-center"},l.createElement("div",{className:"terms-of-service__button-group"},l.createElement(d.Button,{emphasis:"primary",disabled:this.state.loadingAgree||this.state.loadingDisagree,id:"acceptTerms",onClick:this.handleAcceptTerms,type:"submit"},this.state.loadingAgree&&l.createElement(E.A,null),l.createElement(m.FormattedMessage,{id:"terms_of_service.agreeButton",defaultMessage:"I Agree"})),l.createElement(d.Button,{emphasis:"quaternary",disabled:this.state.loadingAgree||this.state.loadingDisagree,id:"rejectTerms",onClick:this.handleRejectTerms,type:"reset"},this.state.loadingDisagree&&l.createElement(E.A,null),l.createElement(m.FormattedMessage,{id:"terms_of_service.disagreeButton",defaultMessage:"I Disagree"}))),Boolean(this.state.serverError)&&l.createElement("div",{className:"terms-of-service__server-error alert alert-warning"},l.createElement(p.A,null)," ",this.state.serverError))))}}const b=(0,s.connect)(function(e){const t=(0,n.zj)(e);return{onboardingFlowEnabled:(0,o.Pu)(e),termsEnabled:"true"===t.EnableCustomTermsOfService,emojiMap:(0,c.v6)(e)}},function(e){return{actions:(0,a.zH)({getTermsOfService:i.AW,updateMyTermsOfServiceStatus:i.Zg},e)}})(M)},3708(e,t,r){r.d(t,{A:()=>i});var s=r(36418),a=r(14778);function i(){const{formatMessage:e}=(0,a.useIntl)();return s.createElement("i",{className:"fa fa-1x fa-angle-left",title:e({id:"generic_icons.logout",defaultMessage:"Logout Icon"})})}},87064(e,t,r){r.d(t,{A:()=>c});var s=r(71633),a=r.n(s),i=r(36418),n=r(14778);const o=({additionalClassName:e})=>{const{formatMessage:t}=(0,n.useIntl)();return i.createElement("i",{className:a()("fa fa-warning",e),title:t({id:"generic_icons.warning",defaultMessage:"Warning Icon"})})},c=i.memo(o)}}]);
//# sourceMappingURL=4414.ee790968f6c3352f664b.js.map