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