import{aX as G,u as T,gg as C,r as d,W,g1 as z,z as B,j as e,a_ as V,ce as D,a as i,gm as X,aG as Y,bp as Z,O as y,ae as S,ct as J,f as v,aT as x,af as Q,Z as m,bf as U,ci as $,g as q,e as L,aY as K}from"./index-d6499a22.js";import{N as ee}from"./NoData-789df290.js";import{u as se}from"./useUserPermissions-3851a25d.js";import{d as te}from"./index-6716d449.js";import{u as re}from"./useMultiStoreSelect-a2174957.js";import{C as ae}from"./CardActionButton-ccf1bc35.js";import{F as ie}from"./FeatureViewsListContent-195ced2c.js";import{d as oe}from"./FileUploaderButton-c4f1b533.js";import"./index-da50fbe6.js";import"./file-utils-b5704e1c.js";import"./useCurrentProject-b23444be.js";import"./useProject-0d0fdeb3.js";import"./FilterResult-550b3b9f.js";import"./TableCells-4f9e6477.js";import"./Deprecated-ec8916ed.js";import"./FeatureGroupTypeBadge-0a81479c.js";import"./TagsSection-169ba331.js";import"./SchematisedTags-747f8809.js";import"./useDownload-7167ff3b.js";const ne=s=>t=>s?t.filter(({name:a,id:o})=>JSON.stringify({name:a,id:o}).toLowerCase().includes(s.toLowerCase())):t,k=[{key:"created",label:"last created"},{key:"name",label:"name"},{key:"version",label:"version"}],ke=()=>{G(K.featureViews);const{id:s,fsId:t}=T(),{selectFSValue:a,selectFSOptions:o,handleFSSelectionChange:N,isLoading:c,hasSharedFS:f,isSharedLoading:M}=re(),{currentData:r,isFetching:g,isLoading:O,refetch:_}=te({pId:+s,fsId:+t,params:{filter_by:"latest_version"}},{refetchOnFocus:!0}),[u,R]=C("fvListSort",k[0].key),[p,j]=d.useState(""),[w,E]=C("fgAsTable",!1),n=d.useMemo(()=>(r==null?void 0:r.items)??[],[r==null?void 0:r.items]),{canEdit:F,isLoading:b}=se(),H=()=>{j("")},P=l=>{j(l.target.value)},A=()=>E(l=>!l),h=d.useMemo(()=>W(z(oe(B(u))),ne(p))(n),[n,p,u]);return M||O?e.jsx(V,{}):!g&&!r?e.jsx(D,{}):e.jsxs(i,{flexDirection:"column",mt:"-20px",children:[e.jsxs(i,{sx:X.stickyHeader,pt:"20px",children:[e.jsxs(i,{gap:"20px",alignItems:"center",children:[e.jsx(Y,{labelProps:{flexGrow:1},variant:"white",value:p,disabled:!n.length,placeholder:"Find a Feature View...",onChange:P,autoFocus:!0}),f&&e.jsx(Z,{width:"auto",variant:"white",listWidth:"max-content",placeholder:"feature store",value:a,options:o,onChange:N}),e.jsx(y,{children:e.jsx(S,{mainText:"You have no edit right on the feature store",disabled:F&&!b,children:e.jsx(I,{disabled:!F||b})})})]}),e.jsx(J,{mt:"10px",mb:"10px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(i,{mb:"10px",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{children:!c&&e.jsxs(e.Fragment,{children:[e.jsx(v,{primary:!0,mr:"5px",children:h.length}),e.jsx(v,{children:"feature views"})]})}),e.jsxs(i,{gap:"10px",alignItems:"center",children:[e.jsx(S,{mainText:"Change View",children:e.jsx(x,{p:"4px",intent:"secondary",onClick:A,children:e.jsx(Q,{icon:w?m.card:m.lines,size:"lg"})})}),e.jsx(U,{labelMode:"inline",width:"150px",color:"white",listWidth:"100%",value:u,disabled:c,options:k,placeholder:"sort by",onChange:l=>R(l.key),isMulti:!1}),e.jsx(ae,{onClick:_,icon:m.refresh,tooltipText:"Refresh"})]})]})]}),(c||g)&&e.jsx(V,{}),e.jsxs(y,{mt:"20px",children:[e.jsx(ie,{data:h,isFiltered:n.length!==h.length,asTable:w,onResetFilters:H}),!c&&!n.length&&e.jsx(le,{hasSharedFS:f})]})]})},le=({hasSharedFS:s})=>e.jsxs(ee,{mainText:s?"No Feature Views for the selected feature store":"No Feature Views",secondaryText:s?"Create one from feature groups or select another feature store":"Create one from feature groups",sx:{gap:"14px"},children:[e.jsx(I,{}),e.jsx(x,{intent:"secondary",href:"https://docs.hopsworks.ai/".concat($.docsVersion,"/user_guides/fs/feature_view/overview/"),external:!0,target:"_blank",children:"Feature View Documentation"})]}),I=({disabled:s})=>{const{id:t,fsId:a}=T(),o=d.useMemo(()=>q(L.featureView.create,L.project.value,{id:t,fsId:a}),[a,t]);return e.jsx(x,{href:o,intent:"primary",disabled:s,children:"New Feature View"})};export{ke as default,k as sortOptions};
