1import{a as ne,h as re,j as e,i as ce}from"./vendor-clerk-DcCvBuIw.js";import{u as le,k as oe,b as s}from"./vendor-react-B_b9qgVR.js";import{u as ie,f as de,a as m}from"./index-PIwaDE5s.js";import{C as xe}from"./UI-DyL6zV6f.js";import"./vendor-posthog-BA-VvvHs.js";const Y=8;function u({title:t,desc:i,children:c,tone:f="normal",highlight:h}){const r=f==="danger"?h?"border-ak-err ring-2 ring-ak-err-bg":"border-ak-err-bg":"border-ak-border";return e.jsxs("div",{className:`rounded-xl border bg-ak-surface p-6 transition-shadow duration-500 ${r}`,children:[e.jsx("h2",{className:"text-base font-semibold text-ak-txt tracking-[-0.3px]",children:t}),i&&e.jsx("p",{className:"mt-1.5 text-[13px] text-ak-txt-2 leading-[1.55] max-w-[520px]",children:i}),c]})}const p="w-full max-w-[360px] px-3 py-2 bg-ak-bg border border-ak-border rounded-lg text-[13px] text-ak-txt focus:border-ak-txt-3 outline-none transition-colors",y="px-3 py-[7px] bg-ak-brand text-white rounded-md text-[13px] font-medium hover:bg-ak-brand-h transition-colors disabled:opacity-50 disabled:cursor-not-allowed";function ge(){var H;const{t,lang:i}=ie(),{toast:c}=de(),f=le(),[h]=oe(),{user:r,isLoaded:$}=ne(),[g,P]=s.useState(""),[C,E]=s.useState(!1),[_,D]=s.useState(!1);s.useEffect(()=>{let a=!1;return m.me().then(n=>{a||(P(n.name??""),D(!0))}).catch(()=>D(!0)),()=>{a=!0}},[]);async function G(){const a=g.trim();if(a){E(!0);try{await m.updateProfile(a),c(t("account.nameSaved"),"success")}catch{c(t("account.nameSaveFailed"),"error")}finally{E(!1)}}}const J=(r==null?void 0:r.passwordEnabled)??!1,[b,F]=s.useState(""),[d,L]=s.useState(""),[w,O]=s.useState(""),[A,I]=s.useState(!1),[R,x]=s.useState(""),K=re((a,n)=>r.updatePassword({currentPassword:a,newPassword:n,signOutOfOtherSessions:!0}));async function Q(a){var n,W,q,V;if(a.preventDefault(),x(""),d.length<Y){x(t("account.pwTooShort").replace("{n}",String(Y)));return}if(d!==w){x(t("account.pwMismatch"));return}if(r){I(!0);try{await K(b,d),F(""),L(""),O(""),c(t("account.pwSaved"),"success")}catch(o){if(ce(o))return;const se=((W=(n=o==null?void 0:o.errors)==null?void 0:n[0])==null?void 0:W.longMessage)??((V=(q=o==null?void 0:o.errors)==null?void 0:q[0])==null?void 0:V.message)??t("account.pwSaveFailed");x(se)}finally{I(!1)}}}const[U,k]=s.useState(!1),[X,j]=s.useState(!1),[Z,T]=s.useState(!1);s.useEffect(()=>{if(h.get("danger")!=="1")return;T(!0);const a=document.getElementById("danger-zone");a==null||a.scrollIntoView({behavior:"smooth",block:"center"});const n=setTimeout(()=>T(!1),2e3);return f("/account",{replace:!0}),()=>clearTimeout(n)},[]);const[l,B]=s.useState(null),[v,N]=s.useState(!0),[S,M]=s.useState(!1),z=s.useRef(!1);s.useEffect(()=>{let a=!1;return m.emailPreferences(i).then(n=>{a||(B(n),z.current||(z.current=!0,N(n.lifecycle_opt_in)))}).catch(()=>{}),()=>{a=!0}},[i]);const ee=!!l&&v!==l.lifecycle_opt_in;async function te(){if(l){M(!0);try{const a=await m.setEmailPreferences({lifecycle_opt_in:v,locale:i});B(a),N(a.lifecycle_opt_in),c(a.lifecycle_opt_in?t("emailPrefs.saved.on"):t("emailPrefs.saved.off"),"success")}catch{c(t("emailPrefs.saveFailed"),"error")}finally{M(!1)}}}const ae=((H=r==null?void 0:r.primaryEmailAddress)==null?void 0:H.emailAddress)??"";return e.jsxs("div",{className:"flex flex-col gap-6 pb-12",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[24px] font-semibold tracking-[-0.02em] text-ak-txt m-0 mb-1.5",children:t("account.title")}),e.jsx("p",{className:"text-[13.5px] text-ak-txt-2 m-0 leading-[1.5] max-w-[640px]",children:t("account.subtitle")})]}),e.jsx(u,{title:t("account.profile"),desc:t("account.profileDesc"),children:e.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-ak-txt-3 mb-1.5",children:t("account.email")}),e.jsx("div",{className:"text-[13px] text-ak-txt-2 font-mono",children:ae||"â"}),e.jsx("p",{className:"mt-1 text-[12px] text-ak-txt-3",children:t("account.emailImmutable")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"account-name",className:"block text-[12px] font-medium text-ak-txt-3 mb-1.5",children:t("account.displayName")}),e.jsx("input",{id:"account-name",value:g,onChange:a=>P(a.target.value),disabled:!_,className:p})]}),e.jsx("div",{children:e.jsx("button",{onClick:G,disabled:C||!_||!g.trim(),className:y,children:t(C?"account.saving":"account.save")})})]})}),e.jsx(u,{title:t("emailPrefs.title"),desc:t("emailPrefs.desc"),children:l?e.jsxs("div",{className:"mt-4 flex flex-col gap-3",children:[e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer max-w-[560px]",children:[e.jsx("input",{type:"checkbox",checked:v,disabled:S,onChange:a=>N(a.target.checked),className:"mt-[3px] h-4 w-4 shrink-0 accent-ak-brand curs
1or-pointer disabled:cursor-not-allowed"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13.5px] text-ak-txt leading-[1.5]",children:t("emailPrefs.lifecycleLabel")}),e.jsx("span",{className:"block mt-1 text-[12.5px] text-ak-txt-3 leading-[1.55]",children:t("emailPrefs.lifecycleHint")})]})]}),e.jsx("p",{className:"text-[12px] text-ak-txt-3 leading-[1.55] max-w-[560px]",children:l.transactional_note}),l.suppressed&&e.jsx("p",{className:"text-[12.5px] text-ak-st-un leading-[1.55] max-w-[560px]",children:l.suppressed_reason==="complaint"?t("emailPrefs.suppressedComplaint"):t("emailPrefs.suppressedBounce")}),e.jsx("div",{className:"mt-1",children:e.jsx("button",{onClick:te,disabled:S||!ee,className:y,children:t(S?"account.saving":"account.save")})})]}):e.jsx("div",{className:"mt-4 h-9 w-[360px] max-w-full rounded-lg bg-ak-bg animate-pulse"})}),e.jsx(u,{title:t("account.password"),desc:t("account.passwordDesc"),children:$?J?e.jsxs("form",{onSubmit:Q,className:"mt-4 flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pw-current",className:"block text-[12px] font-medium text-ak-txt-3 mb-1.5",children:t("account.pwCurrent")}),e.jsx("input",{id:"pw-current",type:"password",autoComplete:"current-password",value:b,onChange:a=>F(a.target.value),className:p})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pw-new",className:"block text-[12px] font-medium text-ak-txt-3 mb-1.5",children:t("account.pwNew")}),e.jsx("input",{id:"pw-new",type:"password",autoComplete:"new-password",value:d,onChange:a=>L(a.target.value),className:p})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pw-confirm",className:"block text-[12px] font-medium text-ak-txt-3 mb-1.5",children:t("account.pwConfirm")}),e.jsx("input",{id:"pw-confirm",type:"password",autoComplete:"new-password",value:w,onChange:a=>O(a.target.value),className:p})]}),R&&e.jsx("p",{className:"text-[12.5px] text-ak-err max-w-[360px] leading-[1.5]",children:R}),e.jsx("p",{className:"text-[12px] text-ak-txt-3 max-w-[360px] leading-[1.5]",children:t("account.pwSignsOutOthers")}),e.jsx("div",{children:e.jsx("button",{type:"submit",disabled:A||!b||!d||!w,className:y,children:t(A?"account.saving":"account.pwUpdate")})})]}):e.jsx("p",{className:"mt-4 text-[13px] text-ak-txt-2 leading-[1.6] max-w-[520px]",children:t("account.pwOauthOnly")}):e.jsx("div",{className:"mt-4 h-9 w-[360px] max-w-full rounded-lg bg-ak-bg animate-pulse"})}),e.jsx("div",{id:"danger-zone",children:e.jsx(u,{title:t("danger.title"),desc:t("danger.desc"),tone:"danger",highlight:Z,children:e.jsx("button",{onClick:()=>k(!0),className:"mt-4 px-3 py-[7px] bg-ak-surface text-ak-err border border-ak-err-bg rounded-md text-[13px] font-medium hover:bg-[#FEF2F2] transition-colors",children:t("danger.deleteBtn")})})}),e.jsx(xe,{open:U,message:t("danger.warnMsg"),confirmLabel:t("danger.warnConfirm"),cancelLabel:t("common.cancel"),onConfirm:()=>{k(!1),j(!0)},onCancel:()=>k(!1)}),X&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>j(!1),children:e.jsxs("div",{className:"bg-ak-surface rounded-xl p-6 max-w-sm mx-4 shadow-xl border border-ak-border",onClick:a=>a.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold text-ak-txt tracking-[-0.3px]",children:t("danger.emailTitle")}),e.jsx("p",{className:"mt-2 text-[13px] text-ak-txt-2 leading-[1.6]",children:t("danger.emailBody")}),e.jsx("a",{href:"mailto:[email protected]?subject=Account%20deletion%20request",className:"mt-3 inline-block text-[13px] font-mono text-ak-brand underline",children:"[email protected]"}),e.jsx("div",{className:"flex justify-end mt-5",children:e.jsx("button",{onClick:()=>j(!1),className:"px-4 py-2 text-[13px] font-medium text-ak-txt-3 hover:text-ak-txt transition-colors",children:t("common.close")})})]})})]})}export{ge 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.