PageSourceSearch

https://clickervolt.com/_nuxt/CRzR1-UD.js

js clickervolt.com collected 2026-10-08 04:05:54 UTC 112,434 bytes, 1 lines download raw bytes

1import{_ as Fe}from"./CDmMBM7F.js";import{_ as xe}from"./yH-t8y5L.js";import{d as le,C as ve,o as t,c as s,b as e,g as E,G as H,R as ke,x as L,e as I,t as b,h as f,D as W,z as g,I as G,E as de,L as Q,a as ae,f as U,S as ue,P as pe,F as se,r as ie,_ as Be,U as je,s as fe,w as D,V as Ce,v as ze,K as be,J as Ie,W as _e,H as Se,X as Ve,Y as Le,n as He,u as Ue}from"./CT8pxmiK.js";import{_ as he}from"./DYdatvnp.js";import{u as De,g as Re,E as we,a as Ge}from"./QAExmQIV.js";import{_ as $e}from"./B0GklMoi.js";import{A as p,a as ce}from"./B-iRw7lc.js";import{FACEBOOK_AUTH_MODE as We}from"./BTxi7-sk.js";import{O as Oe,a as Ne,u as qe,_ as Ye,C as Qe}from"./C0DbhWyw.js";import{u as ge}from"./DcEtyfGf.js";import"./CHOzt-AV.js";import"./CpNeg6sd.js";import"./DhnZVplM.js";import"./DCKO6Fve.js";const me=8;function Xe(a){if(a.length<me)return"weak";let N=0;return a.length>=12?N+=2:a.length>=me&&(N+=1),/[a-z]/.test(a)&&(N+=1),/[A-Z]/.test(a)&&(N+=1),/[0-9]/.test(a)&&(N+=1),/[^a-zA-Z0-9]/.test(a)&&(N+=1),N<=3?"weak":N<=5?"medium":"strong"}function Je(a){return a.currentPassword.length>0&&a.newPassword.length>=me&&a.confirmPassword.length>0&&a.newPassword===a.confirmPassword}function Ze(a){return a.currentPassword.length>0||a.newPassword.length>0||a.confirmPassword.length>0}function Ae(){return{currentPassword:"",newPassword:"",confirmPassword:""}}function Me(){return{formData:Ae(),isValid:!1,hasInput:!1}}const et={class:"space-y-5"},tt={class:"relative"},st=["type","disabled"],ot=["aria-label","aria-pressed"],lt={key:0,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},nt={key:1,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},rt={class:"relative"},at=["type","disabled"],it=["aria-label","aria-pressed"],dt={key:0,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},ut={key:1,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},ct={key:0,class:"mt-2"},vt={class:"flex items-center gap-2"},mt={class:"flex-1 h-2 bg-gray-200 rounded-full overflow-hidden"},pt={class:"relative"},ft=["type","disabled"],gt=["aria-label","aria-pressed"],yt={key:0,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},bt={key:1,class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},xt={key:0,class:"text-xs text-red-600 mt-1"},ht=le({__name:"ChangePasswordForm",props:{disabled:{type:Boolean},error:{}},emits:["state-change"],setup(a,{expose:N,emit:i}){const A=i,P=g(Ae()),w=g(!1),c=g(!1),v=g(!1),x=G(()=>Xe(P.value.newPassword)),M=G(()=>Je(P.value)),C=G(()=>Ze(P.value));return ve(P,()=>{A("state-change",{formData:{...P.value},isValid:M.value,hasInput:C.value})},{deep:!0,immediate:!0}),N({reset:()=>{P.value=Ae(),w.value=!1,c.value=!1,v.value=!1}}),(F,l)=>{const k=xe;return t(),s("div",et,[l[15]||(l[15]=e("div",{class:"flex items-start gap-3 p-3 bg-green-50 border border-green-200 rounded-lg"},[e("svg",{class:"w-5 h-5 text-green-600 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})]),e("ul",{class:"text-xs text-green-700 space-y-1 list-disc list-inside"},[e("li",null,"Use a mix of letters, numbers, and symbols"),e("li",null,"Avoid common words or personal information"),e("li",null,"Don't reuse passwords from other accounts")])],-1)),e("div",null,[l[8]||(l[8]=e("label",{for:"currentPassword",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" Current Password "),e("span",{class:"text-red-500"},"*")],-1)),e("div",tt,[H(e("input",{id:"currentPassword","onUpdate:modelValue":l[0]||(l[0]=o=>P.value.currentPassword=o),type:w.value?"text":"password",placeholder:"Enter your current password",autocomplete:"current-password",disabled:a.disabled,class:"w-full px-4 py-2.5 pr-12 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,st),[[ke,P.value.currentPassword]]),e("button",{type:"button","aria-label":w.value?"Hide current password":"Show current password","aria-pressed":w.value,onClick:l[1]||(l[1]=o=>
1w.value=!w.value),class:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"},[w.value?(t(),s("svg",nt,[...l[7]||(l[7]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},null,-1)])])):(t(),s("svg",lt,[...l[6]||(l[6]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},null,-1),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},null,-1)])]))],8,ot)])]),e("div",null,[l[11]||(l[11]=e("label",{for:"newPassword",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" New Password "),e("span",{class:"text-red-500"},"*")],-1)),e("div",rt,[H(e("input",{id:"newPassword","onUpdate:modelValue":l[2]||(l[2]=o=>P.value.newPassword=o),type:c.value?"text":"password",placeholder:"Enter your new password",autocomplete:"new-password",disabled:a.disabled,class:L(["w-full px-4 py-2.5 pr-12 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition",P.value.newPassword.length>0&&P.value.newPassword.length<I(me)?"border-red-300":"border-gray-300"])},null,10,at),[[ke,P.value.newPassword]]),e("button",{type:"button","aria-label":c.value?"Hide new password":"Show new password","aria-pressed":c.value,onClick:l[3]||(l[3]=o=>c.value=!c.value),class:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"},[c.value?(t(),s("svg",ut,[...l[10]||(l[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},null,-1)])])):(t(),s("svg",dt,[...l[9]||(l[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},null,-1),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},null,-1)])]))],8,it)]),P.value.newPassword?(t(),s("div",ct,[e("div",vt,[e("div",mt,[e("div",{class:L(["h-full transition-all duration-300",x.value==="weak"?"w-1/3 bg-red-500":"",x.value==="medium"?"w-2/3 bg-yellow-500":"",x.value==="strong"?"w-full bg-green-500":""])},null,2)]),e("span",{class:L(["text-xs font-medium",x.value==="weak"?"text-red-600":"",x.value==="medium"?"text-yellow-600":"",x.value==="strong"?"text-green-600":""])},b(x.value==="weak"?"Weak":x.value==="medium"?"Medium":"Strong"),3)])])):f("",!0)]),e("div",null,[l[14]||(l[14]=e("label",{for:"confirmPassword",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" Confirm New Password "),e("span",{class:"text-red-500"},"*")],-1)),e("div",pt,[H(e("input",{id:"confirmPassword","onUpdate:modelValue":l[4]||(l[4]=o=>P.value.confirmPassword=o),type:v.value?"text":"password",placeholder:"Confirm your new password",autocomplete:"new-password",disabled:a.disabled,class:L(["w-full px-4 py-2.5 pr-12 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition",P.value.confirmPassword.length>0&&P.value.newPassword!==P.value.confirmPassword?"border-red-300":"border-gray-300"])},null,10,ft),[[ke,P.value.confirmPassword]]),e("button",{type:"button","aria-label":v.value?"Hide confirmed password":"Show confirmed password","aria-pressed":v.value,onClick:l[5]||(l[5]=o=>v.value=!v.value),class:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"},[v.value?(t(),s("svg",bt,[...l[13]||(l[13]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},null,-1)])])):(t(),s("svg",yt,[...l[12]||(l[12]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},null,-1),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},null,-1)])]))],8,gt)]),P.value.confirmPassword.length>0&&P.value.newPassword!==P.value.confirmPassword?(t(),s("p",xt," Passwords do not match ")):f("",!0)]),a.error?(t(),W(k,{key:0,message:a.error,type:"error"},null,8,["message"])):f("",!0)])}}}),kt=Object.assign(ht,{__name:"ChangePasswordForm"}),wt={class:"flex flex-col h-full -m-6"},Ct={class:"flex-1 overflow-y-auto"},_t={class:"space-y-6 p-6"},At={class:"flex items-center gap-4 p-4 bg-gray-50 rounded-lg"},Pt={class:"flex-1 min-w-0"},$t={class:"flex items-center justify-between gap-2"},Et={class:"flex-1 min-w-0"},It={class:"text-base font-semibold text-gray-900 truncate"},St=["disabled"],Ot={class:"flex items-center gap-2"},Mt=["value"],Tt={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Ft=["disabled"],Nt=["disabled"],Kt={class:"border-t border-gray-200"},Bt=["aria-expanded"],jt={key:0,id:"password-section",class:"px-6 pb-6"},zt={key:0,class:"mx-6 mb-6 flex items-start gap-3 p-4 bg-blue-50 border border-blue-200 rounded-lg"},Vt={class:"px-6 py-4 border-t border-gray-200 bg-gray-50 space-y-2"},Lt={key:0,id:"save-blocked-reason",role:"status","aria-live":"polite",class:"text-xs text-amber-700 text-right"},Ht={class:"flex gap-3"},Ut=["disabled"],Dt=["disabled","aria-describedby"],Rt={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},Gt={key:1},Wt={key:2},qt={class:"bg-white rounded-lg shadow-xl max-w-md w-full p-6"},Yt=["disabled"],Qt=["disabled"],Xt={class:"flex gap-3 pt-2"},Jt=["disabled"],Zt=["disabled"],es={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},ts={key:1},ss={key:2},os=le({__name:"ProfileForm",props:{user:{}},emits:["user-updated","saved","cancel"],setup(a,{emit:N}
1){const i=a,A=N,P=pe(),w=ue(),c=g({firstName:i.user.firstName||"",lastName:i.user.lastName||""}),v=g(!1),x=g(null),M=g(null),C=g(!1),F=g(null),l=g(Me()),k=g(!1),o=g(!1),d=g(null),O=g({newEmail:"",password:""}),y=G(()=>c.value.firstName!==(i.user.firstName||"")||c.value.lastName!==(i.user.lastName||"")),V=G(()=>C.value&&l.value.hasInput),j=G(()=>y.value||V.value),R=G(()=>v.value||V.value&&!l.value.isValid?!1:y.value||V.value),X=G(()=>{if(v.value||R.value||!V.value||l.value.isValid)return null;const{formData:K}=l.value;return K.currentPassword.length===0?"Enter your current password to save.":K.newPassword.length<me?`New password must be at least ${me} characters.`:K.newPassword!==K.confirmPassword?"New password and confirmation must match.":"Complete or clear the password fields to save."});ve(()=>i.user,K=>{c.value.firstName=K.firstName||"",c.value.lastName=K.lastName||""},{deep:!0}),ve(C,K=>{M.value=null,K||(l.value=Me())});const te=K=>{l.value=K},ne=()=>{C.value=!C.value},q=()=>{k.value=!1,d.value=null,O.value={newEmail:"",password:""}},z=(K,m)=>K?.data?.message||K?.message||m,_=async()=>{if(!R.value)return;v.value=!0,x.value=null,M.value=null;const K=y.value,m=V.value&&l.value.isValid,Z=K?w("/api/auth/profile",{method:"PATCH",body:{firstName:c.value.firstName,lastName:c.value.lastName}}):null,$=m?w("/api/auth/change-password",{method:"POST",body:{...l.value.formData}}):null,[r,B]=await Promise.allSettled([Z??Promise.resolve(null),$??Promise.resolve(null)]);let Y=!1,h=!1;K&&(r.status==="rejected"?x.value=z(r.reason,"Failed to update profile"):!r.value||!r.value.success?x.value=r.value?.message||"Failed to update profile":r.value.user&&(A("user-updated",r.value.user),Y=!0)),m&&(B.status==="rejected"?M.value=z(B.reason,"Failed to change password"):!B.value||!B.value.success?M.value=B.value?.message||"Failed to change password":(F.value?.reset(),C.value=!1,h=!0)),v.value=!1,(!K||Y)&&(!m||h)?(Y&&h?P.success("Profile and password updated"):h?P.success("Password updated"):Y&&P.success("Profile updated"),A("saved")):(Y&&P.success("Profile updated"),h&&P.success("Password updated"))},J=async()=>{d.value=null,o.value=!0;try{const K=await w("/api/auth/request-email-change",{method:"POST",body:{newEmail:O.value.newEmail,password:O.value.password}});P.success(K.message||"Verification email sent! Please check your new email address."),q()}catch(K){d.value=K.data?.message||"Failed to send verification email. Please try again."}finally{o.value=!1}};return(K,m)=>{const Z=Fe,$=xe,r=kt;return t(),s("div",wt,[m[20]||(m[20]=e("div",{class:"px-6 pt-6 pb-6 border-b border-gray-200"},[e("p",{class:"text-sm text-gray-600"}," Update your personal information, email, and password. ")],-1)),e("div",Ct,[e("form",{id:"profile-form",onSubmit:de(_,["prevent"])},[e("div",_t,[e("div",At,[m[7]||(m[7]=e("div",{class:"flex-shrink-0 w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center"},[e("svg",{class:"w-8 h-8 text-indigo-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})])],-1)),e("div",Pt,[e("div",$t,[e("div",Et,[m[6]||(m[6]=e("p",{class:"text-sm font-medium text-gray-500"},"Email Address",-1)),e("p",It,b(i.user.email),1)]),e("button",{type:"button",onClick:m[0]||(m[0]=B=>k.value=!0),disabled:v.value||o.value,class:"px-3 py-1.5 text-xs font-medium text-indigo-600 border border-indigo-600 rounded hover:bg-indigo-50 transition disabled:opacity-50 disabled:cursor-not-allowed"}," Change Email ",8,St)])])]),e("div",null,[m[8]||(m[8]=e("label",{for:"username",class:"block text-sm font-medium text-gray-700 mb-2"}," Username ",-1)),e("div",Ot,[e("input",{id:"username",value:i.user.username||"",type:"text",readonly:"",class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg bg-gray-100 text-gray-500 cursor-not-allowed focus:outline-none"},null,8,Mt),i.user.username?(t(),W(Z,{key:0,text:i.user.username,compact:!0},null,8,["text"])):f("",!0)])]),e("div",Tt,[e("div",null,[m[9]||(m[9]=e("label",{for:"firstName",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" First Name "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{id:"firstName","onUpdate:modelValue":m[1]||(m[1]=B=>c.value.firstName=B),type:"text",placeholder:"Enter first name",required:"",autocomplete:"given-name",disabled:v.value,class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,Ft),[[Q,c.value.firstName]])]),e("div",null,[m[10]||(m[10]=e("label",{for:"lastName",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" Last Name "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{id:"lastName","onUpdate:modelValue":m[2]||(m[2]=B=>c.value.lastName=B),type:"text",placeholder:"Enter last name",required:"",autocomplete:"family-name",disabled:v.value,class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,Nt),[[Q,c.value.lastName]])])]),x.value?(t(),W($,{key:0,message:x.value,type:"error"},null,8,["message"])):f("",!0)])],32),e("div",Kt,[e("button",{type:"button","aria-expanded":C.value,"aria-controls":"password-section",onClick:ne,class:"w-full px-6 py-4 flex items-center justify-between hover:bg-gray-50 transition"},[m[12]||(m[12]=ae('<div class="flex items-center gap-3"><div class="flex-shrink-0 w-10 h-10 bg-green-100 rounded-full flex items-center justify-center"><svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path></svg></div><div class="text-left"><h3 class="text-base font-semibold text-gray-900">Change Password</h3><p class="text-xs text-gray-500">Update your account password</p></div></div>',1)),(t(),s("svg",{class:L(["w-5 h-5 text-gray-400 transition-transform",C.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...m[11]||(m[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))],8,Bt),C.value?(t(),s("div",jt,[U(r,{ref_key:"passwordFormRef",ref:F,disabled:v.value,error:M.value,onStateChange:te},null,8,["disabled","error"])])):f("",!0)]),j.value?(t(),s("div",zt,[...m[13]||(m[13]=[e("svg",{class:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),e("div",null,[e("p",{class:"text-sm font-medium text-blue-900"},"You have unsaved changes"),e("p",{class:"text-xs text-blue-700 mt-1"},'Click "Save Changes" to apply them.')],-1)])])):f("",!0)]),e("div",Vt,[X.value?(t(),s("p",Lt,b(X.value),1)):f("",!0),e("div",Ht,[e("button",{type:"button",onClick:m[3]||(m[3]=B=>K.$emit("cancel")),disabled:v.value,class:"flex-1 px-5 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Ut),e("button",{form:"profile-form",type:"submit",disabled:!R.value,"aria-describedby":X.value?"save-blocked-reason":void 0,class:"flex-1 px-5 py-2.5 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[v.value?(t(),s("svg",Rt,[...m[14]||(m[14]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),v.value?(t(),s("span",Wt,"Saving...")):(t(),s("span",Gt,"Save Changes"))],8,Dt)])]),k.value?(t(),s("div",{key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:de(q,["self"])},[e("div",qt,[m[19]||(m[19]=e("h3",{class:"text-lg font-semibold text-gray-900 mb-4"},"Change Email Address",-1)),e("form",{onSubmit:de(J,["prevent"]),class:"space-y-4"},[e("div",null,[m[15]||(m[15]=e("label",{for:"newEmail",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" New Email Address "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{id:"newEmail","onUpdate:modelValue":m[4]||(m[4]=B=>O.value.newEmail=B),type:"email",placeholder:"Enter new email address",required:"",disabled:o.value,class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,Yt),[[Q,O.value.newEmail]])]),e("div",null,[m[16]||(m[16]=e("label",{for:"emailChangePassword",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" Current Password "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{id:"emailChangePassword","onUpdate:modelValue":m[5]||(m[5]=B=>O.value.password=B),type:"password",placeholder:"Enter your current password",required:"",autocomplete:"current-password",disabled:o.value,class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,Qt),[[Q,O.value.password]])]),d.value?(t(),W($,{key:0,message:d.value,type:"error"},null,8,["message"])):f("",!0),m[18]||(m[18]=e("div",{class:"flex items-start gap-3 p-3 bg-blue-50 border border-blue-200 rounded-lg"},[e("svg",{class:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]),e("div",null,[e("p",{class:"text-xs text-blue-900"},"We'll send a verification link to your new email address. You'll need to verify it before the change takes effect.")])],-1)),e("div",Xt,[e("button",{type:"button",onClick:q,disabled:o.value,class:"flex-1 px-4 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Jt),e("button",{type:"submit",disabled:o.value,class:"flex-1 px-4 py-2.5 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[o.value?(t(),s("svg",es,[...m[17]||(m[17]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),o.value?(t(),s("span",ss,"Sending...")):(t(),s("span",ts,"Send Verification"))],8,Zt)])],32)])])):f("",!0)])}}}),ls=Object.assign(os,{__name:"ProfileForm"}),ns={class:"flex flex-col h-full -m-6"},rs={class:"flex-1 space-y-4 p-6 overflow-y-auto"},as=["for"],is=["id","onUpdate:modelValue","placeholder","disabled"],ds={class:"px-6 py-4 border-t border-gray-200 flex gap-3 bg-gray-50"},us=["disabled"],cs=["disabled"],vs={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},ms={key:1},ps={key:2},fs=le({__name:"EventNamesForm",emits:["cancel","saved"],setup(a,{emit:N}){const i=N,A=ue(),{eventNames:P,isLoaded:w,error:c,fetchEventNames:v,getCustomName:x,refreshEventNames:M}=De(),C=g({event_1:"",event_2:"",event_3:"",event_4:"",event_5:"",event_6:"",event_7:"",event_8:"",event_9:"",event_10:""}),F=g(!1),l=g(""),k=g("");v();function o(){we.forEach(O=>{C.value[`event_${O}`]=x(O)??""})}ve(()=>P.value,()=>{w.value&&o()},{immediate:!0}),ve(()=>c.value,O=>{O&&(l.value=O)},{immediate:!0});async function d(){l.value="",k.value="",F.value=!0;try{const O={};we.forEach(V=>{const j=C.value[`event_${V}`];j&&j.trim().length>0&&(O[V]=j.trim())});const y=await A("/api/event-names",{method:"PUT",body:{eventNames:O}});y.success?(await M(),k.value="Custom event names saved successfully!",setTimeout(()=>{i("saved")},1500)):l.value=y.message||"Failed to save custom event names"}catch(O){console.error("[EventNamesForm] Save error:",O),l.value=O.data?.message||"Failed to save custom event names"}finally{F.value=!1}}return(O,y)=>{const V=xe;return t(),s("div",ns,[y[3]||(y[3]=e("div",{class:"px-6 pt-6 pb-6 border-b border-gray-200"},[e("p",{class:"text-sm text-gray-600"},' Customize the names for your 10 custom event slots. These names will appear in your stats tables and reports (e.g., "Opt-ins", "Video Views", "Add to Cart"). ')],-1)),e("form",{onSubmit:de(d,["prevent"]),class:"flex-1 flex flex-col"},[e("div",rs,[y[1]||(y[1]=ae('<div class="flex items-start gap-4 p-4 bg-blue-50 border border-blue-200 rounded-lg"><div class="flex-shrink-0 w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center"><svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"></path></svg></div><div><p class="text-sm font-semibold text-blue-900">What are custom events?</p><ul class="text-xs text-blue-700 mt-2 space-y-1"><li>• Track custom actions beyond conversions (no revenue)</li><li>• Examples: opt-ins, video plays, add to cart, checkout views</li><li>• Leave blank to use default names (&quot;Custom Event 1&quot;, &quot;Custom Event 2&quot;, etc.)</li><li>• Names can be changed anytime</li></ul></div></div>',1)),(t(!0),s(se,null,ie(I(we),j=>(t(),s("div",{key:j,class:"flex items-center gap-3"},[e("label",{for:`event-${j}`,class:"text-sm font-medium text-gray-700 w-20 flex-shrink-0"}," Event "+b(j),9,as),H(e("input",{id:`event-${j}`,"onUpdate:modelValue":R=>C.value[`event_${j}`]=R,type:"text",placeholder:I(Re)(j),disabled:F.value,maxlength:"50",class:"flex-1 px-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,is),[[Q,C.value[`event_${j}`]]])]))),128)),l.value?(t(),W(V,{key:0,message:l.value,type:"error"},null,8,["message"])):f("",!0),k.value?(t(),W(V,{key:1,message:k.value,type:"success"},null,8,["message"])):f("",!0)]),e("div",ds,[e("button",{type:"button",onClick:y[0]||(y[0]=j=>O.$emit("cancel")),disabled:F.value,class:"flex-1 px-5 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,us),e("button",{type:"submit",disabled:F.value,class:"flex-1 px-5 py-2.5 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[F.value?(t(),s("svg",vs,[...y[2]||(y[2]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),F.value?(t(),s("span",ps,"Saving...")):(t(),s("span",ms,"Save Custom Event Names"))],8,cs)])],32)])}}}),gs=Object.assign(fs,{__name:"EventNamesForm"}),ys={},bs={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function xs(a,N){return t(),s("svg",bs,[...N[0]||(N[0]=[e("path",{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.65-1.58-1.11-.01.31-.01.62-.01.93 0 5.21-2.92 9.06-7.14 10.32-1.92.57-3.99.37-5.78-.58-1.74-.93-3.1-2.58-3.66-4.51-.55-1.94-.17-4.04.97-5.71 1.16-1.7 3.08-2.78 5.15-2.92.05 0 .1 0 .15 0v4.2c-1.03.11-2 1.07-2.05 2.14-.07 1.5 1.16 2.8 2.67 2.83 1.5.03 2.73-1.17 2.79-2.66.01-1.35 0-2.69 0-4.04V.02h2.79z",fill:"#25F4EE",transform:"translate(-0.5, -0.5)"},null,-1),e("path",{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.65-1.58-1.11-.01.31-.01.62-.01.93 0 5.21-2.92 9.06-7.14 10.32-1.92.57-3.99.37-5.78-.58-1.74-.93-3.1-2.58-3.66-4.51-.55-1.94-.17-4.04.97-5.71 1.16-1.7 3.08-2.78 5.15-2.92.05 0 .1 0 .15 0v4.2c-1.03.11-2 1.07-2.05 2.14-.07 1.5 1.16 2.8 2.67 2.83 1.5.03 2.73-1.17 2.79-2.66.01-1.35 0-2.69 0-4.04V.02h2.79z",fill:"#FE2C55",transform:"translate(0.5, 0.5)"},null,-1),e("path",{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.65-1.58-1.11-.01.31-.01.62-.01.93 0 5.21-2.92 9.06-7.14 10.32-1.92.57-3.99.37-5.78-.58-1.74-.93-3.1-2.58-3.66-4.51-.55-1.94-.17-4.04.97-5.71 1.16-1.7 3.08-2.78 5.15-2.92.05 0 .1 0 .15 0v4.2c-1.03.11-2 1.07-2.05 2.14-.07 1.5 1.16 2.8 2.67 2.83 1.5.03 2.73-1.17 2.79-2.66.01-1.35 0-2.69 0-4.04V.02h2.79z",fill:"currentColor"},null,-1)])])}const Pe=Object.assign(Be(ys,[["render",xs]]),{__name:"IconsTikTokBrandIcon"}),hs={class:"space-y-3"},ks={key:0,class:"text-sm text-gray-600"},ws=["href"],Cs={class:"block text-sm font-medium text-gray-700 mb-1"},_s=["placeholder"],As={key:0,class:"text-sm text-gray-400 mt-0.5"},Ps={key:0,class:"text-sm text-gray-400 mt-0.5"},$s={key:1},Es=["placeholder"],Is={class:"text-sm text-gray-400 mt-0.5"},Ss=["href"],Os={key:2},Ms={key:0,class:"text-sm text-gray-400 mt-0.5"},Ts=le({__name:"ManualAdPixelForm",props:{form:{},isEditing:{type:Boolean},platform:{default:p.FACEBOOK}},setup(a){return(N,i)=>
1(t(),s("div",hs,[a.platform===I(p).OPENAI?(t(),s("p",ks,[i[5]||(i[5]=E(" Add a Pixel ID and its Conversions API key from the Conversions tab in ",-1)),e("a",{href:I(Oe).ADS_MANAGER_URL,target:"_blank",rel:"noopener",class:"text-indigo-600 underline"},"OpenAI Ads Manager",8,ws),i[6]||(i[6]=E(". You can add multiple pixels and choose the receiving pixel in Tracking Setup. ",-1))])):f("",!0),e("div",null,[e("label",Cs,b(a.platform===I(p).OPENAI?"Conversions API Key":"Access Token"),1),H(e("input",{"onUpdate:modelValue":i[0]||(i[0]=A=>a.form.accessToken=A),type:"password",class:"block w-full rounded-md border-gray-300 text-sm py-1.5 focus:ring-indigo-500 focus:border-indigo-500",placeholder:a.isEditing?"Leave blank to keep current token":a.platform===I(p).OPENAI?"Your OpenAI Conversions API key":"Your Facebook System User Access Token"},null,8,_s),[[Q,a.form.accessToken]]),a.platform===I(p).FACEBOOK?(t(),s("p",As,[...i[7]||(i[7]=[E(" Get it from ",-1),e("a",{href:"https://business.facebook.com/events_manager2/list/",target:"_blank",rel:"noopener",class:"text-blue-500 hover:text-blue-600 underline"},"Events Manager",-1),E(" > Click your Pixel > Settings > Scroll to Conversions API > Click Generate Access Token ",-1)])])):f("",!0)]),e("div",null,[i[9]||(i[9]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Pixel ID",-1)),H(e("input",{"onUpdate:modelValue":i[1]||(i[1]=A=>a.form.pixelId=A),type:"text",class:"block w-full rounded-md border-gray-300 text-sm py-1.5 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"e.g. 1234567890"},null,512),[[Q,a.form.pixelId]]),a.platform===I(p).FACEBOOK?(t(),s("p",Ps,[...i[8]||(i[8]=[E(" Found in ",-1),e("a",{href:"https://eventsmanager.facebook.com/events_manager2/list/",target:"_blank",rel:"noopener",class:"text-blue-500 hover:text-blue-600 underline"},"Events Manager",-1),E(' > Click your Pixel > Settings > You will see "PIXEL ID" or "DATASET ID" depending on when your pixel was created ',-1)])])):f("",!0)]),e("div",null,[i[10]||(i[10]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Pixel Name",-1)),H(e("input",{"onUpdate:modelValue":i[2]||(i[2]=A=>a.form.name=A),type:"text",class:"block w-full rounded-md border-gray-300 text-sm py-1.5 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"e.g. Main Store Pixel"},null,512),[[Q,a.form.name]])]),a.platform===I(p).OPENAI?(t(),s("div",$s,[i[13]||(i[13]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Ads API Key (optional)",-1)),H(e("input",{"onUpdate:modelValue":i[3]||(i[3]=A=>a.form.adsApiKey=A),type:"password",class:"block w-full rounded-md border-gray-300 text-sm py-1.5 focus:ring-indigo-500 focus:border-indigo-500",placeholder:a.isEditing?"Leave blank to keep the current key, if any":"Enables hourly ad cost tracking"},null,8,Es),[[Q,a.form.adsApiKey]]),e("p",Is,[i[11]||(i[11]=E(" Issue it in ",-1)),e("a",{href:I(Oe).ADS_MANAGER_URL,target:"_blank",rel:"noopener",class:"text-blue-500 hover:text-blue-600 underline"},"OpenAI Ads Manager",8,Ss),i[12]||(i[12]=E(" > Settings. Only needed to pull ad spend automatically. ",-1))])])):f("",!0),a.platform===I(p).FACEBOOK?(t(),s("div",Os,[i[15]||(i[15]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Test Event Code (optional)",-1)),H(e("input",{"onUpdate:modelValue":i[4]||(i[4]=A=>a.form.testEventCode=A),type:"text",class:"block w-full rounded-md border-gray-300 text-sm py-1.5 focus:ring-indigo-500 focus:border-indigo-500",placeholder:"e.g. TEST12345"},null,512),[[Q,a.form.testEventCode]]),a.platform===I(p).FACEBOOK?(t(),s("p",Ms,[...i[14]||(i[14]=[E(" From ",-1),e("a",{href:"https://business.facebook.com/events_manager2/list/",target:"_blank",rel:"noopener",class:"text-blue-500 hover:text-blue-600 underline"},"Events Manager",-1),E(" > Click your Pixel > Test Events tab ",-1)])])):f("",!0)])):f("",!0)]))}}),Te=Object.assign(Ts,{__name:"ManualAdPixelForm"}),Fs={class:"flex-1 flex flex-col min-h-0"},Ns={class:"flex-1 space-y-4 p-6 overflow-y-auto min-h-0"},Ks={key:0,class:"flex items-center justify-center py-8"},Bs={key:1,class:"space-y-3"},js={class:"flex items-center justify-between"},zs={class:"flex items-center gap-3"},Vs={key:0,class:"w-10 h-10 rounded-full bg-white border border-gray-200 flex items-center justify-center"},Ls={key:1,class:"w-10 h-10 rounded-full bg-blue-600 flex items-center justify-center"}
1,Hs={key:2,class:"w-10 h-10 rounded-full bg-black flex items-center justify-center overflow-hidden"},Us={key:3,class:"w-10 h-10 rounded-full bg-gray-900 flex items-center justify-center"},Ds={key:4,class:"w-10 h-10 rounded-full bg-green-100 flex items-center justify-center"},Rs={class:"flex items-center gap-2"},Gs={class:"font-medium text-gray-900"},Ws={key:0,class:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800 mr-1.5"},qs={key:0,class:"px-2 py-0.5 text-xs font-medium bg-gray-100 text-gray-500 rounded"},Ys=["title"],Qs=["title"],Xs={class:"text-xs text-gray-500 mt-0.5"},Js={key:0},Zs={key:1},eo={key:2},to={key:3},so={key:4},oo={class:"flex items-center gap-2"},lo={key:0,class:"mx-2 h-6 w-11 flex items-center justify-center"},no=["onClick","disabled","title"],ro={class:"sr-only"},ao=["onClick","disabled"],io=["onClick","disabled"],uo={key:0,class:"mt-2 text-xs text-red-600"},co={key:2,class:"text-center py-8 text-gray-500"},vo={class:"text-sm"},mo={key:3,class:"mt-4 p-4 bg-blue-50 border border-blue-200 rounded-lg space-y-3"},po={class:"text-xs font-semibold text-blue-900"},fo=["data-help","disabled"],go={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},yo={class:"px-6 py-4 border-t border-gray-200 flex gap-3 bg-gray-50"},bo=["disabled"],xo={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},ho={key:1,class:"w-4 h-4",viewBox:"0 0 24 24"},ko=["disabled"],wo={key:0,class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24"},Co={key:1,class:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},_o=["disabled"],Ao={key:1,class:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},Po={key:3,disabled:"",class:"flex-1 px-5 py-2.5 text-sm font-medium text-gray-400 bg-gray-100 border border-gray-200 rounded-lg cursor-not-allowed flex items-center justify-center gap-2"},$o={class:"px-6 py-4"},Eo={class:"flex items-start gap-4"},Io={class:"text-sm text-gray-600"},So={class:"text-gray-900"},Oo={class:"bg-gray-50 border-t border-gray-200 px-6 py-4 flex justify-end gap-3"},Mo=["disabled"],To={class:"p-4 bg-blue-50 border border-blue-200 rounded-lg"},Fo={class:"flex gap-3"},No=["disabled"],Ko={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},Bo=le({__name:"AdPlatformsForm",props:{isEmbedded:{type:Boolean,default:!1},selectedPlatform:{type:String,default:p.GOOGLE}},emits:["cancel","saved"],setup(a,{emit:N}){const i=pe(),A=ue(),P=We==="byot",w=Ce({accessToken:"",adsApiKey:"",adAccountId:"",pixelId:"",name:"",testEventCode:""}),c=Ce({accessToken:"",adsApiKey:"",adAccountId:"",pixelId:"",name:"",testEventCode:""}),v=g(null),x=g(p.FACEBOOK),M=a;ve(()=>M.selectedPlatform,()=>{C(w),Z()});function C(n){n.accessToken=n.adsApiKey=n.adAccountId=n.pixelId=n.name=n.testEventCode=""}const F=N,l=je(),k=g(!0),o=g(!1),d=g([]),{accountCurrency:O}=Ge(),y=g(null),V=g(!1),j=g(!1),R=g(!1),X=g(new Set),{googleAccountsFlattened:te,facebookAccountsFlattened:ne}=qe(d),q=G(()=>M.selectedPlatform===p.GOOGLE?te.value:M.selectedPlatform===p.FACEBOOK?ne.value:d.value.filter(n=>n.platform===M.selectedPlatform));fe(async()=>{if(l.query.success==="google_connected")i.success("Google Ads account connected successfully!"),{...l.query},window.history.replaceState({},"",l.path),F("saved");else if(l.query.success==="facebook_connected")i.success("Facebook account connected successfully!"),{...l.query},window.history.replaceState({},"",l.path),F("saved");else if(l.query.success==="tiktok_connected"){const n=l.query.advertisers||0,u=l.query.pixels||0;i.success(`TikTok connected! ${n} advertiser(s), ${u} pixel(s) imported.`),{...l.query},window.history.replaceState({},"",l.path),F("saved")}else if(l.query.error){const u={google_oauth_denied:"Google authorization was denied",facebook_oauth_denied:"Facebook authorization was denied",tiktok_oauth_denied:"TikTok authorization was denied",oauth_expired:"OAuth session expired, please try again",no_google_ads_accounts:"No Google Ads accounts found. Please ensure you have an ad account.",no_facebook_ad_accounts:"No Facebook ad accounts found. Please ensure you have an active ad account.",no_tiktok_advertisers:"No TikTok advertiser accounts found. Please ensure you have an ad account.",tiktok_not_configured:"TikTok integration not configured on the server.",oauth_failed:"OAuth connection failed",token_exchange_failed:"Failed to exchange tokens with the platform",no_refresh_token:"No refresh token received",invali
1d_state:"Invalid OAuth state",user_fetch_failed:"Failed to fetch user information"}[l.query.error]||"Failed to connect to the platform";i.error(u),{...l.query},window.history.replaceState({},"",l.path)}await z()});async function z(){k.value=!0;try{const n=await A("/api/ad-platforms");n.success?d.value=n.accounts:i.error(n.message||"Failed to load accounts")}catch(n){console.error("[AdPlatformsForm] Load error:",n),i.error("Failed to load accounts")}finally{k.value=!1}}async function _(){V.value=!0;try{const n=await A("/api/ad-platforms/google/oauth-url");n.success&&n.url?(sessionStorage.setItem("openAdPlatformsPanel","true"),sessionStorage.setItem("openAdPlatformType",p.GOOGLE),window.location.href=n.url):(i.error(n.message||"Failed to get OAuth URL"),V.value=!1)}catch(n){console.error("[AdPlatformsForm] OAuth URL error:",n),i.error(n.data?.message||"Failed to connect"),V.value=!1}}async function J(){j.value=!0;try{const n=await A("/api/ad-platforms/facebook/oauth-url");n.success&&n.url?(sessionStorage.setItem("openAdPlatformsPanel","true"),sessionStorage.setItem("openAdPlatformType",p.FACEBOOK),window.location.href=n.url):(i.error(n.message||"Failed to connect to Facebook"),j.value=!1)}catch(n){console.error("[AdPlatformsForm] Facebook OAuth URL error:",n),i.error(n.data?.message||"Failed to connect"),j.value=!1}}async function K(){o.value=!0;try{const n=await A("/api/ad-platforms",{method:"POST",body:{platform:M.selectedPlatform,name:w.name,...M.selectedPlatform===p.OPENAI?{openAiApiKey:w.accessToken,openAiAdsApiKey:w.adsApiKey||void 0,openAiPixelId:w.pixelId}:{facebookAccessToken:w.accessToken,facebookPixelId:w.pixelId,facebookAdAccountId:w.adAccountId||void 0,facebookTestEventCode:w.testEventCode||void 0}}});n.success&&n.account?(d.value=[n.account,...d.value],C(w),i.success("Pixel added successfully!"),F("saved")):i.error(n.message||"Failed to add pixel")}catch(n){console.error("[AdPlatformsForm] BYOT create error:",n),i.error(n.data?.message||"Failed to add pixel")}finally{o.value=!1}}function m(n){v.value=n.id,x.value=n.platform,C(c),c.adAccountId=n.facebookAdAccountId||"",c.pixelId=n.platform===p.OPENAI?n.openAiPixelId||"":n.facebookPixelId||"",c.name=n.name}function Z(){v.value=null,C(c)}async function $(){if(v.value){o.value=!0;try{const n={name:c.name,...x.value===p.OPENAI?{openAiPixelId:c.pixelId}:{facebookPixelId:c.pixelId,facebookAdAccountId:c.adAccountId||void 0,facebookTestEventCode:c.testEventCode||void 0}};c.accessToken&&(x.value===p.OPENAI?n.openAiApiKey=c.accessToken:n.facebookAccessToken=c.accessToken),x.value===p.OPENAI&&c.adsApiKey&&(n.openAiAdsApiKey=c.adsApiKey);const u=await A(`/api/ad-platforms/${v.value}`,{method:"PATCH",body:n});u.success&&u.account?(d.value=d.value.map(re=>re.id===v.value?u.account:re),Z(),i.success("Pixel updated successfully!"),F("saved")):i.error(u.message||"Failed to update pixel")}catch(n){console.error("[AdPlatformsForm] BYOT update error:",n),i.error(n.data?.message||"Failed to update pixel")}finally{o.value=!1}}}async function r(n){X.value.add(n.id);try{const u=await A(`/api/ad-platforms/${n.id}`,{method:"PATCH",body:{isEnabled:!n.isEnabled}});u.success&&u.account?(d.value=d.value.map(re=>re.id===n.id?u.account:re),i.success(`Account ${n.isEnabled?"disabled":"enabled"} successfully`)):i.error(u.message||"Failed to update account")}catch(u){console.error("[AdPlatformsForm] Toggle error:",u),i.error(u.data?.message||"Failed to update account")}finally{X.value.delete(n.id)}}function B(n){y.value=n}async function Y(){if(y.value){o.value=!0;try{const n=await A(`/api/ad-platforms/${y.value.id}`,{method:"DELETE"});n.success?(d.value=d.value.filter(u=>u.id!==y.value.id),y.value=null,i.success("Account deleted successfully")):i.error(n.message||"Failed to delete account")}catch(n){console.error("[AdPlatformsForm] Delete error:",n),i.error(n.data?.message||"Failed to delete account")}finally{o.value=!1}}}function h(n){return ce[n]||n}function oe(n){return{[p.GOOGLE]:"bg-blue-100 text-blue-600",[p.FACEBOOK]:"bg-indigo-100 text-indigo-600",[p.OPENAI]:"bg-gray-900 text-white",[p.TIKTOK]:"bg-gray-900 text-white",[p.MICROSOFT]:"bg-green-100 text-green-600"}[n]||"bg-gray-100 text-gray-600"}function ee(n){const u=n.replace(/-/g,"");return u.length===10?`${u.slice(0,3)}-${u.slice(3,6)}-${u.slice(6)}`:n}async function T(){R.value=!0;try{const n=await A("/api/ad-platforms/tiktok/oauth-url");n.success&&n.url?(sessionStorage.setItem("openAdPlatformsPanel","true"),sessionStorage.setItem("openAdPlatformType",p.TIKTOK),window.location.href=n.url):(i.error(n.message||"Failed to connect to TikTok"),R.value=!1)}catch(n){console.error("[AdPlatformsForm] TikTok OAuth URL error:",n),i.error(n.data?.message||"Failed to connect"),R.value=!1}}return(n,u)=>{const re=$e,Ke=he;return t(),s("div",{class:L([a.isEmbedded?"flex flex-col h-full":"flex flex-col h-full -m-6"])},[u[24]||(u[24]=e("div",{class:"px-6 pt-6 pb-6 border-b border-gray-200 flex-shrink-0"},[e("p",{class:"text-sm text-gray-600"}," Connect your ad platform accounts to automatically send conversion data for closed-loop attribution. ")],-1)),e("div",Fs,[e("div",Ns,[u[13]||(u[13]=ae('<div class="flex items-start gap-4 p-4 bg-blue-50 border border-blue-200 rounded-lg"><div class="flex-shrink-0 w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center"><svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg></div><div><p class="text-sm font-semibold text-blue-900">How it works</p><ul class="text-xs text-blue-700 mt-2 space-y-1"><li>• Conversions are automatically sent to connected platforms</li><li>• OpenAI supports customer matching without a click ID; other platforms require their click ID</li><li>• PII data (email, phone) is hashed before sending</li></ul></div></div>',1)),k.value?(t(),s("div",Ks,[...u[3]||(u[3]=[e("svg",{class:"animate-spin h-6 w-6 text-indigo-600",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1)])])):q.value.length>0?(t(),s("div",Bs,[(t(!0),s(se,null,ie(q.value,S=>(t(),s("div",{key:S.id,class:L(["p-4 bg-white border border-gray-200 rounded-lg transition-opacity",{"opacity-50":!S.isEnabled}]),style:ze({marginLeft:`${(S.depth||0)*24}px`})},[e("div",js,[e("div",zs,[S.platform===I(p).GOOGLE?(t(),s("div",Vs,[...u[4]||(u[4]=[ae('<svg class="w-5 h-5" viewBox="0 0 24 24"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"></path><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"></path><path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"></path><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"></path></svg>',1)])])):S.platform===I(p).FACEBOOK?(t(),s("div",Ls,[...u[5]||(u[5]=[e("svg",{class:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})],-1)])])):S.platform===I(p).TIKTOK?(t(),s("div",Hs,[U(Pe,{class:"w-6 h-6 text-white"})])):S.platform===I(p).OPENAI?(t(),s("div",Us,[U(Ne,{class:"w-5 h-5 text-white"})])):S.platform===I(p).MICROSOFT?(t(),s("div",Ds,[...u[6]||(u[6]=[e("svg",{class:"w-5 h-5 text-green-600",fill:"none",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M11.332 0h-11.332v11.332h11.332v-11.332zM24 0h-11.332v11.332h11.332v-11.332zM11.332 12.668h-11.332v11.332h11.332v-11.332zM24 12.668h-11.332v11.332h11.332v-11.332z"})],-1)])])):(t(),s("div",{key:5,class:L(["w-10 h-10 rounded-full flex items-center justify-center",oe(S.platform)])},[...u[7]||(u[7]=[e("svg",{class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"})],-1)])],2)),e("div",null,[e("div",Rs,[e("span",Gs,[S.isManager?(t(),s("span",Ws,"MCC")):f("",!0),E(" "+b(S.name),1)]),S.isEnabled?f("",!0):(t(),s("span",qs," Disabled ")),S.spendConvertible===!1?(t(),s("span",{key:1,class:"px-2 py-0.5 text-xs font-medium bg-red-100 text-red-700 rounded",title:`No exchange rate is available for ${S.currency} yet — this account's spend is NOT imported until one is`},b(S.currency)+": no exchange rate, spend not imported ",9,Ys)):S.currency&&S.currency!==I(O)?(t(),s("span",{key:2,class:"px-2 py-0.5 text-xs font-medium bg-amber-100 text-amber-700 rounded",title:`This ad account bills in ${S.currency}; its spend is converted to your account currency (${I(O)}) when imported`},b(S.currency)+" → "+b(I(O)),9,Qs)):f("",!0)]),e("div",Xs,[E(b(h(S.platform))+" ",1),S.googleCustomerId?(t(),s("span",Js," • "+b(ee(S.googleCustomerId)),1)):f("",!0),S.openAiPixelId?(t(),s("span",Zs," • Pixel: "+b(S.openAiPixelId),1)):f("",!0),S.openAiCostPullEnabled?(t(),s("span",eo," • Cost tracking on")):f("",!0),S.facebookPixelId?(t(),s("span",to," • Pixel: "+b(S.facebookPixelId),1)):f("",!0),S.facebookAdAccountId?(t(),s("span",so," • act_"+b(S.facebookAdAccountId),1)):f("",!0)])])]),e("div",oo,[X.value.has(S.id)?(t(),s("div",lo,[...u[8]||(u[8]=[e("svg",{class:"animate-spin h-5 w-5 text-indigo-600",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1)])])):(t(),s("button",{key:1,onClick:Ee=>r(S),disabled:o.value||S.isManager,class:L(["relative inline-flex items-center h-6 rounded-full w-11 transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 mx-2",[S.isEnabled?"bg-indigo-600":"bg-gray-200",S.isManager?"opacity-50 cursor-not-allowed":""]]),title:S.isManager?"Manager accounts cannot be enabled for cost pulling":S.isEnabled?"Disable Account":"Enable Account"},[e("span",ro,b(S.isEnabled?"Disable":"Enable"),1),e("span",{class:L(["inline-block w-4 h-4 transform bg-white rounded-full transition-transform",S.isEnabled?"translate-x-6":"translate-x-1"])},null,2)],10,no)),S.platform===I(p).FACEBOOK&&P||S.platform===I(p).OPENAI?(t
1(),s("button",{key:2,onClick:Ee=>m(S),disabled:o.value,class:"p-2 text-gray-400 hover:text-indigo-600 transition",title:"Edit"},[...u[9]||(u[9]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})],-1)])],8,ao)):f("",!0),e("button",{onClick:Ee=>B(S),disabled:o.value,class:"p-2 text-gray-400 hover:text-red-600 transition",title:"Delete"},[...u[10]||(u[10]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,io)])]),S.lastSyncError?(t(),s("div",uo," Last sync error: "+b(S.lastSyncError),1)):f("",!0)],6))),128))])):(t(),s("div",co,[u[11]||(u[11]=e("svg",{class:"w-12 h-12 mx-auto text-gray-300 mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})],-1)),e("p",vo,"No "+b(h(a.selectedPlatform))+" accounts connected",1)])),a.selectedPlatform===I(p).FACEBOOK&&P||a.selectedPlatform===I(p).OPENAI?(t(),s("div",mo,[e("p",po,"Add "+b(h(a.selectedPlatform))+" Pixel",1),U(Te,{form:w,platform:a.selectedPlatform},null,8,["form","platform"]),e("button",{onClick:K,"data-help":a.selectedPlatform===I(p).OPENAI?"openai-integration":void 0,disabled:o.value||!w.accessToken||!w.pixelId||!w.name,class:"w-full px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 transition flex items-center justify-center gap-2"},[o.value?(t(),s("svg",go,[...u[12]||(u[12]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),E(" "+b(o.value?"Adding...":`Add ${h(a.selectedPlatform)} Pixel`),1)],8,fo)])):f("",!0)]),e("div",yo,[e("button",{type:"button",onClick:u[0]||(u[0]=S=>n.$emit("cancel")),class:"flex-1 px-5 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition"}," Close "),a.selectedPlatform===I(p).GOOGLE?(t(),s("button",{key:0,onClick:_,disabled:V.value,class:"flex-1 px-5 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition disabled:opacity-50 flex items-center justify-center gap-2"},[V.value?(t(),s("svg",xo,[...u[14]||(u[14]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):(t(),s("svg",ho,[...u[15]||(u[15]=[e("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"},null,-1),e("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"},null,-1),e("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"},null,-1),e("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"},null,-1)])])),E(" "+b(V.value?"Connecting...":"Connect Google Ads"),1)],8,bo)):a.selectedPlatform===I(p).FACEBOOK&&!P?(t(),s("button",{key:1,onClick:J,disabled:j.value,class:"flex-1 px-5 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition flex items-center justify-center gap-2 disabled:opacity-50"},[j.value?(t(),s("svg",Co,[...u[17]||(u[17]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):(t(),s("svg",wo,[...u[16]||(u[16]=[e("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"},null,-1)])])),E(" "+b(j.value?"Connecting...":"Connect Facebook Account"),1)],8,ko)):a.selectedPlatform===I(p).TIKTOK?(t(),s("button",{key:2,onClick:T,disabled:R.value,"data-help":"tiktok-integration",class:"flex-1 px-5 py-2.5 text-sm font-medium text-white bg-black rounded-lg hover:bg-gray-800 transition flex items-center justify-center gap-2 disabled:opacity-50"},[R.value?(t(),s("svg",Ao,[...u[18]||(u[18]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):(t(),W(Pe,{key:0,class:"w-4 h-4 text-white"})),E(" "+b(R.value?"Connecting...":"Connect TikTok Account"),1)],8,_o)):a.selectedPlatform===I(p).MICROSOFT?(t(),s("button",Po," Coming Soon ")):f("",!0)])]),y.value?(t(),W(re,{key:0,"is-open":!0,onClose:u[2]||(u[2]=S=>y.value=null),title:"Delete Account","max-width":"sm"},{footer:D(()=>[e("div",Oo,[e("button",{onClick:u[1]||(u[1]=S=>y.value=null),class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors"}," Cancel "),e("button",{onClick:Y,disabled:o.value,class:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors"},b(o.value?"Deleting...":"Delete"),9,Mo)])]),default:D(()=>[e("div",$o,[e("div",Eo,[u[22]||(u[22]=e("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-red-100 flex items-center justify-center"},[e("svg",{class:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),e("div",null,[e("p",Io,[u[19]||(u[19]=E(" Are you sure you want to delete ",-1)),e("strong",So,b(y.value.name),1),u[20]||(u[20]=E("? ",-1))]),u[21]||(u[21]=e("p",{class:"text-xs text-gray-500 mt-1"}," Conversions will no longer be sent to this account. ",-1))])])])]),_:1})):f("",!0),U(Ke,{"is-open":!!v.value,title:`Edit ${h(x.value)} Pixel`,level:1,"above-modals":!0,"max-width":"600px",onClose:Z},{footer:D(()=>[e("div",Fo,[e("button",{onClick:Z,class:"flex-1 px-4 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition"}
1," Cancel "),e("button",{onClick:$,disabled:o.value||!c.pixelId||!c.name,class:"flex-1 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 transition flex items-center justify-center gap-2"},[o.value?(t(),s("svg",Ko,[...u[23]||(u[23]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),E(" "+b(o.value?"Saving...":"Save Changes"),1)],8,No)])]),default:D(()=>[e("div",To,[U(Te,{form:c,platform:x.value,"is-editing":!0},null,8,["form","platform"])])]),_:1},8,["is-open","title"])],2)}}}),jo=Object.assign(Bo,{__name:"AdPlatformsForm"}),zo={class:"flex-1 space-y-6 p-6 overflow-y-auto"},Vo=["disabled"],Lo={key:0},Ho={class:"px-6 py-4 border-t border-gray-200 flex gap-3 bg-gray-50"},Uo=["disabled"],Do=["disabled"],Ro={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},Go={key:1},Wo={key:2},qo={__name:"ClickbankIpnKeyForm",props:{currentKey:{type:String,default:""},userId:{type:String,default:null},saving:{type:Boolean,default:!1},error:{type:String,default:null},successMessage:{type:String,default:null},isEmbedded:{type:Boolean,default:!1}},emits:["submit","cancel"],setup(a,{expose:N,emit:i}){const A=a,P=i,w=g({clickbankIpnKey:A.currentKey||""}),c=G(()=>A.userId?`${typeof window<"u"?window.location.origin:""}/api/conversion/ipn/clickbank/${A.userId}`:""),v=G(()=>w.value.clickbankIpnKey.length>0),x=()=>{v.value&&P("submit",{clickbankIpnKey:w.value.clickbankIpnKey})};return N({reset:()=>{w.value={clickbankIpnKey:A.currentKey||""}}}),(M,C)=>{const F=Fe,l=xe;return t(),s("div",{class:L([a.isEmbedded?"h-full":"flex flex-col h-full -m-6"])},[C[8]||(C[8]=e("div",{class:"px-6 pt-6 pb-6 border-b border-gray-200"},[e("p",{class:"text-sm text-gray-600"}," Set your Clickbank IPN secret key here, then copy this same key to your Clickbank account settings along with the IPN URL. ")],-1)),e("form",{onSubmit:de(x,["prevent"]),class:"flex-1 flex flex-col"},[e("div",zo,[C[6]||(C[6]=ae('<div class="flex items-start gap-4 p-4 bg-blue-50 border border-blue-200 rounded-lg"><div class="flex-shrink-0 w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center"><svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg></div><div><p class="text-sm font-semibold text-blue-900">Setup Instructions</p><ul class="text-xs text-blue-700 mt-2 space-y-1"><li>• Set a secret key here (or use default &#39;CLICKERVOLT&#39;)</li><li>• Copy this key to your Clickbank account IPN settings</li><li>• Clickbank will use this key to encrypt conversion notifications</li><li>• Keep this key secure and don&#39;t share it publicly</li></ul></div></div>',1)),e("div",null,[C[2]||(C[2]=e("label",{for:"clickbankIpnKey",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" Clickbank IPN Secret Key "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{id:"clickbankIpnKey","onUpdate:modelValue":C[0]||(C[0]=k=>w.value.clickbankIpnKey=k),type:"text",placeholder:"Enter a secret key (e.g., CLICKERVOLT)",required:"",disabled:a.saving,class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition"},null,8,Vo),[[Q,w.value.clickbankIpnKey]]),C[3]||(C[3]=e("p",{class:"text-xs text-gray-500 mt-1"}," After saving, copy this key to your Clickbank account IPN settings ",-1))]),c.value?(t(),s("div",Lo,[C[4]||(C[4]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Clickbank IPN URL ",-1)),U(F,{text:c.value,label:"Copy IPN URL",class:"w-full"},null,8,["text"]),C[5]||(C[5]=e("p",{class:"text-xs text-gray-500 mt-1"}," Copy this URL to your Clickbank account IPN settings along with your secret key above ",-1))])):f("",!0),a.error?(t(),W(l,{key:1,message:a.error,type:"error"},null,8,["message"])):f("",!0),a.successMessage?(t(),W(l,{key:2,message:a.successMessage,type:"success"},null,8,["message"])):f("",!0)]),e("div",Ho,[e("button",{type:"button",onClick:C[1]||(C[1]=k=>M.$emit("cancel")),disabled:a.saving,class:"flex-1 px-5 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Uo),e("button",{type:"submit",disabled:a.saving||!v.value,class:"flex-1 px-5 py-2.5 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[a.saving?(t(),s("svg",Ro,[...C[7]||(C[7]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),a.saving?(t(),s("span",Wo,"Saving...")):(t(),s("span",Go,"Save IPN Key"))],8,Do)])],32)],2)}}},Yo={class:"flex flex-col h-full -m-6"},Qo={class:"px-6 py-4 border-b border-gray-200 bg-white"},Xo={class:"sm:hidden"},Jo={key:0,value:"ad_platforms"},Zo={class:"hidden sm:block"},el={class:"flex space-x-4","aria-label":"Tabs"},tl={class:"flex-1 overflow-hidden relative"},sl={key:0,class:"h-full flex flex-col sm:flex-row bg-gray-50"},ol={class:"sm:hidden p-4 border-b border-gray-200 bg-white flex-shrink-0"},ll=["value"],nl={class:"hidden sm:flex w-64 flex-shrink-0 bg-white border-r border-gray-200 h-full flex-col"},rl={class:"flex-1 overflow-y-auto p-2 space-y-1"},al=["onClick","data-help"],il={key:0,class:"w-4 h-4",viewBox:"0 0 24 24"}
1,dl={key:1,class:"w-4 h-4 text-white",fill:"currentColor",viewBox:"0 0 24 24"},ul={key:2,class:"w-4 h-4 flex items-center justify-center"},cl={key:4,class:"w-4 h-4 text-green-600",fill:"none",viewBox:"0 0 24 24"},vl={class:"flex-1 h-full overflow-hidden bg-white"},ml={class:"h-full flex flex-col sm:flex-row bg-gray-50"},pl={class:"sm:hidden p-4 border-b border-gray-200 bg-white flex-shrink-0"},fl={class:"hidden sm:flex w-64 flex-shrink-0 bg-white border-r border-gray-200 h-full flex-col"},gl={class:"flex-1 overflow-y-auto p-2 space-y-1"},yl={class:"flex-1 h-full overflow-hidden bg-white"},bl={key:0,class:"h-full"},xl=le({__name:"IntegrationsPanel",props:{currentKey:{type:String,default:""},userId:{type:String,default:null},clickbankSaving:{type:Boolean,default:!1},clickbankError:{type:String,default:null},clickbankSuccessMessage:{type:String,default:null},initialAdPlatform:{type:String,default:null}},emits:["cancel","saved","clickbank-submit"],setup(a){const{canAccessGoogleAds:N,canAccessFacebookAds:i,canAccessTiktokAds:A,canAccessOpenAiAds:P,canAccessAnyAdPlatform:w}=_e(),c=w,v=a,x=g(c.value?"ad_platforms":"affiliate_networks"),M=[{id:p.GOOGLE,name:ce[p.GOOGLE],bgClass:"bg-blue-100"},{id:p.FACEBOOK,name:`${ce[p.FACEBOOK]} (CAPI)`,bgClass:"bg-blue-600"},{id:p.TIKTOK,name:ce[p.TIKTOK],bgClass:"bg-black"},{id:p.OPENAI,name:ce[p.OPENAI],bgClass:"bg-gray-900"},{id:p.MICROSOFT,name:ce[p.MICROSOFT],bgClass:"bg-gray-100"}],C=G(()=>M.filter(k=>k.id===p.GOOGLE?N.value:k.id===p.FACEBOOK?i.value:k.id===p.TIKTOK?A.value:k.id===p.OPENAI?P.value:!1)),l=Ce({activeNetwork:"clickbank",activeAdPlatform:(()=>{if(v.initialAdPlatform){if(v.initialAdPlatform===p.OPENAI&&P.value)return p.OPENAI;if(v.initialAdPlatform===p.GOOGLE&&N.value)return p.GOOGLE;if(v.initialAdPlatform===p.FACEBOOK&&i.value)return p.FACEBOOK}return C.value[0]?.id??p.GOOGLE})()});return(k,o)=>{const d=jo,O=qo;return t(),s("div",Yo,[e("div",Qo,[e("div",Xo,[o[11]||(o[11]=e("label",{for:"tabs",class:"sr-only"},"Select a tab",-1)),H(e("select",{id:"tabs",name:"tabs","onUpdate:modelValue":o[0]||(o[0]=y=>x.value=y),class:"block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500"},[I(c)?(t(),s("option",Jo,"Ad Platforms")):f("",!0),o[10]||(o[10]=e("option",{value:"affiliate_networks"},"Affiliate Networks",-1))],512),[[be,x.value]])]),e("div",Zo,[e("nav",el,[I(c)?(t(),s("button",{key:0,onClick:o[1]||(o[1]=y=>x.value="ad_platforms"),class:L(["px-3 py-2 font-medium text-sm rounded-md transition-colors duration-200",[x.value==="ad_platforms"?"bg-indigo-50 text-indigo-700":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"]])}," Ad Platforms ",2)):f("",!0),e("button",{onClick:o[2]||(o[2]=y=>x.value="affiliate_networks"),class:L(["px-3 py-2 font-medium text-sm rounded-md transition-colors duration-200",[x.value==="affiliate_networks"?"bg-indigo-50 text-indigo-700":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"]])}," Affiliate Networks ",2)])])]),e("div",tl,[I(c)?H((t(),s("div",sl,[e("div",ol,[o[12]||(o[12]=e("label",{for:"ad-platform-select",class:"sr-only"},"Select Ad Platform",-1)),H(e("select",{id:"ad-platform-select","onUpdate:modelValue":o[3]||(o[3]=y=>l.activeAdPlatform=y),class:"block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 text-sm"},[(t(!0),s(se,null,ie(C.value,y=>(t(),s("option",{key:y.id,value:y.id},b(y.name),9,ll))),128))],512),[[be,l.activeAdPlatform]])]),e("div",nl,[o[16]||(o[16]=e("div",{class:"p-4 border-b border-gray-200"},[e("h3",{class:"text-xs font-semibold text-gray-500 uppercase tracking-wider"},"Ad Platforms")],-1)),e("nav",rl,[(t(!0),s(se,null,ie(C.value,y=>(t(),s("button",{key:y.id,onClick:V=>l.activeAdPlatform=y.id,class:L(["w-full text-left px-3 py-2 text-sm font-medium rounded-md transition-colors flex items-center gap-3",[l.activeAdPlatform===y.id?"bg-indigo-50 text-indigo-700":"text-gray-700 hover:bg-gray-50 hover:text-gray-900"]]),"data-help":y.id===I(p).FACEBOOK?"facebook-capi-emq":y.id===I(p).GOOGLE?"google-enhanced-conversions":y.id===I(p).TIKTOK?"tiktok-integration":y.id===I(p).OPENAI?"openai-integration":void 0},[e("div",{class:L(["w-6 h-6 rounded flex items-center justify-center flex-shrink-0",y.bgClass])},[y.id===I(p).GOOGLE?(t(),s("svg",il,[...o[13]||(o[13]=[e("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"},null,-1),e("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"},null,-1),e("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"},null,-1),e("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"},null,-1)])])):y.id===I(p).FACEBOOK?(t(),s("svg",dl,[...o[14]||(o[14]=[e("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"},null,-1)])])):y.id===I(p).TIKTOK?(t(),s("div",ul,[U(Pe,{class:"w-4 h-4 text-white"}
1)])):y.id===I(p).OPENAI?(t(),W(Ne,{key:3,class:"w-4 h-4 text-white"})):y.id===I(p).MICROSOFT?(t(),s("svg",cl,[...o[15]||(o[15]=[e("path",{fill:"currentColor",d:"M11.332 0h-11.332v11.332h11.332v-11.332zM24 0h-11.332v11.332h11.332v-11.332zM11.332 12.668h-11.332v11.332h11.332v-11.332zM24 12.668h-11.332v11.332h11.332v-11.332z"},null,-1)])])):f("",!0)],2),E(" "+b(y.name),1)],10,al))),128))])]),e("div",vl,[U(d,{"is-embedded":!0,"selected-platform":l.activeAdPlatform,onCancel:o[4]||(o[4]=y=>k.$emit("cancel")),onSaved:o[5]||(o[5]=y=>k.$emit("saved"))},null,8,["selected-platform"])])],512)),[[Ie,x.value==="ad_platforms"]]):f("",!0),H(e("div",ml,[e("div",pl,[o[18]||(o[18]=e("label",{for:"network-select",class:"sr-only"},"Select Network",-1)),H(e("select",{id:"network-select","onUpdate:modelValue":o[6]||(o[6]=y=>l.activeNetwork=y),class:"block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 text-sm"},[...o[17]||(o[17]=[e("option",{value:"clickbank"},"Clickbank",-1)])],512),[[be,l.activeNetwork]])]),e("div",fl,[o[20]||(o[20]=e("div",{class:"p-4 border-b border-gray-200"},[e("h3",{class:"text-xs font-semibold text-gray-500 uppercase tracking-wider"},"Networks")],-1)),e("nav",gl,[e("button",{onClick:o[7]||(o[7]=y=>
1l.activeNetwork="clickbank"),class:L(["w-full text-left px-3 py-2 text-sm font-medium rounded-md transition-colors flex items-center gap-3",[l.activeNetwork==="clickbank"?"bg-indigo-50 text-indigo-700":"text-gray-700 hover:bg-gray-50 hover:text-gray-900"]])},[...o[19]||(o[19]=[e("div",{class:"w-6 h-6 rounded bg-blue-100 flex items-center justify-center flex-shrink-0"},[e("svg",{class:"w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})])],-1),E(" Clickbank ",-1)])],2)])]),e("div",yl,[l.activeNetwork==="clickbank"?(t(),s("div",bl,[U(O,{"is-embedded":!0,"current-key":a.currentKey,"user-id":a.userId,saving:a.clickbankSaving,error:a.clickbankError,"success-message":a.clickbankSuccessMessage,onSubmit:o[8]||(o[8]=y=>k.$emit("clickbank-submit",y)),onCancel:o[9]||(o[9]=y=>k.$emit("cancel"))},null,8,["current-key","user-id","saving","error","success-message"])])):f("",!0)])],512),[[Ie,x.value==="affiliate_networks"]])])])}}}),hl=Object.assign(xl,{__name:"IntegrationsPanel"}),kl=[{key:"conversion",label:"Conversion",description:"Triggers when a conversion is tracked"},{key:"refund",label:"Refund",description:"Triggers when a refund is processed"},{key:"event.triggered",label:"Custom Event Triggered",description:"Triggers on any of the 10 custom event slots"}],wl=[{name:"revenue",description:"Conversion revenue amount (in your account currency)"},{name:"currency",description:"Account currency code of the revenue amount (e.g. USD)"},{name:"transaction",description:"Transaction ID"},{name:"email",description:"Visitor email (PII from the profile)"},{name:"first_name",description:"Visitor first name (PII from the profile)"},{name:"last_name",description:"Visitor last name (PII from the profile)"},{name:"phone",description:"Visitor phone (PII from the profile)"},{name:"dob",description:"Visitor date of birth (PII from the profile)"},{name:"gender",description:"Visitor gender (PII from the profile)"},{name:"ip",description:"Visitor IP address from the last click"},{name:"utm_source",description:"utm_source — most recent across click history (v1)"},{name:"utm_medium",description:"utm_medium — most recent across click history (v2)"},{name:"utm_campaign",description:"utm_campaign — most recent across click history (v3)"},{name:"utm_term",description:"utm_term — most recent across click history (v4)"},{name:"utm_content",description:"utm_content — most recent across click history (v5)"}],Cl={class:"space-y-6"},_l={key:0,class:"relative"},Al={class:"space-y-4"},Pl={key:0,class:"text-center py-8 text-gray-500 flex flex-col items-center gap-2"},$l={key:1,class:"text-center py-8 bg-gray-50 rounded-lg border border-gray-200"},El={key:2,class:"bg-white shadow overflow-hidden sm:rounded-md"},Il={class:"divide-y divide-gray-200"},Sl=["onClick"],Ol={class:"flex-1 min-w-0"},Ml={class:"flex items-center space-x-2"},Tl={class:"text-sm font-medium text-gray-900"},Fl={key:0,class:"px-2 py-0.5 text-xs font-medium bg-gray-100 text-gray-500 rounded"},Nl={class:"text-sm text-gray-500 mt-1 truncate max-w-lg"},Kl={class:"mt-2 flex items-center text-xs text-gray-500 space-x-4"},Bl={key:0},jl={key:0,class:"h-6 w-11 flex items-center justify-center"},zl=["onClick","title"],Vl={class:"sr-only"},Ll=["onClick"],Hl=["onClick"],Ul={key:0,class:"py-8 text-center text-gray-500"},Dl={class:"space-y-6 p-6"},Rl={class:"flex border border-gray-300 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500 focus-within:border-indigo-500 transition overflow-hidden"},Gl={class:"flex items-center border-l border-gray-300 bg-gray-50"},Wl={class:"flex items-center gap-2 mt-2 flex-wrap"},ql=["onClick","title"],Yl={class:"space-y-2"},Ql=["value"],Xl={class:"ml-2 text-sm text-gray-700"},Jl={key:0,class:"ml-1 text-xs text-gray-400"},Zl={class:"bg-gray-50 p-4 rounded-md border border-gray-200"},en={key:0,class:"mt-2 text-xs text-center text-gray-500"},tn={key:0,class:"space-y-3"},sn={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg border border-gray-200"},on={class:"font-bold"},ln={class:"flex justify-between px-6 py-4 border-t border-gray-200 bg-gray-50"},nn=["disabled"],rn={key:0,class:"animate-spin -ml-1 mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24"},an={class:"flex space-x-3"},dn=["disabled"],un={key:0,class:"animate-spin -ml-1 mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24"},cn={class:"px-6 py-4"},vn={class:"flex items-start gap-4"},mn={class:"text-sm text-gray-600"},pn={class:"text-gray-900"},fn={class:"bg-gray-50 border-t border-gray-200 px-6 py-4 flex justify-end gap-3"},gn=["disabled"],yn=le({__name:"WebhooksSettings",emits:["saved","cancel"],setup(a,{emit:N}){const i=N,A=g([]),P=g(!0),w=g(!1),c=g(!1),v=g(!1),x=g(null),M=g(""),C=g(new Set),F=g(null),l=g(!1),k=pe(),o=ue(),d=g({name:"",url:"",method:"POST",events:["conversion"],rules:[],includeVisitorProfile:!0,isEnabled:!0}),O=wl,y=$=>{const r=`[${$}]`;let B=d.value.url||"";if(B.endsWith("=")){d.value.url=B+r;return}const h=B.includes("?")?"&":"?";d.value.url=B+h+$+"="+r},V=G(()=>!d.value.rules||d.value.rules.length===0?[]:d.value.rules[0].conditions),j=$=>{(!d.value.rules||d.value.rules.length===0)&&(d.value.rules=[{id:"default_rule",name:"Default Filter",priority:0,enabled:!0,conditions:[]}]),d.value.rules[0].conditions=$},R=G(()=>{if(!M.value.trim())return A.value;const $=M.value.toLowerCase();return A.value.filter(r=>r.name.toLowerCase().includes($)||r.url.toLowerCase().includes($))}),X=async $=>{C.value.add($.id);try{const{data:r}=await ge(`/api/webhooks/${$.id}`,{method:"PATCH",body:{isEnabled:!$.isEnabled}},"$K6RLm-PyYM");if(r.value&&r.value.success){const B=!$.isEnabled,Y=A.value.findIndex(h=>h.id===$.id);Y!==-1&&(A.value[Y].isEnabled=B),k.success(B?"Webhook enabled":"Webhook disabled")}else k.error(r.value?.message||"Failed to update webhook")}catch{k.error("Failed to update webhook")}finally{C.value.delete($.id)}},te=async()=>{P.value=!0;try{const $=await o("/api/webhooks");$&&$.success&&$.webhooks&&(A.value=$.webhooks)}catch($){console.error("Failed to fetch webhooks",$),k.error("Failed to load webhooks")}finally{P.value=!1}},ne=()=>{d.value={name:"",url:"",method:"POST",events:["conversion"],rules:[],includeVisitorProfile:!0,isEnabled:!0},x.value=null,w.value=!0},q=$=>{d.value=JSON.parse(JSON.stringify($)),x.value=null,w.value=!0},z=()=>{w.value=!1,x.value=null},_=async()=>
1{if(!d.value.name||!d.value.url){k.error("Name and URL are required");return}c.value=!0;try{const $=d.value.id?`/api/webhooks/${d.value.id}`:"/api/webhooks",r=d.value.id?"PATCH":"POST",{data:B}=await ge($,{method:r,body:d.value},"$Qx5NP2YaFX");B.value&&B.value.success?(k.success("Webhook saved successfully"),w.value=!1,te(),i("saved")):k.error(B.value?.message||"Failed to save webhook")}catch($){console.error("Error saving webhook",$),k.error("An error occurred")}finally{c.value=!1}},J=$=>{F.value=$},K=async()=>{if(F.value){l.value=!0;try{const{data:$}=await ge(`/api/webhooks/${F.value.id}`,{method:"DELETE"},"$7WRKe_8GY0");$.value&&$.value.success?(k.success("Webhook deleted"),F.value=null,te()):k.error($.value?.message||"Failed to delete webhook")}catch{k.error("Failed to delete webhook")}finally{l.value=!1}}},m=async()=>{if(!d.value.url){k.error("Enter a URL to test");return}v.value=!0,x.value=null;try{const{data:$}=await ge("/api/webhooks/test",{method:"POST",body:{config:d.value}},"$GQqzIBmKYL");$.value&&$.value.success&&$.value.result?(x.value=$.value.result,$.value.result.success?k.success("Test delivery successful"):k.error("Test delivery failed")):k.error($.value?.message||"Test failed")}catch{k.error("Test request failed")}finally{v.value=!1}},Z=$=>new Date($).toLocaleString();return fe(()=>{te()}),($,r)=>{const B=he,Y=$e;return t(),s(se,null,[e("div",Cl,[e("div",{class:"flex justify-between items-center"},[r[10]||(r[10]=e("h3",{class:"text-lg font-medium text-gray-900"},"Global Webhooks",-1)),e("button",{onClick:ne,class:"px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"}," Add Webhook ")]),A.value.length>0?(t(),s("div",_l,[r[11]||(r[11]=e("div",{class:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"},[e("svg",{class:"h-4 w-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})])],-1)),H(e("input",{"onUpdate:modelValue":r[0]||(r[0]=h=>M.value=h),type:"text",placeholder:"Search webhooks...",class:"block w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 text-sm"},null,512),[[Q,M.value]])])):f("",!0),e("div",Al,[P.value?(t(),s("div",Pl,[...r[12]||(r[12]=[e("svg",{class:"animate-spin h-6 w-6 text-indigo-600",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),E(" Loading webhooks... ",-1)])])):A.value.length===0?(t(),s("div",$l,[...r[13]||(r[13]=[e("p",{class:"text-gray-500"},"No webhooks configured.",-1)])])):(t(),s("div",El,[e("ul",Il,[(t(!0),s(se,null,ie(R.value,h=>(t(),s("li",{key:h.id,class:L(["px-6 py-4 flex items-center justify-between hover:bg-gray-50 transition-opacity cursor-pointer",{"opacity-50":!h.isEnabled}]),onClick:oe=>q(h)},[e("div",Ol,[e("div",Ml,[e("h4",Tl,b(h.name),1),e("span",{class:L(["px-1.5 py-0.5 text-xs font-medium rounded",h.method==="GET"?"bg-amber-100 text-amber-700":"bg-indigo-100 text-indigo-700"])},b(h.method||"POST"),3),h.isEnabled?f("",!0):(t(),s("span",Fl," Disabled "))]),e("p",Nl,b(h.url),1),e("div",Kl,[e("span",null,"Events: "+b(h.events.join(", ")),1),h.lastDeliveryAt?(t(),s("span",Bl,[E(" Last delivery: "+b(Z(h.lastDeliveryAt))+" ",1),e("span",{class:L(h.lastDeliveryStatus==="success"?"text-green-600":"text-red-600")}," ("+b(h.lastDeliveryStatus)+") ",3)])):f("",!0)])]),e("div",{class:"flex items-center gap-1 ml-2 flex-shrink-0",onClick:r[1]||(r[1]=de(()=>{},["stop"]))},[C.value.has(h.id)?(t(),s("div",jl,[...r[14]||(r[14]=[e("svg",{class:"animate-spin h-4 w-4 text-indigo-600",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1)])])):(t(),s("button",{key:1,type:"button",onClick:oe=>X(h),class:L(["relative inline-flex items-center h-6 rounded-full w-11 transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",h.isEnabled?"bg-indigo-600":"bg-gray-200"]),title:h.isEnabled?"Disable Webhook":"Enable Webhook"},[e("span",Vl,b(h.isEnabled?"Disable":"Enable"),1),e("span",{class:L(["inline-block w-4 h-4 transform bg-white rounded-full transition-transform",h.isEnabled?"translate-x-6":"translate-x-1"])},null,2)],10,zl)),e("button",{onClick:oe=>q(h),class:"pl-1 text-gray-400 hover:text-indigo-600 transition",title:"Edit"},[...r[15]||(r[15]=[e("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,Ll),e("button",{onClick:oe=>J(h),class:"pl-1 text-gray-400 hover:text-red-600 transition",title:"Delete"},[...r[16]||(r[16]=[e("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,Hl)])],10,Sl))),128))]),R.value.length===0&&M.value?(t(),s("div",Ul," No webhooks match your search. ")):f("",!0)]))])]),U(B,{"is-open":w.value,title:d.value.id?"Edit Webhook":"Create Webhook",level:1,onClose:z},{footer:D(()=>[e("div",ln,[e("button",{type:"button",onClick:m,disabled:v.value,class:"inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-lg text-gray-700 bg-white hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition"},[v.value?(t(),s("svg",rn,[...r[24]||(r[24]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),E(" "+b(v.value?"Sending...":"Test Webhook"),1)],8,
1nn),e("div",an,[e("button",{type:"button",onClick:z,class:"px-4 py-2 border border-gray-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"}," Cancel "),e("button",{type:"button",onClick:_,disabled:c.value,class:"inline-flex items-center px-5 py-2.5 border border-transparent shadow-sm text-sm font-medium rounded-lg text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed transition"},[c.value?(t(),s("svg",un,[...r[25]||(r[25]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),E(" "+b(c.value?"Saving...":"Save Webhook"),1)],8,dn)])])]),default:D(()=>[e("div",Dl,[e("div",null,[r[17]||(r[17]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},[E("Name "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{"onUpdate:modelValue":r[2]||(r[2]=h=>d.value.name=h),type:"text",required:"",class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition",placeholder:"e.g. CRM Integration"},null,512),[[Q,d.value.name]])]),e("div",null,[r[19]||(r[19]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},[E("Endpoint URL "),e("span",{class:"text-red-500"},"*")],-1)),e("div",Rl,[H(e("input",{"onUpdate:modelValue":r[3]||(r[3]=h=>d.value.url=h),type:"url",required:"",class:"flex-1 px-4 py-2.5 border-0 focus:ring-0 focus:outline-none",placeholder:"https://api.example.com/webhook"},null,512),[[Q,d.value.url]]),e("div",Gl,[e("button",{type:"button",onClick:r[4]||(r[4]=h=>d.value.method="POST"),class:L(["px-3 py-2.5 text-xs font-medium transition-colors",d.value.method==="POST"?"bg-indigo-600 text-white":"text-gray-600 hover:bg-gray-100"])}," POST ",2),e("button",{type:"button",onClick:r[5]||(r[5]=h=>d.value.method="GET"),class:L(["px-3 py-2.5 text-xs font-medium transition-colors",d.value.method==="GET"?"bg-indigo-600 text-white":"text-gray-600 hover:bg-gray-100"])}," GET ",2)])]),e("div",Wl,[r[18]||(r[18]=e("span",{class:"text-xs text-gray-500"},"Insert token:",-1)),(t(!0),s(se,null,ie(I(O),h=>(t(),s("button",{key:h.name,type:"button",onClick:oe=>y(h.name),class:"px-2 py-0.5 text-xs bg-indigo-50 text-indigo-700 rounded hover:bg-indigo-100 transition font-mono",title:h.description}," ["+b(h.name)+"] ",9,ql))),128))]),r[20]||(r[20]=e("p",{class:"mt-1 text-xs text-gray-400"},[E(" Any custom incoming query arg also works as a token (e.g. "),e("span",{class:"font-mono"},"[order_id]"),E(") — resolved from the most recent click that carried it. ")],-1))]),e("div",null,[r[21]||(r[21]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2","data-help":"webhook-events"},"Trigger Events",-1)),e("div",Yl,[(t(!0),s(se,null,ie(I(kl),h=>(t(),s("label",{key:h.key,class:"inline-flex items-center mr-6"},[H(e("input",{type:"checkbox","onUpdate:modelValue":r[6]||(r[6]=oe=>d.value.events=oe),value:h.key,class:"rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"},null,8,Ql),[[Se,d.value.events]]),e("span",Xl,b(h.label),1),h.description?(t(),s("span",Jl,"("+b(h.description)+")",1)):f("",!0)]))),128))])]),e("div",null,[r[22]||(r[22]=e("div",{class:"flex justify-between items-center mb-2"},[e("label",{"data-help":"webhook-conditions",class:"block text-sm font-medium text-gray-700"},"Conditions (Optional)"),e("span",{class:"text-xs text-gray-500"},"Only fire if these match")],-1)),e("div",Zl,[U(Ye,{conditions:V.value,"available-fields":I(Qe),"onUpdate:conditions":j},null,8,["conditions","available-fields"]),V.value.length===0?(t(),s("p",en," No conditions set. Webhook will fire for all matching events. ")):f("",!0)])]),d.value.method==="POST"?(t(),s("div",tn,[e("div",sn,[r[23]||(r[23]=e("div",null,[e("div",{class:"text-sm font-medium text-gray-900"},"Include Visitor Profile"),e("div",{class:"text-xs text-gray-600 mt-0.5"},"Send the entire profile history in payload")],-1)),H(e("input",{id:"includeProfile","onUpdate:modelValue":r[7]||(r[7]=h=>d.value.includeVisitorProfile=h),type:"checkbox",class:"h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"},null,512),[[Se,d.value.includeVisitorProfile]])])])):f("",!0),x.value?(t(),s("div",{key:1,class:L(["p-4 rounded-md text-sm",x.value.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"])},[e("p",on,b(x.value.success?"Test Delivery Successful":"Test Delivery Failed"),1),e("p",null,"Status: "+b(x.value.status)+" ("+b(x.value.responseStatus)+")",1),e("pre",{class:L(["mt-2 text-xs overflow-auto max-h-40 bg-white p-2 rounded border",x.value.success?"border-green-200":"border-red-200"])},b(x.value.responseBody),3)],2)):f("",!0)])]),_:1},8,["is-open","title"]),F.value?(t(),W(Y,{key:0,"is-open":!0,onClose:r[9]||(r[9]=h=>F.value=null),title:"Delete Webhook","max-width":"sm"},{footer:D(()=>[e("div",fn,[e("button",{onClick:r[8]||(r[8]=h=>F.value=null),class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors"}," Cancel "),e("button",{onClick:K,disabled:l.value,class:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors"},b(l.value?"Deleting...":"Delete"),9,gn)])]),default:D(()=>[e("div",cn,[e("div",vn,[r[29]||(r[29]=e("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-red-100 flex items-center justify-center"},[e("svg",{class:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),e("div",null,[e("p",mn,[r[26]||(r[26]=E(" Are you sure you want to delete ",-1)),e("strong",pn,b(F.value.name),1),r[27]||(r[27]=E("? ",-1))]),r[28]||(r[28]=e("p",{class:"text-xs text-gray-500 mt-1"}," This webhook will no longer receive event notifications. ",-1))])])])]),_:1})):f("",!0)],64)}}}),bn=Object.assign(yn,{__name:"SettingsWebhooksSettings"}),ye=10,xn=100,hn={class:"space-y-6"},kn={class:"flex justify-between items-center"},wn=["disabled","title"],Cn={key:0,class:"text-center py-8 text-gray-500 flex flex-col items-center gap-2"},_n={key:1,class:"text-center py-8 bg-gray-50 rounded-lg border border-gray-200"}
1,An={key:2,class:"bg-white shadow overflow-hidden sm:rounded-md"},Pn={class:"divide-y divide-gray-200"},$n={class:"flex-1 min-w-0"},En={class:"flex items-center space-x-2"},In={class:"text-sm font-medium text-gray-900 truncate"},Sn={key:0,class:"px-2 py-0.5 text-xs font-medium bg-gray-100 text-gray-500 rounded"},On={key:1,class:"px-2 py-0.5 text-xs font-medium bg-green-100 text-green-700 rounded"},Mn={class:"text-sm text-gray-500 mt-1 font-mono"},Tn={class:"mt-2 flex items-center text-xs text-gray-500 space-x-4"},Fn={key:0},Nn={key:1,class:"text-gray-400"},Kn={key:2},Bn={key:0,class:"flex items-center gap-1 ml-2 flex-shrink-0"},jn=["onClick"],zn={key:3,class:"text-xs text-gray-500"},Vn={class:"space-y-6 p-6"},Ln=["maxlength","onKeydown"],Hn={class:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 bg-gray-50"},Un=["disabled"],Dn={key:0,class:"animate-spin -ml-1 mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24"},Rn={class:"px-6 py-4 space-y-4"},Gn={class:"flex items-stretch gap-2"},Wn=["value"],qn={class:"px-6 py-4"},Yn={class:"flex items-start gap-4"},Qn={class:"text-sm text-gray-600"},Xn={class:"text-gray-900"},Jn={class:"bg-gray-50 border-t border-gray-200 px-6 py-4 flex justify-end gap-3"},Zn=["disabled"],er=le({__name:"ApiKeysSettings",emits:["created","revoked"],setup(a,{emit:N}){const i=N,A=pe(),P=ue(),w=g([]),c=g(!0),v=g(!1),x=g(!1),M=g(""),C=g(null),F=g(!1),l=g(null),k=g(null),o=g(!1),d=G(()=>w.value.filter(z=>!z.revokedAt).length),O=async()=>{c.value=!0;try{const z=await P("/api/api-keys");z?.success?w.value=z.apiKeys:A.error(z?.message||"Failed to load API keys")}catch(z){console.error("Failed to fetch API keys",z),A.error("Failed to load API keys")}finally{c.value=!1}},y=()=>{M.value="",v.value=!0},V=()=>{v.value=!1},j=async()=>{const z=M.value.trim();if(z){x.value=!0;try{const _=await P("/api/api-keys",{method:"POST",body:{name:z}});_?.success&&_.key&&_.apiKey?(w.value=[_.apiKey,...w.value],v.value=!1,C.value=_.key,F.value=!1,await Le(),l.value?.focus(),l.value?.select(),i("created")):A.error(_?.message||"Failed to create API key")}catch(_){console.error("Error creating API key",_),A.error("An error occurred while creating the API key")}finally{x.value=!1}}},R=async()=>{if(C.value)try{await navigator.clipboard.writeText(C.value),F.value=!0,A.success("Copied to clipboard")}catch{l.value?.focus(),l.value?.select(),A.error("Could not copy automatically — select and copy manually")}},X=()=>{C.value=null,F.value=!1},te=z=>{k.value=z},ne=async()=>{if(!k.value)return;const z=k.value.id;o.value=!0;try{const _=await P(`/api/api-keys/${z}`,{method:"DELETE"});if(_?.success){const J=w.value.findIndex(K=>K.id===z);J!==-1&&(w.value[J]={...w.value[J],revokedAt:new Date().toISOString()}),k.value=null,A.success("API key revoked"),i("revoked")}else A.error(_?.message||"Failed to revoke API key")}catch(_){console.error("Error revoking API key",_),A.error("An error occurred while revoking the API key")}finally{o.value=!1}},q=z=>new Date(z).toLocaleString();return fe(()=>{O()}),(z,_)=>{const J=he,K=$e;return t(),s(se,null,[e("div",hn,[e("div",kn,[_[4]||(_[4]=e("h3",{class:"text-lg font-medium text-gray-900"},"Public REST API Keys",-1)),e("button",{type:"button",onClick:y,disabled:c.value||d.value>=I(ye),class:"px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed",title:d.value>=I(ye)?`Limit of ${I(ye)} active keys reached. Revoke one to create another.`:""}," New API Key ",8,wn)]),_[8]||(_[8]=e("p",{class:"text-sm text-gray-600"},[E(" API keys authenticate requests to the public REST API at "),e("code",{class:"px-1 py-0.5 bg-gray-100 rounded text-xs"},"/api/v1/*"),E(". Pass them as "),e("code",{class:"px-1 py-0.5 bg-gray-100 rounded text-xs"},"Authorization: Bearer <key>"),E(". Plaintext is shown "),e("strong",null,"once"),E(" at creation — store it somewhere safe. ")],-1)),c.value?(t(),s("div",Cn,[..._[5]||(_[5]=[e("svg",{class:"animate-spin h-6 w-6 text-indigo-600",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),E(" Loading API keys... ",-1)])])):w.value.length===0?(t(),s("div",_n,[..._[6]||(_[6]=[e("p",{class:"text-gray-500"},"No API keys yet.",-1),e("p",{class:"text-xs text-gray-400 mt-1"},"Create one to start calling the REST API.",-1)])])):(t(),s("div",An,[e("ul",Pn,[(t(!0),s(se,null,ie(w.value,m=>(t(),s("li",{key:m.id,class:L(["px-6 py-4 flex items-center justify-between",{"opacity-60":m.revokedAt}])},[e("div",$n,[e("div",En,[e("h4",In,b(m.name),1),m.revokedAt?(t(),s("span",Sn," Revoked ")):(t(),s("span",On," Active "))]),e("p",Mn,b(m.prefix)+"…",1),e("div",Tn,[e("span",null,"Created "+b(q(m.createdAt)),1),m.lastUsedAt?(t(),s("span",Fn,"Last used "+b(q(m.lastUsedAt)),1)):(t(),s("span",Nn,"Never used")),m.revokedAt?(t(),s("span",Kn,"Revoked "+b(q(m.revokedAt)),1)):f("",!0)])]),m.revokedAt?f("",!0):(t(),s("div",Bn,[e("button",{type:"button",onClick:Z=>te(m),class:"pl-1 text-gray-400 hover:text-red-600 transition",title:"Revoke"},[..._[7]||(_[7]=[e("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,jn)]))],2))),128))])])),!c.value&&d.value>0?(t(),s("p",zn,b(d.value)+" of "+b(I(ye))+" active keys used. ",1)):f("",!0)]),U(J,{"is-open":v.value,title:"New API Key",level:1,onClose:V},{footer:D(()=>[e("div",Hn,[e("button",{type:"button",onClick:V,class:"px-4 py-2 border border-gray-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"}," Cancel "),e("button",{type:"button",onClick:j,disabled:x.value||!M.value.trim(),class:"inline-flex items-center px-5 py-2.5 border border-transparent shadow-sm text-sm font-medium rounded-lg text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed transition"},[x.value?(t(),s("svg",Dn,[..._[12]||(_[12]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):f("",!0),E(" "+b(x.value?"Creating…":"Create Key"),1)],8,Un)])]),default:D(()=>[e("div",Vn,[e("div",null,[_[9]||(_[9]=e("label",{for:"api-key-name",class:"block text-sm font-medium text-gray-700 mb-2"},[E(" Name "),e("span",{class:"text-red-500"},"*")],-1)),H(e("input",{id:"api-key-name","onUpdate:modelValue":_[0]||(_[0]=m=>M.value=m),type:"text",maxlength:I(xn),required:"",placeholder:"e.g. Zapier integration",class:"w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition",onKeydown:Ve(de(j,["prevent"]),["enter"])},null,40,Ln),[[Q,M.value]]),_[10]||(_[10]=e("p",{class:"text-xs text-gray-500 mt-1"}," Used to identify the key in this dashboard. Not sent to the API. ",-1))]),_[11]||(_[11]=e("div",{class:"rounded-md bg-amber-50 border border-amber-200 p-3"},[e("p",{class:"text-sm text-amber-800"},[e("strong",null,"Heads up:"),E(" the plaintext key is shown once on the next screen. It c
1annot be retrieved later — copy it somewhere safe immediately. ")])],-1))])]),_:1},8,["is-open"]),C.value?(t(),W(K,{key:0,"is-open":!0,title:"Copy your new API key","max-width":"lg",onClose:X},{footer:D(()=>[e("div",{class:"bg-gray-50 border-t border-gray-200 px-6 py-4 flex justify-end"},[e("button",{type:"button",onClick:X,class:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition"}," I've copied it — close ")])]),default:D(()=>[e("div",Rn,[_[14]||(_[14]=e("div",{class:"rounded-md bg-amber-50 border border-amber-200 p-3"},[e("p",{class:"text-sm text-amber-800"},[E(" This is the "),e("strong",null,"only time"),E(" we'll show this key. Copy it now and store it somewhere safe — anyone with the key can call your account's API. ")])],-1)),e("div",null,[_[13]||(_[13]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Plaintext key",-1)),e("div",Gn,[e("input",{ref_key:"revealInputRef",ref:l,value:C.value,readonly:"",class:"flex-1 px-3 py-2 border border-gray-300 rounded-lg bg-gray-50 font-mono text-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500",onFocus:_[1]||(_[1]=m=>m.target.select())},null,40,Wn),e("button",{type:"button",onClick:R,class:"px-4 py-2 border border-gray-300 rounded-lg text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 transition"},b(F.value?"Copied!":"Copy"),1)])])])]),_:1})):f("",!0),k.value?(t(),W(K,{key:1,"is-open":!0,title:"Revoke API Key","max-width":"sm",onClose:_[3]||(_[3]=m=>k.value=null)},{footer:D(()=>[e("div",Jn,[e("button",{type:"button",onClick:_[2]||(_[2]=m=>k.value=null),class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition"}," Cancel "),e("button",{type:"button",onClick:ne,disabled:o.value,class:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 disabled:opacity-50 transition"},b(o.value?"Revoking…":"Revoke"),9,Zn)])]),default:D(()=>[e("div",qn,[e("div",Yn,[_[18]||(_[18]=e("div",{class:"flex-shrink-0 w-10 h-10 rounded-full bg-red-100 flex items-center justify-center"},[e("svg",{class:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),e("div",null,[e("p",Qn,[_[15]||(_[15]=E(" Revoke ",-1)),e("strong",Xn,b(k.value.name),1),_[16]||(_[16]=E("? ",-1))]),_[17]||(_[17]=e("p",{class:"text-xs text-gray-500 mt-1"}," Any client using this key will start receiving 401 immediately. This cannot be undone. ",-1))])])])]),_:1})):f("",!0)],64)}}}),tr=Object.assign(er,{__name:"SettingsApiKeysSettings"}),sr={class:"space-y-6"},or={key:0,class:"text-center py-8 text-gray-500"},lr={key:0,class:"rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800"},nr={class:"font-medium"},rr={key:1},ar=["disabled"],ir=["value"],dr={key:0,class:"text-xs text-amber-700 mt-2"},ur={key:2,class:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700"},cr={key:3,class:"rounded-lg border border-green-200 bg-green-50 p-3 text-sm text-green-700"},vr={class:"flex justify-end gap-3 pt-2"},mr=["disabled"],pr=le({__name:"AccountCurrencySettings",emits:["cancel","saved"],setup(a,{emit:N}){const i=N,A=ue(),P=g(!0),w=g(!1),c=g(null),v=g(""),x=g(null),M=g(null),C=typeof Intl<"u"&&"DisplayNames"in Intl?new Intl.DisplayNames(void 0,{type:"currency"}):null;function F(o){try{const d=C?.of(o);return d&&d!==o?` — ${d}`:""}catch{return""}}async function l(){P.value=!0,x.value=null;try{const o=await A("/api/auth/currency");c.value=o,v.value=o.currency}catch(o){x.value=o?.data?.message||o?.message||"Failed to load currency settings"}finally{P.value=!1}}async function k(){if(v.value){w.value=!0,x.value=null,M.value=null;try{const o=await A("/api/auth/currency",{method:"PATCH",body:{currency:v.value}});c.value&&(c.value={...c.value,currency:o.currency,locked:o.locked}),M.value=`Account currency set to ${o.currency}`,i("saved",o.currency)}catch(o){x.value=o?.data?.message||o?.message||"Failed to update currency",(o?.statusCode===409||o?.status===409)&&await l()}finally{w.value=!1}}}return fe(l),(o,d)=>(t(),s("div",sr,[d[5]||(d[5]=e("div",null,[e("h3",{class:"text-lg font-medium text-gray-900"},"Account Currency"),e("p",{class:"text-sm text-gray-600 mt-1"}," Every revenue, refund and ad-spend figure in your reports is stored in this currency. Conversions that report another currency are converted at the moment they are recorded, using exchange rates refreshed hourly. ")],-1)),P.value?(t(),s("div",or," Loading… ")):(t(),s(se,{key:1},[c.value?.locked?(t(),s("div",lr,[e("p",nr,"Locked to "+b(c.value.currency),1),d[2]||(d[2]=e("p",{class:"mt-1"}," This account has already recorded conversions, so its currency can no longer change — otherwise past and future revenue would mix denominations. ",-1))])):(t(),s("div",rr,[d[3]||(d[3]=e("label",{for:"account-currency",class:"block text-sm font-medium text-gray-700 mb-2"},"Currency",-1)),H(e("select",{id:"account-currency","onUpdate:modelValue":d[
10]||(d[0]=O=>v.value=O),disabled:w.value,class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:bg-gray-100"},[(t(!0),s(se,null,ie(c.value?.selectable||[],O=>(t(),s("option",{key:O,value:O},b(O)+b(F(O)),9,ir))),128))],8,ar),[[be,v.value]]),d[4]||(d[4]=e("p",{class:"text-xs text-gray-500 mt-2"}," You can change this until your first conversion is recorded; it is then locked permanently. Amounts reported without a currency are assumed to already be in this currency. ",-1)),c.value&&!c.value.ratesAvailable?(t(),s("p",dr," Exchange rates have not been synced yet — only USD can be selected for now. ")):f("",!0)])),x.value?(t(),s("div",ur,b(x.value),1)):f("",!0),M.value?(t(),s("div",cr,b(M.value),1)):f("",!0),e("div",vr,[e("button",{type:"button",class:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50",onClick:d[1]||(d[1]=O=>o.$emit("cancel"))}," Close "),c.value?.locked?f("",!0):(t(),s("button",{key:0,t
1ype:"button",disabled:w.value||!v.value||v.value===c.value?.currency,class:"px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:k},b(w.value?"Saving…":"Save"),9,mr))])],64))]))}}),fr=Object.assign(pr,{__name:"SettingsAccountCurrencySettings"}),gr={class:"container mx-auto px-6 py-12"},yr={class:"bg-white rounded-xl shadow-md divide-y"},br={class:"flex items-center space-x-4"},xr={class:"text-sm text-gray-600"},hr={class:"flex items-center space-x-4"},kr={class:"text-sm text-gray-600"},wr={key:0,class:"text-gray-500"},Br=le({__name:"settings",setup(a){const N=pe(),{canAccessGoogleAds:i,canAccessFacebookAds:A}=_e(),P=ue(),w=G(()=>i.value||A.value),c=G(()=>w.value?"Connect ad platforms and affiliate networks":"Connect affiliate networks"),v=g(null),x=g(!1),M=g(!1),C=g(!1),F=g(!1),l=g(!1),k=g(!1),o=g(null),d=g(!1),O=g(null),y=g(null);fe(async()=>{if(sessionStorage.getItem("openAdPlatformsPanel")){sessionStorage.removeItem("openAdPlatformsPanel");const T=sessionStorage.getItem("openAdPlatformType");T&&(sessionStorage.removeItem("openAdPlatformType"),o.value=T),k.value=!0}const ee=He();ee.query.tab==="integrations"&&(ee.query.platform&&(o.value=ee.query.platform),k.value=!0,window.history.replaceState({},"",ee.path));try{const T=await P("/api/auth/me",{retry:!1});T.success&&(v.value=T.user)}catch(T){console.error("Error loading user data:",T)}});const V=()=>{x.value=!0},j=()=>{x.value=!1},R=ee=>{v.value&&(v.value={...v.value,...ee})};function X(){M.value=!0}function te(){M.value=!1}function ne(){N.success("Custom event names saved successfully"),te()}const q=()=>{O.value=null,y.value=null,k.value=!0},z=()=>{k.value=!1,setTimeout(()=>{O.value=null,y.value=null},300)};function _(){C.value=!0}function J(){C.value=!1}function K(){}function m(){l.value=!0}function Z(){l.value=!1}const{refreshUser:$}=_e();async function r(ee){v.value&&(v.value.currency=ee),await $(),N.success(`Account currency set to ${ee}`)}function B(){F.value=!0}function Y(){F.value=!1}const h=async ee=>{d.value=!0,O.value=null,y.value=null;try{const T=await P("/api/auth/clickbank-ipn-key",{method:"PATCH",body:ee});T.success?(v.value&&(v.value.metadata={...v.value.metadata||{},clickbankIpnKey:T.clickbankIpnKey}),N.success("Clickbank IPN Key updated successfully"),y.value="Settings saved successfully"):O.value=T.message||"Failed to update Clickbank IPN Key"}catch(T){O.value=T.data?.message||T.message||"An error occurred"}finally{d.value=!1}},oe=()=>{};return Ue({title:"Settings - ClickerVolt",meta:[{name:"description",content:"Manage your account settings"}]}),(ee,T)=>{const n=ls,u=he,re=gs;return t(),s("div",gr,[T[11]||(T[11]=e("div",{class:"mb-8"},[e("h1",{class:"text-3xl font-bold text-gray-900"},"Settings"),e("p",{class:"text-gray-600 mt-2"},"Manage your account settings and preferences")],-1)),e("div",yr,[e("button",{onClick:V,class:"w-full p-6 text-left hover:bg-gray-50 transition flex items-center justify-between group"},[...T[0]||(T[0]=[ae('<div class="flex items-center space-x-4"><div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center"><svg class="w-6 h-6 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path></svg></div><div><h3 data-help="profile-form" class="text-lg font-semibold text-gray-900">Profile Information</h3><p class="text-sm text-gray-600">Update your name, email, and password</p></div></div><svg class="w-5 h-5 text-gray-400 group-hover:text-gray-600 transition" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>',2)])]),e("button",{onClick:X,class:"w-full p-6 text-left hover:bg-gray-50 transition flex items-center justify-between group"},[...T[1]||(T[1]=[ae('<div class="flex items-center space-x-4"><div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center"><svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"></path></svg></div><div><h3 data-help="event-names" class="text-lg font-semibold text-gray-900">Custom Event Names</h3><p class="text-sm text-gray-600">Name your 10 custom event slots (optins, video views, etc.)</p></div></div><svg class="w-5 h-5 text-gray-400 group-hover:text-gray-600 transition" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>',2)])]),e("button",{onClick:q,class:"w-full p-6 text-left hover:bg-gray-50 transition flex items-center justify-between group"},[e("div",br,[T[3]||(T[3]=e("div",{class:"w-12 h-12 bg-teal-100 rounded-full flex items-center justify-center"},[e("svg",{class:"w-6 h-6 text-teal-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"})])],-1)),e("div",null,[T[2]||(T[2]=e("h3",{class:"text-lg font-semibold text-gray-900"},"Integrations",-1)),e("p",xr,b(c.value),1)])]),T[4]||(T[4]=e("svg",{class:"w-5 h-5 text-gray-400 group-hover:text-gray-600 transition",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1))]),e("button",{onClick:_,class:"w-full p-6 text-left hover:bg-gray-50 transition flex items-center justify-between group"},[...T[5]||(T[5]=[ae('<div class="flex items-center space-x-4"><div class="bg-purple-100 p-3 rounded-lg group-hover:bg-purple-200 transition"><svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg></div><div><h3 class="text-lg font-medium text-gray-900">Webhooks</h3><p class="text-sm text-gray-500 mt-1">Configure global webhooks for events</p></div></div><svg class="w-5 h-5 text-gray-400 group-hover:text-gray-600 transition" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>',2)])]),e("button",{onClick:m,class:"w-full p-6 text-left hover:bg-gray-50 transition flex items-center justify-between group"},[e("div",hr,[T[8]||(T[8]=e("div",{class:"w-12 h-12 bg-emerald-100 rounded-full flex items-center justify-center"},[e("svg",{class:"w-6 h-6 text-emerald-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),e("div",null,[T[7]||(T[7]=e("h3",{class:"text-lg font-semibold text-gray-900"},"Account Currency",-1)),e("p",kr,[T[6]||(T[6]=E(" Reporting currency for revenue and ad spend ",-1)),v.value?(t(),s("span",wr,"· "+b(v.value.currency)+b(v.value.currencyLocked?" (locked)":""),1)):f("",!0)])])]),T[9]||(T[9]=e("svg",{class:"w-5 h-5 text-gray-400 group-hover:text-gray-600 transition",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1))]),e("button",{onClick:B,class:"w-full p-6 text-left hover:bg-gray-50 transition flex items-center justify-between group"},[...T[10]||(T[10]=[ae('<div class="flex items-center space-x-4"><div class="bg-blue-100 p-3 rounded-lg group-hover:bg-blue-200 transition"><svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"></path></svg></div><div><h3 class="text-lg font-medium text-gray-900">API Keys</h3><p class="text-sm text-gray-500 mt-1">Mint and revoke keys for the public REST API</p></div></div><svg class="w-5 h-5 text-gray-400 group-hover:text-gray-600 transition" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>',2)])])]),U(u,{"is-open":x.value,title:"Profile Information","max-width":"600px",onClose:j},{default:D(()=>[v.value?(t(),W(n,{key:0,user:v.value,onUserUpdated:R,onSaved:j,onCancel:j},null,8,["user"])):f("",!0)]),_:1},8,["is-open"]),U(u,{"is-open":M.value,title:"Custom Event Names",onClose:te},{default:D(()=>[U(re,{onCancel:te,onSaved:ne})]),_:1},8,["is-open"]),U(u,{"is-open":k.value,title:"Integrations",onClose:z},{default:D(()=>[v.value?(t(),W(hl,{key:0,"current-key":v.value.metadata?.clickbankIpnKey||"CLICKERVOLT","user-id":v.value.id,"clickbank-saving":d.value,"clickbank-error":O.value,"clickbank-success-message":y.value,"initial-ad-platform":o.value,onClickbankSubmit:h,onCancel:z,onSaved:oe},null,8,["current-key","user-id","clickbank-saving","clickbank-error","clickbank-success-message","initial-ad-platform"])):f("",!0)]),_:1},8,["is-open"]),U(u,{"is-open":C.value,title:"Global Webhooks",onClose:J},{default:D(()=>[U(bn,{onSaved:K,onCancel:J})]),_:1},8,["is-open"]),U(u,{"is-open":l.value,title:"Account Currency","max-width":"600px",onClose:Z},{default:D(()=>[U(fr,{onCancel:Z,onSaved:r})]),_:1},8,["is-open"]),U(u,{"is-open":F.value,title:"API Keys",onClose:Y},{default:D(()=>[U(tr)]),_:1},8,["is-open"])])}}});export{Br as default};

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.