import{bw as Y,bx as q,u as N,fV as C,r as l,aZ as G,fX as J,p as K,j as e,D as F,$ as s,f_ as X,b2 as Z,bd as v,L as S,ao as V,cC as Q,f as I,b1 as m,ap as W,C as x,eh as ee,je as te,o as se,q as L,bS as ae,c4 as re}from"./index-46ma1THH.js";import{u as ie}from"./useUserPermissions-DiAMkzC6.js";import{s as oe}from"./searchText-DQ-LeNvB.js";import"./sort-BOLIcXtz.js";import{u as ne}from"./useMultiStoreSelect-B0XeLjHW.js";import{F as le}from"./FeatureViewsListContent-Bk4cRKCd.js";import"./FilterResult-CWV4237e.js";import"./LoadMore-Dsngz54d.js";import"./TableCells-ljdIYfcd.js";import"./Deprecated-CcWZugSq.js";import"./FeatureGroupTypeBadge-DK0B-B3q.js";import"./TagsSection-hjmmhvQy.js";import"./SchematisedTagTable-DgZocj7H.js";import"./SchematisedTagsEdit-Yw_kmyod.js";import"./index-D241LvV7.js";import"./SchematisedTagsForm-dh4vAE2D.js";import"./useUpdateTdOrFvInfoService-BiDORrPs.js";import"./schematised-tags.selectors-WK3AUml0.js";import"./randomArrayString---X8tfjV.js";const E=[{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"}],Ne=()=>{Y(q.featureViews);const{id:t,fsId:a}=N(),{selectFSValue:r,selectFSOptions:c,handleFSSelectionChange:A,isLoading:i,hasSharedFS:f,isSharedLoading:T}=ne(),[d,D]=C("fvListSort_v2",E[0].value),[o,g]=l.useState(""),u=G(o,300),_=l.useMemo(()=>({pId:+t,fsId:+a,params:{filter_by:["latest_version",...u?[`NAME_LIKE:${u}`]:[]],sort_by:d}}),[u,a,t,d]),{data:n,hasMore:M,loadMore:R,isFetchingMore:P,isFetching:k,isLoading:H,refetch:O}=J({api:te,apiEndpointName:"getFeatureViews",apiArgs:_}),[j,$]=C("fgAsTable",!1),{canEdit:b,isLoading:w}=ie(),z=()=>{g("")},B=h=>{g(h.target.value)},U=()=>$(h=>!h),p=l.useMemo(()=>K(oe(o))(n),[n,o]);return T||H?e.jsx(F,{}):e.jsxs(s,{flexDirection:"column",mt:"-20px",children:[e.jsxs(s,{sx:X.stickyHeader,pt:"20px",children:[e.jsxs(s,{gap:"10px",alignItems:"center",children:[e.jsx(Z,{labelProps:{flexGrow:1},variant:"white",value:o,placeholder:"Find a Feature View...",onChange:B,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(Q,{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(I,{primary:!0,mr:"5px",children:p.length}),e.jsx(I,{children:"feature views"})]})}),e.jsxs(s,{gap:"10px",alignItems:"center",children:[e.jsx(V,{mainText:"Change View",children:e.jsx(m,{p:"4px",intent:"secondary",onClick:U,children:e.jsx(W,{icon:j?x.card:x.lines,size:"lg"})})}),e.jsx(v,{labelPosition:"inline",variant:"white",value:d,isDisabled:i,options:E,label:"sort by",onChange:D}),e.jsx(ee,{onClick:O,icon:x.refresh,tooltipText:"Refresh"})]})]})]}),(i||k)&&e.jsx(F,{}),e.jsxs(S,{mt:"20px",children:[e.jsx(le,{data:p,isFiltered:n.length!==p.length,asTable:j,onResetFilters:z,hasMore:M,loadMore:R,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(m,{intent:"secondary",href:re("/user_guides/fs/feature_view/overview/"),external:!0,target:"_blank",children:"Feature View Documentation"})]}),y=({disabled:t})=>{const{id:a,fsId:r}=N(),c=l.useMemo(()=>se(L.project.featureView.create,L.project.value,{id:a,fsId:r}),[r,a]);return e.jsx(m,{href:c,intent:"primary",disabled:t,children:"New Feature View"})};export{Ne as default,E as sortOptions};
