import{b2 as A,r as h,b as M,j as e,Q as c,g as b,o as O,bd as a,x as S,cs as P,b5 as _,af as T,A as F,z as N,aY as Q,cK as z,g4 as G,fY as V,a$ as $,aH as q,gc as I,cu as H,bq as K,bx as B,aU as U,aZ as W,cj as Z}from"./index-ea7817a2.js";import{u as J}from"./useProjectId-fe5627bf.js";import{s as R}from"./styles-5630c171.js";import{s as Y,M as r,f as X,a as ee,b as se,c as v}from"./utils-cf9ea4a1.js";const D=["name","latest version","author","deployed versions","description",""],te=({isFiltered:x,data:d,deployments:j})=>{const m=A(),o=h.useMemo(()=>d.length>0||x,[x,d]),l=h.useCallback(i=>()=>{m(M.models.overview,{mId:i})},[m]),f=h.useCallback((i,p)=>()=>{m(M.models.versionView,{mId:i,vId:p})},[m]);return e.jsxs(c,{flexDirection:"column",flex:"1 1 100%",children:[o&&e.jsx(c,{mb:"12px",justifyContent:"space-between",alignItems:"center",children:e.jsxs(c,{alignItems:"center",children:[e.jsx(b,{primary:!0,children:d.length}),e.jsx(b,{px:"5px",children:"models"})]})}),e.jsx(O,{children:e.jsx(a,{standalone:!0,legend:D,middleColumn:D.indexOf("description"),children:d.map(i=>{const{id:p,name:s,version:t,userFullName:C,description:L}=i,[w,k]=C.split(" ");return e.jsxs(a.Row,{children:[e.jsx(a.Cell,{children:e.jsx(S,{bold:!0,sx:{cursor:"pointer",":hover":{textDecoration:"underline"}},onClick:l(s),children:s})}),e.jsx(a.Cell,{children:e.jsx(b,{primary:!0,onClick:f(s,t.toString()),sx:{textDecoration:"underline",cursor:"pointer"},children:t})}),e.jsx(a.Cell,{children:e.jsx(O,{width:"32px",ml:"auto",mr:"auto",children:e.jsx(P,{firstName:w,lastName:k})})}),e.jsx(a.Cell,{children:e.jsx(c,{alignItems:"center",color:"labels.green",children:_.uniq(j.filter(n=>n.modelName===s).map(n=>n.modelVersion)).sort().map(n=>e.jsx(b,{mr:"4px",sx:{textDecoration:"underline",cursor:"pointer"},primary:!0,onClick:f(s,n.toString()),children:n},n))})}),e.jsx(a.Cell,{children:e.jsx(S,{gray:!0,children:L??"-"})}),e.jsx(a.Cell,{children:e.jsx(T,{mainText:"Overview",children:e.jsx(F,{icon:N.more_zoom,onClick:l(s)})})})]},p)})})})]})},ie=()=>{Q(W.mregistry);const[x,d]=h.useState(""),[j,m]=h.useState([Object.keys(Y)[1]]),[o,l]=h.useState(r.ALL),{data:{firstname:f,lastname:i}={}}=z(),p=J(),{data:s}=G({projectId:p,status:"Running"}),{data:t,isFetching:C,isLoading:L,refetch:w}=V(p,{pollingInterval:5e3,refetchOnFocus:!0}),k=({target:y})=>{d(y.value)},n=y=>()=>{y==="deployed"?o===r.DEPLOYED_ONLY?l(r.ALL):l(r.DEPLOYED_ONLY):o===r.MY_ONLY?l(r.ALL):l(r.MY_ONLY)},u=h.useMemo(()=>{const[y]=j;return!t||!s?[]:X(ee(se(v(t),x),y),o,{username:`${f} ${i}`.toLowerCase()},s.all)},[t,j,x,o,f,i,s]),g=!!t&&v(t).length!==u.length,E=()=>{g?(d(""),l(r.ALL)):window.open("https://docs.hopsworks.ai/machine-learning-api/".concat(Z.docsVersion,"/"),"_blank")};return!u.length&&L?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(c,{alignItems:"center",mb:"20px",children:[e.jsx(q,{variant:"white",placeholder:"Find a model by name...",value:x,labelProps:{flexGrow:1,mr:"8px"},onChange:k}),e.jsxs(c,{sx:R.modelFiltersLabel,children:[e.jsx(I,{mr:"8px",width:"105px",sx:{textAlign:"center",backgroundColor:"white"},style:{whiteSpace:"nowrap"},checked:o===r.DEPLOYED_ONLY,onChange:n("deployed"),children:"deployed only"}),e.jsx(I,{width:"125px",sx:{textAlign:"center",backgroundColor:"white"},checked:o===r.MY_ONLY,onChange:n("own"),children:"my models only"})]}),e.jsx(H,{ml:"20px",mr:"20px",mt:"0",mb:"0",width:"1px",sx:{backgroundColor:"grayShade2",height:"32px"}}),e.jsx(K,{width:"150px",variant:"white",listWidth:"100%",placeholder:"sort by",value:j,options:Object.keys(Y),onChange:m}),e.jsx(c,{ml:"8px",sx:C?R.loading:{},children:e.jsx(F,{type:"button",intent:"primary",tooltip:"Refresh models",icon:C?N.loading:N.refresh,onClickIcon:w})})]}),!u.length&&e.jsxs(c,{flex:"1 1 100%",flexDirection:"column",justifyContent:g?"flex-start":"center",alignItems:"center",height:"100%",mt:g?"40px":0,mb:"105px",children:[e.jsx(b,{fontFamily:"Inter",fontSize:"18px",mb:"20px",sx:{color:"black"},children:g?"No models match the filters":"No models"}),e.jsx(B,{fontSize:"12px",fontFamily:"Inter",mb:"20px",sx:{color:"black"},children:g?"Change or reset filters":"Register a model using the Hopsworks Python library"}),e.jsx(U,{intent:"primary",onClick:E,children:g?"Reset filters":"See documentation ↗"})]}),!!u.length&&s&&e.jsx(te,{data:u,deployments:s.all,isFiltered:!!t&&v(t).length!==u.length})]})};export{ie as default};
