const e=require("../../_util/classNames.js"),t=require("../../_util/props-util/index.js"),n=require("../../_util/vnode.js"),r=require("../../_util/eagerComputed.js"),i=require("../../vc-util/Dom/class.js"),a=require("../../table/context.js"),o=require("../context/HoverContext.js"),s=require("../context/StickyContext.js");require("../utils/legacyUtil.js");const c=require("../utils/valueUtil.js");let l=require("vue");function u(e,t,n,r){let i=e+t-1;return e<=r&&i>=n}function d(e){return e&&typeof e==`object`&&!Array.isArray(e)&&!(0,l.isVNode)(e)}var f=(0,l.defineComponent)({name:`Cell`,props:[`prefixCls`,`record`,`index`,`renderIndex`,`dataIndex`,`customRender`,`component`,`colSpan`,`rowSpan`,`fixLeft`,`fixRight`,`firstFixLeft`,`lastFixLeft`,`firstFixRight`,`lastFixRight`,`appendNode`,`additionalProps`,`ellipsis`,`align`,`rowType`,`isSticky`,`column`,`cellType`,`transformCellText`],setup(f,{slots:p}){let m=a.useInjectSlots(),{onHover:h,startRow:g,endRow:_}=o.useInjectHover(),v=(0,l.computed)(()=>f.colSpan??f.additionalProps?.colSpan??f.additionalProps?.colspan),y=(0,l.computed)(()=>f.rowSpan??f.additionalProps?.rowSpan??f.additionalProps?.rowspan),b=r.default(()=>{let{index:e}=f;return u(e,y.value||1,g.value,_.value)}),x=s.useInjectSticky(),S=(e,t)=>{let{record:n,index:r,additionalProps:i}=f;n&&h(r,r+t-1),i?.onMouseenter?.(e)},C=e=>{let{record:t,additionalProps:n}=f;t&&h(-1,-1),n?.onMouseleave?.(e)},w=e=>{let n=t.filterEmpty(e)[0];return(0,l.isVNode)(n)?n.type===l.Text?n.children:Array.isArray(n.children)?w(n.children):void 0:n},T=(0,l.shallowRef)(null);return(0,l.watch)([b,()=>f.prefixCls,T],()=>{let e=t.findDOMNode(T.value);e&&(b.value?i.addClass(e,`${f.prefixCls}-cell-row-hover`):i.removeClass(e,`${f.prefixCls}-cell-row-hover`))}),()=>{let{prefixCls:r,record:i,index:a,renderIndex:o,dataIndex:s,customRender:u,component:h=`td`,fixLeft:g,fixRight:_,firstFixLeft:b,lastFixLeft:E,firstFixRight:D,lastFixRight:O,appendNode:k=p.appendNode?.(),additionalProps:A={},ellipsis:j,align:M,rowType:N,isSticky:P,column:F={},cellType:I}=f,L=`${r}-cell`,R,z,B=p.default?.();if(c.validateValue(B)||I===`header`)z=B;else{let e=c.getPathValue(i,s);if(z=e,u){let t=u({text:e,value:e,record:i,index:a,renderIndex:o,column:F.__originColumn__});d(t)?(z=t.children,R=t.props):z=t}!(`RC_TABLE_INTERNAL_COL_DEFINE`in F)&&I===`body`&&m.value.bodyCell&&!F.slots?.customRender&&(z=t.flattenChildren(n.customRenderSlot(m.value,`bodyCell`,{text:e,value:e,record:i,index:a,column:F.__originColumn__},()=>{let n=z===void 0?e:z;return[typeof n==`object`&&t.isValidElement(n)||typeof n!=`object`?n:null]}))),f.transformCellText&&(z=f.transformCellText({text:z,record:i,index:a,column:F.__originColumn__}))}typeof z==`object`&&!Array.isArray(z)&&!(0,l.isVNode)(z)&&(z=null),j&&(E||D)&&(z=(0,l.createVNode)(`span`,{class:`${L}-content`},[z])),Array.isArray(z)&&z.length===1&&(z=z[0]);let{colSpan:V,rowSpan:H,style:U,class:W,...G}=R||{},K=(V===void 0?v.value:V)??1,q=(H===void 0?y.value:H)??1;if(K===0||q===0)return null;let J={},Y=typeof g==`number`&&x.value,X=typeof _==`number`&&x.value;Y&&(J.position=`sticky`,J.left=`${g}px`),X&&(J.position=`sticky`,J.right=`${_}px`);let Z={};M&&(Z.textAlign=M);let Q,$=j===!0?{showTitle:!0}:j;return $&&($.showTitle||N===`header`)&&(typeof z==`string`||typeof z==`number`?Q=z.toString():(0,l.isVNode)(z)&&(Q=w([z]))),(0,l.createVNode)(h,{title:Q,...G,...A,colSpan:K===1?null:K,rowSpan:q===1?null:q,class:e.default(L,{[`${L}-fix-left`]:Y&&x.value,[`${L}-fix-left-first`]:b&&x.value,[`${L}-fix-left-last`]:E&&x.value,[`${L}-fix-right`]:X&&x.value,[`${L}-fix-right-first`]:D&&x.value,[`${L}-fix-right-last`]:O&&x.value,[`${L}-ellipsis`]:j,[`${L}-with-append`]:k,[`${L}-fix-sticky`]:(Y||X)&&P&&x.value},A.class,W),onMouseenter:e=>{S(e,q)},onMouseleave:C,style:[A.style,Z,J,U],ref:T},{default:()=>[k,z,p.dragHandle?.()]})}}});exports.default=f;