var b=Object.defineProperty,p=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var m=(e,s,t)=>s in e?b(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,a=(e,s)=>{for(var t in s||(s={}))K.call(s,t)&&m(e,t,s[t]);if(F)for(var t of F(s))q.call(s,t)&&m(e,t,s[t]);return e},r=(e,s)=>p(e,_(s));import{_ as f,b as d,z as n}from"./main.2.8.10.js";const k=(e,s,t)=>{const u=a({},s),{name:i}=e.target;e.target.value!==""?u[i]=e.target.value:delete u[i],t(a({},u))},w=e=>{const s=e==null?void 0:e.staticFields.filter(t=>t.required===!0);return s.length>0?s.map(t=>({formField:"",sendGridFormField:t.key})):[{formField:"",sendGridFormField:""}]},P=e=>!((e!=null&&e.field_map?e.field_map.filter(t=>!t.formField||!t.sendGridFormField||!t.formField==="custom"&&!t.customValue):[]).length>0),g=(e,s,t,u,i,c,h)=>{if(!e.apiKey){t({apiKey:e.apiKey?"":f("API key can't be empty","bit-integrations")});return}t({}),h==="authentication"&&c(r(a({},i),{auth:!0})),h==="refreshLists"&&c(r(a({},i),{customFields:!0}));const y={apiKey:e.apiKey};d(y,"sendGrid_authentication").then(l=>{if(l&&l.success){const o=a({},e);u(!0),h==="authentication"?(l.data&&(o.customFields=l.data),s(o),c(r(a({},i),{auth:!1})),n.success(f("Authorized Successfully","bit-integrations"))):h==="refreshLists"&&(l.data&&(o.customFields=l.data,s(o)),c(r(a({},i),{customFields:!1})),n.success(f("Custom fields fetched successfully","bit-integrations")));return}c(r(a({},i),{auth:!1})),n.error(f("Authorization Failed","bit-integrations"))})},v=(e,s,t)=>{t(r(a({},t),{lists:!0}));const u={apiKey:e.apiKey};d(u,"sendGrid_fetch_all_lists").then(i=>{if(i&&i.success){const c=a({},e);i.data&&(c.lists=i.data),s(c),t(r(a({},t),{lists:!1})),n.success(f("Lists fetched successfully.","bit-integrations"));return}t(r(a({},t),{lists:!1})),n.error(f("Lists fetching failed","bit-integrations"))})};export{w as a,P as c,v as g,k as h,g as s};
