import{j as e,r as h}from"./vendor-react-wBh_31cN.js";import{C as R}from"./combobox-QqI9aNup.js";import{P as K}from"./pagination-D1zFozYl.js";import{V as k}from"./value-7N0Keti9.js";import{F as ee}from"./FilterResult-BIU9i5a2.js";import{cg as A,h as te,b as se}from"./index-dNe6i2rS.js";import{s as y,S as D}from"./sort-BOLIcXtz.js";import{E as O}from"./editable-select-DItn4ZHW.js";import{S as V}from"./search-input-BWz7f2O1.js";import{F,K as l,u as ae}from"./useFeatureFilters-dgIPcuD2.js";import{R as re,a as ne}from"./radio-group-CjbLFQxV.js";import{L as oe}from"./label-gPWmc6ow.js";import{a as ie}from"./storage-connector-DQCKY9HZ.js";import{m as le}from"./min-CMw7fhtu.js";const ce=(t,c,o=0)=>{const r=t.length,i=o&&o<r?o:r,n=i*c;return{data:t.slice(n-i,n>r?r:n),totalPages:r?Math.ceil(r/i):1}},me=({search:t,onSearchChange:c,typeFilters:o,onTypeFiltersChange:r,types:i,onToggleKey:n,keyFilter:m})=>e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2",children:[e.jsx(V,{className:"w-[260px]",value:t,placeholder:"Find feature",onChange:c}),e.jsx(O,{className:"w-[140px]",isMulti:!0,compact:!0,value:o,options:i,placeholder:"type",onChange:r}),e.jsx(F,{icon:"target",checked:m===l.label,onChange:n(l.label),children:"Label (target) features only"})]}),ue=({search:t,onSearchChange:c,typeFilters:o,onTypeFiltersChange:r,types:i,onToggleKey:n,keyFilter:m,storageConnectorType:f,enableStorageConnectorFilter:v,setStorageConnectorType:u,dataPreviewToggler:p})=>e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2",children:[e.jsx(V,{className:"w-[260px]",value:t,placeholder:"Find feature",onChange:c}),e.jsx(O,{className:"w-[140px]",isMulti:!0,compact:!0,value:o,options:i,placeholder:"type",onChange:r,preventAdding:!0}),v&&u?e.jsx(re,{value:f,onValueChange:a=>u(a),className:"flex flex-row gap-3",children:Object.values(ie).map(a=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ne,{value:a,id:`storage-${a}`}),e.jsx(oe,{htmlFor:`storage-${a}`,children:a})]},a))}):null,e.jsx(F,{icon:"primary",checked:m===l.primary,onChange:n(l.primary),children:"Primary Keys"}),e.jsx(F,{icon:"partition",checked:m===l.partition,onChange:n(l.partition),children:"Partition Keys"}),e.jsx(F,{icon:"time",checked:m===l.eventTime,onChange:n(l.eventTime),children:"Event Time"}),p&&e.jsx("div",{className:"ml-auto",children:p})]}),M={"10 features":10,"20 features":20,"50 features":50,"100 features":100,"200 features":200,"all features":void 0},G={"name (A -> Z)":["name",y.string,D.asc],"name (Z -> A)":["name",y.string,D.desc]},Se=(t,c=A.fg,o={})=>{var I;const{extraActions:r,dataPreviewToggler:i}=o,[n,m]=h.useState("20 features"),[f,v]=h.useState("name (A -> Z)"),[u,p]=h.useState(1),a=((I=t==null?void 0:t.features)==null?void 0:I.length)??0,g=M[n]??a,{dataFiltered:d,types:w,search:N,typeFilters:L,keyFilter:S,onTypeFiltersChange:P,onSearchChange:E,onToggleKey:T,onReset:Z}=ae(t.features??[],"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:b,totalPages:x}=h.useMemo(()=>ce(d,u,g),[d,g,u]),$=h.useMemo(()=>{const s=G[f];if(s){const[Q,U,X]=s;return te(y(Q,U,X),j=>{const C=j.findIndex(se("name","Feature Group"));return C>0?[j[C],...j.filter((pe,Y)=>C!==Y)]:j})(b)}return b},[b,f]),q=d.length,W=a!==q;h.useEffect(()=>{p(1)},[g]);const _=c===A.fg?e.jsx(ue,{search:N,typeFilters:L,types:w,keyFilter:S,enableStorageConnectorFilter:!1,onToggleKey:T,onSearchChange:E,onTypeFiltersChange:P,dataPreviewToggler:i}):e.jsx(me,{search:N,typeFilters:L,types:w,keyFilter:S,onToggleKey:T,onSearchChange:E,onTypeFiltersChange:P}),z=e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[e.jsx(k,{primary:!0,children:le(g,a)}),e.jsxs(k,{children:["/ ",a," features"]})]}),B=e.jsxs(e.Fragment,{children:[r,e.jsx(R,{className:"w-max",value:f,options:Object.keys(G).map(s=>({value:s,label:s})),placeholder:"sort by",onChange:s=>{s&&v(s)}}),e.jsx(R,{className:"w-max",value:n,options:Object.keys(M).map(s=>({value:s,label:s})),placeholder:"show",onChange:s=>{s&&m(s)}}),x>1&&e.jsx(K,{totalPages:x,currentPage:u,onChange:p})]}),H=a>g?e.jsx(K,{className:"my-2.5",disabled:x===1,totalPages:x,currentPage:u,onChange:p}):null,J=W?e.jsx(ee,{subject:"features",result:d.length,onReset:Z}):null;return{sortedData:$,toolbar:_,countContent:z,tools:B,bottomPagination:H,filterResult:J}};export{ue as F,G as s,Se as u};
