import{i as e,o as t,r as n}from"./button-DJ30HgDO.js";import{n as r,s as i}from"./chunk-EPOLDU6W-BGm2xlSj.js";import{n as a}from"./use-runtime-config-CkwqDzno.js";import"./use-api-CtLXpHJw.js";import{n as o}from"./use-user-D7emtooi.js";import"./toast-context-val-Z-lwvYkJ.js";import"./gateway-service-BwyflEJR.js";import{i as s,n as c,r as l,t as u}from"./page-status-CNIWXN7q.js";import{t as d}from"./page-container-DN56Bi3o.js";import"./use-toast-BWmLhWRD.js";import"./input-BbiN5lj4.js";import"./entity-service-KdPsD3WQ.js";import{a as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./use-user-gateway-model-permissions-C1ILLuXb.js";var y=t(e(),1),b=t(n(),1);const x=({currentUser:e})=>{let t=`flex flex-row items-center min-h-(--table-row-height) px-1 hover:bg-table-row-hover dark:hover:bg-table-row-hover transition-colors duration-150 border-b border-btn-secondary-border dark:border-btn-secondary-border-dark`,n=`w-1/3 font-semibold text-text-primary dark:text-text-primary-dark`;return(0,b.jsx)(`div`,{className:`flex flex-col text-sm`,children:(0,b.jsxs)(`div`,{className:`divide-y divide-btn-secondary-border dark:divide-btn-secondary-border-dark`,children:[[{label:`Display Name`,value:e.display_name},{label:`Username`,value:e.username}].map(({label:e,value:r})=>(0,b.jsxs)(`div`,{className:t,children:[(0,b.jsx)(`div`,{className:n,children:e}),(0,b.jsx)(`div`,{className:`w-2/3 text-ui-text dark:text-ui-text-dark font-mono break-all`,children:r||`N/A`})]},e)),(0,b.jsxs)(`div`,{className:t,children:[(0,b.jsx)(`div`,{className:n,children:`Groups`}),(0,b.jsx)(`div`,{className:`w-2/3`,children:e.groups&&e.groups.length>0?(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2 py-0.5`,children:e.groups.map(e=>(0,b.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-btn-secondary-bg dark:bg-btn-secondary-bg-dark text-text-primary dark:text-text-primary-dark border border-btn-secondary-border dark:border-btn-secondary-border-dark`,children:e.group_name},e.id))}):(0,b.jsx)(`p`,{className:`italic text-text-primary dark:text-text-primary-dark opacity-60`,children:`This user is not a member of any groups.`})})]}),e.is_admin&&(0,b.jsx)(`div`,{className:`p-1 mt-2 min-h-(--table-row-height) flex items-center`,children:(0,b.jsx)(`p`,{className:`text-logo text-base font-semibold`,children:`You have administrator privileges. Additional management options are available to you.`})})]})})},S=()=>{let{tab:e=`info`}=i(),{currentUser:t,isLoading:n,error:S}=o(),{gen_ai_gateway_enabled:C}=a(),w=t?.username||null,T=h({username:w}),E=f({username:w}),D=p({username:w}),O=g({username:w}),k=m({username:w}),A=v({username:w}),j={info:null,experiments:T,models:E,prompts:D,"ai-endpoints":O,"ai-secrets":k,"ai-models":A}[e]||null,{searchTerm:M,submittedTerm:N,handleInputChange:P,handleSearchSubmit:F,handleClearSearch:I}=s();(0,y.useEffect)(()=>{I()},[e,I]);let L=[{id:`info`,label:`Info`},{id:`experiments`,label:`Experiments`},{id:`prompts`,label:`Prompts`},{id:`models`,label:`Models`},...C?[{id:`ai-endpoints`,label:`AI\xA0Endpoints`},{id:`ai-secrets`,label:`AI\xA0Secrets`},{id:`ai-models`,label:`AI\xA0Models`}]:[]],R=[{header:`Name`,render:e=>(0,b.jsx)(`span`,{className:`truncate block`,title:e.name,children:e.name})},{header:`Permission`,render:e=>e.permission},{header:`Kind`,render:e=>e.kind}],z=n||(j?.isLoading??!1),B=S||(j?.error??null),V=j?.permissions.filter(e=>e.name.toLowerCase().includes(N.toLowerCase()))??[];return(0,b.jsxs)(d,{title:`User Page`,children:[t&&(0,b.jsx)(_,{username:t.username,passwordExpiration:t.password_expiration}),(0,b.jsx)(`div`,{className:`flex space-x-2 justify-between items-center border-b border-btn-secondary-border dark:border-btn-secondary-border-dark mb-3 min-w-0`,children:(0,b.jsx)(`div`,{className:`flex space-x-2 overflow-x-auto whitespace-nowrap scrollbar-hide`,children:L.map(t=>(0,b.jsx)(r,{to:`/user/${t.id}`,className:`py-2 px-4 border-b-2 font-medium text-sm transition-colors duration-200 shrink-0 ${e===t.id?`border-btn-primary text-btn-primary dark:border-btn-primary-dark dark:text-btn-primary-dark`:`border-transparent text-text-primary dark:text-text-primary-dark hover:text-text-primary-hover dark:hover:text-text-primary-hover-dark hover:border-btn-secondary-border dark:hover:border-btn-secondary-border-dark`}`,children:t.label},t.id))})}),(0,b.jsx)(u,{isLoading:z&&(!t||e!==`info`&&!j?.permissions),loadingText:`Loading information...`,error:B,onRetry:e===`info`?void 0:j?.refresh}),!z&&!B&&t&&(0,b.jsxs)(b.Fragment,{children:[e===`info`&&(0,b.jsx)(x,{currentUser:t}),e!==`info`&&j&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`mb-2`,children:(0,b.jsx)(l,{value:M,onInputChange:P,onSubmit:F,onClear:I,placeholder:`Search ${e}...`})}),(0,b.jsx)(c,{data:V,columns:R,searchTerm:N})]})]})]})};var C=S;export{S as UserPage,C as default};