"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../../_virtual/jsx-runtime.js"),u=require("react"),f=require("../../Field/checkbox/Checkbox.js"),a=require("../styles.js"),m=require("../utils.js");const g=({columns:c,selectAllRows:n,rows:l,selectedRows:r,rowIdentifier:s,"data-testid":o,"data-trackid":j})=>{const[d,h]=u.useState(!1);return u.useEffect(()=>{r&&(r.length===0||r.length<l.length)&&h(!1)},[r]),t.jsxRuntimeExports.jsx("thead",{"data-testid":o,"data-trackid":j,children:t.jsxRuntimeExports.jsxs("tr",{role:"row",children:[r&&typeof n=="function"&&t.jsxRuntimeExports.jsx(a.CheckboxCell,{as:"th",role:"columnheader",children:t.jsxRuntimeExports.jsx(f.Checkbox,{onChange:()=>{h(e=>{const i=!e;let x=[];return s&&(x=l.map(p=>m.getRowIdByIdentifier(p,s))),n(x,i),i})},checked:d,name:"select-all",value:0,indeterminate:r.length>0&&!d})}),c.map((e,i)=>!e.hideHeader&&t.jsxRuntimeExports.jsx(a.Th,{textAlign:e.textAlign,onClick:e.onClick,columnWidth:e.width,role:"columnheader",children:t.jsxRuntimeExports.jsxs(a.ThContainer,{children:[t.jsxRuntimeExports.jsx("span",{children:e.header.title}),e.header.icon]})},`${i}_${e.header.title}`))]})})};exports.default=g;
