1import{u as N,r as c,j as e}from"./index-BgCxCLoX.js";import{g as L,u as U,d as R,a as D,c as F}from"./profile-B7ozUYRk.js";import{T as O,a as K,C as E}from"./TrustedDevices-DwrV0Uvw.js";import{U as _}from"./user-cog-DkFHscVJ.js";import{T as q}from"./triangle-alert-Clw9e_GU.js";import{C as A}from"./circle-check-DUptThgY.js";import{L as j}from"./loader-circle-BKVB3e40.js";import{T as H}from"./trash-2-DciZRmbE.js";import{S as B}from"./save-DczELMjL.js";import{K as M}from"./key-round-ZWw7MxvD.js";import"./card-CqIKthb8.js";import"./utils-DgWKjmuI.js";import"./button-OUzJbjEB.js";import"./index-B1UNk8be.js";import"./index-dSc6CJZX.js";import"./input-biuaiVtC.js";import"./label-CHiPhoyb.js";import"./index-BDUGx-_n.js";import"./badge-CTt-xE4W.js";import"./separator-CxNMlBr4.js";import"./alert-BO_EJMKg.js";import"./shield-CGMNlGhw.js";import"./circle-alert-Cw2LKMwX.js";import"./shield-check-BpoifywE.js";import"./check-BMqOOrdh.js";import"./copy-a4gG_3K7.js";import"./download-DYtPblbf.js";import"./alert-dialog-B383AQQL.js";import"./index-CKuaslEW.js";import"./index-zLaDunCl.js";import"./index-Dc_FVRD7.js";import"./index-ByYKhLRC.js";import"./index-B5Udi-Gm.js";import"./Combination-CWbpKF4j.js";import"./index-CTJLTKCj.js";import"./monitor-awzK6Oth.js";import"./formatDistanceToNow-Ba7cbhC8.js";import"./smartphone-CzSk5gBU.js";const x="w-full px-3 py-2 border border-slate-200 dark:border-slate-800 rounded-md bg-white text-[13px] text-slate-900 placeholder:text-slate-400 outline-none focus:border-slate-400",G="admin-mono text-[10.5px] tracking-widest text-slate-500 uppercase",$=[{value:"en",label:"English"},{value:"ro",label:"RomânÄ"},{value:"hu",label:"Magyar"}],z=[{value:"light",labelKey:"themeLightOption"},{value:"dark",labelKey:"themeDarkOption"},{value:"system",labelKey:"themeFollowSystem"}];function J(a){return a?.username?a.username.substring(0,2).toUpperCase():a?.email?a.email.substring(0,2).toUpperCase():"A"}function b(a,i){const t=a?.response?.data?.detail;return typeof t=="string"?t:t&&typeof t=="object"?t.message||JSON.stringify(t):a?.message||i("portalI18n.adminProfilePage.unknownError")}function Q(a){if(!a)return"â";try{return new Date(a).toLocaleString()}catch{return a}}function w({icon:a,title:i,description:t,children:l}){return e.jsxs("div",{className:"border border-slate-200 dark:border-slate-800 rounded-lg overflow-hidden bg-white shadow-sm transition-shadow duration-200 hover:shadow-md",children:[i&&e.jsxs("div",{className:"px-5 py-3 border-b border-slate-200 dark:border-slate-800 bg-slate-50",children:[e.jsxs("h2",{className:"text-[14px] font-semibold text-slate-900 inline-flex items-center gap-2",children:[a&&e.jsx(a,{className:"w-4 h-4 text-slate-500"}),i]}),t&&e.jsx("p",{className:"text-[12px] text-slate-500 mt-0.5",children:t})]}),e.jsx("div",{className:"px-5 py-4",children:l})]})}function h({label:a,hint:i,children:t}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:G,children:a}),t,i&&e.jsx("p",{className:"text-[11.5px] text-slate-500",children:i})]})}function V({profile:a,onProfileChange:i,onError:t,onSuccess:l}){const{t:r,i18n:u}=N(),m=c.useRef(null),[s,g]=c.useState({username:a?.username||"",language:a?.language||"en",theme_preference:a?.theme_preference||"light"}),[f,o]=c.useState(!1),[p,d]=c.useState(!1),I=s.username!==(a?.username||"")||s.language!==(a?.language||"en")||s.theme_preference!==(a?.theme_preference||"light");function v(n,P){g(C=>({...C,[n]:P}))}async function S(){if(!s.username.trim()){t(r("portalI18n.adminProfilePage.usernameRequired"));return}o(!0);try{const n=await D({username:s.username.trim(),language:s.language,theme_preference:s.theme_preference});i(n),s.language&&s.language!==u.language&&u.changeLanguage(s.language),l(r("portalI18n.adminProfilePage.profileSaved"))}catch(n){t(b(n,r))}finally{o(!1)}}async function T(n){const P=n.target.files?.[0];if(!P)return;if(P.size>5*1024*1024){t(r("portalI18n.adminProfilePage.photoTooLarge")),n.target.value="";return}if(!["image/jpeg","image/jpg","image/png","image/webp"].includes(P.type)){t(r("portalI18n.adminProfilePage.photoInvalidType")),n.target.value="";return}d(!0);try{const y=await U(P);i({...a,profile_photo_url:y.profile_photo_url}),l(r("portalI18n.adminProfilePage.photoUploaded"))}catch(y){t(b(y,r))}finally{d(!1),m.current&&(m.current.value="")}}async function k(){if(a?.profile_photo_url&&window.confirm(r("portalI18n.adminProfilePage.removePhotoConfirm")))try{await R(),i({...a,profile_photo_url:null}),l(r("portalI18n.adminProfilePage.photoRemoved"))}catch(n){t(b(n,r))}}return e.jsxs(w,{icon:_,title:r("portalI18n.adminProfilePage.identityPreferencesTitle"),description:r("portalI18n.adminProfilePage.identityPreferencesDescription"),children:[e.jsxs("div",{className:"flex items-start gap-5 mb-5 pb-5 border-b border-slate-200 dark:border-slate-800",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 grid place-items-center overflow-hidden flex-shrink-0",children:a?.profile_photo_url?e.jsx("img",{src:a.profile_photo_url,alt:"",className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-[18px] font-semibold text-slate-600",children:J(a
1)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14px] font-semibold text-slate-900",children:a?.email}),e.jsxs("div",{className:"admin-mono text-[11.5px] text-slate-500 mt-0.5",children:[r("portalI18n.adminProfilePage.accountIdLabel",{id:a?.id}),a?.last_login_at&&e.jsx("span",{children:r("portalI18n.adminProfilePage.lastLogin",{datetime:Q(a.last_login_at)})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsx("input",{type:"file",ref:m,accept:"image/jpeg,image/jpg,image/png,image/webp",onChange:T,className:"hidden"}),e.jsxs("button",{type:"button",onClick:()=>m.current?.click(),disabled:p,className:"px-2.5 py-1 border border-slate-200 dark:border-slate-800 rounded-md bg-white text-[12px] text-slate-700 hover:bg-slate-50 disabled:opacity-50 inline-flex items-center gap-1.5",children:[p?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(E,{className:"w-3.5 h-3.5"}),r(p?"portalI18n.adminProfilePage.uploadingPhoto":"portalI18n.adminProfilePage.uploadPhotoButton")]}),a?.profile_photo_url&&e.jsx("button",{type:"button",onClick:k,className:"p-1.5 rounded-md text-slate-500 hover:bg-rose-50 hover:text-rose-700",title:r("portalI18n.adminProfilePage.removePhotoTitle"),children:e.jsx(H,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-2",children:r("portalI18n.adminProfilePage.photoFormatHint")})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(h,{label:r("portalI18n.adminProfilePage.usernameLabel"),children:e.jsx("input",{type:"text",className:`${x} admin-mono`,value:s.username,onChange:n=>v("username",n.target.value),placeholder:"opsadmin"})}),e.jsx(h,{label:r("portalI18n.adminProfilePage.emailLabel"),hint:r("portalI18n.adminProfilePage.emailHint"),children:e.jsx("input",{type:"email",className:`${x} bg-slate-50 text-slate-500 cursor-not-allowed`,value:a?.email||"",readOnly:!0})}),e.jsx(h,{label:r("portalI18n.adminProfilePage.interfaceLanguageLabel"),children:e.jsx("select",{className:x,value:s.language,onChange:n=>v("language",n.target.value),children:$.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})}),e.jsx(h,{label:r("portalI18n.adminProfilePage.themeLabel"),children:e.jsx("select",{className:x,value:s.theme_preference,onChange:n=>v("theme_preference",n.target.value),children:z.map(n=>e.jsx("option",{value:n.value,children:n.labelKey?r("portalI18n.adminProfilePage."+n.labelKey):n.label},n.value))})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[e.jsxs("button",{type:"button",onClick:S,disabled:!I||f,className:"px-3 py-1.5 border border-slate-200 dark:border-slate-800 rounded-md bg-slate-900 text-white text-[12px] hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5",children:[f?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(B,{className:"w-3.5 h-3.5"}),r("portalI18n.adminProfilePage.saveChangesButton")]}),!I&&e.jsx("span",{className:"text-[11.5px] text-slate-400",children:r("portalI18n.adminProfilePage.noUnsavedChanges")})]})]})}function W({onError:a,onSuccess:i}){const{t}=N(),[l,r]=c.useState({current:"",next:"",confirm:""}),[u,m]=c.useState(!1);function s(o,p){r(d=>({...d,[o]:p}))}function g(){r({current:"",next:"",confirm:""})}async function f(o){if(o.preventDefault(),!l.current||!l.next||!l.confirm){a(t("portalI18n.adminProfilePage.passwordFieldsRequired"));return}if(l.next!==l.confirm){a(t("portalI18n.adminProfilePage.passwordMismatch"));return}if(l.next.length<8){a(t("portalI18n.adminProfilePage.passwordTooShort"));return}m(!0);try{await F(l.current,l.next,l.confirm),g(),i(t("portalI18n.adminProfilePage.passwordChanged"))}catch(p){a(b(p,t))}finally{m(!1)}}return e.jsx(w,{icon:M,title:t("portalI18n.adminProfilePage.changePasswordTitle"),description:t("portalI18n.adminProfilePage.changePasswordDescription"),children:e.jsxs("form",{onSubmit:f,className:"space-y-4 max-w-xl",children:[e.jsx(h,{label:t("portalI18n.adminProfilePage.currentPasswordLabel"),children:e.jsx("input",{type:"password",className:x,value:l.current,onChange:o=>s("current",o.target.value),autoComplete:"current-password",required:!0})}),e.jsx(h,{label:t("portalI18n.adminProfilePage.newPasswordLabel"),hint:t("portalI18n.adminProfilePage.newPasswordHint"),children:e.jsx("input",{type:"password",className:x,value:l.next,onChange:o=>s("next",o.target.value),autoComplete:"new-password",minLength:8,required:!0})}),e.jsx(h,{label:t("portalI18n.adminProfilePage.confirmNewPasswordLabel"),children:e.jsx("input",{type:"password",className:x,value:l.confirm,onChange:o=>
1s("confirm",o.target.value),autoComplete:"new-password",minLength:8,required:!0})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{type:"submit",disabled:u,className:"px-3 py-1.5 border border-slate-200 dark:border-slate-800 rounded-md bg-slate-900 text-white text-[12px] hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5",children:[u&&e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}),t("portalI18n.adminProfilePage.changePasswordButton")]})})]})})}function Fe(){const{t:a}=N(),[i,t]=c.useState(null),[l,r]=c.useState(!0),[u,m]=c.useState(""),[s,g]=c.useState("");async function f(){r(!0);try{const d=await L();t(d)}catch(d){m(b(d,a))}finally{r(!1)}}c.useEffect(()=>{f()},[]),c.useEffect(()=>{if(!s)return;const d=setTimeout(()=>g(""),3e3);return()=>clearTimeout(d)},[s]);function o(d){m(d),g(""),d&&setTimeout(()=>m(""),4e3)}function p(d){g(d),m("")}return e.jsxs("div",{className:"px-7 py-6 space-y-5 max-w-4xl",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-[22px] font-extrabold tracking-tight text-slate-900 inline-flex items-center gap-2",children:[e.jsx(_,{className:"w-5 h-5 text-primary"}),a("portalI18n.adminProfilePage.myProfileHeading")]}),e.jsx("p",{className:"text-[13px] text-slate-500 mt-1",children:a("portalI18n.adminProfilePage.myProfileSubtitle")})]}),u&&e.jsxs("div",{className:"px-4 py-3 border border-rose-200 bg-rose-50 text-[12px] text-rose-700 rounded-md inline-flex items-center gap-2",children:[e.jsx(q,{className:"w-4 h-4"}),u]}),s&&e.jsxs("div",{className:"px-4 py-3 border border-emerald-200 bg-emerald-50 text-[12px] text-emerald-700 rounded-md inline-flex items-center gap-2",children:[e.jsx(A,{className:"w-4 h-4"}),s]}),l&&!i&&e.jsxs("div",{className:"px-4 py-12 border border-slate-200 dark:border-slate-800 rounded-lg bg-white text-center text-slate-500 shadow-sm transition-shadow duration-200 hover:shadow-md",children:[e.jsx(j,{className:"w-5 h-5 inline-block mr-2 animate-spin"}),a("portalI18n.adminProfilePage.loadingProfile")]}),i&&e.jsxs(e.Fragment,{children:[e.jsx(V,{profile:i,onProfileChange:t,onError:o,onSuccess:p}),e.jsx(W,{onError:o,onSuccess:p}),e.jsx(w,{children:e.jsx(O,{})}),e.jsx(w,{children:e.jsx(K,{})})]})]})}export{Fe 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.