import{j as e,B as r,b5 as V,C as E,c4 as Y,d as h,be as O,r as l,f as ee,D as te,g4 as se,dX as y,b as w,e4 as ae,e5 as ne,bG as Z,c3 as R}from"./index-C1DmWO_C.js";import{F as re}from"./FilterResult-BLSGYVa5.js";import{s as d,S as v}from"./sort-BOLIcXtz.js";import{u as ie}from"./Deprecated-BQWZLUTP.js";import{F as oe,K as G,u as le}from"./useFeatureFilters-DdB4Pg89.js";import{F as ce}from"./FeatureFilters-DTS9HN8J.js";import{m as xe}from"./min-BJfYLHXY.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}},me={"name (A -> Z)":["name",d.string,v.asc],"name (Z -> A)":["name",d.string,v.desc]},ue=({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(V,{variant:"white",value:t,icon:E.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:E.target,checked:k===G.label,onChange:n(G.label),children:"Label (target) features only"})}),e.jsx(O,{label:"sort by",labelPosition:"inline",width:"max-content",variant:"white",value:o,ml:"auto",options:Object.keys(me),onChange:g})]})}),H={"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 B;const[n,k]=l.useState("20 features"),[o,g]=l.useState("name (A -> Z)"),x=H[n]||1,[f,C]=l.useState(1),{isActiveFeatures:$,handleBasket:q,isSwitch:J}=ie(),{dataFiltered:j,types:T,search:I,typeFilters:L,keyFilter:K,onTypeFiltersChange:P,onSearchChange:M,onToggleKey:A,onReset:W}=le(t.features??[],"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:S,totalPages:p}=l.useMemo(()=>pe(j,f,x),[j,x,f]),m=l.useMemo(()=>{const u=he[o];if(u){const[z,N,Q]=u;return ee(d(z,N,Q),F=>{const D=F.findIndex(te("name","Feature Group"));return D>0?[F[D],...F.filter((de,U)=>D!==U)]:F})(S)}return S},[S,o]),b=((B=t==null?void 0:t.features)==null?void 0:B.length)??0,X=j.length,_=b!==X;return l.useEffect(()=>{C(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:L,types:T,keyFilter:K,enableStorageConnectorFilter:!1,sortKey:o,setSortKey:g,onToggleKey:A,onSearchChange:M,onTypeFiltersChange:P}),s===y.td&&e.jsx(ue,{search:I,typeFilters:L,types:T,keyFilter:K,sortKey:o,setSortKey:g,onToggleKey:A,onSearchChange:M,onTypeFiltersChange:P}),e.jsxs(r,{width:"100%",mt:"10px",alignItems:"center",children:[e.jsxs(r,{children:[e.jsx(w,{primary:!0,px:"5px",children:xe(x,b)}),e.jsx(w,{children:"features displayed out of"}),e.jsx(w,{primary:!0,px:"5px",children:b}),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:m.length>0,tooltipMainText:"Add all features to basket",tooltipSecondaryText:`${m.length} features`,handleClick:q(m,t),inBasket:$(m,t)})}),e.jsx(h,{ml:"auto",sx:{span:{mt:"4px"}},children:e.jsx(O,{variant:"white",value:n,label:"show",labelPosition:"side",options:Object.keys(H),onChange:k})}),p>1&&e.jsx(h,{sx:{span:{marginTop:"4px"}},children:e.jsx(Z,{ml:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(R,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:C})})})]})]}),e.jsxs(r,{sx:{gap:"20px",mt:"10px",mb:"20px",flexDirection:"column",width:"100%"},...i,children:[m.map(u=>e.jsx(h,{children:c({type:s,parent:t,data:u})},u.name)),b>x&&e.jsx(Z,{mt:"10px",mb:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(R,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:C})}),_&&e.jsx(re,{subject:"features",result:j.length,onReset:W})]})]})};export{ve as F};
