import e from"../../_util/classNames.mjs";import{useInjectTable as t}from"../context/TableContext.mjs";import{getColumnsKey as n}from"../utils/valueUtil.mjs";import r from"../Cell/index.mjs";import{useInjectBody as i}from"../context/BodyContext.mjs";import a from"./ExpandedRow.mjs";import{Fragment as o,computed as s,createVNode as c,defineComponent as l,shallowRef as u,watchEffect as d}from"vue";var f=l({name:`BodyRow`,inheritAttrs:!1,props:[`record`,`index`,`renderIndex`,`recordKey`,`expandedKeys`,`rowComponent`,`cellComponent`,`customRow`,`rowExpandable`,`indent`,`rowKey`,`getRowKey`,`childrenColumnName`],setup(l,{attrs:f}){let p=t(),m=i(),h=u(!1),g=s(()=>l.expandedKeys&&l.expandedKeys.has(l.recordKey));d(()=>{g.value&&(h.value=!0)});let _=s(()=>m.expandableType===`row`&&(!l.rowExpandable||l.rowExpandable(l.record))),v=s(()=>m.expandableType===`nest`),y=s(()=>l.childrenColumnName&&l.record&&l.record[l.childrenColumnName]),b=s(()=>_.value||v.value),x=(e,t)=>{m.onTriggerExpand(e,t)},S=s(()=>l.customRow?.(l.record,l.index)||{}),C=(e,...t)=>{m.expandRowByClick&&b.value&&x(l.record,e),S.value?.onClick?.(e,...t)},w=s(()=>{let{record:e,index:t,indent:n}=l,{rowClassName:r}=m;return typeof r==`string`?r:typeof r==`function`?r(e,t,n):``}),T=s(()=>n(m.flattenColumns));return()=>{let{class:t,style:n}=f,{record:i,index:s,rowKey:u,indent:d=0,rowComponent:b,cellComponent:E}=l,{prefixCls:D,fixedInfoList:O,transformCellText:k}=p,{flattenColumns:A,expandedRowClassName:j,indentSize:M,expandIcon:N,expandedRowRender:P,expandIconColumnIndex:F}=m,I=c(b,{...S.value,"data-row-key":u,class:e(t,`${D}-row`,`${D}-row-level-${d}`,w.value,S.value.class),style:[n,S.value.style],onClick:C},{default:()=>[A.map((e,t)=>{let{customRender:n,dataIndex:a,className:u}=e,f=T[t],p=O[t],m;e.customCell&&(m=e.customCell(i,s,e));let h=t===(F||0)&&v.value?c(o,null,[c(`span`,{style:{paddingLeft:`${M*d}px`},class:`${D}-row-indent indent-level-${d}`},null),N({prefixCls:D,expanded:g.value,expandable:y.value,record:i,onExpand:x})]):null;return c(r,{cellType:`body`,class:u,ellipsis:e.ellipsis,align:e.align,component:E,prefixCls:D,key:f,record:i,index:s,renderIndex:l.renderIndex,dataIndex:a,customRender:n,...p,additionalProps:m,column:e,transformCellText:k,appendNode:h},null)})]}),L;if(_.value&&(h.value||g.value)){let t=P({record:i,index:s,indent:d+1,expanded:g.value}),n=j&&j(i,s,d);L=c(a,{expanded:g.value,class:e(`${D}-expanded-row`,`${D}-expanded-row-level-${d+1}`,n),prefixCls:D,component:b,cellComponent:E,colSpan:A.length,isEmpty:!1},{default:()=>[t]})}return c(o,null,[I,L])}}});export{f as default};