| 1 |
var D=Object.defineProperty,E=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var I=(l,d,n)=>d in l?D(l,d,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[d]=n,v=(l,d)=>{for(var n in d||(d={}))G.call(d,n)&&I(l,n,d[n]);if(M)for(var n of M(d))B.call(d,n)&&I(l,n,d[n]);return l},_=(l,d)=>E(l,z(d));import{j as e,_ as r,G as R,T as k,u as K,$ as L,e as H,F as J,g as U,r as F,S as Z,f as Q}from"./main-96.js";/* empty css */import{h as w,d as W,a as T,b as X,c as V,e as Y,f as C,s as q}from"./bf-674-104.js";import{r as P,a as ee,s as ae,h as $,c as se,b as ie}from"./bf-890-105.js";import{u as le}from"./bf-431-60.js";import{A as O}from"./bf-224-73.js";import{m as de}from"./bf-781-46.js";import{M as te}from"./bf-762-63.js";import{S}from"./bf-39-66.js";import{A as re}from"./bf-747-75.js";import{u as ne}from"./bf-16-67.js";import"./bf-331-47.js";import"./bf-798-54.js";import"./bf-425-69.js";import"./bf-162-70.js";function ce({i:l,formFields:d,field:n,sheetConf:a,setSheetConf:t,addressField:j}){const u=n.required,b=j.filter((s=>!s.required));return e.jsxs("div",{className:"flx flx-around mt-2 mr-1",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:n.formField||"",onChange:s=>w(s,l,a,t),children:[e.jsx("option",{value:"",children:r("Select Field")}),d.map(s=>s.type!=="file-up"&&e.jsx("option",{value:s.key,children:s.name},`ff-zhcrm-${s.key}`))]}),e.jsxs("select",{className:"btcd-paper-inp",name:"mailChimpAddressField",value:n.mailChimpAddressField||"",onChange:s=>w(s,l,a,t),disabled:u,children:[e.jsx("option",{value:"",children:r("Select Field")}),u?Object.values(j).map((s,p)=>e.jsx("option",{value:s.tag,children:s.name},`add-${p*2}`)):Object.values(b).map((s,p)=>e.jsx("option",{value:s.tag,children:s.name},`add-${p*2}`))]}),!u&&e.jsx("button",{onClick:()=>W(l,a,t),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx(R,{})})]})}function me({sheetConf:l,setSheetConf:d,formFields:n,address:a}){var j,u,b;const t=(s,p)=>{const i=v({},l);p==="update"&&(s.target.checked?i.actions.update=!0:delete i.actions.update),p==="double_opt_in"&&(s.target.checked?i.actions.double_opt_in=!0:delete i.actions.double_opt_in),p==="address"&&(s.target.checked?(i.actions.address=!0,i.address_field=a.filter(o=>o.required).map(o=>({formField:"",mailChimpAddressField:o.tag,required:!0}))):(delete i.actions.address,i.address_field="")),d(v({},i))};return e.jsxs("div",{className:"pos-rel d-flx w-8",children:[e.jsx(k,{checked:((j=l.actions)==null?void 0:j.address)||!1,onChange:s=>t(s,"address"),className:"wdt-200 mt-4 mr-2",value:"address",title:r("Add Address Field"),subTitle:r("Add Address Field")}),e.jsx(k,{checked:((u=l.actions)==null?void 0:u.double_opt_in)||!1,onChange:s=>t(s,"double_opt_in"),className:"wdt-200 mt-4 mr-2",value:"double_opt_in",title:r("Double Opt-in"),subTitle:r("Add Double Opt-in")}),e.jsx(k,{checked:((b=l.actions)==null?void 0:b.update)||!1,onChange:s=>t(s,"update"),className:"wdt-200 mt-4 mr-2",value:"user_share",title:r("Update Mail Chimp"),subTitle:r("Update Responses with MailChimp exist Aduience?")})]})}function pe({i:l,formFields:d,field:n,sheetConf:a,setSheetConf:t}){var b,s,p;const j=K(L),{isPro:u}=j;return e.jsxs("div",{className:"flx mt-2 mr-1",children:[e.jsxs("div",{className:"flx integ-fld-wrp",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:n.formField||"",onChange:i=>T(i,l,a,t),children:[e.jsx("option",{value:"",children:r("Select Field")}),e.jsx("optgroup",{label:"Form Fields",children:d.map(i=>i.type!=="file-up"&&e.jsx("option",{value:i.key,children:i.name},`ff-zhcrm-${i.key}`))}),e.jsx("option",{value:"custom",children:r("Custom...")}),e.jsx("optgroup",{label:`General Smart Codes ${u?"":"(PRO)"}`,children:u&&((b=de)==null?void 0:b.map(i=>e.jsx("option",{value:i.name,children:i.label},`ff-rm-${i.name}`)))})]}),n.formField==="custom"&&e.jsx(te,{onChange:i=>X(i,l,a,t),label:r("Custom Value"),className:"mr-2",type:"text",value:n.customValue,placeholder:r("Custom Value")}),e.jsxs("select",{className:"btcd-paper-inp",name:"mailChimpField",value:n.mailChimpField||"",onChange:i=>T(i,l,a,t),children:[e.jsx("option",{value:"",children:r("Select Field")}),((p=(s=a.default)==null?void 0:s.fields)==null?void 0:p[a.listId])&&Object.values(a.default.fields[a.listId]).map((i,o)=>e.jsx("option",{value:i.tag,children:i.name},`mchimp-${o*2}`))]})]}),e.jsx("button",{onClick:()=>V(l,a,t),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>Y(l,a,t),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx(R,{})})]})}function ue({formID:l,formFields:d,handleInput:n,sheetConf:a,setSheetConf:t,isLoading:j,setisLoading:u,setSnackbar:b}){var i,o,m,h,A,y,N,g;const s=[{tag:"addr1",name:"Address 1",required:!0},{tag:"addr2",name:"Address 2",required:!1},{tag:"city",name:"City",required:!0},{tag:"zip",name:"Zip",required:!0},{tag:"state",name:"State",required:!0},{tag:"country",name:"Country",required:!1}],p=c=>{const x=v({},a);c?x.tags=c?c.split(","):[]:delete x.tags,t(v({},x))};return e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("b",{className:"wdt-150 d-in-b",children:r("Audience List:")}),e.jsxs("select",{onChange:n,name:"listId",value:a.listId,className:"btcd-paper-inp w-6",children:[e.jsx("option",{value:"",children:r("Select Audience List")}),((i=a==null?void 0:a.default)==null?void 0:i.audiencelist)&&Object.keys(a.default.audiencelist).map(c=>e.jsx("option",{value:a.default.audiencelist[c].listId,children:a.default.audiencelist[c].listName},c))]}),e.jsx("button",{onClick:()=>P(l,a,t,u,b),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":'"Refresh Audience list"'},type:"button",disabled:j,children:"↻"}),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("div",{className:"d-flx",children:[e.jsx("b",{style:{marginTop:"15px"},className:"wdt-150 d-in-b",children:r("Tags: ")}),e.jsx(le,{defaultValue:a==null?void 0:a.tags,className:"btcd-paper-drpdwn w-6",options:((o=a==null?void 0:a.default)==null?void 0:o.audienceTags)&&Object.keys(a.default.audienceTags).map(c=>({label:a.default.audienceTags[c].tagName,value:a.default.audienceTags[c].tagName})),onChange:c=>p(c)}),e.jsx("button",{onClick:()=>ee(l,a,t,u,b),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${r("Refresh MailChimp Tags")}'`},type:"button",disabled:j,children:"↻"})]}),j&&e.jsx(H,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),((h=(m=a.default)==null?void 0:m.fields)==null?void 0:h[a.listId])&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flx flx-around mt-2 mb-1",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:r("Form Fields")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:r("Mail Chimp Fields")})})]}),a.field_map.map((c,x)=>e.jsx(pe,{i:x,field:c,sheetConf:a,formFields:d,setSheetConf:t},`sheet-m-${x+9}`)),e.jsxs("div",{className:"txt-center mt-2",style:{marginRight:85},children:[e.jsx("button",{onClick:()=>V(a.field_map.length,a,t),className:"icn-btn sh-sm",type:"button",children:"+"}),e.jsx(O,{fieldMap:a.field_map,formFields:d,integrationFields:Object.values(((y=(A=a.default)==null?void 0:A.fields)==null?void 0:y[a.listId])||{}),integKey:"mailChimpField",integValueProp:"tag",onMapped:c=>t(x=>_(v({},x),{field_map:c}))})]}),e.jsx("br",{}),e.jsx("br",{}),((N=a.actions)==null?void 0:N.address)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:r("Address Field Map")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-1",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:r("Form Address Fields")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:r("Mail Chimp Address Fields")})})]}),(g=a==null?void 0:a.address_field)==null?void 0:g.map((c,x)=>e.jsx(ce,{i:x,field:c,sheetConf:a,formFields:d,setSheetConf:t,addressField:s},`sheet-m-${x+9}`)),e.jsxs("div",{className:"txt-center mt-2",style:{marginRight:85},children:[e.jsx("button",{onClick:()=>C(a.address_field.length,a,t),className:"icn-btn sh-sm",type:"button",children:"+"}),e.jsx(O,{fieldMap:a.address_field,formFields:d,integrationFields:s.filter(c=>!c.required),integKey:"mailChimpAddressField",integValueProp:"tag",onMapped:c=>t(x=>_(v({},x),{address_field:c}))})]})]}),e.jsx("br",{}),e.jsx("br",{})]}),a.listId&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:r("Actions")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx(me,{sheetConf:a,setSheetConf:t,formFields:d,address:s})]})]})}function we({mode:l="new",formFields:d,integrations:n,setIntegration:a,allIntegURL:t}){const j=J(),{id:u,formID:b}=U(),[s,p]=F.useState(!1),[i,o]=F.useState({show:!1}),[m,h]=F.useState(()=>l==="edit"?v({},n[u]):{name:"Mail Chimp Integration",type:"Mail Chimp",clientId:"",clientSecret:"",listId:"",listName:"",tags:"",field_map:[{formField:"",mailChimpField:""}],address_field:[],actions:{}}),A=g=>{const c=JSON.parse(g.integration_details);h(x=>Q(x,f=>{f.parentAppId=g.id,f.clientId=c.clientId,f.clientSecret=c.clientSecret,f.tokenDetails=c.tokenDetails}))};F.useEffect(()=>{m!=null&&m.parentAppId&&P(b,m,h,p,o)},[m.parentAppId]),F.useEffect(()=>{window.opener&&ae("mailChimp")},[]);const y=()=>{var g;if((g=m.actions)!=null&&g.address&&!se(m)){o({show:!0,msg:"Please map address required fields to continue."});return}if(!ie(m)){o({show:!0,msg:"Please map fields to continue."});return}l==="edit"?q(n,a,t,m,j,u,1):q(n,a,t,m,j)},N=l==="edit"||!!m.parentAppId;return ne({conf:m,onSeed:g=>h(v({},g)),save:y,saveDisabled:!m.listId||m.field_map.length<1,ready:N}),e.jsxs("div",{children:[e.jsx(Z,{snack:i,setSnackbar:o}),e.jsx(S,{title:r("Name this integration"),children:e.jsx("input",{className:"btcd-paper-inp w-10",onChange:g=>$(g,m,h),name:"name",value:m.name,type:"text",placeholder:r("Integration Name...")})}),e.jsx(re,{type:"Mail Chimp",value:m.parentAppId,onSelect:A}),N&&e.jsx(S,{title:r("Field mapping"),subtitle:r("Choose the destination and match form fields to it."),children:e.jsx(ue,{formID:b,formFields:d,handleInput:g=>$(g,m,h,b,p,o),sheetConf:m,setSheetConf:h,isLoading:s,setisLoading:p,setSnackbar:o})})]})}export{we as default}; |