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