import e from"../../_util/classNames.mjs";import t from"../../vc-util/Dom/addEventListener.mjs";import{useInjectTable as n}from"../context/TableContext.mjs";import r from"../ColGroup.mjs";import{computed as i,createVNode as a,defineComponent as o,nextTick as s,onBeforeUnmount as c,onMounted as l,ref as u,toRef as d,watchEffect as f}from"vue";function p(e,t){return i(()=>{let n=[],r=e.value,i=t.value;for(let e=0;e<i;e+=1){let t=r[e];if(t!==void 0)n[e]=t;else return null}return n})}var m=o({name:`FixedHolder`,inheritAttrs:!1,props:[`columns`,`flattenColumns`,`stickyOffsets`,`customHeaderRow`,`noData`,`maxContentScroll`,`colWidths`,`columCount`,`direction`,`fixHeader`,`stickyTopOffset`,`stickyBottomOffset`,`stickyClassName`],emits:[`scroll`],setup(o,{attrs:m,slots:h,emit:g}){let _=n(),v=i(()=>_.isSticky&&!o.fixHeader?0:_.scrollbarSize),y=u(),b=e=>{let{currentTarget:t,deltaX:n}=e;n&&(g(`scroll`,{currentTarget:t,scrollLeft:t.scrollLeft+n}),e.preventDefault())},x=u();l(()=>{s(()=>{x.value=t(y.value,`wheel`,b)})}),c(()=>{x.value?.remove()});let S=i(()=>o.flattenColumns.every(e=>e.width&&e.width!==0&&e.width!==`0px`)),C=u([]),w=u([]);f(()=>{let e=o.flattenColumns[o.flattenColumns.length-1],t={fixed:e?e.fixed:null,scrollbar:!0,customHeaderCell:()=>({class:`${_.prefixCls}-cell-scrollbar`})};C.value=v.value?[...o.columns,t]:o.columns,w.value=v.value?[...o.flattenColumns,t]:o.flattenColumns});let T=i(()=>{let{stickyOffsets:e,direction:t}=o,{right:n,left:r}=e;return{...e,left:t===`rtl`?[...r.map(e=>e+v.value),0]:r,right:t===`rtl`?n:[...n.map(e=>e+v.value),0],isSticky:_.isSticky}}),E=p(d(o,`colWidths`),d(o,`columCount`));return()=>{let{noData:t,columCount:n,stickyTopOffset:i,stickyBottomOffset:s,stickyClassName:c,maxContentScroll:l}=o,{isSticky:u}=_;return a(`div`,{style:{overflow:`hidden`,...u?{top:`${i}px`,bottom:`${s}px`}:{}},ref:y,class:e(m.class,{[c]:!!c})},[a(`table`,{style:{tableLayout:`fixed`,visibility:t||E.value?null:`hidden`}},[(!t||!l||S.value)&&a(r,{colWidths:E.value?[...E.value,v.value]:[],columCount:n+1,columns:w.value},null),h.default?.({...o,stickyOffsets:T.value,columns:C.value,flattenColumns:w.value})])])}}});export{m as default};