var p=Object.defineProperty;var F=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var k=(e,s,t)=>s in e?p(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,c=(e,s)=>{for(var t in s||(s={}))y.call(s,t)&&k(e,t,s[t]);if(F)for(var t of F(s))A.call(s,t)&&k(e,t,s[t]);return e};import{_ as n,c as o,V as h}from"./main-634.js";import{a4 as q}from"./bf-746-82.js";const S=(e,s,t,r,i,a)=>{var f,_;const l=c({},s),{name:d}=e.target;switch(e.target.value!==""?l[d]=e.target.value:delete l[d],l[e.target.name]=e.target.value,e.target.name){case"listId":l.field_map=[{formField:"",acumbamailFormField:"email"}],l.listId&&!((_=(f=l.default)==null?void 0:f.allFields)!=null&&_[l.listId])&&w(a,l,t,r);break}t(c({},l))},w=(e,s,t,r,i)=>{const{listId:a}=s;if(!a)return;r(!0);const l={auth_token:s.auth_token,list_id:a};o(l,"bitforms_acumbamail_refresh_fields").then(d=>{var f,_;if(d&&d.success){const u=c({},s);if(d.data){(f=u.default)!=null&&f.allFields||(u.default.allFields={}),(_=u.default.allFields)!=null&&_[a]||(u.default.allFields[a]={}),u.default.allFields[a].fields=d.data,u.default.allFields[a].required=["email"],t(c({},u)),r(!1),h.success(n("All list field fetched successfully"));return}r(!1),h.error(n("Failed to fetch list fields"))}}).catch(()=>r(!1))},b=(e,s,t,r)=>{t(!0);const i={auth_token:e.auth_token};o(i,"bitforms_acumbamail_fetch_all_list").then(a=>{if(a&&a.success){const l=c({},e);l.default||(l.default={}),a.data&&(l.default.allLists=a.data),s(c({},l)),t(!1),h.success(n("Lists fetched successfully"));return}t(!1),h.error(n("Lists fetch failed. please try again"))}).catch(()=>t(!1))},P=(e,s,t,r,i,a)=>{if(!e.auth_token){t({auth_token:e.auth_token?"":n("Api Key can't be empty")});return}t({}),i(!0);const l={auth_token:e.auth_token};o(l,"bitforms_acumbamail_authorization_and_fetch_subscriber_list").then(d=>{if(d&&d.success){const f=c({},e);s(f),r(!0),i(!1),q(f),h.success(n("Authorized successfully"));return}i(!1),h.error(n("Authorized failed"))})},x=e=>!((e!=null&&e.field_map?e.field_map.filter(t=>{var r,i,a;return!t.formField&&t.acumbamailFormField&&((a=(i=(r=e==null?void 0:e.default)==null?void 0:r.allFields)==null?void 0:i[e.listId])==null?void 0:a.required.indexOf(t.acumbamailFormField))!==-1}):[]).length>0);export{S as a,x as c,b as f,P as h,w as r};
