1import{b as A,x as p,H as C,y as O,M as F,q as j,w as B,m as a,a5 as U,o as n,j as e,A as D,i as l,t as o,N as V,F as z,L as H,f as R,a6 as K,a7 as W,k as T,O as N,C as Z,E as q,D as I,S as X,l as M,X as Y,n as G,a3 as J,u as Q}from"./Ccw9mUhn.js";import"./DAFaHp-e.js";import"./DuGk2X12.js";import"./D6KhxRPP.js";import"./B623BiJ6.js";import"./D_rq7M5t.js";const ee={class:"text-center"},te={key:0,class:"h-6 w-6 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},se={key:1,class:"h-6 w-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},oe={class:"text-gray-600 mb-6"},ae={class:"text-sm"},ne={key:0},le={key:1},re={key:2},ie={class:"flex justify-center"},ce={key:2,class:"flex gap-3"},ue=A({__name:"ConfirmationModal",props:{isOpen:{type:Boolean},title:{},message:{},confirmText:{default:"Confirmer"},cancelText:{default:"Annuler"},isDangerous:{type:Boolean,default:!1},securityDelay:{default:5}},emits:["close","confirm","cancel"],setup(E,{emit:f}){const d=E,y=f,g=p(0),m=p(null),r=p(!1),b=C(()=>g.value>0),i=C(()=>d.isDangerous&&b.value),h=()=>{d.isDangerous&&(g.value=d.securityDelay,m.value=V(()=>{g.value--,g.value<=0&&(u(),P())},1e3))},u=()=>{m.value&&(clearInterval(m.value),m.value=null),g.value=0,r.value=!1},x=()=>{u()},_=()=>{u(),y("cancel")},P=()=>{r.value=!0,y("confirm")},k=()=>{if(d.isDangerous&&!b.value){h();return}i.value||y("confirm")};return O(()=>{u()}),F(()=>d.isOpen,c=>{c||u()}),(c,v)=>(n(),j(U,{"is-open":c.isOpen,"show-close-button":!a(i),"close-on-backdrop":!a(i),onClose:_},{content:B(()=>[e("div",ee,[e("div",{class:D(["mx-auto flex items-center justify-center h-12 w-12 rounded-full mb-4",c.isDangerous?"bg-red-100":"bg-blue-100"])},[c.isDangerous?(n(),l("svg",te,v[0]||(v[0]=[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-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"},null,-1)]))):(n(),l("svg",se,v[1]||(v[1]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])))],2),e("h2",{class:D(["text-lg font-semibold mb-4",c.isDangerous?"text-red-900":"text-gray-900"])},o(c.title),3),e("div",oe,[e("p",ae,[a(r)?(n(),l("span",ne,"Executing action...")):a(i)?(n(),l("span",re,` You can still cancel this action. If you don't click "Cancel", the action will be executed automatically in `+o(a(g))+" second"+o(a(g)>1?"s":"")+". ",1)):(n(),l("span",le,o(c.message),1))])]),e("div",ie,[a(i)?(n(),l("button",{key:0,onClick:x,class:"cursor-pointer px-6 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors"}," Cancel ("+o(a(g))+") ",1)):a(r)?(n(),l(z,{key:1},[],64)):(n(),l("div",ce,[e("button",{onClick:_,class:"cursor-pointer px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors"},o(c.cancelText),1),e("button",{onClick:k,class:D(["cursor-pointer px-4 py-2 text-sm font-medium rounded-lg transition-colors",c.isDangerous?"text-white bg-red-600 hover:bg-red-700":"text-white bg-blue-600 hover:bg-blue-700"])},o(c.confirmText),3)]))])])]),_:1},8,["is-open","show-close-button","close-on-backdrop"]))}}),de={class:"min-h-screen bg-gray-50"},ge={class:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8"},me={class:"mb-8"},pe={class:"text-3xl font-bold text-gray-900"},fe={class:"mt-2 text-gray-600"},be={class:"bg-white rounded-lg shadow-sm border p-6 mb-6"},he={class:"text-xl font-semibold text-gray-900 mb-4"},ve={class:"space-y-4"},ye={for:"name",class:"block text-sm font-medium text-gray-700 mb-1"},xe={class:"flex gap-3"},_e={key:1,class:"flex-1 px-3 py-2 text-gray-900 bg-gray-50 rounded-lg border border-gray-200"},ke={key:3,class:"flex gap-2"},we=["disabled"],Ce={key:0},Pe={key:1},$e={key:0,class:"mt-1 text-sm text-red-600"},De={for:"email",class:"block text-sm font-medium text-gray-700 mb-1"},Ee={class:"px-3 py-2 text-gray-900 bg-gray-50 rounded-lg border border-gray-200"},Te={class:"mt-1 text-xs text-gray-500"},Ne={class:"bg-white rounded-lg shadow-sm border border-red-200 p-6"},Ie={class:"text-xl font-semibold text-red-900 mb-2"},Me={class:"text-sm text-red-700 mb-4"},Ae={key:0,class:"fixed top-4 right-4 z-[60] max-w-md"},Be={class:"p-4 bg-red-50 border border-red-200 rounded-lg shadow-lg"},Se={class:"text-sm text-red-700"},He=A({__name:"profile",setup(E){const{t:f}=H();R({title:f("subtiltee.profilePage.metaTitle"),meta:[{name:"robots",content:"noindex"}
1]});const d=K(),{updateUser:y}=W(),g=C(()=>d.user.value);C(()=>d.accessStatus.value);const m=p(!1),r=p(""),b=p(!1),i=p(""),h=p(!1),u=p(""),x=p(!1),_=()=>{console.log("ð DELETE BUTTON CLICKED"),u.value="",h.value=!0},P=()=>{r.value=d.userDisplayName.value||"",m.value=!0,i.value="",Y(()=>{const t=document.getElementById("name");t==null||t.focus()})},k=()=>{m.value=!1,r.value="",i.value=""},c=async()=>{var t;if(!r.value.trim()){i.value=f("subtiltee.profilePage.errors.nameEmpty");return}if(r.value.trim().length<2||r.value.trim().length>50){i.value=f("subtiltee.profilePage.errors.nameLength");return}b.value=!0,i.value="";try{console.log("ð PROFILE: Starting name update:",r.value.trim());const s=await $fetch("/api/profile/update",{method:"POST",body:{name:r.value.trim()}});if(console.log("â
PROFILE: API response received:",s),s&&s.success&&s.user)console.log("ð PROFILE: Calling updateUser with:",s.user.name),y({name:s.user.name}),m.value=!1,r.value="",console.log("â
Name updated successfully");else throw new Error("Unexpected response format")}catch(s){console.error("â Error updating name:",s),i.value=((t=s==null?void 0:s.data)==null?void 0:t.statusMessage)||(s==null?void 0:s.message)||f("subtiltee.profilePage.errors.updateFailed")}finally{b.value=!1}},v=async()=>{var t;if(!x.value){x.value=!0,u.value="";try{await $fetch("/api/profile/delete-account",{method:"POST"}),console.log("â
Account deleted successfully"),h.value=!1;const s=J();s&&s.clearAuth();try{localStorage.clear(),sessionStorage.clear()}catch(w){console.warn("Could not clear storage:",w)}const $=Q();window.location.href=$("/")}catch(s){console.error("â Error deleting account:",s),u.value=((t=s==null?void 0:s.data)==null?void 0:t.message)||f("subtiltee.profilePage.errors.deleteFailed")}finally{x.value=!1}}},S=()=>{u.value="",h.value=!1};return(t,s)=>{var w;const $=G;return n(),l("div",de,[e("div",ge,[e("div",me,[T($,{to:"/dashboard",class:"text-green-600 hover:text-green-800 mb-2 inline-block"},{default:B(()=>[M(o(t.$t("subtiltee.profilePage.backToDashboard")),1)]),_:1}),e("h1",pe,o(t.$t("subtiltee.profilePage.title")),1),e("p",fe,o(t.$t("subtiltee.profilePage.subtitle")),1)]),e("div",be,[e("h2",he,o(t.$t("subtiltee.profilePage.personalInformation")),1),e("div",ve,[e("div",null,[e("label",ye,o(t.$t("subtiltee.profilePage.name")),1),e("div",xe,[a(m)?Z((n(),l("input",{key:0,"onUpdate:modelValue":s[0]||(s[0]=L=>X(r)?r.value=L:null),type:"text",id:"name",class:"flex-1 rounded-lg border border-gray-300 px-3 py-2 text-gray-900 focus:border-green-500 focus:outline-none focus:ring-1 focus:ring-green-500",onKeydown:[I(c,["enter"]),I(k,["escape"])]},null,544)),[[q,a(r)]]):(n(),l("span",_e,o(a(d).userDisplayName.value||t.$t("subtiltee.profilePage.notSpecified")),1)),a(m)?(n(),l("div",ke,[e("button",{onClick:c,disabled:a(b),class:"cursor-pointer px-4 py-2 text-sm font-medium text-white bg-green-700 hover:bg-green-700 disabled:bg-green-400 rounded-lg transition-colors"},[a(b)?(n(),l("span",Ce,o(t.$t("subtiltee.profilePage.saving")),1)):(n(),l("span",Pe,o(t.$t("subtiltee.profilePage.save")),1))],8,we),e("button",{onClick:k,class:"cursor-pointer px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-700 bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors"},o(t.$t("subtiltee.profilePage.cancel")),1)])):(n(),l("button",{key:2,onClick:P,class:"cursor-pointer px-4 py-2 text-sm font-medium text-green-600 hover:text-green-700 bg-green-50 hover:bg-green-100 rounded-lg border border-green-200 transition-colors"},o(t.$t("subtiltee.profilePage.edit")),1))]),a(i)?(n(),l("p",$e,o(a(i)),1)):N("",!0)]),e("div",null,[e("label",De,o(t.$t("subtiltee.profilePage.email")),1),e("div",Ee,o((w=a(g))==null?void 0:w.email),1),e("p",Te,o(t.$t("subtiltee.profilePage.emailCannotBeModified")),1)])])]),e("div",Ne,[e("h2",Ie,o(t.$t("subtiltee.profilePage.dangerZone")),1),e("p",Me,o(t.$t("subtiltee.profilePage.dangerZoneWarning")),1),e("button",{onClick:_,class:"cursor-pointer inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors"},[s[1]||(s[1]=e("svg",{class:"mr-2 h-4 w-4",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)),M(" "+o(t.$t("subtiltee.profilePage.deleteMyAccount")),1)])])]),T(ue,{"is-open":a(h),"is-dangerous":!0,"security-delay":10,title:t.$t("subtiltee.profilePage.deleteAccountTitle"),message:t.$t("subtiltee.profilePage.deleteAccountMessage"),"confirm-text":t.$t("subtiltee.profilePage.deletePermanently"),"cancel-text":t.$t("subtiltee.profilePage.cancel"),onConfirm:v,onCancel:S},null,8,["is-open","title","message","confirm-text","cancel-text"]),a(u)&&a(h)?(n(),l("div",Ae,[e("div",Be,[e("p",Se,o(a(u)),1)])])):N("",!0)])}}});
1export{He 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.