1import{a as e}from"./rolldown-runtime-BEU_UCik.js";import{n as t,r as s}from"./vendor-auth-DAuWozuU.js";import{t as a}from"./chunk-62JRHF6Z-D9puh-us.js";import{a as r,i as l,t as n}from"./vendor-query-Ct_3YD9H.js";import{n as i,r as o}from"./User-BzNI1SQp.js";import{t as c}from"./index.es-BTkwoywu.js";import{C as d,L as x,On as m,Sn as p,Tn as u,in as b,jt as h,ln as f,nn as y,ot as g,q as j,yn as v}from"./solid-CofuJNaU.js";import{t as k}from"./ScrollFadeContainer-Dtzq3qC9.js";import{n as N}from"./dist-C1LyjCEA.js";import{t as w}from"./chatService-CWLF64bN.js";import{i as C,r as _}from"./chartUtils-BgSJGHV9.js";import{t as A}from"./FieldError-7uZChftY.js";import"./FieldError-Ch_lZYe_.js";import{f as S,l as R,n as F,t as P}from"./validation-DxexLepU.js";import{n as E,t as q}from"./useVoices-Bb_wTls_.js";import{t as L}from"./ApiKeyModal-CMpANca-.js";var M=e(s()),K=R({given_name:F(100,{requiredMessage:"First name is required"}),family_name:F(100,{requiredMessage:"Last name is required"}),email:P({requiredMessage:"Email is required"}),nickname:F(100,{requiredMessage:"Username is required"})}),$=r(),D=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e??""));return t?Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])):null},I=e=>new Date(e).toISOString().slice(0,10),U=(e,t=(()=>{const e=new Date;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())})())=>{const s=new Map;for(const r of e){const e=D(r.date);null!==e&&I(e)===r.date&&s.set(r.date,r.count)}if(0===s.size)return[];const a=[];for(let r=89;r>=0;r--){const e=I(t-864e5*r);a.push({date:e,count:s.get(e)??0})}return a},T=e=>{const t=String(e??"");if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(t))return"";const s=t.slice(0,10),a=D(s);if(null===a||I(a)!==s)return"";const r=new Date(t).toISOString();return`${_(r)}, ${r.slice(11,16)} UTC`},V=({dailyCounts:e})=>{const t=U(e);if(!t.length)return(0,$.jsx)("div",{className:"p-6 text-center text-sm opacity-50 border border-dashed border-gray-500/20 rounded-lg",children:"No requests recorded yet."});const s=Math.max(...t.map(e=>e.count)),a=100/t.length;return(0,$.jsxs)("div",{children:[(0,$.jsx)("svg",{viewBox:"0 0 100 96",preserveAspectRatio:"none",className:"w-full h-24 rounded-md bg-black/5 dark:bg-black/30",role:"img","aria-label":`Daily request counts, ${_(t[0].date)} to ${_(t[t.length-1].date)}`,children:t.map((e,t)=>{const r=e.count?Math.max(e.count/s*88,2):0;return(0,$.jsx)("rect",{x:t*a+.15*a,y:96-r,width:.7*a,height:r,className:"fill-solar-600 dark:fill-trusty-blue",children:(0,$.jsx)("title",{children:`${_(e.date)} â ${e.count} request${1===e.count?"":"s"}`})},e.date)})}),(0,$.jsxs)("div",{className:"mt-1 flex justify-between text-[11px] opacity-50",children:[(0,$.jsx)("span",{children:_(t[0].date)}),(0,$.jsx)("span",{children:_(t[t.length-1].date)})]})]})},Y=({apiKey:e,onClose:t})=>{const s=(0,M.useRef)(null),a=(0,M.useRef)(null),r=(0,M.useRef)(t),[l,n]=(0,M.useState)(null),[i,d]=(0,M.useState)(!1);(0,M.useEffect)(()=>{r.current=t},[t]);const x=e.id;(0,M.useLayoutEffect)(()=>{const e=s.current;e.open||e.showModal();const t=()=>{r.current()};return e.addEventListener("close",t),()=>e.removeEventListener("close",t)},[]),(0,M.useEffect)(()=>{const e=new AbortController;return o.getPersonalApiKeyActivity(x,e.signal).then(e=>n(e)).catch(t=>{e.signal.aborted||(console.error("Failed to load API key activity:",t),d(!0))}),()=>e.abort()},[x]);return(0,$.jsx)("dialog",{ref:s,className:"w-full max-w-2xl p-0 bg-white dark:bg-[#0a1133] text-deep-space dark:text-white border border-solar-200 dark:border-trusty-blue/30 rounded-lg shadow-2xl overflow-hidden font-sans focus:outline-none backdrop:bg-black/70 backdrop:backdrop-blur-sm animate-in fade-in duration-200",onMouseDown:e=>{a.current=e.target},onClick:e=>{const t=s.current,r=a.current;if(a.current=null,null!==r&&r!==t)return;if(e.target!==t)return;if(0===e.clientX&&0===e.clientY)return;const l=t.getBoundingClientRect();l.top<=e.clientY&&e.clientY<=l.top+l.height&&l.left<=e.clientX&&e.clientX<=l.left+l.width||t.close()},"data-testid":"key-activity-dialog","aria-labelledby":"key-activity-modal-title",children:(0,$.jsxs)("div",{className:"w-full flex flex-col",children:[(0,$.jsx)("div",{className:"p-6 pb-2 flex items-baseline justify-between gap-3",children:(0,$.jsxs)("h2",{id:"key-activity-modal-title",className:"text-xl font-semibold min-w-0",children:["Activity"," ",(0,$.jsx)("span",{className:"font-mono text-base break-all opacity-70",children:e.name})]})}),(0,$.jsx)("div",{className:"p-6 pt-2 space-y-5",children:i?(0,$.jsxs)("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-md text-red-600 dark:text-red-400 text-sm flex items-center gap-2",children:[(0,$.jsx)(c,{icon:p}),(0,$.jsx)("span",{children:"Failed to load activity for this key."})]}):null===l?(0,$.jsxs)("div",{className:"py-10 text-center text-sm opacity-50",children:[(0,$.jsx)(c,{icon:f,spin:!0,className:"mr-2"}),"Loading activity..."]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,$.jsx)("p",{className:"text-xs font-space font-semibold uppercase tracking-wider opacity-60",children:"Requests, last 90 days"}),(0,$.jsxs)("p",{className:"text-sm",children:[(0,$.jsx)("span",{className:"font-bold font-space",children:(l.total_requests??
10).toLocaleString("en-US")})," ",(0,$.jsx)("span",{className:"opacity-60",children:"total all-time"})]})]}),(0,$.jsx)(V,{dailyCounts:l.daily_counts??[]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("p",{className:"mb-2 text-xs font-space font-semibold uppercase tracking-wider opacity-60",children:"Recent requests"}),0===(l.recent??[]).length?(0,$.jsx)("p",{className:"text-sm opacity-50",children:"No requests yet."}):(0,$.jsx)("div",{className:"max-h-56 overflow-auto rounded-lg border border-solar-200 dark:border-trusty-blue/20",children:(0,$.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,$.jsx)("thead",{className:"sticky top-0 bg-solar-50 dark:bg-[#060b28] text-[11px] uppercase tracking-widest opacity-60",children:(0,$.jsxs)("tr",{children:[(0,$.jsx)("th",{scope:"col",className:"px-3 py-2 font-semibold",children:"Time"}),(0,$.jsx)("th",{scope:"col",className:"px-3 py-2 font-semibold",children:"Method"}),(0,$.jsx)("th",{scope:"col",className:"px-3 py-2 font-semibold",children:"Path"}),(0,$.jsx)("th",{scope:"col",className:"px-3 py-2 font-semibold",children:"Status"})]})}),(0,$.jsx)("tbody",{className:"divide-y divide-solar-200/60 dark:divide-trusty-blue/10",children:l.recent.map((e,t)=>{return(0,$.jsxs)("tr",{children:[(0,$.jsx)("td",{className:"px-3 py-1.5 whitespace-nowrap opacity-70",children:T(e.timestamp)}),(0,$.jsx)("td",{className:"px-3 py-1.5 font-mono text-xs",children:e.method}),(0,$.jsx)("td",{className:"px-3 py-1.5 font-mono text-xs break-all",children:e.path}),(0,$.jsx)("td",{className:"px-3 py-1.5 font-mono text-xs font-bold "+(s=e.status_code,"number"!=typeof s?"text-gray-500 dark:text-gray-400":s>=500?"text-red-600 dark:text-red-400":s>=400?"text-amber-600 dark:text-amber-400":"text-green-600 dark:text-green-400"),children:e.status_code??"â"})]},`${e.timestamp}-${t}`);var s})})]})})]})]})}),(0,$.jsx)("div",{className:"p-4 bg-solar-50 dark:bg-white/5 border-t border-solar-200 dark:border-white/10 flex justify-end",children:(0,$.jsx)("button",{type:"button",onClick:()=>s.current?.close(),className:"px-6 py-2 bg-solar-600 dark:bg-blue-600 border border-solar-700 dark:border-trusty-blue/50 rounded-lg text-xs text-white font-bold uppercase tracking-widest hover:bg-solar-700 dark:hover:bg-trusty-blue transition",children:"Close"})})]})})},X=({apiKey:e,onClose:t,onConfirm:s,isRevoking:a})=>{const r=(0,M.useRef)(null),l=(0,M.useRef)(null),n=(0,M.useRef)(t),i=(0,M.useRef)(a);(0,M.useEffect)(()=>{n.current=t,i.current=a},[t,a]);const o=null!==e;if((0,M.useLayoutEffect)(()=>{const e=r.current;if(!e||!o)return;e.open||e.showModal();const t=()=>{n.current()},s=e=>{i.current&&e.preventDefault()};return e.addEventListener("close",t),e.addEventListener("cancel",s),()=>{e.removeEventListener("close",t),e.removeEventListener("cancel",s)}},[o]),!o)return null;return(0,$.jsx)("dialog",{ref:r,className:"w-full max-w-md p-0 bg-white dark:bg-[#0a1133] text-deep-space dark:text-white border border-solar-200 dark:border-trusty-blue/30 rounded-lg shadow-2xl overflow-hidden font-sans focus:outline-none backdrop:bg-black/70 backdrop:backdrop-blur-sm animate-in fade-in duration-200",onMouseDown:e=>{l.current=e.target},onClick:e=>{const t=r.current;if(!t||a)return;const s=l.current;if(l.current=null,null!==s&&s!==t)return;if(e.target!==t)return;if(0===e.clientX&&0===e.clientY)return;const n=t.getBoundingClientRect();n.top<=e.clientY&&e.clientY<=n.top+n.height&&n.left<=e.clientX&&e.clientX<=n.left+n.width||t.close()},"data-testid":"revoke-key-dialog","aria-labelledby":"revoke-key-modal-title",children:(0,$.jsxs)("div",{className:"w-full flex flex-col",children:[(0,$.jsx)("div",{className:"p-6 pb-2",children:(0,$.jsx)("h2",{id:"revoke-key-modal-title",className:"text-xl font-semibold",children:"Revoke API key"})}),(0,$.jsx)("div",{className:"p-6 pt-2",children:(0,$.jsxs)("p",{className:"text-sm text-deep-space/80 dark:text-white/80 leading-relaxed",children:["Are you sure you want to revoke"," ",(0,$.jsx)("span",{className:"font-bold font-mono break-all",children:e.name}),"? This action ",(0,$.jsx)("span",{className:"font-bold",children:"cannot be undone"})," ","and any applications using this key will immediately lose access."]})}),(0,$.jsxs)("div",{className:"p-4 bg-solar-50 dark:bg-white/5 border-t border-solar-200 dark:border-white/10 flex justify-end gap-3",children:[(0,$.jsx)("button",{type:"button",onClick:()=>r.current?.close(),disabled:a,className:"px-4 py-2 bg-transparent border border-solar-300 dark:border-trusty-blue/50 rounded-lg text-xs font-bold uppercase tracking-widest text-deep-space dark:text-white hover:bg-deep-space hover:text-white transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),(0,$.jsxs)("button",{type:"button",onClick:s,disabled:a,className:"px-6 py-2 bg-red-600 border border-red-700 rounded-lg text-xs text-white font-bold uppercase tracking-widest hover:bg-red-700 transition disabled:opacity-70 disabled:cursor-not-allowed flex items-center gap-2",children:[a&&(0,$.jsx)(c,{icon:f,spin:!0,className:"text-xs"}),(0,$.jsx)("span",{children:a?"Revoking...":"Revoke key"})]})]})]})})},B=[{id:"all",label:"All"},{id:"active",label:"Active"},{id:"revoked",label:"Revoked"}],Q=({defaultKeyName:e=""})=>{const[t,s]=(0,M.useState)(null),[r,l]=(0,M.useState)(!1),[n,i]=(0,M.useState)("all"),[m,u]=(0,M.useState)(null),[b,f]=(0,M.useState)(!1),[y,g]=(0,M.useState)(null),[j,w]=(0,M.useState)(0),_=(0,M.useCallback)(()=>{l(!1),w(e=>e+1)},[]);(0,M.useEffect)(()=>{const e=new AbortController;return o.listPersonalApiKeys(e.signal).then(e=>s(e)).catch(t=>{e.signal.aborted||(console.error("Failed to load API keys:",t),l(!0))}),()=>e.abort()},[j]);const A=null!==t,S=t??[],R=S.filter(e=>e.is_active).length,F=A&&R>=10,P=S.filter(e=>"all"===n||("active"===n?e.is_active:!e.is_active)),E={all:S.length,active:R,revoked:S.length-R};return(0,$.jsxs)("section",{className:"page-section-3 p-6 md:p-8","data-testid":"api-keys-section",children:[(0,$.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-1.5",children:[(0,$.jsxs)("h3",{className:"text-sm font-space font-bold uppercase tracking-wider opacity-60 flex items-center gap-2",children:[(0,$.jsx)(c,{icon:h,className:"text-watermelon-500"}),"API Keys"]}),(0,$.jsx)(L,{triggerLabel:"Generate API Key",disabled:!A&&!r||F,triggerTitle:F?"Active key limit reached (10). Revoke a key to create another.":void 0,title:"Create personal API key",description:(0,$.jsxs)($.Fragment,{children:["This API key is tied to your user account â requests made with it act on your behalf. You can hold up to ",10," active keys."]}),generateKey:e=>o.createPersonalApiKey(e),withNameField:!0,defaultName:e,onGenerateSuccess:_})]}),(0,$.jsxs)("p",{className:"text-xs opacity-50 mb-4",children:["Keys can't be viewed after creation â if you've lost yours, generate a new one.",A&&(0,$.jsxs)("span",{"data-testid":"active-key-count",children:[" ",R," of ",10," active keys in use."]})]}
1),r?(0,$.jsxs)("div",{className:"p-4 bg-red-500/10 border border-red-500/20 rounded-lg text-red-600 dark:text-red-400 text-sm flex items-center gap-2",children:[(0,$.jsx)(c,{icon:p}),(0,$.jsx)("span",{children:"Failed to load your API keys."}),(0,$.jsx)("button",{type:"button",onClick:_,className:"ml-auto underline font-semibold hover:opacity-80",children:"Retry"})]}):A?0===t.length?(0,$.jsx)("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400 border border-dashed border-gray-500/20 rounded-xl",children:"Generate an API key to get started."}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("div",{className:"flex items-center gap-2 mb-3",role:"group","aria-label":"Filter keys by status",children:B.map(({id:e,label:t})=>(0,$.jsxs)("button",{type:"button","aria-pressed":n===e,onClick:()=>i(e),className:n===e?"px-3 py-1.5 rounded-full text-xs font-bold font-space transition-colors bg-solar-600 dark:bg-trusty-blue text-white":"px-3 py-1.5 rounded-full text-xs font-bold font-space transition-colors bg-black/5 dark:bg-white/10 text-deep-space/70 dark:text-white/70 hover:bg-black/10 dark:hover:bg-white/20",children:[t," (",E[e],")"]},e))}),0===P.length?(0,$.jsxs)("p",{className:"p-6 text-center text-sm opacity-50",children:["No ",n," keys."]}):(0,$.jsx)("div",{className:"rounded-lg border border-solar-200 dark:border-trusty-blue/20 overflow-hidden",children:(0,$.jsx)(k,{className:"relative w-full overflow-x-auto hide-scrollbar",children:(0,$.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,$.jsx)("thead",{className:"bg-solar-50 dark:bg-[#060b28] text-[11px] uppercase tracking-widest opacity-60",children:(0,$.jsxs)("tr",{children:[(0,$.jsx)("th",{scope:"col",className:"px-4 py-2.5 font-semibold",children:"Name"}),(0,$.jsx)("th",{scope:"col",className:"px-4 py-2.5 font-semibold",children:"Key"}),(0,$.jsx)("th",{scope:"col",className:"px-4 py-2.5 font-semibold",children:"Status"}),(0,$.jsx)("th",{scope:"col",className:"hidden md:table-cell px-4 py-2.5 font-semibold",children:"Created"}),(0,$.jsx)("th",{scope:"col",className:"hidden md:table-cell px-4 py-2.5 font-semibold",children:"Last used"}),(0,$.jsx)("th",{scope:"col",className:"hidden md:table-cell px-4 py-2.5 font-semibold text-right",children:"Requests"}),(0,$.jsx)("th",{scope:"col",className:"px-4 py-2.5",children:(0,$.jsx)("span",{className:"sr-only",children:"Actions"})})]})}),(0,$.jsx)("tbody",{className:"divide-y divide-solar-200/60 dark:divide-trusty-blue/10",children:P.map(e=>(0,$.jsxs)("tr",{"data-testid":"api-key-row",className:e.is_active?"":"opacity-60",children:[(0,$.jsx)("td",{className:"px-4 py-3 font-semibold max-w-[220px] truncate",children:e.name}),(0,$.jsx)("td",{className:"px-4 py-3 font-mono text-xs whitespace-nowrap text-deep-space/70 dark:text-white/70",children:e.prefix?`${e.prefix}â¦`:"â¢â¢â¢â¢â¢â¢â¢â¢"}),(0,$.jsx)("td",{className:"px-4 py-3",children:e.is_active?(0,$.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold font-space bg-green-500/10 border border-green-500/30 text-green-600 dark:text-green-400",children:"Active"}):(0,$.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold font-space bg-gray-500/10 border border-gray-500/30 text-gray-600 dark:text-gray-400",children:"Revoked"})}),(0,$.jsx)("td",{className:"hidden md:table-cell px-4 py-3 whitespace-nowrap opacity-70",children:C(e.created_at)||"N/A"}),(0,$.jsx)("td",{className:"hidden md:table-cell px-4 py-3 whitespace-nowrap opacity-70",children:C(e.last_used_at)||"Never"}),(0,$.jsx)("td",{className:"hidden md:table-cell px-4 py-3 text-right font-mono text-xs opacity-70",children:(e.usage_count??0).toLocaleString("en-US")}),(0,$.jsx)("td",{className:"px-4 py-3",children:(0,$.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,$.jsxs)("button",{type:"button",onClick:()=>g(e),title:"View activity",className:"w-8 h-8 flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-solar-600 dark:hover:text-trusty-blue hover:bg-solar-600/10 dark:hover:bg-trusty-blue/10 rounded-full transition-all",children:[(0,$.jsx)(c,{icon:x}),(0,$.jsxs)("span",{className:"sr-only",children:["View activity for ",e.name]})]}),e.is_active&&(0,$.jsxs)("button",{type:"button",onClick:()=>u(e),title:"Revoke key",className:"w-8 h-8 flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-red-500 hover:bg-red-500/10 rounded-full transition-all",children:[(0,$.jsx)(c,{icon:v}),(0,$.jsxs)("span",{className:"sr-only",children:["Revoke ",e.name]})]})]})})]},e.id))})]})})})]}):(0,$.jsx)("div",{className:"flex items-center justify-center py-8 text-solar-600/50 dark:text-trusty-blue/50 font-bold uppercase tracking-widest animate-pulse",children:"loading api keys..."}),(0,$.jsx)("div",{className:"mt-4 flex justify-end",children:(0,$.jsxs)(a,{to:"/document-center/api-docs",className:"text-sm font-medium text-solar-600 dar
1k:text-trusty-blue hover:text-solar-700 dark:hover:text-trusty-blue/80 transition-colors flex items-center gap-2",children:[(0,$.jsx)(c,{icon:d}),"View API Documentation"]})}),(0,$.jsx)(X,{apiKey:m,onClose:()=>u(null),onConfirm:async()=>{f(!0);try{await o.revokePersonalApiKey(m.id),u(null),_()}catch(e){console.error("Failed to revoke API key:",e),N.error("Failed to revoke API key. Please try again.")}finally{f(!1)}},isRevoking:b}),y&&(0,$.jsx)(Y,{apiKey:y,onClose:()=>g(null)})]})};function G(){const{voices:e,selected:t,defaultVoice:s,loaded:a}=E(),r=l(),i=n({mutationFn:e=>w.setVoicePreference(e),onMutate:async e=>{await r.cancelQueries({queryKey:q});const t=r.getQueryData(q);return r.setQueryData(q,t=>t?{...t,selected:e}:t),{previous:t}},onError:(e,t,s)=>{s&&r.setQueryData(q,s.previous)}});if(!a||0===e.length)return null;const o=e.find(e=>e.voice_id===s)?.label,d=t&&!e.some(e=>e.voice_id===t)?t:null;return(0,$.jsxs)("div",{className:"page-section-3 p-6",children:[(0,$.jsxs)("h3",{className:"text-sm font-space font-bold uppercase tracking-wider opacity-60 mb-4 flex items-center gap-2",children:[(0,$.jsx)(c,{icon:m,className:"text-solar-600 dark:text-trusty-blue"}),"Chat Voice"]}),(0,$.jsx)("p",{className:"text-[11px] uppercase tracking-widest opacity-40 mb-1.5",children:"Answer playback voice"}),(0,$.jsxs)("select",{"aria-label":"Chat voice",value:t,disabled:i.isPending,onChange:e=>i.mutate(e.target.value),className:"w-full text-sm border border-solar-200 dark:border-trusty-blue/20 rounded-lg bg-white disabled:opacity-50",children:[(0,$.jsxs)("option",{value:"",children:["Default",o?` (${o})`:""]}),e.map(e=>(0,$.jsxs)("option",{value:e.voice_id,children:[e.label," (",e.gender,")"]},e.voice_id)),d&&(0,$.jsxs)("option",{value:d,children:[d," (no longer offered)"]})]}),(0,$.jsxs)("div",{className:"mt-2 min-h-4",role:"status","data-testid":"voice-save-state",children:[i.isSuccess&&(0,$.jsx)("span",{className:"text-xs text-green-700 dark:text-green-400 font-semibold",children:"Saved."}),i.isError&&(0,$.jsx)(A,{error:"Could not save your voice â please try again."})]})]})}var O="mb-2 text-xs font-space font-semibold tracking-[0.2em] uppercase text-deep-space/60 dark:text-white/60",J=({name:e,label:t,type:s="text",value:a,onChange:r,error:l,labelExtra:n})=>{const i=`${e}-error`;return(0,$.jsxs)("div",{children:[(0,$.jsxs)("label",{htmlFor:e,className:n?`${O} flex justify-between items-center`:`block ${O}`,children:[t,n]}),(0,$.jsx)("input",{type:s,id:e,name:e,value:a,onChange:r,className:"profile-field transition-colors","aria-invalid":!!l,"aria-describedby":l?i:void 0}),(0,$.jsx)(A,{id:i,error:l})]})},Z=()=>{const{user:e,isLoading:s}=t(),{is_internal:r,is_internal_admin:l,genti_role:n,isLoading:o}=i(),[d,x]=(0,M.useState)({given_name:"",family_name:"",email:"",nickname:""}),{errors:m,validate:p,clearField:h}=S(K);(0,M.useEffect)(()=>{e&&x({given_name:e.given_name||"",family_name:e.family_name||"",email:e.email||"",nickname:e.nickname||""})},[e]);const f=e=>{const{name:t,value:s}=e.target;x(e=>({...e,[t]:s})),h(t)},v=l?"Admin":r?"Internal":n||"Member";return s||o?(0,$.jsx)("div",{className:"page-base profile-page mx-auto p-4",children:(0,$.jsx)("div",{className:"page-section-3 animate-pulse p-12 text-center",children:(0,$.jsx)("p",{className:"text-lg opacity-50",children:"Loading profile..."})})}):(0,$.jsxs)("div",{className:"page-base profile-page",children:[(0,$.jsx)("h1",{className:"text-2xl md:text-3xl font-space font-bold mb-6 text-deep-space dark:text-white",children:"Profile Settings"}),(0,$.jsxs)("div",{className:"grid lg:grid-cols-[1fr_320px] gap-4 lg:gap-6 items-start",children:[(0,$.jsxs)("div",{className:"page-section-3 p-6 md:p-8",children:[(0,$.jsxs)("div",{className:"flex flex-col items-center mb-8",children:[e&&(0,$.jsx)("div",{className:"relative mb-4",children:(0,$.jsx)("div",{className:"w-20 h-20 rounded-full p-[3px] bg-gradient-to-br from-solar-500 via-dwarf-500 to-sunspot-500 dark:from-trusty-blue dark:via-[#F814BF] dark:to-watermelon-500",children:(0,$.jsx)("img",{className:"w-full h-full rounded-full object-cover border-2 border-white dark:border-[#050a24]",src:e.picture,alt:e.name})})}),(0,$.jsxs)("h2",{className:"text-lg font-space font-bold text-deep-space dark:text-white",children:[d.given_name," ",d.family_name]}),(0,$.jsxs)("p",{className:"text-sm opacity-50",children:["@",d.nickname]}),(0,$.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 text-sm opacity-60",children:[(0,$.jsx)("span",{children:d.email}),e?.email_verified&&(0,$.jsx)(c,{icon:j,className:"text-green-500"})]})]}),(0,$.jsxs)("form",{className:"grid md:grid-cols-2 gap-4",onSubmit:e=>{e.preventDefault(),p(d)},children:[(0,$.jsx)(J,{name:"given_name",label:"First Name",value:d.given_name,onChange:f,error:m.given_name}),(0,$.jsx)(J,{name:"family_name",label:"Last Name",value:d.family_name,onChange:f,error:m.family_name}),(0,$.jsx)(J,{name:"nickname",label:"Username",value:d.nickname,onChange:f,error:m.nickname}),(0,$.jsx)(J,{name:"email",label:"Email",type:"email",value:d.email,onChange:f,error:m.email,labelExtra:e?.email_verified?(0,$.jsxs)("span",{className:"text-green-500 normal-case tracking-normal flex items-center gap-1",children:[(0,$.jsx)(c,{icon:j})," Verified"]}):(0,$.jsx)("button",{type:"button",className:"text-xs underline normal-case tracking-normal text-watermelon-500",children:"Verify email"})}),(0,$.jsx)("div",{className:"md:col-span-full mt-2 flex justify-end",children:(0,$.jsxs)("button",{type:"submit",className:"px-6 py-2 bg-solar-600 dar
1k:bg-blue-600 border border-solar-700 dark:border-trusty-blue/50 rounded-lg text-xs text-white font-bold uppercase tracking-widest hover:bg-solar-700 dark:hover:bg-trusty-blue transition shadow-[0_0_15px_rgba(234,88,12,0.3)] dark:shadow-[0_0_15px_rgba(59,130,246,0.4)] flex items-center gap-2",children:[(0,$.jsx)(c,{icon:y}),(0,$.jsx)("span",{children:"Update Profile"})]})})]})]}),(0,$.jsxs)("div",{className:"flex flex-col gap-4 md:gap-6",children:[(0,$.jsxs)("div",{className:"page-section-3 p-6",children:[(0,$.jsxs)("h3",{className:"text-sm font-space font-bold uppercase tracking-wider opacity-60 mb-4 flex items-center gap-2",children:[(0,$.jsx)(c,{icon:b,className:"text-solar-600 dark:text-trusty-blue"}),"Account"]}),(0,$.jsxs)("div",{className:"mb-4",children:[(0,$.jsx)("p",{className:"text-[11px] uppercase tracking-widest opacity-40 mb-1.5",children:"Role"}),(0,$.jsxs)("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-solar-100 dark:bg-trusty-blue/20 border border-solar-200 dark:border-trusty-blue/30",children:[(0,$.jsx)(c,{icon:u,className:"text-solar-600 dark:text-trusty-blue text-xs"}),(0,$.jsx)("span",{className:"text-sm font-semibold font-space",children:v})]})]}),(0,$.jsxs)("div",{children:[(0,$.jsx)("p",{className:"text-[11px] uppercase tracking-widest opacity-40 mb-1.5",children:"Subscription"}),(0,$.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,$.jsxs)(a,{to:"/subscription",className:"inline-flex items-center gap-2 text-sm hover:text-solar-600 dark:hover:text-watermelon-400 transition-colors",children:[(0,$.jsx)(c,{icon:g,className:"text-xs opacity-50"}),"Manage subscription"]}),"Client"===n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("button",{type:"button",className:"inline-flex items-center gap-2 text-sm opacity-60 hover:opacity-100 hover:text-watermelon-500 transition-all text-left",children:"Pause subscription"}),(0,$.jsx)("button",{type:"button",className:"inline-flex items-center gap-2 text-sm opacity-60 hover:opacity-100 hover:text-watermelon-500 transition-all text-left",children:"Cancel subscription"})]})]})]})]}),(0,$.jsx)(G,{})]}),(0,$.jsx)("div",{className:"min-w-0 lg:col-span-full",children:(0,$.jsx)(Q,{defaultKeyName:d.nickname?`${d.nickname}-personal-api-key`:""})})]})]})};export{Z 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.