import{d as e}from"./objectSpread2-DtFdQpqy.js";import{a as t,n}from"./preload-helper-EQ20WQt-.js";import{c as r,l as i,o as a}from"./prop-types-DdDwMzX7.js";import{V as o,a as s,ft as c,lt as l}from"./poll-D7UTo6nN.js";import{Do as u,Eo as d,Fo as f,fn as p,hn as m,pn as h,vn as g}from"./time-BE5vfriQ.js";import{l as _,s as v}from"./react-router-OpaHPRhD.js";import{t as y}from"./helmet-xJbX5x_5.js";import{n as b}from"./short_number-CCNBtmoH.js";import{t as x}from"./column-CvSGioVA.js";import{t as S}from"./avatar_group-DChdi6Bc.js";import{n as C}from"./lists-Aoj54pku.js";import{a as w}from"./columns_area-DMVhiuQq.js";import{n as T}from"./form_fields-BFfmILJg.js";import{r as E}from"./copy_icon_button-CNBfT_gA.js";import{t as D}from"./toggle_field-tLmJ7GmL.js";import{messages as O}from"./members-DS82snYo.js";var k=e(t()),A=n(),j=r({edit:{id:`column.edit_list`,defaultMessage:`Edit list`},create:{id:`column.create_list`,defaultMessage:`Create list`}}),M=({id:e})=>{let t=i(),[n,r]=(0,k.useState)(0),[c,u]=(0,k.useState)([]);return(0,k.useEffect)(()=>{g(e).then(e=>{r(e.length),u(e.slice(0,3))}).catch(()=>{})},[e]),(0,A.jsxs)(b,{to:`/lists/${e}/members`,className:`app-form__link`,children:[(0,A.jsxs)(`div`,{className:`app-form__link__text`,children:[(0,A.jsxs)(`strong`,{children:[t.formatMessage(O.manageMembers),(0,A.jsx)(l,{id:`chevron_right`,icon:s})]}),(0,A.jsx)(a,{id:`lists.list_members_count`,defaultMessage:`{count,plural,one{# member} other{# members}}`,values:{count:n}})]}),(0,A.jsx)(S,{compact:!0,children:c.map(e=>(0,A.jsx)(o,{account:e,size:30},e.id))})]})},N=({list:e})=>{let t=d(),n=v(),{id:r,title:i=``,exclusive:o=!1,replies_policy:s=`list`}=e==null?{}:e,[l,u]=(0,k.useState)(i),[p,g]=(0,k.useState)(o),[_,y]=(0,k.useState)(s),[b,x]=(0,k.useState)(!1),S=(0,k.useCallback)(({target:{value:e}})=>{u(e)},[u]),C=(0,k.useCallback)(({target:{checked:e}})=>{g(e)},[g]),w=(0,k.useCallback)(({target:{value:e}})=>{y(e)},[y]);return(0,A.jsxs)(`form`,{className:`simple_form app-form`,onSubmit:(0,k.useCallback)(()=>{x(!0),r?t(m({id:r,title:l,exclusive:p,replies_policy:_})).then(()=>(x(!1),``)):t(h({title:l,exclusive:p,replies_policy:_})).then(e=>(x(!1),f(e)&&(n.replace(`/lists/${e.payload.id}/edit`),n.push(`/lists/${e.payload.id}/members`)),``))},[n,t,x,r,l,p,_]),children:[(0,A.jsx)(`div`,{className:`fields-group`,children:(0,A.jsx)(E,{required:!0,maxLength:30,label:(0,A.jsx)(a,{id:`lists.list_name`,defaultMessage:`List name`}),value:l,onChange:S,id:`list_title`})}),(0,A.jsx)(`div`,{className:`fields-group`,children:(0,A.jsxs)(T,{label:(0,A.jsx)(a,{id:`lists.show_replies_to`,defaultMessage:`Include replies from list members to`}),value:_,onChange:w,id:`list_replies_policy`,children:[(0,A.jsx)(a,{id:`lists.replies_policy.none`,defaultMessage:`No one`,children:e=>(0,A.jsx)(`option`,{value:`none`,children:e})}),(0,A.jsx)(a,{id:`lists.replies_policy.list`,defaultMessage:`Members of the list`,children:e=>(0,A.jsx)(`option`,{value:`list`,children:e})}),(0,A.jsx)(a,{id:`lists.replies_policy.followed`,defaultMessage:`Any followed user`,children:e=>(0,A.jsx)(`option`,{value:`followed`,children:e})})]})}),r&&(0,A.jsx)(`div`,{className:`fields-group`,children:(0,A.jsx)(M,{id:r})}),(0,A.jsx)(`div`,{className:`fields-group`,children:(0,A.jsxs)(`label`,{className:`app-form__toggle`,children:[(0,A.jsxs)(`div`,{className:`app-form__toggle__label`,children:[(0,A.jsx)(`strong`,{children:(0,A.jsx)(a,{id:`lists.exclusive`,defaultMessage:`Hide members in Home`})}),(0,A.jsx)(`span`,{className:`hint`,children:(0,A.jsx)(a,{id:`lists.exclusive_hint`,defaultMessage:`If someone is on this list, hide them in your Home feed to avoid seeing their posts twice.`})})]}),(0,A.jsx)(`div`,{className:`app-form__toggle__toggle`,children:(0,A.jsx)(`div`,{children:(0,A.jsx)(D,{checked:p,onChange:C})})})]})}),(0,A.jsx)(`div`,{className:`actions`,children:(0,A.jsx)(`button`,{className:`button`,type:`submit`,children:b?(0,A.jsx)(c,{}):r?(0,A.jsx)(a,{id:`lists.save`,defaultMessage:`Save`}):(0,A.jsx)(a,{id:`lists.create`,defaultMessage:`Create`})})})]})},P=({multiColumn:e})=>{let t=i(),n=d(),{id:r}=_(),a=u(e=>r?e.lists.get(r):void 0);(0,k.useEffect)(()=>{r&&n(p(r))},[n,r]);let o=r&&!a;return(0,A.jsxs)(x,{bindToDocument:!e,label:t.formatMessage(r?j.edit:j.create),children:[(0,A.jsx)(w,{title:t.formatMessage(r?j.edit:j.create),icon:`list-ul`,iconComponent:C,multiColumn:e,showBackButton:!0}),(0,A.jsx)(`div`,{className:`scrollable`,children:o?(0,A.jsx)(c,{}):(0,A.jsx)(N,{list:a})}),(0,A.jsxs)(y,{children:[(0,A.jsx)(`title`,{children:t.formatMessage(r?j.edit:j.create)}),(0,A.jsx)(`meta`,{name:`robots`,content:`noindex`})]})]})};export{P as default};
//# sourceMappingURL=new-D1isXpHD.js.map