1import"../chunks/NZTpNUN0.js";import{p as X,l as I,v as Z,a as r,b as tt,s as et,c as u,f as _,e as rt,n as v,r as g,d,i as j,g as K,o,j as i,t as ot}from"../chunks/CswluXHk.js";import{s as at}from"../chunks/D5MUd0dc.js";import{i as R}from"../chunks/Cvwav-Rz.js";import{c as y}from"../chunks/DCqg9Lcd.js";import{d as st,a as it}from"../chunks/BnZqlU5Q.js";import{g as nt}from"../chunks/DvabIYvy.js";import{p as lt}from"../chunks/BGX793Ew.js";import"../chunks/aH0YTA77.js";import{t as P}from"../chunks/CFi-xeDB.js";import{B as J}from"../chunks/DltdByd6.js";import{I as ct}from"../chunks/DuX34-Zw.js";import{C as dt}from"../chunks/BFGY4aR1.js";import{C as pt}from"../chunks/C3F0Z4bJ.js";import{C as mt,a as ft,b as ut}from"../chunks/DQXZ4mXD.js";import{C as vt}from"../chunks/BcsrqGLJ.js";import{A as gt}from"../chunks/r7UZdRXb.js";var yt=_("<!> <!>",1),_t=_('<p class="text-red-500 text-sm"> </p>'),$t=_(`<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 Kit API key can be found in your account settings under Account 2 Info.</p></div> <!></form>`),ht=_('<div class="flex items-center gap-4"><p class="text-sm text-gray-500">Need help? <a href="https://developers.kit.com/v4" 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),xt=_("<!> <!> <!>",1),bt=_('<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(q,S){X(S,!0);const D=()=>rt(lt,"$page",Y),[Y,z]=et(),{kitIntegration:F,team:L}=S.data;let $=I(Z(F?.config?.api_key||"")),n=I(""),w=I(!1),A=I(!1);async function G(){try{if(o(n,""),o(w,!0),!i($)){o(n,"API Key is required");return}const e=await fetch("/api/install/kit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:L.id,config:{api_key:i($)}})}),h=await e.json();if(!e.ok)throw new Error(h.error||"Failed to save integration");P.success("ConvertKit integration saved successfully",{position:"top-right"})}catch(e){console.error("Error saving ConvertKit integration:",e),o(n,e.message||"Failed to save integration",!0),P.error(i(n),{position:"top-right"})}finally{o(w,!1)}}async function H(){try{o(A,!0);const e=await fetch("/api/install/kit",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:L.id})}),h=await e.json();if(!e.ok)throw new Error(h.error||"Failed to remove integration");o($,""),P.success("Kit integration removed successfully",{position:"top-right"})}catch(e){console.error("Error removing Kit integration:",e),o(n,e.message||"Failed to remove integration",!0),P.error(i(n),{position:"top-right"})}finally{o(A,!1)}}var E=bt(),C=u(E),M=u(C);gt(M,{class:"w-4 h-4 mr-1"}),v(),g(C);var Q=d(C,2);y(Q,()=>dt,(e,h)=>{h(e,{class:"my-4",children:(U,kt)=>{var T=xt(),B=j(T);y(B,()=>mt,(x,b)=>{b(x,{children:(k,O)=>{var a=yt(),s=j(a);y(s,()=>ft,(p,m)=>{m(p,{class:"text-lg font-semibold",children:(t,l)=>{v();var c=K("Kit Integration");r(t,c)},$$slots:{default:!0}})});var f=d(s,2);y(f,()=>ut,(p,m)=>{m(p,{children:(t,l)=>{v();var c=K("Connect your Kit account to sync contacts and manage email campaigns.");r(t,c)},$$slots:{default:!0}})}),r(k,a)},$$slots:{default:!0}})});var N=d(B,2);y(N,()=>pt,(x,b)=>{b(x,{children:(k,O)=>{var a=$t(),s=u(a),f=d(u(s),2);ct(f,{id:"apiKey",type:"text",placeholder:"Enter your Kit API key",class:"w-full",get value(){return i($)},set value(t){o($,t,!0)}}),v(2),g(s);var p=d(s,2);{var m=t=>{var l=_t(),c=u(l,!0);g(l),ot(()=>at(c,i(n))),r(t,l)};R(p,t=>{i(n)&&t(m)})}g(a),r(k,a)},$$slots:{default:!0}})});var V=d(N,2);y(V,()=>vt,(x,b)=>{b(x,{class:"flex justify-between items-center border-t bg-gray-50 rounded-b-[11px] py-4",children:(k,O)=>{var a=ht(),s=d(j(a),2),f=u(s);{var p=t=>{J(t,{variant:"destructive",onclick:H,get isLoading(){return i(A)},children:(l,c)=>{v();var W=K("Remove Connection");r(l,W)},$$slots:{default:!0}})};R(f,t=>{F?.config?.api_key&&t(p)})}var m=d(f,2);J(m,{type:"button",onclick:G,get isLoading(){return i(w)},children:(t,l)=>{v();var c=K("Save Integration");r(t,c)},$$slots:{default:!0}}),g(s),r(k,a)},$$slots:{default:!0}})}),r(U,T)},$$slots:{default:!0}})}),g(E),it("click",C,()=>nt(`/brand/${D().params.teamSlug}/settings/integrations`)),r(q,E),tt(),z()}st(["click"]);export{qt as component}; 3//# sourceMappingURL=39.BBrOY3gK.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.