(()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.i18n,s=window.wp.domReady;var n=e.n(s);const a=window.wp.element,o=window.wp.components,r=window.wp.apiFetch;var i=e.n(r);const l=window.wp.data;function c(e){if("object"==typeof GatherPress)return e.split(".").reduce((e,t)=>e?.[t],GatherPress)}const d=window.ReactJSXRuntime,p=()=>{const{isOpen:e,isSaving:s}=(0,l.useSelect)(e=>({isOpen:e("gatherpress/email-modal").isModalOpen(),isSaving:e("gatherpress/email-modal").isSaving()}),[]),{closeModal:n}=(0,l.useDispatch)("gatherpress/email-modal"),[r,p]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),[m,g]=(0,a.useState)(!1),[x,w]=(0,a.useState)(!1),[b,j]=(0,a.useState)(!1),[C,_]=(0,a.useState)(""),f=(0,a.useRef)(null);return(0,a.useEffect)(()=>{j(!(r||h||m||x))},[r,h,m,x]),(0,a.useEffect)(()=>{e&&f.current&&f.current.focus()},[e]),(0,d.jsx)(d.Fragment,{children:e&&(0,d.jsxs)(o.Modal,{title:(0,t.__)("Send event update via email","gatherpress"),onRequestClose:n,shouldCloseOnClickOutside:!1,style:{maxWidth:"550px"},children:[(0,d.jsx)(o.TextareaControl,{label:(0,t.__)("Optional message","gatherpress"),value:C,focus:!0,onChange:e=>_(e),ref:f}),(0,d.jsx)("p",{className:"description",children:(0,t.__)('Select the recipients for your message by checking the relevant boxes. "All Members" includes site users only. RSVP status options include both site users and non-user RSVPs.',"gatherpress")}),(0,d.jsxs)(o.Flex,{gap:"8",children:[(0,d.jsx)(o.FlexItem,{children:(0,d.jsx)(o.CheckboxControl,{label:(0,t._x)("All Members","Email recipient group option","gatherpress"),checked:r,onChange:p})}),(0,d.jsx)(o.FlexItem,{children:(0,d.jsx)(o.CheckboxControl,{label:(0,t._x)("Attending","Email recipient group option","gatherpress"),checked:h,onChange:u})}),(0,d.jsx)(o.FlexItem,{children:(0,d.jsx)(o.CheckboxControl,{label:(0,t._x)("Waiting List","Email recipient group option","gatherpress"),checked:m,onChange:g})}),(0,d.jsx)(o.FlexItem,{children:(0,d.jsx)(o.CheckboxControl,{label:(0,t._x)("Not Attending","Email recipient group option","gatherpress"),checked:x,onChange:w})})]}),(0,d.jsx)("br",{}),(0,d.jsx)(o.Button,{variant:"primary",onClick:()=>{window.confirm((0,t.__)("Confirm you are ready to send?","gatherpress"))&&i()({path:c("urls.eventApiPath")+"/email",method:"POST",data:{post_id:c("eventDetails.postId"),message:C,send:{all:r,attending:h,waiting_list:m,not_attending:x}}}).then(e=>{e.success&&(n(),_(""),p(!1),u(!1),g(!1),w(!1))})},disabled:b||s,children:(0,t._x)("Send Email","Email submission button text","gatherpress")})]})})};n()(()=>{const e=document.getElementById("gatherpress-event-communication-modal");e&&(0,a.createRoot)(e).render((0,d.jsx)(p,{}))})})();