(window.webpackJsonp=window.webpackJsonp||[]).push([[39],{1066:function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var r=n(0);var a=function(t,e){var n=Object(r.useRef)();Object(r.useEffect)((function(){n.current=t}),[t]),Object(r.useEffect)((function(){if(null!==e){var t=setInterval((function(){n.current()}),e);return function(){return clearInterval(t)}}}),[e])}},1105:function(t,e,n){"use strict";var r=n(0),a=n(1066),o=(n(1114),n(8)),i=n(1),c=n(9),u=n.n(c),s=n(3),l=n(5),f=n(2);function m(t){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(){p=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),c=new N(r||[]);return a(i,"_invoke",{value:L(t,n,c)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",b="executing",d="completed",y={};function v(){}function g(){}function O(){}var w={};s(w,i,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(C([])));E&&E!==n&&r.call(E,i)&&(w=E);var _=O.prototype=v.prototype=Object.create(w);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(a,o,i,c){var u=f(t[a],t,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==m(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,a){n(t,r,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,n,r){var a=h;return function(o,i){if(a===b)throw Error("Generator is already running");if(a===d){if("throw"===o)throw i;return{value:t,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=P(c,r);if(u){if(u===y)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===h)throw a=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=b;var s=f(e,n,r);if("normal"===s.type){if(a=r.done?d:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(a=d,r.method="throw",r.arg=s.arg)}}}function P(e,n){var r=n.method,a=e.iterator[r];if(a===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,P(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var o=f(a,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,y;var i=o.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,y):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function C(e){if(e||""===e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),y}},e}function h(t,e,n,r,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,a)}function b(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(t){h(o,r,a,i,c,"next",t)}function c(t){h(o,r,a,i,c,"throw",t)}i(void 0)}))}}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,c=[],u=!0,s=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return y(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n4&&void 0!==arguments[4]&&arguments[4];n("automation",{}),n("isLoading",!0);var c=r.s,u=(r.page,r.filter,r.path,_(r,O)),s={offset:a,limit:o,status:t,search:c,filters:u,version:i?2:1};e("GET",Object(d.A)("/automations"),s)},setAutomationListValues:function(t,e){n(t,e)},fetchRecipient:function(t,e,n){o("GET",Object(d.A)("/automation/".concat(t,"/recipients?limit=").concat(e,"&offset=").concat(n)))},setRecipientsValues:function(t,e){i(t,e)},fetchConversion:function(t,e,n){l("automation",{}),s("GET",Object(d.A)("/automation/".concat(t,"/conversions?limit=").concat(e,"&offset=").concat(n)))},setConversionValues:function(t,e){l(t,e)},fetchContacts:function(t,e,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"";p("automation",{}),m("GET",Object(d.A)("/automation/".concat(t,"/contacts?limit=").concat(e,"&offset=").concat(n,"&type=").concat(r,"&search=").concat(a)))},setContactValues:function(t,e){p(t,e)},fetchAnalytics:function(t,e,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,i=0;4===parseInt(o)&&(i=1),v("GET",Object(d.A)("/analytics/emails/chart/")+"?"+Object(y.stringify)({after:e,before:n,interval:r,oid:t,type:a,mode:o,contact:i}))},setAnalyticsValues:function(t,e){w(t,e)}})},x=n(2),L=n(61),P=n(62),A=n(19),S=n(5),N=n(55),C=n(9),T=n.n(C),I=n(6),D=n.n(I),F=n(12),M=n(1069),G=n(345),z=n(347),B=n(48),R=n(8),q=n(26),U=n(333),Y=n(11);function V(t){return(V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function H(){H=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),c=new A(r||[]);return a(i,"_invoke",{value:k(t,n,c)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var m="suspendedStart",p="executing",h="completed",b={};function d(){}function y(){}function v(){}var g={};s(g,i,(function(){return this}));var O=Object.getPrototypeOf,w=O&&O(O(S([])));w&&w!==n&&r.call(w,i)&&(g=w);var j=v.prototype=d.prototype=Object.create(g);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(a,o,i,c){var u=f(t[a],t,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==V(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,a){n(t,r,e,a)}))}return o=o?o.then(a,a):a()}})}function k(e,n,r){var a=m;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===h){if("throw"===o)throw i;return{value:t,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=x(c,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===m)throw a=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=p;var s=f(e,n,r);if("normal"===s.type){if(a=r.done?h:"suspendedYield",s.arg===b)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(a=h,r.method="throw",r.arg=s.arg)}}}function x(e,n){var r=n.method,a=e.iterator[r];if(a===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=f(a,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var i=o.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function S(e){if(e||""===e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;P(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:S(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function $(t,e,n,r,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,a)}function J(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,c=[],u=!0,s=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Q(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Q(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;P(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:S(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function ot(t,e,n,r,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,a)}function it(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(t){ot(o,r,a,i,c,"next",t)}function c(t){ot(o,r,a,i,c,"throw",t)}i(void 0)}))}}var ct=function(t){var e=t.isOpen,n=t.tasks,a=t.onSuccess,i=t.onError,c=t.onRequestClose,u=t.actionType,s=n?n.length:0,l=Object(nt.useMutation)(function(){var t=it(at().mark((function t(e){return at().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T()({path:Object(d.A)("/bulk-action/automation_v1"),method:"DELETE",data:{ids:e}});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),{onSuccess:function(){setTimeout((function(){return l.reset()}),2500),a&&a()},onError:function(){i&&i()}}),f=function(){var t=it(at().mark((function t(){return at().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l.mutate(n.map((function(t){return t.id})));case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),m={delete:{title:Object(o._n)("Delete Automation","Delete Automations",s,"wp-marketing-automations"),description:Object(r.createElement)(r.Fragment,null,Object(o.__)("You are about to delete ","wp-marketing-automations"),Object(o._n)("automation","automations",s,"wp-marketing-automations"),Object(o.__)(". This action cannot be undone. Cancel to stop, Delete to proceed.","wp-marketing-automations")),confirmBtn:Object(o.__)("Delete","wp-marketing-automations"),cancelBtn:Object(o.__)("Cancel","wp-marketing-automations"),successMsg:Object(o.__)("Bulk action executed successfully","wp-marketing-automations"),errorMsg:Object(o.__)("Unable to delete automation","wp-marketing-automations"),confirmDescription:Object(o.__)("This action is irreversible","wp-marketing-automations")}};return Object(r.createElement)(N.a,{modalTitle:m.hasOwnProperty(u)&&m[u].hasOwnProperty("title")?m[u].title:Object(o._n)("Perform Actions","Perform Actions",s,"wp-marketing-automations"),deleteDescriptionText:m.hasOwnProperty(u)&&m[u].hasOwnProperty("description")?m[u].description:"",confirmButtonText:m.hasOwnProperty(u)&&m[u].hasOwnProperty("confirmBtn")?m[u].confirmBtn:Object(o.__)("Confirm","wp-marketing-automations"),cancelButtonText:m.hasOwnProperty(u)&&m[u].hasOwnProperty("cancelBtn")?m[u].cancelBtn:Object(o.__)("Cancel","wp-marketing-automations"),onConfirm:f,isLoading:l.isLoading,successMessage:l.isSuccess&&(m.hasOwnProperty(u)&&m[u].hasOwnProperty("successMsg")?m[u].successMsg:Object(o.__)("Actions Done!","wp-marketing-automations")),errorMessage:l.isError&&(l.error&&l.error.message?l.error.message:m.hasOwnProperty(u)&&m[u].hasOwnProperty("errorMsg")?m[u].errorMsg:Object(o.__)("Unable to perform action","wp-marketing-automations")),onRequestClose:function(){return!!c&&c()},isOpen:e,confirmDescription:m.hasOwnProperty(u)&&m[u].hasOwnProperty("confirmDescription")?m[u].confirmDescription:"",isDelete:!0})},ut=n(148),st=n(1161);function lt(t){return(lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ft(){ft=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),c=new A(r||[]);return a(i,"_invoke",{value:k(t,n,c)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var m="suspendedStart",p="executing",h="completed",b={};function d(){}function y(){}function v(){}var g={};s(g,i,(function(){return this}));var O=Object.getPrototypeOf,w=O&&O(O(S([])));w&&w!==n&&r.call(w,i)&&(g=w);var j=v.prototype=d.prototype=Object.create(g);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(a,o,i,c){var u=f(t[a],t,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==lt(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,a){n(t,r,e,a)}))}return o=o?o.then(a,a):a()}})}function k(e,n,r){var a=m;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===h){if("throw"===o)throw i;return{value:t,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=x(c,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===m)throw a=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=p;var s=f(e,n,r);if("normal"===s.type){if(a=r.done?h:"suspendedYield",s.arg===b)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(a=h,r.method="throw",r.arg=s.arg)}}}function x(e,n){var r=n.method,a=e.iterator[r];if(a===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=f(a,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var i=o.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function S(e){if(e||""===e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;P(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:S(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function mt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:"";return Object(r.createElement)(r.Fragment,null,"".concat(""!==t?t:Object(o.__)("It seems there was an issue during the import","wp-marketing-automations"),". ").concat(Object(o.__)("For further help, contact","wp-marketing-automations")," "),Object(r.createElement)("a",{href:Object(d.fb)("support",{utm_medium:"Automation+Import+Failed"}),target:"_blank",rel:"noopener noreferrer"},Object(o.__)(" support. ","wp-marketing-automations")))},Wt=function(t){var e=t.onRequestClose,n=t.isV2,a=void 0!==n&&n,i=Object(F.i)(),c=dt(Object(r.useState)({status:!1,modalTitle:Object(o.__)("Import Automation","wp-marketing-automations")}),2),u=c[0],s=c[1],l=dt(Object(r.useState)(null),2),f=l[0],m=l[1],p=function(){var t,n=(t=ft().mark((function t(){var n;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s(pt(pt({},u),{},{loading:!0,title:Object(o.__)("Please wait…","wp-marketing-automations"),message:Object(r.createElement)(r.Fragment,null,Object(o.sprintf)(Object(o.__)("Please wait! We are importing %s data","wp-marketing-automations"),null==f?void 0:f.name))})),t.prev=1,(n=new FormData).append("files",f),n.append("version",a?2:1),t.next=7,T()({method:"POST",body:n,path:Object(d.A)("/automations/import")}).then((function(t){200==t.code?t.result.hasOwnProperty("automation_id")?a?(s(pt(pt({},u),{},{status:!0,loading:!1,title:Object(o.__)("Importing Done","wp-marketing-automations"),message:Object(o.__)("Successfully Imported and added in your Automation","wp-marketing-automations")})),setTimeout((function(){Object(F.l)({page:"autonami",path:"/automation/".concat(t.result.automation_id)},"/",{})}),1e3)):window.location.href="admin.php?page=autonami-automations&edit="+t.result.automation_id:(Object(F.l)({path:"/automations/"},"/",i),e()):(m(null),s(pt(pt({},u),{},{status:!1,loading:!1,title:Object(o.__)("Importing Failed","wp-marketing-automations"),message:Qt(t.message)})))}));case 7:t.next=13;break;case 9:t.prev=9,t.t0=t.catch(1),m(null),s(pt(pt({},u),{},{status:!1,loading:!1,title:Object(o.__)("Importing Failed","wp-marketing-automations"),message:Qt(t.t0.message)}));case 13:case"end":return t.stop()}}),t,null,[[1,9]])})),function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(t){bt(o,r,a,i,c,"next",t)}function c(t){bt(o,r,a,i,c,"throw",t)}i(void 0)}))});return function(){return n.apply(this,arguments)}}();return Object(r.useEffect)((function(){f&&p()}),[f]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(S.Modal,{className:"bwf-admin-modal bwf-admin-modal-480 bwf-admin-modal-no-header",shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1},Object(r.createElement)("div",{className:"bwf-admin-m-header-new"},Object(r.createElement)("div",{className:"bwf-admin-m-title"},Object(o.__)("Import Automation","wp-marketing-automations")),Object(r.createElement)("div",{className:"bwf-admin-m-close",onClick:e},Object(r.createElement)(R.a,{icon:"close",size:20}))),u.title&&Object(r.createElement)("div",{className:"bwf-import-modal-content bwf-t-center"},u.loading?Object(r.createElement)(R.a,{icon:"import-loading"}):Object(r.createElement)(R.a,{icon:u.status?"success-loader":"circle-close",size:48}),Object(r.createElement)("div",{className:"bwf-drop-import-content"},u.message)),!u.title&&Object(r.createElement)(st.a,{onFileSelected:function(t){return m(t)},filetypeArray:["application/json"],importText:Object(o.__)("Drag or Browse a json file to import automation","wp-marketing-automations"),importInfo:"( "+Object(o.__)("File size 10 MB max","wp-marketing-automations")+" )"})))},Kt=n(7);function Zt(){return(Zt=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;P(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:S(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function le(t,e,n,r,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,a)}function fe(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(t){le(o,r,a,i,c,"next",t)}function c(t){le(o,r,a,i,c,"throw",t)}i(void 0)}))}}function me(t){return function(t){if(Array.isArray(t))return ge(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ve(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pe(){return(pe=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){c=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(c)throw o}}}}(wt);try{for(n.s();!(e=n.n()).done;){var r=e.value;t[r.id]=r}}catch(t){n.e(t)}finally{n.f()}}return t}),[wt]),Gt=Object(ut.b)(Mt),zt=Gt.singleSelectProps,Bt=Gt.selectAllProps,Rt=Gt.floatingBarProps,qt=Gt.resetSelection,Ut=Gt.selected,Yt=Object.keys(Ut).filter((function(t){return Ut[t]})).length,Vt=[{key:"select_template",label:Object(r.createElement)(te.a,pe({type:"checkbox",checked:!1,onChange:function(){}},Bt)),isLeftAligned:!0,required:!0,cellClassName:"bwf-col-action bwf-w-30 bwf-table-col-sticky bwf-sticky-left"},{key:"action",label:"",isLeftAligned:!0,required:!0,cellClassName:"bwf-col-action bwf-w-30 bwf-table-col-sticky bwf-sticky-left"},{key:"title",label:Object(o.__)("Name","wp-marketing-automations"),isLeftAligned:!0,required:!0},{key:"event",label:Object(o.__)("Event","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-150"},{key:"actions",label:Object(o.__)("Actions","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-210"},{key:"tasks",label:Object(o.__)("Tasks","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-300"},{key:"total_run",label:Object(o.__)("Total Runs","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-120"},Object(d.qc)()&&{key:"revenue",label:Object(o.__)("Revenue","wp-marketing-automations"),cellClassName:"bwf-w-120"},{key:"status",label:Object(o.__)("Status","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-60"}],Ht=function(t){t!==Et&&p("limit",t)},$t=function(t){var e=[],n="";return Object(x.isEmpty)(t.automation_actions)||Object.entries(t.automation_actions).map((function(t){var r=ye(t,2),a=(r[0],r[1]);Object(x.isEmpty)(n)&&(n=a[0]),e=[].concat(me(e),me(a))})),Object(r.createElement)(r.Fragment,null,Object(x.isEmpty)(n)?"-":Object(r.createElement)(r.Fragment,null,!Object(x.isEmpty)(n)&&n,!Object(x.isEmpty)(e)&&e.length>1&&Object(r.createElement)(K.a,{items:e})))},Jt=function(){var t=fe(se().mark((function t(n,r){return se().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return I(be(be({},r),{},{status:!0})),t.prev=1,t.next=4,T()({path:Object(d.A)("/automations"),method:"DELETE",data:{automation_ids:[n]}}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));I({status:!1}),e(t.message),m(Pt,c,0,Et),Object(d.Lb)(e,3e3)}));case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),I(be(be({},r),{},{error:t.t0.message}));case 9:case"end":return t.stop()}}),t,null,[[1,6]])})));return function(e,n){return t.apply(this,arguments)}}(),Qt=function(){var t=fe(se().mark((function t(n){return se().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e(Object(o.__)("Duplicating…","wp-marketing-automations")),t.prev=1,t.next=4,T()({path:Object(d.A)("/automations/".concat(n,"/duplicate")),method:"POST"}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));e(Object(o.__)("Automation Duplicated","wp-marketing-automations")),m(Pt,c,0,Et),Object(d.Lb)(e,3e3)}));case 4:t.next=10;break;case 6:t.prev=6,t.t0=t.catch(1),Object(d.Lb)(e,3e3),setTimeout((function(){I({status:!0,modalTitle:Object(o.__)("Duplicate Automation","wp-marketing-automations"),error:t.t0.message})}),[1500]);case 10:case"end":return t.stop()}}),t,null,[[1,6]])})));return function(e){return t.apply(this,arguments)}}(),Kt=function(t,e){var n="data:text/json;charset=utf-8,"+encodeURIComponent(t),r=document.createElement("a");r.setAttribute("href",n),r.setAttribute("download",e+".json"),document.body.appendChild(r),r.click(),r.remove()},Zt=function(){var t=fe(se().mark((function t(){var n,r,a,i=arguments;return se().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i.length>0&&void 0!==i[0]?i[0]:0,r=i.length>1&&void 0!==i[1]?i[1]:"automation",e(Object(o.__)("Exporting…","wp-marketing-automations")),a="",a=parseInt(n)>0?Object(d.A)("/automations/".concat(n,"/export?version=1")):Object(d.A)("/automations/export/?version=1"),t.prev=5,t.next=8,T()({path:a,method:"GET"}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));Kt(t.result,r),e(Object(o.__)("Automation exported","wp-marketing-automations")),Object(d.Lb)(e,3e3)}));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(5),Object(d.Lb)(e,3e3),setTimeout((function(){I({status:!0,modalTitle:Object(o.__)("Export Automation","wp-marketing-automations"),error:t.t0.message})}),[1500]);case 14:case"end":return t.stop()}}),t,null,[[5,10]])})));return function(){return t.apply(this,arguments)}}(),Xt=function(){var t=fe(se().mark((function t(n,r){var a,i=arguments;return se().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=i.length>2&&void 0!==i[2]?i[2]:{},e(4===n?Object(o.__)("Updating Automation…","wp-marketing-automations"):n?Object(o.__)("Activating Automation…","wp-marketing-automations"):Object(o.__)("Deactivating Automation…","wp-marketing-automations")),t.prev=2,t.next=5,T()({path:Object(d.A)("/automations/toggle-state"),method:"POST",data:{state:n,automation_id:r}}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));e(4===n?Object(o.__)("Automation migrated","wp-marketing-automations"):n?Object(o.__)("Automation activated","wp-marketing-automations"):Object(o.__)("Automation deactivated","wp-marketing-automations"));var a;a=wt.map((function(t){return t.id==r&&(1==n?t.status="1":4==n?t.migrated=!0:t.status="0"),t})),4==n&&I({status:!1}),p("automations",a),Object(d.Lb)(e,3e3)}));case 5:t.next=12;break;case 7:t.prev=7,t.t0=t.catch(2),4==n&&I(be(be({},a),{},{error:t.t0.message})),Object(d.Lb)(e,3e3),setTimeout((function(){I({status:!0,modalTitle:Object(o.__)("Automation Status Update","wp-marketing-automations"),error:t.t0.message})}),[1500]);case 12:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e,n){return t.apply(this,arguments)}}(),ee=function(t){if(t.hasOwnProperty("migrated")&&t.migrated)return Object(r.createElement)("span",{className:"bwf-tags bwf-tag-blue"},Object(o.__)("Migrated","wp-marketing-automations"));switch(parseInt(t.status)){case 1:return Object(r.createElement)("span",{className:"bwf-tags bwf-tag-green"},Object(o.__)("Active","wp-marketing-automations"));default:return Object(r.createElement)("span",{className:"bwf-tags bwf-tag-red"},Object(o.__)("Inactive","wp-marketing-automations"))}},ne=function(t){return Object(r.createElement)("a",{href:"admin.php?page=autonami-automations&edit="+t.id,className:"bwf-a-no-underline"},Object(r.createElement)("b",null,t.name))},ue=function(t){return Object(r.createElement)(r.Fragment,null,t.event?t.event:Object(o.__)("Not Found","wp-marketing-automations"))},le=function(t){if(!$)return Object(r.createElement)("div",{className:"bwf-placeholder-temp bwf-w-210 bwf-h-15",title:"Loading"});var e=nt.hasOwnProperty(t.id)?nt[t.id]:{};return Object(r.createElement)(A.a,{gap:2,justify:"flex-start"},Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Active","wp-marketing-automations"),position:"top"},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automations-v1/task-history/scheduled",automation:t.id},"/",c)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-scheduled",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("scheduled")?Object(d.tc)(parseInt(e.scheduled)):0))))),Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Paused","wp-marketing-automations"),position:"top"},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automations-v1/task-history/paused",automation:t.id},"/",c)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-paused",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("paused")?Object(d.tc)(parseInt(e.paused)):0))))),Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Completed","wp-marketing-automations"),position:"top"},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automations-v1/task-history/completed",automation:t.id},"/",c)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-completed",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("completed")?Object(d.tc)(parseInt(e.completed)):0))))),Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Failed","wp-marketing-automations"),position:"top"},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automations-v1/task-history/failed",automation:t.id},"/",c)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-failed",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("failed")?Object(d.tc)(parseInt(e.failed)):0))))))},he=Array.isArray(wt)?wt.map((function(t){return[{display:zt.hasOwnProperty(t.id)?Object(r.createElement)(te.a,pe({type:"checkbox",checked:!1,onChange:function(){}},zt[t.id])):Object(r.createElement)(r.Fragment,null),value:null},{display:(e=t,Object(r.createElement)(L.a,{label:Object(o.__)("Quick Actions","wp-marketing-automations"),menuPosition:"bottom right",renderContent:function(t){var n=t.onToggle;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(P.a,null,Object(r.createElement)("a",{href:"admin.php?page=autonami-automations&edit="+e.id,className:"bwf-a-no-underline"},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Edit","wp-marketing-automations"))))),!(e.hasOwnProperty("migrated")&&e.migrated)&&Object(r.createElement)(r.Fragment,null,Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){Xt(1!==parseInt(e.status),e.id),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,1===parseInt(e.status)?Object(o.__)("Deactivate","wp-marketing-automations"):Object(o.__)("Activate","wp-marketing-automations")))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){Qt(e.id),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Duplicate","wp-marketing-automations")))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){var t={status:!0,modalTitle:"",content:Object(r.createElement)(re,{onRequestClose:function(){return I({})},onAction:function(){return Xt(4,e.id,t)}}),isDelete:!1,closeIcon:!0,modalClass:"bwf-admin-modal-medium"};I(be({},t)),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Confirm Migration","wp-marketing-automations")))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){Zt(e.id,e.name),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Export","wp-marketing-automations"))))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){var t={status:!0,modalTitle:Object(o.__)("Delete Automation","wp-marketing-automations"),deleteEntityName:e.name,isDelete:!0,buttonConfirm:Object(o.__)("Delete","wp-marketing-automations"),buttonCancel:Object(o.__)("Cancel","wp-marketing-automations"),closeIcon:!1};I(be(be({},t),{},{onConfirm:function(){return Jt(e.id,t)}})),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Delete","wp-marketing-automations")))))}})),value:""},{display:ne(t),value:t.name},{display:ue(t),value:t.event},{display:$t(t),value:""},{display:le(t),value:""},{display:parseInt(t.run_count)>0?parseInt(t.run_count):"0",value:t.run_count},Object(d.qc)()&&{display:t.revenue&&parseFloat(t.revenue)>0?Object(r.createElement)("span",{className:"bwf-tags bwf-tag-revenue"},Tt(t.revenue)):"-",value:""},{display:ee(t),value:""}];var e})):[],de=D()("bwfcrm-campaign-list-table",{"has-search":!0}),ge=[{type:"icon",data:{class:"bwf-pb-gap",content:Object(r.createElement)(R.a,{icon:"zero-automation",width:"90",height:"90"})}},{type:"content",data:{class:"bwf-h2 bwf-pb-10",content:Object(o.__)("Grow your business with marketing automation","wp-marketing-automations")}},{type:"content",data:{class:"bwf-h4-1 bwf-pb-gap",content:Object(o.__)("Create Automations for abandoned cart, post-purchase, win-back, and more. Build automated workflows that generate profits while you sleep. Connect your site to Zapier, Slack, Twilio, Google Sheets and explore limitless automation possibilities.","wp-marketing-automations")}},{type:"buttons",data:{buttons:[{text:Object(o.__)("Create Automation","wp-marketing-automations"),proCheck:!1,onClick:function(){V(!0)}},{text:Object(o.__)("Import Automation","wp-marketing-automations"),isSecondary:!0,proCheck:!1,onClick:function(){return it(!0)}}]}}],Oe=Object(r.createElement)("div",{className:"bwf-display-flex gap-12"},Object(r.createElement)(Y.a,{isGray:!0,className:"bwf-btn-small bwf-btn-gray is-light",title:Object(o.__)("Refresh Stats","wp-marketing-automations"),onClick:function(){return J(!1),void ft(!0)},disabled:!$,isBusy:!$&<},Object(r.createElement)(R.a,{icon:"retry",size:16}),Object(o.__)("Refresh","wp-marketing-automations")),Object(r.createElement)(Y.a,{isGray:!0,className:"bwf-btn-small bwf-btn-gray is-light",title:Object(o.__)("Export","wp-marketing-automations"),onClick:function(){return Zt()}},Object(r.createElement)(R.a,{icon:"export",size:16}),Object(o.__)("Export","wp-marketing-automations")),Object(r.createElement)(Y.a,{isGray:!0,className:"bwf-btn-small bwf-btn-gray is-light",title:Object(o.__)("Import","wp-marketing-automations"),onClick:function(){return it(!0)}},Object(r.createElement)(R.a,{icon:"import",size:16}),Object(o.__)("Import","wp-marketing-automations"))),we=[{slug:"automations-v1_all",name:Object(o.__)("All","wp-marketing-automations"),path:"/automations-v1/"},{slug:"automations-v1_active",name:Object(o.__)("Active","wp-marketing-automations"),path:"/automations-v1/list/active"},{slug:"automations-v1_inactive",name:Object(o.__)("Inactive","wp-marketing-automations"),path:"/automations-v1/list/inactive"}],je=_t||!["","all"].includes(a)||0!==kt||""!==s||z;return Object(r.createElement)(r.Fragment,null,je?Object(r.createElement)(r.Fragment,null,Object(r.createElement)("div",{className:"bwf-automation-header"},Object(r.createElement)("div",{className:"bwf-automation-h-left"},Object(r.createElement)("div",{className:"bwf-automation-h-title"},Object(o.__)("Automations","wp-marketing-automations")),Object(r.createElement)("div",{className:"bwf-automation-h-tag"},Object(o.__)("Legacy","wp-marketing-automations")),parseInt(kt)>0&&Object(r.createElement)("div",{className:"bwf-automation-h-count"},Object(o.sprintf)(Object(o.__)("(%s Results)","wp-marketing-automations"),kt))),Object(r.createElement)("div",{className:"bwf-automation-h-right"},Object(r.createElement)(Y.a,{isSecondary:!0,onClick:function(){return Object(F.l)({page:"autonami",path:"/automations-v1/task-history/"},"/",{})}},Object(o.__)("Task History","wp-marketing-automations")),Object(r.createElement)(Y.a,{isPrimary:!0,onClick:function(){return V(!0)}},Object(o.__)("Create Automation","wp-marketing-automations")))),Object(r.createElement)(oe,null),Object(r.createElement)(ie.a,{tabs:we,selected:a?"automations-v1_".concat(a):"automations-v1_all",count:Ft,disableUrlUpdate:!0,onChange:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p("offset",0),B(!0),Object(F.l)({page:"autonami",path:e},"/",{})}}),Object(r.createElement)("div",{className:"bwf_clear_16"}),Object(r.createElement)(i.a,{className:de,rows:he,headers:Vt,query:{paged:xt},rowsPerPage:Et,totalRows:kt,isLoading:_t,onPageChange:function(t,e){p("offset",(t-1)*Et)},onQueryChange:function(t){return"per_page"!==t?function(){}:Ht},rowHeader:!0,showMenu:!1,actions:Yt>0?[Object(r.createElement)(ut.a,pe({key:"automation-contact-bulk-action",actions:[{id:"delete",icon:"trash",hint:Object(o.__)("Delete","wp-marketing-automations")}],onAction:Dt,inLine:!0,reset:It},Rt))]:[Object(r.createElement)(ae.a,{key:"search",isLoading:_t,searchTerm:null==c?void 0:c.s,showResultCount:!1,setSearchData:function(t){if(Object(x.size)(t))Object(F.l)({s:t},"/",c);else{var e=Object(x.cloneDeep)(c);e.hasOwnProperty("s")&&(null==e||delete e.s),B(!0),Object(F.l)(e,"/",{})}}})],emptyMessage:Object(o.__)("No automations found","wp-marketing-automations"),extraSectionBeforefilterCol:Oe}),Object(r.createElement)(N.a,{modalTitle:C.modalTitle,deleteEntityName:C.deleteEntityName,confirmText:C.confirmText,confirmButtonText:C.buttonConfirm,cancelButtonText:C.buttonCancel,onConfirm:C.onConfirm,isLoading:C.loading,successMessage:C.success,errorMessage:C.error,content:C.content,onRequestClose:function(){return I({status:!1})},confirmDescription:C.hasOwnProperty("confirmDescription")?C.confirmDescription:"",isOpen:C.status,isDelete:C.isDelete,closeIcon:!C.hasOwnProperty("closeIcon")||C.closeIcon,modalClass:C.modalClass}),Object(r.createElement)(ct,{tasks:pt,isOpen:dt,onSuccess:function(){m(Pt,c,jt,Et),It()},onError:It,onRequestClose:function(){return yt(!1)},screenType:"automation-v1",screenTypeId:a,actionType:gt})):Object(r.createElement)(et.a,{data:ge}),U&&Object(r.createElement)(W,{onCloseModal:function(){return V(!1)},query:c}),ot&&Object(r.createElement)(Wt,{onRequestClose:function(){return it(!1)}}))},we=n(1077),je=n(1095),Ee=n(196),_e=n(1105);function ke(t){return(ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function xe(){xe=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),c=new A(r||[]);return a(i,"_invoke",{value:k(t,n,c)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var m="suspendedStart",p="executing",h="completed",b={};function d(){}function y(){}function v(){}var g={};s(g,i,(function(){return this}));var O=Object.getPrototypeOf,w=O&&O(O(S([])));w&&w!==n&&r.call(w,i)&&(g=w);var j=v.prototype=d.prototype=Object.create(g);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(a,o,i,c){var u=f(t[a],t,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==ke(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,a){n(t,r,e,a)}))}return o=o?o.then(a,a):a()}})}function k(e,n,r){var a=m;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===h){if("throw"===o)throw i;return{value:t,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=x(c,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===m)throw a=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=p;var s=f(e,n,r);if("normal"===s.type){if(a=r.done?h:"suspendedYield",s.arg===b)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(a=h,r.method="throw",r.arg=s.arg)}}}function x(e,n){var r=n.method,a=e.iterator[r];if(a===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=f(a,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var i=o.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function S(e){if(e||""===e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;P(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:S(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function Le(t,e,n,r,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,a)}function Pe(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(t){Le(o,r,a,i,c,"next",t)}function c(t){Le(o,r,a,i,c,"throw",t)}i(void 0)}))}}var Ae=function(t){var e=t.isOpen,n=t.tasks,a=t.onSuccess,i=t.onError,c=t.onRequestClose,u=t.actionType,s=n?n.length:0,l=Object(nt.useMutation)(function(){var t=Pe(xe().mark((function t(e){return xe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T()({path:Object(d.A)("/bulk-action/automation_v2"),method:"DELETE",data:{ids:e}});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),{onSuccess:function(){setTimeout((function(){return l.reset()}),2500),a&&a()},onError:function(){i&&i()}}),f=function(){var t=Pe(xe().mark((function t(){return xe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l.mutate(n.map((function(t){return t.id})));case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),m={delete:{title:Object(o._n)("Delete Automation","Delete Automations",s,"wp-marketing-automations"),description:Object(r.createElement)(r.Fragment,null,Object(o.__)("You are about to delete ","wp-marketing-automations"),Object(o._n)("automation","automations",s,"wp-marketing-automations"),Object(o.__)(". This action cannot be undone. Cancel to stop, Delete to proceed.","wp-marketing-automations")),confirmBtn:Object(o.__)("Delete","wp-marketing-automations"),cancelBtn:Object(o.__)("Cancel","wp-marketing-automations"),successMsg:Object(o.__)("Bulk action executed successfully","wp-marketing-automations"),errorMsg:Object(o.__)("Unable to delete automation","wp-marketing-automations"),confirmDescription:Object(o.__)("This action is irreversible","wp-marketing-automations")}};return Object(r.createElement)(N.a,{modalTitle:m.hasOwnProperty(u)&&m[u].hasOwnProperty("title")?m[u].title:Object(o._n)("Perform Actions","Perform Actions",s,"wp-marketing-automations"),deleteDescriptionText:m.hasOwnProperty(u)&&m[u].hasOwnProperty("description")?m[u].description:"",confirmButtonText:m.hasOwnProperty(u)&&m[u].hasOwnProperty("confirmBtn")?m[u].confirmBtn:Object(o.__)("Confirm","wp-marketing-automations"),cancelButtonText:m.hasOwnProperty(u)&&m[u].hasOwnProperty("cancelBtn")?m[u].cancelBtn:Object(o.__)("Cancel","wp-marketing-automations"),onConfirm:f,isLoading:l.isLoading,successMessage:l.isSuccess&&(m.hasOwnProperty(u)&&m[u].hasOwnProperty("successMsg")?m[u].successMsg:Object(o.__)("Actions Done!","wp-marketing-automations")),errorMessage:l.isError&&(l.error&&l.error.message?l.error.message:m.hasOwnProperty(u)&&m[u].hasOwnProperty("errorMsg")?m[u].errorMsg:Object(o.__)("Unable to perform action","wp-marketing-automations")),onRequestClose:function(){return!!c&&c()},isOpen:e,confirmDescription:m.hasOwnProperty(u)&&m[u].hasOwnProperty("confirmDescription")?m[u].confirmDescription:"",isDelete:!0})},Se=n(40);function Ne(t){return(Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ce(){Ce=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),c=new A(r||[]);return a(i,"_invoke",{value:k(t,n,c)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var m="suspendedStart",p="executing",h="completed",b={};function d(){}function y(){}function v(){}var g={};s(g,i,(function(){return this}));var O=Object.getPrototypeOf,w=O&&O(O(S([])));w&&w!==n&&r.call(w,i)&&(g=w);var j=v.prototype=d.prototype=Object.create(g);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(a,o,i,c){var u=f(t[a],t,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==Ne(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,a){n(t,r,e,a)}))}return o=o?o.then(a,a):a()}})}function k(e,n,r){var a=m;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===h){if("throw"===o)throw i;return{value:t,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=x(c,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===m)throw a=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=p;var s=f(e,n,r);if("normal"===s.type){if(a=r.done?h:"suspendedYield",s.arg===b)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(a=h,r.method="throw",r.arg=s.arg)}}}function x(e,n){var r=n.method,a=e.iterator[r];if(a===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=f(a,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var i=o.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function S(e){if(e||""===e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;P(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:S(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function Te(t,e,n,r,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,a)}function Ie(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(t){Te(o,r,a,i,c,"next",t)}function c(t){Te(o,r,a,i,c,"throw",t)}i(void 0)}))}}function De(){return(De=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&(t="cached"),Yt(t)}}),[It,Dt,St]),Object(r.useEffect)((function(){var t=0,e=0,n=0;Tt.hasOwnProperty("status_count")&&(Tt.status_count.hasOwnProperty("active")&&(e=parseInt(Tt.status_count.active)),Tt.status_count.hasOwnProperty("inactive")&&(t=parseInt(Tt.status_count.inactive))),Tt.hasOwnProperty("contact_activity")&&(n=parseInt(Tt.contact_activity)),Ut(Ge(Ge({},Ht),{"automations-v2_all":parseInt(t)+parseInt(e),"automations-v2_active":e,"automations-v2_inactive":t,"contact-activity":n}))}),[Tt]),Object(r.useEffect)((function(){return function(){p("automations",[]),p("offset",0),Gt.current.abort(),Vt()}}),[]),Object(M.a)("automations-v2","","",!1,Bt,0,!1,c);var $t=Object(r.useMemo)((function(){var t={};if(Array.isArray(Lt)){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Re(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){c=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(c)throw o}}}}(Lt);try{for(n.s();!(e=n.n()).done;){var r=e.value;t[r.id]=r}}catch(t){n.e(t)}finally{n.f()}}return t}),[Lt]),Jt=Object(ut.b)($t),Qt=Jt.singleSelectProps,Kt=Jt.selectAllProps,Zt=Jt.floatingBarProps,Xt=Jt.resetSelection,ee=Jt.selected,ne=Object.keys(ee).filter((function(t){return ee[t]})).length,re=[{key:"select_template",label:Object(r.createElement)(te.a,De({type:"checkbox",checked:!1,onChange:function(){}},Kt)),isLeftAligned:!0,required:!0,cellClassName:"bwf-col-action bwf-w-30 bwf-table-col-sticky bwf-sticky-left"},{key:"action",label:"",isLeftAligned:!0,required:!0,cellClassName:"bwf-col-action bwf-w-30 bwf-table-col-sticky bwf-sticky-left"},{key:"title",label:Object(o.__)("Name","wp-marketing-automations"),isLeftAligned:!0,required:!0},{key:"event",label:Object(o.__)("Event","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-word-break bwf-w-210"},{key:"contacts",label:Object(o.__)("Contact Activity","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-240"}].concat(Fe(Object(d.qc)()?[{key:"revenue",label:Object(o.__)("Revenue","wp-marketing-automations"),cellClassName:"bwf-w-120"}]:[]),[{key:"status",label:Object(o.__)("Status","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-90"}]),oe=function(t){t!==At&&p("limit",t)},ue=function(){var t=Ie(Ce().mark((function t(n,r){return Ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return z(Ge(Ge({},r),{},{status:!0})),t.prev=1,t.next=4,T()({path:Object(d.A)("/automations"),method:"DELETE",data:{automation_ids:[n]}}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));z({status:!1}),e(t.message),m(Ft,a,0,At,c),Object(d.Lb)(e,3e3)}));case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),z(Ge(Ge({},r),{},{error:t.t0.message}));case 9:case"end":return t.stop()}}),t,null,[[1,6]])})));return function(e,n){return t.apply(this,arguments)}}(),se=function(){var t=Ie(Ce().mark((function t(n){return Ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e(Object(o.__)("Duplicating…","wp-marketing-automations")),t.prev=1,t.next=4,T()({path:Object(d.A)("/automations/".concat(n,"/duplicate?version=2")),method:"POST"}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));e(Object(o.__)("Automation Duplicated","wp-marketing-automations")),m(Ft,a,0,At,c),Object(d.Lb)(e,3e3)}));case 4:t.next=10;break;case 6:t.prev=6,t.t0=t.catch(1),Object(d.Lb)(e,3e3),setTimeout((function(){z({status:!0,modalTitle:Object(o.__)("Duplicate Automation","wp-marketing-automations"),error:t.t0.message})}),[1500]);case 10:case"end":return t.stop()}}),t,null,[[1,6]])})));return function(e){return t.apply(this,arguments)}}(),le=function(t,e){var n="data:text/json;charset=utf-8,"+encodeURIComponent(t),r=document.createElement("a");r.setAttribute("href",n),r.setAttribute("download",e+".json"),document.body.appendChild(r),r.click(),r.remove()},fe=function(){var t=Ie(Ce().mark((function t(){var n,r,a,i=arguments;return Ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i.length>0&&void 0!==i[0]?i[0]:0,r=i.length>1&&void 0!==i[1]?i[1]:"automation",e(Object(o.__)("Exporting…","wp-marketing-automations")),a="",!Object(x.isArray)(n)&&parseInt(n)>0?a=Object(d.A)("/automations/".concat(n,"/export?version=2")):(a=Object(d.A)("/automations/export/?version=2"),Object(x.isEmpty)(n)||(a+="&ids=".concat(n.join(",")))),t.prev=5,t.next=8,T()({path:a,method:"GET"}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));le(t.result,r),e(Object(o.__)("Automation exported","wp-marketing-automations")),Object(x.isArray)(n)&&kt(),Object(d.Lb)(e,3e3)}));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(5),Object(d.Lb)(e,3e3),setTimeout((function(){z({status:!0,modalTitle:Object(o.__)("Export Automation","wp-marketing-automations"),error:t.t0.message})}),[1500]);case 14:case"end":return t.stop()}}),t,null,[[5,10]])})));return function(){return t.apply(this,arguments)}}(),me=function(){var t=Ie(Ce().mark((function t(){return Ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e(Object(o.__)("Exporting…","wp-marketing-automations")),t.prev=1,t.next=4,T()({path:Object(d.A)("/export/action"),method:"POST",data:{type:"automation",action:"start",extra_data:{status:Ft,search:s}}}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));t.hasOwnProperty("result")&&t.result.hasOwnProperty("data")&&!Object(x.isEmpty)(t.result.data)&&(bwfcrm_contacts_data.export_data=t.result.data,e(Object(o.__)("Automation export has started","wp-marketing-automations"))),Object(d.Lb)(e,3e3)}));case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),Object(d.Lb)(e,3e3);case 9:case"end":return t.stop()}}),t,null,[[1,6]])})));return function(){return t.apply(this,arguments)}}(),pe=function(){var t=Ie(Ce().mark((function t(n,r){return Ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e(n?Object(o.__)("Activating Automation…","wp-marketing-automations"):Object(o.__)("Deactivating Automation…","wp-marketing-automations")),t.prev=1,t.next=4,T()({path:Object(d.A)("/automations/toggle-state"),method:"POST",data:{state:n,automation_id:r}}).then((function(t){if(200!==t.code)throw Error(Object(d.u)(null==t?void 0:t.message));e(n?Object(o.__)("Automation activated","wp-marketing-automations"):Object(o.__)("Automation deactivated","wp-marketing-automations"));var a;a=Lt.map((function(t){return t.id==r&&(t.status=n?"1":"0"),t})),p("automations",a),Object(d.Lb)(e,3e3)}));case 4:t.next=10;break;case 6:t.prev=6,t.t0=t.catch(1),Object(d.Lb)(e,3e3),setTimeout((function(){z({status:!0,modalTitle:Object(o.__)("Automation Status Update","wp-marketing-automations"),error:t.t0.message})}),[1500]);case 10:case"end":return t.stop()}}),t,null,[[1,6]])})));return function(e,n){return t.apply(this,arguments)}}(),he=function(t){switch(parseInt(t.status)){case 1:return Object(r.createElement)("span",{className:"bwf-tags bwf-tag-green"},Object(o.__)("Active","wp-marketing-automations"));default:return Object(r.createElement)("span",{className:"bwf-tags bwf-tag-red"},Object(o.__)("Inactive","wp-marketing-automations"))}},be=function(t){return Object(r.createElement)("a",{href:"admin.php?page=autonami&path=/automation/"+t.id,onClick:function(e){e.preventDefault(),C("listData",t.hasOwnProperty("name")?t.name:""),Object(F.l)({path:"/automation/".concat(t.id)},"/",a)},className:"bwf-a-no-underline"},Object(r.createElement)("b",null,t.name))},de=function(t){return Object(r.createElement)(r.Fragment,null,t.event?t.event:Object(o.__)("Not Found","wp-marketing-automations"))},ye=function(t){if(!at||Object(x.isEmpty)(ft))return Object(r.createElement)("div",{className:"bwf-placeholder-temp bwf-w-210 bwf-h-15",title:Object(o.__)("Loading","wp-marketing-automations")});var e=ft.hasOwnProperty(t.id)?ft[t.id]:{};return Object(r.createElement)(A.a,{gap:2,justify:"center"},Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Active","wp-marketing-automations")},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automation/".concat(t.id,"/contacts/active")},"/",a)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-scheduled",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("active")?Object(d.tc)(parseInt(e.active)):0))))),Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Paused","wp-marketing-automations")},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automation/".concat(t.id,"/contacts/paused")},"/",a)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-paused",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("paused")?Object(d.tc)(parseInt(e.paused)):0))))),Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Completed","wp-marketing-automations")},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automation/".concat(t.id,"/contacts/completed")},"/",a)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-completed",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("complete")?Object(d.tc)(parseInt(e.complete)):0))))),Object(r.createElement)(A.c,null,Object(r.createElement)(ce.a,{toolTipText:Object(o.__)("Failed","wp-marketing-automations")},Object(r.createElement)("div",{className:"bwf-tag-tooltip"},Object(r.createElement)("a",{className:"bwf-a-no-underline",onClick:function(){Object(F.l)({path:"/automation/".concat(t.id,"/contacts/failed")},"/",a)},style:{display:"inline-flex"}},Object(r.createElement)(R.a,{icon:"status-failed",width:16,height:16}),Object(r.createElement)("span",null,e.hasOwnProperty("failed")?Object(d.tc)(parseInt(e.failed)):0))))))},ve=Array.isArray(Lt)?Lt.map((function(t){return[{display:Qt.hasOwnProperty(t.id)?Object(r.createElement)(te.a,De({type:"checkbox",checked:!1,onChange:function(){}},Qt[t.id])):Object(r.createElement)(r.Fragment,null),value:null},{display:(e=t,Object(r.createElement)(L.a,{label:Object(o.__)("Quick Actions","wp-marketing-automations"),menuPosition:"bottom right",renderContent:function(t){var n=t.onToggle;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(P.a,null,Object(r.createElement)(Ee.a,{to:"wp-admin/admin.php?page=autonami&path=/automation/"+e.id,onClick:function(t){t.preventDefault(),C("listData",e.hasOwnProperty("name")?e.name:""),Object(F.l)({path:"/automation/".concat(e.id)},"/",a)},className:"bwf-a-no-underline"},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Edit","wp-marketing-automations"))))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){pe(1!==parseInt(e.status),e.id),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,1===parseInt(e.status)?Object(o.__)("Deactivate","wp-marketing-automations"):Object(o.__)("Activate","wp-marketing-automations")))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){Object(d.ac)()?se(e.id):H({status:!0,featureTitle:Object(o.__)("Duplicate Automation","wp-marketing-automations"),isFeature:!0,proLink:Object(d.fb)("upgrade",{utm_medium:"Dupicate+Automation+Upgrade+Modal"})}),n()}},Object(r.createElement)(A.a,{justify:"space-between"},Object(r.createElement)(A.c,null,Object(o.__)("Duplicate","wp-marketing-automations")),!Object(d.ac)()&&Object(r.createElement)(A.c,null,d.e))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){Object(d.ac)()?fe(e.id,e.name):H({status:!0,featureTitle:Object(o.__)("Export Automation","wp-marketing-automations"),isFeature:!0,proLink:Object(d.fb)("upgrade",{utm_medium:"Export+Automation+Upgrade+Modal"})}),n()}},Object(r.createElement)(A.a,{justify:"space-between"},Object(r.createElement)(A.c,null,Object(o.__)("Export","wp-marketing-automations")),!Object(d.ac)()&&Object(r.createElement)(A.c,null,d.e))),Object(r.createElement)(P.a,{isClickable:!0,onInvoke:function(){var t={status:!0,modalTitle:Object(o.__)("Delete Automation"),deleteEntityName:e.name,isDelete:!0,buttonConfirm:Object(o.__)("Delete","wp-marketing-automations"),buttonCancel:Object(o.__)("Cancel","wp-marketing-automations")};z(Ge(Ge({},t),{},{onConfirm:function(){return ue(e.id,t)}})),n()}},Object(r.createElement)(A.a,{justify:"flex-start"},Object(r.createElement)(A.c,null,Object(o.__)("Delete","wp-marketing-automations")))))}})),value:""},{display:be(t),value:t.name},{display:de(t),value:t.event},{display:ye(t),value:""}].concat(Fe(Object(d.qc)()?[{display:t.revenue&&parseFloat(t.revenue)>0?Object(r.createElement)("span",{className:"bwf-tags bwf-tag-revenue"},zt(t.revenue)):"-",value:""}]:[]),[{display:he(t),value:""}]);var e})):[],ge=D()("bwfcrm-campaign-list-table",{"has-search":!0}),Oe=[{type:"heading",data:{title:Object(o.__)("Explore easy automation to simply task","wp-marketing-automations"),desc:Object(o.__)("Initiate your automation journey for smoother workflows – Create your first automation for streamlined success","wp-marketing-automations")}},{type:"image-desc",data:[{img:Object(d.t)()+"automation/automation1.png",title:Object(o.__)("Pre-built recipes to get you quick started","wp-marketing-automations"),desc:Object(o.__)("Save time by importing and editing our ever-growing library of practical automation recipes to fit your needs","wp-marketing-automations")},{img:Object(d.t)()+"automation/automation2.png",title:Object(o.__)("Create any automation that you can imagine","wp-marketing-automations"),desc:Object(o.__)("Create personalized journeys with conditional branching, delays, and split paths","wp-marketing-automations")}]},{type:"buttons",data:{buttons:[{text:Object(o.__)("Create Automation","wp-marketing-automations"),onClick:function(){Object(F.l)({path:"/automations/create"},"/",a)}},{text:Object(o.__)("Import Automation","wp-marketing-automations"),isSecondary:!0,onClick:function(){bt(!0)}}]}}],ke=Object(r.createElement)("div",{className:"bwf-display-flex bwf-flex-wrap bwf-flex-start gap-8"},Object(d.ac)()&&Mt.hasOwnProperty("automation")&&Object(r.createElement)(_e.a,{type:"automation",localData:Mt.automation,onDismiss:function(){return Q(!0)}}),Object(r.createElement)(Y.a,{className:"bwf-btn-small is-light",isGray:!0,title:Object(o.__)("Refresh Stats","wp-marketing-automations"),onClick:function(){return ot(!1),void st(!0)},disabled:!at,isBusy:!at&&ct},Object(r.createElement)(R.a,{icon:"retry",size:14}),Object(r.createElement)("span",{className:"bwf-ml-4"},Object(o.__)("Refresh","wp-marketing-automations"))),Object(r.createElement)(Y.a,{className:"bwf-btn-small is-light",title:Object(o.__)("Export All","wp-marketing-automations"),onClick:function(){Object(d.ac)()?me():H({status:!0,featureTitle:Object(o.__)("Export Automations","wp-marketing-automations"),isFeature:!0,proLink:Object(d.fb)("upgrade",{utm_medium:"Export+Automation+Upgrade+Modal"})})},disabled:Mt.hasOwnProperty("automation")&&!J},Object(d.ac)()?Object(r.createElement)(R.a,{icon:"export",size:14}):Object(r.createElement)(R.a,{icon:"king",size:16}),Object(r.createElement)("span",{className:"bwf-ml-4"},Object(o.__)("Export All","wp-marketing-automations"))),Object(r.createElement)(Y.a,{className:"bwf-btn-small is-light",title:Object(o.__)("Import","wp-marketing-automations"),onClick:function(){return bt(!0)}},Object(r.createElement)(R.a,{icon:"import",size:14}),Object(r.createElement)("span",{className:"bwf-ml-4"},Object(o.__)("Import","wp-marketing-automations")))),xe=St||S||!["","all"].includes(n)||0!==Nt||""!==s||K,Le=[{slug:"automations-v2_all",name:Object(o.__)("All","wp-marketing-automations"),path:"/automations/"},{slug:"automations-v2_active",name:Object(o.__)("Active","wp-marketing-automations"),path:"/automations/active"},{slug:"automations-v2_inactive",name:Object(o.__)("Inactive","wp-marketing-automations"),path:"/automations/inactive"}];return Object(r.createElement)(r.Fragment,null,Object(d.X)()&&xe?Object(r.createElement)(r.Fragment,null,Object(r.createElement)("div",{className:"bwf-content-header-new"},Object(r.createElement)("div",{className:"bwf-content-header-left"},Object(r.createElement)("div",{className:"bwf-content-header-title"},Object(o.__)("Automations","wp-marketing-automations")),parseInt(Nt)>0&&Object(r.createElement)("div",{className:"bwf-content-header-count"},Object(o.sprintf)(Object(o.__)("(%s Results)","wp-marketing-automations"),Nt))),Object(r.createElement)("div",{className:"bwf-content-header-right"},Object(r.createElement)(Y.a,{isPrimary:!0,onClick:function(){return Object(F.l)({page:"autonami",path:"/automations/create"},"/",{})}},Object(o.__)("Create Automation","wp-marketing-automations")))),Object(r.createElement)(ie.a,{tabs:Le,selected:n?"automations-v2_".concat(n):"automations-v2_all",count:Ht,disableUrlUpdate:!0,onChange:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p("offset",0),nt(!0),Object(F.l)({page:"autonami",path:e},"/",{})}}),Object(r.createElement)("div",{className:"bwf_clear_16"}),S&&Object(r.createElement)(q.a,{status:"error"},S.message),Object(r.createElement)(i.a,{className:ge,rows:ve,headers:re,query:{paged:Ct},rowsPerPage:At,totalRows:Nt,isLoading:St,onPageChange:function(t,e){p("offset",(t-1)*At)},onQueryChange:function(t){return"per_page"!==t?function(){}:oe},rowHeader:!0,showMenu:!1,actions:ne>0?[Object(r.createElement)(ut.a,De({key:"automation-bulk-action",actions:[{id:"export",icon:"export",hint:Object(o.__)("Export","wp-marketing-automations"),isPro:!0,proLink:Object(d.fb)("upgrade",{utm_medium:"Automation+Bulk+Action+Export+Upgrade+Modal"}),featureTitle:Object(o.__)("Export Automations","wp-marketing-automations")},{id:"delete",icon:"delete",hint:Object(o.__)("Delete","wp-marketing-automations")}],onAction:xt,inLine:!0,reset:kt},Zt))]:[Object(r.createElement)(ae.a,{key:"search",isLoading:St,searchTerm:null==a?void 0:a.s,showResultCount:!1,setSearchData:function(t){if(Object(x.size)(t))Object(F.l)({s:t},"/",a);else{var e=Object(x.cloneDeep)(a);e.hasOwnProperty("s")&&(null==e||delete e.s),nt(!0),Object(F.l)(e,"/",{})}}})],emptyMessage:Object(o.__)("No automations found","wp-marketing-automations"),extraSectionBeforefilterCol:0===ne?ke:Object(r.createElement)(r.Fragment,null)}),Object(r.createElement)(N.a,{modalTitle:G.modalTitle,deleteEntityName:G.deleteEntityName,confirmText:G.confirmText,confirmButtonText:G.buttonConfirm,cancelButtonText:G.buttonCancel,onConfirm:G.onConfirm,isLoading:G.loading,successMessage:G.success,errorMessage:G.error,content:G.content,confirmDescription:G.hasOwnProperty("confirmDescription")?G.confirmDescription:"",onRequestClose:function(){return z({status:!1})},isOpen:G.status,isDelete:G.isDelete}),Object(r.createElement)(Ae,{tasks:yt,isOpen:Ot,onSuccess:function(){m(Ft,a,Pt,At,c),kt()},onError:kt,onRequestClose:function(){return wt(!1)},screenType:"automations",actionType:Et})):Object(r.createElement)(r.Fragment,null,Object(r.createElement)("div",{className:"bwf-content-header-new"},Object(r.createElement)("div",{className:"bwf-content-header-left"},Object(r.createElement)("div",{className:"bwf-content-header-title"},Object(o.__)("Automations","wp-marketing-automations")))),Object(r.createElement)(et.a,{data:Oe})),ht&&Object(r.createElement)(Wt,{onRequestClose:function(){return bt(!1)},isV2:!0}),!Object(d.ac)()&&Object(r.createElement)(Se.b,{isOpen:V.status,onRequestClose:function(){return H({status:!1})},modalContent:V}))};n(1398),e.default=function(t){var e=t.match.params.type,n=void 0===e?"all":e,o=t.automationV2,i=void 0!==o&&o,c=Object(F.i)();return Object(d.m)("Automations"),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(a.a,null),Object(r.createElement)("div",{className:"bwfcrm-automations-list"},i?Object(r.createElement)(Ue,{query:c,type:n,automationV2:i}):Object(r.createElement)(Oe,{query:c,type:n,automationV2:i})))}}}]);