/*! For license information please see admin.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([[328],{49868:function(){jQuery.AsyncQueue=function(){var e,t,a,s,n=this,o=[],r=!1;return s=function(){var e=o.shift();e?(e.apply(n,[n]),!1===r&&s()):t&&t.apply(n)},this.onFailure=function(t){e=t},this.onComplete=function(e){t=e},this.add=function(e){return o.push(e),this},this.storeData=function(e){return a=e,this},this.lastCallbackData=function(){return a},this.run=function(){r=!1,s()},this.pause=function(){return r=!0,this},this.failure=function(){if(r=!0,e){var t=[n];for(i=0;i{c.MailPoet.Ajax.post({api_version:n,endpoint:"UserFlags",action:"set",data:{transactional_emails_opt_in_notice_dismissed:"1"}})};return t<30||i||"PHPMail"===a||s||r?null:(0,u.jsxs)(p.q,{type:"success",timeout:!1,onClose:d,children:[(0,u.jsx)("h3",{children:c.MailPoet.I18n.t("transactionalEmailNoticeTitle")}),(0,u.jsxs)("p",{children:[c.MailPoet.I18n.t("transactionalEmailNoticeBody")," ",(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/292-choose-how-to-send-your-wordpress-websites-emails",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("transactionalEmailNoticeBodyReadMore")})]}),(0,u.jsx)("p",{children:(0,u.jsx)("button",{type:"button",className:"button",onClick:()=>{l(!0),c.MailPoet.Ajax.post({api_version:n,endpoint:"settings",action:"set",data:{send_transactional_emails:"1"}}),d()},children:c.MailPoet.I18n.t("transactionalEmailNoticeCTA")})})]})}h.displayName="TransactionalEmailsProposeOptInNotice";var g=i(87658),_=i(34352),f=i.n(_);function b(){if(!c.MailPoet.subscribersLimitReached)return null;const e=c.MailPoet.hasValidApiKey,t=c.MailPoet.subscribersLimit.toLocaleString();let i=c.MailPoet.I18n.t("subscribersLimitNoticeTitleUnknownLimit"),a=c.MailPoet.I18n.t("subscribersLimitReachedUnknownLimit"),s="";c.MailPoet.subscribersLimit&&(i=c.MailPoet.I18n.t("subscribersLimitNoticeTitle").replace("[subscribersLimit]",t),s=c.MailPoet.I18n.t(e?"yourPlanLimit":"freeVersionLimit").replace("[subscribersLimit]",t),a=c.MailPoet.I18n.t("subscribersLimitReached").replace("[subscribersLimit]",t));const n=e?c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(c.MailPoet.pluginPartialKey):c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount+1),o=f()(c.MailPoet.I18n.t("checkHowToManageSubscribers"),/\[link](.*?)\[\/link]/g,(e=>(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/348-subscribers-limit-for-sending-plans",children:e},"checkManageSubscribers")));return(0,u.jsxs)(p.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,u.jsx)("h3",{children:i}),(0,u.jsxs)("p",{children:[a," ",s," ",c.MailPoet.I18n.t("youNeedToUpgrade"),(0,u.jsx)("br",{}),"active"===c.MailPoet.wpSegmentState?o:null," ",c.MailPoet.I18n.t("actToSeamlessService")]}),(0,u.jsxs)("p",{children:[(0,u.jsx)("a",{target:"_blank",rel:"noopener noreferrer",className:"button button-primary",href:n,children:c.MailPoet.I18n.t("upgradeNow")}),e&&(0,u.jsxs)(u.Fragment,{children:[" ",(0,u.jsx)("button",{type:"button",className:"button",onClick:async()=>{await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"services",action:"recheckKeys"}),window.location.reload()},children:c.MailPoet.I18n.t("refreshMySubscribers")})]})]})]})}b.displayName="SubscribersLimitNotice";var x=i(26973);function v(){if(!c.MailPoet.emailVolumeLimitReached)return null;let e=c.MailPoet.I18n.t("emailVolumeLimitNoticeTitleUnknownLimit"),t=c.MailPoet.I18n.t("youReachedEmailVolumeLimitUnknownLimit");c.MailPoet.emailVolumeLimit&&(e=c.MailPoet.I18n.t("emailVolumeLimitNoticeTitle").replace("[emailVolumeLimit]",c.MailPoet.emailVolumeLimit.toLocaleString()),t=c.MailPoet.I18n.t("youReachedEmailVolumeLimit").replace("[emailVolumeLimit]",c.MailPoet.emailVolumeLimit.toLocaleString()));const i=c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(c.MailPoet.pluginPartialKey),a=new Date,s=new Date(a.getFullYear(),a.getMonth()+1,1);let n=f()(c.MailPoet.I18n.t("toContinueUpgradeYourPlanOrWaitUntil"),/\[link](.*?)\[\/link]/g,(e=>(0,u.jsx)("a",{target:"_blank",rel:"noreferrer",href:i,children:e},e)));return n=f()(n,/\[date]<\/b>\./g,(()=>(0,x.ZP)(`${c.MailPoet.Date.short(s)}.`))),(0,u.jsxs)(p.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,u.jsx)("h3",{children:e}),(0,u.jsxs)("p",{children:[t,(0,u.jsx)("br",{}),n]}),(0,u.jsxs)("p",{children:[(0,u.jsx)("a",{target:"_blank",rel:"noopener noreferrer",className:"button button-primary",href:i,children:c.MailPoet.I18n.t("upgradeNow")})," ",(0,u.jsx)("button",{type:"button",className:"button",onClick:async()=>{await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"services",action:"recheckKeys"}),window.location.reload()},children:c.MailPoet.I18n.t("refreshMyEmailVolumeLimit")})]})]})}v.displayName="EmailVolumeLimitNotice";const j=(0,r.withBoundary)(v);function y(e){let{mssKeyInvalid:t,subscribersCount:i}=e;return t?(0,u.jsxs)(p.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,u.jsx)("h3",{children:c.MailPoet.I18n.t("allSendingPausedHeader")}),(0,u.jsx)("p",{children:f()(c.MailPoet.I18n.t("allSendingPausedBody"),/\[link\](.*?)\[\/link\]/g,(e=>(0,u.jsx)("a",{href:"?page=mailpoet-settings#premium",children:e},"check-sending")))}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{href:`https://account.mailpoet.com?s=${i}`,className:"button button-primary",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("allSendingPausedLink")})})]}):null}function w(){return(0,u.jsxs)(r.ErrorBoundary,{children:[c.MailPoet.subscribersLimitReached&&(0,u.jsx)(b,{}),c.MailPoet.emailVolumeLimitReached&&(0,u.jsx)(j,{}),!c.MailPoet.subscribersLimitReached&&!c.MailPoet.emailVolumeLimitReached&&(0,u.jsx)(y,{mssKeyInvalid:c.MailPoet.hasInvalidMssApiKey,subscribersCount:c.MailPoet.subscribersCount})]})}function S(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(m.w,{}),(0,u.jsx)(w,{}),(0,u.jsx)(h,{mailpoetInstalledDaysAgo:c.MailPoet.installedDaysAgo,sendTransactionalEmails:c.MailPoet.transactionalEmailsEnabled,mtaMethod:c.MailPoet.mtaMethod,apiVersion:c.MailPoet.apiVersion,noticeDismissed:c.MailPoet.transactionalEmailsOptInNoticeDismissed}),(0,u.jsx)(g._,{mtaLog:c.MailPoet.mtaLog,mtaMethod:c.MailPoet.mtaMethod,isInline:!0})]})}y.displayName="InvalidMssKeyNotice";var P=i(56249),M=i(52542),N=i(74457),I=i(3279),C=i(81433),k=i(76944);function*T(){return yield(0,k.t)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.task_list_dismissed":!0}}),{type:"SET_TASK_LIST_HIDDEN"}}function*E(){return yield(0,k.t)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.product_discovery_dismissed":!0}}),{type:"SET_PRODUCT_DISCOVERY_HIDDEN"}}function*A(){return yield(0,k.t)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.upsell_dismissed":!0}}),{type:"SET_UPSELL_HIDDEN"}}function R(e){return e.taskList.isTaskListHidden}function F(e){return e.taskList.tasksStatus}function O(e){return e.productDiscovery.tasksStatus}function L(e){return e.taskList.canImportWooCommerceSubscribers}function D(e){return e.taskList.hasImportedSubscribers}function q(e){return e.formsCount>0}function $(e){return e.productDiscovery.isHidden}function B(e){return e.subscribersStats.global}function W(e){return e.subscribersStats.lists}function V(e){const t=e.productDiscovery.tasksStatus;return e.isWooCommerceActive?t.addSubscriptionForm&&t.setUpWelcomeCampaign&&t.setUpAbandonedCartEmail&&t.brandWooEmails:t.setUpWelcomeCampaign&&t.addSubscriptionForm&&t.sendFirstNewsletter}function U(e){return e.isWooCommerceActive}function z(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 Y(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 G="mailpoet/homepage",K={};var Q=i(57995),X=i(71458),J=i(26372),ee=i.n(J);function te(e,t,i){c.MailPoet.trackEvent(e,{ctaLabel:t},{send_immediately:!0},(()=>{window.location.href=i}))}function ie(e){let{title:t,titleCompleted:i="",slug:a,link:s,order:n,isCompleted:o,isActive:r,children:l=null}=e;const d=ee()("mailpoet-task-list__task",{"mailpoet-task-list__task--completed":o,"mailpoet-task-list__task--active":r}),c=()=>{te("Home Page Task",a,s)};return(0,u.jsxs)("li",{className:d,role:"row",onClick:o?void 0:c,tabIndex:o?void 0:0,onKeyDown:o?void 0:e=>"Enter"===e.key&&c(),children:[(0,u.jsx)("div",{className:"mailpoet-task-list__task-before",children:(0,u.jsx)("div",{className:"mailpoet-task-list__task-icon",children:o?(0,u.jsx)(Q.Z,{icon:X.Z}):n})}),(0,u.jsxs)("div",{className:"mailpoet-task-list__task-content",children:[(0,u.jsx)("div",{className:"mailpoet-task-list__task-title",children:o&&i?i:t}),l]})]})}function ae(e){let{onHide:t}=e;const{tasksStatus:i,currentTask:a,hasImportedSubscribers:s,canImportWooCommerceSubscribers:n}=(0,P.Z)((e=>({tasksStatus:e(G).getTasksStatus(),currentTask:e(G).getCurrentTask(),hasImportedSubscribers:e(G).getHasImportedSubscribers(),canImportWooCommerceSubscribers:e(G).getCanImportWooCommerceSubscribers()})),[]),o=[];return o.push((0,u.jsx)(ie,{slug:"set sender",title:c.MailPoet.I18n.t("senderSetTask"),titleCompleted:c.MailPoet.I18n.t("senderSetTaskDone"),link:"admin.php?page=mailpoet-settings#/basics",order:1,isCompleted:i.senderSet,isActive:"senderSet"===a},"senderSet")),o.push((0,u.jsx)(ie,{slug:"connect mss",title:c.MailPoet.I18n.t("mssConnectedTask"),titleCompleted:c.MailPoet.I18n.t("mssConnectedTaskDone"),link:"admin.php?page=mailpoet-settings#/premium",order:2,isCompleted:i.mssConnected,isActive:"mssConnected"===a},"mssConnected")),n&&o.push((0,u.jsx)(ie,{slug:"import woocommerce subscribers",title:c.MailPoet.I18n.t("wooSubscribersImportedTask"),titleCompleted:c.MailPoet.I18n.t("wooSubscribersImportedTaskDone"),link:"admin.php?page=mailpoet-woocommerce-setup",order:3,isCompleted:i.wooSubscribersImported,isActive:"wooSubscribersImported"===a},"wooSubscribersImported")),o.push((0,u.jsxs)(ie,{slug:"add subscribers",title:c.MailPoet.I18n.t("subscribersAddedTask"),titleCompleted:s?c.MailPoet.I18n.t("subscribersAddedTaskDoneByImport"):c.MailPoet.I18n.t("subscribersAddedTaskDoneByForm"),link:"admin.php?page=mailpoet-import",order:n?4:3,isCompleted:i.subscribersAdded,isActive:"subscribersAdded"===a,children:[!i.subscribersAdded&&(0,u.jsxs)("p",{children:[c.MailPoet.I18n.t("noSubscribersQuestion")," ",(0,u.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:r.stopLinkPropagation,children:c.MailPoet.I18n.t("setUpForm")})]}),i.subscribersAdded&&!s&&(0,u.jsxs)("p",{children:[c.MailPoet.I18n.t("haveSubscribersQuestion")," ",(0,u.jsx)("a",{href:"admin.php?page=mailpoet-import",children:c.MailPoet.I18n.t("import")})]})]},"subscribersAdded")),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-task-list__heading",children:[(0,u.jsx)("h1",{children:c.MailPoet.I18n.t("welcomeToMailPoet")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("beginByCompletingSetup")}),(0,u.jsx)(M.Z,{label:c.MailPoet.I18n.t("hideList"),icon:N.Z,controls:[{title:c.MailPoet.I18n.t("hideList"),onClick:t,icon:null}]})]}),(0,u.jsx)("ul",{children:o.map((e=>e))}),!a&&(0,u.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[c.MailPoet.I18n.t("youAreSet")," ",(0,u.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),t()},children:c.MailPoet.I18n.t("dismissList")})]})]})}function se(e){let{title:t,slug:i,link:a,description:s,doneMessage:n,imgSrc:o,isDone:r}=e;const l=()=>{te("Home Page Task",i,a)};return(0,u.jsxs)("li",{className:ee()("mailpoet-product-discovery__task",{"mailpoet-product-discovery__task--completed":r}),role:"row",onClick:r?void 0:l,tabIndex:r?void 0:0,onKeyDown:r?void 0:e=>"Enter"===e.key&&l(),children:[(0,u.jsx)("img",{src:o,alt:t,width:124,height:72}),(0,u.jsx)("div",{className:"mailpoet-product-discovery__task-content",children:r?(0,u.jsx)("h3",{children:n}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h3",{children:`${t} →`}),s&&(0,u.jsx)("p",{children:s})]})}),(0,u.jsx)("div",{className:"mailpoet-product-discovery__task-after",children:r&&(0,u.jsx)("div",{className:"mailpoet-task-list__task-icon",children:(0,u.jsx)(Q.Z,{icon:X.Z})})})]})}function ne(e){let{heading:t,description:i,children:a,headingAfter:s,className:n=""}=e;return(0,u.jsxs)("section",{className:ee()("mailpoet-homepage-section__container",n),children:[(0,u.jsxs)("header",{className:"mailpoet-homepage-section__heading",children:[(0,u.jsxs)("h2",{children:[t,i&&(0,u.jsx)("span",{children:i})]}),(0,u.jsx)("div",{className:"mailpoet-homepage-section__heading-after",children:s})]}),a]})}function oe(e){let{onHide:t}=e;const{tasksStatus:i,isWooCommerceActive:a,isDiscoveryDone:s}=(0,P.Z)((e=>({tasksStatus:e(G).getProductDiscoveryTasksStatus(),isWooCommerceActive:e(G).getIsWooCommerceActive(),isDiscoveryDone:e(G).getIsProductDiscoveryDone()})),[]),n=[];return n.push((0,u.jsx)(se,{slug:"set up welcome campaign",title:c.MailPoet.I18n.t("setUpWelcomeCampaign"),description:c.MailPoet.I18n.t("setUpWelcomeCampaignDesc"),link:"admin.php?page=mailpoet-automation-templates",imgSrc:`${c.MailPoet.cdnUrl}homepage/welcome-email-illustration.png`,isDone:i.setUpWelcomeCampaign,doneMessage:c.MailPoet.I18n.t("setUpWelcomeCampaignDone")},"setUpWelcomeCampaign"),(0,u.jsx)(se,{slug:"add subscription form",title:c.MailPoet.I18n.t("addSubscriptionForm"),description:c.MailPoet.I18n.t("addSubscriptionFormDesc"),link:"admin.php?page=mailpoet-form-editor-template-selection",imgSrc:`${c.MailPoet.cdnUrl}homepage/subscription-form-illustration.png`,isDone:i.addSubscriptionForm,doneMessage:c.MailPoet.I18n.t("addSubscriptionFormDone")},"addSubscriptionForm")),a?n.push((0,u.jsx)(se,{slug:"set up abandoned cart email",title:c.MailPoet.I18n.t("setUpAbandonedCartEmail"),description:c.MailPoet.I18n.t("setUpAbandonedCartEmailDesc"),link:"admin.php?page=mailpoet-newsletters#/new/woocommerce/woocommerce_abandoned_shopping_cart/conditions",imgSrc:`${c.MailPoet.cdnUrl}homepage/woo-cart-email-illustration.png`,isDone:i.setUpAbandonedCartEmail,doneMessage:c.MailPoet.I18n.t("setUpAbandonedCartEmailDone")},"setUpAbandonedCartEmail"),(0,u.jsx)(se,{slug:"brand woocommerce emails",title:c.MailPoet.I18n.t("brandWooEmails"),description:c.MailPoet.I18n.t("brandWooEmailsDesc"),link:"admin.php?page=mailpoet-settings#/woocommerce",imgSrc:`${c.MailPoet.cdnUrl}homepage/woo-transactional-email-illustration.png`,isDone:i.brandWooEmails,doneMessage:c.MailPoet.I18n.t("brandWooEmailsDone")},"brandWooEmails")):n.push((0,u.jsx)(se,{slug:"send first newsletter",title:c.MailPoet.I18n.t("sendFirstNewsletter"),description:c.MailPoet.I18n.t("sendFirstNewsletterDesc"),link:"admin.php?page=mailpoet-newsletters#/new",imgSrc:`${c.MailPoet.cdnUrl}homepage/newsletter-illustration.png`,isDone:i.sendFirstNewsletter,doneMessage:c.MailPoet.I18n.t("sendFirstNewsletterDone")},"sendFirstNewsletter")),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ne,{className:"mailpoet-homepage-product-discovery",heading:c.MailPoet.I18n.t("startEngagingWithYourCustomers"),headingAfter:(0,u.jsx)(M.Z,{label:c.MailPoet.I18n.t("hideList"),icon:N.Z,controls:[{title:c.MailPoet.I18n.t("hideList"),onClick:t,icon:null}]}),children:(0,u.jsx)("ul",{children:n.map((e=>e))})}),s&&(0,u.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[c.MailPoet.I18n.t("allDone")," ",(0,u.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),t()},children:c.MailPoet.I18n.t("dismissTasks")})]})]})}var re=i(15128),le=i(18822),de=i(43981),ce=i(31347),me=i(42238),pe=i(19382);function ue(e){let{closable:t,onHide:i}=e;return(0,u.jsx)(ne,{className:"mailpoet-homepage-upsell",heading:c.MailPoet.I18n.t("accelerateYourGrowth"),headingAfter:t&&i?(0,u.jsx)(pe.ZP,{icon:re.Z,onClick:i,label:c.MailPoet.I18n.t("close")}):null,children:(0,u.jsxs)("div",{className:"mailpoet-homepage-upsell__content",children:[(0,u.jsxs)("ul",{children:[(0,u.jsxs)("li",{children:[(0,u.jsx)(Q.Z,{icon:le.Z}),(0,u.jsx)("span",{children:c.MailPoet.I18n.t("detailedAnalytics")})]}),(0,u.jsxs)("li",{children:[(0,u.jsx)(Q.Z,{icon:de.Z}),(0,u.jsx)("span",{children:c.MailPoet.I18n.t("advancedSubscriberSegmentation")})]}),(0,u.jsxs)("li",{children:[(0,u.jsx)(Q.Z,{icon:ce.Z}),(0,u.jsx)("span",{children:c.MailPoet.I18n.t("emailMarketingAutomations")})]}),(0,u.jsxs)("li",{children:[(0,u.jsx)(Q.Z,{icon:me.Z}),(0,u.jsx)("span",{children:c.MailPoet.I18n.t("prioritySupport")})]})]}),(0,u.jsx)(pe.ZP,{variant:"primary",href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,"business",{utm_source:"plugin",utm_medium:"homepage",utm_campaign:"upsell"}),children:c.MailPoet.I18n.t("upgradePlan")})]})})}var he=i(48405),ge=i(47384);function _e(e){let{id:t,engagementScore:i}=e;const a={unknown:{name:c.MailPoet.I18n.t("unknownBadgeName"),type:"unknown",tooltipTitle:c.MailPoet.I18n.t("unknownBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipUnknown")},excellent:{name:c.MailPoet.I18n.t("excellentBadgeName"),type:"excellent",tooltipTitle:c.MailPoet.I18n.t("excellentBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipExcellent")},good:{name:c.MailPoet.I18n.t("goodBadgeName"),type:"good",tooltipTitle:c.MailPoet.I18n.t("goodBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipGood")},average:{name:c.MailPoet.I18n.t("averageBadgeName"),type:"average",tooltipTitle:c.MailPoet.I18n.t("averageBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipAverage")}},s=`badge-${t}`;let n;n=null==i?a.unknown:i<20?a.average:i<50?a.good:a.excellent;const o=(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"mailpoet-listing-stats-tooltip-title",children:n.tooltipTitle.toUpperCase()}),(0,u.jsx)("div",{className:"mailpoet-listing-stats-tooltip-description",children:c.MailPoet.I18n.t("engagementScoreDescription")}),(0,u.jsxs)("div",{className:"mailpoet-listing-stats-tooltip-content",children:[(0,u.jsx)(ge.C,{type:"unknown",name:c.MailPoet.I18n.t("unknownBadgeName")})," : ",a.unknown.tooltipText,(0,u.jsx)("br",{}),(0,u.jsx)(ge.C,{type:"excellent",name:c.MailPoet.I18n.t("excellentBadgeName")})," : ",a.excellent.tooltipText,(0,u.jsx)("br",{}),(0,u.jsx)(ge.C,{type:"good",name:c.MailPoet.I18n.t("goodBadgeName")})," : ",a.good.tooltipText,(0,u.jsx)("br",{}),(0,u.jsx)(ge.C,{type:"average",name:c.MailPoet.I18n.t("averageBadgeName")})," : ",a.average.tooltipText]})]},`tooltip-${s}`);return(0,u.jsxs)("div",{className:"mailpoet-listing-stats-opened-clicked",children:[null!=i&&(0,u.jsxs)("div",{className:"mailpoet-listing-stats-percentages",children:[i.toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}),"%"]}),(0,u.jsx)("div",{children:(0,u.jsx)(ge.C,{isInverted:!0,type:n.type,name:n.name,tooltip:o,tooltipId:s,tooltipPlace:"top"})})]})}const fe=(e,t,i)=>{e.preventDefault(),te("Home Page Statistics Click",t,i)};function be(){const{globalChange:e,listsChange:t,hasForms:i}=(0,P.Z)((e=>({globalChange:e(G).getGlobalSubscriberStatsChange(),listsChange:e(G).getListsSubscriberStatsChange(),hasForms:e(G).getHasForms()})),[]),a=0===t.length&&0===e.subscribed&&0===e.unsubscribed;return(0,u.jsx)(ne,{className:"mailpoet-subscribers-stats",heading:c.MailPoet.I18n.t("subscribersHeading"),description:c.MailPoet.I18n.t("subscribersSectionDescription"),headingAfter:!a&&(0,u.jsxs)("span",{className:ee()({"mailpoet-decrease":e.changePercent<0}),children:[(0,u.jsx)(Q.Z,{icon:le.Z}),e.changePercent<0&&"-",Math.abs(e.changePercent)>1e3?"∞%":`${Math.abs(e.changePercent)}%`]}),children:a?(0,u.jsxs)("div",{className:"mailpoet-subscribers-stats-empty",children:[(0,u.jsx)(Q.Z,{icon:le.Z,viewBox:"-4 -4 32 32"}),i?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("subscriberCountHasNotChangeLongTime")}),(0,u.jsx)("a",{href:"admin.php?page=mailpoet-newsletters#/new",onClick:e=>fe(e,"campaigns","admin.php?page=mailpoet-newsletters#/new"),children:c.MailPoet.I18n.t("exploreCampaigns")})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{children:[c.MailPoet.I18n.t("changesWillAppear"),(0,u.jsx)("br",{}),c.MailPoet.I18n.t("starBySettingUpForm")]}),(0,u.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:e=>fe(e,"new form","admin.php?page=mailpoet-form-editor-template-selection"),children:c.MailPoet.I18n.t("createForm")})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-subscribers-stats-global-change",children:[(0,u.jsxs)("div",{children:[c.MailPoet.I18n.t("newSubscribers"),(0,u.jsx)("br",{}),(0,u.jsx)("span",{children:e.subscribed})]}),(0,u.jsxs)("div",{children:[c.MailPoet.I18n.t("unsubscribedSubscribers"),(0,u.jsx)("br",{}),(0,u.jsx)("span",{children:e.unsubscribed})]})]}),!!t.length&&(0,u.jsxs)("table",{className:"mailpoet-subscribers-stats-list-change-table",children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:c.MailPoet.I18n.t("listName")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("listScore")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("subscribedSubscribers")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("unsubscribedSubscribers")})]})}),(0,u.jsx)("tbody",{children:t.map((e=>(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:(0,u.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,u.jsx)("td",{children:(0,u.jsx)("div",{className:"mailpoet-listing-stats",children:(0,u.jsx)(_e,{id:e.id,engagementScore:e.averageEngagementScore})})}),(0,u.jsx)("td",{children:e.subscribed}),(0,u.jsx)("td",{children:e.unsubscribed})]},e.id)))})]})]})})}var xe=i(74193),ve=i(83158);function je(e){let{link:t,abstract:i,title:a,imgSrc:s}=e;return(0,u.jsxs)("a",{className:"mailpoet-resource-post",href:t,target:"_blank",rel:"noreferrer",children:[(0,u.jsx)("img",{src:s,alt:a,width:"292",height:"166"}),(0,u.jsx)("h3",{children:a}),(0,u.jsx)("p",{children:i})]})}function ye(){const[e,t]=(0,o.useState)(1),i=[(0,u.jsx)(je,{link:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("createAnEmailAbstract"),title:c.MailPoet.I18n.t("createAnEmailTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/add_email.png`},"createAnEmail"),(0,u.jsx)(je,{link:"https://kb.mailpoet.com/article/297-create-a-form-with-our-new-editor?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("createAFormAbstract"),title:c.MailPoet.I18n.t("createAFormTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/add_form.png`},"createAForm"),(0,u.jsx)(je,{link:"https://www.mailpoet.com/blog/email-segmentation/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("segmentationGuideAbstract"),title:c.MailPoet.I18n.t("segmentationGuideTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/segmentation.png`},"segmentationGuide"),(0,u.jsx)(je,{link:"https://www.mailpoet.com/blog/re-engagement-emails/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("reEngagementAbstract"),title:c.MailPoet.I18n.t("reEngagementTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/reengagement.png`},"reEngagement"),(0,u.jsx)(je,{link:"https://www.mailpoet.com/blog/newsletter-marketing-strategy/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("marketingStrategyAbstract"),title:c.MailPoet.I18n.t("marketingStrategyTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/marketing.png`},"marketingStrategy"),(0,u.jsx)(je,{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:c.MailPoet.I18n.t("promotingSalesAbstract"),title:c.MailPoet.I18n.t("promotingSalesTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/sales.png`},"promotingSales")],a=(0,o.useCallback)((i=>{i.preventDefault(),t(e+1)}),[e]),s=(0,o.useCallback)((i=>{i.preventDefault(),t(e-1)}),[e]);return(0,u.jsxs)(ne,{className:"mailpoet-homepage-resources",heading:c.MailPoet.I18n.t("learnMoreAboutEmailMarketing"),children:[(0,u.jsx)("div",{className:"mailpoet-homepage-resources__posts",children:i.filter(((t,i)=>i+1===2*e||i+1===2*e-1)).map((e=>e))}),(0,u.jsxs)("div",{className:"mailpoet-homepage-resources__pagination",children:[c.MailPoet.I18n.t("pageOf").replace("%1$d",e.toString()).replace("%2$d",Math.ceil(i.length/2).toString()),e>1?(0,u.jsx)("a",{href:"#",onClick:s,title:c.MailPoet.I18n.t("previousPostsPage"),children:(0,u.jsx)(Q.Z,{icon:xe.Z})}):(0,u.jsx)(Q.Z,{icon:xe.Z}),e({isTaskListHidden:e(G).getIsTaskListHidden(),isProductDiscoveryHidden:e(G).getIsProductDiscoveryHidden(),isUpsellHidden:e(G).getIsUpsellHidden(),canDisplayUpsell:e(G).getCanDisplayUpsell()})),[]),{hideTaskList:s}=(0,he.Z)(G),{hideProductDiscovery:n}=(0,he.Z)(G),{hideUpsell:o}=(0,he.Z)(G);return(0,u.jsxs)("div",{className:"mailpoet-homepage__container",children:[!e&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(ae,{onHide:s})}),!t&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(oe,{onHide:n})}),e&&t&&a&&!i&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(ue,{closable:!0,onHide:o})}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(be,{})}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(ye,{})})]})}function Se(){const[e,t]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{(()=>{const e=(0,I.Z)(G,{actions:a,controls:K,selectors:s,reducer:Y,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},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:c.MailPoet.isWoocommerceActive,subscribersStats:window.mailpoet_homepage_data.subscribersStats,formsCount:window.mailpoet_homepage_data.formsCount}});(0,C.register)(e)})(),t(!0)}),[]),(0,u.jsxs)(l.k.Provider,{value:(0,l.S)(window),children:[(0,u.jsx)(d.Q,{}),(0,u.jsx)(S,{}),e?(0,u.jsx)(we,{}):null]})}const Pe=document.getElementById("mailpoet_homepage_container");Pe&&((0,r.registerTranslations)(),(0,n.s)(Pe).render((0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Se,{})})));var Me=i(26952),Ne=i(16374),Ie=i(65311),Ce=i.n(Ie),ke=i(39519),Te=i.n(ke),Ee=i(26694),Ae=i(38611),Re=i(79830),Fe=i(7936),Oe=i(49773);function Le(e){let{cacheCalculation:t}=e;const[i,a]=(0,o.useState)(!1),[s,n]=(0,o.useState)([]),r=(new Date).getTime()-new Date(t).getTime(),l=Math.floor(r/1e3/60);return(0,u.jsxs)("div",{className:"mailpoet-subscribers-cache-notice",children:[f()((0,Fe.__)("Lists and Segments subscribers counts were calculated {$mins} minutes ago","mailpoet"),/(.*?)<\/abbr>/,((e,i)=>(0,u.jsx)("abbr",{title:t,children:e.replace(/(\{\$mins\}|\$mins)/i,String(l))},i))),(0,u.jsx)(Oe.z,{className:"mailpoet-subscribers-cache-notice-button",type:"button",variant:"secondary",dimension:"small",onClick:()=>{a(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"settings",action:"recalculateSubscribersCountsCache"}).done((()=>{window.location.reload()})).fail((e=>{n(e.errors.map((e=>e.message))),a(!1)}))},withSpinner:i,children:(0,Fe.__)("Recalculate now","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),s.length>0&&(0,u.jsx)(p.q,{type:"error",children:s.map((e=>(0,u.jsx)("p",{children:e},e)))})]})}var De=i(37248);function qe(e){let{subscribersInPlan:t,subscribersInPlanLimit:i}=e;if(!1===t)return null;const a=i?(0,u.jsx)("b",{children:(0,Fe._x)("%1$d / %2$d","count / total subscribers","mailpoet").replace("%1$d",t.toLocaleString()).replace("%2$d",i.toLocaleString())},"subscribers_count"):(0,u.jsx)("b",{children:t},"subscribers_count");return(0,u.jsxs)("div",{className:"mailpoet-subscribers-in-plan",children:[f()((0,Fe._x)("%s subscribers in your plan","number of subscribers in a sending plan","mailpoet"),"%s",(()=>a))," ",(0,u.jsx)(De.Tooltip,{tooltip:(0,Fe.__)("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"}),(0,u.jsx)("span",{className:"mailpoet-subscribers-in-plan-spacer",children:" "})]})}var $e=i(33493);function Be(e){let{location:t}=e;return(0,u.jsxs)(d.Q,{children:[(0,u.jsxs)(Me.Link,{className:"mailpoet-button button-secondary",to:{pathname:"/new",state:{backUrl:t?.pathname}},children:[$e.R,(0,u.jsx)("span",{"data-automation-id":"add-new-subscribers-button",children:c.MailPoet.I18n.t("new")})]}),(0,u.jsx)("a",{className:"mailpoet-button not-small-screen button-secondary",href:"?page=mailpoet-import","data-automation-id":"import-subscribers-button",children:c.MailPoet.I18n.t("import")}),(0,u.jsx)("a",{id:"mailpoet_export_button",className:"mailpoet-button not-small-screen button-secondary",href:"?page=mailpoet-export",children:c.MailPoet.I18n.t("export")})]})}Be.propTypes={location:Te().object.isRequired};const We=(0,Ne.EN)(Be),Ve=c.MailPoet.trackingConfig.emailTrackingEnabled,Ue=[{name:"email",label:c.MailPoet.I18n.t("subscriber"),sortable:!0},{name:"status",label:c.MailPoet.I18n.t("status"),sortable:!0},{name:"segments",label:c.MailPoet.I18n.t("lists")},{name:"tags",label:c.MailPoet.I18n.t("tags")},{name:"statistics",label:c.MailPoet.I18n.t("statisticsColumn"),display:Ve},{name:"created_at",label:c.MailPoet.I18n.t("subscribedOn"),sortable:!0}],ze={onTrash:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneSubscriberTrashed"):c.MailPoet.I18n.t("multipleSubscribersTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneSubscriberDeleted"):c.MailPoet.I18n.t("multipleSubscribersDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneSubscriberRestored"):c.MailPoet.I18n.t("multipleSubscribersRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onNoItemsFound:e=>"bounced"===e&&!window.mailpoet_premium_active&&!window.mailpoet_mss_active&&(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("bouncedSubscribersHelp")}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",className:"button-primary",children:c.MailPoet.I18n.t("bouncedSubscribersPremiumButtonText")})})]})},He=(e,t,i,a)=>(0,u.jsxs)(Ae.u,{title:a,onRequestClose:t,isDismissible:!0,children:[(0,u.jsx)(Re.Y,{field:i}),(0,u.jsx)("span",{className:"mailpoet-gap-half"}),(0,u.jsx)(r.Button,{onClick:e,dimension:"small",variant:"secondary",children:c.MailPoet.I18n.t("apply")})]}),Ze=[{name:"moveToList",label:c.MailPoet.I18n.t("moveToList"),onSelect:function(e,t){return He(e,t,{id:"move_to_segment",name:"move_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},c.MailPoet.I18n.t("moveToList"))},getData:function(){return{segment_id:Number(Ce()("#move_to_segment").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersMovedToList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"addToList",label:c.MailPoet.I18n.t("addToList"),onSelect:function(e,t){return He(e,t,{id:"add_to_segment",name:"add_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},c.MailPoet.I18n.t("addToList"))},getData:function(){return{segment_id:Number(Ce()("#add_to_segment").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersAddedToList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromList",label:c.MailPoet.I18n.t("removeFromList"),onSelect:function(e,t){return He(e,t,{id:"remove_from_segment",name:"remove_from_segment",endpoint:"segments",filter:function(e){return!("default"!==e.type)}},c.MailPoet.I18n.t("removeFromList"))},getData:function(){return{segment_id:Number(Ce()("#remove_from_segment").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersRemovedFromList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromAllLists",label:c.MailPoet.I18n.t("removeFromAllLists"),onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersRemovedFromAllLists").replace("%1$d",Number(e.meta.count).toLocaleString()))}},{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:ze.onTrash},{name:"unsubscribe",label:c.MailPoet.I18n.t("unsubscribe"),onSelect:(e,t,i)=>{const a="all"!==i.selection?i.selected_ids.length:i.count;return(0,u.jsxs)(Ae.u,{title:c.MailPoet.I18n.t("unsubscribe"),onRequestClose:t,isDismissible:!0,children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("unsubscribeConfirm").replace("%s",Number(a).toLocaleString())}),(0,u.jsx)("span",{className:"mailpoet-gap-half"}),(0,u.jsx)(r.Button,{onClick:e,dimension:"small",variant:"secondary",automationId:"bulk-unsubscribe-confirm",children:c.MailPoet.I18n.t("apply")})]})}},{name:"addTag",label:c.MailPoet.I18n.t("addTag"),onSelect:function(e,t){return He(e,t,{id:"add_tag",name:"add_tag",endpoint:"tags"},c.MailPoet.I18n.t("addTag"))},getData:function(){return{tag_id:Number(Ce()("#add_tag").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("tagAddedToMultipleSubscribers").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}},{name:"removeTag",label:c.MailPoet.I18n.t("removeTag"),onSelect:function(e,t){return He(e,t,{id:"remove_tag",name:"remove_tag",endpoint:"tags"},c.MailPoet.I18n.t("removeTag"))},getData:function(){return{tag_id:Number(Ce()("#remove_tag").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("tagRemovedFromMultipleSubscribers").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}}],Ye=[{name:"statistics",label:c.MailPoet.I18n.t("statsListingActionTitle"),link:function(e,t){return(0,u.jsx)(Me.Link,{to:{pathname:`/stats/${e.id}`,state:{backUrl:t?.pathname}},children:c.MailPoet.I18n.t("statsListingActionTitle")})}},{name:"edit",label:c.MailPoet.I18n.t("edit"),link:function(e,t){return(0,u.jsx)(Me.Link,{to:{pathname:`/edit/${e.id}`,state:{backUrl:t?.pathname}},children:c.MailPoet.I18n.t("edit")})}},{name:"sendConfirmationEmail",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("resendConfirmationEmail"),display:function(e){return"unconfirmed"===e.status&&e.count_confirmationsc.MailPoet.Notice.success(c.MailPoet.I18n.t("oneConfirmationEmailSent")))).fail((e=>c.MailPoet.Notice.showApiErrorNotice(e)))}},{name:"trash",className:"mailpoet-hide-on-mobile"}],Ge=e=>0===Number(e.wp_user_id)&&0===Number(e.is_woocommerce_user),Ke=e=>{let t=null;return window.mailpoet_segments.forEach((i=>{i.id===e&&(t=i)})),t};function Qe(e){let{match:t}=e;const i=(0,Ne.TH)();return(0,u.jsxs)("div",{children:[(0,u.jsx)(We,{}),(0,u.jsx)(qe,{subscribersInPlan:c.MailPoet.subscribersCount,subscribersInPlanLimit:c.MailPoet.subscribersLimit}),(0,u.jsx)(w,{}),(0,u.jsx)(Le,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at}),(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:i,params:t.params,endpoint:"subscribers",onRenderItem:(e,t)=>{const a=ee()("manage-column","column-primary","has-row-actions","column-username");let s="";switch(e.status){case"subscribed":s=c.MailPoet.I18n.t("subscribed");break;case"unconfirmed":s=c.MailPoet.I18n.t("unconfirmed");break;case"unsubscribed":s=c.MailPoet.I18n.t("unsubscribed");break;case"inactive":s=c.MailPoet.I18n.t("inactive");break;case"bounced":s=c.MailPoet.I18n.t("bounced");break;default:s="Invalid"}const n=[];return e.subscriptions.length>0&&e.subscriptions.forEach((e=>{const t=Ke(e.segment_id);null!==t&&"subscribed"===e.status&&n.push(t)})),(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:a,children:[(0,u.jsx)(Me.Link,{className:"mailpoet-listing-title",to:{pathname:`/edit/${e.id}`,state:{backUrl:i?.pathname}},children:e.email}),(0,u.jsxs)("div",{className:"mailpoet-listing-subtitle",children:[e.first_name," ",e.last_name]}),t]}),(0,u.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("status"),children:s}),(0,u.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("lists"),children:(0,u.jsx)(r.SegmentTags,{segments:n,dimension:"large"})}),(0,u.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("tags"),children:(0,u.jsx)(r.SubscriberTags,{subscribers:e.tags,variant:"wordpress",isInverted:!0})}),!0===Ve?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":c.MailPoet.I18n.t("statisticsColumn"),children:(0,u.jsx)("div",{className:"mailpoet-listing-stats",children:(0,u.jsx)("a",{href:`#/stats/${e.id}`,children:(0,u.jsx)(_e,{id:e.id,engagementScore:e.engagement_score})},`stats-link-${e.id}`)})}):null,(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("subscribedOn"),children:[c.MailPoet.Date.short(e.created_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.created_at)]})]})},columns:Ue,bulk_actions:Ze,item_actions:Ye,messages:ze,sort_by:"created_at",sort_order:"desc",isItemDeletable:Ge})]})}Qe.propTypes={match:Te().shape({params:Te().object}).isRequired},Qe.displayName="SubscriberList";var Xe=i(73136),Je=i.n(Xe),et=i(93625),tt=i(26869),it=i.n(tt),at=i(3537);class st extends o.Component{render(){const e=this.props.field.name||null,t=this.props.item||{};let i,a;this.props.onValueChange instanceof Function&&(i=t[this.props.field.name],i=void 0===i?this.props.field.defaultValue||"":i),!i&&this.props.field.defaultValue&&(a=this.props.field.defaultValue);let s=this.props.field.id||null;!s&&this.props.field.name&&(s=`field_${this.props.field.name}`);let n,o=this.props.field.className||null;return o||this.props.field.size||(o="regular-text"),n="function"==typeof this.props.field.disabled?this.props.field.disabled(this.props.item):"boolean"==typeof this.props.field.disabled&&this.props.field.disabled,(0,u.jsx)(at.I,{type:"text",disabled:n,className:o,size:"auto"!==this.props.field.size&&this.props.field.size>0?this.props.field.size:null,name:e,id:s,value:i,defaultValue:a,placeholder:this.props.field.placeholder,onChange:this.props.onValueChange,onBlur:this.props.onBlurEvent,customLabel:this.props.field.customLabel,tooltip:this.props.field.tooltip,...this.props.field.validation})}}st.propTypes={onValueChange:Te().func,onBlurEvent:Te().func,field:Te().shape({name:Te().string.isRequired,defaultValue:Te().string,id:Te().string,className:Te().string,size:Te().oneOfType([Te().string,Te().number]),disabled:Te().oneOfType([Te().bool,Te().func]),placeholder:Te().string,validation:Te().shape({"data-parsley-required":Te().bool,"data-parsley-required-message":Te().string,"data-parsley-type":Te().string,"data-parsley-errors-container":Te().string,maxLength:Te().number}),customLabel:Te().string,tooltip:Te().string}).isRequired,item:Te().object.isRequired},st.defaultProps={onValueChange:function(){},onBlurEvent:function(){}};var nt=i(62865);function ot(e){return(0,u.jsx)(nt.g,{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})}ot.propTypes={item:Te().object.isRequired,field:Te().shape({name:Te().string,placeholder:Te().string,defaultValue:Te().string,validation:Te().shape({"data-parsley-required":Te().bool,"data-parsley-required-message":Te().string,"data-parsley-type":Te().string,"data-parsley-errors-container":Te().string,maxLength:Te().number}),className:Te().string,customLabel:Te().string,tooltip:Te().string}).isRequired,onValueChange:Te().func.isRequired};var rt=i(43869),lt=i(67902);class dt extends o.Component{render(){if(void 0===this.props.field.values)return!1;let e,t=!1,i=!1,a=!1;void 0!==this.props.field.placeholder&&(i=(0,u.jsx)("option",{value:"",children:this.props.field.placeholder})),void 0!==this.props.field.filter&&(t=this.props.field.filter),rt.default.isFunction(this.props.field.sortBy)&&(a=this.props.field.sortBy),e=a?rt.default.map(rt.default.sortBy(rt.default.pairs(this.props.field.values),(e=>a(e[0],e[1]))),(e=>e[0])):Object.keys(this.props.field.values);const s=e.filter((e=>!1===t||t(this.props.item,e))).map((e=>(0,u.jsx)("option",{value:e,children:this.props.field.values[e]},`option-${e}`)));return(0,u.jsxs)(lt.Select,{name:this.props.field.name,id:`field_${this.props.field.name}`,value:this.props.item[this.props.field.name]||"",onChange:this.props.onValueChange,automationId:this.props.automationId,...this.props.field.validation,children:[i,s]})}}dt.propTypes={onValueChange:Te().func,field:Te().shape({name:Te().string.isRequired,values:Te().objectOf(Te().string),placeholder:Te().string,filter:Te().func,sortBy:Te().func,validation:Te().shape({"data-parsley-required":Te().bool,"data-parsley-required-message":Te().string,"data-parsley-type":Te().string,"data-parsley-errors-container":Te().string,maxLength:Te().number})}).isRequired,item:Te().object.isRequired,automationId:Te().string},dt.defaultProps={automationId:"",onValueChange:function(){}};var ct=i(60216);class mt extends o.Component{constructor(e){super(e),this.onValueChange=this.onValueChange.bind(this)}onValueChange=(e,t)=>this.props.onValueChange(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,u.jsx)("p",{children:(0,u.jsx)(ct.Y,{checked:e===t,value:t,onCheck:this.onValueChange,name:this.props.field.name,children:this.props.field.values[t]})},`radio-${t}`)));return(0,u.jsx)("div",{children:t})}}mt.propTypes={onValueChange:Te().func,field:Te().shape({name:Te().string.isRequired,values:Te().objectOf(Te().string)}).isRequired,item:Te().object.isRequired},mt.defaultProps={onValueChange:function(){}};var pt=i(49321);class ut extends o.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,u.jsx)("p",{children:(0,u.jsx)(pt.X,{value:"1",checked:e,name:this.props.field.name,onCheck:this.onValueChange,children:this.props.field.values[t]})},`checkbox-${t}`)));return(0,u.jsx)("div",{children:t})}}function ht(e){const t=[];void 0!==e.placeholder&&t.push((0,u.jsx)("option",{value:"",children:e.placeholder},0));const i=Je()().year();for(let e=i;e>=i-100;e-=1)t.push((0,u.jsx)("option",{value:e,children:e},e));return(0,u.jsx)(r.Select,{isMinWidth:!0,name:`${e.name}[year]`,value:e.year,onChange:e.onValueChange,children:t})}function gt(e){const t=[];void 0!==e.placeholder&&t.push((0,u.jsx)("option",{value:"",children:e.placeholder},0));for(let i=1;i<=12;i+=1)t.push((0,u.jsx)("option",{value:i,children:e.monthNames[i-1]},i));return(0,u.jsx)(r.Select,{isMinWidth:!0,name:`${e.name}[month]`,value:e.month,onChange:e.onValueChange,children:t})}function _t(e){const t=[];void 0!==e.placeholder&&t.push((0,u.jsx)("option",{value:"",children:e.placeholder},0));for(let e=1;e<=31;e+=1)t.push((0,u.jsx)("option",{value:e,children:e},e));return(0,u.jsx)(r.Select,{isMinWidth:!0,name:`${e.name}[day]`,value:e.day,onChange:e.onValueChange,children:t})}ut.propTypes={onValueChange:Te().func.isRequired,field:Te().shape({name:Te().string.isRequired,values:Te().objectOf(Te().string)}).isRequired,item:Te().object.isRequired},ht.propTypes={name:Te().string.isRequired,placeholder:Te().string.isRequired,onValueChange:Te().func.isRequired,year:Te().oneOfType([Te().string,Te().number]).isRequired},gt.propTypes={name:Te().string.isRequired,placeholder:Te().string.isRequired,onValueChange:Te().func.isRequired,month:Te().oneOfType([Te().string,Te().number]).isRequired,monthNames:Te().arrayOf(Te().string).isRequired},_t.propTypes={name:Te().string.isRequired,placeholder:Te().string.isRequired,onValueChange:Te().func.isRequired,day:Te().oneOfType([Te().string,Te().number]).isRequired};class ft extends o.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 i=null,a=null;if(null!==t&&3===t.length){[,i,a]=t;const s=Number(e.target.value);this.setState({[`${a}`]:s},(()=>{this.props.onValueChange({target:{name:i,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=Je()(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 i=t.split("/").map((t=>{switch(t){case"YYYY":return(0,u.jsx)(ht,{onValueChange:this.onValueChange,name:this.props.field.name,year:this.state.year,placeholder:this.props.field.year_placeholder},"year");case"MM":return(0,u.jsx)(gt,{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,u.jsx)(_t,{onValueChange:this.onValueChange,name:this.props.field.name,day:this.state.day,placeholder:this.props.field.day_placeholder},"day");default:return(0,u.jsx)("div",{children:"Invalid date type"})}}));return(0,u.jsx)("div",{children:i})}}ft.propTypes={item:Te().object.isRequired,field:Te().shape({name:Te().string,day_placeholder:Te().string,month_placeholder:Te().string,year_placeholder:Te().string,params:Te().object}).isRequired,onValueChange:Te().func.isRequired};var bt=i(86104),xt=i(41745);function vt(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 i=[];return e.field.endpoint?i=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&&(i=e.field.suggestedValues),(0,u.jsx)(xt.T,{label:e.field.label,name:e.field.name,placeholder:e.field.placeholder,selectedValues:t,suggestedValues:i,onChange:e.onValueChange})}class jt extends o.Component{renderField=e=>{let t,i=!1;e.field.description&&(i=(0,u.jsx)("p",{className:"description",children:e.field.description}));let a=e.field;switch(void 0!==e.field.field&&(a=Ce().merge(a,e.field.field)),a.type){case"text":t=(0,u.jsx)(st,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"textarea":t=(0,u.jsx)(ot,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"select":t=(0,u.jsx)(dt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"radio":t=(0,u.jsx)(mt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"checkbox":t=(0,u.jsx)(ut,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"selection":t=(0,u.jsx)(Re.Y,{onValueChange:e.onValueChange,field:e.field,automationId:e.automationId,inline:e.inline,description:e.description,item:e.item},`selection-field-${a.name}`);break;case"date":t=(0,u.jsx)(ft,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"reactComponent":t=(0,u.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,u.jsx)(vt,{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 a.disabled?a.disabled(e.field):a.disabled,n={...a.onWrapperClick?{onClick:a.onWrapperClick}:{}};return(0,u.jsxs)("div",{className:ee()("mailpoet-form-field",{"mailpoet-form-field-disabled":s}),...n,children:[t,i]},`field-${e.index||0}`)};render(){let e=!1;e=void 0!==this.props.field.fields?this.props.field.fields.map(((e,t)=>this.renderField({index:t,field:e,item:this.props.item,onValueChange:this.props.onValueChange||!1}))):this.renderField(this.props);let t=!1;this.props.field.label&&(t=(0,u.jsx)(bt.X,{level:4,children:(0,u.jsx)("label",{htmlFor:`field_${this.props.field.name}`,children:this.props.field.label})}));let i=!1;return this.props.field.tip&&(i=(0,u.jsx)("p",{className:"mailpoet-form-description",children:this.props.field.tip})),(0,u.jsxs)("div",{className:`mailpoet-form-field-${this.props.field.name} form-field-row-${this.props.field.name}`,children:[t,i,e]})}}jt.propTypes={onValueChange:Te().func,field:Te().shape({name:Te().string.isRequired,values:Te().objectOf(Te().string),tip:Te().oneOfType([Te().array,Te().string]),label:Te().string,fields:Te().arrayOf(Te().object),description:Te().string,onWrapperClick:Te().func,disabled:Te().oneOfType([Te().func,Te().bool])}).isRequired,item:Te().object.isRequired},jt.defaultProps={onValueChange:function(){}},(0,r.registerTranslations)();class yt extends o.Component{constructor(e){super(e),this.formRef=(0,o.createRef)(),this.state={loading:!1,errors:[],item:{}}}componentDidMount(){void 0!==this.props.params.id?this.loadItem(this.props.params.id):it()((()=>{const e=Ce()(".mailpoet_form").mailpoetSerializeObject(),t=Array.isArray(this.props.fields)&&this.props.fields.length>0&&this.props.fields.find((e=>"checkbox"===e?.type&&e?.isChecked));t&&t.name&&(e[t.name]="1"),this.setState({item:e})}))}componentDidUpdate(e){void 0===this.props.params.id&&e.location.pathname!==this.props.location.pathname&&(it()((()=>{this.setState({loading:!1,item:{}})})),void 0===this.props.item&&this.formRef.current.reset())}getValues=()=>this.props.item||this.state.item;getErrors=()=>this.props.errors||this.state.errors;loadItem=e=>{this.setState({loading:!0}),this.props.endpoint&&c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:this.props.endpoint,action:"get",data:{id:e}}).done((e=>{this.setState({loading:!1,item:e.data}),"function"==typeof this.props.onItemLoad&&this.props.onItemLoad(e.data)})).fail((()=>{this.setState({loading:!1,item:{}},(function(){this.props.history.push("/lists")}))}))};handleSubmit=e=>{if(e.preventDefault(),void 0!==this.props.isValid&&!1===this.props.isValid())return;this.setState({loading:!0});const t={};this.props.fields.forEach((e=>{void 0!==e.fields?e.fields.forEach((e=>{t[e.name]=this.state.item[e.name]})):t[e.name]=this.state.item[e.name]})),void 0!==this.props.params.id&&(t.id=this.props.params.id),this.props.endpoint&&c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:this.props.endpoint,action:"save",data:t}).always((()=>{this.setState({loading:!1})})).done((()=>{void 0!==this.props.onSuccess?this.props.onSuccess():this.props.history.push("/"),void 0!==this.props.params.id?this.props.messages.onUpdate():this.props.messages.onCreate()})).fail((e=>{e.errors.length>0&&this.setState({errors:e.errors})}))};handleValueChange=e=>{const{name:t,value:i}=Object.prototype.hasOwnProperty.call(e,"target")?e.target:e;return this.props.onChange?this.props.onChange(e):(this.setState((e=>{const a=e.item;return a[t]=i,{item:a}})),!0)};render(){let e;void 0!==this.getErrors()&&(e=this.getErrors().map((e=>(0,u.jsx)("div",{className:"mailpoet_notice notice inline error is-dismissible",children:(0,u.jsx)("p",{children:e.message})},`error-${e.message}`))));const t=ee()("mailpoet_form",{mailpoet_form_loading:this.state.loading||this.props.loading});let i=!1,a=!1;void 0!==this.props.beforeFormContent&&(i=this.props.beforeFormContent(this.getValues())),void 0!==this.props.afterFormContent&&(a=this.props.afterFormContent(this.getValues()));const s=this.props.fields.map((e=>{let t=this.handleValueChange;return e.onBeforeChange&&(t=t=>(e.onBeforeChange(t),this.handleValueChange(t))),(0,u.jsx)(jt,{field:e,item:this.getValues(),onValueChange:t,automationId:e.automationId},`field-${e.name}`)}));let n=!1;return n=this.props.children?this.props.children:(0,u.jsx)(r.Button,{type:"submit",isDisabled:this.state.loading,children:(0,Fe.__)("Save","mailpoet")}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"mailpoet-form-content-around",children:i}),(0,u.jsxs)("form",{id:this.props.id,ref:this.formRef,className:t,onSubmit:void 0!==this.props.onSubmit?this.props.onSubmit:this.handleSubmit,"data-automation-id":this.props.automationId,children:[e,(0,u.jsxs)("div",{className:"mailpoet-form-grid",children:[s,(0,u.jsx)("div",{className:"mailpoet-form-actions",children:n})]})]}),(0,u.jsx)("div",{className:"mailpoet-form-content-around",children:a})]})}}yt.propTypes={params:Te().shape({id:Te().string}),location:Te().shape({pathname:Te().string}),item:Te().object,errors:Te().arrayOf(Te().object),endpoint:Te().string,fields:Te().arrayOf(Te().object),messages:Te().shape({onUpdate:Te().func,onCreate:Te().func}),loading:Te().bool,children:Te().array,id:Te().string,automationId:Te().string,beforeFormContent:Te().func,afterFormContent:Te().func,onItemLoad:Te().func,isValid:Te().func,onChange:Te().func,onSubmit:Te().func,onSuccess:Te().func,history:Te().shape({push:Te().func.isRequired}).isRequired},yt.defaultProps={params:{},location:{},errors:void 0,fields:void 0,item:void 0,onItemLoad:void 0,isValid:void 0,onSuccess:void 0,onChange:void 0,loading:!1,beforeFormContent:void 0,afterFormContent:void 0,children:void 0,id:"",onSubmit:void 0,automationId:"",messages:{onUpdate:()=>{},onCreate:()=>{}},endpoint:void 0};const wt=(0,Ne.EN)(yt);var St=i(92348),Pt=i(2632);const Mt=[{name:"email",label:c.MailPoet.I18n.t("email"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"first_name",label:c.MailPoet.I18n.t("firstname"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"last_name",label:c.MailPoet.I18n.t("lastname"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"status",label:c.MailPoet.I18n.t("status"),type:"select",automationId:"subscriber-status",values:{subscribed:c.MailPoet.I18n.t("subscribed"),unconfirmed:c.MailPoet.I18n.t("unconfirmed"),unsubscribed:c.MailPoet.I18n.t("unsubscribed"),inactive:c.MailPoet.I18n.t("inactive"),bounced:c.MailPoet.I18n.t("bounced")}},{name:"segments",label:c.MailPoet.I18n.t("lists"),type:"selection",placeholder:c.MailPoet.I18n.t("selectList"),tip:c.MailPoet.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},getSearchLabel:function(e,t){let i="";return void 0!==t.subscriptions&&t.subscriptions.forEach((t=>{if(e.id===t.segment_id&&(i=e.name,"unsubscribed"===t.status)){const e=c.MailPoet.Date.format(t.updated_at);i+=" (%1$s)".replace("%1$s",c.MailPoet.I18n.t("unsubscribedOn").replace("%1$s",e))}})),i}},{name:"tags",label:c.MailPoet.I18n.t("tags"),type:"tokenField",placeholder:c.MailPoet.I18n.t("addNewTag"),suggestedValues:[],endpoint:"tags",getName:function(e){return Object.prototype.hasOwnProperty.call(e,"name")?e.name: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=c.MailPoet.I18n.t("year"),t.month_placeholder=c.MailPoet.I18n.t("month"),t.day_placeholder=c.MailPoet.I18n.t("day");break;case"select":t.placeholder="-";break;default:t.placeholder=""}Mt.push(t)}));const Nt={onUpdate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("subscriberUpdated"))},onCreate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("subscriberAdded")),c.MailPoet.trackEvent("Subscribers > Add new")}};function It(e){if(Number(e.wp_user_id)>0)return(0,u.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("WPUserEditNotice"),/\[link\](.*?)\[\/link\]/g,((t,i)=>(0,u.jsx)("a",{href:`user-edit.php?user_id=${e.wp_user_id}`,children:t},i)))})}function Ct(e){return(0,u.jsxs)(u.Fragment,{children:[e?.unsubscribes?.map((e=>{const t=Je()(e.createdAt.date).format("dddd MMMM Do YYYY [at] h:mm:ss a");let i;return i="admin"===e.source?c.MailPoet.I18n.t("unsubscribedAdmin").replace("%1$d",t).replace("%2$d",e.meta):"manage"===e.source?c.MailPoet.I18n.t("unsubscribedManage").replace("%1$d",t):"newsletter"===e.source?f()(c.MailPoet.I18n.t("unsubscribedNewsletter").replace("%1$d",t),/\[link\]/g,((t,i)=>(0,u.jsx)("a",{href:`admin.php?page=mailpoet-newsletter-editor&id=${e.newsletterId}`,children:e.newsletterSubject},i))):"mp_api"===e.source?c.MailPoet.I18n.t("unsubscribedMpApi").replace("%1$d",t):c.MailPoet.I18n.t("unsubscribedUnknown").replace("%1$d",t),(0,u.jsx)("p",{className:"description",children:i},i)})),(0,u.jsxs)("p",{className:"description",children:[(0,u.jsx)("strong",{children:c.MailPoet.I18n.t("tip")})," ",c.MailPoet.I18n.t("customFieldsTip")]})]})}function kt(e){let{match:t}=e;const i=(0,Ne.TH)(),a=(0,Ne.k6)(),s=i.state?.backUrl||"/";return(0,u.jsxs)("div",{className:"mailpoet-main-container",children:[(0,u.jsx)(d.Q,{}),(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(St.B,{}),(0,u.jsx)(Pt.m,{heading:c.MailPoet.I18n.t("subscriber"),headingPrefix:(0,u.jsx)(Pt.x,{onClick:()=>a.push(s),label:c.MailPoet.I18n.t("backToList")})}),(0,u.jsx)(b,{}),(0,u.jsx)(wt,{automationId:"subscriber_edit_form",endpoint:"subscribers",fields:Mt,params:t.params,messages:Nt,beforeFormContent:It,afterFormContent:Ct,onSuccess:()=>a.push(s)})]})}kt.propTypes={match:Te().shape({params:Te().shape({id:Te().string}).isRequired}).isRequired},kt.displayName="SubscriberForm";var Tt=i(9515);function Et(e){let{email:t}=e;const i=(0,Ne.TH)(),a=i.state?.backUrl||"/";return(0,u.jsxs)(bt.X,{level:1,className:"mailpoet-title",children:[(0,u.jsx)("span",{children:c.MailPoet.I18n.t("statsHeading").replace("%s",t)}),(0,u.jsx)(Me.Link,{className:"mailpoet-button button button-secondary button-small",to:a,children:c.MailPoet.I18n.t("backToList")})]})}var At=i(74702);function Rt(e){let{stats:t,subscriber:i}=e;return(0,u.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,u.jsx)("div",{className:"mailpoet-listing",children:(0,u.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{}),t.periodic_stats.map((e=>(0,u.jsx)("td",{children:e.timeframe},e.timeframe)))]})}),(0,u.jsxs)("tbody",{children:[(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:c.MailPoet.I18n.t("statsSentEmail")}),t.periodic_stats.map((e=>(0,u.jsx)("td",{children:e.total_sent},e.timeframe)))]}),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:(0,u.jsx)(At.V,{children:c.MailPoet.I18n.t("statsOpened")})}),t.periodic_stats.map((e=>{const t=e.total_sent>0;let i=e.open.toLocaleString();return t&&(i+=` (${Math.round(e.open/e.total_sent*100)}%)`),(0,u.jsx)("td",{children:i},e.timeframe)}))]}),(0,u.jsxs)("tr",{children:[(0,u.jsxs)("td",{children:[(0,u.jsx)(At.V,{children:c.MailPoet.I18n.t("statsMachineOpened")}),(0,u.jsx)(De.Tooltip,{tooltip:f()(c.MailPoet.I18n.t("statsMachineOpenedTooltip"),/\[link](.*?)\[\/link]/,(e=>(0,u.jsx)("span",{style:{pointerEvents:"all"},children:(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/368-what-are-machine-opens",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")},"machine-opened-info")))})]}),t.periodic_stats.map((e=>{const t=e.total_sent>0;let i=e.machine_open.toLocaleString();return t&&(i+=` (${Math.round(e.machine_open/e.total_sent*100)}%)`),(0,u.jsx)("td",{children:i},e.timeframe)}))]}),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:(0,u.jsx)(At.V,{isInverted:!0,children:c.MailPoet.I18n.t("statsClicked")})}),t.periodic_stats.map((e=>{const t=e.total_sent>0;let i=e.click.toLocaleString();return t&&(i+=` (${Math.round(e.click/e.total_sent*100)}%)`),(0,u.jsx)("td",{children:i},e.timeframe)}))]}),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:c.MailPoet.I18n.t("statsNotClicked")}),t.periodic_stats.map((e=>{const t=e.total_sent-(e.open+e.machine_open),i=e.total_sent>0;let a=t.toLocaleString();return i&&(a+=` (${Math.round(t/e.total_sent*100)}%)`),(0,u.jsx)("td",{children:a},e.timeframe)}))]}),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:c.MailPoet.I18n.t("statisticsColumn")}),(0,u.jsx)("td",{colSpan:t.periodic_stats.length,children:(0,u.jsx)("div",{className:"mailpoet-listing-stats",children:(0,u.jsx)(_e,{id:i.id,engagementScore:i.engagement_score})})})]})]})]})})})}function Ft(e){let{stats:t}=e;return(0,u.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,u.jsx)("div",{className:"mailpoet-listing",children:(0,u.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{}),t.periodic_stats.map((e=>(0,u.jsx)("td",{children:e.timeframe},e.timeframe)))]})}),(0,u.jsxs)("tbody",{children:[(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:"Orders created"}),t.periodic_stats.map((e=>(0,u.jsx)("td",{children:e.woocommerce.count.toLocaleString()},e.timeframe)))]}),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:"Total revenue"}),t.periodic_stats.map((e=>(0,u.jsx)("td",{children:e.woocommerce.formatted},e.timeframe)))]}),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:"Average revenue"}),t.periodic_stats.map((e=>(0,u.jsx)("td",{children:e.woocommerce.formatted_average},e.timeframe)))]})]})]})})})}var Ot=i(84209),Lt=i(83825);function Dt(e){let{limitReached:t,limitValue:i,subscribersCountTowardsLimit:a,premiumActive:s,hasValidApiKey:n,hasPremiumSupport:o}=e;return(0,u.jsxs)("table",{className:"mailpoet-listing-table","data-automation-id":"subscriber-stats-no-access",children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:c.MailPoet.I18n.t("email")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("columnAction")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("columnCount")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("columnActionOn")})]})}),(0,u.jsx)("tbody",{children:(0,u.jsx)("tr",{children:(0,u.jsx)("td",{colSpan:4,children:(0,u.jsx)("div",{className:"mailpoet-subscriber-stats-no-access-content",children:(0,u.jsx)(Lt.K,{title:s&&t?c.MailPoet.I18n.t("upgradeRequired"):c.MailPoet.I18n.t("premiumFeature"),message:(()=>{let e=c.MailPoet.I18n.t("premiumRequired");return s?(e=o?c.MailPoet.I18n.t("planLimitReached"):c.MailPoet.I18n.t("freeLimitReached"),(0,u.jsx)("p",{children:f()(e,/(\[subscribersCount]|\[subscribersLimit])/g,(e=>"[subscribersCount]"===e?a:i))})):(0,u.jsx)("p",{children:f()(e,/\[link](.*?)\[\/link]/g,(e=>(0,u.jsx)("a",{href:c.MailPoet.premiumLink,children:e},e)))})})(),actionButton:s&&t?(0,u.jsx)(Oe.z,{href:n?c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl():c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(a+1),children:c.MailPoet.I18n.t("premiumBannerCtaUpgrade")}):(0,u.jsx)(Oe.z,{href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,null,{utm_medium:"stats",utm_campaign:"signup"}),children:c.MailPoet.I18n.t("premiumBannerCtaFree")})})})})})})]})}function qt(e){let{params:t,location:i}=e;const a=(0,o.useMemo)((()=>Ot.Hooks.applyFilters("mailpoet_subscribers_opened_emails_stats",(()=>(0,u.jsx)(Dt,{limitReached:c.MailPoet.subscribersLimitReached,limitValue:c.MailPoet.subscribersLimit,subscribersCountTowardsLimit:c.MailPoet.subscribersCount,premiumActive:c.MailPoet.premiumActive,hasValidApiKey:c.MailPoet.hasValidApiKey,hasPremiumSupport:c.MailPoet.hasPremiumSupport})),t,i)),[i,t]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:4,children:c.MailPoet.I18n.t("openedEmailsHeading")}),(0,u.jsx)(a,{})]})}function $t(e){return"string"==typeof e?c.MailPoet.Date.format(e):(0,Fe.__)("never","mailpoet")}function Bt(e){let{stats:t}=e;const i=[{label:(0,Fe.__)("Last click","mailpoet"),date:t.last_click||null},{label:(0,Fe.__)("Last engagement","mailpoet"),date:t.last_engagement||null},{label:(0,Fe.__)("Last open","mailpoet"),date:t.last_open||null},{label:(0,Fe.__)("Last page view","mailpoet"),date:t.last_page_view||null},{label:(0,Fe.__)("Last sending","mailpoet"),date:t.last_sending||null}];return t.is_woo_active&&i.push({label:(0,Fe.__)("Last purchase","mailpoet"),date:t.last_purchase||null}),i.sort(((e,t)=>e.date===t.date?0:e.date?t.date?t.date.localeCompare(e.date):-1:1)),(0,u.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,u.jsx)("div",{className:"mailpoet-listing",children:(0,u.jsx)("table",{className:"mailpoet-listing-table",children:(0,u.jsx)("tbody",{children:i.map((e=>{let{label:t,date:i}=e;return(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:t}),(0,u.jsx)("td",{children:(0,u.jsx)("b",{children:$t(i)})})]},t)}))})})})})}function Wt(){const e=(0,Ne.$B)(),t=(0,Ne.TH)(),[i,a]=(0,o.useState)(null),[s,n]=(0,o.useState)(!0),r=(0,l.S)(window).notices.error;return(0,o.useEffect)((()=>{c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"subscriberStats",action:"get",data:{subscriber_id:e.params.id}}).done((e=>{a(e.data),n(!1)})).fail((e=>{n(!1),e.errors.length>0&&r((0,u.jsx)(u.Fragment,{children:e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message)))}),{scroll:!0})}))}),[e.params.id,r]),s?(0,u.jsx)(Tt.g,{}):(0,u.jsxs)("div",{className:"mailpoet-subscriber-stats",children:[(0,u.jsx)(Et,{email:i.email}),(0,u.jsxs)("div",{className:"mailpoet-subscriber-stats-summary-grid",children:[(0,u.jsx)(Rt,{stats:i,subscriber:{id:Number(e.params.id),engagement_score:i.engagement_score}}),(0,u.jsx)(Bt,{stats:i}),i.is_woo_active&&(0,u.jsx)(Ft,{stats:i})]}),(0,u.jsx)(qt,{params:e.params,location:t})]})}function Vt(){return(0,u.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(m.w,{}),(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{path:"/new",render:(0,r.withBoundary)(kt)}),(0,u.jsx)(Ne.AW,{path:"/edit/:id",render:(0,r.withBoundary)(kt)}),(0,u.jsx)(Ne.AW,{path:"/stats/:id/(.*)?",component:(0,r.withBoundary)(Wt)}),(0,u.jsx)(Ne.AW,{path:"*",component:(0,r.withBoundary)(Qe)})]})]})})}Wt.displayName="SubscriberStats";const Ut=document.getElementById("subscribers_container");Ut&&((0,r.registerTranslations)(),(0,n.s)(Ut).render((0,u.jsx)(Vt,{})));var zt=i(83665),Ht=i(26041),Zt=i(49156),Yt=i(60080),Gt=i(85180),Kt=i(96328),Qt=i(93399);class Xt extends o.PureComponent{render(){const e=this.props.event,t=e.soon;let i;if(this.props.premium)i=(0,u.jsx)("a",{href:"?page=mailpoet-premium",target:"_blank",children:(0,Fe.__)("This is a Premium feature","mailpoet")});else if(e.actionButtonLink&&e.actionButtonTitle)i=(0,u.jsx)("a",{href:e.actionButtonLink,target:"_blank",rel:"noopener noreferrer",children:e.actionButtonTitle});else{const a=t?null:rt.default.partial(this.props.eventsConfigurator,e.slug);i=(0,u.jsx)(Oe.z,{disabled:t,onClick:a,role:"presentation",automationId:`create_${e.slug}`,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),a())},children:e.actionButtonTitle||(0,Fe.__)("Set up","mailpoet")})}return(0,u.jsxs)("div",{"data-type":e.slug,className:"mailpoet-newsletter-type",children:[(0,u.jsx)("div",{className:"mailpoet-newsletter-type-image",children:e.badge&&(0,u.jsx)(Qt.C,{title:e.badge.text})}),(0,u.jsxs)("div",{className:"mailpoet-newsletter-type-content",children:[(0,u.jsxs)(bt.X,{level:4,children:[e.title," ",e.soon&&`(${(0,Fe.__)("Soon","mailpoet")})`]}),(0,u.jsx)("p",{children:e.description}),(0,u.jsx)("div",{className:"mailpoet-flex-grow"}),(0,u.jsx)("div",{className:"mailpoet-newsletter-type-action",children:i})]})]})}}Xt.defaultProps={premium:!1},Xt.propTypes={premium:Te().bool,eventsConfigurator:Te().func.isRequired,event:Te().shape({slug:Te().string.isRequired,actionButtonLink:Te().string,title:Te().string.isRequired,soon:Te().bool,badge:Te().shape({style:Te().string,text:Te().string}),description:Te().string.isRequired,actionButtonTitle:Te().string}).isRequired};class Jt extends o.Component{constructor(e){super(e),this.email=this.props.email,this.emailEvents=this.email.events,this.eventsConfigurator=this.eventsConfigurator.bind(this)}eventsConfigurator(e){c.MailPoet.trackEvent("Emails > Automatic Type selected",{"Email type":e}),this.props.history.push(`/new/${this.email.slug}/${e}/conditions`)}render(){return rt.default.map(this.emailEvents,((e,t)=>(0,u.jsx)(Xt,{premium:this.email.premium,event:e,eventsConfigurator:this.eventsConfigurator},t)))}}Jt.propTypes={email:Te().shape({title:Te().string.isRequired,slug:Te().string.isRequired,premium:Te().bool}).isRequired,history:Te().shape({push:Te().func.isRequired}).isRequired};const ei=(0,Ne.EN)(Jt),ti={woocommerce:(0,u.jsxs)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 120 71",style:{enableBackground:"new 0 0 120 71"},children:[(0,u.jsx)("path",{fill:"#9ca6cc",d:"M11.4,0.7h97.1c6.1,0,11.1,4.9,11.1,11v36.7c0,6.1-5,11-11.1,11H73.7L78.5,71l-21-11.6h-46 c-6.1,0-11.1-4.9-11.1-11V11.7C0.3,5.7,5.3,0.7,11.4,0.7z"}),(0,u.jsx)("path",{fill:"#fff",d:"M7.2,10.7c0.7-0.9,1.7-1.4,3.1-1.5c2.5-0.2,3.9,1,4.2,3.5c1.5,10,3.2,18.5,4.9,25.5l10.6-20 c1-1.8,2.2-2.8,3.6-2.9c2.1-0.1,3.4,1.2,4,4c1.2,6.4,2.8,11.8,4.6,16.4c1.3-12.2,3.4-21,6.4-26.4c0.7-1.3,1.8-2,3.2-2.1 c1.1-0.1,2.1,0.2,3.1,1c0.9,0.7,1.4,1.6,1.5,2.7c0,0.9-0.1,1.6-0.5,2.3c-1.9,3.5-3.4,9.3-4.7,17.3c-1.2,7.8-1.6,13.9-1.4,18.3 c0.1,1.2-0.1,2.3-0.6,3.2c-0.6,1.1-1.5,1.6-2.6,1.7c-1.3,0.1-2.6-0.5-3.8-1.8c-4.5-4.6-8.1-11.4-10.7-20.5c-3.2,6.1-5.5,10.8-7,13.8 c-2.9,5.4-5.3,8.2-7.3,8.4c-1.3,0.1-2.4-1-3.4-3.3C11.9,44.1,9.3,32,6.4,14C6.2,12.7,6.5,11.6,7.2,10.7z M111.3,18.3 c-1.7-3-4.3-4.9-7.8-5.6c-0.9-0.2-1.8-0.3-2.6-0.3c-4.7,0-8.4,2.4-11.4,7.2c-2.5,4.1-3.8,8.6-3.8,13.5c0,3.7,0.8,6.9,2.3,9.5 c1.7,3,4.3,4.9,7.8,5.6c0.9,0.2,1.8,0.3,2.6,0.3c4.7,0,8.5-2.4,11.4-7.2c2.5-4.1,3.8-8.6,3.8-13.6C113.7,24,112.9,20.9,111.3,18.3z M105.2,31.6c-0.7,3.2-1.9,5.5-3.7,7.1c-1.4,1.2-2.7,1.8-3.9,1.5c-1.2-0.2-2.1-1.2-2.9-3.1c-0.6-1.5-0.9-3-0.9-4.4 c0-1.2,0.1-2.4,0.3-3.5c0.4-2,1.3-3.9,2.6-5.7c1.6-2.4,3.3-3.3,5-3c1.2,0.2,2.1,1.2,2.9,3.1c0.6,1.5,0.9,3,0.9,4.4 C105.6,29.3,105.5,30.5,105.2,31.6z M81,18.3c-1.7-3-4.4-4.9-7.8-5.6c-0.9-0.2-1.8-0.3-2.6-0.3c-4.7,0-8.4,2.4-11.4,7.2 c-2.5,4.1-3.8,8.6-3.8,13.5c0,3.7,0.8,6.9,2.3,9.5c1.7,3,4.3,4.9,7.8,5.6c0.9,0.2,1.8,0.3,2.6,0.3c4.7,0,8.5-2.4,11.4-7.2 c2.5-4.1,3.8-8.6,3.8-13.6C83.3,24,82.5,20.9,81,18.3z M74.8,31.6c-0.7,3.2-1.9,5.5-3.7,7.1c-1.4,1.2-2.7,1.8-3.9,1.5 c-1.2-0.2-2.1-1.2-2.9-3.1c-0.6-1.5-0.9-3-0.9-4.4c0-1.2,0.1-2.4,0.3-3.5c0.4-2,1.3-3.9,2.6-5.7c1.6-2.4,3.3-3.3,5-3 c1.2,0.2,2.1,1.2,2.9,3.1c0.6,1.5,0.9,3,0.9,4.4C75.2,29.3,75.1,30.5,74.8,31.6z"})]})};var ii=i(3243),ai=i(63062);function si(e){let{isModalOpen:t,onClose:i}=e;return t?(0,u.jsxs)(ai.Z,{title:(0,Fe.__)("New editor","mailpoet"),onRequestClose:i,className:"mailpoet-new-editor-modal",children:[(0,u.jsxs)("div",{className:"mailpoet-new-editor-modal-image",children:[(0,u.jsx)("span",{className:"mailpoet-new-editor-modal-image__beta_label",children:(0,Fe.__)("Beta version","mailpoet")}),(0,u.jsx)("img",{src:`${c.MailPoet.cdnUrl}email-editor/new-editor-modal-header.png`,alt:(0,Fe.__)("New editor","mailpoet")})]}),(0,u.jsx)("p",{children:(0,Fe.__)("Create modern, beautiful emails that embody your brand with advanced customization and editing capabilities.","mailpoet")}),(0,u.jsx)("p",{className:"mailpoet-new-editor-modal-note",children:(0,Fe.__)("Emails created in the new editor cannot be reverted to the legacy version.","mailpoet")}),(0,u.jsxs)("div",{className:"mailpoet-new-editor-modal-footer",children:[(0,u.jsx)(pe.ZP,{type:"button",variant:"tertiary",onClick:()=>{i()},children:(0,Fe.__)("Cancel","mailpoet")}),(0,u.jsx)(pe.ZP,{type:"button",variant:"primary",onClick:()=>{window.location.href="admin.php?page=mailpoet-email-editor"},children:(0,Fe.__)("Continue","mailpoet")})]})]}):null}function ni(e){let{errors:t}=e;return t.length<1?null:(0,u.jsx)(p.q,{type:"error",closable:!1,children:t.map((e=>(0,u.jsx)("p",{children:e.message},e.message)))})}var oi=i(96300);function ri(e){let{filter:t,history:i,hideClosingButton:a=!1,hideScreenOptions:s=!0}=e;const[n,r]=(0,o.useState)(!1),[l,d]=(0,o.useState)(!1),m=c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor"),p=e=>{void 0!==e&&(i.push(`/new/${e}`),c.MailPoet.trackEvent("Emails > Type selected",{"Email type":e}))},h=async()=>{c.MailPoet.trackEvent("Emails > Type selected",{"Email type":"wc_transactional"});let e=window.mailpoet_woocommerce_transactional_email_id;if(!e)try{e=(await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"settings",action:"set",data:{"woocommerce.use_mailpoet_editor":1}})).data.woocommerce.transactional_email_id,c.MailPoet.trackEvent("Emails > WooCommerce email customizer enabled")}catch(e){return(0,oi.q)(e)&&e.errors.length>0?(0,u.jsx)(ni,{errors:e.errors}):null}return window.location.href=`?page=mailpoet-newsletter-editor&id=${e}`,null},g=e=>{const t=!0===window.mailpoet_is_new_user?"mailpoet_badge mailpoet_badge_video":"mailpoet_badge mailpoet_badge_video mailpoet_badge_video_grey";return(0,u.jsxs)("div",{"data-type":e.slug,className:"mailpoet-newsletter-type",children:[(0,u.jsx)("div",{className:"mailpoet-newsletter-type-image"}),(0,u.jsxs)("div",{className:"mailpoet-newsletter-type-content",children:[(0,u.jsxs)(bt.X,{level:4,children:[e.title," ",e.beta?`(${(0,Fe.__)("Beta","mailpoet")})`:""]}),(0,u.jsx)("p",{children:e.description}),e.videoGuide&&(0,u.jsxs)("a",{className:t,href:e.videoGuide,target:"_blank",rel:"noopener noreferrer",children:[(0,u.jsx)("span",{className:"dashicons dashicons-format-video"}),(0,Fe.__)("See video guide","mailpoet")]}),e.kbLink&&(0,u.jsx)("a",{href:e.kbLink,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Read more.","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-flex-grow"}),(0,u.jsx)("div",{className:"mailpoet-newsletter-type-action",children:e.action})]})]},e.slug)},_=()=>{if(!c.MailPoet.isWoocommerceActive)return[];const e=[{slug:"wc_transactional",title:(0,Fe.__)("WooCommerce Emails Customizer","mailpoet"),description:(0,Fe.__)("Customize the template used for your WooCommerce emails using MailPoet's editor. Example of WooCommerce email: Order processing notification, Order failed notification, ...","mailpoet"),action:(0,u.jsx)(Oe.z,{automationId:"customize_woocommerce",onClick:h,tabIndex:0,onKeyDown:async e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),await h())},children:(0,Fe.__)("Customize","mailpoet")})}];return c.MailPoet.hideAutomations&&e.push((()=>{const e=()=>{c.MailPoet.trackEvent("Emails > Type selected",{"Email type":"woocommerce_automatewoo"},{send_immediately:!0},(()=>{window.location.href="edit.php?post_type=aw_workflow#presets"}))};return{slug:"woocommerce_automatewoo",title:(0,Fe.__)("Automations","mailpoet"),description:(0,Fe.__)("Convert and retain customers with automated marketing that does the hard work for you. AutomateWoo has the tools you need to grow your store and make more money.","mailpoet"),kbLink:"https://kb.mailpoet.com/article/408-integration-with-automatewoo",action:(0,u.jsx)(Oe.z,{automationId:"woocommerce_automatewoo",onClick:e,tabIndex:0,onKeyDown:t=>{["keydown","keypress"].includes(t.type)&&["Enter"," "].includes(t.key)&&(t.preventDefault(),e())},children:(0,Fe.__)("Set up","mailpoet")})}})()),e},f=rt.default.partial((e=>{r(!0),c.MailPoet.trackEvent("Emails > Type selected",{"Email type":e}),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"newsletters",action:"create",data:{type:e,subject:(0,Fe.__)("Subject","mailpoet")}}).done((e=>{i.push(`/template/${e.data.id}`)})).fail((e=>(r(!1),e.errors.length>0?(0,u.jsx)(ni,{errors:e.errors}):null)))}),"standard"),b=rt.default.partial(p,"notification"),x=rt.default.partial(p,"welcome"),v=rt.default.partial(p,"re-engagement"),j=m?(0,u.jsxs)(Ht.Z,{className:"mailpoet-dropdown-button-group",children:[(0,u.jsx)(Oe.z,{automationId:"create_standard",onClick:f,tabIndex:0,withSpinner:n,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),f())},children:(0,Fe.__)("Create","mailpoet")}),(0,u.jsx)(Zt.Z,{focusOnMount:!1,className:"mailpoet-dropdown-button",contentClassName:"mailpoet-dropdown-button-content",popoverProps:{placement:"bottom-end"},renderToggle:e=>{let{isOpen:t,onToggle:i}=e;return(0,u.jsx)(Oe.z,{className:"mailpoet-button-with-wordpress-icon",onClick:i,"aria-expanded":t,automationId:"create_standard_email_dropdown",children:(0,u.jsx)(Gt.Z,{icon:Kt.Z,size:24})})},renderContent:()=>(0,u.jsx)(Yt.Z,{variant:"tertiary",onClick:()=>d(!0),children:(0,Fe.__)("Create using new editor (Beta)","mailpoet")})})]}):(0,u.jsx)(Oe.z,{automationId:"create_standard",onClick:f,tabIndex:0,withSpinner:n,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),f())},children:(0,Fe.__)("Create","mailpoet")}),y=[{slug:"standard",title:(0,Fe.__)("Newsletter","mailpoet"),description:(0,Fe.__)("Send a newsletter with images, buttons, dividers, and social bookmarks. Or, just send a basic text email.","mailpoet"),action:j},{slug:"welcome",title:(0,Fe.__)("Welcome Email","mailpoet"),description:(0,Fe.__)("Automatically send an email (or series of emails) to new subscribers or WordPress users. Send a day, a week, or a month after they sign up.","mailpoet"),videoGuide:"https://kb.mailpoet.com/article/254-video-guide-to-welcome-emails",action:(0,u.jsx)(Oe.z,{onClick:x,automationId:"create_welcome",withSpinner:n,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),x())},tabIndex:0,children:(0,Fe.__)("Set up","mailpoet")})},{slug:"notification",title:(0,Fe.__)("Latest Post Notifications","mailpoet"),description:(0,Fe.__)("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,u.jsx)(Oe.z,{automationId:"create_notification",onClick:b,withSpinner:n,tabIndex:0,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),b())},children:(0,Fe.__)("Set up","mailpoet")})},{slug:"re_engagement",title:(0,Fe.__)("Re-engagement Emails","mailpoet"),description:(0,Fe.__)("Automatically email and win back subscribers who have recently lost interest and stopped engaging with your emails.","mailpoet"),action:(0,u.jsx)(Oe.z,{automationId:"create_notification",onClick:v,withSpinner:n,tabIndex:0,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),v())},children:(0,Fe.__)("Set up","mailpoet")})}];let w=Ot.Hooks.applyFilters("mailpoet_newsletters_types",[...y],this);t&&(w=w.filter(t));const S=c.MailPoet.Ajax.constructGetUrl({api_version:c.MailPoet.apiVersion,endpoint:"newsletterTemplates",action:"getAll"});return(0,u.jsxs)(u.Fragment,{children:[s&&(0,u.jsx)(St.B,{}),(0,u.jsx)("link",{rel:"prefetch",href:window.mailpoet_editor_javascript_url,as:"script"}),(0,u.jsxs)("div",{className:"mailpoet-newsletter-types",children:[!a&&(0,u.jsx)("div",{className:"mailpoet-newsletter-types-close",children:(0,u.jsx)("button",{type:"button",onClick:()=>i.push("/"),className:"mailpoet-modal-close",children:ii.X})}),w.map((e=>g(e)),this),(()=>{if(!window.mailpoet_woocommerce_automatic_emails)return[];let e=window.mailpoet_woocommerce_automatic_emails;return t&&(e=rt.default.filter(e,t)),rt.default.map(e,(e=>{const a=e;return(0,u.jsxs)(o.Fragment,{children:[!t&&(0,u.jsxs)("div",{className:"mailpoet-newsletter-types-separator",children:[(0,u.jsx)("div",{className:"mailpoet-newsletter-types-separator-line"}),(0,u.jsx)("div",{className:"mailpoet-newsletter-types-separator-logo",children:ti[a.slug]||null}),(0,u.jsx)("div",{className:"mailpoet-newsletter-types-separator-line"})]}),"woocommerce"===a.slug&&!c.MailPoet.hideAutomations&&(0,u.jsx)(ei,{email:a,history:i}),"woocommerce"===a.slug&&_().map((e=>g(e)),this)]},a.slug)}))})()]}),(0,u.jsx)("link",{rel:"prefetch",href:S,as:"fetch"}),(0,u.jsx)(si,{onClose:()=>d(!1),isModalOpen:l})]})}ri.defaultProps={filter:null,hideScreenOptions:!0,hideClosingButton:!1};const li=(0,Ne.EN)(ri);var di=i(40292);function ci(e){let{newsletter:t,isSent:i,currentTime:a}=e,s=i;if(void 0===s&&(s=t.statistics&&t.queue&&"scheduled"!==t.queue.status),!s)return null;const n={link:`/stats/${t.id}`,onClick:Ot.Hooks.applyFilters("mailpoet_newsletters_listing_stats_tracking",zt.gP)},o=Number(t.total_sent||t.queue.count_processed);let l,d,c,m,p,h=0,g=0,_=null;o>0&&(h=100*t.statistics.clicked/o,g=100*t.statistics.opened/o,_=t.statistics.revenue),void 0!==a?(l=6,d=t.queue.scheduled_at||t.queue.created_at,c=Je()(a).diff(Je()(d),"hours"),m=c=20&&t.statistics.opened>=5&&!m,b=(e,i)=>((e,t,i,a)=>a<=0||!t.link?e:t.externalLink?(0,u.jsx)("a",{href:t.link,onClick:t.onClick||null,children:e},`stats-${i}`):(0,u.jsx)(Me.Link,{to:t.link,onClick:t.onClick||null,children:e},`stats-${i}`))(e,n,`${i}-${t.id}`,o),x=(0,u.jsx)(di.M,{opened:g,clicked:h,revenues:_&&_.value>0?_.formatted:null,hideBadges:!f,newsletterId:t.id,wrapContentInLink:b}),v=(0,u.jsxs)(u.Fragment,{children:[x,m&&b((0,u.jsx)(r.Tag,{className:"mailpoet-listing-stats-too-early",dimension:"large",variant:"excellent",isInverted:!0,children:(0,Fe.__)("Nice job! Check back in %1$d hour(s) for more stats.","mailpoet").replace("%1$d",l-c)}),"check-back")]});let j;return p&&g<5&&c>=24&&o>=10&&(j=(0,u.jsx)("div",{children:(0,u.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,Fe.__)("What can I do to improve this?","mailpoet")})})),(0,u.jsxs)(u.Fragment,{children:[v,j]})}const mi=Te().shape({clicked:Te().number,opened:Te().number,unsubscribed:Te().number,revenue:Te().shape({count:Te().number,currency:Te().string,formatted:Te().string,value:Te().number})}),pi=Te().shape({status:Te().string,count_processed:Te().string.isRequired,count_total:Te().string.isRequired,created_at:Te().string,scheduled_at:Te().string});ci.propTypes={newsletter:Te().shape({id:Te().number.isRequired,queue:Te().oneOfType([pi,Te().bool]),total_sent:Te().number,statistics:Te().oneOfType([mi,Te().bool])}).isRequired,isSent:Te().bool,currentTime:Te().string},ci.defaultProps={isSent:void 0,currentTime:void 0},ci.displayName="NewsletterStatistics";const ui=(0,r.withBoundary)(ci),hi=c.MailPoet.trackingConfig.emailTrackingEnabled,gi=window.mailpoet_woocommerce_automatic_emails||{},_i={onTrash:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was moved to the trash.","mailpoet"):(0,Fe.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was permanently deleted.","mailpoet"):(0,Fe.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email has been restored from the Trash.","mailpoet"):(0,Fe.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},fi=[{name:"subject",label:(0,Fe.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Fe.__)("Settings","mailpoet")},{name:"statistics",label:(0,Fe.__)("Clicked, Opened","mailpoet"),display:hi},{name:"status",label:(0,Fe.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,Fe.__)("Last modified on","mailpoet"),sortable:!0}],bi=[{name:"trash",label:(0,Fe.__)("Move to trash","mailpoet"),onSuccess:_i.onTrash}];let xi=[{name:"view",link:function(e){return(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Edit","mailpoet"),onClick:zt.Q2},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Duplicate","mailpoet"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Fe.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},{name:"trash",className:"mailpoet-hide-on-mobile"}];xi=(0,zt.y8)(xi);class vi extends o.Component{constructor(e){super(e),this.state={eventCounts:{},newslettersCount:void 0},this.afterGetItems=this.afterGetItems.bind(this)}updateStatus=(e,t)=>{t.persist(),c.MailPoet.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=>{if("active"===e.data.status){const e=t.target.getAttribute("data-group"),i=gi[e];c.MailPoet.Notice.success((0,Fe.__)("Your %1s Automatic Email is now activated!","mailpoet").replace("%1s",i.title))}this.forceUpdate()})).fail((i=>{c.MailPoet.Notice.showApiErrorNotice(i),t.target.checked=!e}))};renderStatus=e=>{const t=parseInt(e.total_sent,10)>-1?(0,Fe.__)("Sent to %1$d customers","mailpoet").replace("%1$d",e.total_sent.toLocaleString()):null;return(0,u.jsxs)("div",{children:[(0,u.jsx)(r.Toggle,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,"data-group":e.options.group,dimension:"small",defaultChecked:"active"===e.status}),(0,u.jsxs)("p",{className:"mailpoet-listing-notification-status",children:[t&&(0,u.jsx)(Me.Link,{to:`/sending-status/${e.id}`,children:t}),!t&&(0,u.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small",children:(0,Fe.__)("Not sent yet","mailpoet")})]})]})};renderSettings=e=>{const t=gi[e.options.group].events[e.options.event];let i;try{i=JSON.parse(e.options.meta||null)}catch(t){i=e.options.meta||null}const a=i&&i.option?rt.default.pluck(i.option,"name"):[];if(i&&rt.default.isEmpty(a))return(0,u.jsx)("span",{className:"mailpoet-listing-error",children:(0,Fe.__)("You need to configure email options before this email can be sent.","mailpoet")});let s,n;if(s=a.length>1&&"listingScheduleDisplayTextPlural"in t?f()(t.listingScheduleDisplayTextPlural,"%s",((e,t)=>(0,u.jsx)(r.StringTags,{strings:a},t))):f()(t.listingScheduleDisplayText,"%s",((e,t)=>(0,u.jsx)(r.StringTags,{strings:a},t))),s&&"immediate"!==e.options.afterTimeType)switch(e.options.afterTimeType){case"minutes":n=(0,Fe.__)("%1$d minute(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;case"hours":n=(0,Fe.__)("%1$d hour(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;case"days":n=(0,Fe.__)("%1$d day(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;case"weeks":n=(0,Fe.__)("%1$d week(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;default:n=(0,Fe.__)("Invalid sending delay.","mailpoet")}return(0,u.jsxs)("span",{children:[s,n&&(0,u.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,u.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,u.jsx)(r.ScheduledIcon,{})}),n]})]})};renderItem=(e,t)=>{const i=ee()("manage-column","column-primary","has-row-actions");return(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:i,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,zt.Q2)(e)},children:e.subject}),t]}),(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===hi?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Fe.__)("Clicked, Opened","mailpoet"),children:(0,u.jsx)(ui,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,u.jsx)("td",{className:"column","data-colname":(0,Fe.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Last modified on","mailpoet"),children:[c.MailPoet.Date.short(e.updated_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;afterGetItems(e){(0,zt._X)(e),this.countEmailTypes(e)}countEmailTypes(e){const t={woocommerce_product_purchased:0,woocommerce_product_purchased_in_category:0,woocommerce_first_purchase:0};if(Array.isArray(e.items)){const i=e.items.map((e=>e.options.event)).reduce(((e,t)=>(e[t]?e[t]+=1:e[t]=1,e)),t);this.setState({eventCounts:i})}}renderWarning(){const{eventCounts:e}=this.state;return e.woocommerce_product_purchased+e.woocommerce_product_purchased_in_category+e.woocommerce_first_purchase?"1"===window.mailpoet_woocommerce_optin_on_checkout?null:(0,u.jsxs)("div",{className:"notice error",children:[(0,u.jsx)("p",{children:(0,Fe.__)("WooCommerce emails won’t be sent to new customers because the opt-in on checkout is disabled. Enable it so they can immediately get your emails after their first purchase.","mailpoet")}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{href:"?page=mailpoet-settings#woocommerce",children:(0,Fe.__)("Edit WooCommerce settings","mailpoet")})})]}):null}render(){const{match:e,location:t}=this.props;return(0,u.jsxs)(u.Fragment,{children:[this.renderWarning(),0===this.state.newslettersCount&&(0,u.jsx)(li,{filter:e=>"woocommerce"===e.slug,hideScreenOptions:!1,hideClosingButton:!0}),0!==this.state.newslettersCount&&(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:t,params:e.params,endpoint:"newsletters",type:"automatic",base_url:"woocommerce",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:fi,bulk_actions:bi,item_actions:xi,messages:_i,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})}this.afterGetItems(e)}})]})}}vi.propTypes={match:Te().shape({params:Te().shape({tab:Te().string}).isRequired}).isRequired,location:Te().object.isRequired},vi.displayName="ListingsComponent";const ji=(0,Ne.EN)((0,r.withBoundary)(vi));var yi=i(23525),wi=i(11103);const Si=(0,Ne.EN)((e=>(0,u.jsx)(wi.b,{...e})));var Pi=i(26050),Mi=i(16424);class Ni extends o.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:i,afterDelete:a}=this.props;(0,Mi._)({message:(0,Fe.__)('You are about to delete the template named "%1$s".',"mailpoet").replace("%1$s",t),onConfirm:()=>{i(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"delete",data:{id:e}}).done((()=>{a(!0,e)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0}),a(!1)}))}})}onPreview(){c.MailPoet.Modal.popup({title:this.props.name,template:'',data:this.props})}onSelect(){const{newsletterId:e,name:t,beforeSelect:i,afterSelect:a}=this.props;i(),c.MailPoet.trackEvent("Emails > Template selected",{"Email name":t}),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:{id:e,template_id:this.props.id}}).done((e=>{a(!0,e.data.id)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0}),a(!1)}))}render(){const{index:e,name:t,thumbnail:i,readonly:a}=this.props;let s="";return"string"==typeof i&&i.length>0&&(s=(0,u.jsxs)("a",{className:"mailpoet-template-preview",href:"#",onClick:e=>{e.preventDefault(),this.onPreview(e)},children:[(0,u.jsx)("div",{className:"mailpoet-template-thumbnail",children:i?(0,u.jsx)("img",{src:i,alt:(0,Fe.__)("Template preview","mailpoet"),loading:"lazy"}):""}),(0,u.jsx)("div",{className:"mailpoet-template-preview-overlay",children:(0,u.jsx)(Oe.z,{children:(0,Fe.__)("Preview","mailpoet")})})]})),(0,u.jsx)(Pi.G,{label:t,onSelect:this.onSelect,onDelete:!1===a?this.onDelete:void 0,automationId:`select_template_${e}`,className:"mailpoet-template-two-lines",children:s})}}Ni.contextType=l.k,Ni.propTypes={index:Te().number.isRequired,id:Te().number.isRequired,newsletterId:Te().string.isRequired,name:Te().string.isRequired,thumbnail:Te().string,readonly:Te().bool.isRequired,beforeDelete:Te().func.isRequired,afterDelete:Te().func.isRequired,beforeSelect:Te().func.isRequired,afterSelect:Te().func.isRequired},Ni.defaultProps={thumbnail:null},Ni.displayName="TemplateBox";class Ii extends o.Component{constructor(e){super(e),this.fileRef=(0,o.createRef)(),this.handleSubmit=this.handleSubmit.bind(this)}handleSubmit(e){if(e.preventDefault(),rt.default.size(this.fileRef.current.files)<=0)return!1;const t=rt.default.first(this.fileRef.current.files),i=new FileReader;return i.onload=e=>{try{this.saveTemplate(JSON.parse(e.target.result)),c.MailPoet.trackEvent("Emails > Template imported")}catch(e){this.context.notices.error((0,u.jsx)("p",{children:(0,Fe.__)("This template file appears to be damaged. Please try another one.","mailpoet")}))}},i.readAsText(t),!0}saveTemplate(e){const t=e,{beforeImport:i,afterImport:a}=this.props;rt.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),i(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"save",data:t}).done((e=>{a(!0,e.data)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0}),a(!1)}))}render(){return(0,u.jsxs)("div",{className:"mailpoet-template-import",children:[(0,u.jsxs)("h4",{children:[(0,Fe.__)("Import a template","mailpoet"),(0,u.jsx)(De.Tooltip,{tooltip:(0,Fe.__)("You can only upload .json templates that were originally created with MailPoet.","mailpoet"),place:"right",className:"tooltip-help-import-template"})]}),(0,u.jsxs)("form",{onSubmit:this.handleSubmit,children:[(0,u.jsx)("input",{type:"file",placeholder:(0,Fe.__)("Select a .json file to upload","mailpoet"),ref:this.fileRef}),(0,u.jsx)("p",{className:"submit",children:(0,u.jsx)("input",{className:"button button-primary",type:"submit",value:(0,Fe.__)("Upload","mailpoet")})})]})]})}}Ii.contextType=l.k,Ii.propTypes={beforeImport:Te().func.isRequired,afterImport:Te().func.isRequired};const Ci=[];window.mailpoet_newsletters_templates_recently_sent_count&&Ci.push({name:"recent",label:(0,Fe.__)("Recently sent","mailpoet")}),Ci.push({name:"standard",label:(0,Fe.__)("Newsletters","mailpoet")},{name:"welcome",label:(0,Fe.__)("Welcome Emails","mailpoet")},{name:"notification",label:(0,Fe.__)("Post Notifications","mailpoet")},{name:"re_engagement",label:(0,Fe.__)("Re-engagement Emails","mailpoet")},{name:"blank",label:(0,Fe.__)("Simple text","mailpoet")}),window.mailpoet_woocommerce_active&&Ci.push({name:"woocommerce",label:(0,Fe.__)("WooCommerce Emails","mailpoet")}),Ci.push({name:"saved",label:(0,Fe.__)("Your saved templates","mailpoet")});class ki extends o.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(){c.MailPoet.Ajax.get({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"getAll"}).done((e=>{0===e.data.length&&(e.data=[{name:(0,Fe.__)("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.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0})})).always((()=>{this.selectInitialTab()}))}addTemplate(e){const t=Ci.map((e=>e.name));let i;-1===t.indexOf("woocommerce")&&t.push("woocommerce");try{i=JSON.parse(e.categories).filter((e=>-1!==t.indexOf(e)))}catch(e){i=[]}0===i.length&&i.push("saved"),i.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(((i,a)=>{if(e.includes(t)){if(i.categories.includes('"blank"')&&!a.categories.includes('"blank"'))return-1;if(!i.categories.includes('"blank"')&&a.categories.includes('"blank"'))return 1}return i.id{e=a.data.type,t=a.data.options,"automatic"===e&&(e=a.data.options.group||e),window.mailpoet_newsletters_templates_recently_sent_count?i="recent":rt.default.findWhere(Ci,{name:a.data.type})?i=a.data.type:"automatic"===a.data.type&&rt.default.findWhere(Ci,{name:a.data.options.group})&&(i=a.data.options.group)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0})})).always((()=>{this.setState({templates:this.templates,emailType:e,emailOptions:t,selectedTab:i,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"),i=`admin.php?page=mailpoet-newsletter-editor&id=${e}`;return t?`${i}&context=${t}`:i})(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,u.jsx)(Tt.g,{});const e=Ci.concat({name:"import",label:(0,Fe._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,u.jsx)(Ii,{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,u.jsx)("p",{children:(0,Fe.__)("This category does not contain any template yet!","mailpoet")}):e.map(((e,t)=>(0,u.jsx)(Ni,{index:t,newsletterId:this.props.match.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 i,a=null;if("automation"===this.state.emailType){const e=this.state.emailOptions?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"admin.php?page=mailpoet-automation";i=()=>{window.location=t},a=(0,u.jsx)("input",{type:"button",className:"button link-button",onClick:i,value:"Cancel"})}return(0,u.jsxs)("div",{children:[(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(Si,{emailType:this.state.emailType,automationId:"email_template_selection_heading",buttons:a,onLogoClick:i}),(0,u.jsxs)("div",{className:"mailpoet-templates",children:[(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(yi.R,{categories:e,active:this.state.selectedTab,onSelect:e=>this.setState({selectedTab:e})})}),(0,u.jsx)(r.ErrorBoundary,{children:t})]})]})}}ki.contextType=l.k,ki.propTypes={match:Te().shape({params:Te().shape({id:Te().string}).isRequired}).isRequired},ki.display="NewsletterTemplates";var Ti=i(61888),Ei=i.n(Ti),Ai=i(5837),Ri=i.n(Ai),Fi=i(15133),Oi=i(61515),Li=i(93676),Di=i(28270),qi=i.n(Di),$i=i(40612);const Bi={abbreviated:[(0,Fe.__)("Jan","mailpoet"),(0,Fe.__)("Feb","mailpoet"),(0,Fe.__)("Mar","mailpoet"),(0,Fe.__)("Apr","mailpoet"),(0,Fe.__)("May","mailpoet"),(0,Fe.__)("Jun","mailpoet"),(0,Fe.__)("Jul","mailpoet"),(0,Fe.__)("Aug","mailpoet"),(0,Fe.__)("Sep","mailpoet"),(0,Fe.__)("Oct","mailpoet"),(0,Fe.__)("Nov","mailpoet"),(0,Fe.__)("Dec","mailpoet")],wide:[(0,Fe.__)("January","mailpoet"),(0,Fe.__)("February","mailpoet"),(0,Fe.__)("March","mailpoet"),(0,Fe.__)("April","mailpoet"),(0,Fe.__)("May","mailpoet"),(0,Fe.__)("June","mailpoet"),(0,Fe.__)("July","mailpoet"),(0,Fe.__)("August","mailpoet"),(0,Fe.__)("September","mailpoet"),(0,Fe.__)("October","mailpoet"),(0,Fe.__)("November","mailpoet"),(0,Fe.__)("December","mailpoet")]},Wi={narrow:[(0,Fe._x)("S","Sunday - one letter abbreviation","mailpoet"),(0,Fe._x)("M","Monday - one letter abbreviation","mailpoet"),(0,Fe._x)("T","Tuesday - one letter abbreviation","mailpoet"),(0,Fe._x)("W","Wednesday - one letter abbreviation","mailpoet"),(0,Fe._x)("T","Thursday - one letter abbreviation","mailpoet"),(0,Fe._x)("F","Friday - one letter abbreviation","mailpoet"),(0,Fe._x)("S","Saturday - one letter abbreviation","mailpoet")],abbreviated:[(0,Fe.__)("Sun","mailpoet"),(0,Fe.__)("Mon","mailpoet"),(0,Fe.__)("Tue","mailpoet"),(0,Fe.__)("Wed","mailpoet"),(0,Fe.__)("Thu","mailpoet"),(0,Fe.__)("Fri","mailpoet"),(0,Fe.__)("Sat","mailpoet")],wide:[(0,Fe.__)("Sunday","mailpoet"),(0,Fe.__)("Monday","mailpoet"),(0,Fe.__)("Tuesday","mailpoet"),(0,Fe.__)("Wednesday","mailpoet"),(0,Fe.__)("Thursday","mailpoet"),(0,Fe.__)("Friday","mailpoet"),(0,Fe.__)("Saturday","mailpoet")]};Li.Z.localize.month=qi()({values:Bi,defaultWidth:"wide"}),Li.Z.localize.day=qi()({values:Wi,defaultWidth:"wide"}),Li.Z.options.weekStartsOn=void 0!==c.MailPoet.wpWeekStartsOn?c.MailPoet.wpWeekStartsOn:1,(0,Oi.registerLocale)("mailpoet",Li.Z);class Vi extends o.Component{onChange=(e,t)=>{const i=t,a=this.getStorageDate(e);i.target.name=this.getFieldName(),i.target.value=a,this.props.onChange(i)};getFieldName=()=>this.props.name||"date";getDisplayDateFormat=e=>c.MailPoet.Date.convertFormat(e).replace(/D/g,"d").replace(/Y/g,"y").replace(/A/g,"a").replace(/o/g,"Y").replace(/\[/g,"").replace(/\]/g,"");getDate=e=>{const t={parseFormat:this.props.storageFormat};return c.MailPoet.Date.toDate(e,t)};getStorageDate=e=>{const t={format:this.props.storageFormat};return c.MailPoet.Date.format(e,t)};render(){return(0,u.jsx)($i.a,{name:this.getFieldName(),selected:this.getDate(this.props.value),dateFormat:this.getDisplayDateFormat(this.props.displayFormat),disabled:this.props.disabled,onChange:this.onChange,minDate:this.getDate(window.mailpoet_current_date),maxDate:this.props.maxDate,locale:"mailpoet",...this.props.validation})}}class Ui extends o.Component{render(){const e=Object.keys(this.props.timeOfDayItems).map((e=>(0,u.jsx)("option",{value:e,children:this.props.timeOfDayItems[e]},`option-${this.props.timeOfDayItems[e]}`)));return(0,u.jsx)(lt.Select,{name:this.props.name||"time",value:this.props.value,disabled:this.props.disabled,onChange:this.props.onChange,isMinWidth:!0,...this.props.validation,children:e})}}Ui.propTypes={timeOfDayItems:Te().objectOf(Te().string).isRequired,name:Te().string,value:Te().string.isRequired,disabled:Te().bool,onChange:Te().func.isRequired,validation:Te().object},Ui.defaultProps={name:"time",disabled:!1,validation:{}},Ui.displayName="TimeSelect";class zi extends o.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||it()((()=>{this.setState(this.buildStateFromProps(this.props))}))}getDateTime=()=>[this.state.date,this.state.time].join(this.DATE_TIME_SEPARATOR);buildStateFromProps=e=>{const t=e.value||this.props.defaultDateTime,[i,a]=t.split(this.DATE_TIME_SEPARATOR);return{date:i,time:a}};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,u.jsx)(Fi.Grid.Column,{className:"mailpoet-datetime-container",children:(0,u.jsxs)(r.ErrorBoundary,{children:[(0,u.jsx)(Vi,{name:"date",value:this.state.date,onChange:this.handleChange,displayFormat:this.props.dateDisplayFormat,storageFormat:this.props.dateStorageFormat,disabled:this.props.disabled,validation:this.props.dateValidation,maxDate:this.props.maxDate}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(Ui,{name:"time",value:this.state.time,onChange:this.handleChange,disabled:this.props.disabled,timeOfDayItems:this.props.timeOfDayItems})]})})}}var Hi=i(86656),Zi=i(57036),Yi=i(44584),Gi=i(50438);class Ki extends o.Component{constructor(e){super(e),this.state={emailAddress:e.item.sender_address,showSenderDomainWarning:!1,showAuthEmailsError:!1},this.onChange=this.onChange.bind(this),this.onBlur=this.onBlur.bind(this),window.mailpoet_sender_address_field_blur=this.onBlur;const t=e.field.id||`field_${e.field.name}`;this.domElementSelector=`#${t}`,this.parsleyFieldName="invalidFromAddress"}componentDidMount(){this.validateEmailAddress()}onChange(e){const t=e.target.value.toLowerCase();this.setState({emailAddress:t}),this.props.onValueChange({...e,target:{...e.target,name:e.target.name,value:t}}),this.setState({showAuthEmailsError:!1,showSenderDomainWarning:!1}),(0,Zi.dy)(this.domElementSelector,this.parsleyFieldName)}onBlur(){this.validateEmailAddress()}isEmailAddressAuthorized=e=>(window.mailpoet_authorized_emails||[]).includes(e);showInvalidFromAddressError=()=>{(0,Zi.Ib)(this.domElementSelector,this.parsleyFieldName," "),this.setState({showAuthEmailsError:!0})};showSenderFieldError=(e,t)=>{window.mailpoet_mss_active&&((0,Zi.dy)(this.domElementSelector,this.parsleyFieldName),(0,Zi.K0)(this.domElementSelector)?e||this.showInvalidFromAddressError(t):(0,Zi.OP)(this.domElementSelector))};showSenderDomainError=e=>{e&&this.setState({showSenderDomainWarning:!0})};validateEmailAddress(){if(!window.mailpoet_mss_active)return;const e=this.state.emailAddress,t=(0,Yi.DA)(e);if(window.mailpoet_verified_sender_domains.includes(t))return;const i=this.isEmailAddressAuthorized(e);this.showSenderFieldError(i,e),c.MailPoet.freeMailDomains.indexOf(t)>-1||(0,Gi.g)(e).then((t=>{this.showSenderDomainError(t,e)})).catch((()=>{}))}render(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(st,{item:{...this.props.item,sender_address:this.state.emailAddress},field:this.props.field,onValueChange:this.onChange,onBlurEvent:this.onBlur}),(0,u.jsx)("div",{className:"regular-text regular-text-full-width",children:(0,u.jsx)(Hi.L,{emailAddress:this.state.emailAddress,mssActive:window.mailpoet_mss_active,isEmailAuthorized:!this.state.showAuthEmailsError,showSenderDomainWarning:this.state.showSenderDomainWarning,onSuccessfulEmailOrDomainAuthorization:e=>{"email"===e.type&&(this.setState({showAuthEmailsError:!1}),c.MailPoet.trackEvent("MSS in plugin authorize email",{"authorized email source":"newsletter",wasSuccessful:"yes"})),"domain"===e.type&&(this.setState({showSenderDomainWarning:!1}),c.MailPoet.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"newsletter",wasSuccessful:"yes"})),(0,Zi.dy)(this.domElementSelector,this.parsleyFieldName)}})})]})}}Ki.propTypes={field:Te().object.isRequired,item:Te().shape({sender_address:Te().string.isRequired}).isRequired,onValueChange:Te().func},Ki.defaultProps={onValueChange:function(){}},Ki.displayName="SenderField";const Qi=rt.default.once((()=>c.MailPoet.trackEvent("User has typed a GA campaign name"))),Xi=f()((0,Fe.__)("For example, “Spring email”. [link]Read the guide.[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,u.jsxs)("span",{children:[(0,u.jsx)("br",{}),(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/187-track-your-newsletters-subscribers-in-google-analytics",target:"_blank",rel:"noopener noreferrer",className:"mailpoet-link",children:e})]},t))),Ji={name:"ga_campaign",label:(0,Fe.__)("Google Analytics Campaign","mailpoet"),tip:Xi,type:"text",onBeforeChange:Qi};var ea=i(76545),ta=i(42305),ia=i(20174),aa=i(81207),sa=i(53124);const na={saveDraftNewsletter:()=>Promise.resolve()},oa=o.createContext(na);var ra=i(79951);function la(e,t){return`segments:${e.join(",")}|filterSegmentId:${t}`}const da=[{name:"segments",label:(0,Fe.__)("Send to","mailpoet"),type:"selection",placeholder:(0,Fe.__)("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,Fe.__)("Please select a list","mailpoet"),"data-parsley-segments-with-subscribers":(0,Fe.__)("Please select a list with subscribers.","mailpoet")}},{name:"filter-segment-toggle",type:"reactComponent",component:(0,r.withBoundary)((function(e){let{item:t,onValueChange:i,field:a}=e;const s=t?.options.filterSegmentId,[n,l]=(0,o.useState)(ia.P$&&!!s),d=(0,o.useCallback)((e=>{i({target:{name:"options",value:{...t?.options??{},filterSegmentId:e}}})}),[t,i]),m=(0,o.useContext)(oa);(0,o.useEffect)((()=>{ia.P$||""===s||d("")}),[d,s]);const p=(0,o.useCallback)((e=>{i({target:{name:a.name,value:e}}),e||d(""),l(e),c.MailPoet.trackEvent("Emails > Filter by segment toggled",{"Email type":t.type})}),[a,i,d,t]);let h;if(n){const e={name:"filter-segment",type:"selection",placeholder:(0,Fe.__)("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,Fe.__)("Please select a filter segment","mailpoet")}};h=(0,u.jsx)(Re.Y,{item:t,field:e,onValueChange:e=>{d(e.target.value),c.MailPoet.trackEvent("Emails > Filter by segment selected",{"Email type":t.type})}})}const g=`admin.php?page=mailpoet-segments#/new-segment?newsletterId=${t.id}`;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.Toggle,{checked:n,disabled:a.disabled,name:"isFilterSegmentEnabled",onCheck:p,automationId:"filter-segment-toggle"}),(0,u.jsxs)("span",{className:"mailpoet-form-toggle-text",children:[(0,Fe.__)("Filter by segment","mailpoet"),(0,u.jsx)(Gt.Z,{"data-tip":!0,"data-for":"filter-segment-tooltip",className:"filter-segment-tooltip",icon:sa.Z})]}),(0,u.jsx)(aa.u,{place:"right",multiline:!0,id:"filter-segment-tooltip",children:(0,u.jsx)("div",{children:(0,Fe.__)("Subscribers selected in 'Send to' will only receive an email if they also belong to this segment.","mailpoet")})}),(0,u.jsx)("div",{className:"mailpoet-gap"}),h,n&&(0,u.jsx)("p",{children:f()((0,Fe.__)("Can't find the segment you're looking for? [link]Create new[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,i)=>(0,u.jsx)("a",{className:"mailpoet-link",rel:"noopener noreferrer",onClick:async e=>{e.preventDefault(),c.MailPoet.trackEvent("Emails > Create new segment clicked",{"Email type":t.type}),await m.saveDraftNewsletter(),window.location.href=g},href:g,children:e},i)))})]})}))}],ca={name:"recipient-count",type:"reactComponent",component:(0,r.withBoundary)((function(e){const[t,i]=(0,o.useState)(!0),[a,s]=(0,o.useState)(0),n=(0,o.useMemo)((()=>(e.item.segments||[]).map((e=>e.id))),[e.item.segments]),r=(0,o.useMemo)((()=>e.item.options?.filterSegmentId||null),[e.item.options?.filterSegmentId]),l=(0,o.useRef)(""),d=(0,o.useRef)({});return(0,o.useEffect)((()=>{const e=la(n,r);return l.current=e,n.length<1?(s(0),void i(!1)):e in d.current?(s(d.current[e]),void i(!1)):(i(!0),void c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"subscriberCount",data:{segmentIds:n,filterSegmentId:r}}).done((t=>{const i=t.data.count;d.current[e]=i;const a=la(n,r);l.current===a&&s(i)})).always((()=>i(!1))))}),[n,r]),(0,u.jsxs)("div",{children:[(0,Fe.__)("Estimated recipients","mailpoet"),":",t&&(0,u.jsx)(ra.ZP,{className:"mailpoet-recipient-count-spinner"}),!t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(aa.u,{place:"right",multiline:!0,id:"estimated-count-tooltip",children:(0,Fe.__)("This count may change at the time of sending.","mailpoet")}),(0,u.jsx)("span",{"data-tip":!0,"data-for":"estimated-count-tooltip",className:"estimated-recipient-count",children:a.toLocaleString()})]})]})}))},ma={name:"send-to",label:(0,Fe.__)("Send to","mailpoet"),tip:(0,Fe.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:da},pa={name:"send-to",label:(0,Fe.__)("Send to","mailpoet"),tip:(0,Fe.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:[...da,ca]},ua=window.mailpoet_current_time||"00:00",ha=`${window.mailpoet_tomorrow_date} 08:00:00`,ga=window.mailpoet_schedule_time_of_day,_a=window.mailpoet_date_format,fa=window.mailpoet_date_storage_format;class ba extends o.Component{getCurrentValue=()=>({isScheduled:"0",scheduledAt:ha,...this.props.item?.[this.props.field.name]??{}});getDateValidation=()=>({"data-parsley-required":!0,"data-parsley-required-message":(0,Fe.__)("Please enter the scheduled date.","mailpoet"),"data-parsley-errors-container":"#mailpoet_scheduling"});isScheduled=()=>"1"===this.getCurrentValue().isScheduled;handleCheckboxChange=(e,t)=>{const i={...t};i.target.value=t.target.checked?"1":"0",this.handleValueChange(i)};handleValueChange=e=>{const t=this.getCurrentValue(),i={};i[e.target.name]=e.target.value,this.props.onValueChange({target:{name:this.props.field.name,value:{...t,...i}}})};render(){let e;const t=new Date;return t.setFullYear(t.getFullYear()+5),this.isScheduled()&&(e=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{className:"mailpoet-form-schedule-time",children:[(0,Fe.__)("Your website’s time is","mailpoet")," ",ua]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{id:"mailpoet_scheduling",children:(0,u.jsx)(zi,{name:"scheduledAt",value:this.getCurrentValue().scheduledAt,onChange:this.handleValueChange,disabled:this.props.field.disabled,dateValidation:this.getDateValidation(),defaultDateTime:ha,timeOfDayItems:ga,dateDisplayFormat:_a,dateStorageFormat:fa,maxDate:t})})]})),(0,u.jsxs)("div",{children:[(0,u.jsx)(ea.Z,{checked:this.isScheduled(),disabled:this.props.field.disabled,name:"isScheduled",onCheck:this.handleCheckboxChange,automationId:"email-schedule-checkbox"}),e]})}}let xa=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Fe.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Fe.__)("Type newsletter subject","mailpoet"),tooltip:(0,Fe.__)("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,Fe.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Fe.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Fe.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Fe.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Fe.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},pa,{name:"options",label:(0,Fe.__)("Schedule it","mailpoet"),type:"reactComponent",component:(0,r.withBoundary)(ba)},{name:"sender",label:(0,Fe.__)("Sender","mailpoet"),tip:(0,Fe.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Fe.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,r.withBoundary)(Ki),placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ji,{name:"reply-to",label:(0,Fe.__)("Reply-to","mailpoet"),tip:(0,Fe.__)("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,Fe.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];xa=Ot.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",xa);const va={getFields:()=>xa,getSendButtonOptions:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Je()(window.mailpoet_current_date_time),i={value:"object"==typeof e.options&&"1"===e.options?.isScheduled&&c.MailPoet.Date.isInFuture(e.options?.scheduledAt,t)?(0,Fe.__)("Schedule","mailpoet"):(0,Fe.__)("Send","mailpoet")};return e.status!==ta.sj.Sent&&e.status!==ta.sj.Sending||(i.disabled="disabled"),i}},ja=window.mailpoet_time_format||"H:i",ya={immediate:(0,Fe.__)("immediately","mailpoet"),minutes:(0,Fe.__)("minute(s) later","mailpoet"),hours:(0,Fe.__)("hour(s) later","mailpoet"),days:(0,Fe.__)("day(s) later","mailpoet"),weeks:(0,Fe.__)("week(s) later","mailpoet")},wa={daily:(0,Fe.__)("Once a day at...","mailpoet"),weekly:(0,Fe.__)("Weekly on...","mailpoet"),monthly:(0,Fe.__)("Monthly on the...","mailpoet"),nthWeekDay:(0,Fe.__)("Monthly every...","mailpoet"),immediately:(0,Fe.__)("Immediately","mailpoet")},Sa=rt.default.object(rt.default.map(rt.default.times(96,(e=>900*e)),(e=>{const t=new Date(null);return t.setSeconds(e),[e,c.MailPoet.Date.format(t,{format:ja,offset:0})]}))),Pa={0:(0,Fe.__)("Sunday","mailpoet"),1:(0,Fe.__)("Monday","mailpoet"),2:(0,Fe.__)("Tuesday","mailpoet"),3:(0,Fe.__)("Wednesday","mailpoet"),4:(0,Fe.__)("Thursday","mailpoet"),5:(0,Fe.__)("Friday","mailpoet"),6:(0,Fe.__)("Saturday","mailpoet")},Ma=rt.default.object(rt.default.map(rt.default.times(28,(e=>e)),(e=>{const t={0:(0,Fe.__)("1st","mailpoet"),1:(0,Fe.__)("2nd","mailpoet"),2:(0,Fe.__)("3rd","mailpoet")};let i;return i=void 0!==t[e]?t[e]:(0,Fe.__)("%1$dth","mailpoet").replace("%1$d",e+1),[e+1,i]}))),Na={1:(0,Fe.__)("1st","mailpoet"),2:(0,Fe.__)("2nd","mailpoet"),3:(0,Fe.__)("3rd","mailpoet"),L:(0,Fe._x)("last","e.g. monthly every last Monday","mailpoet")},Ia={name:"intervalType",values:wa},Ca={name:"timeOfDay",values:Sa},ka={name:"weekDay",values:Pa},Ta={name:"monthDay",values:Ma},Ea={name:"nthWeekDay",values:Na};class Aa extends o.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};handleValueChanges=e=>{const t=this.getCurrentValue();return this.props.onValueChange({target:{name:this.props.field.name,value:rt.default.extend({},t,e)}})};handleIntervalChange=e=>{const t=e.target.value,i={};i.intervalType=t,"monthly"===t&&(i.monthDay="1"),this.handleValueChanges(i)};handleTimeOfDayChange=e=>this.handleValueChanges({timeOfDay:e.target.value});handleWeekDayChange=e=>this.handleValueChanges({weekDay:e.target.value});handleMonthDayChange=e=>this.handleValueChanges({monthDay:e.target.value});handleNthWeekDayChange=e=>this.handleValueChanges({nthWeekDay:e.target.value});render(){const e=this.getCurrentValue();let t,i,a,s;return"immediately"!==e.intervalType&&(t=(0,u.jsx)(dt,{field:Ca,item:this.getCurrentValue(),onValueChange:this.handleTimeOfDayChange})),"weekly"!==e.intervalType&&"nthWeekDay"!==e.intervalType||(i=(0,u.jsx)(dt,{field:ka,item:this.getCurrentValue(),onValueChange:this.handleWeekDayChange})),"monthly"===e.intervalType&&(a=(0,u.jsx)(dt,{field:Ta,item:this.getCurrentValue(),onValueChange:this.handleMonthDayChange})),"nthWeekDay"===e.intervalType&&(s=(0,u.jsx)(dt,{field:Ea,item:this.getCurrentValue(),onValueChange:this.handleNthWeekDayChange})),(0,u.jsxs)("div",{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsx)(dt,{field:Ia,item:this.getCurrentValue(),onValueChange:this.handleIntervalChange,automationId:"newsletter_interval_type"}),"immediately"===e.intervalType&&(0,u.jsx)("div",{children:(0,u.jsx)("p",{children:(0,Fe.__)("after publishing a post","mailpoet")})})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[s,a,i,t]}),"immediately"!==e.intervalType&&(0,u.jsx)("div",{className:"mailpoet-gap"})]})}}Aa.propTypes={item:Te().object.isRequired,field:Te().shape({name:Te().string}).isRequired,onValueChange:Te().func.isRequired};let Ra=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Fe.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Fe.__)("Type newsletter subject","mailpoet"),tooltip:(0,Fe.__)("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,Fe.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Fe.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Fe.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Fe.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Fe.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Fe.__)("Select a frequency","mailpoet"),type:"reactComponent",component:Aa},pa,{name:"sender",label:(0,Fe.__)("Sender","mailpoet"),tip:(0,Fe.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Fe.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,r.withBoundary)(Ki),placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ji,{name:"reply-to",label:(0,Fe.__)("Reply-to","mailpoet"),tip:(0,Fe.__)("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,Fe.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Ra=Ot.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Ra);const Fa={getFields:function(){return Ra},getSendButtonOptions:function(){return{value:(0,Fe.__)("Activate","mailpoet")}}},Oa=window.mailpoet_roles||{},La=rt.default.filter(window.mailpoet_segments||[],(e=>"default"===e.type)),Da={name:"event",values:{segment:(0,Fe.__)("When someone subscribes to the list...","mailpoet"),user:(0,Fe.__)("When a new WordPress user is added to your site...","mailpoet")}},qa={name:"segment",placeholder:(0,Fe.__)("Select a list","mailpoet"),forceSelect2:!0,values:La,getCount:e=>parseInt(e.subscribers,10).toLocaleString(),getLabel:e=>e.name,getValue:e=>e.id},$a={name:"role",values:Oa},Ba={name:"afterTimeNumber",size:3,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,Fe.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},Wa={name:"afterTimeType",values:ya};class Va extends o.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};handleValueChange=(e,t)=>{const i=this.getCurrentValue(),a={};let s=t;return"afterTimeNumber"===e&&(s=parseInt(t,10),s=Number.isNaN(s)?"":s),a[e]=s,this.props.onValueChange({target:{name:this.props.field.name,value:rt.default.extend({},i,a)}})};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,i;return t="user"===e.event?(0,u.jsx)(dt,{field:$a,item:this.getCurrentValue(),onValueChange:this.handleRoleChange}):(0,u.jsx)(Re.Y,{field:qa,item:this.getCurrentValue(),onValueChange:this.handleSegmentChange}),"immediate"!==e.afterTimeType&&(i=(0,u.jsx)(st,{field:Ba,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeNumberChange})),(0,u.jsxs)("div",{children:[(0,u.jsx)(dt,{field:Da,item:this.getCurrentValue(),onValueChange:this.handleEventChange}),(0,u.jsx)("div",{className:"mailpoet-gap"}),t,(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[i,(0,u.jsx)(dt,{field:Wa,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeTypeChange})]}),(0,u.jsx)("div",{className:"mailpoet-form-errors"}),(0,u.jsx)("div",{className:"mailpoet-gap"})]})}}Va.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired,item:Te().object.isRequired,field:Te().shape({name:Te().string}).isRequired,onValueChange:Te().func.isRequired},Va.displayName="WelcomeScheduling";const Ua=(0,Ne.EN)(Va);let za=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Fe.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Fe.__)("Type newsletter subject","mailpoet"),tooltip:(0,Fe.__)("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,Fe.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Fe.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Fe.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Fe.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Fe.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Fe.__)("When to send this welcome email?","mailpoet"),type:"reactComponent",component:(0,r.withBoundary)(Ua)},Ji,{name:"sender",label:(0,Fe.__)("Sender","mailpoet"),tip:(0,Fe.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Fe.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,r.withBoundary)(Ki),placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,Fe.__)("Reply-to","mailpoet"),tip:(0,Fe.__)("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,Fe.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];za=Ot.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",za);const Ha={getFields:function(){return za},getSendButtonOptions:function(){return{value:(0,Fe.__)("Activate","mailpoet")}}};class Za extends o.Component{constructor(e){super(e);const{item:t,event:i}=this.props;this.handleChange=this.handleChange.bind(this);const a=t.afterTimeType||i.defaultAfterTimeType||"immediate",s="minutes"===a?30:1,n=t.afterTimeNumber||s;this.state={afterTimeType:a,afterTimeNumber:n},t.afterTimeNumber===n&&t.afterTimeType===a||this.propagateChange(this.state)}handleChange(e,t){let{value:i}=e.target;"afterTimeNumber"===t&&(i=parseInt(e.target.value,10),i=Number.isNaN(i)?null:i);const a={[t]:i},{afterTimeType:s}=this.state;"afterTimeType"===t&&s!==i&&("minutes"===s&&(a.afterTimeNumber=1),"minutes"===i&&(a.afterTimeNumber=30)),this.setState(a,this.propagateChange(a))}displayAfterTimeTypeOptions(){const{event:e}=this.props;let t=ya;e.timeDelayValues&&(t=Object.entries(e.timeDelayValues).reduce(((e,t)=>{let[i,a]=t;return e[i]=a.text,e}),{}));const{afterTimeType:i}=this.state,a={field:{id:"scheduling_time_interval",name:"scheduling_time_interval",forceSelect2:!0,values:rt.default.map(t,((e,t)=>({name:e,id:t}))),extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>i},onValueChange:rt.default.partial(this.handleChange,rt.default,"afterTimeType")};return(0,u.jsx)(Re.Y,{field:a.field,onValueChange:a.onValueChange})}displayAfterTimeNumberField(){const{afterTimeNumberSize:e,event:t}=this.props,{afterTimeType:i,afterTimeNumber:a}=this.state;if("immediate"===i)return null;if(t.timeDelayValues&&t.timeDelayValues[i]&&!t.timeDelayValues[i].displayAfterTimeNumberField)return null;const s={field:{id:"scheduling_time_duration",name:"scheduling_time_duration",className:"mailpoet-form-input-small",defaultValue:a?a.toString():"",size:e,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,Fe.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},item:{},onValueChange:rt.default.partial(this.handleChange,rt.default,"afterTimeNumber")};return(0,u.jsx)(st,{field:s.field,item:s.item,onValueChange:s.onValueChange})}propagateChange(e){const{onValueChange:t}=this.props;t&&t(e)}render(){const{event:e}=this.props;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("h4",{children:[" ",(0,Fe.__)("When to send this email?","mailpoet")," "]}),(0,u.jsxs)(Fi.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[this.displayAfterTimeNumberField(),this.displayAfterTimeTypeOptions(),e.afterDelayText&&(0,u.jsx)("p",{children:e.afterDelayText})]}),(0,u.jsx)("div",{className:"mailpoet-form-errors"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),e.schedulingReadMoreLink&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("a",{href:e.schedulingReadMoreLink.link,target:"_blank",rel:"noopener noreferrer",className:"event-scheduling-read-more-link",children:e.schedulingReadMoreLink.text}),(0,u.jsx)("div",{className:"mailpoet-gap"})]})]})}}function Ya(e){const t=e&&e.values?e.values:[];return t?t.map((e=>({id:e.id,name:e.name}))):t}function Ga(e){let{eventOptions:t,eventSlug:i,selected:a,onValueChange:s}=e;function n(e){s&&s({eventOptionValue:e.target.value})}return(0,u.jsx)("div",{children:(0,u.jsx)("div",{className:"event-option-selection",children:function(){if(!t)return null;const e={field:{name:`event_options_${i}`,forceSelect2:!0,endpoint:t.endpoint,resetSelect2OnUpdate:!0,values:Ya(t),multiple:t.multiple||!1,placeholder:t.placeholder||!1,transformChangedValue:(e,t)=>rt.default.map(t,(e=>({id:e.id,name:e.text}))),selected:()=>a,getLabel:rt.default.property("name"),getValue:rt.default.property("id"),validation:{"data-parsley-required":!0}},onValueChange:n,item:{action:""}};return"product_categories"===t.endpoint&&(e.field.name="category_ids",e.item={action:"purchasedCategory"}),"products"===t.endpoint&&(e.field.name="product_ids",e.item={action:"purchasedProduct"}),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Re.Y,{field:e.field,onValueChange:e.onValueChange,item:e.item}),(0,u.jsx)("div",{className:"mailpoet-gap"})]})}()})})}Za.propTypes={item:Te().shape({afterTimeType:Te().string.isRequired,afterTimeNumber:Te().number}).isRequired,afterTimeNumberSize:Te().number,onValueChange:Te().func,event:Te().shape({defaultAfterTimeType:Te().string,afterDelayText:Te().string,timeDelayValues:Te().objectOf(Te().shape({text:Te().string,displayAfterTimeNumberField:Te().bool})),schedulingReadMoreLink:Te().shape({link:Te().string.isRequired,text:Te().string.isRequired})}).isRequired},Za.defaultProps={afterTimeNumberSize:3,onValueChange:null},Za.displayName="EventScheduling",Ga.displayName="EventOptions";const Ka=(0,r.withBoundary)(Ga);class Qa extends o.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=rt.default.indexBy(this.email.events,"slug"),this.segments=rt.default.filter(window.mailpoet_segments,(e=>null===e.deleted_at));const i=this.events[this.emailOptions.event],a=this.emailOptions.afterTimeType||i.defaultAfterTimeType||"immediate";this.state={event:i,afterTimeType:a,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,i=e;i.afterTimeType&&"immediate"===i.afterTimeType?i.afterTimeNumber=null:!i.afterTimeType||i.afterTimeNumber||t||(i.afterTimeNumber=1),this.setState(e,this.propagateChange)}displayScheduling(){const{afterTimeNumber:e,afterTimeType:t,event:i}=this.state,a={item:{afterTimeNumber:e,afterTimeType:t},event:i,onValueChange:this.handleChange};return(0,u.jsx)(Za,{item:a.item,event:a.event,onValueChange:a.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,u.jsx)("div",{className:"event-segment-selection",children:(0,u.jsx)(Re.Y,{field:t.field,onValueChange:t.onValueChange})})}displayEventOptions(){const{event:e,eventSlug:t}=this.state;let i;try{i=JSON.parse(this.emailOptions.meta||null)}catch(e){i=this.emailOptions.meta||null}const a={emailSlug:this.email.slug,eventSlug:t,onValueChange:this.handleChange,eventOptions:e.options||null};return i&&i.option&&("remote"===a.eventOptions.type&&(a.eventOptions.values=i.option),a.selected=rt.default.map(i.option,(e=>e.id))),(0,u.jsx)(Ka,{emailSlug:a.emailSlug,eventSlug:a.eventSlug,eventOptions:a.eventOptions,onValueChange:a.onValueChange,selected:a.selected})}displayHeader(){const{event:e}=this.state;return e.title}propagateChange(){const{eventSlug:e,afterTimeType:t,afterTimeNumber:i,segment:a,eventOptionValue:s}=this.state,{onValueChange:n}=this.props;if(!n)return;const o={group:this.email.slug,event:e,afterTimeType:t};i&&(o.afterTimeNumber=i),a&&(o.segment=a),s&&(o.meta=JSON.stringify({option:this.state.eventOptionValue})),n({target:{name:"options",value:o}})}render(){return(0,u.jsxs)("div",{children:[(0,u.jsx)(bt.X,{level:5,children:this.displayHeader()}),this.displayEventOptions(),this.displaySegments(),this.displayScheduling()]})}}Qa.propTypes={field:Te().shape({email:Te().shape({events:Te().object.isRequired}).isRequired,emailOptions:Te().object.isRequired}).isRequired,onValueChange:Te().func},Qa.defaultProps={onValueChange:null},Qa.displayName="SendEventConditions";const Xa=window.mailpoet_woocommerce_automatic_emails||[],Ja={getFields:function(e){return(e=>{const t=Xa[e.options.group];if(!t)return!1;const i=e.options;return[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Fe.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Fe.__)("Type newsletter subject","mailpoet"),tooltip:(0,Fe.__)("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,Fe.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Fe.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Fe.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Fe.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Fe.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Fe.__)("Send this %1s Automatic Email when...","mailpoet").replace("%1s",t.title),type:"reactComponent",component:(0,r.withBoundary)(Qa),email:t,emailOptions:i},Ji,{name:"sender",label:(0,Fe.__)("Sender","mailpoet"),tip:(0,Fe.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Fe.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"text",placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,Fe.__)("Reply-to","mailpoet"),tip:(0,Fe.__)("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,Fe.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}]})(e)},getSendButtonOptions:function(){return{value:(0,Fe.__)("Activate","mailpoet")}}};var es=i(30211);function ts(e){let{afterTimeNumber:t,afterTimeType:i,updateAfterTimeNumber:a,updateAfterTimeType:s,inactiveSubscribersPeriod:n}=e;const o="weeks"===i?7:30,r=Number(t)*o;let l=n;return 365===n&&(l=360),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:4,children:(0,Fe.__)("When to send this re-engagement email?","mailpoet")}),(0,u.jsxs)(Fi.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[(0,u.jsx)("p",{children:(0,Fe.__)("After no activity for","mailpoet")}),(0,u.jsx)(at.I,{type:"text",placeholder:(0,Fe.__)("count","mailpoet"),value:t,onChange:(0,Yi.z2)(a)}),(0,u.jsxs)(lt.Select,{value:i,onChange:(0,Yi.z2)(s),children:[(0,u.jsx)("option",{value:"weeks",children:"weeks"}),(0,u.jsx)("option",{value:"months",children:"months"})]})]}),!!n&&l<=r&&(0,u.jsx)("p",{className:"mailpoet-re-engagement-scheduling-note",children:f()((0,Fe.__)("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(n/30)}`),/\[link\](.*?)\[\/link\]/g,(e=>(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/264-inactive-subscribers",target:"_blank",rel:"noopener noreferrer",children:e},"link")))})]})}const is=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Fe.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Fe.__)("Type newsletter subject","mailpoet"),tooltip:(0,Fe.__)("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,Fe.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Fe.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Fe.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Fe.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Fe.__)("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,u.jsx)(ts,{afterTimeNumber:e.item.options.afterTimeNumber.toString(),afterTimeType:e.item.options.afterTimeType,inactiveSubscribersPeriod:Number(c.MailPoet.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:t=>{e.onValueChange({target:{name:"options",value:(0,es.assoc)("afterTimeNumber",t,e.item.options)}})},updateAfterTimeType:t=>{e.onValueChange({target:{name:"options",value:(0,es.assoc)("afterTimeType",t,e.item.options)}})}})}},ma,{name:"sender",label:(0,Fe.__)("Sender","mailpoet"),tip:(0,Fe.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Fe.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:Ki,placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"reply-to",label:(0,Fe.__)("Reply-to","mailpoet"),tip:(0,Fe.__)("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,Fe.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Fe.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]},Ji],as={getFields(){return is},getSendButtonOptions(){return{value:(0,Fe.__)("Activate","mailpoet")}}};var ss=i(86194);let ns=null;var os=i(82380);function rs(e){let{toggleLoadingState:t,updatePendingState:i}=e;const a=(0,o.useCallback)((async()=>{try{const{success:e,res:t}=await(0,r.callApi)({endpoint:"services",action:"refreshMSSKeyStatus"});!0===e?i(!(0,r.isTruthy)(t.data.result.data.is_approved)):c.MailPoet.Notice.showApiErrorNotice(t)}catch(e){c.MailPoet.Notice.showApiErrorNotice(e)}}),[i]),[s,n]=(0,o.useState)(!0);return(0,u.jsxs)("div",{className:"mailpoet_error",children:[(0,u.jsx)(os.aK,{}),s&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("br",{}),(0,u.jsx)("br",{}),(0,u.jsx)(os.qy,{onRefreshClick:async e=>{e.preventDefault(),t(!0),await a(),n(!1),t(!1)}})]})]})}rs.displayName="PendingNewsletterMessage";const ls=(0,r.withBoundary)(rs),ds=window.mailpoet_woocommerce_automatic_emails||{},cs=(e,t)=>`${Ri()(t,{strict:!0,lower:!0})||"email"}-${e}`,ms=e=>"immediate"===e.afterTimeType?"immediate":`${e.afterTimeNumber} ${e.afterTimeType}`;function ps(e){let t,i;if(!c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")||null===e.wp_post_id)return e&&e.body&&e.body.content&&(i=e.body.content,t=JSON.stringify(e.body.content),!i.blocks||!Array.isArray(i.blocks)||0===i.blocks.length)?(0,Fe.__)("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,Fe.__)('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,Fe.__)("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,Fe._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,Fe.__)("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||c.MailPoet.trackingConfig.emailTrackingEnabled?void 0:(0,u.jsx)("span",{style:{pointerEvents:"all"},children:f()((0,Fe.__)("Re-engagement emails are disabled because [link]open and click tracking[/link] is disabled.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e=>(0,u.jsx)("a",{href:"?page=mailpoet-settings#/advanced",rel:"noopener noreferrer",children:e},"advancedSettingsTabLink")))})}class us extends o.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.match.params.id).always((()=>{this.setState({loading:!1})})),Ce()("#mailpoet_newsletter").parsley({successClass:""})}componentDidUpdate(e){this.props.match.params.id!==e.match.params.id&&this.loadItem(this.props.match.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===ta.j9.Automatic&&ds[e.options.group])return Ja;switch(e.type){case"notification":return Fa;case"welcome":return Ha;case"re_engagement":return as;default:return va}};getThumbnailPromise=e=>this.state?.thumbnailPromise??(0,ss.W0)(e);isValid=()=>Ce()("#mailpoet_newsletter").parsley().isValid();isValidFromAddress=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return!0;const e=await this.loadVerifiedSenderDomains(),t=(0,Yi.DA)(this.state.item.sender_address);if(-1!==e.indexOf(t))return!0;const i=await this.loadAuthorizedEmailAddresses(),a=this.state.item.sender_address;return-1!==i.indexOf(a)};loadItem=e=>(this.setState({loading:!0}),c.MailPoet.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,i=e.data;if(i.type===ta.j9.Automation){const e=i.options?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"/new";return this.setState({item:{}},(()=>{this.props.history.push(t)}))}!i.ga_campaign&&ia.P$&&(i.ga_campaign=cs(i.id,i.subject));const a=new URLSearchParams(this.props.location.search).get("filterSegmentId");return a&&(e.data.options.filterSegmentId=a),this.setState({item:e.data,fields:this.getFieldsByNewsletter(e.data),thumbnailPromise:t,validationError:ps(e.data)}),!0})).fail((()=>{this.setState({item:{}},(()=>{this.props.history.push("/new")}))})));saveTemplate=(e,t)=>{this.getThumbnailPromise(e.meta.preview_url).then((i=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"save",data:{newsletter_id:e.data.id,name:e.data.subject,thumbnail_data:i,body:JSON.stringify(e.data.body),categories:'["recent"]'}}).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)})),t()})).catch((e=>{this.showError({errors:[e]})}))};loadAuthorizedEmailAddresses=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return[];const e=(await c.MailPoet.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 c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[];handleSend=e=>(e.preventDefault(),this.isValid()?(c.MailPoet.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}),c.MailPoet.Modal.loading(!1)})):(window.mailpoet_sender_address_field_blur(),c.MailPoet.Modal.loading(!1))}))):Ce()("#mailpoet_newsletter").parsley().validate());sendNewsletter=e=>c.MailPoet.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 c.MailPoet.Modal.loading(!1),void this.props.history.push(`/send/congratulate/${this.state.item.id}`);this.props.history.push(`/${this.state.item.type||""}`);let i=[];e.data.segments.map((e=>i.push(...e.filters))),i=Ei().uniqWith(i,((e,t)=>e.action===t.action&&e.type===t.type));const a=i.map((e=>function(e){const t=e.action,i=e.type;if("automations"===i)switch(t){case"enteredAutomation":return"entered automation";case"exitedAutomation":return"exited automation";default:return""}if("email"===i)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"===i)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"===i)switch(t){case"customerInCountry":return"is in country";case"customerInPostalCode":return"postal code";case"customerInCity":return"city";case"purchasedCategory":return"purchased in category";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";default:return""}return"woocommerceSubscription"===i&&"hasActiveSubscription"===t?"has an active subscription":"woocommerceMembership"===i&&"isMemberOf"===t?"is active member of":""}(e))).join(", "),s="scheduled"===t.data.status;c.MailPoet.trackEvent("Emails > Newsletter sent",{scheduled:s,"Segment Applied":!!this.state.item.options.filterSegmentId,segments:a}),s?this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("The newsletter has been scheduled.","mailpoet")})):this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("The newsletter is being sent...","mailpoet")}),{id:"mailpoet_notice_being_sent"}),c.MailPoet.Modal.loading(!1)}))})).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)}));activateNewsletter=e=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:this.props.match.params.id,status:"active"}}).done((t=>{this.saveTemplate(e,(()=>{if(window.mailpoet_show_congratulate_after_first_newsletter)return c.MailPoet.Modal.loading(!1),void this.props.history.push(`/send/congratulate/${this.state.item.id}`);const e=this.state.item.options;this.props.history.push("automatic"===this.state.item.type?`/${e.group}`:`/${this.state.item.type||""}`),"automatic"===this.state.item.type&&ds[e.group]?(this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.sprintf)((0,Fe.__)("Your %1s Automatic Email is now activated!","mailpoet"),ds[e.group]?.title??"")})),c.MailPoet.trackEvent("Emails > Automatic email activated",{Type:Ri()(`${e.group}-${e.event}`),Delay:ms(e)})):"welcome"===t.data.type?(this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("Your Welcome Email is now activated!","mailpoet")})),c.MailPoet.trackEvent("Emails > Welcome email activated",{"List type":e.event,Delay:ms(e)})):"re_engagement"===t.data.type?(this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("Your Re-engagement Email is now activated!","mailpoet")})),c.MailPoet.trackEvent("Emails > Re-engagement email activated",{Inactivity:ms(e),"Segment Applied":!!this.state.item.options.filterSegmentId})):"notification"===t.data.type&&(this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("Your post notification is now active!","mailpoet")})),c.MailPoet.trackEvent("Emails > Post notifications activated",{Frequency:e.intervalType,"Segment Applied":!!this.state.item.options.filterSegmentId})),c.MailPoet.Modal.loading(!1)}))})).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)}));handleResume=e=>(e.preventDefault(),this.isValid()?this.saveNewsletter().done((()=>{this.setState({loading:!0})})).done((()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"resume",data:{newsletter_id:this.state.item.id}}).done((()=>{this.props.history.push(`/${this.state.item.type||""}`),this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("The newsletter sending has been resumed.","mailpoet")}))})).fail((e=>{this.showError(e)}))})).fail((e=>{this.showError(e)})).always((()=>{this.setState({loading:!1})})):Ce()("#mailpoet_newsletter").parsley().validate(),!1);handleSave=e=>{e.preventDefault(),this.saveNewsletter().done((()=>{this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("Email was updated successfully!","mailpoet")}))})).done((()=>{const e="automatic"===this.state.item.type?this.state.item.options.group:this.state.item.type;this.props.history.push(`/${e||""}`)})).fail((e=>{this.showError(e)}))};handleRedirectToDesign=e=>{e.preventDefault();const t=e.target.href;this.saveNewsletter().done((()=>{this.context.notices.success((0,u.jsx)("p",{children:(0,Fe.__)("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=Ei().omit(e,["body","created_at","deleted_at","hash","status","updated_at","type"]);return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:t})};showError=e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0,timeout:!1})};handleFormChange=e=>{const t=e.target.name,i=e.target.value;return this.setState((e=>{const a={...e.item},s=a.subject,n=a.ga_campaign;return a[t]=i,"subject"===t&&n===cs(a.id,s)&&(a.ga_campaign=cs(a.id,i)),"reply_to_address"===t&&(a[t]=i.toLowerCase()),{item:a}})),!0};handleSaveDraft=()=>{Ce()("#mailpoet_newsletter").parsley().destroy()};disableSegmentsSelectorWhenPaused=e=>t=>"segments"===t.name||"options"===t.name?{...t,disabled:e}:t;disableGAIfPremiumInactive=()=>e=>ia.P$||"ga_campaign"!==e.name?e:{...e,disabled:!0,onWrapperClick:()=>this.setState({showPremiumModal:!0,premiumModalMessage:(0,Fe.__)("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||ia.P$?e:{...e,disabled:!0,onWrapperClick:e=>{e.preventDefault(),this.setState({showPremiumModal:!0,premiumModalMessage:(0,Fe.__)("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:i,type:a,options:s,wp_post_id:n},mssKeyPendingApproval:o}=this.state,l="sending"===t&&i&&"paused"===i.status,d=this.getSendButtonOptions(),m=this.getPreparedFields(l),p=!(!window.mailpoet_subscribers_limit_reached&&!o&&void 0===this.state.validationError);let h=a;return h===ta.j9.Automatic&&(h=s.group||h),(0,u.jsxs)("div",{className:"mailpoet-form-send-email",children:[(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(Si,{emailType:h,automationId:"newsletter_send_heading"}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(oa.Provider,{value:this.state.sendContextValue,children:(0,u.jsxs)(wt,{id:"mailpoet_newsletter",fields:m,automationId:"newsletter_send_form",item:this.state.item,loading:this.state.loading,onChange:this.handleFormChange,onSubmit:this.handleSave,children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{className:"send-newsletter-buttons",children:[(0,u.jsx)(r.Button,{variant:"secondary",type:"submit",automationId:"email-save-draft",onClick:this.handleSaveDraft,isDisabled:this.state.loading,children:(0,Fe.__)("Save as draft and close","mailpoet")}),l?(0,u.jsx)(r.Button,{type:"button",onClick:this.handleResume,isDisabled:p||this.state.loading,automationId:"email-resume",children:(0,Fe.__)("Resume","mailpoet")}):(0,u.jsx)(r.Button,{type:"button",onClick:this.handleSend,...d,isDisabled:p||this.state.loading,automationId:"email-submit",children:d.value||(0,Fe.__)("Send","mailpoet")}),void 0!==this.state.validationError&&(0,u.jsx)(De.Tooltip,{tooltip:(0,u.jsx)("div",{children:this.state.validationError}),tooltipId:"helpTooltipSendEmail"})]}),(0,u.jsxs)("p",{children:[(0,Fe.__)("or simply","mailpoet")," ",(0,u.jsx)("a",{className:"mailpoet-link",href:c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")&&n?`admin.php?page=mailpoet-email-editor&postId=${n}`:`?page=mailpoet-newsletter-editor&id=${this.props.match.params.id}`,onClick:this.handleRedirectToDesign,children:(0,Fe.__)("go back to the Design page","mailpoet")}),"."]}),o&&(0,u.jsx)(ls,{toggleLoadingState:this.toggleLoadingState,updatePendingState:this.updatePendingApprovalState}),e&&(0,u.jsx)(ia.ZG,{onRequestClose:this.closePremiumModal,children:this.state.premiumModalMessage})]})})})]})}}us.contextType=l.k;const hs=(0,Ne.EN)(us);function gs(e){const[t,i]=(0,o.useState)(!1);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:0,children:(0,Fe.__)("Congratulations!","mailpoet")}),(0,u.jsx)(bt.X,{level:3,children:(a=e.newsletter,"welcome"===a.type?(0,Fe.__)("Your Welcome Email is now active.","mailpoet"):"notification"===a.type?(0,Fe.__)("Your Post Notification is now active.","mailpoet"):"automatic"===a.type?(0,Fe.__)("Your WooCommerce email has been activated.","mailpoet"):"scheduled"===a.status?(0,Fe.__)("Your newsletter is scheduled to be sent.","mailpoet"):(0,Fe.__)("Your newsletter is being sent!","mailpoet"))}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)("img",{src:e.illustrationImageUrl,alt:"",width:"500"}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)(r.Button,{type:"button",dimension:"small",onClick:()=>{e.successClicked(),i(!0)},withSpinner:t,children:(0,Fe.__)("Close","mailpoet")})]});var a}function _s(e){return(0,u.jsxs)("div",{className:"mailpoet-wizard-step",children:[(0,u.jsx)("div",{className:"mailpoet-wizard-step-illustration",children:(0,u.jsx)("img",{src:e.illustrationUrl,width:"500",alt:""})}),(0,u.jsx)("div",{className:"mailpoet-wizard-step-content",children:e.children})]})}function fs(){return(0,u.jsxs)(r.List,{children:[(0,u.jsx)("li",{children:(0,Fe.__)("Reliable marketing and transactional email delivery. Reach inboxes, not spam boxes","mailpoet")}),(0,u.jsx)("li",{children:(0,Fe.__)("Send your emails super fast (up to 50,000 emails per hour)","mailpoet")}),(0,u.jsx)("li",{children:(0,Fe.__)("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,u.jsx)("li",{children:(0,Fe.__)("Authenticate your emails (with SPF and DKIM) to improve deliverability and avoid spam boxes","mailpoet")})]})}function bs(e){const[t,i]=(0,o.useState)(!1),a=()=>{e.onFinish(),i(!0)};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.Heading,{level:1,children:(s=e.newsletter.type,{standard:(0,Fe.__)("Your email has been sent!","mailpoet"),welcome:(0,Fe.__)("You are all set up and ready to go!","mailpoet"),notification:(0,Fe.__)("You are all set up and ready to go!","mailpoet"),woocommerce:(0,Fe.__)("You are all set up and ready to go!","mailpoet")}[s]||(0,Fe.__)("You are all set up and ready to go!","mailpoet"))}),(0,u.jsx)(_s,{illustrationUrl:e.MSSPitchIllustrationUrl,children:(0,u.jsxs)("div",{className:"mailpoet-welcome-wizard-step-content",children:[(0,u.jsx)(r.Heading,{level:4,children:(0,Fe.__)("What’s next? Sign up to the MailPoet Starter plan for fast and reliable email delivery","mailpoet")}),(0,u.jsx)("p",{children:e.subscribersCount<1e3?(0,Fe._x)("Did you know? Users with 1,000 subscribers or less get the Starter plan for free.","Promotion for our email sending service: Paragraph","mailpoet"):(0,Fe._x)("Starting at only $10 per month, MailPoet Business offers the following features","Promotion for our email sending service: Paragraph","mailpoet")}),(0,u.jsxs)(r.Heading,{level:5,children:[(0,Fe._x)("You’ll get","Promotion for our email sending service: Paragraph","mailpoet"),":"]}),(0,u.jsx)(fs,{}),(0,u.jsx)("p",{children:f()((0,Fe.__)("Please enter your key in [link]the Settings[/link] if you have already purchased it.","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,u.jsx)("a",{href:"admin.php?page=mailpoet-settings#/premium",children:e},t)))}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(r.Button,{isFullWidth:!0,href:e.purchaseUrl,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),window.open(e.purchaseUrl),a()},children:(0,Fe._x)("Sign up for free","Promotion for our email sending service: Button","mailpoet")}),(0,u.jsx)(r.Button,{isFullWidth:!0,variant:"tertiary",onClick:a,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),a())},withSpinner:t,children:(0,Fe._x)("No thanks!","Promotion for our email sending service: Skip link","mailpoet")})]})})]});var s}function xs(e){return window.has_mss_key_specified?(0,u.jsx)(gs,{successClicked:e.successClicked,illustrationImageUrl:e.illustrationImageUrl,newsletter:e.newsletter}):(0,u.jsx)(bs,{MSSPitchIllustrationUrl:e.MSSPitchIllustrationUrl,onFinish:e.successClicked,subscribersCount:e.subscribersCount,purchaseUrl:e.purchaseUrl,newsletter:e.newsletter})}function vs(e){const[t,i]=(0,o.useState)(!1);return(0,u.jsxs)("div",{children:[(0,u.jsx)(bt.X,{level:1,children:(0,Fe.__)("Oops! We can’t send your newsletter","mailpoet")}),(0,u.jsx)(bt.X,{level:3,children:f()((0,Fe.__)("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,u.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://kb.mailpoet.com/article/231-sending-does-not-work",children:e},t)))}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)("img",{src:window.mailpoet_congratulations_error_image,alt:"",width:"500"}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)(r.Button,{dimension:"small",type:"button",onClick:()=>{e.failClicked(),i(!0)},withSpinner:t,children:(0,Fe.__)("Close","mailpoet")})]})}gs.propTypes={successClicked:Te().func.isRequired,illustrationImageUrl:Te().string.isRequired,newsletter:Te().shape({status:Te().string.isRequired,type:Te().string.isRequired}).isRequired},_s.propTypes={illustrationUrl:Te().string.isRequired,children:Te().oneOfType([Te().arrayOf(Te().node),Te().node]).isRequired},xs.propTypes={successClicked:Te().func.isRequired,illustrationImageUrl:Te().string.isRequired,MSSPitchIllustrationUrl:Te().string.isRequired,newsletter:Te().shape({status:Te().string.isRequired,type:Te().string.isRequired}).isRequired,subscribersCount:Te().number.isRequired,purchaseUrl:Te().string.isRequired},vs.propTypes={failClicked:Te().func.isRequired};var js=i(16065);function ys(e){return(0,u.jsx)("div",{className:"mailpoet-congratulate-loading",children:e.showRichLoadingScreen&&(0,u.jsxs)("div",{children:[(0,u.jsx)(bt.X,{level:0,children:(0,Fe.__)("Verification","mailpoet")}),(0,u.jsx)(bt.X,{level:3,children:(0,Fe.__)("Congrats, you’re sending your first newsletter! We’re doing a quick verification to make sure everything works fine.","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)("div",{className:"mailpoet-gap-large"}),(0,u.jsx)(js.a,{size:64})]})})}ys.propTypes={showRichLoadingScreen:Te().bool.isRequired};const ws=Math.floor(4*Math.random());function Ss(){return c.MailPoet.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 Ps extends o.Component{constructor(e){super(e),this.state={loading:!0,newsletter:null,testingPassed:!1,timeStart:Je()(),minimumLoadingTimePassed:!1},this.tick=this.tick.bind(this)}componentDidMount(){this.loadNewsletter(this.props.match.params.id),this.tick()}componentDidUpdate(e){e.match.params.id!==this.props.match.params.id&&this.loadNewsletter(this.props.match.params.id)}tick(){Je()().subtract(20,"second").isAfter(this.state.timeStart)&&this.setState({error:!0,loading:!1}),this.state.loading&&this.loadNewsletter(this.props.match.params.id),Je()().subtract(6,"seconds").isAfter(this.state.timeStart)&&this.setState({minimumLoadingTimePassed:!0}),!this.state.loading&&this.state.minimumLoadingTimePassed||setTimeout(this.tick,2e3)}loadNewsletter(e){c.MailPoet.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,u.jsx)(ys,{illustrationImageUrl:window.mailpoet_congratulations_loading_image,successClicked:Ss,showRichLoadingScreen:e})):this.state.error?(c.MailPoet.trackEvent("Cron testing done",{"Cron is working":"false"}),(0,u.jsx)(vs,{failClicked:()=>{window.location=window.mailpoet_emails_page}})):(t=this.state.newsletter,this.state.testingPassed&&c.MailPoet.trackEvent("Cron testing done",{"Cron is working":"true"}),(0,u.jsx)(xs,{illustrationImageUrl:window.mailpoet_congratulations_success_images[ws],MSSPitchIllustrationUrl:window.mailpoet_congratulations_success_images[ws],successClicked:Ss,newsletter:t,isWoocommerceActive:window.mailpoet_woocommerce_active,subscribersCount:window.mailpoet_subscribers_count,purchaseUrl:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,"starter",{utm_medium:"first-newsletter-congratulations",utm_campaign:"purchase"})}));var e,t}render(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("style",{dangerouslySetInnerHTML:{__html:"body { background: #fff; overflow-x: hidden; }"}}),(0,u.jsxs)("div",{className:"mailpoet-congratulate",children:[(0,u.jsx)("div",{className:"mailpoet-gap-large"}),this.renderContent()]})]})}}Ps.propTypes={match:Te().shape({params:Te().shape({id:Te().string}).isRequired}).isRequired},Ps.displayName="Congratulate";class Ms extends o.Component{componentDidMount(){c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,Fe.__)("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.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))}showTemplateSelection=e=>{this.props.history.push(`/template/${e}`)};render(){return(0,u.jsx)("div",{children:(0,u.jsx)(Si,{emailType:"standard",automationId:"standard_newsletter_creation_heading"})})}}Ms.contextType=l.k,Ms.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired},Ms.displayName="NewsletterStandard";const Ns=(0,Ne.EN)(Ms),Is={name:"options",type:"reactComponent",component:Aa};class Cs extends o.Component{constructor(e){super(e),this.state={options:{intervalType:"daily",timeOfDay:0,weekDay:1,monthDay:0,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=()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:rt.default.extend({},this.state,{type:"notification",subject:(0,Fe.__)("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.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))};showTemplateSelection=e=>{this.props.history.push(`/template/${e}`)};render(){return(0,u.jsxs)("div",{children:[(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(Si,{emailType:"notification",automationId:"post_notification_creation_heading"}),(0,u.jsxs)(Fi.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,u.jsx)(bt.X,{level:4,children:(0,Fe.__)("When to send this post notification email?","mailpoet")}),(0,u.jsx)(Aa,{item:this.state,field:Is,onValueChange:this.handleValueChange}),(0,u.jsx)(Oe.z,{isFullWidth:!0,onClick:this.handleNext,type:"button",children:(0,Fe.__)("Next","mailpoet")})]})]})}}Cs.contextType=l.k,Cs.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired},Cs.displayName="NewsletterNotification";const ks=(0,Ne.EN)(Cs),Ts={name:"options",label:"Event",type:"reactComponent",component:Ua};class Es extends o.Component{constructor(e){super(e);let t=window.mailpoet_segments||[],i=1;t=t.filter((e=>"default"===e.type)),rt.default.size(t)>0&&(i=rt.default.first(t).id),this.state={options:{event:"segment",segment:i,role:"subscriber",afterTimeNumber:1,afterTimeType:"immediate"}},this.handleValueChange=this.handleValueChange.bind(this),this.handleNext=this.handleNext.bind(this)}handleValueChange(e){const{state:t}=this;t[e.target.name]=e.target.value,this.setState(t)}handleNext(e){e.preventDefault(),this.isValid()?c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:rt.default.extend({},this.state,{type:"welcome",subject:(0,Fe.__)("Subject","mailpoet")})}).done((e=>{this.showTemplateSelection(e.data.id)})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})):this.validate()}isValid=()=>Ce()("#welcome_scheduling").parsley().isValid();validate=()=>Ce()("#welcome_scheduling").parsley().validate();showTemplateSelection(e){this.props.history.push(`/template/${e}`)}render(){return(0,u.jsxs)("div",{children:[(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(Si,{emailType:"welcome",automationId:"welcome_email_creation_heading"}),(0,u.jsxs)(Fi.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,u.jsx)(bt.X,{level:4,children:(0,Fe.__)("When to send this welcome email?","mailpoet")}),(0,u.jsxs)("form",{id:"welcome_scheduling",children:[(0,u.jsx)(Ua,{item:this.state,field:Ts,onValueChange:this.handleValueChange}),(0,u.jsx)(Oe.z,{isFullWidth:!0,type:"submit",onClick:this.handleNext,children:(0,Fe.__)("Next","mailpoet")})]})]})]})}}function As(){let e="";c.MailPoet.deactivateSubscriberAfterInactiveDays&&(e=(Math.floor(Number(c.MailPoet.deactivateSubscriberAfterInactiveDays)/30)-1).toString());const[t,i]=(0,o.useState)({afterTimeNumber:e,afterTimeType:"months"}),[a,s]=(0,o.useState)([]),[n,r]=(0,o.useState)(!1),l=(0,Ne.k6)();return(0,u.jsxs)("div",{children:[(0,u.jsx)(et.A,{color:"#fff"}),a&&(0,u.jsx)(ni,{errors:a}),(0,u.jsx)(Si,{emailType:"re_engagement",automationId:"re_engagement_heading_creation_heading"}),(0,u.jsxs)(Fi.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,u.jsx)(ts,{afterTimeNumber:t.afterTimeNumber,afterTimeType:t.afterTimeType,inactiveSubscribersPeriod:Number(c.MailPoet.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:(0,es.compose)([i,(0,es.assoc)("afterTimeNumber",es.__,t)]),updateAfterTimeType:(0,es.compose)([i,(0,es.assoc)("afterTimeType",es.__,t)])}),(0,u.jsx)(Oe.z,{isFullWidth:!0,onClick:()=>(s([]),r(!0),void c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"newsletters",action:"create",data:{type:"re_engagement",subject:(0,Fe.__)("Subject","mailpoet"),options:t}}).done((e=>{var t;t=e.data.id,l.push(`/template/${t}`)})).fail((e=>{r(!1),e.errors&&s(e.errors)}))),type:"button",isDisabled:!t.afterTimeNumber||n,withSpinner:n,children:(0,Fe.__)("Next","mailpoet")})]})]})}Es.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired},Es.displayName="NewsletterWelcome",As.displayName="NewsletterTypeReEngagement";class Rs extends o.Component{static getEventOptions(e){return e.options||null}static getEventOptionsFirstValue(e){return e&&rt.default.isArray(e.values)&&e.values[0].id?e.values[0].id:null}constructor(e){super(e);const{email:t,name:i}=e;this.handleChange=this.handleChange.bind(this),this.handleNextStep=this.handleNextStep.bind(this),this.email=t,this.emailEvents=this.email.events,this.segments=rt.default.filter(window.mailpoet_segments,(e=>null===e.deleted_at));const a=this.getEvent(i),s=this.constructor.getEventOptions(a),n=this.constructor.getEventOptionsFirstValue(s);this.state={event:a,eventSlug:a.slug,eventOptionValue:n,segment:a.sendToLists?this.getFirstSegment():null,afterTimeType:a.defaultAfterTimeType||"immediate",afterTimeNumber:null}}handleChange(e){const{segment:t,afterTimeNumber:i}=this.state,a=e;if(a.eventSlug){a.event=this.getEvent(a.eventSlug),a.segment=a.event.sendToLists?t||this.getFirstSegment():null;const e=this.constructor.getEventOptions(a.event);a.eventOptionValue=e?this.constructor.getEventOptionsFirstValue(e):null}a.afterTimeType&&"immediate"===a.afterTimeType?a.afterTimeNumber=null:!a.afterTimeType||a.afterTimeNumber||i||(a.afterTimeNumber=1),this.setState(a),this.resetValidationErrors(),this.isValid()&&this.validate()}handleNextStep(e){if(e.preventDefault(),!this.isValid())return void this.validate();const{history:t}=this.props,{eventSlug:i,afterTimeType:a,afterTimeNumber:s,event:n,segment:o,eventOptionValue:r}=this.state,l={group:this.email.slug,event:i,afterTimeType:a};s&&(l.afterTimeNumber=s),l.sendTo=n.sendToLists?"segment":"user",o&&(l.segment=o),r&&(l.meta=JSON.stringify({option:r})),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"automatic",subject:(0,Fe.__)("Subject","mailpoet"),options:l}}).done((e=>{c.MailPoet.trackEvent("Emails > New Automatic Email Created",{"Event type":l.event,"Schedule type":l.afterTimeType,"Schedule value":l.afterTimeNumber}),t.push(`/template/${e.data.id}`)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))}getEvent(e){return this.emailEvents[e]}getFirstSegment(){return rt.default.isArray(this.segments)&&this.segments[0].id?this.segments[0].id:null}isValid=()=>!Ce()("#newsletter_scheduling").parsley()||Ce()("#newsletter_scheduling").parsley().isValid();validate=()=>{Ce()("#newsletter_scheduling").parsley()&&Ce()("#newsletter_scheduling").parsley().validate()};resetValidationErrors=()=>{Ce()("#newsletter_scheduling").parsley()&&Ce()("#newsletter_scheduling").parsley().reset()};displayHeader(){const{event:e}=this.state;return e.title}displayEventOptions(){const{eventSlug:e,event:t}=this.state,i={emailSlug:this.email.slug,eventSlug:e,eventOptions:this.constructor.getEventOptions(t),onValueChange:this.handleChange};return(0,u.jsx)(Ka,{emailSlug:i.emailSlug,eventSlug:i.eventSlug,eventOptions:i.eventOptions,onValueChange:i.onValueChange})}displaySegments(){const{event:e}=this.state;if(!e.sendToLists)return null;const t={field:{id:"segments",forceSelect2:!0,values:this.segments,extendSelect2Options:{minimumResultsForSearch:1/0}},onValueChange:e=>this.handleChange({segment:e.target.value})};return(0,u.jsx)("div",{className:"event-segment-selection",children:(0,u.jsx)(Re.Y,{field:t.field,onValueChange:t.onValueChange})})}displayScheduling(){const{afterTimeNumber:e,afterTimeType:t,event:i}=this.state,a={item:{afterTimeNumber:e,afterTimeType:t},event:i,onValueChange:this.handleChange};return(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Za,{item:a.item,event:a.event,onValueChange:a.onValueChange})})}displayEventTip(){const{event:e}=this.state;return e.tip?(0,u.jsxs)("p",{className:"description",children:[(0,u.jsx)("strong",{children:(0,Fe.__)("Tip:","mailpoet")})," ",e.tip]}):null}render(){return(0,u.jsxs)("div",{children:[(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(Si,{emailType:"woocommerce",automationId:"woocommerce_email_creation_heading"}),(0,u.jsx)(Fi.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:(0,u.jsxs)("form",{id:"newsletter_scheduling",children:[(0,u.jsx)(bt.X,{level:4,children:this.displayHeader()}),(0,u.jsx)("div",{children:this.displayEventOptions()}),(0,u.jsx)("div",{children:this.displaySegments()}),(0,u.jsx)("div",{children:this.displayScheduling()}),(0,u.jsx)(Oe.z,{isFullWidth:!0,onClick:this.handleNextStep,type:"submit",children:(0,Fe._x)("Next","Button label: Next step","mailpoet")})]})}),this.displayEventTip()]})}}Rs.contextType=l.k,Rs.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired,name:Te().string.isRequired,email:Te().shape({title:Te().string.isRequired,slug:Te().string.isRequired}).isRequired},Rs.displayName="EventsConditions";var Fs=i(5934),Os=i(41991),Ls=i(10235);function Ds(e){let{newsletter:t}=e;const[i,a]=(0,o.useState)("paused"===t.queue.status),[s,n]=(0,o.useState)([]),l=async()=>{n([]),await(async()=>{await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"resume",data:{newsletter_id:t.id}}).done((()=>a(!1))).fail((e=>n(e.errors)))})()};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ni,{errors:s}),i&&(0,u.jsx)(Oe.z,{dimension:"small",onClick:t.status===ta.sj.Corrupt?async()=>{(0,r.confirmAlert)({message:(0,Fe.__)("The was an issue sending this email before, please confirm the issues are fixed to proceed."),onConfirm:l})}:l,children:(0,Fe.__)("Resume","mailpoet")}),!i&&(0,u.jsx)(Oe.z,{dimension:"small",onClick:async()=>{n([]),await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"pause",data:{newsletter_id:t.id}}).done((()=>a(!0))).fail((e=>n(e.errors)))},children:(0,Fe.__)("Pause","mailpoet")})]})}function qs(e){let{newsletter:t,mailerLog:i}=e;const a=t.sent_at||t.queue.scheduled_at,s=a?(0,Os.default)(a,"yyyy-MM-dd HH:mm:ss",new Date):void 0,n=t.queue&&"scheduled"!==t.queue.status,o="paused"===i.status,r=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Me.Link,{to:`/sending-status/${t.id}`,"data-automation-id":`sending_status_${t.id}`,children:(0,u.jsx)(Ls.sj,{processed:parseInt(t.queue.count_processed,10),scheduledFor:s,total:parseInt(t.queue.count_total,10),isPaused:o,status:t.status,logs:t.logs})}),"completed"!==t.queue.status&&!o&&(0,u.jsx)(Ds,{newsletter:t})]}),l=(0,u.jsx)(Ls.sj,{scheduledFor:s,isPaused:"scheduled"===t.queue.status&&o,status:t.status,logs:t.logs});return(0,u.jsxs)(u.Fragment,{children:[n&&r,!n&&l]})}qs.displayName="QueueStatus";const $s=(0,r.withBoundary)(qs),Bs=c.MailPoet.trackingConfig.emailTrackingEnabled,Ws={onNoItemsFound:(e,t)=>t?(0,Fe.__)("No emails found.","mailpoet"):(0,Fe.__)("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 i=null;i=1===t?(0,Fe.__)("1 email was moved to the trash.","mailpoet"):(0,Fe.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was permanently deleted.","mailpoet"):(0,Fe.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email has been restored from the Trash.","mailpoet"):(0,Fe.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},Vs=[{name:"subject",label:(0,Fe.__)("Subject","mailpoet"),sortable:!0},{name:"status",label:(0,Fe.__)("Status","mailpoet")},{name:"segments",label:(0,Fe.__)("Lists","mailpoet")},{name:"statistics",label:(0,Fe.__)("Clicked, Opened","mailpoet"),display:Bs},{name:"sent_at",label:(0,Fe.__)("Sent on","mailpoet"),sortable:!0}],Us=[{name:"trash",label:(0,Fe.__)("Move to trash","mailpoet"),onSuccess:Ws.onTrash}],zs=e=>{let t=`?page=mailpoet-newsletter-editor&id=${e.id}`;c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")&&e.wp_post_id&&(t=`admin.php?page=mailpoet-email-editor&postId=${e.wp_post_id}`),e.queue&&"sending"===e.status&&null===e.queue.status?(0,Mi._)({message:(0,Fe.__)("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 Hs=[{name:"view",link:function(e){return(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Edit","mailpoet"),onClick:zs},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Duplicate","mailpoet"),onClick:function(e,t){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Fe.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];Hs=(0,zt.y8)(Hs);class Zs extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}renderItem=(e,t,i)=>{const a=ee()("manage-column","column-primary","has-row-actions");return(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:a,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:"#",onClick:t=>{t.preventDefault(),zs(e)},children:e.queue.newsletter_rendered_subject||e.subject}),t]}),(0,u.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,Fe.__)("Status","mailpoet"),children:(0,u.jsx)($s,{newsletter:e,mailerLog:i.mta_log})}),(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Lists","mailpoet"),children:(0,u.jsxs)(r.ErrorBoundary,{children:[(0,u.jsx)(Fs.Eg,{segments:e.segments,dimension:"large"}),(0,u.jsx)(Fs.$6,{newsletter:e,dimension:"large"})]})}),!0===Bs?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Fe.__)("Clicked, Opened","mailpoet"),children:(0,u.jsx)(ui,{newsletter:e,currentTime:i.current_time})}):null,(0,u.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Sent on","mailpoet"),children:e.sent_at?(0,u.jsxs)(u.Fragment,{children:[c.MailPoet.Date.short(e.sent_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.sent_at)]}):null})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,u.jsxs)(u.Fragment,{children:[0===this.state.newslettersCount&&(0,u.jsx)(li,{filter:e=>"standard"===e.slug,hideScreenOptions:!1,hideClosingButton:!0}),0!==this.state.newslettersCount&&(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"standard",base_url:"standard",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:Vs,bulk_actions:Us,item_actions:Hs,messages:Ws,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,zt._X)(e),(0,zt.bF)(e)}})]})}}Zs.contextType=l.k,Zs.propTypes={location:Te().object.isRequired,match:Te().shape({params:Te().object}).isRequired},Zs.displayName="NewsletterListStandard";const Ys=(0,Ne.EN)((0,r.withBoundary)(Zs));var Gs=i(45959);const Ks=window.mailpoet_roles||{},Qs=window.mailpoet_segments||{},Xs=c.MailPoet.trackingConfig.emailTrackingEnabled,Js={onNoItemsFound:(e,t)=>t?(0,Fe.__)("No emails found.","mailpoet"):(0,Fe.__)("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 i=null;i=1===t?(0,Fe.__)("1 email was moved to the trash.","mailpoet"):(0,Fe.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was permanently deleted.","mailpoet"):(0,Fe.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email has been restored from the Trash.","mailpoet"):(0,Fe.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},en=[{name:"subject",label:(0,Fe.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Fe.__)("Settings","mailpoet")},{name:"statistics",label:(0,Fe.__)("Statistics","mailpoet"),display:Xs},{name:"status",label:(0,Fe.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,Fe.__)("Last modified on","mailpoet"),sortable:!0}],tn=[{name:"trash",label:(0,Fe.__)("Move to trash","mailpoet"),onSuccess:Js.onTrash}];let an=[{name:"view",link:function(e){return(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Preview","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Duplicate","mailpoet"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Fe.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Edit","mailpoet"),onClick:zt.Q2},{name:"trash",className:"mailpoet-hide-on-mobile"}];an=(0,zt.y8)(an);class sn extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),c.MailPoet.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&&c.MailPoet.Notice.success((0,Fe.__)("Your Welcome Email is now activated!","mailpoet")),this.forceUpdate()})).fail((i=>{c.MailPoet.Notice.showApiErrorNotice(i),t.target.checked=!e}))};renderStatus=e=>{const t=(0,Fe._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",e.total_sent.toLocaleString()),i=(0,Fe._x)("%1$d scheduled","number of welcome emails scheduled to be sent","mailpoet").replace("%1$d",e.total_scheduled.toLocaleString());return(0,u.jsxs)("div",{children:[(0,u.jsx)(ea.Z,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status}),(0,u.jsxs)("p",{className:"mailpoet-listing-stats-description",children:[(0,u.jsx)(Me.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:t})," ",(0,u.jsx)("br",{}),i]})]})};renderSettings=e=>{let t,i,a;if("user"===e.options.event)t="mailpoet_all"===e.options.role?(0,Fe.__)("Sent when a new WordPress user is added to your site.","mailpoet"):f()((0,Fe.__)("Sent when a new WordPress user with the role %1$s is added to your site.","mailpoet"),"%1$s",((t,i)=>(0,u.jsx)(At.V,{variant:"list",children:Ks[e.options.role]},i)));else{if(a=rt.default.find(Qs,(t=>Number(t.id)===Number(e.options.segment))),void 0===a)return(0,u.jsx)(Me.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Fe.__)("You need to select a list to send to.","mailpoet")});t=f()((0,Fe.__)("Sent when someone subscribes to the list: %1$s.","mailpoet"),"%1$s",((e,t)=>(0,u.jsx)(At.V,{variant:"list",children:a.name},t)))}if(t&&"immediate"!==e.options.afterTimeType)switch(e.options.afterTimeType){case"minutes":i=(0,Fe.__)("%1$d minute(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;case"hours":i=(0,Fe.__)("%1$d hour(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;case"days":i=(0,Fe.__)("%1$d day(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;case"weeks":i=(0,Fe.__)("%1$d week(s) later","mailpoet").replace("%1$d",e.options.afterTimeNumber);break;default:i=(0,Fe.__)("Invalid sending delay.","mailpoet")}return(0,u.jsxs)("span",{children:[t,i&&(0,u.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,u.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,u.jsx)(Gs.P,{})}),i]})]})};renderItem=(e,t)=>{const i=ee()("manage-column","column-primary","has-row-actions");return(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:i,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,zt.Q2)(e)},children:e.subject}),t]}),(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===Xs?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Fe.__)("Clicked, Opened","mailpoet"),children:(0,u.jsx)(ui,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,u.jsx)("td",{className:"column","data-colname":(0,Fe.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Last modified on","mailpoet"),children:[c.MailPoet.Date.short(e.updated_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,u.jsxs)(u.Fragment,{children:[0===this.state.newslettersCount&&(0,u.jsx)(li,{filter:e=>"welcome"===e.slug,hideScreenOptions:!1,hideClosingButton:!0}),0!==this.state.newslettersCount&&(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"welcome",base_url:"welcome",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:en,bulk_actions:tn,item_actions:an,messages:Js,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,zt._X)(e),(0,zt.bF)(e)}})]})}}sn.propTypes={location:Te().object.isRequired,match:Te().shape({params:Te().object}).isRequired},sn.displayName="NewsletterListWelcome";const nn=(0,Ne.EN)((0,r.withBoundary)(sn)),on={onNoItemsFound:(e,t)=>t?(0,Fe.__)("No emails found.","mailpoet"):(0,Fe.__)("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 i=null;i=1===t?(0,Fe.__)("1 email was moved to the trash.","mailpoet"):(0,Fe.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was permanently deleted.","mailpoet"):(0,Fe.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email has been restored from the Trash.","mailpoet"):(0,Fe.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},rn=[{name:"subject",label:(0,Fe.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Fe.__)("Settings","mailpoet")},{name:"history",label:(0,Fe.__)("History","mailpoet"),width:100},{name:"status",label:(0,Fe.__)("Status","mailpoet"),width:100},{name:"updated_at",label:(0,Fe.__)("Last modified on","mailpoet"),sortable:!0}],ln=[{name:"trash",label:(0,Fe.__)("Move to trash","mailpoet"),onSuccess:on.onTrash}],dn=[{name:"view",link:function(e){return(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Edit","mailpoet"),onClick:zt.Q2},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Duplicate","mailpoet"),onClick:function(e,t){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Fe.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class cn extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),c.MailPoet.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&&c.MailPoet.Notice.success((0,Fe.__)("Your post notification is now active!","mailpoet")),this.forceUpdate()})).fail((i=>{c.MailPoet.Notice.showApiErrorNotice(i),t.target.checked=!e}))};renderStatus=e=>(0,u.jsx)(ea.Z,{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,u.jsx)(Me.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Fe.__)("You need to select a list to send to.","mailpoet")});const i=f()((0,Fe.__)("Send to %1$s","mailpoet"),"%1$s",((t,i)=>(0,u.jsxs)(o.Fragment,{children:[(0,u.jsx)(Fs.Eg,{segments:e.segments},`segment-${i}`),(0,u.jsx)(Fs.$6,{newsletter:e},`filter-segment-${i}`)]},i)));switch(e.options.intervalType){case"daily":t=(0,Fe.__)("Daily at %1$s","mailpoet").replace("%1$s",Sa[e.options.timeOfDay]);break;case"weekly":t=(0,Fe.__)("Weekly on %1$s at %2$s","mailpoet").replace("%1$s",Pa[e.options.weekDay]).replace("%2$s",Sa[e.options.timeOfDay]);break;case"monthly":t=(0,Fe.__)("Monthly on the %1$s at %2$s","mailpoet").replace("%1$s",Ma[e.options.monthDay]).replace("%2$s",Sa[e.options.timeOfDay]);break;case"nthWeekDay":t=(0,Fe.__)("Every %1$s %2$s of the month at %3$s","mailpoet").replace("%1$s",Na[e.options.nthWeekDay]).replace("%2$s",Pa[e.options.weekDay]).replace("%3$s",Sa[e.options.timeOfDay]);break;case"immediately":t=(0,Fe.__)("Immediately","mailpoet");break;default:t="Invalid sending frequency"}return(0,u.jsxs)("span",{children:[i,(0,u.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,u.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,u.jsx)(Gs.P,{})}),t]})]})};renderHistoryLink=e=>0===Number(e.children_count)?(0,u.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small mailpoet-listing-notification-status",children:(0,Fe.__)("Not sent yet","mailpoet")}):(0,u.jsxs)(Me.Link,{className:"mailpoet-nowrap","data-automation-id":`history-${e.id}`,to:`/notification/history/${e.id}`,children:[(0,u.jsx)(Oe.z,{className:"mailpoet-hide-on-mobile",dimension:"small",children:(0,Fe.__)("View history","mailpoet")}),(0,u.jsx)(Oe.z,{className:"mailpoet-show-on-mobile mailpoet-listing-notification-status",dimension:"small",variant:"secondary",children:(0,Fe.__)("View history","mailpoet")})]});renderItem=(e,t)=>{const i=ee()("manage-column","column-primary","has-row-actions");return(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:i,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,zt.Q2)(e)},children:e.subject}),t]}),(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Settings","mailpoet"),children:this.renderSettings(e)}),(0,u.jsx)("td",{className:"column","data-colname":(0,Fe.__)("History","mailpoet"),children:this.renderHistoryLink(e)}),(0,u.jsx)("td",{className:"column","data-colname":(0,Fe.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Last modified on","mailpoet"),children:[c.MailPoet.Date.short(e.updated_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,u.jsxs)(u.Fragment,{children:[0===this.state.newslettersCount&&(0,u.jsx)(li,{filter:e=>"notification"===e.slug,hideScreenOptions:!1,hideClosingButton:!0}),0!==this.state.newslettersCount&&(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"notification",base_url:"notification",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:rn,bulk_actions:ln,item_actions:dn,messages:on,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,zt._X)(e),(0,zt.bF)(e)}})]})}}cn.propTypes={location:Te().object.isRequired,match:Te().shape({params:Te().object}).isRequired},cn.displayName="NewsletterListNotification";const mn=(0,Ne.EN)((0,r.withBoundary)(cn)),pn=c.MailPoet.trackingConfig.emailTrackingEnabled,un={onNoItemsFound:(e,t)=>t?(0,Fe.__)("No emails found.","mailpoet"):(0,Fe.__)("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 i=null;i=1===t?(0,Fe.__)("1 email was moved to the trash.","mailpoet"):(0,Fe.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was permanently deleted.","mailpoet"):(0,Fe.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email has been restored from the Trash.","mailpoet"):(0,Fe.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},hn=[{name:"subject",label:(0,Fe.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Fe.__)("Settings","mailpoet")},{name:"statistics",label:(0,Fe.__)("Clicked, Opened","mailpoet"),display:pn},{name:"status",label:(0,Fe.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,Fe.__)("Last modified on","mailpoet"),sortable:!0}],gn=[{name:"trash",label:(0,Fe.__)("Move to trash","mailpoet"),onSuccess:un.onTrash}];let _n=[{name:"view",link:function(e){return(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Preview","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Duplicate","mailpoet"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Fe.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Fe.__)("Edit","mailpoet"),onClick:zt.Q2},{name:"trash",className:"mailpoet-hide-on-mobile"}];_n=(0,zt.y8)(_n);class fn extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),c.MailPoet.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&&c.MailPoet.Notice.success((0,Fe.__)("Your Re-engagement Email is now activated!","mailpoet")),this.forceUpdate()})).fail((i=>{c.MailPoet.Notice.showApiErrorNotice(i),t.target.checked=!e}))};renderStatus=e=>{const t=(0,Fe._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",e.total_sent.toLocaleString());return(0,u.jsxs)("div",{children:[(0,u.jsx)(ea.Z,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status}),(0,u.jsx)("p",{className:"mailpoet-listing-stats-description",children:(0,u.jsx)(Me.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:t})})]})};renderSettings=e=>{if(0===e.segments.length)return(0,u.jsx)(Me.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Fe.__)("You need to select a list to send to.","mailpoet")});const t=f()((0,Fe.__)("Send to %1$s","mailpoet"),"%1$s",((t,i)=>(0,u.jsxs)(o.Fragment,{children:[(0,u.jsx)(Fs.Eg,{segments:e.segments},`segment-${i}`),(0,u.jsx)(Fs.$6,{newsletter:e},`filter-segment-${i}`)]},i)));let i=(0,Fe._x)("month",'month in the sentence "1 month after inactivity"',"mailpoet");e.options.afterTimeNumber>1&&"months"===e.options.afterTimeType?i=(0,Fe._x)("months",'months in the sentence "5 months after inactivity"',"mailpoet"):e.options.afterTimeNumber>1&&"weeks"===e.options.afterTimeType?i=(0,Fe._x)("weeks",'weeks in the sentence "5 weeks after inactivity"',"mailpoet"):1===e.options.afterTimeNumber&&"weeks"===e.options.afterTimeType&&(i=(0,Fe._x)("week",'week in the sentence "1 week after inactivity"',"mailpoet"));const a=(0,Fe._x)("{$count} {$frequency} after inactivity",'example: "5 months after inactivity"',"mailpoet").replace("{$count}",e.options.afterTimeNumber).replace("{$frequency}",i);return(0,u.jsxs)("span",{children:[t,(0,u.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,u.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,u.jsx)(Gs.P,{})}),a]})]})};renderItem=(e,t)=>{const i=ee()("manage-column","column-primary","has-row-actions");return(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:i,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,zt.Q2)(e)},children:e.subject}),t]}),(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===pn?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Fe.__)("Clicked, Opened","mailpoet"),children:(0,u.jsx)(ui,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,u.jsx)("td",{className:"column","data-colname":(0,Fe.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Last modified on","mailpoet"),children:[c.MailPoet.Date.short(e.updated_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,u.jsxs)(u.Fragment,{children:[0===this.state.newslettersCount&&(0,u.jsx)(li,{filter:e=>"re_engagement"===e.slug,hideScreenOptions:!1,hideClosingButton:!0}),0!==this.state.newslettersCount&&(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"re_engagement",base_url:"re_engagement",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:hn,bulk_actions:gn,item_actions:_n,messages:un,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,zt._X)(e),(0,zt.bF)(e)}})]})}}fn.propTypes={location:Te().object.isRequired,match:Te().shape({params:Te().object}).isRequired},fn.displayName="NewsletterListReEngagement";const bn=(0,Ne.EN)((0,r.withBoundary)(fn)),xn=c.MailPoet.trackingConfig.emailTrackingEnabled,vn=[{name:"subject",label:(0,Fe.__)("Subject","mailpoet")},{name:"status",label:(0,Fe.__)("Status","mailpoet")},{name:"segments",label:(0,Fe.__)("Lists","mailpoet")},{name:"statistics",label:(0,Fe.__)("Clicked, Opened","mailpoet"),display:xn},{name:"sent_at",label:(0,Fe.__)("Sent on","mailpoet"),sortable:!0}],jn={onNoItemsFound:(e,t)=>t?(0,Fe.__)("No emails found.","mailpoet"):(0,Fe.__)("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 i=null;i=1===t?(0,Fe.__)("1 email was moved to the trash.","mailpoet"):(0,Fe.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email was permanently deleted.","mailpoet"):(0,Fe.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?(0,Fe.__)("1 email has been restored from the Trash.","mailpoet"):(0,Fe.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},yn=[{name:"trash",label:(0,Fe.__)("Move to trash","mailpoet"),onSuccess:jn.onTrash}],wn=(0,zt.y8)([{name:"view",link:function(e){return(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Preview","mailpoet")})}},{name:"trash",className:"mailpoet-hide-on-mobile"}]),Sn=(e,t,i)=>{const a=ee()("manage-column","column-primary","has-row-actions");return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("td",{className:a,children:[(0,u.jsx)("strong",{children:(0,u.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:e.queue.newsletter_rendered_subject||e.subject})}),t]}),(0,u.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,Fe.__)("Status","mailpoet"),children:(0,u.jsx)($s,{newsletter:e,mailerLog:i.mta_log})}),(0,u.jsxs)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Lists","mailpoet"),children:[(0,u.jsx)(Fs.Eg,{segments:e.segments,dimension:"large"}),(0,u.jsx)(Fs.$6,{newsletter:e,dimension:"large"})]}),!0===xn?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Fe.__)("Clicked, Opened","mailpoet"),children:(0,u.jsx)(ui,{newsletter:e,currentTime:i.current_time})}):null,(0,u.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Fe.__)("Sent on","mailpoet"),children:e.sent_at?(0,u.jsxs)(u.Fragment,{children:[c.MailPoet.Date.short(e.sent_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.sent_at)]}):null})]})};function Pn(e){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Me.Link,{className:"mailpoet-button button button-secondary button-small",to:"/notification",children:(0,Fe.__)("Back to Post notifications","mailpoet")}),(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:e.location,params:{...e.match.params,parentId:e.parentId},endpoint:"newsletters",type:"notification_history",base_url:"notification/history/:parentId",onRenderItem:Sn,columns:vn,messages:jn,item_actions:wn,bulk_actions:yn,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{(0,zt._X)(e),(0,zt.bF)(e)}})]})}Pn.propTypes={parentId:Te().string.isRequired,location:Te().shape({pathname:Te().string}).isRequired,match:Te().shape({params:Te().shape({id:Te().node}).isRequired}).isRequired},Pn.displayName="NewsletterListNotificationHistory";const Mn=(0,Ne.EN)((0,r.withBoundary)(Pn)),Nn=[{name:"subscriber_id",label:(0,Fe.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,Fe._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet")},{name:"failureReason",label:(0,Fe.__)("Failure reason (if applicable)","mailpoet")}],In={onNoItemsFound:()=>(0,Fe.__)("No sending task found.","mailpoet")};function Cn(e){const[t,i]=(0,o.useState)({id:e.match.params.id,subject:"",sent:!1});return(0,o.useEffect)((()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:t.id}}).done((e=>i({id:t.id,subject:e.data.subject,sent:null!==e.data.sent_at}))).fail((e=>c.MailPoet.Notice.showApiErrorNotice(e)))}),[t.id]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h1",{children:(0,Fe._x)("Sending status","Page title. This page displays a list of emails along with their sending status: unprocessed, sent or failed.","mailpoet")}),(0,u.jsx)(An,{newsletter:t}),(0,u.jsx)(En,{location:e.location,params:e.match.params})]})}Cn.propTypes={location:Te().shape({pathname:Te().string}).isRequired,match:Te().shape({params:Te().shape({id:Te().string.isRequired}).isRequired}).isRequired},Cn.displayName="SendingStatus";const kn=(e,t)=>e.location.pathname===t.location.pathname&&e.params.id===t.params.id,Tn=e=>(0,u.jsx)("div",{children:(0,u.jsx)(Rn,{...e})}),En=(0,o.memo)((e=>{let{location:t,params:i}=e;return(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:t,params:i,endpoint:"sending_task_subscribers",base_url:"sending-status/:id",onRenderItem:Tn,getListingItemKey:e=>`${e.taskId}-${e.subscriberId}`,columns:Nn,messages:In,auto_refresh:!0,sort_by:"failed",sort_order:"desc",afterGetItems:e=>{(0,zt._X)(e),(0,zt.bF)(e)}})}),kn);function An(e){let{newsletter:t}=e;return t.id&&t.subject&&t.sent?(0,u.jsx)("p",{children:(0,u.jsx)(Me.Link,{to:`/stats/${t.id}`,children:t.subject})}):null}function Rn(e){let{error:t,failed:i,taskId:a,processed:s,email:n,subscriberId:o,lastName:r,firstName:l}=e;const d=ee()("manage-column","column-primary","has-row-actions");let m=(0,Fe._x)("Unprocessed","status when the sending of a newsletter has not been processed","mailpoet");return s&&(m=i?(0,u.jsxs)("span",{children:[(0,Fe._x)("Failed","status when the sending of a newsletter has failed","mailpoet"),(0,u.jsx)("br",{}),(0,u.jsx)("a",{className:"button",href:"#",onClick:e=>{e.preventDefault(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sending_task_subscribers",action:"resend",data:{taskId:a,subscriberId:o}}).done((()=>window.mailpoet_listing.forceUpdate())).fail((e=>c.MailPoet.Notice.showApiErrorNotice(e)))},children:(0,Fe.__)("Resend","mailpoet")})]}):(0,Fe._x)("Sent","status when a newsletter has been sent","mailpoet")),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("td",{"data-automation-id":`name_${a}_${o}`,className:d,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-subscribers#/edit/${o}`,children:n}),(0,u.jsx)("div",{className:"mailpoet-listing-subtitle",children:`${l} ${r}`})]}),(0,u.jsx)("td",{className:"column","data-automation-id":`status_${a}_${o}`,"data-colname":(0,Fe._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet"),children:m}),(0,u.jsx)("td",{className:"column","data-automation-id":`error_${a}_${o}`,"data-colname":(0,Fe.__)("Failure reason (if applicable)","mailpoet"),children:t})]})}En.propTypes={location:Te().shape({pathname:Te().string}).isRequired,params:Te().shape({id:Te().string.isRequired}).isRequired},An.propTypes={newsletter:Te().shape({id:Te().string,subject:Te().string,sent:Te().bool})},An.defaultProps={newsletter:{id:null,subject:null,sent:!1}},Rn.propTypes={error:Te().string,email:Te().string.isRequired,failed:Te().number.isRequired,taskId:Te().number.isRequired,lastName:Te().string.isRequired,firstName:Te().string.isRequired,processed:Te().number.isRequired,subscriberId:Te().number.isRequired},Rn.defaultProps={error:""},Rn.displayName="ListingItem",Cn.displayName="SendingStatus";var Fn=i(23584),On=i(52249),Ln=i(23064),Dn=i.n(Ln);function qn(e){const t=e.installedDaysAgo,i=t>30?c.MailPoet.I18n.t("reviewRequestUsingForMonths").replace("[months]",Math.round(t/30)):c.MailPoet.I18n.t("reviewRequestUsingForDays").replace("[days]",t);return(0,u.jsxs)("div",{className:"mailpoet_review_request",children:[(0,u.jsx)("img",{src:e.reviewRequestIllustrationUrl,height:"280",width:"280",alt:""}),(0,u.jsx)("h2",{children:c.MailPoet.I18n.t("reviewRequestHeading")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("reviewRequestDidYouKnow").replace("[username]",e.username)}),(0,u.jsx)("p",{children:i}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{href:"http://bit.ly/2Bi124o",target:"_blank",rel:"noopener noreferrer",className:"button button-primary",children:c.MailPoet.I18n.t("reviewRequestRateUsNow")})}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{id:"mailpoet_review_request_not_now",children:c.MailPoet.I18n.t("reviewRequestNotNow")})})]})}qn.propTypes={installedDaysAgo:Te().number.isRequired,reviewRequestIllustrationUrl:Te().string.isRequired,username:Te().string.isRequired};const $n=()=>((0,o.useLayoutEffect)((()=>{window.mailpoet_display_nps_poll&&c.MailPoet.libs3rdPartyEnabled&&(ns||(ns=c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"analytics",action:"getTrackingData"})),ns).then((e=>{let{data:t}=e;return(e=>{let t;t=window.mailpoet_display_nps_form?"EqOgKsgZd832Sz9w":window.mailpoet_is_new_user?"6L479eVPXk7pBn6S":"k0aJAsQAWI2ERyGv",Dn()({writeKey:t,userId:window.mailpoet_current_wp_user.ID+window.mailpoet_site_url,traits:{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},events:{submit:e=>{e.rating>=9&&e.completed&&c.MailPoet.Modal.popup({width:800,template:On.renderToString(qn({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",(()=>c.MailPoet.Modal.close()))}})}}})})(t)}))}),[]),null),Bn=e=>function(t){return $n(),(0,u.jsx)(e,{...t})};function Wn(){return(0,u.jsx)(d.Q,{children:(0,u.jsxs)(Me.Link,{id:"mailpoet-new-email",className:"mailpoet-button button-secondary",to:"/new",onClick:()=>c.MailPoet.trackEvent("Emails > Add New"),"data-automation-id":"new_email",children:[$e.R,(0,u.jsx)("span",{children:(0,Fe.__)("New email","mailpoet")})]})})}function Vn(e){let{children:t,location:i}=e;return null!==(0,wi.X)(i)||(e=>e.hash.match(/^#\/new/)||e.pathname.match(/^\/new/))(i)?null:t}Vn.propTypes={location:Te().string.isRequired,children:Te().node.isRequired};const Un=(0,Ne.EN)(Vn);function zn(){return(0,u.jsx)("style",{dangerouslySetInnerHTML:{__html:".wrap { margin: 0 !important; }"}})}var Hn=i(23535),Zn=i(59355),Yn=i(99983);const Gn=20,Kn=5,Qn=5,Xn=5,Jn=100,eo=e=>{const t=e<.1?2:1;return c.MailPoet.Num.toLocaleFixed(e,t)},to=e=>+(+e).toFixed(1);function io(e){let{newsletter:t,isWoocommerceActive:i}=e;const a=t.total_sent||0;let s=0,n=0,o=0,r=0,l=0;a>0&&(s=100*t.statistics.clicked/a,n=100*t.statistics.opened/a,o=100*t.statistics.machineOpened/a,r=100*t.statistics.unsubscribed/a,l=100*t.statistics.bounced/a);const d=eo(s),c=eo(n),m=eo(o),p=eo(r),h=eo(l),g=a>=Gn&&t.statistics.opened>=Kn,_=t.statistics.unsubscribed>=Qn&&a>=Jn,b=t.statistics.bounced>=Xn&&a>=Jn,x=(0,Yn.y)("opened",n)||"",v=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,u.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${x}`,children:[c,"% "]}),(0,Fe._x)("opened","Percentage of subscribers that opened a newsletter link","mailpoet")]}),g&&(0,u.jsx)(Yn.$,{isInverted:!1,stat:"opened",rate:n,tooltipId:`opened-${t.id||"0"}`,tooltipPlace:"right"})]}),j=(0,u.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,u.jsxs)("span",{className:"mailpoet-statistics-value-number",children:[m,"% "]}),(0,Fe._x)("machine-opened","Percentage of newsletters that were opened by a machine","mailpoet"),(0,u.jsx)(De.Tooltip,{tooltip:f()((0,Fe.__)("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,u.jsx)("span",{style:{pointerEvents:"all"},children:(0,u.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")))})]}),y=to(r),w=_?(0,Yn.y)("unsubscribed",y):"",S=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,u.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${w}`,children:[p,"% "]}),(0,Fe._x)("unsubscribed","Percentage of subscribers that unsubscribed from a newsletter","mailpoet")]}),_&&(0,u.jsx)(Yn.$,{isInverted:!1,stat:"unsubscribed",rate:y,tooltipId:`unsubscribed-${t.id||"0"}`,tooltipPlace:"right"})]}),P=to(l),M=b?(0,Yn.y)("bounced",P):"",N=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,u.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${M}`,children:[h,"% "]}),(0,Fe._x)("bounced","Percentage of subscribers that bounced from a newsletter","mailpoet")]}),b&&(0,u.jsx)(Yn.$,{isInverted:!1,stat:"bounced",rate:P,tooltipId:`bounced-${t.id||"0"}`,tooltipPlace:"right"})]}),I=(0,Yn.y)("clicked",s),C=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-statistics-value",children:[(0,u.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${I}`,children:[d,"% "]}),(0,Fe._x)("clicked","Percentage of subscribers that clicked a newsletter link","mailpoet")]}),g&&(0,u.jsx)(Yn.$,{isInverted:!1,stat:"clicked",rate:s,tooltipId:`clicked-${t.id||"0"}`,tooltipPlace:"right"})]});return(0,u.jsxs)("div",{className:"mailpoet-stats-general",children:[(0,u.jsxs)(Fi.Grid.ThreeColumns,{className:"mailpoet-stats-general-top-row",children:[(0,u.jsx)("div",{children:(0,u.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,Fe.__)("Sent to","mailpoet"),": ",(0,u.jsx)("span",{className:"mailpoet-statistics-value-number",children:a.toLocaleString()})]})}),(0,u.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:S}),(0,u.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:N})]}),(0,u.jsxs)(Fi.Grid.ThreeColumns,{children:[(0,u.jsx)("div",{children:C}),(0,u.jsxs)("div",{className:"mailpoet-statistics-with-left-separator",children:[v,j]}),i&&(0,u.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:Ot.Hooks.applyFilters("mailpoet_newsletters_revenues_stats",null,t.statistics.revenue)}),!i&&(0,u.jsx)("div",{})]}),(0,u.jsxs)("div",{className:"mailpoet-stats-general-read-more",children:[(0,u.jsx)("p",{className:"mailpoet-stats-has-margin-left",children:(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/190-whats-a-good-email-open-rate",target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Read more on stats.","mailpoet")})}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{href:`admin.php?page=mailpoet-newsletters#/sending-status/${t.id}`,children:(0,Fe.__)("Sending status","mailpoet")})})]})]})}io.displayName="NewsletterGeneralStats";var ao=i(53339);const so=e=>{let t=`?page=mailpoet-newsletter-editor&id=${e.id}`;return c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")&&e.wp_post_id&&(t=`admin.php?page=mailpoet-email-editor&postId=${e.wp_post_id}`),t},no=e=>{const t=so(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,r.confirmAlert)({message:(0,Fe.__)("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},oo=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{};c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((t=>{const i=so(t.data);c.MailPoet.Notice.success((0,Fe.sprintf)((0,Fe.__)('Email "%s" has been duplicated. New email: %s ',"mailpoet"),e.subject,i,t.data.subject),{static:!0})})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})).always((()=>{t()}))},ro=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{};c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"delete",data:{id:e.id}}).done((()=>{c.MailPoet.Notice.success((0,Fe.__)('Email "%1$s" has been deleted.',"mailpoet").replace("%1$s",e.subject)),window.location.href="?page=mailpoet-newsletters"})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})).always((()=>{t()}))};function lo(e){let{newsletter:t}=e;const[i,a]=(0,o.useState)(!1),s=t?.queue?.scheduled_at||t?.queue?.created_at||t?.created_at;return(0,u.jsxs)(Fi.Grid.ThreeColumns,{className:"mailpoet-stats-info",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)(bt.X,{level:1,children:t.subject}),(0,u.jsxs)("div",{children:[(0,u.jsx)(r.Tag,{isInverted:!1,children:(0,r.getNewsletterStatusString)(t.status)})," ",(0,u.jsxs)("b",{children:[c.MailPoet.Date.short(s)," • ",c.MailPoet.Date.time(s)]})]}),Array.isArray(t.segments)&&t.segments.length&&(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"mailpoet-stats-info-key",children:(0,Fe.__)("To","mailpoet")}),": ",(0,u.jsx)(r.SegmentTags,{dimension:"large",segments:t.segments}),(0,u.jsx)(r.FilterSegmentTag,{newsletter:t,dimension:"large"})]})]}),(0,u.jsx)("div",{className:"mailpoet-stats-info-sender-preview",children:(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,u.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Fe.__)("From","mailpoet"),": "]}),t.sender_address?t.sender_address:"-"]}),(0,u.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,u.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Fe.__)("Reply-to","mailpoet"),": "]}),t.reply_to_address?t.reply_to_address:"-"]}),(0,u.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,u.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Fe.__)("GA campaign","mailpoet"),": "]}),t.ga_campaign?t.ga_campaign:"-"]})]})}),(0,u.jsx)("div",{className:"mailpoet-stats-button-group",children:(0,u.jsxs)(Ht.Z,{children:[(0,u.jsx)(pe.ZP,{href:t.preview_url,target:"_blank",rel:"noopener noreferrer",variant:"secondary",children:(0,Fe.__)("Preview","mailpoet")}),(0,u.jsx)(Zt.Z,{className:"mailpoet-stats-has-margin-left",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:e=>{let{isOpen:i,onToggle:a}=e;return(0,u.jsxs)(Ht.Z,{children:[(0,u.jsx)(pe.ZP,{disabled:"standard"!==t.type,onClick:()=>{no(t)},variant:"primary",children:(0,Fe.__)("Edit","mailpoet")}),(0,u.jsxs)(pe.ZP,{onClick:a,"aria-expanded":i,variant:"primary",children:[" ",(0,u.jsx)(Gt.Z,{icon:Kt.Z,size:18})]})]})},renderContent:()=>(0,u.jsxs)(ao.Z,{children:[(0,u.jsx)(Yt.Z,{isBusy:i,className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:"standard"!==t.type,onClick:()=>{a(!0),oo(t,(()=>{a(!1)}))},children:(0,Fe.__)("Duplicate","mailpoet")}),(0,u.jsx)(Yt.Z,{isBusy:i,isDestructive:!0,onClick:()=>{a(!0),ro(t,(()=>{a(!1)}))},children:(0,Fe.__)("Move to Trash","mailpoet")})]})})]})})]})}lo.displayName="NewsletterStatsInfo";var co=i(83393);const{subscribersLimitReached:mo,subscribersLimit:po,subscribersCount:uo,premiumActive:ho,hasValidApiKey:go,hasValidPremiumKey:_o,isPremiumPluginInstalled:fo,pluginPartialKey:bo}=c.MailPoet,xo=go||_o,vo=e=>(0,u.jsx)("p",{children:f()(e,/(\[subscribersCount]|\[subscribersLimit])/g,(e=>"[subscribersCount]"===e?uo:po))}),jo=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"_blank";return(0,u.jsx)(Oe.z,{href:t,target:i,rel:"noopener noreferrer",children:e})},yo=e=>(0,u.jsx)(co.yM,{buttonText:e});function wo(e){let t,i,{message:a,actionButton:s}=e;if(!_o||fo&&ho)if(mo){t=vo((0,Fe.__)("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=xo?c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(bo):c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(+uo+1,null,null,null);i=jo((0,Fe.__)("Upgrade your plan","mailpoet"),e)}else t=a,i=s;else t=vo((0,Fe.__)("Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.","mailpoet")),i=yo(fo?(0,Fe.__)("Activate MailPoet Premium plugin","mailpoet"):(0,Fe.__)("Download MailPoet Premium plugin","mailpoet"));return(0,u.jsx)(Lt.K,{title:(0,Fe.__)("This is a Premium feature","mailpoet"),message:t,actionButton:i})}function So(){const e=(0,u.jsx)(Oe.z,{href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,"starter",{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,Fe.__)("Upgrade","mailpoet")}),t=(0,u.jsxs)("p",{children:[(0,Fe.__)("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. All starting $10 per month.","mailpoet")," ",(0,u.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",children:(0,Fe.__)("Learn more","mailpoet")}),"."]});return(0,u.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,u.jsx)(wo,{message:t,actionButton:e})})}function Po(){if(!window.mailpoet_display_detailed_stats)return(0,u.jsx)(So,{});if(window.mailpoet_subscribers_limit_reached){const e=window.mailpoet_has_valid_api_key,t=(0,Fe.__)("Upgrade required","mailpoet"),i=e?(0,Fe.__)("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"):(0,Fe.__)("Congratulations, you now have [subscribersCount] subscribers! Our free version is limited to [subscribersLimit] subscribers. You need to upgrade now to be able to continue using MailPoet.","mailpoet").replace("[subscribersLimit]",c.MailPoet.subscribersLimit.toString()).replace("[subscribersCount]",c.MailPoet.subscribersCount.toString()),a=e?c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(c.MailPoet.pluginPartialKey):c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(window.mailpoet_subscribers_count+1);return(0,u.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,u.jsx)(Lt.K,{title:t,message:(0,u.jsx)("p",{children:i}),actionButton:(0,u.jsx)(Oe.z,{target:"_blank",rel:"noopener noreferrer",href:a,children:(0,Fe.__)("Upgrade Now","mailpoet")})})})}return null}Po.displayName="PremiumBanner";const Mo=(0,r.withBoundary)(Po);function No(e){let{match:t,history:i,location:a}=e;const[s,n]=(0,o.useState)({item:void 0,loading:!0}),l=(0,o.useCallback)((e=>{n({loading:!0,item:s.item}),c.MailPoet.Modal.loading(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:window.mailpoet_display_detailed_stats?"stats":"newsletters",action:window.mailpoet_display_detailed_stats?"get":"getWithStats",data:{id:e,accept:"all"}}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>{n({loading:!1,item:e.data})})).fail((e=>{c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0}),n({loading:!1}),i.push("/")}))}),[i,s.item]);(0,o.useEffect)((()=>{window.scrollTo(0,0),s.item?.id!==t.params.id&&l(t.params.id)}),[t.params.id,l,s.item]);const{item:m,loading:p}=s,h=m;return p?null:h?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(St.B,{}),(0,u.jsx)(zn,{}),(0,u.jsx)(d.Q,{}),(0,u.jsxs)("div",{className:"mailpoet-stats-page",children:[(0,u.jsx)(w,{}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(lo,{newsletter:h})}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(io,{newsletter:h,isWoocommerceActive:c.MailPoet.isWoocommerceActive})}),(0,u.jsxs)(Hn.m,{activeKey:"clicked",children:[(0,u.jsx)(Zn.O,{title:(0,Fe.__)("Clicked Links","mailpoet"),children:Ot.Hooks.applyFilters("mailpoet_newsletters_clicked_links_table",(0,u.jsx)(Mo,{}),h.clicked_links)},"clicked"),Ot.Hooks.applyFilters("mailpoet_newsletters_purchased_products",null,h),(0,u.jsx)(Zn.O,{title:(0,Fe.__)("Subscriber Engagement","mailpoet"),automationId:"engagement-tab",children:Ot.Hooks.applyFilters("mailpoet_newsletters_subscriber_engagement",(0,u.jsx)(Mo,{}),a,t.params,h)},"engagement"),(0,u.jsx)(Zn.O,{title:(0,Fe._x)("Bounces","A tab title for the list of bounces (w.wiki/45Qc)","mailpoet"),automationId:"bounces-tab",children:Ot.Hooks.applyFilters("mailpoet_newsletters_bounces",(0,u.jsx)(Mo,{}),a,t.params)},"bounces")]})]})]}):(0,u.jsxs)("h3",{children:[" ",(0,Fe.__)("This email does not exist.","mailpoet")," "]})}No.displayName="CampaignStatsPage";const Io=(0,Ne.EN)(No);function Co(e){let{newsletters:t}=e;return(0,u.jsxs)(p.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,u.jsx)("h3",{children:(0,Fe.__)("Paused emails","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("There was problem sending the following email(s), please fix the issues described for each email and resume.","mailpoet")}),(0,u.jsx)("ul",{children:t.map((e=>{let{id:t,subject:i}=e;return(0,u.jsx)("li",{children:i},t)}))})]})}Co.displayName="CorruptEmailNotice";const ko=window.mailpoet_woocommerce_automatic_emails||[],To=Bn((()=>{const{parentId:e}=(0,Ne.UO)();return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Un,{children:(0,u.jsx)(Wn,{})}),c.MailPoet.corrupt_newsletters.length>0&&(0,u.jsx)(Co,{newsletters:c.MailPoet.corrupt_newsletters}),(0,u.jsxs)(Fn.t,{activeKey:"standard",routerType:"switch-only",onSwitch:e=>(e=>c.MailPoet.trackEvent(`Tab Emails > ${e} clicked`))(e),automationId:"newsletters_listing_tabs",children:[(0,u.jsx)(r.Tab,{route:"standard/(.*)?",title:(0,Fe.__)("Newsletters","mailpoet"),automationId:`tab-${(0,Fe.__)("Newsletters","mailpoet")}`,children:(0,u.jsx)(Ys,{})},"standard"),(0,u.jsx)(r.Tab,{route:"welcome/(.*)?",title:(0,Fe.__)("Welcome Emails","mailpoet"),automationId:`tab-${(0,Fe.__)("Welcome Emails","mailpoet")}`,children:(0,u.jsx)(nn,{})},"welcome"),(0,u.jsx)(r.Tab,{route:"notification/(.*)?",title:(0,Fe.__)("Post Notifications","mailpoet"),automationId:`tab-${(0,Fe.__)("Post Notifications","mailpoet")}`,children:e?(0,u.jsx)(Mn,{parentId:e}):(0,u.jsx)(mn,{})},"notification"),(0,u.jsx)(r.Tab,{route:"re_engagement/(.*)?",title:(0,Fe.__)("Re-engagement Emails","mailpoet"),automationId:`tab-${(0,Fe.__)("Re-engagement Emails","mailpoet")}`,children:(0,u.jsx)(bn,{})},"re_engagement"),window.mailpoet_woocommerce_active&&!c.MailPoet.hideAutomations&&rt.default.map(ko,(e=>(0,u.jsx)(r.Tab,{route:`${e.slug}/(.*)?`,title:e.title,automationId:`tab-${e.title}`,children:(0,u.jsx)(ji,{})},e.slug)))]})]})}));function Eo(e){let{history:t}=e;return(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(li,{history:t,hideClosingButton:0===window.mailpoet_newsletters_count})})}To.displayName="NewsletterTabs",Eo.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired},Eo.displayName="NewNewsletter";const Ao=[...(()=>{const e=[];return rt.default.each(ko,(t=>{e.push({path:`/${t.slug}/(.*)?`,component:(0,r.withBoundary)(To)});const{events:i}=t;rt.default.isObject(i)&&rt.default.each(i,(i=>{e.push({path:`/new/${t.slug}/${i.slug}/conditions`,render:e=>{const a={...e,email:t,name:i.slug};return(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Rs,{...a})})}})})),e.push({path:`/new/${t.slug}`,render:e=>{const i={...e,email:t};return(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(ei,{...i})})}})})),e})(),{path:"/notification/history/:parentId/(.*)?",render:(0,r.withBoundary)(To)},{path:"/(standard|welcome|notification|re_engagement)/(.*)?",render:(0,r.withBoundary)(To)},{path:"/new/standard",render:(0,r.withBoundary)(Ns)},{path:"/new/notification",render:(0,r.withBoundary)(ks)},{path:"/new/welcome",render:(0,r.withBoundary)(Es)},{path:"/new/re-engagement",render:(0,r.withBoundary)(As)},{path:"/new",render:(0,r.withBoundary)(Eo)},{name:"template",path:"/template/:id",render:(0,r.withBoundary)(ki)},{path:"/send/congratulate/:id",render:(0,r.withBoundary)(Ps)},{path:"/send/:id",render:(0,r.withBoundary)(hs)},{path:"/sending-status/:id/(.*)?",render:(0,r.withBoundary)(Cn)},{path:"/stats/:id/(.*)?",render:(0,r.withBoundary)(Io)}];function Ro(){return(0,u.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(m.w,{}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(h,{mailpoetInstalledDaysAgo:c.MailPoet.installedDaysAgo,sendTransactionalEmails:c.MailPoet.transactionalEmailsEnabled,mtaMethod:c.MailPoet.mtaMethod,apiVersion:c.MailPoet.apiVersion,noticeDismissed:c.MailPoet.transactionalEmailsOptInNoticeDismissed})}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(w,{})}),(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{exact:!0,path:"/",render:()=>(0,u.jsx)(Ne.l_,{to:0===window.mailpoet_newsletters_count?"/new":"/standard"})}),Ao.map((e=>(0,u.jsx)(Ne.AW,{path:e.path,component:e.component,name:e.name||null,data:e.data||null,render:e.render},e.path)))]})]})})}const Fo=document.getElementById("newsletters_container");Fo&&((0,r.registerTranslations)(),(0,n.s)(Fo).render((0,u.jsx)(Ro,{})));var Oo=i(7969),Lo=i(36657);function Do(e){let{segmentType:t}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(d.Q,{children:["static"===t&&(0,u.jsxs)(Me.Link,{className:"mailpoet-button button-secondary",to:"/new","data-automation-id":"new-list",children:[$e.R,(0,u.jsx)("span",{children:c.MailPoet.I18n.t("new")})]}),"dynamic"===t&&(0,u.jsxs)(Me.Link,{className:"mailpoet-button button-secondary",to:Lo.$W,"data-automation-id":"new-segment",children:[$e.R,(0,u.jsx)("span",{children:c.MailPoet.I18n.t("newSegment")})]})]}),(0,u.jsx)(qe,{subscribersInPlan:c.MailPoet.subscribersCount,subscribersInPlanLimit:c.MailPoet.subscribersLimit}),(0,u.jsx)(Le,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at}),(0,u.jsx)(w,{})]})}const qo=e=>"wp_users"===e.type,$o=e=>"woocommerce_users"===e.type,Bo=e=>qo(e)||$o(e),Wo=c.MailPoet.trackingConfig.emailTrackingEnabled,Vo=[{name:"name",label:c.MailPoet.I18n.t("name"),sortable:!0},{name:"description",label:c.MailPoet.I18n.t("description")},{name:"average_subscriber_score",label:c.MailPoet.I18n.t("listScore"),display:Wo},{name:"subscribed",label:c.MailPoet.I18n.t("subscribed"),className:"mailpoet-listing-column-narrow"},{name:"unconfirmed",label:c.MailPoet.I18n.t("unconfirmed"),className:"mailpoet-listing-column-narrow"},{name:"unsubscribed",label:c.MailPoet.I18n.t("unsubscribed"),className:"mailpoet-listing-column-narrow"},{name:"inactive",label:c.MailPoet.I18n.t("inactive"),className:"mailpoet-listing-column-narrow"},{name:"bounced",label:c.MailPoet.I18n.t("bounced"),className:"mailpoet-listing-column-narrow"},{name:"created_at",label:c.MailPoet.I18n.t("createdOn"),sortable:!0}],Uo={onTrash:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneSegmentTrashed"):c.MailPoet.I18n.t("multipleSegmentsTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneSegmentDeleted"):c.MailPoet.I18n.t("multipleSegmentsDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneSegmentRestored"):c.MailPoet.I18n.t("multipleSegmentsRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},zo=[{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:Uo.onTrash}],Ho=e=>!Bo(e),Zo=[{name:"edit",className:"mailpoet-hide-on-mobile",link:function(e){return(0,u.jsx)(Me.Link,{to:`/edit/${e.id}`,children:c.MailPoet.I18n.t("edit")})},display:function(e){return!Bo(e)}},{name:"duplicate_segment",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("duplicate"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success(c.MailPoet.I18n.t("listDuplicated").replace("%1$s",(0,Oo.r)(e.data.name))),t()})).fail((e=>{c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})),display:function(e){return!Bo(e)}},{name:"read_more",className:"mailpoet-hide-on-mobile",link:function(){return(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/133-the-wordpress-users-list",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("readMore")})},display:function(e){return qo(e)}},{name:"synchronize_segment",label:c.MailPoet.I18n.t("forceSync"),onClick:async function(e,t){c.MailPoet.Modal.loading(!0),await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"synchronize",data:{type:e.type}}).done((()=>{let i=c.MailPoet.I18n.t("listSynchronized").replace("%1$s",e.name);"woocommerce_users"===e.type&&(i=c.MailPoet.I18n.t("listSynchronizationWasScheduled").replace("%1$s",e.name)),c.MailPoet.Modal.loading(!1),c.MailPoet.Notice.success(i),t()})).fail((e=>{c.MailPoet.Modal.loading(!1),e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},display:function(e){return qo(e)||$o(e)}},{name:"view_subscribers",link:function(e){return(0,u.jsx)("a",{href:e.subscribers_url,"data-automation-id":`view_subscribers_${e.name}`,children:c.MailPoet.I18n.t("viewSubscribers")})}},{name:"trash",className:"mailpoet-hide-on-mobile",display:function(e){return!$o(e)}}];class Yo extends o.Component{renderItem=(e,t)=>{const i=ee()("manage-column","column-primary","has-row-actions"),a=Number(e.subscribers_count.subscribed||0),s=Number(e.subscribers_count.unconfirmed||0),n=Number(e.subscribers_count.unsubscribed||0),o=Number(e.subscribers_count.inactive||0),r=Number(e.subscribers_count.bounced||0);let l;return l=Bo(e)?(0,u.jsx)("span",{className:"mailpoet-listing-title",children:(0,Oo.r)(e.name)}):(0,u.jsx)(Me.Link,{className:"mailpoet-listing-title",to:`/edit/${e.id}`,children:(0,Oo.r)(e.name)}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("td",{className:i,"data-automation-id":`segment_name_${(0,Oo.kb)(e.name)}`,children:[l,t]}),(0,u.jsx)("td",{"data-colname":c.MailPoet.I18n.t("description"),children:(0,u.jsx)("abbr",{children:(0,Oo.r)(e.description)})}),Wo?(0,u.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":c.MailPoet.I18n.t("averageScore"),children:(0,u.jsx)("div",{className:"mailpoet-listing-stats",children:(0,u.jsx)(_e,{id:e.id,engagementScore:e.average_engagement_score})})}):null,(0,u.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("subscribed"),children:(0,u.jsx)("abbr",{children:a.toLocaleString()})}),(0,u.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("unconfirmed"),children:(0,u.jsx)("abbr",{children:s.toLocaleString()})}),(0,u.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("unsubscribed"),children:(0,u.jsx)("abbr",{children:n.toLocaleString()})}),(0,u.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("inactive"),children:(0,u.jsx)("abbr",{children:o.toLocaleString()})}),(0,u.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("bounced"),children:(0,u.jsx)("abbr",{children:r.toLocaleString()})}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("createdOn"),children:[c.MailPoet.Date.short(e.created_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.created_at)]})]})};render(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Do,{segmentType:"static"}),(0,u.jsx)("div",{className:"mailpoet-segments-listing",children:(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,messages:Uo,search:!1,endpoint:"segments",base_url:"lists",onRenderItem:this.renderItem,columns:Vo,bulk_actions:zo,item_actions:Zo,sort_by:"name",sort_order:"asc",isItemDeletable:Ho,isItemToggleable:qo})})]})}}const Go=(0,Ne.EN)(Yo),Ko=[{name:"name",label:c.MailPoet.I18n.t("name"),type:"text"},{name:"description",label:c.MailPoet.I18n.t("description"),type:"textarea",tip:c.MailPoet.I18n.t("segmentDescriptionTip")},{name:"showInManageSubscriptionPage",label:c.MailPoet.I18n.t("showInManageSubscriptionPage"),type:"checkbox",values:{showInManageSubscriptionPage:c.MailPoet.I18n.t("showInManageSubscriptionPageTip")},isChecked:!0}],Qo={onUpdate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("segmentUpdated"))},onCreate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("segmentAdded")),c.MailPoet.trackEvent("Lists > Add new")}};function Xo(e){let{match:t}=e;return(0,u.jsxs)("div",{className:"mailpoet-main-container",children:[(0,u.jsx)(d.Q,{}),(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(St.B,{}),(0,u.jsx)(Pt.m,{heading:c.MailPoet.I18n.t("segment"),headingPrefix:(0,u.jsx)(Pt.x,{href:"#/",label:(0,Fe.__)("Lists","mailpoet"),"aria-label":(0,Fe.__)("Navigate to the lists page","mailpoet")})}),(0,u.jsx)(b,{}),(0,u.jsx)(wt,{endpoint:"segments",fields:Ko,params:t.params,messages:Qo})]})}Xo.displayName="SegmentForm";const Jo=document.getElementById("static_segments_container");function er(){return(0,u.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(m.w,{}),(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{path:"/new",component:(0,r.withBoundary)(Xo)}),(0,u.jsx)(Ne.AW,{path:"/edit/:id",component:(0,r.withBoundary)(Xo)}),(0,u.jsx)(Ne.AW,{path:"*",component:(0,r.withBoundary)(Go)})]})]})})}Jo&&((0,r.registerTranslations)(),(0,n.s)(Jo).render((0,u.jsx)(er,{})));var tr=i(46166),ir=i(82203),ar=i(67201),sr=i(5019);function nr(e){let{children:t,title:i,description:a}=e;return(0,u.jsxs)("div",{className:"mailpoet-admin-fields",children:[(0,u.jsxs)("div",{className:"mailpoet-admin-fields-title",children:[(0,u.jsx)(sr.X,{level:4,children:i}),(0,u.jsx)("p",{children:a})]}),(0,u.jsx)(ir.C,{children:(0,u.jsx)(ar.Z,{children:t})})]})}function or(e){let{children:t,slug:i,title:a,description:s}=e;return(0,u.jsxs)("div",{className:"mailpoet-admin-field",children:[a&&(0,u.jsx)("p",{children:(0,u.jsx)("label",{htmlFor:`field_${i}`,children:a})}),(0,u.jsx)("div",{children:t}),s&&(0,u.jsx)("p",{className:"mailpoet-admin-field-description",children:s})]})}var rr=i(33334),lr=i(58678),dr=i(92180),cr=i(94460);function mr(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),a=(0,P.Z)((e=>e(dr.t).getAutomations()),[]),{updateSegmentFilter:s,updateSegmentFilterFromEvent:n}=(0,he.Z)(dr.t);(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&s({operator:lr.f5.ANY},t)}),[s,i,t]);const r=a.map((e=>({value:e.id,label:e.name})));return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{n("operator",t,e)},isMinWidth:!0,children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select"),(0,u.jsx)(tr.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("searchAutomations"),options:r,value:r.filter((e=>{if(!i.automation_ids)return;const t=e.value;return-1!==i.automation_ids.indexOf(t)})),onChange:e=>{s({automation_ids:e.map((e=>e.value))},t)}})]})}const pr={[cr.Z.ENTERED_AUTOMATION]:mr,[cr.Z.EXITED_AUTOMATION]:mr};function ur(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getNewslettersList()),[]),r=n?.map((e=>{const t=e.sent_at?c.MailPoet.Date.format(e.sent_at):c.MailPoet.I18n.t("notSentYet");return{label:e.subject,tag:t,value:Number(e.id)}}));return(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t),i.action===lr.zd.MACHINE_OPENED&&i.operator===lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[i.action,i.operator,t,a]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{isMinWidth:!0,automationId:"segment-email-opens-condition",value:i.operator,onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),i.action!==lr.zd.MACHINE_OPENED?(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")}):null]},"select"),(0,u.jsx)(tr.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("selectNewsletterPlaceholder"),options:r,automationId:"segment-email",value:(0,es.filter)((e=>{if(!i.newsletters)return;const t=e.value;return-1!==i.newsletters.indexOf(t)}),r),onChange:e=>{a({newsletters:(0,es.map)((0,es.parseInt)(10),(0,es.map)("value",e))},t)}})]})}const hr=e=>!!e;var gr=i(66265);function _r(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:s}=(0,he.Z)(dr.t);(0,o.useEffect)((()=>{(0,gr.J)(i.timeframe,lr.u4)||s({timeframe:lr.u4.IN_THE_LAST},t)}),[i,s,t]);const n=i.timeframe===lr.u4.IN_THE_LAST;return(0,u.jsx)(u.Fragment,{children:(l=e=>n&&"{days}"===e?(0,u.jsx)(r.Input,{type:"number",value:i.days||"","data-automation-id":"segment-number-of-days",onChange:e=>{a("days",t,e)},min:1,step:1,placeholder:c.MailPoet.I18n.t("daysPlaceholder")},"input"):"{timeframe}"===e?(0,u.jsxs)(lt.Select,{value:i.timeframe,onChange:e=>{a("timeframe",t,e)},children:[(0,u.jsx)("option",{value:"inTheLast",children:c.MailPoet.I18n.t("inTheLast")}),(0,u.jsx)("option",{value:"allTime",children:c.MailPoet.I18n.t("overAllTime")})]},"timeframe-select"):n&&"string"==typeof e&&e.trim().length>1?(0,u.jsx)("div",{children:e},e):null,c.MailPoet.I18n.t("emailActionOpensDaysSentence").split(/({days})|({timeframe})/gim).map(l))});var l}function fr(e){return e.timeframe===lr.u4.ALL_TIME||!!e.days}function br(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{void 0===i.operator&&a({operator:"more"},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fi.Grid.CenteredRow,{children:(n=e=>"{condition}"===e?(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:"more",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:"less",children:c.MailPoet.I18n.t("lessThan")}),(0,u.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("notEquals")})]},"select"):"{opens}"===e?(0,u.jsx)(at.I,{type:"number",value:i.opens||"","data-automation-id":"segment-number-of-opens",onChange:e=>{s("opens",t,e)},min:"0",placeholder:c.MailPoet.I18n.t("emailActionOpens")},"input"):"string"==typeof e&&e.trim().length>1?(0,u.jsx)("div",{children:e},"opens"):null,c.MailPoet.I18n.t("emailActionOpensSentence").split(/({condition})|({opens})|(\b[a-zA-Z]+\b)/gim).map(n))}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]});var n}const xr={[lr.zd.OPENS_ABSOLUTE_COUNT]:br,[lr.zd.MACHINE_OPENS_ABSOLUTE_COUNT]:br,[lr.zd.CLICKED]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getNewslettersList()),[]),[r,l]=(0,o.useState)([]),[d,m]=(0,o.useState)([]),[p,h]=(0,o.useState)(!1),g=n?.map((e=>{const t=e.sent_at?c.MailPoet.Date.format(e.sent_at):(0,Fe.__)("Not sent yet","mailpoet");return{label:e.subject,tag:t,value:Number(e.id)}})),_=(0,o.useCallback)((()=>{var e;hr(i.newsletter_id)&&(m([]),e=i.newsletter_id,l([]),h(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"newsletter_links",action:"get",data:{newsletterId:e}}).then((e=>{const{data:t}=e,i=t.map((e=>({value:e.id,label:e.url})));h(!1),m(i)})).fail((e=>{l(e.errors)})))}),[i.newsletter_id]);return(0,o.useEffect)((()=>{_()}),[_,i.newsletter_id]),(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[i.operator,t,a]),(0,u.jsxs)(u.Fragment,{children:[r.length>0&&(0,u.jsx)(ni,{errors:r}),(0,u.jsx)(tr.ReactSelect,{placeholder:c.MailPoet.I18n.t("selectNewsletterPlaceholder"),options:g,value:(0,es.find)(["value",i.newsletter_id],g),onChange:e=>{a({newsletter_id:e.value,link_ids:[]},t)},automationId:"segment-email"}),(0,u.jsxs)(lt.Select,{isMinWidth:!0,value:i.operator,onChange:e=>s("operator",t,e),automationId:"select-operator",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),p&&(0,u.jsx)("span",{children:c.MailPoet.I18n.t("loadingDynamicSegmentItems")}),!p&&hr(i.newsletter_id)&&(0,u.jsx)(tr.ReactSelect,{isMulti:!0,automationId:"segment-link-select",placeholder:c.MailPoet.I18n.t("allLinksPlaceholder"),options:d.length?d:[{value:0,label:c.MailPoet.I18n.t("noLinksHint"),isDisabled:!0}],value:(0,es.filter)((e=>!!i.link_ids&&-1!==i.link_ids.indexOf(e.value)),d),onChange:e=>{a({link_ids:(e||[]).map((e=>e.value))},t)}})]})},[lr.zd.OPENED]:ur,[lr.zd.WAS_SENT]:ur,[lr.zd.MACHINE_OPENED]:ur,[lr.zd.CLICKED_ANY]:null,[lr.zd.NUMBER_RECEIVED]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{["more","less","equals","not_equals"].includes(i.operator)||a({operator:"more"},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fi.Grid.CenteredRow,{children:(n=e=>"{condition}"===e?(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:"more",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:"less",children:c.MailPoet.I18n.t("lessThan")}),(0,u.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("notEquals")})]},"select"):"{emails}"===e?(0,u.jsx)(at.I,{type:"number",value:i.emails||"","data-automation-id":"segment-number-emails-received",onChange:e=>{s("emails",t,e)},min:"0",placeholder:(0,Fe.__)("emails","mailpoet")},"input"):"string"==typeof e&&e.trim().length>1?(0,u.jsx)("div",{children:e},"emails"):null,(0,Fe.__)("{condition} {emails} emails","mailpoet").split(/({condition})|({emails})|(\b[a-zA-Z]+\b)/gim).map(n))}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]});var n},[lr.zd.NUMBER_OF_CLICKS]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{["more","less","equals","not_equals"].includes(i.operator)||a({operator:"more"},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fi.Grid.CenteredRow,{children:(n=e=>"{condition}"===e?(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:"more",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:"less",children:c.MailPoet.I18n.t("lessThan")}),(0,u.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("notEquals")})]},"select"):"{clicks}"===e?(0,u.jsx)(at.I,{type:"number",value:i.clicks||"","data-automation-id":"segment-number-of-clicks",onChange:e=>{s("clicks",t,e)},min:"0",placeholder:(0,Fe.__)("clicks","mailpoet")},"input"):"string"==typeof e&&e.trim().length>1?(0,u.jsx)("div",{children:e},"clicks"):null,(0,Fe.__)("{condition} {clicks} clicks","mailpoet").split(/({condition})|({clicks})|(\b[a-zA-Z]+\b)/gim).map(n))}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]});var n}};var vr=i(71622),jr=i(30673);let yr=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 wr=[yr.BEFORE,yr.AFTER,yr.ON,yr.ON_OR_AFTER,yr.ON_OR_BEFORE,yr.NOT_ON,yr.IN_THE_LAST,yr.NOT_IN_THE_LAST],Sr=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return c.MailPoet.Date.format(e,{format:"Y-m-d"})}},Pr=e=>{const t=(0,vr.default)(e);if((0,jr.default)(t))return t};function Mr(e){let{filterIndex:t,defaultOperator:i}=e;const a=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:s,updateSegmentFilterFromEvent:n}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{wr.includes(a.operator)||s({operator:i},t),a.operator!==yr.BEFORE&&a.operator!==yr.AFTER&&a.operator!==yr.ON&&a.operator!==yr.ON_OR_AFTER&&a.operator!==yr.ON_OR_BEFORE&&a.operator!==yr.NOT_ON||void 0!==Pr(a.value)&&/^\d+-\d+-\d+$/.test(a.value)||s({value:Sr(new Date)},t),a.operator!==yr.IN_THE_LAST&&a.operator!==yr.NOT_IN_THE_LAST||"string"!=typeof a.value||/^\d*$/.exec(a.value)||s({value:""},t)}),[s,a,t,i]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{value:a.operator,isMinWidth:!0,onChange:e=>{n("operator",t,e)},children:[(0,u.jsx)("option",{value:yr.BEFORE,children:c.MailPoet.I18n.t("before")}),(0,u.jsx)("option",{value:yr.ON_OR_BEFORE,children:c.MailPoet.I18n.t("onOrBefore")}),(0,u.jsx)("option",{value:yr.ON,children:c.MailPoet.I18n.t("on")}),(0,u.jsx)("option",{value:yr.NOT_ON,children:c.MailPoet.I18n.t("notOn")}),(0,u.jsx)("option",{value:yr.ON_OR_AFTER,children:c.MailPoet.I18n.t("onOrAfter")}),(0,u.jsx)("option",{value:yr.AFTER,children:c.MailPoet.I18n.t("after")}),(0,u.jsx)("option",{value:yr.IN_THE_LAST,children:c.MailPoet.I18n.t("inTheLast")}),(0,u.jsx)("option",{value:yr.NOT_IN_THE_LAST,children:c.MailPoet.I18n.t("notInTheLast")})]},"select"),(a.operator===yr.BEFORE||a.operator===yr.AFTER||a.operator===yr.ON||a.operator===yr.ON_OR_AFTER||a.operator===yr.ON_OR_BEFORE||a.operator===yr.NOT_ON)&&(0,u.jsx)($i.a,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:e=>{s({value:Sr(e)},t)},selected:a.value?Pr(a.value):void 0}),(a.operator===yr.IN_THE_LAST||a.operator===yr.NOT_IN_THE_LAST)&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(at.I,{className:"mailpoet-segments-input-small",type:"number",value:a.value||"",onChange:e=>{n("value",t,e)},min:"1",placeholder:c.MailPoet.I18n.t("daysPlaceholder")},"input"),(0,u.jsx)("span",{children:c.MailPoet.I18n.t("daysPlaceholder")})]})]})}function Nr(e){return!(!e.operator||!e.value)&&([yr.BEFORE,yr.AFTER,yr.ON,yr.NOT_ON,yr.ON_OR_BEFORE,yr.ON_OR_AFTER].includes(e.operator)?/^\d+-\d+-\d+$/.test(e.value):!![yr.IN_THE_LAST,yr.NOT_IN_THE_LAST].includes(e.operator)&&(/^\d+$/.test(e.value)&&Number(e.value)>0))}function Ir(e){return function(t){return(0,u.jsx)(Mr,{...t,defaultOperator:e})}}const Cr=Ir(yr.BEFORE),kr=Ir(yr.IN_THE_LAST);var Tr=i(70468);const Er=["is","isNot","contains","notContains","startsWith","notStartsWith","endsWith","notEndsWith"];function Ar(e){return!!Er.includes(e.operator)&&"string"==typeof e.value&&e.value.length>0}function Rr(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{Er.includes(i.operator)||s({operator:"is",value:""},t)}),[s,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{automationId:"subscriber-text-field-select",value:i.operator,isMinWidth:!0,onChange:e=>{a("operator",t,e)},children:[(0,u.jsx)("option",{value:"is",children:c.MailPoet.I18n.t("is")}),(0,u.jsx)("option",{value:"isNot",children:c.MailPoet.I18n.t("isNot")}),(0,u.jsx)("option",{value:"contains",children:c.MailPoet.I18n.t("contains")}),(0,u.jsx)("option",{value:"notContains",children:c.MailPoet.I18n.t("notContains")}),(0,u.jsx)("option",{value:"startsWith",children:c.MailPoet.I18n.t("startsWith")}),(0,u.jsx)("option",{value:"notStartsWith",children:c.MailPoet.I18n.t("notStartsWith")}),(0,u.jsx)("option",{value:"endsWith",children:c.MailPoet.I18n.t("endsWith")}),(0,u.jsx)("option",{value:"notEndsWith",children:c.MailPoet.I18n.t("notEndsWith")})]},"select"),(0,u.jsx)(at.I,{className:"mailpoet-segments-input-medium","data-automation-id":"text-custom-field-value",value:i.value||"",onChange:e=>{a("value",t,e)},placeholder:c.MailPoet.I18n.t("value")},"input")]})}const Fr={[Tr.wq.CUSTOMER_IN_COUNTRY]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),s=(0,P.Z)((e=>e(dr.t).getWooCommerceCountries()),[]).map((e=>({value:e.code,label:e.name})));return(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,isMinWidth:!0,onChange:e=>{a({operator:e.target.value},t)},automationId:"select-operator-country",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-country"),(0,u.jsx)(tr.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("selectWooCountry"),options:s,value:(0,es.filter)((e=>{if(i.country_code)return-1!==i.country_code.indexOf(e.value)}),s),onChange:e=>{a({country_code:(e||[]).map((e=>e.value))},t)},automationId:"select-segment-country"},"select-segment-country")]})},[Tr.wq.CUSTOMER_IN_CITY]:Rr,[Tr.wq.CUSTOMER_IN_POSTAL_CODE]:Rr,[Tr.wq.NUMBER_OF_ORDERS]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{void 0===i.number_of_orders_type&&a({number_of_orders_type:"="},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(r.Select,{value:i.number_of_orders_type,onChange:e=>{s("number_of_orders_type",t,e)},automationId:"select-number-of-orders-type",children:[(0,u.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,u.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,u.jsx)(r.Input,{"data-automation-id":"input-number-of-orders-count",type:"number",min:0,value:i.number_of_orders_count||"",placeholder:c.MailPoet.I18n.t("wooNumberOfOrdersCount"),onChange:e=>{s("number_of_orders_count",t,e)}}),(0,u.jsx)("div",{children:c.MailPoet.I18n.t("wooNumberOfOrdersOrders")})]}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.NUMBER_OF_REVIEWS]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{(0,gr.J)(i.count_type,lr.Si)||a({count_type:lr.Si.EQUALS},t),(0,gr.J)(i.rating,lr.Nj)||a({rating:lr.Nj.ANY},t),(0,gr.J)(i.timeframe,lr.u4)||a({timeframe:lr.u4.IN_THE_LAST},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(r.Select,{value:i.rating,isMinWidth:!0,onChange:e=>{s("rating",t,e)},children:[(0,u.jsx)("option",{value:lr.Nj.ANY,children:c.MailPoet.I18n.t("wooAnyStarRating")}),(0,u.jsx)("option",{value:lr.Nj.ONE,children:c.MailPoet.I18n.t("wooOneStarRating")}),(0,u.jsx)("option",{value:lr.Nj.TWO,children:c.MailPoet.I18n.t("wooTwoStarRating")}),(0,u.jsx)("option",{value:lr.Nj.THREE,children:c.MailPoet.I18n.t("wooThreeStarRating")}),(0,u.jsx)("option",{value:lr.Nj.FOUR,children:c.MailPoet.I18n.t("wooFourStarRating")}),(0,u.jsx)("option",{value:lr.Nj.FIVE,children:c.MailPoet.I18n.t("wooFiveStarRating")})]},"rating-select"),(0,u.jsxs)(r.Select,{value:i.count_type,isMinWidth:!0,onChange:e=>{s("count_type",t,e)},automationId:"select-number-of-reviews-type",children:[(0,u.jsx)("option",{value:lr.Si.EQUALS,children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:lr.Si.NOT_EQUALS,children:c.MailPoet.I18n.t("notEquals")}),(0,u.jsx)("option",{value:lr.Si.MORE_THAN,children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:lr.Si.LESS_THAN,children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,u.jsx)(r.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-number-of-reviews-count",type:"number",min:0,value:i.count||"",placeholder:c.MailPoet.I18n.t("wooNumberOfOrdersCount"),onChange:e=>{s("count",t,e)}}),(0,u.jsx)("div",{children:c.MailPoet.I18n.t("wooNumberOfReviewsReviews")}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.PURCHASE_DATE]:Cr,[Tr.wq.PURCHASED_PRODUCT]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),s=(0,P.Z)((e=>e(dr.t).getProducts()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{i.operator!==lr.f5.ALL&&i.operator!==lr.f5.ANY&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,isMinWidth:!0,onChange:e=>{a({operator:e.target.value},t)},automationId:"select-operator",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),(0,u.jsx)(tr.ReactSelect,{isMulti:!0,dimension:"small",placeholder:c.MailPoet.I18n.t("selectWooPurchasedProduct"),options:s,value:(0,es.filter)((e=>{if(void 0!==i.product_ids&&0!==i.product_ids.length)return-1!==i.product_ids.indexOf(e.value)}),s),onChange:e=>{a({product_ids:(e||[]).map((e=>e.value))},t)},automationId:"select-segment-products"},"select-segment-products")]})},[Tr.wq.PURCHASED_CATEGORY]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),s=(0,P.Z)((e=>e(dr.t).getProductCategories()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{i.operator!==lr.f5.ALL&&i.operator!==lr.f5.ANY&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,isMinWidth:!0,onChange:e=>{a({operator:e.target.value},t)},automationId:"select-operator",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),(0,u.jsx)(tr.ReactSelect,{isMulti:!0,dimension:"small",placeholder:c.MailPoet.I18n.t("selectWooPurchasedCategory"),options:s,value:(0,es.filter)((e=>{if(void 0!==i.category_ids&&0!==i.category_ids.length)return-1!==i.category_ids.indexOf(e.value)}),s),onChange:e=>{a({category_ids:(e||[]).map((e=>e.value))},t)},automationId:"select-segment-category"},"select-segment-category")]})},[Tr.wq.SINGLE_ORDER_VALUE]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getWooCommerceCurrencySymbol()),[]);return(0,o.useEffect)((()=>{void 0===i.single_order_value_type&&a({single_order_value_type:">"},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(r.Select,{value:i.single_order_value_type,onChange:e=>{s("single_order_value_type",t,e)},automationId:"select-single-order-value-type",children:[(0,u.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:">=",children:c.MailPoet.I18n.t("moreThanOrEqual")}),(0,u.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,u.jsx)("option",{value:"<=",children:c.MailPoet.I18n.t("lessThanOrEqual")}),(0,u.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,u.jsx)(r.Input,{"data-automation-id":"input-single-order-value-amount",type:"number",min:0,step:.01,value:i.single_order_value_amount||"",placeholder:c.MailPoet.I18n.t("wooSpentAmount"),onChange:e=>{s("single_order_value_amount",t,e)}}),(0,u.jsx)("div",{children:n})]}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.TOTAL_SPENT]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getWooCommerceCurrencySymbol()),[]);return(0,o.useEffect)((()=>{void 0===i.total_spent_type&&a({total_spent_type:">"},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(r.Select,{value:i.total_spent_type,onChange:e=>{s("total_spent_type",t,e)},automationId:"select-total-spent-type",children:[(0,u.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,u.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,u.jsx)(r.Input,{"data-automation-id":"input-total-spent-amount",type:"number",min:0,step:.01,value:i.total_spent_amount||"",placeholder:c.MailPoet.I18n.t("wooSpentAmount"),onChange:e=>{s("total_spent_amount",t,e)}}),(0,u.jsx)("div",{children:n})]}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.AVERAGE_SPENT]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getWooCommerceCurrencySymbol()),[]);return(0,o.useEffect)((()=>{[">",">=","=","!=","<=","<"].includes(i.average_spent_type)||a({average_spent_type:">"},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(r.Select,{value:i.average_spent_type,isMinWidth:!0,onChange:e=>{s("average_spent_type",t,e)},automationId:"select-average-spent-type",children:[(0,u.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:">=",children:c.MailPoet.I18n.t("moreThanOrEqual")}),(0,u.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,u.jsx)("option",{value:"<=",children:c.MailPoet.I18n.t("lessThanOrEqual")}),(0,u.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,u.jsx)(r.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-average-spent-amount",type:"number",min:0,step:.01,value:i.average_spent_amount||"",placeholder:c.MailPoet.I18n.t("wooSpentAmount"),onChange:e=>{s("average_spent_amount",t,e)}}),(0,u.jsx)("div",{children:n}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.USED_COUPON_CODE]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),[s,n]=(0,o.useState)(!1),[l,d]=(0,o.useState)([]),[m,p]=(0,o.useState)(!1),[h,g]=(0,o.useState)(1),[_,f]=(0,o.useState)(!0),[b,x]=(0,o.useState)(""),[v,j]=(0,o.useState)([]),y=(0,o.useCallback)(((e,t,a,s)=>{s&&(e||p(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"coupons",action:"getCoupons",data:{page_number:t,page_size:1e3,include_coupon_ids:i.coupon_code_ids,search:a}}).then((i=>{const{data:a}=i,s=a.map((e=>({value:e.id.toString(),label:e.text}))),n=t+1;0===s.length?f(!1):(d((e=>(0,es.uniqBy)((e=>e.value),[...e,...s]))),g(n)),e||p(!1)})).fail((e=>{j(e.errors)})))}),[i.coupon_code_ids]),w=(0,es.debounce)(300,(e=>{const t=b;x(e),!m&&(_&&e||t&&!e)&&(g(1),y(!1,1,e,_))}));return(0,o.useEffect)((()=>{s||(y(!0,h,b,_),n(!0))}),[s,h,b,y,_]),(0,o.useEffect)((()=>{Array.isArray(i.coupon_code_ids)||a({coupon_code_ids:[]},t),(0,gr.J)(i.operator,lr.f5)||a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[v.length>0&&(0,u.jsx)(ni,{errors:v}),s?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(r.Select,{isMaxContentWidth:!0,value:i.operator,onChange:e=>{a({operator:e.target.value},t)},automationId:"select-operator-used-coupon-code",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-used-coupon-codes"),(0,u.jsx)(tr.ReactSelect,{isFullWidth:!0,isMulti:!0,isLoadingMore:m,placeholder:c.MailPoet.I18n.t("selectWooCouponCodes"),options:l,value:(0,es.filter)((e=>{if(i.coupon_code_ids)return-1!==i.coupon_code_ids.indexOf(e.value)}),l),onInputChange:e=>{w(e)},onChange:e=>{a({coupon_code_ids:(e||[]).map((e=>e.value))},t)},automationId:"select-shipping-methods",onMenuScrollToBottom:()=>{!m&&_&&y(!1,h,b,_)}},"select-coupon-codes")]}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]}):(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,Fe.__)("Loading coupon codes...","mailpoet")})]})},[Tr.wq.USED_PAYMENT_METHOD]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),s=(0,P.Z)((e=>e(dr.t).getPaymentMethods()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(r.Select,{isMaxContentWidth:!0,value:i.operator,onChange:e=>{a({operator:e.target.value},t)},automationId:"select-operator-used-payment-methods",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-used-payment-methods"),(0,u.jsx)(tr.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:c.MailPoet.I18n.t("selectWooPaymentMethods"),options:s,value:(0,es.filter)((e=>{if(i.payment_methods)return-1!==i.payment_methods.indexOf(e.value)}),s),onChange:e=>{a({payment_methods:(e||[]).map((e=>e.value))},t)},automationId:"select-payment-methods"},"select-payment-methods")]}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.USED_SHIPPING_METHOD]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),s=(0,P.Z)((e=>e(dr.t).getShippingMethods()),[]).map((e=>({value:e.instanceId,label:e.name})));return(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(r.Select,{isMaxContentWidth:!0,value:i.operator,onChange:e=>{a({operator:e.target.value},t)},automationId:"select-operator-used-shipping-methods",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-used-shipping-methods"),(0,u.jsx)(tr.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:c.MailPoet.I18n.t("selectWooShippingMethods"),options:s,value:(0,es.filter)((e=>{if(i.shipping_methods)return-1!==i.shipping_methods.indexOf(e.value)}),s),onChange:e=>{a({shipping_methods:(e||[]).map((e=>e.value))},t)},automationId:"select-shipping-methods"},"select-shipping-methods")]}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(_r,{filterIndex:t})})]})},[Tr.wq.FIRST_ORDER]:Cr};function Or(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);(0,o.useEffect)((()=>{i.action===lr.jx.WORDPRESS_ROLE&&i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]);const n=(0,P.Z)((e=>e(dr.t).getWordpressRoles()),[]).map((e=>({value:e.role_id,label:e.role_name})));return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsxs)(lt.Select,{isFullWidth:!0,automationId:"segment-wordpress-role-condition",value:i.operator,onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select")}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(tr.ReactSelect,{dimension:"small",isMulti:!0,automationId:"segment-wordpress-role",placeholder:c.MailPoet.I18n.t("selectUserRolePlaceholder"),options:n,value:(0,es.filter)((e=>{if(i.wordpressRole)return-1!==i.wordpressRole.indexOf(e.value)}),n),onChange:e=>{a({wordpressRole:(0,es.map)("value",e)},t)}})})]})}let Lr=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 Dr=[Lr.HIGHER_THAN,Lr.LOWER_THAN,Lr.EQUALS,Lr.NOT_EQUALS,Lr.UNKNOWN,Lr.NOT_UNKNOWN];function qr(e){return!!(0,lr.F3)(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 $r(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{void 0===i.operator&&s({operator:"equals",value:""},t)}),[s,i,t]),(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{automationId:"text-custom-field-operator",value:i.operator,onChange:e=>{a("operator",t,e)},children:[(0,u.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("is")}),(0,u.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("isNot")}),(0,u.jsx)("option",{value:"contains",children:c.MailPoet.I18n.t("contains")}),(0,u.jsx)("option",{value:"not_contains",children:c.MailPoet.I18n.t("notContains")}),(0,u.jsx)("option",{value:"more_than",children:c.MailPoet.I18n.t("moreThan")}),(0,u.jsx)("option",{value:"less_than",children:c.MailPoet.I18n.t("lessThan")}),(0,u.jsx)("option",{value:"is_blank",children:c.MailPoet.I18n.t("isBlank")}),(0,u.jsx)("option",{value:"is_not_blank",children:c.MailPoet.I18n.t("isNotBlank")})]},"select"),!(0,lr.F3)(i.operator)&&(0,u.jsx)(at.I,{"data-automation-id":"text-custom-field-value",value:i.value||"",onChange:e=>{a("value",t,e)},placeholder:c.MailPoet.I18n.t("value")},"input")]})}function Br(e){return!!(0,lr.F3)(e.operator)||"string"==typeof e.value&&e.value.length>0}function Wr(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getCustomFieldsList()),[]),o=(0,es.find)({id:Number(i.custom_field_id)},n);if(!o)return null;const r=o.params;if(!r||!Array.isArray(r.values))return null;const l=r.values.map((e=>({value:e.value,label:e.value}))),d=l.find((e=>e.value===i.value))?.label;return(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{automationId:"text-custom-field-operator",value:i.operator,onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("is")}),(0,u.jsx)("option",{value:lr.DB.BLANK,children:c.MailPoet.I18n.t("isBlank")}),(0,u.jsx)("option",{value:lr.DB.NOT_BLANK,children:c.MailPoet.I18n.t("isNotBlank")})]},"select"),!(0,lr.F3)(i.operator)&&(0,u.jsx)(tr.ReactSelect,{dimension:"small",placeholder:c.MailPoet.I18n.t("selectValue"),options:l,value:i.value&&d?{value:i.value,label:d}:null,onChange:e=>{a({value:e.value},t)},automationId:"segment-wordpress-role"})]})}var Vr=i(12892),Ur=i(15826);function zr(e){return!!(0,lr.F3)(e.operator)||("month"===e.date_type||!("string"!=typeof e.operator||e.operator.length<1))&&"string"==typeof e.value&&e.value.length>1}const Hr=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return(0,Ur.default)(e,"yyyy-MM-dd 00:00:00")}},Zr=e=>{const t=(0,vr.default)(e);if((0,jr.default)(t))return t},Yr={month:function(e){let{onChange:t,item:i,filterIndex:a}=e;return(0,o.useEffect)((()=>{zr(i)||t((0,es.assign)(i,{value:"2017-01-01 00:00:00"}),a),void 0===i.operator&&t((0,es.assign)(i,{operator:"equals"}),a)}),[t,i,a]),(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{t((0,es.assign)(i,{operator:e.target.value}),a)},children:[(0,u.jsx)("option",{value:"equals",children:(0,Fe.__)("is","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.BLANK,children:(0,Fe.__)("is blank","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.NOT_BLANK,children:(0,Fe.__)("is not blank","mailpoet")})]},"select-operator"),!(0,lr.F3)(i.operator)&&(0,u.jsxs)(lt.Select,{value:i.value,onChange:e=>{t((0,es.assign)(i,{value:e.target.value}),a)},children:[(0,u.jsx)("option",{value:"2017-01-01 00:00:00",children:(0,Fe.__)("january","mailpoet")}),(0,u.jsx)("option",{value:"2017-02-01 00:00:00",children:(0,Fe.__)("february","mailpoet")}),(0,u.jsx)("option",{value:"2017-03-01 00:00:00",children:(0,Fe.__)("march","mailpoet")}),(0,u.jsx)("option",{value:"2017-04-01 00:00:00",children:(0,Fe.__)("april","mailpoet")}),(0,u.jsx)("option",{value:"2017-05-01 00:00:00",children:(0,Fe.__)("may","mailpoet")}),(0,u.jsx)("option",{value:"2017-06-01 00:00:00",children:(0,Fe.__)("june","mailpoet")}),(0,u.jsx)("option",{value:"2017-07-01 00:00:00",children:(0,Fe.__)("july","mailpoet")}),(0,u.jsx)("option",{value:"2017-08-01 00:00:00",children:(0,Fe.__)("august","mailpoet")}),(0,u.jsx)("option",{value:"2017-09-01 00:00:00",children:(0,Fe.__)("september","mailpoet")}),(0,u.jsx)("option",{value:"2017-10-01 00:00:00",children:(0,Fe.__)("october","mailpoet")}),(0,u.jsx)("option",{value:"2017-11-01 00:00:00",children:(0,Fe.__)("november","mailpoet")}),(0,u.jsx)("option",{value:"2017-12-01 00:00:00",children:(0,Fe.__)("december","mailpoet")})]},"select")]})},year:function(e){let{onChange:t,item:i,filterIndex:a}=e;const s=(0,Vr.default)(new Date);return(0,o.useEffect)((()=>{zr(i)||t((0,es.assign)(i,{value:`${s}-01-01 00:00:00`,operator:"equals"}),a)}),[s,t,i,a]),(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{t((0,es.assign)(i,{operator:e.target.value}),a)},children:[(0,u.jsx)("option",{value:"equals",children:(0,Fe.__)("is","mailpoet")}),(0,u.jsx)("option",{value:"before",children:(0,Fe._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,u.jsx)("option",{value:"after",children:(0,Fe._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,u.jsx)("option",{value:lr.DB.BLANK,children:(0,Fe.__)("is blank","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.NOT_BLANK,children:(0,Fe.__)("is not blank","mailpoet")})]},"select-operator"),(0,u.jsx)(lt.Select,{value:i.value,onChange:e=>{t((0,es.assign)(i,{value:e.target.value}),a)},children:(0,es.range)(0,100).map((e=>(0,u.jsx)("option",{value:s-e+"-01-01 00:00:00",children:s-e},s-e)))},"select-year")]})},year_month:function(e){let{onChange:t,item:i,filterIndex:a}=e;return(0,o.useEffect)((()=>{void 0!==i.value&&""!==i.value||t((0,es.assign)(i,{value:`${(0,Ur.default)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)}),[t,i,a]),(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{t((0,es.assign)(i,{operator:e.target.value}),a)},children:[(0,u.jsx)("option",{value:"equals",children:(0,Fe.__)("is","mailpoet")}),(0,u.jsx)("option",{value:"before",children:(0,Fe._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,u.jsx)("option",{value:"after",children:(0,Fe._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,u.jsx)("option",{value:lr.DB.BLANK,children:(0,Fe.__)("is blank","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.NOT_BLANK,children:(0,Fe.__)("is not blank","mailpoet")})]},"select-operator"),!(0,lr.F3)(i.operator)&&(0,u.jsx)($i.a,{onChange:e=>t((0,es.assign)(i,{value:Hr(e)}),a),selected:i.value?Zr(i.value):void 0,dateFormat:"MM/yyyy",showMonthYearPicker:!0})]})},year_month_day:function(e){let{onChange:t,item:i,filterIndex:a}=e;return(0,o.useEffect)((()=>{zr(i)||t((0,es.assign)(i,{value:`${(0,Ur.default)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)}),[t,i,a]),(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{t((0,es.assign)(i,{operator:e.target.value}),a)},children:[(0,u.jsx)("option",{value:"equals",children:(0,Fe.__)("is","mailpoet")}),(0,u.jsx)("option",{value:"before",children:(0,Fe._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,u.jsx)("option",{value:"after",children:(0,Fe._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,u.jsx)("option",{value:lr.DB.BLANK,children:(0,Fe.__)("is blank","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.NOT_BLANK,children:(0,Fe.__)("is not blank","mailpoet")})]},"select-operator"),!(0,lr.F3)(i.operator)&&(0,u.jsx)($i.a,{dateFormat:"MMM d, yyyy",onChange:e=>t((0,es.assign)(i,{value:Hr(e)}),a),selected:i.value?Zr(i.value):void 0})]})}};var Gr=function(e){return e.DATE="date",e.TEXT="text",e.TEXTAREA="textarea",e.RADIO="radio",e.CHECKBOX="checkbox",e.SELECT="select",e}(Gr||{});const Kr={[Gr.TEXT]:qr,[Gr.TEXTAREA]:qr,[Gr.RADIO]:Br,[Gr.SELECT]:Br,[Gr.CHECKBOX]:function(e){return!!(0,lr.F3)(e.operator)||["1","0"].includes(e.value)},[Gr.DATE]:zr},Qr={[Gr.TEXT]:$r,[Gr.TEXTAREA]:$r,[Gr.RADIO]:Wr,[Gr.SELECT]:Wr,[Gr.CHECKBOX]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{void 0===i.operator?s({operator:"equals",value:"1"},t):"equals"!==i.operator||["1","0"].includes(i.value)||s({value:"1"},t)}),[s,i,t]),(0,u.jsxs)(Fi.Grid.CenteredRow,{children:[(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>{a("operator",t,e)},children:[(0,u.jsx)("option",{value:"equals",children:(0,Fe.__)("is","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.BLANK,children:(0,Fe.__)("is blank","mailpoet")}),(0,u.jsx)("option",{value:lr.DB.NOT_BLANK,children:(0,Fe.__)("is not blank","mailpoet")})]},"select-operator"),!(0,lr.F3)(i.operator)&&(0,u.jsxs)(lt.Select,{value:i.value,onChange:e=>a("value",t,e),children:[(0,u.jsx)("option",{value:"1",children:(0,Fe.__)("checked","mailpoet")}),(0,u.jsx)("option",{value:"0",children:(0,Fe.__)("unchecked","mailpoet")})]},"select")]})},[Gr.DATE]:function(e){let{customField:t,filterIndex:i}=e;const a=(0,P.Z)((e=>e(dr.t).getSegmentFilter(i)),[i]),{updateSegmentFilter:s}=(0,he.Z)(dr.t);(0,o.useEffect)((()=>{a.date_type!==t.params.date_type&&s({date_type:t.params.date_type,value:""},i)}),[a.date_type,s,t.params.date_type,i]);const n=Yr[t.params.date_type];return n?(0,u.jsx)(n,{item:a,onChange:s,filterIndex:i}):null}};function Xr(){return(0,u.jsx)(wo,{message:(()=>{const e=c.MailPoet.I18n.t("premiumFeatureMultipleConditions");return(0,u.jsx)("p",{children:f()(e,/\[link](.*?)\[\/link]/g,(e=>(0,u.jsx)("a",{href:c.MailPoet.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e)))})})(),actionButton:(0,u.jsx)(Oe.z,{href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,null,{utm_medium:"segments",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("premiumBannerCtaFree")})})}const Jr={[lr.jx.WORDPRESS_ROLE]:Or,[lr.jx.SUBSCRIBER_SCORE]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t);return(0,o.useEffect)((()=>{Dr.includes(i.operator)||a({operator:Lr.HIGHER_THAN},t),i.operator!==Lr.HIGHER_THAN&&i.operator!==Lr.LOWER_THAN&&i.operator!==Lr.EQUALS&&i.operator!==Lr.NOT_EQUALS||void 0!==i.value||a({value:""},t),i.operator!==Lr.UNKNOWN&&i.operator!==Lr.NOT_UNKNOWN||a({value:null},t)}),[a,i,t]),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(n=e=>"{condition}"===e?(0,u.jsxs)(lt.Select,{value:i.operator,automationId:"segment-subscriber-score-operator",onChange:e=>{s("operator",t,e)},children:[(0,u.jsx)("option",{value:Lr.HIGHER_THAN,children:c.MailPoet.I18n.t("higherThan")}),(0,u.jsx)("option",{value:Lr.LOWER_THAN,children:c.MailPoet.I18n.t("lowerThan")}),(0,u.jsx)("option",{value:Lr.EQUALS,children:c.MailPoet.I18n.t("equals")}),(0,u.jsx)("option",{value:Lr.NOT_EQUALS,children:c.MailPoet.I18n.t("notEquals")}),(0,u.jsx)("option",{value:Lr.UNKNOWN,children:c.MailPoet.I18n.t("unknown")}),(0,u.jsx)("option",{value:Lr.NOT_UNKNOWN,children:c.MailPoet.I18n.t("notUnknown")})]},"select"):"{score}"===e?(i.operator===Lr.HIGHER_THAN||i.operator===Lr.LOWER_THAN||i.operator===Lr.EQUALS||i.operator===Lr.NOT_EQUALS)&&(0,u.jsx)(at.I,{type:"number",value:i.value||"","data-automation-id":"segment-subscriber-score-value",onChange:e=>{s("value",t,e)},min:"0",placeholder:c.MailPoet.I18n.t("subscriberScorePlaceholder")},"input"):"string"==typeof e&&e.trim().length>0?i.operator!==Lr.UNKNOWN&&i.operator!==Lr.NOT_UNKNOWN&&(0,u.jsx)("div",{children:e},"score"):null,c.MailPoet.I18n.t("subscriberScoreSentence").split(/({condition})|({score})|(\b%\b)/gim).map(n))});var n},[lr.jx.SUBSCRIBED_DATE]:Cr,[lr.jx.MAILPOET_CUSTOM_FIELD]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a}=(0,he.Z)(dr.t),s=(0,P.Z)((e=>e(dr.t).getCustomFieldsList()),[]),n=(0,es.find)({id:Number(i.custom_field_id)},s),o=s.map((e=>({value:e.id.toString(),label:e.name}))),r=Qr[i.custom_field_type];return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{children:(0,u.jsx)(tr.ReactSelect,{dimension:"small",isFullWidth:!0,placeholder:c.MailPoet.I18n.t("selectCustomFieldPlaceholder"),options:o,automationId:"select-custom-field",value:(0,es.find)((e=>{if(i.custom_field_id)return i.custom_field_id===e.value}),o),onChange:e=>{const i=(0,es.find)({id:Number(e.value)},s);i&&a({custom_field_id:e.value,custom_field_type:i.type,operator:void 0,value:void 0},t)}})}),(0,u.jsx)("div",{children:r&&(0,u.jsx)(r,{customField:n,filterIndex:t})})]})},[lr.jx.SUBSCRIBED_TO_LIST]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),a=(0,P.Z)((e=>e(dr.t).getStaticSegmentsList()),[]),{updateSegmentFilter:s,updateSegmentFilterFromEvent:n}=(0,he.Z)(dr.t);(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&s({operator:lr.f5.ANY},t)}),[s,i,t]);const r=a.map((e=>({value:e.id,label:e.name})));return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{isMinWidth:!0,value:i.operator,onChange:e=>{n("operator",t,e)},children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select"),(0,u.jsx)(tr.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("searchLists"),options:r,value:(0,es.filter)((e=>{if(!i.segments)return;const t=e.value;return-1!==i.segments.indexOf(t)}),r),onChange:e=>{s({segments:(0,es.map)((0,es.parseInt)(10),(0,es.map)("value",e))},t)}})]})},[lr.jx.SUBSCRIBER_TAG]:function(e){let{filterIndex:t}=e;return Ot.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag",(0,u.jsx)(Xr,{}),t)},[lr.jx.SUBSCRIBER_FIRST_NAME]:Rr,[lr.jx.SUBSCRIBER_LAST_NAME]:Rr,[lr.jx.SUBSCRIBER_EMAIL]:Rr,[lr.jx.SUBSCRIBED_VIA_FORM]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),a=(0,P.Z)((e=>e(dr.t).getSignupForms()),[]),{updateSegmentFilter:s,updateSegmentFilterFromEvent:n}=(0,he.Z)(dr.t);(0,o.useEffect)((()=>{i.operator!==lr.f5.ANY&&i.operator!==lr.f5.NONE&&s({operator:lr.f5.ANY},t)}),[s,i,t]);const r=a.map((e=>({value:e.id,label:e.name})));return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(lt.Select,{isMinWidth:!0,value:i.operator,onChange:e=>{n("operator",t,e)},children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select"),(0,u.jsx)(tr.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("searchForms"),options:r,value:r.filter((e=>{if(!i.form_ids)return;const t=e.value;return-1!==i.form_ids.indexOf(t)})),onChange:e=>{s({form_ids:e.map((e=>e.value))},t)}})]})},[lr.jx.SUBSCRIBER_LAST_ENGAGEMENT_DATE]:kr,[lr.jx.SUBSCRIBER_LAST_PURCHASE_DATE]:kr,[lr.jx.SUBSCRIBER_LAST_OPEN_DATE]:kr,[lr.jx.SUBSCRIBER_LAST_CLICK_DATE]:kr,[lr.jx.SUBSCRIBER_LAST_PAGE_VIEW_DATE]:kr,[lr.jx.SUBSCRIBER_LAST_SENDING_DATE]:kr},el={[lr.Bt.Automations]:function(e){return!!Object.values(cr.Z).some((t=>t===e.action))&&(e.action!==cr.Z.ENTERED_AUTOMATION||function(e){return(e.operator===lr.f5.ANY||e.operator===lr.f5.NONE||e.operator===lr.f5.ALL)&&Array.isArray(e.automation_ids)&&e.automation_ids.length>0}(e))},[lr.Bt.Email]:function(e){return!!Object.values(lr.zd).some((t=>t===e.action))&&(e.action===lr.zd.CLICKED_ANY||(e.action===lr.zd.CLICKED?!!e.newsletter_id:[lr.zd.OPENED,lr.zd.MACHINE_OPENED].includes(e.action)?Array.isArray(e.newsletters)&&e.newsletters.length>0:[lr.zd.OPENS_ABSOLUTE_COUNT,lr.zd.MACHINE_OPENS_ABSOLUTE_COUNT].includes(e.action)?fr(e)&&!!e.opens&&!!e.operator:lr.zd.NUMBER_RECEIVED===e.action?fr(e)&&!!e.emails&&!!e.operator:e.action===lr.zd.NUMBER_OF_CLICKS&&fr(e)&&!!e.clicks&&!!e.operator))},[lr.Bt.WooCommerce]:function(e){return!!Object.values(Tr.wq).some((t=>t===e.action))&&(e.action===Tr.wq.PURCHASED_CATEGORY?function(e){return!(void 0===e.category_ids||0===e.category_ids.length||!e.operator)}(e):e.action===Tr.wq.PURCHASED_PRODUCT?function(e){return!(void 0===e.product_ids||0===e.product_ids.length||!e.operator)}(e):e.action===Tr.wq.CUSTOMER_IN_COUNTRY?function(e){return!(void 0===e.country_code||0===e.country_code.length)}(e):e.action===Tr.wq.NUMBER_OF_ORDERS?function(e){return!(!e.number_of_orders_count||!fr(e)||!e.number_of_orders_type)}(e):e.action===Tr.wq.TOTAL_SPENT?function(e){return!(!e.total_spent_amount||!fr(e)||!e.total_spent_type)}(e):e.action===Tr.wq.SINGLE_ORDER_VALUE?function(e){return!(!e.single_order_value_amount||!fr(e)||!e.single_order_value_type)}(e):e.action===Tr.wq.AVERAGE_SPENT?function(e){return!(!e.average_spent_amount||!e.average_spent_type||!fr(e))}(e):e.action===Tr.wq.USED_PAYMENT_METHOD?function(e){return!(!e.payment_methods||e.payment_methods.length<1||!e.operator||!fr(e))}(e):e.action===Tr.wq.USED_SHIPPING_METHOD?function(e){return!(!e.shipping_methods||e.shipping_methods.length<1||!e.operator||!fr(e))}(e):e.action===Tr.wq.PURCHASE_DATE?Nr(e):e.action===Tr.wq.NUMBER_OF_REVIEWS?function(e){return!!(e.count&&e.count_type&&e.rating&&fr(e))}(e):e.action===Tr.wq.USED_COUPON_CODE?function(e){return!(!e.coupon_code_ids||e.coupon_code_ids.length<1||!(0,gr.J)(e.operator,lr.f5)||!fr(e))}(e):e.action===Tr.wq.FIRST_ORDER?Nr(e):![Tr.wq.CUSTOMER_IN_POSTAL_CODE,Tr.wq.CUSTOMER_IN_CITY].includes(e.action)||Ar(e))},[lr.Bt.WordPressRole]:function(e){return e.action&&e.action!==lr.jx.WORDPRESS_ROLE?e.action===lr.jx.MAILPOET_CUSTOM_FIELD?function(e){const t=Kr[e.custom_field_type];return!!t&&t(e)}(e):e.action===lr.jx.SUBSCRIBER_SCORE?function(e){if(e.operator===Lr.HIGHER_THAN||e.operator===Lr.LOWER_THAN||e.operator===Lr.EQUALS||e.operator===Lr.NOT_EQUALS){const t=Number(e.value),i=Number(parseFloat(e.value));return!Number.isNaN(t)&&!Number.isNaN(i)&&t>=0&&t<=100}return e.operator===Lr.UNKNOWN||e.operator===Lr.NOT_UNKNOWN}(e):e.action===lr.jx.SUBSCRIBED_TO_LIST?function(e){return(e.operator===lr.f5.ANY||e.operator===lr.f5.ALL||e.operator===lr.f5.NONE)&&Array.isArray(e.segments)&&e.segments.length>0}(e):e.action===lr.jx.SUBSCRIBER_TAG?function(e){return Ot.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag_validate",!1,e)}(e):[lr.jx.SUBSCRIBER_FIRST_NAME,lr.jx.SUBSCRIBER_LAST_NAME,lr.jx.SUBSCRIBER_EMAIL].includes(e.action)?Ar(e):[lr.jx.SUBSCRIBER_LAST_ENGAGEMENT_DATE,lr.jx.SUBSCRIBER_LAST_PURCHASE_DATE,lr.jx.SUBSCRIBER_LAST_OPEN_DATE,lr.jx.SUBSCRIBER_LAST_CLICK_DATE,lr.jx.SUBSCRIBER_LAST_PAGE_VIEW_DATE,lr.jx.SUBSCRIBER_LAST_SENDING_DATE].includes(e.action)?Nr(e):e.action===lr.jx.SUBSCRIBED_VIA_FORM?function(e){return(e.operator===lr.f5.ANY||e.operator===lr.f5.NONE)&&Array.isArray(e.form_ids)&&e.form_ids.length>0}(e):!(!e.operator||!e.value)&&!!Object.values(yr).includes(e.operator)&&Nr(e):Array.isArray(e.wordpressRole)&&e.wordpressRole.length>0},[lr.Bt.WooCommerceMembership]:function(e){const t=!e.plan_ids||!e.plan_ids.length||!e.operator;return e.action!==Tr.hs.MEMBER_OF||!t},[lr.Bt.WooCommerceSubscription]:function(e){const t=!e.product_ids||!e.product_ids.length||!e.operator;return e.action!==Tr.ht.ACTIVE_SUBSCRIPTIONS||!t}};function tl(e){return!(e.length<1)&&0===e.map((e=>void 0!==el[e.segmentType]&&el[e.segmentType](e))).filter((e=>!1===e)).length}let il,al;function sl(){const e=(0,P.Z)((e=>e(dr.t).getSegment()),[]),t=(0,P.Z)((e=>e(dr.t).getSubscriberCount()),[]),{updateSubscriberCount:i}=(0,he.Z)(dr.t),a=JSON.stringify(e),s=(0,o.useRef)(1),n=(0,o.useRef)(null),r=(0,o.useRef)(!1),l=(0,o.useRef)((0,Ti.debounce)((function e(t){if(r.current)return void(n.current=t);n.current=null,s.current+=1;const a=s.current;r.current=!0,function(e){const t={filters:e.filters,filters_connect:e.filters_connect};return Ei().isEqual(t,il)?Promise.resolve(al):(il={filters:[...e.filters],filters_connect:e.filters_connect},c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"dynamic_segments",action:"getCount",data:e,timeout:2e4}).then((e=>{const{data:t}=e;return al={count:t.count,errors:void 0},al})))}(t).then((t=>{if(r.current=!1,n.current)return void e(n.current);if(a!==s.current)return;const o={loading:!1};t&&(o.count=t.count,o.errors=t.errors),i(o)}),(e=>{r.current=!1;const t={},a=e.errors.map((e=>e.message));t.loading=!1,t.count=void 0,t.errors=a,i(t)}))}),2e3,{trailing:!0}));return(0,o.useEffect)((()=>{tl(e.filters)?(i({loading:!0,count:void 0,errors:void 0}),(0,l.current)(e)):i({count:void 0,loading:!1})}),[e,a,i]),t.errors?(0,u.jsx)("div",{className:"mailpoet-form-field",children:(0,u.jsxs)("span",{className:"mailpoet-form-error-message",children:[c.MailPoet.I18n.t("dynamicSegmentSizeCalculatingTimeout")," ",(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/237-guide-to-subscriber-segmentation?utm_source=plugin&utm_medium=segments",target:"_blank",className:"mailpoet-form-error-message",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("learnMore")})]})}):t.loading||void 0!==t.count?t.loading?(0,u.jsx)("div",{className:"mailpoet-form-field",children:(0,u.jsx)("span",{className:"mailpoet-form-notice-message",children:c.MailPoet.I18n.t("dynamicSegmentSizeIsCalculated")})}):(0,u.jsx)("div",{className:"mailpoet-form-field",children:(0,u.jsx)("span",{className:"mailpoet-form-notice-message",children:c.MailPoet.I18n.t("dynamicSegmentSize").replace("%1$d",t.count.toLocaleString())})}):(0,u.jsx)("span",{})}const nl={[lr.Bt.Automations]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),a=pr[i.action];return a?(0,u.jsx)(a,{filterIndex:t}):null},[lr.Bt.Email]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),a=xr[i.action];return a?(0,u.jsx)(a,{filterIndex:t}):null},[lr.Bt.WooCommerce]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),a=Fr[i.action];return a?(0,u.jsx)(a,{filterIndex:t}):null},[lr.Bt.WordPressRole]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]);let a;return a=i.action?Jr[i.action]:Or,a?(0,u.jsx)(a,{filterIndex:t}):null},[lr.Bt.WooCommerceMembership]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getMembershipPlans()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{i.action===Tr.hs.MEMBER_OF&&i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>s("operator",t,e),automationId:"select-operator",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator")}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(tr.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:c.MailPoet.I18n.t("selectWooMembership"),options:n,value:(0,es.filter)((e=>!!i.plan_ids&&-1!==i.plan_ids.indexOf(e.value)),n),onChange:e=>{a({plan_ids:(e||[]).map((e=>e.value))},t)},automationId:"select-segment-plans"},"select-segment-membership-plan")})]})},[lr.Bt.WooCommerceSubscription]:function(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:s}=(0,he.Z)(dr.t),n=(0,P.Z)((e=>e(dr.t).getSubscriptionProducts()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{i.action===Tr.ht.ACTIVE_SUBSCRIPTIONS&&i.operator!==lr.f5.ANY&&i.operator!==lr.f5.ALL&&i.operator!==lr.f5.NONE&&a({operator:lr.f5.ANY},t)}),[a,i,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsxs)(lt.Select,{value:i.operator,onChange:e=>s("operator",t,e),automationId:"select-operator",children:[(0,u.jsx)("option",{value:lr.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,u.jsx)("option",{value:lr.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,u.jsx)("option",{value:lr.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator")}),(0,u.jsx)(Fi.Grid.CenteredRow,{children:(0,u.jsx)(tr.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:c.MailPoet.I18n.t("selectWooSubscription"),options:n,value:(0,es.filter)((e=>!!i.product_ids&&-1!==i.product_ids.indexOf(e.value)),n),onChange:e=>{a({product_ids:(e||[]).map((e=>e.value))},t)},automationId:"select-segment-products"},"select-segment-category")})]})}};function ol(e){let{filterIndex:t}=e;const i=(0,P.Z)((e=>e(dr.t).getSegmentFilter(t)),[t]);if(void 0===i||void 0===nl[i.segmentType])return null;const a=nl[i.segmentType];return(0,u.jsx)(a,{filterIndex:t})}function rl(){const e=(0,P.Z)((e=>e(dr.t).getSegment()),[]),t=[lr.zd.OPENED,lr.zd.OPENS_ABSOLUTE_COUNT,lr.zd.MACHINE_OPENED,lr.zd.MACHINE_OPENS_ABSOLUTE_COUNT];let i=!1;return e.filters.forEach((e=>{t.includes(e.action)&&(i=!0)})),i?(0,u.jsx)("div",{className:"mailpoet-form-field",children:(0,u.jsx)("span",{className:"mailpoet-form-notice-message",children:c.MailPoet.I18n.t("privacyProtectionNotice")})}):(0,u.jsx)("span",{})}const ll=Ot.Hooks.applyFilters("mailpoet_dynamic_segments_form_filters_before",(()=>null)),dl=Ot.Hooks.applyFilters("mailpoet_dynamic_filters_filter_before",(()=>null)),cl=Ot.Hooks.applyFilters("mailpoet_dynamic_filters_filter_after",(()=>(0,u.jsx)("div",{className:"mailpoet-gap"})));function ml(e){let{isNewSegment:t,newsletterId:i}=e;const a=(0,P.Z)((e=>e(dr.t).getSegment()),[]),s=(0,P.Z)((e=>e(dr.t).getAvailableFilters()),[]),n=(0,P.Z)((e=>e(dr.t).findFiltersValueForSegment(a)),[a]),r=(0,P.Z)((e=>e(dr.t).getSubscriberCount()),[]),l=(0,P.Z)((e=>e(dr.t).getErrors()),[]),{updateSegment:d,updateSegmentFilter:m,handleSave:p}=(0,he.Z)(dr.t),[h,g]=(0,o.useState)(!1),_=Ot.Hooks.applyFilters("mailpoet_dynamic_segments_form_add_condition_action",(()=>{g(!0)}));return(0,u.jsx)("div",{className:"mailpoet-form-container",children:(0,u.jsxs)("form",{children:[l.length>0&&(0,u.jsx)(ni,{errors:l.map((e=>({message:e})))}),(0,u.jsxs)(nr,{title:(0,Fe.__)("Details","mailpoet"),description:(0,Fe.__)("What do you want to call this segment?","mailpoet"),children:[(0,u.jsx)(or,{slug:"name",title:(0,Fe.__)("Name","mailpoet"),children:(0,u.jsx)(at.I,{isFullWidth:!0,type:"text",name:"name",id:"field_name",value:a.name||"","data-automation-id":"input-name",onChange:e=>{d({name:e.target.value})},placeholder:(0,Fe.__)("Enter name","mailpoet")})}),(0,u.jsx)(or,{slug:"description",title:(0,Fe.__)("Description","mailpoet"),description:(0,Fe.__)("This text box is for your own use and is never shown to your subscribers.","mailpoet"),children:(0,u.jsx)(at.I,{isFullWidth:!0,name:"description",id:"field_description",value:a.description||"","data-automation-id":"input-description",onChange:e=>{d({description:e.target.value})},placeholder:(0,Fe.__)("Enter description","mailpoet")})})]}),(0,u.jsx)(nr,{title:(0,Fe.__)("Conditions","mailpoet"),description:(0,Fe.__)("Set your segment constraints","mailpoet"),children:(0,u.jsx)(or,{children:(0,u.jsxs)("div",{className:"mailpoet-segments-segments-section",children:[(0,u.jsx)(ll,{}),Array.isArray(n)&&n.map(((e,t)=>(0,u.jsxs)(o.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-segments-grid","data-automation-id":`filter-row-${t}`,children:[(0,u.jsx)(dl,{filterRows:n,index:t}),(0,u.jsx)("div",{className:"mailpoet-segments-filter-selector",children:(0,u.jsx)(tr.ReactSelect,{dimension:"small",placeholder:(0,Fe.__)("Select action","mailpoet"),options:s,value:e.filterValue,onChange:e=>{m({segmentType:e.group,action:e.value},t)},automationId:"select-segment-action",isFullWidth:!0})}),void 0!==e.index&&(0,u.jsx)(ol,{filterIndex:e.index})]}),(0,u.jsx)(cl,{index:t})]},e.index))),(0,u.jsxs)("div",{className:"mailpoet-segments-conditions-bottom",children:[(0,u.jsx)(pe.ZP,{type:"button",variant:"secondary",onClick:e=>{e.preventDefault(),_(a,d)},children:(0,Fe.__)("Add a condition","mailpoet")}),(!c.MailPoet.premiumActive||!c.MailPoet.hasValidPremiumKey||c.MailPoet.subscribersLimitReached)&&(0,u.jsx)(rr.x,{text:(0,Fe.__)("UPGRADE","mailpoet")}),h&&(0,u.jsx)(ia.ZG,{onRequestClose:()=>{g(!1)},children:(0,Fe.__)("Multiple conditions per segment are not available in the free version of the MailPoet plugin.","mailpoet")})]})]})})}),(0,u.jsxs)("div",{className:"mailpoet-admin-fields-footer",children:[(0,u.jsxs)("div",{className:"mailpoet-segments-counter-section",children:[(0,u.jsx)(sl,{}),(0,u.jsx)(rl,{})]}),(0,u.jsx)("div",{className:"mailpoet-form-actions",children:(0,u.jsx)(pe.ZP,{variant:"primary",type:"submit",onClick:e=>{e.preventDefault(),p(t,i)},disabled:!tl(a.filters)||void 0===r.count,children:i?(0,Fe.__)("Save and return","mailpoet"):(0,Fe.__)("Save","mailpoet")})})]})]})})}function pl(){const e=(0,Ne.$B)(),{pageLoaded:t,pageUnloaded:i}=(0,he.Z)(dr.t),a=(0,P.Z)((e=>e(dr.t).getPreviousPage()))||"/",s=(0,Ne.TH)(),n=new URLSearchParams(s.search).get("newsletterId")||null;(0,o.useEffect)((()=>(t(e.params.id),()=>{i()})),[e.params.id,t,i]);const r=void 0===e.params.id||Number.isNaN(Number(e.params.id));return(0,u.jsxs)("div",{className:"mailpoet-main-container",children:[(0,u.jsx)(d.Q,{}),(0,u.jsx)(St.B,{}),(0,u.jsx)(Pt.m,{heading:e.params.id?(0,Fe.__)("Edit segment","mailpoet"):(0,Fe.__)("New segment","mailpoet"),headingPrefix:(0,u.jsx)(Pt.x,{id:"mailpoet-segments-back-button",href:`#${a}`,label:(0,Fe.__)("Return to previous page","mailpoet"),onClick:e=>{n&&(e.preventDefault(),window.location.href=`admin.php?page=mailpoet-newsletters#/send/${n}`)}})}),(0,u.jsx)(ml,{isNewSegment:r,newsletterId:n})]})}pl.displayName="SegmentEditor";const ul=[{name:"name",label:c.MailPoet.I18n.t("nameColumn"),sortable:!0},{name:"description",label:c.MailPoet.I18n.t("description"),sortable:!1},{name:"count",label:c.MailPoet.I18n.t("subscribersCountColumn"),sortable:!1},{name:"subscribed",label:c.MailPoet.I18n.t("subscribed"),sortable:!1},{name:"updated_at",label:c.MailPoet.I18n.t("updatedAtColumn"),sortable:!0}],hl={onLoadingItems:()=>c.MailPoet.I18n.t("loadingDynamicSegmentItems"),onNoItemsFound:()=>c.MailPoet.I18n.t("noDynamicSegmentItemsFound"),onTrash:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneDynamicSegmentTrashed"):c.MailPoet.I18n.t("multipleDynamicSegmentsTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneDynamicSegmentDeleted"):c.MailPoet.I18n.t("multipleDynamicSegmentsDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneDynamicSegmentRestored"):c.MailPoet.I18n.t("multipleDynamicSegmentsRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)}},gl=[{name:"edit",className:"mailpoet-hide-on-mobile",link:e=>(0,u.jsx)(Me.Link,{to:`${Lo.jY}/${e.id}`,children:c.MailPoet.I18n.t("edit")}),display:e=>!e.is_plugin_missing},{name:"duplicate_segment",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("duplicate"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"dynamic_segments",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success(c.MailPoet.I18n.t("segmentDuplicated").replace("%1$s",(0,Oo.r)(e.data.name)),{scroll:!0}),t()})).fail((e=>{c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},{name:"edit_disabled",className:"mailpoet-hide-on-mobile mailpoet-disabled",link:e=>(0,u.jsx)(Me.Link,{to:`${Lo.jY}/${e.id}`,children:c.MailPoet.I18n.t("edit")}),display:e=>e.is_plugin_missing},{name:"view_subscribers",link:e=>(0,u.jsx)("a",{href:e.subscribers_url,children:c.MailPoet.I18n.t("viewSubscribers")})},{name:"trash",className:"mailpoet-hide-on-mobile"}],_l=[{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:hl.onTrash}];function fl(e,t){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("td",{className:"column-primary","data-colname":c.MailPoet.I18n.t("nameColumn"),children:[(0,u.jsx)("span",{className:"mailpoet-listing-title",children:e.name}),t]}),(0,u.jsx)("td",{"data-colname":c.MailPoet.I18n.t("description"),children:(0,u.jsx)("abbr",{children:e.description})}),e.is_plugin_missing?(0,u.jsx)("td",{colSpan:2,className:"column mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("missingPluginMessageColumn"),children:e.missing_plugin_message&&e.missing_plugin_message.message&&e.missing_plugin_message.link?f()(e.missing_plugin_message.message,/\[link](.*?)\[\/link]/g,(t=>(0,u.jsx)("a",{className:"mailpoet-listing-link-important",href:e.missing_plugin_message.link,target:"_blank",rel:"noopener noreferrer",children:t},"missingPluginMessageLink"))):e.missing_plugin_message.message}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("subscribersCountColumn"),children:parseInt(e.count_all,10).toLocaleString()}),(0,u.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("subscribed"),children:parseInt(e.count_subscribed,10).toLocaleString()})]}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("updatedAtColumn"),children:[c.MailPoet.Date.short(e.created_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.created_at)]})]})}const bl=(0,Ne.EN)((function(e){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Do,{segmentType:"dynamic"}),(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,location:e.location,params:e.match.params,search:!0,onRenderItem:fl,endpoint:"dynamic_segments",base_url:"segments",columns:ul,messages:hl,sort_by:"created_at",sort_order:"desc",item_actions:gl,bulk_actions:_l}),(0,u.jsxs)("p",{className:"mailpoet_sending_methods_help help",children:[(0,u.jsxs)("b",{children:[c.MailPoet.I18n.t("segmentsTip"),":"]})," ",c.MailPoet.I18n.t("segmentsTipText")," ",(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/237-guide-to-subscriber-segmentation?utm_source=plugin&utm_medium=segments&utm_campaign=helpdocs",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("segmentsTipLink")})]})]})}));var xl=i(18925);const vl=[{name:(0,Fe.__)("Recently Subscribed","mailpoet"),slug:"recently-subscribed",category:lr.r9.ENGAGEMENT,description:(0,Fe.__)("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,Fe.__)("Engaged Subscribers (30 days)","mailpoet"),slug:"engaged-subscribers-30-days",category:lr.r9.ENGAGEMENT,description:(0,Fe.__)("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:"lastClickDate",operator:"inTheLast",value:"30"},{segmentType:"userRole",action:"lastOpenDate",operator:"inTheLast",value:"30"},{segmentType:"userRole",action:"lastPurchaseDate",operator:"inTheLast",value:"30"},{segmentType:"userRole",action:"lastSendingDate",operator:"inTheLast",value:"30"}],filtersConnect:lr.cK.OR},{name:(0,Fe.__)("Engaged Subscribers (3 months)","mailpoet"),slug:"engaged-subscribers-3-months",category:lr.r9.ENGAGEMENT,description:(0,Fe.__)("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:"lastClickDate",operator:"inTheLast",value:"90"},{segmentType:"userRole",action:"lastOpenDate",operator:"inTheLast",value:"90"},{segmentType:"userRole",action:"lastPurchaseDate",operator:"inTheLast",value:"90"},{segmentType:"userRole",action:"lastSendingDate",operator:"inTheLast",value:"90"}],filtersConnect:lr.cK.OR},{name:(0,Fe.__)("Engaged Subscribers (6 months)","mailpoet"),slug:"engaged-subscribers-6-months",category:lr.r9.ENGAGEMENT,description:(0,Fe.__)("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:"lastClickDate",operator:"inTheLast",value:"180"},{segmentType:"userRole",action:"lastOpenDate",operator:"inTheLast",value:"180"},{segmentType:"userRole",action:"lastPurchaseDate",operator:"inTheLast",value:"180"},{segmentType:"userRole",action:"lastSendingDate",operator:"inTheLast",value:"180"}],filtersConnect:lr.cK.OR},{name:(0,Fe.__)("Recent Buyers","mailpoet"),slug:"recent-buyers",category:lr.r9.PURCHASE_HISTORY,description:(0,Fe.__)("Customers who have made a purchase within the last 30 days. ","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:lr.u4.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:0,days:"30"}]},{name:(0,Fe.__)("Repeat Buyers","mailpoet"),slug:"repeat-buyers",category:lr.r9.PURCHASE_HISTORY,description:(0,Fe.__)("Customers who have made at least two purchases in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:lr.u4.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:1,days:"180"}]},{name:(0,Fe.__)("Loyal Buyers","mailpoet"),slug:"loyal-buyers",category:lr.r9.PURCHASE_HISTORY,description:(0,Fe.__)("Customers who have made at least five purchases in the last 12 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:lr.u4.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:4,days:"365"}]},{name:(0,Fe.__)("Win-Back","mailpoet"),slug:"win-back",category:lr.r9.PURCHASE_HISTORY,description:(0,Fe.__)("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,Fe.__)("Lapsed Customers","mailpoet"),slug:"lapsed-customers",category:lr.r9.PURCHASE_HISTORY,description:(0,Fe.__)("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,Fe.__)("Recent Openers","mailpoet"),slug:"recent-openers",category:lr.r9.ENGAGEMENT,description:(0,Fe.__)("Contacts who have opened an email in the last 7 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"opensAbsoluteCount",operator:"more",timeframe:lr.u4.IN_THE_LAST,opens:"0",days:"7"}]},{name:(0,Fe.__)("Big Spenders","mailpoet"),slug:"big-spenders",category:lr.r9.SHOPPING_BEHAVIOR,description:(0,Fe.__)("Customers who have completed $100 or more worth of orders in the last 12 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"woocommerce",action:"totalSpent",timeframe:lr.u4.IN_THE_LAST,total_spent_type:">",total_spent_amount:100,days:"365"}]}],jl=[{slug:lr.r9.ENGAGEMENT,name:(0,Fe.__)("Engagement","mailpoet")},{slug:lr.r9.PURCHASE_HISTORY,name:(0,Fe.__)("Purchase History","mailpoet")},{slug:lr.r9.SHOPPING_BEHAVIOR,name:(0,Fe.__)("Shopping Behavior","mailpoet")}];function yl(e){const t=jl.find((t=>t.slug===e));return t?t.name:null}var wl=i(41211);const Sl=[{name:"all",title:(0,u.jsx)(wl.J$,{title:(0,Fe.__)("All","mailpoet"),count:vl.length})}];function Pl(){const e=(0,P.Z)((e=>e(dr.t).getErrors()),[]),{createFromTemplate:t}=(0,he.Z)(dr.t),i=()=>{c.MailPoet.trackEvent("Segments > New empty segment")};return(0,u.jsxs)("div",{className:"mailpoet-main-container",children:[(0,u.jsx)(St.B,{}),(0,u.jsx)(d.Q,{}),(0,u.jsxs)(Pt.m,{className:"mailpoet-templates-header",heading:(0,Fe.__)("Start with a pre-built segment","mailpoet"),headingPrefix:(0,u.jsx)(Pt.x,{href:"#/",label:(0,Fe.__)("Segments list","mailpoet"),"aria-label":(0,Fe.__)("Navigate to the segments list page","mailpoet")}),children:[(0,u.jsx)(xl.Z,{label:(0,Fe.__)("Search segment templates","mailpoet")}),(0,u.jsx)(pe.ZP,{variant:"secondary",href:`#${Lo.yK}`,"data-automation-id":"new-custom-segment",onClick:()=>{i()},children:(0,Fe.__)("Create custom segment","mailpoet")})]}),e.length>0&&(0,u.jsx)(ni,{errors:e.map((e=>({message:e})))}),(0,u.jsx)(wl.x4,{tabs:Sl,children:e=>(0,u.jsx)(wl.rj,{children:vl.filter((t=>"all"===e.name||t.category===e.name)).map((e=>(0,u.jsx)(wl.ck,{name:e.name,description:e.description,category:yl(e.category),badge:e.isEssential?"essential":void 0,onClick:()=>{t(e)}},e.slug)))})}),(0,u.jsxs)(wl.$_,{children:[(0,u.jsx)("p",{children:(0,Fe.__)("Want to set your own conditions?","mailpoet")}),(0,u.jsx)(pe.ZP,{variant:"link",href:`#${Lo.yK}`,onClick:()=>{i()},children:(0,Fe.__)("Create custom segment","mailpoet")})]})]})}jl.forEach((e=>{const t=vl.filter((t=>t.category===e.slug)).length;Sl.push({name:e.slug,title:(0,u.jsx)(wl.J$,{title:e.name,count:t})})}));const Ml=document.getElementById("dynamic_segments_container");function Nl(){const{setPreviousPage:e}=(0,he.Z)(dr.t),t=(0,Ne.k6)(),i=(0,o.useRef)(t.location.pathname);return(0,o.useEffect)((()=>t.listen((t=>{e(i.current),i.current=t.pathname}))),[t,e]),null}function Il(){return(0,u.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(Nl,{}),(0,u.jsx)(m.w,{}),(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{path:Lo.yK,component:(0,r.withBoundary)(pl)}),(0,u.jsx)(Ne.AW,{path:`${Lo.jY}/:id`,component:(0,r.withBoundary)(pl)}),(0,u.jsx)(Ne.AW,{path:Lo.$W,component:(0,r.withBoundary)(Pl)}),(0,u.jsx)(Ne.AW,{path:"*",component:(0,r.withBoundary)(bl)})]})]})})}Ml&&((0,r.registerTranslations)(),(0,dr.M)(),(0,n.s)(Ml).render((0,u.jsx)(Il,{})));const Cl=()=>{c.MailPoet.trackEvent("Forms > Add New"),setTimeout((()=>{window.location=window.mailpoet_form_template_selection_url}),200)};function kl(){const[e,t]=(0,o.useState)(!1);return(0,u.jsx)(d.Q,{children:(0,u.jsx)(Oe.z,{onClick:()=>{t(!0),Cl()},withSpinner:e,automationId:"create_new_form",variant:"secondary",iconStart:$e.R,children:c.MailPoet.I18n.t("new")})})}kl.displayName="FormsHeading";const Tl=[{name:"name",label:c.MailPoet.I18n.t("formName"),sortable:!0},{name:"segments",label:c.MailPoet.I18n.t("segments")},{name:"type",label:c.MailPoet.I18n.t("type")},{name:"status",label:c.MailPoet.I18n.t("status")},{name:"updated_at",label:c.MailPoet.I18n.t("updatedAt"),sortable:!0}],El={onTrash:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneFormTrashed"):c.MailPoet.I18n.t("multipleFormsTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onDelete:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneFormDeleted"):c.MailPoet.I18n.t("multipleFormsDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onRestore:e=>{const t=Number(e.meta.count);let i=null;i=1===t?c.MailPoet.I18n.t("oneFormRestored"):c.MailPoet.I18n.t("multipleFormsRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(i)},onNoItemsFound:()=>(0,u.jsxs)("div",{className:"mailpoet-forms-add-new-row",children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("noItemsFound")}),(0,u.jsx)(r.Button,{onClick:Cl,automationId:"add_new_form",iconStart:$e.R,children:c.MailPoet.I18n.t("new")})]})},Al=[{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:El.onTrash}],Rl=[{name:"edit",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("edit"),link:function(e){return(0,u.jsx)("a",{href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:c.MailPoet.I18n.t("edit")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("duplicate"),onClick:function(e,t){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"duplicate",data:{id:e.id}}).done((e=>{const i=e.data.name?e.data.name:c.MailPoet.I18n.t("noName");c.MailPoet.Notice.success(c.MailPoet.I18n.t("formDuplicated").replace("%1$s",(0,Oo.r)(i))),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class Fl extends o.Component{updateStatus=(e,t)=>{t.persist(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"setStatus",data:{id:Number(t.target.getAttribute("data-id")),status:e?"enabled":"disabled"}}).done((e=>{"enabled"===e.data.status&&c.MailPoet.Notice.success(c.MailPoet.I18n.t("formActivated"))})).fail((i=>{c.MailPoet.Notice.showApiErrorNotice(i),t.target.checked=!e}))};isItemInactive=e=>"disabled"===e.status;renderStatus(e){return(0,u.jsxs)("div",{children:[(0,u.jsx)(ea.Z,{onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"enabled"===e.status}),(0,u.jsxs)("p",{children:[c.MailPoet.I18n.t("signups"),": ",e.signups.toLocaleString()]})]})}renderItem=(e,t)=>{null===e.settings&&c.MailPoet.Notice.error(c.MailPoet.I18n.t("formSettingsCorrupted").replace("%1$s",(0,Oo.r)(e.name)).replace("[link]",``).replace("[/link]",""));const i=ee()("manage-column","column-primary","has-row-actions"),a=window.mailpoet_segments.filter((t=>-1!==Ce().inArray(t.id,e.segments))),s=function(e){const t=[];return"1"===e?.form_placement?.fixed_bar?.enabled&&t.push(c.MailPoet.I18n.t("placeFixedBarFormOnPages")),"1"===e?.form_placement?.below_posts?.enabled&&t.push(c.MailPoet.I18n.t("placeFormBellowPages")),"1"===e?.form_placement?.popup?.enabled&&t.push(c.MailPoet.I18n.t("placePopupFormOnPages")),"1"===e?.form_placement?.slide_in?.enabled&&t.push(c.MailPoet.I18n.t("placeSlideInFormOnPages")),t.length>0?t.join(", "):c.MailPoet.I18n.t("placeFormOthers")}(e.settings);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("td",{className:i,children:[(0,u.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:e.name?e.name:`(${c.MailPoet.I18n.t("noName")})`}),t]}),(0,u.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("segments"),children:(0,u.jsx)(Fs.Eg,{segments:a,dimension:"large",children:"user"===e.settings?.segments_selected_by&&(0,u.jsx)("span",{className:"mailpoet-tags-prefix",children:c.MailPoet.I18n.t("userChoice")})})}),(0,u.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("type"),children:s}),(0,u.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("status"),children:this.renderStatus(e)}),(0,u.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("updatedAt"),children:[c.MailPoet.Date.short(e.updated_at),(0,u.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};render(){return(0,u.jsxs)("div",{className:"mailpoet-listing-no-actions-on-mobile",children:[(0,u.jsx)(kl,{}),(0,u.jsx)(Ee.N,{limit:window.mailpoet_listing_per_page,className:"mailpoet-forms-listing",location:this.props.location,params:this.props.match.params,messages:El,search:!1,endpoint:"forms",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:Tl,bulk_actions:Al,item_actions:Rl})]})}}Fl.propTypes={location:Te().object.isRequired,match:Te().shape({params:Te().object}).isRequired},Fl.displayName="FormList";const Ol=Bn(Fl);function Ll(){return(0,u.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(m.w,{}),(0,u.jsx)(Ne.AW,{path:"*",render:(0,r.withBoundary)(Ol)})]})})}const Dl=document.getElementById("forms_container");Dl&&((0,r.registerTranslations)(),(0,n.s)(Dl).render((0,u.jsx)(Ll,{})));var ql=i(85143);function $l(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ql.R,{}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("knowledgeBaseIntro")}),(0,u.jsxs)("ul",{className:"mailpoet-text-links",children:[(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/116-common-problems",children:"Common Problems"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/165-newsletters",children:"Newsletters"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/156-migration-questions",children:"Migration Questions"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/149-sending-methods",children:"Sending Methods"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/139-subscription-forms",children:"Subscription Forms"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/114-getting-started",children:"Getting Started"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/123-newsletter-designer",children:"Newsletter Designer"})}),(0,u.jsx)("li",{children:(0,u.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/121-subscribers-and-lists",children:"Subscribers and Lists"})})]}),(0,u.jsx)(Oe.z,{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/",children:c.MailPoet.I18n.t("knowledgeBaseButton")})]})}var Bl=i(39425);function Wl(e){e.target.select()}function Vl(e,t){if(rt.default.isObject(e)){const i=Object.keys(e).map((t=>`${t}: ${e[t]}`));return(0,u.jsx)("textarea",{readOnly:!0,id:t,onFocus:Wl,value:i.join("\n"),style:{width:"100%",height:"400px"}})}return(0,u.jsx)("p",{children:c.MailPoet.I18n.t("systemInfoDataError")})}function Ul(){const e="mailpoet-system-info",t=window.systemInfoData;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,u.jsx)("p",{children:c.MailPoet.I18n.t("systemInfoIntro")})}),Vl(t,e),(0,u.jsx)(Bl.m,{variant:"secondary",targetId:e})]})}function zl(e){return(0,u.jsx)("table",{className:"widefat fixed",style:{maxWidth:e.max_width},children:(0,u.jsx)("tbody",{children:e.rows.map((e=>(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{className:"row-title",children:e.key}),(0,u.jsx)("td",{children:e.value})]},`row_${e.key}`)))})})}function Hl(e){return(0,u.jsx)("span",{children:!0===e.children&&e.truthy||!1===e.children&&e.falsy||e.unknown})}function Zl(e){const t=e.status_data,i={active:c.MailPoet.I18n.t("running"),inactive:c.MailPoet.I18n.t("cronWaiting")},a=Array.isArray(t.last_error)?(0,u.jsx)(u.Fragment,{children:t.last_error.map((e=>(0,u.jsxs)("div",{children:[e.worker,": ",(0,u.jsx)("i",{children:e.message})]},e.worker)))}):t.last_error;return(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusCronStatusTitle")}),(0,u.jsx)(zl,{max_width:"400px",rows:[{key:c.MailPoet.I18n.t("accessible"),value:(0,u.jsx)(Hl,{children:t.accessible})},{key:c.MailPoet.I18n.t("status"),value:i[t.status]?i[t.status]:c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastUpdated"),value:t.updated_at?c.MailPoet.Date.full(1e3*t.updated_at):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastRunStarted"),value:t.run_accessed_at?c.MailPoet.Date.full(1e3*t.run_started_at):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastRunCompleted"),value:t.run_completed_at?c.MailPoet.Date.full(1e3*t.run_completed_at):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastSeenError"),value:a||c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("lastSeenErrorDate"),value:t.last_error_date?c.MailPoet.Date.full(1e3*t.last_error_date):c.MailPoet.I18n.t("unknown")}]})]})}function Yl(e){let t=e.task.scheduled_at;t&&(t=(0,Os.default)(t,"yyyy-MM-dd HH:mm:ss",new Date));const i=(0,Os.default)(e.task.updated_at,"yyyy-MM-dd HH:mm:ss",new Date);return(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{className:"column column-primary",children:e.task.id}),(0,u.jsx)("td",{className:"column",children:e.task.type}),(0,u.jsx)("td",{className:"column",children:e.task.newsletter?(0,u.jsx)("a",{href:e.task.newsletter.preview_url,"data-newsletter-id":e.task.newsletter.newsletter_id,"data-queue-id":e.task.newsletter.queue_id,target:"_blank",rel:"noopener noreferrer",children:e.task.newsletter.subject||c.MailPoet.I18n.t("preview")}):c.MailPoet.I18n.t("none")}),(0,u.jsx)("td",{className:"column",children:e.task.priority}),e.show_scheduled_at?(0,u.jsx)("td",{className:"column-date",children:(0,u.jsx)("abbr",{children:`${c.MailPoet.Date.short(t)} ${c.MailPoet.Date.time(t)}`})}):null,(0,u.jsx)("td",{className:"column-date",children:(0,u.jsx)("abbr",{children:`${c.MailPoet.Date.short(i)} ${c.MailPoet.Date.time(i)}`})})]})}function Gl(e){return(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{className:"row-title",children:"Id"}),(0,u.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("type")}),(0,u.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("email")}),(0,u.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("priority")}),e.show_scheduled_at?(0,u.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("scheduledAt")}):null,(0,u.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("updatedAt")})]})}function Kl(e){const t=e.show_scheduled_at?6:5;return(0,u.jsxs)("table",{className:"widefat fixed striped",children:[(0,u.jsx)("thead",{children:(0,u.jsx)(Gl,{show_scheduled_at:e.show_scheduled_at})}),(0,u.jsx)("tbody",{children:e.tasks.length?e.tasks.map((t=>(0,u.jsx)(Yl,{task:t,show_scheduled_at:e.show_scheduled_at},t.id))):(0,u.jsx)("tr",{className:"mailpoet-listing-no-items",children:(0,u.jsx)("td",{colSpan:t,children:c.MailPoet.I18n.t("nothingToShow")})})}),(0,u.jsx)("tfoot",{children:(0,u.jsx)(Gl,{show_scheduled_at:e.show_scheduled_at})})]})}function Ql(e){const t=e.status_data;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusQueueTitle")}),(0,u.jsx)(zl,{max_width:"400px",rows:[{key:c.MailPoet.I18n.t("status"),value:"paused"===t.status?c.MailPoet.I18n.t("paused"):c.MailPoet.I18n.t("running")},{key:c.MailPoet.I18n.t("startedAt"),value:t.started?c.MailPoet.Date.full(1e3*t.started):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("sentEmails"),value:t.sent||0},{key:c.MailPoet.I18n.t("retryAttempt"),value:t.retry_attempt||c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("retryAt"),value:t.retry_at?c.MailPoet.Date.full(1e3*t.retry_at):c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("error"),value:t.error?t.error.error_message:c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("totalCompletedTasks"),value:t.tasksStatusCounts.completed},{key:c.MailPoet.I18n.t("totalRunningTasks"),value:t.tasksStatusCounts.running},{key:c.MailPoet.I18n.t("totalPausedTasks"),value:t.tasksStatusCounts.paused},{key:c.MailPoet.I18n.t("totalScheduledTasks"),value:t.tasksStatusCounts.scheduled}]}),(0,u.jsx)("h5",{children:c.MailPoet.I18n.t("scheduledTasks")}),(0,u.jsx)(Kl,{show_scheduled_at:!0,tasks:t.latestTasks.filter((e=>"scheduled"===e.status))}),(0,u.jsx)("h5",{children:c.MailPoet.I18n.t("runningTasks")}),(0,u.jsx)(Kl,{tasks:t.latestTasks.filter((e=>null===e.status))}),(0,u.jsx)("h5",{children:c.MailPoet.I18n.t("completedTasks")}),(0,u.jsx)(Kl,{tasks:t.latestTasks.filter((e=>"completed"===e.status))})]})}function Xl(e){let{version:t,storage:i,latestTrigger:a,latestCompletedTrigger:s,latestCompletedRun:n}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h4",{children:c.MailPoet.I18n.t("actionSchedulerStatus")}),(0,u.jsx)(zl,{max_width:"400px",rows:[{key:c.MailPoet.I18n.t("version"),value:t},{key:c.MailPoet.I18n.t("storage"),value:i},{key:c.MailPoet.I18n.t("latestActionSchedulerTrigger"),value:c.MailPoet.Date.full(Je().utc(a).local())},{key:c.MailPoet.I18n.t("latestActionSchedulerCompletedTrigger"),value:c.MailPoet.Date.full(Je().utc(s).local())},{key:c.MailPoet.I18n.t("latestActionSchedulerCompletedRun"),value:c.MailPoet.Date.full(Je().utc(n).local())}]})]})}function Jl(e,t,i,a,s){const n=e?"success":"error";let o=e?t:i;return a&&(o=f()(o,/\[link\](.*?)\[\/link\]/g,(e=>(0,u.jsx)("a",{className:"mailpoet-text-link",href:a,children:e},"kb-link")))),(0,u.jsxs)("div",{className:`mailpoet_notice notice inline notice-${n}`,children:[(0,u.jsx)("p",{children:o}),s?(0,u.jsx)("p",{children:(0,u.jsx)("i",{children:s})}):null]})}function ed(e){const t=e.cron.isReachable,i=e.cron.url,a=`${c.MailPoet.I18n.t("systemStatusConnectionUnsuccessful")} ${c.MailPoet.I18n.t("systemStatusCronConnectionUnsuccessfulInfo")}`,s=c.MailPoet.I18n.t("systemStatusConnectionSuccessful"),n=t?null:e.cron.pingResponse;return(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusCronTitle")}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{className:"mailpoet-text-link",href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Jl(t,s,a,"https://kb.mailpoet.com/article/231-sending-does-not-work",n)]})}function td(e){const t=e.mss.enabled?`${c.MailPoet.I18n.t("systemStatusConnectionUnsuccessful")} ${c.MailPoet.I18n.t("systemStatusMSSConnectionUnsuccessfulInfo")}`:c.MailPoet.I18n.t("systemStatusMSSConnectionCanNotConnect"),i=e.mss.enabled?c.MailPoet.I18n.t("systemStatusConnectionSuccessful"):c.MailPoet.I18n.t("systemStatusMSSConnectionCanConnect");return(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusMSSTitle")}),Jl(e.mss.isReachable,i,t,"https://kb.mailpoet.com/article/319-known-errors-when-validating-a-mailpoet-key",null)]})}function id(){const e=window.systemStatusData,t=window.actionSchedulerData;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,u.jsx)("p",{children:e.mss.enabled?c.MailPoet.I18n.t("systemStatusIntroCronMSS"):c.MailPoet.I18n.t("systemStatusIntroCron")})}),ed(e),td(e),(0,u.jsx)(Zl,{status_data:e.cronStatus}),(0,u.jsx)(Xl,{...t}),t?(0,u.jsx)(Ql,{status_data:e.queueStatus}):null]})}function ad(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("yourPrivacyContent1")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("yourPrivacyContent2")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("yourPrivacyContent3")}),(0,u.jsx)(Oe.z,{target:"_blank",rel:"noreferrer noopener",href:"https://www.mailpoet.com/privacy-notice/",children:c.MailPoet.I18n.t("yourPrivacyButton")})]})}function sd(){return(0,u.jsxs)(l.k.Provider,{value:(0,l.S)(window),children:[(0,u.jsx)(d.D,{}),(0,u.jsx)(m.w,{}),(0,u.jsxs)(Fn.t,{activeKey:"knowledgeBase",children:[(0,u.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabKnowledgeBaseTitle"),children:(0,u.jsx)($l,{})},"knowledgeBase"),(0,u.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabSystemStatusTitle"),children:(0,u.jsx)(id,{})},"systemStatus"),(0,u.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabSystemInfoTitle"),children:(0,u.jsx)(Ul,{})},"systemInfo"),(0,u.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabYourPrivacyTitle"),children:(0,u.jsx)(ad,{})},"yourPrivacy")]})]})}zl.propTypes={max_width:Te().string,rows:Te().arrayOf(Te().shape({key:Te().string.isRequired,value:Te().oneOfType([Te().string,Te().number,Te().element]).isRequired})).isRequired},zl.defaultProps={max_width:"auto"},Hl.propTypes={truthy:Te().string,falsy:Te().string,unknown:Te().string,children:Te().bool},Hl.defaultProps={truthy:(0,Fe.__)("Yes","mailpoet"),falsy:(0,Fe.__)("No","mailpoet"),unknown:(0,Fe.__)("Unknown","mailpoet"),children:null},Zl.propTypes={status_data:Te().shape({accessible:Te().bool,last_error_date:Te().string,status:Te().string,updated_at:Te().number,run_accessed_at:Te().number,run_completed_at:Te().number,run_started_at:Te().number,last_error:Te().oneOfType([Te().string,Te().array])}).isRequired},Yl.propTypes={show_scheduled_at:Te().bool,task:Te().shape({id:Te().number.isRequired,type:Te().string.isRequired,priority:Te().number.isRequired,updated_at:Te().string.isRequired,scheduled_at:Te().string,status:Te().string,newsletter:Te().shape({newsletter_id:Te().number.isRequired,queue_id:Te().number.isRequired,preview_url:Te().string.isRequired,subject:Te().string})}).isRequired},Yl.defaultProps={show_scheduled_at:!1},Gl.propTypes={show_scheduled_at:Te().bool},Gl.defaultProps={show_scheduled_at:!1},Kl.propTypes={show_scheduled_at:Te().bool,tasks:Te().arrayOf(Yl.propTypes.task).isRequired},Kl.defaultProps={show_scheduled_at:!1},Ql.propTypes={status_data:Te().shape({status:Te().string,started:Te().number,sent:Te().number,retry_attempt:Te().number,retry_at:Te().number,error:Te().shape({operation:Te().string,error_message:Te().string}),tasksStatusCounts:Te().shape({completed:Te().number.isRequired,running:Te().number.isRequired,paused:Te().number.isRequired,scheduled:Te().number.isRequired}).isRequired,latestTasks:Te().arrayOf(Yl.propTypes.task).isRequired}).isRequired};const nd=document.getElementById("help_container");nd&&((0,r.registerTranslations)(),(0,n.s)(nd).render((0,u.jsx)(sd,{})));var od=i(13269);function rd(e){let{children:t,location:{pathname:i}}=e;return(0,o.useEffect)((()=>{window.scrollTo(0,0)}),[i]),t||null}rd.propTypes={location:Te().shape({pathname:Te().string.isRequired}).isRequired,children:Te().node.isRequired},rd.displayName="ScrollToTopComponent";const ld=(0,Ne.EN)((0,od.lV)(rd));function dd(e){let{activeMethod:t,onMethodChange:i}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,u.jsx)("span",{className:"mailpoet_import_heading",children:c.MailPoet.I18n.t("methodSelectionHead")}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs-row",children:(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file",target:"_blank",rel:"noopener noreferrer",children:(0,u.jsx)(At.V,{dimension:"large",variant:"excellent",isInverted:!0,children:c.MailPoet.I18n.t("seeVideo")})})})]}),(0,u.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,u.jsx)(ct.Y,{name:"select_method",automationId:"import-paste-method",id:"import-paste-method",checked:"paste-method"===t,value:"paste-method",onCheck:i}),(0,u.jsx)("label",{htmlFor:"import-paste-method",children:c.MailPoet.I18n.t("methodPaste")})]}),(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,u.jsx)(ct.Y,{name:"select_method",automationId:"import-csv-method",id:"import-csv-method",checked:"file-method"===t,value:"file-method",onCheck:i}),(0,u.jsx)("label",{htmlFor:"import-csv-method",children:c.MailPoet.I18n.t("methodUpload")})]}),(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,u.jsx)(ct.Y,{name:"select_method",automationId:"import-mailchimp-method",id:"import-mailchimp-method",checked:"mailchimp-method"===t,value:"mailchimp-method",onCheck:i}),(0,u.jsx)("label",{htmlFor:"import-mailchimp-method",children:c.MailPoet.I18n.t("methodMailChimp")})]})]})]})}function cd(e){let{hidePrevious:t,isLastStep:i,canGoNext:a,onPreviousAction:s,onNextAction:n}=e;return(0,u.jsxs)("div",{className:"mailpoet-settings-save",children:[!t&&(0,u.jsx)(Oe.z,{type:"button",variant:"secondary",onClick:s,children:c.MailPoet.I18n.t("previousStep")}),(0,u.jsx)(Oe.z,{type:"button",automationId:"import-next-step",isDisabled:!a,onClick:()=>{a&&n()},children:c.MailPoet.I18n.t(i?"import":"nextStep")})]})}dd.propTypes={activeMethod:Te().string,onMethodChange:Te().func.isRequired},dd.defaultProps={activeMethod:void 0},dd.displayName="SelectImportMethod",cd.propTypes={canGoNext:Te().bool,hidePrevious:Te().bool,isLastStep:Te().bool,onPreviousAction:Te().func,onNextAction:Te().func},cd.defaultProps={hidePrevious:!1,isLastStep:!1,canGoNext:!0,onPreviousAction:()=>{},onNextAction:()=>{}},cd.displayName="PreviousNextStepButtons";const md="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",pd="Email, First Name, Last Name\njohn@doe.com, John, Doe\nmary@smith.com, Mary, Smith\njohnny@walker.com, Johnny, Walker";function ud(e){let{onValueChange:t,canFinish:i,onFinish:a,data:s,onPrevious:n}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,u.jsx)("label",{htmlFor:"paste_input",children:c.MailPoet.I18n.t("pasteLabel")}),(0,u.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,u.jsx)("a",{className:"mailpoet-link",href:`${md}`,target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsx)(nt.g,{id:"paste_input",rows:"15",placeholder:pd,isCode:!0,onChange:e=>{t(e.target.value)},defaultValue:s})}),(0,u.jsx)(cd,{canGoNext:i,onPreviousAction:n,onNextAction:a})]})}ud.propTypes={onFinish:Te().func,onPrevious:Te().func,canFinish:Te().bool.isRequired,onValueChange:Te().func.isRequired,data:Te().string},ud.defaultProps={onFinish:()=>{},onPrevious:()=>{},data:""},ud.displayName="MethodPaste";const hd="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files";function gd(e){let{onValueChange:t,canFinish:i,onFinish:a,onPrevious:s}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,u.jsx)("label",{htmlFor:"file_local",children:c.MailPoet.I18n.t("methodUpload")}),(0,u.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,u.jsx)("a",{className:"mailpoet-link",href:`${hd}`,target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsx)(at.I,{type:"file",id:"file_local",accept:".csv","data-automation-id":"import-file-upload-input",onChange:e=>{const i=e.target.value.match(/[^.]+$/);c.MailPoet.Notice.hide(),null===i||"csv"!==i[0].toLowerCase()?(c.MailPoet.Notice.error(c.MailPoet.I18n.t("wrongFileFormat")),t("")):t(e.target.files[0])}})}),(0,u.jsx)(cd,{canGoNext:i,onPreviousAction:s,onNextAction:a})]})}function _d(e){let{onFinish:t,onPrevious:i}=e;const[a,s]=(0,o.useState)(""),[n,r]=(0,o.useState)(void 0),[l,d]=(0,o.useState)([]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mailpoet-settings-label",children:(0,u.jsxs)("label",{htmlFor:"mailpoet_mailchimp_key_input",children:[(0,u.jsx)("span",{className:"mailpoet_import_heading",children:c.MailPoet.I18n.t("methodMailChimpLabel")}),(0,u.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("methodMailChimpDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,u.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,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,u.jsx)(at.I,{dimension:"small",id:"mailpoet_mailchimp_key_input",type:"text",onChange:e=>{s(e.target.value),""===e.target.value.trim()&&r(void 0)}}),(0,u.jsx)("span",{className:"mailpoet-gap"}),(0,u.jsx)(Oe.z,{type:"button",dimension:"small",onClick:()=>{c.MailPoet.Modal.loading(!0),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpLists",data:{api_key:a}}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>r(e.data))).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},children:c.MailPoet.I18n.t("methodMailChimpVerify")}),(0,u.jsx)("span",{className:"mailpoet-gap"}),(0,u.jsx)("span",{children:Array.isArray(n)&&0===n.length?c.MailPoet.I18n.t("noMailChimpLists"):null})]})}),n?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("methodMailChimpSelectList")}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsx)(Re.Y,{field:{id:"segments",name:"list-selection",multiple:!0,placeholder:c.MailPoet.I18n.t("methodMailChimpSelectPlaceholder"),forceSelect2:!0,values:n},onValueChange:e=>d(e.target.value)})})]}):null,(0,u.jsx)(cd,{canGoNext:Array.isArray(l)&&l.length>0,onPreviousAction:i,onNextAction:()=>{c.MailPoet.Modal.loading(!0),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpSubscribers",data:{api_key:a,lists:l}}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>t(e.data))).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}})]})}gd.propTypes={canFinish:Te().bool.isRequired,onFinish:Te().func,onPrevious:Te().func,onValueChange:Te().func.isRequired},gd.defaultProps={onFinish:()=>{},onPrevious:()=>{}},gd.displayName="MethodUpload",_d.propTypes={onFinish:Te().func,onPrevious:Te().func},_d.defaultProps={onFinish:()=>{},onPrevious:()=>{}},_d.displayName="MethodMailChimp";var fd=i(80824),bd=i.n(fd);const xd=e=>window.roleBasedEmails.findIndex((t=>e.startsWith(`${t}@`)))>=0,vd=e=>{let t,i=rt.default.unescape(e);return i=i.toLowerCase().replace(/^["';.,\s]+|[^\x20-\x7E]+$|["';.,_\s]+$/g,"").replace(/\s+|%\d+|,+/g,""),t=/<(.*?)>/.exec(i),t&&(i=t[1].trim()),t=/mailto:(?:\s+)?(.*)/.exec(i),t&&(i=t[1].trim()),!!window.mailpoet_email_regex.test(i)&&!xd(i)&&i};function jd(e){let{history:t,setStepMethodSelectionData:i,subscribersLimitForValidation:a}=e;const[s,n]=(0,o.useState)(void 0),[l,d]=(0,o.useState)(""),[m,p]=(0,o.useState)(void 0),h=e=>{i(e),t.push(((e,t,i)=>void 0===e||void 0===e.subscribersCount||e.subscribersCount{t.push("/step_clean_list")},_=()=>{((e,t)=>{const i=encodeURI(e).split(/%..|./).length-1;c.MailPoet.Notice.hide(),i>window.maxPostSizeBytes?c.MailPoet.Notice.error(c.MailPoet.I18n.t("maxPostSizeNotice")):(c.MailPoet.Modal.loading(!0),bd().parse(e,function(e){return{skipEmptyLines:!0,error(){c.MailPoet.Notice.hide(),c.MailPoet.Notice.error(c.MailPoet.I18n.t("dataProcessingError"))},complete(t){const i=function(e){let t=[];const i=[],a=[],s=[],n=[];let o,r,l,d,c=null,m=null,p=!1;return Object.keys(e).forEach((u=>{l=e[u].map((e=>e.trim())),d=l.length,null===m&&(m=d),d===m&&(null===c?(Object.keys(l).forEach((e=>{r=vd(l[e]),null===c&&window.mailpoet_email_regex.test(r)&&(c=e,i[r]=!0,l[e]=r,t[r]=l)})),null===c&&0===parseInt(u,10)&&(p=!0,t[0]=l)):""!==l[c]&&(o=vd(l[c]),rt.default.has(i,o)?a.push(o):xd(l[c])?n.push(l[c]):window.mailpoet_email_regex.test(o)?(i[o]=!0,l[c]=o,t[o]=l):s.push(l[c])))})),t=rt.default.values(t),t&&(p&&t.length>=2||!p&&t.length>=1)?{header:window.mailpoet_email_regex.test(t[0][c])?null:t.shift(),subscribers:t,subscribersCount:t.length,duplicate:rt.default.uniq(a),invalid:rt.default.uniq(s),role:rt.default.uniq(n)}:null}(t.data);if(i)e(i);else{let e=c.MailPoet.I18n.t("noValidRecords");e=e.replace("[link]",''),e=e.replace("[/link]",""),c.MailPoet.Notice.error(e)}c.MailPoet.Modal.loading(!1)}}}((e=>{c.MailPoet.trackEvent("Subscribers import started",{source:"file-method"===s?"file upload":"pasted data"}),h(e)}))))})("paste-method"===s?l:m)};return(0,u.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(dd,{activeMethod:s,onMethodChange:n})}),"paste-method"===s&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(ud,{onPrevious:g,onValueChange:d,onFinish:_,canFinish:!!l.trim(),data:l})}),"file-method"===s&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(gd,{onPrevious:g,onValueChange:p,onFinish:_,canFinish:!!m,data:m})}),"mailchimp-method"===s&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(_d,{onPrevious:g,onFinish:e=>{c.MailPoet.trackEvent("Subscribers import started",{source:"MailChimp"}),h(e)}})}),void 0===s&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(cd,{canGoNext:!1,onPreviousAction:g})})]})}jd.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired,setStepMethodSelectionData:Te().func.isRequired,subscribersLimitForValidation:Te().number.isRequired},jd.diplayName="StepMethodSelection";const yd=(0,Ne.EN)(jd);function wd(e){let{onProceed:t,iHaveCleanedList:i}=e;return(0,u.jsxs)("div",{className:"mailpoet-clean-list-step-container",children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("cleanListText1")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("cleanListText2")}),(0,u.jsxs)("p",{children:[t&&(0,u.jsx)(Oe.z,{onClick:t,variant:"tertiary",children:c.MailPoet.I18n.t("listCleaningGotIt")}),(0,u.jsx)(Oe.z,{target:"_blank",href:"https://kb.mailpoet.com/article/287-list-cleaning-services",children:c.MailPoet.I18n.t("tryListCleaning")}),i&&(0,u.jsx)(Oe.z,{onClick:i,variant:"secondary",children:c.MailPoet.I18n.t("cleanedList")})]})]})}function Sd(e){let{onSubmit:t,history:i}=e;const[a,s]=(0,o.useState)(void 0);return(0,u.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,u.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("validationStepHeading")}),(0,u.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,u.jsx)(ct.Y,{automationId:"mailpoet_import_validation_step_option1",id:"existing-list",checked:"existing-list"===a,value:"existing-list",onCheck:s}),(0,u.jsx)("label",{htmlFor:"existing-list",children:c.MailPoet.I18n.t("validationStepRadio1")})]}),(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,u.jsx)(ct.Y,{automationId:"mailpoet_import_validation_step_option2",id:"address-book",checked:"address-book"===a,value:"address-book",onCheck:s}),(0,u.jsx)("label",{htmlFor:"address-book",children:c.MailPoet.I18n.t("validationStepRadio2")})]})]}),(0,u.jsx)(cd,{canGoNext:void 0!==a,onPreviousAction:()=>i.push("step_method_selection"),onNextAction:()=>t(a)})]})}function Pd(){return(0,u.jsxs)("div",{className:"mailpoet-clean-list-step-container","data-automation-id":"import_wrong_source_block",children:[(0,u.jsx)("p",{children:c.MailPoet.I18n.t("validationStepBlock1")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("validationStepBlock2")}),(0,u.jsx)("p",{children:(0,u.jsx)(Oe.z,{href:"https://kb.mailpoet.com/article/269-reconfirm-subscribers-to-your-list",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("validationStepBlockButton")})})]})}function Md(e){let{onSubmit:t}=e;const[i,a]=(0,o.useState)("over2years"),s=(0,o.useCallback)((e=>{a(e.target.value)}),[a]),n=(0,o.useCallback)((()=>{t("over2years"===i||"1to2years"===i?"notRecently":"recently")}),[t,i]);return(0,u.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,u.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("validationStepLastSentHeading")}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsxs)(lt.Select,{defaultValue:i,onChange:s,automationId:"last_sent_to_list",children:[(0,u.jsx)("option",{value:"over2years",children:c.MailPoet.I18n.t("validationStepLastSentOption1")}),(0,u.jsx)("option",{value:"1to2years",children:c.MailPoet.I18n.t("validationStepLastSentOption2")}),(0,u.jsx)("option",{value:"less1year",children:c.MailPoet.I18n.t("validationStepLastSentOption3")}),(0,u.jsx)("option",{value:"less3months",children:c.MailPoet.I18n.t("validationStepLastSentOption4")})]})}),(0,u.jsx)("div",{className:"mailpoet-settings-save",children:(0,u.jsx)(Oe.z,{type:"button",automationId:"last_sent_to_list_next",onClick:n,children:c.MailPoet.I18n.t("validationStepLastSentNext")})})]})}function Nd(e){let{stepMethodSelectionData:t,history:i}=e;const[a,s]=(0,o.useState)(void 0),[n,l]=(0,o.useState)(void 0);(0,o.useEffect)((()=>{void 0===t&&i.replace("step_method_selection")}),[t,i]);const d=(0,o.useCallback)((e=>{l(e),"recently"===e&&i.push("step_data_manipulation")}),[i,l]);return(0,u.jsxs)(u.Fragment,{children:[void 0===a&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Sd,{onSubmit:s,history:i})}),"address-book"===a&&(0,u.jsx)(Pd,{}),"existing-list"===a&&void 0===n&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Md,{onSubmit:d})}),"existing-list"===a&&"notRecently"===n&&(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(wd,{iHaveCleanedList:()=>d("recently")})})]})}wd.displayName="CleanList",Sd.propTypes={history:Te().shape({push:Te().func.isRequired}).isRequired,onSubmit:Te().func.isRequired},Sd.displayName="InitialQuestion",Md.propTypes={onSubmit:Te().func.isRequired},Md.displayName="LastSentQuestion",Nd.defaultProps={stepMethodSelectionData:void 0},Nd.displayName="StepInputValidationComponent";const Id=(0,Ne.EN)(Nd);function Cd(e){let{translation:t,subscribers:i}=e,a="";return i.length&&(a=f()(t.replace("%2$s",i.join(", ")),"%1$s",(()=>(0,u.jsx)("strong",{children:i.length.toLocaleString()},t))),a=(0,u.jsx)("p",{children:a})),a}function kd(e){let{stepMethodSelectionData:t}=e;const{invalid:i,duplicate:a,role:s}=t,[n,r]=(0,o.useState)(!1),l=ee()("mailpoet_subscribers_data_parse_results_details",{mailpoet_hidden:!n}),d=(0,u.jsx)(Cd,{translation:c.MailPoet.I18n.t("importNoticeInvalid"),subscribers:i}),m=(0,u.jsx)(Cd,{translation:c.MailPoet.I18n.t("importNoticeDuplicate"),subscribers:a});let p="";if(s.length&&(p=f()(c.MailPoet.I18n.t("importNoticeRoleBased"),/(%1\$s|\[link\].*\[\/link\]|%2\$s)/,(e=>"%1$s"===e?(0,u.jsx)("strong",{children:s.length.toLocaleString()},"role-length"):"%2$s"===e?s.join(", "):(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/270-role-based-email-addresses-are-not-allowed",target:"_blank",rel:"noopener noreferrer",children:e.replace("[link]","").replace("[/link]","")},e))),p=(0,u.jsx)("p",{children:p})),i.length||a.length||s.length){const e=i.length+a.length+s.length;return(0,u.jsxs)("div",{className:"error",children:[(0,u.jsxs)("p",{children:[f()(c.MailPoet.I18n.t("importNoticeSkipped"),"%1$s",(()=>(0,u.jsx)("strong",{children:e.toLocaleString()},"lengths")))," ",(0,u.jsx)("a",{className:"mailpoet_subscribers_data_parse_results_details_show","data-automation-id":"show-more-details",onClick:()=>r(!n),role:"button",tabIndex:0,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),r(!n))},children:c.MailPoet.I18n.t("showMoreDetails")})]}),(0,u.jsxs)("div",{className:l,children:[(0,u.jsx)("hr",{}),d,m,p]})]})}return null}Cd.propTypes={translation:Te().string.isRequired,subscribers:Te().arrayOf(Te().string).isRequired},kd.propTypes={stepMethodSelectionData:Te().shape({duplicate:Te().arrayOf(Te().string),invalid:Te().arrayOf(Te().string),role:Te().arrayOf(Te().string)})},kd.defaultProps={stepMethodSelectionData:{invalid:[],duplicate:[],role:[]}};const Td=()=>{const e={data:window.mailpoetColumnsSelect2,width:"15em"};Ce()("select.mailpoet_subscribers_column_data_match").select2(e).on("select2:selecting",(t=>{const i=t.currentTarget,a=t.params.args.data.id;"create"===a?(t.preventDefault(),Ce()(i).select2("close"),c.MailPoet.Modal.popup({title:c.MailPoet.I18n.t("addNewField"),template:Ce()("#form_template_field_form").html()}),Ce()("#form_field_new").parsley().on("form:submit",(()=>{const t=Ce()("#form_field_new").mailpoetSerializeObject();return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"customFields",action:"save",data:t}).done((t=>{const a={id:t.data.id,name:t.data.name,text:t.data.name,type:t.data.type,params:t.data.params,custom:!0};2===window.mailpoetColumnsSelect2.length&&window.mailpoetColumnsSelect2.push({name:c.MailPoet.I18n.t("userColumns"),children:[]}),window.mailpoetColumnsSelect2[2].children.push(a),window.mailpoetColumns.push(a),Ce()("select.mailpoet_subscribers_column_data_match").each((()=>{Ce()(i).html("").select2("destroy").select2(e)})),Ce()(i).data("column-id",a.id),c.MailPoet.Modal.close()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{positionAfter:"#field_name"})})),!1}))):Ce()("select.mailpoet_subscribers_column_data_match").each((()=>{const e=i,s=Ce()(e).val();s===a&&"ignore"!==s&&(confirm(`${c.MailPoet.I18n.t("selectedValueAlreadyMatched")} ${c.MailPoet.I18n.t("confirmCorrespondingColumn")}`)?Ce()(e).data("column-id","ignore"):(t.preventDefault(),Ce()(i).select2("close")))}))})).on("select2:select",(e=>{const t=e.currentTarget,i=e.params.data.id;Ce()(t).data("column-id",i)})).on("select2:open",(()=>{const e=document.querySelectorAll(".select2-search__field[aria-controls]");0!==e.length&&e[e.length-1].focus()})),Ce().map(Ce()(".mailpoet_subscribers_column_data_match"),(e=>{const t=Ce()(e).data("column-id");Ce()(e).val(t).trigger("change")}))},Ed=(e,t)=>{const i=[],a=[];let s,n,o,r;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&&(o=t[l],r=window.mailpoetColumns.map((e=>e.name)).indexOf(o),-1!==r?n=window.mailpoetColumns[r].id:o&&(/first|first name|given name/i.test(o)?n="first_name":/last|last name/i.test(o)&&(n="last_name"))),n="ignore"!==n&&-1===a.indexOf(n)?n:"ignore",i[l]={column_id:n},a.push(n)})),i},Ad=10;function Rd(e){let{header:t,subscribers:i}=e;const a=Ed(i,t);return(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:c.MailPoet.I18n.t("matchData")}),a.map(((e,t)=>(0,u.jsx)("th",{children:(0,u.jsx)("select",{className:"mailpoet_subscribers_column_data_match","data-column-id":e.column_id,"data-column-index":t,id:`column_${t}`})},e.column_id+t)))]})}function Fd(e){let{header:t}=e;return(0,u.jsxs)("tr",{className:"mailpoet_header",children:[(0,u.jsx)("td",{}),t.map((e=>(0,u.jsx)("td",{children:e},e)))]})}function Od(e){let{subscriber:t,index:i}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("td",{children:i}),t.map(((e,t)=>(0,u.jsx)("td",{children:e},`${e}-${i}-${t}`)))]})}function Ld(e){let{subscribers:t,subscribersCount:i}=e;const a=". . .",s=Array(t[0].length).fill(a);return(0,u.jsxs)(u.Fragment,{children:[t.slice(0,Ad).map(((e,t)=>(0,u.jsx)("tr",{children:(0,u.jsx)(Od,{subscriber:e,index:t+1})},`${e[0]}-${t}`))),i>Ad+1?(0,u.jsx)("tr",{children:(0,u.jsx)(Od,{subscriber:s,index:a})},"filler"):null,i>Ad?(0,u.jsx)("tr",{children:(0,u.jsx)(Od,{subscriber:t[i-1],index:i})},t[i-1][0]):null]})}function Dd(e){let{subscribersCount:t,subscribers:i,header:a}=e;return(0,o.useLayoutEffect)((()=>{Td()})),(0,u.jsx)("div",{className:"subscribers_data",children:(0,u.jsxs)("table",{className:"mailpoet_subscribers widefat fixed",children:[(0,u.jsx)("thead",{children:(0,u.jsx)(Rd,{header:a,subscribers:i})}),(0,u.jsxs)("tbody",{children:[a?(0,u.jsx)(Fd,{header:a}):null,(0,u.jsx)(Ld,{subscribers:i,subscribersCount:t})]})]})})}Rd.propTypes={subscribers:Te().arrayOf(Te().arrayOf(Te().oneOfType([Te().string,Te().number]))).isRequired,header:Te().arrayOf(Te().string)},Rd.defaultProps={header:[]},Fd.propTypes={header:Te().arrayOf(Te().string).isRequired},Od.propTypes={subscriber:Te().arrayOf(Te().oneOfType([Te().string,Te().number])).isRequired,index:Te().node.isRequired},Ld.propTypes={subscribersCount:Te().number.isRequired,subscribers:Te().arrayOf(Te().arrayOf(Te().oneOfType([Te().string,Te().number]))).isRequired},Dd.propTypes={subscribersCount:Te().number,subscribers:Te().arrayOf(Te().arrayOf(Te().oneOfType([Te().string,Te().number]))),header:Te().arrayOf(Te().string)},Dd.defaultProps={subscribersCount:0,subscribers:[],header:[]};const qd=e=>{c.MailPoet.Modal.popup({title:c.MailPoet.I18n.t("addNewList"),template:Ce()("#new_segment_template").html()}),Ce()("#new_segment_name").on("keypress",(e=>{13===e.which&&Ce()("#new_segment_process").trigger("click")})),Ce()("#new_segment_process").on("click",(()=>{const t=Ce()("#new_segment_name").val().trim(),i=Ce()("#new_segment_description").val().trim();c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"addSegment",data:{name:t,description:i}}).done((t=>{e({id:t.data.id,name:t.data.name,text:t.data.name,subscriberCount:0}),c.MailPoet.Modal.close()})).fail((e=>{e.errors.length>0&&(c.MailPoet.Notice.hide(),c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{positionAfter:"#new_segment_name"}))}))})),Ce()("#new_segment_cancel").on("click",(()=>{c.MailPoet.Modal.close()}))};function $d(e){let{setSelectedSegments:t}=e;const{segments:i}=(0,o.useContext)(l.k),{all:a,updateAll:s}=i,[n,r]=(0,o.useState)(a);(0,o.useLayoutEffect)((()=>{!function(e,i){const a=Ce()("select#mailpoet_segments_select");if(a.data("select2"))return;const s=e=>{let t=`${e.name}`;return e.count&&(t+=`${e.count}`),t};a.html(""),a.select2({data:e.map((e=>({...e,text:e.name}))),dropdownCssClass:"mailpoet-form-select2-dropdown",escapeMarkup:e=>e,templateResult:s,templateSelection:s}).on("change",(e=>{const i=Ce()('[data-id="notice_segmentSelection"]');e.currentTarget.value?Ce()('[data-id="notice_segmentSelection"]').remove():i.length||c.MailPoet.Notice.error(c.MailPoet.I18n.t("segmentSelectionRequired"),{static:!0,scroll:!0,id:"notice_segmentSelection",hideClose:!0});(e=>{t(e)})(rt.default.pluck(a.select2("data"),"id"))}))}(n)}),[n,t]);const d=e=>{!function(){const e=Ce()("select#mailpoet_segments_select");e.data("select2")&&(e.select2("destroy"),e.find("option").remove(),e.off("select2:unselecting").off("change").off("select2:opening"))}(),t([]),r([...n,e]),s([...n,e])};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mailpoet-settings-label",children:(0,u.jsxs)("label",{htmlFor:"mailpoet_segments_select",children:[c.MailPoet.I18n.t("pickLists"),(0,u.jsx)("p",{className:"description",children:c.MailPoet.I18n.t("pickListsDescription")})]})}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,u.jsx)("div",{className:"mailpoet-form-select mailpoet-form-input",children:(0,u.jsx)("select",{id:"mailpoet_segments_select","data-placeholder":c.MailPoet.I18n.t("select"),multiple:"multiple",children:(0,u.jsx)("option",{})})}),(0,u.jsx)(Oe.z,{variant:"tertiary",onClick:()=>qd(d),children:c.MailPoet.I18n.t("createANewList")})]})})]})}function Bd(){return(0,u.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("consentSubscribed"),/\[link](.*?)\[\/link]/,(e=>(0,u.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 Wd(e){let{newSubscribersStatus:t,setNewSubscribersStatus:i}=e;const a=(0,o.useCallback)((e=>{i(e.target.value)}),[i]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,u.jsx)("label",{htmlFor:"new_subscribers_status",children:c.MailPoet.I18n.t("newSubscribersStatus")}),(0,u.jsx)(Bd,{})]}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsxs)(lt.Select,{id:"new_subscribers_status",placeholder:c.MailPoet.I18n.t("select"),name:"new_subscribers_status",onChange:a,defaultValue:t,children:[(0,u.jsx)("option",{value:"subscribed",children:c.MailPoet.I18n.t("subscribed")}),(0,u.jsx)("option",{value:"inactive",children:c.MailPoet.I18n.t("inactive")}),(0,u.jsx)("option",{value:"unsubscribed",children:c.MailPoet.I18n.t("unsubscribed")})]})})]})}function Vd(e){let{existingSubscribersStatus:t,setExistingSubscribersStatus:i}=e;const a=(0,o.useCallback)((e=>{i(e.target.value)}),[i]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,u.jsx)("label",{htmlFor:"existing_subscribers_status",children:c.MailPoet.I18n.t("existingSubscribersStatus")}),(0,u.jsx)(Bd,{})]}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,u.jsxs)(lt.Select,{id:"existing_subscribers_status",placeholder:c.MailPoet.I18n.t("select"),name:"existing_subscribers_status",onChange:a,defaultValue:t,children:[(0,u.jsx)("option",{value:"dont_update",children:c.MailPoet.I18n.t("dontUpdate")}),(0,u.jsx)("option",{value:"subscribed",children:c.MailPoet.I18n.t("subscribed")}),(0,u.jsx)("option",{value:"inactive",children:c.MailPoet.I18n.t("inactive")}),(0,u.jsx)("option",{value:"unsubscribed",children:c.MailPoet.I18n.t("unsubscribed")})]})})]})}function Ud(e){let{updateExistingSubscribers:t,setUpdateExistingSubscribers:i}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("updateExistingSubscribers")}),(0,u.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,u.jsx)(ct.Y,{id:"update_existing_subscribers",name:"update_existing_subscribers",value:"1",checked:t,onCheck:()=>i(!0)}),(0,u.jsx)("label",{htmlFor:"update_existing_subscribers",children:c.MailPoet.I18n.t("updateExistingSubscribersYes")}),(0,u.jsx)("span",{className:"mailpoet-gap"}),(0,u.jsx)(ct.Y,{id:"dont_update_existing_subscribers",name:"update_existing_subscribers",value:"",checked:!t,onCheck:()=>i(!1)}),(0,u.jsx)("label",{htmlFor:"dont_update_existing_subscribers",children:c.MailPoet.I18n.t("updateExistingSubscribersNo")})]})]})}$d.propTypes={setSelectedSegments:Te().func.isRequired},Ud.propTypes={setUpdateExistingSubscribers:Te().func.isRequired,updateExistingSubscribers:Te().bool.isRequired},i(49868);function zd(e){let{selectedTags:t,setSelectedTags:i}=e;const a=(0,o.useCallback)((e=>{let{value:t}=e;i(t)}),[i]),s=c.MailPoet.tags.map((e=>e.name));return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mailpoet-settings-label",children:[c.MailPoet.I18n.t("assignTagsLabel"),(0,u.jsx)("p",{className:"description",children:c.MailPoet.I18n.t("assignTagsDescription")})]}),(0,u.jsx)("div",{className:"mailpoet-settings-inputs mailpoet-import-tags",children:(0,u.jsx)(xt.T,{name:"tags",onChange:a,suggestedValues:s,selectedValues:t,placeholder:c.MailPoet.I18n.t("addNewTag")})})]})}function Hd(e){let{history:t,stepMethodSelectionData:i,subscribersLimitForValidation:a,setStepDataManipulationData:s}=e;const[n,r]=(0,o.useState)([]),[l,d]=(0,o.useState)(!0),[m,p]=(0,o.useState)("subscribed"),[h,g]=(0,o.useState)("dontUpdate"),[_,f]=(0,o.useState)([]);return(0,o.useEffect)((()=>{void 0===i&&t.replace("step_method_selection")}),[i,t]),void 0===i?null:(0,u.jsxs)("div",{"data-automation-id":"import_data_manipulation_step",children:[(0,u.jsx)(kd,{stepMethodSelectionData:i}),(0,u.jsx)(Dd,{subscribersCount:i.subscribersCount,subscribers:i.subscribers,header:i.header}),(0,u.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,u.jsx)($d,{setSelectedSegments:r}),(0,u.jsx)(Wd,{newSubscribersStatus:m,setNewSubscribersStatus:p}),(0,u.jsx)(Vd,{existingSubscribersStatus:h,setExistingSubscribersStatus:g}),(0,u.jsx)(Ud,{setUpdateExistingSubscribers:d,updateExistingSubscribers:l}),(0,u.jsx)(zd,{selectedTags:_,setSelectedTags:f}),(0,u.jsx)(cd,{canGoNext:n.length>0,onPreviousAction:()=>t.push(function(e,t){return void 0===e||void 0===e.subscribersCount||e.subscribersCount{((e,t,i,a,s,n,o)=>{const r={},l=new(Ce().AsyncQueue);let d=0;const m=Date.now()/1e3,p={created:0,updated:0,errors:[],segments:[],tags:[]};c.MailPoet.Modal.progress(!0);const u=e.reduce(((e,t,i)=>(i%2e3==0&&e.push([]),e[e.length-1].push(t),e)),[]);rt.default.each(Ce()("select.mailpoet_subscribers_column_data_match"),((e,t)=>{const i=Ce()(e).data("column-id");"ignore"!==i&&(r[i]={index:t})})),rt.default.each(u,(()=>{l.add((o=>{o.pause(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"processImport",data:JSON.stringify({columns:r,subscribers:u[d],timestamp:m,segments:t,newSubscribersStatus:i,existingSubscribersStatus:a,updateSubscribers:s,tags:n})}).done((t=>{const i=t.data.added_to_segment_with_welcome_notification;var a,s;p.created+=t.data.created,p.updated+=t.data.updated,p.segments=t.data.segments,p.added_to_segment_with_welcome_notification=i,c.MailPoet.Modal.setProgress((a=p,s=e,Math.floor((a.created+a.updated)/s.length*100))),o.run()})).fail((e=>{c.MailPoet.Modal.progress(!1),e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})),d+=1}))})),l.run(),l.onComplete((()=>{c.MailPoet.Modal.progress(!1),p.errors.length>0&&!p.updated&&!p.created?c.MailPoet.Notice.error(rt.default.flatten(p.errors)):(p.segments=rt.default.map(rt.default.filter(p.segments,(e=>t.includes(e.id))),(e=>e.name)),o(p))}))})(i.subscribers,n,m,h,l,_,(e=>{s(e),t.push("step_results")}))},isLastStep:!0})]})]})}Hd.propTypes={history:Te().shape({push:Te().func.isRequired,replace:Te().func.isRequired}).isRequired,stepMethodSelectionData:Te().shape({duplicate:Te().arrayOf(Te().string),header:Te().arrayOf(Te().string),invalid:Te().arrayOf(Te().string),role:Te().arrayOf(Te().string),subscribersCount:Te().number,subscribers:Te().arrayOf(Te().arrayOf(Te().oneOfType([Te().string,Te().number])))}),subscribersLimitForValidation:Te().number.isRequired,setStepDataManipulationData:Te().func.isRequired},Hd.defaultProps={stepMethodSelectionData:void 0};const Zd=(0,Ne.EN)(Hd);function Yd(e){let{subscribersCount:t,segments:i,initialMessage:a}=e;if(t){let e=f()(a,"%1$s",(()=>(0,u.jsx)("strong",{children:t.toLocaleString()},"%1$s")));return e=f()(e,"%2$s",(()=>`"${i.join('", "')}"`)),(0,u.jsx)("p",{children:e})}return null}function Gd(e){let{createdSubscribers:t,updatedSubscribers:i}=e;return t||i?null:(0,u.jsx)("p",{children:c.MailPoet.I18n.t("importNoAction")})}function Kd(e){let{createdSubscribers:t,updatedSubscribers:i}=e;return t||i?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{children:(0,u.jsx)("b",{children:c.MailPoet.I18n.t("congratulationResult")})}),(0,u.jsx)("p",{children:f()(c.MailPoet.I18n.t("suppressionListReminder"),/\[link](.*?)\[\/link]/,(e=>(0,u.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 Qd(e){let{addedToSegmentWithWelcomeNotification:t}=e;return t?(0,u.jsx)("p",{children:c.MailPoet.I18n.t("importNoWelcomeEmail")}):null}function Xd(e){let{errors:t,createdSubscribers:i,updatedSubscribers:a,segments:s,addedToSegmentWithWelcomeNotification:n,history:l}=e;return(0,o.useEffect)((()=>{void 0===s&&0===t.length&&void 0===i&&void 0===a&&l.replace("step_method_selection")}),[s,i,t.length,l,a]),t.length&&c.MailPoet.Notice.error(rt.default.flatten(t)),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsxs)("div",{className:"updated",children:[(0,u.jsx)(Yd,{subscribersCount:i,segments:s,initialMessage:c.MailPoet.I18n.t("subscribersCreated")}),(0,u.jsx)(Yd,{subscribersCount:a,segments:s,initialMessage:c.MailPoet.I18n.t("subscribersUpdated")}),(0,u.jsx)(Gd,{createdSubscribers:i,updatedSubscribers:a}),(0,u.jsx)(Qd,{addedToSegmentWithWelcomeNotification:n})]})}),(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Kd,{createdSubscribers:i,updatedSubscribers:a})}),(0,u.jsx)("div",{className:"mailpoet-settings-grid",children:(0,u.jsxs)("div",{className:"mailpoet-settings-save",children:[(0,u.jsx)(Oe.z,{variant:"secondary",type:"button",onClick:()=>l.push("step_method_selection"),children:c.MailPoet.I18n.t("importAgain")}),(0,u.jsx)(Oe.z,{type:"button",onClick:()=>{window.location.href="admin.php?page=mailpoet-subscribers"},children:c.MailPoet.I18n.t("viewSubscribers")})]})})]})}Yd.propTypes={segments:Te().arrayOf(Te().string.isRequired),subscribersCount:Te().number,initialMessage:Te().string},Yd.defaultProps={segments:[],subscribersCount:0,initialMessage:""},Yd.displayName="ResultMessage",Gd.propTypes={createdSubscribers:Te().number,updatedSubscribers:Te().number},Gd.defaultProps={createdSubscribers:0,updatedSubscribers:0},Gd.displayName="NoAction",Kd.propTypes={createdSubscribers:Te().number,updatedSubscribers:Te().number},Kd.defaultProps={createdSubscribers:0,updatedSubscribers:0},Kd.displayName="SuppressionListReminder",Qd.propTypes={addedToSegmentWithWelcomeNotification:Te().bool},Qd.defaultProps={addedToSegmentWithWelcomeNotification:!1},Qd.diplayName="NoWelcomeEmail",Xd.propTypes={history:Te().shape({push:Te().func.isRequired,replace:Te().func.isRequired}).isRequired,errors:Te().arrayOf(Te().string.isRequired),segments:Te().arrayOf(Te().string.isRequired),createdSubscribers:Te().number,updatedSubscribers:Te().number,addedToSegmentWithWelcomeNotification:Te().bool},Xd.defaultProps={errors:[],segments:void 0,createdSubscribers:void 0,updatedSubscribers:void 0,addedToSegmentWithWelcomeNotification:void 0},Xd.displayName="StepResultsComponent";const Jd=(0,Ne.EN)(Xd);function ec(e){let{history:t}=e;return(0,u.jsx)(wd,{onProceed:()=>t.push("step_method_selection")})}ec.displayName="StepCleanList";const tc=document.getElementById("import_container");function ic(){const[e,t]=(0,o.useState)(void 0),[i,a]=(0,o.useState)({}),s=(0,l.S)(window);return(0,u.jsx)(l.k.Provider,{value:s,children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(m.w,{}),(0,u.jsx)(ld,{children:(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{path:"/step_clean_list",render:(0,r.withBoundary)(ec)}),(0,u.jsx)(Ne.AW,{path:"/step_method_selection",render:e=>(0,u.jsx)(yd,{...e,setStepMethodSelectionData:t,subscribersLimitForValidation:100})}),(0,u.jsx)(Ne.AW,{path:"/step_input_validation",render:t=>(0,u.jsx)(Id,{...t,stepMethodSelectionData:e})}),(0,u.jsx)(Ne.AW,{path:"/step_data_manipulation",render:t=>(0,u.jsx)(Zd,{...t,stepMethodSelectionData:e,subscribersLimitForValidation:100,setStepDataManipulationData:a})}),(0,u.jsx)(Ne.AW,{path:"/step_results",render:e=>(0,u.jsx)(Jd,{...e,errors:i.errors,createdSubscribers:i.created,updatedSubscribers:i.updated,segments:i.segments,addedToSegmentWithWelcomeNotification:i.added_to_segment_with_welcome_notification})}),(0,u.jsx)(Ne.AW,{path:"*",render:()=>(0,u.jsx)(Ne.l_,{to:"/step_clean_list"})})]})})]})})}tc&&((0,r.registerTranslations)(),(0,n.s)(tc).render((0,u.jsx)(ic,{})));var ac=i(76721),sc=i.n(ac);Ce()(document).ready((()=>{let e;if(!Ce()("#mailpoet_subscribers_export").length)return;if(!window.exportData.segments)return;const t=sc().compile(Ce()("#mailpoet_subscribers_export_template").html());function i(t){const i="mailpoet-disabled";"on"===t?e.removeClass(i):e.addClass(i)}Ce()("#mailpoet-export").html(t(window.exportData));const a=Ce()("#export_lists"),s=Ce()("#export_columns");function n(e){let t=`${e.name}`;return void 0!==e.count&&(t+=`${e.count}`),t}function o(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 i=t.params.args.data.id,a=["select","deselect"];let s;rt.default.contains(a,i)&&(t.preventDefault(),"deselect"===i?Ce()(t.target).val("").trigger("change"):(s=[],rt.default.each(e.find("option"),(e=>{const t=e.value;rt.default.contains(a,t)||s.push(t)})),Ce()(t.target).val(s).trigger("change")),Ce()(t.target).select2("close"))})).on("change",(()=>{window.exportData.segments&&a.select2("data").length&&s.select2("data").length||!window.exportData.segments&&s.select2("data").length?i("on"):i("off")}))}e=Ce()("#mailpoet-export-button"),window.segments.forEach((e=>{a.append(Ce()("").attr("value",e.id).text(e.name))})),window.subscriberFieldsSelect2.forEach((e=>{e.text=e.name,e.children.forEach((e=>{e.name=(0,Oo.r)(e.name),e.text=(0,Oo.r)(e.name)}))})),o(a,window.segments),o(s,window.subscriberFieldsSelect2),s.val(["email","first_name","last_name","list_status","global_status","subscribed_ip","created_at","confirmed_at","confirmed_ip"]).trigger("change"),e.on("click",(e=>{if(Ce()(e.target).hasClass("mailpoet-disabled"))return;c.MailPoet.Modal.loading(!0);const t=Ce()(':radio[name="option_format"]:checked').val();c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"ImportExport",action:"processExport",data:JSON.stringify({export_format_option:t,segments:!!window.exportData.segments&&a.val(),subscriber_fields:s.val()})}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>{const i=c.MailPoet.I18n.t("exportMessage").replace("%1$s",`${parseInt(e.data.totalExported,10).toLocaleString()}`).replace("[link]",``).replace("[/link]","");Ce()("#export_result_notice").html(`

${i}

`).show(),window.location.href=e.data.exportFileURL,c.MailPoet.trackEvent("Subscribers export completed",{"Total exported":e.data.totalExported,"File Format":t})})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}))}));var nc=i(37441),oc=i(19613);function rc(e){let{children:t}=e;return(0,u.jsx)("div",{className:"mailpoet-steps-content",children:t})}const lc=(0,u.jsx)("svg",{width:"13",height:"11",viewBox:"0 0 13 11",children:(0,u.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"})}),dc=(0,u.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",children:(0,u.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 cc(e){let{onCheck:t,showError:i,checked:a,automationId:s,...n}=e;return(0,u.jsxs)("div",{className:ee()({"mailpoet-form-yesno":!0,"mailpoet-form-yesno-error":i,"mailpoet-disabled":n.disabled}),"data-automation-id":s,children:[(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"radio",checked:!0===a,onChange:()=>t(!0),...n}),(0,u.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-yes",children:lc})]}),(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"radio",checked:!1===a,onChange:()=>t(!1),...n}),(0,u.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-no",children:dc})]})]})}function mc(e){let{submitForm:t,loading:i,showCustomersImportSetting:a,isWizardStep:s=!1}=e;const[n,l]=(0,o.useState)(null),[d,c]=(0,o.useState)(!1===a?"unsubscribed":null),[m,p]=(0,o.useState)(!1),h=s?(0,Fe._x)("Continue","A label on a button","mailpoet"):(0,Fe._x)("Start using WooCommerce features","Submit button caption on the standalone WooCommerce setup page","mailpoet");let g;return"subscribed"===d&&(g=!0),"unsubscribed"===d&&(g=!1),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.TypographyHeading,{level:1,children:(0,Fe._x)("Power up your WooCommerce store","Title on the WooCommerce setup page","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("p",{children:(0,Fe.__)("MailPoet comes with powerful features for WooCommerce. Select features that you would like to use with your store.","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("form",{onSubmit:e=>(e.preventDefault(),p(!0),null===d||null===n||t(d,n),!1),children:[(0,u.jsxs)("div",{children:[a?(0,u.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,u.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,u.jsx)(cc,{showError:m&&null===d,checked:g,onCheck:e=>c(e?"subscribed":"unsubscribed"),name:"mailpoet_woocommerce_import_type",automationId:"woocommerce_import_type"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{children:f()((0,Fe.__)("Do you want to import your WooCommerce customers as subscribed? [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,u.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,u.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,u.jsx)("span",{children:"GDPR"}),(0,Fe._x)("To be compliant with privacy regulations, your customers must have explicitly accepted to receive your marketing emails.","GDPR compliance information","mailpoet")]})]})]}):null,(0,u.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,u.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,u.jsx)(cc,{showError:m&&null===n,checked:n,onCheck:e=>l(e),name:"mailpoet_woocommerce_tracking",automationId:"woocommerce_tracking"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{children:f()((0,Fe.__)("Collect more precise email and site engagement, and e-commerce metrics by enabling cookie tracking. [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/280-woocommerce-cookie-tracking",rel:"noopener noreferrer",target:"_blank",children:e},e)))}),(0,u.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,u.jsx)("span",{children:"GDPR"}),(0,Fe._x)("To be compliant, you should display a cookie tracking banner on your website.","GDPR compliance information","mailpoet")]})]})]})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:i,disabled:i,automationId:"submit_woocommerce_setup",children:h})]})]})}function pc(e){return(0,u.jsx)(_s,{illustrationUrl:e.illustrationUrl,children:e.children})}function uc(e){let{isWizardStep:t=!1,redirectToNextStep:i=null}=e;const[a,s]=(0,o.useState)(!1),[n,l]=(0,oc.yu)("woocommerce"),d=(0,oc.yu)("tracking")[1],m=(0,oc.yu)("woocommerce_import_screen_displayed")[1],p=(0,oc.yu)("mailpoet_subscribe_old_woocommerce_customers")[1],h=e=>{s(!1),c.MailPoet.Notice.showApiErrorNotice(e,{scroll:!0})},g=e=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(h),_=(0,u.jsx)(pc,{illustrationUrl:window.wizard_woocommerce_illustration_url,children:(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(mc,{loading:a,submitForm:async(e,a)=>{s(!0);const o="basic"===c.MailPoet.trackingConfig.level?"basic":"partial",r={level:a?"full":o},u={enabled:"subscribed"===e?"1":""},_={woocommerce_import_screen_displayed:1,"mailpoet_subscribe_old_woocommerce_customers.enabled":u.enabled,"tracking.level":r.level,"woocommerce.accept_cookie_revenue_tracking.set":"1"};await g(_),d(r),p(u),l({...n,accept_cookie_revenue_tracking:{...n.accept_cookie_revenue_tracking||{},set:"1"}}),m("1"),await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"setupWooCommerceInitialImport"}).fail(h),t?i():await(async()=>{t?await g({version:window.mailpoet_version}).then((()=>{window.location.href=window.finish_wizard_url})):window.location.href=window.finish_wizard_url})()},isWizardStep:t,showCustomersImportSetting:window.mailpoet_show_customers_import})})});return t?_:(0,u.jsx)(rc,{children:_})}function hc(e){let{skipStep:t,loading:i,update_sender:a,submit_sender:s,sender:n=null}=e;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:1,children:(0,Fe.__)("Start by configuring your sender information","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("p",{children:[(0,u.jsx)("b",{children:(0,Fe.__)("Default sender","mailpoet")}),(0,u.jsx)("br",{}),(0,Fe.__)("Enter details of the person or brand your subscribers expect to receive emails from","mailpoet")]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("form",{id:"mailpoet_sender_form",onSubmit:e=>{e.preventDefault(),Ce()("#mailpoet_sender_form").parsley().validate()&&s()},children:[(0,u.jsxs)(Fi.Grid.TwoColumns,{children:[(0,u.jsxs)("label",{htmlFor:"senderName",children:[(0,u.jsx)("span",{className:"mailpoet-wizard-label",children:(0,Fe._x)("From Name","A form field label","mailpoet")}),(0,u.jsx)(r.Input,{isFullWidth:!0,name:"senderName",type:"text",placeholder:"John Doe",value:n?n.name:"","data-parsley-required":!0,onChange:e=>a({name:e.target.value})})]}),(0,u.jsxs)("label",{htmlFor:"senderAddress",children:[(0,u.jsx)("span",{className:"mailpoet-wizard-label",children:(0,Fe._x)("From Address","A form field label","mailpoet")}),(0,u.jsx)(r.Input,{isFullWidth:!0,name:"senderAddress",type:"text",placeholder:"john@doe.com",value:n?n.address:"","data-parsley-required":!0,"data-parsley-type":"email",onChange:e=>a({address:e.target.value})})]})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:i,children:(0,Fe._x)("Continue","A label on a button","mailpoet")}),(0,u.jsx)(r.Button,{href:"#skipStep",isDisabled:i,isFullWidth:!0,onClick:t,variant:"tertiary",children:(0,Fe._x)("Skip this step","A label on a skip button","mailpoet")})]})]})}pc.propTypes={illustrationUrl:Te().string.isRequired,children:Te().oneOfType([Te().arrayOf(Te().node),Te().node]).isRequired},uc.displayName="WooCommerceController",hc.displayName="WelcomeWizardSenderStep";const gc=e=>null==e;function _c(e){let{loading:t,submitForm:i}=e;const[a,s]=(0,o.useState)({tracking:void 0,libs3rdParty:void 0}),[n,r]=(0,o.useState)(!1);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:1,children:(0,Fe.__)("Confirm privacy and data settings","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("form",{onSubmit:function(e){return e.preventDefault(),r(!0),gc(a.libs3rdParty)||gc(a.tracking)||i(a.tracking,a.libs3rdParty),!1},children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{id:"mailpoet-wizard-3rd-party-libs",className:"mailpoet-wizard-woocommerce-option",children:[(0,u.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,u.jsx)(cc,{showError:n&&gc(a.libs3rdParty),onCheck:e=>{const t={libs3rdParty:e};s((e=>({...e,...t})))},checked:a.libs3rdParty,name:"mailpoet_libs_3rdParty"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{children:(0,Fe.__)("Enable modern text fonts in emails and show contextual help articles in MailPoet","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-wizard-note",children:f()((0,Fe.__)("MailPoet may load Google Fonts, DocsBot and other [link]3rd party libraries[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,u.jsx)("a",{href:"https://kb.mailpoet.com/article/338-what-3rd-party-libraries-we-use",target:"_blank",rel:"noopener noreferrer",children:e},t)))})]})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("div",{id:"mailpoet-wizard-tracking",className:"mailpoet-wizard-woocommerce-option",children:[(0,u.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,u.jsx)(cc,{showError:n&&gc(a.tracking),onCheck:e=>{const t={tracking:e};s((e=>({...e,...t})))},checked:a.tracking,name:"mailpoet_tracking"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{children:(0,Fe.__)("Help improve MailPoet","mailpoet")}),(0,u.jsx)("div",{className:"mailpoet-wizard-note",children:f()((0,Fe.__)("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,u.jsx)("a",{href:"https://kb.mailpoet.com/article/130-sharing-your-data-with-us",target:"_blank",rel:"noopener noreferrer",children:e},t)))})]})]})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(Oe.z,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,disabled:t,children:(0,Fe._x)("Continue","A label on a button","mailpoet")})]})]})}_c.propTypes={loading:Te().bool.isRequired,submitForm:Te().func.isRequired},_c.displayName="WelcomeWizardUsageTrackingStep";var fc=i(6198);async function bc(e){await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}async function xc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;await bc({version:window.mailpoet_version}),window.location.href=e||window.finish_wizard_url}function vc(){const[e,t]=(0,o.useState)(!1),i=e=>{e.preventDefault(),t(!0)},a=()=>t(!1);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{children:f()(c.MailPoet.I18n.t("welcomeWizardMSSAdvancedUsers"),/\[link](.*?)\[\/link]/g,((e,t)=>(0,u.jsx)("a",{onClick:i,href:"#",children:e},t)))}),e&&(0,u.jsxs)(ai.Z,{className:"mailpoet-welcome-wizard-confirmation-modal",title:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalTitle"),onRequestClose:a,children:[(0,u.jsx)("p",{children:c.MailPoet.mailFunctionEnabled?c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraph"):c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraphWithoutMailFunction")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalSecondParagraph")}),(0,u.jsxs)("div",{className:"mailpoet-welcome-wizard-confirmation-modal-buttons",children:[(0,u.jsx)(r.Button,{variant:"secondary",onClick:a,children:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalGoBackButton")}),(0,u.jsx)(r.Button,{onClick:async e=>{e.preventDefault(),await xc("admin.php?page=mailpoet-settings#/mta/other")},children:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalOkButton")})]})]})]})}const jc="https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase";function yc(){const e=(0,Ne.k6)(),{step:t}=(0,Ne.UO)(),i=(0,oc.v9)("getKeyActivationState")();return(0,o.useEffect)((()=>{!0===i.isKeyValid&&e.replace(`/steps/${t}/part/3`)}),[i.isKeyValid,e,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:1,children:c.MailPoet.I18n.t("welcomeWizardMSSFirstPartTitle")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSFirstPartSubtitle")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-welcome-wizard-mss-list",children:(0,u.jsxs)(r.List,{children:[(0,u.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList1")}),(0,u.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList2")}),c.MailPoet.subscribersCount<1e3?(0,u.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList3Free")}):(0,u.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList3Paid")})]})}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,href:jc,target:"_blank",rel:"noopener noreferrer",onClick:i=>function(e,t,i){e.preventDefault(),window.open(jc),t.push(`/steps/${i}/part/2`)}(i,e,t),iconEnd:(0,u.jsx)(Gt.Z,{icon:fc.Z}),children:c.MailPoet.I18n.t("welcomeWizardMSSFirstPartButton")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(vc,{})]})}var wc=i(86873),Sc=i(77135);function Pc(){const e=(0,Ne.k6)(),{step:t}=(0,Ne.UO)(),i=(0,oc.v9)("getKeyActivationState")();return(0,o.useEffect)((()=>{!0===i.isKeyValid&&e.push(`/steps/${t}/part/3`)}),[i.isKeyValid,e,t]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.Heading,{level:1,children:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartTitle")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartEnterKey")}),(0,u.jsx)("p",{children:f()(c.MailPoet.I18n.t("welcomeWizardMSSSecondPartNoAccount"),/\[link](.*?)\[\/link]/g,((e,t)=>(0,u.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,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("label",{htmlFor:"mailpoet_premium_key",children:[(0,u.jsx)("span",{className:"mailpoet-wizard-label",children:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartInputLabel")}),(0,u.jsx)(Sc.c,{placeholder:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartInputPlaceholder"),isFullWidth:!0})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(wc.X,{label:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartButton"),isFullWidth:!0}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(vc,{})]})}function Mc(){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt.X,{level:1,children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartTitle")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartFirstParagraph")}),(0,u.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartSecondParagraph")}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",type:"button",onClick:()=>xc(),isFullWidth:!0,children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartButton")})]})}function Nc(){const{path:e}=(0,Ne.$B)(),{step:t}=(0,Ne.UO)();return(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{exact:!0,path:`${e}`,children:(0,u.jsx)(Ne.l_,{to:`/steps/${t}/part/1`})}),(0,u.jsx)(Ne.AW,{path:`${e}/part/1`,children:(0,u.jsx)(yc,{})}),(0,u.jsx)(Ne.AW,{path:`${e}/part/2`,children:(0,u.jsx)(Pc,{})}),(0,u.jsx)(Ne.AW,{path:`${e}/part/3`,children:(0,u.jsx)(Mc,{})})]})}const Ic=e=>{let{name:t,address:i}=e;const a=i.split("@").pop().toLowerCase();return window.mailpoet_free_domains.indexOf(a)>-1?(e=>{let{name:t,address:i}=e;const a=`wordpress@${window.location.hostname.replace("www.","")}`;return{sender:{name:t,address:a},reply_to:{name:t,address:i},"signup_confirmation.from.address":a,"signup_confirmation.from.name":t,"signup_confirmation.reply_to.address":i,"signup_confirmation.reply_to.name":t}})({name:t,address:i}):(e=>{let{name:t,address:i}=e;return{sender:{name:t,address:i},reply_to:{name:t,address:i},"signup_confirmation.from.address":i,"signup_confirmation.from.name":t,"signup_confirmation.reply_to.address":i,"signup_confirmation.reply_to.name":t}})({name:t,address:i})},Cc=()=>{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},kc=()=>Cc().length,Tc=e=>Cc()[e-1]||null,Ec=(e,t,i)=>{i{(s>a||s<1)&&i.push("/steps/1")}),[s,a,i]);const g=(0,rt.partial)(Ec,i,xc),_=(0,o.useCallback)((async(e,t)=>{const i={enabled:e?"1":""},a={enabled:t?"1":""},s={analytics:i,"3rd_party_libs":a};await bc(s),p(i),h(a)}),[p,h]),f=(0,o.useCallback)((async(e,t)=>{l(!0),await _(e,t),g(s),l(!1)}),[g,s,_]),b=(0,o.useCallback)((e=>{m({...c,...e})}),[c,m]),x=(0,o.useCallback)((async()=>{l(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await _(!0,!0),await bc(Ic(c)).then((()=>g(s))),l(!1)}),[g,c,s,_]),v=(0,o.useCallback)((async e=>{e.preventDefault(),l(!0);const t={address:window.admin_email,name:""};window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await _(!0,!0),await bc(Ic(t)).then((()=>{m(t),g(s)})),l(!1)}),[g,s,m,_]),j=Tc(s);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(St.B,{}),(0,u.jsx)(d.D,{logoWithLink:!1,children:(0,u.jsx)(Ac.R,{count:a,current:s})}),(0,u.jsxs)(rc,{children:["WelcomeWizardSenderStep"===j?(0,u.jsx)(pc,{illustrationUrl:window.wizard_sender_illustration_url,children:(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(hc,{update_sender:b,submit_sender:x,skipStep:v,loading:n,sender:c})})}):null,"WelcomeWizardUsageTrackingStep"===j?(0,u.jsx)(pc,{illustrationUrl:window.wizard_tracking_illustration_url,children:(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(_c,{loading:n,submitForm:f})})}):null,"WelcomeWizardPitchMSSStep"===j?(0,u.jsx)(pc,{illustrationUrl:window.wizard_MSS_pitch_illustration_url,children:(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Nc,{})})}):null,"WizardWooCommerceStep"===j?(0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(uc,{isWizardStep:!0,redirectToNextStep:()=>g(s)})}):null]})]})}function Fc(){let e="/steps/1";window.location.search.includes("woocommerce-setup")&&(e="/woocommerce");const t=(0,l.S)(window);return(0,u.jsx)(l.k.Provider,{value:t,children:(0,u.jsxs)(Me.HashRouter,{children:[(0,u.jsx)(m.w,{}),(0,u.jsxs)(Ne.rs,{children:[(0,u.jsx)(Ne.AW,{path:"/steps/:step",component:(0,r.withBoundary)(Rc)}),(0,u.jsx)(Ne.AW,{path:"/woocommerce",component:(0,r.withBoundary)(uc)}),(0,u.jsx)(Ne.AW,{render:()=>(0,u.jsx)(Ne.l_,{to:e})})]})]})})}Rc.displayName="WelcomeWizardStepsController";const Oc=document.getElementById("mailpoet-wizard-container");function Lc(){const[e,t]=(0,o.useState)(null),i=(0,l.S)(window),a=i.notices.error;function s(s){const n=s.target.name,o=s.target.checked;c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"set",data:{[n]:o?1:0}}).done((()=>{const a=e[n];a.value=o,t({...e,[n]:a});const s=`Feature '${n}' was ${o?"enabled":"disabled"}.`;i.notices.success((0,u.jsx)("p",{children:s}))})).fail((e=>{e.errors.length>0&&a(e.errors.map((e=>(0,u.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))}return(0,o.useEffect)((()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"getAll"}).done((e=>{const i=e.data.reduce(((e,t)=>({...e,[t.name]:t})),{});t(i)})).fail((e=>{e.errors.length>0&&a((0,u.jsx)(u.Fragment,{children:e.errors.map((e=>(0,u.jsx)("p",{children:e.message})))}),{scroll:!0})}))}),[a]),null===e?(0,u.jsx)("p",{children:"Loading experimental features..."}):0===Object.values(e).length?(0,u.jsx)("p",{children:"There are no experimental features at the moment."}):(0,u.jsx)(l.k.Provider,{value:i,children:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(m.w,{}),Object.values(e).map((e=>{const t=`experimental-feature-${e.name}`;return(0,u.jsx)("div",{children:(0,u.jsxs)("label",{htmlFor:t,children:[(0,u.jsx)("input",{id:t,type:"checkbox",name:e.name,defaultChecked:e.value,onChange:s})," ",e.name]})},e.name)}))]})})}Oc&&((0,r.registerTranslations)(),(0,nc.N)(),(0,n.s)(Oc).render((0,u.jsx)(Fc,{})));const Dc=document.getElementById("experimental_features_container");Lc.displayName="ExperimentalFeatures",Dc&&((0,r.registerTranslations)(),(0,n.s)(Dc).render((0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Lc,{})})));var qc=i(26227);function $c(e){let{message:t,editing:i}=e;return i?(0,u.jsx)("textarea",{value:t,className:"mailpoet-logs-full-message",readOnly:!0}):(0,u.jsx)(u.Fragment,{children:`${t.substr(0,150)}…`})}function Bc(e){let{log:t}=e;const[i,a]=(0,o.useState)(!1);return(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{role:"gridcell",children:t.name}),(0,u.jsx)("td",{onClick:function(e){(function(e){return(e.ctrlKey||e.metaKey)&&!e.altKey})(e)&&(i||a(!0))},role:"gridcell",children:(0,u.jsx)($c,{message:t.message,editing:i})}),(0,u.jsx)("td",{role:"gridcell",children:c.MailPoet.Date.full(t.created_at)})]},`log-row-${t.id}`)}function Wc(e){let{logs:t,onFilter:i,originalFrom:a,originalTo:s,originalSearch:n,originalOffset:l,originalLimit:d}=e;const[m,p]=(0,o.useState)(a??void 0),[h,g]=(0,o.useState)(s??void 0),[_,f]=(0,o.useState)(l??""),[b,x]=(0,o.useState)(d??""),[v,j]=(0,o.useState)(n||""),y=(0,Ti.curry)(((e,t)=>{e(null!==t?c.MailPoet.Date.format(t,{format:"Y-m-d"}):void 0)})),w=(0,o.useCallback)((()=>{const e={};m&&(e.from=m),h&&(e.to=h),_&&""!==_.trim()&&(e.offset=_),b&&""!==b.trim()&&(e.limit=b),v&&""!==v.trim()&&(e.search=v.trim()),i(e)}),[m,b,_,v,h,i]);return(0,u.jsxs)("div",{className:"mailpoet-listing mailpoet-logs",children:[(0,u.jsxs)("div",{className:"mailpoet-listing-header",children:[(0,u.jsxs)("div",{className:"mailpoet-listing-search",children:[(0,u.jsx)("label",{htmlFor:"search_input",className:"screen-reader-text",children:c.MailPoet.I18n.t("searchLabel")}),(0,u.jsx)(r.Input,{dimension:"small",iconStart:qc.J,type:"search",id:"search_input",name:"s",onChange:e=>j(e.target.value),value:v,placeholder:c.MailPoet.I18n.t("searchLabel")})]}),(0,u.jsxs)("div",{className:"mailpoet-listing-filters",children:[`${c.MailPoet.I18n.t("from")}:`,(0,u.jsxs)(r.ErrorBoundary,{children:[(0,u.jsx)($i.a,{dateFormat:"MMMM d, yyyy",onChange:y(p),maxDate:new Date,selected:m?(0,vr.default)(m):void 0,dimension:"small"}),`${c.MailPoet.I18n.t("to")}:`,(0,u.jsx)($i.a,{dateFormat:"MMMM d, yyyy",onChange:y(g),maxDate:new Date,selected:h?(0,vr.default)(h):void 0,dimension:"small"})]})]}),(0,u.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,u.jsx)("label",{htmlFor:"offset_input",className:"screen-reader-text",children:c.MailPoet.I18n.t("offsetLabel")}),(0,u.jsx)(r.Input,{dimension:"small",id:"offset_input",name:"o",type:"number",onChange:e=>f(e.target.value),value:_,placeholder:c.MailPoet.I18n.t("offsetLabel")})]}),(0,u.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,u.jsx)("label",{htmlFor:"limit_input",className:"screen-reader-text",children:c.MailPoet.I18n.t("limitLabel")}),(0,u.jsx)(r.Input,{dimension:"small",id:"limit_input",name:"l",type:"number",onChange:e=>x(e.target.value),value:b,placeholder:c.MailPoet.I18n.t("limitLabel")})]}),(0,u.jsx)(r.Button,{dimension:"small",onClick:w,children:c.MailPoet.I18n.t("filter")})]}),(0,u.jsxs)("table",{className:"mailpoet-listing-table widefat striped",role:"grid",children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:c.MailPoet.I18n.t("tableHeaderName")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("tableHeaderMessage")}),(0,u.jsx)("th",{children:c.MailPoet.I18n.t("tableHeaderCreatedOn")})]})}),(0,u.jsx)("tbody",{children:(0,u.jsx)(r.ErrorBoundary,{children:t.map((e=>(0,u.jsx)(Bc,{log:e},`log-${e.id}`)))})})]})]})}Bc.displayName="Log",Wc.displayName="LogsList";const Vc=document.getElementById("mailpoet_logs_container");if(Vc){const e=new URL(window.location.href);(0,n.s)(Vc).render((0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(Wc,{logs:window.mailpoet_logs,originalFrom:e.searchParams.get("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=>{let[i,a]=t;e.searchParams.append(i,a)})),window.location.href=e.href}})}))}var Uc=i(634);function zc(e){let{onRequestClose:t}=e;const[i,a]=(0,o.useState)(!1);return Ce()((e=>{e(document).on("click",".notice .mailpoet-js-button-fix-this",(()=>{a(!0)}))})),(0,u.jsxs)(l.k.Provider,{value:(0,l.S)(window),children:[(0,u.jsx)(m.w,{}),i&&(0,u.jsx)(Uc.d,{onRequestClose:()=>{a(!1),t()}})]})}zc.defaultProps={onRequestClose:Ti.noop};const Hc=document.getElementById("mailpoet_set_from_address_modal");Hc&&(0,n.s)(Hc).render((0,u.jsx)(zc,{onRequestClose:()=>{window.location.href.includes("?page=mailpoet-settings")&&window.location.reload()}}));const Zc=e=>(async e=>{if("MailPoet"!==c.MailPoet.mtaMethod)return!0;const t=await(async()=>"MailPoet"!==c.MailPoet.mtaMethod?[]:(await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[])(),i=(0,Yi.DA)(e);return-1!==t.indexOf(i)||-1!==(await(async()=>"MailPoet"!==c.MailPoet.mtaMethod?[]:(await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"mailer",action:"getAuthorizedEmailAddresses"})).data||[])()).indexOf(e)})(e).then((e=>{if(!e)return c.MailPoet.Notice.error(c.MailPoet.I18n.t("mailerSendingNotResumedUnauthorized"),{scroll:!0}),c.MailPoet.trackEvent("Unauthorized email used",{"Unauthorized email source":"send"}),!1;c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"mailer",action:"resumeSending"}).done((()=>{c.MailPoet.Notice.success(c.MailPoet.I18n.t("mailerSendingResumedNotice"))})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}));Ce()((e=>{e(document).on("click",".notice .mailpoet-js-button-resume-sending",(e=>{Zc(e.target.value)}))}));var Yc=i(79142);const Gc=e=>{const t=window.location.href.includes("?page=mailpoet-settings"),i=window.location.href.includes("?page=mailpoet-newsletters#/send");(e=>{const t=`${(0,Yi.HD)()||"some other"} page`;e&&e.type&&"email"===e.type?c.MailPoet.trackEvent("MSS in plugin authorize email",{"authorized email source":"modal","original page":t,wasSuccessful:"yes"}):e&&e.type&&"domain"===e.type&&c.MailPoet.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"modal","original page":t,wasSuccessful:"yes"})})(e),(t||i)&&window.location.reload()};function Kc(){const[e,t]=(0,o.useState)(""),[i,a]=(0,o.useState)("email");return(0,o.useEffect)((()=>{const e=e=>{e.preventDefault();const i=String(e?.target?.dataset?.email||""),s=String(e?.target?.dataset?.type||"");a(s||"email"),t(i)};Ce()((t=>{t(document).on("click",".mailpoet-js-button-authorize-email-and-sender-domain",e)}))}),[]),(0,u.jsx)(u.Fragment,{children:e&&(0,u.jsx)(Yc.h,{senderEmail:e,onRequestClose:()=>{t("")},onSuccessAction:Gc,showSenderEmailTab:"email"===i,showSenderDomainTab:"domain"===i,initialTab:"domain"===i?"sender_domain":"sender_email"})})}const Qc=document.getElementById("mailpoet_authorize_sender_email_modal");Qc&&(0,n.s)(Qc).render((0,u.jsx)(Kc,{}));const Xc=()=>{window.location.href=window.mailpoet_welcome_wizard_url};function Jc(){return(0,u.jsx)("section",{className:"landing-header",children:(0,u.jsxs)("div",{className:"mailpoet-content-center",children:[(0,u.jsx)(bt.X,{level:0,children:(0,Fe.__)("Better email — without leaving WordPress","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("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,u.jsx)(r.Button,{onClick:Xc,dimension:"hero",children:(0,Fe.__)("Begin setup","mailpoet")})]})})}function em(){return(0,u.jsx)("section",{className:"landing-footer",children:(0,u.jsxs)("div",{className:"landing-footer-content mailpoet-content-center",children:[(0,u.jsxs)(bt.X,{level:4,children:[" ",(0,Fe.__)("Ready to start using MailPoet?","mailpoet")," "]}),(0,u.jsx)(r.Button,{onClick:Xc,dimension:"hero",children:(0,Fe.__)("Begin setup","mailpoet")})]})})}function tm(){const e=[{slug:"item-1",title:(0,Fe.__)("What types of campaigns can I create with MailPoet?","mailpoet"),text:(0,Fe.__)("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,Fe.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns"},{slug:"item-2",title:(0,Fe.__)("How do I send a newsletter?","mailpoet"),text:(0,Fe.__)("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,Fe.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/344-create-a-standard-newsletter"},{slug:"item-3",title:(0,Fe.__)("Do I need a paid plan?","mailpoet"),text:(0,Fe.__)("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,Fe.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/349-choosing-your-mailpoet-plan"},{slug:"item-4",title:(0,Fe.__)("How do I import my customers from WooCommerce?","mailpoet"),text:(0,Fe.__)('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,Fe.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list"},{slug:"item-5",title:(0,Fe.__)("How do I customize emails for my store?","mailpoet"),text:(0,Fe.__)("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,Fe.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/277-woocommerce-automatic-emails"}];return(0,u.jsxs)("section",{className:"landing-faq",children:[(0,u.jsxs)("div",{className:"mailpoet-content-center landing-faq-header",children:[(0,u.jsxs)(bt.X,{level:2,children:[" ",(0,Fe.__)("Frequently asked questions","mailpoet")," "]}),(0,u.jsx)("p",{children:f()((0,Fe.__)("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,u.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e)))})]}),(0,u.jsx)("div",{className:"mailpoet-content-center landing-faq-mobile",children:(0,u.jsx)(bt.X,{level:2,children:(0,Fe.__)("FAQ","mailpoet")})}),(0,u.jsx)("div",{className:"mailpoet-faq-accordion",children:e.map((e=>(0,u.jsxs)("details",{children:[(0,u.jsxs)("summary",{children:[" ",(0,u.jsxs)("strong",{children:[" ",e.title," "]})," "]}),(0,u.jsxs)("div",{className:"content",children:[(0,u.jsx)("p",{children:e.text}),(0,u.jsx)("p",{children:(0,u.jsx)("a",{href:e.readMoreLink,rel:"noopener noreferrer",target:"_blank",children:e.readMoreText})})]})]},e.slug)))}),(0,u.jsxs)("div",{className:"mailpoet-content-center landing-faq-mobile",children:[(0,u.jsx)("p",{children:(0,Fe.__)("Can’t find what you’re looking for?","mailpoet")}),(0,u.jsx)("p",{children:f()((0,Fe.__)("[link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,u.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e)))})]})]})}Jc.displayName="Landingpage Header",em.displayName="Landingpage Footer",tm.displayName="Landingpage FAQ";const im={heroImage:`${c.MailPoet.cdnUrl}landingpage/landingpage-hero-image.png`,featureImages:{icon_1:`${c.MailPoet.cdnUrl}landingpage/feature_icon_1.png`,icon_2:`${c.MailPoet.cdnUrl}landingpage/feature_icon_2.png`,icon_3:`${c.MailPoet.cdnUrl}landingpage/feature_icon_3.png`,icon_4:`${c.MailPoet.cdnUrl}landingpage/feature_icon_4.png`},wooCommerceFeatureImages:{feature_1:`${c.MailPoet.cdnUrl}landingpage/woo_feature_automate_your_marketing.png`,feature_2:`${c.MailPoet.cdnUrl}landingpage/woo_feature_measure_revenue_per_email.png`,feature_3:`${c.MailPoet.cdnUrl}landingpage/woo_feature_let_your_brand_shine.png`,feature_4:`${c.MailPoet.cdnUrl}landingpage/woo_feature_rescue_abandoned_carts.png`}};function am(){return(0,u.jsxs)("section",{className:"landing-content",children:[(0,u.jsxs)("div",{className:"hero-section mailpoet-content-center",children:[(0,u.jsx)("img",{src:im.heroImage,alt:"",className:"hero-image landingpage-images"}),(0,u.jsx)("br",{}),(0,u.jsx)("br",{}),(0,u.jsx)(bt.X,{level:4,children:(0,Fe.sprintf)((0,Fe.__)("Powerful email marketing, trusted by %s websites","mailpoet"),"700,000+")}),(0,u.jsx)("br",{}),(0,u.jsxs)(Fi.Grid.FourColumns,{className:"landingpage-general-features",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("img",{src:im.featureImages.icon_1,alt:"",className:"landingpage-feature-icon"}),(0,u.jsx)("strong",{children:(0,Fe.__)("Deliver beautiful emails","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Choose from our pre-built templates or create your own with our drag-and-drop email builder.","mailpoet")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("img",{src:im.featureImages.icon_2,alt:"",className:"landingpage-feature-icon"}),(0,u.jsx)("strong",{children:(0,Fe.__)("Grow your mailing list","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Use our custom sign-up forms to reach more subscribers while you deliver engaging content.","mailpoet")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("img",{src:im.featureImages.icon_3,alt:"",className:"landingpage-feature-icon"}),(0,u.jsx)("strong",{children:(0,Fe.__)("Reach the right people","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("From the first hello to repeated purchases, send emails to the right people at the right time.","mailpoet")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("img",{src:im.featureImages.icon_4,alt:"",className:"landingpage-feature-icon"}),(0,u.jsx)("strong",{children:(0,Fe.__)("Save time with automations","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Set up smart triggers based on user behavior to automate list management, email sending, and more.","mailpoet")})]})]})]}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsxs)("div",{className:"landingpage-wooCommerce-features",children:[(0,u.jsxs)("div",{className:"mailpoet-content-center",children:[(0,u.jsx)(bt.X,{level:2,children:(0,Fe.__)("MailPoet + WooCommerce","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Deliver hyper-relevant content at every stage of your customer’s journey","mailpoet")})]}),(0,u.jsx)("br",{}),(0,u.jsxs)(Fi.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,u.jsx)("div",{children:(0,u.jsx)("img",{src:im.wooCommerceFeatureImages.feature_1,alt:(0,Fe.__)("Automate customer communication feature Image","mailpoet"),className:"landingpage-images"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{children:(0,Fe.__)("Automate customer communication","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Drive sales and build loyalty through automated marketing messages that respond to your customer’s purchase data.","mailpoet")})]})]}),(0,u.jsxs)(Fi.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,u.jsx)("div",{children:(0,u.jsx)("img",{src:im.wooCommerceFeatureImages.feature_2,alt:(0,Fe.__)("Measure revenue per email feature Image","mailpoet"),className:"landingpage-images"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{children:(0,Fe.__)("Measure revenue per email","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("See how much revenue your campaign is bringing and make improvements based on auto-generated email statistics.","mailpoet")})]})]}),(0,u.jsxs)(Fi.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,u.jsx)("div",{children:(0,u.jsx)("img",{src:im.wooCommerceFeatureImages.feature_3,alt:(0,Fe.__)("Let your brand shine feature Image","mailpoet"),className:"landingpage-images"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{children:(0,Fe.__)("Let your brand shine","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Use our inbuilt WooCommerce email customizer to design your store's transactional emails and build customer confidence.","mailpoet")})]})]}),(0,u.jsxs)(Fi.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,u.jsx)("div",{children:(0,u.jsx)("img",{src:im.wooCommerceFeatureImages.feature_4,alt:(0,Fe.__)("Rescue abandoned carts feature Image","mailpoet"),className:"landingpage-images"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{children:(0,Fe.__)("Rescue abandoned carts","mailpoet")}),(0,u.jsx)("p",{children:(0,Fe.__)("Set up automated abandoned cart emails to win customers back and recover lost revenue.","mailpoet")})]})]})]})]})}function sm(){return(0,u.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,u.jsxs)("main",{children:[(0,u.jsx)(St.B,{}),(0,u.jsx)(d.Q,{}),(0,u.jsx)(et.A,{color:"#fff"}),(0,u.jsx)(Jc,{}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(am,{}),(0,u.jsx)("div",{className:"mailpoet-gap"}),(0,u.jsx)(tm,{}),(0,u.jsx)(em,{})]})})}am.displayName="Landingpage Content",sm.displayName="Landingpage";const nm=document.getElementById("mailpoet_landingpage_container");nm&&((0,r.registerTranslations)(),(0,n.s)(nm).render((0,u.jsx)(r.ErrorBoundary,{children:(0,u.jsx)(sm,{})}))),i(86555)},86555:function(){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"}))}))},28270:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,i){var a;if("formatting"===(null!=i&&i.context?String(i.context):"standalone")&&e.formattingValues){var s=e.defaultFormattingWidth||e.defaultWidth,n=null!=i&&i.width?String(i.width):s;a=e.formattingValues[n]||e.formattingValues[s]}else{var o=e.defaultWidth,r=null!=i&&i.width?String(i.width):e.defaultWidth;a=e.values[r]||e.values[o]}return a[e.argumentCallback?e.argumentCallback(t):t]}},e.exports=t.default},80824:function(e,t){var i,a;i=function e(){"use strict";var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},i=!t.document&&!!t.postMessage,a=t.IS_PAPA_WORKER||!1,s={},n=0,o={parse:function(i,a){var r=(a=a||{}).dynamicTyping||!1;if(j(r)&&(a.dynamicTypingFunction=r,r={}),a.dynamicTyping=r,a.transform=!!j(a.transform)&&a.transform,a.worker&&o.WORKERS_SUPPORTED){var l=function(){if(!o.WORKERS_SUPPORTED)return!1;var i,a,r=(i=t.URL||t.webkitURL||null,a=e.toString(),o.BLOB_URL||(o.BLOB_URL=i.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; ","(",a,")();"],{type:"text/javascript"})))),l=new t.Worker(r);return l.onmessage=_,l.id=n++,s[l.id]=l}();return l.userStep=a.step,l.userChunk=a.chunk,l.userComplete=a.complete,l.userError=a.error,a.step=j(a.step),a.chunk=j(a.chunk),a.complete=j(a.complete),a.error=j(a.error),delete a.worker,void l.postMessage({input:i,config:a,workerId:l.id})}var u=null;return o.NODE_STREAM_INPUT,"string"==typeof i?(i=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}(i),u=a.download?new d(a):new m(a)):!0===i.readable&&j(i.read)&&j(i.on)?u=new p(a):(t.File&&i instanceof File||i instanceof Object)&&(u=new c(a)),u.stream(i)},unparse:function(e,t){var i=!1,a=!0,s=",",n="\r\n",r='"',l=r+r,d=!1,c=null,m=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||o.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))&&(i=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(d=t.skipEmptyLines),"string"==typeof t.newline&&(n=t.newline),"string"==typeof t.quoteChar&&(r=t.quoteChar),"boolean"==typeof t.header&&(a=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+r),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(m=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var p=new RegExp(h(r),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return u(null,e,d);if("object"==typeof e[0])return u(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])),u(e.fields||[],e.data||[],d);throw new Error("Unable to serialize unrecognized input");function u(e,t,i){var o="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var r=Array.isArray(e)&&0=this._config.preview;if(a)t.postMessage({results:r,workerId:o.WORKER_ID,finished:d});else if(j(this._config.chunk)&&!i){if(this._config.chunk(r,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);r=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(r.data),this._completeResults.errors=this._completeResults.errors.concat(r.errors),this._completeResults.meta=r.meta),this._completed||!d||!j(this._config.complete)||r&&r.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),d||r&&r.meta.paused||this._nextChunk(),r}this._halted=!0},this._sendError=function(e){j(this._config.error)?this._config.error(e):a&&this._config.error&&t.postMessage({workerId:o.WORKER_ID,error:e,finished:!1})}}function d(e){var t;(e=e||{}).chunkSize||(e.chunkSize=o.RemoteChunkSize),l.call(this,e),this._nextChunk=i?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),i||(t.onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var a in e)t.setRequestHeader(a,e[a])}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)}i&&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 i=t.statusText||e;this._sendError(new Error(i))}}function c(e){var t,i;(e=e||{}).chunkSize||(e.chunkSize=o.LocalChunkSize),l.call(this,e);var a="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,i=e.slice||e.webkitSlice||e.mozSlice,a?((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,i=this._config.chunkSize;return i?(e=t.substring(0,i),t=t.substring(i)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function p(e){l.call(this,e=e||{});var t=[],i=!0,a=!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(){a&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):i=!0},this._streamData=v((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),i&&(i=!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(),a=!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 u(e){var t,i,a,s=Math.pow(2,53),n=-s,r=/^\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,p=!1,u=!1,_=[],f={data:[],errors:[],meta:{}};if(j(e.step)){var b=e.step;e.step=function(t){if(f=t,w())y();else{if(y(),0===f.data.length)return;c+=t.data.length,e.preview&&c>e.preview?i.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 y(){return f&&a&&(P("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+o.DefaultDelimiter+"'"),a=!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":_[a]),e.transform&&(o=e.transform(o,n)),o=S(n,o),"__parsed_extra"===n?(s[n]=s[n]||[],s[n].push(o)):s[n]=o}return e.header&&(a>_.length?P("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+a,m+i):a<_.length&&P("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+a,m+i)),s}var i=1;return!f.data.length||Array.isArray(f.data[0])?(f.data=f.data.map(t),i=f.data.length):f.data=t(f.data,0),e.header&&f.meta&&(f.meta.fields=_),m+=i,f}()}function w(){return e.header&&0===_.length}function S(t,i){return a=t,e.dynamicTypingFunction&&void 0===e.dynamicTyping[a]&&(e.dynamicTyping[a]=e.dynamicTypingFunction(a)),!0===(e.dynamicTyping[a]||e.dynamicTyping)?"true"===i||"TRUE"===i||"false"!==i&&"FALSE"!==i&&(function(e){if(r.test(e)){var t=parseFloat(e);if(n=a.length/2?"\r\n":"\r"}(s,l)),a=!1,e.delimiter)j(e.delimiter)&&(e.delimiter=e.delimiter(s),f.meta.delimiter=e.delimiter);else{var d=function(t,i,a,s,n){var r,l,d,c;n=n||[",","\t","|",";",o.RECORD_SEP,o.UNIT_SEP];for(var m=0;m=r)return H(!0)}else for(q=c,c++;;){if(-1===(q=o.indexOf(t,q+1)))return u||y.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),U();if(q===g-1)return U(o.substring(c,q).replace(D,t));if(t!==d||o[q+1]!==d){if(t===d||0===q||o[q-1]!==d){-1!==O&&O=r)return H(!0);break}y.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),q++}}else q++}return U();function W(e){v.push(e),S=c}function V(e){var t=0;if(-1!==e){var i=o.substring(q+1,e);i&&""===i.trim()&&(t=i.length)}return t}function U(e){return u||(void 0===e&&(e=o.substring(c)),w.push(e),c=g,W(w),x&&Z()),H()}function z(e){c=e,W(w),w=[],L=o.indexOf(a,c)}function H(e){return{data:v,errors:y,meta:{delimiter:i,linebreak:a,aborted:m,truncated:!!e,cursor:S+(p||0)}}}function Z(){n(H()),v=[],y=[]}},this.abort=function(){m=!0},this.getCharIndex=function(){return c}}function _(e){var t=e.data,i=s[t.workerId],a=!1;if(t.error)i.userError(t.error,t.file);else if(t.results&&t.results.data){var n={abort:function(){a=!0,f(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:b,resume:b};if(j(i.userStep)){for(var o=0;o