import{a as e,d as t,i as n}from"./objectSpread2-DtFdQpqy.js";import{n as r}from"./preload-helper-EQ20WQt-.js";import{c as i,j as a,o,t as s}from"./prop-types-DdDwMzX7.js";import{ct as c,i as l,pt as u}from"./poll-9cD-z1op.js";import{Io as d,Ma as f,bo as p,fo as m,go as h,ko as g,yo as _}from"./time-BE5vfriQ.js";import{t as v}from"./intl-DxYtUOxD.js";import{H as y,un as b}from"./status_quoted-I7FHuyaO.js";import{t as x}from"./option-Cmf2nYUi.js";var S=t(s());_();var C=t(l()),w=r();e();var T=i({close:{id:`lightbox.close`,defaultMessage:`Close`}}),E=d([(e,t)=>e.getIn([`timelines`,`account:${t}`,`items`],m()),e=>e.get(`statuses`)],(e,t)=>h(e.map(e=>t.get(e)).filter(e=>!e.get(`reblog`)).map(e=>e.get(`language`)))),D=(e,{accountId:t})=>({acct:e.getIn([`accounts`,t,`acct`]),availableLanguages:E(e,t),selectedLanguages:h(e.getIn([`relationships`,t,`languages`])||m())}),O=(e,{accountId:t})=>({onSubmit(n){e(f(t,{languages:n}))}}),k=class extends y{constructor(...e){super(...e),n(this,`state`,{selectedLanguages:this.props.selectedLanguages}),n(this,`handleLanguageToggle`,(e,t)=>{let{selectedLanguages:n}=this.state;t?this.setState({selectedLanguages:n.add(e)}):this.setState({selectedLanguages:n.delete(e)})}),n(this,`handleSubmit`,()=>{this.props.onSubmit(this.state.selectedLanguages.toArray()),this.props.onClose()})}renderItem(e){let t=this.props.languages.find(t=>t[0]===e),n=this.state.selectedLanguages.includes(e);return t?(0,w.jsx)(x,{name:`languages`,value:e,label:t[1],checked:n,onToggle:this.handleLanguageToggle,multiple:!0},e):null}render(){let{acct:e,availableLanguages:t,selectedLanguages:n,intl:r,onClose:i}=this.props;return(0,w.jsxs)(`div`,{className:`modal-root__modal report-dialog-modal`,children:[(0,w.jsxs)(`div`,{className:`report-modal__target`,children:[(0,w.jsx)(c,{className:`report-modal__close`,title:r.formatMessage(T.close),icon:`times`,iconComponent:u,onClick:i,size:20}),(0,w.jsx)(o,{id:`subscribed_languages.target`,defaultMessage:`Change subscribed languages for {target}`,values:{target:(0,w.jsx)(`strong`,{children:e})}})]}),(0,w.jsxs)(`div`,{className:`report-dialog-modal__container`,children:[(0,w.jsx)(`p`,{className:`report-dialog-modal__lead`,children:(0,w.jsx)(o,{id:`subscribed_languages.lead`,defaultMessage:`Only posts in selected languages will appear on your home and list timelines after the change. Select none to receive posts in all languages.`})}),(0,w.jsx)(`div`,{children:t.union(n).delete(null).map(e=>this.renderItem(e))}),(0,w.jsx)(`div`,{className:`flex-spacer`}),(0,w.jsx)(`div`,{className:`report-dialog-modal__actions`,children:(0,w.jsx)(b,{disabled:p(this.state.selectedLanguages,this.props.selectedLanguages),onClick:this.handleSubmit,children:(0,w.jsx)(o,{id:`subscribed_languages.save`,defaultMessage:`Save changes`})})})]})]})}};n(k,`propTypes`,{accountId:S.default.string.isRequired,acct:S.default.string.isRequired,availableLanguages:C.default.setOf(S.default.string),selectedLanguages:C.default.setOf(S.default.string),onClose:S.default.func.isRequired,languages:S.default.arrayOf(S.default.arrayOf(S.default.string)),intl:S.default.object.isRequired,submit:S.default.func.isRequired}),n(k,`defaultProps`,{languages:a});var A=g(D,O)(v(k));export{A as default};
//# sourceMappingURL=subscribed_languages_modal-CIeAlCyN.js.map