import{j as e,a as r,aH as X,d as Z,c4 as Y,L as h,bd as q,r as l,p as ee,A as te,g5 as se,eh as y,f as w,eq as ae,er as ne,bG as B,c3 as H}from"./index-_eM6l4Nf.js";import{F as re}from"./FilterResult-DzQsF93v.js";import{s as d,S as v}from"./sort-BOLIcXtz.js";import{u as ie}from"./Deprecated-Cn0z8EIY.js";import{F as oe,K as O,u as le}from"./useFeatureFilters-DHl2jdlW.js";import{F as ce}from"./FeatureFilters-B-XNaevL.js";import{m as xe}from"./min-CIERvabW.js";const pe=(t,c,a=0)=>{const s=t.length,i=a&&a<s?a:s,n=i*c;return{data:t.slice(n-i,n>s?s:n),totalPages:s?Math.ceil(s/i):1}},ue={"name (A -> Z)":["name",d.string,v.asc],"name (Z -> A)":["name",d.string,v.desc]},me=({search:t,onSearchChange:c,typeFilters:a,onTypeFiltersChange:s,types:i,onToggleKey:n,keyFilter:k,sortKey:o,setSortKey:g})=>e.jsx(r,{width:"100%",flexDirection:"column",alignItems:"center",children:e.jsxs(r,{width:"100%",children:[e.jsx(X,{variant:"white",value:t,icon:Z.glass,placeholder:"Find feature",onChange:c}),e.jsx(Y,{maxWidth:"180px",width:"max-content",ml:"15px",variant:"white",isMulti:!0,value:a,options:i,placeholder:"type",onChange:s,noDataMessage:"type all"}),e.jsx(h,{ml:"10px",sx:{label:{div:{bg:"white"}}},children:e.jsx(oe,{icon:Z.target,checked:k===O.label,onChange:n(O.label),children:"Label (target) features only"})}),e.jsx(q,{label:"sort by",labelPosition:"inline",width:"max-content",variant:"white",value:o,ml:"auto",options:Object.keys(ue),onChange:g})]})}),R={"10 features":10,"20 features":20,"50 features":50,"100 features":100,"200 features":200,"all features":void 0},he={"name (A -> Z)":["name",d.string,v.asc],"name (Z -> A)":["name",d.string,v.desc]},ve=({data:t,renderChild:c,extraActions:a,type:s=y.fg,...i})=>{var M;const[n,k]=l.useState("20 features"),[o,g]=l.useState("name (A -> Z)"),x=R[n]||1,[f,S]=l.useState(1),{isActiveFeatures:G,handleBasket:$,isSwitch:J}=ie(),{dataFiltered:j,types:D,search:I,typeFilters:T,keyFilter:P,onTypeFiltersChange:A,onSearchChange:K,onToggleKey:E,onReset:W}=le(t.features??[],"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:C,totalPages:p}=l.useMemo(()=>pe(j,f,x),[j,x,f]),u=l.useMemo(()=>{const m=he[o];if(m){const[N,Q,U]=m;return ee(d(N,Q,U),b=>{const L=b.findIndex(te("name","Feature Group"));return L>0?[b[L],...b.filter((de,V)=>L!==V)]:b})(C)}return C},[C,o]),F=((M=t==null?void 0:t.features)==null?void 0:M.length)??0,_=j.length,z=F!==_;return l.useEffect(()=>{S(1)},[x]),e.jsxs(r,{width:"100%",flexDirection:"column",alignItems:"center",children:[e.jsxs(r,{sx:{...se.stickyHeader},pt:"20px",mt:"-20px",children:[s===y.fg&&e.jsx(ce,{search:I,typeFilters:T,types:D,keyFilter:P,enableStorageConnectorFilter:!1,sortKey:o,setSortKey:g,onToggleKey:E,onSearchChange:K,onTypeFiltersChange:A}),s===y.td&&e.jsx(me,{search:I,typeFilters:T,types:D,keyFilter:P,sortKey:o,setSortKey:g,onToggleKey:E,onSearchChange:K,onTypeFiltersChange:A}),e.jsxs(r,{width:"100%",mt:"10px",alignItems:"center",children:[e.jsxs(r,{children:[e.jsx(w,{primary:!0,px:"5px",children:xe(x,F)}),e.jsx(w,{children:"features displayed out of"}),e.jsx(w,{primary:!0,px:"5px",children:F}),e.jsx(w,{children:"features"})]}),a&&e.jsx(r,{ml:"10px",children:a}),J&&s===y.fg&&e.jsx(h,{ml:"10px",children:e.jsx(ae,{mode:ne.bulk,possible:u.length>0,tooltipMainText:"Add all features to basket",tooltipSecondaryText:`${u.length} features`,handleClick:$(u,t),inBasket:G(u,t)})}),e.jsx(h,{ml:"auto",sx:{span:{mt:"4px"}},children:e.jsx(q,{variant:"white",value:n,label:"show",labelPosition:"side",options:Object.keys(R),onChange:k})}),p>1&&e.jsx(h,{sx:{span:{marginTop:"4px"}},children:e.jsx(B,{ml:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(H,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:S})})})]})]}),e.jsxs(r,{sx:{gap:"20px",mt:"10px",mb:"20px",flexDirection:"column",width:"100%"},...i,children:[u.map(m=>e.jsx(h,{children:c({type:s,parent:t,data:m})},m.name)),F>x&&e.jsx(B,{mt:"10px",mb:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(H,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:S})}),z&&e.jsx(re,{subject:"features",result:j.length,onReset:W})]})]})};export{ve as F};
