import{bC as K,u as L,fR as C,r as l,bd as Q,fT as q,p as U,j as e,L as F,B as s,fW as W,aM as Y,bm as v,e as S,ar as V,cA as $,Q as N,aG as x,as as J,Z as h,c1 as X,q as ee,s as E,bD as te,hx as se}from"./index-dP1W1_bd.js";import{N as ae}from"./NoData-DLZ_8GEo.js";import{u as re}from"./useUserPermissions-Olw8jjZn.js";import{s as ie}from"./searchText-DQ-LeNvB.js";import"./sort-BOLIcXtz.js";import{u as oe}from"./useMultiStoreSelect-BgwXFUPU.js";import{C as ne}from"./CardActionButton-BtCnEqTK.js";import{F as le}from"./FeatureViewsListContent-D34aaNyn.js";import"./FileUploaderButton-frSujVRY.js";import"./useDownload-C3yCvYJa.js";import"./useProject-CXVt1xnE.js";import"./length-BzpOfCdE.js";import"./uniq-98MdbBvs.js";import"./uniqBy-6mvKp2Ip.js";import"./dumbPluralize-CcxDsNiu.js";import"./FilterResult-VfTAUiIy.js";import"./LoadMore-D545rYnU.js";import"./TableCells-B8fH3MMt.js";import"./Deprecated-ClfPkp7s.js";import"./FeatureGroupTypeBadge-BWolRbn-.js";import"./TagsSection-D52WF27P.js";import"./SchematisedTagTable-D9koY5Q-.js";import"./SchematisedTagsEdit-Caewn4Mk.js";import"./index-DEBSKkGo.js";import"./ButtonWithRole-CF64B_Or.js";import"./SchematisedTagsForm-DmZAUPYh.js";import"./useUpdateTdOrFvInfoService-Rjt2OAr8.js";import"./schematised-tags.selectors-xn4c-iOu.js";import"./randomArrayString---X8tfjV.js";import"./utils-UGwNsahk.js";const I=[{value:"CREATION:DESC",label:"last created"},{value:"CREATION:ASC",label:"first created"},{value:"VERSION:DESC",label:"version"},{value:"NAME:ASC",label:"name ascending"},{value:"NAME:DESC",label:"name descending"}],Oe=()=>{K(te.featureViews);const{id:t,fsId:a}=L(),{selectFSValue:r,selectFSOptions:c,handleFSSelectionChange:A,isLoading:i,hasSharedFS:f,isSharedLoading:T}=oe(),[p,D]=C("fvListSort_v2",I[0].value),[o,g]=l.useState(""),d=Q(o,300),M=l.useMemo(()=>({pId:+t,fsId:+a,params:{filter_by:["latest_version",...d?[`NAME_LIKE:${d}`]:[]],sort_by:p}}),[d,a,t,p]),{data:n,hasMore:R,loadMore:_,isFetchingMore:P,isFetching:k,isLoading:H,refetch:O}=q({api:se,apiEndpointName:"getFeatureViews",apiArgs:M}),[j,B]=C("fgAsTable",!1),{canEdit:b,isLoading:w}=re(),Z=()=>{g("")},z=m=>{g(m.target.value)},G=()=>B(m=>!m),u=l.useMemo(()=>U(ie(o))(n),[n,o]);return T||H?e.jsx(F,{}):e.jsxs(s,{flexDirection:"column",mt:"-20px",children:[e.jsxs(s,{sx:W.stickyHeader,pt:"20px",children:[e.jsxs(s,{gap:"10px",alignItems:"center",children:[e.jsx(Y,{labelProps:{flexGrow:1},variant:"white",value:o,placeholder:"Find a Feature View...",onChange:z,autoFocus:!0}),f&&e.jsx(v,{width:"auto",variant:"white",label:"feature store",labelPosition:"inline",value:r,options:c,onChange:A}),e.jsx(S,{children:e.jsx(V,{mainText:"You have no edit right on the feature store",disabled:b&&!w,children:e.jsx(y,{disabled:!b||w})})})]}),e.jsx($,{mt:"10px",mb:"10px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(s,{mb:"10px",justifyContent:"space-between",alignItems:"center",children:[e.jsx(s,{children:!i&&e.jsxs(e.Fragment,{children:[e.jsx(N,{primary:!0,mr:"5px",children:u.length}),e.jsx(N,{children:"feature views"})]})}),e.jsxs(s,{gap:"10px",alignItems:"center",children:[e.jsx(V,{mainText:"Change View",children:e.jsx(x,{p:"4px",intent:"secondary",onClick:G,children:e.jsx(J,{icon:j?h.card:h.lines,size:"lg"})})}),e.jsx(v,{labelPosition:"inline",variant:"white",value:p,isDisabled:i,options:I,label:"sort by",onChange:D}),e.jsx(ne,{onClick:O,icon:h.refresh,tooltipText:"Refresh"})]})]})]}),(i||k)&&e.jsx(F,{}),e.jsxs(S,{mt:"20px",children:[e.jsx(le,{data:u,isFiltered:n.length!==u.length,asTable:j,onResetFilters:Z,hasMore:R,loadMore:_,isFetchingMore:P}),!i&&!n.length&&e.jsx(ce,{hasSharedFS:f})]})]})},ce=({hasSharedFS:t})=>e.jsxs(ae,{mainText:t?"No Feature Views for the selected feature store":"No Feature Views",secondaryText:t?"Create one from feature groups or select another feature store":"Create one from feature groups",sx:{gap:"14px"},children:[e.jsx(y,{}),e.jsx(x,{intent:"secondary",href:X("/user_guides/fs/feature_view/overview/"),external:!0,target:"_blank",children:"Feature View Documentation"})]}),y=({disabled:t})=>{const{id:a,fsId:r}=L(),c=l.useMemo(()=>ee(E.featureView.create,E.project.value,{id:a,fsId:r}),[r,a]);return e.jsx(x,{href:c,intent:"primary",disabled:t,children:"New Feature View"})};export{Oe as default,I as sortOptions};
