import{b1 as _,r as h,e as O,j as e,a as c,f as C,O as M,bc as a,c as S,cr as P,b4 as T,ae as A,V as Y,Z as N,aX as G,cH as V,f$ as Q,fS as z,a_ as $,aG as B,g7 as D,ct as H,bp as X,bw as Z,aT as q,aY as K,ci as W}from"./index-d6499a22.js";import{u as J}from"./useProjectId-6028b5ae.js";import{s as F}from"./styles-2de7fa0b.js";import{s as I,M as r,f as U,a as ee,b as se,c as v}from"./utils-14352779.js";const R=["name","latest version","author","deployed versions","description",""],te=({isFiltered:x,data:d,deployments:j})=>{const m=_(),o=h.useMemo(()=>d.length>0||x,[x,d]),l=h.useCallback(i=>()=>{m(O.models.overview,{mId:i})},[m]),f=h.useCallback((i,p)=>()=>{m(O.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(C,{primary:!0,children:d.length}),e.jsx(C,{px:"5px",children:"models"})]})}),e.jsx(M,{children:e.jsx(a,{standalone:!0,legend:R,middleColumn:R.indexOf("description"),children:d.map(i=>{const{id:p,name:s,version:t,userFullName:b,description:L}=i,[w,k]=b.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(C,{primary:!0,onClick:f(s,t.toString()),sx:{textDecoration:"underline",cursor:"pointer"},children:t})}),e.jsx(a.Cell,{children:e.jsx(M,{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:T.uniq(j.filter(n=>n.modelName===s).map(n=>n.modelVersion)).sort().map(n=>e.jsx(C,{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(A,{mainText:"Overview",children:e.jsx(Y,{icon:N.more_zoom,onClick:l(s)})})})]},p)})})})]})},ie=()=>{G(K.mregistry);const[x,d]=h.useState(""),[j,m]=h.useState([Object.keys(I)[1]]),[o,l]=h.useState(r.ALL),{data:{firstname:f,lastname:i}={}}=V(),p=J(),{data:s}=Q({projectId:p,status:"Running"}),{data:t,isFetching:b,isLoading:L,refetch:w}=z(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?[]:U(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(W.docsVersion,"/"),"_blank")};return!u.length&&L?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(c,{alignItems:"center",mb:"20px",children:[e.jsx(B,{variant:"white",placeholder:"Find a model by name...",value:x,labelProps:{flexGrow:1,mr:"8px"},onChange:k}),e.jsxs(c,{sx:F.modelFiltersLabel,children:[e.jsx(D,{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(D,{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(X,{width:"150px",variant:"white",listWidth:"100%",placeholder:"sort by",value:j,options:Object.keys(I),onChange:m}),e.jsx(c,{ml:"8px",sx:b?F.loading:{},children:e.jsx(Y,{type:"button",intent:"primary",tooltip:"Refresh models",icon:b?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(C,{fontFamily:"Inter",fontSize:"18px",mb:"20px",sx:{color:"black"},children:g?"No models match the filters":"No models"}),e.jsx(Z,{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(q,{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};
