/*! For license information please see admin.js.LICENSE.txt */ (globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[884],{16563(e,t,a){"use strict";var i={};a.r(i),a.d(i,{hideProductDiscovery:()=>C,hideTaskList:()=>k,hideUpsell:()=>I});var s={};a.r(s),a.d(s,{getCanDisplayUpsell:()=>z,getCanImportWooCommerceSubscribers:()=>T,getCurrentTask:()=>q,getGlobalSubscriberStatsChange:()=>L,getHasForms:()=>F,getHasImportedSubscribers:()=>R,getIsFreeMailUser:()=>D,getIsNewUserForSenderDomainAuth:()=>P,getIsProductDiscoveryDone:()=>W,getIsProductDiscoveryHidden:()=>M,getIsTaskListHidden:()=>U,getIsUpsellHidden:()=>H,getIsWooCommerceActive:()=>B,getListsSubscriberStatsChange:()=>$,getMssActive:()=>O,getProductDiscoveryTasksStatus:()=>A,getTasksStatus:()=>E});var n=a(79124),r=a(7378),o=a(14762),l=a(13722),d=a(25354),c=a(65591),m=a(83673),u=a(27901),p=a(69139),h=a(14442),g=a(86106);function _({mailpoetInstalledDaysAgo:e,sendTransactionalEmails:t,mtaMethod:a,noticeDismissed:i,apiVersion:s}){const[n,o]=(0,r.useState)(!1),l=()=>{m.U.Ajax.post({api_version:s,endpoint:"UserFlags",action:"set",data:{transactional_emails_opt_in_notice_dismissed:"1"}})};return e<30||t||"PHPMail"===a||i||n?null:(0,g.jsxs)(h.$,{type:"success",timeout:!1,onClose:l,children:[(0,g.jsx)("h3",{children:(0,p.__)("Good news! MailPoet can now send your website’s emails too","mailpoet")}),(0,g.jsxs)("p",{children:[(0,p.__)("All of your WordPress and WooCommerce emails are sent with your hosting company, unless you have an SMTP plugin. Would you like such emails to be delivered with MailPoet’s active sending method for better deliverability?","mailpoet")," ",(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/292-choose-how-to-send-your-wordpress-websites-emails",target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Read more.","mailpoet")})]}),(0,g.jsx)("p",{children:(0,g.jsx)("button",{type:"button",className:"button",onClick:()=>{o(!0),m.U.Ajax.post({api_version:s,endpoint:"settings",action:"set",data:{send_transactional_emails:"1"}}),l()},children:(0,p._x)("Enable","verb","mailpoet")})})]})}_.displayName="TransactionalEmailsProposeOptInNotice";var f=a(83571),b=a(10812);function x(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.q,{}),(0,g.jsx)(b.D,{}),(0,g.jsx)(_,{mailpoetInstalledDaysAgo:m.U.installedDaysAgo,sendTransactionalEmails:m.U.transactionalEmailsEnabled,mtaMethod:m.U.mtaMethod,apiVersion:m.U.apiVersion,noticeDismissed:m.U.transactionalEmailsOptInNoticeDismissed}),(0,g.jsx)(f.R,{mtaLog:m.U.mtaLog,mtaMethod:m.U.mtaMethod,isInline:!0})]})}var v=a(51751),y=a(90194),j=a(39173),w=a(89074),S=a(95924),N=a(84356);function*k(){return yield(0,N.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.task_list_dismissed":!0}}),{type:"SET_TASK_LIST_HIDDEN"}}function*C(){return yield(0,N.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.product_discovery_dismissed":!0}}),{type:"SET_PRODUCT_DISCOVERY_HIDDEN"}}function*I(){return yield(0,N.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.upsell_dismissed":!0}}),{type:"SET_UPSELL_HIDDEN"}}function U(e){return e.taskList.isTaskListHidden}function E(e){return e.taskList.tasksStatus}function A(e){return e.productDiscovery.tasksStatus}function T(e){return e.taskList.canImportWooCommerceSubscribers}function R(e){return e.taskList.hasImportedSubscribers}function P(e){return e.taskList.isNewUserForSenderDomainAuth}function D(e){return e.taskList.isFreeMailUser}function O(e){return e.taskList.mssActive}function F(e){return e.formsCount>0}function M(e){return e.productDiscovery.isHidden}function L(e){return e.subscribersStats.global}function $(e){return e.subscribersStats.lists}function W(e){const t=e.productDiscovery.tasksStatus;return e.isWooCommerceActive?t.addSubscriptionForm&&t.setUpWelcomeCampaign&&t.setUpAbandonedCartEmail&&t.brandWooEmails:t.setUpWelcomeCampaign&&t.addSubscriptionForm&&t.sendFirstNewsletter}function B(e){return e.isWooCommerceActive}function q(e){return e.taskList.tasksStatus.senderSet?e.taskList.tasksStatus.mssConnected?!e.taskList.tasksStatus.wooSubscribersImported&&e.taskList.canImportWooCommerceSubscribers?"wooSubscribersImported":e.taskList.tasksStatus.subscribersAdded?null:"subscribersAdded":"mssConnected":"senderSet"}function H(e){return e.upsell.isHidden}function z(e){return e.upsell.upsellStatus?.canDisplay}function V(e,t){switch(t.type){case"SET_TASK_LIST_HIDDEN":return{...e,taskList:{...e.taskList,isTaskListHidden:!0}};case"SET_PRODUCT_DISCOVERY_HIDDEN":return{...e,productDiscovery:{...e.productDiscovery,isHidden:!0}};case"SET_UPSELL_HIDDEN":return{...e,upsell:{...e.upsell,isHidden:!0}};default:return e}}const Y="mailpoet/homepage",G={};var K=a(87452),Q=a(13387),J=a(3698),Z=a.n(J);function X(e,t,a){m.U.trackEvent(e,{ctaLabel:t},{send_immediately:!0},()=>{window.location.href=a})}function ee({title:e,titleCompleted:t="",slug:a,link:i,order:s,isCompleted:n,isActive:r,children:o=null}){const l=Z()("mailpoet-task-list__task",{"mailpoet-task-list__task--completed":n,"mailpoet-task-list__task--active":r}),d=()=>{X("Home Page Task",a,i)};return(0,g.jsxs)("li",{className:l,role:"row",onClick:n?void 0:d,tabIndex:n?void 0:0,onKeyDown:n?void 0:e=>"Enter"===e.key&&d(),children:[(0,g.jsx)("div",{className:"mailpoet-task-list__task-before",children:(0,g.jsx)("div",{className:"mailpoet-task-list__task-icon",children:n?(0,g.jsx)(K.A,{icon:Q.A}):s})}),(0,g.jsxs)("div",{className:"mailpoet-task-list__task-content",children:[(0,g.jsx)("div",{className:"mailpoet-task-list__task-title",children:n&&t?t:e}),o]})]})}function te({onHide:e}){const{tasksStatus:t,currentTask:a,hasImportedSubscribers:i,canImportWooCommerceSubscribers:s,isNewUserForSenderDomainAuth:n,isFreeMailUser:r,mssActive:l}=(0,v.A)(e=>({tasksStatus:e(Y).getTasksStatus(),currentTask:e(Y).getCurrentTask(),hasImportedSubscribers:e(Y).getHasImportedSubscribers(),canImportWooCommerceSubscribers:e(Y).getCanImportWooCommerceSubscribers(),isNewUserForSenderDomainAuth:e(Y).getIsNewUserForSenderDomainAuth(),isFreeMailUser:e(Y).getIsFreeMailUser(),mssActive:e(Y).getMssActive()}),[]),d=[];if(d.push((0,g.jsx)(ee,{slug:"set sender",title:m.U.I18n.t("senderSetTask"),titleCompleted:m.U.I18n.t("senderSetTaskDone"),link:"admin.php?page=mailpoet-settings#/basics",order:1,isCompleted:t.senderSet,isActive:"senderSet"===a},"senderSet")),d.push((0,g.jsx)(ee,{slug:"connect mss",title:m.U.I18n.t("mssConnectedTask"),titleCompleted:m.U.I18n.t("mssConnectedTaskDone"),link:"admin.php?page=mailpoet-settings#/premium",order:2,isCompleted:t.mssConnected,isActive:"mssConnected"===a},"mssConnected")),s&&d.push((0,g.jsx)(ee,{slug:"import woocommerce subscribers",title:m.U.I18n.t("wooSubscribersImportedTask"),titleCompleted:m.U.I18n.t("wooSubscribersImportedTaskDone"),link:"admin.php?page=mailpoet-woocommerce-setup",order:3,isCompleted:t.wooSubscribersImported,isActive:"wooSubscribersImported"===a},"wooSubscribersImported")),d.push((0,g.jsxs)(ee,{slug:"add subscribers",title:m.U.I18n.t("subscribersAddedTask"),titleCompleted:i?m.U.I18n.t("subscribersAddedTaskDoneByImport"):m.U.I18n.t("subscribersAddedTaskDoneByForm"),link:"admin.php?page=mailpoet-import",order:s?4:3,isCompleted:t.subscribersAdded,isActive:"subscribersAdded"===a,children:[!t.subscribersAdded&&(0,g.jsxs)("p",{children:[m.U.I18n.t("noSubscribersQuestion")," ",(0,g.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:o.stopLinkPropagation,children:m.U.I18n.t("setUpForm")})]}),t.subscribersAdded&&!i&&(0,g.jsxs)("p",{children:[m.U.I18n.t("haveSubscribersQuestion")," ",(0,g.jsx)("a",{href:"admin.php?page=mailpoet-import",children:m.U.I18n.t("import")})]})]},"subscribersAdded")),n&&l){let e="admin.php?page=mailpoet-settings#/basics";r||(e="admin.php?page=mailpoet-settings#/basics/authorizedEmailModal"),d.push((0,g.jsx)(ee,{slug:"authenticate sender domain",title:m.U.I18n.t("senderDomainAuthenticatedTask"),titleCompleted:m.U.I18n.t("senderDomainAuthenticatedTaskDone"),link:e,order:s?5:4,isCompleted:t.senderDomainAuthenticated,isActive:"senderDomainAuthenticated"===a,children:!t.senderDomainAuthenticated&&(0,g.jsx)("p",{children:m.U.I18n.t("improveDeliveryRates")})},"senderDomainAuthenticated"))}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-task-list__heading",children:[(0,g.jsx)("h1",{children:m.U.I18n.t("welcomeToMailPoet")}),(0,g.jsx)("p",{children:m.U.I18n.t("beginByCompletingSetup")}),(0,g.jsx)(y.A,{label:m.U.I18n.t("hideList"),icon:j.A,controls:[{title:m.U.I18n.t("hideList"),onClick:e,icon:null}]})]}),(0,g.jsx)("ul",{children:d.map(e=>e)}),!a&&(0,g.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[m.U.I18n.t("youAreSet")," ",(0,g.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:m.U.I18n.t("dismissList")})]})]})}function ae({title:e,slug:t,link:a,description:i,doneMessage:s,imgSrc:n,isDone:r}){const o=()=>{X("Home Page Task",t,a)};return(0,g.jsxs)("li",{className:Z()("mailpoet-product-discovery__task",{"mailpoet-product-discovery__task--completed":r}),role:"row",onClick:r?void 0:o,tabIndex:r?void 0:0,onKeyDown:r?void 0:e=>"Enter"===e.key&&o(),children:[(0,g.jsx)("img",{src:n,alt:e,width:124,height:72}),(0,g.jsx)("div",{className:"mailpoet-product-discovery__task-content",children:r?(0,g.jsx)("h3",{children:s}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h3",{children:`${e} →`}),i&&(0,g.jsx)("p",{children:i})]})}),(0,g.jsx)("div",{className:"mailpoet-product-discovery__task-after",children:r&&(0,g.jsx)("div",{className:"mailpoet-task-list__task-icon",children:(0,g.jsx)(K.A,{icon:Q.A})})})]})}function ie({heading:e,description:t,children:a,headingAfter:i,className:s=""}){return(0,g.jsxs)("section",{className:Z()("mailpoet-homepage-section__container",s),children:[(0,g.jsxs)("header",{className:"mailpoet-homepage-section__heading",children:[(0,g.jsxs)("h2",{children:[e,t&&(0,g.jsx)("span",{children:t})]}),(0,g.jsx)("div",{className:"mailpoet-homepage-section__heading-after",children:i})]}),a]})}function se({onHide:e}){const{tasksStatus:t,isWooCommerceActive:a,isDiscoveryDone:i}=(0,v.A)(e=>({tasksStatus:e(Y).getProductDiscoveryTasksStatus(),isWooCommerceActive:e(Y).getIsWooCommerceActive(),isDiscoveryDone:e(Y).getIsProductDiscoveryDone()}),[]),s=[];return s.push((0,g.jsx)(ae,{slug:"set up welcome campaign",title:m.U.I18n.t("setUpWelcomeCampaign"),description:m.U.I18n.t("setUpWelcomeCampaignDesc"),link:"admin.php?page=mailpoet-automation-templates&initialTab=welcome",imgSrc:`${m.U.cdnUrl}homepage/welcome-email-illustration.png`,isDone:t.setUpWelcomeCampaign,doneMessage:m.U.I18n.t("setUpWelcomeCampaignDone")},"setUpWelcomeCampaign"),(0,g.jsx)(ae,{slug:"add subscription form",title:m.U.I18n.t("addSubscriptionForm"),description:m.U.I18n.t("addSubscriptionFormDesc"),link:"admin.php?page=mailpoet-form-editor-template-selection",imgSrc:`${m.U.cdnUrl}homepage/subscription-form-illustration.png`,isDone:t.addSubscriptionForm,doneMessage:m.U.I18n.t("addSubscriptionFormDone")},"addSubscriptionForm")),a?s.push((0,g.jsx)(ae,{slug:"set up abandoned cart email",title:m.U.I18n.t("setUpAbandonedCartEmail"),description:m.U.I18n.t("setUpAbandonedCartEmailDesc"),link:"admin.php?page=mailpoet-automation-templates&initialTab=abandoned-cart",imgSrc:`${m.U.cdnUrl}homepage/woo-cart-email-illustration.png`,isDone:t.setUpAbandonedCartEmail,doneMessage:m.U.I18n.t("setUpAbandonedCartEmailDone")},"setUpAbandonedCartEmail"),(0,g.jsx)(ae,{slug:"brand woocommerce emails",title:m.U.I18n.t("brandWooEmails"),description:m.U.I18n.t("brandWooEmailsDesc"),link:"admin.php?page=mailpoet-settings#/woocommerce",imgSrc:`${m.U.cdnUrl}homepage/woo-transactional-email-illustration.20241219.png`,isDone:t.brandWooEmails,doneMessage:m.U.I18n.t("brandWooEmailsDone")},"brandWooEmails")):s.push((0,g.jsx)(ae,{slug:"send first newsletter",title:m.U.I18n.t("sendFirstNewsletter"),description:m.U.I18n.t("sendFirstNewsletterDesc"),link:"admin.php?page=mailpoet-newsletters#/new",imgSrc:`${m.U.cdnUrl}homepage/newsletter-illustration.png`,isDone:t.sendFirstNewsletter,doneMessage:m.U.I18n.t("sendFirstNewsletterDone")},"sendFirstNewsletter")),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ie,{className:"mailpoet-homepage-product-discovery",heading:m.U.I18n.t("startEngagingWithYourCustomers"),headingAfter:(0,g.jsx)(y.A,{label:m.U.I18n.t("hideList"),icon:j.A,controls:[{title:m.U.I18n.t("hideList"),onClick:e,icon:null}]}),children:(0,g.jsx)("ul",{children:s.map(e=>e)})}),i&&(0,g.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[m.U.I18n.t("allDone")," ",(0,g.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:m.U.I18n.t("dismissTasks")})]})]})}var ne=a(35061),re=a(58768),oe=a(59068),le=a(19453),de=a(8254),ce=a(69611);function me({closable:e,onHide:t}){return(0,g.jsx)(ie,{className:"mailpoet-homepage-upsell",heading:m.U.I18n.t("accelerateYourGrowth"),headingAfter:e&&t?(0,g.jsx)(ce.Ay,{icon:ne.A,onClick:t,label:m.U.I18n.t("close")}):null,children:(0,g.jsxs)("div",{className:"mailpoet-homepage-upsell__content",children:[(0,g.jsxs)("ul",{children:[(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:re.A}),(0,g.jsx)("span",{children:m.U.I18n.t("detailedAnalytics")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:oe.A}),(0,g.jsx)("span",{children:m.U.I18n.t("advancedSubscriberSegmentation")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:le.A}),(0,g.jsx)("span",{children:m.U.I18n.t("emailMarketingAutomations")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:de.A}),(0,g.jsx)("span",{children:m.U.I18n.t("prioritySupport")})]})]}),(0,g.jsx)(ce.Ay,{variant:"primary",href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,"business",{utm_source:"plugin",utm_medium:"homepage",utm_campaign:"upsell"}),children:m.U.I18n.t("upgradePlan")})]})})}var ue=a(59717),pe=a(19299);function he(e){return null==e?"unknown":e<20?"average":e<50?"good":"excellent"}function ge({id:e,engagementScore:t}){const a={unknown:{name:m.U.I18n.t("unknownBadgeName"),type:"unknown",tooltipTitle:m.U.I18n.t("unknownBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipUnknown")},excellent:{name:m.U.I18n.t("excellentBadgeName"),type:"excellent",tooltipTitle:m.U.I18n.t("excellentBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipExcellent")},good:{name:m.U.I18n.t("goodBadgeName"),type:"good",tooltipTitle:m.U.I18n.t("goodBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipGood")},average:{name:m.U.I18n.t("averageBadgeName"),type:"average",tooltipTitle:m.U.I18n.t("averageBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipAverage")}},i=`badge-${e}`,s=a[he(t)],n=(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-listing-stats-tooltip-title",children:s.tooltipTitle.toUpperCase()}),(0,g.jsx)("div",{className:"mailpoet-listing-stats-tooltip-description",children:m.U.I18n.t("engagementScoreDescription")}),(0,g.jsxs)("div",{className:"mailpoet-listing-stats-tooltip-content",children:[(0,g.jsx)(pe.E,{type:"unknown",name:m.U.I18n.t("unknownBadgeName")})," : ",a.unknown.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(pe.E,{type:"excellent",name:m.U.I18n.t("excellentBadgeName")})," : ",a.excellent.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(pe.E,{type:"good",name:m.U.I18n.t("goodBadgeName")})," : ",a.good.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(pe.E,{type:"average",name:m.U.I18n.t("averageBadgeName")})," : ",a.average.tooltipText]})]},`tooltip-${i}`);return(0,g.jsxs)("div",{className:"mailpoet-listing-stats-opened-clicked",children:[null!=t&&(0,g.jsxs)("div",{className:"mailpoet-listing-stats-percentages",children:[t.toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}),"%"]}),(0,g.jsx)("div",{children:(0,g.jsx)(pe.E,{isInverted:!0,type:s.type,name:s.name,tooltip:n,tooltipId:i,tooltipPlace:"top"})})]})}const _e=(e,t,a)=>{e.preventDefault(),X("Home Page Statistics Click",t,a)};function fe(){const{globalChange:e,listsChange:t,hasForms:a}=(0,v.A)(e=>({globalChange:e(Y).getGlobalSubscriberStatsChange(),listsChange:e(Y).getListsSubscriberStatsChange(),hasForms:e(Y).getHasForms()}),[]),i=0===t.length&&0===e.subscribed&&0===e.unsubscribed;return(0,g.jsx)(ie,{className:"mailpoet-subscribers-stats",heading:m.U.I18n.t("subscribersHeading"),description:m.U.I18n.t("subscribersSectionDescription"),headingAfter:!i&&(0,g.jsxs)("span",{className:Z()({"mailpoet-decrease":e.changePercent<0}),children:[(0,g.jsx)(K.A,{icon:re.A}),e.changePercent<0&&"-",Math.abs(e.changePercent)>1e3?"∞%":`${Math.abs(e.changePercent)}%`]}),children:i?(0,g.jsxs)("div",{className:"mailpoet-subscribers-stats-empty",children:[(0,g.jsx)(K.A,{icon:re.A,viewBox:"-4 -4 32 32"}),a?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:m.U.I18n.t("subscriberCountHasNotChangeLongTime")}),(0,g.jsx)("a",{href:"admin.php?page=mailpoet-newsletters#/new",onClick:e=>_e(e,"campaigns","admin.php?page=mailpoet-newsletters#/new"),children:m.U.I18n.t("exploreCampaigns")})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("p",{children:[m.U.I18n.t("changesWillAppear"),(0,g.jsx)("br",{}),m.U.I18n.t("starBySettingUpForm")]}),(0,g.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:e=>_e(e,"new form","admin.php?page=mailpoet-form-editor-template-selection"),children:m.U.I18n.t("createForm")})]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-subscribers-stats-global-change",children:[(0,g.jsxs)("div",{children:[m.U.I18n.t("newSubscribers"),(0,g.jsx)("br",{}),(0,g.jsx)("span",{children:e.subscribed})]}),(0,g.jsxs)("div",{children:[m.U.I18n.t("unsubscribedSubscribers"),(0,g.jsx)("br",{}),(0,g.jsx)("span",{children:e.unsubscribed})]})]}),!!t.length&&(0,g.jsxs)("table",{className:"mailpoet-subscribers-stats-list-change-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:m.U.I18n.t("listName")}),(0,g.jsx)("th",{children:m.U.I18n.t("listScore")}),(0,g.jsx)("th",{children:m.U.I18n.t("subscribedSubscribers")}),(0,g.jsx)("th",{children:m.U.I18n.t("unsubscribedSubscribers")})]})}),(0,g.jsx)("tbody",{children:t.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:(0,g.jsx)("a",{href:`admin.php?page=mailpoet-subscribers#/page[1]/sort_by[created_at]/sort_order[desc]/group[all]/filter[segment=${e.id}]`,children:e.name})}),(0,g.jsx)("td",{children:(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)(ge,{id:e.id,engagementScore:e.averageEngagementScore})})}),(0,g.jsx)("td",{children:e.subscribed}),(0,g.jsx)("td",{children:e.unsubscribed})]},e.id))})]})]})})}var be=a(56828),xe=a(24671);function ve({link:e,abstract:t,title:a,imgSrc:i}){return(0,g.jsxs)("a",{className:"mailpoet-resource-post",href:e,target:"_blank",rel:"noreferrer",children:[(0,g.jsx)("img",{src:i,alt:a,width:"292",height:"166"}),(0,g.jsx)("h3",{children:a}),(0,g.jsx)("p",{children:t})]})}function ye(){const[e,t]=(0,r.useState)(1),a=[(0,g.jsx)(ve,{link:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns",abstract:m.U.I18n.t("createAnEmailAbstract"),title:m.U.I18n.t("createAnEmailTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/add_email.20241219.png`},"createAnEmail"),(0,g.jsx)(ve,{link:"https://kb.mailpoet.com/article/297-create-a-subscription-form-with-our-editor",abstract:m.U.I18n.t("createAFormAbstract"),title:m.U.I18n.t("createAFormTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/add_form.png`},"createAForm"),(0,g.jsx)(ve,{link:"https://www.mailpoet.com/blog/email-segmentation/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("segmentationGuideAbstract"),title:m.U.I18n.t("segmentationGuideTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/segmentation.png`},"segmentationGuide"),(0,g.jsx)(ve,{link:"https://www.mailpoet.com/blog/re-engagement-emails/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("reEngagementAbstract"),title:m.U.I18n.t("reEngagementTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/reengagement.png`},"reEngagement"),(0,g.jsx)(ve,{link:"https://www.mailpoet.com/blog/newsletter-marketing-strategy/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("marketingStrategyAbstract"),title:m.U.I18n.t("marketingStrategyTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/marketing.png`},"marketingStrategy"),(0,g.jsx)(ve,{link:"https://www.mailpoet.com/blog/how-to-promote-your-sales-with-email-marketing-mailpoet-woocommerce-segmentation/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("promotingSalesAbstract"),title:m.U.I18n.t("promotingSalesTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/sales.png`},"promotingSales")],i=(0,r.useCallback)(a=>{a.preventDefault(),t(e+1)},[e]),s=(0,r.useCallback)(a=>{a.preventDefault(),t(e-1)},[e]);return(0,g.jsxs)(ie,{className:"mailpoet-homepage-resources",heading:m.U.I18n.t("learnMoreAboutEmailMarketing"),children:[(0,g.jsx)("div",{className:"mailpoet-homepage-resources__posts",children:a.filter((t,a)=>a+1===2*e||a+1===2*e-1).map(e=>e)}),(0,g.jsxs)("div",{className:"mailpoet-homepage-resources__pagination",children:[m.U.I18n.t("pageOf").replace("%1$d",e.toString()).replace("%2$d",Math.ceil(a.length/2).toString()),e>1?(0,g.jsx)("a",{href:"#",onClick:s,title:m.U.I18n.t("previousPostsPage"),children:(0,g.jsx)(K.A,{icon:be.A})}):(0,g.jsx)(K.A,{icon:be.A}),e({isTaskListHidden:e(Y).getIsTaskListHidden(),isProductDiscoveryHidden:e(Y).getIsProductDiscoveryHidden(),isUpsellHidden:e(Y).getIsUpsellHidden(),canDisplayUpsell:e(Y).getCanDisplayUpsell()}),[]),{hideTaskList:s}=(0,ue.A)(Y),{hideProductDiscovery:n}=(0,ue.A)(Y),{hideUpsell:r}=(0,ue.A)(Y);return(0,g.jsxs)("div",{className:"mailpoet-homepage__container",children:[!e&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(te,{onHide:s})}),!t&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(se,{onHide:n})}),e&&t&&i&&!a&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(me,{closable:!0,onHide:r})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(fe,{})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ye,{})})]})}function we(){const[e,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{(()=>{const e=(0,w.A)(Y,{actions:i,controls:G,selectors:s,reducer:V,initialState:{taskList:{isTaskListHidden:window.mailpoet_homepage_data.taskListDismissed,tasksStatus:window.mailpoet_homepage_data.taskListStatus,canImportWooCommerceSubscribers:window.mailpoet_homepage_data.wooCustomersCount>0,hasImportedSubscribers:window.mailpoet_homepage_data.subscribersCount>10,isNewUserForSenderDomainAuth:window.mailpoet_homepage_data.isNewUserForSenderDomainAuth,mssActive:window.mailpoet_mss_active,isFreeMailUser:window.mailpoet_homepage_data.isFreeMailUser},productDiscovery:{isHidden:window.mailpoet_homepage_data.productDiscoveryDismissed,tasksStatus:window.mailpoet_homepage_data.productDiscoveryStatus},upsell:{isHidden:window.mailpoet_homepage_data.upsellDismissed,upsellStatus:window.mailpoet_homepage_data.upsellStatus},isWooCommerceActive:m.U.isWoocommerceActive,subscribersStats:window.mailpoet_homepage_data.subscribersStats,formsCount:window.mailpoet_homepage_data.formsCount}});(0,S.register)(e)})(),t(!0)},[]),(0,g.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,g.jsx)(d.x,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(x,{}),e?(0,g.jsx)(je,{}):null]})}const Se=document.getElementById("mailpoet_homepage_container");Se&&((0,o.registerTranslations)(),(0,n.H)(Se).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(we,{})})));var Ne=a(36125),ke=a(99091),Ce=a(41669),Ie=a.n(Ce),Ue=a(77779),Ee=a(54312),Ae=a(93691),Te=a(15172),Re=a(18867),Pe=a(51359),De=a(16037),Oe=a(4686),Fe=a(97997);function Me({subscribersInPlan:e,subscribersInPlanLimit:t}){return!1===e?null:(0,g.jsxs)("span",{className:"mailpoet-segment-subscriber-count-message",children:[(0,g.jsx)("b",{children:t?(0,p.sprintf)((0,p._n)("%1$s / %2$s subscriber","%1$s / %2$s subscribers",e,"mailpoet"),e.toLocaleString(),t.toLocaleString()):(0,p.sprintf)((0,p._n)("%s subscriber","%s subscribers",e,"mailpoet"),e.toLocaleString())}),(0,g.jsx)(Fe.Tooltip,{tooltip:(0,p.__)("This is the total of subscribed, unconfirmed and inactive subscribers we count when you are sending with MailPoet Sending Service. The count excludes unsubscribed and bounced (invalid) email addresses.","mailpoet"),place:"right"})]})}var Le=a(97041);function $e({cacheCalculation:e}){const[t,a]=(0,r.useState)(!1),[i,s]=(0,r.useState)([]),n=(new Date).getTime()-new Date(e).getTime(),o=Math.floor(n/1e3/60);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"mailpoet-segment-subscriber-cache",children:(0,p.sprintf)((0,p._n)("Calculated %s min ago","Calculated %s mins ago",o,"mailpoet"),o.toLocaleString())}),(0,g.jsx)(Le.$,{variant:"tertiary",onClick:()=>{a(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"settings",action:"recalculateSubscribersCountsCache"}).done(()=>{window.location.reload()}).fail(e=>{a(!1),e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e,{static:!0,scroll:!0}):s(e.errors.map(e=>e.message)))})},withSpinner:t,children:(0,p.__)("Recalculate","mailpoet")}),i.length>0&&(0,g.jsx)(h.$,{type:"error",children:i.map(e=>(0,g.jsx)("p",{children:e},e))})]})}function We(){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:"\n #screen-meta-links { margin-bottom: -22px; }\n "}})}function Be(){const e=(0,ke.zy)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(We,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(Oe.z,{className:"mailpoet-subscribers-page-header",heading:(0,p.__)("Subscribers","mailpoet"),children:(0,g.jsxs)("span",{className:"mailpoet-subscribers-heading-actions",children:[(0,g.jsxs)("span",{className:"mailpoet-subscribers-heading-primary-actions",children:[(0,g.jsx)(Ne.Link,{className:"page-title-action",to:{pathname:"/new",state:{backUrl:e?.pathname}},children:(0,g.jsx)("span",{"data-automation-id":"add-new-subscribers-button",children:(0,p.__)("Add new subscriber","mailpoet")})}),(0,g.jsx)("a",{className:"page-title-action",href:"?page=mailpoet-import","data-automation-id":"import-subscribers-button",children:(0,p.__)("Import","mailpoet")}),(0,g.jsx)("a",{id:"mailpoet_export_button",className:"page-title-action",href:"?page=mailpoet-export",children:(0,p.__)("Export","mailpoet")})]}),(0,g.jsxs)("span",{className:"mailpoet-subscribers-heading-management-actions",children:[(0,g.jsx)("a",{className:"page-title-action",href:"?page=mailpoet-tags","data-automation-id":"manage-tags-button",children:(0,p.__)("Tags","mailpoet")}),(0,g.jsx)("a",{className:"page-title-action",href:"?page=mailpoet-custom-fields","data-automation-id":"manage-custom-fields-button",children:(0,p.__)("Custom fields","mailpoet")})]})]})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(Me,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)($e,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]})]})}const qe=m.U.trackingConfig.emailTrackingEnabled,He=window.mailpoet_bulk_confirmation_resend_limit,ze="bulk-resend-confirmation-checkbox-input",Ve=()=>({onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 subscriber was moved to the trash.","mailpoet"):(0,p.__)("%1$d subscribers were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 subscriber was permanently deleted.","mailpoet"):(0,p.__)("%1$d subscribers were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 subscriber has been restored from the trash.","mailpoet"):(0,p.__)("%1$d subscribers have been restored from the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onNoItemsFound:(e,t)=>{if("bounced"===e&&!window.mailpoet_premium_active&&!window.mailpoet_mss_active)return(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,p.__)("Email addresses that are invalid or don't exist anymore are called \"bounced addresses\". It's a good practice not to send emails to bounced addresses to keep a good reputation with spam filters. Send your emails with MailPoet and we'll automatically ensure to keep a list of bounced addresses without any setup.","mailpoet")}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",className:"button-primary",children:(0,p.__)("Get premium version!","mailpoet")})})]});if("trash"!==e&&t){const e=encodeURIComponent(t);return(0,g.jsxs)("p",{children:[(0,p.__)("No items found.","mailpoet")," ",(0,g.jsx)("a",{href:`#/group[trash]/search[${e}]`,className:"button button-link",children:(0,p.__)("Have you checked the Trash?","mailpoet")})]})}return!1}}),Ye=(e,t,a,i)=>(0,g.jsxs)(Pe.a,{title:i,onRequestClose:t,isDismissible:!0,children:[(0,g.jsx)(De.L,{field:a}),(0,g.jsx)("span",{className:"mailpoet-gap-half"}),(0,g.jsx)(o.Button,{onClick:e,dimension:"small",variant:"secondary",children:(0,p.__)("Apply","mailpoet")})]});function Ge({submitModal:e,closeModal:t,count:a}){const[i,s]=(0,r.useState)(!1),[n,o]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{document.getElementById(ze)?.focus()},[]),(0,g.jsx)(Ue.A,{title:(0,p.__)("Resend confirmation emails","mailpoet"),onRequestClose:t,children:(0,g.jsxs)(Ee.A,{spacing:3,children:[(0,g.jsx)(Ae.A,{as:"p",children:(0,p.sprintf)((0,p.__)("You selected %1$s subscribers. MailPoet can resend confirmation emails to up to %2$s of them at a time.","mailpoet"),Number(a).toLocaleString(),He.toLocaleString())}),(0,g.jsx)(Ae.A,{as:"p",children:(0,p.__)("Some subscribers may be skipped if they already received too many confirmation emails, got one recently, or were added too long ago.","mailpoet")}),(0,g.jsx)("div",{"data-automation-id":"bulk-resend-confirmation-checkbox",children:(0,g.jsx)(Te.A,{id:ze,label:(0,p.__)("I confirm these subscribers asked to join my list.","mailpoet"),checked:i,disabled:n,onChange:e=>s(e)})}),(0,g.jsx)("div",{children:(0,g.jsx)(ce.Ay,{variant:"primary",onClick:()=>{i&&!n&&(o(!0),e())},disabled:!i||n,isBusy:n,"data-automation-id":"bulk-resend-confirmation-confirm",children:(0,p.__)("Resend emails","mailpoet")})})]})})}const Ke=e=>{const t=e.data;if(!t)return void m.U.Notice.success((0,p.__)("Confirmation emails are being resent.","mailpoet"));const a=Number(t.queued_count),i=Number(t.skipped_count);if(0===a)return void m.U.Notice.success((0,p.__)("No confirmation emails were resent. The selected subscribers could not receive another confirmation email right now.","mailpoet"));const s=[String((0,p.sprintf)((0,p._n)("MailPoet is resending confirmation emails to %d subscriber.","MailPoet is resending confirmation emails to %d subscribers.",a,"mailpoet"),a))];i>0&&s.push(String((0,p.sprintf)((0,p._n)("%d selected subscriber was skipped.","%d selected subscribers were skipped.",i,"mailpoet"),i))),m.U.Notice.success(s.join(" "),{onOpen:e=>{e.attr("role","status"),e.attr("aria-live","polite")}})},Qe=()=>{const e=[{name:"moveToList",label:(0,p.__)("Move to list...","mailpoet"),onSelect:function(e,t){return Ye(e,t,{id:"move_to_segment",name:"move_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},(0,p.__)("Move to list...","mailpoet"))},getData:function(){return{segment_id:Number(Ie()("#move_to_segment").val())}},onSuccess:function(e){m.U.Notice.success((0,p.__)("%1$d subscribers were moved to list %2$s.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"addToList",label:(0,p.__)("Add to list...","mailpoet"),onSelect:function(e,t){return Ye(e,t,{id:"add_to_segment",name:"add_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},(0,p.__)("Add to list...","mailpoet"))},getData:function(){return{segment_id:Number(Ie()("#add_to_segment").val())}},onSuccess:function(e){m.U.Notice.success((0,p.__)("%1$d subscribers were added to list %2$s.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromList",label:(0,p.__)("Remove from list...","mailpoet"),onSelect:function(e,t){return Ye(e,t,{id:"remove_from_segment",name:"remove_from_segment",endpoint:"segments",filter:function(e){return"default"===e.type}},(0,p.__)("Remove from list...","mailpoet"))},getData:function(){return{segment_id:Number(Ie()("#remove_from_segment").val())}},onSuccess:function(e){m.U.Notice.success((0,p.__)("%1$d subscribers were removed from list %2$s.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromAllLists",label:(0,p.__)("Remove from all lists","mailpoet"),onSuccess:function(e){m.U.Notice.success((0,p.__)("%1$d subscribers were removed from all lists.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()))}},{name:"trash",label:(0,p.__)("Move to trash","mailpoet"),onSuccess:Ve().onTrash},{name:"unsubscribe",label:(0,p.__)("Unsubscribe","mailpoet"),display:({group:e})=>"unsubscribed"!==e,onSelect:(e,t,a)=>{const i="all"!==a.selection?a.selected_ids.length:a.count;return(0,g.jsxs)(Pe.a,{title:(0,p.__)("Unsubscribe","mailpoet"),onRequestClose:t,isDismissible:!0,children:[(0,g.jsx)("p",{children:(0,p.__)("This action will unsubscribe %s subscribers from all lists. This action cannot be undone. Are you sure, you want to continue?","mailpoet").replace("%s",Number(i).toLocaleString())}),(0,g.jsx)("span",{className:"mailpoet-gap-half"}),(0,g.jsx)(o.Button,{onClick:e,dimension:"small",variant:"secondary",automationId:"bulk-unsubscribe-confirm",children:(0,p.__)("Apply","mailpoet")})]})}},{name:"resendConfirmationEmails",label:(0,p.__)("Resend confirmation emails","mailpoet"),display:({group:e})=>"unconfirmed"===e&&window.mailpoet_signup_confirmation_enabled,onSelect:(e,t,a)=>{const i="all"!==a.selection?a.selected_ids.length:a.count;return(0,g.jsx)(Ge,{submitModal:e,closeModal:t,count:i})},onSuccess:Ke},{name:"addTag",label:(0,p.__)("Add tag...","mailpoet"),onSelect:function(e,t){return Ye(e,t,{id:"add_tag",name:"add_tag",endpoint:"tags"},(0,p.__)("Add tag...","mailpoet"))},getData:function(){return{tag_id:Number(Ie()("#add_tag").val())}},onSuccess:function(e){m.U.Notice.success((0,p.__)("Tag %1$s was added to %2$d subscribers.","mailpoet").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}},{name:"removeTag",label:(0,p.__)("Remove tag...","mailpoet"),onSelect:function(e,t){return Ye(e,t,{id:"remove_tag",name:"remove_tag",endpoint:"tags"},(0,p.__)("Remove tag...","mailpoet"))},getData:function(){return{tag_id:Number(Ie()("#remove_tag").val())}},onSuccess:function(e){m.U.Notice.success((0,p.__)("Tag %1$s was removed from %2$d subscribers.","mailpoet").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}}];return e},Je=e=>0===Number(e.wp_user_id)&&0===Number(e.is_woocommerce_user);function Ze(){const e=(0,ke.zy)(),t=(0,ke.g)();return(0,g.jsxs)("div",{children:[(0,g.jsx)(Be,{}),(0,g.jsx)(b.D,{}),(0,g.jsx)(Re.l,{limit:window.mailpoet_listing_per_page,location:e,params:t,endpoint:"subscribers",onRenderItem:(t,a)=>{const i=Z()("manage-column","column-primary","has-row-actions","column-username");let s="";switch(t.status){case"subscribed":s=(0,p.__)("Subscribed","mailpoet");break;case"unconfirmed":s=(0,p.__)("Unconfirmed","mailpoet");break;case"unsubscribed":s=(0,p.__)("Unsubscribed","mailpoet");break;case"inactive":s=(0,p.__)("Inactive","mailpoet");break;case"bounced":s=(0,p.__)("Bounced","mailpoet");break;default:s="Invalid"}const n=[];return t.subscriptions.length>0&&t.subscriptions.forEach(e=>{const t=(e=>{let t=null;return window.mailpoet_segments.forEach(a=>{a.id===e&&(t=a)}),t})(e.segment_id);null!==t&&"subscribed"===e.status&&n.push(t)}),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{className:i,children:[(0,g.jsx)(Ne.Link,{className:"mailpoet-listing-title",to:`/edit/${t.id}`,state:{backUrl:e?.pathname},children:t.email}),(0,g.jsxs)("div",{className:"mailpoet-listing-subtitle",children:[t.first_name," ",t.last_name]}),a]}),(0,g.jsx)("td",{className:"column","data-colname":(0,p.__)("Status","mailpoet"),children:s}),(0,g.jsx)("td",{className:"column","data-colname":(0,p.__)("Lists","mailpoet"),children:(0,g.jsx)(o.SegmentTags,{segments:n,dimension:"large"})}),(0,g.jsx)("td",{className:"column","data-colname":(0,p.__)("Tags","mailpoet"),children:(0,g.jsx)(o.SubscriberTags,{subscribers:t.tags,variant:"wordpress",isInverted:!0})}),!0===qe?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,p.__)("Score","mailpoet"),children:(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)("a",{href:`#/stats/${t.id}`,children:(0,g.jsx)(ge,{id:t.id,engagementScore:t.engagement_score})},`stats-link-${t.id}`)})}):null,(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,p.__)("Confirmed on","mailpoet"),children:t.last_subscribed_at?m.U.Date.full(t.last_subscribed_at):null}),(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,p.__)("Subscribed on","mailpoet"),children:t.created_at?m.U.Date.full(t.created_at):null})]})},columns:[{name:"email",label:(0,p.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,p.__)("Status","mailpoet"),sortable:!0},{name:"segments",label:(0,p.__)("Lists","mailpoet")},{name:"tags",label:(0,p.__)("Tags","mailpoet")},{name:"statistics",label:(0,p.__)("Score","mailpoet"),display:qe},{name:"last_subscribed_at",label:(0,p.__)("Subscribed on","mailpoet"),sortable:!0},{name:"created_at",label:(0,p.__)("Created on","mailpoet"),sortable:!0}],bulk_actions:Qe(),item_actions:[{name:"statistics",label:(0,p.__)("Statistics","mailpoet"),link:function(e,t){return(0,g.jsx)(Ne.Link,{to:`/stats/${e.id}`,state:{backUrl:t?.pathname},children:(0,p.__)("Statistics","mailpoet")})}},{name:"edit",label:(0,p.__)("Edit","mailpoet"),link:function(e,t){return(0,g.jsx)(Ne.Link,{to:`/edit/${e.id}`,state:{backUrl:t?.pathname},children:(0,p.__)("Edit","mailpoet")})}},{name:"sendConfirmationEmail",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Resend confirmation email","mailpoet"),display:function(e){return"unconfirmed"===e.status},onClick:function(e){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"subscribers",action:"sendConfirmationEmail",data:{id:e.id}}).done(()=>m.U.Notice.success((0,p.__)("1 confirmation email has been sent.","mailpoet"))).fail(e=>m.U.Notice.showApiErrorNotice(e))}},{name:"trash",className:"mailpoet-hide-on-mobile"}],messages:Ve(),sort_by:"created_at",sort_order:"desc",isItemDeletable:Je})]})}Ze.displayName="SubscriberList";var Xe=a(36637),et=a.n(Xe),tt=a(2726),at=a.n(tt),it=a(70390),st=a.n(it),nt=a(23108),rt=a.n(nt),ot=a(68354);class lt extends r.Component{render(){const{onValueChange:e=()=>{},onBlurEvent:t=()=>{}}=this.props,a=this.props.field.name||null,i=this.props.item||{};let s,n;e instanceof Function&&(s=i[this.props.field.name],s=void 0===s?this.props.field.defaultValue||"":s),!s&&this.props.field.defaultValue&&(n=this.props.field.defaultValue);let r=this.props.field.id||null;!r&&this.props.field.name&&(r=`field_${this.props.field.name}`);let o,l=this.props.field.className||null;return l||this.props.field.size||(l="regular-text"),o="function"==typeof this.props.field.disabled?this.props.field.disabled(this.props.item):"boolean"==typeof this.props.field.disabled&&this.props.field.disabled,(0,g.jsx)(ot.p,{type:"text",disabled:o,className:l,size:"auto"!==this.props.field.size&&this.props.field.size>0?this.props.field.size:null,name:a,id:r,value:s,defaultValue:n,placeholder:this.props.field.placeholder,onChange:e,onBlur:t,customLabel:this.props.field.customLabel,tooltip:this.props.field.tooltip,...this.props.field.validation})}}lt.propTypes={onValueChange:rt().func,onBlurEvent:rt().func,field:rt().shape({name:rt().string.isRequired,defaultValue:rt().string,id:rt().string,className:rt().string,size:rt().oneOfType([rt().string,rt().number]),disabled:rt().oneOfType([rt().bool,rt().func]),placeholder:rt().string,validation:rt().shape({"data-parsley-required":rt().bool,"data-parsley-required-message":rt().string,"data-parsley-type":rt().string,"data-parsley-errors-container":rt().string,maxLength:rt().number}),customLabel:rt().string,tooltip:rt().string}).isRequired,item:rt().object.isRequired};var dt=a(99808);function ct(e){return(0,g.jsx)(dt.T,{type:"text",name:e.field.name,id:`field_${e.field.name}`,value:e.item[e.field.name],placeholder:e.field.placeholder,defaultValue:e.field.defaultValue,onChange:e.onValueChange,className:e.field.className,customLabel:e.field.customLabel,tooltip:e.field.tooltip,...e.field.validation})}ct.propTypes={item:rt().object.isRequired,field:rt().shape({name:rt().string,placeholder:rt().string,defaultValue:rt().string,validation:rt().shape({"data-parsley-required":rt().bool,"data-parsley-required-message":rt().string,"data-parsley-type":rt().string,"data-parsley-errors-container":rt().string,maxLength:rt().number}),className:rt().string,customLabel:rt().string,tooltip:rt().string}).isRequired,onValueChange:rt().func.isRequired};var mt=a(95338),ut=a(41636);class pt extends r.Component{render(){if(void 0===this.props.field.values)return!1;const{automationId:e="",onValueChange:t=()=>{}}=this.props;let a,i=!1,s=!1,n=!1;void 0!==this.props.field.placeholder&&(s=(0,g.jsx)("option",{value:"",children:this.props.field.placeholder})),void 0!==this.props.field.filter&&(i=this.props.field.filter),mt.default.isFunction(this.props.field.sortBy)&&(n=this.props.field.sortBy),a=n?mt.default.map(mt.default.sortBy(mt.default.pairs(this.props.field.values),e=>n(e[0],e[1])),e=>e[0]):Object.keys(this.props.field.values);const r=a.filter(e=>!1===i||i(this.props.item,e)).map(e=>(0,g.jsx)("option",{value:e,children:this.props.field.values[e]},`option-${e}`));return(0,g.jsxs)(ut.Select,{name:this.props.field.name,id:`field_${this.props.field.name}`,value:this.props.item[this.props.field.name]||"",onChange:t,automationId:e,...this.props.field.validation,children:[s,r]})}}pt.propTypes={onValueChange:rt().func,field:rt().shape({name:rt().string.isRequired,values:rt().objectOf(rt().string),placeholder:rt().string,filter:rt().func,sortBy:rt().func,validation:rt().shape({"data-parsley-required":rt().bool,"data-parsley-required-message":rt().string,"data-parsley-type":rt().string,"data-parsley-errors-container":rt().string,maxLength:rt().number})}).isRequired,item:rt().object.isRequired,automationId:rt().string};var ht=a(63146);class gt extends r.Component{constructor(e){super(e),this.onValueChange=this.onValueChange.bind(this)}onValueChange=(e,t)=>{const{onValueChange:a=()=>{}}=this.props;a(t)};render(){if(void 0===this.props.field.values)return!1;const e=this.props.item[this.props.field.name],t=Object.keys(this.props.field.values).map(t=>(0,g.jsx)("p",{children:(0,g.jsx)(ht.s,{checked:e===t,value:t,onCheck:this.onValueChange,name:this.props.field.name,children:this.props.field.values[t]})},`radio-${t}`));return(0,g.jsx)("div",{children:t})}}gt.propTypes={onValueChange:rt().func,field:rt().shape({name:rt().string.isRequired,values:rt().objectOf(rt().string)}).isRequired,item:rt().object.isRequired};var _t=a(32882);class ft extends r.Component{constructor(e){super(e),this.onValueChange=this.onValueChange.bind(this)}onValueChange=(e,t)=>(t.target.value=e?"1":"0",this.props.onValueChange(t));render(){if(void 0===this.props.field.values)return!1;const e=!!Number(this.props.item[this.props.field.name]),t=Object.keys(this.props.field.values).map(t=>(0,g.jsx)("p",{children:(0,g.jsx)(_t.S,{value:"1",checked:e,name:this.props.field.name,onCheck:this.onValueChange,children:this.props.field.values[t]})},`checkbox-${t}`));return(0,g.jsx)("div",{children:t})}}function bt(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));const a=et()().year();for(let e=a;e>=a-100;e-=1)t.push((0,g.jsx)("option",{value:e,children:e},e));return(0,g.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[year]`,value:e.year,onChange:e.onValueChange,children:t})}function xt(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));for(let a=1;a<=12;a+=1)t.push((0,g.jsx)("option",{value:a,children:e.monthNames[a-1]},a));return(0,g.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[month]`,value:e.month,onChange:e.onValueChange,children:t})}function vt(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));for(let e=1;e<=31;e+=1)t.push((0,g.jsx)("option",{value:e,children:e},e));return(0,g.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[day]`,value:e.day,onChange:e.onValueChange,children:t})}ft.propTypes={onValueChange:rt().func.isRequired,field:rt().shape({name:rt().string.isRequired,values:rt().objectOf(rt().string)}).isRequired,item:rt().object.isRequired},bt.propTypes={name:rt().string.isRequired,placeholder:rt().string.isRequired,onValueChange:rt().func.isRequired,year:rt().oneOfType([rt().string,rt().number]).isRequired},xt.propTypes={name:rt().string.isRequired,placeholder:rt().string.isRequired,onValueChange:rt().func.isRequired,month:rt().oneOfType([rt().string,rt().number]).isRequired,monthNames:rt().arrayOf(rt().string).isRequired},vt.propTypes={name:rt().string.isRequired,placeholder:rt().string.isRequired,onValueChange:rt().func.isRequired,day:rt().oneOfType([rt().string,rt().number]).isRequired};class yt extends r.Component{constructor(e){super(e),this.state={year:"",month:"",day:""},this.onValueChange=this.onValueChange.bind(this)}componentDidMount(){this.extractDateParts()}componentDidUpdate(e){void 0!==this.props.item&&void 0!==e.item&&this.props.item.id!==e.item.id&&this.extractDateParts()}onValueChange(e){const t=e.target.name.match(/(.*?)\[(.*?)\]/);let a=null,i=null;if(null!==t&&3===t.length){[,a,i]=t;const s=Number(e.target.value);this.setState({[`${i}`]:s},()=>{this.props.onValueChange({target:{name:a,value:this.formatValue()}})})}}formatValue(){let e;switch(this.props.field.params.date_type){case"year_month_day":e={year:this.state.year,month:this.state.month,day:this.state.day};break;case"year_month":e={year:this.state.year,month:this.state.month};break;case"month":e={month:this.state.month};break;case"year":e={year:this.state.year};break;default:e={value:"invalid type"}}return e}extractDateParts(){const e=void 0!==this.props.item[this.props.field.name]?this.props.item[this.props.field.name].trim():"";if(""===e)return;const t=et()(e);this.setState({year:t.format("YYYY"),month:t.format("M"),day:t.format("D")})}render(){const e=window.mailpoet_month_names||[];let t=(window.mailpoet_date_formats||{})[this.props.field.params.date_type][0];this.props.field.params.date_format&&(t=this.props.field.params.date_format);const a=t.split("/").map(t=>{switch(t){case"YYYY":return(0,g.jsx)(bt,{onValueChange:this.onValueChange,name:this.props.field.name,year:this.state.year,placeholder:this.props.field.year_placeholder},"year");case"MM":return(0,g.jsx)(xt,{onValueChange:this.onValueChange,name:this.props.field.name,month:this.state.month,monthNames:e,placeholder:this.props.field.month_placeholder},"month");case"DD":return(0,g.jsx)(vt,{onValueChange:this.onValueChange,name:this.props.field.name,day:this.state.day,placeholder:this.props.field.day_placeholder},"day");default:return(0,g.jsx)("div",{children:"Invalid date type"})}});return(0,g.jsx)("div",{children:a})}}yt.propTypes={item:rt().object.isRequired,field:rt().shape({name:rt().string,day_placeholder:rt().string,month_placeholder:rt().string,year_placeholder:rt().string,params:rt().object}).isRequired,onValueChange:rt().func.isRequired};var jt=a(94367),wt=a(90574);function St(e){const t=Array.isArray(e.item[e.field.name])?e.field.name&&e.item[e.field.name].map(t=>e.field.getName(t)):[];let a=[];return e.field.endpoint?a=function(e){let t=[];return void 0!==window[`mailpoet_${e}`]&&(t=window[`mailpoet_${e}`]),t}(String(e.field.endpoint)).map(t=>e.field.getName(t)):e.field.suggestedValues&&(a=e.field.suggestedValues),(0,g.jsx)(wt.g,{label:e.field.label,name:e.field.name,placeholder:e.field.placeholder,selectedValues:t,suggestedValues:a,onChange:e.onValueChange})}class Nt extends r.Component{renderField=e=>{let t,a=!1;e.field.description&&(a=(0,g.jsx)("p",{className:"description",children:e.field.description}));let i=e.field;switch(void 0!==e.field.field&&(i=Ie().merge(i,e.field.field)),i.type){case"text":t=(0,g.jsx)(lt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"textarea":t=(0,g.jsx)(ct,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"select":t=(0,g.jsx)(pt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"radio":t=(0,g.jsx)(gt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"checkbox":t=(0,g.jsx)(ft,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"selection":t=(0,g.jsx)(De.L,{onValueChange:e.onValueChange,field:e.field,automationId:e.automationId,inline:e.inline,description:e.description,item:e.item},`selection-field-${i.name}`);break;case"date":t=(0,g.jsx)(yt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"reactComponent":t=(0,g.jsx)(e.field.component,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"tokenField":t=(0,g.jsx)(St,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,description:e.description});break;case"empty":break;default:t="invalid"}const s="function"==typeof i.disabled?i.disabled(e.field):i.disabled,n={...i.onWrapperClick?{onClick:i.onWrapperClick}:{}};return(0,g.jsxs)("div",{className:Z()("mailpoet-form-field",{"mailpoet-form-field-disabled":s}),...n,children:[t,a]},`field-${e.index||0}`)};render(){let e=!1;const{onValueChange:t=()=>{}}=this.props;e=void 0!==this.props.field.fields?this.props.field.fields.map((e,a)=>this.renderField({index:a,field:e,item:this.props.item,onValueChange:t||!1})):this.renderField(this.props);let a=!1;this.props.field.label&&(a=(0,g.jsx)(jt.D,{level:4,children:(0,g.jsx)("label",{htmlFor:`field_${this.props.field.name}`,children:this.props.field.label})}));let i=!1;return this.props.field.tip&&(i=(0,g.jsx)("p",{className:"mailpoet-form-description",children:this.props.field.tip})),(0,g.jsxs)("div",{className:`mailpoet-form-field-${this.props.field.name} form-field-row-${this.props.field.name}`,children:[a,i,e]})}}Nt.propTypes={onValueChange:rt().func,field:rt().shape({name:rt().string.isRequired,values:rt().objectOf(rt().string),tip:rt().oneOfType([rt().array,rt().string]),label:rt().string,fields:rt().arrayOf(rt().object),description:rt().string,onWrapperClick:rt().func,disabled:rt().oneOfType([rt().func,rt().bool])}).isRequired,item:rt().object.isRequired},(0,o.registerTranslations)();class kt extends r.Component{constructor(e){super(e),this.formRef=(0,r.createRef)(),this.state={loading:!1,errors:[],item:{}}}componentDidMount(){const{fields:e,params:t={}}=this.props;void 0!==t.id?this.loadItem(t.id):st()(()=>{const t=Ie()(".mailpoet_form").mailpoetSerializeObject(),a=Array.isArray(e)&&e.length>0&&e.find(e=>"checkbox"===e?.type&&e?.isChecked);a&&a.name&&(t[a.name]="1"),this.setState({item:t})})}componentDidUpdate(e){const{item:t,location:a={},params:i={}}=this.props;void 0===i.id&&e.location?.pathname!==a.pathname&&(st()(()=>{this.setState({loading:!1,item:{}})}),void 0===t&&this.formRef.current.reset())}getValues=()=>this.props.item||this.state.item;getErrors=()=>this.props.errors||this.state.errors;loadItem=e=>{const{navigate:t,endpoint:a,onItemLoad:i}=this.props;this.setState({loading:!0}),a&&m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:a,action:"get",data:{id:e}}).done(e=>{this.setState({loading:!1,item:e.data}),"function"==typeof i&&i(e.data)}).fail(()=>{this.setState({loading:!1,item:{}},()=>{t("/lists")})})};handleSubmit=e=>{e.preventDefault();const{navigate:t,endpoint:a,fields:i=[],isValid:s,messages:n={onUpdate:()=>{},onCreate:()=>{}},onSuccess:r,params:o={}}=this.props;if("function"==typeof s&&!1===s())return;this.setState({loading:!0});const l={};i.forEach(e=>{void 0!==e.fields?e.fields.forEach(e=>{l[e.name]=this.state.item[e.name]}):l[e.name]=this.state.item[e.name]}),void 0!==o.id&&(l.id=o.id),a&&m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:a,action:"save",data:l}).always(()=>{this.setState({loading:!1})}).done(()=>{"function"==typeof r?r():t("/"),void 0!==o.id?n.onUpdate():n.onCreate()}).fail(e=>{e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e):this.setState({errors:e.errors}))})};handleValueChange=e=>{const{onChange:t}=this.props,{name:a,value:i}=Object.prototype.hasOwnProperty.call(e,"target")?e.target:e;return"function"==typeof t?t(e):(this.setState(e=>{const t=e.item;return t[a]=i,{item:t}}),!0)};render(){const{children:e,afterFormContent:t,beforeFormContent:a,onSubmit:i,fields:s=[],id:n=""}=this.props;let r;void 0!==this.getErrors()&&(r=this.getErrors().map(e=>(0,g.jsx)("div",{className:"mailpoet_notice notice inline error is-dismissible",children:(0,g.jsx)("p",{children:e.message})},`error-${e.message}`)));const l=Z()("mailpoet_form",{mailpoet_form_loading:this.state.loading||this.props.loading});let d=!1,c=!1;"function"==typeof a&&(d=a(this.getValues())),"function"==typeof t&&(c=t(this.getValues()));const m=s.map(e=>{let t=this.handleValueChange;return e.onBeforeChange&&(t=t=>(e.onBeforeChange(t),this.handleValueChange(t))),(0,g.jsx)(Nt,{field:e,item:this.getValues(),onValueChange:t,automationId:e.automationId},`field-${e.name}`)});let u=!1;return u=e||(0,g.jsx)(o.Button,{type:"submit",isDisabled:this.state.loading,children:(0,p.__)("Save","mailpoet")}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-form-content-around",children:d}),(0,g.jsxs)("form",{id:n,ref:this.formRef,className:l,onSubmit:"function"==typeof i?i:this.handleSubmit,"data-automation-id":this.props.automationId,children:[r,(0,g.jsxs)("div",{className:"mailpoet-form-grid",children:[m,(0,g.jsx)("div",{className:"mailpoet-form-actions",children:u})]})]}),(0,g.jsx)("div",{className:"mailpoet-form-content-around",children:c})]})}}function Ct(e){const t=(0,ke.Zp)();return(0,g.jsx)(kt,{...e,navigate:t})}kt.propTypes={params:rt().shape({id:rt().string}),location:rt().shape({pathname:rt().string}),item:rt().object,errors:rt().arrayOf(rt().object),endpoint:rt().string,fields:rt().arrayOf(rt().object),messages:rt().shape({onUpdate:rt().func,onCreate:rt().func}),loading:rt().bool,children:rt().array,id:rt().string,automationId:rt().string,beforeFormContent:rt().func,afterFormContent:rt().func,onItemLoad:rt().func,isValid:rt().func,onChange:rt().func,onSubmit:rt().func,onSuccess:rt().func,navigate:rt().func.isRequired};var It=a(12218);const Ut=[{name:"email",label:m.U.I18n.t("email"),type:"text",disabled:function(e){return Boolean(Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user))}},{name:"first_name",label:m.U.I18n.t("firstname"),type:"text",disabled:function(e){return Boolean(Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user))}},{name:"last_name",label:m.U.I18n.t("lastname"),type:"text",disabled:function(e){return Boolean(Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user))}},{name:"status",label:m.U.I18n.t("status"),type:"select",automationId:"subscriber-status",values:{subscribed:m.U.I18n.t("subscribed"),unconfirmed:m.U.I18n.t("unconfirmed"),unsubscribed:m.U.I18n.t("unsubscribed"),inactive:m.U.I18n.t("inactive"),bounced:m.U.I18n.t("bounced")}},{name:"segments",label:m.U.I18n.t("lists"),type:"selection",placeholder:m.U.I18n.t("selectList"),tip:m.U.I18n.t("welcomeEmailTip"),api_version:window.mailpoet_api_version,endpoint:"segments",multiple:!0,selected:function(e){return!1===Array.isArray(e.subscriptions)?null:e.subscriptions.filter(e=>"subscribed"===e.status).map(e=>e.segment_id)},filter:function(e){return!e?.deleted_at&&"default"===e?.type},getLabel:function(e){return e?.name||""},getCount:function(e){return e?.subscribers||0},getSearchLabel:function(e,t){let a="";return void 0!==t.subscriptions&&t.subscriptions.forEach(t=>{if(e?.id===t.segment_id&&(a=e?.name||"","unsubscribed"===t.status)){const e=m.U.Date.format(t.updated_at);a+=" (%1$s)".replace("%1$s",m.U.I18n.t("unsubscribedOn").replace("%1$s",e))}}),a}},{name:"tags",label:m.U.I18n.t("tags"),type:"tokenField",placeholder:m.U.I18n.t("addNewTag"),suggestedValues:[],endpoint:"tags",getName:function(e){return Object.prototype.hasOwnProperty.call(e,"name")?e.name:String(e)}}];(window.mailpoet_custom_fields||[]).forEach(e=>{const t={name:`cf_${e.id}`,label:e.name,type:e.type};switch(e.params&&(t.params=e.params,e.params.values&&(t.values=e.params.values)),e.type){case"date":t.year_placeholder=m.U.I18n.t("year"),t.month_placeholder=m.U.I18n.t("month"),t.day_placeholder=m.U.I18n.t("day");break;case"select":t.placeholder="-";break;default:t.placeholder=""}Ut.push(t)});const Et={onUpdate:function(){m.U.Notice.success(m.U.I18n.t("subscriberUpdated"))},onCreate:function(){m.U.Notice.success(m.U.I18n.t("subscriberAdded")),m.U.trackEvent("Subscribers > Add new")}};function At(e){if(Number(e.wp_user_id)>0)return(0,g.jsx)("p",{className:"description",children:at()(m.U.I18n.t("WPUserEditNotice"),/\[link\](.*?)\[\/link\]/g,(t,a)=>(0,g.jsx)("a",{href:`user-edit.php?user_id=${e.wp_user_id}`,children:t},a))})}function Tt(e){return(0,g.jsxs)(g.Fragment,{children:[e?.unsubscribes?.map(e=>{const t=et()(e.createdAt.date).format("dddd MMMM Do YYYY [at] h:mm:ss a");let a;a="admin"===e.source?m.U.I18n.t("unsubscribedAdmin").replace("%1$d",t).replace("%2$d",e.meta||""):"manage"===e.source?m.U.I18n.t("unsubscribedManage").replace("%1$d",t):"newsletter"===e.source?at()(m.U.I18n.t("unsubscribedNewsletter").replace("%1$d",t),/\[link\]/g,(t,a)=>(0,g.jsx)("a",{href:`admin.php?page=mailpoet-newsletter-editor&id=${e.newsletterId||""}`,children:e.newsletterSubject||""},a)):"mp_api"===e.source?m.U.I18n.t("unsubscribedMpApi").replace("%1$d",t):m.U.I18n.t("unsubscribedUnknown").replace("%1$d",t);const i=e.reasonLabel?m.U.I18n.t(e.reasonText?"unsubscribeReasonWithDetails":"unsubscribeReason").replace("%1$s",e.reasonLabel).replace("%2$s",e.reasonText||""):null;return(0,g.jsxs)("div",{className:"description",children:[(0,g.jsx)("p",{children:a}),i&&(0,g.jsx)("p",{children:i})]},`${e.source}-${t}-${e.newsletterId||""}`)}),(0,g.jsxs)("p",{className:"description",children:[(0,g.jsx)("strong",{children:m.U.I18n.t("tip")})," ",m.U.I18n.t("customFieldsTip")]})]})}function Rt(){const e=(0,ke.zy)(),t=(0,ke.g)(),a=(0,ke.Zp)(),i=e.state?.backUrl||"/";return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Oe.z,{heading:t.id?(0,p.__)("Edit subscriber","mailpoet"):(0,p.__)("Add new subscriber","mailpoet"),headingPrefix:(0,g.jsx)(Oe.o,{onClick:()=>a(i),label:m.U.I18n.t("backToList")})}),(0,g.jsx)(It.X,{}),(0,g.jsx)(Ct,{automationId:"subscriber_edit_form",endpoint:"subscribers",fields:Ut,params:t,messages:Et,beforeFormContent:At,afterFormContent:Tt,onSuccess:()=>a(i)})]})}Rt.displayName="SubscriberForm";var Pt=a(8720),Dt=a(37059),Ot=a(64929),Ft=a(1452);function Mt({email:e,avatarUrl:t,subscribedAt:a,sourceLabel:i}){const s=(0,ke.zy)(),n=(0,ke.Zp)(),r=s.state?.backUrl||"/",o=function(e,t){if(!e)return null;const a=m.U.Date.short(e);return t?(0,p.sprintf)((0,p.__)("Subscribed on %1$s / via %2$s","mailpoet"),a,t):(0,p.sprintf)((0,p.__)("Subscribed on %s","mailpoet"),a)}(a,i);return(0,g.jsxs)(Dt.A,{className:"mailpoet-subscriber-stats-heading",align:"center",gap:4,children:[(0,g.jsx)(Ot.A,{children:(0,g.jsx)(Oe.o,{onClick:()=>n(r),label:m.U.I18n.t("backToList")})}),t?(0,g.jsx)(Ot.A,{children:(0,g.jsx)("img",{className:"mailpoet-subscriber-stats-heading-avatar",src:t,alt:"",width:48,height:48})}):null,(0,g.jsxs)(Ft.A,{children:[(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-heading-email",children:e}),o?(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-heading-subtitle",children:o}):null]})]})}Mt.displayName="StatsHeading";var Lt=a(16325),$t=a(36370);function Wt({stats:e}){const t=e.woocommerce_overview;if(!t)return null;const a=[{label:(0,p.__)("Orders placed","mailpoet"),value:(0,g.jsx)("a",{href:t.orders_url,children:t.orders_count.toLocaleString()})},{label:(0,p.__)("Lifetime value","mailpoet"),value:t.total_revenue_formatted},{label:(0,p.__)("Average order value","mailpoet"),value:t.average_order_value_formatted}];return(0,g.jsx)(Dt.A,{className:"mailpoet-subscriber-stats-woocommerce-overview",align:"stretch",gap:4,children:a.map(e=>(0,g.jsx)(Ft.A,{children:(0,g.jsx)(Lt.A,{size:"medium",children:(0,g.jsxs)($t.A,{children:[(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-woocommerce-overview-label",children:e.label}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-woocommerce-overview-value",children:e.value})]})})},e.label))})}Wt.displayName="WoocommerceOverview";var Bt=a(58642),qt=a(58319),Ht=a(40729),zt=a(55855);const Vt=[{label:(0,p.__)("7 days","mailpoet"),value:"7_days"},{label:(0,p.__)("30 days","mailpoet"),value:"30_days"},{label:(0,p.__)("3 months","mailpoet"),value:"3_months"},{label:(0,p.__)("12 months","mailpoet"),value:"12_months"}];function Yt(e,t){return e.find(e=>e.key===t)}function Gt(e){return Intl.NumberFormat(void 0,{maximumFractionDigits:1,notation:"compact"}).format(e)}function Kt({stats:e,type:t}){if("sent"===t)return(0,g.jsx)(g.Fragment,{children:Gt(e.total_sent)});const a=function(e,t){return t<=0?0:e/t*100}("opened"===t?e.open:e.click,e.total_sent),i=function(e){const t=Math.round(10*e)/10,a=Number.isInteger(t)?0:1;return`${t.toLocaleString(void 0,{minimumFractionDigits:a,maximumFractionDigits:1})}%`}(a);return"clicked"===t?(0,g.jsxs)("span",{className:"mailpoet-subscriber-stats-engagement-value-with-badge",children:[(0,g.jsx)(zt.f,{stat:"clicked",rate:a,tooltipId:`subscriber-stats-clicked-${e.key}`}),(0,g.jsx)("span",{children:i})]}):(0,g.jsx)(g.Fragment,{children:i})}function Qt({stats:e}){const[t,a]=(0,r.useState)("30_days"),i=(0,r.useMemo)(()=>Yt(e.periodic_stats,"lifetime"),[e.periodic_stats]),s=(0,r.useMemo)(()=>Yt(e.periodic_stats,t)||Yt(e.periodic_stats,"30_days")||e.periodic_stats[0],[t,e.periodic_stats]);if(!s||!i)return null;const n=he(e.engagement_score),o=[{label:(0,p.__)("Emails sent","mailpoet"),type:"sent"},{label:(0,p.__)("Opened","mailpoet"),type:"opened"},{label:(0,p.__)("Clicked","mailpoet"),type:"clicked"}];return(0,g.jsxs)(Lt.A,{className:"mailpoet-subscriber-stats-card",size:"medium",children:[(0,g.jsx)(Bt.A,{className:"mailpoet-subscriber-stats-card-header",children:(0,g.jsxs)(Dt.A,{align:"center",gap:3,children:[(0,g.jsx)(Ft.A,{children:(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-card-title-row",children:[(0,g.jsx)("h2",{className:"mailpoet-subscriber-stats-card-title",children:(0,p.__)("Engagement","mailpoet")}),(0,g.jsx)(Ht.vw,{className:"mailpoet-subscriber-stats-engagement-badge",variant:n,children:(l=n,{unknown:(0,p.__)("Unknown","mailpoet"),average:(0,p.__)("Average","mailpoet"),good:(0,p.__)("Good","mailpoet"),excellent:(0,p.__)("Excellent","mailpoet")}[l])})]})}),(0,g.jsx)(qt.A,{className:"mailpoet-subscriber-stats-period-control",hideLabelFromVision:!0,label:(0,p.__)("Engagement period","mailpoet"),onChange:e=>a(e),options:Vt,value:t})]})}),(0,g.jsx)($t.A,{children:(0,g.jsxs)("table",{className:"mailpoet-subscriber-stats-engagement-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,g.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Engagement metric","mailpoet")})}),(0,g.jsx)("th",{children:s.timeframe}),(0,g.jsx)("th",{children:i.timeframe})]})}),(0,g.jsx)("tbody",{children:o.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{scope:"row",children:e.label}),(0,g.jsx)("td",{children:(0,g.jsx)(Kt,{stats:s,type:e.type})}),(0,g.jsx)("td",{children:(0,g.jsx)(Kt,{stats:i,type:e.type})})]},e.type))})]})})]});var l}function Jt(){return(0,g.jsx)("span",{className:"mailpoet-subscriber-stats-empty-value",children:"-"})}function Zt({value:e}){return e?(0,g.jsx)(g.Fragment,{children:e}):(0,g.jsx)(Jt,{})}function Xt(e){switch(e){case"subscribed":return(0,p.__)("Subscribed","mailpoet");case"unconfirmed":return(0,p.__)("Unconfirmed","mailpoet");case"unsubscribed":return(0,p.__)("Unsubscribed","mailpoet");case"inactive":return(0,p.__)("Inactive","mailpoet");case"bounced":return(0,p.__)("Bounced","mailpoet");default:return e}}function ea({label:e,children:t}){return(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-profile-row",children:[(0,g.jsx)("dt",{children:e}),(0,g.jsx)("dd",{children:t})]})}function ta({profile:e,subscriberId:t}){const a=(0,ke.zy)(),i=(0,ke.Zp)();return(0,g.jsxs)(Lt.A,{className:"mailpoet-subscriber-stats-card",size:"medium",children:[(0,g.jsx)(Bt.A,{className:"mailpoet-subscriber-stats-card-header",children:(0,g.jsxs)(Dt.A,{align:"center",justify:"space-between",children:[(0,g.jsx)("h2",{className:"mailpoet-subscriber-stats-card-title",children:(0,p.__)("Profile information","mailpoet")}),(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:()=>i(`/edit/${t}`,{state:{backUrl:a.pathname}}),children:(0,p.__)("Edit","mailpoet")})]})}),(0,g.jsx)($t.A,{children:(0,g.jsxs)("dl",{className:"mailpoet-subscriber-stats-profile-list",children:[(0,g.jsx)(ea,{label:(0,p.__)("Status","mailpoet"),children:(0,g.jsx)(Zt,{value:Xt(e.status)})}),"unsubscribed"===e.status&&(0,g.jsx)(ea,{label:(0,p.__)("Unsubscribe reason","mailpoet"),children:(0,g.jsx)(Zt,{value:e.unsubscribe_reason??void 0})}),(0,g.jsx)(ea,{label:(0,p.__)("First name","mailpoet"),children:(0,g.jsx)(Zt,{value:e.first_name})}),(0,g.jsx)(ea,{label:(0,p.__)("Last name","mailpoet"),children:(0,g.jsx)(Zt,{value:e.last_name})}),(0,g.jsx)(ea,{label:(0,p.__)("Email address","mailpoet"),children:(0,g.jsx)(Zt,{value:e.email})}),e.shipping_address.length>0&&(0,g.jsx)(ea,{label:(0,p.__)("Shipping","mailpoet"),children:(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-shipping-address",children:e.shipping_address.join("\n")})}),e.custom_fields.map(e=>(0,g.jsx)(ea,{label:e.name,children:(0,g.jsx)(Zt,{value:e.value})},e.id)),(0,g.jsx)(ea,{label:(0,p.__)("Tags","mailpoet"),children:e.tags.length>0?(0,g.jsx)(o.SubscriberTags,{subscribers:e.tags,variant:"wordpress",isInverted:!0}):(0,g.jsx)(Jt,{})}),(0,g.jsx)(ea,{label:(0,p.__)("Lists","mailpoet"),children:e.segments.length>0?(0,g.jsx)(o.SegmentTags,{segments:e.segments}):(0,g.jsx)(Jt,{})})]})})]})}Qt.displayName="EngagementCard",ta.displayName="ProfileInformation";var aa=a(42176),ia=a(79616),sa=a(25557),na=a(48547),ra=a(31e3),oa=a(14206);const{subscribersLimitReached:la,subscribersLimit:da,subscribersCount:ca,premiumActive:ma,hasValidApiKey:ua,hasValidPremiumKey:pa,isPremiumPluginInstalled:ha,pluginPartialKey:ga}=m.U,_a=ua||pa,fa=e=>(0,g.jsx)("p",{children:at()(e,/(\[subscribersCount]|\[subscribersLimit])/g,e=>"[subscribersCount]"===e?ca:da)}),ba=(e,t,a="_blank")=>(0,g.jsx)(Le.$,{href:t,target:a,rel:"noopener noreferrer",children:e});function xa({message:e,actionButton:t,capabilities:a={}}){let i,s,n=(0,p.__)("This is a Premium feature","mailpoet");if(!pa||ha&&ma)if(la){i=fa((0,p.__)("Congratulations, you now have [subscribersCount] subscribers! Your plan is limited to [subscribersLimit] subscribers. You need to upgrade now to be able to continue using MailPoet.","mailpoet"));const e=_a?m.U.MailPoetComUrlFactory.getUpgradeUrl(ga):m.U.MailPoetComUrlFactory.getPurchasePlanUrl(+ca+1,null,null,null);s=ba((0,p.__)("Upgrade your plan","mailpoet"),e)}else if(ua&&!pa||pa&&Object.keys(a).some(e=>m.U.capabilities[e].isRestricted)){n=(0,p.__)("Upgrade your plan","mailpoet"),i=e;const t=m.U.MailPoetComUrlFactory.getUpgradeUrl(ga,{s:ca,capabilities:a});s=ba((0,p.__)("Upgrade","mailpoet"),t)}else i=e,s=t;else i=fa((0,p.__)("Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.","mailpoet")),r=ha?(0,p.__)("Activate MailPoet Premium plugin","mailpoet"):(0,p.__)("Download MailPoet Premium plugin","mailpoet"),s=(0,g.jsx)(oa.Wr,{buttonText:r});var r;return(0,g.jsx)(ra.P,{title:n,message:i,actionButton:s})}function va(e,t=0){const a=new Date;return a.setDate(a.getDate()-e),a.setHours(Math.max(0,a.getHours()-t)),a}function ya(e){return m.U.Date.format(e,{format:"Y-m-d"})}function ja(e){const t=new Date,a=new Date;a.setDate(t.getDate()-1);const i=ya(e);return i===ya(t)?(0,p.__)("Today","mailpoet"):i===ya(a)?(0,p.__)("Yesterday","mailpoet"):m.U.Date.short(e)}function wa({item:e}){return(0,g.jsxs)("li",{className:"mailpoet-subscriber-stats-activity-item",children:[(0,g.jsx)("span",{className:"mailpoet-subscriber-stats-activity-icon","aria-hidden":"true",children:(0,g.jsx)(K.A,{icon:e.icon})}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-activity-item-content",children:(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-activity-item-main",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-activity-item-title",children:e.title}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-activity-item-description",children:e.description})]}),(0,g.jsx)("time",{className:"mailpoet-subscriber-stats-activity-item-date",dateTime:e.date.toISOString(),children:m.U.Date.full(e.date)})]})})]})}function Sa({group:e}){return(0,g.jsxs)("li",{className:"mailpoet-subscriber-stats-activity-day",children:[(0,g.jsx)("h3",{className:"mailpoet-subscriber-stats-activity-day-title",children:e.label}),(0,g.jsx)("ul",{className:"mailpoet-subscriber-stats-activity-list",children:e.items.map(e=>(0,g.jsx)(wa,{item:e},e.key))})]})}function Na({eventType:e}){const t=[{key:"opened",eventType:"open",icon:ia.A,title:(0,p.__)("Opened email “Spring sale newsletter”","mailpoet"),description:(0,p.__)("Opened the email on desktop.","mailpoet"),date:va(0,2)},{key:"clicked",eventType:"click",icon:sa.A,title:(0,p.__)("Clicked a link in email “Spring sale newsletter”","mailpoet"),description:(0,p.__)("https://example.com/spring-collection","mailpoet"),date:va(0,3)},{key:"purchased",eventType:"purchase",icon:na.A,title:(0,p.__)("Completed purchase","mailpoet"),description:(0,p.__)("Revenue tracked from an email click.","mailpoet"),date:va(1)},{key:"unsubscribed",eventType:"unsubscribe",icon:ne.A,title:(0,p.__)("Unsubscribed","mailpoet"),description:(0,p.__)("Reason: No reason provided","mailpoet"),date:va(1,2)}].filter(t=>"all"===e||t.eventType===e).sort((e,t)=>t.date.getTime()-e.date.getTime()).reduce((e,t)=>{const a=ya(t.date),i=e.find(e=>e.key===a);return i?(i.items.push(t),e):(e.push({key:a,label:ja(t.date),items:[t]}),e)},[]);return(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-locked-activity","data-automation-id":"subscriber-stats-no-access",children:[(0,g.jsx)("ul",{className:"mailpoet-subscriber-stats-activity-days mailpoet-subscriber-stats-activity-list-sample","aria-label":(0,p.__)("Sample subscriber activity","mailpoet"),children:t.map(e=>(0,g.jsx)(Sa,{group:e},e.key))}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-no-access-content",children:(0,g.jsx)(xa,{message:(()=>{const e=(0,p.__)("Learn more about how each of your subscribers is engaging with your emails. See which emails they’ve opened, the links they clicked. If you’re a WooCommerce store owner, you’ll also see any purchases made as a result of your emails. [link]Learn more[/link].","mailpoet");return(0,g.jsx)("p",{children:at()(e,/\[link](.*?)\[\/link]/g,e=>(0,g.jsx)("a",{href:m.U.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e))})})(),actionButton:(0,g.jsx)(Le.$,{href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,null,{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Upgrade","mailpoet")}),capabilities:{detailedAnalytics:!0}})})]})}function ka({eventType:e,params:t,location:a}){const i=(0,r.useMemo)(()=>aa.Hooks.applyFilters("mailpoet_subscribers_opened_emails_stats",()=>(0,g.jsx)(Na,{eventType:e}),t,a,e),[e,a,t]);return(0,g.jsx)(i,{})}const Ca=[{label:(0,p.__)("All events","mailpoet"),value:"all"},{label:(0,p.__)("Email opens","mailpoet"),value:"open"},{label:(0,p.__)("Link clicks","mailpoet"),value:"click"},{label:(0,p.__)("Purchases","mailpoet"),value:"purchase"},{label:(0,p.__)("Unsubscribes","mailpoet"),value:"unsubscribe"}];function Ia({lastEngagementAt:e,location:t,params:a}){const[i,s]=(0,r.useState)("all"),n=e?(0,p.sprintf)((0,p.__)("Last seen on %s","mailpoet"),m.U.Date.full(e)):(0,p.__)("Last seen: never","mailpoet");return(0,g.jsxs)(Lt.A,{className:"mailpoet-subscriber-stats-card mailpoet-subscriber-stats-activity",size:"medium",children:[(0,g.jsx)(Bt.A,{className:"mailpoet-subscriber-stats-card-header",children:(0,g.jsxs)(Dt.A,{align:"center",gap:3,children:[(0,g.jsx)(Ft.A,{children:(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"mailpoet-subscriber-stats-card-title",children:(0,p.__)("Activity","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-card-subtitle",children:n})]})}),(0,g.jsx)(qt.A,{className:"mailpoet-subscriber-stats-activity-filter",hideLabelFromVision:!0,label:(0,p.__)("Activity event type","mailpoet"),onChange:e=>s(e),options:Ca,value:i})]})}),(0,g.jsx)($t.A,{className:"mailpoet-subscriber-stats-activity-body",children:(0,g.jsx)(ka,{eventType:i,params:a,location:t})})]})}function Ua(){const e=(0,ke.g)(),t=(0,ke.zy)(),[a,i]=(0,r.useState)(null),[s,n]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"subscriberStats",action:"get",data:{subscriber_id:e.id}}).done(e=>{i(e.data),n(!1)}).fail(e=>{n(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[e.id]),s?(0,g.jsx)(Pt.R,{}):a?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats",children:[(0,g.jsx)(Mt,{email:a.email,avatarUrl:a.avatar_url,subscribedAt:a.subscribed_at,sourceLabel:a.source_label}),a.is_woo_active&&a.is_woocommerce_user&&(0,g.jsx)(Wt,{stats:a}),(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-content",children:[(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-primary-column",children:[(0,g.jsx)(Qt,{stats:a}),(0,g.jsx)(ta,{profile:a.profile,subscriberId:Number(e.id)})]}),(0,g.jsx)(Ia,{lastEngagementAt:a.last_engagement,params:e,location:t})]})]})]}):null}function Ea(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:"/new",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Rt,{})})}),(0,g.jsx)(ke.qh,{path:"/edit/:id",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Rt,{})})}),(0,g.jsx)(ke.qh,{path:"/stats/:id/*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Ua,{})})}),(0,g.jsx)(ke.qh,{path:"*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Ze,{})})})]})]})})}Ia.displayName="ActivityShell",Ua.displayName="SubscriberStats";const Aa=document.getElementById("subscribers_container");Aa&&((0,o.registerTranslations)(),(0,n.H)(Aa).render((0,g.jsx)(Ea,{})));var Ta=a(95776),Ra=a(66177),Pa=a(5296),Da=a(75847),Oa=a(45919);function Fa({isModalOpen:e,onClose:t}){const[a,i]=(0,r.useState)(!1),{notices:s}=(0,r.useContext)(l.F),n=(0,r.useCallback)(()=>{i(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,p.__)("Subject","mailpoet"),new_editor:!0}}).done(e=>{window.location.href=m.U.getBlockEmailEditorUrl(e.data.wp_post_id)}).fail(e=>{i(!1),t(),e.errors.length>0&&s.apiError(e,{scroll:!0})})},[s,t]);return e?(m.U.trackEvent("New Email Editor > try new email editor modal opened",{},{send_immediately:!0}),(0,g.jsxs)(Ue.A,{title:(0,p.__)("Try the new email editor","mailpoet"),onRequestClose:()=>{m.U.trackEvent("New Email Editor > try new email editor modal closed"),t()},className:"mailpoet-new-editor-modal",children:[(0,g.jsxs)("div",{className:"mailpoet-new-editor-modal-image",children:[(0,g.jsx)("span",{className:"mailpoet-new-editor-modal-image__beta_label",children:(0,p.__)("Alpha version","mailpoet")}),(0,g.jsx)("img",{src:`${m.U.cdnUrl}email-editor/new-editor-modal-header.png`,alt:(0,p.__)("Try the new email editor","mailpoet"),width:"324",height:"130"})]}),(0,g.jsx)("p",{children:(0,p.__)("Take a first look at our new email editor. It introduces a more flexible, modern way to design your emails. This version is still evolving, and your feedback will help guide what comes next.","mailpoet")}),(0,g.jsx)("p",{className:"mailpoet-new-editor-modal-note",children:(0,p.__)("Note: Emails created here can't be opened in the legacy editor.","mailpoet")}),(0,g.jsxs)("div",{className:"mailpoet-new-editor-modal-footer",children:[(0,g.jsx)(ce.Ay,{type:"button",variant:"tertiary",onClick:()=>{m.U.trackEvent("New Email Editor > try new email editor modal cancel button clicked",{},{send_immediately:!0},t)},children:(0,p.__)("Cancel","mailpoet")}),(0,g.jsx)(ce.Ay,{type:"button",variant:"primary",isBusy:a,onClick:()=>{m.U.trackEvent("New Email Editor > try new email editor modal create with new editor button clicked",{},{send_immediately:!0},n)},children:(0,p.__)("Try it now","mailpoet")})]})]})):null}var Ma=a(5863);function La({errors:e}){return e.length<1?null:(0,g.jsx)(h.$,{type:"error",closable:!1,children:e.map(e=>(0,g.jsx)("p",{children:e.message},e.message))})}var $a=a(43987),Wa=a(60713);const Ba=$a.Ay;function qa({children:e}){return(0,g.jsx)(Ba,{delay:0,text:(0,g.jsx)("div",{className:"mailpoet-newsletter-type-info-tooltip",children:e}),children:(0,g.jsx)("div",{className:"mailpoet-newsletter-type-info",children:(0,g.jsx)(Da.A,{icon:Wa.A,size:20})})})}const Ha=Ta.A;function za({filter:e=null,hideScreenOptions:t=!0}){const a=(0,ke.Zp)(),[i,s]=(0,r.useState)(null),[n,o]=(0,r.useState)(!1),l=window.mailpoet_block_email_editor_enabled,d=e=>{void 0!==e&&(a(`/new/${e}`),m.U.trackEvent("Emails > Type selected",{"Email type":e}))},c=mt.default.partial(e=>{s(e),m.U.trackEvent("Emails > Type selected",{"Email type":e}),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletters",action:"create",data:{type:e,subject:(0,p.__)("Subject","mailpoet")}}).done(e=>{a(`/template/${e.data.id}`)}).fail(e=>(s(null),e.errors.length>0?(0,g.jsx)(La,{errors:e.errors}):null))},"standard"),u=mt.default.partial(d,"notification"),h=mt.default.partial(d,"re-engagement"),_=l?(0,g.jsxs)(Ra.A,{className:"mailpoet-dropdown-button-group",children:[(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:c,isBusy:"standard"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Newsletter","mailpoet"),"data-automation-id":"create_standard",children:(0,p.__)("Create","mailpoet")}),(0,g.jsx)(Pa.A,{className:"mailpoet-dropdown-button",contentClassName:"mailpoet-dropdown-button-content",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,g.jsx)(ce.Ay,{variant:"secondary",className:"mailpoet-button-with-wordpress-icon",onClick:t,isBusy:"standard"===i,disabled:null!==i,"aria-expanded":e,"aria-label":(0,p.__)("Choose editor version","mailpoet"),"data-automation-id":"create_standard_email_dropdown",children:(0,g.jsx)(Da.A,{icon:Oa.A,size:24})}),onToggle:e=>e&&m.U.trackEvent("New Email Editor > create email icon clicked"),renderContent:()=>(0,g.jsx)(Ha,{variant:"tertiary",onClick:()=>{o(!0),m.U.trackEvent("New Email Editor > creating using new email editor button clicked")},children:(0,p.__)("Create using the new email editor (Alpha)","mailpoet")})})]}):(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:c,isBusy:i,"data-automation-id":"create_standard",children:(0,p.__)("Create","mailpoet")}),f=[{slug:"standard",title:(0,p.__)("Newsletter","mailpoet"),description:(0,p.__)("Send a newsletter with images, buttons, dividers, and social bookmarks. Or, just send a basic text email.","mailpoet"),action:_},{slug:"automations",title:(0,g.jsxs)(g.Fragment,{children:[(0,p.__)("Automations","mailpoet")," ",(0,g.jsx)(qa,{children:(0,p.__)("Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.","mailpoet")})]}),description:(0,p.__)("Set up automated emails like welcome emails, abandoned cart reminders or one of our many automation templates to inform, engage and reward your audience.","mailpoet"),action:(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:()=>{s("automation"),window.location.href="admin.php?page=mailpoet-automation-templates"},isBusy:"automation"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Automation","mailpoet"),"data-automation-id":"create_automation",children:(0,p.__)("Create","mailpoet")})},{slug:"notification",title:(0,p.__)("Latest Post Notifications","mailpoet"),description:(0,p.__)("Let MailPoet email your subscribers with your latest content. You can send daily, weekly, monthly, or even immediately after publication.","mailpoet"),videoGuide:"https://kb.mailpoet.com/article/210-video-guide-to-post-notifications",action:(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:u,isBusy:"notification"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Latest Post Notification","mailpoet"),"data-automation-id":"create_notification",children:(0,p.__)("Create","mailpoet")})},{slug:"re_engagement",title:(0,p.__)("Re-engagement Emails","mailpoet"),description:(0,p.__)("Automatically email and win back subscribers who have recently lost interest and stopped engaging with your emails.","mailpoet"),action:(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:h,isBusy:"re_engagement"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Re-engagement Email","mailpoet"),"data-automation-id":"create_re_engagement",children:(0,p.__)("Create","mailpoet")})}];let b=aa.Hooks.applyFilters("mailpoet_newsletters_types",[...f],this);e&&(b=b.filter(e));const x=m.U.Ajax.constructGetUrl({api_version:m.U.apiVersion,endpoint:"newsletterTemplates",action:"getAll"});return(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)(Ma.x,{}),(0,g.jsx)("link",{rel:"prefetch",href:window.mailpoet_editor_javascript_url,as:"script"}),(0,g.jsx)("div",{className:"mailpoet-newsletter-types",children:b.map(e=>(e=>(0,g.jsxs)("div",{"data-type":e.slug,className:"mailpoet-newsletter-type",children:[(0,g.jsx)("div",{className:"mailpoet-newsletter-type-image"}),(0,g.jsxs)("div",{className:"mailpoet-newsletter-type-content",children:[(0,g.jsxs)(jt.D,{level:4,children:[e.title," ",e.beta?`(${(0,p.__)("Beta","mailpoet")})`:""]}),(0,g.jsx)("p",{children:e.description}),(0,g.jsx)("div",{className:"mailpoet-flex-grow"}),(0,g.jsx)("div",{className:"mailpoet-newsletter-type-action",children:e.action})]})]},e.slug))(e),this)}),(0,g.jsx)("link",{rel:"prefetch",href:x,as:"fetch"}),(0,g.jsx)(Fa,{onClose:()=>o(!1),isModalOpen:n})]})}var Va=a(7352),Ya=a(74733);function Ga(e){const t=(0,ke.zy)();return(0,g.jsx)(Ya.Y,{...e,location:t})}var Ka=a(25249),Qa=a(61349);class Ja extends r.Component{constructor(e){super(e),this.onPreview=this.onPreview.bind(this),this.onDelete=this.onDelete.bind(this),this.onSelect=this.onSelect.bind(this)}onDelete(){const{id:e,name:t,beforeDelete:a,afterDelete:i}=this.props;(0,Qa.Z)({message:(0,p.__)('You are about to delete the template named "%1$s".',"mailpoet").replace("%1$s",t),onConfirm:()=>{a(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"delete",data:{id:e}}).done(()=>{i(!0,e)}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0}),i(!1)})}})}onPreview(){m.U.Modal.popup({title:this.props.name,template:'',data:this.props})}onSelect(){const{newsletterId:e,name:t,beforeSelect:a,afterSelect:i}=this.props;a(),m.U.trackEvent("Emails > Template selected",{"Email name":t}),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:{id:e,template_id:this.props.id}}).done(e=>{i(!0,e.data.id)}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0}),i(!1)})}render(){const{index:e,name:t,readonly:a,thumbnail:i=null}=this.props;let s="";return"string"==typeof i&&i.length>0&&(s=(0,g.jsxs)("a",{className:"mailpoet-template-preview",href:"#",onClick:e=>{e.preventDefault(),this.onPreview(e)},children:[(0,g.jsx)("div",{className:"mailpoet-template-thumbnail",children:i?(0,g.jsx)("img",{src:i,alt:(0,p.__)("Template preview","mailpoet"),loading:"lazy"}):""}),(0,g.jsx)("div",{className:"mailpoet-template-preview-overlay",children:(0,g.jsx)(Le.$,{children:(0,p.__)("Preview","mailpoet")})})]})),(0,g.jsx)(Ka.c,{label:t,onSelect:this.onSelect,onDelete:!1===a?this.onDelete:void 0,automationId:`select_template_${e}`,className:"mailpoet-template-two-lines",children:s})}}Ja.contextType=l.F,Ja.propTypes={index:rt().number.isRequired,id:rt().number.isRequired,newsletterId:rt().string.isRequired,name:rt().string.isRequired,thumbnail:rt().string,readonly:rt().bool.isRequired,beforeDelete:rt().func.isRequired,afterDelete:rt().func.isRequired,beforeSelect:rt().func.isRequired,afterSelect:rt().func.isRequired},Ja.displayName="TemplateBox";class Za extends r.Component{constructor(e){super(e),this.fileRef=(0,r.createRef)(),this.handleSubmit=this.handleSubmit.bind(this)}handleSubmit(e){if(e.preventDefault(),mt.default.size(this.fileRef.current.files)<=0)return!1;const t=mt.default.first(this.fileRef.current.files),a=new FileReader;return a.onload=e=>{try{this.saveTemplate(JSON.parse(e.target.result)),m.U.trackEvent("Emails > Template imported")}catch(e){this.context.notices.error((0,g.jsx)("p",{children:(0,p.__)("This template file appears to be damaged. Please try another one.","mailpoet")}))}},a.readAsText(t),!0}saveTemplate(e){const t=e,{beforeImport:a,afterImport:i}=this.props;mt.default.isUndefined(t.body)||(t.body=JSON.stringify(t.body));try{t.categories=JSON.parse(t.categories)}catch(e){t.categories=[]}-1===t.categories.indexOf("saved")&&t.categories.push("saved"),-1===t.categories.indexOf("standard")&&-1===t.categories.indexOf("welcome")&&-1===t.categories.indexOf("notification")&&t.categories.push("standard"),t.categories=JSON.stringify(t.categories),a(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"save",data:t}).done(e=>{i(!0,e.data)}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0}),i(!1)})}render(){return(0,g.jsxs)("div",{className:"mailpoet-template-import",children:[(0,g.jsxs)("h4",{children:[(0,p.__)("Import a template","mailpoet"),(0,g.jsx)(Fe.Tooltip,{tooltip:(0,p.__)("You can only upload .json templates that were originally created with MailPoet.","mailpoet"),place:"right",className:"tooltip-help-import-template"})]}),(0,g.jsxs)("form",{onSubmit:this.handleSubmit,children:[(0,g.jsx)("input",{type:"file",placeholder:(0,p.__)("Select a .json file to upload","mailpoet"),ref:this.fileRef}),(0,g.jsx)("p",{className:"submit",children:(0,g.jsx)("input",{className:"button button-primary",type:"submit",value:(0,p.__)("Upload","mailpoet")})})]})]})}}Za.contextType=l.F,Za.propTypes={beforeImport:rt().func.isRequired,afterImport:rt().func.isRequired};var Xa=a(1672);const ei=[];window.mailpoet_newsletters_templates_recently_sent_count&&ei.push({name:"recent",label:(0,p.__)("Recently sent","mailpoet")}),ei.push({name:"standard",label:(0,p.__)("Newsletters","mailpoet")},{name:"welcome",label:(0,p.__)("Welcome Emails","mailpoet")},{name:"notification",label:(0,p.__)("Post Notifications","mailpoet")},{name:"re_engagement",label:(0,p.__)("Re-engagement Emails","mailpoet")},{name:"blank",label:(0,p.__)("Simple text","mailpoet")}),window.mailpoet_woocommerce_active&&ei.push({name:"woocommerce",label:(0,p.__)("WooCommerce Emails","mailpoet")}),ei.push({name:"saved",label:(0,p.__)("Your saved templates","mailpoet")});class ti extends r.Component{constructor(e){super(e),this.state={loading:!0,templates:{},emailType:null,emailOptions:{},selectedTab:""},this.templates={},this.addTemplate=this.addTemplate.bind(this),this.afterTemplateDelete=this.afterTemplateDelete.bind(this),this.afterTemplateSelect=this.afterTemplateSelect.bind(this),this.afterTemplateImport=this.afterTemplateImport.bind(this)}componentDidMount(){m.U.Ajax.get({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"getAll"}).done(e=>{0===e.data.length&&(e.data=[{name:(0,p.__)("MailPoet's Guide","mailpoet"),categories:'["welcome", "notification", "standard", "woocommerce"]',readonly:!0}]),e.data.forEach(this.addTemplate),this.sortTemplates()}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0})}).always(()=>{this.selectInitialTab()})}addTemplate(e){const t=ei.map(e=>e.name);let a;-1===t.indexOf("woocommerce")&&t.push("woocommerce");try{a=JSON.parse(e.categories).filter(e=>-1!==t.indexOf(e))}catch(e){a=[]}0===a.length&&a.push("saved"),a.forEach(t=>{void 0===this.templates[t]&&(this.templates[t]=[]),this.templates[t].unshift(e)})}sortTemplates(){const e=["welcome","notification","standard"];Object.keys(this.templates).forEach(t=>{this.templates[t].sort((a,i)=>{if(e.includes(t)){if(a.categories.includes('"blank"')&&!i.categories.includes('"blank"'))return-1;if(!a.categories.includes('"blank"')&&i.categories.includes('"blank"'))return 1}return a.id{e=i.data.type,t=i.data.options,"automatic"===e&&(e=i.data.options.group||e),window.mailpoet_newsletters_templates_recently_sent_count?a="recent":mt.default.findWhere(ei,{name:i.data.type})?a=i.data.type:"automatic"===i.data.type&&mt.default.findWhere(ei,{name:i.data.options.group})&&(a=i.data.options.group)}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0})}).always(()=>{this.setState({templates:this.templates,emailType:e,emailOptions:t,selectedTab:a,loading:!1})})}afterTemplateDelete(e,t){e&&Object.keys(this.templates).forEach(e=>{this.templates[e]=this.templates[e].filter(e=>e.id!==t)}),this.setState({templates:this.templates,loading:!1})}afterTemplateSelect(e,t){e?window.location=(e=>{const t=new URLSearchParams(window.location.search).get("context"),a=`admin.php?page=mailpoet-newsletter-editor&id=${e}`;return t?`${a}&context=${t}`:a})(t):this.setState({loading:!1})}afterTemplateImport(e,t){e&&this.addTemplate(t),this.setState({templates:this.templates,selectedTab:e?"saved":"import",loading:!1})}render(){if(this.state.loading)return(0,g.jsx)(Pt.R,{});const e=ei.concat({name:"import",label:(0,p._x)("Import","Importing template tab title","mailpoet")}).map(e=>Object.assign(e,{automationId:`templates-${e.name.replace(/\s+/g,"-").toLowerCase()}`}));let t=null;if("import"===this.state.selectedTab)t=(0,g.jsx)(Za,{beforeImport:()=>this.setState({loading:!0}),afterImport:this.afterTemplateImport});else{let e=this.state.templates[this.state.selectedTab]||[];e=0===e.length?this.state.loading?null:(0,g.jsx)("p",{children:(0,p.__)("This category does not contain any template yet!","mailpoet")}):e.map((e,t)=>(0,g.jsx)(Ja,{index:t,newsletterId:this.props.params.id,beforeDelete:()=>this.setState({loading:!0}),afterDelete:this.afterTemplateDelete,beforeSelect:()=>this.setState({loading:!0}),afterSelect:this.afterTemplateSelect,id:e.id,name:e.name,thumbnail:e.thumbnail,readonly:e.readonly},e.id)),t=e}let a,i=null;if(Xa.Ls.includes(this.state.emailType)){const e=this.state.emailOptions?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"admin.php?page=mailpoet-automation";a=()=>{window.location=t},i=(0,g.jsx)("input",{type:"button",className:"button link-button",onClick:a,value:"Cancel"})}return(0,g.jsxs)("div",{children:[(0,g.jsx)(Ga,{emailType:this.state.emailType,automationId:"email_template_selection_heading",buttons:i,onLogoClick:a}),(0,g.jsxs)("div",{className:"mailpoet-templates",children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Va.L,{categories:e,active:this.state.selectedTab,onSelect:e=>this.setState({selectedTab:e})})}),(0,g.jsx)(o.ErrorBoundary,{children:t})]})]})}}ti.contextType=l.F,ti.propTypes={params:rt().shape({id:rt().string}).isRequired};var ai=a(35558),ii=a.n(ai),si=a(29065),ni=a.n(si),ri=a(69308),oi=a(76056);const li={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function di(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const ci={date:di({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:di({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:di({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},mi={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function ui(e){return(t,a)=>{let i;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;i=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;i=e.values[s]||e.values[t]}return i[e.argumentCallback?e.argumentCallback(t):t]}}function pi(e){return(t,a={})=>{const i=a.width,s=i&&e.matchPatterns[i]||e.matchPatterns[e.defaultMatchWidth],n=t.match(s);if(!n)return null;const r=n[0],o=i&&e.parsePatterns[i]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let a=0;ae.test(r)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a}(o,e=>e.test(r));let d;return d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d,{value:d,rest:t.slice(r.length)}}}var hi;const gi={code:"en-US",formatDistance:(e,t,a)=>{let i;const s=li[e];return i="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+i:i+" ago":i},formatLong:ci,formatRelative:(e,t,a,i)=>mi[e],localize:{ordinalNumber:(e,t)=>{const a=Number(e),i=a%100;if(i>20||i<10)switch(i%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:ui({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:ui({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:ui({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:ui({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:ui({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(hi={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const a=e.match(hi.matchPattern);if(!a)return null;const i=a[0],s=e.match(hi.parsePattern);if(!s)return null;let n=hi.valueCallback?hi.valueCallback(s[0]):s[0];return n=t.valueCallback?t.valueCallback(n):n,{value:n,rest:e.slice(i.length)}}),era:pi({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:pi({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:pi({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:pi({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:pi({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},_i=gi;var fi=a(78169);function bi(e){return(t,a)=>{let i;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;i=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;i=e.values[s]||e.values[t]}return i[e.argumentCallback?e.argumentCallback(t):t]}}const xi={abbreviated:[(0,p.__)("Jan","mailpoet"),(0,p.__)("Feb","mailpoet"),(0,p.__)("Mar","mailpoet"),(0,p.__)("Apr","mailpoet"),(0,p.__)("May","mailpoet"),(0,p.__)("Jun","mailpoet"),(0,p.__)("Jul","mailpoet"),(0,p.__)("Aug","mailpoet"),(0,p.__)("Sep","mailpoet"),(0,p.__)("Oct","mailpoet"),(0,p.__)("Nov","mailpoet"),(0,p.__)("Dec","mailpoet")],wide:[(0,p.__)("January","mailpoet"),(0,p.__)("February","mailpoet"),(0,p.__)("March","mailpoet"),(0,p.__)("April","mailpoet"),(0,p.__)("May","mailpoet"),(0,p.__)("June","mailpoet"),(0,p.__)("July","mailpoet"),(0,p.__)("August","mailpoet"),(0,p.__)("September","mailpoet"),(0,p.__)("October","mailpoet"),(0,p.__)("November","mailpoet"),(0,p.__)("December","mailpoet")]},vi={narrow:[(0,p._x)("S","Sunday - one letter abbreviation","mailpoet"),(0,p._x)("M","Monday - one letter abbreviation","mailpoet"),(0,p._x)("T","Tuesday - one letter abbreviation","mailpoet"),(0,p._x)("W","Wednesday - one letter abbreviation","mailpoet"),(0,p._x)("T","Thursday - one letter abbreviation","mailpoet"),(0,p._x)("F","Friday - one letter abbreviation","mailpoet"),(0,p._x)("S","Saturday - one letter abbreviation","mailpoet")],abbreviated:[(0,p.__)("Sun","mailpoet"),(0,p.__)("Mon","mailpoet"),(0,p.__)("Tue","mailpoet"),(0,p.__)("Wed","mailpoet"),(0,p.__)("Thu","mailpoet"),(0,p.__)("Fri","mailpoet"),(0,p.__)("Sat","mailpoet")],wide:[(0,p.__)("Sunday","mailpoet"),(0,p.__)("Monday","mailpoet"),(0,p.__)("Tuesday","mailpoet"),(0,p.__)("Wednesday","mailpoet"),(0,p.__)("Thursday","mailpoet"),(0,p.__)("Friday","mailpoet"),(0,p.__)("Saturday","mailpoet")]};_i.localize.month=bi({values:xi,defaultWidth:"wide"}),_i.localize.day=bi({values:vi,defaultWidth:"wide"}),_i.options.weekStartsOn=void 0!==m.U.wpWeekStartsOn?m.U.wpWeekStartsOn:1,(0,oi.registerLocale)("mailpoet",_i);class yi extends r.Component{onChange=(e,t)=>{const a=t,i=this.getAsStringInFormat(e);a.target.name=this.getFieldName(),a.target.value=i,this.props.onChange(a)};getFieldName=()=>this.props.name||"date";getDate=e=>et()(e).toDate();getAsStringInFormat=e=>et()(e).format(m.U.Date.convertFormat(this.props.storageFormat));render(){return(0,g.jsx)(fi.t,{name:this.getFieldName(),selected:this.getDate(this.props.value),formatWithWordPressSettings:!0,disabled:this.props.disabled,onChange:this.onChange,minDate:this.getDate(window.mailpoet_current_date),maxDate:this.props.maxDate,locale:"mailpoet",...this.props.validation})}}class ji extends r.Component{render(){const{onChange:e,timeOfDayItems:t,value:a,disabled:i=!1,name:s="time",validation:n={}}=this.props,r=Object.keys(t).map(e=>(0,g.jsx)("option",{value:e,children:t[e]},`option-${t[e]}`)),o=Object.keys(t),l=a&&!o.includes(a),d=a.lastIndexOf(":"),c=d>0?a.slice(0,d):a,m=l?(0,g.jsx)("option",{value:a,children:c}):null;return(0,g.jsxs)(ut.Select,{name:s||"time",value:a,disabled:i,onChange:e,isMinWidth:!0,...n,children:[m,r]})}}ji.propTypes={timeOfDayItems:rt().objectOf(rt().string).isRequired,name:rt().string,value:rt().string.isRequired,disabled:rt().bool,onChange:rt().func.isRequired,validation:rt().object},ji.displayName="TimeSelect";class wi extends r.Component{DATE_TIME_SEPARATOR=" ";constructor(e){super(e),this.state=this.buildStateFromProps(e)}componentDidUpdate(e){this.props.value===e.value&&this.props.defaultDateTime===e.defaultDateTime||st()(()=>{this.setState(this.buildStateFromProps(this.props))})}getDateTime=()=>{const e=[this.state.date,this.state.time].join(this.DATE_TIME_SEPARATOR);return m.U.Date.toGmtDatetimeString(e)};buildStateFromProps=e=>{const t=e.value||this.props.defaultDateTime,a=m.U.Date.datetimeString(t),[i,s]=a.split(this.DATE_TIME_SEPARATOR);return{date:i,time:s}};handleChange=e=>{const t={};t[e.target.name]=e.target.value,this.setState(t,this.propagateChange)};propagateChange=()=>{this.props.onChange&&this.props.onChange({target:{name:this.props.name||"",value:this.getDateTime()}})};render(){return(0,g.jsx)(ri.Grid.Column,{className:"mailpoet-datetime-container",children:(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(yi,{name:"date",value:this.state.date,onChange:this.handleChange,storageFormat:this.props.dateStorageFormat,disabled:this.props.disabled,validation:this.props.dateValidation,maxDate:this.props.maxDate}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(ji,{name:"time",value:this.state.time,onChange:this.handleChange,disabled:this.props.disabled,timeOfDayItems:this.props.timeOfDayItems})]})})}}var Si=a(88516),Ni=a(34599),ki=a(98933);class Ci extends r.Component{constructor(e){super(e);const t=(0,ki.Y8)(e.item.sender_address);this.state={emailAddress:e.item.sender_address,showSenderDomainWarning:!window.mailpoet_sender_restrictions?.skipAuthorization&&!window.mailpoet_verified_sender_domains.includes(t),isPartiallyVerifiedDomain:window.mailpoet_partially_verified_sender_domains.includes(t),showAuthEmailsError:!1},this.onChange=this.onChange.bind(this),this.onBlur=this.onBlur.bind(this),window.mailpoet_sender_address_field_blur=this.onBlur;const a=e.field.id||`field_${e.field.name}`;this.domElementSelector=`#${a}`,this.parsleyFieldName="invalidFromAddress"}componentDidMount(){this.validateEmailAddress()}onChange(e){const{onValueChange:t=()=>{}}=this.props,a=e.target.value.toLowerCase();this.setState({emailAddress:a}),t({...e,target:{...e.target,name:e.target.name,value:a}}),this.setState({showAuthEmailsError:!1,showSenderDomainWarning:!1}),(0,Ni.SB)(this.domElementSelector,this.parsleyFieldName)}onBlur(){this.validateEmailAddress()}isEmailAddressAuthorized=e=>(window.mailpoet_authorized_emails||[]).includes(e);showInvalidFromAddressError=()=>{(0,Ni.oI)(this.domElementSelector,this.parsleyFieldName," "),this.setState({showAuthEmailsError:!0})};showSenderFieldError=(e,t)=>{window.mailpoet_mss_active&&((0,Ni.SB)(this.domElementSelector,this.parsleyFieldName),(0,Ni.vg)(this.domElementSelector)?e?this.showSenderDomainError(!0):this.showInvalidFromAddressError(t):(0,Ni.jr)(this.domElementSelector))};showSenderDomainError=e=>{e&&this.setState({showSenderDomainWarning:!0})};validateEmailAddress(){if(!window.mailpoet_mss_active)return;if(window.mailpoet_sender_restrictions?.skipAuthorization)return;const e=this.state.emailAddress,t=(0,ki.Y8)(e);if(window.mailpoet_verified_sender_domains.includes(t))return;const a=this.isEmailAddressAuthorized(e);this.showSenderFieldError(a,e),this.setState({isPartiallyVerifiedDomain:window.mailpoet_partially_verified_sender_domains.includes(t)})}render(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(lt,{item:{...this.props.item,sender_address:this.state.emailAddress},field:this.props.field,onValueChange:this.onChange,onBlurEvent:this.onBlur}),(0,g.jsx)("div",{className:"regular-text regular-text-full-width",children:(0,g.jsx)(Si.Y,{emailAddress:this.state.emailAddress,mssActive:window.mailpoet_mss_active,isEmailAuthorized:!this.state.showAuthEmailsError,showSenderDomainWarning:this.state.showSenderDomainWarning&&!this.state.showAuthEmailsError,isPartiallyVerifiedDomain:this.state.isPartiallyVerifiedDomain,senderRestrictions:window.mailpoet_sender_restrictions,onSuccessfulEmailOrDomainAuthorization:e=>{"email"===e.type&&(this.setState({showAuthEmailsError:!1}),m.U.trackEvent("MSS in plugin authorize email",{"authorized email source":"newsletter",wasSuccessful:"yes"})),"domain"===e.type&&(this.setState({showSenderDomainWarning:!1}),this.setState({isPartiallyVerifiedDomain:!1}),m.U.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"newsletter",wasSuccessful:"yes"})),(0,Ni.SB)(this.domElementSelector,this.parsleyFieldName)}})})]})}}Ci.propTypes={field:rt().object.isRequired,item:rt().shape({sender_address:rt().string.isRequired}).isRequired,onValueChange:rt().func},Ci.displayName="SenderField";const Ii=mt.default.once(()=>m.U.trackEvent("User has typed a GA campaign name")),Ui=at()((0,p.__)("For example, “Spring email”. [link]Read the guide.[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsxs)("span",{children:[(0,g.jsx)("br",{}),(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/187-track-newsletters-subscribers-in-google-analytics",target:"_blank",rel:"noopener noreferrer",className:"mailpoet-link",children:e})]},t)),Ei={name:"ga_campaign",label:(0,p.__)("Google Analytics Campaign","mailpoet"),tip:Ui,type:"text",onBeforeChange:Ii};var Ai=a(8872),Ti=a(94667),Ri=a(6548),Pi=a(24683),Di=a(66880);const Oi={saveDraftNewsletter:()=>Promise.resolve()},Fi=r.createContext(Oi);var Mi=a(58270);function Li(e,t){return`segments:${e.join(",")}|filterSegmentId:${t}`}const $i=[{name:"segments",label:(0,p.__)("Send to","mailpoet"),type:"selection",placeholder:(0,p.__)("Choose","mailpoet"),id:"mailpoet_segments",api_version:window.mailpoet_api_version,endpoint:"segments",multiple:!0,filter:function(e){return!e?.deleted_at},getLabel:function(e){return e.name},getCount:function(e){return parseInt(e.subscribers,10).toLocaleString()},transformChangedValue:function(e){const t=this.getItems()||[];return e.map(e=>t.find(t=>t.id===e))},validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please select a list","mailpoet"),"data-parsley-segments-with-subscribers":(0,p.__)("Please select a list with subscribers.","mailpoet")}},{name:"filter-segment-toggle",type:"reactComponent",component:(0,o.withBoundary)(function({item:e,onValueChange:t,field:a}){const i=e?.options.filterSegmentId,[s,n]=(0,r.useState)(Ri.d&&!!i),l=(0,r.useCallback)(a=>{t({target:{name:"options",value:{...e?.options??{},filterSegmentId:a}}})},[e,t]),d=(0,r.useContext)(Fi);(0,r.useEffect)(()=>{Ri.d||""===i||l("")},[l,i]);const c=(0,r.useCallback)(i=>{t({target:{name:a.name,value:i}}),i||l(""),n(i),m.U.trackEvent("Emails > Filter by segment toggled",{"Email type":e.type})},[a,t,l,e]);let u;if(s){const t={name:"filter-segment",type:"selection",placeholder:(0,p.__)("Choose","mailpoet"),id:"mailpoetFilterSegment",api_version:window.mailpoet_api_version,endpoint:"segments",multiple:!1,forceSelect2:!0,selected:e=>e.options.filterSegmentId,filter:function(e){return!e.deleted_at&&"dynamic"===e.type},getLabel:function(e){return e.name},getCount:function(e){return parseInt(e.subscribers,10).toLocaleString()},validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please select a filter segment","mailpoet")}};u=(0,g.jsx)(De.L,{item:e,field:t,onValueChange:t=>{l(t.target.value),m.U.trackEvent("Emails > Filter by segment selected",{"Email type":e.type})}})}const h=`admin.php?page=mailpoet-segments#/new-segment?newsletterId=${e.id}`;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.Toggle,{checked:s,disabled:a.disabled,name:"isFilterSegmentEnabled",onCheck:c,automationId:"filter-segment-toggle"}),(0,g.jsxs)("span",{className:"mailpoet-form-toggle-text",children:[(0,p.__)("Filter by segment","mailpoet"),(0,g.jsx)(Da.A,{"data-tip":!0,"data-tooltip-id":"filter-segment-tooltip",className:"filter-segment-tooltip",icon:Di.A})]}),(0,g.jsx)(Pi.m,{place:"right",id:"filter-segment-tooltip",children:(0,g.jsx)("div",{children:(0,p.__)("Subscribers selected in 'Send to' will only receive an email if they also belong to this segment.","mailpoet")})}),(0,g.jsx)("div",{className:"mailpoet-gap"}),u,s&&(0,g.jsx)("p",{children:at()((0,p.__)("Can't find the segment you're looking for? [link]Create new[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,(t,a)=>(0,g.jsx)("a",{className:"mailpoet-link",rel:"noopener noreferrer",onClick:async t=>{t.preventDefault(),m.U.trackEvent("Emails > Create new segment clicked",{"Email type":e.type}),await d.saveDraftNewsletter(),window.location.href=h},href:h,children:t},a))})]})})}],Wi={name:"recipient-count",type:"reactComponent",component:(0,o.withBoundary)(function(e){const[t,a]=(0,r.useState)(!0),[i,s]=(0,r.useState)(0),n=(0,r.useMemo)(()=>(e.item.segments||[]).map(e=>e.id),[e.item.segments]),o=(0,r.useMemo)(()=>e.item.options?.filterSegmentId||null,[e.item.options?.filterSegmentId]),l=(0,r.useRef)(""),d=(0,r.useRef)({});return(0,r.useEffect)(()=>{const e=Li(n,o);return l.current=e,n.length<1?(s(0),void a(!1)):e in d.current?(s(d.current[e]),void a(!1)):(a(!0),void m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"subscriberCount",data:{segmentIds:n,filterSegmentId:o}}).done(t=>{const a=t.data.count;d.current[e]=a;const i=Li(n,o);l.current===i&&s(a)}).always(()=>a(!1)))},[n,o]),(0,g.jsxs)("div",{children:[(0,p.__)("Estimated recipients","mailpoet"),":",t&&(0,g.jsx)(Mi.Ay,{className:"mailpoet-recipient-count-spinner"}),!t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Pi.m,{place:"right",id:"estimated-count-tooltip",children:(0,p.__)("This count may change at the time of sending.","mailpoet")}),(0,g.jsx)("span",{"data-tip":!0,"data-tooltip-id":"estimated-count-tooltip",className:"estimated-recipient-count",children:i.toLocaleString()})]})]})})},Bi={name:"send-to",label:(0,p.__)("Send to","mailpoet"),tip:(0,p.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:$i},qi={name:"send-to",label:(0,p.__)("Send to","mailpoet"),tip:(0,p.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:[...$i,Wi]},Hi=`${window.mailpoet_tomorrow_date} 08:00:00`,zi=m.U.Date.toGmtDatetimeString(Hi),Vi=window.mailpoet_schedule_time_of_day,Yi=window.mailpoet_date_storage_format;class Gi extends r.Component{getCurrentValue=()=>({isScheduled:"0",scheduledAt:zi,...this.props.item?.[this.props.field.name]??{}});getDateValidation=()=>({"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please enter the scheduled date.","mailpoet"),"data-parsley-errors-container":"#mailpoet_scheduling"});isScheduled=()=>"1"===this.getCurrentValue().isScheduled;handleCheckboxChange=(e,t)=>{const a={...t};a.target.value=t.target.checked?"1":"0",this.handleValueChange(a)};handleValueChange=e=>{const t=this.getCurrentValue(),a={};a[e.target.name]=e.target.value,this.props.onValueChange({target:{name:this.props.field.name,value:{...t,...a}}})};render(){let e;const t=new Date;return t.setFullYear(t.getFullYear()+5),this.isScheduled()&&(e=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("span",{className:"mailpoet-form-schedule-time",children:[(0,p.__)("Your website’s time is","mailpoet")," ",m.U.Date.time(new Date)]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{id:"mailpoet_scheduling",children:(0,g.jsx)(wi,{name:"scheduledAt",value:this.getCurrentValue().scheduledAt,onChange:this.handleValueChange,disabled:this.props.field.disabled,dateValidation:this.getDateValidation(),defaultDateTime:zi,timeOfDayItems:Vi,dateStorageFormat:Yi,maxDate:t})})]})),(0,g.jsxs)("div",{children:[(0,g.jsx)(Ai.l,{checked:this.isScheduled(),disabled:this.props.field.disabled,name:"isScheduled",onCheck:this.handleCheckboxChange,automationId:"email-schedule-checkbox"}),e]})}}let Ki=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},qi,{name:"options",label:(0,p.__)("Schedule it","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(Gi)},{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Ci),placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ei,{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Ki=aa.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Ki);const Qi={getFields:()=>Ki,getSendButtonOptions:(e={})=>{const t={value:"object"==typeof e.options&&"1"===e.options?.isScheduled&&m.U.Date.isInFuture(e.options?.scheduledAt,new Date)?(0,p.__)("Schedule","mailpoet"):(0,p.__)("Send","mailpoet")};return e.status!==Ti.um.Sent&&e.status!==Ti.um.Sending||(t.disabled="disabled"),t}},Ji=window.mailpoet_time_format||"H:i",Zi={immediate:(0,p.__)("immediately","mailpoet"),minutes:(0,p.__)("minute(s) later","mailpoet"),hours:(0,p.__)("hour(s) later","mailpoet"),days:(0,p.__)("day(s) later","mailpoet"),weeks:(0,p.__)("week(s) later","mailpoet")},Xi={daily:(0,p.__)("Once a day at...","mailpoet"),weekly:(0,p.__)("Weekly on...","mailpoet"),monthly:(0,p.__)("Monthly on the...","mailpoet"),nthWeekDay:(0,p.__)("Monthly every...","mailpoet"),immediately:(0,p.__)("Immediately","mailpoet")},es=mt.default.object(mt.default.map(mt.default.times(96,e=>900*e),e=>{const t=new Date(null);return t.setSeconds(e),[e,m.U.Date.format(t,{format:Ji,offset:0})]})),ts={0:(0,p.__)("Sunday","mailpoet"),1:(0,p.__)("Monday","mailpoet"),2:(0,p.__)("Tuesday","mailpoet"),3:(0,p.__)("Wednesday","mailpoet"),4:(0,p.__)("Thursday","mailpoet"),5:(0,p.__)("Friday","mailpoet"),6:(0,p.__)("Saturday","mailpoet")},as=mt.default.object(mt.default.map(mt.default.times(28,e=>e),e=>{const t={0:(0,p.__)("1st","mailpoet"),1:(0,p.__)("2nd","mailpoet"),2:(0,p.__)("3rd","mailpoet")};let a;return a=void 0!==t[e]?t[e]:(0,p.__)("%1$dth","mailpoet").replace("%1$d",e+1),[e+1,a]})),is={1:(0,p.__)("1st","mailpoet"),2:(0,p.__)("2nd","mailpoet"),3:(0,p.__)("3rd","mailpoet"),4:(0,p.__)("4th","mailpoet"),L:(0,p._x)("last","e.g. monthly every last Monday","mailpoet")},ss="1",ns=["0","1","2","3","4","5","6"],rs=e=>[...e].sort((e,t)=>Number(e)-Number(t)),os=e=>null==e?"":String(e).trim(),ls=e=>{const t=os(e);return ns.includes(t)?t:ss},ds=e=>{const t=ls(e),a=ns.indexOf(t);return[...ns.slice(a),...ns.slice(0,a)]},cs=(e,t,a)=>{const i=Object.keys(a),s=os(e).split(",").map(e=>e.trim()).filter(e=>i.includes(e));return 0===s.length?[t]:rs([...new Set(s)])},ms=e=>rs(e).join(","),us=(e,t,a,i=rs(Object.keys(t)))=>((e,t)=>[...e].sort((e,a)=>{const i=t.indexOf(e),s=t.indexOf(a);return-1===i||-1===s?Number(e)-Number(a):i-s}))(cs(e,a,t),i).map(e=>t[e]).join(", "),ps={name:"intervalType",values:Xi},hs={name:"timeOfDay",values:es},gs={name:"weekDay",values:ts},_s={name:"nthWeekDay",values:is},fs=e=>4===e?"mailpoet-grid-four-columns":"mailpoet-grid-three-columns";function bs({name:e,values:t,selectedValues:a,onValueChange:i,automationId:s,columns:n,valueOrder:r}){const o=a.map(e=>`${e}`),l=r||Object.keys(t);return(0,g.jsx)("div",{className:fs(n),children:l.map(a=>(0,g.jsx)("span",{children:(0,g.jsx)(_t.S,{name:e,value:a,checked:o.includes(a),onCheck:e=>{let t=o;e?t=[...o,a]:o.length>1&&(t=o.filter(e=>e!==a)),i(ms(t))},automationId:`${s}_${a}`,children:t[a]})},`${e}-${a}`))})}bs.propTypes={name:rt().string.isRequired,values:rt().objectOf(rt().string).isRequired,selectedValues:rt().arrayOf(rt().string).isRequired,onValueChange:rt().func.isRequired,automationId:rt().string.isRequired,columns:rt().oneOf([3,4]).isRequired,valueOrder:rt().arrayOf(rt().string)};class xs extends r.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};getDefaultWeekDay=()=>ls(m.U.wpWeekStartsOn);getOrderedWeekDayKeys=()=>ds(m.U.wpWeekStartsOn);handleValueChanges=e=>{const t=this.getCurrentValue();return this.props.onValueChange({target:{name:this.props.field.name,value:mt.default.extend({},t,e)}})};handleIntervalChange=e=>{const t=e.target.value,a=this.getCurrentValue(),i={};i.intervalType=t,"monthly"===t&&(i.monthDay=ms(cs(a.monthDay,ss,as))),"weekly"===t&&(i.weekDay=ms(cs(a.weekDay,this.getDefaultWeekDay(),ts))),"nthWeekDay"===t&&(i.weekDay=((e,t)=>cs(e,t,ts)[0])(a.weekDay,this.getDefaultWeekDay()),i.nthWeekDay=a.nthWeekDay||ss),this.handleValueChanges(i)};handleTimeOfDayChange=e=>this.handleValueChanges({timeOfDay:e.target.value});handleWeekDayChange=e=>this.handleValueChanges({weekDay:e.target.value});handleWeekDaysChange=e=>this.handleValueChanges({weekDay:e});handleMonthDaysChange=e=>this.handleValueChanges({monthDay:e});handleNthWeekDayChange=e=>this.handleValueChanges({nthWeekDay:e.target.value});render(){const e=this.getCurrentValue(),t=this.getDefaultWeekDay(),a=this.getOrderedWeekDayKeys(),i={...gs,sortBy:e=>a.indexOf(e)};let s,n,r,o;return"immediately"!==e.intervalType&&(n=(0,g.jsx)(pt,{field:hs,item:this.getCurrentValue(),onValueChange:this.handleTimeOfDayChange})),"weekly"===e.intervalType&&(s=(0,g.jsx)(bs,{name:"weekDay",values:ts,selectedValues:cs(e.weekDay,t,ts),onValueChange:this.handleWeekDaysChange,automationId:"newsletter_week_day",columns:3,valueOrder:a})),"nthWeekDay"===e.intervalType&&(r=(0,g.jsx)(pt,{field:i,item:this.getCurrentValue(),onValueChange:this.handleWeekDayChange})),"monthly"===e.intervalType&&(s=(0,g.jsx)(bs,{name:"monthDay",values:as,selectedValues:cs(e.monthDay,ss,as),onValueChange:this.handleMonthDaysChange,automationId:"newsletter_month_day",columns:4})),"nthWeekDay"===e.intervalType&&(o=(0,g.jsx)(pt,{field:_s,item:this.getCurrentValue(),onValueChange:this.handleNthWeekDayChange})),(0,g.jsxs)("div",{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsx)(pt,{field:ps,item:this.getCurrentValue(),onValueChange:this.handleIntervalChange,automationId:"newsletter_interval_type"}),"immediately"===e.intervalType&&(0,g.jsx)("div",{children:(0,g.jsx)("p",{children:(0,p.__)("after publishing a post","mailpoet")})})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),s&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-grid-column",children:s}),(0,g.jsx)("div",{className:"mailpoet-gap"})]}),(0,g.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[o,r,n]}),"immediately"!==e.intervalType&&(0,g.jsx)("div",{className:"mailpoet-gap"})]})}}xs.propTypes={item:rt().object.isRequired,field:rt().shape({name:rt().string}).isRequired,onValueChange:rt().func.isRequired};let vs=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,p.__)("Select a frequency","mailpoet"),type:"reactComponent",component:xs},qi,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Ci),placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ei,{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];vs=aa.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",vs);const ys={getFields:function(){return vs},getSendButtonOptions:function(){return{value:(0,p.__)("Activate","mailpoet")}}},js=window.mailpoet_roles||{},ws=mt.default.filter(window.mailpoet_segments||[],e=>"default"===e.type),Ss={name:"event",values:{segment:(0,p.__)("When someone subscribes to the list...","mailpoet"),user:(0,p.__)("When a new WordPress user is added to your site...","mailpoet")}},Ns={name:"segment",placeholder:(0,p.__)("Select a list","mailpoet"),forceSelect2:!0,values:ws,getCount:e=>parseInt(e.subscribers,10).toLocaleString(),getLabel:e=>e.name,getValue:e=>e.id},ks={name:"role",values:js},Cs={name:"afterTimeNumber",size:3,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,p.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},Is={name:"afterTimeType",values:Zi};class Us extends r.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};handleValueChange=(e,t)=>{const a=this.getCurrentValue(),i={};let s=t;return"afterTimeNumber"===e&&(s=parseInt(t,10),s=Number.isNaN(s)?"":s),i[e]=s,this.props.onValueChange({target:{name:this.props.field.name,value:mt.default.extend({},a,i)}})};handleEventChange=e=>this.handleValueChange("event",e.target.value);handleSegmentChange=e=>this.handleValueChange("segment",e.target.value);handleRoleChange=e=>this.handleValueChange("role",e.target.value);handleAfterTimeNumberChange=e=>this.handleValueChange("afterTimeNumber",e.target.value);handleAfterTimeTypeChange=e=>this.handleValueChange("afterTimeType",e.target.value);render(){const e=this.getCurrentValue();let t,a;return t="user"===e.event?(0,g.jsx)(pt,{field:ks,item:this.getCurrentValue(),onValueChange:this.handleRoleChange}):(0,g.jsx)(De.L,{field:Ns,item:this.getCurrentValue(),onValueChange:this.handleSegmentChange}),"immediate"!==e.afterTimeType&&(a=(0,g.jsx)(lt,{field:Cs,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeNumberChange})),(0,g.jsxs)("div",{children:[(0,g.jsx)(pt,{field:Ss,item:this.getCurrentValue(),onValueChange:this.handleEventChange}),(0,g.jsx)("div",{className:"mailpoet-gap"}),t,(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[a,(0,g.jsx)(pt,{field:Is,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeTypeChange})]}),(0,g.jsx)("div",{className:"mailpoet-form-errors"}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})}}Us.propTypes={item:rt().object.isRequired,field:rt().shape({name:rt().string}).isRequired,onValueChange:rt().func.isRequired},Us.displayName="WelcomeScheduling";let Es=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,p.__)("When to send this welcome email?","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(Us)},Ei,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Ci),placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Es=aa.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Es);const As={getFields:function(){return Es},getSendButtonOptions:function(){return{value:(0,p.__)("Activate","mailpoet")}}},Ts=3;class Rs extends r.Component{constructor(e){super(e);const{item:t,event:a}=this.props;this.handleChange=this.handleChange.bind(this);const i=t.afterTimeType||a.defaultAfterTimeType||"immediate",s="minutes"===i?30:1,n=t.afterTimeNumber||s;this.state={afterTimeType:i,afterTimeNumber:n},t.afterTimeNumber===n&&t.afterTimeType===i||this.propagateChange(this.state)}handleChange(e,t){let{value:a}=e.target;"afterTimeNumber"===t&&(a=parseInt(e.target.value,10),a=Number.isNaN(a)?null:a);const i={[t]:a},{afterTimeType:s}=this.state;"afterTimeType"===t&&s!==a&&("minutes"===s&&(i.afterTimeNumber=1),"minutes"===a&&(i.afterTimeNumber=30)),this.setState(i,this.propagateChange(i))}displayAfterTimeTypeOptions(){const{event:e}=this.props;let t=Zi;e.timeDelayValues&&(t=Object.entries(e.timeDelayValues).reduce((e,[t,a])=>(e[t]=a.text,e),{}));const{afterTimeType:a}=this.state,i={field:{id:"scheduling_time_interval",name:"scheduling_time_interval",forceSelect2:!0,values:mt.default.map(t,(e,t)=>({name:e,id:t})),extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>a},onValueChange:mt.default.partial(this.handleChange,mt.default,"afterTimeType")};return(0,g.jsx)(De.L,{field:i.field,onValueChange:i.onValueChange})}displayAfterTimeNumberField(){const{event:e,afterTimeNumberSize:t=Ts}=this.props,{afterTimeType:a,afterTimeNumber:i}=this.state;if("immediate"===a)return null;if(e.timeDelayValues&&e.timeDelayValues[a]&&!e.timeDelayValues[a].displayAfterTimeNumberField)return null;const s={field:{id:"scheduling_time_duration",name:"scheduling_time_duration",className:"mailpoet-form-input-small",defaultValue:i?i.toString():"",size:t,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,p.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},item:{},onValueChange:mt.default.partial(this.handleChange,mt.default,"afterTimeNumber")};return(0,g.jsx)(lt,{field:s.field,item:s.item,onValueChange:s.onValueChange})}propagateChange(e){const{onValueChange:t=null}=this.props;t&&t(e)}render(){const{event:e}=this.props;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("h4",{children:[" ",(0,p.__)("When to send this email?","mailpoet")," "]}),(0,g.jsxs)(ri.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[this.displayAfterTimeNumberField(),this.displayAfterTimeTypeOptions(),e.afterDelayText&&(0,g.jsx)("p",{children:e.afterDelayText})]}),(0,g.jsx)("div",{className:"mailpoet-form-errors"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),e.schedulingReadMoreLink&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("a",{href:e.schedulingReadMoreLink.link,target:"_blank",rel:"noopener noreferrer",className:"event-scheduling-read-more-link",children:e.schedulingReadMoreLink.text}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})]})}}function Ps(e){const t=e&&e.values?e.values:[];return t?t.map(e=>({id:e.id,name:e.name})):t}function Ds({eventOptions:e,eventSlug:t,selected:a,onValueChange:i}){function s(e){i&&i({eventOptionValue:e.target.value})}return(0,g.jsx)("div",{children:(0,g.jsx)("div",{className:"event-option-selection",children:function(){if(!e)return null;const i={field:{name:`event_options_${t}`,forceSelect2:!0,endpoint:e.endpoint,resetSelect2OnUpdate:!0,values:Ps(e),multiple:e.multiple||!1,placeholder:e.placeholder||!1,transformChangedValue:(e,t)=>mt.default.map(t,e=>({id:e.id,name:e.text})),selected:()=>a,getLabel:mt.default.property("name"),getValue:mt.default.property("id"),validation:{"data-parsley-required":!0}},onValueChange:s,item:{action:""}};return"product_categories"===e.endpoint&&(i.field.name="category_ids",i.item={action:"purchasedCategory"}),"products"===e.endpoint&&(i.field.name="product_ids",i.item={action:"purchasedProduct"}),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(De.L,{field:i.field,onValueChange:i.onValueChange,item:i.item}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})}()})})}Rs.propTypes={item:rt().shape({afterTimeType:rt().string.isRequired,afterTimeNumber:rt().number}).isRequired,afterTimeNumberSize:rt().number,onValueChange:rt().func,event:rt().shape({defaultAfterTimeType:rt().string,afterDelayText:rt().string,timeDelayValues:rt().objectOf(rt().shape({text:rt().string,displayAfterTimeNumberField:rt().bool})),schedulingReadMoreLink:rt().shape({link:rt().string.isRequired,text:rt().string.isRequired})}).isRequired},Rs.displayName="EventScheduling",Ds.displayName="EventOptions";const Os=(0,o.withBoundary)(Ds);class Fs extends r.Component{constructor(e){super(e);const{field:t}=e;this.handleChange=this.handleChange.bind(this),this.email=t.email,this.emailOptions=t.emailOptions,this.events=mt.default.indexBy(this.email.events,"slug"),this.segments=mt.default.filter(window.mailpoet_segments,e=>null===e.deleted_at);const a=this.events[this.emailOptions.event],i=this.emailOptions.afterTimeType||a.defaultAfterTimeType||"immediate";this.state={event:a,afterTimeType:i,eventSlug:this.emailOptions.event,eventOptionValue:null,afterTimeNumber:this.emailOptions.afterTimeNumber||1,segment:this.emailOptions.segment?this.emailOptions.segment:null}}handleChange(e){const{afterTimeNumber:t}=this.state,a=e;a.afterTimeType&&"immediate"===a.afterTimeType?a.afterTimeNumber=null:!a.afterTimeType||a.afterTimeNumber||t||(a.afterTimeNumber=1),this.setState(e,this.propagateChange)}displayScheduling(){const{afterTimeNumber:e,afterTimeType:t,event:a}=this.state,i={item:{afterTimeNumber:e,afterTimeType:t},event:a,onValueChange:this.handleChange};return(0,g.jsx)(Rs,{item:i.item,event:i.event,onValueChange:i.onValueChange})}displaySegments(){const{segment:e}=this.state;if("user"===this.emailOptions.sendTo)return null;const t={field:{id:"segments",forceSelect2:!0,values:this.segments,extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>e},onValueChange:e=>this.handleChange({segment:e.target.value})};return(0,g.jsx)("div",{className:"event-segment-selection",children:(0,g.jsx)(De.L,{field:t.field,onValueChange:t.onValueChange})})}displayEventOptions(){const{event:e,eventSlug:t}=this.state;let a;try{a=JSON.parse(this.emailOptions.meta||null)}catch(e){a=this.emailOptions.meta||null}const i={emailSlug:this.email.slug,eventSlug:t,onValueChange:this.handleChange,eventOptions:e.options||null};return a&&a.option&&("remote"===i.eventOptions.type&&(i.eventOptions.values=a.option),i.selected=mt.default.map(a.option,e=>e.id)),(0,g.jsx)(Os,{emailSlug:i.emailSlug,eventSlug:i.eventSlug,eventOptions:i.eventOptions,onValueChange:i.onValueChange,selected:i.selected})}displayHeader(){const{event:e}=this.state;return e.title}propagateChange(){const{eventSlug:e,afterTimeType:t,afterTimeNumber:a,segment:i,eventOptionValue:s}=this.state,{onValueChange:n=null}=this.props;if(!n)return;const r={group:this.email.slug,event:e,afterTimeType:t};a&&(r.afterTimeNumber=a),i&&(r.segment=i),s&&(r.meta=JSON.stringify({option:this.state.eventOptionValue})),n({target:{name:"options",value:r}})}render(){return(0,g.jsxs)("div",{children:[(0,g.jsx)(jt.D,{level:5,children:this.displayHeader()}),this.displayEventOptions(),this.displaySegments(),this.displayScheduling()]})}}Fs.propTypes={field:rt().shape({email:rt().shape({events:rt().object.isRequired}).isRequired,emailOptions:rt().object.isRequired}).isRequired,onValueChange:rt().func},Fs.displayName="SendEventConditions";const Ms=window.mailpoet_woocommerce_automatic_emails||[],Ls={getFields:function(e){return(e=>{const t=Ms[e.options.group];if(!t)return!1;const a=e.options;return[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,p.__)("Send this %1s Automatic Email when...","mailpoet").replace("%1s",t.title),type:"reactComponent",component:(0,o.withBoundary)(Fs),email:t,emailOptions:a},Ei,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}]})(e)},getSendButtonOptions:function(){return{value:(0,p.__)("Activate","mailpoet")}}};var $s=a(39429);function Ws({afterTimeNumber:e,afterTimeType:t,updateAfterTimeNumber:a,updateAfterTimeType:i,inactiveSubscribersPeriod:s}){const n="weeks"===t?7:30,r=Number(e)*n;let o=s;return 365===s&&(o=360),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(jt.D,{level:4,children:(0,p.__)("When to send this re-engagement email?","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("After no activity for","mailpoet")}),(0,g.jsxs)(ri.Grid.TwoColumns,{children:[(0,g.jsx)("div",{children:(0,g.jsx)(ot.p,{type:"number",placeholder:(0,p.__)("count","mailpoet"),value:e,min:1,onChange:(0,ki.k9)(a),required:!0})}),(0,g.jsx)("div",{children:(0,g.jsxs)(ut.Select,{value:t,onChange:(0,ki.k9)(i),children:[(0,g.jsx)("option",{value:"weeks",children:(0,p.__)("weeks","mailpoet")}),(0,g.jsx)("option",{value:"months",children:(0,p.__)("months","mailpoet")})]})})]}),(!s||o>r)&&(0,g.jsx)("div",{className:"mailpoet-gap"}),!!s&&o<=r&&(0,g.jsx)("p",{className:"mailpoet-re-engagement-scheduling-note",children:at()((0,p.__)("Disengaged subscribers will [link]become inactive[/link] after {$months} months and won’t receive this email. Please select a shorter period.","mailpoet").replace("{$months}",`${Math.floor(s/30)}`),/\[link\](.*?)\[\/link\]/g,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/264-inactive-subscribers",target:"_blank",rel:"noopener noreferrer",children:e},"link"))})]})}const Bs=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",type:"reactComponent",component:function(e){return(0,g.jsx)(Ws,{afterTimeNumber:e.item.options.afterTimeNumber.toString(),afterTimeType:e.item.options.afterTimeType,inactiveSubscribersPeriod:Number(m.U.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:t=>{e.onValueChange({target:{name:"options",value:(0,$s.assoc)("afterTimeNumber",t,e.item.options)}})},updateAfterTimeType:t=>{e.onValueChange({target:{name:"options",value:(0,$s.assoc)("afterTimeType",t,e.item.options)}})}})}},Bi,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:Ci,placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]},Ei],qs={getFields:()=>Bs,getSendButtonOptions:()=>({value:(0,p.__)("Activate","mailpoet")})};var Hs=a(82518);let zs=null;var Vs=a(74298);function Ys({toggleLoadingState:e,updatePendingState:t}){const a=(0,r.useCallback)(async()=>{try{const{success:e,res:a}=await(0,o.callApi)({endpoint:"services",action:"refreshMSSKeyStatus"});!0===e?t(!(0,o.isTruthy)(a.data.result.data.is_approved)):m.U.Notice.showApiErrorNotice(a)}catch(e){m.U.Notice.showApiErrorNotice(e)}},[t]),[i,s]=(0,r.useState)(!0);return(0,g.jsxs)("div",{className:"mailpoet_error",children:[(0,g.jsx)(Vs.wk,{}),i&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)(Vs.Tr,{onRefreshClick:async t=>{t.preventDefault(),e(!0),await a(),s(!1),e(!1)}})]})]})}Ys.displayName="PendingNewsletterMessage";const Gs=(0,o.withBoundary)(Ys),Ks=window.mailpoet_woocommerce_automatic_emails||{},Qs=(e,t)=>`${ni()(t,{strict:!0,lower:!0})||"email"}-${e}`,Js=e=>"immediate"===e.afterTimeType?"immediate":`${e.afterTimeNumber} ${e.afterTimeType}`;function Zs(e){let t,a;if(null===e.wp_post_id)return e&&e.body&&e.body.content&&(a=e.body.content,t=JSON.stringify(e.body.content),!a.blocks||!Array.isArray(a.blocks)||0===a.blocks.length)?(0,p.__)("Poet, please add prose to your masterpiece before you send it to your followers.","mailpoet"):window.mailpoet_mss_active&&t.indexOf("[link:subscription_unsubscribe_url]")<0&&t.indexOf("[link:subscription_unsubscribe]")<0?(0,p.__)('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.',"mailpoet"):"re_engagement"===e.type&&t.indexOf("[link:subscription_re_engage_url]")<0?(0,p.__)("A re-engagement email must include a link with [link:subscription_re_engage_url] shortcode.","mailpoet"):"notification"===e.type&&t.indexOf('"type":"automatedLatestContent"')<0&&t.indexOf('"type":"automatedLatestContentLayout"')<0?(0,p._x)("Please add an “Automatic Latest Content” widget to the email from the right sidebar.","(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside","mailpoet"):"standard"===e.type&&"sent"===e.status?(0,p.__)("This email has already been sent. It can be edited, but not sent again. Duplicate this email if you want to send it again.","mailpoet"):"re_engagement"!==e.type||m.U.trackingConfig.emailTrackingEnabled?void 0:(0,g.jsx)("span",{style:{pointerEvents:"all"},children:at()((0,p.__)("Re-engagement emails are disabled because [link]open and click tracking[/link] is disabled.","mailpoet"),/\[link\](.*?)\[\/link\]/g,e=>(0,g.jsx)("a",{href:"?page=mailpoet-settings#/advanced",rel:"noopener noreferrer",children:e},"advancedSettingsTabLink"))})}class Xs extends r.Component{constructor(e){super(e),this.saveDraftNewsletter=this.saveDraftNewsletter.bind(this),this.state={fields:[],item:{},loading:!0,thumbnailPromise:null,showPremiumModal:!1,mssKeyPendingApproval:window.mailpoet_mss_key_pending_approval,sendContextValue:{saveDraftNewsletter:this.saveDraftNewsletter}}}componentDidMount(){this.loadItem(this.props.params.id).always(()=>{this.setState({loading:!1})}),Ie()("#mailpoet_newsletter").parsley({successClass:""})}componentDidUpdate(e){this.props.params.id!==e.params.id&&this.loadItem(this.props.params.id).always(()=>{this.setState({loading:!1})})}getFieldsByNewsletter=e=>this.getSubtype(e).getFields(e);getSendButtonOptions=()=>this.getSubtype(this.state.item).getSendButtonOptions(this.state.item);getSubtype=e=>{if(e.type===Ti.Gn.Automatic&&Ks[e.options.group])return Ls;switch(e.type){case"notification":return ys;case"welcome":return As;case"re_engagement":return qs;default:return Qi}};getThumbnailPromise=e=>this.state?.thumbnailPromise??(0,Hs.uz)(e);isValid=()=>Ie()("#mailpoet_newsletter").parsley().isValid();isCampaign=()=>(window.mailpoet_sender_restrictions?.campaignTypes??[]).includes(this.state?.item?.type);isAuthorizedDomainRequired=()=>{const e=window.mailpoet_sender_restrictions?.isAuthorizedDomainRequiredForNewCampaigns||!1;return this.isCampaign()&&e};isValidFromAddress=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return!0;if(window.mailpoet_sender_restrictions?.skipAuthorization)return!0;const e=await this.loadVerifiedSenderDomains(),t=(0,ki.Y8)(this.state.item.sender_address);if(-1!==e.indexOf(t))return!0;const a=await this.loadAuthorizedEmailAddresses(),i=this.state.item.sender_address;return-1!==a.indexOf(i)&&!this.isAuthorizedDomainRequired()};loadItem=e=>(this.setState({loading:!0}),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:e}}).done(e=>{const t="draft"===e.data.status?this.getThumbnailPromise(e.meta.preview_url):null,a=e.data;if(a.type===Ti.Gn.Automation){const e=a.options?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"/new";return this.setState({item:{}},()=>{this.props.navigate(t)})}!a.ga_campaign&&Ri.d&&(a.ga_campaign=Qs(a.id,a.subject));const i=new URLSearchParams(this.props.location.search).get("filterSegmentId");return i&&(e.data.options.filterSegmentId=i),this.setState({item:e.data,fields:this.getFieldsByNewsletter(e.data),thumbnailPromise:t,validationError:Zs(e.data)}),e.data?.wp_post_id&&m.U.trackEvent("New Email Editor > Send page opened-Newsletter created by BlockEmailEditor"),!0}).fail(()=>{this.setState({item:{}},()=>{this.props.navigate("/new")})}));saveTemplate=(e,t)=>{this.getThumbnailPromise(e.meta.preview_url).then(a=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"save",data:{newsletter_id:e.data.id,name:e.data.subject,thumbnail_data:a,body:JSON.stringify(e.data.body),categories:'["recent"]'}}).then(()=>t()).fail(e=>{this.showError(e),this.setState({loading:!1}),m.U.Modal.loading(!1)})}).catch(e=>{this.showError({errors:[e]})})};loadAuthorizedEmailAddresses=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return[];const e=(await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"getAuthorizedEmailAddresses"})).data||[];return window.mailpoet_authorized_emails=e,e};loadVerifiedSenderDomains=async()=>"MailPoet"!==window.mailpoet_mta_method?[]:(await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[];handleSend=e=>(e.preventDefault(),this.isValid()?(m.U.Modal.loading(!0),this.isValidFromAddress().then(e=>{e?this.saveNewsletter().done(()=>{this.setState({loading:!0})}).done(e=>{switch(e.data.type){case"notification":case"welcome":case"automatic":case"re_engagement":this.activateNewsletter(e);break;default:this.sendNewsletter(e)}}).fail(e=>{this.showError(e),this.setState({loading:!1}),m.U.Modal.loading(!1)}):(window.mailpoet_sender_address_field_blur(),m.U.Modal.loading(!1))})):Ie()("#mailpoet_newsletter").parsley().validate());sendNewsletter=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"add",data:{newsletter_id:this.state.item.id}}).done(t=>{this.saveTemplate(e,()=>{if(window.mailpoet_show_congratulate_after_first_newsletter)return m.U.Modal.loading(!1),void this.props.navigate(`/send/congratulate/${this.state.item.id}`);this.redirectToListing("activated");let a=[];e.data.segments.map(e=>a.push(...e.filters)),a=ii().uniqWith(a,(e,t)=>e.action===t.action&&e.type===t.type);const i=a.map(e=>function(e){const t=e.action,a=e.type;if("automations"===a)switch(t){case"enteredAutomation":return"entered automation";case"exitedAutomation":return"exited automation";default:return""}if("email"===a)switch(t){case"machineOpensAbsoluteCount":return"number of machine-opens";case"opensAbsoluteCount":return"number of opens";case"clicked":return"clicked";case"clickedAny":return"clicked any email";case"opened":return"opened";case"machineOpened":return"machine-opened";case"wasSent":return"was sent";case"numberReceived":return"number of emails received";case"numberOfClicks":return"number of clicks";default:return""}if("userRole"===a)switch(t){case"subscriberTag":return"subscriber tags";case"subscribedToList":return"subscribed to list";case"subscriberScore":return"score";case"wordpressRole":return"WordPress user role";case"lastEngagementDate":return"last engagement date";case"lastClickDate":return"last click date";case"lastPurchaseDate":return"last purchase date";case"lastOpenDate":return"last open date";case"lastPageViewDate":return"last page view date";case"lastSendingDate":return"last sending date";case"subscriberFirstName":return"first name";case"subscriberLastName":return"last name";case"subscriberEmail":return"email";case"subscribedViaForm":return"subscribed via form";default:return""}if("woocommerce"===a)switch(t){case"customerInCountry":return"is in country";case"customerInPostalCode":return"postal code";case"customerInCity":return"city";case"purchasedCategory":return"purchased in category";case"purchasedTag":return"purchased with tag";case"purchasedProduct":return"purchased product";case"subscribedDate":return"subscribed date";case"totalSpent":return"total spent";case"firstOrder":return"first order";case"purchaseDate":return"purchase date";case"averageSpent":return"average order value";case"singleOrderValue":return"single order value";case"usedPaymentMethod":return"used payment method";case"usedShippingMethod":return"used shipping method";case"numberOfReviews":return"number of reviews";case"usedCouponCode":return"used coupon code";case"numberOfOrders":return"number of orders";case"purchasedWithAttribute":return"purchased with attribute";default:return""}return"woocommerceSubscription"===a&&"hasActiveSubscription"===t?"has an active subscription":"woocommerceMembership"===a&&"isMemberOf"===t?"is active member of":""}(e)).join(", "),s="scheduled"===t.data.status;m.U.trackEvent("Emails > Newsletter sent",{scheduled:s,"Segment Applied":!!this.state.item.options.filterSegmentId,segments:i,editor:this.state.item.wp_post_id?"BlockEmailEditor":"legacyEditor"}),s?this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("The newsletter has been scheduled.","mailpoet")})):this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("The newsletter is being sent...","mailpoet")}),{id:"mailpoet_notice_being_sent"}),m.U.Modal.loading(!1)})}).fail(e=>{this.showError(e),this.setState({loading:!1}),m.U.Modal.loading(!1)});activateNewsletter=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:this.props.params.id,status:"active"}}).done(t=>{this.saveTemplate(e,()=>{if(window.mailpoet_show_congratulate_after_first_newsletter)return m.U.Modal.loading(!1),void this.props.navigate(`/send/congratulate/${this.state.item.id}`);this.redirectToListing("activated");const e=this.state.item.options;"automatic"===this.state.item.type&&Ks[e.group]?m.U.trackEvent("Emails > Automatic email activated",{Type:ni()(`${e.group}-${e.event}`),Delay:Js(e)}):"welcome"===t.data.type?m.U.trackEvent("Emails > Welcome email activated",{"List type":e.event,Delay:Js(e)}):"re_engagement"===t.data.type?(this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("Your Re-engagement Email is now activated!","mailpoet")})),m.U.trackEvent("Emails > Re-engagement email activated",{Inactivity:Js(e),"Segment Applied":!!this.state.item.options.filterSegmentId})):"notification"===t.data.type&&(this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("Your post notification is now active!","mailpoet")})),m.U.trackEvent("Emails > Post notifications activated",{Frequency:e.intervalType,"Segment Applied":!!this.state.item.options.filterSegmentId})),m.U.Modal.loading(!1)})}).fail(e=>{this.showError(e),this.setState({loading:!1}),m.U.Modal.loading(!1)});handleResume=e=>(e.preventDefault(),this.isValid()?this.saveNewsletter().done(()=>{this.setState({loading:!0})}).done(()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"resume",data:{newsletter_id:this.state.item.id}}).done(()=>{this.redirectToListing("activated"),this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("The newsletter sending has been resumed.","mailpoet")}))}).fail(e=>{this.showError(e)})}).fail(e=>{this.showError(e)}).always(()=>{this.setState({loading:!1})}):Ie()("#mailpoet_newsletter").parsley().validate(),!1);handleSave=e=>{e.preventDefault(),this.saveNewsletter().done(()=>{this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("Email was updated successfully!","mailpoet")}))}).done(()=>{this.redirectToListing("saved")}).fail(e=>{this.showError(e)})};redirectToListing=e=>{["automatic","welcome"].includes(this.state.item.type)?window.location.href=`admin.php?page=mailpoet-automation¬ice=${e}`:this.props.navigate(`/${this.state.item.type}`)};handleRedirectToDesign=e=>{e.preventDefault();const t=e.target.href;this.saveNewsletter().done(()=>{this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("Email was updated successfully!","mailpoet")}))}).done(()=>{window.location=t}).fail(e=>{this.showError(e)})};saveNewsletter=()=>{const e=this.state.item;e.queue=void 0,this.setState({loading:!0});const t=ii().omit(e,["body","created_at","deleted_at","hash","status","updated_at","type"]);return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:t})};showError=e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0,timeout:!1})};handleFormChange=e=>{const t=e.target.name,a=e.target.value;return this.setState(e=>{const i={...e.item},s=i.subject,n=i.ga_campaign;return i[t]=a,"subject"===t&&n===Qs(i.id,s)&&(i.ga_campaign=Qs(i.id,a)),"reply_to_address"===t&&(i[t]=a.toLowerCase()),{item:i}}),!0};handleSaveDraft=()=>{Ie()("#mailpoet_newsletter").parsley().destroy()};disableSegmentsSelectorWhenPaused=e=>t=>"segments"===t.name||"options"===t.name?{...t,disabled:e}:t;disableGAIfPremiumInactive=()=>e=>Ri.d||"ga_campaign"!==e.name?e:{...e,disabled:!0,onWrapperClick:()=>this.setState({showPremiumModal:!0,premiumModalMessage:(0,p.__)("Google Analytics tracking is not available in the free version of the MailPoet plugin.","mailpoet")})};disableFilterSegmentToggleIfPremiumInactive=()=>e=>{if(!Array.isArray(e.fields))return e;const t={...e};return t.fields=t.fields.map(e=>"filter-segment-toggle"!==e.name||Ri.d?e:{...e,disabled:!0,onWrapperClick:e=>{e.preventDefault(),this.setState({showPremiumModal:!0,premiumModalMessage:(0,p.__)("Filtering by segment is not available in the free version of the MailPoet plugin.","mailpoet")})}}),t};getPreparedFields=e=>Array.isArray(this.state.fields)?this.state.fields.map(this.disableSegmentsSelectorWhenPaused(e)).map(this.disableGAIfPremiumInactive()).map(this.disableFilterSegmentToggleIfPremiumInactive()):[];closePremiumModal=()=>this.setState({showPremiumModal:!1});toggleLoadingState=e=>this.setState({loading:e});updatePendingApprovalState=e=>this.setState({mssKeyPendingApproval:e});saveDraftNewsletter=async()=>{this.handleSaveDraft(),await this.saveNewsletter()};render(){const{showPremiumModal:e,item:{status:t,queue:a,type:i,options:s,wp_post_id:n},mssKeyPendingApproval:r}=this.state,l="sending"===t&&a&&"paused"===a.status,d=this.getSendButtonOptions(),c=this.getPreparedFields(l),u=!(!window.mailpoet_subscribers_limit_reached&&!r&&void 0===this.state.validationError);let h=i;return h===Ti.Gn.Automatic&&(h=s.group||h),(0,g.jsxs)("div",{className:"mailpoet-form-send-email",children:[(0,g.jsx)(Ga,{emailType:h,automationId:"newsletter_send_heading"}),(0,g.jsxs)(o.ErrorBoundary,{children:[this.state.item.campaign_name?(0,g.jsx)("div",{className:"mailpoet-form-grid mailpoet-send-campaign-name",children:(0,g.jsx)("h1",{children:this.state.item.campaign_name})}):null,(0,g.jsx)(Fi.Provider,{value:this.state.sendContextValue,children:(0,g.jsxs)(Ct,{id:"mailpoet_newsletter",fields:c,automationId:"newsletter_send_form",item:this.state.item,loading:this.state.loading,onChange:this.handleFormChange,onSubmit:this.handleSave,children:[(0,g.jsxs)(ri.Grid.CenteredRow,{className:"send-newsletter-buttons",children:[(0,g.jsx)(o.Button,{variant:"secondary",type:"submit",automationId:"email-save-draft",onClick:this.handleSaveDraft,isDisabled:this.state.loading,children:(0,p.__)("Save as draft and close","mailpoet")}),l?(0,g.jsx)(o.Button,{type:"button",onClick:this.handleResume,isDisabled:u||this.state.loading,automationId:"email-resume",children:(0,p.__)("Resume","mailpoet")}):(0,g.jsx)(o.Button,{type:"button",onClick:this.handleSend,...d,isDisabled:u||this.state.loading,automationId:"email-submit",children:d.value||(0,p.__)("Send","mailpoet")}),void 0!==this.state.validationError&&(0,g.jsx)(Fe.Tooltip,{tooltip:(0,g.jsx)("div",{children:this.state.validationError}),tooltipId:"helpTooltipSendEmail"})]}),(0,g.jsxs)("p",{children:[(0,p.__)("or simply","mailpoet")," ",(0,g.jsx)("a",{className:"mailpoet-link",href:n?m.U.getBlockEmailEditorUrl(Number(n)):`?page=mailpoet-newsletter-editor&id=${Number(this.props.params.id)}`,onClick:this.handleRedirectToDesign,children:(0,p.__)("go back to the Design page","mailpoet")}),"."]}),r&&(0,g.jsx)(Gs,{toggleLoadingState:this.toggleLoadingState,updatePendingState:this.updatePendingApprovalState}),e&&(0,g.jsx)(Ri.D,{onRequestClose:this.closePremiumModal,children:this.state.premiumModalMessage})]})})]})]})}}function en(e){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(jt.D,{level:0,children:(0,p.__)("Congratulations!","mailpoet")}),(0,g.jsx)(jt.D,{level:3,children:(i=e.newsletter,"welcome"===i.type?(0,p.__)("Your Welcome Email is now active.","mailpoet"):"notification"===i.type?(0,p.__)("Your Post Notification is now active.","mailpoet"):"automatic"===i.type?(0,p.__)("Your WooCommerce email has been activated.","mailpoet"):"scheduled"===i.status?(0,p.__)("Your newsletter is scheduled to be sent.","mailpoet"):(0,p.__)("Your newsletter is being sent!","mailpoet"))}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("img",{src:e.illustrationImageUrl,alt:"",width:"500"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)(o.Button,{type:"button",dimension:"small",onClick:()=>{e.successClicked(),a(!0)},withSpinner:t,children:(0,p.__)("Close","mailpoet")})]});var i}function tn(e){return(0,g.jsxs)("div",{className:"mailpoet-wizard-step",children:[(0,g.jsx)("div",{className:"mailpoet-wizard-step-illustration",children:(0,g.jsx)("img",{src:e.illustrationUrl,alt:""})}),(0,g.jsx)("div",{className:"mailpoet-wizard-step-content",children:e.children})]})}function an(){return(0,g.jsxs)(o.List,{children:[(0,g.jsx)("li",{children:(0,p.__)("Reliable marketing and transactional email delivery. Reach inboxes, not spam boxes","mailpoet")}),(0,g.jsx)("li",{children:(0,p.__)("Send your emails super fast (up to 50,000 emails per hour)","mailpoet")}),(0,g.jsx)("li",{children:(0,p.__)("Maintain your sender reputation and improve engagement levels with automated bounce and complaint handling. Stop sending to non-deliverable and complaining addresses, automatically","mailpoet")}),(0,g.jsx)("li",{children:(0,p.__)("Authenticate your emails (with SPF and DKIM) to improve deliverability and avoid spam boxes","mailpoet")})]})}function sn(e){const[t,a]=(0,r.useState)(!1),i=()=>{e.onFinish(),a(!0)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.Heading,{level:1,children:(s=e.newsletter.type,{standard:(0,p.__)("Your email has been sent!","mailpoet"),welcome:(0,p.__)("You are all set up and ready to go!","mailpoet"),notification:(0,p.__)("You are all set up and ready to go!","mailpoet"),woocommerce:(0,p.__)("You are all set up and ready to go!","mailpoet")}[s]||(0,p.__)("You are all set up and ready to go!","mailpoet"))}),(0,g.jsx)(tn,{illustrationUrl:e.MSSPitchIllustrationUrl,children:(0,g.jsxs)("div",{className:"mailpoet-welcome-wizard-step-content",children:[(0,g.jsx)(o.Heading,{level:4,children:(0,p.__)("What’s next? Sign up to the MailPoet Starter plan for fast and reliable email delivery","mailpoet")}),(0,g.jsx)("p",{children:e.subscribersCount<500?(0,p._x)("Did you know? Users with 500 subscribers or less get the Starter plan for free.","Promotion for our email sending service: Paragraph","mailpoet"):(0,p._x)("Starting at only $10 per month, MailPoet Business offers the following features","Promotion for our email sending service: Paragraph","mailpoet")}),(0,g.jsxs)(o.Heading,{level:5,children:[(0,p._x)("You’ll get","Promotion for our email sending service: Paragraph","mailpoet"),":"]}),(0,g.jsx)(an,{}),(0,g.jsx)("p",{children:at()((0,p.__)("Please enter your key in [link]the Settings[/link] if you have already purchased it.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsx)("a",{href:"admin.php?page=mailpoet-settings#/premium",children:e},t))}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{isFullWidth:!0,href:e.purchaseUrl,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),window.open(e.purchaseUrl),i()},children:(0,p._x)("Sign up for free","Promotion for our email sending service: Button","mailpoet")}),(0,g.jsx)(o.Button,{isFullWidth:!0,variant:"tertiary",onClick:i,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),i())},withSpinner:t,children:(0,p._x)("No thanks!","Promotion for our email sending service: Skip link","mailpoet")})]})})]});var s}function nn(e){return window.has_mss_key_specified?(0,g.jsx)(en,{successClicked:e.successClicked,illustrationImageUrl:e.illustrationImageUrl,newsletter:e.newsletter}):(0,g.jsx)(sn,{MSSPitchIllustrationUrl:e.MSSPitchIllustrationUrl,onFinish:e.successClicked,subscribersCount:e.subscribersCount,purchaseUrl:e.purchaseUrl,newsletter:e.newsletter})}function rn(e){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)("div",{children:[(0,g.jsx)(jt.D,{level:1,children:(0,p.__)("Oops! We can’t send your newsletter","mailpoet")}),(0,g.jsx)(jt.D,{level:3,children:at()((0,p.__)("Rest assured, this is fairly common and is usually fixed quickly. [link]See our quick guide[/link] to help you solve this and get your website sending.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://kb.mailpoet.com/article/231-sending-does-not-work",children:e},t))}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("img",{src:window.mailpoet_congratulations_error_image,alt:"",width:"500"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)(o.Button,{dimension:"small",type:"button",onClick:()=>{e.failClicked(),a(!0)},withSpinner:t,children:(0,p.__)("Close","mailpoet")})]})}Xs.contextType=l.F,en.propTypes={successClicked:rt().func.isRequired,illustrationImageUrl:rt().string.isRequired,newsletter:rt().shape({status:rt().string.isRequired,type:rt().string.isRequired}).isRequired},tn.propTypes={illustrationUrl:rt().string.isRequired,children:rt().oneOfType([rt().arrayOf(rt().node),rt().node]).isRequired},nn.propTypes={successClicked:rt().func.isRequired,illustrationImageUrl:rt().string.isRequired,MSSPitchIllustrationUrl:rt().string.isRequired,newsletter:rt().shape({status:rt().string.isRequired,type:rt().string.isRequired}).isRequired,subscribersCount:rt().number.isRequired,purchaseUrl:rt().string.isRequired},rn.propTypes={failClicked:rt().func.isRequired};var on=a(98191);function ln(e){return(0,g.jsx)("div",{className:"mailpoet-congratulate-loading",children:e.showRichLoadingScreen&&(0,g.jsxs)("div",{children:[(0,g.jsx)(jt.D,{level:0,children:(0,p.__)("Verification","mailpoet")}),(0,g.jsx)(jt.D,{level:3,children:(0,p.__)("Congrats, you’re sending your first newsletter! We’re doing a quick verification to make sure everything works fine.","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)(on.a,{size:64})]})})}ln.propTypes={showRichLoadingScreen:rt().bool.isRequired};const dn=Math.floor(4*Math.random());function cn(){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:{show_congratulate_after_first_newsletter:!1}}).always(()=>{window.location=window.mailpoet_emails_page})}class mn extends r.Component{constructor(e){super(e),this.state={loading:!0,newsletter:null,testingPassed:!1,timeStart:et()(),minimumLoadingTimePassed:!1},this.tick=this.tick.bind(this)}componentDidMount(){this.loadNewsletter(this.props.params.id),this.tick()}componentDidUpdate(e){e.params.id!==this.props.params.id&&this.loadNewsletter(this.props.params.id)}tick(){et()().subtract(20,"second").isAfter(this.state.timeStart)&&this.setState({error:!0,loading:!1}),this.state.loading&&this.loadNewsletter(this.props.params.id),et()().subtract(6,"seconds").isAfter(this.state.timeStart)&&this.setState({minimumLoadingTimePassed:!0}),!this.state.loading&&this.state.minimumLoadingTimePassed||setTimeout(this.tick,2e3)}loadNewsletter(e){m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:e}}).done(e=>this.newsletterLoaded(e.data))}newsletterLoaded(e){"standard"!==e.type||"scheduled"===e.status?this.setState({newsletter:e,loading:!1,minimumLoadingTimePassed:!0}):"sent"===e.status||"sending"===e.status?this.setState({newsletter:e,loading:!1,testingPassed:!0}):this.setState({newsletter:e})}renderContent(){return this.state.loading||!this.state.minimumLoadingTimePassed?(e=!this.state.newsletter,(0,g.jsx)(ln,{illustrationImageUrl:window.mailpoet_congratulations_loading_image,successClicked:cn,showRichLoadingScreen:e})):this.state.error?(m.U.trackEvent("Cron testing done",{"Cron is working":"false"}),(0,g.jsx)(rn,{failClicked:()=>{window.location=window.mailpoet_emails_page}})):(t=this.state.newsletter,this.state.testingPassed&&m.U.trackEvent("Cron testing done",{"Cron is working":"true"}),(0,g.jsx)(nn,{illustrationImageUrl:window.mailpoet_congratulations_success_images[dn],MSSPitchIllustrationUrl:window.mailpoet_congratulations_success_images[dn],successClicked:cn,newsletter:t,isWoocommerceActive:window.mailpoet_woocommerce_active,subscribersCount:window.mailpoet_subscribers_count,purchaseUrl:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,"starter",{utm_medium:"first-newsletter-congratulations",utm_campaign:"purchase"})}));var e,t}render(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:"body { background: #fff; overflow-x: hidden; }"}}),(0,g.jsxs)("div",{className:"mailpoet-congratulate",children:[(0,g.jsx)("div",{className:"mailpoet-gap-large"}),this.renderContent()]})]})}}mn.propTypes={params:rt().shape({id:rt().string}).isRequired},mn.displayName="Congratulate";class un extends r.Component{componentDidMount(){m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,p.__)("Subject","mailpoet")}}).done(e=>{window.location.search.includes("loadedvia=woo_multichannel_dashboard")&&window.MailPoet.trackEvent("MailPoet - WooCommerce Multichannel Marketing dashboard > Newsletter template selection page",{"WooCommerce version":window.mailpoet_woocommerce_version}),this.showTemplateSelection(e.data.id)}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0})})}showTemplateSelection=e=>{this.props.navigate(`/template/${e}`)};render(){return(0,g.jsx)("div",{children:(0,g.jsx)(Ga,{emailType:"standard",automationId:"standard_newsletter_creation_heading"})})}}un.contextType=l.F,un.propTypes={navigate:rt().func.isRequired},un.displayName="NewsletterStandard";const pn={name:"options",type:"reactComponent",component:xs};class hn extends r.Component{constructor(e){super(e),this.state={options:{intervalType:"daily",timeOfDay:0,weekDay:ls(m.U.wpWeekStartsOn),monthDay:"1",nthWeekDay:"1"}}}componentDidMount(){window.location.search.includes("loadedvia=woo_multichannel_dashboard")&&window.MailPoet.trackEvent("MailPoet - WooCommerce Multichannel Marketing dashboard > Create post notification page",{"WooCommerce version":window.mailpoet_woocommerce_version})}handleValueChange=e=>{const t=this.state;t[e.target.name]=e.target.value,this.setState(t)};handleNext=()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:mt.default.extend({},this.state,{type:"notification",subject:(0,p.__)("The last [newsletter:total] posts from our blog","mailpoet")})}).done(e=>{this.showTemplateSelection(e.data.id)}).fail(e=>{e.errors.length>0&&this.context.notices.apiError(e,{scroll:!0})})};showTemplateSelection=e=>{this.props.navigate(`/template/${e}`)};render(){return(0,g.jsxs)("div",{children:[(0,g.jsx)(Ga,{emailType:"notification",automationId:"post_notification_creation_heading"}),(0,g.jsxs)(ri.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,g.jsx)(jt.D,{level:4,children:(0,p.__)("When to send this post notification email?","mailpoet")}),(0,g.jsx)(xs,{item:this.state,field:pn,onValueChange:this.handleValueChange}),(0,g.jsx)(Le.$,{isFullWidth:!0,onClick:this.handleNext,type:"button",children:(0,p.__)("Next","mailpoet")})]})]})}}function gn(){let e="11";m.U.deactivateSubscriberAfterInactiveDays&&(e=(Math.floor(Number(m.U.deactivateSubscriberAfterInactiveDays)/30)-1).toString());const[t,a]=(0,r.useState)({afterTimeNumber:e,afterTimeType:"months"}),[i,s]=(0,r.useState)([]),[n,o]=(0,r.useState)(!1),l=(0,ke.Zp)();return(0,g.jsxs)("div",{children:[i&&(0,g.jsx)(La,{errors:i}),(0,g.jsx)(Ga,{emailType:"re_engagement",automationId:"re_engagement_heading_creation_heading"}),(0,g.jsxs)(ri.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,g.jsx)(Ws,{afterTimeNumber:t.afterTimeNumber,afterTimeType:t.afterTimeType,inactiveSubscribersPeriod:Number(m.U.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:(0,$s.compose)([a,(0,$s.assoc)("afterTimeNumber",$s.__,t)]),updateAfterTimeType:(0,$s.compose)([a,(0,$s.assoc)("afterTimeType",$s.__,t)])}),(0,g.jsx)(Le.$,{isFullWidth:!0,onClick:()=>(s([]),o(!0),void m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletters",action:"create",data:{type:"re_engagement",subject:(0,p.__)("Subject","mailpoet"),options:t}}).done(e=>{var t;t=e.data.id,l(`/template/${t}`)}).fail(e=>{o(!1),e.errors&&s(e.errors)})),type:"button",isDisabled:!t.afterTimeNumber||n,withSpinner:n,children:(0,p.__)("Next","mailpoet")})]})]})}hn.contextType=l.F,gn.displayName="NewsletterTypeReEngagement";var _n=a(35635),fn=a(68380),bn=a(4534);function xn({newsletter:e}){const[t,a]=(0,r.useState)("paused"===e.queue.status),[i,s]=(0,r.useState)([]),n=async()=>{s([]),await(async()=>{await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"resume",data:{newsletter_id:e.id}}).done(()=>a(!1)).fail(e=>s(e.errors))})()};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(La,{errors:i}),t&&(0,g.jsx)(Le.$,{dimension:"small",onClick:e.status===Ti.um.Corrupt?async()=>{(0,o.confirmAlert)({message:(0,p.__)("There was an issue sending this email before. Please confirm the problems are fixed to proceed.","mailpoet"),onConfirm:n})}:n,children:(0,p.__)("Resume","mailpoet")}),!t&&(0,g.jsx)(Le.$,{dimension:"small",onClick:async()=>{s([]),await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"pause",data:{newsletter_id:e.id}}).done(()=>a(!0)).fail(e=>s(e.errors))},children:(0,p.__)("Pause","mailpoet")})]})}function vn(){return(0,g.jsx)("div",{className:"mailpoet-listing-stats-too-early",children:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-help#/systemStatus",className:"mailpoet-tag mailpoet-tag-inverted mailpoet-tag-unknown",children:(0,p.__)("Cancelled","mailpoet")})})}function yn({newsletter:e,mailerLog:t}){const a=e.sent_at||e.queue.scheduled_at,i=e.queue&&"cancelled"===e.queue.status,s=e.queue&&"scheduled"!==e.queue.status,n="paused"===t.status,r=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ne.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:(0,g.jsx)(bn.um,{processed:parseInt(e.queue.count_processed,10),scheduledFor:a,total:parseInt(e.queue.count_total,10),isPaused:n,status:e.status,logs:e.logs})}),i&&(0,g.jsx)(vn,{}),"completed"!==e.queue.status&&!i&&!n&&(0,g.jsx)(xn,{newsletter:e})]}),o=(0,g.jsx)(bn.um,{scheduledFor:a,isPaused:"scheduled"===e.queue.status&&n,status:e.status,logs:e.logs});return(0,g.jsxs)(g.Fragment,{children:[s&&r,!s&&o]})}yn.displayName="QueueStatus";const jn=(0,o.withBoundary)(yn);var wn=a(63027);function Sn({newsletter:e,isSent:t,currentTime:a}){let i=t;if(void 0===i&&(i=e.statistics&&e.queue&&"scheduled"!==e.queue.status),!i)return null;const s={link:`/stats/${e.id}`,onClick:aa.Hooks.applyFilters("mailpoet_newsletters_listing_stats_tracking",Xa.cp)},n=Number(e.total_sent||e.queue.count_processed),r=e.queue&&"cancelled"===e.queue.status;if(r&&0===n)return null;let l,d,c,m,u,h=0,_=0,f=null;n>0&&(h=100*e.statistics.clicked/n,_=100*e.statistics.opened/n,f=e.statistics.revenue),r||void 0===a?(m=!1,u=!1):(l=6,d=e.queue.scheduled_at||e.queue.created_at,c=et()(a).diff(et()(d),"hours"),m=c=20&&e.statistics.opened>=5&&!m,x=m&&"completed"===e.queue.status,v=(t,a)=>((e,t,a,i)=>i<=0||!t.link?e:t.externalLink?(0,g.jsx)("a",{href:t.link,onClick:t.onClick||null,children:e},`stats-${a}`):(0,g.jsx)(Ne.Link,{to:t.link,onClick:t.onClick||null,children:e},`stats-${a}`))(t,s,`${a}-${e.id}`,n),y=(0,g.jsx)(wn.j,{opened:_,clicked:h,revenues:f&&f.value>0?f.formatted:null,hideBadges:!b,newsletterId:e.id,wrapContentInLink:v}),j=(0,g.jsxs)(g.Fragment,{children:[y,x&&v((0,g.jsx)(o.Tag,{className:"mailpoet-listing-stats-too-early",dimension:"large",variant:"excellent",isInverted:!0,children:(0,p.__)("Nice job! Check back in %1$d hour(s) for more stats.","mailpoet").replace("%1$d",l-c)}),"check-back")]});let w;return u&&_<5&&c>=24&&n>=10&&(w=(0,g.jsx)("div",{children:(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/191-how-to-improve-my-open-and-click-rates",target:"_blank",rel:"noopener noreferrer",className:"mailpoet_stat_link_small",children:(0,p.__)("What can I do to improve this?","mailpoet")})})),(0,g.jsxs)(g.Fragment,{children:[j,w]})}const Nn=rt().shape({clicked:rt().number,opened:rt().number,unsubscribed:rt().number,revenue:rt().shape({count:rt().number,currency:rt().string,formatted:rt().string,value:rt().number})}),kn=rt().shape({status:rt().string,count_processed:rt().string.isRequired,count_total:rt().string.isRequired,created_at:rt().string,scheduled_at:rt().string});Sn.propTypes={newsletter:rt().shape({id:rt().number.isRequired,queue:rt().oneOfType([kn,rt().bool]),total_sent:rt().number,statistics:rt().oneOfType([Nn,rt().bool])}).isRequired,isSent:rt().bool,currentTime:rt().string},Sn.displayName="NewsletterStatistics";const Cn=(0,o.withBoundary)(Sn);function In(e,t){let a=null,i=!1,s=0;const n=Date.now(),r=()=>{i||(Date.now()-n>3e5?t.onError((0,p.__)("The export is taking longer than expected. Please try again later.","mailpoet")):(e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"statisticsExport",action:"getStatus",data:{task_id:e}}).then(e=>e.data))(e).then(e=>{i||(s=0,e.error?t.onError(e.error):e.exportFileURL?t.onComplete(e):a=window.setTimeout(r,2500))}).catch(e=>{if(!i){if(s+=1,s>=3){const a=e?.errors?.[0]?.message??(0,p.__)("Could not check the export status.","mailpoet");return void t.onError(a)}a=window.setTimeout(r,2500)}}))};return r(),{cancel:()=>{i=!0,null!==a&&(window.clearTimeout(a),a=null)}}}const Un=m.U.trackingConfig.emailTrackingEnabled,En={onNoItemsFound:(e,t)=>t?(0,p.__)("No emails found.","mailpoet"):(0,p.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was moved to the trash.","mailpoet"):(0,p.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was permanently deleted.","mailpoet"):(0,p.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email has been restored from the Trash.","mailpoet"):(0,p.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},An=[{name:"name",label:(0,p.__)("Name","mailpoet"),sortable:!0},{name:"status",label:(0,p.__)("Status","mailpoet")},{name:"segments",label:(0,p.__)("Lists","mailpoet")},{name:"statistics",label:(0,p.__)("Clicked, Opened","mailpoet"),display:Un},{name:"sent_at",label:(0,p.__)("Sent on","mailpoet"),sortable:!0}],Tn=[{name:"trash",label:(0,p.__)("Move to trash","mailpoet"),onSuccess:En.onTrash}];Un&&m.U.capabilities.detailedAnalytics&&!m.U.capabilities.detailedAnalytics.isRestricted&&Tn.push({name:"export_stats",label:(0,p.__)("Export statistics","mailpoet"),getData:()=>({format:"csv"}),onSuccess:e=>(e=>{e?.data?.taskId?(m.U.Notice.success((0,p.__)("Export queued. The download will start automatically when it is ready.","mailpoet"),{timeout:6e3}),In(e.data.taskId,{onComplete:e=>{e.exportFileURL?(m.U.trackEvent("Email statistics export completed",{"File Format":"csv","Export Type":"bulk"}),window.location.href=e.exportFileURL):m.U.Notice.error((0,p.__)("The export file could not be generated.","mailpoet"),{scroll:!0})},onError:e=>{m.U.Notice.error(e,{scroll:!0})}})):m.U.Notice.error((0,p.__)("Could not start the export.","mailpoet"),{scroll:!0})})(e)});const Rn=e=>{const t=m.U.getActiveEmailEditorUrl(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,Qa.Z)({message:(0,p.__)("Sending is in progress. Do you want to pause sending and edit the newsletter?","mailpoet"),onConfirm:()=>{window.location.href=`${t}&pauseConfirmed=yes`}}):window.location.href=t};let Pn=[{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Edit","mailpoet"),onClick:Rn},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Duplicate","mailpoet"),onClick:function(e,t){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done(e=>{m.U.Notice.success((0,p.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,_n.Zn)(e.data.subject))),t()}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}},{name:"trash",className:"mailpoet-hide-on-mobile"}];Pn=(0,Xa.pE)(Pn);class Dn extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}renderItem=(e,t,a)=>{const i=Z()("manage-column","column-primary","has-row-actions"),s=e.queue.newsletter_rendered_subject||e.subject;return(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:i,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:"#",onClick:t=>{t.preventDefault(),Rn(e)},children:e.campaign_name?(0,g.jsxs)(g.Fragment,{children:[e.campaign_name," ",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"mailpoet-listing-subtitle",children:s})]}):s}),t]}),(0,g.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,p.__)("Status","mailpoet"),children:(0,g.jsx)(jn,{newsletter:e,mailerLog:a.mta_log})}),(0,g.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,p.__)("Lists","mailpoet"),children:(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(fn.vC,{segments:e.segments,dimension:"large"}),(0,g.jsx)(fn.y,{newsletter:e,dimension:"large"})]})}),!0===Un?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,p.__)("Clicked, Opened","mailpoet"),children:(0,g.jsx)(Cn,{newsletter:e,currentTime:a.current_time})}):null,(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,p.__)("Sent on","mailpoet"),children:e.sent_at?m.U.Date.full(e.sent_at):null})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,g.jsxs)(g.Fragment,{children:[0===this.state.newslettersCount&&(0,g.jsx)(za,{filter:e=>"standard"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,g.jsx)(Re.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,endpoint:"newsletters",type:"standard",base_url:"standard",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:An,bulk_actions:Tn,item_actions:Pn,messages:En,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{if(!e.loading){const t=e.groups.reduce((e,t)=>e+t.count,0);this.setState({newslettersCount:t})}(0,Xa.DP)(e),(0,Xa.tQ)(e)}})]})}}Dn.contextType=l.F,Dn.propTypes={location:rt().object.isRequired,params:rt().object.isRequired},Dn.displayName="NewsletterListStandard";const On=(0,o.withBoundary)(Dn);function Fn(e){const t=(0,ke.zy)(),a=(0,ke.g)();return(0,g.jsx)(On,{...e,location:t,params:a})}var Mn=a(95069);const Ln={onNoItemsFound:(e,t)=>t?(0,p.__)("No emails found.","mailpoet"):(0,p.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was moved to the trash.","mailpoet"):(0,p.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was permanently deleted.","mailpoet"):(0,p.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email has been restored from the Trash.","mailpoet"):(0,p.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},$n=[{name:"subject",label:(0,p.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,p.__)("Settings","mailpoet")},{name:"history",label:(0,p.__)("History","mailpoet"),width:100},{name:"status",label:(0,p.__)("Status","mailpoet"),width:100},{name:"updated_at",label:(0,p.__)("Last modified on","mailpoet"),sortable:!0}],Wn=[{name:"trash",label:(0,p.__)("Move to trash","mailpoet"),onSuccess:Ln.onTrash}],Bn=[{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Edit","mailpoet"),onClick:Xa.$U},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Duplicate","mailpoet"),onClick:function(e,t){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done(e=>{m.U.Notice.success((0,p.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,_n.Zn)(e.data.subject))),t()}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class qn extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:Number(t.target.getAttribute("data-id")),status:e?"active":"draft"}}).done(e=>{"active"===e.data.status&&m.U.Notice.success((0,p.__)("Your post notification is now active!","mailpoet")),this.forceUpdate()}).fail(a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e})};renderStatus=e=>(0,g.jsx)(Ai.l,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status});renderSettings=e=>{let t;if(0===e.segments.length)return(0,g.jsx)(Ne.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,p.__)("You need to select a list to send to.","mailpoet")});const a=at()((0,p.__)("Send to %1$s","mailpoet"),"%1$s",(t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsx)(fn.vC,{segments:e.segments},`segment-${a}`),(0,g.jsx)(fn.y,{newsletter:e},`filter-segment-${a}`)]},a)),i=ls(m.U.wpWeekStartsOn),s=ds(m.U.wpWeekStartsOn);switch(e.options.intervalType){case"daily":t=(0,p.__)("Daily at %1$s","mailpoet").replace("%1$s",es[e.options.timeOfDay]);break;case"weekly":t=(0,p.__)("Weekly on %1$s at %2$s","mailpoet").replace("%1$s",us(e.options.weekDay,ts,i,s)).replace("%2$s",es[e.options.timeOfDay]);break;case"monthly":t=(0,p.__)("Monthly on the %1$s at %2$s","mailpoet").replace("%1$s",us(e.options.monthDay,as,ss)).replace("%2$s",es[e.options.timeOfDay]);break;case"nthWeekDay":t=(0,p.__)("Every %1$s %2$s of the month at %3$s","mailpoet").replace("%1$s",is[e.options.nthWeekDay]).replace("%2$s",ts[e.options.weekDay]).replace("%3$s",es[e.options.timeOfDay]);break;case"immediately":t=(0,p.__)("Immediately","mailpoet");break;default:t="Invalid sending frequency"}return(0,g.jsxs)("span",{children:[a,(0,g.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,g.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,g.jsx)(Mn.x,{})}),t]})]})};renderHistoryLink=e=>0===Number(e.children_count)?(0,g.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small mailpoet-listing-notification-status",children:(0,p.__)("Not sent yet","mailpoet")}):(0,g.jsxs)(Ne.Link,{className:"mailpoet-nowrap","data-automation-id":`history-${e.id}`,to:`/notification/history/${e.id}`,children:[(0,g.jsx)(Le.$,{className:"mailpoet-hide-on-mobile",dimension:"small",children:(0,p.__)("View history","mailpoet")}),(0,g.jsx)(Le.$,{className:"mailpoet-show-on-mobile mailpoet-listing-notification-status",dimension:"small",variant:"secondary",children:(0,p.__)("View history","mailpoet")})]});renderItem=(e,t)=>{const a=Z()("manage-column","column-primary","has-row-actions");return(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:a,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:m.U.getActiveEmailEditorUrl(e),onClick:t=>{t.preventDefault(),(0,Xa.$U)(e)},children:e.subject}),t]}),(0,g.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,p.__)("Settings","mailpoet"),children:this.renderSettings(e)}),(0,g.jsx)("td",{className:"column","data-colname":(0,p.__)("History","mailpoet"),children:this.renderHistoryLink(e)}),(0,g.jsx)("td",{className:"column","data-colname":(0,p.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,p.__)("Last modified on","mailpoet"),children:m.U.Date.full(e.updated_at)})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,g.jsxs)(g.Fragment,{children:[0===this.state.newslettersCount&&(0,g.jsx)(za,{filter:e=>"notification"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,g.jsx)(Re.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,endpoint:"newsletters",type:"notification",base_url:"notification",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:$n,bulk_actions:Wn,item_actions:Bn,messages:Ln,auto_refresh:!0,sort_by:"updated_at",sort_order:"desc",afterGetItems:e=>{if(!e.loading){const t=e.groups.reduce((e,t)=>e+t.count,0);this.setState({newslettersCount:t})}(0,Xa.DP)(e),(0,Xa.tQ)(e)}})]})}}qn.propTypes={location:rt().object.isRequired,params:rt().object.isRequired},qn.displayName="NewsletterListNotification";const Hn=(0,o.withBoundary)(qn);function zn(e){const t=(0,ke.zy)(),a=(0,ke.g)();return(0,g.jsx)(Hn,{...e,location:t,params:a})}const Vn=m.U.trackingConfig.emailTrackingEnabled,Yn={onNoItemsFound:(e,t)=>t?(0,p.__)("No emails found.","mailpoet"):(0,p.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was moved to the trash.","mailpoet"):(0,p.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was permanently deleted.","mailpoet"):(0,p.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email has been restored from the Trash.","mailpoet"):(0,p.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},Gn=[{name:"subject",label:(0,p.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,p.__)("Settings","mailpoet")},{name:"statistics",label:(0,p.__)("Clicked, Opened","mailpoet"),display:Vn},{name:"status",label:(0,p.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,p.__)("Last modified on","mailpoet"),sortable:!0}],Kn=[{name:"trash",label:(0,p.__)("Move to trash","mailpoet"),onSuccess:Yn.onTrash}];let Qn=[{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Preview","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Duplicate","mailpoet"),onClick:(e,t)=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done(e=>{m.U.Notice.success((0,p.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,_n.Zn)(e.data.subject))),t()}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,p.__)("Edit","mailpoet"),onClick:Xa.$U},{name:"trash",className:"mailpoet-hide-on-mobile"}];Qn=(0,Xa.pE)(Qn);class Jn extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:Number(t.target.getAttribute("data-id")),status:e?"active":"draft"}}).done(e=>{"active"===e.data.status&&m.U.Notice.success((0,p.__)("Your Re-engagement Email is now activated!","mailpoet")),this.forceUpdate()}).fail(a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e})};renderStatus=e=>{const t=(0,p._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",e.total_sent.toLocaleString());return(0,g.jsxs)("div",{children:[(0,g.jsx)(Ai.l,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status}),(0,g.jsx)("p",{className:"mailpoet-listing-stats-description",children:(0,g.jsx)(Ne.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:t})})]})};renderSettings=e=>{if(0===e.segments.length)return(0,g.jsx)(Ne.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,p.__)("You need to select a list to send to.","mailpoet")});const t=at()((0,p.__)("Send to %1$s","mailpoet"),"%1$s",(t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsx)(fn.vC,{segments:e.segments},`segment-${a}`),(0,g.jsx)(fn.y,{newsletter:e},`filter-segment-${a}`)]},a));let a=(0,p._x)("month",'month in the sentence "1 month after inactivity"',"mailpoet");e.options.afterTimeNumber>1&&"months"===e.options.afterTimeType?a=(0,p._x)("months",'months in the sentence "5 months after inactivity"',"mailpoet"):e.options.afterTimeNumber>1&&"weeks"===e.options.afterTimeType?a=(0,p._x)("weeks",'weeks in the sentence "5 weeks after inactivity"',"mailpoet"):1===e.options.afterTimeNumber&&"weeks"===e.options.afterTimeType&&(a=(0,p._x)("week",'week in the sentence "1 week after inactivity"',"mailpoet"));const i=(0,p._x)("{$count} {$frequency} after inactivity",'example: "5 months after inactivity"',"mailpoet").replace("{$count}",e.options.afterTimeNumber).replace("{$frequency}",a);return(0,g.jsxs)("span",{children:[t,(0,g.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,g.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,g.jsx)(Mn.x,{})}),i]})]})};renderItem=(e,t)=>{const a=Z()("manage-column","column-primary","has-row-actions");return(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:a,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:m.U.getActiveEmailEditorUrl(e),onClick:t=>{t.preventDefault(),(0,Xa.$U)(e)},children:e.subject}),t]}),(0,g.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,p.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===Vn?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,p.__)("Clicked, Opened","mailpoet"),children:(0,g.jsx)(Cn,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,g.jsx)("td",{className:"column","data-colname":(0,p.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,p.__)("Last modified on","mailpoet"),children:m.U.Date.full(e.updated_at)})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,g.jsxs)(g.Fragment,{children:[0===this.state.newslettersCount&&(0,g.jsx)(za,{filter:e=>"re_engagement"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,g.jsx)(Re.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,endpoint:"newsletters",type:"re_engagement",base_url:"re_engagement",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:Gn,bulk_actions:Kn,item_actions:Qn,messages:Yn,auto_refresh:!0,sort_by:"updated_at",sort_order:"desc",afterGetItems:e=>{if(!e.loading){const t=e.groups.reduce((e,t)=>e+t.count,0);this.setState({newslettersCount:t})}(0,Xa.DP)(e),(0,Xa.tQ)(e)}})]})}}Jn.propTypes={location:rt().object.isRequired,params:rt().object.isRequired},Jn.displayName="NewsletterListReEngagement";const Zn=(0,o.withBoundary)(Jn);function Xn(e){const t=(0,ke.zy)(),a=(0,ke.g)();return(0,g.jsx)(Zn,{...e,location:t,params:a})}const er=m.U.trackingConfig.emailTrackingEnabled,tr=[{name:"subject",label:(0,p.__)("Subject","mailpoet")},{name:"status",label:(0,p.__)("Status","mailpoet")},{name:"segments",label:(0,p.__)("Lists","mailpoet")},{name:"statistics",label:(0,p.__)("Clicked, Opened","mailpoet"),display:er},{name:"sent_at",label:(0,p.__)("Sent on","mailpoet"),sortable:!0}],ar={onNoItemsFound:(e,t)=>t?(0,p.__)("No emails found.","mailpoet"):(0,p.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was moved to the trash.","mailpoet"):(0,p.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email was permanently deleted.","mailpoet"):(0,p.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,p.__)("1 email has been restored from the Trash.","mailpoet"):(0,p.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},ir=[{name:"trash",label:(0,p.__)("Move to trash","mailpoet"),onSuccess:ar.onTrash}],sr=(0,Xa.pE)([{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Preview","mailpoet")})}},{name:"trash",className:"mailpoet-hide-on-mobile"}]),nr=(e,t,a)=>{const i=Z()("manage-column","column-primary","has-row-actions");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{className:i,children:[(0,g.jsx)("strong",{children:(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:e.queue.newsletter_rendered_subject||e.subject})}),t]}),(0,g.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,p.__)("Status","mailpoet"),children:(0,g.jsx)(jn,{newsletter:e,mailerLog:a.mta_log})}),(0,g.jsxs)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,p.__)("Lists","mailpoet"),children:[(0,g.jsx)(fn.vC,{segments:e.segments,dimension:"large"}),(0,g.jsx)(fn.y,{newsletter:e,dimension:"large"})]}),!0===er?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,p.__)("Clicked, Opened","mailpoet"),children:(0,g.jsx)(Cn,{newsletter:e,currentTime:a.current_time})}):null,(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,p.__)("Sent on","mailpoet"),children:e.sent_at?m.U.Date.full(e.sent_at):null})]})};function rr(e){const t=(0,ke.g)(),a=(0,ke.zy)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:(0,g.jsx)(Ne.Link,{className:"mailpoet-button button button-secondary button-small",to:"/notification",children:(0,p.__)("Back to Post notifications","mailpoet")})}),(0,g.jsx)(Re.l,{limit:window.mailpoet_listing_per_page,location:a,params:{...t,parentId:e.parentId},endpoint:"newsletters",type:"notification_history",base_url:"notification/history/:parentId",onRenderItem:nr,columns:tr,messages:ar,item_actions:sr,bulk_actions:ir,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{(0,Xa.DP)(e),(0,Xa.tQ)(e)}})]})}rr.propTypes={parentId:rt().string.isRequired},rr.displayName="NewsletterListNotificationHistory";const or=(0,o.withBoundary)(rr);var lr=a(27314);const dr=[{name:"subscriber_id",label:(0,p.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,p._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet")},{name:"failureReason",label:(0,p.__)("Failure reason (if applicable)","mailpoet")}],cr={onNoItemsFound:()=>(0,p.__)("No sending task found.","mailpoet")};function mr(){const e=(0,ke.g)(),t=(0,ke.zy)(),[a,i]=(0,r.useState)({id:e.id,subject:"",sent:!1}),[s,n]=(0,r.useState)(null),o=(0,r.useRef)(null),l=(0,r.useCallback)(e=>{n(e)},[]);return(0,r.useEffect)(()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:a.id}}).done(e=>i({id:a.id,subject:e.data.subject,sent:null!==e.data.sent_at})).fail(e=>m.U.Notice.showApiErrorNotice(e))},[a.id]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h1",{children:(0,p._x)("Sending status","Page title. This page displays a list of emails along with their sending status: unprocessed, sent or failed.","mailpoet")}),(0,g.jsx)(hr,{newsletter:a}),a.sent&&0===s&&(0,g.jsx)("p",{className:"mailpoet-notice mailpoet-notice-info",children:(0,lr.A)((0,p.__)("Sending status data is no longer available. Per-subscriber records for this newsletter have been cleaned up. You can adjust the retention period in Advanced settings.","mailpoet"),{link:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-settings#/advanced",children:" "})})}),(0,g.jsx)(pr,{location:t,params:e,refreshRef:o,onItemCountUpdate:l})]})}mr.displayName="SendingStatus";const ur=(e,t)=>e.location.pathname===t.location.pathname&&e.params.id===t.params.id,pr=(0,r.memo)(({location:e,params:t,refreshRef:a,onItemCountUpdate:i})=>(0,g.jsx)(Re.l,{limit:window.mailpoet_listing_per_page,location:e,params:t,endpoint:"sending_task_subscribers",base_url:"sending-status/:id",onRenderItem:e=>((e,t)=>(0,g.jsx)("div",{children:(0,g.jsx)(gr,{...e,refreshRef:t})}))(e,a),getListingItemKey:e=>`${e.taskId}-${e.subscriberId}`,columns:dr,messages:cr,auto_refresh:!0,sort_by:"failed",sort_order:"desc",refreshRef:a,afterGetItems:e=>{(0,Xa.DP)(e),(0,Xa.tQ)(e),"function"!=typeof i||"all"!==e.group||e.search||i(e.count)}}),ur);function hr({newsletter:e={id:null,subject:null,sent:!1}}){return e.id&&e.subject&&e.sent?(0,g.jsx)("p",{children:(0,g.jsx)(Ne.Link,{to:`/stats/${e.id}`,children:e.subject})}):null}function gr({failed:e,taskId:t,processed:a,email:i,subscriberId:s,lastName:n,firstName:r,refreshRef:o=null,error:l=""}){const d=Z()("manage-column","column-primary","has-row-actions");let c=(0,p._x)("Unprocessed","status when the sending of a newsletter has not been processed","mailpoet");return a&&(c=e?(0,g.jsxs)("span",{children:[(0,p._x)("Failed","status when the sending of a newsletter has failed","mailpoet"),(0,g.jsx)("br",{}),(0,g.jsx)("a",{className:"button",href:"#",onClick:e=>{e.preventDefault(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sending_task_subscribers",action:"resend",data:{taskId:t,subscriberId:s}}).done(()=>o?.current&&o.current()).fail(e=>m.U.Notice.showApiErrorNotice(e))},children:(0,p.__)("Resend","mailpoet")})]}):(0,p._x)("Sent","status when a newsletter has been sent","mailpoet")),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{"data-automation-id":`name_${t}_${s}`,className:d,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-subscribers#/edit/${s}`,children:i}),(0,g.jsx)("div",{className:"mailpoet-listing-subtitle",children:`${r} ${n}`})]}),(0,g.jsx)("td",{className:"column","data-automation-id":`status_${t}_${s}`,"data-colname":(0,p._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet"),children:c}),(0,g.jsx)("td",{className:"column","data-automation-id":`error_${t}_${s}`,"data-colname":(0,p.__)("Failure reason (if applicable)","mailpoet"),children:l})]})}pr.propTypes={location:rt().shape({pathname:rt().string}).isRequired,params:rt().shape({id:rt().string.isRequired}).isRequired,refreshRef:rt().shape({current:rt().func}),onItemCountUpdate:rt().func},hr.propTypes={newsletter:rt().shape({id:rt().string,subject:rt().string,sent:rt().bool})},gr.propTypes={error:rt().string,email:rt().string.isRequired,failed:rt().number.isRequired,taskId:rt().number.isRequired,lastName:rt().string.isRequired,firstName:rt().string.isRequired,processed:rt().number.isRequired,subscriberId:rt().number.isRequired,refreshRef:rt().shape({current:rt().func})},gr.displayName="ListingItem",mr.displayName="SendingStatus";var _r=a(14051),fr=a(65270),br=a(38255),xr=a.n(br);function vr({installedDaysAgo:e,reviewRequestIllustrationUrl:t,username:a}){const i=Math.round(e/30),s=e>30?(0,p.sprintf)((0,p._n)("You’ve been using MailPoet for %d month now, and we would love to read your own review.","You’ve been using MailPoet for %d months now, and we would love to read your own review.",i,"mailpoet"),i):(0,p.sprintf)((0,p._n)("You’ve been using MailPoet for %d day now, and we would love to read your own review.","You’ve been using MailPoet for %d days now, and we would love to read your own review.",e,"mailpoet"),e);return(0,g.jsxs)("div",{className:"mailpoet_review_request",children:[(0,g.jsx)("img",{src:t,height:"280",width:"280",alt:""}),(0,g.jsx)("h2",{children:(0,p.__)("Thank you! Time to tell the world?","mailpoet")}),(0,g.jsx)("p",{children:(0,p.sprintf)((0,p.__)("%s, did you know that hundreds of WordPress users read the reviews on the plugin repository? They’re also a source of inspiration for our team.","mailpoet"),(0,_n.Zn)(a))}),(0,g.jsx)("p",{children:s}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:"http://bit.ly/2Bi124o",target:"_blank",rel:"noopener noreferrer",className:"button button-primary",children:(0,p.__)("Rate us now","mailpoet")})}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{id:"mailpoet_review_request_not_now",children:(0,p.__)("Not now")})})]})}const yr=(e=null)=>new Promise((t,a)=>{window.mailpoet_display_nps_poll&&window.mailpoet_3rd_party_libs_enabled?(zs||(zs=m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"analytics",action:"getTrackingData"})),zs).then(({data:a})=>{((e,t)=>{let a;a=t||(window.mailpoet_display_nps_form?"EqOgKsgZd832Sz9w":window.mailpoet_is_new_user?"6L479eVPXk7pBn6S":"k0aJAsQAWI2ERyGv");const i={name:window.mailpoet_current_wp_user.user_nicename,email:window.mailpoet_current_wp_user.user_email,mailpoetVersion:window.mailpoet_version,mailpoetPremiumIsActive:window.mailpoet_premium_active,createdAt:e.installedAtIso,newslettersSent:e.newslettersSent,welcomeEmails:e.welcomeEmails,postnotificationEmails:e.postnotificationEmails,woocommerceEmails:e.woocommerceEmails,subscribers:e.subscribers,lists:e.lists,sendingMethod:e.sendingMethod,woocommerceIsInstalled:e.woocommerceIsInstalled,woocommerceVersion:e.woocommerceVersion,WordPressVersion:e.WordPressVersion,blockTheme:e.blockTheme,themeVersion:e.themeVersion,theme:e.theme};e.gutenbergVersion&&(i.gutenbergVersion=e.gutenbergVersion),e.wooCommerceVersion&&(i.wooCommerceVersion=e.wooCommerceVersion),xr()({writeKey:a,userId:window.mailpoet_current_wp_user.ID+window.mailpoet_site_url,traits:i,events:{submit:e=>{e.rating>=9&&e.completed&&m.U.Modal.popup({width:800,template:fr.renderToString(vr({username:window.mailpoet_current_wp_user_firstname||window.mailpoet_current_wp_user.user_login,reviewRequestIllustrationUrl:window.mailpoet_review_request_illustration_url,installedDaysAgo:window.mailpoet_installed_days_ago})),onInit:()=>{document.getElementById("mailpoet_review_request_not_now").addEventListener("click",()=>m.U.Modal.close())}})}}})})(a,e),t()}):a()}),jr=e=>function(t){return(0,r.useLayoutEffect)(()=>{yr().catch(()=>{})},[]),(0,g.jsx)(e,{...t})};function wr(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(We,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(Oe.z,{heading:(0,p.__)("Emails","mailpoet"),children:(0,g.jsx)(Ne.Link,{id:"mailpoet-new-email",className:"page-title-action",to:"/new",onClick:()=>{m.U.trackEvent("Emails > Add New")},"data-automation-id":"new_email",children:(0,p.__)("Add new email","mailpoet")})})]})}function Sr({children:e}){const t=(0,ke.zy)();return null!==(0,Ya.S)(t)||(e=>e.hash.match(/^#\/new/)||e.pathname.match(/^\/new/))(t)?null:e}function Nr(){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:".wrap { margin: 0 !important; }"}})}Sr.propTypes={children:rt().node.isRequired};var kr=a(59617),Cr=a(16791);const Ir=e=>{const t=e<.1?2:1;return m.U.Num.toLocaleFixed(e,t)},Ur=e=>+(+e).toFixed(1);function Er({newsletter:e,isWoocommerceActive:t}){const a=e.total_sent||0;let i=0,s=0,n=0,r=0,o=0;a>0&&(i=100*e.statistics.clicked/a,s=100*e.statistics.opened/a,n=100*e.statistics.machineOpened/a,r=100*e.statistics.unsubscribed/a,o=100*e.statistics.bounced/a);const l=Ir(i),d=Ir(s),c=Ir(n),u=Ir(r),h=Ir(o),_=a>=20&&e.statistics.opened>=5,f=e.statistics.unsubscribed>=5&&a>=100,b=e.statistics.bounced>=5&&a>=100,x=(0,zt.u)("opened",s)||"",v=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${x}`,children:[d,"% "]}),(0,p._x)("opened","Percentage of subscribers that opened a newsletter link","mailpoet")]}),_&&(0,g.jsx)(zt.f,{isInverted:!1,stat:"opened",rate:s,tooltipId:`opened-${e.id||"0"}`,tooltipPlace:"right"})]}),y=(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:"mailpoet-statistics-value-number",children:[c,"% "]}),(0,p._x)("machine-opened","Percentage of newsletters that were opened by a machine","mailpoet"),(0,g.jsx)(Fe.Tooltip,{tooltip:at()((0,p.__)("A machine-opened email is an email opened by a computer in the background without the user’s explicit request or knowledge. [link]Read more[/link]","mailpoet"),/\[link](.*?)\[\/link]/,e=>(0,g.jsx)("span",{style:{pointerEvents:"all"},children:(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/368-what-are-machine-opens",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")},"machine-opened-tooltip"))})]}),j=Ur(r),w=f?(0,zt.u)("unsubscribed",j):"",S=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${w}`,children:[u,"% "]}),(0,p._x)("unsubscribed","Percentage of subscribers that unsubscribed from a newsletter","mailpoet")]}),f&&(0,g.jsx)(zt.f,{isInverted:!1,stat:"unsubscribed",rate:j,tooltipId:`unsubscribed-${e.id||"0"}`,tooltipPlace:"right"})]}),N=Ur(o),k=b?(0,zt.u)("bounced",N):"",C=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${k}`,children:[h,"% "]}),(0,p._x)("bounced","Percentage of subscribers that bounced from a newsletter","mailpoet")]}),b&&(0,g.jsx)(zt.f,{isInverted:!1,stat:"bounced",rate:N,tooltipId:`bounced-${e.id||"0"}`,tooltipPlace:"right"})]}),I=(0,zt.u)("clicked",i),U=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${I}`,children:[l,"% "]}),(0,p._x)("clicked","Percentage of subscribers that clicked a newsletter link","mailpoet")]}),_&&(0,g.jsx)(zt.f,{isInverted:!1,stat:"clicked",rate:i,tooltipId:`clicked-${e.id||"0"}`,tooltipPlace:"right"})]});return(0,g.jsxs)("div",{className:"mailpoet-stats-general",children:[(0,g.jsxs)(ri.Grid.ThreeColumns,{className:"mailpoet-stats-general-top-row",children:[(0,g.jsx)("div",{children:(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,p.__)("Sent to","mailpoet"),": ",(0,g.jsx)("span",{className:"mailpoet-statistics-value-number",children:a.toLocaleString()})]})}),(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:S}),(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:C})]}),(0,g.jsxs)(ri.Grid.ThreeColumns,{children:[(0,g.jsx)("div",{children:U}),(0,g.jsxs)("div",{className:"mailpoet-statistics-with-left-separator",children:[v,m.U.trackingConfig.opensSeparated&&y]}),t&&(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:aa.Hooks.applyFilters("mailpoet_newsletters_revenues_stats",null,e.statistics.revenue)}),!t&&(0,g.jsx)("div",{})]}),(0,g.jsxs)("div",{className:"mailpoet-stats-general-read-more",children:[(0,g.jsx)("p",{className:"mailpoet-stats-has-margin-left",children:(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/190-whats-a-good-email-open-rate",target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Read more on stats.","mailpoet")})}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:`admin.php?page=mailpoet-newsletters#/sending-status/${e.id}`,children:(0,p.__)("Sending status","mailpoet")})})]})]})}Er.displayName="NewsletterGeneralStats";var Ar=a(19718),Tr=a(81692);function Rr(e,t){m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"statisticsExport",action:"exportCampaign",data:{id:e,format:t}}).always(()=>{m.U.Modal.loading(!1)}).done(e=>{const a=e.data?.exportFileURL;a?(m.U.trackEvent("Email statistics export completed",{"File Format":t,"Export Type":"aggregate"}),window.location.href=a):m.U.Notice.error((0,p.__)("The export file could not be generated.","mailpoet"),{scroll:!0})}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}function Pr({newsletter:e}){const[t,a]=(0,r.useState)(!1),{start:i,isExporting:s}=(e=>{const[t,a]=(0,r.useState)(!1),i=(0,r.useRef)(null),s=(0,r.useCallback)(()=>{null!==i.current&&(i.current(),i.current=null)},[]);(0,r.useEffect)(()=>s,[s]);const n=(0,r.useCallback)((e,t)=>{a(!1),e.exportFileURL?(m.U.trackEvent("Email statistics export completed",{"File Format":t,"Export Type":"recipients"}),window.location.href=e.exportFileURL):m.U.Notice.error((0,p.__)("The export file could not be generated.","mailpoet"),{scroll:!0})},[]),o=(0,r.useCallback)(e=>{a(!1),m.U.Notice.error(e,{scroll:!0})},[]),l=(0,r.useCallback)(s=>{t||(a(!0),m.U.Notice.success((0,p.__)("Export queued. The download will start automatically when it is ready.","mailpoet"),{timeout:6e3}),((e,t)=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"statisticsExport",action:"exportRecipients",data:{id:e,format:t}}).then(e=>e.data))(e,s).then(e=>{if(e.exportFileURL)return void n(e,s);const t=In(e.taskId,{onComplete:e=>n(e,s),onError:o});i.current=t.cancel}).catch(e=>{const t=e?.errors?.[0]?.message??(0,p.__)("Could not start the export.","mailpoet");o(t)}))},[o,n,t,e]);return{start:l,isExporting:t}})(e.id);if(!m.U.trackingConfig.emailTrackingEnabled)return null;const n=!m.U.capabilities.detailedAnalytics||m.U.capabilities.detailedAnalytics.isRestricted,o=(e,t)=>{t(),n?a(!0):i(e)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Pa.A,{className:"mailpoet-stats-export-dropdown",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,g.jsxs)(ce.Ay,{variant:"secondary",onClick:t,"aria-expanded":e,"aria-label":(0,p.__)("Export","mailpoet"),isBusy:s,disabled:s,children:[(0,p.__)("Export","mailpoet"),(0,g.jsx)(Da.A,{icon:Oa.A,size:18})]}),renderContent:({onClose:t})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Tr.A,{label:(0,p.__)("Campaign summary","mailpoet"),children:[(0,g.jsx)(Ta.A,{className:"mailpoet-no-box-shadow",onClick:()=>{Rr(e.id,"csv"),t()},children:(0,p.__)("Export as CSV","mailpoet")}),(0,g.jsx)(Ta.A,{className:"mailpoet-no-box-shadow",onClick:()=>{Rr(e.id,"xlsx"),t()},children:(0,p.__)("Export as Excel (XLSX)","mailpoet")})]}),(0,g.jsxs)(Tr.A,{label:(0,p.__)("Per recipient","mailpoet"),children:[(0,g.jsx)(Ta.A,{className:"mailpoet-no-box-shadow",onClick:()=>o("csv",t),children:(0,p.__)("Recipients as CSV","mailpoet")}),(0,g.jsx)(Ta.A,{className:"mailpoet-no-box-shadow",onClick:()=>o("xlsx",t),children:(0,p.__)("Recipients as Excel (XLSX)","mailpoet")})]})]})}),t&&(0,g.jsx)(Ri.D,{onRequestClose:()=>a(!1),data:{capabilities:{detailedAnalytics:!0}},tracking:{utm_medium:"upsell_modal",utm_campaign:"stats_recipients_export"},children:(0,p.__)("Per-recipient statistics export is available with detailed analytics.","mailpoet")})]})}Pr.displayName="ExportButton";const Dr=Ta.A,Or=e=>m.U.getActiveEmailEditorUrl(e);function Fr({newsletter:e,onClose:t}){const a=(0,p.sprintf)((0,p.__)("Re: %s","mailpoet"),e.subject),[i,s]=(0,r.useState)(a),[n,o]=(0,r.useState)(!1);return(0,g.jsxs)(Ue.A,{title:(0,p.__)("Resend to non-openers","mailpoet"),onRequestClose:t,children:[(0,g.jsx)("p",{children:(0,p.__)("This will send a copy of this email to subscribers who haven’t opened it. A different subject line is required.","mailpoet")}),(0,g.jsx)(Ar.A,{label:(0,p.__)("New subject line","mailpoet"),value:i,onChange:s,help:(0,p.__)("Must be different from the original subject.","mailpoet")}),(0,g.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px"},children:[(0,g.jsx)(ce.Ay,{variant:"tertiary",onClick:t,disabled:n,children:(0,p.__)("Cancel","mailpoet")}),(0,g.jsx)(ce.Ay,{variant:"primary",onClick:()=>{i.trim()&&(o(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"resendToNonOpeners",data:{id:e.id,subject:i.trim()}}).done(()=>{m.U.Notice.success((0,p.__)("A copy of this email is being sent to non-openers.","mailpoet"),{static:!0}),t()}).fail(e=>{e?.errors?.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}).always(()=>{o(!1)}))},isBusy:n,disabled:!i.trim()||n,children:(0,p.__)("Resend","mailpoet")})]})]})}function Mr({newsletter:e}){const[t,a]=(0,r.useState)(!1),[i,s]=(0,r.useState)(!1),n=function(e){if("standard"!==e.type||"sent"!==e.status)return{eligible:!1};const t=e.sent_at;if(!t)return{eligible:!1,reason:(0,p.__)("No send date available.","mailpoet")};const a=(Date.now()-new Date(t).getTime())/36e5;if(a<24){const e=Math.ceil(24-a);return{eligible:!1,reason:(0,p.sprintf)((0,p._n)("Available in %d hour.","Available in %d hours.",e,"mailpoet"),e)}}return a>72?{eligible:!1,reason:(0,p.__)("Resend window expired (3 days).","mailpoet")}:{eligible:!0}}(e),l=e?.queue?.scheduled_at||e?.queue?.created_at||e?.created_at;return(0,g.jsxs)(ri.Grid.ThreeColumns,{className:"mailpoet-stats-info",children:[(0,g.jsxs)("div",{children:[(0,g.jsxs)(jt.D,{level:1,children:[e.campaign_name?e.campaign_name:e.subject,e.campaign_name&&(0,g.jsx)("span",{children:` (${e.subject})`})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)(o.Tag,{isInverted:!1,children:(0,o.getNewsletterStatusString)(e.status)})," ",(0,g.jsxs)("b",{children:[m.U.Date.short(l)," • ",m.U.Date.time(l)]})]}),Array.isArray(e.segments)&&e.segments.length&&(0,g.jsxs)("div",{children:[(0,g.jsx)("span",{className:"mailpoet-stats-info-key",children:(0,p.__)("To","mailpoet")}),": ",(0,g.jsx)(o.SegmentTags,{dimension:"large",segments:e.segments}),(0,g.jsx)(o.FilterSegmentTag,{newsletter:e,dimension:"large"})]})]}),(0,g.jsx)("div",{className:"mailpoet-stats-info-sender-preview",children:(0,g.jsxs)("div",{children:[(0,g.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,g.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,p.__)("From","mailpoet"),": "]}),e.sender_address?e.sender_address:"-"]}),(0,g.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,g.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,p.__)("Reply-to","mailpoet"),": "]}),e.reply_to_address?e.reply_to_address:"-"]}),(0,g.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,g.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,p.__)("GA campaign","mailpoet"),": "]}),e.ga_campaign?e.ga_campaign:"-"]})]})}),(0,g.jsx)("div",{className:"mailpoet-stats-button-group",children:(0,g.jsxs)(Ra.A,{children:[(0,g.jsx)(Pr,{newsletter:e}),(0,g.jsx)(ce.Ay,{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",variant:"secondary",children:(0,p.__)("Preview","mailpoet")}),(0,g.jsx)(Pa.A,{className:"mailpoet-stats-has-margin-left",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:a})=>(0,g.jsxs)(Ra.A,{children:[(0,g.jsx)(ce.Ay,{disabled:"standard"!==e.type,onClick:()=>{(e=>{const t=Or(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,o.confirmAlert)({message:(0,p.__)("Sending is in progress. Do you want to pause sending and edit the newsletter?","mailpoet"),onConfirm:()=>{window.location.href=`${t}&pauseConfirmed=yes`}}):window.location.href=t})(e)},variant:"primary",children:(0,p.__)("Edit","mailpoet")}),(0,g.jsxs)(ce.Ay,{onClick:a,"aria-expanded":t,variant:"primary",children:[" ",(0,g.jsx)(Da.A,{icon:Oa.A,size:18})]})]}),renderContent:()=>(0,g.jsxs)(Tr.A,{children:[(0,g.jsx)(Dr,{isBusy:t,className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:"standard"!==e.type,onClick:()=>{a(!0),((e,t=()=>{})=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done(t=>{const a=Or(t.data);m.U.Notice.success((0,p.sprintf)((0,p.__)('Email "%s" has been duplicated. New email: %s ',"mailpoet"),e.subject,a,t.data.subject),{static:!0})}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}).always(()=>{t()})})(e,()=>{a(!1)})},children:(0,p.__)("Duplicate","mailpoet")}),"standard"===e.type&&"sent"===e.status&&(0,g.jsx)(Dr,{className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:!n.eligible,onClick:()=>{n.eligible&&s(!0)},info:n.reason,children:(0,p.__)("Resend to non-openers","mailpoet")}),(0,g.jsx)(Dr,{isBusy:t,isDestructive:!0,onClick:()=>{a(!0),((e,t=()=>{})=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"trash",data:{id:e.id}}).done(()=>{m.U.Notice.success((0,p.__)("1 email was moved to the trash.","mailpoet")),window.location.href="?page=mailpoet-newsletters"}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}).always(()=>{t()})})(e,()=>{a(!1)})},children:(0,p.__)("Move to Trash","mailpoet")})]})})]})}),i&&(0,g.jsx)(Fr,{newsletter:e,onClose:()=>s(!1)})]})}function Lr(){const e=(0,g.jsx)(Le.$,{href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,"starter",{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Upgrade","mailpoet")}),t=(0,g.jsxs)("p",{children:[(0,p.__)("Learn more about your subscribers and optimize your campaigns. See who opened your emails, which links they clicked, and then use the data to make your emails even better. And if you run a WooCommerce store, you’ll also see the revenue earned per email.","mailpoet")," ",(0,g.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",children:(0,p.__)("Learn more","mailpoet")}),"."]});return(0,g.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,g.jsx)(xa,{message:t,actionButton:e,capabilities:{detailedAnalytics:!0}})})}function $r(){return window.mailpoet_display_detailed_stats?null:(0,g.jsx)(Lr,{})}Mr.displayName="NewsletterStatsInfo",$r.displayName="PremiumBanner";const Wr=(0,o.withBoundary)($r);function Br(){const[e,t]=(0,r.useState)({item:void 0,loading:!0}),a=(0,ke.zy)(),i=(0,ke.Zp)(),s=(0,ke.g)(),n=(0,r.useCallback)(a=>{t({loading:!0,item:e.item}),m.U.Modal.loading(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:window.mailpoet_display_detailed_stats?"stats":"newsletters",action:window.mailpoet_display_detailed_stats?"get":"getWithStats",data:{id:a,accept:"all"}}).always(()=>{m.U.Modal.loading(!1)}).done(e=>{t({loading:!1,item:e.data})}).fail(e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0}),t({loading:!1}),i("/")})},[i,e.item]);(0,r.useEffect)(()=>{window.scrollTo(0,0),e.item?.id!==s.id&&n(s.id)},[s.id,n,e.item]);const{item:l,loading:c}=e,u=l;return c?null:u?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Nr,{}),(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsxs)("div",{className:"mailpoet-stats-page",children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Mr,{newsletter:u})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Er,{newsletter:u,isWoocommerceActive:m.U.isWoocommerceActive})}),(0,g.jsxs)(kr.t,{activeKey:"clicked",children:[(0,g.jsx)(Cr.o,{title:(0,p.__)("Clicked Links","mailpoet"),children:aa.Hooks.applyFilters("mailpoet_newsletters_clicked_links_table",(0,g.jsx)(Wr,{}),u.clicked_links)},"clicked"),m.U.isWoocommerceActive&&(0,g.jsx)(Cr.o,{title:(0,p.__)("Products Sold","mailpoet"),automationId:"products-sold-tab",children:aa.Hooks.applyFilters("mailpoet_newsletters_purchased_products",(0,g.jsx)(Wr,{}),u)},"products"),(0,g.jsx)(Cr.o,{title:(0,p.__)("Subscriber Engagement","mailpoet"),automationId:"engagement-tab",children:aa.Hooks.applyFilters("mailpoet_newsletters_subscriber_engagement",(0,g.jsx)(Wr,{}),a,s,u)},"engagement"),(0,g.jsx)(Cr.o,{title:(0,p._x)("Bounces","A tab title for the list of bounces (w.wiki/45Qc)","mailpoet"),automationId:"bounces-tab",children:aa.Hooks.applyFilters("mailpoet_newsletters_bounces",(0,g.jsx)(Wr,{}),a,s)},"bounces"),(0,g.jsx)(Cr.o,{title:(0,p.__)("Unsubscribe reasons","mailpoet"),automationId:"unsubscribe-reasons-tab",children:aa.Hooks.applyFilters("mailpoet_newsletters_unsubscribe_reasons",(0,g.jsx)(Wr,{}),u.statistics.unsubscribeReasons)},"unsubscribe-reasons")]})]})]}):(0,g.jsxs)("h3",{children:[" ",(0,p.__)("This email does not exist.","mailpoet")," "]})}function qr({newsletters:e}){return(0,g.jsxs)(h.$,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,g.jsx)("h3",{children:(0,p.__)("Paused emails","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("There was problem sending the following email(s), please fix the issues described for each email and resume.","mailpoet")}),(0,g.jsx)("ul",{children:e.map(({id:e,subject:t})=>(0,g.jsx)("li",{children:t},e))})]})}Br.displayName="CampaignStatsPage",qr.displayName="CorruptEmailNotice";var Hr=a(73193);function zr(){const e=(0,r.useCallback)(()=>{(0,Hr.k)({endpoint:"UserFlags",method:"set","data[legacy_automatic_emails_notice_dismissed]":"1"})},[]);return(0,g.jsx)(h.$,{type:"info",timeout:!1,closable:!0,renderInPlace:!0,onClose:e,children:(0,g.jsx)("p",{children:(0,lr.A)((0,p.__)("We moved your existing Welcome and WooCommerce emails to Automations. Rest assured, all your automations are still actively running. View automations","mailpoet"),{link:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-automation"})})})})}const Vr=jr(()=>{const{parentId:e}=(0,ke.g)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Sr,{children:(0,g.jsx)(wr,{})}),window.mailpoet_legacy_automatic_emails_count>0&&!window.mailpoet_legacy_automatic_emails_notice_dismissed&&(0,g.jsx)(zr,{}),m.U.corrupt_newsletters.length>0&&(0,g.jsx)(qr,{newsletters:m.U.corrupt_newsletters}),(0,g.jsxs)(_r.k,{activeKey:"standard",routerType:"switch-only",onSwitch:e=>(e=>{m.U.trackEvent(`Tab Emails > ${e} clicked`)})(e),automationId:"newsletters_listing_tabs",children:[(0,g.jsx)(o.Tab,{route:"standard/*",title:(0,p.__)("Newsletters","mailpoet"),automationId:`tab-${(0,p.__)("Newsletters","mailpoet")}`,children:(0,g.jsx)(Fn,{})},"standard"),(0,g.jsx)(o.Tab,{route:"notification/*",title:(0,p.__)("Post Notifications","mailpoet"),automationId:`tab-${(0,p.__)("Post Notifications","mailpoet")}`,children:e?(0,g.jsx)(or,{parentId:e}):(0,g.jsx)(zn,{})},"notification"),(0,g.jsx)(o.Tab,{route:"re_engagement/*",title:(0,p.__)("Re-engagement Emails","mailpoet"),automationId:`tab-${(0,p.__)("Re-engagement Emails","mailpoet")}`,children:(0,g.jsx)(Xn,{})},"re_engagement")]})]})}),Yr=[{path:"/notification/history/:parentId/*",children:(0,o.withBoundary)(Vr)},{path:"/standard/*",children:(0,o.withBoundary)(Vr)},{path:"/notification/*",children:(0,o.withBoundary)(Vr)},{path:"/re_engagement/*",children:(0,o.withBoundary)(Vr)},{path:"/new/standard",children:(0,o.withBoundary)(function(e){const t=(0,ke.Zp)();return(0,g.jsx)(un,{...e,navigate:t})})},{path:"/new/notification",children:(0,o.withBoundary)(function(){const e=(0,ke.Zp)();return(0,g.jsx)(hn,{navigate:e})})},{path:"/new/re-engagement",children:(0,o.withBoundary)(gn)},{path:"/new",children:(0,o.withBoundary)(function(){return(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(d.x,{}),(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(Oe.z,{heading:(0,p.__)("What would you like to create?","mailpoet"),headingPrefix:(0,g.jsx)(Oe.o,{href:"#/",label:(0,p.__)("Listing","mailpoet"),"aria-label":(0,p.__)("Go back to email listing page","mailpoet")})}),(0,g.jsx)(za,{})]})]})})},{name:"template",path:"/template/:id",children:(0,o.withBoundary)(function(e){const t=(0,ke.g)();return(0,g.jsx)(ti,{...e,params:t})})},{path:"/send/congratulate/:id",children:(0,o.withBoundary)(function(e){const t=(0,ke.g)();return(0,g.jsx)(mn,{...e,params:t})})},{path:"/send/:id",children:(0,o.withBoundary)(function(e){const t=(0,ke.zy)(),a=(0,ke.Zp)(),i=(0,ke.g)();return(0,g.jsx)(Xs,{...e,location:t,navigate:a,params:i})})},{path:"/sending-status/:id/*",children:(0,o.withBoundary)(mr)},{path:"/stats/:id/*",children:(0,o.withBoundary)(Br)}];function Gr(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(_,{mailpoetInstalledDaysAgo:m.U.installedDaysAgo,sendTransactionalEmails:m.U.transactionalEmailsEnabled,mtaMethod:m.U.mtaMethod,apiVersion:m.U.apiVersion,noticeDismissed:m.U.transactionalEmailsOptInNoticeDismissed})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(b.D,{})}),(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:"/",element:(0,g.jsx)(ke.C5,{to:0===window.mailpoet_newsletters_count?"/new":"/standard"})}),Yr.map(e=>(0,g.jsx)(ke.qh,{path:e.path,element:(0,g.jsx)(e.children,{})},e.path))]})]})})}const Kr=document.getElementById("newsletters_container");Kr&&((0,o.registerTranslations)(),(0,n.H)(Kr).render((0,g.jsx)(Gr,{})));var Qr=a(14755),Jr=a(94779),Zr=a(53169),Xr=a(84051),eo=a(60782);function to(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{}),(0,g.jsx)(Oe.z,{heading:(0,p.__)("Lists","mailpoet"),children:(0,g.jsx)(Ne.Link,{className:"page-title-action",to:"/new","data-automation-id":"new-list",children:(0,p.__)("Add new list","mailpoet")})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(Me,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)($e,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]}),(0,g.jsx)(b.D,{})]})}var ao=a(80502),io=a(85123);let so=!1;function no(){if(so)return;const e=window.mailpoet_segments_api;ao.default.use(ao.default.createRootURLMiddleware(`${e.root}/`)),ao.default.use(ao.default.createNonceMiddleware(e.nonce)),so=!0}function ro(e,t){return(0,r.createElement)("span",{"data-automation-id":`listing_item_${e.id}_${t}_count`},Number(e.subscribers_count[t]??0).toLocaleString())}const oo=[{id:"name",label:(0,p.__)("Name","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{const t=0===Number(e.show_in_manage_subscription_page)?(0,r.createElement)("span",{className:"mailpoet-listing-title-private-label"},` ${m.U.I18n.t("privateListLabel")}`):null,a=[e.name,t].filter(Boolean),i={className:"mailpoet-listing-title","data-automation-id":`listing_item_${e.id}`},s=t=>(0,r.createElement)("span",{"data-automation-id":`segment_name_${e.name}`},t),n=(0,r.createElement)("div",{className:"mailpoet-listing-actions-holder"},(0,r.createElement)("div",{className:"mailpoet-listing-actions"},(0,r.createElement)("a",{"data-automation-id":`view_subscribers_${e.name}`,href:e.subscribers_url},m.U.I18n.t("viewSubscribers"))));return"wp_users"===e.type||"woocommerce_users"===e.type?(0,r.createElement)("div",null,s((0,r.createElement)("span",i,...a)),n):(0,r.createElement)("div",null,s((0,r.createElement)("a",{...i,href:`#/edit/${e.id}`},...a)),n)}},{id:"description",label:(0,p.__)("Description","mailpoet"),enableSorting:!1,enableGlobalSearch:!1},...m.U.trackingConfig.emailTrackingEnabled?[{id:"average_engagement_score",label:m.U.I18n.t("listScore"),enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)(ge,{id:Number(e.id),engagementScore:e.average_engagement_score})}]:[],{id:"subscribed",label:m.U.I18n.t("subscribed"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>ro(e,"subscribed")},{id:"unconfirmed",label:m.U.I18n.t("unconfirmed"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>ro(e,"unconfirmed")},{id:"unsubscribed",label:m.U.I18n.t("unsubscribed"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>ro(e,"unsubscribed")},{id:"inactive",label:m.U.I18n.t("inactive"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>ro(e,"inactive")},{id:"bounced",label:m.U.I18n.t("bounced"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>ro(e,"bounced")},{id:"created_at",label:m.U.I18n.t("createdOn"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{return(t=e.created_at)?(0,r.createElement)("span",null,m.U.Date.full(t)):(0,r.createElement)("span",null,"—");var t}}],lo=Number(window.mailpoet_listing_per_page),co={type:"table",perPage:lo,page:1,sort:{field:"name",direction:"asc"},fields:["description",...m.U.trackingConfig.emailTrackingEnabled?["average_engagement_score"]:[],"subscribed","unconfirmed","unsubscribed","inactive","bounced","created_at"],titleField:"name",showTitle:!0};function mo(e){return"wp_users"===e.type}function uo(e){return"woocommerce_users"===e.type}function po(e){return mo(e)||uo(e)}function ho(){const e=window.location.hash.split("/").map(e=>e.replace(/\]$/,"").split("[")).reduce((e,[t,a])=>a?"group"!==t||"all"!==a&&"trash"!==a?("page"===t||"paged"===t)&&Number(a)>0?{...e,page:Number(a)}:("per_page"===t||"limit"===t)&&Number(a)>0?{...e,perPage:Number(a)}:"sort_by"===t||"orderby"===t?{...e,orderby:a}:"sort_order"!==t&&"order"!==t||"asc"!==a&&"desc"!==a?e:{...e,order:a}:{...e,group:a}:e,{}),[t,a]=(0,r.useState)(e.group??"all"),[i,s]=(0,r.useState)([]),[n,o]=(0,r.useState)(null),[l,d]=(0,r.useState)(null),[c,u]=(0,r.useState)(null),[h]=(0,r.useState)(()=>({...co,page:e.page??co.page,perPage:e.perPage??co.perPage,sort:{field:e.orderby??co.sort?.field??"name",direction:e.order??co.sort?.direction??"asc"}})),_=(0,r.useCallback)(e=>async function(e){return no(),(await(0,ao.default)({path:(0,io.F)("/mailpoet/v1/segments",e),method:"GET"})).data}({...e,group:t}),[t]),{view:f,setView:b,items:x,meta:v,groups:y,isLoading:j,error:w,clearError:S,refresh:N}=(0,eo.i)({initialView:h,load:_});(0,r.useEffect)(()=>{!function(e,t){const a=[["group",e],["page",t.page&&1!==t.page?t.page:void 0],["limit",t.perPage&&t.perPage!==lo?t.perPage:void 0],["sort_by",t.sort?.field&&"name"!==t.sort.field?t.sort.field:void 0],["sort_order",t.sort?.direction&&"asc"!==t.sort.direction?t.sort.direction:void 0]].reduce((e,[t,a])=>a?`${e}/${t}[${a}]`:e,"");window.history.replaceState(null,"",`#/lists${a}`)}(t,f)},[t,f]);const k=(0,r.useCallback)(async(e,t,a)=>{const i=t.map(e=>Number(e.id));if(a?.select_all||"empty_trash"===e||0!==i.length)try{const n=await async function(e,t,a){return no(),(await(0,ao.default)({path:"/mailpoet/v1/segments/bulk-action",method:"POST",data:{action:e,ids:t,...a}})).data}(e,i,a),r=function(e,t){return"delete"===e||"empty_trash"===e?t.deleted:t.updated}(e,n);s([]),o(n.errors.length?n.errors.map(e=>e.message).join("\n"):null),d(r>0?function(e,t,a=!1){return"trash"===e?`${a?(0,p.__)("1 list was moved to the trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d list was moved to the trash.","%d lists were moved to the trash.",t,"mailpoet"),t)} ${(0,p.__)("Note that deleting a list does not delete its subscribers.","mailpoet")}`:"restore"===e?1===t?(0,p.__)("1 list has been restored from the Trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d list has been restored from the Trash.","%d lists have been restored from the Trash.",t,"mailpoet"),t):`${(0,p.sprintf)((0,p._n)("%d list was permanently deleted.","%d lists were permanently deleted.",t,"mailpoet"),t)} ${(0,p.__)("Note that deleting a list does not delete its subscribers.","mailpoet")}`}(e,r,t.some(mo)):null),N()}catch(e){const t=e;d(null),o(t?.message||(0,p.__)("The bulk action could not be completed.","mailpoet"))}},[N]),C=(0,r.useCallback)(e=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"duplicate",data:{id:e.id}}).done(e=>{m.U.Notice.success(m.U.I18n.t("listDuplicated").replace("%1$s",(0,_n.Zn)(e.data.name))),N()}).fail(e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[N]),I=(0,r.useCallback)(e=>{m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"synchronize",data:{type:e.type}}).done(()=>{const t="woocommerce_users"===e.type?m.U.I18n.t("listSynchronizationWasScheduled").replace("%1$s",e.name):m.U.I18n.t("listSynchronized").replace("%1$s",e.name);m.U.Modal.loading(!1),m.U.Notice.success(t),N()}).fail(e=>{m.U.Modal.loading(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[N]),U=(0,r.useMemo)(()=>[{id:"edit",label:(0,p.__)("Edit","mailpoet"),isPrimary:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at&&!po(e),callback:e=>{const t=e[0];t&&(window.location.hash=`/edit/${t.id}`)}},{id:"duplicate",label:m.U.I18n.t("duplicate"),supportsBulk:!1,isEligible:e=>!e.deleted_at&&!po(e),callback:e=>{e[0]&&C(e[0])}},{id:"read_more",label:m.U.I18n.t("readMore"),supportsBulk:!1,isEligible:e=>mo(e),callback:()=>{window.open("https://kb.mailpoet.com/article/133-the-wordpress-users-list","_blank","noopener,noreferrer")}},{id:"synchronize",label:m.U.I18n.t("forceSync"),supportsBulk:!1,isEligible:e=>mo(e)||uo(e),callback:e=>{e[0]&&I(e[0])}},{id:"view_subscribers",label:m.U.I18n.t("viewSubscribers"),supportsBulk:!1,callback:e=>{const t=e[0];t&&(window.location.href=t.subscribers_url)}},{id:"trash_wp_users",label:(0,p.__)("Trash and disable","mailpoet"),supportsBulk:!1,isEligible:e=>!e.deleted_at&&mo(e),callback:e=>{k("trash",e)}},{id:"trash",label:m.U.I18n.t("moveToTrash"),supportsBulk:!0,isEligible:e=>!e.deleted_at&&!mo(e)&&!uo(e),callback:e=>{k("trash",e)}},{id:"restore_wp_users",label:(0,p.__)("Restore and enable","mailpoet"),supportsBulk:!1,isEligible:e=>!!e.deleted_at&&mo(e),callback:e=>{k("restore",e)}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:e=>!!e.deleted_at&&!mo(e),callback:e=>{k("restore",e)}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>!!e.deleted_at&&!po(e),callback:e=>{u({action:"delete",targets:e,count:e.length})}}],[k,C,I]),E=(0,r.useMemo)(()=>({totalItems:v.count,totalPages:v.pages}),[v]),A=(0,r.useMemo)(()=>{const e={all:null,trash:null};return(y??[]).forEach(t=>{"all"!==t.name&&"trash"!==t.name||(e[t.name]=t.count)}),e},[y]),T=(0,r.useMemo)(()=>{const e=(e,t)=>null===t?e:`${e} (${t})`;return[{name:"all",title:e((0,p.__)("All","mailpoet"),A.all),className:"mailpoet-dataviews-group-all"},..."trash"===t||(A.trash??0)>0?[{name:"trash",title:e((0,p.__)("Trash","mailpoet"),A.trash),className:"mailpoet-dataviews-group-trash"}]:[]]},[t,A]);(0,r.useEffect)(()=>{"trash"!==t||j||w||0!==A.trash||(a("all"),s([]),b(e=>({...e,page:1})))},[t,A.trash,j,w,b]);const R=e=>{s(e)},P="trash"===t?(0,p.__)("Trash is empty.","mailpoet"):(0,p.__)("No lists found.","mailpoet"),D=function(e){if(!e)return{title:"",message:"",confirmText:""};const{action:t,count:a}=e;return"empty_trash"===t?{title:(0,p.__)("Empty Trash","mailpoet"),message:(0,g.jsxs)(g.Fragment,{children:[(0,p.sprintf)((0,p._n)("Are you sure you want to permanently delete %d list from the Trash?","Are you sure you want to permanently delete %d lists from the Trash?",a,"mailpoet"),a)," ",(0,g.jsx)("strong",{children:(0,p.__)("This action can not be reversed.","mailpoet")})]}),confirmText:(0,p.__)("Empty Trash","mailpoet")}:{title:(0,p._n)("Delete selected list permanently","Delete selected lists permanently",a,"mailpoet"),message:(0,g.jsxs)(g.Fragment,{children:[(0,p.sprintf)((0,p._n)("Are you sure you want to permanently delete %d selected list?","Are you sure you want to permanently delete %d selected lists?",a,"mailpoet"),a)," ",(0,g.jsx)("strong",{children:(0,p.__)("This action can not be reversed.","mailpoet")})]}),confirmText:(0,p.__)("Delete permanently","mailpoet")}}(c);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ma.x,{}),(0,g.jsx)(to,{}),w&&(0,g.jsx)(Qr.A,{status:"error",onRemove:S,children:w}),n&&(0,g.jsx)(Qr.A,{status:"error",onRemove:()=>o(null),children:n}),l&&(0,g.jsx)(Qr.A,{status:"success",onRemove:()=>d(null),children:l}),(0,g.jsx)(Jr.A,{className:"mailpoet-segments-dataviews__tabs",activeClass:"is-active",tabs:T,initialTabName:t,onSelect:e=>{"all"!==e&&"trash"!==e||e!==t&&(a(e),s([]),o(null),d(null),S(),b(e=>({...e,page:1})))},children:()=>(0,g.jsx)("div",{className:"mailpoet-segments-dataviews mailpoet-segments-listing","data-automation-id":"segments_listing",children:(0,g.jsxs)(Xr.A,{data:x,fields:oo,view:f,onChangeView:b,actions:U,paginationInfo:E,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:i,onChangeSelection:R,isLoading:j,empty:(0,g.jsx)("div",{children:P}),children:[(0,g.jsx)("div",{className:"mailpoet-segments-dataviews__toolbar",children:(0,g.jsx)(Xr.A.Search,{label:(0,p.__)("Search","mailpoet")})}),"trash"===t&&(A.trash??0)>0&&(0,g.jsx)("div",{className:"mailpoet-segments-dataviews__toolbar",children:(0,g.jsx)("button",{type:"button",className:"button","data-automation-id":"empty_trash",onClick:()=>{u({action:"empty_trash",targets:[],count:A.trash??0,params:{select_all:!0,group:"trash",page:f.page??1,per_page:f.perPage??lo,orderby:f.sort?.field,order:f.sort?.direction}})},children:(0,p.__)("Empty Trash","mailpoet")})}),(0,g.jsx)(Xr.A.Layout,{}),(0,g.jsx)(Xr.A.Footer,{})]},t)})},t),(0,g.jsx)(Zr.A,{className:"mailpoet-confirm-dialog",isOpen:!!c,title:D.title,confirmButtonText:D.confirmText,__experimentalHideHeader:!1,onConfirm:()=>{c&&k(c.action,c.targets,c.params),u(null)},onCancel:()=>u(null),children:(0,g.jsx)("p",{children:D.message})})]})}const go=window.mailpoet_confirmation_emails||[],_o=window.mailpoet_pages||[],fo={0:(0,p.__)("Use global default","mailpoet")};_o.forEach(e=>{fo[String(e.id)]=e.title});const bo=[{name:"name",label:m.U.I18n.t("segmentFormName"),type:"text",tip:m.U.I18n.t("segmentFormNameTip")},{name:"description",label:m.U.I18n.t("description"),type:"textarea",tip:m.U.I18n.t("segmentDescriptionTip")},{name:"show_in_manage_subscription_page",label:m.U.I18n.t("showInManageSubscriptionPage"),type:"checkbox",values:{show_in_manage_subscription_page:m.U.I18n.t("showInManageSubscriptionPageTip")},isChecked:!0},{name:"confirmation_email_id",label:(0,p.__)("Confirmation email","mailpoet"),type:"reactComponent",component:function({onValueChange:e,item:t}){const[a,i]=(0,r.useState)(go),[s,n]=(0,r.useState)(!1),o=t.confirmation_email_id||"0",l=(0,r.useCallback)(async()=>{n(!0);try{const t=(await m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletters",action:"createConfirmationEmail"})).data;i(e=>[...e,t]),e({target:{name:"confirmation_email_id",value:String(t.id)}});const a=`admin.php?page=mailpoet-newsletter-editor&id=${t.id}`;m.U.Notice.success(`${(0,p.__)("Confirmation email created.","mailpoet")} ${(0,p.__)("Edit it now","mailpoet")}`)}catch(e){m.U.Notice.showApiErrorNotice(e,{scroll:!0})}finally{n(!1)}},[e]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{name:"confirmation_email_id",id:"field_confirmation_email_id",value:o,onChange:e,children:[(0,g.jsx)("option",{value:"0",children:(0,p.__)("Use global default","mailpoet")}),a.map(e=>(0,g.jsx)("option",{value:String(e.id),children:e.subject},e.id))]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Le.$,{type:"button",variant:"secondary",dimension:"small",onClick:l,isDisabled:s,children:s?(0,p.__)("Creating…","mailpoet"):(0,p.__)("Create new","mailpoet")}),"0"!==o&&(0,g.jsx)(Le.$,{variant:"secondary",dimension:"small",href:`admin.php?page=mailpoet-newsletter-editor&id=${o}`,target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Edit","mailpoet")})]})},tip:(0,p.__)("Choose a custom confirmation email for subscribers joining this list. If not set, the global default is used.","mailpoet")},{name:"confirmation_page_id",label:(0,p.__)("Confirmation page","mailpoet"),type:"select",values:fo,tip:(0,p.__)("Choose a custom confirmation page for subscribers joining this list. If not set, the global default is used.","mailpoet")}],xo={onUpdate:function(){m.U.Notice.success(m.U.I18n.t("segmentUpdated"))},onCreate:function(){m.U.Notice.success(m.U.I18n.t("segmentAdded")),m.U.trackEvent("Lists > Add new")}};function vo(){const e=(0,ke.g)();return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Oe.z,{heading:e.id?(0,p.__)("Edit list","mailpoet"):(0,p.__)("Add new list","mailpoet"),headingPrefix:(0,g.jsx)(Oe.o,{href:"#/",label:(0,p.__)("Lists","mailpoet"),"aria-label":(0,p.__)("Navigate to the lists page","mailpoet")})}),(0,g.jsx)(It.X,{}),(0,g.jsx)(Ct,{endpoint:"segments",fields:bo,params:e,messages:xo})]})}vo.displayName="SegmentForm";const yo=document.getElementById("static_segments_container"),jo=(0,o.withBoundary)(vo),wo=(0,o.withBoundary)(function(){return(0,g.jsx)(ho,{})});function So(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:"/new",element:(0,g.jsx)(jo,{})}),(0,g.jsx)(ke.qh,{path:"/edit/:id",element:(0,g.jsx)(jo,{})}),(0,g.jsx)(ke.qh,{path:"*",element:(0,g.jsx)(wo,{})})]})]})})}yo&&((0,o.registerTranslations)(),(0,n.H)(yo).render((0,g.jsx)(So,{})));var No=a(38094),ko=a(8392);function Co({children:e,title:t,description:a}){return(0,g.jsxs)("div",{className:"mailpoet-admin-fields",children:[(0,g.jsxs)("div",{className:"mailpoet-admin-fields-title",children:[(0,g.jsx)(ko.D,{level:4,children:t}),(0,g.jsx)("p",{children:a})]}),(0,g.jsx)(Lt.A,{children:(0,g.jsx)($t.A,{children:e})})]})}function Io({children:e,slug:t,title:a,description:i}){return(0,g.jsxs)("div",{className:"mailpoet-admin-field",children:[a&&(0,g.jsx)("p",{children:(0,g.jsx)("label",{htmlFor:`field_${t}`,children:a})}),(0,g.jsx)("div",{children:e}),i&&(0,g.jsx)("p",{className:"mailpoet-admin-field-description",children:i})]})}var Uo=a(70458),Eo=a(67230),Ao=a(61258),To=a(66542);function Ro({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),a=(0,v.A)(e=>e(Ao.Hz).getAutomations(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,ue.A)(Ao.Hz);(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&i({operator:Eo.dP.ANY},e)},[i,t,e]);const n=a.map(e=>({value:e.id,label:e.name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{s("operator",e,t)},isMinWidth:!0,children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("searchAutomations"),options:n,value:n.filter(e=>{if(!t.automation_ids)return;const a=e.value;return-1!==t.automation_ids.indexOf(a)}),onChange:t=>{i({automation_ids:t.map(e=>e.value)},e)}})]})}const Po={[To.g.ENTERED_AUTOMATION]:Ro,[To.g.EXITED_AUTOMATION]:Ro};function Do({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getNewslettersList(),[]),n=s?.map(e=>{const t=e.sent_at?m.U.Date.format(e.sent_at):m.U.I18n.t("notSentYet");return{label:e.name,tag:t,value:Number(e.id)}});return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e),t.action===Eo._R.MACHINE_OPENED&&t.operator===Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[t.action,t.operator,e,a]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{isMinWidth:!0,automationId:"segment-email-opens-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),t.action!==Eo._R.MACHINE_OPENED?(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")}):null]},"select"),(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:n,automationId:"segment-email",value:(0,$s.filter)(e=>{if(!t.newsletters)return;const a=e.value;return-1!==t.newsletters.indexOf(a)},n),onChange:t=>{a({newsletters:(0,$s.map)((0,$s.parseInt)(10),(0,$s.map)("value",t))},e)}})]})}const Oo=e=>!!e;var Fo=a(65177);function Mo({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,ue.A)(Ao.Hz);(0,r.useEffect)(()=>{(0,Fo.J)(t.timeframe,Eo.VE)||i({timeframe:Eo.VE.IN_THE_LAST},e)},[t,i,e]);const s=t.timeframe===Eo.VE.IN_THE_LAST;return(0,g.jsx)(g.Fragment,{children:(n=i=>s&&"{days}"===i?(0,g.jsx)(o.Input,{type:"number",value:t.days||"","data-automation-id":"segment-number-of-days",onChange:t=>{a("days",e,t)},min:1,step:1,placeholder:m.U.I18n.t("daysPlaceholder")},"input"):"{timeframe}"===i?(0,g.jsxs)(ut.Select,{value:t.timeframe,onChange:t=>{a("timeframe",e,t)},children:[(0,g.jsx)("option",{value:"inTheLast",children:m.U.I18n.t("inTheLast")}),(0,g.jsx)("option",{value:"allTime",children:m.U.I18n.t("overAllTime")})]},"timeframe-select"):s&&"string"==typeof i&&i.trim().length>1?(0,g.jsx)("div",{children:i},i):null,m.U.I18n.t("emailActionOpensDaysSentence").split(/({days})|({timeframe})/gim).map(n))});var n}function Lo(e){return e.timeframe===Eo.VE.ALL_TIME||parseInt(e.days,10)>=1}function $o({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{void 0===t.operator&&a({operator:"more"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{opens}"===a?(0,g.jsx)(ot.p,{type:"number",value:t.opens||"","data-automation-id":"segment-number-of-opens",onChange:t=>{i("opens",e,t)},min:"0",placeholder:m.U.I18n.t("emailActionOpens")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"opens"):null,m.U.I18n.t("emailActionOpensSentence").split(/({condition})|({opens})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]});var s}const Wo={[Eo._R.OPENS_ABSOLUTE_COUNT]:$o,[Eo._R.MACHINE_OPENS_ABSOLUTE_COUNT]:$o,[Eo._R.CLICKED]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getNewslettersList(),[]),[n,o]=(0,r.useState)([]),[l,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),h=s?.map(e=>{const t=e.sent_at?m.U.Date.format(e.sent_at):(0,p.__)("Not sent yet","mailpoet");return{label:e.name,tag:t,value:Number(e.id)}}),_=(0,r.useCallback)(()=>{var e;Oo(t.newsletter_id)&&(d([]),e=t.newsletter_id,o([]),u(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletter_links",action:"get",data:{newsletterId:e}}).then(e=>{const{data:t}=e,a=t.map(e=>({value:e.id,label:e.url}));u(!1),d(a)}).fail(e=>{o(e.errors)}))},[t.newsletter_id]);return(0,r.useEffect)(()=>{_()},[_,t.newsletter_id]),(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[t.operator,e,a]),(0,g.jsxs)(g.Fragment,{children:[n.length>0&&(0,g.jsx)(La,{errors:n}),(0,g.jsx)(No.ReactSelect,{placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:h,value:(0,$s.find)(["value",t.newsletter_id],h),onChange:t=>{a({newsletter_id:t.value,link_ids:[]},e)},automationId:"segment-email"}),(0,g.jsxs)(ut.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{i("operator",e,t)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),c&&(0,g.jsx)("span",{children:m.U.I18n.t("loadingDynamicSegmentItems")}),!c&&Oo(t.newsletter_id)&&(0,g.jsx)(No.ReactSelect,{isMulti:!0,automationId:"segment-link-select",placeholder:m.U.I18n.t("allLinksPlaceholder"),options:l.length?l:[{value:0,label:m.U.I18n.t("noLinksHint"),isDisabled:!0}],value:(0,$s.filter)(e=>!!t.link_ids&&-1!==t.link_ids.indexOf(e.value),l),onChange:t=>{a({link_ids:(t||[]).map(e=>e.value)},e)}})]})},[Eo._R.OPENED]:Do,[Eo._R.WAS_SENT]:Do,[Eo._R.MACHINE_OPENED]:Do,[Eo._R.CLICKED_ANY]:null,[Eo._R.NUMBER_RECEIVED]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{emails}"===a?(0,g.jsx)(ot.p,{type:"number",value:t.emails||"","data-automation-id":"segment-number-emails-received",onChange:t=>{i("emails",e,t)},min:"0",placeholder:(0,p.__)("emails","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"emails"):null,(0,p.__)("{condition} {emails} emails","mailpoet").split(/({condition})|({emails})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]});var s},[Eo._R.NUMBER_OF_CLICKS]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{clicks}"===a?(0,g.jsx)(ot.p,{type:"number",value:t.clicks||"","data-automation-id":"segment-number-of-clicks",onChange:t=>{i("clicks",e,t)},min:"0",placeholder:(0,p.__)("clicks","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"clicks"):null,(0,p.__)("{condition} {clicks} clicks","mailpoet").split(/({condition})|({clicks})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]});var s}};var Bo=a(89011);function qo(e,t){const a=t?.additionalDigits??2,i=function(e){const t={},a=e.split(Ho.dateTimeDelimiter);let i;if(a.length>2)return t;if(/:/.test(a[0])?i=a[0]:(t.date=a[0],i=a[1],Ho.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Ho.timeZoneDelimiter)[0],i=e.substr(t.date.length,e.length))),i){const e=Ho.timezone.exec(i);e?(t.time=i.replace(e[1],""),t.timezone=e[1]):t.time=i}return t}(e);let s;if(i.date){const e=function(e,t){const a=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(a);if(!i)return{year:NaN,restDateString:""};const s=i[1]?parseInt(i[1]):null,n=i[2]?parseInt(i[2]):null;return{year:null===n?s:100*n,restDateString:e.slice((i[1]||i[2]).length)}}(i.date,a);s=function(e,t){if(null===t)return new Date(NaN);const a=e.match(zo);if(!a)return new Date(NaN);const i=!!a[4],s=Go(a[1]),n=Go(a[2])-1,r=Go(a[3]),o=Go(a[4]),l=Go(a[5])-1;if(i)return function(e,t,a){return t>=1&&t<=53&&a>=0&&a<=6}(0,o,l)?function(e,t,a){const i=new Date(0);i.setUTCFullYear(e,0,4);const s=7*(t-1)+a+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+s),i}(t,o,l):new Date(NaN);{const e=new Date(0);return function(e,t,a){return t>=0&&t<=11&&a>=1&&a<=(Qo[t]||(Jo(e)?29:28))}(t,n,r)&&function(e,t){return t>=1&&t<=(Jo(e)?366:365)}(t,s)?(e.setUTCFullYear(t,n,Math.max(s,r)),e):new Date(NaN)}}(e.restDateString,e.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const n=s.getTime();let r,o=0;if(i.time&&(o=function(e){const t=e.match(Vo);if(!t)return NaN;const a=Ko(t[1]),i=Ko(t[2]),s=Ko(t[3]);return function(e,t,a){return 24===e?0===t&&0===a:a>=0&&a<60&&t>=0&&t<60&&e>=0&&e<25}(a,i,s)?a*Bo.s0+i*Bo.Cg+1e3*s:NaN}(i.time),isNaN(o)))return new Date(NaN);if(!i.timezone){const e=new Date(n+o),t=new Date(0);return t.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),t.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),t}return r=function(e){if("Z"===e)return 0;const t=e.match(Yo);if(!t)return 0;const a="+"===t[1]?-1:1,i=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,s)?a*(i*Bo.s0+s*Bo.Cg):NaN}(i.timezone),isNaN(r)?new Date(NaN):new Date(n+o+r)}const Ho={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},zo=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Vo=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Yo=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Go(e){return e?parseInt(e):1}function Ko(e){return e&&parseFloat(e.replace(",","."))||0}const Qo=[31,null,31,30,31,30,31,31,30,31,30,31];function Jo(e){return e%400==0||e%4==0&&e%100!=0}var Zo=a(85963);function Xo(e){if(!(t=e,t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof e))return!1;var t;const a=(0,Zo.a)(e);return!isNaN(Number(a))}let el=function(e){return e.BEFORE="before",e.AFTER="after",e.ON="on",e.ON_OR_BEFORE="onOrBefore",e.ON_OR_AFTER="onOrAfter",e.NOT_ON="notOn",e.IN_THE_LAST="inTheLast",e.NOT_IN_THE_LAST="notInTheLast",e}({});const tl=[el.BEFORE,el.AFTER,el.ON,el.ON_OR_AFTER,el.ON_OR_BEFORE,el.NOT_ON,el.IN_THE_LAST,el.NOT_IN_THE_LAST],al=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return m.U.Date.format(e,{format:"Y-m-d"})}},il=e=>{if(!e)return;const t=qo(e);return Xo(t)?t:void 0};function sl({filterIndex:e,defaultOperator:t}){const a=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{tl.includes(a.operator)||i({operator:t},e),a.operator!==el.BEFORE&&a.operator!==el.AFTER&&a.operator!==el.ON&&a.operator!==el.ON_OR_AFTER&&a.operator!==el.ON_OR_BEFORE&&a.operator!==el.NOT_ON||void 0!==il(a.value)&&/^\d+-\d+-\d+$/.test(a.value)||i({value:al(new Date)},e),a.operator!==el.IN_THE_LAST&&a.operator!==el.NOT_IN_THE_LAST||"string"!=typeof a.value||/^\d*$/.exec(a.value)||i({value:""},e)},[i,a,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:a.operator,isMinWidth:!0,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:el.BEFORE,children:m.U.I18n.t("before")}),(0,g.jsx)("option",{value:el.ON_OR_BEFORE,children:m.U.I18n.t("onOrBefore")}),(0,g.jsx)("option",{value:el.ON,children:m.U.I18n.t("on")}),(0,g.jsx)("option",{value:el.NOT_ON,children:m.U.I18n.t("notOn")}),(0,g.jsx)("option",{value:el.ON_OR_AFTER,children:m.U.I18n.t("onOrAfter")}),(0,g.jsx)("option",{value:el.AFTER,children:m.U.I18n.t("after")}),(0,g.jsx)("option",{value:el.IN_THE_LAST,children:m.U.I18n.t("inTheLast")}),(0,g.jsx)("option",{value:el.NOT_IN_THE_LAST,children:m.U.I18n.t("notInTheLast")})]},"select"),(a.operator===el.BEFORE||a.operator===el.AFTER||a.operator===el.ON||a.operator===el.ON_OR_AFTER||a.operator===el.ON_OR_BEFORE||a.operator===el.NOT_ON)&&(0,g.jsx)(fi.t,{className:"mailpoet-segments-datepicker-small",formatWithWordPressSettings:!0,onChange:t=>{i({value:al(t)},e)},selected:a.value?il(a.value):void 0}),(a.operator===el.IN_THE_LAST||a.operator===el.NOT_IN_THE_LAST)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ot.p,{className:"mailpoet-segments-input-small",type:"number",value:a.value||"",onChange:t=>{s("value",e,t)},min:"1",placeholder:m.U.I18n.t("daysPlaceholder")},"input"),(0,g.jsx)("span",{children:m.U.I18n.t("daysPlaceholder")})]})]})}function nl(e){return!(!e.operator||!e.value)&&([el.BEFORE,el.AFTER,el.ON,el.NOT_ON,el.ON_OR_BEFORE,el.ON_OR_AFTER].includes(e.operator)?/^\d+-\d+-\d+$/.test(e.value):!![el.IN_THE_LAST,el.NOT_IN_THE_LAST].includes(e.operator)&&(/^\d+$/.test(e.value)&&Number(e.value)>0))}function rl(e){return function(t){return(0,g.jsx)(sl,{...t,defaultOperator:e})}}const ol=rl(el.BEFORE),ll=rl(el.IN_THE_LAST);var dl=a(66567);function cl({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{void 0===t.number_of_orders_type&&a({number_of_orders_type:"="},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{value:t.number_of_orders_type,onChange:t=>{i("number_of_orders_type",e,t)},automationId:"select-number-of-orders-type",children:[(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.jsx)(o.Input,{"data-automation-id":"input-number-of-orders-count",type:"number",min:0,value:t.number_of_orders_count||"",placeholder:m.U.I18n.t("wooNumberOfOrdersCount"),onChange:t=>{i("number_of_orders_count",e,t)}}),(0,g.jsx)("div",{children:m.U.I18n.t("wooNumberOfOrdersOrders")})]}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})}const ml=["is","isNot","contains","notContains","startsWith","notStartsWith","endsWith","notEndsWith"];function ul(e){return!!ml.includes(e.operator)&&"string"==typeof e.value&&e.value.length>0}function pl({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{ml.includes(t.operator)||i({operator:"is",value:""},e)},[i,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{automationId:"subscriber-text-field-select",value:t.operator,isMinWidth:!0,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"is",children:m.U.I18n.t("is")}),(0,g.jsx)("option",{value:"isNot",children:m.U.I18n.t("isNot")}),(0,g.jsx)("option",{value:"contains",children:m.U.I18n.t("contains")}),(0,g.jsx)("option",{value:"notContains",children:m.U.I18n.t("notContains")}),(0,g.jsx)("option",{value:"startsWith",children:m.U.I18n.t("startsWith")}),(0,g.jsx)("option",{value:"notStartsWith",children:m.U.I18n.t("notStartsWith")}),(0,g.jsx)("option",{value:"endsWith",children:m.U.I18n.t("endsWith")}),(0,g.jsx)("option",{value:"notEndsWith",children:m.U.I18n.t("notEndsWith")})]},"select"),(0,g.jsx)(ot.p,{className:"mailpoet-segments-input-medium","data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:m.U.I18n.t("value")},"input")]})}const hl={[dl.Ag.CUSTOMER_IN_COUNTRY]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getWooCommerceCountries(),[]).map(e=>({value:e.code,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-country",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-country"),(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectWooCountry"),options:i,value:(0,$s.filter)(e=>{if(t.country_code)return-1!==t.country_code.indexOf(e.value)},i),onChange:t=>{a({country_code:(t||[]).map(e=>e.value)},e)},automationId:"select-segment-country"},"select-segment-country")]})},[dl.Ag.CUSTOMER_IN_CITY]:pl,[dl.Ag.CUSTOMER_IN_POSTAL_CODE]:pl,[dl.Ag.NUMBER_OF_ORDERS]:cl,[dl.Ag.NUMBER_OF_ORDERS_WITH_COUPON]:cl,[dl.Ag.NUMBER_OF_REVIEWS]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{(0,Fo.J)(t.count_type,Eo.YR)||a({count_type:Eo.YR.EQUALS},e),(0,Fo.J)(t.rating,Eo.Un)||a({rating:Eo.Un.ANY},e),(0,Fo.J)(t.timeframe,Eo.VE)||a({timeframe:Eo.VE.IN_THE_LAST},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(o.Select,{value:t.rating,isMinWidth:!0,onChange:t=>{i("rating",e,t)},children:[(0,g.jsx)("option",{value:Eo.Un.ANY,children:m.U.I18n.t("wooAnyStarRating")}),(0,g.jsx)("option",{value:Eo.Un.ONE,children:m.U.I18n.t("wooOneStarRating")}),(0,g.jsx)("option",{value:Eo.Un.TWO,children:m.U.I18n.t("wooTwoStarRating")}),(0,g.jsx)("option",{value:Eo.Un.THREE,children:m.U.I18n.t("wooThreeStarRating")}),(0,g.jsx)("option",{value:Eo.Un.FOUR,children:m.U.I18n.t("wooFourStarRating")}),(0,g.jsx)("option",{value:Eo.Un.FIVE,children:m.U.I18n.t("wooFiveStarRating")})]},"rating-select"),(0,g.jsxs)(o.Select,{value:t.count_type,isMinWidth:!0,onChange:t=>{i("count_type",e,t)},automationId:"select-number-of-reviews-type",children:[(0,g.jsx)("option",{value:Eo.YR.EQUALS,children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:Eo.YR.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:Eo.YR.MORE_THAN,children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:Eo.YR.LESS_THAN,children:m.U.I18n.t("lessThan")})]},"select"),(0,g.jsx)(o.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-number-of-reviews-count",type:"number",min:0,value:t.count||"",placeholder:m.U.I18n.t("wooNumberOfOrdersCount"),onChange:t=>{i("count",e,t)}}),(0,g.jsx)("div",{children:m.U.I18n.t("wooNumberOfReviewsReviews")}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})},[dl.Ag.PURCHASE_DATE]:ol,[dl.Ag.PURCHASED_PRODUCT]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getProducts(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(No.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedProduct"),options:i,value:(0,$s.filter)(e=>{if(void 0!==t.product_ids&&0!==t.product_ids.length)return-1!==t.product_ids.indexOf(e.value)},i),onChange:t=>{a({product_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-segment-products"},"select-segment-products")]})},[dl.Ag.PURCHASED_PRODUCT_VARIATION]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getVariableProducts(),[]),s=(0,r.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i]),[n,o]=(0,r.useState)(void 0),[l,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),[h,_]=(0,r.useState)(!1),f=(0,r.useRef)(0),b=(0,r.useCallback)(e=>{f.current+=1;const t=f.current;u(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"woocommerce_product_variations",action:"getVariations",data:{product_id:e}}).then(e=>{t===f.current&&d(e.data.variations.map(e=>({value:e.id,label:e.name})))}).always(()=>{t===f.current&&u(!1)})},[]),x=(0,r.useCallback)(e=>{f.current+=1;const t=f.current;u(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"woocommerce_product_variations",action:"getVariations",data:{variation_id:e}}).then(e=>{t===f.current&&(e.data.product&&o(e.data.product.id),d(e.data.variations.map(e=>({value:e.id,label:e.name}))))}).always(()=>{t===f.current&&u(!1)})},[]);(0,r.useEffect)(()=>{t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t.operator,e]),(0,r.useEffect)(()=>{h||(_(!0),Array.isArray(t.variation_ids)&&t.variation_ids.length>0&&x(t.variation_ids[0]))},[h,t.variation_ids,x]);const y=(0,$s.filter)(e=>!(!Array.isArray(t.variation_ids)||0===t.variation_ids.length)&&-1!==t.variation_ids.indexOf(e.value),l),j=n&&s.find(e=>e.value===n)||null;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(No.ReactSelect,{dimension:"small",isClearable:!0,placeholder:m.U.I18n.t("selectWooVariableProduct"),options:s,value:j,onChange:t=>(t=>{const i=t?t.value:void 0;o(i),d([]),a({variation_ids:[]},e),i&&b(i)})(t),automationId:"select-variable-product"},"select-variable-product"),(0,g.jsx)(No.ReactSelect,{isMulti:!0,dimension:"small",placeholder:c?(0,p.__)("Loading variations…","mailpoet"):m.U.I18n.t("selectWooPurchasedProductVariation"),isDisabled:!n||c,options:l,value:y,onChange:t=>{a({variation_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-product-variations"},"select-product-variations")]})},[dl.Ag.PURCHASED_CATEGORY]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getProductCategories(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(No.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedCategory"),options:i,value:(0,$s.filter)(e=>{if(void 0!==t.category_ids&&0!==t.category_ids.length)return-1!==t.category_ids.indexOf(e.value)},i),onChange:t=>{a({category_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-segment-category"},"select-segment-category")]})},[dl.Ag.PURCHASED_WITH_ATTRIBUTE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getProductAttributes(),[]),s=(0,r.useMemo)(()=>Object.values(i).filter(e=>e.terms.length>0).map(e=>({value:e.taxonomy,label:e.label})),[i]),n=(0,v.A)(e=>e(Ao.Hz).getLocalProductAttributes(),[]),o=(0,r.useMemo)(()=>Object.values(n).filter(e=>e.values.length>0).map(e=>({value:`${e.name}@local`,label:e.name})),[n]),l=(0,r.useMemo)(()=>Object.values(o).map(e=>e.value),[o]),d=(0,r.useMemo)(()=>[...s,...o],[s,o]),c=(0,r.useMemo)(()=>"taxonomy"===t.attribute_type?i[t.attribute_taxonomy_slug].terms.map(e=>({value:e.term_id.toString(),label:e.name})):"local"===t.attribute_type?n[t.attribute_local_name].values.map(e=>({value:e,label:e})):[],[t.attribute_type,t.attribute_taxonomy_slug,t.attribute_local_name,i,n]);(0,r.useEffect)(()=>{t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]);const m=(0,r.useCallback)(t=>{l.includes(t.value)?a({attribute_type:"local",attribute_local_name:t.value.replace(/@local$/,""),attribute_local_values:[],attribute_taxonomy_slug:null,attribute_term_ids:null},e):a({attribute_type:"taxonomy",attribute_local_name:null,attribute_local_values:null,attribute_taxonomy_slug:t.value,attribute_term_ids:[]},e)},[e,l,a]),u=(0,r.useMemo)(()=>"local"===t.attribute_type?(0,$s.filter)(e=>{if(t.attribute_local_name)return`${t.attribute_local_name}@local`===e.value},o):(0,$s.filter)(e=>{if(void 0!==t.attribute_taxonomy_slug)return t.attribute_taxonomy_slug===e.value},s),[t.attribute_type,t.attribute_local_name,t.attribute_taxonomy_slug,o,s]),h=(0,r.useMemo)(()=>(0,$s.filter)(e=>t.attribute_local_values?-1!==t.attribute_local_values.indexOf(e.value):t.attribute_term_ids?-1!==t.attribute_term_ids.indexOf(e.value):void 0,c),[t.attribute_local_values,t.attribute_term_ids,c]),_=(0,r.useCallback)(i=>{"local"===t.attribute_type?a({attribute_term_ids:null,attribute_local_values:(i||[]).map(e=>e.value)},e):a({attribute_term_ids:(i||[]).map(e=>e.value),attribute_local_values:null},e)},[t.attribute_type,a,e]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:(0,p.__)("any of","mailpoet")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:(0,p.__)("all of","mailpoet")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:(0,p.__)("none of","mailpoet")})]},"select-operator"),(0,g.jsx)(No.ReactSelect,{dimension:"small",placeholder:(0,p.__)("Search attributes","mailpoet"),options:d,value:u,onChange:m},"select-segment-product-attribute"),c.length>0&&(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,placeholder:(0,p.__)("Search attributes terms","mailpoet"),options:c,value:h,onChange:_},"select-segment-product-attribute-terms")]})},[dl.Ag.PURCHASED_TAG]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getProductTags(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(No.ReactSelect,{isMulti:!0,dimension:"small",placeholder:(0,p.__)("Search tags","mailpoet"),options:i,value:(0,$s.filter)(e=>{if(void 0!==t.tag_ids&&0!==t.tag_ids.length)return-1!==t.tag_ids.indexOf(e.value)},i),onChange:t=>{a({tag_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-segment-tags"},"select-segment-tag")]})},[dl.Ag.SINGLE_ORDER_VALUE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getWooCommerceCurrencySymbol(),[]);return(0,r.useEffect)(()=>{void 0===t.single_order_value_type&&a({single_order_value_type:">"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{value:t.single_order_value_type,onChange:t=>{i("single_order_value_type",e,t)},automationId:"select-single-order-value-type",children:[(0,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:">=",children:m.U.I18n.t("moreThanOrEqual")}),(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:"<=",children:m.U.I18n.t("lessThanOrEqual")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.jsx)(o.Input,{"data-automation-id":"input-single-order-value-amount",type:"number",min:0,step:.01,value:t.single_order_value_amount||"",placeholder:m.U.I18n.t("wooSpentAmount"),onChange:t=>{i("single_order_value_amount",e,t)}}),(0,g.jsx)("div",{children:s})]}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})},[dl.Ag.TOTAL_SPENT]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getWooCommerceCurrencySymbol(),[]);return(0,r.useEffect)(()=>{void 0===t.total_spent_type&&a({total_spent_type:">"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{value:t.total_spent_type,onChange:t=>{i("total_spent_type",e,t)},automationId:"select-total-spent-type",children:[(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.jsx)(o.Input,{"data-automation-id":"input-total-spent-amount",type:"number",min:0,step:.01,value:t.total_spent_amount||"",placeholder:m.U.I18n.t("wooSpentAmount"),onChange:t=>{i("total_spent_amount",e,t)}}),(0,g.jsx)("div",{children:s})]}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})},[dl.Ag.AVERAGE_SPENT]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getWooCommerceCurrencySymbol(),[]);return(0,r.useEffect)(()=>{[">",">=","=","!=","<=","<"].includes(t.average_spent_type)||a({average_spent_type:">"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(o.Select,{value:t.average_spent_type,isMinWidth:!0,onChange:t=>{i("average_spent_type",e,t)},automationId:"select-average-spent-type",children:[(0,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:">=",children:m.U.I18n.t("moreThanOrEqual")}),(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:"<=",children:m.U.I18n.t("lessThanOrEqual")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.jsx)(o.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-average-spent-amount",type:"number",min:0,step:.01,value:t.average_spent_amount||"",placeholder:m.U.I18n.t("wooSpentAmount"),onChange:t=>{i("average_spent_amount",e,t)}}),(0,g.jsx)("div",{children:s}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})},[dl.Ag.USED_COUPON_CODE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),[i,s]=(0,r.useState)(!1),[n,l]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[u,h]=(0,r.useState)(1),[_,f]=(0,r.useState)(!0),[b,x]=(0,r.useState)(""),[y,j]=(0,r.useState)([]),w=(0,r.useCallback)((e,a,i,s)=>{s&&(e||c(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"coupons",action:"getCoupons",data:{page_number:a,page_size:1e3,include_coupon_ids:t.coupon_code_ids,search:i}}).then(t=>{const{data:i}=t,s=i.map(e=>({value:e.id.toString(),label:e.text})),n=a+1;0===s.length?f(!1):(l(e=>(0,$s.uniqBy)(e=>e.value,[...e,...s])),h(n)),e||c(!1)}).fail(e=>{j(e.errors)}))},[t.coupon_code_ids]),S=(0,$s.debounce)(300,e=>{const t=b;x(e),!d&&(_&&e||t&&!e)&&(h(1),w(!1,1,e,_))});return(0,r.useEffect)(()=>{i||(w(!0,u,b,_),s(!0))},[i,u,b,w,_]),(0,r.useEffect)(()=>{Array.isArray(t.coupon_code_ids)||a({coupon_code_ids:[]},e),(0,Fo.J)(t.operator,Eo.dP)||a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[y.length>0&&(0,g.jsx)(La,{errors:y}),i?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-coupon-code",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-coupon-codes"),(0,g.jsx)(No.ReactSelect,{isFullWidth:!0,isMulti:!0,isLoadingMore:d,placeholder:m.U.I18n.t("selectWooCouponCodes"),options:n,value:(0,$s.filter)(e=>{if(t.coupon_code_ids)return-1!==t.coupon_code_ids.indexOf(e.value)},n),onInputChange:e=>{S(e)},onChange:t=>{a({coupon_code_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-shipping-methods",onMenuScrollToBottom:()=>{!d&&_&&w(!1,u,b,_)}},"select-coupon-codes")]}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]}):(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,p.__)("Loading coupon codes...","mailpoet")})]})},[dl.Ag.USED_PAYMENT_METHOD]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getPaymentMethods(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-payment-methods",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-payment-methods"),(0,g.jsx)(No.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooPaymentMethods"),options:i,value:(0,$s.filter)(e=>{if(t.payment_methods)return-1!==t.payment_methods.indexOf(e.value)},i),onChange:t=>{a({payment_methods:(t||[]).map(e=>e.value)},e)},automationId:"select-payment-methods"},"select-payment-methods")]}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})},[dl.Ag.USED_SHIPPING_METHOD]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getShippingMethods(),[]).map(e=>({value:e.instanceId,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-shipping-methods",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-shipping-methods"),(0,g.jsx)(No.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooShippingMethods"),options:i,value:(0,$s.filter)(e=>{if(t.shipping_methods)return-1!==t.shipping_methods.indexOf(e.value)},i),onChange:t=>{a({shipping_methods:(t||[]).map(e=>e.value)},e)},automationId:"select-shipping-methods"},"select-shipping-methods")]}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(Mo,{filterIndex:e})})]})},[dl.Ag.FIRST_ORDER]:ol};function gl({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);(0,r.useEffect)(()=>{t.action===Eo.gw.WORDPRESS_ROLE&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]);const s=(0,v.A)(e=>e(Ao.Hz).getWordpressRoles(),[]).map(e=>({value:e.role_id,label:e.role_name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsxs)(ut.Select,{isFullWidth:!0,automationId:"segment-wordpress-role-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select")}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,automationId:"segment-wordpress-role",placeholder:m.U.I18n.t("selectUserRolePlaceholder"),options:s,value:(0,$s.filter)(e=>{if(t.wordpressRole)return-1!==t.wordpressRole.indexOf(e.value)},s),onChange:t=>{a({wordpressRole:(0,$s.map)("value",t)},e)}})})]})}let _l=function(e){return e.HIGHER_THAN="higherThan",e.LOWER_THAN="lowerThan",e.EQUALS="equals",e.NOT_EQUALS="not_equals",e.UNKNOWN="unknown",e.NOT_UNKNOWN="not_unknown",e}({});const fl=[_l.HIGHER_THAN,_l.LOWER_THAN,_l.EQUALS,_l.NOT_EQUALS,_l.UNKNOWN,_l.NOT_UNKNOWN];function bl(e){return!!(0,Eo.uA)(e.operator)||"string"==typeof e.value&&e.value.length>0&&("equals"===e.operator||"contains"===e.operator||"not_contains"===e.operator||"not_equals"===e.operator||"more_than"===e.operator||"less_than"===e.operator)}function xl({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{void 0===t.operator&&i({operator:"equals",value:""},e)},[i,t,e]),(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("is")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("isNot")}),(0,g.jsx)("option",{value:"contains",children:m.U.I18n.t("contains")}),(0,g.jsx)("option",{value:"not_contains",children:m.U.I18n.t("notContains")}),(0,g.jsx)("option",{value:"more_than",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less_than",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"is_blank",children:m.U.I18n.t("isBlank")}),(0,g.jsx)("option",{value:"is_not_blank",children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,Eo.uA)(t.operator)&&(0,g.jsx)(ot.p,{"data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:m.U.I18n.t("value")},"input")]})}function vl(e){return!!(0,Eo.uA)(e.operator)||"string"==typeof e.value&&e.value.length>0}function yl({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getCustomFieldsList(),[]),n=(0,$s.find)({id:Number(t.custom_field_id)},s);if(!n)return null;const r=n.params;if(!r||!Array.isArray(r.values))return null;const o=r.values.map(e=>({value:e.value,label:e.value})),l=o.find(e=>e.value===t.value)?.label;return(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("is")}),(0,g.jsx)("option",{value:Eo.FI.BLANK,children:m.U.I18n.t("isBlank")}),(0,g.jsx)("option",{value:Eo.FI.NOT_BLANK,children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,Eo.uA)(t.operator)&&(0,g.jsx)(No.ReactSelect,{dimension:"small",placeholder:m.U.I18n.t("selectValue"),options:o,value:t.value&&l?{value:t.value,label:l}:null,onChange:t=>{a({value:t.value},e)},automationId:"segment-wordpress-role"})]})}var jl=a(86452),wl=a(16519),Sl=a(51831);function Nl(e){const t=(0,Zo.a)(e);return(0,wl.m)(t,function(e){const t=(0,Zo.a)(e),a=(0,Sl.w)(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t))+1}var kl=a(98491);function Cl(e){return(0,kl.k)(e,{weekStartsOn:1})}function Il(e){const t=(0,Zo.a)(e),a=t.getFullYear(),i=(0,Sl.w)(e,0);i.setFullYear(a+1,0,4),i.setHours(0,0,0,0);const s=Cl(i),n=(0,Sl.w)(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const r=Cl(n);return t.getTime()>=s.getTime()?a+1:t.getTime()>=r.getTime()?a:a-1}function Ul(e){const t=(0,Zo.a)(e),a=+Cl(t)-+function(e){const t=Il(e),a=(0,Sl.w)(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),Cl(a)}(t);return Math.round(a/Bo.my)+1}function El(e,t){const a=(0,Zo.a)(e),i=a.getFullYear(),s=(0,jl.q)(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,r=(0,Sl.w)(e,0);r.setFullYear(i+1,0,n),r.setHours(0,0,0,0);const o=(0,kl.k)(r,t),l=(0,Sl.w)(e,0);l.setFullYear(i,0,n),l.setHours(0,0,0,0);const d=(0,kl.k)(l,t);return a.getTime()>=o.getTime()?i+1:a.getTime()>=d.getTime()?i:i-1}function Al(e,t){const a=(0,Zo.a)(e),i=+(0,kl.k)(a,t)-+function(e,t){const a=(0,jl.q)(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=El(e,t),n=(0,Sl.w)(e,0);return n.setFullYear(s,0,i),n.setHours(0,0,0,0),(0,kl.k)(n,t)}(a,t);return Math.round(i/Bo.my)+1}function Tl(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const Rl={y(e,t){const a=e.getFullYear(),i=a>0?a:1-a;return Tl("yy"===t?i%100:i,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):Tl(a+1,2)},d:(e,t)=>Tl(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>Tl(e.getHours()%12||12,t.length),H:(e,t)=>Tl(e.getHours(),t.length),m:(e,t)=>Tl(e.getMinutes(),t.length),s:(e,t)=>Tl(e.getSeconds(),t.length),S(e,t){const a=t.length,i=e.getMilliseconds();return Tl(Math.trunc(i*Math.pow(10,a-3)),t.length)}},Pl={G:function(e,t,a){const i=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(i,{width:"abbreviated"});case"GGGGG":return a.era(i,{width:"narrow"});default:return a.era(i,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),i=t>0?t:1-t;return a.ordinalNumber(i,{unit:"year"})}return Rl.y(e,t)},Y:function(e,t,a,i){const s=El(e,i),n=s>0?s:1-s;return"YY"===t?Tl(n%100,2):"Yo"===t?a.ordinalNumber(n,{unit:"year"}):Tl(n,t.length)},R:function(e,t){return Tl(Il(e),t.length)},u:function(e,t){return Tl(e.getFullYear(),t.length)},Q:function(e,t,a){const i=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return Tl(i,2);case"Qo":return a.ordinalNumber(i,{unit:"quarter"});case"QQQ":return a.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(i,{width:"narrow",context:"formatting"});default:return a.quarter(i,{width:"wide",context:"formatting"})}},q:function(e,t,a){const i=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return Tl(i,2);case"qo":return a.ordinalNumber(i,{unit:"quarter"});case"qqq":return a.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(i,{width:"narrow",context:"standalone"});default:return a.quarter(i,{width:"wide",context:"standalone"})}},M:function(e,t,a){const i=e.getMonth();switch(t){case"M":case"MM":return Rl.M(e,t);case"Mo":return a.ordinalNumber(i+1,{unit:"month"});case"MMM":return a.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(i,{width:"narrow",context:"formatting"});default:return a.month(i,{width:"wide",context:"formatting"})}},L:function(e,t,a){const i=e.getMonth();switch(t){case"L":return String(i+1);case"LL":return Tl(i+1,2);case"Lo":return a.ordinalNumber(i+1,{unit:"month"});case"LLL":return a.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(i,{width:"narrow",context:"standalone"});default:return a.month(i,{width:"wide",context:"standalone"})}},w:function(e,t,a,i){const s=Al(e,i);return"wo"===t?a.ordinalNumber(s,{unit:"week"}):Tl(s,t.length)},I:function(e,t,a){const i=Ul(e);return"Io"===t?a.ordinalNumber(i,{unit:"week"}):Tl(i,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):Rl.d(e,t)},D:function(e,t,a){const i=Nl(e);return"Do"===t?a.ordinalNumber(i,{unit:"dayOfYear"}):Tl(i,t.length)},E:function(e,t,a){const i=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(i,{width:"short",context:"formatting"});default:return a.day(i,{width:"wide",context:"formatting"})}},e:function(e,t,a,i){const s=e.getDay(),n=(s-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return Tl(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,a,i){const s=e.getDay(),n=(s-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return Tl(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(s,{width:"narrow",context:"standalone"});case"cccccc":return a.day(s,{width:"short",context:"standalone"});default:return a.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,a){const i=e.getDay(),s=0===i?7:i;switch(t){case"i":return String(s);case"ii":return Tl(s,t.length);case"io":return a.ordinalNumber(s,{unit:"day"});case"iii":return a.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(i,{width:"short",context:"formatting"});default:return a.day(i,{width:"wide",context:"formatting"})}},a:function(e,t,a){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(i,{width:"narrow",context:"formatting"});default:return a.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,a){const i=e.getHours();let s;switch(s=12===i?"noon":0===i?"midnight":i/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,a){const i=e.getHours();let s;switch(s=i>=17?"evening":i>=12?"afternoon":i>=4?"morning":"night",t){case"B":case"BB":case"BBB":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return Rl.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):Rl.H(e,t)},K:function(e,t,a){const i=e.getHours()%12;return"Ko"===t?a.ordinalNumber(i,{unit:"hour"}):Tl(i,t.length)},k:function(e,t,a){let i=e.getHours();return 0===i&&(i=24),"ko"===t?a.ordinalNumber(i,{unit:"hour"}):Tl(i,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):Rl.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):Rl.s(e,t)},S:function(e,t){return Rl.S(e,t)},X:function(e,t,a){const i=e.getTimezoneOffset();if(0===i)return"Z";switch(t){case"X":return Ol(i);case"XXXX":case"XX":return Fl(i);default:return Fl(i,":")}},x:function(e,t,a){const i=e.getTimezoneOffset();switch(t){case"x":return Ol(i);case"xxxx":case"xx":return Fl(i);default:return Fl(i,":")}},O:function(e,t,a){const i=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Dl(i,":");default:return"GMT"+Fl(i,":")}},z:function(e,t,a){const i=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Dl(i,":");default:return"GMT"+Fl(i,":")}},t:function(e,t,a){return Tl(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return Tl(e.getTime(),t.length)}};function Dl(e,t=""){const a=e>0?"-":"+",i=Math.abs(e),s=Math.trunc(i/60),n=i%60;return 0===n?a+String(s):a+String(s)+t+Tl(n,2)}function Ol(e,t){return e%60==0?(e>0?"-":"+")+Tl(Math.abs(e)/60,2):Fl(e,t)}function Fl(e,t=""){const a=e>0?"-":"+",i=Math.abs(e);return a+Tl(Math.trunc(i/60),2)+t+Tl(i%60,2)}const Ml=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Ll=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},$l={p:Ll,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],i=a[1],s=a[2];if(!s)return Ml(e,t);let n;switch(i){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",Ml(i,t)).replace("{{time}}",Ll(s,t))}},Wl=/^D+$/,Bl=/^Y+$/,ql=["D","DD","YY","YYYY"],Hl=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,zl=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vl=/^'([^]*?)'?$/,Yl=/''/g,Gl=/[a-zA-Z]/;function Kl(e,t,a){const i=(0,jl.q)(),s=a?.locale??i.locale??gi,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,r=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,o=(0,Zo.a)(e);if(!Xo(o))throw new RangeError("Invalid time value");let l=t.match(zl).map(e=>{const t=e[0];return"p"===t||"P"===t?(0,$l[t])(e,s.formatLong):e}).join("").match(Hl).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Ql(e)};if(Pl[t])return{isToken:!0,value:e};if(t.match(Gl))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});s.localize.preprocessor&&(l=s.localize.preprocessor(o,l));const d={firstWeekContainsDate:n,weekStartsOn:r,locale:s};return l.map(i=>{if(!i.isToken)return i.value;const n=i.value;return(!a?.useAdditionalWeekYearTokens&&function(e){return Bl.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return Wl.test(e)}(n))&&function(e,t,a){const i=function(e,t,a){const i="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${i} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(console.warn(i),ql.includes(e))throw new RangeError(i)}(n,t,String(e)),(0,Pl[n[0]])(o,n,s.localize,d)}).join("")}function Ql(e){const t=e.match(Vl);return t?t[1].replace(Yl,"'"):e}function Jl(e){return!!(0,Eo.uA)(e.operator)||("month"===e.date_type||!("string"!=typeof e.operator||e.operator.length<1))&&"string"==typeof e.value&&e.value.length>1}const Zl=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return Kl(e,"yyyy-MM-dd 00:00:00")}},Xl=e=>{const t=qo(e);if(Xo(t))return t},ed={month:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{Jl(t)||e((0,$s.assign)(t,{value:"2017-01-01 00:00:00"}),a),void 0===t.operator&&e((0,$s.assign)(t,{operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,onChange:i=>{e((0,$s.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Eo.uA)(t.operator)&&(0,g.jsxs)(ut.Select,{value:t.value,onChange:i=>{e((0,$s.assign)(t,{value:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"2017-01-01 00:00:00",children:(0,p.__)("january","mailpoet")}),(0,g.jsx)("option",{value:"2017-02-01 00:00:00",children:(0,p.__)("february","mailpoet")}),(0,g.jsx)("option",{value:"2017-03-01 00:00:00",children:(0,p.__)("march","mailpoet")}),(0,g.jsx)("option",{value:"2017-04-01 00:00:00",children:(0,p.__)("april","mailpoet")}),(0,g.jsx)("option",{value:"2017-05-01 00:00:00",children:(0,p.__)("may","mailpoet")}),(0,g.jsx)("option",{value:"2017-06-01 00:00:00",children:(0,p.__)("june","mailpoet")}),(0,g.jsx)("option",{value:"2017-07-01 00:00:00",children:(0,p.__)("july","mailpoet")}),(0,g.jsx)("option",{value:"2017-08-01 00:00:00",children:(0,p.__)("august","mailpoet")}),(0,g.jsx)("option",{value:"2017-09-01 00:00:00",children:(0,p.__)("september","mailpoet")}),(0,g.jsx)("option",{value:"2017-10-01 00:00:00",children:(0,p.__)("october","mailpoet")}),(0,g.jsx)("option",{value:"2017-11-01 00:00:00",children:(0,p.__)("november","mailpoet")}),(0,g.jsx)("option",{value:"2017-12-01 00:00:00",children:(0,p.__)("december","mailpoet")})]},"select")]})},year:function({onChange:e,item:t,filterIndex:a}){const i=(s=new Date,(0,Zo.a)(s).getFullYear());var s;return(0,r.useEffect)(()=>{Jl(t)||e((0,$s.assign)(t,{value:`${i}-01-01 00:00:00`,operator:"equals"}),a)},[i,e,t,a]),(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,onChange:i=>{e((0,$s.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,p._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,p._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),(0,g.jsx)(ut.Select,{value:t.value,onChange:i=>{e((0,$s.assign)(t,{value:i.target.value}),a)},children:(0,$s.range)(0,100).map(e=>(0,g.jsx)("option",{value:i-e+"-01-01 00:00:00",children:i-e},i-e))},"select-year")]})},year_month:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{void 0!==t.value&&""!==t.value||e((0,$s.assign)(t,{value:`${Kl(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,onChange:i=>{e((0,$s.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,p._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,p._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Eo.uA)(t.operator)&&(0,g.jsx)(fi.t,{onChange:i=>e((0,$s.assign)(t,{value:Zl(i)}),a),selected:t.value?Xl(t.value):void 0,dateFormat:"MM/yyyy",showMonthYearPicker:!0})]})},year_month_day:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{Jl(t)||e((0,$s.assign)(t,{value:`${Kl(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,onChange:i=>{e((0,$s.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,p._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,p._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Eo.uA)(t.operator)&&(0,g.jsx)(fi.t,{formatWithWordPressSettings:!0,onChange:i=>e((0,$s.assign)(t,{value:Zl(i)}),a),selected:t.value?Xl(t.value):void 0})]})}};var td=function(e){return e.DATE="date",e.TEXT="text",e.TEXTAREA="textarea",e.RADIO="radio",e.CHECKBOX="checkbox",e.SELECT="select",e}(td||{});const ad={[td.TEXT]:bl,[td.TEXTAREA]:bl,[td.RADIO]:vl,[td.SELECT]:vl,[td.CHECKBOX]:function(e){return!!(0,Eo.uA)(e.operator)||["1","0"].includes(e.value)},[td.DATE]:Jl},id={[td.TEXT]:xl,[td.TEXTAREA]:xl,[td.RADIO]:yl,[td.SELECT]:yl,[td.CHECKBOX]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{void 0===t.operator?i({operator:"equals",value:"1"},e):"equals"!==t.operator||["1","0"].includes(t.value)||i({value:"1"},e)},[i,t,e]),(0,g.jsxs)(ri.Grid.CenteredRow,{children:[(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:Eo.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Eo.uA)(t.operator)&&(0,g.jsxs)(ut.Select,{value:t.value,onChange:t=>{a("value",e,t)},children:[(0,g.jsx)("option",{value:"1",children:(0,p.__)("checked","mailpoet")}),(0,g.jsx)("option",{value:"0",children:(0,p.__)("unchecked","mailpoet")})]},"select")]})},[td.DATE]:function({customField:e,filterIndex:t}){const a=(0,v.A)(e=>e(Ao.Hz).getSegmentFilter(t),[t]),{updateSegmentFilter:i}=(0,ue.A)(Ao.Hz);(0,r.useEffect)(()=>{a.date_type!==e.params.date_type&&i({date_type:e.params.date_type,value:""},t)},[a.date_type,i,e.params.date_type,t]);const s=ed[e.params.date_type];return s?(0,g.jsx)(s,{item:a,onChange:i,filterIndex:t}):null}};function sd(){return(0,g.jsx)(xa,{message:(()=>{const e=m.U.I18n.t("premiumFeatureMultipleConditions");return(0,g.jsx)("p",{children:at()(e,/\[link](.*?)\[\/link]/g,e=>(0,g.jsx)("a",{href:m.U.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e))})})(),actionButton:(0,g.jsx)(Le.$,{href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,null,{utm_medium:"segments",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("premiumBannerCtaFree")})})}const nd={[Eo.gw.WORDPRESS_ROLE]:gl,[Eo.gw.SUBSCRIBER_SCORE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz);return(0,r.useEffect)(()=>{fl.includes(t.operator)||a({operator:_l.HIGHER_THAN},e),t.operator!==_l.HIGHER_THAN&&t.operator!==_l.LOWER_THAN&&t.operator!==_l.EQUALS&&t.operator!==_l.NOT_EQUALS||void 0!==t.value||a({value:""},e),t.operator!==_l.UNKNOWN&&t.operator!==_l.NOT_UNKNOWN||a({value:null},e)},[a,t,e]),(0,g.jsx)(ri.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(ut.Select,{value:t.operator,automationId:"segment-subscriber-score-operator",onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:_l.HIGHER_THAN,children:m.U.I18n.t("higherThan")}),(0,g.jsx)("option",{value:_l.LOWER_THAN,children:m.U.I18n.t("lowerThan")}),(0,g.jsx)("option",{value:_l.EQUALS,children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:_l.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:_l.UNKNOWN,children:m.U.I18n.t("unknown")}),(0,g.jsx)("option",{value:_l.NOT_UNKNOWN,children:m.U.I18n.t("notUnknown")})]},"select"):"{score}"===a?(t.operator===_l.HIGHER_THAN||t.operator===_l.LOWER_THAN||t.operator===_l.EQUALS||t.operator===_l.NOT_EQUALS)&&(0,g.jsx)(ot.p,{type:"number",value:t.value||"","data-automation-id":"segment-subscriber-score-value",onChange:t=>{i("value",e,t)},min:"0",placeholder:m.U.I18n.t("subscriberScorePlaceholder")},"input"):"string"==typeof a&&a.trim().length>0?t.operator!==_l.UNKNOWN&&t.operator!==_l.NOT_UNKNOWN&&(0,g.jsx)("div",{children:a},"score"):null,m.U.I18n.t("subscriberScoreSentence").split(/({condition})|({score})|(\b%\b)/gim).map(s))});var s},[Eo.gw.SUBSCRIBED_DATE]:ol,[Eo.gw.MAILPOET_CUSTOM_FIELD]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getCustomFieldsList(),[]),s=(0,$s.find)({id:Number(t.custom_field_id)},i),n=i.map(e=>({value:e.id.toString(),label:e.name})),r=id[t.custom_field_type];return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{children:(0,g.jsx)(No.ReactSelect,{dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectCustomFieldPlaceholder"),options:n,automationId:"select-custom-field",value:(0,$s.find)(e=>{if(t.custom_field_id)return t.custom_field_id===e.value},n),onChange:t=>{const s=(0,$s.find)({id:Number(t.value)},i);s&&a({custom_field_id:t.value,custom_field_type:s.type,operator:void 0,value:void 0},e)}})}),(0,g.jsx)("div",{children:r&&(0,g.jsx)(r,{customField:s,filterIndex:e})})]})},[Eo.gw.SUBSCRIBED_TO_LIST]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),a=(0,v.A)(e=>e(Ao.Hz).getStaticSegmentsList(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,ue.A)(Ao.Hz);(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&i({operator:Eo.dP.ANY},e)},[i,t,e]);const n=a.map(e=>({value:e.id,label:e.name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("searchLists"),options:n,value:(0,$s.filter)(e=>{if(!t.segments)return;const a=e.value;return-1!==t.segments.indexOf(a)},n),onChange:t=>{i({segments:(0,$s.map)((0,$s.parseInt)(10),(0,$s.map)("value",t))},e)}})]})},[Eo.gw.SUBSCRIBER_TAG]:function({filterIndex:e}){return aa.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag",(0,g.jsx)(sd,{}),e)},[Eo.gw.SUBSCRIBER_FIRST_NAME]:pl,[Eo.gw.SUBSCRIBER_LAST_NAME]:pl,[Eo.gw.SUBSCRIBER_EMAIL]:pl,[Eo.gw.SUBSCRIBED_VIA_FORM]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),a=(0,v.A)(e=>e(Ao.Hz).getSignupForms(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,ue.A)(Ao.Hz);(0,r.useEffect)(()=>{t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.NONE&&i({operator:Eo.dP.ANY},e)},[i,t,e]);const n=a.map(e=>({value:e.id,label:e.name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ut.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(No.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("searchForms"),options:n,value:n.filter(e=>{if(!t.form_ids)return;const a=e.value;return-1!==t.form_ids.indexOf(a)}),onChange:t=>{i({form_ids:t.map(e=>e.value)},e)}})]})},[Eo.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE]:ll,[Eo.gw.SUBSCRIBER_LAST_PURCHASE_DATE]:ll,[Eo.gw.SUBSCRIBER_LAST_OPEN_DATE]:ll,[Eo.gw.SUBSCRIBER_LAST_CLICK_DATE]:ll,[Eo.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE]:ll,[Eo.gw.SUBSCRIBER_LAST_SENDING_DATE]:ll},rd={[Eo.dx.Automations]:function(e){return!!Object.values(To.g).some(t=>t===e.action)&&(e.action!==To.g.ENTERED_AUTOMATION||function(e){return(e.operator===Eo.dP.ANY||e.operator===Eo.dP.NONE||e.operator===Eo.dP.ALL)&&Array.isArray(e.automation_ids)&&e.automation_ids.length>0}(e))},[Eo.dx.Email]:function(e){return!!Object.values(Eo._R).some(t=>t===e.action)&&(e.action===Eo._R.CLICKED_ANY||(e.action===Eo._R.CLICKED?!!e.newsletter_id:[Eo._R.OPENED,Eo._R.MACHINE_OPENED,Eo._R.WAS_SENT].includes(e.action)?Array.isArray(e.newsletters)&&e.newsletters.length>0:[Eo._R.OPENS_ABSOLUTE_COUNT,Eo._R.MACHINE_OPENS_ABSOLUTE_COUNT].includes(e.action)?Lo(e)&&!!e.opens&&!!e.operator:Eo._R.NUMBER_RECEIVED===e.action?Lo(e)&&!!e.emails&&!!e.operator:e.action===Eo._R.NUMBER_OF_CLICKS&&Lo(e)&&!!e.clicks&&!!e.operator))},[Eo.dx.WooCommerce]:function(e){return!!Object.values(dl.Ag).some(t=>t===e.action)&&(e.action===dl.Ag.PURCHASED_CATEGORY?function(e){return!(void 0===e.category_ids||0===e.category_ids.length||!e.operator)}(e):e.action===dl.Ag.PURCHASED_PRODUCT?function(e){return!(void 0===e.product_ids||0===e.product_ids.length||!e.operator)}(e):e.action===dl.Ag.PURCHASED_PRODUCT_VARIATION?function(e){return Array.isArray(e.variation_ids)&&e.variation_ids.length>0&&!!e.operator}(e):e.action===dl.Ag.CUSTOMER_IN_COUNTRY?function(e){return!(void 0===e.country_code||0===e.country_code.length)}(e):[dl.Ag.NUMBER_OF_ORDERS,dl.Ag.NUMBER_OF_ORDERS_WITH_COUPON].includes(e.action)?function(e){return!(!e.number_of_orders_count||!Lo(e)||!e.number_of_orders_type)}(e):e.action===dl.Ag.TOTAL_SPENT?function(e){return!(!e.total_spent_amount||!Lo(e)||!e.total_spent_type)}(e):e.action===dl.Ag.SINGLE_ORDER_VALUE?function(e){return!(!e.single_order_value_amount||!Lo(e)||!e.single_order_value_type)}(e):e.action===dl.Ag.AVERAGE_SPENT?function(e){return!(!e.average_spent_amount||!e.average_spent_type||!Lo(e))}(e):e.action===dl.Ag.USED_PAYMENT_METHOD?function(e){return!(!e.payment_methods||e.payment_methods.length<1||!e.operator||!Lo(e))}(e):e.action===dl.Ag.USED_SHIPPING_METHOD?function(e){return!(!e.shipping_methods||e.shipping_methods.length<1||!e.operator||!Lo(e))}(e):e.action===dl.Ag.PURCHASE_DATE?nl(e):e.action===dl.Ag.NUMBER_OF_REVIEWS?function(e){return!!(e.count&&e.count_type&&e.rating&&Lo(e))}(e):e.action===dl.Ag.USED_COUPON_CODE?function(e){return!(!e.coupon_code_ids||e.coupon_code_ids.length<1||!(0,Fo.J)(e.operator,Eo.dP)||!Lo(e))}(e):e.action===dl.Ag.FIRST_ORDER?nl(e):e.action===dl.Ag.PURCHASED_WITH_ATTRIBUTE?function(e){return!!(e.operator&&e.attribute_type&&("taxonomy"!==e.attribute_type||void 0!==e.attribute_taxonomy_slug&&Array.isArray(e.attribute_term_ids)&&0!==e.attribute_term_ids.length)&&("local"!==e.attribute_type||e.attribute_local_name&&0!==e.attribute_local_name.length&&Array.isArray(e.attribute_local_values)&&0!==e.attribute_local_values.length))}(e):[dl.Ag.CUSTOMER_IN_POSTAL_CODE,dl.Ag.CUSTOMER_IN_CITY].includes(e.action)?ul(e):e.action!==dl.Ag.PURCHASED_TAG||function(e){return!(void 0===e.tag_ids||0===e.tag_ids.length||!e.operator)}(e))},[Eo.dx.WordPressRole]:function(e){return e.action&&e.action!==Eo.gw.WORDPRESS_ROLE?e.action===Eo.gw.MAILPOET_CUSTOM_FIELD?function(e){const t=ad[e.custom_field_type];return!!t&&t(e)}(e):e.action===Eo.gw.SUBSCRIBER_SCORE?function(e){if(e.operator===_l.HIGHER_THAN||e.operator===_l.LOWER_THAN||e.operator===_l.EQUALS||e.operator===_l.NOT_EQUALS){const t=Number(e.value),a=Number(parseFloat(e.value));return!Number.isNaN(t)&&!Number.isNaN(a)&&t>=0&&t<=100}return e.operator===_l.UNKNOWN||e.operator===_l.NOT_UNKNOWN}(e):e.action===Eo.gw.SUBSCRIBED_TO_LIST?function(e){return(e.operator===Eo.dP.ANY||e.operator===Eo.dP.ALL||e.operator===Eo.dP.NONE)&&Array.isArray(e.segments)&&e.segments.length>0}(e):e.action===Eo.gw.SUBSCRIBER_TAG?function(e){return aa.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag_validate",!1,e)}(e):[Eo.gw.SUBSCRIBER_FIRST_NAME,Eo.gw.SUBSCRIBER_LAST_NAME,Eo.gw.SUBSCRIBER_EMAIL].includes(e.action)?ul(e):[Eo.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE,Eo.gw.SUBSCRIBER_LAST_PURCHASE_DATE,Eo.gw.SUBSCRIBER_LAST_OPEN_DATE,Eo.gw.SUBSCRIBER_LAST_CLICK_DATE,Eo.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE,Eo.gw.SUBSCRIBER_LAST_SENDING_DATE].includes(e.action)?nl(e):e.action===Eo.gw.SUBSCRIBED_VIA_FORM?function(e){return(e.operator===Eo.dP.ANY||e.operator===Eo.dP.NONE)&&Array.isArray(e.form_ids)&&e.form_ids.length>0}(e):!(!e.operator||!e.value)&&!!Object.values(el).includes(e.operator)&&nl(e):Array.isArray(e.wordpressRole)&&e.wordpressRole.length>0},[Eo.dx.WooCommerceMembership]:function(e){const t=!e.plan_ids||!e.plan_ids.length||!e.operator;return e.action!==dl.HM.MEMBER_OF||!t},[Eo.dx.WooCommerceSubscription]:function(e){const t=!e.product_ids||!e.product_ids.length||!e.operator;return e.action!==dl.IC.ACTIVE_SUBSCRIPTIONS||!t}};function od(e){return!(e.length<1)&&0===e.map(e=>void 0!==rd[e.segmentType]&&rd[e.segmentType](e)).filter(e=>!1===e).length}let ld,dd;function cd(){const e=(0,v.A)(e=>e(Ao.Hz).getSegment(),[]),t=(0,v.A)(e=>e(Ao.Hz).getSubscriberCount(),[]),{updateSubscriberCount:a}=(0,ue.A)(Ao.Hz),i=JSON.stringify(e),s=(0,r.useRef)(1),n=(0,r.useRef)(null),o=(0,r.useRef)(!1),l=(0,r.useRef)((0,ai.debounce)(function e(t){if(o.current)return void(n.current=t);n.current=null,s.current+=1;const i=s.current;o.current=!0,function(e){const t={filters:e.filters,filters_connect:e.filters_connect};return ii().isEqual(t,ld)?Promise.resolve(dd):(ld={filters:[...e.filters],filters_connect:e.filters_connect},m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"dynamic_segments",action:"getCount",data:e,timeout:2e4}).then(e=>{const{data:t}=e;return dd={count:t.count,errors:void 0},dd}))}(t).then(t=>{if(o.current=!1,n.current)return void e(n.current);if(i!==s.current)return;const r={loading:!1};t&&(r.count=t.count,r.errors=t.errors),a(r)},e=>{o.current=!1;const t={},i=e.errors.map(e=>e.message);t.loading=!1,t.count=void 0,t.errors=i,a(t)})},2e3,{trailing:!0}));return(0,r.useEffect)(()=>{od(e.filters)?(a({loading:!0,count:void 0,errors:void 0}),(0,l.current)(e)):a({count:void 0,loading:!1})},[e,i,a]),t.errors?(0,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsxs)("span",{className:"mailpoet-form-error-message",children:[m.U.I18n.t("dynamicSegmentSizeCalculatingTimeout")," ",(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/237-guide-to-subscriber-segmentation",target:"_blank",className:"mailpoet-form-error-message",rel:"noopener noreferrer",children:m.U.I18n.t("learnMore")})]})}):t.loading||void 0!==t.count?t.loading?(0,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("dynamicSegmentSizeIsCalculated")})}):(0,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("dynamicSegmentSize").replace("%1$d",t.count.toLocaleString())})}):(0,g.jsx)("span",{})}const md={[Eo.dx.Automations]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),a=Po[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[Eo.dx.Email]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),a=Wo[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[Eo.dx.WooCommerce]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),a=hl[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[Eo.dx.WordPressRole]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]);let a;return a=t.action?nd[t.action]:gl,a?(0,g.jsx)(a,{filterIndex:e}):null},[Eo.dx.WooCommerceMembership]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getMembershipPlans(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.action===dl.HM.MEMBER_OF&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(No.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooMembership"),options:s,value:(0,$s.filter)(e=>!!t.plan_ids&&-1!==t.plan_ids.indexOf(e.value),s),onChange:t=>{a({plan_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-segment-plans"},"select-segment-membership-plan")})]})},[Eo.dx.WooCommerceSubscription]:function({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,ue.A)(Ao.Hz),s=(0,v.A)(e=>e(Ao.Hz).getSubscriptionProducts(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.action===dl.IC.ACTIVE_SUBSCRIPTIONS&&t.operator!==Eo.dP.ANY&&t.operator!==Eo.dP.ALL&&t.operator!==Eo.dP.NONE&&a({operator:Eo.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsxs)(ut.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:Eo.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:Eo.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:Eo.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,g.jsx)(ri.Grid.CenteredRow,{children:(0,g.jsx)(No.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooSubscription"),options:s,value:(0,$s.filter)(e=>!!t.product_ids&&-1!==t.product_ids.indexOf(e.value),s),onChange:t=>{a({product_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-segment-products"},"select-segment-category")})]})}};function ud({filterIndex:e}){const t=(0,v.A)(t=>t(Ao.Hz).getSegmentFilter(e),[e]);if(void 0===t||void 0===md[t.segmentType])return null;const a=md[t.segmentType];return(0,g.jsx)(a,{filterIndex:e})}function pd(){const e=(0,v.A)(e=>e(Ao.Hz).getSegment(),[]),t=[Eo._R.OPENED,Eo._R.OPENS_ABSOLUTE_COUNT,Eo._R.MACHINE_OPENED,Eo._R.MACHINE_OPENS_ABSOLUTE_COUNT];let a=!1;return e.filters.forEach(e=>{t.includes(e.action)&&(a=!0)}),a?(0,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("privacyProtectionNotice")})}):(0,g.jsx)("span",{})}const hd=aa.Hooks.applyFilters("mailpoet_dynamic_segments_form_filters_before",()=>null),gd=aa.Hooks.applyFilters("mailpoet_dynamic_filters_filter_before",()=>null),_d=aa.Hooks.applyFilters("mailpoet_dynamic_filters_filter_after",()=>(0,g.jsx)("div",{className:"mailpoet-gap"}));function fd({isNewSegment:e,newsletterId:t}){const{segment:a,segmentFilters:i,subscriberCount:s,filterRows:n,errors:o}=(0,v.A)(e=>{const t=e(Ao.Hz).getSegment();return{segment:t,segmentFilters:e(Ao.Hz).getAvailableFilters(),subscriberCount:e(Ao.Hz).getSubscriberCount(),filterRows:e(Ao.Hz).findFiltersValueForSegment(t),errors:e(Ao.Hz).getErrors()}},[]),l=a.filters.length,d=m.U.capabilities.segmentFilters.value>0&&l>=m.U.capabilities.segmentFilters.value,{updateSegment:c,updateSegmentFilter:u,handleSave:h}=(0,ue.A)(Ao.Hz),[_,f]=(0,r.useState)(!1),b=aa.Hooks.applyFilters("mailpoet_dynamic_segments_form_add_condition_action",()=>{f(!0)});return(0,g.jsx)("div",{className:"mailpoet-form-container",children:(0,g.jsxs)("form",{children:[o.length>0&&(0,g.jsx)(La,{errors:o.map(e=>({message:e}))}),(0,g.jsxs)(Co,{title:(0,p.__)("Details","mailpoet"),description:(0,p.__)("What do you want to call this segment?","mailpoet"),children:[(0,g.jsx)(Io,{slug:"name",title:(0,p.__)("Name","mailpoet"),children:(0,g.jsx)(ot.p,{isFullWidth:!0,type:"text",name:"name",id:"field_name",value:a.name||"","data-automation-id":"input-name",onChange:e=>{c({name:e.target.value})},placeholder:(0,p.__)("Enter name","mailpoet")})}),(0,g.jsx)(Io,{slug:"description",title:(0,p.__)("Description","mailpoet"),description:(0,p.__)("This text box is for your own use and is never shown to your subscribers.","mailpoet"),children:(0,g.jsx)(ot.p,{isFullWidth:!0,name:"description",id:"field_description",value:a.description||"","data-automation-id":"input-description",onChange:e=>{c({description:e.target.value})},placeholder:(0,p.__)("Enter description","mailpoet")})})]}),(0,g.jsx)(Co,{title:(0,p.__)("Conditions","mailpoet"),description:(0,p.__)("Set your segment constraints","mailpoet"),children:(0,g.jsx)(Io,{children:(0,g.jsxs)("div",{className:"mailpoet-segments-segments-section",children:[(0,g.jsx)(hd,{}),Array.isArray(n)&&n.map((e,t)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-segments-grid","data-automation-id":`filter-row-${t}`,children:[(0,g.jsx)(gd,{filterRows:n,index:t}),(0,g.jsx)("div",{className:"mailpoet-segments-filter-selector",children:(0,g.jsx)(No.ReactSelect,{dimension:"small",placeholder:(0,p.__)("Select action","mailpoet"),options:i,value:e.filterValue,onChange:e=>{u({segmentType:e.group,action:e.value},t)},automationId:"select-segment-action",isFullWidth:!0})}),void 0!==e.index&&(0,g.jsx)(ud,{filterIndex:e.index})]}),(0,g.jsx)(_d,{index:t})]},e.index)),(0,g.jsxs)("div",{className:"mailpoet-segments-conditions-bottom",children:[(0,g.jsx)(ce.Ay,{type:"button",variant:"secondary",onClick:e=>{e.preventDefault(),b(a,c)},children:(0,p.__)("Add a condition","mailpoet")}),(!m.U.premiumActive||!m.U.hasValidPremiumKey||m.U.subscribersLimitReached||d)&&(0,g.jsx)(Uo.S,{text:(0,p.__)("UPGRADE","mailpoet")}),_&&(0,g.jsx)(Ri.D,{onRequestClose:()=>{f(!1)},data:{capabilities:{segmentFilters:0}},children:(0,p.__)("Multiple conditions per segment are not available in the free version of the MailPoet plugin.","mailpoet")})]})]})})}),(0,g.jsxs)("div",{className:"mailpoet-admin-fields-footer",children:[(0,g.jsxs)("div",{className:"mailpoet-segments-counter-section",children:[(0,g.jsx)(cd,{}),(0,g.jsx)(pd,{})]}),(0,g.jsx)("div",{className:"mailpoet-form-actions",children:(0,g.jsx)(ce.Ay,{variant:"primary",type:"submit",onClick:a=>{a.preventDefault(),h(e,t)},disabled:!od(a.filters)||void 0===s.count,children:t?(0,p.__)("Save and return","mailpoet"):(0,p.__)("Save","mailpoet")})})]})]})})}function bd(){const e=(0,ke.g)(),{pageLoaded:t,pageUnloaded:a}=(0,ue.A)(Ao.Hz),i=(0,v.A)(e=>e(Ao.Hz).getPreviousPage())||"/",s=(0,ke.zy)(),n=new URLSearchParams(s.search).get("newsletterId")||null;(0,r.useEffect)(()=>(t(e.id),()=>{a()}),[e.id,t,a]);const o=void 0===e.id||Number.isNaN(Number(e.id));return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Oe.z,{heading:e.id?(0,p.__)("Edit segment","mailpoet"):(0,p.__)("Add new segment","mailpoet"),headingPrefix:(0,g.jsx)(Oe.o,{id:"mailpoet-segments-back-button",href:`#${i}`,label:(0,p.__)("Return to previous page","mailpoet"),onClick:e=>{n&&(e.preventDefault(),window.location.href=`admin.php?page=mailpoet-newsletters#/send/${n}`)}})}),(0,g.jsx)(fd,{isNewSegment:o,newsletterId:n})]})}bd.displayName="SegmentEditor";var xd=a(62623);function vd(){const{notices:e}=(0,v.A)(e=>({notices:e(xd.store).getNotices()}),[]),{removeNotice:t}=(0,ue.A)(xd.store),a=e.filter(({isDismissible:e,type:t})=>e&&"default"===t),i=e.filter(({isDismissible:e,type:t})=>!e&&"default"===t);return(0,g.jsxs)(g.Fragment,{children:[i.reverse().map(({id:e,status:t,content:a,__unstableHTML:i})=>(0,g.jsx)(h.$,{renderInPlace:!0,type:t,timeout:!1,children:i??(0,g.jsx)("p",{children:a})},e)),a.reverse().map(({id:e,status:a,content:i,__unstableHTML:s})=>(0,g.jsx)(h.$,{type:a,renderInPlace:!0,timeout:!1,closable:!0,onClose:()=>t(e),children:s??(0,g.jsx)("p",{children:i})},e))]})}var yd=a(95660),jd=a(61479);let wd=!1;function Sd(){if(wd)return;const e=window.mailpoet_segments_api;ao.default.use(ao.default.createRootURLMiddleware(`${e.root}/`)),ao.default.use(ao.default.createNonceMiddleware(e.nonce)),wd=!0}function Nd(e){return Object.entries(e).reduce((e,[t,a])=>void 0!==a?{...e,[t]:a}:e,{})}const kd=[{id:"name",label:(0,p.__)("Segment","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,render:({item:e})=>(0,r.createElement)("div",{"data-automation-id":`mailpoet_dynamic_segment_name_${e.id}`},e.is_plugin_missing?(0,r.createElement)("span",null,e.name):(0,r.createElement)("a",{href:`#${jd.r$}/${e.id}`},e.name),e.description?(0,r.createElement)("div",null,e.description):null,e.is_plugin_missing?(0,r.createElement)("div",{className:"mailpoet-segments-dataviews__row-note","data-automation-id":`mailpoet_dynamic_segment_plugin_missing_message_${e.id}`},function(e){return(0,p.sprintf)((0,p.__)("Edit unavailable: %s","mailpoet"),e.missing_plugin_message?.message??(0,p.__)("Required plugin is inactive.","mailpoet"))}(e)):null)},{id:"subscribers",label:(0,p.__)("Number of subscribers","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>e.is_plugin_missing?(0,r.createElement)("span",null,"—"):(0,r.createElement)("div",{"data-automation-id":`mailpoet_dynamic_segment_count_all_${e.id}`},e.count_all)},{id:"subscribed",label:(0,p.__)("Subscribed","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>e.is_plugin_missing?null:"0"===e.count_subscribed?(0,r.createElement)("span",null,e.count_subscribed):(0,r.createElement)("a",{"data-automation-id":`mailpoet_dynamic_segment_count_subscribed_${e.id}`,className:"components-button is-link mailpoet-listing-text-right-align",href:e.subscribers_url},e.count_subscribed)},{id:"updated_at",label:(0,p.__)("Modified","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{return t=e.updated_at,a=e.id,t?(0,r.createElement)("span",{"data-automation-id":a?`mailpoet_dynamic_segment_updated_at_${a}`:"mailpoet_dynamic_segment_updated_at"},m.U.Date.full(t)):(0,r.createElement)("span",null,"—");var t,a}}];var Cd=a(79534);const Id={type:"table",fields:["subscribers","subscribed","updated_at"],titleField:"name",showTitle:!0};function Ud(e){return{...Id,perPage:e.limit,page:Math.floor(e.offset/e.limit)+1,search:e.search,sort:{field:e.sort_by,direction:"asc"===e.sort_order?"asc":"desc"}}}function Ed(e,t){return(e.perPage??25)===t.limit&&(e.page??1)===Math.floor(t.offset/t.limit)+1&&(e.search??"")===t.search&&(e.sort?.field??"updated_at")===t.sort_by&&(e.sort?.direction??"desc")===t.sort_order}function Ad(e){return e.limit>0&&e.offset%e.limit!==0}var Td=a(87691);const Rd=[{name:(0,p.__)("Recently Subscribed","mailpoet"),slug:"recently-subscribed",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have subscribed to your emails within the last 30 days.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"subscribedDate",operator:"inTheLast",value:"30"}]},{name:(0,p.__)("Engaged Subscribers (30 days)","mailpoet"),slug:"engaged-subscribers-30-days",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have interacted with your emails or made at least one purchase, and received emails from you in the last 30 days.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"inTheLast",value:"30"}]},{name:(0,p.__)("Engaged Subscribers (3 months)","mailpoet"),slug:"engaged-subscribers-3-months",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have interacted with your emails or made at least one purchase, and received emails from you in the last 3 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"inTheLast",value:"90"}]},{name:(0,p.__)("Engaged Subscribers (6 months)","mailpoet"),slug:"engaged-subscribers-6-months",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have interacted with your emails or made at least one purchase, and received emails from you in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"inTheLast",value:"180"}],filtersConnect:Eo.Z2.OR},{name:(0,p.__)("Unengaged Subscribers","mailpoet"),slug:"unengaged-subscribers",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who haven’t interacted with your emails, haven’t made a purchase, or haven’t visited your page in the last 6 months.","mailpoet"),filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"notInTheLast",value:"180"},{segmentType:"userRole",action:"subscribedDate",operator:"notInTheLast",value:"210"},{segmentType:"email",action:"numberReceived",operator:"more",emails:"9",timeframe:Eo.VE.ALL_TIME}],isEssential:!0},{name:(0,p.__)("First-Time Buyers","mailpoet"),slug:"first-time-buyers",category:Eo.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made their first purchase in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:"firstOrder",operator:el.IN_THE_LAST,value:"30"}],isEssential:!0},{name:(0,p.__)("Recent Buyers","mailpoet"),slug:"recent-buyers",category:Eo.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made a purchase within the last 30 days. ","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Eo.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:0,days:"30"}]},{name:(0,p.__)("Repeat Buyers","mailpoet"),slug:"repeat-buyers",category:Eo.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made at least two purchases in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Eo.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:1,days:"180"}]},{name:(0,p.__)("Loyal Buyers","mailpoet"),slug:"loyal-buyers",category:Eo.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made at least five purchases in the last 12 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Eo.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:4,days:"365"}]},{name:(0,p.__)("Win-Back","mailpoet"),slug:"win-back",category:Eo.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have previously purchased, but haven’t made a purchase in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastPurchaseDate",operator:"notInTheLast",value:"180"}]},{name:(0,p.__)("Lapsed Customers","mailpoet"),slug:"lapsed-customers",category:Eo.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who haven’t made a purchase in the last 9 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"userRole",action:"lastPurchaseDate",operator:"notInTheLast",value:"270"}]},{name:(0,p.__)("Clickers","mailpoet"),slug:"clickers",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who regularly click on your emails in the last 90 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:Eo.VE.IN_THE_LAST,clicks:"2",days:"90"}],isEssential:!1},{name:(0,p.__)("Non-Openers","mailpoet"),slug:"non-openers",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have received but haven’t opened an email in the last 90 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"numberReceived",operator:"more",timeframe:Eo.VE.IN_THE_LAST,emails:"0",days:"90"},{segmentType:"email",action:"opensAbsoluteCount",operator:"equals",timeframe:Eo.VE.IN_THE_LAST,opens:"0",days:"90"}]},{name:(0,p.__)("Recent Clickers","mailpoet"),slug:"recent-clickers",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have clicked on an email in the last 7 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:Eo.VE.IN_THE_LAST,clicks:"0",days:"7"}],isEssential:!1},{name:(0,p.__)("Recent Openers","mailpoet"),slug:"recent-openers",category:Eo.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have opened an email in the last 7 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"opensAbsoluteCount",operator:"more",timeframe:Eo.VE.IN_THE_LAST,opens:"0",days:"7"}]},{name:(0,p.__)("Big Spenders","mailpoet"),slug:"big-spenders",category:Eo.eu.SHOPPING_BEHAVIOR,description:(0,p.__)("Customers who have completed $100 or more worth of orders in the last 12 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"woocommerce",action:"totalSpent",timeframe:Eo.VE.IN_THE_LAST,total_spent_type:">",total_spent_amount:100,days:"365"}]},{name:(0,p.__)("Used a discount code","mailpoet"),slug:"used-a-discount-code",category:Eo.eu.SHOPPING_BEHAVIOR,description:(0,p.__)("Customers who made a purchase with a coupon code in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:dl.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:0,timeframe:Eo.VE.IN_THE_LAST,days:"30"}],isEssential:!1},{name:(0,p.__)("Frequently uses discounts","mailpoet"),slug:"frequently-uses-discounts",category:Eo.eu.SHOPPING_BEHAVIOR,description:(0,p.__)("Customers who have regularly used coupons in the last 90 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:dl.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:2,timeframe:Eo.VE.IN_THE_LAST,days:"90"}],isEssential:!1}],Pd=[{slug:Eo.eu.ENGAGEMENT,name:(0,p.__)("Engagement","mailpoet")},{slug:Eo.eu.PURCHASE_HISTORY,name:(0,p.__)("Purchase History","mailpoet")},{slug:Eo.eu.SHOPPING_BEHAVIOR,name:(0,p.__)("Shopping Behavior","mailpoet")}];function Dd(e){const t=Pd.find(t=>t.slug===e);return t?t.name:null}var Od=a(97384);const Fd=[{name:"all",title:(0,g.jsx)(Od.Ic,{title:(0,p.__)("All","mailpoet"),count:Rd.length})}];Pd.forEach(e=>{const t=Rd.filter(t=>t.category===e.slug).length;Fd.push({name:e.slug,title:(0,g.jsx)(Od.Ic,{title:e.name,count:t})})});const Md=document.getElementById("dynamic_segments_container");function Ld(){const{setPreviousPage:e}=(0,ue.A)(Ao.Hz),t=(0,ke.zy)(),a=(0,r.useRef)(t.pathname);return(0,r.useEffect)(()=>{e(a.current),a.current=t.pathname},[t,e]),null}const $d=(0,o.withBoundary)(bd),Wd=(0,o.withBoundary)(function(){const e=(0,v.A)(e=>e(Ao.Hz).getErrors(),[]),{createFromTemplate:t}=(0,ue.A)(Ao.Hz),a=()=>{m.U.trackEvent("Segments > New empty segment")};return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsxs)(Oe.z,{className:"mailpoet-templates-header",heading:(0,p.__)("Start with a pre-built segment","mailpoet"),headingPrefix:(0,g.jsx)(Oe.o,{href:"#/",label:(0,p.__)("Segments list","mailpoet"),"aria-label":(0,p.__)("Navigate to the segments list page","mailpoet")}),children:[(0,g.jsx)(Td.A,{label:(0,p.__)("Search segment templates","mailpoet"),onChange:()=>null}),(0,g.jsx)("a",{href:`#${jd.LX}`,"data-automation-id":"new-custom-segment",onClick:()=>{a()},className:"page-title-action",children:(0,p.__)("Or, create custom segment","mailpoet")})]}),e.length>0&&(0,g.jsx)(La,{errors:e.map(e=>({message:e}))}),(0,g.jsx)(Od.Kp,{tabs:Fd,children:e=>(0,g.jsx)(Od.xA,{children:Rd.filter(t=>"all"===e.name||t.category===e.name).map(e=>(0,g.jsx)(Od.q7,{name:e.name,description:e.description,category:Dd(e.category),badge:e.isEssential?"essential":void 0,onClick:()=>{t(e)}},e.slug))})}),(0,g.jsxs)(Od.wi,{children:[(0,g.jsx)("p",{children:(0,p.__)("Want to set your own conditions?","mailpoet")}),(0,g.jsx)(ce.Ay,{variant:"link",href:`#${jd.LX}`,onClick:()=>{a()},children:(0,p.__)("Create custom segment","mailpoet")})]})]})}),Bd=(0,o.withBoundary)(function(){const[e]=(0,r.useState)(()=>(0,yd.dt)()),[t,a]=(0,r.useState)(e.group),[i,s]=(0,r.useState)([]),[n,o]=(0,r.useState)(null),[l,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),_=(0,r.useRef)(Ad(e)?e.offset:null),f=(0,r.useRef)(Ud(e)),x=(0,r.useRef)(e.group),v=(0,r.useCallback)(e=>async function(e){return Sd(),(await(0,ao.default)({path:(0,io.F)("/mailpoet/v1/dynamic-segments",Nd(e)),method:"GET"})).data}({...e,group:t}),[t]),{view:y,setView:j,items:w,meta:S,groups:N,isLoading:k,error:C,clearError:I,refresh:U}=(0,eo.i)({initialView:Ud(e),load:v,extraParams:t=>null!==_.current&&Ed(t,{...e,offset:_.current})?{page:void 0,per_page:void 0,offset:_.current,limit:t.perPage??e.limit,sort_by:t.sort?.field??"updated_at",sort_order:t.sort?.direction??"desc"}:{}});(0,r.useEffect)(()=>{f.current=y,x.current=t},[t,y]),(0,r.useEffect)(()=>{null!==_.current&&Ed(y,{...e,offset:_.current})||(0,yd.ql)({group:t,limit:y.perPage??25,offset:((y.page??1)-1)*(y.perPage??25),search:y.search??"",sort_by:y.sort?.field??"updated_at",sort_order:y.sort?.direction??"desc"})},[t,e,y]),(0,r.useEffect)(()=>{const e=()=>{const e=(0,yd.dt)(),t=e.group;_.current=Ad(e)?e.offset:null,t!==x.current&&a(t),Ed(f.current,e)||j(t=>Ed(t,e)?t:Ud(e)),s([]),o(null),c(null),I()};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[I,j]);const E=e=>{_.current=null,j(e)},A=(0,r.useCallback)(async(e,t)=>{if(0!==t.length)try{const a=await async function(e,t){return Sd(),(await(0,ao.default)({path:"/mailpoet/v1/dynamic-segments/bulk-action",method:"POST",data:{action:e,ids:t}})).data}(e,t.map(e=>Number(e.id))),i=function(e,t){return"delete"===e?t.deleted:t.updated}(e,a);s([]),o(a.errors.length?a.errors.map(e=>e.message).join("\n"):null),c(i>0?function(e,t){return"trash"===e?(0,p.sprintf)((0,p._n)("Segment moved to trash.","%d segments moved to trash.",t,"mailpoet"),t):"restore"===e?(0,p.sprintf)((0,p._n)("Segment restored.","%d segments restored.",t,"mailpoet"),t):(0,p.sprintf)((0,p._n)("Segment permanently deleted.","%d segments permanently deleted.",t,"mailpoet"),t)}(e,i):null),U()}catch(e){const t=e;c(null),o(t?.message||(0,p.__)("The bulk action could not be completed.","mailpoet"))}},[U]),T=(0,r.useCallback)(async e=>{try{const t=(await m.U.Ajax.post({api_version:"v1",endpoint:"dynamic_segments",action:"duplicate",data:{id:e.id}})).data;m.U.Notice.success((0,p.sprintf)((0,p.__)('Segment "%s" has been duplicated.',"mailpoet"),(0,_n.Zn)(t.name))),U()}catch(e){(0,Cd.C)(e)&&m.U.Notice.showApiErrorNotice(e)}},[U]),R=(0,r.useMemo)(()=>[{id:"view_subscribers",label:(0,p.__)("View subscribers","mailpoet"),supportsBulk:!1,callback:e=>{const t=e[0];t&&(window.location.href=t.subscribers_url)}},{id:"edit",label:(0,p.__)("Edit","mailpoet"),isPrimary:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at&&!e.is_plugin_missing,callback:e=>{const t=e[0];t&&(window.location.hash=`${jd.r$}/${t.id}`)}},{id:"edit_missing_plugin",label:(0,p.__)("Edit unavailable","mailpoet"),disabled:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at&&e.is_plugin_missing,callback:()=>{}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),supportsBulk:!1,isEligible:e=>!e.deleted_at,callback:e=>{e[0]&&T(e[0])}},{id:"trash",label:(0,p.__)("Move to trash","mailpoet"),supportsBulk:!0,isEligible:e=>!e.deleted_at,callback:e=>{h({action:"trash",selected:e})}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:e=>!!e.deleted_at,callback:e=>{h({action:"restore",selected:e})}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>!!e.deleted_at,callback:e=>{h({action:"delete",selected:e})}}],[T]),P=(0,r.useMemo)(()=>({totalItems:S.count,totalPages:S.pages}),[S]),D=(0,r.useMemo)(()=>{const e={all:null,trash:null};(N??[]).forEach(t=>{"all"!==t.name&&"trash"!==t.name||(e[t.name]=t.count)});const t=(e,t)=>null===t?e:`${e} (${t})`;return[{name:"all",title:t((0,p.__)("All","mailpoet"),e.all),className:"mailpoet-dataviews-group-all mailpoet-tab-all"},{name:"trash",title:t((0,p.__)("Trash","mailpoet"),e.trash),className:"mailpoet-dataviews-group-trash mailpoet-tab-trash"}]},[N]),O=function(e){if(!e)return{title:"",message:"",confirmText:""};const{action:t,selected:a}=e,i=a.map(({name:e})=>`"${e}"`).join(", ");return"trash"===t?{title:(0,p._n)("Trash selected segment","Trash selected segments",a.length,"mailpoet"),message:(0,p.sprintf)((0,p._n)("Are you sure you want to trash the selected segment %s?","Are you sure you want to trash the selected segments %s?",a.length,"mailpoet"),i),confirmText:(0,p.__)("Trash","mailpoet")}:"restore"===t?{title:(0,p._n)("Restore selected segment","Restore selected segments",a.length,"mailpoet"),message:(0,p.sprintf)((0,p._n)("Are you sure you want to restore the selected segment %s?","Are you sure you want to restore segments %s?",a.length,"mailpoet"),i),confirmText:(0,p.__)("Restore","mailpoet")}:{title:(0,p._n)("Delete selected segment permanently","Delete selected segments permanently",a.length,"mailpoet"),message:(0,g.jsxs)(g.Fragment,{children:[(0,p.sprintf)((0,p._n)("Are you sure you want to delete the selected segment %s permanently?","Are you sure you want to delete the selected segments %s permanently?",a.length,"mailpoet"),i)," ",(0,g.jsx)("strong",{children:(0,p.__)("This action can not be reversed.","mailpoet")})]}),confirmText:(0,p.__)("Delete permanently","mailpoet")}}(u);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(vd,{}),(0,g.jsx)(Oe.z,{heading:(0,p.__)("Segments","mailpoet"),children:(0,g.jsx)("a",{href:`#${jd.WA}`,"data-automation-id":"new-segment",className:"page-title-action",children:(0,p.__)("Add new segment","mailpoet")})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(Me,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)($e,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]}),(0,g.jsx)(b.D,{}),C&&(0,g.jsx)(Qr.A,{status:"error",onRemove:I,children:C}),n&&(0,g.jsx)(Qr.A,{status:"error",onRemove:()=>o(null),children:n}),l&&(0,g.jsx)(Qr.A,{status:"success",onRemove:()=>c(null),children:l}),(0,g.jsx)(Jr.A,{className:"mailpoet-segments-dataviews__tabs",activeClass:"is-active",tabs:D,initialTabName:t,onSelect:e=>{"all"!==e&&"trash"!==e||e!==t&&(_.current=null,a(e),s([]),o(null),c(null),I(),j({...y,page:1}))},children:()=>(0,g.jsx)("div",{className:"mailpoet-segments-dataviews mailpoet-segments-listing","data-automation-id":"dynamic_segments_listing",children:(0,g.jsxs)(Xr.A,{data:w,fields:kd,view:y,onChangeView:E,actions:R,paginationInfo:P,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:i,onChangeSelection:s,isLoading:k,empty:(0,g.jsx)("div",{children:(0,p.__)("No data to display","mailpoet")}),children:[(0,g.jsx)("div",{className:"mailpoet-segments-dataviews__toolbar",children:(0,g.jsx)(Xr.A.Search,{label:(0,p.__)("Search","mailpoet")})}),(0,g.jsx)(Xr.A.Layout,{}),(0,g.jsx)(Xr.A.Footer,{})]})})},t),(0,g.jsx)(Zr.A,{className:"mailpoet-confirm-dialog",isOpen:!!u,title:O.title,confirmButtonText:O.confirmText,__experimentalHideHeader:!1,onConfirm:()=>{u&&A(u.action,u.selected),h(null)},onCancel:()=>h(null),children:(0,g.jsx)("p",{children:O.message})})]})});function qd(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(Ld,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:jd.LX,element:(0,g.jsx)($d,{})}),(0,g.jsx)(ke.qh,{path:`${jd.r$}/:id`,element:(0,g.jsx)($d,{})}),(0,g.jsx)(ke.qh,{path:jd.WA,element:(0,g.jsx)(Wd,{})}),(0,g.jsx)(ke.qh,{path:"*",element:(0,g.jsx)(Bd,{})})]})]})})}Md&&((0,o.registerTranslations)(),(0,Ao.y$)(),(0,n.H)(Md).render((0,g.jsx)(qd,{})));const Hd=()=>{m.U.trackEvent("Forms > Add New"),setTimeout(()=>{window.location.href=window.mailpoet_form_template_selection_url},200)};function zd(){const[e,t]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(We,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(Oe.z,{heading:(0,p.__)("Forms","mailpoet"),children:(0,g.jsx)("button",{onClick:()=>{t(!0),Hd()},"data-automation-id":"create_new_form",className:"page-title-action "+(e?"mailpoet-button-with-spinner":""),type:"button",children:(0,p.__)("Add new form","mailpoet")})})]})}function Vd({form:e}){const[t,a]=(0,r.useState)("enabled"===e.status),[i,s]=(0,r.useState)(!1);return(0,g.jsxs)("div",{children:[(0,g.jsx)(Ai.l,{onCheck:(i,n)=>{n.persist();const r=t;a(i),s(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"setStatus",data:{id:Number(e.id),status:i?"enabled":"disabled"}}).done(e=>{"enabled"===e.data.status&&m.U.Notice.success((0,p.__)("Your Form is now activated!","mailpoet"))}).fail(e=>{m.U.Notice.showApiErrorNotice(e),a(r)}).always(()=>s(!1))},"data-id":e.id,dimension:"small",checked:t,disabled:i}),(0,g.jsxs)("p",{children:[(0,p.__)("Sign-ups","mailpoet"),": ",e.signups.toLocaleString()]})]})}zd.displayName="FormsHeading",Vd.displayName="FormStatusToggle";const Yd=[{id:"name",label:(0,p.__)("Name","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-form-editor&id=${e.id}`},e.name?e.name:`(${(0,p.__)("no name","mailpoet")})`)},{id:"segments",label:(0,p.__)("Lists","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>{const t=new Set(e.segments.map(e=>String(e))),a=window.mailpoet_segments.filter(e=>t.has(String(e.id)));return(0,r.createElement)(fn.vC,{segments:a,dimension:"large"},"user"===e.settings?.segments_selected_by?(0,r.createElement)("span",{className:"mailpoet-tags-prefix"},(0,p.__)("User choice:","mailpoet")):null)}},{id:"type",label:(0,p.__)("Type","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)("span",null,function(e){const t=[],a=e?.form_placement;return"1"===a?.fixed_bar?.enabled&&t.push((0,p.__)("Fixed bar","mailpoet")),"1"===a?.below_posts?.enabled&&t.push((0,p.__)("Below pages","mailpoet")),"1"===a?.popup?.enabled&&t.push((0,p.__)("Pop-up","mailpoet")),"1"===a?.slide_in?.enabled&&t.push((0,p.__)("Slide–in","mailpoet")),t.length>0?t.join(", "):(0,p.__)("Others (widget)","mailpoet")}(e.settings))},{id:"status",label:(0,p.__)("Status","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)(Vd,{form:e})},{id:"updated_at",label:(0,p.__)("Modified date","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>e.updated_at?(0,r.createElement)("span",null,m.U.Date.full(e.updated_at)):(0,r.createElement)("span",null,"—")}];let Gd=!1;function Kd(){if(Gd)return;const e=window.mailpoet_forms_api;ao.default.use(ao.default.createRootURLMiddleware(`${e.root}/`)),ao.default.use(ao.default.createNonceMiddleware(e.nonce)),Gd=!0}const Qd={type:"table",perPage:20,page:1,sort:{field:"updated_at",direction:"desc"},fields:["segments","type","status","updated_at"],titleField:"name",showTitle:!0};function Jd(){const[e,t]=(0,r.useState)("all"),[a,i]=(0,r.useState)([]),[s,n]=(0,r.useState)(null),[l,d]=(0,r.useState)(null),c=(0,r.useCallback)(t=>async function(e){return Kd(),(await(0,ao.default)({path:(0,io.F)("/mailpoet/v1/forms",e),method:"GET"})).data}({...t,group:e}),[e]),{view:u,setView:h,items:_,meta:f,groups:b,isLoading:x,error:v,clearError:y,refresh:j}=(0,eo.i)({initialView:Qd,load:c}),w=(0,r.useRef)(new Set);(0,r.useEffect)(()=>{_.forEach(e=>{null===e.settings&&(w.current.has(e.id)||(w.current.add(e.id),m.U.Notice.error((0,p.__)('Form settings of "%1$s" form are corrupted. Please [link]reconfigure the form in the editor[/link].',"mailpoet").replace("%1$s",(0,_n.Zn)(e.name)).replace("[link]",``).replace("[/link]",""))))})},[_]);const S=(0,r.useCallback)(async(e,t)=>{const a=t.map(e=>Number(e.id));if(0!==a.length){if("delete"===e){const e=1===a.length?(0,p.__)("Delete this form permanently?","mailpoet"):(0,p.sprintf)((0,p._n)("Delete %d form permanently?","Delete %d forms permanently?",a.length,"mailpoet"),a.length);if(!window.confirm(e))return}try{const t=await async function(e,t){return Kd(),(await(0,ao.default)({path:"/mailpoet/v1/forms/bulk-action",method:"POST",data:{action:e,ids:t}})).data.count}(e,a);i([]),d(function(e,t){return"trash"===e?1===t?(0,p.__)("1 form was moved to the trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d form was moved to the trash.","%d forms were moved to the trash.",t,"mailpoet"),t):"restore"===e?1===t?(0,p.__)("1 form has been restored from the trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d form has been restored from the trash.","%d forms have been restored from the trash.",t,"mailpoet"),t):1===t?(0,p.__)("1 form was permanently deleted.","mailpoet"):(0,p.sprintf)((0,p._n)("%d form was permanently deleted.","%d forms were permanently deleted.",t,"mailpoet"),t)}(e,t)),j()}catch(e){const t=e;n(t?.message||(0,p.__)("The bulk action could not be completed.","mailpoet"))}}},[j]),N=(0,r.useCallback)(e=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"duplicate",data:{id:Number(e.id)}}).done(e=>{const t=e.data.name?e.data.name:(0,p.__)("no name","mailpoet");m.U.Notice.success((0,p.__)('Form "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,_n.Zn)(t))),j()}).fail(e=>{e.errors&&e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[j]),k=(0,r.useMemo)(()=>[{id:"edit",label:(0,p.__)("Edit","mailpoet"),icon:"edit",isPrimary:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at,callback:e=>{const t=e[0];t&&(window.location.href=`admin.php?page=mailpoet-form-editor&id=${t.id}`)}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),supportsBulk:!1,isEligible:e=>!e.deleted_at,callback:e=>{e[0]&&N(e[0])}},{id:"trash",label:(0,p.__)("Move to trash","mailpoet"),supportsBulk:!0,isEligible:e=>!e.deleted_at,callback:e=>{S("trash",e)}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:e=>!!e.deleted_at,callback:e=>{S("restore",e)}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>!!e.deleted_at,callback:e=>{S("delete",e)}}],[S,N]),C=(0,r.useMemo)(()=>({totalItems:f.count,totalPages:f.pages}),[f]),I=(0,r.useMemo)(()=>{const e={all:null,trash:null};(b??[]).forEach(t=>{"all"!==t.name&&"trash"!==t.name||(e[t.name]=t.count)});const t=(e,t)=>null===t?e:`${e} (${t})`;return[{name:"all",title:t((0,p.__)("All","mailpoet"),e.all),className:"mailpoet-dataviews-group-all"},{name:"trash",title:t((0,p.__)("Trash","mailpoet"),e.trash),className:"mailpoet-dataviews-group-trash"}]},[b]),U="trash"===e?(0,p.__)("Trash is empty.","mailpoet"):(0,p.__)("No forms were found. Why not create a new one?","mailpoet");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(zd,{}),v&&(0,g.jsx)(Qr.A,{status:"error",onRemove:y,children:v}),s&&(0,g.jsx)(Qr.A,{status:"error",onRemove:()=>n(null),children:s}),l&&(0,g.jsx)(Qr.A,{status:"success",onRemove:()=>d(null),children:l}),(0,g.jsx)(Jr.A,{className:"mailpoet-forms-dataviews__tabs",activeClass:"is-active",tabs:I,initialTabName:e,onSelect:a=>{"all"!==a&&"trash"!==a||a!==e&&(t(a),i([]),n(null),d(null),y(),h({...u,page:1}))},children:()=>(0,g.jsx)("div",{className:"mailpoet-forms-dataviews","data-automation-id":"forms_listing",children:(0,g.jsxs)(Xr.A,{data:_,fields:Yd,view:u,onChangeView:h,actions:k,paginationInfo:C,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:a,onChangeSelection:i,isLoading:x,empty:"trash"===e?(0,g.jsx)("div",{children:U}):(0,g.jsxs)("div",{className:"mailpoet-forms-add-new-row",children:[(0,g.jsx)("p",{children:U}),(0,g.jsx)(o.Button,{onClick:Hd,automationId:"add_new_form",children:(0,p.__)("Add new form","mailpoet")})]}),children:[(0,g.jsx)("div",{className:"mailpoet-forms-dataviews__toolbar",children:(0,g.jsx)(Xr.A.Search,{label:(0,p.__)("Search forms","mailpoet")})}),(0,g.jsx)(Xr.A.Layout,{}),(0,g.jsx)(Xr.A.Footer,{})]})})})]})}Jd.displayName="FormList";const Zd=jr(Jd);function Xd(){return(0,g.jsx)(Zd,{})}function ec(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsx)(b.D,{}),(0,g.jsx)(ke.BV,{children:(0,g.jsx)(ke.qh,{path:"*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Xd,{})})})})]})})}const tc=document.getElementById("forms_container");function ac(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:m.U.I18n.t("knowledgeBaseIntro")}),(0,g.jsxs)("ul",{className:"mailpoet-text-links",children:[(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/116-common-problems",children:"Common Problems"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/165-guides-tips",children:"Newsletters"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/156-migration-questions",children:"Migration Questions"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/149-other-sending-methods",children:"Sending Methods"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/139-subscription-forms",children:"Subscription Forms"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/114-getting-started",children:"Getting Started"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/123-newsletter-editor-designer",children:"Newsletter Designer"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/121-subscribers-and-lists",children:"Subscribers and Lists"})})]}),(0,g.jsx)(Le.$,{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/",children:m.U.I18n.t("knowledgeBaseButton")})]})}tc&&((0,o.registerTranslations)(),(0,n.H)(tc).render((0,g.jsx)(ec,{})));var ic=a(61630);function sc(e){e.target.select()}function nc(e,t){if(mt.default.isObject(e)){const a=Object.keys(e).map(t=>`${t}: ${e[t]}`);return(0,g.jsx)("textarea",{readOnly:!0,id:t,onFocus:sc,value:a.join("\n"),style:{width:"100%",height:"400px"}})}return(0,g.jsx)("p",{children:m.U.I18n.t("systemInfoDataError")})}function rc(){const e="mailpoet-system-info",t=window.systemInfoData;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,g.jsx)("p",{children:m.U.I18n.t("systemInfoIntro")})}),nc(t,e),(0,g.jsx)(ic.T,{variant:"secondary",targetId:e})]})}function oc({rows:e,max_width:t="auto",is_fixed:a=!0}){return(0,g.jsx)("table",{className:Z()("widefat",{fixed:a}),style:{maxWidth:t},children:(0,g.jsx)("tbody",{children:e.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{className:"row-title",children:e.key}),(0,g.jsx)("td",{children:e.value}),e.action?(0,g.jsx)("td",{children:e.action}):null]},`row_${e.key}`))})})}function lc({truthy:e=(0,p.__)("Yes","mailpoet"),falsy:t=(0,p.__)("No","mailpoet"),unknown:a=(0,p.__)("Unknown","mailpoet"),children:i=null}){return(0,g.jsx)("span",{children:!0===i&&e||!1===i&&t||a})}function dc(e){const t=e.status_data,a={active:m.U.I18n.t("running"),inactive:m.U.I18n.t("cronWaiting")},i=Array.isArray(t.last_error)?(0,g.jsx)(g.Fragment,{children:t.last_error.map(e=>(0,g.jsxs)("div",{children:[e.worker,": ",(0,g.jsx)("i",{children:e.message})]},e.worker))}):t.last_error;return(0,g.jsxs)("div",{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusCronStatusTitle")}),(0,g.jsx)(oc,{max_width:"400px",rows:[{key:m.U.I18n.t("accessible"),value:(0,g.jsx)(lc,{children:t.accessible})},{key:m.U.I18n.t("status"),value:a[t.status]?a[t.status]:m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastUpdated"),value:t.updated_at?m.U.Date.full(1e3*t.updated_at):m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastRunStarted"),value:t.run_started_at?m.U.Date.full(1e3*t.run_started_at):m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastRunCompleted"),value:t.run_completed_at?m.U.Date.full(1e3*t.run_completed_at):m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastSeenError"),value:i||m.U.I18n.t("none")},{key:m.U.I18n.t("lastSeenErrorDate"),value:t.last_error_date?m.U.Date.full(1e3*t.last_error_date):m.U.I18n.t("unknown")}]})]})}function cc({task:e,type:t}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,r.useState)(null),o="cancel"===t,l="reschedule"===t,d=e.scheduledAt,c=m.U.Date.isInPast(d,new Date);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Zr.A,{className:"mailpoet-help-modal",isOpen:a,title:o?(0,p.__)("Cancel task","mailpoet"):(0,p.__)("Reschedule task","mailpoet"),cancelButtonText:(0,p.__)("Not now","mailpoet"),confirmButtonText:o?(0,p.__)("Yes, cancel task","mailpoet"):(0,p.__)("Yes, reschedule task","mailpoet"),onConfirm:async()=>{await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"help",action:o?"cancelTask":"rescheduleTask",data:{id:e.id}}).done(()=>{n(null),i(!1),window.location.reload()}).catch(e=>{n(e.errors.map(e=>e.message).join(" "))})},onCancel:()=>i(!1),__experimentalHideHeader:!1,children:[s&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Qr.A,{status:"error",isDismissible:!1,children:s}),(0,g.jsx)("br",{})]}),o&&(0,p.sprintf)((0,p.__)('Are you sure you want to cancel the task with ID %1$s for the email "%2$s"? Once cancelled, the email will not be sent.',"mailpoet"),e.id.toString(),e.newsletter.subject||(0,p.__)("(no subject)","mailpoet")),l&&(0,p.sprintf)((0,p.__)('Are you sure you want to reschedule the task with ID %1$s for the email "%2$s"?',"mailpoet"),e.id.toString(),e.newsletter.subject||(0,p.__)("(no subject)","mailpoet"))," ",l&&c&&(0,p.__)("The email will be sent immediately.","mailpoet"),l&&!c&&(0,p.sprintf)((0,p.__)("The task will be scheduled for sending on %s.","mailpoet"),m.U.Date.full(d))]}),(0,g.jsx)(ce.Ay,{variant:"secondary",size:"small",isDestructive:o,onClick:()=>i(!0),children:o?(0,p.__)("Cancel task","mailpoet"):(0,p.__)("Reschedule task","mailpoet")})]})}function mc({task:e}){return(0,g.jsx)(cc,{task:e,type:"cancel"})}function uc({task:e}){return(0,g.jsx)(cc,{task:e,type:"reschedule"})}function pc({type:e,task:t}){const a="scheduled"===e,i="cancelled"===e,s="scheduled"===e||"running"===e,n="cancelled"===e;return(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{className:"column column-primary",children:t.id}),(0,g.jsx)("td",{className:"column",children:t.newsletter?(0,g.jsx)("a",{href:t.newsletter.previewUrl,"data-newsletter-id":t.newsletter.newsletterId,"data-queue-id":t.newsletter.queueId,target:"_blank",rel:"noopener noreferrer",children:t.newsletter.subject||m.U.I18n.t("preview")}):m.U.I18n.t("none")}),(0,g.jsx)("td",{className:"column",children:t.subscriberEmail?(0,g.jsx)("a",{href:`admin.php?page=mailpoet-subscribers#/search[${t.subscriberEmail}]`,children:t.subscriberEmail}):(0,g.jsx)("i",{children:m.U.I18n.t("multipleSubscribers")})}),(0,g.jsx)("td",{className:"column",children:t.priority}),a?(0,g.jsx)("td",{className:"column-date",children:(0,g.jsx)("abbr",{children:m.U.Date.full(t.scheduledAt)})}):null,i?(0,g.jsx)("td",{className:"column-date",children:(0,g.jsx)("abbr",{children:m.U.Date.full(t.cancelledAt)})}):null,(0,g.jsx)("td",{className:"column-date",children:(0,g.jsx)("abbr",{children:m.U.Date.full(t.updatedAt)})}),s?(0,g.jsx)("td",{children:(0,g.jsx)(mc,{task:t})}):null,n?(0,g.jsx)("td",{children:(0,g.jsx)(uc,{task:t})}):null]})}function hc({type:e}){const t=["scheduled","running","cancelled"].includes(e);return(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{className:"row-title",children:"Id"}),(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("email")}),(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("subscriber")}),(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("priority")}),"scheduled"===e?(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("scheduledAt")}):null,"cancelled"===e?(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("cancelledAt")}):null,(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("updatedAt")}),t?(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("action")}):null]})}function gc({tasks:e,type:t}){let a=5;return"running"===t&&(a+=1),"scheduled"!==t&&"cancelled"!==t||(a+=2),(0,g.jsxs)("table",{className:"widefat fixed striped",children:[(0,g.jsx)("thead",{children:(0,g.jsx)(hc,{type:t})}),(0,g.jsx)("tbody",{children:e.length?e.map(e=>(0,g.jsx)(pc,{task:e,type:t},e.id)):(0,g.jsx)("tr",{className:"mailpoet-listing-no-items",children:(0,g.jsx)("td",{colSpan:a,children:m.U.I18n.t("nothingToShow")})})}),(0,g.jsx)("tfoot",{children:(0,g.jsx)(hc,{type:t})})]})}function _c({statusData:e}){const t=e;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusQueueTitle")}),(0,g.jsx)(oc,{max_width:"400px",rows:[{key:m.U.I18n.t("status"),value:"paused"===t.status?m.U.I18n.t("paused"):m.U.I18n.t("running")},{key:m.U.I18n.t("startedAt"),value:t.started?m.U.Date.full(1e3*t.started):m.U.I18n.t("unknown")},{key:m.U.I18n.t("sentEmails"),value:t.sent||0},{key:m.U.I18n.t("retryAttempt"),value:t.retryAttempt||m.U.I18n.t("none")},{key:m.U.I18n.t("retryAt"),value:t.retryAt?m.U.Date.full(1e3*t.retryAt):m.U.I18n.t("none")},{key:m.U.I18n.t("error"),value:t.error?t.error.errorMessage:m.U.I18n.t("none")},{key:m.U.I18n.t("totalCompletedTasks"),value:t.tasksStatusCounts.completed},{key:m.U.I18n.t("totalRunningTasks"),value:t.tasksStatusCounts.running},{key:m.U.I18n.t("totalPausedTasks"),value:t.tasksStatusCounts.paused},{key:m.U.I18n.t("totalCancelledTasks"),value:t.tasksStatusCounts.cancelled},{key:m.U.I18n.t("totalScheduledTasks"),value:t.tasksStatusCounts.scheduled}]}),(0,g.jsx)("h5",{children:m.U.I18n.t("scheduledTasks")}),(0,g.jsx)(gc,{type:"scheduled",tasks:t.latestTasks.filter(e=>"scheduled"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("cancelledTasks")}),(0,g.jsx)(gc,{type:"cancelled",tasks:t.latestTasks.filter(e=>"cancelled"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("runningTasks")}),(0,g.jsx)(gc,{type:"running",tasks:t.latestTasks.filter(e=>null===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("pausedTasks")}),(0,g.jsx)(gc,{type:"paused",tasks:t.latestTasks.filter(e=>"paused"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("completedTasks")}),(0,g.jsx)(gc,{type:"completed",tasks:t.latestTasks.filter(e=>"completed"===e.status)})]})}function fc({version:e,storage:t,latestTrigger:a,latestCompletedTrigger:i,latestCompletedRun:s}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("actionSchedulerStatus")}),(0,g.jsx)(oc,{max_width:"400px",rows:[{key:m.U.I18n.t("version"),value:e},{key:m.U.I18n.t("storage"),value:t},{key:m.U.I18n.t("latestActionSchedulerTrigger"),value:m.U.Date.full(a)},{key:m.U.I18n.t("latestActionSchedulerCompletedTrigger"),value:m.U.Date.full(i)},{key:m.U.I18n.t("latestActionSchedulerCompletedRun"),value:m.U.Date.full(s)}]})]})}function bc(){const[e,t]=(0,r.useState)({total:0}),[a,i]=(0,r.useState)("");(0,r.useEffect)(()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"help",action:"getInconsistentDataStatus"}).done(e=>{t(e.data||null)}).catch(e=>{m.U.Notice.show({type:"error",message:e.errors.map(e=>e.message).join(" "),scroll:!0})})},[]);const s=(0,r.useMemo)(()=>({orphaned_sending_tasks:(0,p.__)("Orphaned Sending Tasks","mailpoet"),orphaned_sending_task_subscribers:(0,p.__)("Orphaned Sending Task Subscribers","mailpoet"),sending_queue_without_newsletter:(0,p.__)("Sending Queues without Newsletter","mailpoet"),orphaned_subscriptions:(0,p.__)("Orphaned Subscriptions","mailpoet"),orphaned_links:(0,p.__)("Orphaned Links","mailpoet"),orphaned_newsletter_posts:(0,p.__)("Orphaned Newsletter Posts","mailpoet")}),[]),n=(0,r.useCallback)(e=>{i(e),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"help",action:"fixInconsistentData",data:{inconsistency:e}}).done(e=>{i(""),t(e.data||null),m.U.Notice.show({message:(0,p.__)("Inconsistency fixed!","mailpoet"),scroll:!0})}).catch(e=>{i(""),m.U.Notice.show({type:"error",message:e.errors.map(e=>e.message).join(" "),scroll:!0})})},[]);if(!e||0===e.total)return null;const o=Object.entries(e).filter(([e,t])=>"total"!==e&&t>0).map(([e,t])=>({key:s[e],value:t,action:(0,g.jsx)(ce.Ay,{variant:"primary",size:"small",label:(0,p.__)("Clean","mailpoet"),onClick:()=>n(e),isBusy:a===e,disabled:!!a,children:(0,p.__)("Fix","mailpoet")})}));return(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{children:(0,p.__)("Data Inconsistencies","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)('We found the following data inconsistencies in your DB. Click the "Fix" button to clean them.',"mailpoet")}),(0,g.jsx)(oc,{rows:o,max_width:"400px",is_fixed:!1})]})}function xc(e){return null==e||""===e?m.U.I18n.t("none"):"boolean"==typeof e?e?m.U.I18n.t("yes"):m.U.I18n.t("no"):Array.isArray(e)?0===e.length?m.U.I18n.t("none"):e.map(e=>e&&e.worker&&e.message?`${e.worker}: ${e.message}`:`${e}`).join("; "):"object"==typeof e?JSON.stringify(e):`${e}`}function vc(e){return e?m.U.Date.full(1e3*e):m.U.I18n.t("unknown")}function yc(e,t){e.push(""),e.push(`### ${t} ###`)}function jc(e,t,a){e.push(` - ${t}: ${xc(a)}`)}function wc(e){return null==e||""===e?m.U.I18n.t("none"):e}function Sc(e){if("boolean"==typeof e)return e?m.U.I18n.t("yes"):m.U.I18n.t("no");const t=`${e||""}`.trim().toLowerCase();return"yes"===t||"no"===t?m.U.I18n.t(t):xc(e)}function Nc(e,t){const a={};if(!e||"string"!=typeof e)return a;if(t&&t.length>0){const i=[...t].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),s=new RegExp(`(?:^| - )(?${i.join("|")}): `,"g"),n=[...e.matchAll(s)];return n.forEach((t,i)=>{const s=t.index+t[0].length,r=n[i+1]?n[i+1].index:e.length;a[t.groups.key]=e.slice(s,r).trim()}),a}return e.split(" - ").forEach(e=>{const t=e.indexOf(": ");-1!==t&&(a[e.slice(0,t).trim()]=e.slice(t+2).trim())}),a}function kc(e,t,a,i,s){const n=e?"success":"error";let r=e?t:a;return i&&(r=at()(r,/\[link\](.*?)\[\/link\]/g,e=>(0,g.jsx)("a",{className:"mailpoet-text-link",href:i,children:e},"kb-link"))),(0,g.jsxs)("div",{className:`mailpoet_notice notice inline notice-${n}`,children:[(0,g.jsx)("p",{children:r}),s?(0,g.jsx)("p",{children:(0,g.jsx)("i",{children:s})}):null]})}function Cc(e){const t=e.cron.isReachable,a=e.cron.url,i=`${m.U.I18n.t("systemStatusConnectionUnsuccessful")} ${m.U.I18n.t("systemStatusCronConnectionUnsuccessfulInfo")}`,s=m.U.I18n.t("systemStatusConnectionSuccessful"),n=t?null:e.cron.pingResponse;return(0,g.jsxs)("div",{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusCronTitle")}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{className:"mailpoet-text-link",href:a,target:"_blank",rel:"noopener noreferrer",children:a})}),kc(t,s,i,"https://kb.mailpoet.com/article/231-sending-does-not-work",n)]})}function Ic(e){const t=e.mss.enabled?`${m.U.I18n.t("systemStatusConnectionUnsuccessful")} ${m.U.I18n.t("systemStatusMSSConnectionUnsuccessfulInfo")}`:m.U.I18n.t("systemStatusMSSConnectionCanNotConnect"),a=e.mss.enabled?m.U.I18n.t("systemStatusConnectionSuccessful"):m.U.I18n.t("systemStatusMSSConnectionCanConnect");return(0,g.jsxs)("div",{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusMSSTitle")}),kc(e.mss.isReachable,a,t,"https://kb.mailpoet.com/article/319-known-errors-when-validating-a-mailpoet-key",null)]})}function Uc(){const e="mailpoet-system-status-report",t=window.systemInfoData,a=window.systemStatusData,i=window.actionSchedulerData,[s,n]=(0,r.useState)(!1),[o,l]=(0,r.useState)(m.U.I18n.t("systemStatusCopyForSupport")),d=(0,r.useMemo)(()=>function(e,t,a){const i=[],s=t.queueStatus||{},n=e||{},r=Nc(n["WP info"],["WP_MEMORY_LIMIT","WP_MAX_MEMORY_LIMIT","WP_DEBUG","WordPress language","WordPress timezone"]),o=Nc(n["PHP info"],["PHP max_execution_time","PHP memory_limit","PHP upload_max_filesize","PHP post_max_size"]),l=Nc(n["MailPoet Sending Service"],["Is reachable","Ping response","API key state","Premium key state"]),d=Nc(n["MailPoet sending info"],["Send all site's emails with","Task Scheduler method","Default FROM address","Default Reply-To address","Bounce Email Address"]),c=Nc(n["Data inconsistency status"]),u=[l["API key state"],l["Premium key state"]?`premium: ${l["Premium key state"]}`:null].filter(Boolean).join("; "),p=u?`${n["MailPoet Premium/MSS key"]} (${u})`:n["MailPoet Premium/MSS key"],h=t.cronStatus||{},g=Array.isArray(h.last_error)?h.last_error.map(e=>`${e.worker}: ${e.message}`).join("; "):h.last_error,_=a?.version||m.U.I18n.t("none"),f=a?.storage||m.U.I18n.t("none"),b=a?.latestTrigger?m.U.Date.full(a.latestTrigger):m.U.I18n.t("unknown"),x=a?.latestCompletedTrigger?m.U.Date.full(a.latestCompletedTrigger):m.U.I18n.t("unknown"),v=a?.latestCompletedRun?m.U.Date.full(a.latestCompletedRun):m.U.I18n.t("unknown");let y=m.U.I18n.t("unknown");"paused"===s.status?y=m.U.I18n.t("paused"):void 0!==s.status&&(y=m.U.I18n.t("running"));const j=void 0!==s.retryAttempt&&null!==s.retryAttempt?s.retryAttempt:m.U.I18n.t("none"),w=s.retryAt?vc(s.retryAt):m.U.I18n.t("unknown"),S=s.error?.errorMessage||m.U.I18n.t("none"),N=s.tasksStatusCounts||{},k=Array.isArray(t.activePlugins)?t.activePlugins.map(e=>({name:`${e?.name||""}`.trim(),author:`${e?.author||""}`.trim(),version:`${e?.version||""}`.trim(),versionLatest:e?.versionLatest?`${e.versionLatest}`.trim():null})).filter(e=>e.name&&e.author&&e.version):[];return i.push("### MailPoet System Status Report ###"),i.push(`Generated: ${(new Date).toISOString()}`),yc(i,"Site & Account"),jc(i,"Site name",n.name),jc(i,"Email",n.email),jc(i,"MailPoet Premium/MSS key",p),jc(i,"Plugin installed at",n["Plugin installed at"]),jc(i,"Installed via WooCommerce onboarding wizard",Sc(n["Installed via WooCommerce onboarding wizard"])),jc(i,"Total subscribers",n["Total number of subscribers"]),yc(i,"Versions"),jc(i,"MailPoet Free",n["MailPoet Free version"]),jc(i,"MailPoet Premium",n["MailPoet Premium version"]),jc(i,"WordPress",n["WordPress version"]),jc(i,"PHP",n["PHP version"]),jc(i,"Database",n["Database version"]),jc(i,"Action Scheduler",_),yc(i,"Environment"),jc(i,"Web server",n["Web server"]),jc(i,"Server OS",n["Server OS"]),jc(i,"Multisite",n["Multisite environment?"]),jc(i,"Current theme",n["Current Theme"]),jc(i,"WordPress language",r["WordPress language"]),jc(i,"WordPress timezone",r["WordPress timezone"]),yc(i,"WordPress & PHP Config"),jc(i,"WP_MEMORY_LIMIT",r.WP_MEMORY_LIMIT),jc(i,"WP_MAX_MEMORY_LIMIT",r.WP_MAX_MEMORY_LIMIT),jc(i,"WP_DEBUG",r.WP_DEBUG),jc(i,"PHP max_execution_time",o["PHP max_execution_time"]),jc(i,"PHP memory_limit",o["PHP memory_limit"]),jc(i,"PHP upload_max_filesize",o["PHP upload_max_filesize"]),jc(i,"PHP post_max_size",o["PHP post_max_size"]),yc(i,`Active Plugins (${k.length})`),function(e,t){const a=(t||[]).filter(Boolean);a.length?a.forEach(t=>{const a=t.versionLatest?` (update to version ${t.versionLatest} is available)`:"";e.push(` - ${t.name}: by ${t.author} - ${t.version}${a}`)}):e.push(` - ${m.U.I18n.t("none")}`)}(i,k),yc(i,"Sending Configuration"),jc(i,"Sending method",n["Sending Method"]),jc(i,"Send all site's emails with",d["Send all site's emails with"]),jc(i,"Sending frequency",n["Sending Frequency"]),jc(i,"Default FROM address",wc(d["Default FROM address"])),jc(i,"Default Reply-To address",wc(d["Default Reply-To address"])),jc(i,"Bounce email address",wc(d["Bounce Email Address"])),yc(i,"Connection to MailPoet Sending Service"),jc(i,"Enabled",Sc(t.mss?.enabled)),jc(i,"Reachable",Sc(t.mss?.isReachable)),jc(i,"Ping response",l["Ping response"]),jc(i,"API key state",l["API key state"]),jc(i,"Premium key state",l["Premium key state"]),yc(i,"Task Scheduler / Cron"),jc(i,"Status",h.status||m.U.I18n.t("unknown")),jc(i,"Task Scheduler method",d["Task Scheduler method"]),jc(i,"Ping URL",t.cron?.url),jc(i,"Accessible",Sc(h.accessible)),jc(i,"Ping response",t.cron?.pingResponse),jc(i,"Last updated",vc(h.updated_at)),jc(i,"Last run started",vc(h.run_started_at)),jc(i,"Last run completed",vc(h.run_completed_at)),jc(i,"Last seen error",g||m.U.I18n.t("none")),yc(i,"Action Scheduler Status"),jc(i,"Storage type",f),jc(i,"Next trigger run",b),jc(i,"Last trigger run",x),jc(i,"Last worker run",v),yc(i,"Sending Queue"),jc(i,"Status",y),jc(i,"Started at",vc(s.started)),jc(i,"Sent emails",s.sent||0),jc(i,"Retry attempt",j),jc(i,"Retry at",w),jc(i,"Error",S),jc(i,"Total completed tasks",N.completed||0),jc(i,"Total running tasks",N.running||0),jc(i,"Total paused tasks",N.paused||0),jc(i,"Total cancelled tasks",N.cancelled||0),jc(i,"Total scheduled tasks",N.scheduled||0),yc(i,"Data Inconsistency"),jc(i,"Orphaned sending tasks",c["Orphaned sending tasks"]),jc(i,"Orphaned sending task subscribers",c["Orphaned sending task subscribers"]),jc(i,"Sending queue without newsletter",c["Sending queue without newsletter"]),jc(i,"Orphaned subscriptions",c["Orphaned subscriptions"]),jc(i,"Orphaned links",c["Orphaned links"]),jc(i,"Orphaned newsletter posts",c["Orphaned newsletter posts"]),i.push(""),i.join("\n")}(t,a,i),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,g.jsx)("p",{children:a.mss.enabled?m.U.I18n.t("systemStatusIntroCronMSS"):m.U.I18n.t("systemStatusIntroCron")})}),(0,g.jsxs)("div",{className:"updated mailpoet-system-status-report inline",children:[(0,g.jsx)("p",{children:m.U.I18n.t("systemStatusGetReportIntro")}),(0,g.jsxs)("p",{className:"submit",children:[(0,g.jsx)("button",{type:"button",className:"button button-primary",onClick:()=>n(!0),children:m.U.I18n.t("systemStatusGetReportTitle")}),(0,g.jsx)("a",{className:"button button-secondary",href:"https://kb.mailpoet.com/article/understanding-the-mailpoet-system-status-page",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("systemStatusUnderstandingReport")})]}),s?(0,g.jsxs)("div",{className:"mailpoet-debug-report",children:[(0,g.jsx)("textarea",{readOnly:!0,id:e,value:d}),(0,g.jsxs)("p",{className:"submit",children:[(0,g.jsx)("button",{type:"button",className:"button button-primary",onClick:()=>function(e){const t=`mailpoet-system-status-${(new Date).toISOString().slice(0,10)}.txt`,a=new Blob([e],{type:"text/plain;charset=utf-8"}),i=window.URL.createObjectURL(a),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(i)}(d),children:m.U.I18n.t("systemStatusDownloadReport")}),(0,g.jsx)("button",{type:"button",className:"button",onClick:async()=>{try{await(0,Fo.l)(e,e=>{e?(l(m.U.I18n.t("copyToClipboardSuccess")),window.setTimeout(()=>{l(m.U.I18n.t("systemStatusCopyForSupport"))},3e3)):l(m.U.I18n.t("copyToClipboardFailure"))},!0)}catch{l(m.U.I18n.t("copyToClipboardFailure"))}},children:o})]})]}):null]}),Cc(a),Ic(a),(0,g.jsx)(dc,{status_data:a.cronStatus}),(0,g.jsx)(fc,{...i}),i?(0,g.jsx)(_c,{statusData:a.queueStatus}):null,(0,g.jsx)(bc,{})]})}function Ec(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent1")}),(0,g.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent2")}),(0,g.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent3")}),(0,g.jsx)(Le.$,{target:"_blank",rel:"noreferrer noopener",href:"https://www.mailpoet.com/privacy-notice/",children:m.U.I18n.t("yourPrivacyButton")})]})}lc.propTypes={truthy:rt().string,falsy:rt().string,unknown:rt().string,children:rt().bool},dc.propTypes={status_data:rt().shape({accessible:rt().bool,last_error_date:rt().string,status:rt().string,updated_at:rt().number,run_accessed_at:rt().number,run_completed_at:rt().number,run_started_at:rt().number,last_error:rt().oneOfType([rt().string,rt().array])}).isRequired};var Ac=a(4379);function Tc(){return(0,g.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,g.jsx)(d.V,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsx)(Ac.z,{heading:(0,p.__)("Help","mailpoet")}),(0,g.jsx)(b.D,{}),(0,g.jsxs)(_r.k,{activeKey:"knowledgeBase",children:[(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabKnowledgeBaseTitle"),children:(0,g.jsx)(ac,{})},"knowledgeBase"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemStatusTitle"),children:(0,g.jsx)(Uc,{})},"systemStatus"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemInfoTitle"),children:(0,g.jsx)(rc,{})},"systemInfo"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabYourPrivacyTitle"),children:(0,g.jsx)(Ec,{})},"yourPrivacy")]})]})}const Rc=document.getElementById("help_container");Rc&&((0,o.registerTranslations)(),(0,n.H)(Rc).render((0,g.jsx)(Tc,{})));var Pc=a(77129);function Dc({children:e}){const t=(0,ke.zy)();return(0,r.useEffect)(()=>{window.scrollTo(0,0)},[t.pathname]),e||null}Dc.propTypes={children:rt().node.isRequired},Dc.displayName="ScrollToTopComponent";const Oc=(0,Pc.fk)(Dc);var Fc=a(60695);function Mc({onMethodChange:e,activeMethod:t}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("span",{className:"mailpoet_import_heading",children:m.U.I18n.t("methodSelectionHead")}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs-row",children:(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file",target:"_blank",rel:"noopener noreferrer",children:(0,g.jsx)(Fc.v,{dimension:"large",variant:"excellent",isInverted:!0,children:m.U.I18n.t("seeVideo")})})})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(ht.s,{name:"select_method",automationId:"import-paste-method",id:"import-paste-method",checked:"paste-method"===t,value:"paste-method",onCheck:e}),(0,g.jsx)("label",{htmlFor:"import-paste-method",children:m.U.I18n.t("methodPaste")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(ht.s,{name:"select_method",automationId:"import-csv-method",id:"import-csv-method",checked:"file-method"===t,value:"file-method",onCheck:e}),(0,g.jsx)("label",{htmlFor:"import-csv-method",children:m.U.I18n.t("methodUpload")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(ht.s,{name:"select_method",automationId:"import-mailchimp-method",id:"import-mailchimp-method",checked:"mailchimp-method"===t,value:"mailchimp-method",onCheck:e}),(0,g.jsx)("label",{htmlFor:"import-mailchimp-method",children:m.U.I18n.t("methodMailChimp")})]})]})]})}function Lc({hidePrevious:e=!1,isLastStep:t=!1,canGoNext:a=!0,onPreviousAction:i=()=>{},onNextAction:s=()=>{}}){return(0,g.jsxs)("div",{className:"mailpoet-settings-save",children:[!e&&(0,g.jsx)(Le.$,{type:"button",variant:"secondary",onClick:i,children:m.U.I18n.t("previousStep")}),(0,g.jsx)(Le.$,{type:"button",automationId:"import-next-step",isDisabled:!a,onClick:()=>{a&&s()},children:m.U.I18n.t(t?"import":"nextStep")})]})}function $c({canFinish:e,onValueChange:t,data:a="",onFinish:i=()=>{},onPrevious:s=()=>{}}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"paste_input",children:m.U.I18n.t("pasteLabel")}),(0,g.jsx)("p",{className:"description",children:at()(m.U.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsx)(dt.T,{id:"paste_input",rows:"15",placeholder:"Email, First Name, Last Name\njohn@doe.com, John, Doe\nmary@smith.com, Mary, Smith\njohnny@walker.com, Johnny, Walker",isCode:!0,onChange:e=>{t(e.target.value)},defaultValue:a})}),(0,g.jsx)(Lc,{canGoNext:e,onPreviousAction:s,onNextAction:i})]})}function Wc({onValueChange:e,canFinish:t,onFinish:a=()=>{},onPrevious:i=()=>{}}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"file_local",children:m.U.I18n.t("methodUpload")}),(0,g.jsx)("p",{className:"description",children:at()(m.U.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsx)(ot.p,{type:"file",id:"file_local",accept:".csv","data-automation-id":"import-file-upload-input",onChange:t=>{const a=t.target.value.match(/[^.]+$/);m.U.Notice.hide(),null===a||"csv"!==a[0].toLowerCase()?(m.U.Notice.error(m.U.I18n.t("wrongFileFormat")),e("")):e(t.target.files[0])}})}),(0,g.jsx)(Lc,{canGoNext:t,onPreviousAction:i,onNextAction:a})]})}function Bc({onFinish:e=()=>{},onPrevious:t=()=>{}}){const[a,i]=(0,r.useState)(""),[s,n]=(0,r.useState)(void 0),[o,l]=(0,r.useState)([]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:(0,g.jsxs)("label",{htmlFor:"mailpoet_mailchimp_key_input",children:[(0,g.jsx)("span",{className:"mailpoet_import_heading",children:m.U.I18n.t("methodMailChimpLabel")}),(0,g.jsx)("p",{className:"description",children:at()(m.U.I18n.t("methodMailChimpDescription"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/255-migrating-from-mailchimp-to-mailpoet#api",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})]})}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,g.jsx)(ot.p,{dimension:"small",id:"mailpoet_mailchimp_key_input",type:"text",onChange:e=>{i(e.target.value),""===e.target.value.trim()&&n(void 0)}}),(0,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)(Le.$,{type:"button",dimension:"small",onClick:()=>{m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpLists",data:{api_key:a}}).always(()=>{m.U.Modal.loading(!1)}).done(e=>n(e.data)).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},children:m.U.I18n.t("methodMailChimpVerify")}),(0,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)("span",{children:Array.isArray(s)&&0===s.length?m.U.I18n.t("noMailChimpLists"):null})]})}),s?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("methodMailChimpSelectList")}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsx)(De.L,{field:{id:"segments",name:"list-selection",multiple:!0,placeholder:m.U.I18n.t("methodMailChimpSelectPlaceholder"),forceSelect2:!0,values:s},onValueChange:e=>l(e.target.value)})})]}):null,(0,g.jsx)(Lc,{canGoNext:Array.isArray(o)&&o.length>0,onPreviousAction:t,onNextAction:()=>{m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpSubscribers",data:{api_key:a,lists:o}}).always(()=>{m.U.Modal.loading(!1)}).done(t=>e(t.data)).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}})]})}Mc.propTypes={activeMethod:rt().string,onMethodChange:rt().func.isRequired},Mc.displayName="SelectImportMethod",Lc.propTypes={canGoNext:rt().bool,hidePrevious:rt().bool,isLastStep:rt().bool,onPreviousAction:rt().func,onNextAction:rt().func},Lc.displayName="PreviousNextStepButtons",$c.propTypes={onFinish:rt().func,onPrevious:rt().func,canFinish:rt().bool.isRequired,onValueChange:rt().func.isRequired,data:rt().string},$c.displayName="MethodPaste",Wc.propTypes={canFinish:rt().bool.isRequired,onFinish:rt().func,onPrevious:rt().func,onValueChange:rt().func.isRequired},Wc.displayName="MethodUpload",Bc.propTypes={onFinish:rt().func,onPrevious:rt().func},Bc.displayName="MethodMailChimp";var qc=a(87714),Hc=a.n(qc);const zc=e=>{if("string"!=typeof e)return!1;const t=e.toLowerCase();return window.roleBasedEmails.findIndex(e=>t.startsWith(`${e}@`))>=0},Vc=e=>{let t,a=mt.default.unescape(e);return a=a.toLowerCase().replace(/^["';.,\s]+|[^\x20-\x7E]+$|["';.,_\s]+$/g,"").replace(/\s+|%\d+|,+/g,""),t=/<(.*?)>/.exec(a),t&&(a=t[1].trim()),t=/mailto:(?:\s+)?(.*)/.exec(a),t&&(a=t[1].trim()),!!window.mailpoet_email_regex.test(a)&&a};function Yc({setStepMethodSelectionData:e,subscribersLimitForValidation:t}){const a=(0,ke.Zp)(),[i,s]=(0,r.useState)(void 0),[n,l]=(0,r.useState)(""),[d,c]=(0,r.useState)(void 0),u=s=>{e(s),a(((e,t,a)=>void 0===e||void 0===e.subscribersCount||e.subscribersCount{a("/step_clean_list")},h=()=>{(e=>{const t=encodeURI(e).split(/%..|./).length-1;m.U.Notice.hide(),t>window.maxPostSizeBytes?m.U.Notice.error(m.U.I18n.t("maxPostSizeNotice")):(m.U.Modal.loading(!0),Hc().parse(e,function(e){return{skipEmptyLines:!0,error(){m.U.Notice.hide(),m.U.Notice.error(m.U.I18n.t("dataProcessingError"))},complete(t){const a=function(e){let t=[];const a=[],i=[],s=[],n=[];let r,o,l,d,c=0,m=0,u=0,p=null,h=null,g=!1;return Object.keys(e).forEach(_=>{if(l=e[_].map(e=>e.trim()),d=l.length,null===h&&(h=d),d===h)if(null===p){let e=null;if(Object.keys(l).forEach(i=>{o=Vc(l[i]),null===p&&window.mailpoet_email_regex.test(o)&&(zc(o)?null===e&&(e=i):(p=i,a[o]=!0,l[i]=o,t[o]=l))}),null===p&&null!==e){p=e;const t=Vc(l[e]);a[t]=!0,n.push(l[e]),u+=1}null===p&&0===parseInt(_,10)&&(g=!0,t[0]=l)}else""!==l[p]&&(r=Vc(l[p]),mt.default.has(a,r)?(i.push(r),c+=1):zc(r)?(a[r]=!0,n.push(l[p]),u+=1):window.mailpoet_email_regex.test(r)?(a[r]=!0,l[p]=r,t[r]=l):(s.push(l[p]),m+=1))}),t=mt.default.values(t),t&&(g&&t.length>=2||!g&&t.length>=1)?{header:window.mailpoet_email_regex.test(t[0][p])?null:t.shift(),subscribers:t,subscribersCount:t.length,duplicate:mt.default.uniq(i),invalid:mt.default.uniq(s),role:mt.default.uniq(n),duplicateRowsCount:c,invalidRowsCount:m,roleRowsCount:u}:null}(t.data);if(a)e(a);else{let e=m.U.I18n.t("noValidRecords");e=e.replace("[link]",''),e=e.replace("[/link]",""),m.U.Notice.error(e)}m.U.Modal.loading(!1)}}}(e=>{m.U.trackEvent("Subscribers import started",{source:"file-method"===i?"file upload":"pasted data"}),u(e)})))})("paste-method"===i?n:d)};return(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Mc,{activeMethod:i,onMethodChange:s})}),"paste-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)($c,{onPrevious:p,onValueChange:l,onFinish:h,canFinish:!!n.trim(),data:n})}),"file-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Wc,{onPrevious:p,onValueChange:c,onFinish:h,canFinish:!!d,data:d})}),"mailchimp-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Bc,{onPrevious:p,onFinish:e=>{m.U.trackEvent("Subscribers import started",{source:"MailChimp"}),u(e)}})}),void 0===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Lc,{canGoNext:!1,onPreviousAction:p})})]})}function Gc({onProceed:e,iHaveCleanedList:t}){return(0,g.jsxs)("div",{className:"mailpoet-clean-list-step-container",children:[(0,g.jsx)("p",{children:m.U.I18n.t("cleanListText1")}),(0,g.jsx)("p",{children:m.U.I18n.t("cleanListText2")}),(0,g.jsxs)("p",{children:[e&&(0,g.jsx)(Le.$,{onClick:e,variant:"tertiary",children:m.U.I18n.t("listCleaningGotIt")}),(0,g.jsx)(Le.$,{target:"_blank",href:"https://kb.mailpoet.com/article/287-list-cleaning-services",children:m.U.I18n.t("tryListCleaning")}),t&&(0,g.jsx)(Le.$,{onClick:t,variant:"secondary",children:m.U.I18n.t("cleanedList")})]})]})}function Kc({onSubmit:e}){const t=(0,ke.Zp)(),[a,i]=(0,r.useState)(void 0);return(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("validationStepHeading")}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(ht.s,{automationId:"mailpoet_import_validation_step_option1",id:"existing-list",checked:"existing-list"===a,value:"existing-list",onCheck:i}),(0,g.jsx)("label",{htmlFor:"existing-list",children:m.U.I18n.t("validationStepRadio1")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(ht.s,{automationId:"mailpoet_import_validation_step_option2",id:"address-book",checked:"address-book"===a,value:"address-book",onCheck:i}),(0,g.jsx)("label",{htmlFor:"address-book",children:m.U.I18n.t("validationStepRadio2")})]})]}),(0,g.jsx)(Lc,{canGoNext:void 0!==a,onPreviousAction:()=>t("/step_method_selection"),onNextAction:()=>e(a)})]})}function Qc(){return(0,g.jsxs)("div",{className:"mailpoet-clean-list-step-container","data-automation-id":"import_wrong_source_block",children:[(0,g.jsx)("p",{children:m.U.I18n.t("validationStepBlock1")}),(0,g.jsx)("p",{children:m.U.I18n.t("validationStepBlock2")}),(0,g.jsx)("p",{children:(0,g.jsx)(Le.$,{href:"https://kb.mailpoet.com/article/269-reconfirm-subscribers-to-your-list",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("validationStepBlockButton")})})]})}function Jc({onSubmit:e}){const[t,a]=(0,r.useState)("over2years"),i=(0,r.useCallback)(e=>{a(e.target.value)},[a]),s=(0,r.useCallback)(()=>{e("over2years"===t||"1to2years"===t?"notRecently":"recently")},[e,t]);return(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("validationStepLastSentHeading")}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(ut.Select,{defaultValue:t,onChange:i,automationId:"last_sent_to_list",children:[(0,g.jsx)("option",{value:"over2years",children:m.U.I18n.t("validationStepLastSentOption1")}),(0,g.jsx)("option",{value:"1to2years",children:m.U.I18n.t("validationStepLastSentOption2")}),(0,g.jsx)("option",{value:"less1year",children:m.U.I18n.t("validationStepLastSentOption3")}),(0,g.jsx)("option",{value:"less3months",children:m.U.I18n.t("validationStepLastSentOption4")})]})}),(0,g.jsx)("div",{className:"mailpoet-settings-save",children:(0,g.jsx)(Le.$,{type:"button",automationId:"last_sent_to_list_next",onClick:s,children:m.U.I18n.t("validationStepLastSentNext")})})]})}function Zc({stepMethodSelectionData:e}){const t=(0,ke.Zp)(),[a,i]=(0,r.useState)(void 0),[s,n]=(0,r.useState)(void 0);(0,r.useEffect)(()=>{void 0===e&&t("/step_method_selection",{replace:!0})},[e,t]);const l=(0,r.useCallback)(e=>{n(e),"recently"===e&&t("/step_data_manipulation")},[t,n]);return(0,g.jsxs)(g.Fragment,{children:[void 0===a&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Kc,{onSubmit:i})}),"address-book"===a&&(0,g.jsx)(Qc,{}),"existing-list"===a&&void 0===s&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Jc,{onSubmit:l})}),"existing-list"===a&&"notRecently"===s&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Gc,{iHaveCleanedList:()=>l("recently")})})]})}function Xc({translation:e,subscribers:t}){let a="";return t.length&&(a=at()(e.replace("%2$s",t.join(", ")),"%1$s",()=>(0,g.jsx)("strong",{children:t.length.toLocaleString()},e)),a=(0,g.jsx)("p",{children:a})),a}function em({stepMethodSelectionData:e={invalid:[],duplicate:[],role:[]}}){const{invalid:t,duplicate:a,role:i}=e,[s,n]=(0,r.useState)(!1),o=Z()("mailpoet_subscribers_data_parse_results_details",{mailpoet_hidden:!s}),l=(0,g.jsx)(Xc,{translation:m.U.I18n.t("importNoticeInvalid"),subscribers:t}),d=(0,g.jsx)(Xc,{translation:m.U.I18n.t("importNoticeDuplicate"),subscribers:a});let c="";if(i.length&&(c=at()(m.U.I18n.t("importNoticeRoleBased"),/(%1\$s|\[link\].*\[\/link\]|%2\$s)/,e=>"%1$s"===e?(0,g.jsx)("strong",{children:i.length.toLocaleString()},"role-length"):"%2$s"===e?i.join(", "):(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/270-sending-to-role-based-email-addresses-is-not-allowed",target:"_blank",rel:"noopener noreferrer",children:e.replace("[link]","").replace("[/link]","")},e)),c=(0,g.jsx)("p",{children:c})),t.length||a.length||i.length){const e=t.length+a.length+i.length;return(0,g.jsxs)("div",{className:"error",children:[(0,g.jsxs)("p",{children:[at()(m.U.I18n.t("importNoticeSkipped"),"%1$s",()=>(0,g.jsx)("strong",{children:e.toLocaleString()},"lengths"))," ",(0,g.jsx)("a",{className:"mailpoet_subscribers_data_parse_results_details_show","data-automation-id":"show-more-details",onClick:()=>n(!s),role:"button",tabIndex:0,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),n(!s))},children:m.U.I18n.t("showMoreDetails")})]}),(0,g.jsxs)("div",{className:o,children:[(0,g.jsx)("hr",{}),l,d,c]})]})}return null}Yc.propTypes={setStepMethodSelectionData:rt().func.isRequired,subscribersLimitForValidation:rt().number.isRequired},Yc.diplayName="StepMethodSelection",Gc.displayName="CleanList",Kc.propTypes={onSubmit:rt().func.isRequired},Kc.displayName="InitialQuestion",Jc.propTypes={onSubmit:rt().func.isRequired},Jc.displayName="LastSentQuestion",Zc.displayName="StepInputValidation",Xc.propTypes={translation:rt().string.isRequired,subscribers:rt().arrayOf(rt().string).isRequired},em.propTypes={stepMethodSelectionData:rt().shape({duplicate:rt().arrayOf(rt().string),invalid:rt().arrayOf(rt().string),role:rt().arrayOf(rt().string)})};function tm({header:e=[],subscribers:t}){const a=((e,t)=>{const a=[],i=[];let s,n,r,o;return Object.keys(e[0]).forEach(l=>{s=e[0][l],n="ignore",s%1!=0&&window.mailpoet_email_regex.test(s)?n="email":t&&(r=t[l],o=window.mailpoetColumns.map(e=>e.name).indexOf(r),-1!==o?n=window.mailpoetColumns[o].id:r&&(/first|first name|given name/i.test(r)?n="first_name":/last|last name/i.test(r)&&(n="last_name"))),n="ignore"!==n&&-1===i.indexOf(n)?n:"ignore",a[l]={column_id:n},i.push(n)}),a})(t,e);return(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:m.U.I18n.t("matchData")}),a.map((e,t)=>(0,g.jsx)("th",{children:(0,g.jsx)("select",{className:"mailpoet_subscribers_column_data_match","data-column-id":e.column_id,"data-column-index":t,id:`column_${t}`})},t))]})}function am({header:e}){return(0,g.jsxs)("tr",{className:"mailpoet_header",children:[(0,g.jsx)("td",{}),e.map(e=>(0,g.jsx)("td",{children:e},e))]})}function im({subscriber:e,index:t}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("td",{children:t}),e.map((e,a)=>(0,g.jsx)("td",{children:e},`${e}-${t}-${a}`))]})}function sm({subscribers:e,subscribersCount:t}){const a=". . .",i=Array(e[0].length).fill(a);return(0,g.jsxs)(g.Fragment,{children:[e.slice(0,10).map((e,t)=>(0,g.jsx)("tr",{children:(0,g.jsx)(im,{subscriber:e,index:t+1})},`${e[0]}-${t}`)),t>11?(0,g.jsx)("tr",{children:(0,g.jsx)(im,{subscriber:i,index:a})},"filler"):null,t>10?(0,g.jsx)("tr",{children:(0,g.jsx)(im,{subscriber:e[t-1],index:t})},e[t-1][0]):null]})}function nm({subscribersCount:e=0,subscribers:t=[],header:a=[],onCreateCustomField:i}){return(0,r.useLayoutEffect)(()=>{(e=>{const t={data:window.mailpoetColumnsSelect2,width:"15em"};Ie()("select.mailpoet_subscribers_column_data_match").select2(t).on("select2:selecting",t=>{const a=t.currentTarget,i=t.params.args.data.id;"create"===i?(t.preventDefault(),Ie()(a).select2("close"),e(a)):Ie()("select.mailpoet_subscribers_column_data_match").each((e,s)=>{if(s===a)return;const n=Ie()(s).val();n===i&&"ignore"!==n&&(confirm(`${m.U.I18n.t("selectedValueAlreadyMatched")} ${m.U.I18n.t("confirmCorrespondingColumn")}`)?Ie()(s).data("column-id","ignore"):(t.preventDefault(),Ie()(a).select2("close")))})}).on("select2:select",e=>{const t=e.currentTarget,a=e.params.data.id;Ie()(t).data("column-id",a)}).on("select2:open",()=>{const e=document.querySelectorAll(".select2-search__field[aria-controls]");0!==e.length&&e[e.length-1].focus()}),Ie().map(Ie()(".mailpoet_subscribers_column_data_match"),e=>{const t=Ie()(e).data("column-id");Ie()(e).val(t).trigger("change")})})(i)},[i]),(0,g.jsx)("div",{className:"subscribers_data",children:(0,g.jsxs)("table",{className:"mailpoet_subscribers widefat fixed",children:[(0,g.jsx)("thead",{children:(0,g.jsx)(tm,{header:a,subscribers:t})}),(0,g.jsxs)("tbody",{children:[a?(0,g.jsx)(am,{header:a}):null,(0,g.jsx)(sm,{subscribers:t,subscribersCount:e})]})]})})}function rm({setSelectedSegments:e}){const{segments:t}=(0,r.useContext)(l.F),{all:a,updateAll:i}=t,[s,n]=(0,r.useState)(a);(0,r.useLayoutEffect)(()=>{!function(t){const a=Ie()("select#mailpoet_segments_select");if(a.data("select2"))return;const i=e=>{let t=`${e.name}`;return e.count&&(t+=`${e.count}`),t};a.html(""),a.select2({data:t.map(e=>({...e,text:e.name})),dropdownCssClass:"mailpoet-form-select2-dropdown",escapeMarkup:e=>e,templateResult:i,templateSelection:i}).on("change",t=>{const i=Ie()('[data-id="notice_segmentSelection"]');t.currentTarget.value?Ie()('[data-id="notice_segmentSelection"]').remove():i.length||m.U.Notice.error(m.U.I18n.t("segmentSelectionRequired"),{static:!0,scroll:!0,id:"notice_segmentSelection",hideClose:!0});(t=>{e(t)})(mt.default.pluck(a.select2("data"),"id"))})}(s)},[s,e]);const o=t=>{!function(){const e=Ie()("select#mailpoet_segments_select");e.data("select2")&&(e.select2("destroy"),e.find("option").remove(),e.off("select2:unselecting").off("change").off("select2:opening"))}(),e([]),n([...s,t]),i([...s,t])};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:(0,g.jsxs)("label",{htmlFor:"mailpoet_segments_select",children:[m.U.I18n.t("pickLists"),(0,g.jsx)("p",{className:"description",children:m.U.I18n.t("pickListsDescription")})]})}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,g.jsx)("div",{className:"mailpoet-form-select mailpoet-form-input",children:(0,g.jsx)("select",{id:"mailpoet_segments_select","data-placeholder":m.U.I18n.t("select"),multiple:"multiple",children:(0,g.jsx)("option",{})})}),(0,g.jsx)(Le.$,{variant:"tertiary",onClick:()=>{return e=o,m.U.Modal.popup({title:m.U.I18n.t("addNewList"),template:Ie()("#new_segment_template").html()}),Ie()("#new_segment_name").on("keypress",e=>{13===e.which&&Ie()("#new_segment_process").trigger("click")}),Ie()("#new_segment_process").on("click",()=>{const t=Ie()("#new_segment_name").val()?.toString().trim()||"",a=Ie()("#new_segment_description").val()?.toString().trim()||"";m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"addSegment",data:{name:t,description:a}}).done(t=>{e({id:t.data.id,name:t.data.name,text:t.data.name,subscriberCount:0}),m.U.Modal.close()}).fail(e=>{e.errors.length>0&&(m.U.Notice.hide(),m.U.Notice.showApiErrorNotice(e,{positionAfter:"#new_segment_error_message"}))}).catch(()=>{})}),void Ie()("#new_segment_cancel").on("click",()=>{m.U.Modal.close()});var e},children:m.U.I18n.t("createANewList")})]})})]})}function om(){return(0,g.jsx)("p",{className:"description",children:at()(m.U.I18n.t("consentSubscribed"),/\[link](.*?)\[\/link]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/357-why-express-consent-is-important",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})}function lm({newSubscribersStatus:e,setNewSubscribersStatus:t}){const a=(0,r.useCallback)(e=>{t(e.target.value)},[t]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"new_subscribers_status",children:m.U.I18n.t("newSubscribersStatus")}),(0,g.jsx)(om,{})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(ut.Select,{id:"new_subscribers_status",placeholder:m.U.I18n.t("select"),name:"new_subscribers_status",onChange:a,defaultValue:e,children:[(0,g.jsx)("option",{value:"subscribed",children:m.U.I18n.t("subscribed")}),(0,g.jsx)("option",{value:"inactive",children:m.U.I18n.t("inactive")}),(0,g.jsx)("option",{value:"unsubscribed",children:m.U.I18n.t("unsubscribed")})]})})]})}function dm({existingSubscribersStatus:e,setExistingSubscribersStatus:t}){const a=(0,r.useCallback)(e=>{t(e.target.value)},[t]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"existing_subscribers_status",children:m.U.I18n.t("existingSubscribersStatus")}),(0,g.jsx)(om,{})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(ut.Select,{id:"existing_subscribers_status",placeholder:m.U.I18n.t("select"),name:"existing_subscribers_status",onChange:a,defaultValue:e,children:[(0,g.jsx)("option",{value:"dont_update",children:m.U.I18n.t("dontUpdate")}),(0,g.jsx)("option",{value:"subscribed",children:m.U.I18n.t("subscribed")}),(0,g.jsx)("option",{value:"inactive",children:m.U.I18n.t("inactive")}),(0,g.jsx)("option",{value:"unsubscribed",children:m.U.I18n.t("unsubscribed")})]})})]})}function cm({updateExistingSubscribers:e,setUpdateExistingSubscribers:t}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("updateExistingSubscribers")}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,g.jsx)(ht.s,{id:"update_existing_subscribers",name:"update_existing_subscribers",value:"1",checked:e,onCheck:()=>t(!0)}),(0,g.jsx)("label",{htmlFor:"update_existing_subscribers",children:m.U.I18n.t("updateExistingSubscribersYes")}),(0,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)(ht.s,{id:"dont_update_existing_subscribers",name:"update_existing_subscribers",value:"",checked:!e,onCheck:()=>t(!1)}),(0,g.jsx)("label",{htmlFor:"dont_update_existing_subscribers",children:m.U.I18n.t("updateExistingSubscribersNo")})]})]})}tm.propTypes={subscribers:rt().arrayOf(rt().arrayOf(rt().oneOfType([rt().string,rt().number]))).isRequired,header:rt().arrayOf(rt().string)},am.propTypes={header:rt().arrayOf(rt().string).isRequired},im.propTypes={subscriber:rt().arrayOf(rt().oneOfType([rt().string,rt().number])).isRequired,index:rt().node.isRequired},sm.propTypes={subscribersCount:rt().number.isRequired,subscribers:rt().arrayOf(rt().arrayOf(rt().oneOfType([rt().string,rt().number]))).isRequired},nm.propTypes={subscribersCount:rt().number,subscribers:rt().arrayOf(rt().arrayOf(rt().oneOfType([rt().string,rt().number]))),header:rt().arrayOf(rt().string),onCreateCustomField:rt().func.isRequired},rm.propTypes={setSelectedSegments:rt().func.isRequired},cm.propTypes={setUpdateExistingSubscribers:rt().func.isRequired,updateExistingSubscribers:rt().bool.isRequired},a(36202);function mm({selectedTags:e,setSelectedTags:t}){const a=(0,r.useCallback)(({value:e})=>{t(e)},[t]),i=m.U.tags.map(e=>e.name);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[m.U.I18n.t("assignTagsLabel"),(0,g.jsx)("p",{className:"description",children:m.U.I18n.t("assignTagsDescription")})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs mailpoet-import-tags",children:(0,g.jsx)(wt.g,{name:"tags",onChange:a,suggestedValues:i,selectedValues:e,placeholder:m.U.I18n.t("addNewTag")})})]})}var um=a(13911),pm=a(12146),hm=a(2373);function gm({dateSettings:e,onClose:t,onSuccess:a}){const[i,s]=(0,r.useState)(()=>(0,hm.uS)(e)),[n,o]=(0,r.useState)(!1),[l,d]=(0,r.useState)(null);return(0,g.jsx)(Ue.A,{title:m.U.I18n.t("addNewField"),onRequestClose:t,className:"mailpoet-custom-fields-form-modal",focusOnMount:!0,children:(0,g.jsxs)("form",{onSubmit:async function(e){e.preventDefault();const t=(0,hm._J)(i);if(t)d(t);else{o(!0),d(null);try{a(await(0,pm.AA)((0,hm.WD)(i)))}catch(e){d(function(e){return e?.message||m.U.I18n.t("customFieldCreateError")||(0,p.__)("Custom field could not be created","mailpoet")}(e))}finally{o(!1)}}},"data-automation-id":"create_custom_field_form",children:[(0,g.jsx)(hm.bV,{data:i,dateSettings:e,disabled:n,onChange:s}),l&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(um.A,{marginTop:4}),(0,g.jsx)("div",{className:"mailpoet-custom-fields-form-error",role:"alert",children:l})]}),(0,g.jsx)(um.A,{marginTop:6}),(0,g.jsxs)(Dt.A,{justify:"flex-end",gap:3,children:[(0,g.jsx)(Ot.A,{children:(0,g.jsx)(ce.Ay,{variant:"tertiary",onClick:t,disabled:n,__next40pxDefaultSize:!0,children:(0,p.__)("Cancel","mailpoet")})}),(0,g.jsx)(Ot.A,{children:(0,g.jsx)(ce.Ay,{variant:"primary",type:"submit",isBusy:n,disabled:n,__next40pxDefaultSize:!0,children:(0,p.__)("Create custom field","mailpoet")})})]})]})})}function _m({subscribersLimitForValidation:e,setStepDataManipulationData:t,stepMethodSelectionData:a}){const i=(0,ke.Zp)(),[s,n]=(0,r.useState)([]),[o,l]=(0,r.useState)(!0),[d,c]=(0,r.useState)("subscribed"),[u,p]=(0,r.useState)("dontUpdate"),[h,_]=(0,r.useState)([]),[f,b]=(0,r.useState)(null),x=(0,r.useMemo)(()=>({dateTypes:window.mailpoet_import_custom_fields_date_types??[],dateFormats:window.mailpoet_import_custom_fields_date_formats??{}}),[]),v=(0,r.useCallback)(e=>{b(e)},[]);(0,r.useEffect)(()=>{void 0===a&&i("/step_method_selection",{replace:!0})},[a,i]);const y=(0,r.useMemo)(()=>({duplicate:a?.duplicateRowsCount??a?.duplicate?.length??0,invalid:a?.invalidRowsCount??a?.invalid?.length??0,role:a?.roleRowsCount??a?.role?.length??0}),[a]);return void 0===a?null:(0,g.jsxs)("div",{"data-automation-id":"import_data_manipulation_step",children:[(0,g.jsx)(em,{stepMethodSelectionData:a}),(0,g.jsx)(nm,{subscribersCount:a.subscribersCount,subscribers:a.subscribers,header:a.header,onCreateCustomField:v}),(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)(rm,{setSelectedSegments:n}),(0,g.jsx)(lm,{newSubscribersStatus:d,setNewSubscribersStatus:c}),(0,g.jsx)(dm,{existingSubscribersStatus:u,setExistingSubscribersStatus:p}),(0,g.jsx)(cm,{setUpdateExistingSubscribers:l,updateExistingSubscribers:o}),(0,g.jsx)(mm,{selectedTags:h,setSelectedTags:_}),(0,g.jsx)(Lc,{canGoNext:s.length>0,onPreviousAction:()=>i(function(e,t){return void 0===e||void 0===e.subscribersCount||e.subscribersCount{((e,t,a,i,s,n,r)=>{const o={},l=new(Ie().AsyncQueue);let d=0;const c=Date.now()/1e3,u={created:0,updated:0,errors:[],segments:[],tags:[]};m.U.Modal.progress(!0);const p=e.reduce((e,t,a)=>(a%2e3==0&&e.push([]),e[e.length-1].push(t),e),[]);mt.default.each(Ie()("select.mailpoet_subscribers_column_data_match"),(e,t)=>{const a=Ie()(e).data("column-id");"ignore"!==a&&(o[a]={index:t})}),mt.default.each(p,()=>{l.add(r=>{r.pause(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"processImport",data:JSON.stringify({columns:o,subscribers:p[d],timestamp:c,segments:t,newSubscribersStatus:a,existingSubscribersStatus:i,updateSubscribers:s,tags:n})}).done(t=>{const a=t.data.added_to_segment_with_welcome_notification;var i,s;u.created+=t.data.created,u.updated+=t.data.updated,u.segments=t.data.segments,u.added_to_segment_with_welcome_notification=a,m.U.Modal.setProgress((i=u,s=e,Math.floor((i.created+i.updated)/s.length*100))),r.run()}).fail(e=>{m.U.Modal.progress(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}),d+=1})}),l.run(),l.onComplete(()=>{m.U.Modal.progress(!1),u.errors.length>0&&!u.updated&&!u.created?m.U.Notice.error(mt.default.flatten(u.errors)):(u.segments=mt.default.map(mt.default.filter(u.segments,e=>t.includes(e.id)),e=>e.name),r(u))})})(a.subscribers,s,d,u,o,h,e=>{t({...e,skipped_duplicate:y.duplicate,skipped_invalid:y.invalid,skipped_role:y.role}),i("/step_results")})},isLastStep:!0})]}),f&&(0,g.jsx)(gm,{dateSettings:x,onClose:()=>b(null),onSuccess:e=>{f&&(((e,t)=>{const a=(e=>({id:e.id,name:e.name,text:e.name,type:e.type,params:e.params,custom:!0}))(t);(()=>{let e=window.mailpoetColumnsSelect2.find(e=>e.name===m.U.I18n.t("userColumns"));if(!e){const t=m.U.I18n.t("userColumns");e={name:t,text:t,children:[]},window.mailpoetColumnsSelect2.push(e)}return e})().children.push(a),window.mailpoetColumns.push(a);const i=`${a.id}`,s={data:window.mailpoetColumnsSelect2,width:"15em"};Ie()("select.mailpoet_subscribers_column_data_match").each((t,n)=>{const r=Ie()(n);if(n===e)return r.find(`option[value="${i}"]`).remove(),r.append(new Option(a.text,i,!0,!0)),r.data("column-id",a.id),r.attr("data-column-id",a.id),r.val(i).trigger("change"),r.trigger({type:"select2:select",params:{data:{...a,id:i}}}),void r.next(".select2-container").find(".select2-selection__rendered").text(a.text).attr("title",a.text);const o=r.data("column-id");r.html("").select2("destroy").select2(s),r.data("column-id",o),r.attr("data-column-id",o),r.val(`${o}`).trigger("change")})})(f,e),b(null))}})]})}function fm({subscribersCount:e=0,segments:t=[],initialMessage:a=""}){if(e){let i=at()(a,"%1$s",()=>(0,g.jsx)("strong",{children:e.toLocaleString()},"%1$s"));return i=at()(i,"%2$s",()=>`"${t.join('", "')}"`),(0,g.jsx)("p",{children:i})}return null}function bm({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?null:(0,g.jsx)("p",{children:m.U.I18n.t("importNoAction")})}function xm({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:(0,g.jsx)("b",{children:m.U.I18n.t("congratulationResult")})}),(0,g.jsx)("p",{children:at()(m.U.I18n.t("suppressionListReminder"),/\[link](.*?)\[\/link]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/359-how-to-import-a-suppression-list",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})]}):null}function vm({addedToSegmentWithWelcomeNotification:e=!1}){return e?(0,g.jsx)("p",{children:m.U.I18n.t("importNoWelcomeEmail")}):null}function ym({errors:e=[],createdSubscribers:t,updatedSubscribers:a,skippedDuplicateSubscribers:i,skippedInvalidSubscribers:s,skippedRoleSubscribers:n,segments:l,addedToSegmentWithWelcomeNotification:d}){const c=(0,ke.Zp)();return(0,r.useEffect)(()=>{void 0===l&&0===e.length&&void 0===t&&void 0===i&&void 0===s&&void 0===n&&void 0===a&&c("/step_method_selection",{replace:!0})},[l,t,e.length,c,i,s,n,a]),e.length&&m.U.Notice.error(mt.default.flatten(e)),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsxs)("div",{className:"updated",children:[(0,g.jsx)(fm,{subscribersCount:t,segments:l,initialMessage:m.U.I18n.t("subscribersCreated")}),(0,g.jsx)(fm,{subscribersCount:a,segments:l,initialMessage:m.U.I18n.t("subscribersUpdated")}),(0,g.jsx)(fm,{subscribersCount:s,initialMessage:m.U.I18n.t("importSkippedInvalid")}),(0,g.jsx)(fm,{subscribersCount:i,initialMessage:m.U.I18n.t("importSkippedDuplicate")}),(0,g.jsx)(fm,{subscribersCount:n,initialMessage:m.U.I18n.t("importSkippedRoleBased")}),(0,g.jsx)(bm,{createdSubscribers:t,updatedSubscribers:a}),(0,g.jsx)(vm,{addedToSegmentWithWelcomeNotification:d})]})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(xm,{createdSubscribers:t,updatedSubscribers:a})}),(0,g.jsx)("div",{className:"mailpoet-settings-grid",children:(0,g.jsxs)("div",{className:"mailpoet-settings-save",children:[(0,g.jsx)(Le.$,{variant:"secondary",type:"button",onClick:()=>{window.location.href=`${window.location.pathname}${window.location.search}#/step_method_selection`},children:m.U.I18n.t("importAgain")}),(0,g.jsx)(Le.$,{type:"button",onClick:()=>{window.location.href="admin.php?page=mailpoet-subscribers"},children:m.U.I18n.t("viewSubscribers")})]})})]})}function jm(){const e=(0,ke.Zp)();return(0,g.jsx)(Gc,{onProceed:()=>e("/step_method_selection")})}_m.propTypes={stepMethodSelectionData:rt().shape({duplicate:rt().arrayOf(rt().string),duplicateRowsCount:rt().number,header:rt().arrayOf(rt().string),invalid:rt().arrayOf(rt().string),invalidRowsCount:rt().number,role:rt().arrayOf(rt().string),roleRowsCount:rt().number,subscribersCount:rt().number,subscribers:rt().arrayOf(rt().arrayOf(rt().oneOfType([rt().string,rt().number])))}),subscribersLimitForValidation:rt().number.isRequired,setStepDataManipulationData:rt().func.isRequired},fm.propTypes={segments:rt().arrayOf(rt().string.isRequired),subscribersCount:rt().number,initialMessage:rt().string},fm.displayName="ResultMessage",bm.propTypes={createdSubscribers:rt().number,updatedSubscribers:rt().number},bm.displayName="NoAction",xm.propTypes={createdSubscribers:rt().number,updatedSubscribers:rt().number},xm.displayName="SuppressionListReminder",vm.propTypes={addedToSegmentWithWelcomeNotification:rt().bool},vm.diplayName="NoWelcomeEmail",ym.propTypes={errors:rt().arrayOf(rt().string.isRequired),segments:rt().arrayOf(rt().string.isRequired),createdSubscribers:rt().number,updatedSubscribers:rt().number,skippedDuplicateSubscribers:rt().number,skippedInvalidSubscribers:rt().number,skippedRoleSubscribers:rt().number,addedToSegmentWithWelcomeNotification:rt().bool},ym.displayName="StepResults",jm.displayName="StepCleanList";const wm=document.getElementById("import_container");function Sm(){const[e,t]=(0,r.useState)(void 0),[a,i]=(0,r.useState)({}),s=(0,l.f)(window);return(0,g.jsx)(l.F.Provider,{value:s,children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(u.q,{}),(0,g.jsx)(Oc,{children:(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:"/step_clean_list",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(jm,{})})}),(0,g.jsx)(ke.qh,{path:"/step_method_selection",element:(0,g.jsx)(Yc,{setStepMethodSelectionData:t,subscribersLimitForValidation:100})}),(0,g.jsx)(ke.qh,{path:"/step_input_validation",element:(0,g.jsx)(Zc,{stepMethodSelectionData:e})}),(0,g.jsx)(ke.qh,{path:"/step_data_manipulation",element:(0,g.jsx)(_m,{stepMethodSelectionData:e,subscribersLimitForValidation:100,setStepDataManipulationData:i})}),(0,g.jsx)(ke.qh,{path:"/step_results",element:(0,g.jsx)(ym,{errors:a.errors,createdSubscribers:a.created,updatedSubscribers:a.updated,skippedDuplicateSubscribers:a.skipped_duplicate,skippedInvalidSubscribers:a.skipped_invalid,skippedRoleSubscribers:a.skipped_role,segments:a.segments,addedToSegmentWithWelcomeNotification:a.added_to_segment_with_welcome_notification})}),(0,g.jsx)(ke.qh,{path:"*",element:(0,g.jsx)(ke.C5,{to:"/step_clean_list"})})]})})]})})}wm&&((0,o.registerTranslations)(),(0,n.H)(wm).render((0,g.jsx)(Sm,{})));var Nm=a(75370),km=a.n(Nm);Ie()(document).ready(()=>{let e;if(!Ie()("#mailpoet_subscribers_export").length)return;if(!window.exportData.segments)return;const t=km().compile(Ie()("#mailpoet_subscribers_export_template").html());function a(t){const a="mailpoet-disabled";"on"===t?e.removeClass(a):e.addClass(a)}Ie()("#mailpoet-export").html(t(window.exportData));const i=Ie()("#export_lists"),s=Ie()("#export_columns");function n(e){let t=`${e.name}`;return void 0!==e.count&&(t+=`${e.count}`),t}function r(e,t){e.data("select2")&&e.html("").select2("destroy"),e.select2({data:t,width:"20em",dropdownCssClass:"mailpoet-form-select2-dropdown",escapeMarkup:e=>e,templateResult:n,templateSelection:n}).on("select2:selecting",t=>{const a=t.params.args.data.id,i=["select","deselect"];let s;mt.default.contains(i,a)&&(t.preventDefault(),"deselect"===a?Ie()(t.target).val("").trigger("change"):(s=[],mt.default.each(e.find("option"),e=>{const t=e.value;mt.default.contains(i,t)||s.push(t)}),Ie()(t.target).val(s).trigger("change")),Ie()(t.target).select2("close"))}).on("change",()=>{window.exportData.segments&&i.select2("data").length&&s.select2("data").length||!window.exportData.segments&&s.select2("data").length?a("on"):a("off")})}e=Ie()("#mailpoet-export-button"),window.segments.forEach(e=>{i.append(Ie()("").attr("value",e.id).text(e.name))}),window.subscriberFieldsSelect2.forEach(e=>{e.text=e.name,e.children.forEach(e=>{e.name=(0,_n.Zn)(e.name),e.text=(0,_n.Zn)(e.name)})}),r(i,window.segments),r(s,window.subscriberFieldsSelect2),s.val(["email","first_name","last_name","list_status","global_status","created_at","confirmed_at"]).trigger("change"),e.on("click",e=>{if(Ie()(e.target).hasClass("mailpoet-disabled"))return;m.U.Modal.loading(!0);const t=Ie()(':radio[name="option_format"]:checked').val();m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"ImportExport",action:"processExport",data:JSON.stringify({export_format_option:t,segments:!!window.exportData.segments&&i.val(),subscriber_fields:s.val()})}).always(()=>{m.U.Modal.loading(!1)}).done(e=>{const a=m.U.I18n.t("exportMessage").replace("%1$s",`${parseInt(e.data.totalExported,10).toLocaleString()}`).replace("[link]",``).replace("[/link]","");Ie()("#export_result_notice").html(`

${a}

`).show(),window.location.href=e.data.exportFileURL,m.U.trackEvent("Subscribers export completed",{"Total exported":e.data.totalExported,"File Format":t})}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})})});var Cm=a(6072),Im=a(9339);function Um({children:e}){return(0,g.jsx)("div",{className:"mailpoet-steps-content",children:e})}const Em=(0,g.jsx)("svg",{width:"13",height:"11",viewBox:"0 0 13 11",children:(0,g.jsx)("path",{fill:"currentColor",d:"M9.967.638c.483-.698 1.405-.846 2.06-.33.654.515.793 1.499.31 2.197l-5.44 7.857c-.55.794-1.64.857-2.267.132l-3.4-3.928c-.552-.638-.515-1.632.083-2.22.598-.59 1.53-.55 2.082.088l2.19 2.532L9.968.638z"})}),Am=(0,g.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",children:(0,g.jsx)("path",{fill:"currentColor",d:"M12.407 3.31c.576.576.576 1.509 0 2.084L9.914 7.888l2.411 2.412c.586.585.586 1.535 0 2.121-.585.586-1.535.586-2.12 0l-2.413-2.412L5.3 12.503c-.576.575-1.509.575-2.084 0-.575-.575-.575-1.508 0-2.083l2.493-2.495-2.41-2.41c-.587-.587-.587-1.536 0-2.122.585-.586 1.535-.586 2.12 0L7.83 5.804l2.494-2.493c.575-.576 1.508-.576 2.083 0z"})});function Tm({onCheck:e,showError:t,checked:a,automationId:i,...s}){return(0,g.jsxs)("div",{className:Z()({"mailpoet-form-yesno":!0,"mailpoet-form-yesno-error":t,"mailpoet-disabled":s.disabled}),"data-automation-id":i,children:[(0,g.jsxs)("label",{children:[(0,g.jsx)("input",{"aria-label":(0,p.__)("Yes","mailpoet"),type:"radio",checked:!0===a,onChange:()=>e(!0),...s}),(0,g.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-yes",children:Em})]}),(0,g.jsxs)("label",{children:[(0,g.jsx)("input",{"aria-label":(0,p.__)("No","mailpoet"),type:"radio",checked:!1===a,onChange:()=>e(!1),...s}),(0,g.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-no",children:Am})]})]})}function Rm({submitForm:e,loading:t,showCustomersImportSetting:a,isWizardStep:i=!1}){const[s,n]=(0,r.useState)(null),[l,d]=(0,r.useState)(!1===a?"unsubscribed":null),[c,m]=(0,r.useState)(!1),u=i?(0,p._x)("Continue","A label on a button","mailpoet"):(0,p._x)("Start using WooCommerce features","Submit button caption on the standalone WooCommerce setup page","mailpoet");let h;return"subscribed"===l&&(h=!0),"unsubscribed"===l&&(h=!1),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.TypographyHeading,{level:1,children:(0,p._x)("Power up your WooCommerce store","Title on the WooCommerce setup page","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:(0,p.__)("MailPoet comes with powerful features for WooCommerce. Select features that you would like to use with your store.","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("form",{onSubmit:t=>(t.preventDefault(),m(!0),null===l||null===s||e(l,s),!1),children:[(0,g.jsxs)("div",{children:[a?(0,g.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:at()((0,p.__)("Do you want to import your WooCommerce customers as subscribed? [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list",rel:"noopener noreferrer",target:"_blank",children:e},e))}),(0,g.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,g.jsx)("span",{children:"GDPR"}),(0,p._x)("To be compliant with privacy regulations, your customers must have explicitly accepted to receive your marketing emails.","GDPR compliance information","mailpoet")]})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(Tm,{showError:c&&null===l,checked:h,onCheck:e=>d(e?"subscribed":"unsubscribed"),name:"mailpoet_woocommerce_import_type",automationId:"woocommerce_import_type"})})]}):null,(0,g.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:at()((0,p.__)("Collect more precise email and site engagement, and e-commerce metrics by enabling cookie tracking. [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/280-woocommerce-cookie-tracking",rel:"noopener noreferrer",target:"_blank",children:e},e))}),(0,g.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,g.jsx)("span",{children:"GDPR"}),(0,p._x)("To be compliant, you should display a cookie tracking banner on your website.","GDPR compliance information","mailpoet")]})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(Tm,{showError:c&&null===s,checked:s,onCheck:e=>n(e),name:"mailpoet_woocommerce_tracking",automationId:"woocommerce_tracking"})})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,disabled:t,automationId:"submit_woocommerce_setup",children:u})]})]})}function Pm(e){return(0,g.jsx)(tn,{illustrationUrl:e.illustrationUrl,children:e.children})}function Dm({isWizardStep:e=!1,redirectToNextStep:t=null}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,Im.iK)("woocommerce"),l=(0,Im.iK)("tracking")[1],d=(0,Im.iK)("woocommerce_import_screen_displayed")[1],c=(0,Im.iK)("mailpoet_subscribe_old_woocommerce_customers")[1],u=e=>{i(!1),m.U.Notice.showApiErrorNotice(e,{scroll:!0})},p=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(u),h=(0,g.jsx)(Pm,{illustrationUrl:window.wizard_woocommerce_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Rm,{loading:a,submitForm:async(a,r)=>{i(!0);const o="basic"===m.U.trackingConfig.level?"basic":"partial",h={level:r?"full":o,opens:"merged"},g={enabled:"subscribed"===a?"1":""},_={woocommerce_import_screen_displayed:1,"mailpoet_subscribe_old_woocommerce_customers.enabled":g.enabled,"tracking.level":h.level,"woocommerce.accept_cookie_revenue_tracking.set":"1","tracking.opens":h.opens};await p(_),l(h),c(g),n({...s,accept_cookie_revenue_tracking:{...s.accept_cookie_revenue_tracking||{},set:"1"}}),d("1"),await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"setupWooCommerceInitialImport"}).fail(u),e?t():await(async()=>{e?await p({version:window.mailpoet_version}).then(()=>{window.location.href=window.finish_wizard_url}):window.location.href=window.finish_wizard_url})()},isWizardStep:e,showCustomersImportSetting:window.mailpoet_show_customers_import})})});return e?h:(0,g.jsx)(Um,{children:h})}function Om({skipStep:e,loading:t,update_sender:a,submit_sender:i,sender:s=null}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(jt.D,{level:1,children:(0,p.__)("Start by configuring your sender information","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("p",{children:[(0,g.jsx)("b",{children:(0,p.__)("Default sender","mailpoet")}),(0,g.jsx)("br",{}),(0,p.__)("Enter details of the person or brand your subscribers expect to receive emails from","mailpoet")]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("form",{id:"mailpoet_sender_form",onSubmit:e=>{e.preventDefault(),Ie()("#mailpoet_sender_form").parsley().validate()&&i()},children:[(0,g.jsxs)(ri.Grid.TwoColumns,{children:[(0,g.jsxs)("label",{htmlFor:"senderName",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:(0,p._x)("From Name","A form field label","mailpoet")}),(0,g.jsx)(o.Input,{isFullWidth:!0,name:"senderName",type:"text",placeholder:"John Doe",value:s?s.name:"","data-parsley-required":!0,onChange:e=>a({name:e.target.value})})]}),(0,g.jsxs)("label",{htmlFor:"senderAddress",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:(0,p._x)("From Address","A form field label","mailpoet")}),(0,g.jsx)(o.Input,{isFullWidth:!0,name:"senderAddress",type:"text",placeholder:"john@doe.com",value:s?s.address:"","data-parsley-required":!0,"data-parsley-type":"email",onChange:e=>a({address:e.target.value})})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,children:(0,p._x)("Continue","A label on a button","mailpoet")}),(0,g.jsx)(o.Button,{href:"#skipStep",isDisabled:t,isFullWidth:!0,onClick:e,variant:"tertiary",children:(0,p._x)("Skip this step","A label on a skip button","mailpoet")})]})]})}Pm.propTypes={illustrationUrl:rt().string.isRequired,children:rt().oneOfType([rt().arrayOf(rt().node),rt().node]).isRequired},Dm.displayName="WooCommerceController",Om.displayName="WelcomeWizardSenderStep";const Fm=e=>null==e;function Mm({loading:e,submitForm:t}){const[a,i]=(0,r.useState)({tracking:void 0,libs3rdParty:void 0}),[s,n]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(jt.D,{level:1,children:(0,p.__)("Confirm privacy and data settings","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("form",{onSubmit:function(e){return e.preventDefault(),n(!0),Fm(a.libs3rdParty)||Fm(a.tracking)||t(a.tracking,a.libs3rdParty),!1},children:[(0,g.jsxs)("div",{children:[(0,g.jsxs)("div",{id:"mailpoet-wizard-3rd-party-libs",className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,p.__)("Enable modern text fonts in emails and show contextual help articles in MailPoet","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-wizard-note",children:at()((0,p.__)("MailPoet may load Google Fonts, WordPress.com and other [link]3rd party libraries[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/338-enabledisable-3rd-party-libraries",target:"_blank",rel:"noopener noreferrer",children:e},t))})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(Tm,{showError:s&&Fm(a.libs3rdParty),onCheck:e=>{const t={libs3rdParty:e};i(e=>({...e,...t}))},checked:a.libs3rdParty,name:"mailpoet_libs_3rdParty"})})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{id:"mailpoet-wizard-tracking",className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,p.__)("Help improve MailPoet","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-wizard-note",children:at()((0,p.__)("Get improved features and fixes faster by sharing with us [link]non-sensitive data about how you use MailPoet[/link]. No personal data is tracked or stored.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/130-sharing-your-data-with-us",target:"_blank",rel:"noopener noreferrer",children:e},t))})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(Tm,{showError:s&&Fm(a.tracking),onCheck:e=>{const t={tracking:e};i(e=>({...e,...t}))},checked:a.tracking,name:"mailpoet_tracking"})})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Le.$,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:e,disabled:e,children:(0,p._x)("Continue","A label on a button","mailpoet")})]})]})}Mm.propTypes={loading:rt().bool.isRequired,submitForm:rt().func.isRequired},Mm.displayName="WelcomeWizardUsageTrackingStep";var Lm=a(69472);async function $m(e){await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}async function Wm(e=null){await $m({version:window.mailpoet_version,installed_after_new_domain_restrictions:1,welcome_wizard_current_step:""}),window.location.href=e||window.finish_wizard_url}function Bm(){const[e,t]=(0,r.useState)(!1),a=e=>{e.preventDefault(),t(!0)},i=()=>t(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:at()(m.U.I18n.t("welcomeWizardMSSAdvancedUsers"),/\[link](.*?)\[\/link]/g,(e,t)=>(0,g.jsx)("a",{onClick:a,href:"#",children:e},t))}),e&&(0,g.jsxs)(Ue.A,{className:"mailpoet-welcome-wizard-confirmation-modal",title:m.U.I18n.t("welcomeWizardMSSConfirmationModalTitle"),onRequestClose:i,children:[(0,g.jsx)("p",{children:m.U.mailFunctionEnabled?m.U.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraph"):m.U.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraphWithoutMailFunction")}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSConfirmationModalSecondParagraph")}),(0,g.jsxs)("div",{className:"mailpoet-welcome-wizard-confirmation-modal-buttons",children:[(0,g.jsx)(o.Button,{variant:"secondary",onClick:i,children:m.U.I18n.t("welcomeWizardMSSConfirmationModalGoBackButton")}),(0,g.jsx)(o.Button,{onClick:async e=>{e.preventDefault(),await Wm("admin.php?page=mailpoet-settings#/mta/other")},children:m.U.I18n.t("welcomeWizardMSSConfirmationModalOkButton")})]})]})]})}const qm=(e,t,a=!1)=>{$m({welcome_wizard_current_step:t}),a?e(t,{replace:!0}):e(t)},Hm="https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase";function zm(){const e=(0,ke.Zp)(),{step:t}=(0,ke.g)(),a=(0,Im.d4)("getKeyActivationState");return(0,r.useEffect)(()=>{!0===a.isKeyValid&&qm(e,`/steps/${t}/part/3`,!0)},[a.isKeyValid,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(jt.D,{level:1,children:m.U.I18n.t("welcomeWizardMSSFirstPartTitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSFirstPartSubtitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-welcome-wizard-mss-list",children:(0,g.jsxs)(o.List,{children:[(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList1")}),(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList2")}),m.U.subscribersCount<500?(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList3Free")}):(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList3Paid")})]})}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,href:Hm,target:"_blank",rel:"noopener noreferrer",onClick:a=>function(e,t,a){e.preventDefault(),window.open(Hm),qm(t,`/steps/${a}/part/2`)}(a,e,t),iconEnd:(0,g.jsx)(Da.A,{icon:Lm.A}),children:m.U.I18n.t("welcomeWizardMSSFirstPartButton")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Bm,{})]})}var Vm=a(87560),Ym=a(14240);function Gm(){const e=(0,ke.Zp)(),{step:t}=(0,ke.g)(),a=(0,Im.d4)("getKeyActivationState");return(0,r.useEffect)(()=>{!0===a.isKeyValid&&qm(e,`/steps/${t}/part/3`,!0)},[a.isKeyValid,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.Heading,{level:1,children:m.U.I18n.t("welcomeWizardMSSSecondPartTitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSSecondPartEnterKey")}),(0,g.jsx)("p",{children:at()(m.U.I18n.t("welcomeWizardMSSSecondPartNoAccount"),/\[link](.*?)\[\/link]/g,(e,t)=>(0,g.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase",children:e},t))}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("label",{htmlFor:"mailpoet_premium_key",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:m.U.I18n.t("welcomeWizardMSSSecondPartInputLabel")}),(0,g.jsx)(Ym.M,{placeholder:m.U.I18n.t("welcomeWizardMSSSecondPartInputPlaceholder"),isFullWidth:!0,forceRevealed:!0})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Vm.y,{label:m.U.I18n.t("welcomeWizardMSSSecondPartButton"),isFullWidth:!0}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Bm,{})]})}function Km(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(jt.D,{level:1,children:m.U.I18n.t("welcomeWizardMSSThirdPartTitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSThirdPartFirstParagraph")}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSThirdPartSecondParagraph")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",type:"button",onClick:()=>Wm(),isFullWidth:!0,children:m.U.I18n.t("welcomeWizardMSSThirdPartButton")})]})}function Qm(){const{pathname:e}=(0,ke.zy)(),{step:t}=(0,ke.g)(),a=(0,ke.Zp)(),i=(0,ke.zy)();return(0,r.useEffect)(()=>{i.pathname.includes("part")||qm(a,`/steps/${t}/part/1`,!0)},[t,e,a,i]),(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:"part/1",element:(0,g.jsx)(zm,{})}),(0,g.jsx)(ke.qh,{path:"part/2",element:(0,g.jsx)(Gm,{})}),(0,g.jsx)(ke.qh,{path:"part/3",element:(0,g.jsx)(Km,{})})]})}const Jm=()=>{const e=["WelcomeWizardSenderStep"];return window.mailpoet_is_dotcom||e.push("WelcomeWizardUsageTrackingStep"),window.mailpoet_woocommerce_active&&e.push("WizardWooCommerceStep"),window.mailpoet_has_valid_api_key||e.push("WelcomeWizardPitchMSSStep"),e},Zm=()=>Jm().length,Xm=async(e,t,a)=>{a{(i>a||i<1)&&qm(t,"/steps/1")},[i,a,t]);const p=(0,mt.partial)(Xm,t,Wm),h=(0,r.useCallback)(async(e,t)=>{const a={enabled:e?"1":""},i={enabled:t?"1":""},s={analytics:a,"3rd_party_libs":i};await $m(s),m(a),u(i)},[m,u]),_=(0,r.useCallback)(async(e,t)=>{n(!0),await h(e,t),p(i),n(!1)},[p,i,h]),f=(0,r.useCallback)(e=>{c({...l,...e})},[l,c]),b=(0,r.useCallback)(async()=>{n(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await h(!0,!0),await $m((({name:e,address:t})=>{const a=t.split("@").pop().toLowerCase();return window.mailpoet_free_domains.indexOf(a)>-1?(({name:e,address:t})=>{const a=`wordpress@${window.location.hostname.replace("www.","")}`;return{sender:{name:e,address:a},reply_to:{name:e,address:t},"signup_confirmation.from.address":a,"signup_confirmation.from.name":e,"signup_confirmation.reply_to.address":t,"signup_confirmation.reply_to.name":e}})({name:e,address:t}):(({name:e,address:t})=>({sender:{name:e,address:t},reply_to:{name:e,address:t},"signup_confirmation.from.address":t,"signup_confirmation.from.name":e,"signup_confirmation.reply_to.address":t,"signup_confirmation.reply_to.name":e}))({name:e,address:t})})(l)).then(()=>p(i)),n(!1)},[p,l,i,h]),x=(0,r.useCallback)(async e=>{e.preventDefault(),n(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await h(!0,!0),p(i),n(!1)},[p,i,h]),v=(y=i,Jm()[y-1]||null);var y;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.V,{hideScreenOptions:!0,logoWithLink:!1,children:(0,g.jsx)(eu.g,{count:a,current:i,doneCallback:e=>{qm(t,`/steps/${e}`)}})}),(0,g.jsxs)(Um,{children:["WelcomeWizardSenderStep"===v?(0,g.jsx)(Pm,{illustrationUrl:window.wizard_sender_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Om,{update_sender:f,submit_sender:b,skipStep:x,loading:s,sender:l})})}):null,"WelcomeWizardUsageTrackingStep"===v?(0,g.jsx)(Pm,{illustrationUrl:window.wizard_tracking_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Mm,{loading:s,submitForm:_})})}):null,"WelcomeWizardPitchMSSStep"===v?(0,g.jsx)(Pm,{illustrationUrl:window.wizard_MSS_pitch_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Qm,{})})}):null,"WizardWooCommerceStep"===v?(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Dm,{isWizardStep:!0,redirectToNextStep:()=>p(i)})}):null]})]})}tu.displayName="WelcomeWizardStepsController";const au=(0,o.withBoundary)(tu),iu=(0,o.withBoundary)(Dm);function su(){let e="/steps/1";const t=window.mailpoet_welcome_wizard_current_step;"string"==typeof t&&t.startsWith("/steps")&&(e=t),window.location.search.includes("woocommerce-setup")&&(e="/woocommerce");const a=(0,l.f)(window);return(0,g.jsx)(l.F.Provider,{value:a,children:(0,g.jsxs)(Ne.HashRouter,{children:[(0,g.jsx)(u.q,{}),(0,g.jsxs)(ke.BV,{children:[(0,g.jsx)(ke.qh,{path:"/steps/:step/*",element:(0,g.jsx)(au,{})}),(0,g.jsx)(ke.qh,{path:"/woocommerce",element:(0,g.jsx)(iu,{})}),(0,g.jsx)(ke.qh,{path:"*",element:(0,g.jsx)(ke.C5,{to:e})})]})]})})}const nu=document.getElementById("mailpoet-wizard-container");function ru(){const[e,t]=(0,r.useState)(null),a=(0,l.f)(window),i=a.notices.error;function s(s){const n=s.target.name,r=s.target.checked;m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"set",data:{[n]:r?1:0}}).done(()=>{const i=e[n];i.value=r,t({...e,[n]:i});const s=`Feature '${n}' was ${r?"enabled":"disabled"}.`;a.notices.success((0,g.jsx)("p",{children:s}))}).fail(e=>{e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e):i(e.errors.map(e=>(0,g.jsx)("p",{children:e.message},e.message)),{scroll:!0}))})}return(0,r.useEffect)(()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"getAll"}).done(e=>{const a=e.data.reduce((e,t)=>({...e,[t.name]:t}),{});t(a)}).fail(e=>{e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e):i((0,g.jsx)(g.Fragment,{children:e.errors.map(e=>(0,g.jsx)("p",{children:e.message}))}),{scroll:!0}))})},[i]),null===e?(0,g.jsx)("p",{children:"Loading experimental features..."}):0===Object.values(e).length?(0,g.jsx)("p",{children:"There are no experimental features at the moment."}):(0,g.jsx)(l.F.Provider,{value:a,children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.q,{}),Object.values(e).map(e=>{const t=`experimental-feature-${e.name}`;return(0,g.jsx)("div",{children:(0,g.jsxs)("label",{htmlFor:t,children:[(0,g.jsx)("input",{id:t,type:"checkbox",name:e.name,defaultChecked:e.value,onChange:s})," ",e.name]})},e.name)})]})})}nu&&((0,o.registerTranslations)(),(0,Cm.k)(),(0,n.H)(nu).render((0,g.jsx)(su,{})));const ou=document.getElementById("experimental_features_container");ru.displayName="ExperimentalFeatures",ou&&((0,o.registerTranslations)(),(0,n.H)(ou).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ru,{})})));var lu=a(31415);function du({log:e}){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{role:"gridcell",className:"mailpoet-logs-min-width",children:e.name}),(0,g.jsx)("td",{role:"gridcell",children:(0,g.jsx)("div",{className:"mailpoet-logs-message "+(t?"mailpoet-logs-message-full":""),children:e.message})}),(0,g.jsx)("td",{role:"gridcell",className:"mailpoet-logs-min-width",children:(0,g.jsx)(o.Button,{dimension:"small",variant:"secondary",onClick:()=>{a(!t)},children:t?(0,p.__)("Show less","mailpoet"):(0,p.__)("Show more","mailpoet")})}),(0,g.jsx)("td",{className:"mailpoet-logs-min-width",role:"gridcell",children:m.U.Date.full(e.created_at)})]},`log-row-${e.id}`)}function cu({logs:e,onFilter:t,originalFrom:a,originalTo:i,originalSearch:s,originalOffset:n,originalLimit:l}){const[d,c]=(0,r.useState)(a??void 0),[u,h]=(0,r.useState)(i??void 0),[_,f]=(0,r.useState)(n??""),[b,x]=(0,r.useState)(l??""),[v,y]=(0,r.useState)(s||""),j=(0,ai.curry)((e,t)=>{e(null!==t?m.U.Date.format(t,{format:"Y-m-d"}):void 0)}),w=(0,r.useCallback)(()=>{const e={};d&&(e.from=d),u&&(e.to=u),_&&""!==_.trim()&&(e.offset=_),b&&""!==b.trim()&&(e.limit=b),v&&""!==v.trim()&&(e.search=v.trim()),t(e)},[d,b,_,v,u,t]);return(0,g.jsxs)("div",{className:"mailpoet-listing mailpoet-logs",children:[(0,g.jsxs)("div",{className:"mailpoet-listing-header",children:[(0,g.jsxs)("div",{className:"mailpoet-listing-search",children:[(0,g.jsx)("label",{htmlFor:"search_input",className:"screen-reader-text",children:(0,p.__)("Search","mailpoet")}),(0,g.jsx)(o.Input,{dimension:"small",iconStart:lu.I,type:"search",id:"search_input",name:"s",onChange:e=>y(e.target.value),value:v,placeholder:(0,p.__)("Search","mailpoet")})]}),(0,g.jsxs)("div",{className:"mailpoet-listing-filters",children:[`${(0,p.__)("From","mailpoet")}:`,(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(fi.t,{formatWithWordPressSettings:!0,onChange:j(c),maxDate:new Date,selected:d?qo(d):void 0,dimension:"small"}),`${(0,p.__)("To","mailpoet")}:`,(0,g.jsx)(fi.t,{formatWithWordPressSettings:!0,onChange:j(h),maxDate:new Date,selected:u?qo(u):void 0,dimension:"small"})]})]}),(0,g.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,g.jsx)("label",{htmlFor:"offset_input",className:"screen-reader-text",children:(0,p.__)("Offset","mailpoet")}),(0,g.jsx)(o.Input,{dimension:"small",id:"offset_input",name:"o",type:"number",onChange:e=>f(e.target.value),value:_,placeholder:(0,p.__)("Offset","mailpoet")})]}),(0,g.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,g.jsx)("label",{htmlFor:"limit_input",className:"screen-reader-text",children:(0,p.__)("Limit","mailpoet")}),(0,g.jsx)(o.Input,{dimension:"small",id:"limit_input",name:"l",type:"number",onChange:e=>x(e.target.value),value:b,placeholder:(0,p.__)("Limit","mailpoet")})]}),(0,g.jsx)(o.Button,{dimension:"small",onClick:w,children:(0,p._x)("Filter","verb","mailpoet")})]}),(0,g.jsxs)("table",{className:"mailpoet-listing-table widefat striped",role:"grid",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,p.__)("Name","mailpoet")}),(0,g.jsx)("th",{children:(0,p.__)("Message","mailpoet")}),(0,g.jsx)("th",{children:(0,p.__)("Action","mailpoet")}),(0,g.jsx)("th",{children:(0,p.__)("Created On","mailpoet")})]})}),(0,g.jsx)("tbody",{children:(0,g.jsx)(o.ErrorBoundary,{children:e.map(e=>(0,g.jsx)(du,{log:e},`log-${e.id}`))})})]})]})}du.displayName="Log",cu.displayName="LogsList";const mu=document.getElementById("mailpoet_logs_container");if(mu){const e=new URL(window.location.href);(0,n.H)(mu).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(cu,{logs:window.mailpoet_logs,originalFrom:e.searchParams.get("from")||window.mailpoet_logs_default_from,originalTo:e.searchParams.get("to"),originalSearch:e.searchParams.get("search"),originalOffset:e.searchParams.get("offset"),originalLimit:e.searchParams.get("limit"),onFilter:t=>{e.searchParams.delete("from"),e.searchParams.delete("to"),e.searchParams.delete("search"),e.searchParams.delete("offset"),e.searchParams.delete("limit"),Object.entries(t).forEach(([t,a])=>{e.searchParams.append(t,a)}),window.location.href=e.href}})}))}var uu=a(66162);function pu({onRequestClose:e=ai.noop}){const[t,a]=(0,r.useState)(!1);return Ie()(e=>{e(document).on("click",".notice .mailpoet-js-button-fix-this",()=>{a(!0)})}),(0,g.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,g.jsx)(u.q,{}),t&&(0,g.jsx)(uu.U,{onRequestClose:()=>{a(!1),e()}})]})}const hu=document.getElementById("mailpoet_set_from_address_modal");hu&&(0,n.H)(hu).render((0,g.jsx)(pu,{onRequestClose:()=>{window.location.href.includes("?page=mailpoet-settings")&&window.location.reload()}}));const gu=e=>(async e=>{if("MailPoet"!==m.U.mtaMethod)return!0;if(window.mailpoet_sender_restrictions?.skipAuthorization)return!0;const t=await(async()=>"MailPoet"!==m.U.mtaMethod?[]:(await m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[])(),a=(0,ki.Y8)(e);return-1!==t.indexOf(a)||-1!==(await(async()=>"MailPoet"!==m.U.mtaMethod?[]:(await m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"mailer",action:"getAuthorizedEmailAddresses"})).data||[])()).indexOf(e)})(e).then(e=>{if(!e)return m.U.Notice.error((0,p.__)("Failed to resume sending because the email address is unauthorized. Please authorize it and try again.","mailpoet"),{scroll:!0}),m.U.trackEvent("Unauthorized email used",{"Unauthorized email source":"send"}),!1;m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"mailer",action:"resumeSending"}).done(()=>{m.U.Notice.success((0,p.__)("Sending has been resumed.","mailpoet"))}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})});Ie()(e=>{e(document).on("click",".notice .mailpoet-js-button-resume-sending",e=>{gu(e.target.value)})});var _u=a(11234);const fu=e=>{const t=window.location.href.includes("?page=mailpoet-settings"),a=window.location.href.includes("?page=mailpoet-newsletters#/send");(e=>{const t=`${(0,ki.no)()||"some other"} page`;e&&e.type&&"email"===e.type?m.U.trackEvent("MSS in plugin authorize email",{"authorized email source":"modal","original page":t,wasSuccessful:"yes"}):e&&e.type&&"domain"===e.type&&m.U.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"modal","original page":t,wasSuccessful:"yes"})})(e),(t||a)&&window.location.reload()};function bu(){const[e,t]=(0,r.useState)(""),[a,i]=(0,r.useState)("email");return(0,r.useEffect)(()=>{const e=e=>{e.preventDefault();const a=String(e?.target?.dataset?.email||""),s=String(e?.target?.dataset?.type||"");i(s||"email"),t(a)};Ie()(t=>{t(document).on("click",".mailpoet-js-button-authorize-email-and-sender-domain",e)})},[]),(0,g.jsx)(g.Fragment,{children:e&&(0,g.jsx)(_u.J,{senderEmail:e,onRequestClose:()=>{t("")},onSuccessAction:fu,showSenderEmailTab:"email"===a,showSenderDomainTab:"domain"===a,initialTab:"domain"===a?"sender_domain":"sender_email"})})}const xu=document.getElementById("mailpoet_authorize_sender_email_modal");function vu({color:e}){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:`body { background: ${e}; }`}})}xu&&(0,n.H)(xu).render((0,g.jsx)(bu,{}));const yu=()=>{window.location.href=window.mailpoet_welcome_wizard_url};function ju(){const e=window.mailpoet_welcome_wizard_current_step,t="string"==typeof e&&e.startsWith("/steps");return(0,g.jsx)(o.Button,{onClick:yu,dimension:"hero",children:t?(0,p.__)("Continue setup","mailpoet"):(0,p.__)("Begin setup","mailpoet")})}function wu(){return(0,g.jsx)("section",{className:"landing-header",children:(0,g.jsxs)("div",{className:"mailpoet-content-center",children:[(0,g.jsx)(jt.D,{level:0,children:(0,p.__)("Better email — without leaving WordPress","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Whether you’re just starting out or have already established your business, we’ve got the tools you need to reach customers where they are.","mailpoet")}),(0,g.jsx)(ju,{})]})})}function Su(){return(0,g.jsx)("section",{className:"landing-footer",children:(0,g.jsxs)("div",{className:"landing-footer-content mailpoet-content-center",children:[(0,g.jsxs)(jt.D,{level:4,children:[" ",(0,p.__)("Ready to start using MailPoet?","mailpoet")," "]}),(0,g.jsx)(ju,{})]})})}function Nu(){const e=[{slug:"item-1",title:(0,p.__)("What types of campaigns can I create with MailPoet?","mailpoet"),text:(0,p.__)("MailPoet allows you to create five different types of campaigns: Newsletter, Welcome Email, Latest Post Notifications, Re-engagement Emails, and WooCommerce behavior-based emails.","mailpoet"),readMoreText:(0,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns"},{slug:"item-2",title:(0,p.__)("How do I send a newsletter?","mailpoet"),text:(0,p.__)("You can manually create a standard newsletter to be sent immediately or scheduled to be sent at a later time. Simply go to MailPoet > Emails and click on the “+ New Email” button to select “Newsletter”.","mailpoet"),readMoreText:(0,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/344-create-a-standard-newsletter"},{slug:"item-3",title:(0,p.__)("Do I need a paid plan?","mailpoet"),text:(0,p.__)("When you install the MailPoet plugin, you can use it for free up to 1,000 subscribers. If you have more than 1,000 subscribers, or want access to MailPoet’s advanced features, you'll need one of our paid plans: Creator, Business, or Agency. The best choice of plan type will depend on whether you want to send with our MailPoet Sending Service or your own sending method, as well as the number of sites you will be using MailPoet on.","mailpoet"),readMoreText:(0,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/349-mailpoet-plans-and-limits-explained"},{slug:"item-4",title:(0,p.__)("How do I import my customers from WooCommerce?","mailpoet"),text:(0,p.__)('The WooCommerce Customers list is a list automatically created by MailPoet with all of your WooCommerce customers. It also includes “Guest" customers. If WooCommerce is active, users that installed or updated the plugin should have chosen if they wanted to add the customers as “Subscribed” or “Unsubscribed” to the WooCommerce Customers list.',"mailpoet"),readMoreText:(0,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list"},{slug:"item-5",title:(0,p.__)("How do I customize emails for my store?","mailpoet"),text:(0,p.__)("You can create and send the following four WooCommerce Automatic emails with MailPoet: Abandoned Shopping Cart, First Purchase, Purchased In This Category, Purchased This Product. You can read more about each in our article.","mailpoet"),readMoreText:(0,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/277-woocommerce-automatic-emails"}];return(0,g.jsxs)("section",{className:"landing-faq",children:[(0,g.jsxs)("div",{className:"mailpoet-content-center landing-faq-header",children:[(0,g.jsxs)(jt.D,{level:2,children:[" ",(0,p.__)("Frequently asked questions","mailpoet")," "]}),(0,g.jsx)("p",{children:at()((0,p.__)("Here are some common questions on getting started. Can't find what you're looking for? [link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e))})]}),(0,g.jsx)("div",{className:"mailpoet-content-center landing-faq-mobile",children:(0,g.jsx)(jt.D,{level:2,children:(0,p.__)("FAQ","mailpoet")})}),(0,g.jsx)("div",{className:"mailpoet-faq-accordion",children:e.map(e=>(0,g.jsxs)("details",{children:[(0,g.jsxs)("summary",{children:[" ",(0,g.jsxs)("strong",{children:[" ",e.title," "]})," "]}),(0,g.jsxs)("div",{className:"content",children:[(0,g.jsx)("p",{children:e.text}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:e.readMoreLink,rel:"noopener noreferrer",target:"_blank",children:e.readMoreText})})]})]},e.slug))}),(0,g.jsxs)("div",{className:"mailpoet-content-center landing-faq-mobile",children:[(0,g.jsx)("p",{children:(0,p.__)("Can’t find what you’re looking for?","mailpoet")}),(0,g.jsx)("p",{children:at()((0,p.__)("[link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e))})]})]})}wu.displayName="Landingpage Header",Su.displayName="Landingpage Footer",Nu.displayName="Landingpage FAQ";const ku={heroImage:`${m.U.cdnUrl}landingpage/landingpage-hero-image.png`,featureImages:{icon_1:`${m.U.cdnUrl}landingpage/feature_icon_1.png`,icon_2:`${m.U.cdnUrl}landingpage/feature_icon_2.png`,icon_3:`${m.U.cdnUrl}landingpage/feature_icon_3.png`,icon_4:`${m.U.cdnUrl}landingpage/feature_icon_4.png`},wooCommerceFeatureImages:{feature_1:`${m.U.cdnUrl}landingpage/woo_feature_automate_your_marketing.20241219.png`,feature_2:`${m.U.cdnUrl}landingpage/woo_feature_measure_revenue_per_email.png`,feature_3:`${m.U.cdnUrl}landingpage/woo_feature_let_your_brand_shine.png`,feature_4:`${m.U.cdnUrl}landingpage/woo_feature_rescue_abandoned_carts.png`}};function Cu(){return(0,g.jsxs)("section",{className:"landing-content",children:[(0,g.jsxs)("div",{className:"hero-section mailpoet-content-center",children:[(0,g.jsx)("img",{src:ku.heroImage,alt:"",className:"hero-image landingpage-images"}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)(jt.D,{level:4,children:(0,p.sprintf)((0,p.__)("Powerful email marketing, trusted by %s websites","mailpoet"),"600,000+")}),(0,g.jsx)("br",{}),(0,g.jsxs)(ri.Grid.FourColumns,{className:"landingpage-general-features",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:ku.featureImages.icon_1,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Deliver beautiful emails","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Choose from our pre-built templates or create your own with our drag-and-drop email builder.","mailpoet")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:ku.featureImages.icon_2,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Grow your mailing list","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Use our custom sign-up forms to reach more subscribers while you deliver engaging content.","mailpoet")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:ku.featureImages.icon_3,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Reach the right people","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("From the first hello to repeated purchases, send emails to the right people at the right time.","mailpoet")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:ku.featureImages.icon_4,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Save time with automations","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Set up smart triggers based on user behavior to automate list management, email sending, and more.","mailpoet")})]})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{className:"landingpage-wooCommerce-features",children:[(0,g.jsxs)("div",{className:"mailpoet-content-center",children:[(0,g.jsx)(jt.D,{level:2,children:(0,p.__)("MailPoet + WooCommerce","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Deliver hyper-relevant content at every stage of your customer’s journey","mailpoet")})]}),(0,g.jsx)("br",{}),(0,g.jsxs)(ri.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:ku.wooCommerceFeatureImages.feature_1,alt:(0,p.__)("Automate customer communication feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Automate customer communication","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Drive sales and build loyalty through automated marketing messages that respond to your customer’s purchase data.","mailpoet")})]})]}),(0,g.jsxs)(ri.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:ku.wooCommerceFeatureImages.feature_2,alt:(0,p.__)("Measure revenue per email feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Measure revenue per email","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("See how much revenue your campaign is bringing and make improvements based on auto-generated email statistics.","mailpoet")})]})]}),(0,g.jsxs)(ri.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:ku.wooCommerceFeatureImages.feature_3,alt:(0,p.__)("Let your brand shine feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Let your brand shine","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Use our inbuilt WooCommerce email customizer to design your store's transactional emails and build customer confidence.","mailpoet")})]})]}),(0,g.jsxs)(ri.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:ku.wooCommerceFeatureImages.feature_4,alt:(0,p.__)("Rescue abandoned carts feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Rescue abandoned carts","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Set up automated abandoned cart emails to win customers back and recover lost revenue.","mailpoet")})]})]})]})]})}function Iu(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)("main",{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(vu,{color:"#fff"}),(0,g.jsx)(wu,{}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Cu,{}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Nu,{}),(0,g.jsx)(Su,{})]})})}Cu.displayName="Landingpage Content",Iu.displayName="Landingpage";const Uu=document.getElementById("mailpoet_landingpage_container");Uu&&((0,o.registerTranslations)(),(0,n.H)(Uu).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Iu,{})}))),a(13435)},13435(){document.addEventListener("DOMContentLoaded",function(){window.mailpoet_track_wizard_loaded_via_woocommerce&&(window.MailPoet.trackEvent("User opened the MailPoet setup task in WooCommerce > Home",{"WooCommerce version":window.mailpoet_woocommerce_version}),window.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"delete",data:"send_event_that_wizard_was_loaded_via_woocommerce"})),window.mailpoet_track_wizard_loaded_via_woocommerce_marketing_dashboard&&(window.MailPoet.trackEvent("User clicked on complete MailPoet setup in WooCommerce > Multichannel Marketing dashboard",{"WooCommerce version":window.mailpoet_woocommerce_version}),window.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"delete",data:"wizard_loaded_via_woocommerce_marketing_dashboard"}))})},87714(e,t){var a,i;a=function e(){"use strict";var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},a=!t.document&&!!t.postMessage,i=t.IS_PAPA_WORKER||!1,s={},n=0,r={parse:function(a,i){var o=(i=i||{}).dynamicTyping||!1;if(y(o)&&(i.dynamicTypingFunction=o,o={}),i.dynamicTyping=o,i.transform=!!y(i.transform)&&i.transform,i.worker&&r.WORKERS_SUPPORTED){var l=function(){if(!r.WORKERS_SUPPORTED)return!1;var a,i,o=(a=t.URL||t.webkitURL||null,i=e.toString(),r.BLOB_URL||(r.BLOB_URL=a.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",i,")();"],{type:"text/javascript"})))),l=new t.Worker(o);return l.onmessage=_,l.id=n++,s[l.id]=l}();return l.userStep=i.step,l.userChunk=i.chunk,l.userComplete=i.complete,l.userError=i.error,i.step=y(i.step),i.chunk=y(i.chunk),i.complete=y(i.complete),i.error=y(i.error),delete i.worker,void l.postMessage({input:a,config:i,workerId:l.id})}var p=null;return r.NODE_STREAM_INPUT,"string"==typeof a?(a=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}(a),p=i.download?new d(i):new m(i)):!0===a.readable&&y(a.read)&&y(a.on)?p=new u(i):(t.File&&a instanceof File||a instanceof Object)&&(p=new c(i)),p.stream(a)},unparse:function(e,t){var a=!1,i=!0,s=",",n="\r\n",o='"',l=o+o,d=!1,c=null,m=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||r.BAD_DELIMITERS.filter(function(e){return-1!==t.delimiter.indexOf(e)}).length||(s=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(a=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(d=t.skipEmptyLines),"string"==typeof t.newline&&(n=t.newline),"string"==typeof t.quoteChar&&(o=t.quoteChar),"boolean"==typeof t.header&&(i=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+o),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(m=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var u=new RegExp(h(o),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return p(null,e,d);if("object"==typeof e[0])return p(c||Object.keys(e[0]),e,d)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),p(e.fields||[],e.data||[],d);throw new Error("Unable to serialize unrecognized input");function p(e,t,a){var r="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var o=Array.isArray(e)&&0=this._config.preview;if(i)t.postMessage({results:o,workerId:r.WORKER_ID,finished:d});else if(y(this._config.chunk)&&!a){if(this._config.chunk(o,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);o=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(o.data),this._completeResults.errors=this._completeResults.errors.concat(o.errors),this._completeResults.meta=o.meta),this._completed||!d||!y(this._config.complete)||o&&o.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),d||o&&o.meta.paused||this._nextChunk(),o}this._halted=!0},this._sendError=function(e){y(this._config.error)?this._config.error(e):i&&this._config.error&&t.postMessage({workerId:r.WORKER_ID,error:e,finished:!1})}}function d(e){var t;(e=e||{}).chunkSize||(e.chunkSize=r.RemoteChunkSize),l.call(this,e),this._nextChunk=a?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),a||(t.onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!a),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var i in e)t.setRequestHeader(i,e[i])}if(this._config.chunkSize){var s=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+s)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}a&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var a=t.statusText||e;this._sendError(new Error(a))}}function c(e){var t,a;(e=e||{}).chunkSize||(e.chunkSize=r.LocalChunkSize),l.call(this,e);var i="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,a=e.slice||e.webkitSlice||e.mozSlice,i?((t=new FileReader).onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function m(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,a=this._config.chunkSize;return a?(e=t.substring(0,a),t=t.substring(a)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function u(e){l.call(this,e=e||{});var t=[],a=!0,i=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){i&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):a=!0},this._streamData=v(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),a&&(a=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=v(function(e){this._streamCleanUp(),this._sendError(e)},this),this._streamEnd=v(function(){this._streamCleanUp(),i=!0,this._streamData("")},this),this._streamCleanUp=v(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function p(e){var t,a,i,s=Math.pow(2,53),n=-s,o=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,d=this,c=0,m=0,u=!1,p=!1,_=[],f={data:[],errors:[],meta:{}};if(y(e.step)){var b=e.step;e.step=function(t){if(f=t,w())j();else{if(j(),0===f.data.length)return;c+=t.data.length,e.preview&&c>e.preview?a.abort():(f.data=f.data[0],b(f,d))}}}function v(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function j(){return f&&i&&(N("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+r.DefaultDelimiter+"'"),i=!1),e.skipEmptyLines&&(f.data=f.data.filter(function(e){return!v(e)})),w()&&function(){if(f)if(Array.isArray(f.data[0])){for(var t=0;w()&&t=_.length?"__parsed_extra":_[i]),e.transform&&(r=e.transform(r,n)),r=S(n,r),"__parsed_extra"===n?(s[n]=s[n]||[],s[n].push(r)):s[n]=r}return e.header&&(i>_.length?N("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+i,m+a):i<_.length&&N("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+i,m+a)),s}var a=1;return!f.data.length||Array.isArray(f.data[0])?(f.data=f.data.map(t),a=f.data.length):f.data=t(f.data,0),e.header&&f.meta&&(f.meta.fields=_),m+=a,f}()}function w(){return e.header&&0===_.length}function S(t,a){return i=t,e.dynamicTypingFunction&&void 0===e.dynamicTyping[i]&&(e.dynamicTyping[i]=e.dynamicTypingFunction(i)),!0===(e.dynamicTyping[i]||e.dynamicTyping)?"true"===a||"TRUE"===a||"false"!==a&&"FALSE"!==a&&(function(e){if(o.test(e)){var t=parseFloat(e);if(n=i.length/2?"\r\n":"\r"}(s,l)),i=!1,e.delimiter)y(e.delimiter)&&(e.delimiter=e.delimiter(s),f.meta.delimiter=e.delimiter);else{var d=function(t,a,i,s,n){var o,l,d,c;n=n||[",","\t","|",";",r.RECORD_SEP,r.UNIT_SEP];for(var m=0;m=o)return V(!0)}else for(L=c,c++;;){if(-1===(L=r.indexOf(t,L+1)))return p||j.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),H();if(L===g-1)return H(r.substring(c,L).replace(M,t));if(t!==d||r[L+1]!==d){if(t===d||0===L||r[L-1]!==d){-1!==O&&O=o)return V(!0);break}j.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),L++}}else L++}return H();function B(e){v.push(e),S=c}function q(e){var t=0;if(-1!==e){var a=r.substring(L+1,e);a&&""===a.trim()&&(t=a.length)}return t}function H(e){return p||(void 0===e&&(e=r.substring(c)),w.push(e),c=g,B(w),x&&Y()),V()}function z(e){c=e,B(w),w=[],F=r.indexOf(i,c)}function V(e){return{data:v,errors:j,meta:{delimiter:a,linebreak:i,aborted:m,truncated:!!e,cursor:S+(u||0)}}}function Y(){n(V()),v=[],j=[]}},this.abort=function(){m=!0},this.getCharIndex=function(){return c}}function _(e){var t=e.data,a=s[t.workerId],i=!1;if(t.error)a.userError(t.error,t.file);else if(t.results&&t.results.data){var n={abort:function(){i=!0,f(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:b,resume:b};if(y(a.userStep)){for(var r=0;r{e.O(0,[223],()=>e(e.s=16563)),e.O()}]);