import e from"../../_util/classNames.mjs";import{useInjectTable as t}from"../context/TableContext.mjs";import n from"./HeaderRow.mjs";import{computed as r,createVNode as i,defineComponent as a}from"vue";function o(t){let n=[];function r(t,i,a=0){n[a]=n[a]||[];let o=i;return t.filter(Boolean).map(t=>{let i={key:t.key,class:e(t.className,t.class),column:t,colStart:o},s=1,c=t.children;return c&&c.length>0&&(s=r(c,o,a+1).reduce((e,t)=>e+t,0),i.hasSubColumns=!0),`colSpan`in t&&({colSpan:s}=t),`rowSpan`in t&&(i.rowSpan=t.rowSpan),i.colSpan=s,i.colEnd=i.colStart+s-1,n[a].push(i),o+=s,s})}r(t,0);let i=n.length;for(let e=0;e<i;e+=1)n[e].forEach(t=>{!(`rowSpan`in t)&&!t.hasSubColumns&&(t.rowSpan=i-e)});return n}var s=a({name:`TableHeader`,inheritAttrs:!1,props:[`columns`,`flattenColumns`,`stickyOffsets`,`customHeaderRow`],setup(e){let a=t(),s=r(()=>o(e.columns));return()=>{let{prefixCls:t,getComponent:r}=a,{stickyOffsets:o,flattenColumns:c,customHeaderRow:l}=e,u=r([`header`,`wrapper`],`thead`),d=r([`header`,`row`],`tr`),f=r([`header`,`cell`],`th`);return i(u,{class:`${t}-thead`},{default:()=>[s.value.map((e,t)=>i(n,{key:t,flattenColumns:c,cells:e,stickyOffsets:o,rowComponent:d,cellComponent:f,customHeaderRow:l,index:t},null))]})}}});export{s as default};