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