1import"../chunks/NZTpNUN0.js";import{p as Z,l as P,v as tt,a as r,b as et,s as rt,c as u,f as y,e as at,n as g,r as v,d as p,i as K,g as C,o as a,j as i,t as ot}from"../chunks/CswluXHk.js";import{s as st}from"../chunks/D5MUd0dc.js";import{i as O}from"../chunks/Cvwav-Rz.js";import{c as h}from"../chunks/DCqg9Lcd.js";import{d as it,a as nt}from"../chunks/BnZqlU5Q.js";import{g as lt}from"../chunks/DvabIYvy.js";import{p as ct}from"../chunks/BGX793Ew.js";import"../chunks/aH0YTA77.js";import{t as w}from"../chunks/CFi-xeDB.js";import{B as R}from"../chunks/DltdByd6.js";import{I as pt}from"../chunks/DuX34-Zw.js";import{C as mt}from"../chunks/BFGY4aR1.js";import{C as dt}from"../chunks/C3F0Z4bJ.js";import{C as ft,a as ut,b as gt}from"../chunks/DQXZ4mXD.js";import{C as vt}from"../chunks/BcsrqGLJ.js";import{A as ht}from"../chunks/r7UZdRXb.js";var yt=y("<!> <!>",1),_t=y('<p class="text-red-500 text-sm"> </p>'),$t=y(`<form class="space-y-4"><div class="space-y-2"><label for="apiKey" class="text-sm font-medium">API Key</label> <!> <p class="text-sm text-gray-500">Your Mailchimp API key can be found in your account settings under 2 API Keys.</p></div> <!></form>`),xt=y('<div class="flex items-center gap-4"><p class="text-sm text-gray-500">Need help? <a href="https://mailchimp.com/help/about-api-keys/" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline">Learn how to get your API key</a></p></div> <div class="space-x-2"><!> <!></div>',1),bt=y("<!> <!> <!>",1),It=y('<div class="mb-20"><button class="flex items-center text-sm text-gray-600 hover:text-gray-900 mb-4"><!> Back to Integrations</button> <!></div>');function qt(J,S){Z(S,!0);const q=()=>at(ct,"$page",D),[D,Y]=rt(),{mailchimpIntegration:M,team:F}=S.data;let _=P(tt(M?.config?.api_key||"")),z=M?.config?.list_id||"",n=P(""),A=P(!1),E=P(!1);async function G(){try{if(a(n,""),a(A,!0),!i(_)){a(n,"API Key is required");return}const e=await fetch("/api/install/mailchimp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:F.id,config:{api_key:i(_)}})}),$=await e.json();if(!e.ok)throw new Error($.error||"Failed to save integration");w.success("Mailchimp integration saved successfully",{position:"top-right"})}catch(e){console.error("Error saving Mailchimp integration:",e),a(n,e.message||"Failed to save integration",!0),w.error(i(n),{position:"top-right"})}finally{a(A,!1)}}async function H(){try{a(E,!0);const e=await fetch("/api/install/mailchimp",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:F.id})}),$=await e.json();if(!e.ok)throw new Error($.error||"Failed to remove integration");a(_,""),z="",w.success("Mailchimp integration removed successfully",{position:"top-right"})}catch(e){console.error("Error removing Mailchimp integration:",e),a(n,e.message||"Failed to remove integration",!0),w.error(i(n),{position:"top-right"})}finally{a(E,!1)}}var j=It(),k=u(j),Q=u(k);ht(Q,{class:"w-4 h-4 mr-1"}),g(),v(k);var U=p(k,2);h(U,()=>mt,(e,$)=>{$(e,{class:"my-4",children:(V,kt)=>{var L=bt(),T=K(L);h(T,()=>ft,(x,b)=>{b(x,{children:(I,N)=>{var o=yt(),s=K(o);h(s,()=>ut,(m,d)=>{d(m,{class:"text-lg font-semibold",children:(t,l)=>{g();var c=C("Mailchimp Integration");r(t,c)},$$slots:{default:!0}})});var f=p(s,2);h(f,()=>gt,(m,d)=>{d(m,{children:(t,l)=>{g();var c=C(`Connect your Mailchimp account to sync contacts and manage email 3 campaigns.`);r(t,c)},$$slots:{default:!0}})}),r(I,o)},$$slots:{default:!0}})});var B=p(T,2);h(B,()=>dt,(x,b)=>{b(x,{children:(I,N)=>{var o=$t(),s=u(o),f=p(u(s),2);pt(f,{id:"apiKey",type:"text",placeholder:"Enter your Mailchimp API key",class:"w-full",get value(){return i(_)},set value(t){a(_,t,!0)}}),g(2),v(s);var m=p(s,2);{var d=t=>{var l=_t(),c=u(l,!0);v(l),ot(()=>st(c,i(n))),r(t,l)};O(m,t=>{i(n)&&t(d)})}v(o),r(I,o)},$$slots:{default:!0}})});var W=p(B,2);h(W,()=>vt,(x,b)=>{b(x,{class:"flex justify-between items-center border-t bg-gray-50 rounded-b-[11px] py-4",children:(I,N)=>{var o=xt(),s=p(K(o),2),f=u(s);{var m=t=>{R(t,{variant:"destructive",onclick:H,get isLoading(){return i(E)},children:(l,c)=>{g();var X=C("Remove Connection");r(l,X)},$$slots:{default:!0}})};O(f,t=>{M?.config?.api_key&&t(m)})}var d=p(f,2);
3R(d,{type:"button",onclick:G,get isLoading(){return i(A)},children:(t,l)=>{g();var c=C("Save Integration");r(t,c)},$$slots:{default:!0}}),v(s),r(I,o)},$$slots:{default:!0}})}),r(V,L)},$$slots:{default:!0}})}),v(j),nt("click",k,()=>lt(`/brand/${q().params.teamSlug}/settings/integrations`)),r(J,j),et(),Y()}it(["click"]);export{qt as component}; 4//# sourceMappingURL=41.Zmgafx0r.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.