var K=Object.defineProperty,P=Object.defineProperties;var A=Object.getOwnPropertyDescriptors;var o=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var p=(e,s,t)=>s in e?K(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,h=(e,s)=>{for(var t in s||(s={}))b.call(s,t)&&p(e,t,s[t]);if(o)for(var t of o(s))z.call(s,t)&&p(e,t,s[t]);return e},f=(e,s)=>P(e,A(s));var y=(e,s,t)=>new Promise((r,a)=>{var u=c=>{try{l(t.next(c))}catch(m){a(m)}},i=c=>{try{l(t.throw(c))}catch(m){a(m)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(u,i);l((t=t.apply(e,s)).next())});import{_ as n,b as F,c as d,F as g,s as q}from"./bi.636.93.js";const I=(e,s,t,r,a)=>{const u=h({},s),i=h({},r);i[e.target.name]="",u[e.target.name]=e.target.value,a(i),t(u)},x=(e,s,t,r,a)=>{if(!e.authKey){s({authKey:e.authKey?"":n("API Key can't be empty")});return}s({}),a(f(h({},r),{auth:!0}));const u={authKey:e.authKey};F(u,"moosend_handle_authorize").then(i=>{if(i.data.Code===0){t(!0),a(f(h({},r),{auth:!1})),d.success(n("Authorized Successfully"));return}a(f(h({},r),{auth:!1})),d.error(n("Authorized failed"))})},M=(e,s,t,r)=>y(void 0,null,function*(){r&&r(f(h({},t),{list:!0}));const a={authKey:e.authKey},u=yield F(a,"moosend_handle_authorize");if(u.success&&u.data.Code===0){const{MailingLists:i}=u.data.Context,l=h({},e);return i&&(l.default||(l.default={}),l.default.lists=i,s(l),r&&(r(f(h({},t),{list:!1})),d.success(n("List refresh successfully")))),!0}return r&&(r(f(h({},t),{list:!1})),d.success(n("List refresh failed"))),!1}),k=e=>{const s=e==null?void 0:e.moosendFields.filter(t=>t.required===!0);return s.length>0?s.map(t=>({formFields:"",moosendFormFields:t.key})):[{formFields:"",moosendFormFields:""}]},_=e=>!((e!=null&&e.field_map?e.field_map.filter(t=>!t.formFields||!t.moosendFormFields||!t.formFields==="custom"&&!t.customValue):[]).length>0),T=(e,s,t)=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!e.listId&&e.method!=="0"&&d.error("Please select list"),!_(e)){d.error("Please map mandatory fields");return}e.field_map.length>0&&s(t)},B=(e,s,t,r,a,u)=>{u(!0),g(e,s,t,r,a,"","",u).then(l=>{var c;l.success?(d.success((c=l.data)==null?void 0:c.msg),a(t)):d.error(l.data||l)})},E=(e,s,t,r,a,u)=>{if(!_(t)){d.error("Please map mandatory fields");return}q({flow:e,allIntegURL:s,conf:t,navigate:r,edit:a,setIsLoading:u})};export{k as a,x as b,B as c,M as g,I as h,T as n,E as s};
