1import{u as be,a as re,r as De,Y as Ue,_ as fe,ao as pe,M as Ae}from"./index-Dg7iAOYr.js";import{_ as Fe}from"./AppLayout.vue_vue_type_script_setup_true_lang-CDGJUeC2.js";import{d as ae,r as g,c as L,w as se,o as he,a as _e,z as n,B as e,G as o,u as a,E as F,Q as W,$ as Ie,F as X,H as me,W as q,V as ie,Y as je,C as l,A as G,U as ne,q as Te,X as Me,D as ve,k as te,n as ye,K as Ve}from"./vendor-vue-Dzwqm9Y9.js";import{u as Y,s as Le,a as ze,b as Oe,c as Re}from"./user-w1U2FB2H.js";import{b as J}from"./apiError-BcAuv_LF.js";import{u as oe}from"./vendor-i18n-BuoWFzps.js";import{t as le}from"./totp-DaPgbKfx.js";import{b as We}from"./vendor-misc-B-nM3tYW.js";import"./AppHeader.vue_vue_type_style_index_0_scoped_25b0c839_lang-B0lsvCqV.js";import"./useClipboard-DI2IZ1WO.js";import"./LocaleSwitcher-BZZz6YQD.js";/* empty css */const He={class:"card"},qe={class:"border-b border-gray-100 px-6 py-4 dark:border-dark-700"},Ke={class:"text-lg font-medium text-gray-900 dark:text-white"},Qe={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Ye={class:"px-6 py-6 space-y-6"},Ge={class:"flex items-center justify-between"},Xe={class:"input-label mb-0"},Ze={class:"relative inline-flex items-center cursor-pointer"},Je={class:"input-label"},et={class:"text-xs text-gray-400 ml-2"},tt={class:"flex items-center gap-2"},at=["placeholder"],ot=["disabled"],st={class:"input-label"},rt={class:"mb-2 text-xs text-yellow-600 dark:text-yellow-400"},lt={key:0,class:"space-y-2 mb-3"},nt={class:"flex items-center gap-2 min-w-0 flex-1"},it={class:"relative inline-flex items-center cursor-pointer shrink-0"},dt=["checked","onChange"],ct={class:"text-sm text-gray-700 dark:text-gray-300 truncate"},ut={class:"flex items-center gap-2 shrink-0"},pt=["placeholder"],ft=["onClick","disabled"],mt={key:0,class:"text-xs text-gray-400"},vt=["onClick","disabled"],bt=["onClick","disabled"],ht={class:"text-xs text-yellow-500"},yt={key:1,class:"text-xs text-green-500"},gt=["onClick"],_t={key:1,class:"space-y-2 mb-3"},xt={class:"flex-1 text-sm text-gray-700 dark:text-gray-300"},wt={key:0,class:"flex items-center gap-1"},kt=["onClick","disabled"],$t=["onClick"],Ct={key:1,class:"flex items-center gap-1"},Et=["onUpdate:modelValue","placeholder"],St=["onClick","disabled"],Bt={key:0,class:"text-xs text-gray-400"},Pt=["onClick","disabled"],Nt={key:2,class:"flex gap-2"},Dt=["placeholder"],Ut=["disabled"],At={key:3,class:"text-xs text-gray-400"},Ft=3,It=ae({__name:"ProfileBalanceNotifyCard",props:{enabled:{type:Boolean},threshold:{},extraEmails:{},systemDefaultThreshold:{},userEmail:{}},setup(U){const i=U,{t}=oe(),d=be(),u=re(),x=g(i.enabled),k=g(i.threshold),C=g([...i.extraEmails]),v=g([]),S=g(""),P=g(!1),p=g(""),D=g(""),I=g(!1),z=g(!1),T=g(0);let r=null;const f=L(()=>C.value.length+v.value.length<Ft);se(()=>i.enabled,N=>{x.value=N}),se(()=>i.threshold,N=>{k.value=N}),se(()=>i.extraEmails,N=>{C.value=[...N]}),he(()=>{C.value.length===0&&i.userEmail&&(S.value=i.userEmail)}),_e(()=>{for(const N of v.value)N.timer&&clearInterval(N.timer);r&&clearInterval(r)});const b=async()=>{try{const N=await Y.updateProfile({balance_notify_enabled:x.value});d.user=N}catch(N){u.showError(J(N,t("common.error"))),x.value=!x.value}},j=async()=>{P.value=!0;try{const N=k.value&&k.value>0?k.value:0,h=await Y.updateProfile({balance_notify_threshold:N});d.user=h,u.showSuccess(t("common.saved"))}catch(N){u.showError(J(N,t("common.error")))}finally{P.value=!1}};async function O(N){const h=!N.disabled;try{const c=await Y.toggleNotifyEmail(N.email,h);d.user=c,C.value=[...c.balance_notify_extra_emails]}catch(c){u.showError(J(c,t("common.error")))}}function E(){const N=S.value.trim();if(!N)return;if(C.value.some(c=>c.email.toLowerCase()===N.toLowerCase())||v.value.some(c=>c.email.toLowerCase()===N.toLowerCase())){u.showError(t("profile.balanceNotify.emailDuplicate"));return}v.value.push({email:N,codeSent:!1,code:"",sending:!1,verifying:!1,countdown:0,timer:null}),S.value=""}async function y(N){const h=v.value[N];if(h){h.sending=!0;try{await Y.sendNotifyEmailCode(h.email),h.codeSent=!0,h.countdown=60,h.timer=setInterval(()=>{h.countdown--,h.countdown<=0&&h.timer&&(clearInterval(h.timer),h.timer=null)},1e3),u.showSuccess(t("profile.balanceNotify.codeSent"))}catch(c){u.showError(J(c,t("common.error")))}finally{h.sending=!1}}}async function _(N){const h=v.value[N];if(!(!h||!h.code||h.code.length!==6)){h.verifying=!0;try{await Y.verifyNotifyEmail(h.email,h.code),h.timer&&clearInterval(h.timer),v.value=v.value.filter(w=>w!==h),u.showSuccess(t("profile.balanceNotify.verifySuccess"));const c=await Y.getProfile();d.user=c,C.value=[...c.balance_notify_extra_emails]}catch(c){u.showError(J(c,t("common.error")))}finally{h.verifying=!1}}}const m=async N=>{try{await Y.removeNotifyEmail(N),u.showSuccess(t("profile.balanceNotify.removeSuccess"));const h=await Y.getProfile();d.user=h,C.value=[...h.balance_notify_extra_emails]}catch(h){u.showError(J(h,t("common.error")))}};async function M(N){z.value=!0;try{await Y.sendNotifyEmailCode(N),p.value=N,D.value="",T.value=60,r&&clearInterval(r),r=setInterval(()=>{T.value--,T.value<=0&&r&&(clearInterval(r),r=null)},1e3),u.showSuccess(t("profile.balanceNotify.codeSent"))}catch(h){u.showError(J(h,t("common.error")))}finally{z.value=!1}}async function V(N){if(!(!D.value||D.value.length!==6)){I.value=!0;try{await Y.verifyNotifyEmail(N,D.value),p.value="",D.value="",r&&(clearInterval(r),r=null),u.showSuccess(t("profile.balanceNotify.verifySuccess"));const h=await Y.getProfile();d.user=h,C.value=[...h.balance_notify_extra_emails]}catch(h){u.showError(J(h,t("common.error")))}finally{I.value=!1}}}return(N,h)=>(l(),n("div",He,[e("div",qe,[e("h2",Ke,o(a(t)("profile.balanceNotify.title")),1),e("p",Qe,o(a(t)("profile.balanceNotify.description")),1)]),e("div",Ye,[e("div",Ge,[e("label",Xe,o(a(t)("profile.balanceNotify.enabled")),1),e("label",Ze,[W(e("input",{type:"checkbox","onUpdate:modelValue":h[0]||(h[0]=c=>x.value=c),onChange:b,class:"sr-only peer"},null,544),[[Ie,x.value]]),h[5]||(h[5]=e("div",{class:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:after:border-gray-600 peer-checked:bg-primary-600"},null,-1))])]),x.value?(l(),n(X,{key:0},[e("div",null,[e("label",Je,[me(o(a(t)("profile.balanceNotify.threshold"))+" ",1),e("span",et,o(a(t)("profile.balanceNotify.thresholdHint")),1)]),e("div",tt,[h[6]||(h[6]=e("span",{class:"text-gray-500"},"$",-1)),W(e("input",{"onUpdate:modelValue":h[1]||(h[1]=c=>k.value=c),type:"number",min:"0",step:"0.01",class:"input flex-1",placeholder:U.systemDefaultThreshold>0?`${a(t)("profile.balanceNotify.systemDefault")} $${U.systemDefaultThreshold}`:a(t)("profile.balanceNotify.thresholdPlaceholder")},null,8,at),[[q,k.value,void 0,{number:!0}]]),e("button",{onClick:j,disabled:P.value,class:"btn btn-primary btn-sm whitespace-nowrap"},o(P.value?a(t)("common.saving"):a(t)("common.save")),9,ot)])]),e("div",null,[e("label",st,o(a(t)("profile.balanceNotify.extraEmails")),1),e("p",rt,o(a(t)("profile.balanceNotify.extraEmailsHint")),1),C.value.length>0?(l(),n("div",lt,[(l(!0),n(X,null,ie(C.value,(c,w)=>(l(),n("div",{key:w,class:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-dark-700 rounded-lg"},[e("div",nt,[e("label",it,[e("input",{type:"checkbox",checked:!c.disabled,onChange:B=>O(c),class:"sr-only peer"},null,40,dt),h[7]||(h[7]=e("div",{class:"w-9 h-5 bg-gray-200 peer-focus:outline-none rounded-full peer dark:bg-gray-600 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all dark:after:border-gray-500 peer-checked:bg-primary-600"},null,-1))]),e("span",ct,o(c.email),1)]),e("div",ut,[c.verified?(l(),n("span",yt,o(a(t)("profile.balanceNotify.verified")),1)):(l(),n(X,{key:0},[p.value===c.email?(l(),n(X,{key:0},[W(e("input",{"onUpdate:modelValue":h[2]||(h[2]=B=>
1D.value=B),type:"text",maxlength:"6",class:"w-20 rounded border border-gray-300 px-2 py-1 text-xs dark:border-dark-500 dark:bg-dark-700",placeholder:a(t)("profile.balanceNotify.codePlaceholder")},null,8,pt),[[q,D.value]]),e("button",{onClick:B=>V(c.email),disabled:!D.value||D.value.length!==6||I.value,class:"text-xs text-primary-600 hover:text-primary-700"},o(a(t)("profile.balanceNotify.verify")),9,ft),T.value>0?(l(),n("span",mt,o(T.value)+"s",1)):(l(),n("button",{key:1,onClick:B=>M(c.email),disabled:z.value,class:"text-xs text-gray-500 hover:text-gray-700"},o(a(t)("profile.balanceNotify.resend")),9,vt)),e("button",{onClick:h[3]||(h[3]=B=>p.value=""),class:"text-xs text-gray-400 hover:text-gray-600"},o(a(t)("common.cancel")),1)],64)):(l(),n(X,{key:1},[e("button",{onClick:B=>M(c.email),disabled:z.value,class:"text-xs text-primary-600 hover:text-primary-700"},o(a(t)("profile.balanceNotify.verify")),9,bt),e("span",ht,o(a(t)("profile.balanceNotify.unverified")),1)],64))],64)),e("button",{onClick:B=>m(c.email),class:"text-red-500 hover:text-red-700 text-xs"},o(a(t)("profile.balanceNotify.removeEmail")),9,gt)])]))),128))])):F("",!0),v.value.length>0?(l(),n("div",_t,[(l(!0),n(X,null,ie(v.value,(c,w)=>(l(),n("div",{key:c.email,class:"flex items-center gap-2 px-3 py-2 bg-yellow-50 dark:bg-yellow-900/10 rounded-lg border border-yellow-200 dark:border-yellow-800"},[e("span",xt,o(c.email),1),c.codeSent?(l(),n("div",Ct,[W(e("input",{"onUpdate:modelValue":B=>c.code=B,type:"text",maxlength:"6",class:"w-20 rounded border border-gray-300 px-2 py-1 text-xs dark:border-dark-500 dark:bg-dark-700",placeholder:a(t)("profile.balanceNotify.codePlaceholder")},null,8,Et),[[q,c.code]]),e("button",{onClick:B=>_(w),disabled:!c.code||c.code.length!==6||c.verifying,class:"text-xs text-primary-600 hover:text-primary-700"},o(a(t)("profile.balanceNotify.verify")),9,St),c.countdown>0?(l(),n("span",Bt,o(c.countdown)+"s",1)):(l(),n("button",{key:1,onClick:B=>y(w),disabled:c.sending,class:"text-xs text-gray-500 hover:text-gray-700"},o(a(t)("profile.balanceNotify.resend")),9,Pt))])):(l(),n("div",wt,[e("button",{onClick:B=>y(w),disabled:c.sending,class:"text-xs text-primary-600 hover:text-primary-700"},o(a(t)("profile.balanceNotify.sendCode")),9,kt),e("button",{onClick:B=>v.value.splice(w,1),class:"text-xs text-red-500 hover:text-red-700 ml-1"},o(a(t)("profile.balanceNotify.removeEmail")),9,$t)]))]))),128))])):F("",!0),f.value?(l(),n("div",Nt,[W(e("input",{"onUpdate:modelValue":h[4]||(h[4]=c=>S.value=c),type:"email",class:"input flex-1",placeholder:a(t)("profile.balanceNotify.emailPlaceholder"),onKeyup:je(E,["enter"])},null,40,Dt),[[q,S.value]]),e("button",{onClick:E,disabled:!S.value,class:"btn btn-secondary whitespace-nowrap"},o(a(t)("common.add")),9,Ut)])):(l(),n("p",At,o(a(t)("profile.balanceNotify.maxEmailsReached")),1))])],64)):F("",!0)])]))}}),jt={key:0,class:"border-b border-gray-100 px-6 py-4 dark:border-dark-700"},Tt={class:"text-lg font-medium text-gray-900 dark:text-white"},Mt={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Vt=["src","alt"],Lt={key:1},zt={class:"space-y-1"},Ot={key:0,class:"text-sm font-semibold text-gray-900 dark:text-white"},Rt={key:1,class:"text-sm font-medium text-gray-900 dark:text-white"},Wt={class:"text-sm text-gray-500 dark:text-gray-400"},Ht={class:"flex flex-wrap items-center gap-3"},qt={class:"btn btn-secondary btn-sm cursor-pointer"},Kt=["disabled"],Qt=["disabled"],ge=20*1024,Yt=ae({__name:"ProfileAvatarCard",props:{user:{},embedded:{type:Boolean,default:!1}},setup(U){const i=U,{t}=oe(),d=be(),u=re(),x=[1,.92,.84,.76,.68,.6,.52,.44,.36],k=[.92,.84,.76,.68,.6,.52,.44,.36],C=g(""),v=g(!1),S=L(()=>{var E,y,_,m;return((y=(E=i.user)==null?void 0:E.username)==null?void 0:y.trim())||((m=(_=i.user)==null?void 0:_.email)==null?void 0:m.trim())||t("profile.user")}),P=L(()=>S.value.charAt(0).toUpperCase()||"U"),p=L(()=>{var E,y;return C.value.trim()||((y=(E=i.user)==null?void 0:E.avatar_url)==null?void 0:y.trim())||""});se(()=>{var E;return(E=i.user)==null?void 0:E.avatar_url},()=>{C.value=""});function D(E){const y=E.trim();return y?/^data:image\/[a-zA-Z0-9.+-]+;base64,/i.test(y)?y:(u.showError(t("profile.avatar.uploadRequired")),null):null}function I(E){return new Promise((y,_)=>{const m=new FileReader;m.onload=()=>y(typeof m.result=="string"?m.result:""),m.onerror=()=>
1_(m.error??new Error("avatar_read_failed")),m.readAsDataURL(E)})}function z(E){return new Promise((y,_)=>{const m=new Image;m.onload=()=>y(m),m.onerror=()=>_(new Error(t("profile.avatar.readFailed"))),m.src=E})}function T(E,y,_){return new Promise((m,M)=>{E.toBlob(V=>{if(!V){M(new Error(t("profile.avatar.compressFailed")));return}m(V)},y,_)})}async function r(E){const y=await I(E),_=await z(y),m=document.createElement("canvas"),M=m.getContext("2d");if(!M)throw new Error(t("profile.avatar.compressFailed"));for(const V of x){const N=Math.max(1,Math.round(_.naturalWidth*V)),h=Math.max(1,Math.round(_.naturalHeight*V));m.width=N,m.height=h,M.clearRect(0,0,N,h),M.drawImage(_,0,0,N,h);for(const c of k){const w=await T(m,"image/webp",c);if(w.size<=ge){const B=E.name.replace(/\.[^.]+$/,"")||"avatar";return new File([w],`${B}.webp`,{type:"image/webp"})}}}throw new Error(t("profile.avatar.compressTooLarge"))}async function f(E){if(!E.type.startsWith("image/"))throw new Error(t("profile.avatar.invalidType"));if(E.type==="image/gif"){if(E.size>ge)throw new Error(t("profile.avatar.gifTooLarge"));return E}return E.size<=ge?E:r(E)}async function b(E){var m;const y=E.target,_=(m=y==null?void 0:y.files)==null?void 0:m[0];if(y&&(y.value=""),!!_)try{const M=await f(_),V=await I(M),N=D(V);if(!N)return;C.value=N}catch(M){u.showError(J(M,t("common.error")))}}async function j(){var y;const E=D(C.value);if(E){v.value=!0;try{const _=await Y.updateProfile({avatar_url:E});d.user=_,C.value=((y=_.avatar_url)==null?void 0:y.trim())||"",u.showSuccess(t("profile.avatar.saveSuccess"))}catch(_){u.showError(J(_,t("common.error")))}finally{v.value=!1}}}async function O(){var E,y;if(!v.value){if(!C.value.trim()&&!((y=(E=i.user)==null?void 0:E.avatar_url)!=null&&y.trim())){u.showError(t("profile.avatar.emptyDeleteHint"));return}v.value=!0;try{const _=await Y.updateProfile({avatar_url:""});d.user=_,C.value="",u.showSuccess(t("profile.avatar.deleteSuccess"))}catch(_){u.showError(J(_,t("common.error")))}finally{v.value=!1}}}return(E,y)=>(l(),n("div",{class:G(i.embedded?"space-y-4":"card")},[i.embedded?F("",!0):(l(),n("div",jt,[e("h2",Tt,o(a(t)("profile.avatar.title")),1),e("p",Mt,o(a(t)("profile.avatar.description")),1)])),e("div",{class:G(i.embedded?"space-y-3":"flex flex-col gap-5 px-6 py-6 sm:flex-row sm:items-start")},[e("div",{class:G(i.embedded?"flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-2xl bg-gradient-to-br from-primary-500 to-primary-600 text-xl font-bold text-white shadow-lg shadow-primary-500/20":"flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden rounded-2xl bg-gradient-to-br from-primary-500 to-primary-600 text-3xl font-bold text-white shadow-lg shadow-primary-500/20")},[p.value?(l(),n("img",{key:0,"data-testid":"profile-avatar-preview",src:p.value,alt:S.value,class:"h-full w-full object-cover"},null,8,Vt)):(l(),n("span",Lt,o(P.value),1))],2),e("div",{class:G(i.embedded?"space-y-3":"min-w-0 flex-1 space-y-4")},[e("div",zt,[i.embedded?(l(),n("p",Ot,o(a(t)("profile.avatar.title")),1)):(l(),n("p",Rt,o(S.value),1)),e("p",Wt,o(a(t)("profile.avatar.uploadHint")),1)]),e("div",Ht,[e("label",qt,[e("input",{"data-testid":"profile-avatar-file-input",type:"file",accept:"image/*",class:"hidden",onChange:b},null,32),me(" "+o(a(t)("profile.avatar.uploadAction")),1)]),e("button",{"data-testid":"profile-avatar-save",type:"button",class:"btn btn-primary btn-sm",disabled:v.value||!C.value,onClick:j},o(a(t)("common.save")),9,Kt),e("button",{"data-testid":"profile-avatar-delete",type:"button",class:"btn btn-secondary btn-sm",disabled:v.value,onClick:O},o(a(t)("common.delete")),9,Qt)])],2)],2)],2))}}),Gt={key:0,class:"border-b border-gray-100 px-6 py-4 dark:border-dark-700"},Xt={class:"text-lg font-medium text-gray-900 dark:text-white"},Zt={key:0},Jt={class:"text-sm font-semibold text-gray-900 dark:text-white"},ea={for:"username",class:"input-label"},ta=["placeholder"],aa={class:"flex justify-end pt-4"},oa=["disabled"],sa=ae({__name:"ProfileEditForm",props:{initialUsername:{},embedded:{type:Boolean,default:!1}},setup(U){const i=U,{t}=oe(),d=be(),u=re(),x=g(i.initialUsername),k=g(!1);se(()=>i.initialUsername,v=>{x.value=v});const C=async()=>
1{if(!x.value.trim()){u.showError(t("profile.usernameRequired"));return}k.value=!0;try{const v=await Y.updateProfile({username:x.value});d.user=v,u.showSuccess(t("profile.updateSuccess"))}catch(v){u.showError(J(v,t("profile.updateFailed")))}finally{k.value=!1}};return(v,S)=>(l(),n("div",{class:G(i.embedded?"space-y-4":"card")},[i.embedded?F("",!0):(l(),n("div",Gt,[e("h2",Xt,o(a(t)("profile.editProfile")),1)])),e("div",{class:G(i.embedded?"":"px-6 py-6")},[e("form",{onSubmit:ne(C,["prevent"]),class:"space-y-4"},[i.embedded?(l(),n("div",Zt,[e("p",Jt,o(a(t)("profile.editProfile")),1)])):F("",!0),e("div",null,[e("label",ea,o(a(t)("profile.username")),1),W(e("input",{id:"username","onUpdate:modelValue":S[0]||(S[0]=P=>x.value=P),type:"text",class:"input",placeholder:a(t)("profile.enterUsername")},null,8,ta),[[q,x.value]])]),e("div",aa,[e("button",{type:"submit",disabled:k.value,class:"btn btn-primary"},o(k.value?a(t)("profile.updating"):a(t)("profile.updateProfile")),9,oa)])],32)],2)],2))}}),ra={key:0,class:"border-b border-gray-100 px-6 py-4 dark:border-dark-700"},la={class:"text-lg font-medium text-gray-900 dark:text-white"},na={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},ia={key:0},da={class:"text-sm font-semibold text-gray-900 dark:text-white"},ca={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},ua={class:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"},pa={class:"flex min-w-0 flex-1 items-start gap-4"},fa={key:1},ma={class:"min-w-0 flex-1 space-y-3"},va={class:"flex flex-wrap items-center gap-2"},ba={class:"font-medium text-gray-900 dark:text-white"},ha=["data-testid"],ya={key:0,class:"text-sm text-gray-600 dark:text-gray-300"},ga={key:1,class:"grid gap-1 text-sm text-gray-500 dark:text-gray-400"},_a={key:0,class:"font-medium text-gray-700 dark:text-gray-200"},xa={key:1},wa={key:2},ka={key:3},$a={key:2,"data-testid":"profile-binding-email-form",class:"grid gap-2 sm:grid-cols-[minmax(0,1.4fr)_auto]"},Ca=["placeholder","disabled"],Ea=["disabled"],Sa=["placeholder","disabled"],Ba=["placeholder","disabled"],Pa=["disabled"],Na={class:"flex shrink-0 flex-wrap items-center gap-3"},Da=["data-testid","onClick"],Ua=["data-testid","disabled","onClick"],Aa=ae({__name:"ProfileIdentityBindingsSection",props:{user:{},linuxdoEnabled:{type:Boolean,default:!1},dingtalkEnabled:{type:Boolean,default:!1},oidcEnabled:{type:Boolean,default:!1},oidcProviderName:{default:"OIDC"},wechatEnabled:{type:Boolean,default:!1},wechatOpenEnabled:{type:Boolean,default:void 0},wechatMpEnabled:{type:Boolean,default:void 0},embedded:{type:Boolean,default:!1},compact:{type:Boolean,default:!1}},setup(U){const i=U,{t}=oe(),d=Me(),u=re(),x=be(),k=g(null),C=g(!1),v=g(!1),S=g(!i.compact),P=g(null),p=Te({email:"",verifyCode:"",password:""});se(()=>i.user,s=>{k.value=null,s&&typeof s.email=="string"&&!s.email.endsWith(".invali
1d")&&(p.email=s.email)},{immediate:!0}),se(()=>i.compact,s=>{s||(S.value=!0)},{immediate:!0});const D=L(()=>k.value??i.user),I=L(()=>i.compact),z=L(()=>i.embedded?I.value?"rounded-2xl border border-gray-100 bg-white p-4 shadow-sm dark:border-dark-700 dark:bg-dark-900/40":"rounded-2xl border border-gray-100 bg-gray-50/70 p-4 dark:border-dark-700 dark:bg-dark-900/30":"px-6 py-5"),T=L(()=>m("email")),r=L(()=>!I.value||S.value),f=L(()=>T.value?t("profile.authBindings.replaceEmailPasswordPlaceholder"):t("profile.authBindings.passwordPlaceholder")),b=L(()=>T.value?t("profile.authBindings.confirmEmailReplaceAction"):t("profile.authBindings.confirmEmailBindAction")),j={"Primary account email is managed from the profile form.":"profile.authBindings.notes.emailManagedFromProfile","You can unbind this sign-in method.":"profile.authBindings.notes.canUnbind","Bind another sign-in method before unbinding.":"profile.authBindings.notes.bindAnotherBeforeUnbind"};function O(s){return s?Ue(s)?s:typeof s.wechat_oauth_enabled!="boolean"?null:{...s,wechat_oauth_open_enabled:s.wechat_oauth_enabled,wechat_oauth_mp_enabled:s.wechat_oauth_enabled}:null}const E=L(()=>{const s=O(u.cachedPublicSettings);return s||O({wechat_oauth_enabled:i.wechatEnabled,wechat_oauth_open_enabled:i.wechatOpenEnabled,wechat_oauth_mp_enabled:i.wechatMpEnabled})}),y=L(()=>De(E.value));function _(s){return typeof s=="boolean"?s:s?typeof s.bound=="boolean"?s.bound:!!(s.provider_subject||s.issuer||s.provider_key):null}function m(s){return M(D.value,s)}function M(s,A){var R,ce,ue,ke;if(A==="email"){if(typeof(s==null?void 0:s.email_bound)=="boolean")return s.email_bound;const Ne=((R=s==null?void 0:s.auth_bindings)==null?void 0:R.email)??((ce=s==null?void 0:s.identity_bindings)==null?void 0:ce.email);return _(Ne)??!1}const $=s==null?void 0:s[`${A}_bound`];if(typeof $=="boolean")return $;const Z=((ue=s==null?void 0:s.auth_bindings)==null?void 0:ue[A])??((ke=s==null?void 0:s.identity_bindings)==null?void 0:ke[A]);return _(Z)??!1}function V(s){var $,Z,ee,R;const A=((Z=($=D.value)==null?void 0:$.auth_bindings)==null?void 0:Z[s])??((R=(ee=D.value)==null?void 0:ee.identity_bindings)==null?void 0:R[s]);return!A||typeof A=="boolean"?null:A}function N(s){var $;const A=(($=s==null?void 0:s.email)==null?void 0:$.trim())||"";
1return!A||A.endsWith(".invalid")&&!M(s,"email")?"":A}function h(s){return s==="linuxdo"?i.linuxdoEnabled:s==="dingtalk"?i.dingtalkEnabled:s==="oidc"?i.oidcEnabled:y.value.mode!==null}const c=L(()=>{var s,A,$,Z,ee,R,ce,ue;return[{provider:"email",label:t("profile.authBindings.providers.email"),bound:m("email"),canBind:!1,canUnbind:!1,details:V("email")},{provider:"linuxdo",label:t("profile.authBindings.providers.linuxdo"),bound:m("linuxdo"),canBind:!m("linuxdo")&&h("linuxdo")&&(((s=V("linuxdo"))==null?void 0:s.can_bind)??!0),canUnbind:!!(m("linuxdo")&&((A=V("linuxdo"))!=null&&A.can_unbind)),details:V("linuxdo")},{provider:"dingtalk",label:t("profile.authBindings.providers.dingtalk"),bound:m("dingtalk"),canBind:!m("dingtalk")&&h("dingtalk")&&((($=V("dingtalk"))==null?void 0:$.can_bind)??!0),canUnbind:!!(m("dingtalk")&&((Z=V("dingtalk"))!=null&&Z.can_unbind)),details:V("dingtalk")},{provider:"oidc",label:t("profile.authBindings.providers.oidc",{providerName:i.oidcProviderName}),bound:m("oidc"),canBind:!m("oidc")&&h("oidc")&&(((ee=V("oidc"))==null?void 0:ee.can_bind)??!0),canUnbind:!!(m("oidc")&&((R=V("oidc"))!=null&&R.can_unbind)),details:V("oidc")},{provider:"wechat",label:t("profile.authBindings.providers.wechat"),bound:m("wechat"),canBind:!m("wechat")&&h("wechat")&&(((ce=V("wechat"))==null?void 0:ce.can_bind)??!0),canUnbind:!!(m("wechat")&&((ue=V("wechat"))!=null&&ue.can_unbind)),details:V("wechat")}]});function w(s){return s==="linuxdo"?"L":s==="dingtalk"?"D":s==="wechat"?"W":s==="oidc"?"O":"E"}function B(s){return s==="linuxdo"?"bg-orange-100 text-orange-600 dark:bg-orange-900/20 dark:text-orange-300":s==="dingtalk"?"bg-blue-100 text-blue-600 dark:bg-blue-900/20 dark:text-blue-300":s==="wechat"?"bg-green-100 text-green-600 dark:bg-green-900/20 dark:text-green-300":s==="oidc"?"bg-sky-100 text-sky-600 dark:bg-sky-900/20 dark:text-sky-300":"bg-primary-100 text-primary-600 dark:bg-primary-900/20 dark:text-primary-300"}function K(s){return s==="email"?N(D.value):""}function H(s){return!s||typeof s.bound_count!="number"||s.bound_count<=1?"":t("profile.authBindings.boundCount",{count:s.bound_count})}function Q(s){var $,Z,ee;if(!s)return"";const A=(($=s.note_key)==null?void 0:$.trim())||j[((Z=s.note)==null?void 0:Z.trim())||""]||"";if(A){const R=t(A);if(R!==A)return R}return((ee=s.note)==null?void 0:ee.trim())||""}function de(s,A){return A?!!(s!=="email"&&!!(A.display_name||A.subject_hint)||H(A)||Q(A)):!1}function $e(){S.value=!S.value}function Ce(s){s!=="email"&&Le(s,{redirectTo:d.fullPath||"/profile",wechatOAuthSettings:s==="wechat"?E.value:null})}function xe(s){k.value=s,x.user=s}async function Ee(s,A){P.value=s;try{const $=await Re(s);xe($),u.showSuccess(t("profile.authBindings.unbindSuccess",{providerName:A}))}catch($){u.showError($.message||t("common.tryAgain"))}finally{P.value=null}}function Se(s,A){s!=="email"&&Ee(s,A)}function we(s){return p.email?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p.email)?s&&!p.verifyCode?(u.showError(t("auth.codeRequired")),!1):s&&!p.password?(u.showError(t("auth.passwordRequired")),!1):s&&!T.value&&p.password.length<6?(u.showError(t("auth.passwordMinLength")),!1):!0:(u.showError(t("auth.invalidEmail")),!1):(u.showError(t("auth.emailRequired")),!1)}async function Be(){if(we(!1)){C.value=!0;try{await ze(p.email),u.showSuccess(t("profile.authBindings.codeSentTo",{email:p.email}))}catch(s){u.showError(s.message||t("auth.sendCodeFailed"))}finally{C.value=!1}}}async function Pe(){if(we(!0)){v.value=!0;try{const s=await Oe({email:p.email,verify_code:p.verifyCode,password:p.password}),A=T.value;xe(s),p.verifyCode="",p.password="",I.value&&(S.value=!1),u.showSuccess(t(A?"profile.authBindings.replaceSuccess":"profile.authBindings.bindSuccess"))}catch(s){u.showError(s.message||t("common.tryAgain"))}finally{v.value=!1}}}return(s,A)=>(l(),n("div",{class:G(i.embedded?"space-y-4":"card overflow-hidden")},[i.embedded?F("",!0):(l(),n("div",ra,[e("h2",la,o(a(t)("profile.authBindings.title")),1),e("p",na,o(a(t)("profile.authBindings.description")),1)])),e("div",{class:G(i.embedded?"space-y-4":"divide-y divide-gray-100 dark:divide-dark-700")},[i.embedded?(l(),n("div",ia,[e("p",da,o(a(t)("profile.authBindings.title")),1),e("p",ca,o(a(t)("profile.authBindings.description")),1)])):F("",!0),(l(!0),n(X,null,ie(c.value,$=>{var Z,ee;return l(),n("div",{key:$.provider,class:G(z.value)},[e("div",ua,[e("div",pa,[e("div",{class:G([B($.provider),"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl text-sm font-semibold"])},[$.provider==="email"?(l(),ve(fe,{key:0,name:"mail",size:"sm",class:"text-current"})):(l(),n("span",fa,o(w($.provider)),1))],2),e("div",ma,[e("div",va,[e("h3",ba,o($.label),1),e("span",{"data-testid":`profile-binding-${$.provider}-status`,class:G(["badge",$.bound?"badge-success":"badge-gray"])},o($.bound?a(t)("profile.authBindings.status.bound"):a(t)("profile.authBindings.status.notBound")),11,ha)]),K($.provider)?(l(),n("p",ya,o(K($.provider)),1)):F("",!0),de($.provider,$.details)?(l(),n("div",ga,[$.provider!=="email"&&((Z=$.details)!=null&&Z.display_name)?(l(),n("p",_a,o($.details.display_name),1)):
1F("",!0),$.provider!=="email"&&((ee=$.details)!=null&&ee.subject_hint)?(l(),n("p",xa,o($.details.subject_hint),1)):F("",!0),H($.details)?(l(),n("p",wa,o(H($.details)),1)):F("",!0),Q($.details)?(l(),n("p",ka,o(Q($.details)),1)):F("",!0)])):F("",!0),$.provider==="email"&&r.value?(l(),n("div",$a,[W(e("input",{"onUpdate:modelValue":A[0]||(A[0]=R=>p.email=R),"data-testid":"profile-binding-email-input",type:"email",class:"input",placeholder:a(t)("profile.authBindings.emailPlaceholder"),disabled:C.value||v.value},null,8,Ca),[[q,p.email,void 0,{trim:!0}]]),e("button",{"data-testid":"profile-binding-email-send-code",type:"button",class:"btn btn-secondary btn-sm",disabled:C.value||v.value,onClick:Be},o(C.value?a(t)("common.loading"):a(t)("profile.authBindings.sendCodeAction")),9,Ea),W(e("input",{"onUpdate:modelValue":A[1]||(A[1]=R=>p.verifyCode=R),"data-testid":"profile-binding-email-code-input",type:"text",inputmode:"numeric",maxlength:"6",class:"input",placeholder:a(t)("profile.authBindings.codePlaceholder"),disabled:v.value},null,8,Sa),[[q,p.verifyCode,void 0,{trim:!0}]]),W(e("input",{"onUpdate:modelValue":A[2]||(A[2]=R=>p.password=R),"data-testid":"profile-binding-email-password-input",type:"password",class:"input",placeholder:f.value,disabled:v.value},null,8,Ba),[[q,p.password]]),e("button",{"data-testid":"profile-binding-email-submit",type:"button",class:"btn btn-primary btn-sm sm:col-span-2",disabled:v.value,onClick:Pe},o(v.value?a(t)("common.loading"):b.value),9,Pa)])):F("",!0)])]),e("div",Na,[$.provider==="email"&&I.value?(l(),n("button",{key:0,"data-testid":"profile-binding-email-toggle",type:"button",class:"btn btn-secondary btn-sm",onClick:$e},o(r.value?a(t)("profile.authBindings.hideEmailFormAction"):a(t)("profile.authBindings.manageEmailAction")),1)):F("",!0),$.canBind?(l(),n("button",{key:1,"data-testid":`profile-binding-${$.provider}-action`,type:"button",class:"btn btn-primary btn-sm",onClick:R=>Ce($.provider)},o(a(t)("profile.authBindings.bindAction",{providerName:$.label})),9,Da)):F("",!0),$.canUnbind?(l(),n("button",{key:2,"data-testid":`profile-binding-${$.provider}-unbind`,type:"button",class:"btn btn-secondary btn-sm",disabled:P.value===$.provider,onClick:R=>Se($.provider,$.label)},o(P.value===$.provider?a(t)("common.loading"):a(t)("profile.authBindings.unbindAction")),9,Ua)):F("",!0)])])],2)}),128))],2)],2))}}),Fa={class:"space-y-6"},Ia={"data-testid":"profile-overview-hero",class:"card overflow-hidden border border-primary-100/80 bg-gradient-to-br from-primary-50 via-white to-amber-50/70 dark:border-primary-900/40 dark:from-primary-950/40 dark:via-dark-900 dark:to-dark-950"},ja={class:"px-6 py-6 md:px-8"},Ta={class:"flex flex-col gap-6 lg:flex-row lg:items-start"},Ma={class:"flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-[1.75rem] bg-gradient-to-br from-primary-500 to-primary-600 text-2xl font-bold text-white shadow-lg shadow-primary-500/20"},Va=["src","alt"],La={key:1},za={class:"min-w-0 flex-1 space-y-5"},Oa={class:"space-y-3"},Ra={class:"flex flex-wrap items-center gap-2"},Wa={class:"truncate text-2xl font-semibold text-gray-900 dark:text-white"},Ha={class:"space-y-1"},qa={class:"truncate text-sm text-gray-600 dark:text-gray-300"},Ka={key:0,class:"flex flex-wrap gap-2 text-xs text-gray-500 dark:text-gray-400"},Qa={class:"grid gap-3 sm:grid-cols-3"},Ya={"data-testid":"profile-overview-metric-balance",class:"rounded-2xl bg-white/85 px-4 py-3 shadow-sm ring-1 ring-white/70 dark:bg-dark-900/60 dark:ring-dark-700"},Ga={class:"text-xs font-medium uppercase tracking-[0.16em] text-gray-400 dark:text-gray-500"},Xa={class:"mt-1 text-lg font-semibold text-gray-900 dark:text-white"},Za={"data-testid":"profile-overview-metric-concurrency",class:"rounded-2xl bg-white/85 px-4 py-3 shadow-sm ring-1 ring-white/70 dark:bg-dark-900/60 dark:ring-dark-700"},Ja={class:"text-xs font-medium uppercase tracking-[0.16em] text-gray-400 dark:text-gray-500"},eo={class:"mt-1 text-lg font-semibold text-gray-900 dark:text-white"},to={"data-testid":"profile-overview-metric-member-since",class:"rounded-2xl bg-white/85 px-4 py-3 shadow-sm ring-1 ring-white/70 dark:bg-dark-900/60 dark:ring-dark-700"},ao={class:"text-xs font-medium uppercase tracking-[0.16em] text-gray-400 dark:text-gray-500"},oo={class:"mt-1 text-lg font-semibold text-gray-900 dark:text-white"},so={class:"space-y-6"},ro={"data-testid":"profile-main-column",class:"space-y-6"},lo={"data-testid":"profile-basics-panel",class:"card border border-gray-100 bg-white/90 p-6 dark:border-dark-700 dark:bg-dark-900/50"},no={class:"mb-5 flex items-start justify-between gap-4"},io={class:"text-lg font-semibold text-gray-900 dark:text-white"},co={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},uo={class:"grid gap-6 sm:grid-cols-1 md:grid-cols-2"},po={class:"rounded-3xl border border-gray-100 bg-gray-50/80 p-5 dark:border-dark-700 dark:bg-dark-900/30"},fo={class:"rounded-3xl border border-gray-100 bg-gray-50/80 p-5 dark:border-dark-700 dark:bg-dark-900/30"},mo={"data-testid":"profile-auth-bindings-panel",class:"card border border-gray-100 bg-white/90 p-6 dark:border-dark-700 dark:bg-dark-900/50"},vo={"data-testid":"profile-side-column",class:"space-y-6"},bo={key:0,class:"card border border-gray-100 bg-white/90 p-6 dark:border-dark-700 dark:bg-dark-900/50"},ho={class:"text-lg font-semibold text-gray-900 dark:text-white"},yo={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},go={class:"mt-5 grid gap-3"},_o=ae({__name:"ProfileInfoCard",props:{user:{},linuxdoEnabled:{type:Boolean,default:!1},dingtalkEnabled:{type:Boolean,default:!1},oidcEnabled:{type:Boolean,default:!1},oidcProviderName:{default:"OIDC"},wechatEnabled:{type:Boolean,default:!1},wechatOpenEnabled:{type:Boolean,default:void 0},wechatMpEnabled:{type:Boolean,default:void 0}},setup(U){const i=U,{t}=oe();function d(r){return typeof r=="boolean"?r:r?typeof r.bound=="boolean"?r.bound:!!(r.provider_subject||r.issuer||r.provider_key):null}function u(r){var j,O;if(typeof(r==null?void 0:r.email_bound)=="boolean")return r.email_bound;const f=((j=r==null?void 0:r.auth_bindings)==null?void 0:j.email)??((O=r==null?void 0:r.identity_bindings)==null?void 0:O.email);return d(f)??!1}const x=L(()=>{var r,f;return((f=(r=i.user)==null?void 0:r.avatar_url)==null?void 0:f.trim())||""}),k=L(()=>{var r,f,b,j;return((f=(r=i.user)==null?void 0:r.username)==null?void 0:f.trim())||((j=(b=i.user)==null?void 0:b.email)==null?void 0:j.trim())||t("profile.user")}),C=L(()=>{var f,b;const r=((b=(f=i.user)==null?void 0:f.email)==null?void 0:b.trim())||"";
1return!r||r.endsWith(".invalid")&&!u(i.user)?"":r}),v=L(()=>k.value.charAt(0).toUpperCase()||"U"),S=L(()=>{var b,j;const r=(j=(b=i.user)==null?void 0:b.created_at)==null?void 0:j.trim();if(!r)return"-";const f=new Date(r);return Number.isNaN(f.getTime())?"-":new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short"}).format(f)}),P=L(()=>({email:t("profile.authBindings.providers.email"),linuxdo:t("profile.authBindings.providers.linuxdo"),dingtalk:t("profile.authBindings.providers.dingtalk"),oidc:t("profile.authBindings.providers.oidc",{providerName:i.oidcProviderName}),wechat:t("profile.authBindings.providers.wechat"),github:"GitHub",google:"Google"}));function p(r){return`$${r.toFixed(2)}`}function D(r){const f=r.trim().toLowerCase();return f==="email"||f==="linuxdo"||f==="wechat"||f==="github"||f==="google"?f:f==="oidc"||f.startsWith("oidc:")||f.startsWith("oidc/")?"oidc":null}function I(r,...f){for(const b of f){const j=r[b];if(typeof j=="string"&&j.trim())return j.trim()}return""}function z(r){if(!r)return null;if(typeof r=="string"){const O=D(r);return!O||O==="email"?null:{provider:O,label:P.value[O]}}const f=r,b=D(I(f,"provider","source","provider_type","auth_provider"));if(!b||b==="email")return null;const j=I(f,"provider_label","label","provider_name","providerName");return{provider:b,label:j||P.value[b]}}const T=L(()=>{var O,E,y,_;const r=i.user;if(!r)return[];const f=[],b=z(((O=r.profile_sources)==null?void 0:O.avatar)??r.avatar_source),j=z(((E=r.profile_sources)==null?void 0:E.username)??((y=r.profile_sources)==null?void 0:y.display_name)??((_=r.profile_sources)==null?void 0:_.nickname)??r.display_name_source??r.username_source??r.nickname_source);return b&&f.push({key:"avatar",text:t("profile.authBindings.source.avatar",{providerName:b.label})}),j&&f.push({key:"username",text:t("profile.authBindings.source.username",{providerName:j.label})}),f});return(r,f)=>{var b,j,O,E,y,_,m;return l(),n("div",Fa,[e("section",Ia,[e("div",ja,[e("div",Ta,[e("div",Ma,[x.value?(l(),n("img",{key:0,src:x.value,alt:k.value,class:"h-full w-full object-cover"},null,8,Va)):(l(),n("span",La,o(v.value),1))]),e("div",za,[e("div",Oa,[e("div",Ra,[e("h2",Wa,o(k.value),1),e("span",{class:G(["badge",((b=U.user)==null?void 0:b.role)==="admin"?"badge-primary":"badge-gray"])},o(((j=U.user)==null?void 0:j.role)==="admin"?a(t)("profile.administrator"):a(t)("profile.user")),3),e("span",{class:G(["badge",((O=U.user)==null?void 0:O.status)==="active"?"badge-success":"badge-danger"])},o(((E=U.user)==null?void 0:E.status)==="active"?a(t)("common.active"):a(t)("common.disabled")),3)]),e("div",Ha,[e("p",qa,o(C.value),1),T.value.length?(l(),n("div",Ka,[(l(!0),n(X,null,ie(T.value,M=>(l(),n("span",{key:M.key,class:"inline-flex items-center gap-1 rounded-full bg-white/80 px-3 py-1 ring-1 ring-primary-100 dark:bg-dark-900/70 dark:ring-primary-900/40"},[te(fe,{name:"link",size:"sm"}),me(" "+o(M.text),1)]))),128))])):F("",!0)])]),e("div",Qa,[e("div",Ya,[e("p",Ga,o(a(t)("profile.accountBalance")),1),e("p",Xa,o(p(((y=U.user)==null?void 0:y.balance)||0)),1)]),e("div",Za,[e("p",Ja,o(a(t)("profile.concurrencyLimit")),1),e("p",eo,o(((_=U.user)==null?void 0:_.concurrency)||0),1)]),e("div",to,[e("p",ao,o(a(t)("profile.memberSince")),1),e("p",oo,o(S.value),1)])])])])])]),e("div",so,[e("div",ro,[e("section",lo,[e("div",no,[e("div",null,[e("h3",io,o(a(t)("profile.basicsTitle")),1),e("p",co,o(a(t)("profile.basicsDescription")),1)])]),e("div",uo,[e("div",po,[te(Yt,{user:U.user,embedded:""},null,8,["user"])]),e("div",fo,[te(sa,{"initial-username":((m=U.user)==null?void 0:m.username)||"",embedded:""},null,8,["initial-username"])])])]),e("section",mo,[te(Aa,{user:U.user,"linuxdo-enabled":U.linuxdoEnabled,"dingtalk-enabled":U.dingtalkEnabled,"oidc-enabled":U.oidcEnabled,"oidc-provider-name":U.oidcProviderName,"wechat-enabled":U.wechatEnabled,"wechat-open-enabled":U.wechatOpenEnabled,"wechat-mp-enabled":U.wechatMpEnabled,embedded:"",compact:""},null,8,["user","linuxdo-enabled","dingtalk-enabled","oidc-enabled","oidc-provider-name","wechat-enabled","wechat-open-enabled","wechat-mp-enabled"])])]),e("div",vo,[T.value.length?(l(),n("section",bo,[e("h3",ho,o(a(t)("profile.linkedProfileSources")),1),e("p",yo,o(a(t)("profile.linkedProfileSourcesDescription")),1),e("div",go,[(l(!0),n(X,null,ie(T.value,M=>(l(),n("div",{key:M.key,class:"flex items-start gap-3 rounded-2xl border border-gray-100 bg-gray-50/80 px-4 py-3 text-sm text-gray-600 dark:border-dark-700 dark:bg-dark-900/30 dark:text-gray-300"},[te(fe,{name:"link",size:"sm",class:"mt-0.5 text-gray-400 dark:text-gray-500"}),e("span",null,o(M.text),1)]))),128))])])):F("",!0)])])])}}}),xo={key:0,class:"border-b border-gray-100 px-6 py-4 dark:border-dark-700"},wo={class:"text-lg font-medium text-gray-900 dark:text-white"},ko={key:0},$o={class:"text-sm font-semibold text-gray-900 dark:text-white"},Co={for:"old_password",class:"input-label"},Eo={for:"new_password",class:"input-label"},So={class:"input-hint"},Bo={for:"confirm_password",class:"input-label"},Po={class:"flex justify-end pt-4"},No=["disabled"],Do=ae({__name:"ProfilePasswordForm",props:{embedded:{type:Boolean,default:!1}},setup(U){const{t:i}=oe(),t=re(),d=U,u=g(!1),x=g({old_password:"",new_password:"",confirm_password:""}),k=async()=>
1{if(x.value.new_password!==x.value.confirm_password){t.showError(i("profile.passwordsNotMatch"));return}if(x.value.new_password.length<8){t.showError(i("profile.passwordTooShort"));return}u.value=!0;try{await Y.changePassword(x.value.old_password,x.value.new_password),x.value={old_password:"",new_password:"",confirm_password:""},t.showSuccess(i("profile.passwordChangeSuccess"))}catch(C){t.showError(J(C,i("profile.passwordChangeFailed")))}finally{u.value=!1}};return(C,v)=>(l(),n("div",{class:G(d.embedded?"space-y-4":"card")},[d.embedded?F("",!0):(l(),n("div",xo,[e("h2",wo,o(a(i)("profile.changePassword")),1)])),e("div",{class:G(d.embedded?"":"px-6 py-6")},[e("form",{onSubmit:ne(k,["prevent"]),class:"space-y-4"},[d.embedded?(l(),n("div",ko,[e("p",$o,o(a(i)("profile.changePassword")),1)])):F("",!0),e("div",null,[e("label",Co,o(a(i)("profile.currentPassword")),1),W(e("input",{id:"old_password","onUpdate:modelValue":v[0]||(v[0]=S=>x.value.old_password=S),type:"password",required:"",autocomplete:"current-password",class:"input"},null,512),[[q,x.value.old_password]])]),e("div",null,[e("label",Eo,o(a(i)("profile.newPassword")),1),W(e("input",{id:"new_password","onUpdate:modelValue":v[1]||(v[1]=S=>x.value.new_password=S),type:"password",required:"",autocomplete:"new-password",class:"input"},null,512),[[q,x.value.new_password]]),e("p",So,o(a(i)("profile.passwordHint")),1)]),e("div",null,[e("label",Bo,o(a(i)("profile.confirmNewPassword")),1),W(e("input",{id:"confirm_password","onUpdate:modelValue":v[2]||(v[2]=S=>x.value.confirm_password=S),type:"password",required:"",autocomplete:"new-password",class:"input"},null,512),[[q,x.value.confirm_password]])]),e("div",Po,[e("button",{type:"submit",disabled:u.value,class:"btn btn-primary"},o(u.value?a(i)("profile.changingPassword"):a(i)("profile.changePasswordButton")),9,No)])],32)],2)
1],2))}}),Uo={class:"flex min-h-full items-center justify-center p-4"},Ao={class:"relative w-full max-w-md transform rounded-xl bg-white p-6 shadow-xl transition-all dark:bg-dark-800"},Fo={class:"mb-6 text-center"},Io={class:"text-xl font-semibold text-gray-900 dark:text-white"},jo={class:"mt-2 text-sm text-gray-500 dark:text-gray-400"},To={key:0,class:"space-y-6"},Mo={key:0,class:"flex items-center justify-center py-8"},Vo={key:0,class:"space-y-4"},Lo={class:"input-label"},zo={class:"flex gap-2"},Oo=["placeholder"],Ro=["disabled"],Wo={key:1,class:"space-y-4"},Ho={class:"input-label"},qo=["placeholder"],Ko={class:"flex justify-end gap-3 pt-4"},Qo=["disabled"],Yo={key:1,class:"space-y-6"},Go={class:"flex justify-center"},Xo={class:"rounded-lg border border-gray-200 p-4 bg-white dark:border-dark-600 dark:bg-white"},Zo=["src"],Jo={class:"text-center"},es={class:"text-sm text-gray-500 dark:text-gray-400 mb-2"},ts={class:"flex items-center justify-center gap-2"},as={class:"rounded bg-gray-100 px-3 py-2 font-mono text-sm dark:bg-dark-700"},os={class:"flex justify-end gap-3 pt-4"},ss=["disabled"],rs={key:2,class:"space-y-6"},ls={class:"mb-6"},ns={class:"input-label text-center block mb-3"},is={class:"flex justify-center gap-2"},ds=["onInput","onKeydown"],cs={class:"flex justify-end gap-3"},us=["disabled"],ps=ae({__name:"TotpSetupModal",emits:["close","success"],setup(U,{emit:i}){const t=i,{t:d}=oe(),u=re(),x=g(0),k=g(!0),C=g("password"),v=g({emailCode:"",password:""}),S=g(!1),P=g(0),p=g(null),D=g(!1),I=g(null),z=g(!1),T=g(["","","","","",""]),r=g([]),f=g(""),b=L(()=>{switch(x.value){case 0:return C.value==="email"?d("profile.totp.verifyEmailFirst"):d("profile.totp.verifyPasswordFirst");case 1:return d("profile.totp.setupStep1");case 2:return d("profile.totp.setupStep2");default:return""}}),j=L(()=>C.value==="email"?v.value.emailCode.length===6:v.value.password.length>0);se(()=>{var c;return(c=I.value)==null?void 0:c.qr_code_url},async c=>{if(c)try{f.value=await We.toDataURL(c,{width:200,margin:2,color:{dark:"#000000",light:"#ffffff"}})}catch(w){console.error("Failed to generate QR code:",w)}},{immediate:!0});const O=(c,w)=>{r.value[w]=c},E=(c,w)=>{const K=c.target.value.replace(/[^0-9]/g,"");T.value[w]=K,K&&w<5&&ye(()=>{var H;(H=r.value[w+1])==null||H.focus()})},y=(c,w)=>{var B;c.key==="Backspace"&&!c.target.value&&w>0&&(c.preventDefault(),(B=r.value[w-1])==null||B.focus())},_=c=>{var H;c.preventDefault();const B=(((H=c.clipboardData)==null?void 0:H.getData("text"))||"").replace(/[^0-9]/g,"").slice(0,6).split("");B.forEach((Q,de)=>{T.value[de]=Q,r.value[de]&&(r.value[de].value=Q)});for(let Q=B.length;Q<6;Q++)T.value[Q]="",r.value[Q]&&(r.value[Q].value="");const K=Math.min(B.length,5);ye(()=>{var Q;(Q=r.value[K])==null||Q.focus()})},m=async()=>{if(I.value)try{await navigator.clipboard.writeText(I.value.secret),u.showSuccess(d("common.copied"))}catch{u.showError(d("common.copyFailed"))}},M=async()=>{var c,w;k.value=!0;try{const B=await le.getVerificationMethod();C.value=B.method}catch(B){u.showError(((w=(c=B.response)==null?void 0:c.data)==null?void 0:w.message)||d("common.error")),t("close")}finally{k.value=!1}},V=async()=>{var c,w;S.value=!0;try{await le.sendVerifyCode(),u.showSuccess(d("profile.totp.codeSent")),P.value=60,p.value&&(clearInterval(p.value),p.value=null),p.value=setInterval(()=>{P.value--,P.value<=0&&p.value&&(clearInterval(p.value),p.value=null)},1e3)}catch(B){u.showError(((w=(c=B.response)==null?void 0:c.data)==null?void 0:w.message)||d("profile.totp.sendCodeFailed"))}finally{S.value=!1}},N=async()=>{var c,w;D.value=!0;try{const B=C.value==="email"?{email_code:v.value.emailCode}:{password:v.value.password};I.value=await le.initiateSetup(B),x.value=1}catch(B){u.showError(((w=(c=B.response)==null?void 0:c.data)==null?void 0:w.message)||d("profile.totp.setupFailed"))}finally{D.value=!1}},h=async()=>{var w,B;const c=T.value.join("");if(!(c.length!==6||!I.value)){z.value=!0;try{await le.enable({totp_code:c,setup_token:I.value.setup_token}),u.showSuccess(d("profile.totp.enableSuccess")),t("success")}catch(K){u.showError(((B=(w=K.response)==null?void 0:w.data)==null?void 0:B.message)||d("profile.totp.verifyFailed")),T.value=["","","","","",""],ye(()=>{var H;(H=r.value[0])==null||H.focus()})}finally{z.value=!1}}};return he(()=>{M()}),_e(()=>{p.value&&(clearInterval(p.value),p.value=null)}),(c,w)=>(l(),n("div",{class:"fixed inset-0 z-50 overflow-y-auto",onClick:w[7]||(w[7]=ne(B=>c.$emit("close"),["self"]))},[e("div",Uo,[e("div",{class:"fixed inset-0 bg-black/50 transition-opacity",onClick:w[0]||(w[0]=B=>c.$emit("close"))}),e("div",Ao,[e("div",Fo,[e("h3",Io,o(a(d)("profile.totp.setupTitle")),1),e("p",jo,o(b.value),1)]),x.value===0?(l(),n("div",To,[k.value?(l(),n("div",Mo,[...w[8]||(w[8]=[e("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"},null,-1)])])):(l(),n(X,{key:1},[C.value==="email"?(l(),n("div",Vo,[e("div",null,[e("label",Lo,o(a(d)("profile.totp.emailCode")),1),e("div",zo,[W(e("input",{"onUpdate:modelValue":w[1]||(w[1]=B=>v.value.emailCode=B),type:"text",maxlength:"6",inputmode:"numeric",class:"input flex-1",placeholder:a(d)("profile.totp.enterEmailCode")},null,8,Oo),[[q,v.value.emailCode]]),e("button",{type:"button",class:"btn btn-secondary whitespace-nowrap",disabled:S.value||P.value>0,onClick:V},o(P.value>0?`${P.value}s`:S.value?a(d)("common.sending"):a(d)("profile.totp.sendCode")),9,Ro)])])])):(l(),n("div",Wo,[e("div",null,[e("label",Ho,o(a(d)("profile.currentPassword")),1),W(e("input",{"onUpdate:modelValue":w[2]||(w[2]=B=>v.value.password=B),type:"password",autocomplete:"current-password",class:"input",placeholder:a(d)("profile.totp.enterPassword")},null,8,qo),[[q,v.value.password]])])])),e("div",Ko,[e("button",{type:"button",class:"btn btn-secondary",onClick:w[3]||(w[3]=B=>c.$emit("close"))},o(a(d)("common.cancel")),1),e("button",{type:"button",class:"btn btn-primary",disabled:!j.value||D.value,onClick:N},o(D.value?a(d)("common.loading"):a(d)("common.next")),9,Qo)])],64))])):F("",!0),x.value===1?(l(),n("div",Yo,[I.value?(l(),n(X,{key:0},[e("div",Go,[e("div",Xo,[e("img",{src:f.value,alt:"QR Code",class:"h-48 w-48"},null,8,Zo)])]),e("div",Jo,[e("p",es,o(a(d)("profile.totp.manualEntry")),1),e("div",ts,[e("code",as,o(I.value.secret),1),e("button",{type:"button",class:"rounded p-1.5 text-gray-500 hover:bg-gray-100 dark:hover:bg-dark-700",onClick:m},[...w[9]||(w[9]=[e("svg",{class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"})],-1)])])])])],64)):F("",!0),e("div",os,[e("button",{type:"button",class:"btn btn-secondary",onClick:w[4]||(w[4]=B=>c.$emit("close"))},o(a(d)("common.cancel")),1),e("button",{type:"button",class:"btn btn-primary",disabled:!I.value,onClick:w[5]||(w[5]=B=>x.value=2)},o(a(d)("common.next")),9,ss)])])):F("",!0),x.value===2?(l(),n("div",rs,[e("form",{onSubmit:ne(h,["prevent"])},[e("div",ls,[e("label",ns,o(a(d)("profile.totp.enterCode")),1),e("div",is,[(l(),n(X,null,ie(6,
1(B,K)=>e("input",{key:K,ref_for:!0,ref:H=>O(H,K),type:"text",maxlength:"1",inputmode:"numeric",pattern:"[0-9]",class:"h-12 w-10 rounded-lg border border-gray-300 text-center text-lg font-semibold focus:border-primary-500 focus:ring-primary-500 dark:border-dark-600 dark:bg-dark-700",onInput:H=>E(H,K),onKeydown:H=>y(H,K),onPaste:_},null,40,ds)),64))])]),e("div",cs,[e("button",{type:"button",class:"btn btn-secondary",onClick:w[6]||(w[6]=B=>x.value=1)},o(a(d)("common.back")),1),e("button",{type:"submit",class:"btn btn-primary",disabled:z.value||T.value.join("").length!==6},o(z.value?a(d)("common.verifying"):a(d)("profile.totp.verify")),9,us)])],32)])):F("",!0)])])]))}}),fs={class:"flex min-h-full items-center justify-center p-4"},ms={class:"relative w-full max-w-md transform rounded-xl bg-white p-6 shadow-xl transition-all dark:bg-dark-800"},vs={class:"mb-6"},bs={class:"mt-4 text-center text-xl font-semibold text-gray-900 dark:text-white"},hs={class:"mt-2 text-center text-sm text-gray-500 dark:text-gray-400"},ys={key:0,class:"flex items-center justify-center py-8"},gs={key:0},_s={class:"input-label"},xs={class:"flex gap-2"},ws=["placeholder"],ks=["disabled"],$s={key:1},Cs={for:"password",class:"input-label"},Es=["placeholder"],Ss={class:"flex justify-end gap-3 pt-4"},Bs=["disabled"],Ps=ae({__name:"TotpDisableDialog",emits:["close","success"],setup(U,{emit:i}){const t=i,{t:d}=oe(),u=re(),x=g(!0),k=g("password"),C=g(!1),v=g(!1),S=g(0),P=g(null),p=g({emailCode:"",password:""}),D=L(()=>k.value==="email"?p.value.emailCode.length===6:p.value.password.length>0),I=async()=>{var r,f;x.value=!0;try{const b=await le.getVerificationMethod();k.value=b.method}catch(b){u.showError(((f=(r=b.response)==null?void 0:r.data)==null?void 0:f.message)||d("common.error")),t("close")}finally{x.value=!1}},z=async()=>{var r,f;v.value=!0;try{await le.sendVerifyCode(),u.showSuccess(d("profile.totp.codeSent")),S.value=60,P.value&&(clearInterval(P.value),P.value=null),P.value=setInterval(()=>{S.value--,S.value<=0&&P.value&&(clearInterval(P.value),P.value=null)},1e3)}catch(b){u.showError(((f=(r=b.response)==null?void 0:r.data)==null?void 0:f.message)||d("profile.totp.sendCodeFailed"))}finally{v.value=!1}},T=async()=>{var r,f;if(D.value){C.value=!0;try{const b=k.value==="email"?{email_code:p.value.emailCode}:{password:p.value.password};await le.disable(b),u.showSuccess(d("profile.totp.disableSuccess")),t("success")}catch(b){u.showError(((f=(r=b.response)==null?void 0:r.data)==null?void 0:f.message)||d("profile.totp.disableFailed"))}finally{C.value=!1}}};return he(()=>{I()}),_e(()=>{P.value&&(clearInterval(P.value),P.value=null)}),(r,f)=>(l(),n("div",{class:"fixed inset-0 z-50 overflow-y-auto",onClick:f[4]||(f[4]=ne(b=>r.$emit("close"),["self"]))},[e("div",fs,[e("div",{class:"fixed inset-0 bg-black/50 transition-opacity",onClick:f[0]||(f[0]=b=>r.$emit("close"))}),e("div",ms,[e("div",vs,[f[5]||(f[5]=e("div",{class:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},[e("svg",{class:"h-6 w-6 text-red-600 dark:text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})])],-1)),e("h3",bs,o(a(d)("profile.totp.disableTitle")),1),e("p",hs,o(a(d)("profile.totp.disableWarning")),1)]),x.value?(l(),n("div",ys,[...f[6]||(f[6]=[e("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"},null,-1)])])):(l(),n("form",{key:1,onSubmit:ne(T,["prevent"]),class:"space-y-4"},[k.value==="email"?(l(),n("div",gs,[e("label",_s,o(a(d)("profile.totp.emailCode")),1),e("div",xs,[W(e("input",{"onUpdate:modelValue":f[1]||(f[1]=b=>p.value.emailCode=b),type:"text",maxlength:"6",inputmode:"numeric",class:"input flex-1",placeholder:a(d)("profile.totp.enterEmailCode")},null,8,ws),[[q,p.value.emailCode]]),e("button",{type:"button",class:"btn btn-secondary whitespace-nowrap",disabled:v.value||S.value>0,onClick:z},o(S.value>0?`${S.value}s`:v.value?a(d)("common.sending"):a(d)("profile.totp.sendCode")),9,ks)])])):(l(),n("div",$s,[e("label",Cs,o(a(d)("profile.currentPassword")),1),W(e("input",{id:"password","onUpdate:modelValue":f[2]||(f[2]=b=>p.value.password=b),type:"password",autocomplete:"current-password",class:"input",placeholder:a(d)("profile.totp.enterPassword")},null,8,Es),[[q,p.value.password]])])),e("div",Ss,[e("button",{type:"button",class:"btn btn-secondary",onClick:f[3]||(f[3]=b=>r.$emit("close"))},o(a(d)("common.cancel")),1),e("button",{type:"submit",class:"btn btn-danger",disabled:C.value||!D.value},o(C.value?a(d)("common.processing"):a(d)("profile.totp.confirmDisable")),9,Bs)])],32))])])]))}}),Ns={class:"card"},Ds={class:"border-b border-gray-100 px-6 py-4 dark:border-dark-700"},Us={class:"text-lg font-medium text-gray-900 dark:text-white"},As={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Fs={class:"px-6 py-6"},Is={key:0,class:"flex items-center justify-center py-8"},js={key:1,class:"flex items-center gap-4 py-4"},Ts={class:"font-medium text-gray-700 dark:text-gray-300"},Ms={class:"text-sm text-gray-500 dark:text-gray-400"},Vs={key:2,class:"flex items-center justify-between"},Ls={class:"flex items-center gap-4"},zs={class:"font-medium text-gray-900 dark:text-white"},Os={key:0,class:"text-sm text-gray-500 dark:text-gray-400"},Rs={key:3,class:"flex items-center justify-between"},Ws={class:"flex items-center gap-4"},Hs={class:"font-medium text-gray-700 dark:text-gray-300"},qs={class:"text-sm text-gray-500 dark:text-gray-400"},Ks=ae({__name:"ProfileTotpCard",setup(U){const{t:i}=oe(),t=g(!0),d=g(null),u=g(!1),x=g(!1),k=async()=>{t.value=!0;try{d.value=await le.getStatus()}catch(P){console.error("Failed to load TOTP status:",P)}finally{t.value=!1}},C=()=>{u.value=!1,k()},v=()=>{x.value=!1,k()},S=P=>new Date(P*1e3).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"});return he(()=>{k()}),(P,p)=>{var D;return l(),n("div",Ns,[e("div",Ds,[e("h2",Us,o(a(i)("profile.totp.title")),1),e("p",As,o(a(i)("profile.totp.description")),1)]),e("div",Fs,[t.value?(l(),n("div",Is,[...p[4]||(p[4]=[e("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"},null,-1)])])):d.value&&!d.value.feature_enabled?(l(),n("div",js,[p[5]||(p[5]=e("div",{class:"flex-shrink-0 rounded-full bg-gray-100 p-3 dark:bg-dark-700"},[e("svg",{class:"h-6 w-6 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})])],-1)),e("div",null,[e("p",Ts,o(a(i)("profile.totp.featureDisabled")),1),e("p",Ms,o(a(i)("profile.totp.featureDisabledHint")),1)])])):(D=d.value)!=null&&D.enabled?(l(),n("div",Vs,[e("div",Ls,[p[6]||(p[6]=e("div",{class:"flex-shrink-0 rounded-full bg-green-100 p-3 dark:bg-green-900/30"},[e("svg",{class:"h-6 w-6 text-green-600 dark:text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})])],-1)),e("div",null,[e("p",zs,o(a(i)("profile.totp.enabled")),1),d.value.enabled_at?(l(),n("p",Os,o(a(i)("profile.totp.enabledAt"))+": "+o(S(d.value.enabled_at)),1)):F("",!0)])]),e("button",{type:"button",class:"btn btn-outline-danger",onClick:p[
10]||(p[0]=I=>x.value=!0)},o(a(i)("profile.totp.disable")),1)])):(l(),n("div",Rs,[e("div",Ws,[p[7]||(p[7]=e("div",{class:"flex-shrink-0 rounded-full bg-gray-100 p-3 dark:bg-dark-700"},[e("svg",{class:"h-6 w-6 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})])],-1)),e("div",null,[e("p",Hs,o(a(i)("profile.totp.notEnabled")),1),e("p",qs,o(a(i)("profile.totp.notEnabledHint")),1)])]),e("button",{type:"button",class:"btn btn-primary",onClick:p[1]||(p[1]=I=>u.value=!0)},o(a(i)("profile.totp.enable")),1)]))]),u.value?(l(),ve(ps,{key:0,onClose:p[2]||(p[2]=I=>u.value=!1),onSuccess:C})):F("",!0),x.value?(l(),ve(Ps,{key:1,onClose:p[3]||(p[3]=I=>x.value=!1),onSuccess:v})):F("",!0)])}}}),Qs={class:"card"},Ys={class:"flex items-start justify-between border-b border-gray-100 px-6 py-4 dark:border-dark-700"},Gs={class:"text-lg font-medium text-gray-900 dark:text-white"},Xs={class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Zs=["disabled"],Js={class:"px-6 py-6"},er={key:0,class:"mb-5 text-sm text-gray-500 dark:text-gray-400"},tr={key:1,class:"mb-5 text-sm text-amber-600 dark:text-amber-400"},ar={class:"grid gap-3 sm:grid-cols-2"},or={for:"passkey-name",class:"input-label"},sr=["placeholder"],rr={for:"passkey-add-password",class:"input-label"},lr=["placeholder"],nr={class:"flex justify-end gap-2"},ir=["disabled"],dr=["disabled"],cr={key:1,class:"flex justify-center py-6"},ur={key:2,class:"rounded-lg border border-dashed border-gray-200 px-4 py-8 text-center text-sm text-gray-500 dark:border-dark-700 dark:text-gray-400"},pr={key:3,class:"divide-y divide-gray-100 dark:divide-dark-700"},fr={class:"min-w-0"},mr={class:"flex items-center gap-2"},vr={class:"truncate font-medium text-gray-900 dark:text-white"},br={key:0,class:"rounded-full bg-green-50 px-2 py-0.5 text-xs text-green-700 dark:bg-green-900/30 dark:text-green-300"},hr={class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},yr={class:"flex shrink-0 gap-2"},gr=["disabled","onClick"],_r=["disabled","onClick"],xr={key:0,class:"fixed inset-0 z-50 overflow-y-auto"},wr={class:"flex min-h-full items-center justify-center p-4"},kr={class:"relative w-full max-w-md transform rounded-xl bg-white p-6 shadow-xl transition-all dark:bg-dark-800"},$r={class:"text-lg font-semibold text-gray-900 dark:text-white"},Cr={class:"mt-2 text-sm text-gray-500 dark:text-gray-400"},Er={for:"passkey-delete-password",class:"input-label"},Sr=["placeholder"],Br={class:"flex justify-end gap-3"},Pr=["disabled"],Nr=["disabled"],Dr=ae({__name:"ProfilePasskeyCard",props:{enabled:{type:Boolean}},setup(U){const i=U,{t}=oe(),d=re(),u=pe.isSupported(),x=g(!1),k=g(!1),C=g(!1),v=g(""),S=g(""),P=g(null),p=g(""),D=g([]);function I(y,_){const m=y.message;return typeof m=="string"&&m.length>0?m:_}async function z(){if(!i.enabled){D.value=[];return}x.value=!0;try{D.value=await pe.list()}catch(y){y.reason!=="PASSKEY_DISABLED"&&d.showError(t("profile.passkey.loadFailed"))}finally{x.value=!1}}async function T(){if(S.value.length!==0){k.value=!0;try{await pe.register(v.value.trim(),S.value),d.showSuccess(t("profile.passkey.added")),r(),await z()}catch(y){y instanceof DOMException&&y.name==="NotAllowedError"||d.showError(I(y,t("profile.passkey.addFailed")))}finally{k.value=!1}}}function r(){C.value=!1,v.value="",S.value=""}async function f(y){var m;const _=(m=window.prompt(t("profile.passkey.renamePrompt"),y.name))==null?void 0:m.trim();if(!(!_||_===y.name)){k.value=!0;try{await pe.rename(y.id,_),y.name=_,d.showSuccess(t("profile.passkey.renamed"))}catch{d.showError(t("profile.passkey.renameFailed"))}finally{k.value=!1}}}function b(y){P.value=y,p.value=""}function j(){P.value=null,p.value=""}async function O(){const y=P.value;if(!(!y||p.value.length===0)){k.value=!0;try{await pe.remove(y.id,p.value),D.value=D.value.filter(_=>_.id!==y.id),d.showSuccess(t("profile.passkey.deleted")),j()}catch(_){d.showError(I(_,t("profile.passkey.deleteFailed")))}finally{k.value=!1}}}function E(y){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"}).format(new Date(y))}return se(()=>i.enabled,()=>{z()},{immediate:!0}),(y,_)=>(l(),n("div",Qs,[e("div",Ys,[e("div",null,[e("h2",Gs,o(a(t)("profile.passkey.title")),1),e("p",Xs,o(a(t)("profile.passkey.description")),1)]),U.enabled&&a(u)&&!C.value?(l(),n("button",{key:0,t
1ype:"button",class:"btn btn-primary",disabled:k.value,onClick:_[0]||(_[0]=m=>C.value=!0)},o(a(t)("profile.passkey.add")),9,Zs)):F("",!0)]),e("div",Js,[U.enabled?F("",!0):(l(),n("div",er,o(a(t)("profile.passkey.featureDisabled")),1)),U.enabled&&!a(u)?(l(),n("div",tr,o(a(t)("profile.passkey.unsupported")),1)):F("",!0),e("div",null,[U.enabled&&a(u)&&C.value?(l(),n("form",{key:0,class:"mb-5 flex flex-col gap-3 rounded-lg border border-gray-200 p-4 dark:border-dark-700",onSubmit:ne(T,["prevent"])},[e("div",ar,[e("div",null,[e("label",or,o(a(t)("profile.passkey.name")),1),W(e("input",{id:"passkey-name","onUpdate:modelValue":_[1]||(_[1]=m=>v.value=m),class:"input",maxlength:"100",placeholder:a(t)("profile.passkey.namePlaceholder"),autofocus:""},null,8,sr),[[q,v.value]])]),e("div",null,[e("label",rr,o(a(t)("profile.currentPassword")),1),W(e("input",{id:"passkey-add-password","onUpdate:modelValue":_[2]||(_[2]=m=>S.value=m),type:"password",autocomplete:"current-password",class:"input",placeholder:a(t)("profile.passkey.passwordPlaceholder")},null,8,lr),[[q,S.value]])])]),e("div",nr,[e("button",{type:"button",class:"btn btn-secondary",disabled:k.value,onClick:r},o(a(t)("common.cancel")),9,ir),e("button",{type:"submit",class:"btn btn-primary",disabled:k.value||S.value.length===0},o(k.value?a(t)("common.processing"):a(t)("profile.passkey.continue")),9,dr)])],32)):F("",!0),x.value?(l(),n("div",cr,[..._[4]||(_[4]=[e("div",{class:"h-8 w-8 animate-spin rounded-full border-b-2 border-primary-500"},null,-1)])])):D.value.length===0?(l(),n("div",ur,o(a(t)("profile.passkey.empty")),1)):(l(),n("div",pr,[(l(!0),n(X,null,ie(D.value,m=>(l(),n("div",{key:m.id,class:"flex items-center justify-between gap-4 py-4 first:pt-0 last:pb-0"},[e("div",fr,[e("div",mr,[te(a(fe),{name:"key",size:"md",class:"shrink-0 text-primary-500"}),e("p",vr,o(m.name),1),m.backup?(l(),n("span",br,o(a(t)("profile.passkey.synced")),1)):F("",!0)]),e("p",hr,[me(o(a(t)("profile.passkey.createdAt",{date:E(m.created_at)}))+" ",1),m.last_used_at?(l(),n(X,{key:0},[me(" · "+o(a(t)("profile.passkey.lastUsed",{date:E(m.last_used_at)})),1)],64)):F("",!0)])]),e("div",yr,[e("button",{type:"button",class:"btn btn-secondary btn-sm",disabled:k.value,onClick:M=>f(m)},o(a(t)("common.edit")),9,gr),e("button",{type:"button",class:"btn btn-ghost btn-sm text-red-600 hover:bg-red-50 dark:text-red-300 dark:hover:bg-red-950/30",disabled:k.value,onClick:M=>b(m)},o(a(t)("common.delete")),9,_r)])]))),128))]))])]),P.value?(l(),n("div",xr,[e("div",wr,[e("div",{class:"fixed inset-0 bg-black/50 transition-opacity",onClick:j}),e("div",kr,[e("h3",$r,o(a(t)("profile.passkey.deleteTitle")),1),e("p",Cr,o(a(t)("profile.passkey.deleteConfirm",{name:P.value.name})),1),e("form",{class:"mt-4 space-y-4",onSubmit:ne(O,["prevent"])},[e("div",null,[e("label",Er,o(a(t)("profile.currentPassword")),1),W(e("input",{id:"passkey-delete-password","onUpdate:modelValue":_[3]||(_[3]=m=>p.value=m),type:"password",autocomplete:"current-password",class:"input",placeholder:a(t)("profile.passkey.passwordPlaceholder"),autofocus:""},null,8,Sr),[[q,p.value]])]),e("div",Br,[e("button",{type:"button",class:"btn btn-secondary",disabled:k.value,onClick:j},o(a(t)("common.cancel")),9,Pr),e("button",{type:"submit",class:"btn btn-danger",disabled:k.value||p.value.length===0},o(k.value?a(t)("common.processing"):a(t)("common.delete")),9,Nr)])],32)])])])):F("",!0)]))}}),Ur={"data-testid":"profile-shell",class:"mx-auto max-w-[950px] space-y-6"},Ar={key:0,class:"card border-primary-200 bg-primary-50 p-6 dark:bg-primary-900/20"},Fr={class:"flex items-center gap-4"},Ir={class:"rounded-xl bg-primary-100 p-3 text-primary-600"},jr={class:"font-semibold text-primary-800 dark:text-primary-200"},Tr={class:"text-sm font-medium"},Xr=ae({__name:"ProfileView",setup(U){const{t:i}=oe(),t=re(),d=be(),u=L(()=>d.user),x=g(""),k=g(!1),C=g(0),v=g(!1),S=g(!1),P=g(!1),p=g(void 0),D=g(void 0),I=g(!1),z=g("OIDC"),T=g(!1);return he(async()=>{const r=d.refreshUser().catch(b=>{console.error("Failed to refresh profile:",b)}),f=t.fetchPublicSettings().then(b=>{b&&(x.value=b.contact_info||"",k.value=b.balance_low_notify_enabled??!1,C.value=b.balance_low_notify_threshold??0,v.value=b.linuxdo_oauth_enabled??!1,S.value=b.dingtalk_oauth_enabled??!1,P.value=Ae(b),p.value=typeof b.wechat_oauth_open_enabled=="boolean"?b.wechat_oauth_open_enabled:void 0,D.value=typeof b.wechat_oauth_mp_enabled=="boolean"?b.wechat_oauth_mp_enabled:void 0,I.value=b.oidc_oauth_enabled??!1,z.value=b.oidc_oauth_provider_name||"OIDC",T.value=b.passkey_enabled===!0)}).catch(b=>{console.error("Failed to load settings:",b)});await Promise.all([r,f])}),(r,f)=>(l(),ve(Fe,null,{default:Ve(()=>[e("div",Ur,[te(_o,{user:u.value,"linuxdo-enabled":v.value,"dingtalk-enabled":S.value,"oidc-enabled":I.value,"oidc-provider-name":z.value,"wechat-enabled":P.value,"wechat-open-enabled":p.value,"wechat-mp-enabled":D.value},null,8,["user","linuxdo-enabled","dingtalk-enabled","oidc-enabled","oidc-provider-name","wechat-enabled","wechat-open-enabled","wechat-mp-enabled"]),x.value?(l(),n("div",Ar,[e("div",Fr,[e("div",Ir,[te(a(fe),{name:"chat",size:"lg"})]),e("div",null,[e("h3",jr,o(a(i)("common.contactSupport")),1),e("p",Tr,o(x.value),1)])])])):F("",!0),te(Do),u.value&&k.value?(l(),ve(It,{key:1,enabled:u.value.balance_notify_enabled??!0,threshold:u.value.balance_notify_threshold,"extra-emails":u.value.balance_notify_extra_emails??[],"system-default-threshold":C.value,"user-email":u.value.email},null,8,["enabled","threshold","extra-emails","system-default-threshold","user-email"])):F("",!0),te(Ks),te(Dr,{enabled:T.value},null,8,["enabled"])])]),_:1}))}});
1export{Xr 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.