import e from"../_util/omit.mjs";import t from"../vc-virtual-list/index.mjs";import{useInjectKeysState as n,useInjectTreeContext as r}from"./contextTypes.mjs";import{nodeListProps as i}from"./props.mjs";import{getKey as a}from"./utils/treeUtil.mjs";import o from"./MotionTreeNode.mjs";import{findExpandedKeys as s,getExpandRange as c}from"./utils/diffUtil.mjs";import{Fragment as l,computed as u,createVNode as d,defineComponent as f,ref as p,shallowRef as m,watch as h}from"vue";var g={width:0,height:0,display:`flex`,overflow:`hidden`,opacity:0,border:0,padding:0,margin:0},_=()=>{},v=`RC_TREE_MOTION_${Math.random()}`,y={key:v},b={key:v,level:0,index:0,pos:`0`,node:y,nodes:[y]},x={parent:null,children:[],pos:b.pos,data:y,title:null,key:v,isStart:[],isEnd:[]};function S(e,t,n,r){return t===!1||!n?e:e.slice(0,Math.ceil(n/r)+1)}function C(e){let{key:t,pos:n}=e;return a(t,n)}function w(e){let t=String(e.key),n=e;for(;n.parent;)n=n.parent,t=`${n.key} > ${t}`;return t}var T=f({compatConfig:{MODE:3},name:`NodeList`,inheritAttrs:!1,props:i,setup(i,{expose:f,attrs:y}){let b=p(),T=p(),{expandedKeys:E,flattenNodes:D}=n();f({scrollTo:e=>{b.value.scrollTo(e)},getIndentWidth:()=>T.value.offsetWidth});let O=m(D.value),k=m([]),A=p(null);function j(){O.value=D.value,k.value=[],A.value=null,i.onListChangeEnd()}let M=r();h([()=>E.value.slice(),D],([e,t],[n,r])=>{let a=s(n,e);if(a.key!==null){let{virtual:e,height:n,itemHeight:o}=i;if(a.add){let i=r.findIndex(({key:e})=>e===a.key),s=S(c(r,t,a.key),e,n,o),l=r.slice();l.splice(i+1,0,x),O.value=l,k.value=s,A.value=`show`}else{let i=t.findIndex(({key:e})=>e===a.key),s=S(c(t,r,a.key),e,n,o),l=t.slice();l.splice(i+1,0,x),O.value=l,k.value=s,A.value=`hide`}}else r!==t&&(O.value=t)}),h(()=>M.value.dragging,e=>{e||j()});let N=u(()=>i.motion===void 0?O.value:D.value),P=()=>{i.onActiveChange(null)};return()=>{let{prefixCls:n,selectable:r,checkable:s,disabled:c,motion:u,height:f,itemHeight:p,virtual:m,focusable:h,activeItem:x,focused:S,tabindex:E,onKeydown:D,onFocus:O,onBlur:M,onListChangeStart:F,onListChangeEnd:I,...L}={...i,...y};return d(l,null,[S&&x&&d(`span`,{style:g,"aria-live":`assertive`},[w(x)]),d(`div`,null,[d(`input`,{style:g,disabled:h===!1||c,tabindex:h===!1?null:E,onKeydown:D,onFocus:O,onBlur:M,value:``,onChange:_,"aria-label":`for screen reader`},null)]),d(`div`,{class:`${n}-treenode`,"aria-hidden":!0,style:{position:`absolute`,pointerEvents:`none`,visibility:`hidden`,height:0,overflow:`hidden`}},[d(`div`,{class:`${n}-indent`},[d(`div`,{ref:T,class:`${n}-indent-unit`},null)])]),d(t,{...e(L,[`onActiveChange`]),data:N.value,itemKey:C,height:f,fullHeight:!1,virtual:m,itemHeight:p,prefixCls:`${n}-list`,ref:b,onVisibleChange:(e,t)=>{let n=new Set(e);t.filter(e=>!n.has(e)).some(e=>C(e)===v)&&j()}},{default:e=>{let{pos:t,data:{...n},title:r,key:i,isStart:s,isEnd:c}=e,l=a(i,t);return delete n.key,delete n.children,d(o,{...n,eventKey:l,title:r,active:!!x&&i===x.key,data:e.data,isStart:s,isEnd:c,motion:u,motionNodes:i===v?k.value:null,motionType:A.value,onMotionStart:F,onMotionEnd:j,onMousemove:P},null)}})])}}});export{v as MOTION_KEY,b as MotionEntity,T as default,S as getMinimumRangeTransitionRange};