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