var p=Object.defineProperty,_=Object.defineProperties;var y=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var f=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,c=(i,t)=>{for(var e in t||(t={}))v.call(t,e)&&f(i,e,t[e]);if(h)for(var e of h(t))F.call(t,e)&&f(i,e,t[e]);return i},m=(i,t)=>_(i,y(t));import{b as u,_ as g}from"./main.2.8.10.js";import{u as o}from"./Note.DalStCGz.js";const d=i=>i||i===0?String(i):"",w=i=>{const t=Object.values(i||{}),e=t.filter(a=>a.required).map(a=>d(a.fieldId)).filter(Boolean);return{requiredFieldIds:e,requiredFieldIdSet:new Set(e),allFieldIdSet:new Set(t.map(a=>d(a.fieldId)).filter(Boolean))}},A=i=>{const t=new Map;return i.forEach(e=>{const a=d(e==null?void 0:e.activeCampaignField);if(!a)return;const r=t.get(a);(!r||!r.formField&&e.formField)&&t.set(a,c({},e))}),t},q=(i,t)=>i.map(e=>{const a=t.get(e);return a?m(c({},a),{required:!0}):{formField:"",activeCampaignField:e,required:!0}}),b=(i,t,e)=>i.filter(a=>!t.has(d(a==null?void 0:a.activeCampaignField))).map(a=>{const r=c({},a),s=d(r==null?void 0:r.activeCampaignField);return s&&!e.has(s)&&(r.activeCampaignField=""),r.required&&delete r.required,r}),M=(i,t)=>{const e=Array.isArray(i)?i:[],{requiredFieldIds:a,requiredFieldIdSet:r,allFieldIdSet:s}=w(t),l=A(e);return[...q(a,l),...b(e,r,s)]},R=(i,t,e)=>{const a=c({},t);a.name=i.target.value,e(c({},a))},B=(i,t,e,a)=>{const r={api_key:i.api_key,api_url:i.api_url};e(!0),u(r,"aCampaign_lists").then(s=>{s&&s.success?s.data.activeCampaignLists?(t(l=>o(l,n=>{n.default||(n.default={}),n.default.activeCampaignLists=s.data.activeCampaignLists})),a({show:!0,msg:g("ActiveCampaign lists refreshed","bit-integrations")})):a({show:!0,msg:g("No ActiveCampaign lists found. Try changing the header row number or try again","bit-integrations")}):a({show:!0,msg:g("ActiveCampaign lists refresh failed. please try again","bit-integrations")}),e(!1)}).catch(()=>e(!1))},I=(i,t,e,a)=>{const r={api_key:i.api_key,api_url:i.api_url};e(!0),u(r,"aCampaign_accounts").then(s=>{s&&s.success?s.data?(t(l=>o(l,n=>{n.accounts=s.data})),a({show:!0,msg:g("ActiveCampaign accounts refreshed","bit-integrations")})):a({show:!0,msg:g("No ActiveCampaign account found. Try changing the header row number or try again","bit-integrations")}):a({show:!0,msg:g("ActiveCampaign accounts refresh failed. please try again","bit-integrations")}),e(!1)}).catch(()=>e(!1))},N=(i,t,e,a)=>{const r={api_key:i.api_key,api_url:i.api_url};u(r,"aCampaign_tags").then(s=>{s&&s.success?s.data.activeCampaignTags?(t(l=>o(l,n=>{n.default||(n.default={}),n.default.activeCampaignTags=s.data.activeCampaignTags})),a({show:!0,msg:g("ActiveCampaign tags refreshed","bit-integrations")})):a({show:!0,msg:g("No ActiveCampaign tags found. Try changing the header row number or try again","bit-integrations")}):a({show:!0,msg:g("ActiveCampaign tags refresh failed. please try again","bit-integrations")}),e(!1)}).catch(()=>e(!1))},P=(i,t,e,a)=>{const r={api_key:i.api_key,api_url:i.api_url};e(!0),u(r,"aCampaign_headers").then(s=>{s&&s.success?s.data.activeCampaignField?(t(l=>o(l,n=>{n.default||(n.default={}),n.default.fields=s.data.activeCampaignField,n.field_map=M(n.field_map,n.default.fields)})),a({show:!0,msg:g("ActiveCampaign fields refreshed","bit-integrations")})):a({show:!0,msg:g("No ActiveCampaign fields found. Try changing the header row number or try again","bit-integrations")}):a({show:!0,msg:g("ActiveCampaign fields refresh failed. please try again","bit-integrations")}),e(!1)}).catch(()=>e(!1))},E=i=>!((i!=null&&i.field_map?i.field_map.filter(e=>!e.formField&&e.activeCampaignField&&e.required):[]).length>0);export{B as a,I as b,P as c,E as d,R as h,N as r};
