const e=require("../../_util/classNames.js"),t=require("../context/TableContext.js"),n=require("./HeaderRow.js");let r=require("vue");function i(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.default(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 a=(0,r.defineComponent)({name:`TableHeader`,inheritAttrs:!1,props:[`columns`,`flattenColumns`,`stickyOffsets`,`customHeaderRow`],setup(e){let a=t.useInjectTable(),o=(0,r.computed)(()=>i(e.columns));return()=>{let{prefixCls:t,getComponent:i}=a,{stickyOffsets:s,flattenColumns:c,customHeaderRow:l}=e,u=i([`header`,`wrapper`],`thead`),d=i([`header`,`row`],`tr`),f=i([`header`,`cell`],`th`);return(0,r.createVNode)(u,{class:`${t}-thead`},{default:()=>[o.value.map((e,t)=>(0,r.createVNode)(n.default,{key:t,flattenColumns:c,cells:e,stickyOffsets:s,rowComponent:d,cellComponent:f,customHeaderRow:l,index:t},null))]})}}});exports.default=a;