diff --git a/build/Automation_Rules/assets/js/automation-rule-editor.asset.php b/build/Automation_Rules/assets/js/automation-rule-editor.asset.php index dd0c11ec..b3a7737f 100644 --- a/build/Automation_Rules/assets/js/automation-rule-editor.asset.php +++ b/build/Automation_Rules/assets/js/automation-rule-editor.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'c057b652847479aa5766'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'cde8f424b90c1f8038c9'); diff --git a/build/Automation_Rules/assets/js/automation-rule-editor.js b/build/Automation_Rules/assets/js/automation-rule-editor.js index 48683778..b4b7ce26 100644 --- a/build/Automation_Rules/assets/js/automation-rule-editor.js +++ b/build/Automation_Rules/assets/js/automation-rule-editor.js @@ -42,4 +42,4 @@ `,Pt=vt.div` direction: ltr; display: flex; -`,$t=({value:e,onChange:t,...n})=>{const{baseControlProps:a,controlProps:o}=(0,l.useBaseControlProps)(n),s=e?e.split(":"):["07","00"],[c,u]=(0,r.useState)(s[0]),[p,m]=(0,r.useState)(s[1]),d=(e,t="00")=>(e=Number(e),isNaN(e)?t:e<10?`0${e}`:e),f=`${d(c)}:${d(p)}`;return(0,r.useEffect)((()=>{e!==f&&t(f)}),[f]),(0,r.createElement)(l.BaseControl,{...a},(0,r.createElement)(l.__experimentalHStack,null,(0,r.createElement)(Pt,null,(0,r.createElement)(At,{value:d(c),onChange:u,min:0,max:23,step:1,...o,label:(0,i.__)("Hours"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Et(2)}),(0,r.createElement)(Ct,{"aria-hidden":"true"},":"),(0,r.createElement)(Tt,{value:d(p),onChange:m,min:0,max:59,step:1,label:(0,i.__)("Minutes"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Et(2)})),(0,r.createElement)(kt,null)))},Mt=[{label:(0,i.__)("Only run if","newsletter-optin-box"),value:"allow"},{label:(0,i.__)("Do not run if","newsletter-optin-box"),value:"prevent"}],Ot=[{label:(0,i.__)("all","newsletter-optin-box"),value:"all"},{label:(0,i.__)("any","newsletter-optin-box"),value:"any"}];function Nt(e,t){return(0,j.useMemo)((()=>[{label:t,value:"",disabled:!0},...e]),[e,t])}function Bt({type:e,action:t,ruleCount:n,setConditionalLogicAttribute:a}){const o=n>1;return(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start",wrap:!0},(0,r.createElement)(l.SelectControl,{label:(0,i.__)("If","newsletter-optin-box"),hideLabelFromVision:!0,value:t||"allow",options:Mt,onChange:e=>a("action",e),size:"default",__nextHasNoMarginBottom:!0}),o&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.SelectControl,{label:(0,i.__)("all","newsletter-optin-box"),hideLabelFromVision:!0,value:e||"all",options:Ot,onChange:e=>a("type",e),size:"default",__nextHasNoMarginBottom:!0}),(0,r.createElement)(l.__experimentalText,null,(0,i.__)("of the following rules are true:","newsletter-optin-box"))))}function Rt({rule:e,comparisons:t,availableSmartTags:n,mergeTagsArray:a,index:o,updateRule:s,removeRule:c}){var u;const p=(0,j.useCallback)((e=>s(o,"full",e)),[o,s]),m=(0,j.useCallback)((e=>s(o,"value",e)),[o,s]),d=(0,j.useCallback)((e=>s(o,"condition",e)),[o,s]),f=(0,j.useCallback)((()=>c(o)),[o,c]),g=null!==(u=e.full)&&void 0!==u?u:e.type?`[[${e.type}]]`:"",_=g.indexOf("]]"),b=g.indexOf("[[",_),y=-1===_||-1!==b&&b>_,h=qt({availableSmartTags:a,onMergeTagClick:(0,j.useCallback)((e=>{p(g?`${g} ${e}`.trim():e)}),[g,p])}),v=(0,j.useMemo)((()=>{const t=e.type;if(void 0!==n[t])return n[t];const r=t.replace("_",".",1);if(void 0!==n[r])return n[r];for(const[e,r]of Object.entries(n)){if(-1!==e.indexOf(".")&&e.split(".").slice(1).join(".")===t)return r;const n=e=>Array.isArray(e)?e:e.split(/[\s,]+/);if(r.deprecated&&n(r.deprecated).includes(t))return r}return null}),[e.type,n]),x=Nt((E=v?.options,(0,j.useMemo)((()=>E?Array.isArray(E)?E.map(((e,t)=>({label:e,value:t}))):Object.keys(E).map((e=>({label:E[e],value:e}))):[]),[E])),(0,i.__)("Select a value","newsletter-optin-box"));var E;const w=!y&&x.length>1,k=y?"string":v?.conditional_logic||"string",C=Nt((0,j.useMemo)((()=>{const e=[];return Object.keys(t).forEach((n=>{let r=t[n].type;if(w){if("string"===k&&"is"!=n&&"is_not"!=n)return;if("is_empty"===n||"is_not_empty"===n||"is_between"===n)return}"any"!==r&&r!=k||e.push({label:t[n].name,value:n})})),e}),[k,t]),(0,i.__)("Select a comparison","newsletter-optin-box")),S="is_empty"===e.condition||"is_not_empty"===e.condition;return(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start",wrap:!0,expanded:!0},(0,r.createElement)("div",{style:{minWidth:320}},(0,r.createElement)(l.__experimentalInputControl,{placeholder:(0,i.__)("Enter a smart tag","newsletter-optin-box"),value:g,onChange:p,autoComplete:"off",suffix:h,__next40pxDefaultSize:!0,isPressEnterToChange:!0})),(0,r.createElement)("div",{style:{width:150}},(0,r.createElement)(l.SelectControl,{label:(0,i.__)("Comparison","newsletter-optin-box"),hideLabelFromVision:!0,value:e.condition?e.condition:"is",options:C,onChange:d,size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0})),!S&&(0,r.createElement)("div",{style:{minWidth:320}},w&&(0,r.createElement)(l.SelectControl,{label:(0,i.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",options:x,onChange:m,size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),!w&&(0,r.createElement)(l.__experimentalInputControl,{type:"number"===k?"number":"text",label:(0,i.__)("Value","newsletter-optin-box"),placeholder:(0,i.__)("Enter a value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",onChange:m,__next40pxDefaultSize:!0})),(0,r.createElement)(l.Button,{onClick:f,icon:"trash",variant:"tertiary",isDestructive:!0}))}function zt({rules:e,comparisons:t,availableSmartTags:n,setConditionalLogicAttribute:a,disableTags:o,closeModal:s}){const c=(0,j.useMemo)((()=>Array.isArray(e)?e.filter((e=>e.type&&""!==e.type)):[]),[e]),u=(0,j.useMemo)((()=>{const e={};return n.forEach((t=>{t.conditional_logic&&(e[t.smart_tag]={...t,key:t.smart_tag,type:t.conditional_logic,isPremium:Array.isArray(o)&&o.some((e=>t.smart_tag.startsWith(e)))})})),e}),[n]),p=(0,j.useCallback)((e=>{const t=[...c];t.splice(e,1),a("rules",t)}),[c,a]),m=(0,j.useCallback)(((e,t,n)=>{const r=[...c];r[e][t]=n,a("rules",r)}),[c,a]),d=(0,j.useMemo)((()=>Object.values(u)),[u]),f=(0,j.useCallback)(((e,t)=>{const n=u[e],r=n?.options||[],o=n?.placeholder||"";let l=Array.isArray(r)&&r.length?Object.keys(r)[0]:o;n?.default&&(l=n.default);const i=[...c];i.push({type:e,condition:"is",full:t,value:l}),a("rules",i)}),[c]),g=0===c.length?(0,i.__)("Add a conditional logic rule","newsletter-optin-box"):(0,i.__)("Add another rule","newsletter-optin-box"),_=qt({availableSmartTags:d,onMergeTagClick:f,raw:!0,icon:"plus",label:g,text:g,toggleProps:{variant:"primary"}});return(0,r.createElement)(r.Fragment,null,c.map(((e,n)=>(0,r.createElement)(Rt,{key:n,rule:e,index:n,updateRule:m,removeRule:p,comparisons:t,availableSmartTags:u,mergeTagsArray:d}))),(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start",wrap:!0},_,s&&(0,r.createElement)(l.Button,{onClick:s,variant:"secondary"},(0,i.__)("Return to editor","newsletter-optin-box"))))}function jt({onChange:e,value:t,comparisons:n,toggleText:a,availableSmartTags:o,className:s,inModal:c=!1,disableTags:u=[]}){const[p,m]=(0,j.useState)(!1);"object"!=typeof t&&(t={enabled:!1,action:"allow",rules:[{condition:"is",type:"date",value:""}],type:"all"});const d=(n,r)=>{e({...t,[n]:r})},f=(0,r.createElement)(l.__experimentalVStack,{spacing:5},(0,r.createElement)(Bt,{ruleCount:Array.isArray(t.rules)?t.rules.length:0,type:t.type,action:t.action,setConditionalLogicAttribute:d}),(0,r.createElement)(zt,{rules:t.rules,comparisons:n,availableSmartTags:o,setConditionalLogicAttribute:d,closeModal:c&&(()=>m(!1)),disableTags:u}));return(0,r.createElement)(l.__experimentalVStack,{spacing:5,className:s},(0,r.createElement)(l.ToggleControl,{checked:!!t.enabled,onChange:e=>d("enabled",e),label:a||(0,i.__)("Optionally enable/disable this trigger depending on specific conditions.","newsletter-optin-box"),__nextHasNoMarginBottom:!0}),t.enabled&&(0,r.createElement)(r.Fragment,null,c?(0,r.createElement)(r.Fragment,null,p&&(0,r.createElement)(l.Modal,{title:(0,i.__)("Conditional Logic","newsletter-optin-box"),onRequestClose:()=>m(!1),isFullScreen:!0},f),(0,r.createElement)(l.Button,{variant:"secondary",className:"noptin-block-button",onClick:()=>m(!0)},(0,i.__)("Edit Conditional Logic","newsletter-optin-box"))):(0,r.createElement)(r.Fragment,null,f)))}const It={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>ee<=t,includes:(e,t)=>e.includes(t),"!includes":(e,t)=>!e.includes(t),empty:e=>!e,"!empty":e=>e},Ft=(e,t,n)=>!!It[t]&&It[t](e,n),Dt=["number","search","email","password","tel","url","date"];function Lt({setting:e,availableSmartTags:t,isPressEnterToChange:n,...a}){void 0===n&&(n=!0);const o=qt({availableSmartTags:t,onMergeTagClick:(0,r.useCallback)((e=>{a.onChange&&a.onChange(a.value?`${a.value} ${e}`.trim():e)}),[a.value,a.onChange])});return"string"==typeof a.suffix||a.suffix instanceof String?a.suffix=(0,r.createElement)(l.__experimentalInputControlSuffixWrapper,null,a.suffix):o&&!a.suffix&&(a.suffix=o),e.disabled&&(a.readOnly=!0,a.onFocus=e=>e.target.select()),("string"==typeof a.prefix||a.prefix instanceof String)&&(a.prefix=(0,r.createElement)(l.__experimentalInputControlPrefixWrapper,null,a.prefix)),(0,r.createElement)(l.__experimentalInputControl,{...a,type:Dt.includes(e.type)?e.type:"text",placeholder:e.placeholder?e.placeholder:"",isPressEnterToChange:n,__next40pxDefaultSize:!0})}function Ht({value:e,onChange:t,...n}){const{baseControlProps:a,controlProps:o}=(0,l.useBaseControlProps)({...n});return(0,r.createElement)(l.BaseControl,{...a},(0,r.createElement)(l.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:t,onToggle:n})=>(0,r.createElement)(l.Button,{onClick:n,"aria-expanded":t},(0,r.createElement)(l.ColorIndicator,{colorValue:e})),renderContent:()=>(0,r.createElement)(l.ColorPicker,{color:e,onChange:t}),...o}))}function Vt({availableSmartTags:e,autoGrow:t=!1,label:n,id:a,...o}){const i=qt({availableSmartTags:e,onMergeTagClick:(0,r.useCallback)((e=>{o.onChange&&o.onChange(o.value?`${o.value} ${e}`.trim():e)}),[o.value,o.onChange]),toggleProps:{size:"small"}}),s=i?(0,r.createElement)(l.__experimentalHStack,null,(0,r.createElement)("span",null,n),i):n,c=a||(0,F.useInstanceId)(Vt,"noptin-textarea");return(0,r.useEffect)((()=>{if(t){const e=document.getElementById(c);e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}}),[o.value,t,c]),(0,r.createElement)(l.TextareaControl,{...o,id:c,label:s,__nextHasNoMarginBottom:!0})}function Ut({options:e,...t}){const[n,a]=(0,r.useState)(e);return(0,r.createElement)(l.ComboboxControl,{...t,options:n,onFilterValueChange:t=>{a(t?e.filter((e=>!e.disabled&&""!==e.value&&(e.search?e.search.toLowerCase():e.label.toLowerCase()).includes(t.toLowerCase()))):e)},__experimentalRenderItem:({item:e,...t})=>e.render?"string"==typeof e.render?(0,r.createElement)("div",{...t,dangerouslySetInnerHTML:{__html:e.render}}):e.render:e.label,autocomplete:"off"})}function Wt({options:e,value:t,onChange:n,...a}){const o=Array.isArray(t)?t:[],i=(0,r.useMemo)((()=>e.map((e=>e.label))),[e]),s=(0,r.useCallback)((e=>i.includes(e)),[i]),c=(0,r.useMemo)((()=>o.map((t=>{const n=e.find((e=>e.value===t));return n?n.label:t}))),[t,e]),u=(0,r.useCallback)((t=>{const r=new Set;for(const n of t){const t=e.find((e=>e.label===n));t&&r.add(t.value)}n(Array.from(r))}),[n,e]),p=(0,r.useCallback)((t=>{const n=e.find((e=>e.label===t.item));return n&&n.render?(0,r.createElement)(j.RawHTML,null,n.render):(0,r.createElement)(r.Fragment,null,t.item)}),[e]);return(0,r.createElement)(l.FormTokenField,{value:c,suggestions:i,onChange:u,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalValidateInput:s,__experimentalRenderItem:p,...a})}const Gt=[{id:"key",label:(0,i.__)("Key","noptin-addons-pack"),type:"text"},{id:"value",label:(0,i.__)("Value","noptin-addons-pack"),type:"text"}];function qt({availableSmartTags:e=[],onMergeTagClick:t=((e,t)=>{}),raw:n=!1,icon:a="shortcode",label:o=(0,i.__)("Insert merge tag","newsletter-optin-box"),...s}){const c=function(e){return(0,r.useMemo)((()=>{if(!Array.isArray(e))return{};const t={};return e.forEach((e=>{const n=e.group?e.group:(0,i.__)("General","newsletter-optin-box");Array.isArray(t[n])||(t[n]=[]),t[n].push(e)})),t}),[e])}(e),u=Object.keys(c).length;let p=null;return u>0&&(p=(0,r.createElement)(l.DropdownMenu,{icon:a,label:o,...s},(({onClose:e})=>(0,r.createElement)(r.Fragment,null,Object.keys(c).map(((a,o)=>(0,r.createElement)(l.MenuGroup,{label:u>1?a:void 0,key:o},c[a].map((a=>(0,r.createElement)(l.MenuItem,{icon:a.isPremium?x:a.icon||G,iconPosition:"left",disabled:a.isPremium,onClick:()=>{if(!a.isPremium){if(t){const e=n?a.smart_tag:`[[${Kt(a)}]]`;t(e,`[[${Kt(a)}]]`)}e()}},key:a.smart_tag},(0,r.createElement)(j.RawHTML,null,a.isPremium?`${a.label} - Premium`:a.label))))))))))),p}function Kt(e){return e.example?e.example:e.default?`${e.smart_tag} default="${e.default}"`:`${e.smart_tag}`}function Qt({availableSmartTags:e,value:t,onChange:n,button:a,fields:o,openModal:s,prepend:c,disable:u,disabled:p,onDisable:m,cardProps:d,repeaterKey:f,id:g,defaultItem:_,...b}){const[y,h]=(0,r.useState)(!1),v=Array.isArray(t)?t:[],x=g||(0,F.useInstanceId)(Qt,"noptin-repeater"),{baseControlProps:E,controlProps:w}=(0,l.useBaseControlProps)({...b,id:x}),k=_||{};if(f?.newOnly&&(k.new=!0),!o)return console.warn("No fields provided to repeater control."),null;Object.keys(o).forEach((e=>{void 0!==o[e].default&&(k[e]=o[e].default)}));const C=!!s,S=(0,r.createElement)(l.__experimentalVStack,null,c,v.map(((a,i)=>(0,r.createElement)(l.Card,{size:"small",className:"noptin-no-shadow",id:`${x}__item-${i}`,"data-index":i,borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0,...d||{},key:f?.to&&t[f.to]?t[f.to]:i},(0,r.createElement)(Xt,{id:`${x}__item-${i}`,fields:o,value:a,availableSmartTags:e,onChange:e=>{if(f?.to&&f.from&&e[f.from]&&(!f.newOnly||e.new)){const t=e[f.from].toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");e[f.to]=t.substring(0,f.maxLength||64),v.find(((t,n)=>i!==n&&t[f.to]===e[f.to]))&&(e[f.to]=`${e[f.to]}_${i}`)}const t=[...v];t[i]=e,n(t)},onDelete:()=>{const e=[...v];e.splice(i,1),n(e)},onMoveUp:i>0?()=>{const e=[...v],t=e[i];e.splice(i,1),e.splice(i-1,0,t),n(e)}:null,onMoveDown:i{const e=[...v],t=e[i];e.splice(i,1),e.splice(i+1,0,t),n(e)}:null,repeaterKey:f})))),(0,r.createElement)(l.__experimentalHStack,null,(0,r.createElement)(l.Button,{onClick:()=>{const e=[...v];e.push(k),n(e)},variant:"primary"},a||(0,i.__)("Add Item","newsletter-optin-box")),C&&(0,r.createElement)(l.Button,{onClick:()=>h(!1),variant:"secondary"},(0,i.__)("Go Back","newsletter-optin-box")))),A=!u||!p;return(0,r.createElement)(l.BaseControl,{...E},(0,r.createElement)("div",{...w},C&&(0,r.createElement)(l.__experimentalVStack,null,u&&(0,r.createElement)(l.ToggleControl,{label:u,checked:p,onChange:e=>{m&&m(e)}}),A&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.Button,{onClick:()=>h(!0),variant:"secondary"},s||(0,i.__)("Set Items","newsletter-optin-box")),y&&(0,r.createElement)(l.Modal,{title:b.label||s||(0,i.__)("Set Items","newsletter-optin-box"),onRequestClose:()=>h(!1),size:"medium"},S))),!C&&S))}function Xt({fields:e,availableSmartTags:t,value:n,onChange:a,repeaterKey:o,onDelete:s,onMoveUp:c,onMoveDown:u,id:p}){const[m,d]=(0,r.useState)(!o?.from),f=(0,r.useCallback)((()=>{d(!m)}),[m]),g=!m&&o?.from;let _=null;if(o){const e=o.to&&n?.[o.to]?(0,r.createElement)("code",null,(0,i.sprintf)(o.display||"%s",n?.[o.to])):null,t={paddingLeft:16,paddingRight:16,height:48};_=(0,r.createElement)(l.CardHeader,{style:{padding:0}},(0,r.createElement)(l.Flex,{as:l.Button,onClick:f,style:t,"aria-controls":`${p}__body`,"aria-expanded":!g,type:"button"},(0,r.createElement)(l.__experimentalHStack,{as:l.FlexBlock},(0,r.createElement)(l.__experimentalText,{as:"h3",weight:600},n?.[o.from]||(0,i.__)("(new)","newsletter-optin-box"))),(0,r.createElement)(l.FlexItem,null,(0,r.createElement)(l.__experimentalHStack,null,e,(0,r.createElement)(l.Icon,{icon:m?"arrow-up-alt2":"arrow-down-alt2"})))))}return(0,r.createElement)(r.Fragment,null,_,!g&&(0,r.createElement)(l.CardBody,{id:`${p}__body`,hidden:g},(0,r.createElement)(l.__experimentalVStack,null,Object.keys(e).map((o=>(0,r.createElement)(rn,{key:o,settingKey:o,availableSmartTags:t,setting:e[o],saved:n,setAttributes:e=>{a({...n,...e})}}))),(0,r.createElement)(l.__experimentalHStack,{className:"noptin-repeater-item__actions",justify:"flex-start"},!n?.predefined&&(0,r.createElement)(l.Button,{variant:"link",onClick:s,text:(0,i.__)("Remove Item","newsletter-optin-box"),isDestructive:!0}),c&&(0,r.createElement)(l.Button,{onClick:c,icon:"arrow-up-alt",text:(0,i.__)("Move Up","newsletter-optin-box"),size:"small",iconSize:16}),u&&(0,r.createElement)(l.Button,{onClick:u,icon:"arrow-down-alt",text:(0,i.__)("Move Down","newsletter-optin-box"),size:"small",iconSize:16})))))}function Yt({setting:e,availableSmartTags:t,value:n,onChange:a,...o}){const{baseControlProps:s,controlProps:c}=(0,l.useBaseControlProps)(o);Array.isArray(n)||(n=[]);const u=(0,r.useCallback)((({item:e,index:o})=>(0,r.createElement)(l.Flex,{className:"noptin-repeater-item",wrap:!0},Gt.map(((l,i)=>(0,r.createElement)(Jt,{key:i,availableSmartTags:t,field:l,value:void 0===e[l.id]?"":e[l.id],onChange:e=>{const t=[...n];t[o][l.id]=e,a(t)}}))),(0,r.createElement)(l.FlexItem,null,(0,r.createElement)(l.Button,{icon:"trash",variant:"tertiary",className:"noptin-component__field",label:(0,i.__)("Delete","noptin-addons-pack"),showTooltip:!0,onClick:()=>{const e=[...n];e.splice(o,1),a(e)},isDestructive:!0})))),[n,a]);return(0,r.createElement)(l.BaseControl,{...s},(0,r.createElement)("div",{...c},n.map(((e,t)=>(0,r.createElement)(u,{key:t,item:e,index:t}))),(0,r.createElement)(l.Button,{onClick:()=>{const e=[...n];e.push({}),a(e)},variant:"secondary"},e.add_field?e.add_field:(0,i.__)("Add","newsletter-optin-box"))))}function Jt({field:e,availableSmartTags:t,value:n,onChange:a}){const o=qt({availableSmartTags:t,onMergeTagClick:(0,r.useCallback)((e=>{a&&a(n?`${n} ${e}`.trim():e)}),[n,a])});return(0,r.createElement)(l.FlexBlock,null,(0,r.createElement)(l.__experimentalInputControl,{label:e.label,type:e.type,value:n,placeholder:(0,i.sprintf)((0,i.__)("Enter %s","noptin-addons-pack"),e.label),className:"noptin-component__field noptin-condition-field",suffix:o,onChange:a,isPressEnterToChange:!0,__next40pxDefaultSize:!0}))}function Zt({setting:e,value:t,options:n,onChange:a,...o}){const{baseControlProps:i,controlProps:s}=(0,l.useBaseControlProps)(o);return Array.isArray(t)||(t=[]),(0,r.createElement)(l.BaseControl,{...i},(0,r.createElement)("div",{...s},n.map(((e,n)=>(0,r.createElement)(l.CheckboxControl,{key:n,label:e.label,checked:t.includes(e.value),onChange:n=>{a(n?[...t,e.value]:t.filter((t=>t!==e.value)))}})))))}function en({value:e,onChange:t,id:n,...a}){const{baseControlProps:o,controlProps:i}=(0,l.useBaseControlProps)({...a,id:n,__nextHasNoMarginBottom:!0}),{wp:s,tinymce:c}=window,u=(0,r.useRef)(!1),p=(0,r.useRef)(null);return(0,r.useEffect)((()=>{if(!u.current)return;const t=t=>{t?.target?.classList?.contains("wp-switch-editor")&&setTimeout((()=>{const t=c?.get(n);t&&(t.setContent(e||""),t._lastChange=e)}),50)};return p.current?.addEventListener("click",t),()=>{p.current?.removeEventListener("click",t)}}),[p.current,e]),(0,r.useEffect)((()=>{if(!u.current)return;const e=c?.get(n);e&&e._lastChange}),[e]),(0,r.useEffect)((()=>{function r(){s.oldEditor.initialize(n,{tinymce:!!window.tinymce&&{content_css:!1,theme_advanced_buttons:"bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect",drag_drop_upload:!0,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,dfw",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",min_height:400,wpautop:!1,setup(n){e&&n.on("loadContent",(()=>n.setContent(e))),n.on("blur",(()=>(t(n.getContent()),!1)));const r=(0,F.debounce)((()=>{const e=n.getContent();e!==n._lastChange&&(n._lastChange=e,t(e))}),250);n.on("Paste Change input Undo Redo",r),n.on("remove",r.cancel),n.on("keydown",(e=>{q.isKeyboardEvent.primary(e,"z")&&e.stopPropagation(),q.isKeyboardEvent.primary(e,"s")&&r.flush();const{altKey:t}=e;t&&e.keyCode===q.F10&&e.stopPropagation()})),u.current=!0},...window?.tinyMCEPreInit?.mceInit[n]||{}},mediaButtons:!0,quicktags:{buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,close"}})}function a(){"complete"===document.readyState&&r()}return c?.execCommand("mceRemoveEditor",!0,n),"complete"===document.readyState?r():document.addEventListener("readystatechange",a),()=>{document.removeEventListener("readystatechange",a),s.oldEditor.remove(n)}}),[]),(0,r.createElement)(l.BaseControl,{...o},(0,r.createElement)("div",{ref:p},(0,r.createElement)("textarea",{...i,className:"wp-editor-area",style:{width:"100%"},value:e,onChange:e=>t(e.target.value),rows:10})))}const tn=(e,t)=>{if(0===t.length||!e||"object"!=typeof e)return;const[n,...r]=t;return 0===r.length?e[n]:tn(e[n],r)},nn=(e,t,n)=>{if(0===t.length)return e;const[r,...a]=t;return 0===a.length?{...e,[r]:n}:{...e,[r]:nn(e[r]||{},a,n)}};function rn({settingKey:e,setting:t,availableSmartTags:n,prop:a,saved:o,setAttributes:s}){const c=(a?`${a}.${e}`:e).split("."),u=t.sanitize?t.sanitize:e=>e,p=(0,r.useCallback)((e=>{if(tn(o,c)===e)return;const[t,...n]=c;return 0===n.length?s(u({[t]:e})):s(u({[t]:nn(o[t]||{},n,e)}))}),[o,c,s,u]);if(t.if||t.restrict){const e=t.restrict?t.restrict.split("."):t.if.split(".");if(!tn(o,e))return null}if(Array.isArray(t.conditions)&&!t.conditions.every((e=>{const t=e.key.split("."),n=e.operator?e.operator:"==";return Ft(e.value,n,tn(o,t))})))return null;if(t.condition&&!t.condition(o))return null;let m=tn(o,c);(void 0===m||t.disabled)&&(m=t.default);const d=void 0!==m&&""!==m&&null!==m;let f=[];t.options&&(f=Array.isArray(t.options)?[...t.options]:Object.keys(t.options).map((e=>({label:t.options?.[e],value:e}))));const g=`noptin-component__field-${e}`,_="string"==typeof t.description?(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:t.description}}):t.description,b=t.customAttributes?t.customAttributes:{},y={label:t.label,value:d?m:"",onChange:p,className:g,help:_,...b};if(t.tooltip&&(y.label=(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start"},(0,r.createElement)("span",null,t.label),(0,r.createElement)(l.Tooltip,{delay:0,placement:"top",text:t.tooltip},(0,r.createElement)("span",null,(0,r.createElement)(l.Icon,{icon:"info",style:{color:"#454545"}}))))),t.type&&!t.el&&(t.el=t.type,["toggle","switch","checkbox","checkbox_alt","text","number","email","tel","date","color","image"].includes(t.type)&&(t.el="input")),"button"===t.el)return(0,r.createElement)("div",null,(0,r.createElement)(l.Button,{...t.buttonProps||{}}));if("select"===t.el)return t.multiple?(0,r.createElement)(Wt,{...y,options:f}):(f.find((e=>""===e?.value))||f.unshift({label:t.placeholder?t.placeholder:(0,i.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,r.createElement)(l.SelectControl,{...y,options:f,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}));if("combobox"===t.el)return f.unshift({label:t.placeholder?t.placeholder:(0,i.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,r.createElement)(Ut,{...y,options:f,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0});if("form_token"===t.el||"token"===t.el)return(0,r.createElement)(l.FormTokenField,{...y,value:Array.isArray(y.value)?y.value:[],suggestions:Array.isArray(t.suggestions)?t.suggestions:[],__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,tokenizeOnBlur:!0});if("multi_checkbox"===t.el||"multi_checkbox_alt"===t.el)return(0,r.createElement)(Zt,{...y,options:f});if("conditional_logic"===t.el)return(0,r.createElement)(jt,{...y,availableSmartTags:n,comparisons:t.comparisons,toggleText:t.toggle_text,inModal:t.in_modal});if("time"===t.el)return(0,r.createElement)($t,{...y});if("color"===t.el)return(0,r.createElement)(Ht,{...y});if("input"===t.el){if(t.type&&["toggle","switch","checkbox","checkbox_alt"].includes(t.type))return(0,r.createElement)(l.ToggleControl,{...y,checked:!!d&&m});if("number"===t.type){const e=e=>{if(e)return"string"==typeof e||e instanceof String?(0,r.createElement)(l.__experimentalInputControlSuffixWrapper,null,e):e},n=e=>{if(e)return"string"==typeof e||e instanceof String?(0,r.createElement)(l.__experimentalInputControlPrefixWrapper,null,e):e};return Array.isArray(y.suffix)?y.suffix=e(1===m||"1"===m?y.suffix[0]:y.suffix[1]):y.suffix=e(y.suffix),Array.isArray(y.prefix)?y.prefix=n(1===m||"1"===m?y.prefix[0]:y.prefix[1]):y.prefix=n(y.prefix),(0,r.createElement)(l.__experimentalNumberControl,{...y,placeholder:t.placeholder?t.placeholder:"",__next40pxDefaultSize:!0})}return"image"===t.type&&(y.suffix=(0,r.createElement)(l.Button,{onClick:()=>{var e=window.wp.media({title:(0,i.__)("Upload Image","newsletter-optin-box"),multiple:!1,library:{type:"image"}}).open().on("select",(t=>{let n=e.state().get("selection").first();p(n.toJSON().sizes.full.url)}))},icon:"upload",label:(0,i.__)("Upload Image","newsletter-optin-box"),showTooltip:!0})),(0,r.createElement)(Lt,{...y,setting:t,availableSmartTags:"trigger_settings"===a?[]:n,isPressEnterToChange:!t.isInputToChange})}return"textarea"===t.el?(0,r.createElement)(Vt,{...y,placeholder:t.placeholder?t.placeholder:"",availableSmartTags:"trigger_settings"===a?[]:n}):"tinymce"===t.el?(0,r.createElement)(en,{...y}):"paragraph"===t.el?(0,r.createElement)("div",{className:g},(0,r.createElement)(l.Tip,null,t.raw?(0,r.createElement)(j.RawHTML,null,t.content):t.content)):"hero"===t.el?(0,r.createElement)("div",{className:g},(0,r.createElement)("h3",null,t.content)):"key_value_repeater"===t.el||"webhook_key_value_repeater"===t.el?(0,r.createElement)(Yt,{...y,setting:t,availableSmartTags:"trigger_settings"===a?[]:n}):"repeater"===t.el?(0,r.createElement)(Qt,{...y,availableSmartTags:"trigger_settings"===a?[]:n}):e}const an=(0,r.createContext)([]),on=()=>(0,r.useContext)(an),ln=({children:e})=>{const{automationRule:{trigger_settings:t,smartTags:n}}=_(),a=(0,r.useMemo)((()=>function(e,t){const n=[];return e?(Object.keys(e).forEach((r=>{const a=e[r];if(a.hidden)return;if(a.conditions&&!a.conditions.every((e=>{let n=!1;return n=Array.isArray(e.value)?e.value.some((n=>n==t[e.key])):e.value==t[e.key],n===("is"===e.operator)})))return;let o=r;a.label?o=a.label:a.description&&(o=a.description),n.push({...a,smart_tag:r,label:o,example:a.example?a.example:"",description:a.description?a.description:"",placeholder:a.placeholder?a.placeholder:"",conditional_logic:!!a.conditional_logic&&a.conditional_logic,options:a.options?a.options:[]})})),n):n}(n,t||{})),[n,t]);return(0,r.createElement)(an.Provider,{value:a},e)};function sn({sectionKey:e,label:t,prop:n,settings:a}){const o=on(),i=Object.keys(a);if(!i.length)return null;const{automationRule:s,setAttributes:c}=_();return(0,r.createElement)(W,null,(0,r.createElement)(u,{title:t,className:`noptin-automation-rule-editor__section noptin-automation-rule-editor__section-${e}`},(0,r.createElement)(l.__experimentalVStack,{spacing:5,as:l.CardBody},i.map((e=>(0,r.createElement)(rn,{key:e,settingKey:e,prop:n,availableSmartTags:o,saved:s,setAttributes:c,setting:a[e]}))))))}function cn(){const{error:e,success:t,resetMessages:n,automationRule:{settings:a}}=_(),o=(0,r.createElement)(r.Fragment,null,e&&(0,r.createElement)(l.Notice,{status:"error",onDismiss:n},e),t&&(0,r.createElement)(l.Notice,{status:"success",onDismiss:n},t));if(!a)return o;const i=Object.keys(a);return i.length?(0,r.createElement)(l.__experimentalVStack,{className:"noptin-automation-rule-editor__sections"},o,(0,r.createElement)(W,null,i.map((e=>(0,r.createElement)(sn,{key:e,sectionKey:e,...a[e]}))))):o}const un=window.noptinEmailSettingsMisc||{};function pn(e,t){const n={};Array.isArray(e)||Object.entries(e).forEach((([e,r])=>{if("email"!==e){if(!r.category){if(!un.isTest)return;r.category="Deprecated"}n[r.category]||(n[r.category]={}),n[r.category][e]={...r,selectText:"triggers"===t?(0,i.__)("Use trigger","newsletter-optin-box"):(0,i.__)("Set-up","newsletter-optin-box"),forcePremium:R(e,r.category)},r.alt_category&&(n[r.alt_category]||(n[r.alt_category]={}),n[r.alt_category][e]=n[r.category][e])}})),Array.isArray(un.integrations)&&un.integrations.forEach((r=>{r.plan&&"free"!==r.plan&&r[t]&&!Array.isArray(r[t])&&Object.entries(r[t]).forEach((([t,a])=>{a.forEach((({id:a,label:o,description:l,premium:i=!1})=>{if("premium"===r.plan||i)if(e[a]){const t=e[a].category;t&&n[t][a]&&(n[t][a].forcePremium=!0)}else n[t]||(n[t]={}),n[t][a]={name:a,label:o,description:l,category:t,image:r.icon_url,forcePremium:!0,is_installed:!1,installation:r.installation}}))}))}));const r={};return Object.keys(n).sort().forEach((e=>{r[e]=n[e]})),r}un.license;const mn={"noptin-trigger":{title:(0,i.__)("Select a trigger for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-trigger",cardGroups:pn(un.data?.triggers||{},"triggers")},"noptin-action":{title:(0,i.__)("Select an action for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-action",cardGroups:pn(un.data?.actions||{},"actions")}},dn=(0,r.createContext)(void 0),fn=({children:e})=>{const[t,n]=(0,r.useState)(un.data?.add_new||(0,E.addQueryArgs)(window.location.href,{noptin_edit_automation_rule:"0"})),a=(0,r.useMemo)((()=>{let e="";const r={};for(const[n,a]of Object.entries(mn)){const o=a.arg?(0,E.getQueryArg)(t,a.arg):"";if(!o){e=n;break}r[n]=o}return{currentTitle:mn[e]?.title||"",currentStep:e,isLastStep:e===Object.keys(mn).pop(),isFirstStep:e===Object.keys(mn)[0],hasSteps:Object.keys(mn).length>0,stepValues:r,steps:mn,campaign:"automation-rules",removeQueryArgs:(...e)=>{n((0,E.removeQueryArgs)(t,...e))},addQueryArg:(e,r)=>{n((0,E.addQueryArgs)(t,{[e]:r}))},withQueryArg:(e,n)=>(0,E.addQueryArgs)(t,{[e]:n}),url:t}}),[t,n]);return(0,r.createElement)(dn.Provider,{value:a},e)},gn=({categories:e,selectedCategory:t,onClickCategory:n})=>{const a="noptin-campaign-explorer__sidebar";return(0,r.createElement)("div",{className:a},(0,r.createElement)("div",{className:`${a}__categories-list`},e.map((e=>(0,r.createElement)(l.Button,{key:e,label:e,className:`${a}__categories-list__item`,isPressed:t===e,onClick:()=>{n(e)}},e)))))},bn=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,r.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,r.createElement)(l.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",n=e.path||"",a=e.viewBox||"0 0 24 24";return e.path?(0,r.createElement)(l.SVG,{viewBox:a,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,r.createElement)(l.Path,{fill:t,d:n})):(0,r.createElement)(l.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,r.createElement)(l.Icon,{size:24,icon:"email",style:{color:"#424242"}})},yn=({name:e,label:t,description:n,image:a,onSelect:o,hrefCallback:s,href:c,...u})=>{const p=(e=>{const t=e.learnMoreUrl?(0,r.createElement)(l.Button,{variant:"secondary",href:e.learnMoreUrl},(0,r.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,i.__)("Learn More"))," ",(0,r.createElement)(l.Icon,{size:16,icon:"arrow-right-alt"})):null;if(e.forcePremium?!1!==e.is_installed&&e?.licenseDetails?.key:!1!==e.is_installed)return{upgradeText:null,button:(0,r.createElement)(l.Button,{variant:"primary",onClick:e.onClick,href:e.href},(0,r.createElement)("span",{className:"noptin-selectable-card__label"},e.selectText||(0,i.__)("Select"))," ",(0,r.createElement)(l.Icon,{size:16,icon:"arrow-right-alt"})),secondaryButton:t};const n=(t,n)=>!1===e.is_installed&&e.installation?.[t]?e.installation?.[t]:e.licenseDetails[t]||n,a=n("install_desc",(0,i.__)("Activate your license key to unlock","newsletter-optin-box")),o=n("install_text",(0,i.__)("View Pricing","newsletter-optin-box")),s=n("install_url",(0,E.addQueryArgs)("https://noptin.com/pricing/",{utm_source:e.name||"license",utm_campaign:e.campaign||"noptin",utm_medium:"plugin-dashboard"}));return{upgradeText:a,button:(0,r.createElement)(l.Button,{variant:"primary",href:s},(0,r.createElement)("span",{className:"noptin-selectable-card-action__label"},o)," ",(0,r.createElement)(l.Icon,{size:16,icon:"lock"})),secondaryButton:e.licenseDetails?.key?t:(0,r.createElement)(l.Button,{variant:"secondary",href:e.licenseDetails?.activate_url},(0,r.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,i.__)("Activate"))," ",(0,r.createElement)(l.Icon,{size:16,icon:"unlock"}))}})({onClick:(0,r.useCallback)((()=>o?o(e):null),[e,o]),name:e.replace("automation_rule_",""),href:s?s(e):c,...u});return(0,r.createElement)(l.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,size:"small"},(0,r.createElement)(l.CardHeader,null,(0,r.createElement)(l.__experimentalHeading,{level:4,numberOfLines:1},t),(0,r.createElement)(bn,{image:a,title:t})),(0,r.createElement)(l.CardBody,null,(0,r.createElement)(l.__experimentalVStack,{spacing:4},n&&(0,r.createElement)(l.__experimentalText,{as:"p",variant:"muted"},n),p.upgradeText&&(0,r.createElement)(l.__experimentalText,{as:"em",isDestructive:!0},p.upgradeText))),(0,r.createElement)(l.CardFooter,{isBorderless:!0,justify:p.secondaryButton?"space-between":"flex-end"},p.secondaryButton,p.button),(0,r.createElement)(l.__experimentalElevation,{value:1,hover:3}))},hn=({showTitle:e,selectedCategory:t,cards:n,...a})=>{const o="noptin-campaign-explorer";return(0,r.createElement)("div",{className:`${o}__list`},e&&(0,r.createElement)(l.__experimentalHeading,{level:2,lineHeight:"48px",className:`${o}__category-name`},t),(0,r.createElement)("div",{role:"listbox",className:`${o}-list`},Object.keys(n).sort().map((e=>(0,r.createElement)(yn,{key:e,name:e,...a,...n[e]})))))},vn=({cardGroups:e,...t})=>{const n=Object.keys(e).length,[a,o]=(0,r.useState)(Object.keys(e)[0]);(0,r.useEffect)((()=>{n>0&&!e[a]&&o(Object.keys(e)[0])}),[e,a]);const l=n>1,i=(0,r.useMemo)((()=>Object.keys(e)),[e]),s=(0,r.useMemo)((()=>e[a]||{}),[e,a]),u=c()("noptin-campaign-explorer",{"noptin-campaign-explorer--show-sidebar":l});return(0,r.createElement)("div",{className:u},l&&(0,r.createElement)(gn,{selectedCategory:a,categories:i,onClickCategory:o}),(0,r.createElement)(hn,{showTitle:l,selectedCategory:a,cards:s,...t}))},xn=e=>{if(!e.isOpen)return null;const t=e.steps[e.currentStep];if(t.modal)return(0,r.createElement)(l.Modal,{onRequestClose:e.closeModal,...t.modal.props},t.modal.content);if(t.cardGroups){const n=[...Object.keys(e.stepValues)].pop(),a=(0,r.createElement)(r.Fragment,null,n&&!e.isFirstStep&&(0,r.createElement)(l.Button,{icon:"arrow-left-alt",onClick:()=>e.removeQueryArgs(e.steps[n]?.arg||""),label:(0,i.__)("Back","newsletter-optin-box"),showTooltip:!0})),o=e.isLastStep?void 0:n=>{t.arg&&e.addQueryArg(t.arg,n)};return(0,r.createElement)(l.Modal,{title:e.currentTitle,onRequestClose:e.closeModal,headerActions:a,isFullScreen:!0},(0,r.createElement)(vn,{cardGroups:t.cardGroups,licenseDetails:e.licenseDetails,onSelect:o,hrefCallback:t.arg&&e.isLastStep?n=>e.withQueryArg(t.arg,n):void 0,campaign:e.campaign}))}return null},En=({buttonProps:e,...t})=>{const[n,a]=(0,r.useState)(!1),o=(0,r.useCallback)((()=>{a(!0)}),[a]),i=(0,r.useCallback)((()=>{a(!1)}),[a]),s=t.currentStep&&t.hasSteps,c={...e,onClick:s?o:void 0,href:s?void 0:t.url};return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.Button,{...c}),(0,r.createElement)(xn,{isOpen:n,closeModal:i,...t}))},wn=({text:e})=>{const t=(()=>{const e=(0,r.useContext)(dn);if(!e)throw new Error("useModal must be used within a ModalProvider");return e})();return(0,r.createElement)(En,{licenseDetails:un.license||{},buttonProps:{variant:"primary",type:"button",text:e||(0,i.__)("Add New Automation","newsletter-optin-box")},...t})},kn=({text:e})=>(0,r.createElement)(fn,null,(0,r.createElement)(wn,{text:e})),Cn=({children:e})=>{const{automationRule:{trigger_id:t}}=_(),n=R(t,window.noptinEmailSettingsMisc?.triggers?.[t]?.category),[r,a]=A({heading:(0,i.__)("Unlock Premium Feature","newsletter-optin-box"),helpText:(0,i.__)("This automation trigger is only available to premium license holders.","newsletter-optin-box"),needsAddonsPack:!1,slug:"automation-rule-trigger-"+t});return!r&&n?a:e};function Sn(){const{automationRule:{id:e}}=_(),t=!!(e&&e>0);return(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start"},(0,r.createElement)(l.__experimentalText,{as:"h1",size:23,weight:500},t?(0,i.__)("Edit Automation Rule","newsletter-optin-box"):(0,i.__)("Add Automation Rule","newsletter-optin-box")),t&&(0,r.createElement)(kn,{text:(0,i.__)("Add New","newsletter-optin-box")}))}function An({automationRule:e}){return(0,r.createElement)("div",{className:"noptin-automation-rule__editor"},(0,r.createElement)(W,null,(0,r.createElement)(l.SlotFillProvider,null,(0,r.createElement)(b,{automationRule:e},(0,r.createElement)(Cn,null,(0,r.createElement)(ln,null,(0,r.createElement)(l.__experimentalVStack,{spacing:4},(0,r.createElement)(Sn,null),(0,r.createElement)(l.Flex,{wrap:!0,align:"top"},(0,r.createElement)(l.FlexBlock,{className:"noptin-es6-editor__main"},(0,r.createElement)(cn,null)),(0,r.createElement)(l.FlexItem,{className:"noptin-component-editor__sidebar"},(0,r.createElement)(l.__experimentalVStack,null,(0,r.createElement)(z,null),(0,r.createElement)(h,null)))))))))))}const Tn=e=>{const t=window.noptinEmailSettingsMisc?.data?.app||{};return(0,r.createElement)(j.StrictMode,null,(0,r.createElement)(W,null,(0,r.createElement)(An,{...e,...t})))};o()((()=>{((e,t)=>{if(t){const n=t.getAttribute("data-app"),a=n?JSON.parse(n):{};j.createRoot?(0,j.createRoot)(t).render((0,r.createElement)(e,{...a})):(0,j.render)((0,r.createElement)(e,{...a}),t)}})(Tn,document.getElementById("noptin-automation-rule__editor-app"))}))},146:(e,t,n)=>{"use strict";var r=n(404),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function s(e){return r.isMemo(e)?l:i[e.$$typeof]||a}i[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[r.Memo]=l;var c=Object.defineProperty,u=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,f=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(f){var a=d(n);a&&a!==f&&e(t,a,r)}var l=u(n);p&&(l=l.concat(p(n)));for(var i=s(t),g=s(n),_=0;_{"use strict";var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,a=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,l=n?Symbol.for("react.strict_mode"):60108,i=n?Symbol.for("react.profiler"):60114,s=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,p=n?Symbol.for("react.concurrent_mode"):60111,m=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,f=n?Symbol.for("react.suspense_list"):60120,g=n?Symbol.for("react.memo"):60115,_=n?Symbol.for("react.lazy"):60116,b=n?Symbol.for("react.block"):60121,y=n?Symbol.for("react.fundamental"):60117,h=n?Symbol.for("react.responder"):60118,v=n?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case u:case p:case o:case i:case l:case d:return e;default:switch(e=e&&e.$$typeof){case c:case m:case _:case g:case s:return e;default:return t}}case a:return t}}}function E(e){return x(e)===p}t.AsyncMode=u,t.ConcurrentMode=p,t.ContextConsumer=c,t.ContextProvider=s,t.Element=r,t.ForwardRef=m,t.Fragment=o,t.Lazy=_,t.Memo=g,t.Portal=a,t.Profiler=i,t.StrictMode=l,t.Suspense=d,t.isAsyncMode=function(e){return E(e)||x(e)===u},t.isConcurrentMode=E,t.isContextConsumer=function(e){return x(e)===c},t.isContextProvider=function(e){return x(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return x(e)===m},t.isFragment=function(e){return x(e)===o},t.isLazy=function(e){return x(e)===_},t.isMemo=function(e){return x(e)===g},t.isPortal=function(e){return x(e)===a},t.isProfiler=function(e){return x(e)===i},t.isStrictMode=function(e){return x(e)===l},t.isSuspense=function(e){return x(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===p||e===i||e===l||e===d||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===_||e.$$typeof===g||e.$$typeof===s||e.$$typeof===c||e.$$typeof===m||e.$$typeof===y||e.$$typeof===h||e.$$typeof===v||e.$$typeof===b)},t.typeOf=x},404:(e,t,n)=>{"use strict";e.exports=n(72)},942:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e="",t=0;t{if(!n){var l=1/0;for(u=0;u=o)&&Object.keys(r.O).every((e=>r.O[e](n[s])))?n.splice(s--,1):(i=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,a,o]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={180:0,856:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,[l,i,s]=n,c=0;if(l.some((t=>0!==e[t]))){for(a in i)r.o(i,a)&&(r.m[a]=i[a]);if(s)var u=s(r)}for(t&&t(n);cr(921)));a=r.O(a)})(); \ No newline at end of file +`,$t=({value:e,onChange:t,...n})=>{const{baseControlProps:a,controlProps:o}=(0,l.useBaseControlProps)(n),s=e?e.split(":"):["07","00"],[c,u]=(0,r.useState)(s[0]),[p,m]=(0,r.useState)(s[1]),d=(e,t="00")=>(e=Number(e),isNaN(e)?t:e<10?`0${e}`:e),f=`${d(c)}:${d(p)}`;return(0,r.useEffect)((()=>{e!==f&&t(f)}),[f]),(0,r.createElement)(l.BaseControl,{...a},(0,r.createElement)(l.__experimentalHStack,null,(0,r.createElement)(Pt,null,(0,r.createElement)(At,{value:d(c),onChange:u,min:0,max:23,step:1,...o,label:(0,i.__)("Hours"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Et(2)}),(0,r.createElement)(Ct,{"aria-hidden":"true"},":"),(0,r.createElement)(Tt,{value:d(p),onChange:m,min:0,max:59,step:1,label:(0,i.__)("Minutes"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Et(2)})),(0,r.createElement)(kt,null)))},Mt=[{label:(0,i.__)("Only run if","newsletter-optin-box"),value:"allow"},{label:(0,i.__)("Do not run if","newsletter-optin-box"),value:"prevent"}],Ot=[{label:(0,i.__)("all","newsletter-optin-box"),value:"all"},{label:(0,i.__)("any","newsletter-optin-box"),value:"any"}];function Nt(e,t){return(0,j.useMemo)((()=>[{label:t,value:"",disabled:!0},...e]),[e,t])}function Bt({type:e,action:t,ruleCount:n,setConditionalLogicAttribute:a}){const o=n>1;return(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start",wrap:!0},(0,r.createElement)(l.SelectControl,{label:(0,i.__)("If","newsletter-optin-box"),hideLabelFromVision:!0,value:t||"allow",options:Mt,onChange:e=>a("action",e),size:"default",__nextHasNoMarginBottom:!0}),o&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.SelectControl,{label:(0,i.__)("all","newsletter-optin-box"),hideLabelFromVision:!0,value:e||"all",options:Ot,onChange:e=>a("type",e),size:"default",__nextHasNoMarginBottom:!0}),(0,r.createElement)(l.__experimentalText,null,(0,i.__)("of the following rules are true:","newsletter-optin-box"))))}function Rt({rule:e,comparisons:t,availableSmartTags:n,mergeTagsArray:a,index:o,updateRule:s,removeRule:c}){var u;const p=(0,j.useCallback)((e=>s(o,"full",e)),[o,s]),m=(0,j.useCallback)((e=>s(o,"value",e)),[o,s]),d=(0,j.useCallback)((e=>s(o,"condition",e)),[o,s]),f=(0,j.useCallback)((()=>c(o)),[o,c]),g=null!==(u=e.full)&&void 0!==u?u:e.type?`[[${e.type}]]`:"",_=g.indexOf("]]"),b=g.indexOf("[[",_),y=-1===_||-1!==b&&b>_,h=qt({availableSmartTags:a,onMergeTagClick:(0,j.useCallback)((e=>{p(g?`${g} ${e}`.trim():e)}),[g,p])}),v=(0,j.useMemo)((()=>{const t=e.type;if(void 0!==n[t])return n[t];const r=t.replace("_",".",1);if(void 0!==n[r])return n[r];for(const[e,r]of Object.entries(n)){if(-1!==e.indexOf(".")&&e.split(".").slice(1).join(".")===t)return r;const n=e=>Array.isArray(e)?e:e.split(/[\s,]+/);if(r.deprecated&&n(r.deprecated).includes(t))return r}return null}),[e.type,n]),x=Nt((E=v?.options,(0,j.useMemo)((()=>E?Array.isArray(E)?E.map(((e,t)=>({label:e,value:t}))):Object.keys(E).map((e=>({label:E[e],value:e}))):[]),[E])),(0,i.__)("Select a value","newsletter-optin-box"));var E;const w=!y&&x.length>1,k=y?"string":v?.conditional_logic||"string",C=Nt((0,j.useMemo)((()=>{const e=[];return Object.keys(t).forEach((n=>{let r=t[n].type;if(w){if("string"===k&&"is"!=n&&"is_not"!=n)return;if("is_empty"===n||"is_not_empty"===n||"is_between"===n)return}"any"!==r&&r!=k||e.push({label:t[n].name,value:n})})),e}),[k,t]),(0,i.__)("Select a comparison","newsletter-optin-box")),S="is_empty"===e.condition||"is_not_empty"===e.condition;return(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start",wrap:!0,expanded:!0},(0,r.createElement)("div",{style:{minWidth:320}},(0,r.createElement)(l.__experimentalInputControl,{placeholder:(0,i.__)("Enter a smart tag","newsletter-optin-box"),value:g,onChange:p,autoComplete:"off",suffix:h,__next40pxDefaultSize:!0,isPressEnterToChange:!0})),(0,r.createElement)("div",{style:{width:150}},(0,r.createElement)(l.SelectControl,{label:(0,i.__)("Comparison","newsletter-optin-box"),hideLabelFromVision:!0,value:e.condition?e.condition:"is",options:C,onChange:d,size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0})),!S&&(0,r.createElement)("div",{style:{minWidth:320}},w&&(0,r.createElement)(l.SelectControl,{label:(0,i.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",options:x,onChange:m,size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),!w&&(0,r.createElement)(l.__experimentalInputControl,{type:"number"===k?"number":"text",label:(0,i.__)("Value","newsletter-optin-box"),placeholder:(0,i.__)("Enter a value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",onChange:m,__next40pxDefaultSize:!0})),(0,r.createElement)(l.Button,{onClick:f,icon:"trash",variant:"tertiary",isDestructive:!0}))}function zt({rules:e,comparisons:t,availableSmartTags:n,setConditionalLogicAttribute:a,disableTags:o,closeModal:s}){const c=(0,j.useMemo)((()=>Array.isArray(e)?e.filter((e=>e.type&&""!==e.type)):[]),[e]),u=(0,j.useMemo)((()=>{const e={};return n.forEach((t=>{t.conditional_logic&&(e[t.smart_tag]={...t,key:t.smart_tag,type:t.conditional_logic,isPremium:Array.isArray(o)&&o.some((e=>t.smart_tag.startsWith(e)))})})),e}),[n]),p=(0,j.useCallback)((e=>{const t=[...c];t.splice(e,1),a("rules",t)}),[c,a]),m=(0,j.useCallback)(((e,t,n)=>{const r=[...c];r[e][t]=n,a("rules",r)}),[c,a]),d=(0,j.useMemo)((()=>Object.values(u)),[u]),f=(0,j.useCallback)(((e,t)=>{const n=u[e],r=n?.options||[],o=n?.placeholder||"";let l=Array.isArray(r)&&r.length?Object.keys(r)[0]:o;n?.default&&(l=n.default);const i=[...c];i.push({type:e,condition:"is",full:t,value:l}),a("rules",i)}),[c]),g=0===c.length?(0,i.__)("Add a conditional logic rule","newsletter-optin-box"):(0,i.__)("Add another rule","newsletter-optin-box"),_=qt({availableSmartTags:d,onMergeTagClick:f,raw:!0,icon:"plus",label:g,text:g,toggleProps:{variant:"primary"}});return(0,r.createElement)(r.Fragment,null,c.map(((e,n)=>(0,r.createElement)(Rt,{key:n,rule:e,index:n,updateRule:m,removeRule:p,comparisons:t,availableSmartTags:u,mergeTagsArray:d}))),(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start",wrap:!0},_,s&&(0,r.createElement)(l.Button,{onClick:s,variant:"secondary"},(0,i.__)("Return to editor","newsletter-optin-box"))))}function jt({onChange:e,value:t,comparisons:n,toggleText:a,availableSmartTags:o,className:s,inModal:c=!1,disableTags:u=[]}){const[p,m]=(0,j.useState)(!1);"object"!=typeof t&&(t={enabled:!1,action:"allow",rules:[{condition:"is",type:"date",value:""}],type:"all"});const d=(n,r)=>{e({...t,[n]:r})},f=(0,r.createElement)(l.__experimentalVStack,{spacing:5},(0,r.createElement)(Bt,{ruleCount:Array.isArray(t.rules)?t.rules.length:0,type:t.type,action:t.action,setConditionalLogicAttribute:d}),(0,r.createElement)(zt,{rules:t.rules,comparisons:n,availableSmartTags:o,setConditionalLogicAttribute:d,closeModal:c&&(()=>m(!1)),disableTags:u}));return(0,r.createElement)(l.__experimentalVStack,{spacing:5,className:s},(0,r.createElement)(l.ToggleControl,{checked:!!t.enabled,onChange:e=>d("enabled",e),label:a||(0,i.__)("Optionally enable/disable this trigger depending on specific conditions.","newsletter-optin-box"),__nextHasNoMarginBottom:!0}),t.enabled&&(0,r.createElement)(r.Fragment,null,c?(0,r.createElement)(r.Fragment,null,p&&(0,r.createElement)(l.Modal,{title:(0,i.__)("Conditional Logic","newsletter-optin-box"),onRequestClose:()=>m(!1),isFullScreen:!0},f),(0,r.createElement)(l.Button,{variant:"secondary",className:"noptin-block-button",onClick:()=>m(!0)},(0,i.__)("Edit Conditional Logic","newsletter-optin-box"))):(0,r.createElement)(r.Fragment,null,f)))}const It={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>ee<=t,includes:(e,t)=>e.includes(t),"!includes":(e,t)=>!e.includes(t),empty:e=>!e,"!empty":e=>e},Ft=(e,t,n)=>!!It[t]&&It[t](e,n),Dt=["number","search","email","password","tel","url","date"];function Lt({setting:e,availableSmartTags:t,isPressEnterToChange:n,...a}){void 0===n&&(n=!0);const o=qt({availableSmartTags:t,onMergeTagClick:(0,r.useCallback)((e=>{a.onChange&&a.onChange(a.value?`${a.value} ${e}`.trim():e)}),[a.value,a.onChange])});return"string"==typeof a.suffix||a.suffix instanceof String?a.suffix=(0,r.createElement)(l.__experimentalInputControlSuffixWrapper,null,a.suffix):o&&!a.suffix&&(a.suffix=o),e.disabled&&(a.readOnly=!0,a.onFocus=e=>e.target.select()),("string"==typeof a.prefix||a.prefix instanceof String)&&(a.prefix=(0,r.createElement)(l.__experimentalInputControlPrefixWrapper,null,a.prefix)),(0,r.createElement)(l.__experimentalInputControl,{...a,type:Dt.includes(e.type)?e.type:"text",placeholder:e.placeholder?e.placeholder:"",isPressEnterToChange:n,__next40pxDefaultSize:!0})}function Ht({value:e,onChange:t,...n}){const{baseControlProps:a,controlProps:o}=(0,l.useBaseControlProps)({...n});return(0,r.createElement)(l.BaseControl,{...a},(0,r.createElement)(l.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:t,onToggle:n})=>(0,r.createElement)(l.Button,{onClick:n,"aria-expanded":t},(0,r.createElement)(l.ColorIndicator,{colorValue:e})),renderContent:()=>(0,r.createElement)(l.ColorPicker,{color:e,onChange:t}),...o}))}function Vt({availableSmartTags:e,autoGrow:t=!1,label:n,id:a,...o}){const i=qt({availableSmartTags:e,onMergeTagClick:(0,r.useCallback)((e=>{o.onChange&&o.onChange(o.value?`${o.value} ${e}`.trim():e)}),[o.value,o.onChange]),toggleProps:{size:"small"}}),s=i?(0,r.createElement)(l.__experimentalHStack,null,(0,r.createElement)("span",null,n),i):n,c=a||(0,F.useInstanceId)(Vt,"noptin-textarea");return(0,r.useEffect)((()=>{if(t){const e=document.getElementById(c);e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}}),[o.value,t,c]),(0,r.createElement)(l.TextareaControl,{...o,id:c,label:s,__nextHasNoMarginBottom:!0})}function Ut({options:e,...t}){const[n,a]=(0,r.useState)(e);return(0,r.createElement)(l.ComboboxControl,{...t,options:n,onFilterValueChange:t=>{a(t?e.filter((e=>!e.disabled&&""!==e.value&&(e.search?e.search.toLowerCase():e.label.toLowerCase()).includes(t.toLowerCase()))):e)},__experimentalRenderItem:({item:e,...t})=>e.render?"string"==typeof e.render?(0,r.createElement)("div",{...t,dangerouslySetInnerHTML:{__html:e.render}}):e.render:e.label,autocomplete:"off"})}function Wt({options:e,value:t,onChange:n,...a}){const o=Array.isArray(t)?t:[],i=(0,r.useMemo)((()=>e.map((e=>e.label))),[e]),s=(0,r.useCallback)((e=>i.includes(e)),[i]),c=(0,r.useMemo)((()=>o.map((t=>{const n=e.find((e=>e.value===t));return n?n.label:t}))),[t,e]),u=(0,r.useCallback)((t=>{const r=new Set;for(const n of t){const t=e.find((e=>e.label===n));t&&r.add(t.value)}n(Array.from(r))}),[n,e]),p=(0,r.useCallback)((t=>{const n=e.find((e=>e.label===t.item));return n&&n.render?(0,r.createElement)(j.RawHTML,null,n.render):(0,r.createElement)(r.Fragment,null,t.item)}),[e]);return(0,r.createElement)(l.FormTokenField,{value:c,suggestions:i,onChange:u,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalValidateInput:s,__experimentalRenderItem:p,...a})}const Gt=[{id:"key",label:(0,i.__)("Key","noptin-addons-pack"),type:"text"},{id:"value",label:(0,i.__)("Value","noptin-addons-pack"),type:"text"}];function qt({availableSmartTags:e=[],onMergeTagClick:t=((e,t)=>{}),raw:n=!1,icon:a="shortcode",label:o=(0,i.__)("Insert merge tag","newsletter-optin-box"),...s}){const c=function(e){return(0,r.useMemo)((()=>{if(!Array.isArray(e))return{};const t={};return e.forEach((e=>{const n=e.group?e.group:(0,i.__)("General","newsletter-optin-box");Array.isArray(t[n])||(t[n]=[]),t[n].push(e)})),t}),[e])}(e),u=Object.keys(c).length;let p=null;return u>0&&(p=(0,r.createElement)(l.DropdownMenu,{icon:a,label:o,...s},(({onClose:e})=>(0,r.createElement)(r.Fragment,null,Object.keys(c).map(((a,o)=>(0,r.createElement)(l.MenuGroup,{label:u>1?a:void 0,key:o},c[a].map((a=>(0,r.createElement)(l.MenuItem,{icon:a.isPremium?x:a.icon||G,iconPosition:"left",disabled:a.isPremium,onClick:()=>{if(!a.isPremium){if(t){const e=n?a.smart_tag:`[[${Kt(a)}]]`;t(e,`[[${Kt(a)}]]`)}e()}},key:a.smart_tag},(0,r.createElement)(j.RawHTML,null,a.isPremium?`${a.label} - Premium`:a.label))))))))))),p}function Kt(e){return e.example?e.example:e.default?`${e.smart_tag} default="${e.default}"`:`${e.smart_tag}`}function Qt({availableSmartTags:e,value:t,onChange:n,button:a,fields:o,openModal:s,prepend:c,disable:u,disabled:p,onDisable:m,cardProps:d,repeaterKey:f,id:g,defaultItem:_,...b}){const[y,h]=(0,r.useState)(!1),v=Array.isArray(t)?t:[],x=g||(0,F.useInstanceId)(Qt,"noptin-repeater"),{baseControlProps:E,controlProps:w}=(0,l.useBaseControlProps)({...b,id:x}),k=_||{};if(f?.newOnly&&(k.new=!0),!o)return console.warn("No fields provided to repeater control."),null;Object.keys(o).forEach((e=>{void 0!==o[e].default&&(k[e]=o[e].default)}));const C=!!s,S=(0,r.createElement)(l.__experimentalVStack,null,c,v.map(((a,i)=>(0,r.createElement)(l.Card,{size:"small",className:"noptin-no-shadow",id:`${x}__item-${i}`,"data-index":i,borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0,...d||{},key:f?.to&&t[f.to]?t[f.to]:i},(0,r.createElement)(Xt,{id:`${x}__item-${i}`,fields:o,value:a,availableSmartTags:e,onChange:e=>{if(f?.to&&f.from&&e[f.from]&&(!f.newOnly||e.new)){const t=e[f.from].toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");e[f.to]=t.substring(0,f.maxLength||64),v.find(((t,n)=>i!==n&&t[f.to]===e[f.to]))&&(e[f.to]=`${e[f.to]}_${i}`)}const t=[...v];t[i]=e,n(t)},onDelete:()=>{const e=[...v];e.splice(i,1),n(e)},onMoveUp:i>0?()=>{const e=[...v],t=e[i];e.splice(i,1),e.splice(i-1,0,t),n(e)}:null,onMoveDown:i{const e=[...v],t=e[i];e.splice(i,1),e.splice(i+1,0,t),n(e)}:null,repeaterKey:f})))),(0,r.createElement)(l.__experimentalHStack,null,(0,r.createElement)(l.Button,{onClick:()=>{const e=[...v];e.push(k),n(e)},variant:"primary"},a||(0,i.__)("Add Item","newsletter-optin-box")),C&&(0,r.createElement)(l.Button,{onClick:()=>h(!1),variant:"secondary"},(0,i.__)("Go Back","newsletter-optin-box")))),A=!u||!p;return(0,r.createElement)(l.BaseControl,{...E},(0,r.createElement)("div",{...w},C&&(0,r.createElement)(l.__experimentalVStack,null,u&&(0,r.createElement)(l.ToggleControl,{label:u,checked:p,onChange:e=>{m&&m(e)}}),A&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.Button,{onClick:()=>h(!0),variant:"secondary"},s||(0,i.__)("Set Items","newsletter-optin-box")),y&&(0,r.createElement)(l.Modal,{title:b.label||s||(0,i.__)("Set Items","newsletter-optin-box"),onRequestClose:()=>h(!1),size:"medium"},S))),!C&&S))}function Xt({fields:e,availableSmartTags:t,value:n,onChange:a,repeaterKey:o,onDelete:s,onMoveUp:c,onMoveDown:u,id:p}){const[m,d]=(0,r.useState)(!o?.from),f=(0,r.useCallback)((()=>{d(!m)}),[m]),g=!m&&o?.from;let _=null;if(o){const e=o.to&&n?.[o.to]?(0,r.createElement)("code",null,(0,i.sprintf)(o.display||"%s",n?.[o.to])):null,t={paddingLeft:16,paddingRight:16,height:48};_=(0,r.createElement)(l.CardHeader,{style:{padding:0}},(0,r.createElement)(l.Flex,{as:l.Button,onClick:f,style:t,"aria-controls":`${p}__body`,"aria-expanded":!g,type:"button"},(0,r.createElement)(l.__experimentalHStack,{as:l.FlexBlock},(0,r.createElement)(l.__experimentalText,{as:"h3",weight:600},n?.[o.from]||(0,i.__)("(new)","newsletter-optin-box"))),(0,r.createElement)(l.FlexItem,null,(0,r.createElement)(l.__experimentalHStack,null,e,(0,r.createElement)(l.Icon,{icon:m?"arrow-up-alt2":"arrow-down-alt2"})))))}return(0,r.createElement)(r.Fragment,null,_,!g&&(0,r.createElement)(l.CardBody,{id:`${p}__body`,hidden:g},(0,r.createElement)(l.__experimentalVStack,null,Object.keys(e).map((o=>(0,r.createElement)(rn,{key:o,settingKey:o,availableSmartTags:t,setting:e[o],saved:n,setAttributes:e=>{a({...n,...e})}}))),(0,r.createElement)(l.__experimentalHStack,{className:"noptin-repeater-item__actions",justify:"flex-start"},!n?.predefined&&(0,r.createElement)(l.Button,{variant:"link",onClick:s,text:(0,i.__)("Remove Item","newsletter-optin-box"),isDestructive:!0}),c&&(0,r.createElement)(l.Button,{onClick:c,icon:"arrow-up-alt",text:(0,i.__)("Move Up","newsletter-optin-box"),size:"small",iconSize:16}),u&&(0,r.createElement)(l.Button,{onClick:u,icon:"arrow-down-alt",text:(0,i.__)("Move Down","newsletter-optin-box"),size:"small",iconSize:16})))))}function Yt({setting:e,availableSmartTags:t,value:n,onChange:a,...o}){const{baseControlProps:s,controlProps:c}=(0,l.useBaseControlProps)(o);Array.isArray(n)||(n=[]);const u=(0,r.useCallback)((({item:e,index:o})=>(0,r.createElement)(l.Flex,{className:"noptin-repeater-item",wrap:!0},Gt.map(((l,i)=>(0,r.createElement)(Jt,{key:i,availableSmartTags:t,field:l,value:void 0===e[l.id]?"":e[l.id],onChange:e=>{const t=[...n];t[o][l.id]=e,a(t)}}))),(0,r.createElement)(l.FlexItem,null,(0,r.createElement)(l.Button,{icon:"trash",variant:"tertiary",className:"noptin-component__field",label:(0,i.__)("Delete","noptin-addons-pack"),showTooltip:!0,onClick:()=>{const e=[...n];e.splice(o,1),a(e)},isDestructive:!0})))),[n,a]);return(0,r.createElement)(l.BaseControl,{...s},(0,r.createElement)("div",{...c},n.map(((e,t)=>(0,r.createElement)(u,{key:t,item:e,index:t}))),(0,r.createElement)(l.Button,{onClick:()=>{const e=[...n];e.push({}),a(e)},variant:"secondary"},e.add_field?e.add_field:(0,i.__)("Add","newsletter-optin-box"))))}function Jt({field:e,availableSmartTags:t,value:n,onChange:a}){const o=qt({availableSmartTags:t,onMergeTagClick:(0,r.useCallback)((e=>{a&&a(n?`${n} ${e}`.trim():e)}),[n,a])});return(0,r.createElement)(l.FlexBlock,null,(0,r.createElement)(l.__experimentalInputControl,{label:e.label,type:e.type,value:n,placeholder:(0,i.sprintf)((0,i.__)("Enter %s","noptin-addons-pack"),e.label),className:"noptin-component__field noptin-condition-field",suffix:o,onChange:a,isPressEnterToChange:!0,__next40pxDefaultSize:!0}))}function Zt({setting:e,value:t,options:n,onChange:a,...o}){const{baseControlProps:i,controlProps:s}=(0,l.useBaseControlProps)(o);return Array.isArray(t)||(t=[]),(0,r.createElement)(l.BaseControl,{...i},(0,r.createElement)("div",{...s},n.map(((e,n)=>(0,r.createElement)(l.CheckboxControl,{key:n,label:e.label,checked:t.includes(e.value),onChange:n=>{a(n?[...t,e.value]:t.filter((t=>t!==e.value)))}})))))}function en({value:e,onChange:t,id:n,...a}){const{baseControlProps:o,controlProps:i}=(0,l.useBaseControlProps)({...a,id:n,__nextHasNoMarginBottom:!0}),{wp:s,tinymce:c}=window,u=(0,r.useRef)(!1),p=(0,r.useRef)(null);return(0,r.useEffect)((()=>{if(!u.current)return;const t=t=>{t?.target?.classList?.contains("wp-switch-editor")&&setTimeout((()=>{const t=c?.get(n);t&&(t.setContent(e||""),t._lastChange=e)}),50)};return p.current?.addEventListener("click",t),()=>{p.current?.removeEventListener("click",t)}}),[p.current,e]),(0,r.useEffect)((()=>{if(!u.current)return;const e=c?.get(n);e&&e._lastChange}),[e]),(0,r.useEffect)((()=>{function r(){s.oldEditor.initialize(n,{tinymce:!!window.tinymce&&{content_css:!1,theme_advanced_buttons:"bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect",drag_drop_upload:!0,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,dfw",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",min_height:400,wpautop:!1,setup(n){e&&n.on("loadContent",(()=>n.setContent(e))),n.on("blur",(()=>(t(n.getContent()),!1)));const r=(0,F.debounce)((()=>{const e=n.getContent();e!==n._lastChange&&(n._lastChange=e,t(e))}),250);n.on("Paste Change input Undo Redo",r),n.on("remove",r.cancel),n.on("keydown",(e=>{q.isKeyboardEvent.primary(e,"z")&&e.stopPropagation(),q.isKeyboardEvent.primary(e,"s")&&r.flush();const{altKey:t}=e;t&&e.keyCode===q.F10&&e.stopPropagation()})),u.current=!0},...window?.tinyMCEPreInit?.mceInit[n]||{}},mediaButtons:!0,quicktags:{buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,close"}})}function a(){"complete"===document.readyState&&r()}return c?.execCommand("mceRemoveEditor",!0,n),"complete"===document.readyState?r():document.addEventListener("readystatechange",a),()=>{document.removeEventListener("readystatechange",a),s.oldEditor.remove(n)}}),[]),(0,r.createElement)(l.BaseControl,{...o},(0,r.createElement)("div",{ref:p},(0,r.createElement)("textarea",{...i,className:"wp-editor-area",style:{width:"100%"},value:e,onChange:e=>t(e.target.value),rows:10})))}const tn=(e,t)=>{if(0===t.length||!e||"object"!=typeof e)return;const[n,...r]=t;return 0===r.length?e[n]:tn(e[n],r)},nn=(e,t,n)=>{if(0===t.length)return e;const[r,...a]=t;return 0===a.length?{...e,[r]:n}:{...e,[r]:nn(e[r]||{},a,n)}};function rn({settingKey:e,setting:t,availableSmartTags:n,prop:a,saved:o,setAttributes:s}){const c=(a?`${a}.${e}`:e).split("."),u=t.sanitize?t.sanitize:e=>e,p=(0,r.useCallback)((e=>{if(tn(o,c)===e)return;const[t,...n]=c;return 0===n.length?s(u({[t]:e})):s(u({[t]:nn(o[t]||{},n,e)}))}),[o,c,s,u]);if(t.if||t.restrict){const e=t.restrict?t.restrict.split("."):t.if.split(".");if(!tn(o,e))return null}if(Array.isArray(t.conditions)&&!t.conditions.every((e=>{const t=e.key.split("."),n=e.operator?e.operator:"==";return Ft(e.value,n,tn(o,t))})))return null;if(t.condition&&!t.condition(o))return null;let m=tn(o,c);(void 0===m||t.disabled)&&(m=t.default);const d=void 0!==m&&""!==m&&null!==m;let f=[];t.options&&(f=Array.isArray(t.options)?[...t.options]:Object.keys(t.options).map((e=>({label:t.options?.[e],value:e}))));const g=`noptin-component__field-${e}`,_="string"==typeof t.description?(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:t.description}}):t.description,b=t.customAttributes?t.customAttributes:{},y={label:t.label,value:d?m:"",onChange:p,className:g,help:_,...b};if(t.tooltip&&(y.label=(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start"},(0,r.createElement)("span",null,t.label),(0,r.createElement)(l.Tooltip,{delay:0,placement:"top",text:t.tooltip},(0,r.createElement)("span",null,(0,r.createElement)(l.Icon,{icon:"info",style:{color:"#454545"}}))))),t.type&&!t.el&&(t.el=t.type,["toggle","switch","checkbox","checkbox_alt","text","number","email","tel","date","color","image"].includes(t.type)&&(t.el="input")),"button"===t.el)return(0,r.createElement)("div",null,(0,r.createElement)(l.Button,{...t.buttonProps||{}}));if("select"===t.el)return t.multiple?(0,r.createElement)(Wt,{...y,options:f}):(f.find((e=>""===e?.value))||f.unshift({label:t.placeholder?t.placeholder:(0,i.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,r.createElement)(l.SelectControl,{...y,options:f,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}));if("combobox"===t.el)return f.unshift({label:t.placeholder?t.placeholder:(0,i.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,r.createElement)(Ut,{...y,options:f,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0});if("form_token"===t.el||"token"===t.el)return(0,r.createElement)(l.FormTokenField,{...y,value:Array.isArray(y.value)?y.value:[],suggestions:Array.isArray(t.suggestions)?t.suggestions:[],__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,tokenizeOnBlur:!0});if("multi_checkbox"===t.el||"multi_checkbox_alt"===t.el)return(0,r.createElement)(Zt,{...y,options:f});if("conditional_logic"===t.el)return(0,r.createElement)(jt,{...y,availableSmartTags:n,comparisons:t.comparisons,toggleText:t.toggle_text,inModal:t.in_modal});if("time"===t.el)return(0,r.createElement)($t,{...y});if("color"===t.el)return(0,r.createElement)(Ht,{...y});if("input"===t.el){if(t.type&&["toggle","switch","checkbox","checkbox_alt"].includes(t.type))return(0,r.createElement)(l.ToggleControl,{...y,checked:!!d&&m});if("number"===t.type){const e=e=>{if(e)return"string"==typeof e||e instanceof String?(0,r.createElement)(l.__experimentalInputControlSuffixWrapper,null,e):e},n=e=>{if(e)return"string"==typeof e||e instanceof String?(0,r.createElement)(l.__experimentalInputControlPrefixWrapper,null,e):e};return Array.isArray(y.suffix)?y.suffix=e(1===m||"1"===m?y.suffix[0]:y.suffix[1]):y.suffix=e(y.suffix),Array.isArray(y.prefix)?y.prefix=n(1===m||"1"===m?y.prefix[0]:y.prefix[1]):y.prefix=n(y.prefix),(0,r.createElement)(l.__experimentalNumberControl,{...y,placeholder:t.placeholder?t.placeholder:"",__next40pxDefaultSize:!0})}return"image"===t.type&&(y.suffix=(0,r.createElement)(l.Button,{onClick:()=>{var e=window.wp.media({title:(0,i.__)("Upload Image","newsletter-optin-box"),multiple:!1,library:{type:"image"}}).open().on("select",(t=>{let n=e.state().get("selection").first();p(n.toJSON().sizes.full.url)}))},icon:"upload",label:(0,i.__)("Upload Image","newsletter-optin-box"),showTooltip:!0})),(0,r.createElement)(Lt,{...y,setting:t,availableSmartTags:"trigger_settings"===a?[]:n,isPressEnterToChange:!t.isInputToChange})}return"textarea"===t.el?(0,r.createElement)(Vt,{...y,placeholder:t.placeholder?t.placeholder:"",availableSmartTags:"trigger_settings"===a?[]:n}):"tinymce"===t.el?(0,r.createElement)(en,{...y}):"paragraph"===t.el?(0,r.createElement)("div",{className:g},(0,r.createElement)(l.Tip,null,t.raw?(0,r.createElement)(j.RawHTML,null,t.content):t.content)):"hero"===t.el?(0,r.createElement)("div",{className:g},(0,r.createElement)("h3",null,t.content)):"key_value_repeater"===t.el||"webhook_key_value_repeater"===t.el?(0,r.createElement)(Yt,{...y,setting:t,availableSmartTags:"trigger_settings"===a?[]:n}):"repeater"===t.el?(0,r.createElement)(Qt,{...y,availableSmartTags:"trigger_settings"===a?[]:n}):e}const an=(0,r.createContext)([]),on=()=>(0,r.useContext)(an),ln=({children:e})=>{const{automationRule:{trigger_settings:t,smartTags:n}}=_(),a=(0,r.useMemo)((()=>function(e,t){const n=[];return e?(Object.keys(e).forEach((r=>{const a=e[r];if(a.hidden)return;if(a.conditions&&!a.conditions.every((e=>{let n=!1;return n=Array.isArray(e.value)?e.value.some((n=>n==t[e.key])):e.value==t[e.key],n===("is"===e.operator)})))return;let o=r;a.label?o=a.label:a.description&&(o=a.description),n.push({...a,smart_tag:r,label:o,example:a.example?a.example:"",description:a.description?a.description:"",placeholder:a.placeholder?a.placeholder:"",conditional_logic:!!a.conditional_logic&&a.conditional_logic,options:a.options?a.options:[]})})),n):n}(n,t||{})),[n,t]);return(0,r.createElement)(an.Provider,{value:a},e)};function sn({sectionKey:e,label:t,prop:n,settings:a}){const o=on(),i=Object.keys(a);if(!i.length)return null;const{automationRule:s,setAttributes:c}=_();return(0,r.createElement)(W,null,(0,r.createElement)(u,{title:t,className:`noptin-automation-rule-editor__section noptin-automation-rule-editor__section-${e}`},(0,r.createElement)(l.__experimentalVStack,{spacing:5,as:l.CardBody},i.map((e=>(0,r.createElement)(rn,{key:e,settingKey:e,prop:n,availableSmartTags:o,saved:s,setAttributes:c,setting:a[e]}))))))}function cn(){const{error:e,success:t,resetMessages:n,automationRule:{settings:a}}=_(),o=(0,r.createElement)(r.Fragment,null,e&&(0,r.createElement)(l.Notice,{status:"error",onDismiss:n},e),t&&(0,r.createElement)(l.Notice,{status:"success",onDismiss:n},t));if(!a)return o;const i=Object.keys(a);return i.length?(0,r.createElement)(l.__experimentalVStack,{className:"noptin-automation-rule-editor__sections"},o,(0,r.createElement)(W,null,i.map((e=>(0,r.createElement)(sn,{key:e,sectionKey:e,...a[e]}))))):o}const un=window.noptinEmailSettingsMisc||{};function pn(e,t){const n={};Array.isArray(e)||Object.entries(e).forEach((([e,r])=>{if("email"!==e){if(!r.category){if(!un.isTest)return;r.category="Deprecated"}n[r.category]||(n[r.category]={}),n[r.category][e]={...r,selectText:"triggers"===t?(0,i.__)("Use trigger","newsletter-optin-box"):(0,i.__)("Set-up","newsletter-optin-box"),forcePremium:R(e,r.category)},r.alt_category&&(n[r.alt_category]||(n[r.alt_category]={}),n[r.alt_category][e]=n[r.category][e])}})),Array.isArray(un.integrations)&&un.integrations.forEach((r=>{r.plan&&"free"!==r.plan&&r[t]&&!Array.isArray(r[t])&&Object.entries(r[t]).forEach((([t,a])=>{a.forEach((({id:a,label:o,description:l,premium:i=!1})=>{if("premium"===r.plan||i)if(e[a]){const t=e[a].category;t&&n[t][a]&&(n[t][a].forcePremium=!0)}else n[t]||(n[t]={}),n[t][a]={name:a,label:o,description:l,category:t,image:r.icon_url,forcePremium:!0,is_installed:!1,installation:r.installation}}))}))}));const r={},a=(0,i.__)("General","newsletter-optin-box");return n.hasOwnProperty(a)&&(r[a]=n[a]),Object.keys(n).sort().forEach((e=>{e!==a&&(r[e]=n[e])})),r}un.license;const mn={"noptin-trigger":{title:(0,i.__)("Select a trigger for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-trigger",cardGroups:pn(un.data?.triggers||{},"triggers")},"noptin-action":{title:(0,i.__)("Select an action for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-action",cardGroups:pn(un.data?.actions||{},"actions")}},dn=(0,r.createContext)(void 0),fn=({children:e})=>{const[t,n]=(0,r.useState)(un.data?.add_new||(0,E.addQueryArgs)(window.location.href,{noptin_edit_automation_rule:"0"})),a=(0,r.useMemo)((()=>{let e="";const r={};for(const[n,a]of Object.entries(mn)){const o=a.arg?(0,E.getQueryArg)(t,a.arg):"";if(!o){e=n;break}r[n]=o}return{currentTitle:mn[e]?.title||"",currentStep:e,isLastStep:e===Object.keys(mn).pop(),isFirstStep:e===Object.keys(mn)[0],hasSteps:Object.keys(mn).length>0,stepValues:r,steps:mn,campaign:"automation-rules",removeQueryArgs:(...e)=>{n((0,E.removeQueryArgs)(t,...e))},addQueryArg:(e,r)=>{n((0,E.addQueryArgs)(t,{[e]:r}))},withQueryArg:(e,n)=>(0,E.addQueryArgs)(t,{[e]:n}),url:t}}),[t,n]);return(0,r.createElement)(dn.Provider,{value:a},e)},gn=({categories:e,selectedCategory:t,onClickCategory:n})=>{const a="noptin-campaign-explorer__sidebar";return(0,r.createElement)("div",{className:a},(0,r.createElement)("div",{className:`${a}__categories-list`},e.map((e=>(0,r.createElement)(l.Button,{key:e,label:e,className:`${a}__categories-list__item`,isPressed:t===e,onClick:()=>{n(e)}},e)))))},bn=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,r.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,r.createElement)(l.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",n=e.path||"",a=e.viewBox||"0 0 24 24";return e.path?(0,r.createElement)(l.SVG,{viewBox:a,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,r.createElement)(l.Path,{fill:t,d:n})):(0,r.createElement)(l.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,r.createElement)(l.Icon,{size:24,icon:"email",style:{color:"#424242"}})},yn=({name:e,label:t,description:n,image:a,onSelect:o,hrefCallback:s,href:c,...u})=>{const p=(e=>{const t=e.learnMoreUrl?(0,r.createElement)(l.Button,{variant:"secondary",href:e.learnMoreUrl},(0,r.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,i.__)("Learn More"))," ",(0,r.createElement)(l.Icon,{size:16,icon:"arrow-right-alt"})):null;if(e.forcePremium?!1!==e.is_installed&&e?.licenseDetails?.key:!1!==e.is_installed)return{upgradeText:null,button:(0,r.createElement)(l.Button,{variant:"primary",onClick:e.onClick,href:e.href},(0,r.createElement)("span",{className:"noptin-selectable-card__label"},e.selectText||(0,i.__)("Select"))," ",(0,r.createElement)(l.Icon,{size:16,icon:"arrow-right-alt"})),secondaryButton:t};const n=(t,n)=>!1===e.is_installed&&e.installation?.[t]?e.installation?.[t]:e.licenseDetails[t]||n,a=n("install_desc",(0,i.__)("Activate your license key to unlock","newsletter-optin-box")),o=n("install_text",(0,i.__)("View Pricing","newsletter-optin-box")),s=n("install_url",(0,E.addQueryArgs)("https://noptin.com/pricing/",{utm_source:e.name||"license",utm_campaign:e.campaign||"noptin",utm_medium:"plugin-dashboard"}));return{upgradeText:a,button:(0,r.createElement)(l.Button,{variant:"primary",href:s},(0,r.createElement)("span",{className:"noptin-selectable-card-action__label"},o)," ",(0,r.createElement)(l.Icon,{size:16,icon:"lock"})),secondaryButton:e.licenseDetails?.key?t:(0,r.createElement)(l.Button,{variant:"secondary",href:e.licenseDetails?.activate_url},(0,r.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,i.__)("Activate"))," ",(0,r.createElement)(l.Icon,{size:16,icon:"unlock"}))}})({onClick:(0,r.useCallback)((()=>o?o(e):null),[e,o]),name:e.replace("automation_rule_",""),href:s?s(e):c,...u});return(0,r.createElement)(l.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,size:"small"},(0,r.createElement)(l.CardHeader,null,(0,r.createElement)(l.__experimentalHeading,{level:4,numberOfLines:1},t),(0,r.createElement)(bn,{image:a,title:t})),(0,r.createElement)(l.CardBody,null,(0,r.createElement)(l.__experimentalVStack,{spacing:4},n&&(0,r.createElement)(l.__experimentalText,{as:"p",variant:"muted"},n),p.upgradeText&&(0,r.createElement)(l.__experimentalText,{as:"em",isDestructive:!0},p.upgradeText))),(0,r.createElement)(l.CardFooter,{isBorderless:!0,justify:p.secondaryButton?"space-between":"flex-end"},p.secondaryButton,p.button),(0,r.createElement)(l.__experimentalElevation,{value:1,hover:3}))},hn=({showTitle:e,selectedCategory:t,cards:n,...a})=>{const o="noptin-campaign-explorer";let i=Object.entries(n);return i.sort(((e,t)=>e[1].label.localeCompare(t[1].label))),(0,r.createElement)("div",{className:`${o}__list`},e&&(0,r.createElement)(l.__experimentalHeading,{level:2,lineHeight:"48px",className:`${o}__category-name`},t),(0,r.createElement)("div",{role:"listbox",className:`${o}-list`},i.map((([e,t])=>(0,r.createElement)(yn,{key:e,name:e,...a,...t})))))},vn=({cardGroups:e,...t})=>{const n=Object.keys(e).length,[a,o]=(0,r.useState)(Object.keys(e)[0]);(0,r.useEffect)((()=>{n>0&&!e[a]&&o(Object.keys(e)[0])}),[e,a]);const l=n>1,i=(0,r.useMemo)((()=>Object.keys(e)),[e]),s=(0,r.useMemo)((()=>e[a]||{}),[e,a]),u=c()("noptin-campaign-explorer",{"noptin-campaign-explorer--show-sidebar":l});return(0,r.createElement)("div",{className:u},l&&(0,r.createElement)(gn,{selectedCategory:a,categories:i,onClickCategory:o}),(0,r.createElement)(hn,{showTitle:l,selectedCategory:a,cards:s,...t}))},xn=e=>{if(!e.isOpen)return null;const t=e.steps[e.currentStep];if(t.modal)return(0,r.createElement)(l.Modal,{onRequestClose:e.closeModal,...t.modal.props},t.modal.content);if(t.cardGroups){const n=[...Object.keys(e.stepValues)].pop(),a=(0,r.createElement)(r.Fragment,null,n&&!e.isFirstStep&&(0,r.createElement)(l.Button,{icon:"arrow-left-alt",onClick:()=>e.removeQueryArgs(e.steps[n]?.arg||""),label:(0,i.__)("Back","newsletter-optin-box"),showTooltip:!0})),o=e.isLastStep?void 0:n=>{t.arg&&e.addQueryArg(t.arg,n)};return(0,r.createElement)(l.Modal,{title:e.currentTitle,onRequestClose:e.closeModal,headerActions:a,isFullScreen:!0},(0,r.createElement)(vn,{cardGroups:t.cardGroups,licenseDetails:e.licenseDetails,onSelect:o,hrefCallback:t.arg&&e.isLastStep?n=>e.withQueryArg(t.arg,n):void 0,campaign:e.campaign}))}return null},En=({buttonProps:e,...t})=>{const[n,a]=(0,r.useState)(!1),o=(0,r.useCallback)((()=>{a(!0)}),[a]),i=(0,r.useCallback)((()=>{a(!1)}),[a]),s=t.currentStep&&t.hasSteps,c={...e,onClick:s?o:void 0,href:s?void 0:t.url};return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.Button,{...c}),(0,r.createElement)(xn,{isOpen:n,closeModal:i,...t}))},wn=({text:e})=>{const t=(()=>{const e=(0,r.useContext)(dn);if(!e)throw new Error("useModal must be used within a ModalProvider");return e})();return(0,r.createElement)(En,{licenseDetails:un.license||{},buttonProps:{variant:"primary",type:"button",text:e||(0,i.__)("Add New Automation","newsletter-optin-box")},...t})},kn=({text:e})=>(0,r.createElement)(fn,null,(0,r.createElement)(wn,{text:e})),Cn=({children:e})=>{const{automationRule:{trigger_id:t}}=_(),n=R(t,window.noptinEmailSettingsMisc?.triggers?.[t]?.category),[r,a]=A({heading:(0,i.__)("Unlock Premium Feature","newsletter-optin-box"),helpText:(0,i.__)("This automation trigger is only available to premium license holders.","newsletter-optin-box"),needsAddonsPack:!1,slug:"automation-rule-trigger-"+t});return!r&&n?a:e};function Sn(){const{automationRule:{id:e}}=_(),t=!!(e&&e>0);return(0,r.createElement)(l.__experimentalHStack,{justify:"flex-start"},(0,r.createElement)(l.__experimentalText,{as:"h1",size:23,weight:500},t?(0,i.__)("Edit Automation Rule","newsletter-optin-box"):(0,i.__)("Add Automation Rule","newsletter-optin-box")),t&&(0,r.createElement)(kn,{text:(0,i.__)("Add New","newsletter-optin-box")}))}function An({automationRule:e}){return(0,r.createElement)("div",{className:"noptin-automation-rule__editor"},(0,r.createElement)(W,null,(0,r.createElement)(l.SlotFillProvider,null,(0,r.createElement)(b,{automationRule:e},(0,r.createElement)(Cn,null,(0,r.createElement)(ln,null,(0,r.createElement)(l.__experimentalVStack,{spacing:4},(0,r.createElement)(Sn,null),(0,r.createElement)(l.Flex,{wrap:!0,align:"top"},(0,r.createElement)(l.FlexBlock,{className:"noptin-es6-editor__main"},(0,r.createElement)(cn,null)),(0,r.createElement)(l.FlexItem,{className:"noptin-component-editor__sidebar"},(0,r.createElement)(l.__experimentalVStack,null,(0,r.createElement)(z,null),(0,r.createElement)(h,null)))))))))))}const Tn=e=>{const t=window.noptinEmailSettingsMisc?.data?.app||{};return(0,r.createElement)(j.StrictMode,null,(0,r.createElement)(W,null,(0,r.createElement)(An,{...e,...t})))};o()((()=>{((e,t)=>{if(t){const n=t.getAttribute("data-app"),a=n?JSON.parse(n):{};j.createRoot?(0,j.createRoot)(t).render((0,r.createElement)(e,{...a})):(0,j.render)((0,r.createElement)(e,{...a}),t)}})(Tn,document.getElementById("noptin-automation-rule__editor-app"))}))},146:(e,t,n)=>{"use strict";var r=n(404),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function s(e){return r.isMemo(e)?l:i[e.$$typeof]||a}i[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[r.Memo]=l;var c=Object.defineProperty,u=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,f=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(f){var a=d(n);a&&a!==f&&e(t,a,r)}var l=u(n);p&&(l=l.concat(p(n)));for(var i=s(t),g=s(n),_=0;_{"use strict";var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,a=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,l=n?Symbol.for("react.strict_mode"):60108,i=n?Symbol.for("react.profiler"):60114,s=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,p=n?Symbol.for("react.concurrent_mode"):60111,m=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,f=n?Symbol.for("react.suspense_list"):60120,g=n?Symbol.for("react.memo"):60115,_=n?Symbol.for("react.lazy"):60116,b=n?Symbol.for("react.block"):60121,y=n?Symbol.for("react.fundamental"):60117,h=n?Symbol.for("react.responder"):60118,v=n?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case u:case p:case o:case i:case l:case d:return e;default:switch(e=e&&e.$$typeof){case c:case m:case _:case g:case s:return e;default:return t}}case a:return t}}}function E(e){return x(e)===p}t.AsyncMode=u,t.ConcurrentMode=p,t.ContextConsumer=c,t.ContextProvider=s,t.Element=r,t.ForwardRef=m,t.Fragment=o,t.Lazy=_,t.Memo=g,t.Portal=a,t.Profiler=i,t.StrictMode=l,t.Suspense=d,t.isAsyncMode=function(e){return E(e)||x(e)===u},t.isConcurrentMode=E,t.isContextConsumer=function(e){return x(e)===c},t.isContextProvider=function(e){return x(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return x(e)===m},t.isFragment=function(e){return x(e)===o},t.isLazy=function(e){return x(e)===_},t.isMemo=function(e){return x(e)===g},t.isPortal=function(e){return x(e)===a},t.isProfiler=function(e){return x(e)===i},t.isStrictMode=function(e){return x(e)===l},t.isSuspense=function(e){return x(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===p||e===i||e===l||e===d||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===_||e.$$typeof===g||e.$$typeof===s||e.$$typeof===c||e.$$typeof===m||e.$$typeof===y||e.$$typeof===h||e.$$typeof===v||e.$$typeof===b)},t.typeOf=x},404:(e,t,n)=>{"use strict";e.exports=n(72)},942:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e="",t=0;t{if(!n){var l=1/0;for(u=0;u=o)&&Object.keys(r.O).every((e=>r.O[e](n[s])))?n.splice(s--,1):(i=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,a,o]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={180:0,856:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,[l,i,s]=n,c=0;if(l.some((t=>0!==e[t]))){for(a in i)r.o(i,a)&&(r.m[a]=i[a]);if(s)var u=s(r)}for(t&&t(n);cr(921)));a=r.O(a)})(); \ No newline at end of file diff --git a/build/Automation_Rules/assets/js/automation-rules.asset.php b/build/Automation_Rules/assets/js/automation-rules.asset.php index 28a75f0c..2e6e7cfc 100644 --- a/build/Automation_Rules/assets/js/automation-rules.asset.php +++ b/build/Automation_Rules/assets/js/automation-rules.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '8d13395561560cc88384'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '5e05b3b84a26327ed13f'); diff --git a/build/Automation_Rules/assets/js/automation-rules.js b/build/Automation_Rules/assets/js/automation-rules.js index ffcc4d1d..ec05fc68 100644 --- a/build/Automation_Rules/assets/js/automation-rules.js +++ b/build/Automation_Rules/assets/js/automation-rules.js @@ -1 +1 @@ -(()=>{var e,t={93:(e,t,r)=>{"use strict";const n=window.wp.domReady;var a=r.n(n);const o=window.React,l=window.wp.i18n,i=window.noptinEmailSettingsMisc||{},s=(i.license,window.wp.url),c=window.wp.components,u=window.noptinEmailEditorSettings||{},m=window.noptinEmailSettingsMisc||{},p=(m.license,u.types||{}),d=(Object.keys(p).map((e=>({value:e,label:p[e].label}))),Object.keys(u.templates||{}).map((e=>({value:e,label:u.templates[e]}))),m.license||{}),_=(d.is_usable&&d.key,/_published|_unpublished|_deleted|_user_role$/),g=["noptin_subscriber_","delete_user","new_user","update_user","wp_login","after_password_reset","create_or_update_"],y=[["woocommerce","subscription"],["latest_","_digest"]],b=["WordPress Users"],f=["latest_posts_digest"],E=["periodic"],h=(e,t=void 0)=>{if(!e||f.includes(e))return!1;if(E.includes(e))return!0;if(t&&b.includes(t))return!0;if(y.some((t=>t.every((t=>e.includes(t))))))return!0;const r=e.replace(/^automation_rule_/,"");return _.test(r)?"post_published"!==r:g.some((e=>r.startsWith(e)))};function w(e,t){const r={};Array.isArray(e)||Object.entries(e).forEach((([e,n])=>{if("email"!==e){if(!n.category){if(!i.isTest)return;n.category="Deprecated"}r[n.category]||(r[n.category]={}),r[n.category][e]={...n,selectText:"triggers"===t?(0,l.__)("Use trigger","newsletter-optin-box"):(0,l.__)("Set-up","newsletter-optin-box"),forcePremium:h(e,n.category)},n.alt_category&&(r[n.alt_category]||(r[n.alt_category]={}),r[n.alt_category][e]=r[n.category][e])}})),Array.isArray(i.integrations)&&i.integrations.forEach((n=>{n.plan&&"free"!==n.plan&&n[t]&&!Array.isArray(n[t])&&Object.entries(n[t]).forEach((([t,a])=>{a.forEach((({id:a,label:o,description:l,premium:i=!1})=>{if("premium"===n.plan||i)if(e[a]){const t=e[a].category;t&&r[t][a]&&(r[t][a].forcePremium=!0)}else r[t]||(r[t]={}),r[t][a]={name:a,label:o,description:l,category:t,image:n.icon_url,forcePremium:!0,is_installed:!1,installation:n.installation}}))}))}));const n={};return Object.keys(r).sort().forEach((e=>{n[e]=r[e]})),n}const v={"noptin-trigger":{title:(0,l.__)("Select a trigger for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-trigger",cardGroups:w(i.data?.triggers||{},"triggers")},"noptin-action":{title:(0,l.__)("Select an action for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-action",cardGroups:w(i.data?.actions||{},"actions")}},x=(0,o.createContext)(void 0),k=({children:e})=>{const[t,r]=(0,o.useState)(i.data?.add_new||(0,s.addQueryArgs)(window.location.href,{noptin_edit_automation_rule:"0"})),n=(0,o.useMemo)((()=>{let e="";const n={};for(const[r,a]of Object.entries(v)){const o=a.arg?(0,s.getQueryArg)(t,a.arg):"";if(!o){e=r;break}n[r]=o}return{currentTitle:v[e]?.title||"",currentStep:e,isLastStep:e===Object.keys(v).pop(),isFirstStep:e===Object.keys(v)[0],hasSteps:Object.keys(v).length>0,stepValues:n,steps:v,campaign:"automation-rules",removeQueryArgs:(...e)=>{r((0,s.removeQueryArgs)(t,...e))},addQueryArg:(e,n)=>{r((0,s.addQueryArgs)(t,{[e]:n}))},withQueryArg:(e,r)=>(0,s.addQueryArgs)(t,{[e]:r}),url:t}}),[t,r]);return(0,o.createElement)(x.Provider,{value:n},e)};var S=r(942),C=r.n(S);const O=window.wp.element,A=({categories:e,selectedCategory:t,onClickCategory:r})=>{const n="noptin-campaign-explorer__sidebar";return(0,o.createElement)("div",{className:n},(0,o.createElement)("div",{className:`${n}__categories-list`},e.map((e=>(0,o.createElement)(c.Button,{key:e,label:e,className:`${n}__categories-list__item`,isPressed:t===e,onClick:()=>{r(e)}},e)))))},j=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,o.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,o.createElement)(c.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",r=e.path||"",n=e.viewBox||"0 0 24 24";return e.path?(0,o.createElement)(c.SVG,{viewBox:n,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,o.createElement)(c.Path,{fill:t,d:r})):(0,o.createElement)(c.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,o.createElement)(c.Icon,{size:24,icon:"email",style:{color:"#424242"}})},T=({name:e,label:t,description:r,image:n,onSelect:a,hrefCallback:i,href:u,...m})=>{const p=(e=>{const t=e.learnMoreUrl?(0,o.createElement)(c.Button,{variant:"secondary",href:e.learnMoreUrl},(0,o.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,l.__)("Learn More"))," ",(0,o.createElement)(c.Icon,{size:16,icon:"arrow-right-alt"})):null;if(e.forcePremium?!1!==e.is_installed&&e?.licenseDetails?.key:!1!==e.is_installed)return{upgradeText:null,button:(0,o.createElement)(c.Button,{variant:"primary",onClick:e.onClick,href:e.href},(0,o.createElement)("span",{className:"noptin-selectable-card__label"},e.selectText||(0,l.__)("Select"))," ",(0,o.createElement)(c.Icon,{size:16,icon:"arrow-right-alt"})),secondaryButton:t};const r=(t,r)=>!1===e.is_installed&&e.installation?.[t]?e.installation?.[t]:e.licenseDetails[t]||r,n=r("install_desc",(0,l.__)("Activate your license key to unlock","newsletter-optin-box")),a=r("install_text",(0,l.__)("View Pricing","newsletter-optin-box")),i=r("install_url",(0,s.addQueryArgs)("https://noptin.com/pricing/",{utm_source:e.name||"license",utm_campaign:e.campaign||"noptin",utm_medium:"plugin-dashboard"}));return{upgradeText:n,button:(0,o.createElement)(c.Button,{variant:"primary",href:i},(0,o.createElement)("span",{className:"noptin-selectable-card-action__label"},a)," ",(0,o.createElement)(c.Icon,{size:16,icon:"lock"})),secondaryButton:e.licenseDetails?.key?t:(0,o.createElement)(c.Button,{variant:"secondary",href:e.licenseDetails?.activate_url},(0,o.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,l.__)("Activate"))," ",(0,o.createElement)(c.Icon,{size:16,icon:"unlock"}))}})({onClick:(0,o.useCallback)((()=>a?a(e):null),[e,a]),name:e.replace("automation_rule_",""),href:i?i(e):u,...m});return(0,o.createElement)(c.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,size:"small"},(0,o.createElement)(c.CardHeader,null,(0,o.createElement)(c.__experimentalHeading,{level:4,numberOfLines:1},t),(0,o.createElement)(j,{image:n,title:t})),(0,o.createElement)(c.CardBody,null,(0,o.createElement)(c.__experimentalVStack,{spacing:4},r&&(0,o.createElement)(c.__experimentalText,{as:"p",variant:"muted"},r),p.upgradeText&&(0,o.createElement)(c.__experimentalText,{as:"em",isDestructive:!0},p.upgradeText))),(0,o.createElement)(c.CardFooter,{isBorderless:!0,justify:p.secondaryButton?"space-between":"flex-end"},p.secondaryButton,p.button),(0,o.createElement)(c.__experimentalElevation,{value:1,hover:3}))},B=({showTitle:e,selectedCategory:t,cards:r,...n})=>{const a="noptin-campaign-explorer";return(0,o.createElement)("div",{className:`${a}__list`},e&&(0,o.createElement)(c.__experimentalHeading,{level:2,lineHeight:"48px",className:`${a}__category-name`},t),(0,o.createElement)("div",{role:"listbox",className:`${a}-list`},Object.keys(r).sort().map((e=>(0,o.createElement)(T,{key:e,name:e,...n,...r[e]})))))},M=({cardGroups:e,...t})=>{const r=Object.keys(e).length,[n,a]=(0,o.useState)(Object.keys(e)[0]);(0,o.useEffect)((()=>{r>0&&!e[n]&&a(Object.keys(e)[0])}),[e,n]);const l=r>1,i=(0,o.useMemo)((()=>Object.keys(e)),[e]),s=(0,o.useMemo)((()=>e[n]||{}),[e,n]),c=C()("noptin-campaign-explorer",{"noptin-campaign-explorer--show-sidebar":l});return(0,o.createElement)("div",{className:c},l&&(0,o.createElement)(A,{selectedCategory:n,categories:i,onClickCategory:a}),(0,o.createElement)(B,{showTitle:l,selectedCategory:n,cards:s,...t}))},I=e=>{if(!e.isOpen)return null;const t=e.steps[e.currentStep];if(t.modal)return(0,o.createElement)(c.Modal,{onRequestClose:e.closeModal,...t.modal.props},t.modal.content);if(t.cardGroups){const r=[...Object.keys(e.stepValues)].pop(),n=(0,o.createElement)(o.Fragment,null,r&&!e.isFirstStep&&(0,o.createElement)(c.Button,{icon:"arrow-left-alt",onClick:()=>e.removeQueryArgs(e.steps[r]?.arg||""),label:(0,l.__)("Back","newsletter-optin-box"),showTooltip:!0})),a=e.isLastStep?void 0:r=>{t.arg&&e.addQueryArg(t.arg,r)};return(0,o.createElement)(c.Modal,{title:e.currentTitle,onRequestClose:e.closeModal,headerActions:n,isFullScreen:!0},(0,o.createElement)(M,{cardGroups:t.cardGroups,licenseDetails:e.licenseDetails,onSelect:a,hrefCallback:t.arg&&e.isLastStep?r=>e.withQueryArg(t.arg,r):void 0,campaign:e.campaign}))}return null},N=({buttonProps:e,...t})=>{const[r,n]=(0,o.useState)(!1),a=(0,o.useCallback)((()=>{n(!0)}),[n]),l=(0,o.useCallback)((()=>{n(!1)}),[n]),i=t.currentStep&&t.hasSteps,s={...e,onClick:i?a:void 0,href:i?void 0:t.url};return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.Button,{...s}),(0,o.createElement)(I,{isOpen:r,closeModal:l,...t}))},P=({text:e})=>{const t=(()=>{const e=(0,o.useContext)(x);if(!e)throw new Error("useModal must be used within a ModalProvider");return e})();return(0,o.createElement)(N,{licenseDetails:i.license||{},buttonProps:{variant:"primary",type:"button",text:e||(0,l.__)("Add New Automation","newsletter-optin-box")},...t})},D=({text:e})=>(0,o.createElement)(k,null,(0,o.createElement)(P,{text:e})),z=()=>(0,o.createElement)(c.__experimentalVStack,{alignment:"center",justify:"center",spacing:6,style:{minHeight:320}},(0,o.createElement)(c.Icon,{icon:"admin-generic",size:100,style:{color:"#646970"}}),(0,o.createElement)(c.__experimentalText,{align:"center",color:"#646970",size:16,isBlock:!0},(0,l.__)('Automation rules are simple "if this, then that" commands. Trigger an action when a product is purchased, a user creates an account, someone is tagged, etc.',"newsletter-optin-box")),(0,o.createElement)(D,{text:(0,l.__)("Create your first automation rule","newsletter-optin-box")}),(0,o.createElement)(c.__experimentalText,{align:"center",size:14,isBlock:!0},(0,o.createElement)("a",{href:"https://noptin.com/guide/automation-rules/",style:{color:"#646970"},target:"_blank"},(0,l.__)("Or Learn more","newsletter-optin-box")))),Q=window.wp.apiFetch;var $=r.n(Q);const H=({ruleId:e})=>{const[t,r]=(0,o.useState)(!1);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.Button,{icon:"trash",size:"compact",showTooltip:!0,label:(0,l.__)("Delete","newsletter-optin-box"),type:"button",onClick:()=>r(!0),isDestructive:!0}),t&&(0,o.createElement)(c.Modal,{onRequestClose:()=>r(!1),title:(0,l.__)("Delete Rule","newsletter-optin-box"),size:"small"},(0,o.createElement)(c.__experimentalVStack,{spacing:4},(0,o.createElement)(c.__experimentalText,null,(0,l.__)("Are you sure you want to delete this automation rule?","newsletter-optin-box")),(0,o.createElement)(c.__experimentalHStack,{spacing:4,justify:"flex-start",alignment:"flex-start"},(0,o.createElement)(c.Button,{variant:"primary",text:(0,l.__)("Delete","newsletter-optin-box"),type:"button",onClick:()=>{r(!1);const t=document.querySelector(`.noptin_automation_rule_${e}`);t&&t.classList.add("noptin-fade-out"),$()({path:`/noptin/v1/automation_rules/${e}`,method:"DELETE"}).then((e=>(t&&t.remove(),e))).catch((e=>{alert(e.message),t&&t.classList.remove("noptin-fade-out")}))},isDestructive:!0}),(0,o.createElement)(c.Button,{variant:"secondary",text:(0,l.__)("Cancel","newsletter-optin-box"),type:"button",onClick:()=>r(!1)})))))},L=({ruleId:e,status:t})=>{const[r,n]=(0,o.useState)(t);return(0,o.createElement)(c.ToggleControl,{checked:r,label:r?(0,l.__)("Active","newsletter-optin-box"):(0,l.__)("Inactive","newsletter-optin-box"),className:"noptin-toggle-button",onChange:()=>{n(!r),$()({path:`/noptin/v1/automation_rules/${e}`,method:"PATCH",data:{status:!r}}).catch((e=>{alert(e.message),n(r)}))},__nextHasNoMarginBottom:!0})},F=e=>(0,o.createElement)(c.__experimentalHStack,{alignment:"center",justify:"flex-end",spacing:1},(0,o.createElement)(c.Button,{href:e.editUrl,label:(0,l.__)("Edit","newsletter-optin-box"),size:"compact",icon:"edit",showTooltip:!0}),(0,o.createElement)(H,{ruleId:e.ruleId}),(0,o.createElement)(L,{ruleId:e.ruleId,status:e.status})),R=(e,t)=>{if(t){const r=t.getAttribute("data-app"),n=r?JSON.parse(r):{};O.createRoot?(0,O.createRoot)(t).render((0,o.createElement)(e,{...n})):(0,O.render)((0,o.createElement)(e,{...n}),t)}};a()((()=>{R(z,document.getElementById("noptin-automation-rules__editor--add-new__in-table")),document.querySelectorAll(".noptin-automation-rules__editor--add-new__button").forEach((e=>{R(D,e)})),document.querySelectorAll(".noptin-automation-rule-actions__app").forEach((e=>{R(F,e)}))}))},942:(e,t)=>{var r;!function(){"use strict";var n={}.hasOwnProperty;function a(){for(var e="",t=0;t{if(!r){var l=1/0;for(u=0;u=o)&&Object.keys(n.O).every((e=>n.O[e](r[s])))?r.splice(s--,1):(i=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[r,a,o]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={229:0,833:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,[l,i,s]=r,c=0;if(l.some((t=>0!==e[t]))){for(a in i)n.o(i,a)&&(n.m[a]=i[a]);if(s)var u=s(n)}for(t&&t(r);cn(93)));a=n.O(a)})(); \ No newline at end of file +(()=>{var e,t={93:(e,t,r)=>{"use strict";const n=window.wp.domReady;var a=r.n(n);const o=window.React,l=window.wp.i18n,i=window.noptinEmailSettingsMisc||{},s=(i.license,window.wp.url),c=window.wp.components,u=window.noptinEmailEditorSettings||{},m=window.noptinEmailSettingsMisc||{},p=(m.license,u.types||{}),d=(Object.keys(p).map((e=>({value:e,label:p[e].label}))),Object.keys(u.templates||{}).map((e=>({value:e,label:u.templates[e]}))),m.license||{}),_=(d.is_usable&&d.key,/_published|_unpublished|_deleted|_user_role$/),g=["noptin_subscriber_","delete_user","new_user","update_user","wp_login","after_password_reset","create_or_update_"],y=[["woocommerce","subscription"],["latest_","_digest"]],b=["WordPress Users"],f=["latest_posts_digest"],h=["periodic"],E=(e,t=void 0)=>{if(!e||f.includes(e))return!1;if(h.includes(e))return!0;if(t&&b.includes(t))return!0;if(y.some((t=>t.every((t=>e.includes(t))))))return!0;const r=e.replace(/^automation_rule_/,"");return _.test(r)?"post_published"!==r:g.some((e=>r.startsWith(e)))};function w(e,t){const r={};Array.isArray(e)||Object.entries(e).forEach((([e,n])=>{if("email"!==e){if(!n.category){if(!i.isTest)return;n.category="Deprecated"}r[n.category]||(r[n.category]={}),r[n.category][e]={...n,selectText:"triggers"===t?(0,l.__)("Use trigger","newsletter-optin-box"):(0,l.__)("Set-up","newsletter-optin-box"),forcePremium:E(e,n.category)},n.alt_category&&(r[n.alt_category]||(r[n.alt_category]={}),r[n.alt_category][e]=r[n.category][e])}})),Array.isArray(i.integrations)&&i.integrations.forEach((n=>{n.plan&&"free"!==n.plan&&n[t]&&!Array.isArray(n[t])&&Object.entries(n[t]).forEach((([t,a])=>{a.forEach((({id:a,label:o,description:l,premium:i=!1})=>{if("premium"===n.plan||i)if(e[a]){const t=e[a].category;t&&r[t][a]&&(r[t][a].forcePremium=!0)}else r[t]||(r[t]={}),r[t][a]={name:a,label:o,description:l,category:t,image:n.icon_url,forcePremium:!0,is_installed:!1,installation:n.installation}}))}))}));const n={},a=(0,l.__)("General","newsletter-optin-box");return r.hasOwnProperty(a)&&(n[a]=r[a]),Object.keys(r).sort().forEach((e=>{e!==a&&(n[e]=r[e])})),n}const v={"noptin-trigger":{title:(0,l.__)("Select a trigger for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-trigger",cardGroups:w(i.data?.triggers||{},"triggers")},"noptin-action":{title:(0,l.__)("Select an action for your automation rule","newsletter-optin-box"),show:!0,arg:"noptin-action",cardGroups:w(i.data?.actions||{},"actions")}},x=(0,o.createContext)(void 0),k=({children:e})=>{const[t,r]=(0,o.useState)(i.data?.add_new||(0,s.addQueryArgs)(window.location.href,{noptin_edit_automation_rule:"0"})),n=(0,o.useMemo)((()=>{let e="";const n={};for(const[r,a]of Object.entries(v)){const o=a.arg?(0,s.getQueryArg)(t,a.arg):"";if(!o){e=r;break}n[r]=o}return{currentTitle:v[e]?.title||"",currentStep:e,isLastStep:e===Object.keys(v).pop(),isFirstStep:e===Object.keys(v)[0],hasSteps:Object.keys(v).length>0,stepValues:n,steps:v,campaign:"automation-rules",removeQueryArgs:(...e)=>{r((0,s.removeQueryArgs)(t,...e))},addQueryArg:(e,n)=>{r((0,s.addQueryArgs)(t,{[e]:n}))},withQueryArg:(e,r)=>(0,s.addQueryArgs)(t,{[e]:r}),url:t}}),[t,r]);return(0,o.createElement)(x.Provider,{value:n},e)};var S=r(942),C=r.n(S);const O=window.wp.element,A=({categories:e,selectedCategory:t,onClickCategory:r})=>{const n="noptin-campaign-explorer__sidebar";return(0,o.createElement)("div",{className:n},(0,o.createElement)("div",{className:`${n}__categories-list`},e.map((e=>(0,o.createElement)(c.Button,{key:e,label:e,className:`${n}__categories-list__item`,isPressed:t===e,onClick:()=>{r(e)}},e)))))},j=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,o.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,o.createElement)(c.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",r=e.path||"",n=e.viewBox||"0 0 24 24";return e.path?(0,o.createElement)(c.SVG,{viewBox:n,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,o.createElement)(c.Path,{fill:t,d:r})):(0,o.createElement)(c.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,o.createElement)(c.Icon,{size:24,icon:"email",style:{color:"#424242"}})},T=({name:e,label:t,description:r,image:n,onSelect:a,hrefCallback:i,href:u,...m})=>{const p=(e=>{const t=e.learnMoreUrl?(0,o.createElement)(c.Button,{variant:"secondary",href:e.learnMoreUrl},(0,o.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,l.__)("Learn More"))," ",(0,o.createElement)(c.Icon,{size:16,icon:"arrow-right-alt"})):null;if(e.forcePremium?!1!==e.is_installed&&e?.licenseDetails?.key:!1!==e.is_installed)return{upgradeText:null,button:(0,o.createElement)(c.Button,{variant:"primary",onClick:e.onClick,href:e.href},(0,o.createElement)("span",{className:"noptin-selectable-card__label"},e.selectText||(0,l.__)("Select"))," ",(0,o.createElement)(c.Icon,{size:16,icon:"arrow-right-alt"})),secondaryButton:t};const r=(t,r)=>!1===e.is_installed&&e.installation?.[t]?e.installation?.[t]:e.licenseDetails[t]||r,n=r("install_desc",(0,l.__)("Activate your license key to unlock","newsletter-optin-box")),a=r("install_text",(0,l.__)("View Pricing","newsletter-optin-box")),i=r("install_url",(0,s.addQueryArgs)("https://noptin.com/pricing/",{utm_source:e.name||"license",utm_campaign:e.campaign||"noptin",utm_medium:"plugin-dashboard"}));return{upgradeText:n,button:(0,o.createElement)(c.Button,{variant:"primary",href:i},(0,o.createElement)("span",{className:"noptin-selectable-card-action__label"},a)," ",(0,o.createElement)(c.Icon,{size:16,icon:"lock"})),secondaryButton:e.licenseDetails?.key?t:(0,o.createElement)(c.Button,{variant:"secondary",href:e.licenseDetails?.activate_url},(0,o.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,l.__)("Activate"))," ",(0,o.createElement)(c.Icon,{size:16,icon:"unlock"}))}})({onClick:(0,o.useCallback)((()=>a?a(e):null),[e,a]),name:e.replace("automation_rule_",""),href:i?i(e):u,...m});return(0,o.createElement)(c.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,size:"small"},(0,o.createElement)(c.CardHeader,null,(0,o.createElement)(c.__experimentalHeading,{level:4,numberOfLines:1},t),(0,o.createElement)(j,{image:n,title:t})),(0,o.createElement)(c.CardBody,null,(0,o.createElement)(c.__experimentalVStack,{spacing:4},r&&(0,o.createElement)(c.__experimentalText,{as:"p",variant:"muted"},r),p.upgradeText&&(0,o.createElement)(c.__experimentalText,{as:"em",isDestructive:!0},p.upgradeText))),(0,o.createElement)(c.CardFooter,{isBorderless:!0,justify:p.secondaryButton?"space-between":"flex-end"},p.secondaryButton,p.button),(0,o.createElement)(c.__experimentalElevation,{value:1,hover:3}))},B=({showTitle:e,selectedCategory:t,cards:r,...n})=>{const a="noptin-campaign-explorer";let l=Object.entries(r);return l.sort(((e,t)=>e[1].label.localeCompare(t[1].label))),(0,o.createElement)("div",{className:`${a}__list`},e&&(0,o.createElement)(c.__experimentalHeading,{level:2,lineHeight:"48px",className:`${a}__category-name`},t),(0,o.createElement)("div",{role:"listbox",className:`${a}-list`},l.map((([e,t])=>(0,o.createElement)(T,{key:e,name:e,...n,...t})))))},M=({cardGroups:e,...t})=>{const r=Object.keys(e).length,[n,a]=(0,o.useState)(Object.keys(e)[0]);(0,o.useEffect)((()=>{r>0&&!e[n]&&a(Object.keys(e)[0])}),[e,n]);const l=r>1,i=(0,o.useMemo)((()=>Object.keys(e)),[e]),s=(0,o.useMemo)((()=>e[n]||{}),[e,n]),c=C()("noptin-campaign-explorer",{"noptin-campaign-explorer--show-sidebar":l});return(0,o.createElement)("div",{className:c},l&&(0,o.createElement)(A,{selectedCategory:n,categories:i,onClickCategory:a}),(0,o.createElement)(B,{showTitle:l,selectedCategory:n,cards:s,...t}))},P=e=>{if(!e.isOpen)return null;const t=e.steps[e.currentStep];if(t.modal)return(0,o.createElement)(c.Modal,{onRequestClose:e.closeModal,...t.modal.props},t.modal.content);if(t.cardGroups){const r=[...Object.keys(e.stepValues)].pop(),n=(0,o.createElement)(o.Fragment,null,r&&!e.isFirstStep&&(0,o.createElement)(c.Button,{icon:"arrow-left-alt",onClick:()=>e.removeQueryArgs(e.steps[r]?.arg||""),label:(0,l.__)("Back","newsletter-optin-box"),showTooltip:!0})),a=e.isLastStep?void 0:r=>{t.arg&&e.addQueryArg(t.arg,r)};return(0,o.createElement)(c.Modal,{title:e.currentTitle,onRequestClose:e.closeModal,headerActions:n,isFullScreen:!0},(0,o.createElement)(M,{cardGroups:t.cardGroups,licenseDetails:e.licenseDetails,onSelect:a,hrefCallback:t.arg&&e.isLastStep?r=>e.withQueryArg(t.arg,r):void 0,campaign:e.campaign}))}return null},I=({buttonProps:e,...t})=>{const[r,n]=(0,o.useState)(!1),a=(0,o.useCallback)((()=>{n(!0)}),[n]),l=(0,o.useCallback)((()=>{n(!1)}),[n]),i=t.currentStep&&t.hasSteps,s={...e,onClick:i?a:void 0,href:i?void 0:t.url};return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.Button,{...s}),(0,o.createElement)(P,{isOpen:r,closeModal:l,...t}))},N=({text:e})=>{const t=(()=>{const e=(0,o.useContext)(x);if(!e)throw new Error("useModal must be used within a ModalProvider");return e})();return(0,o.createElement)(I,{licenseDetails:i.license||{},buttonProps:{variant:"primary",type:"button",text:e||(0,l.__)("Add New Automation","newsletter-optin-box")},...t})},D=({text:e})=>(0,o.createElement)(k,null,(0,o.createElement)(N,{text:e})),z=()=>(0,o.createElement)(c.__experimentalVStack,{alignment:"center",justify:"center",spacing:6,style:{minHeight:320}},(0,o.createElement)(c.Icon,{icon:"admin-generic",size:100,style:{color:"#646970"}}),(0,o.createElement)(c.__experimentalText,{align:"center",color:"#646970",size:16,isBlock:!0},(0,l.__)('Automation rules are simple "if this, then that" commands. Trigger an action when a product is purchased, a user creates an account, someone is tagged, etc.',"newsletter-optin-box")),(0,o.createElement)(D,{text:(0,l.__)("Create your first automation rule","newsletter-optin-box")}),(0,o.createElement)(c.__experimentalText,{align:"center",size:14,isBlock:!0},(0,o.createElement)("a",{href:"https://noptin.com/guide/automation-rules/",style:{color:"#646970"},target:"_blank"},(0,l.__)("Or Learn more","newsletter-optin-box")))),Q=window.wp.apiFetch;var $=r.n(Q);const H=({ruleId:e})=>{const[t,r]=(0,o.useState)(!1);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.Button,{icon:"trash",size:"compact",showTooltip:!0,label:(0,l.__)("Delete","newsletter-optin-box"),type:"button",onClick:()=>r(!0),isDestructive:!0}),t&&(0,o.createElement)(c.Modal,{onRequestClose:()=>r(!1),title:(0,l.__)("Delete Rule","newsletter-optin-box"),size:"small"},(0,o.createElement)(c.__experimentalVStack,{spacing:4},(0,o.createElement)(c.__experimentalText,null,(0,l.__)("Are you sure you want to delete this automation rule?","newsletter-optin-box")),(0,o.createElement)(c.__experimentalHStack,{spacing:4,justify:"flex-start",alignment:"flex-start"},(0,o.createElement)(c.Button,{variant:"primary",text:(0,l.__)("Delete","newsletter-optin-box"),type:"button",onClick:()=>{r(!1);const t=document.querySelector(`.noptin_automation_rule_${e}`);t&&t.classList.add("noptin-fade-out"),$()({path:`/noptin/v1/automation_rules/${e}`,method:"DELETE"}).then((e=>(t&&t.remove(),e))).catch((e=>{alert(e.message),t&&t.classList.remove("noptin-fade-out")}))},isDestructive:!0}),(0,o.createElement)(c.Button,{variant:"secondary",text:(0,l.__)("Cancel","newsletter-optin-box"),type:"button",onClick:()=>r(!1)})))))},L=({ruleId:e,status:t})=>{const[r,n]=(0,o.useState)(t);return(0,o.createElement)(c.ToggleControl,{checked:r,label:r?(0,l.__)("Active","newsletter-optin-box"):(0,l.__)("Inactive","newsletter-optin-box"),className:"noptin-toggle-button",onChange:()=>{n(!r),$()({path:`/noptin/v1/automation_rules/${e}`,method:"PATCH",data:{status:!r}}).catch((e=>{alert(e.message),n(r)}))},__nextHasNoMarginBottom:!0})},F=e=>(0,o.createElement)(c.__experimentalHStack,{alignment:"center",justify:"flex-end",spacing:1},(0,o.createElement)(c.Button,{href:e.editUrl,label:(0,l.__)("Edit","newsletter-optin-box"),size:"compact",icon:"edit",showTooltip:!0}),(0,o.createElement)(H,{ruleId:e.ruleId}),(0,o.createElement)(L,{ruleId:e.ruleId,status:e.status})),G=(e,t)=>{if(t){const r=t.getAttribute("data-app"),n=r?JSON.parse(r):{};O.createRoot?(0,O.createRoot)(t).render((0,o.createElement)(e,{...n})):(0,O.render)((0,o.createElement)(e,{...n}),t)}};a()((()=>{G(z,document.getElementById("noptin-automation-rules__editor--add-new__in-table")),document.querySelectorAll(".noptin-automation-rules__editor--add-new__button").forEach((e=>{G(D,e)})),document.querySelectorAll(".noptin-automation-rule-actions__app").forEach((e=>{G(F,e)}))}))},942:(e,t)=>{var r;!function(){"use strict";var n={}.hasOwnProperty;function a(){for(var e="",t=0;t{if(!r){var l=1/0;for(u=0;u=o)&&Object.keys(n.O).every((e=>n.O[e](r[s])))?r.splice(s--,1):(i=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[r,a,o]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={229:0,833:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,[l,i,s]=r,c=0;if(l.some((t=>0!==e[t]))){for(a in i)n.o(i,a)&&(n.m[a]=i[a]);if(s)var u=s(n)}for(t&&t(r);cn(93)));a=n.O(a)})(); \ No newline at end of file diff --git a/build/Emails/assets/js/view-campaigns.asset.php b/build/Emails/assets/js/view-campaigns.asset.php index db4a0070..77fb8c03 100644 --- a/build/Emails/assets/js/view-campaigns.asset.php +++ b/build/Emails/assets/js/view-campaigns.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '7e85bb9ad39eba4fdd7a'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'a2be524059246c68366e'); diff --git a/build/Emails/assets/js/view-campaigns.js b/build/Emails/assets/js/view-campaigns.js index 76b1724e..f188e3b6 100644 --- a/build/Emails/assets/js/view-campaigns.js +++ b/build/Emails/assets/js/view-campaigns.js @@ -1,5 +1,5 @@ -(()=>{var e,t={893:(e,t,n)=>{"use strict";var r={};n.r(r),n.d(r,{AddNewButton:()=>H,AddNewTable:()=>q,EditParent:()=>Ht,EmailStatus:()=>Lt,Image:()=>W,Section:()=>G,SelectableCard:()=>Q,SelectableCards:()=>X});const a=window.wp.domReady;var i=n.n(a);const o=window.wp.apiFetch;var s=n.n(o);const l=window.React,c=window.noptinEmailSettingsMisc||{},u=(c.license,window.wp.i18n),p=window.wp.url,d=window.wp.components,m=window.noptinEmailEditorSettings||{},f=window.noptinEmailSettingsMisc||{},g=(f.license,m.types||{}),h=(Object.keys(g).map((e=>({value:e,label:g[e].label}))),Object.keys(m.templates||{}).map((e=>({value:e,label:m.templates[e]}))),f.license||{}),y=(h.is_usable&&h.key,/_published|_unpublished|_deleted|_user_role$/),b=["noptin_subscriber_","delete_user","new_user","update_user","wp_login","after_password_reset","create_or_update_"],_=[["woocommerce","subscription"],["latest_","_digest"]],v=["WordPress Users"],w=["latest_posts_digest"],x=["periodic"],k=(e,t=void 0)=>{if(!e||w.includes(e))return!1;if(x.includes(e))return!0;if(t&&v.includes(t))return!0;if(_.some((t=>t.every((t=>e.includes(t))))))return!0;const n=e.replace(/^automation_rule_/,"");return y.test(n)?"post_published"!==n:b.some((e=>n.startsWith(e)))},E=c.data?.add_new||(0,p.addQueryArgs)(window.location.href,{noptin_campaign:0}),S=function(e,t){const n={};Array.isArray(e)||Object.entries(e).forEach((([e,t])=>{if(!t.category){if(!c.isTest)return;t.category="Deprecated"}n[t.category]||(n[t.category]={}),n[t.category][e]={...t,forcePremium:k(e,t.category)},t.alt_category&&(n[t.alt_category]||(n[t.alt_category]={}),n[t.alt_category][e]=n[t.category][e])})),"automation_type"===t&&Array.isArray(c.integrations)&&c.integrations.forEach((t=>{t.plan&&"free"!==t.plan&&t.triggers&&!Array.isArray(t.triggers)&&Object.entries(t.triggers).forEach((([r,a])=>{a.forEach((({id:a,label:i,description:o,premium:s=!1})=>{if("premium"!==t.plan&&!s)return;const l=`automation_rule_${a}`;if(e[l]){const t=e[l].category;t&&n[t][l]&&(n[t][l].forcePremium=!0)}else n[r]||(n[r]={}),n[r][l]={label:i,description:(0,u.sprintf)((0,u.__)("Sends an email %s","newsletter-optin-box"),o.charAt(0).toLowerCase()+o.slice(1)),category:r,image:t.icon_url,forcePremium:!0,is_installed:!1,installation:t.installation}}))}))}));const r={};return Object.keys(n).sort().forEach((e=>{r[e]=n[e]})),r}(c.data?.sub_types||{},`${c.data?.type||"any"}_type`),C={select_type:{title:(0,u.__)("Select Campaign Type","newsletter-optin-box"),show:Object.keys(S).length>0,arg:"noptin_email_sub_type",cardGroups:S},select_sender:{title:(0,u.__)("Send to","newsletter-optin-box"),show:!!c.data?.supports_recipients,arg:"noptin_email_sender",cardGroups:{[(0,u.__)("Send to","newsletter-optin-box")]:Object.entries(c.senders||{}).reduce(((e,[t,n])=>(e[t]={...n,forcePremium:!["noptin","manual_recipients"].includes(t)},e[t].integration&&Array.isArray(c.integrations)&&c.integrations.forEach((n=>{e[t].integration===n.slug&&(e[t].installation=n.installation)})),e)),{})}},campaign_name:{title:c.data?.new_campaign_label,show:!!c.data?.child_type,modal:{props:{title:c.data?.new_campaign_label,size:"medium"},content:(0,l.createElement)((()=>{const[e,t]=(0,l.useState)(""),[n,r]=(0,l.useState)(!1),[a,i]=(0,l.useState)(""),o=(0,l.useCallback)((t=>{t.preventDefault(),e&&(i(""),r(!0),s()({path:"/wp/v2/noptin-campaign",method:"POST",data:{title:e,status:"publish",meta:{campaign_type:c.data?.type}}}).then((e=>{e.noptin_campaign_type?.edit_url?window.location.href=e.noptin_campaign_type.edit_url:window.location.href=window.location.href})).catch((e=>{i(e.message),r(!1)})))}),[e]);return(0,l.createElement)(d.__experimentalVStack,{as:"form",onSubmit:o,style:{opacity:n?.5:1}},(0,l.createElement)(d.__experimentalInputControl,{label:(0,u.sprintf)(/* translators: %s: campaign type */ /* translators: %s: campaign type */ -(0,u.__)("%s name","newsletter-optin-box"),c.data?.label),help:(0,u.__)("Enter a name for your campaign","newsletter-optin-box"),value:e,onChange:t,style:{width:"100%"},required:!0,disabled:n,suffix:(0,l.createElement)(d.Button,{variant:"primary",type:"submit",disabled:!e,isBusy:n,isPressed:n},(0,u.__)("Create","newsletter-optin-box"),n&&(0,l.createElement)(d.Spinner,null))}),a&&(0,l.createElement)(d.Notice,{status:"error",onDismiss:()=>i("")},a))}),null)}}},A=Object.entries(C).reduce(((e,[t,n])=>(n.show&&(e[t]=n),e)),{}),O=(0,l.createContext)(void 0),P=({children:e})=>{const[t,n]=(0,l.useState)(E),r=(0,l.useMemo)((()=>{let e="";const r={};for(const[n,a]of Object.entries(A)){const i=a.arg?(0,p.getQueryArg)(t,a.arg):"";if(!i){e=n;break}r[n]=i}return{currentTitle:A[e]?.title||"",currentStep:e,isLastStep:e===Object.keys(A).pop(),isFirstStep:e===Object.keys(A)[0],hasSteps:Object.keys(A).length>0,stepValues:r,steps:A,campaign:`${c.data?.type||"noptin"}-emails`,removeQueryArgs:(...e)=>{n((0,p.removeQueryArgs)(t,...e))},addQueryArg:(e,r)=>{n((0,p.addQueryArgs)(t,{[e]:r}))},withQueryArg:(e,n)=>(0,p.addQueryArgs)(t,{[e]:n}),url:t}}),[t,n]);return(0,l.createElement)(O.Provider,{value:r},e)};var T=n(942),$=n.n(T);const j=window.wp.element,M=({categories:e,selectedCategory:t,onClickCategory:n})=>{const r="noptin-campaign-explorer__sidebar";return(0,l.createElement)("div",{className:r},(0,l.createElement)("div",{className:`${r}__categories-list`},e.map((e=>(0,l.createElement)(d.Button,{key:e,label:e,className:`${r}__categories-list__item`,isPressed:t===e,onClick:()=>{n(e)}},e)))))},B=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,l.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,l.createElement)(d.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",n=e.path||"",r=e.viewBox||"0 0 24 24";return e.path?(0,l.createElement)(d.SVG,{viewBox:r,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,l.createElement)(d.Path,{fill:t,d:n})):(0,l.createElement)(d.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,l.createElement)(d.Icon,{size:24,icon:"email",style:{color:"#424242"}})},z=({name:e,label:t,description:n,image:r,onSelect:a,hrefCallback:i,href:o,...s})=>{const c=(e=>{const t=e.learnMoreUrl?(0,l.createElement)(d.Button,{variant:"secondary",href:e.learnMoreUrl},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,u.__)("Learn More"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"arrow-right-alt"})):null;if(e.forcePremium?!1!==e.is_installed&&e?.licenseDetails?.key:!1!==e.is_installed)return{upgradeText:null,button:(0,l.createElement)(d.Button,{variant:"primary",onClick:e.onClick,href:e.href},(0,l.createElement)("span",{className:"noptin-selectable-card__label"},e.selectText||(0,u.__)("Select"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"arrow-right-alt"})),secondaryButton:t};const n=(t,n)=>!1===e.is_installed&&e.installation?.[t]?e.installation?.[t]:e.licenseDetails[t]||n,r=n("install_desc",(0,u.__)("Activate your license key to unlock","newsletter-optin-box")),a=n("install_text",(0,u.__)("View Pricing","newsletter-optin-box")),i=n("install_url",(0,p.addQueryArgs)("https://noptin.com/pricing/",{utm_source:e.name||"license",utm_campaign:e.campaign||"noptin",utm_medium:"plugin-dashboard"}));return{upgradeText:r,button:(0,l.createElement)(d.Button,{variant:"primary",href:i},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},a)," ",(0,l.createElement)(d.Icon,{size:16,icon:"lock"})),secondaryButton:e.licenseDetails?.key?t:(0,l.createElement)(d.Button,{variant:"secondary",href:e.licenseDetails?.activate_url},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,u.__)("Activate"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"unlock"}))}})({onClick:(0,l.useCallback)((()=>a?a(e):null),[e,a]),name:e.replace("automation_rule_",""),href:i?i(e):o,...s});return(0,l.createElement)(d.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,size:"small"},(0,l.createElement)(d.CardHeader,null,(0,l.createElement)(d.__experimentalHeading,{level:4,numberOfLines:1},t),(0,l.createElement)(B,{image:r,title:t})),(0,l.createElement)(d.CardBody,null,(0,l.createElement)(d.__experimentalVStack,{spacing:4},n&&(0,l.createElement)(d.__experimentalText,{as:"p",variant:"muted"},n),c.upgradeText&&(0,l.createElement)(d.__experimentalText,{as:"em",isDestructive:!0},c.upgradeText))),(0,l.createElement)(d.CardFooter,{isBorderless:!0,justify:c.secondaryButton?"space-between":"flex-end"},c.secondaryButton,c.button),(0,l.createElement)(d.__experimentalElevation,{value:1,hover:3}))},N=({showTitle:e,selectedCategory:t,cards:n,...r})=>{const a="noptin-campaign-explorer";return(0,l.createElement)("div",{className:`${a}__list`},e&&(0,l.createElement)(d.__experimentalHeading,{level:2,lineHeight:"48px",className:`${a}__category-name`},t),(0,l.createElement)("div",{role:"listbox",className:`${a}-list`},Object.keys(n).sort().map((e=>(0,l.createElement)(z,{key:e,name:e,...r,...n[e]})))))},I=({cardGroups:e,...t})=>{const n=Object.keys(e).length,[r,a]=(0,l.useState)(Object.keys(e)[0]);(0,l.useEffect)((()=>{n>0&&!e[r]&&a(Object.keys(e)[0])}),[e,r]);const i=n>1,o=(0,l.useMemo)((()=>Object.keys(e)),[e]),s=(0,l.useMemo)((()=>e[r]||{}),[e,r]),c=$()("noptin-campaign-explorer",{"noptin-campaign-explorer--show-sidebar":i});return(0,l.createElement)("div",{className:c},i&&(0,l.createElement)(M,{selectedCategory:r,categories:o,onClickCategory:a}),(0,l.createElement)(N,{showTitle:i,selectedCategory:r,cards:s,...t}))},R=e=>{if(!e.isOpen)return null;const t=e.steps[e.currentStep];if(t.modal)return(0,l.createElement)(d.Modal,{onRequestClose:e.closeModal,...t.modal.props},t.modal.content);if(t.cardGroups){const n=[...Object.keys(e.stepValues)].pop(),r=(0,l.createElement)(l.Fragment,null,n&&!e.isFirstStep&&(0,l.createElement)(d.Button,{icon:"arrow-left-alt",onClick:()=>e.removeQueryArgs(e.steps[n]?.arg||""),label:(0,u.__)("Back","newsletter-optin-box"),showTooltip:!0})),a=e.isLastStep?void 0:n=>{t.arg&&e.addQueryArg(t.arg,n)};return(0,l.createElement)(d.Modal,{title:e.currentTitle,onRequestClose:e.closeModal,headerActions:r,isFullScreen:!0},(0,l.createElement)(I,{cardGroups:t.cardGroups,licenseDetails:e.licenseDetails,onSelect:a,hrefCallback:t.arg&&e.isLastStep?n=>e.withQueryArg(t.arg,n):void 0,campaign:e.campaign}))}return null},D=({buttonProps:e,...t})=>{const[n,r]=(0,l.useState)(!1),a=(0,l.useCallback)((()=>{r(!0)}),[r]),i=(0,l.useCallback)((()=>{r(!1)}),[r]),o=t.currentStep&&t.hasSteps,s={...e,onClick:o?a:void 0,href:o?void 0:t.url};return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(d.Button,{...s}),(0,l.createElement)(R,{isOpen:n,closeModal:i,...t}))},L={variant:"primary",text:c.data?.new_campaign_label,type:"button"},F=()=>{const e=(()=>{const e=(0,l.useContext)(O);if(!e)throw new Error("useModal must be used within a ModalProvider");return e})();return(0,l.createElement)(D,{licenseDetails:c.license||{},buttonProps:L,...e})},H=()=>(0,l.createElement)(P,null,(0,l.createElement)(F,null)),q=()=>(0,l.createElement)(d.__experimentalVStack,{alignment:"center",justify:"center",spacing:6,style:{minHeight:320}},(0,l.createElement)(d.Icon,{icon:c.data?.icon,size:100,style:{color:"#646970"}}),(0,l.createElement)(d.__experimentalText,{align:"center",color:"#646970",size:16,isBlock:!0},c.data?.upsell||c.data?.click_to_add_first),c.data?.click_to_add_first&&(0,l.createElement)(H,null),!c.data?.click_to_add_first&&(0,l.createElement)(d.Button,{text:(0,u.__)("View Pricing","newsletter-optin-box"),href:"https://noptin.com/pricing/?utm_source=sequence&utm_medium=plugin&utm_campaign=email-campaigns",variant:"primary",target:"_blank"}));function G({title:e,isSecodary:t,className:n,children:r}){const[a,i]=(0,l.useState)(!0),o=$()(n,"noptin-component__section");return(0,l.createElement)(d.Card,{variant:t?"secondary":"primary",className:o},(0,l.createElement)(d.CardHeader,null,(0,l.createElement)(d.Flex,null,(0,l.createElement)(d.FlexBlock,null,(0,l.createElement)("h3",null,e)),(0,l.createElement)(d.FlexItem,null,(0,l.createElement)(d.Button,{variant:"tertiary",onClick:()=>i(!a),icon:a?"arrow-up-alt2":"arrow-down-alt2"})))),a&&r)}const V=c.license||{},W=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,l.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,l.createElement)(d.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",n=e.path||"",r=e.viewBox||"0 0 24 24";return e.path?(0,l.createElement)(d.SVG,{viewBox:r,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,l.createElement)(d.Path,{fill:t,d:n})):(0,l.createElement)(d.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,l.createElement)(d.Icon,{size:24,icon:"email",style:{color:"#424242"}})},Q=({name:e,label:t,description:n,image:r,selectText:a,is_installed:i,forcePremium:o,onSelect:s})=>{const m=(0,l.useCallback)((()=>s(e)),[e,s]),[f,g]=((e,t,n,r,a)=>{if(t?e&&V.key:e)return[null,(0,l.createElement)(d.Button,{variant:"primary",onClick:r},(0,l.createElement)("span",{className:"noptin-selectable-card__label"},a||(0,u.__)("Select"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"arrow-right-alt"}))];const i=!e&&V.install_desc||(0,u.__)("Activate your license key to unlock","newsletter-optin-box"),o=!e&&V.install_text||(0,u.__)("View Pricing","newsletter-optin-box");let s=!e&&V.install_url||V.upgrade_url||"https://noptin.com/pricing/";V.key||(s=(0,p.addQueryArgs)(s,{utm_source:n,utm_campaign:(c.data?.type||"noptin")+"-emails"}));const m=V.key?"primary":"secondary";return[i,(0,l.createElement)(d.Button,{variant:m,href:s},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},o)," ",(0,l.createElement)(d.Icon,{size:16,icon:"lock"}))]})(!1!==i,o||!1,e,m,a);return(0,l.createElement)(d.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,onClick:f?void 0:m,size:"small"},(0,l.createElement)(d.CardHeader,null,(0,l.createElement)(d.__experimentalHeading,{level:4,numberOfLines:1},t),(0,l.createElement)(W,{image:r,title:t})),(0,l.createElement)(d.CardBody,null,(0,l.createElement)(d.__experimentalVStack,{spacing:4},n&&(0,l.createElement)(d.__experimentalText,{as:"p",variant:"muted"},n),f&&(0,l.createElement)(d.__experimentalText,{as:"em",isDestructive:!0},f))),(0,l.createElement)(d.CardFooter,{isBorderless:!0,justify:"flex-end"},g),(0,l.createElement)(d.__experimentalElevation,{value:1,hover:3,isInteractive:!0}))},U=({showingAll:e=!0,cards:t,onSelect:n})=>{const r=Object.entries(t),a=e?r:r.slice(0,3);return(0,l.createElement)(d.Flex,{className:"noptin-selectable-card",justify:"left",align:"stretch",wrap:!0},a.map((([e,t],r)=>(0,l.createElement)(Q,{key:`${e}__${r}`,onSelect:n,name:e,...t}))))},X=({cards:e,title:t,onSelect:n,onGroupSelect:r,unwrap:a=!1})=>{const i=Object.keys(e).length,o=r&&i>3;if(console.log(i),0===i)return null;const s=(0,l.createElement)(U,{cards:e,onSelect:n,showingAll:a||!o});if(a)return s;const c={};return o&&(c["aria-expanded"]="false",c.onClick=()=>r&&r(t),c.label=(0,u.__)("Show all","newsletter-optin-box"),c.showTooltip=!0),(0,l.createElement)(d.__experimentalVStack,{spacing:2},(0,l.createElement)(d.__experimentalHStack,{as:o?d.Button:"h2",...c},t),s)};function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?se(ye,--ge):0,me--,10===he&&(me=1,de--),he}function we(){return he=ge2||Se(he)>3?"":" "}function Te(e,t){for(;--t&&we()&&!(he<48||he>102||he>57&&he<65||he>70&&he<97););return Ee(e,ke()+(t<6&&32==xe()&&32==we()))}function $e(e){for(;we();)switch(he){case e:return ge;case 34:case 39:34!==e&&39!==e&&$e(he);break;case 40:41===e&&$e(e);break;case 92:we()}return ge}function je(e,t){for(;we()&&e+he!==57&&(e+he!==84||47!==xe()););return"/*"+Ee(t,ge-1)+"*"+ne(47===e?e:we())}function Me(e){for(;!Se(xe());)we();return Ee(e,ge)}var Be="-ms-",ze="-moz-",Ne="-webkit-",Ie="comm",Re="rule",De="decl",Le="@keyframes";function Fe(e,t){for(var n="",r=ue(e),a=0;a0&&ce(k)-p&&pe(m>32?Qe(k+";",r,n,p-1):Qe(ie(k," ","")+";",r,n,p-2),l);break;case 59:k+=";";default:if(pe(x=Ve(k,t,n,c,u,a,s,_,v=[],w=[],p),i),123===b)if(0===u)Ge(k,t,x,x,v,i,p,s,w);else switch(99===d&&110===se(k,3)?100:d){case 100:case 108:case 109:case 115:Ge(e,x,x,r&&pe(Ve(e,x,x,0,0,a,s,_,a,v=[],p),w),a,w,p,s,r?v:w);break;default:Ge(k,x,x,x,[""],w,0,s,w)}}c=u=m=0,g=y=1,_=k="",p=o;break;case 58:p=1+ce(k),m=f;default:if(g<1)if(123==b)--g;else if(125==b&&0==g++&&125==ve())continue;switch(k+=ne(b),b*g){case 38:y=u>0?1:(k+="\f",-1);break;case 44:s[c++]=(ce(k)-1)*y,y=1;break;case 64:45===xe()&&(k+=Oe(we())),d=xe(),u=p=ce(_=k+=Me(ke())),b++;break;case 45:45===f&&2==ce(k)&&(g=0)}}return i}function Ve(e,t,n,r,a,i,o,s,l,c,u){for(var p=a-1,d=0===a?i:[""],m=ue(d),f=0,g=0,h=0;f0?d[y]+" "+b:ie(b,/&\f/g,d[y])))&&(l[h++]=_);return be(e,t,n,0===a?Re:s,l,c,u)}function We(e,t,n){return be(e,t,n,Ie,ne(he),le(e,2,-2),0)}function Qe(e,t,n,r){return be(e,t,n,De,le(e,0,r),le(e,r+1,-1),r)}var Ue=function(e,t,n){for(var r=0,a=0;r=a,a=xe(),38===r&&12===a&&(t[n]=1),!Se(a);)we();return Ee(e,ge)},Xe=new WeakMap,Ye=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||Xe.get(n))&&!r){Xe.set(e,!0);for(var a=[],i=function(e,t){return Ae(function(e,t){var n=-1,r=44;do{switch(Se(r)){case 0:38===r&&12===xe()&&(t[n]=1),e[n]+=Ue(ge-1,t,n);break;case 2:e[n]+=Oe(r);break;case 4:if(44===r){e[++n]=58===xe()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=ne(r)}}while(r=we());return e}(Ce(e),t))}(t,a),o=n.props,s=0,l=0;s6)switch(se(e,t+1)){case 109:if(45!==se(e,t+4))break;case 102:return ie(e,/(.+:)(.+)-([^]+)/,"$1"+Ne+"$2-$3$1"+ze+(108==se(e,t+3)?"$3":"$2-$3"))+e;case 115:return~oe(e,"stretch")?Ze(ie(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==se(e,t+1))break;case 6444:switch(se(e,ce(e)-3-(~oe(e,"!important")&&10))){case 107:return ie(e,":",":"+Ne)+e;case 101:return ie(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ne+(45===se(e,14)?"inline-":"")+"box$3$1"+Ne+"$2$3$1"+Be+"$2box$3")+e}break;case 5936:switch(se(e,t+11)){case 114:return Ne+e+Be+ie(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ne+e+Be+ie(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ne+e+Be+ie(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ne+e+Be+e+e}return e}var Je=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case De:e.return=Ze(e.value,e.length);break;case Le:return Fe([_e(e,{value:ie(e.value,"@","@"+Ne)})],r);case Re:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return Fe([_e(e,{props:[ie(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return Fe([_e(e,{props:[ie(t,/:(plac\w+)/,":"+Ne+"input-$1")]}),_e(e,{props:[ie(t,/:(plac\w+)/,":-moz-$1")]}),_e(e,{props:[ie(t,/:(plac\w+)/,Be+"input-$1")]})],r)}return""}))}}],et=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r,a,i=e.stylisPlugins||Je,o={},s=[];r=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n96?ht:yt},_t=function(e,t,n){var r;if(t){var a=t.shouldForwardProp;r=e.__emotion_forwardProp&&a?function(t){return e.__emotion_forwardProp(t)&&a(t)}:a}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},vt=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return gt(t,n,r),dt((function(){return function(e,t,n){gt(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var a=t;do{e.insert(t===a?"."+r:"",a,e.sheet,!0),a=a.next}while(void 0!==a)}}(t,n,r)})),null},wt=function e(t,n){var r,a,i=t.__emotion_real===t,o=i&&t.__emotion_base||t;void 0!==n&&(r=n.label,a=n.target);var s=_t(t,n,i),c=s||bt(o),u=!c("as");return function(){var p=arguments,d=i&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==r&&d.push("label:"+r+";"),null==p[0]||void 0===p[0].raw)d.push.apply(d,p);else{d.push(p[0][0]);for(var m=p.length,f=1;f=4;++r,a-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(a){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(a)+l;return{name:c,styles:a,next:ct}}(d.concat(h),t.registered,y);g+=t.key+"-"+_.name,void 0!==a&&(g+=" "+a);var v=u&&void 0===s?bt(f):c,w={};for(var x in e)u&&"as"===x||v(x)&&(w[x]=e[x]);return w.className=g,w.ref=n,l.createElement(l.Fragment,null,l.createElement(vt,{cache:t,serialized:_,isStringTag:"string"==typeof f}),l.createElement(f,w))},(0,l.forwardRef)((function(e,t){var n=(0,l.useContext)(mt);return g(e,n,t)})));return h.displayName=void 0!==r?r:"Styled("+("string"==typeof o?o:o.displayName||o.name||"Component")+")",h.defaultProps=t.defaultProps,h.__emotion_real=h,h.__emotion_base=o,h.__emotion_styles=d,h.__emotion_forwardProp=s,Object.defineProperty(h,"toString",{value:function(){return"."+a}}),h.withComponent=function(t,r){return e(t,Y({},n,r,{shouldForwardProp:_t(h,r,!0)})).apply(void 0,d)},h}}.bind();["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){wt[e]=wt(e)}));const xt=[0,100],kt=[0,100],Et=e=>`${1===e.length?"0":""}${e}`,St=(e,t,n)=>Math.max(Math.min(e,n),t),Ct=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,At=(e,t,n)=>{const r=Ct(e,t);for(let a=0;a=i[0]&&r<=i[1])return At(e,t,n)}return r},Ot=(e,t)=>"number"==typeof t?t:e%Math.abs(t[1]-t[0])+t[0],Pt=(e,t)=>"number"==typeof e?St(Math.abs(e),...t):1===e.length||e[0]===e[1]?St(Math.abs(e[0]),...t):[Math.abs(St(e[0],...t)),St(Math.abs(e[1]),...t)],Tt=(e,t,n)=>(n<0?n+=1:n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e),$t=(e,t,n)=>{let r,a,i;if(e/=360,n/=100,0==(t/=100))r=a=i=n;else{const o=n<.5?n*(1+t):n+t-n*t,s=2*n-o;r=Tt(s,o,e+1/3),a=Tt(s,o,e),i=Tt(s,o,e-1/3)}return[Math.round(255*r),Math.round(255*a),Math.round(255*i)]},jt=(e,t,n,r)=>(299*e+587*t+114*n)/1e3>=r,Mt=(e,t,n)=>`hsl(${e}, ${t}%, ${n}%)`,Bt=(e,t,n,r)=>"rgb"===r?`rgb(${e}, ${t}, ${n})`:`#${Et(e.toString(16))}${Et(t.toString(16))}${Et(n.toString(16))}`,zt=(e,{format:t="hex",saturation:n=[50,55],lightness:r=[50,60],differencePoint:a=130}={})=>{const i=Math.abs((e=>{const t=e.length;let n=0;for(let r=0;r{t=Pt(t,xt),n=Pt(n,kt);const i=a?At(0,359,a):Ct(0,359),o="number"==typeof t?t:Ct(...t),s="number"==typeof n?n:Ct(...n),[l,c,u]=$t(i,o,s);return{color:"hsl"===e?Mt(i,o,s):Bt(l,c,u,e),isLight:jt(l,c,u,r)}};const Nt=zt,It=wt.span` +(()=>{var e,t={893:(e,t,n)=>{"use strict";var r={};n.r(r),n.d(r,{AddNewButton:()=>H,AddNewTable:()=>q,EditParent:()=>Ht,EmailStatus:()=>Lt,Image:()=>W,Section:()=>G,SelectableCard:()=>Q,SelectableCards:()=>X});const a=window.wp.domReady;var i=n.n(a);const o=window.wp.apiFetch;var s=n.n(o);const l=window.React,c=window.noptinEmailSettingsMisc||{},u=(c.license,window.wp.i18n),p=window.wp.url,d=window.wp.components,m=window.noptinEmailEditorSettings||{},f=window.noptinEmailSettingsMisc||{},g=(f.license,m.types||{}),h=(Object.keys(g).map((e=>({value:e,label:g[e].label}))),Object.keys(m.templates||{}).map((e=>({value:e,label:m.templates[e]}))),f.license||{}),y=(h.is_usable&&h.key,/_published|_unpublished|_deleted|_user_role$/),b=["noptin_subscriber_","delete_user","new_user","update_user","wp_login","after_password_reset","create_or_update_"],_=[["woocommerce","subscription"],["latest_","_digest"]],v=["WordPress Users"],w=["latest_posts_digest"],x=["periodic"],k=(e,t=void 0)=>{if(!e||w.includes(e))return!1;if(x.includes(e))return!0;if(t&&v.includes(t))return!0;if(_.some((t=>t.every((t=>e.includes(t))))))return!0;const n=e.replace(/^automation_rule_/,"");return y.test(n)?"post_published"!==n:b.some((e=>n.startsWith(e)))},E=c.data?.add_new||(0,p.addQueryArgs)(window.location.href,{noptin_campaign:0}),S=function(e,t){const n={};Array.isArray(e)||Object.entries(e).forEach((([e,t])=>{if(!t.category){if(!c.isTest)return;t.category="Deprecated"}n[t.category]||(n[t.category]={}),n[t.category][e]={...t,forcePremium:k(e,t.category)},t.alt_category&&(n[t.alt_category]||(n[t.alt_category]={}),n[t.alt_category][e]=n[t.category][e])})),"automation_type"===t&&Array.isArray(c.integrations)&&c.integrations.forEach((t=>{t.plan&&"free"!==t.plan&&t.triggers&&!Array.isArray(t.triggers)&&Object.entries(t.triggers).forEach((([r,a])=>{a.forEach((({id:a,label:i,description:o,premium:s=!1})=>{if("premium"!==t.plan&&!s)return;const l=`automation_rule_${a}`;if(e[l]){const t=e[l].category;t&&n[t][l]&&(n[t][l].forcePremium=!0)}else n[r]||(n[r]={}),n[r][l]={label:i,description:(0,u.sprintf)((0,u.__)("Sends an email %s","newsletter-optin-box"),o.charAt(0).toLowerCase()+o.slice(1)),category:r,image:t.icon_url,forcePremium:!0,is_installed:!1,installation:t.installation}}))}))}));const r={},a=(0,u.__)("Recurring","newsletter-optin-box");return n.hasOwnProperty(a)&&(r[a]=n[a]),Object.keys(n).sort().forEach((e=>{e!==a&&(r[e]=n[e])})),r}(c.data?.sub_types||{},`${c.data?.type||"any"}_type`),C={select_type:{title:(0,u.__)("Select Campaign Type","newsletter-optin-box"),show:Object.keys(S).length>0,arg:"noptin_email_sub_type",cardGroups:S},select_sender:{title:(0,u.__)("Send to","newsletter-optin-box"),show:!!c.data?.supports_recipients,arg:"noptin_email_sender",cardGroups:{[(0,u.__)("Send to","newsletter-optin-box")]:Object.entries(c.senders||{}).reduce(((e,[t,n])=>(e[t]={...n,forcePremium:!["noptin","manual_recipients"].includes(t)},e[t].integration&&Array.isArray(c.integrations)&&c.integrations.forEach((n=>{e[t].integration===n.slug&&(e[t].installation=n.installation)})),e)),{})}},campaign_name:{title:c.data?.new_campaign_label,show:!!c.data?.child_type,modal:{props:{title:c.data?.new_campaign_label,size:"medium"},content:(0,l.createElement)((()=>{const[e,t]=(0,l.useState)(""),[n,r]=(0,l.useState)(!1),[a,i]=(0,l.useState)(""),o=(0,l.useCallback)((t=>{t.preventDefault(),e&&(i(""),r(!0),s()({path:"/wp/v2/noptin-campaign",method:"POST",data:{title:e,status:"publish",meta:{campaign_type:c.data?.type}}}).then((e=>{e.noptin_campaign_type?.edit_url?window.location.href=e.noptin_campaign_type.edit_url:window.location.href=window.location.href})).catch((e=>{i(e.message),r(!1)})))}),[e]);return(0,l.createElement)(d.__experimentalVStack,{as:"form",onSubmit:o,style:{opacity:n?.5:1}},(0,l.createElement)(d.__experimentalInputControl,{label:(0,u.sprintf)(/* translators: %s: campaign type */ /* translators: %s: campaign type */ +(0,u.__)("%s name","newsletter-optin-box"),c.data?.label),help:(0,u.__)("Enter a name for your campaign","newsletter-optin-box"),value:e,onChange:t,style:{width:"100%"},required:!0,disabled:n,suffix:(0,l.createElement)(d.Button,{variant:"primary",type:"submit",disabled:!e,isBusy:n,isPressed:n},(0,u.__)("Create","newsletter-optin-box"),n&&(0,l.createElement)(d.Spinner,null))}),a&&(0,l.createElement)(d.Notice,{status:"error",onDismiss:()=>i("")},a))}),null)}}},A=Object.entries(C).reduce(((e,[t,n])=>(n.show&&(e[t]=n),e)),{}),O=(0,l.createContext)(void 0),P=({children:e})=>{const[t,n]=(0,l.useState)(E),r=(0,l.useMemo)((()=>{let e="";const r={};for(const[n,a]of Object.entries(A)){const i=a.arg?(0,p.getQueryArg)(t,a.arg):"";if(!i){e=n;break}r[n]=i}return{currentTitle:A[e]?.title||"",currentStep:e,isLastStep:e===Object.keys(A).pop(),isFirstStep:e===Object.keys(A)[0],hasSteps:Object.keys(A).length>0,stepValues:r,steps:A,campaign:`${c.data?.type||"noptin"}-emails`,removeQueryArgs:(...e)=>{n((0,p.removeQueryArgs)(t,...e))},addQueryArg:(e,r)=>{n((0,p.addQueryArgs)(t,{[e]:r}))},withQueryArg:(e,n)=>(0,p.addQueryArgs)(t,{[e]:n}),url:t}}),[t,n]);return(0,l.createElement)(O.Provider,{value:r},e)};var T=n(942),$=n.n(T);const j=window.wp.element,M=({categories:e,selectedCategory:t,onClickCategory:n})=>{const r="noptin-campaign-explorer__sidebar";return(0,l.createElement)("div",{className:r},(0,l.createElement)("div",{className:`${r}__categories-list`},e.map((e=>(0,l.createElement)(d.Button,{key:e,label:e,className:`${r}__categories-list__item`,isPressed:t===e,onClick:()=>{n(e)}},e)))))},B=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,l.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,l.createElement)(d.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",n=e.path||"",r=e.viewBox||"0 0 24 24";return e.path?(0,l.createElement)(d.SVG,{viewBox:r,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,l.createElement)(d.Path,{fill:t,d:n})):(0,l.createElement)(d.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,l.createElement)(d.Icon,{size:24,icon:"email",style:{color:"#424242"}})},z=({name:e,label:t,description:n,image:r,onSelect:a,hrefCallback:i,href:o,...s})=>{const c=(e=>{const t=e.learnMoreUrl?(0,l.createElement)(d.Button,{variant:"secondary",href:e.learnMoreUrl},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,u.__)("Learn More"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"arrow-right-alt"})):null;if(e.forcePremium?!1!==e.is_installed&&e?.licenseDetails?.key:!1!==e.is_installed)return{upgradeText:null,button:(0,l.createElement)(d.Button,{variant:"primary",onClick:e.onClick,href:e.href},(0,l.createElement)("span",{className:"noptin-selectable-card__label"},e.selectText||(0,u.__)("Select"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"arrow-right-alt"})),secondaryButton:t};const n=(t,n)=>!1===e.is_installed&&e.installation?.[t]?e.installation?.[t]:e.licenseDetails[t]||n,r=n("install_desc",(0,u.__)("Activate your license key to unlock","newsletter-optin-box")),a=n("install_text",(0,u.__)("View Pricing","newsletter-optin-box")),i=n("install_url",(0,p.addQueryArgs)("https://noptin.com/pricing/",{utm_source:e.name||"license",utm_campaign:e.campaign||"noptin",utm_medium:"plugin-dashboard"}));return{upgradeText:r,button:(0,l.createElement)(d.Button,{variant:"primary",href:i},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},a)," ",(0,l.createElement)(d.Icon,{size:16,icon:"lock"})),secondaryButton:e.licenseDetails?.key?t:(0,l.createElement)(d.Button,{variant:"secondary",href:e.licenseDetails?.activate_url},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},(0,u.__)("Activate"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"unlock"}))}})({onClick:(0,l.useCallback)((()=>a?a(e):null),[e,a]),name:e.replace("automation_rule_",""),href:i?i(e):o,...s});return(0,l.createElement)(d.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,size:"small"},(0,l.createElement)(d.CardHeader,null,(0,l.createElement)(d.__experimentalHeading,{level:4,numberOfLines:1},t),(0,l.createElement)(B,{image:r,title:t})),(0,l.createElement)(d.CardBody,null,(0,l.createElement)(d.__experimentalVStack,{spacing:4},n&&(0,l.createElement)(d.__experimentalText,{as:"p",variant:"muted"},n),c.upgradeText&&(0,l.createElement)(d.__experimentalText,{as:"em",isDestructive:!0},c.upgradeText))),(0,l.createElement)(d.CardFooter,{isBorderless:!0,justify:c.secondaryButton?"space-between":"flex-end"},c.secondaryButton,c.button),(0,l.createElement)(d.__experimentalElevation,{value:1,hover:3}))},N=({showTitle:e,selectedCategory:t,cards:n,...r})=>{const a="noptin-campaign-explorer";let i=Object.entries(n);return i.sort(((e,t)=>e[1].label.localeCompare(t[1].label))),(0,l.createElement)("div",{className:`${a}__list`},e&&(0,l.createElement)(d.__experimentalHeading,{level:2,lineHeight:"48px",className:`${a}__category-name`},t),(0,l.createElement)("div",{role:"listbox",className:`${a}-list`},i.map((([e,t])=>(0,l.createElement)(z,{key:e,name:e,...r,...t})))))},I=({cardGroups:e,...t})=>{const n=Object.keys(e).length,[r,a]=(0,l.useState)(Object.keys(e)[0]);(0,l.useEffect)((()=>{n>0&&!e[r]&&a(Object.keys(e)[0])}),[e,r]);const i=n>1,o=(0,l.useMemo)((()=>Object.keys(e)),[e]),s=(0,l.useMemo)((()=>e[r]||{}),[e,r]),c=$()("noptin-campaign-explorer",{"noptin-campaign-explorer--show-sidebar":i});return(0,l.createElement)("div",{className:c},i&&(0,l.createElement)(M,{selectedCategory:r,categories:o,onClickCategory:a}),(0,l.createElement)(N,{showTitle:i,selectedCategory:r,cards:s,...t}))},R=e=>{if(!e.isOpen)return null;const t=e.steps[e.currentStep];if(t.modal)return(0,l.createElement)(d.Modal,{onRequestClose:e.closeModal,...t.modal.props},t.modal.content);if(t.cardGroups){const n=[...Object.keys(e.stepValues)].pop(),r=(0,l.createElement)(l.Fragment,null,n&&!e.isFirstStep&&(0,l.createElement)(d.Button,{icon:"arrow-left-alt",onClick:()=>e.removeQueryArgs(e.steps[n]?.arg||""),label:(0,u.__)("Back","newsletter-optin-box"),showTooltip:!0})),a=e.isLastStep?void 0:n=>{t.arg&&e.addQueryArg(t.arg,n)};return(0,l.createElement)(d.Modal,{title:e.currentTitle,onRequestClose:e.closeModal,headerActions:r,isFullScreen:!0},(0,l.createElement)(I,{cardGroups:t.cardGroups,licenseDetails:e.licenseDetails,onSelect:a,hrefCallback:t.arg&&e.isLastStep?n=>e.withQueryArg(t.arg,n):void 0,campaign:e.campaign}))}return null},D=({buttonProps:e,...t})=>{const[n,r]=(0,l.useState)(!1),a=(0,l.useCallback)((()=>{r(!0)}),[r]),i=(0,l.useCallback)((()=>{r(!1)}),[r]),o=t.currentStep&&t.hasSteps,s={...e,onClick:o?a:void 0,href:o?void 0:t.url};return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(d.Button,{...s}),(0,l.createElement)(R,{isOpen:n,closeModal:i,...t}))},L={variant:"primary",text:c.data?.new_campaign_label,type:"button"},F=()=>{const e=(()=>{const e=(0,l.useContext)(O);if(!e)throw new Error("useModal must be used within a ModalProvider");return e})();return(0,l.createElement)(D,{licenseDetails:c.license||{},buttonProps:L,...e})},H=()=>(0,l.createElement)(P,null,(0,l.createElement)(F,null)),q=()=>(0,l.createElement)(d.__experimentalVStack,{alignment:"center",justify:"center",spacing:6,style:{minHeight:320}},(0,l.createElement)(d.Icon,{icon:c.data?.icon,size:100,style:{color:"#646970"}}),(0,l.createElement)(d.__experimentalText,{align:"center",color:"#646970",size:16,isBlock:!0},c.data?.upsell||c.data?.click_to_add_first),c.data?.click_to_add_first&&(0,l.createElement)(H,null),!c.data?.click_to_add_first&&(0,l.createElement)(d.Button,{text:(0,u.__)("View Pricing","newsletter-optin-box"),href:"https://noptin.com/pricing/?utm_source=sequence&utm_medium=plugin&utm_campaign=email-campaigns",variant:"primary",target:"_blank"}));function G({title:e,isSecodary:t,className:n,children:r}){const[a,i]=(0,l.useState)(!0),o=$()(n,"noptin-component__section");return(0,l.createElement)(d.Card,{variant:t?"secondary":"primary",className:o},(0,l.createElement)(d.CardHeader,null,(0,l.createElement)(d.Flex,null,(0,l.createElement)(d.FlexBlock,null,(0,l.createElement)("h3",null,e)),(0,l.createElement)(d.FlexItem,null,(0,l.createElement)(d.Button,{variant:"tertiary",onClick:()=>i(!a),icon:a?"arrow-up-alt2":"arrow-down-alt2"})))),a&&r)}const V=c.license||{},W=({image:e,title:t})=>{if("string"==typeof e&&e.startsWith("http"))return(0,l.createElement)("img",{src:e,width:24,alt:t,style:{maxWidth:24}});if("string"==typeof e)return(0,l.createElement)(d.Icon,{size:24,icon:e,style:{color:"#424242"}});if(e&&"object"==typeof e){const t=e.fill||"#008000",n=e.path||"",r=e.viewBox||"0 0 24 24";return e.path?(0,l.createElement)(d.SVG,{viewBox:r,xmlns:"http://www.w3.org/2000/svg",style:{maxWidth:24}},(0,l.createElement)(d.Path,{fill:t,d:n})):(0,l.createElement)(d.Icon,{size:24,style:{color:t},icon:e.icon})}return(0,l.createElement)(d.Icon,{size:24,icon:"email",style:{color:"#424242"}})},Q=({name:e,label:t,description:n,image:r,selectText:a,is_installed:i,forcePremium:o,onSelect:s})=>{const m=(0,l.useCallback)((()=>s(e)),[e,s]),[f,g]=((e,t,n,r,a)=>{if(t?e&&V.key:e)return[null,(0,l.createElement)(d.Button,{variant:"primary",onClick:r},(0,l.createElement)("span",{className:"noptin-selectable-card__label"},a||(0,u.__)("Select"))," ",(0,l.createElement)(d.Icon,{size:16,icon:"arrow-right-alt"}))];const i=!e&&V.install_desc||(0,u.__)("Activate your license key to unlock","newsletter-optin-box"),o=!e&&V.install_text||(0,u.__)("View Pricing","newsletter-optin-box");let s=!e&&V.install_url||V.upgrade_url||"https://noptin.com/pricing/";V.key||(s=(0,p.addQueryArgs)(s,{utm_source:n,utm_campaign:(c.data?.type||"noptin")+"-emails"}));const m=V.key?"primary":"secondary";return[i,(0,l.createElement)(d.Button,{variant:m,href:s},(0,l.createElement)("span",{className:"noptin-selectable-card-action__label"},o)," ",(0,l.createElement)(d.Icon,{size:16,icon:"lock"}))]})(!1!==i,o||!1,e,m,a);return(0,l.createElement)(d.Card,{className:`noptin-selectable-card noptin-selectable-card__${e}`,onClick:f?void 0:m,size:"small"},(0,l.createElement)(d.CardHeader,null,(0,l.createElement)(d.__experimentalHeading,{level:4,numberOfLines:1},t),(0,l.createElement)(W,{image:r,title:t})),(0,l.createElement)(d.CardBody,null,(0,l.createElement)(d.__experimentalVStack,{spacing:4},n&&(0,l.createElement)(d.__experimentalText,{as:"p",variant:"muted"},n),f&&(0,l.createElement)(d.__experimentalText,{as:"em",isDestructive:!0},f))),(0,l.createElement)(d.CardFooter,{isBorderless:!0,justify:"flex-end"},g),(0,l.createElement)(d.__experimentalElevation,{value:1,hover:3,isInteractive:!0}))},U=({showingAll:e=!0,cards:t,onSelect:n})=>{const r=Object.entries(t),a=e?r:r.slice(0,3);return(0,l.createElement)(d.Flex,{className:"noptin-selectable-card",justify:"left",align:"stretch",wrap:!0},a.map((([e,t],r)=>(0,l.createElement)(Q,{key:`${e}__${r}`,onSelect:n,name:e,...t}))))},X=({cards:e,title:t,onSelect:n,onGroupSelect:r,unwrap:a=!1})=>{const i=Object.keys(e).length,o=r&&i>3;if(console.log(i),0===i)return null;const s=(0,l.createElement)(U,{cards:e,onSelect:n,showingAll:a||!o});if(a)return s;const c={};return o&&(c["aria-expanded"]="false",c.onClick=()=>r&&r(t),c.label=(0,u.__)("Show all","newsletter-optin-box"),c.showTooltip=!0),(0,l.createElement)(d.__experimentalVStack,{spacing:2},(0,l.createElement)(d.__experimentalHStack,{as:o?d.Button:"h2",...c},t),s)};function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?se(ye,--ge):0,me--,10===he&&(me=1,de--),he}function we(){return he=ge2||Se(he)>3?"":" "}function Te(e,t){for(;--t&&we()&&!(he<48||he>102||he>57&&he<65||he>70&&he<97););return Ee(e,ke()+(t<6&&32==xe()&&32==we()))}function $e(e){for(;we();)switch(he){case e:return ge;case 34:case 39:34!==e&&39!==e&&$e(he);break;case 40:41===e&&$e(e);break;case 92:we()}return ge}function je(e,t){for(;we()&&e+he!==57&&(e+he!==84||47!==xe()););return"/*"+Ee(t,ge-1)+"*"+ne(47===e?e:we())}function Me(e){for(;!Se(xe());)we();return Ee(e,ge)}var Be="-ms-",ze="-moz-",Ne="-webkit-",Ie="comm",Re="rule",De="decl",Le="@keyframes";function Fe(e,t){for(var n="",r=ue(e),a=0;a0&&ce(k)-p&&pe(m>32?Qe(k+";",r,n,p-1):Qe(ie(k," ","")+";",r,n,p-2),l);break;case 59:k+=";";default:if(pe(x=Ve(k,t,n,c,u,a,s,_,v=[],w=[],p),i),123===b)if(0===u)Ge(k,t,x,x,v,i,p,s,w);else switch(99===d&&110===se(k,3)?100:d){case 100:case 108:case 109:case 115:Ge(e,x,x,r&&pe(Ve(e,x,x,0,0,a,s,_,a,v=[],p),w),a,w,p,s,r?v:w);break;default:Ge(k,x,x,x,[""],w,0,s,w)}}c=u=m=0,g=y=1,_=k="",p=o;break;case 58:p=1+ce(k),m=f;default:if(g<1)if(123==b)--g;else if(125==b&&0==g++&&125==ve())continue;switch(k+=ne(b),b*g){case 38:y=u>0?1:(k+="\f",-1);break;case 44:s[c++]=(ce(k)-1)*y,y=1;break;case 64:45===xe()&&(k+=Oe(we())),d=xe(),u=p=ce(_=k+=Me(ke())),b++;break;case 45:45===f&&2==ce(k)&&(g=0)}}return i}function Ve(e,t,n,r,a,i,o,s,l,c,u){for(var p=a-1,d=0===a?i:[""],m=ue(d),f=0,g=0,h=0;f0?d[y]+" "+b:ie(b,/&\f/g,d[y])))&&(l[h++]=_);return be(e,t,n,0===a?Re:s,l,c,u)}function We(e,t,n){return be(e,t,n,Ie,ne(he),le(e,2,-2),0)}function Qe(e,t,n,r){return be(e,t,n,De,le(e,0,r),le(e,r+1,-1),r)}var Ue=function(e,t,n){for(var r=0,a=0;r=a,a=xe(),38===r&&12===a&&(t[n]=1),!Se(a);)we();return Ee(e,ge)},Xe=new WeakMap,Ye=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||Xe.get(n))&&!r){Xe.set(e,!0);for(var a=[],i=function(e,t){return Ae(function(e,t){var n=-1,r=44;do{switch(Se(r)){case 0:38===r&&12===xe()&&(t[n]=1),e[n]+=Ue(ge-1,t,n);break;case 2:e[n]+=Oe(r);break;case 4:if(44===r){e[++n]=58===xe()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=ne(r)}}while(r=we());return e}(Ce(e),t))}(t,a),o=n.props,s=0,l=0;s6)switch(se(e,t+1)){case 109:if(45!==se(e,t+4))break;case 102:return ie(e,/(.+:)(.+)-([^]+)/,"$1"+Ne+"$2-$3$1"+ze+(108==se(e,t+3)?"$3":"$2-$3"))+e;case 115:return~oe(e,"stretch")?Ze(ie(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==se(e,t+1))break;case 6444:switch(se(e,ce(e)-3-(~oe(e,"!important")&&10))){case 107:return ie(e,":",":"+Ne)+e;case 101:return ie(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ne+(45===se(e,14)?"inline-":"")+"box$3$1"+Ne+"$2$3$1"+Be+"$2box$3")+e}break;case 5936:switch(se(e,t+11)){case 114:return Ne+e+Be+ie(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ne+e+Be+ie(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ne+e+Be+ie(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ne+e+Be+e+e}return e}var Je=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case De:e.return=Ze(e.value,e.length);break;case Le:return Fe([_e(e,{value:ie(e.value,"@","@"+Ne)})],r);case Re:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return Fe([_e(e,{props:[ie(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return Fe([_e(e,{props:[ie(t,/:(plac\w+)/,":"+Ne+"input-$1")]}),_e(e,{props:[ie(t,/:(plac\w+)/,":-moz-$1")]}),_e(e,{props:[ie(t,/:(plac\w+)/,Be+"input-$1")]})],r)}return""}))}}],et=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r,a,i=e.stylisPlugins||Je,o={},s=[];r=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n96?ht:yt},_t=function(e,t,n){var r;if(t){var a=t.shouldForwardProp;r=e.__emotion_forwardProp&&a?function(t){return e.__emotion_forwardProp(t)&&a(t)}:a}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},vt=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return gt(t,n,r),dt((function(){return function(e,t,n){gt(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var a=t;do{e.insert(t===a?"."+r:"",a,e.sheet,!0),a=a.next}while(void 0!==a)}}(t,n,r)})),null},wt=function e(t,n){var r,a,i=t.__emotion_real===t,o=i&&t.__emotion_base||t;void 0!==n&&(r=n.label,a=n.target);var s=_t(t,n,i),c=s||bt(o),u=!c("as");return function(){var p=arguments,d=i&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==r&&d.push("label:"+r+";"),null==p[0]||void 0===p[0].raw)d.push.apply(d,p);else{d.push(p[0][0]);for(var m=p.length,f=1;f=4;++r,a-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(a){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(a)+l;return{name:c,styles:a,next:ct}}(d.concat(h),t.registered,y);g+=t.key+"-"+_.name,void 0!==a&&(g+=" "+a);var v=u&&void 0===s?bt(f):c,w={};for(var x in e)u&&"as"===x||v(x)&&(w[x]=e[x]);return w.className=g,w.ref=n,l.createElement(l.Fragment,null,l.createElement(vt,{cache:t,serialized:_,isStringTag:"string"==typeof f}),l.createElement(f,w))},(0,l.forwardRef)((function(e,t){var n=(0,l.useContext)(mt);return g(e,n,t)})));return h.displayName=void 0!==r?r:"Styled("+("string"==typeof o?o:o.displayName||o.name||"Component")+")",h.defaultProps=t.defaultProps,h.__emotion_real=h,h.__emotion_base=o,h.__emotion_styles=d,h.__emotion_forwardProp=s,Object.defineProperty(h,"toString",{value:function(){return"."+a}}),h.withComponent=function(t,r){return e(t,Y({},n,r,{shouldForwardProp:_t(h,r,!0)})).apply(void 0,d)},h}}.bind();["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){wt[e]=wt(e)}));const xt=[0,100],kt=[0,100],Et=e=>`${1===e.length?"0":""}${e}`,St=(e,t,n)=>Math.max(Math.min(e,n),t),Ct=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,At=(e,t,n)=>{const r=Ct(e,t);for(let a=0;a=i[0]&&r<=i[1])return At(e,t,n)}return r},Ot=(e,t)=>"number"==typeof t?t:e%Math.abs(t[1]-t[0])+t[0],Pt=(e,t)=>"number"==typeof e?St(Math.abs(e),...t):1===e.length||e[0]===e[1]?St(Math.abs(e[0]),...t):[Math.abs(St(e[0],...t)),St(Math.abs(e[1]),...t)],Tt=(e,t,n)=>(n<0?n+=1:n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e),$t=(e,t,n)=>{let r,a,i;if(e/=360,n/=100,0==(t/=100))r=a=i=n;else{const o=n<.5?n*(1+t):n+t-n*t,s=2*n-o;r=Tt(s,o,e+1/3),a=Tt(s,o,e),i=Tt(s,o,e-1/3)}return[Math.round(255*r),Math.round(255*a),Math.round(255*i)]},jt=(e,t,n,r)=>(299*e+587*t+114*n)/1e3>=r,Mt=(e,t,n)=>`hsl(${e}, ${t}%, ${n}%)`,Bt=(e,t,n,r)=>"rgb"===r?`rgb(${e}, ${t}, ${n})`:`#${Et(e.toString(16))}${Et(t.toString(16))}${Et(n.toString(16))}`,zt=(e,{format:t="hex",saturation:n=[50,55],lightness:r=[50,60],differencePoint:a=130}={})=>{const i=Math.abs((e=>{const t=e.length;let n=0;for(let r=0;r{t=Pt(t,xt),n=Pt(n,kt);const i=a?At(0,359,a):Ct(0,359),o="number"==typeof t?t:Ct(...t),s="number"==typeof n?n:Ct(...n),[l,c,u]=$t(i,o,s);return{color:"hsl"===e?Mt(i,o,s):Bt(l,c,u,e),isLight:jt(l,c,u,r)}};const Nt=zt,It=wt.span` white-space: nowrap; border-radius: 200px; height: 24px; diff --git a/src/Integrations/Custom_Fields_Integration.php b/src/Integrations/Custom_Fields_Integration.php index e0b32e04..ef77f8b2 100644 --- a/src/Integrations/Custom_Fields_Integration.php +++ b/src/Integrations/Custom_Fields_Integration.php @@ -36,9 +36,15 @@ public function __construct() { * @param array $custom_fields The known user custom fields. */ public function filter_user_fields( $custom_fields ) { + static $fields = null; + + if ( is_null( $fields ) ) { + $fields = $this->get_user_fields(); + } + return array_merge( $custom_fields, - $this->get_user_fields() + $fields ); } @@ -58,9 +64,15 @@ protected function get_user_fields() { * @param string $post_type The post type. */ public function filter_post_type_fields( $custom_fields, $post_type ) { + static $fields = array(); + + if ( ! isset( $fields[ $post_type ] ) ) { + $fields[ $post_type ] = $this->get_post_type_fields( $post_type ); + } + return array_merge( $custom_fields, - $this->get_post_type_fields( $post_type ) + $fields[ $post_type ] ); } diff --git a/src/Objects/Collection.php b/src/Objects/Collection.php index 9f744838..a79cad66 100644 --- a/src/Objects/Collection.php +++ b/src/Objects/Collection.php @@ -1033,7 +1033,6 @@ public function register_temporary_merge_tags() { $recipient = \Hizzle\Noptin\Emails\Main::$current_email_recipient; if ( isset( $recipient[ $this->type ] ) ) { - if ( ! is_array( $noptin_current_objects ) ) { $noptin_current_objects = array(); }