import{n as e,s as t,t as n}from"./jsx-runtime-Bzw2jH9X.js";import{$ as r,C as i,E as a,Et as o,G as s,I as c,J as l,V as u,X as d,Y as f,_ as p,b as m,bt as h,c as g,d as _,et as v,i as y,it as b,kt as x,l as S,s as C,tt as w,wt as T,xt as E,z as D}from"./useSize-B63T5I0m.js";import{E as O,O as ee,P as k,Qt as A,Zt as j,dn as M,j as N}from"./services-Ddh4dHvP.js";import{t as te}from"./es-U-GPF54m.js";import{n as P}from"./motion-BqO5uKbL.js";import{a as F}from"./Compact-COtW2uyB.js";import{t as I}from"./AntdIconLight-CvbQyke2.js";import{t as ne}from"./DisabledContext-BTU2x9XV.js";import{n as re}from"./compact-item-H7dJfxqE.js";import{n as L,r as R}from"./Button-BYvGFKvK.js";import{t as z}from"./spin-DUmNjrhn.js";import{t as B}from"./FileOutlined-CKr2chz_.js";import{t as ie}from"./createLucideIcon-BkIMvJln.js";import{t as ae}from"./ellipsis-BH-VjFh2.js";import{t as oe}from"./plus-C1OQIJyL.js";import{t as V}from"./x-CkbzgTHo.js";import{t as se}from"./react-9QMQ-6_p.js";import{B as ce,Ut as le,en as H,qt as ue}from"./index-DkcBoy_T.js";var U=t(e()),de=U.createContext(null),fe=U.createContext({}),pe=e=>{let{dropPosition:t,dropLevelOffset:n,indent:r}=e,i={pointerEvents:`none`,position:`absolute`,right:0,backgroundColor:`red`,height:2};switch(t){case-1:i.top=0,i.left=-n*r;break;case 1:i.bottom=0,i.left=-n*r;break;case 0:i.bottom=0,i.left=r}return U.createElement(`div`,{style:i})},me=U.memo(({prefixCls:e,level:t,isStart:n,isEnd:r})=>{let i=`${e}-indent-unit`,a=[];for(let e=0;e<t;e+=1)a.push(U.createElement(`span`,{key:e,className:d(i,{[`${i}-start`]:n[e],[`${i}-end`]:r[e]})}));return U.createElement(`span`,{"aria-hidden":`true`,className:`${e}-indent`},a)});function W(e,t){return e[t]}function he(e,t){return`${e}-${t}`}function ge(e){return e&&e.type&&e.type.isTreeNode}function G(e,t){return e??t}function K(e){let{title:t,_title:n,key:r,children:i}=e||{},a=t||`title`;return{title:a,_title:n||[a],key:r||`key`,children:i||`children`}}function _e(e){function t(e){return r(e).map(e=>{if(!ge(e))return b(!e,`Tree/TreeNode can only accept TreeNode as children.`),null;let{key:n}=e,{children:r,...i}=e.props,a={key:n,...i},o=t(r);return o.length&&(a.children=o),a}).filter(e=>e)}return t(e)}function ve(e,t,n){let{_title:r,key:i,children:a}=K(n),o=new Set(t===!0?[]:t),s=[];function c(e,n=null){return e.map((l,u)=>{let d=he(n?n.pos:`0`,u),f=G(l[i],d),p;for(let e=0;e<r.length;e+=1){let t=r[e];if(l[t]!==void 0){p=l[t];break}}let m=Object.assign(F(l,[...r,i,a]),{title:p,key:f,parent:n,pos:d,children:null,data:l,isStart:[...n?n.isStart:[],u===0],isEnd:[...n?n.isEnd:[],u===e.length-1]});return s.push(m),m.children=t===!0||o.has(f)?c(l[a]||[],m):[],m})}return c(e),s}function ye(e,t,n){let{childrenPropName:r,externalGetKey:i,fieldNames:a}=typeof n==`object`?n||{}:{externalGetKey:n},{key:o,children:s}=K(a),c=r||s,l;i?typeof i==`string`?l=e=>e[i]:typeof i==`function`&&(l=e=>i(e)):l=(e,t)=>G(e[o],t);function u(n,r,i,a){let o=n?n[c]:e,s=n?he(i.pos,r):`0`,d=n?[...a,n]:[];n&&t({node:n,index:r,pos:s,key:l(n,s),parentPos:i.node?i.pos:null,level:i.level+1,nodes:d}),o&&o.forEach((e,t)=>{u(e,t,{node:n,pos:s,level:i?i.level+1:-1},d)})}u(null)}function be(e,{initWrapper:t,processEntity:n,onProcessFinished:r,externalGetKey:i,childrenPropName:a,fieldNames:o}={},s){let c=i||s,l={},u={},d={posEntities:l,keyEntities:u};return t&&(d=t(d)||d),ye(e,e=>{let{node:t,index:r,pos:i,key:a,parentPos:o,level:s,nodes:c}=e,f={node:t,nodes:c,index:r,key:a,pos:i,level:s},p=G(a,i);l[i]=f,u[p]=f,f.parent=l[o],f.parent&&(f.parent.children=f.parent.children||[],f.parent.children.push(f)),n&&n(f,d)},{externalGetKey:c,childrenPropName:a,fieldNames:o}),r&&r(d),d}function xe(e,t,n,r){return e===!1?!1:e||!t&&!n||t&&r&&!n}function Se(e,{expandedKeys:t,selectedKeys:n,loadedKeys:r,loadingKeys:i,checkedKeys:a,halfCheckedKeys:o,dragOverNodeKey:s,dropPosition:c,keyEntities:l}){let u=W(l,e);return{eventKey:e,expanded:t.indexOf(e)!==-1,selected:n.indexOf(e)!==-1,loaded:r.indexOf(e)!==-1,loading:i.indexOf(e)!==-1,checked:a.indexOf(e)!==-1,halfChecked:o.indexOf(e)!==-1,pos:String(u?u.pos:``),dragOver:s===e&&c===0,dragOverGapTop:s===e&&c===-1,dragOverGapBottom:s===e&&c===1}}function q(e){let{data:t,expanded:n,selected:r,checked:i,loaded:a,loading:o,halfChecked:s,dragOver:c,dragOverGapTop:l,dragOverGapBottom:u,pos:d,active:f,eventKey:p}=e,m={...t,expanded:n,selected:r,checked:i,loaded:a,loading:o,halfChecked:s,dragOver:c,dragOverGapTop:l,dragOverGapBottom:u,pos:d,active:f,key:p};return`props`in m||Object.defineProperty(m,"props",{get(){return b(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),e}}),m}function Ce(){return Ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ce.apply(this,arguments)}var we=`open`,Te=`close`,Ee=`---`,J=e=>{let{eventKey:t,className:n,style:r,dragOver:i,dragOverGapTop:a,dragOverGapBottom:o,isLeaf:s,isStart:c,isEnd:l,expanded:u,selected:f,checked:p,halfChecked:m,loading:g,domRef:_,active:y,data:b,onMouseMove:x,selectable:S,treeId:C,...w}=e,T=h(C,t),E=U.useContext(de),{classNames:D,styles:O}=E||{},ee=U.useContext(fe),k=U.useRef(null),[A,j]=U.useState(!1),M=!!(E.disabled||e.disabled||ee.nodeDisabled?.(b)),N=U.useMemo(()=>!E.checkable||e.checkable===!1?!1:E.checkable,[E.checkable,e.checkable]),te=t=>{M||E.onNodeSelect(t,q(e))},P=t=>{M||N&&!e.disableCheckbox&&E.onNodeCheck(t,q(e),!p)},F=U.useMemo(()=>typeof S==`boolean`?S:E.selectable,[S,E.selectable]),I=t=>{E.onNodeClick(t,q(e)),F?te(t):P(t)},ne=t=>{E.onNodeDoubleClick(t,q(e))},re=t=>{E.onNodeMouseEnter(t,q(e))},L=t=>{E.onNodeMouseLeave(t,q(e))},R=t=>{E.onNodeContextMenu(t,q(e))},z=U.useMemo(()=>!(!E.draggable||E.draggable.nodeDraggable&&!E.draggable.nodeDraggable(b)),[E.draggable,b]),B=t=>{t.stopPropagation(),j(!0),E.onNodeDragStart(t,e);try{t.dataTransfer.setData(`text/plain`,``)}catch{}},ie=t=>{t.preventDefault(),t.stopPropagation(),E.onNodeDragEnter(t,e)},ae=t=>{t.preventDefault(),t.stopPropagation(),E.onNodeDragOver(t,e)},oe=t=>{t.stopPropagation(),E.onNodeDragLeave(t,e)},V=t=>{t.stopPropagation(),j(!1),E.onNodeDragEnd(t,e)},se=t=>{t.preventDefault(),t.stopPropagation(),j(!1),E.onNodeDrop(t,e)},ce=t=>{g||E.onNodeExpand(t,q(e))},le=U.useMemo(()=>{let{children:e}=W(E.keyEntities,t)||{};return!!(e||[]).length},[E.keyEntities,t]),H=U.useMemo(()=>xe(s,E.loadData,le,e.loaded),[s,E.loadData,le,e.loaded]);U.useEffect(()=>{g||typeof E.loadData==`function`&&u&&!H&&!e.loaded&&E.onNodeLoad(q(e))},[g,E.loadData,E.onNodeLoad,u,H,e]);let ue=U.useMemo(()=>E.draggable?.icon?U.createElement(`span`,{className:`${E.prefixCls}-draggable-icon`},E.draggable.icon):null,[E.draggable]),pe=t=>{let n=e.switcherIcon||E.switcherIcon;return typeof n==`function`?n({...e,isLeaf:t}):n},he=()=>{if(H){let e=pe(!0);return e===!1?null:U.createElement(`span`,{className:d(`${E.prefixCls}-switcher`,`${E.prefixCls}-switcher-noop`,D?.itemSwitcher),style:O?.itemSwitcher},e)}let e=pe(!1);return e===!1?null:U.createElement(`span`,{onClick:ce,className:d(`${E.prefixCls}-switcher`,`${E.prefixCls}-switcher_${u?we:Te}`,D?.itemSwitcher),style:O?.itemSwitcher},e)},ge=U.useMemo(()=>{if(!N)return null;let t=typeof N==`boolean`?null:N;return U.createElement(`span`,{className:d(`${E.prefixCls}-checkbox`,{[`${E.prefixCls}-checkbox-checked`]:p,[`${E.prefixCls}-checkbox-indeterminate`]:!p&&m,[`${E.prefixCls}-checkbox-disabled`]:M||e.disableCheckbox}),onClick:P,role:`checkbox`,"aria-checked":m?`mixed`:p,"aria-disabled":M||e.disableCheckbox,"aria-labelledby":T},t)},[N,p,m,M,e.disableCheckbox,T]),G=U.useMemo(()=>H?null:u?we:Te,[H,u]),K=U.useMemo(()=>U.createElement(`span`,{className:d(D?.itemIcon,`${E.prefixCls}-iconEle`,`${E.prefixCls}-icon__${G||`docu`}`,{[`${E.prefixCls}-icon_loading`]:g}),style:O?.itemIcon}),[E.prefixCls,G,g]),_e=U.useMemo(()=>{let n=!!E.draggable;return e.disabled||!n||E.dragOverNodeKey!==t?null:E.dropIndicatorRender({dropPosition:E.dropPosition,dropLevelOffset:E.dropLevelOffset,indent:E.indent,prefixCls:E.prefixCls,direction:E.direction})},[E.dropPosition,E.dropLevelOffset,E.indent,E.prefixCls,E.direction,E.draggable,E.dragOverNodeKey,E.dropIndicatorRender]),ve=U.useMemo(()=>{let{title:t=Ee}=e,n=`${E.prefixCls}-node-content-wrapper`,r;if(E.showIcon){let t=e.icon||E.icon;r=t?U.createElement(`span`,{className:d(D?.itemIcon,`${E.prefixCls}-iconEle`,`${E.prefixCls}-icon__customize`),style:O?.itemIcon},typeof t==`function`?t(e):t):K}else E.loadData&&g&&(r=K);let i;return i=typeof t==`function`?t(b):E.titleRender?E.titleRender(b):t,U.createElement(`span`,{ref:k,title:typeof t==`string`?t:``,className:d(n,`${n}-${G||`normal`}`,{[`${E.prefixCls}-node-selected`]:!M&&(f||A)}),onMouseEnter:re,onMouseLeave:L,onContextMenu:R,onClick:I,onDoubleClick:ne},r,U.createElement(`span`,{className:d(`${E.prefixCls}-title`,D?.itemTitle),style:O?.itemTitle},i),_e)},[E.prefixCls,E.showIcon,e,E.icon,K,E.titleRender,b,G,re,L,R,I,ne]),ye=v(w,{aria:!0,data:!0}),{level:be}=W(E.keyEntities,t)||{},Se=l[l.length-1],J=!M&&z,De=E.draggingNodeKey===t;return U.createElement(`div`,Ce({ref:_,role:`treeitem`,id:T,"aria-expanded":H?void 0:u,"aria-selected":F&&!M?f:void 0,"aria-checked":N&&!M?m?`mixed`:p:void 0,"aria-disabled":M,className:d(n,`${E.prefixCls}-treenode`,D?.item,{[`${E.prefixCls}-treenode-disabled`]:M,[`${E.prefixCls}-treenode-switcher-${u?`open`:`close`}`]:!s,[`${E.prefixCls}-treenode-checkbox-checked`]:p,[`${E.prefixCls}-treenode-checkbox-indeterminate`]:m,[`${E.prefixCls}-treenode-selected`]:f,[`${E.prefixCls}-treenode-loading`]:g,[`${E.prefixCls}-treenode-active`]:y,[`${E.prefixCls}-treenode-leaf-last`]:Se,[`${E.prefixCls}-treenode-draggable`]:z,dragging:De,"drop-target":E.dropTargetKey===t,"drop-container":E.dropContainerKey===t,"drag-over":!M&&i,"drag-over-gap-top":!M&&a,"drag-over-gap-bottom":!M&&o,"filter-node":E.filterTreeNode?.(q(e)),[`${E.prefixCls}-treenode-leaf`]:H}),style:{...r,...O?.item},draggable:J,onDragStart:J?B:void 0,onDragEnter:z?ie:void 0,onDragOver:z?ae:void 0,onDragLeave:z?oe:void 0,onDrop:z?se:void 0,onDragEnd:z?V:void 0,onMouseMove:x},ye),U.createElement(me,{prefixCls:E.prefixCls,level:be,isStart:c,isEnd:l}),ue,he(),ge,ve)};J.isTreeNode=1;function De(e,t){let[n,r]=U.useState(!1);o(()=>{if(n)return e(),()=>{t()}},[n]),o(()=>(r(!0),()=>{r(!1)}),[])}function Oe(){return Oe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Oe.apply(this,arguments)}var ke=U.forwardRef((e,t)=>{let{className:n,style:r,motion:i,motionNodes:a,motionType:s,onMotionStart:c,onMotionEnd:l,active:u,treeNodeRequiredProps:f,...p}=e,[m,h]=U.useState(!0),{prefixCls:g}=U.useContext(de),_=a&&s!==`hide`;o(()=>{a&&_!==m&&h(_)},[a]);let v=()=>{a&&c()},y=U.useRef(!1),b=()=>{a&&!y.current&&(y.current=!0,l())};return De(v,b),a?U.createElement(te,Oe({ref:t,visible:m},i,{motionAppear:s===`show`,onVisibleChanged:e=>{_===e&&b()}}),({className:e,style:t},n)=>U.createElement(`div`,{ref:n,className:d(`${g}-treenode-motion`,e),style:t},a.map(e=>{let{data:{...t},title:n,key:r,isStart:i,isEnd:a}=e;delete t.children;let o=Se(r,f);return U.createElement(J,Oe({},t,o,{title:n,active:u,data:e.data,key:r,isStart:i,isEnd:a}))}))):U.createElement(J,Oe({domRef:t,className:n,style:r},p,{active:u}))});function Ae(e=[],t=[]){let n=e.length,r=t.length;if(Math.abs(n-r)!==1)return{add:!1,key:null};function i(e,t){let n=new Map;e.forEach(e=>{n.set(e,!0)});let r=t.filter(e=>!n.has(e));return r.length===1?r[0]:null}return n<r?{add:!0,key:i(e,t)}:{add:!1,key:i(t,e)}}function je(e,t,n){let r=e[e.findIndex(e=>e.key===n)+1],i=t.findIndex(e=>e.key===n);if(r){let e=t.findIndex(e=>e.key===r.key);return t.slice(i+1,e)}return t.slice(i+1)}function Me(){return Me=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Me.apply(this,arguments)}var Y=`RC_TREE_MOTION_${Math.random()}`,Ne={key:Y},Pe={key:Y,level:0,index:0,pos:`0`,node:Ne,nodes:[Ne]},Fe={parent:null,children:[],pos:Pe.pos,data:Ne,title:null,key:Y,isStart:[],isEnd:[]};function Ie(e,t,n,r){return t===!1||!n?e:e.slice(0,Math.ceil(n/r)+1)}function Le(e){let{key:t,pos:n}=e;return G(t,n)}var Re=U.forwardRef((e,t)=>{let{prefixCls:n,data:r,selectable:i,checkable:a,expandedKeys:s,selectedKeys:c,checkedKeys:l,loadedKeys:u,loadingKeys:d,halfCheckedKeys:f,keyEntities:p,disabled:m,dragging:g,dragOverNodeKey:_,dropPosition:v,motion:y,height:b,itemHeight:x,virtual:S,scrollWidth:C,focusable:w,activeItem:T,tabIndex:D,onKeyDown:O,onFocus:ee,onBlur:k,onMouseDown:A,onActiveChange:j,onListChangeStart:M,onListChangeEnd:N,...te}=e,P=E(),F=U.useRef(null),I=U.useRef(null);U.useImperativeHandle(t,()=>({scrollTo:e=>{F.current.scrollTo(e)},getIndentWidth:()=>I.current.offsetWidth}));let[ne,re]=U.useState(s),[L,R]=U.useState(r),[z,B]=U.useState(r),[ie,ae]=U.useState([]),[oe,V]=U.useState(null),se=U.useRef(r);se.current=r;function ce(){let e=se.current;R(e),B(e),ae([]),V(null),N()}o(()=>{re(s);let e=Ae(ne,s);if(e.key!==null){if(e.add){let t=L.findIndex(({key:t})=>t===e.key),n=Ie(je(L,r,e.key),S,b,x),i=L.slice();i.splice(t+1,0,Fe),B(i),ae(n),V(`show`)}else{let t=r.findIndex(({key:t})=>t===e.key),n=Ie(je(r,L,e.key),S,b,x),i=r.slice();i.splice(t+1,0,Fe),B(i),ae(n),V(`hide`)}}else L!==r&&(R(r),B(r))},[s,r]),U.useEffect(()=>{g||ce()},[g]);let H=y?z:r,ue={expandedKeys:s,selectedKeys:c,loadedKeys:u,loadingKeys:d,checkedKeys:l,halfCheckedKeys:f,dragOverNodeKey:_,dropPosition:v,keyEntities:p};return U.createElement(U.Fragment,null,U.createElement(`div`,{className:`${n}-treenode`,"aria-hidden":!0,style:{position:`absolute`,pointerEvents:`none`,visibility:`hidden`,height:0,overflow:`hidden`,border:0,padding:0}},U.createElement(`div`,{className:`${n}-indent`},U.createElement(`div`,{ref:I,className:`${n}-indent-unit`}))),U.createElement(le,Me({},te,{data:H,itemKey:Le,height:b,fullHeight:!1,virtual:S,itemHeight:x,scrollWidth:C,prefixCls:`${n}-list`,ref:F,role:`tree`,tabIndex:w!==!1&&!m?D:void 0,"aria-activedescendant":T?h(P,T.key):void 0,onKeyDown:O,onFocus:ee,onBlur:k,onMouseDown:A,onVisibleChange:e=>{e.every(e=>Le(e)!==Y)&&ce()}}),e=>{let{pos:t,data:{...n},title:r,key:i,isStart:a,isEnd:o}=e,s=G(i,t);delete n.key,delete n.children;let c=Se(s,ue);return U.createElement(ke,Me({},n,c,{title:r,active:!!T&&i===T.key,pos:t,data:e.data,isStart:a,isEnd:o,motion:y,motionNodes:i===Y?ie:null,motionType:oe,onMotionStart:M,onMotionEnd:ce,treeNodeRequiredProps:ue,treeId:P,onMouseMove:()=>{j(null)}}))}))});function X(e,t){if(!e)return[];let n=e.slice(),r=n.indexOf(t);return r>=0&&n.splice(r,1),n}function Z(e,t){let n=(e||[]).slice();return n.indexOf(t)===-1&&n.push(t),n}function ze(e){return e.split(`-`)}function Be(e,t){let n=[],r=W(t,e);function i(e=[]){e.forEach(({key:e,children:t})=>{n.push(e),i(t)})}return i(r.children),n}function Ve(e){if(e.parent){let t=ze(e.pos);return Number(t[t.length-1])===e.parent.children.length-1}return!1}function He(e){let t=ze(e.pos);return Number(t[t.length-1])===0}function Ue(e,t,n,r,i,a,o,s,c,l){let{clientX:u,clientY:d}=e,{top:f,height:p}=e.target.getBoundingClientRect(),m=((l===`rtl`?-1:1)*((i?.x||0)-u)-12)/r,h=c.filter(e=>s[e]?.children?.length),g=W(s,n.eventKey);if(d<f+p/2){let e=o.findIndex(e=>e.key===g.key),t=o[e<=0?0:e-1].key;g=W(s,t)}let _=g.key,v=g,y=g.key,b=0,x=0;if(!h.includes(_))for(let e=0;e<m&&Ve(g);e+=1)g=g.parent,x+=1;let S=t.data,C=g.node,w=!0;return He(g)&&g.level===0&&d<f+p/2&&a({dragNode:S,dropNode:C,dropPosition:-1})&&g.key===n.eventKey?b=-1:(v.children||[]).length&&h.includes(y)?a({dragNode:S,dropNode:C,dropPosition:0})?b=0:w=!1:x===0?m>-1.5?a({dragNode:S,dropNode:C,dropPosition:1})?b=1:w=!1:a({dragNode:S,dropNode:C,dropPosition:0})?b=0:a({dragNode:S,dropNode:C,dropPosition:1})?b=1:w=!1:a({dragNode:S,dropNode:C,dropPosition:1})?b=1:w=!1,{dropPosition:b,dropLevelOffset:x,dropTargetKey:g.key,dropTargetPos:g.pos,dragOverNodeKey:y,dropContainerKey:b===0?null:g.parent?.key||null,dropAllowed:w}}function We(e,t){if(!e)return;let{multiple:n}=t;return n?e.slice():e.length?[e[0]]:e}function Ge(e){if(!e)return null;let t;if(Array.isArray(e))t={checkedKeys:e,halfCheckedKeys:void 0};else if(typeof e==`object`)t={checkedKeys:e.checked||void 0,halfCheckedKeys:e.halfChecked||void 0};else return b(!1,"`checkedKeys` is not an array or an object"),null;return t}function Ke(e,t){let n=new Set;function r(e){if(n.has(e))return;let i=W(t,e);if(!i)return;n.add(e);let{parent:a,node:o}=i;o.disabled||a&&r(a.key)}return(e||[]).forEach(e=>{r(e)}),[...n]}function qe(e,t){let n=new Set;return e.forEach(e=>{t.has(e)||n.add(e)}),n}function Je(e){let{disabled:t,disableCheckbox:n,checkable:r}=e||{};return!!(t||n)||r===!1}function Ye(e,t,n,r){let i=new Set(e),a=new Set;for(let e=0;e<=n;e+=1)(t.get(e)||new Set).forEach(e=>{let{key:t,node:n,children:a=[]}=e;i.has(t)&&!r(n)&&a.filter(e=>!r(e.node)).forEach(e=>{i.add(e.key)})});let o=new Set;for(let e=n;e>=0;--e)(t.get(e)||new Set).forEach(e=>{let{parent:t,node:n}=e;if(r(n)||!e.parent||o.has(e.parent.key))return;if(r(e.parent.node)){o.add(t.key);return}let s=!0,c=!1;(t.children||[]).filter(e=>!r(e.node)).forEach(({key:e})=>{let t=i.has(e);s&&!t&&(s=!1),!c&&(t||a.has(e))&&(c=!0)}),s&&i.add(t.key),c&&a.add(t.key),o.add(t.key)});return{checkedKeys:Array.from(i),halfCheckedKeys:Array.from(qe(a,i))}}function Xe(e,t,n,r,i){let a=new Set(e),o=new Set(t);for(let e=0;e<=r;e+=1)(n.get(e)||new Set).forEach(e=>{let{key:t,node:n,children:r=[]}=e;!a.has(t)&&!o.has(t)&&!i(n)&&r.filter(e=>!i(e.node)).forEach(e=>{a.delete(e.key)})});o=new Set;let s=new Set;for(let e=r;e>=0;--e)(n.get(e)||new Set).forEach(e=>{let{parent:t,node:n}=e;if(i(n)||!e.parent||s.has(e.parent.key))return;if(i(e.parent.node)){s.add(t.key);return}let r=!0,c=!1;(t.children||[]).filter(e=>!i(e.node)).forEach(({key:e})=>{let t=a.has(e);r&&!t&&(r=!1),!c&&(t||o.has(e))&&(c=!0)}),r||a.delete(t.key),c&&o.add(t.key),s.add(t.key)});return{checkedKeys:Array.from(a),halfCheckedKeys:Array.from(qe(o,a))}}function Ze(e,t,n,r){let i=[],a;a=r||Je;let o=new Set(e.filter(e=>{let t=!!W(n,e);return t||i.push(e),t})),s=new Map,c=0;Object.keys(n).forEach(e=>{let t=n[e],{level:r}=t,i=s.get(r);i||(i=new Set,s.set(r,i)),i.add(t),c=Math.max(c,r)}),b(!i.length,`Tree missing follow keys: ${i.slice(0,100).map(e=>`'${e}'`).join(`, `)}`);let l;return l=t===!0?Ye(o,s,c,a):Xe(o,t.halfCheckedKeys,s,c,a),l}function Qe(){return Qe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Qe.apply(this,arguments)}var $e=10,et=class extends U.Component{static defaultProps={prefixCls:`rc-tree`,showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[],dropIndicatorRender:pe,allowDrop:()=>!0,expandAction:!1};static TreeNode=J;destroyed=!1;delayedDragEnterLogic;loadingRetryTimes={};state={keyEntities:{},indent:null,selectedKeys:[],checkedKeys:[],halfCheckedKeys:[],loadedKeys:[],loadingKeys:[],expandedKeys:[],draggingNodeKey:null,dragChildrenKeys:[],dropTargetKey:null,dropPosition:null,dropContainerKey:null,dropLevelOffset:null,dropTargetPos:null,dropAllowed:!0,dragOverNodeKey:null,treeData:[],flattenNodes:[],activeKey:null,listChanging:!1,prevProps:null,fieldNames:K()};dragStartMousePosition=null;dragNodeProps=null;currentMouseOverDroppableNodeKey=null;focusedByMouse=!1;listRef=U.createRef();componentDidMount(){this.destroyed=!1,this.onUpdated(),window.addEventListener(`mouseup`,this.onGlobalMouseUp)}componentDidUpdate(){this.onUpdated()}onUpdated(){let{activeKey:e,itemScrollOffset:t=0}=this.props;e!==void 0&&e!==this.state.activeKey&&(this.setState({activeKey:e}),e!==null&&this.scrollTo({key:e,offset:t}))}componentWillUnmount(){window.removeEventListener(`dragend`,this.onWindowDragEnd),window.removeEventListener(`mouseup`,this.onGlobalMouseUp),this.destroyed=!0}static getDerivedStateFromProps(e,t){let{prevProps:n}=t,r={prevProps:e};function i(t){return!n&&e.hasOwnProperty(t)||n&&n[t]!==e[t]}let a,{fieldNames:o}=t;if(i(`fieldNames`)&&(o=K(e.fieldNames),r.fieldNames=o),i(`treeData`)?{treeData:a}=e:i(`children`)&&(b(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),a=_e(e.children)),a){r.treeData=a;let e=be(a,{fieldNames:o});r.keyEntities={[Y]:Pe,...e.keyEntities}}let s=r.keyEntities||t.keyEntities;if(i(`expandedKeys`)||n&&i(`autoExpandParent`))r.expandedKeys=e.autoExpandParent||!n&&e.defaultExpandParent?Ke(e.expandedKeys,s):e.expandedKeys;else if(!n&&e.defaultExpandAll){let e={...s};delete e[Y];let t=[];Object.keys(e).forEach(n=>{let r=e[n];r.children&&r.children.length&&t.push(r.key)}),r.expandedKeys=t}else!n&&e.defaultExpandedKeys&&(r.expandedKeys=e.autoExpandParent||e.defaultExpandParent?Ke(e.defaultExpandedKeys,s):e.defaultExpandedKeys);if(r.expandedKeys||delete r.expandedKeys,(a||r.expandedKeys)&&(r.flattenNodes=ve(a||t.treeData,r.expandedKeys||t.expandedKeys,o)),e.selectable&&(i(`selectedKeys`)?r.selectedKeys=We(e.selectedKeys,e):!n&&e.defaultSelectedKeys&&(r.selectedKeys=We(e.defaultSelectedKeys,e))),e.checkable){let o;if(i(`checkedKeys`)?o=Ge(e.checkedKeys)||{}:!n&&e.defaultCheckedKeys?o=Ge(e.defaultCheckedKeys)||{}:a&&(o=Ge(e.checkedKeys)||{checkedKeys:t.checkedKeys,halfCheckedKeys:t.halfCheckedKeys}),o){let{checkedKeys:t=[],halfCheckedKeys:n=[]}=o;if(!e.checkStrictly){let e=Ze(t,!0,s);({checkedKeys:t,halfCheckedKeys:n}=e)}r.checkedKeys=t,r.halfCheckedKeys=n}}return i(`loadedKeys`)&&(r.loadedKeys=e.loadedKeys),r}onNodeDragStart=(e,t)=>{let{expandedKeys:n,keyEntities:r}=this.state,{onDragStart:i}=this.props,{eventKey:a}=t;this.dragNodeProps=t,this.dragStartMousePosition={x:e.clientX,y:e.clientY};let o=X(n,a);this.setState({draggingNodeKey:a,dragChildrenKeys:Be(a,r),indent:this.listRef.current.getIndentWidth()}),this.setExpandedKeys(o),window.addEventListener(`dragend`,this.onWindowDragEnd),i?.({event:e,node:q(t)})};onNodeDragEnter=(e,t)=>{let{expandedKeys:n,keyEntities:r,dragChildrenKeys:i,flattenNodes:a,indent:o}=this.state,{onDragEnter:s,onExpand:c,allowDrop:l,direction:u}=this.props,{pos:d,eventKey:f}=t;if(this.currentMouseOverDroppableNodeKey!==f&&(this.currentMouseOverDroppableNodeKey=f),!this.dragNodeProps){this.resetDragState();return}let{dropPosition:p,dropLevelOffset:m,dropTargetKey:h,dropContainerKey:g,dropTargetPos:_,dropAllowed:v,dragOverNodeKey:y}=Ue(e,this.dragNodeProps,t,o,this.dragStartMousePosition,l,a,r,n,u);if(i.includes(h)||!v){this.resetDragState();return}if(this.delayedDragEnterLogic||={},Object.keys(this.delayedDragEnterLogic).forEach(e=>{clearTimeout(this.delayedDragEnterLogic[e])}),this.dragNodeProps.eventKey!==t.eventKey&&(e.persist(),this.delayedDragEnterLogic[d]=window.setTimeout(()=>{if(this.state.draggingNodeKey===null)return;let i=[...n],a=W(r,t.eventKey);a&&(a.children||[]).length&&(i=Z(n,t.eventKey)),this.setExpandedKeys(i),c?.(i,{node:q(t),expanded:!0,nativeEvent:e.nativeEvent})},800)),this.dragNodeProps.eventKey===h&&m===0){this.resetDragState();return}this.setState({dragOverNodeKey:y,dropPosition:p,dropLevelOffset:m,dropTargetKey:h,dropContainerKey:g,dropTargetPos:_,dropAllowed:v}),s?.({event:e,node:q(t),expandedKeys:n})};onNodeDragOver=(e,t)=>{let{dragChildrenKeys:n,flattenNodes:r,keyEntities:i,expandedKeys:a,indent:o}=this.state,{onDragOver:s,allowDrop:c,direction:l}=this.props;if(!this.dragNodeProps)return;let{dropPosition:u,dropLevelOffset:d,dropTargetKey:f,dropContainerKey:p,dropTargetPos:m,dropAllowed:h,dragOverNodeKey:g}=Ue(e,this.dragNodeProps,t,o,this.dragStartMousePosition,c,r,i,a,l);!n.includes(f)&&h&&(this.dragNodeProps.eventKey===f&&d===0?(this.state.dropPosition!==null||this.state.dropLevelOffset!==null||this.state.dropTargetKey!==null||this.state.dropContainerKey!==null||this.state.dropTargetPos!==null||this.state.dropAllowed!==!1||this.state.dragOverNodeKey!==null)&&this.resetDragState():(u!==this.state.dropPosition||d!==this.state.dropLevelOffset||f!==this.state.dropTargetKey||p!==this.state.dropContainerKey||m!==this.state.dropTargetPos||h!==this.state.dropAllowed||g!==this.state.dragOverNodeKey)&&this.setState({dropPosition:u,dropLevelOffset:d,dropTargetKey:f,dropContainerKey:p,dropTargetPos:m,dropAllowed:h,dragOverNodeKey:g}),s?.({event:e,node:q(t)}))};onNodeDragLeave=(e,t)=>{this.currentMouseOverDroppableNodeKey===t.eventKey&&!e.currentTarget.contains(e.relatedTarget)&&(this.resetDragState(),this.currentMouseOverDroppableNodeKey=null);let{onDragLeave:n}=this.props;n?.({event:e,node:q(t)})};onWindowDragEnd=e=>{this.onNodeDragEnd(e,null,!0),window.removeEventListener(`dragend`,this.onWindowDragEnd)};onNodeDragEnd=(e,t)=>{let{onDragEnd:n}=this.props;this.setState({dragOverNodeKey:null}),this.cleanDragState(),n?.({event:e,node:q(t)}),this.dragNodeProps=null,window.removeEventListener(`dragend`,this.onWindowDragEnd)};onNodeDrop=(e,t,n=!1)=>{let{dragChildrenKeys:r,dropPosition:i,dropTargetKey:a,dropTargetPos:o,dropAllowed:s}=this.state;if(!s)return;let{onDrop:c}=this.props;if(this.setState({dragOverNodeKey:null}),this.cleanDragState(),a===null)return;let l={...Se(a,this.getTreeNodeRequiredProps()),active:this.getActiveItem()?.key===a,data:W(this.state.keyEntities,a).node},u=r.includes(a);b(!u,`Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.`);let d=ze(o),f={event:e,node:q(l),dragNode:this.dragNodeProps?q(this.dragNodeProps):null,dragNodesKeys:[this.dragNodeProps.eventKey].concat(r),dropToGap:i!==0,dropPosition:i+Number(d[d.length-1])};n||c?.(f),this.dragNodeProps=null};resetDragState(){this.setState({dragOverNodeKey:null,dropPosition:null,dropLevelOffset:null,dropTargetKey:null,dropContainerKey:null,dropTargetPos:null,dropAllowed:!1})}cleanDragState=()=>{let{draggingNodeKey:e}=this.state;e!==null&&this.setState({draggingNodeKey:null,dropPosition:null,dropContainerKey:null,dropTargetKey:null,dropLevelOffset:null,dropAllowed:!0,dragOverNodeKey:null}),this.dragStartMousePosition=null,this.currentMouseOverDroppableNodeKey=null};triggerExpandActionExpand=(e,t)=>{let{expandedKeys:n,flattenNodes:r}=this.state,{expanded:i,key:a,isLeaf:o}=t;if(o||e.shiftKey||e.metaKey||e.ctrlKey)return;let s=r.filter(e=>e.key===a)[0],c=q({...Se(a,this.getTreeNodeRequiredProps()),data:s.data});this.setExpandedKeys(i?X(n,a):Z(n,a)),this.onNodeExpand(e,c)};onNodeClick=(e,t)=>{let{onClick:n,expandAction:r}=this.props;r===`click`&&this.triggerExpandActionExpand(e,t),n?.(e,t)};onNodeDoubleClick=(e,t)=>{let{onDoubleClick:n,expandAction:r}=this.props;r===`doubleClick`&&this.triggerExpandActionExpand(e,t),n?.(e,t)};onNodeSelect=(e,t)=>{let{selectedKeys:n}=this.state,{keyEntities:r,fieldNames:i}=this.state,{onSelect:a,multiple:o}=this.props,{selected:s}=t,c=t[i.key],l=!s;n=l?o?Z(n,c):[c]:X(n,c);let u=n.map(e=>{let t=W(r,e);return t?t.node:null}).filter(Boolean);this.setUncontrolledState({selectedKeys:n}),a?.(n,{event:`select`,selected:l,node:t,selectedNodes:u,nativeEvent:e.nativeEvent})};onNodeCheck=(e,t,n)=>{let{keyEntities:r,checkedKeys:i,halfCheckedKeys:a}=this.state,{checkStrictly:o,onCheck:s}=this.props,{key:c}=t,l,u={event:`check`,node:t,checked:n,nativeEvent:e.nativeEvent};if(o){let e=n?Z(i,c):X(i,c);l={checked:e,halfChecked:X(a,c)},u.checkedNodes=e.map(e=>W(r,e)).filter(Boolean).map(e=>e.node),this.setUncontrolledState({checkedKeys:e})}else{let{checkedKeys:e,halfCheckedKeys:t}=Ze([...i,c],!0,r);if(!n){let n=new Set(e);n.delete(c),{checkedKeys:e,halfCheckedKeys:t}=Ze(Array.from(n),{checked:!1,halfCheckedKeys:t},r)}l=e,u.checkedNodes=[],u.checkedNodesPositions=[],u.halfCheckedKeys=t,e.forEach(e=>{let t=W(r,e);if(!t)return;let{node:n,pos:i}=t;u.checkedNodes.push(n),u.checkedNodesPositions.push({node:n,pos:i})}),this.setUncontrolledState({checkedKeys:e},!1,{halfCheckedKeys:t})}s?.(l,u)};onNodeLoad=e=>{let{key:t}=e,{keyEntities:n}=this.state;if(W(n,t)?.children?.length)return;let r=new Promise((n,r)=>{this.setState(({loadedKeys:i=[],loadingKeys:a=[]})=>{let{loadData:o,onLoad:s}=this.props;return!o||i.includes(t)||a.includes(t)?null:(o(e).then(()=>{let{loadedKeys:r}=this.state,i=Z(r,t);s?.(i,{event:`load`,node:e}),this.setUncontrolledState({loadedKeys:i}),this.setState(e=>({loadingKeys:X(e.loadingKeys,t)})),n()}).catch(e=>{if(this.setState(e=>({loadingKeys:X(e.loadingKeys,t)})),this.loadingRetryTimes[t]=(this.loadingRetryTimes[t]||0)+1,this.loadingRetryTimes[t]>=$e){let{loadedKeys:e}=this.state;b(!1,"Retry for `loadData` many times but still failed. No more retry."),this.setUncontrolledState({loadedKeys:Z(e,t)}),n()}r(e)}),{loadingKeys:Z(a,t)})})});return r.catch(()=>{}),r};onNodeMouseEnter=(e,t)=>{let{onMouseEnter:n}=this.props;n?.({event:e,node:t})};onNodeMouseLeave=(e,t)=>{let{onMouseLeave:n}=this.props;n?.({event:e,node:t})};onNodeContextMenu=(e,t)=>{let{onRightClick:n}=this.props;n&&(e.preventDefault(),n({event:e,node:t}))};onMouseDown=e=>{this.focusedByMouse=!0;let{onMouseDown:t}=this.props;t?.(e)};onGlobalMouseUp=()=>{this.focusedByMouse=!1};onFocus=(...e)=>{let{onFocus:t,disabled:n}=this.props,{activeKey:r,selectedKeys:i,flattenNodes:a}=this.state;if(!this.focusedByMouse&&!n&&r===null){let e=i.find(e=>a.some(t=>t.key===e));e===void 0?this.onActiveChange(a?.[0]?.key||null):this.onActiveChange(e)}t?.(...e)};onBlur=(...e)=>{let{onBlur:t}=this.props;this.onActiveChange(null),t?.(...e)};getTreeNodeRequiredProps=()=>{let{expandedKeys:e,selectedKeys:t,loadedKeys:n,loadingKeys:r,checkedKeys:i,halfCheckedKeys:a,dragOverNodeKey:o,dropPosition:s,keyEntities:c}=this.state;return{expandedKeys:e||[],selectedKeys:t||[],loadedKeys:n||[],loadingKeys:r||[],checkedKeys:i||[],halfCheckedKeys:a||[],dragOverNodeKey:o,dropPosition:s,keyEntities:c}};setExpandedKeys=e=>{if(this.props.hasOwnProperty(`expandedKeys`))return;let{treeData:t,fieldNames:n}=this.state,r=ve(t,e,n);this.setUncontrolledState({expandedKeys:e,flattenNodes:r},!0)};onNodeExpand=(e,t)=>{let{expandedKeys:n}=this.state,{listChanging:r,fieldNames:i}=this.state,{onExpand:a,loadData:o}=this.props,{expanded:s}=t,c=t[i.key];if(r)return;let l=n.includes(c),u=!s;if(b(s&&l||!s&&!l,`Expand state not sync with index check`),n=u?Z(n,c):X(n,c),this.setExpandedKeys(n),a?.(n,{node:t,expanded:u,nativeEvent:e.nativeEvent}),u&&o){let e=this.onNodeLoad(t);e&&e.then(()=>{let e=ve(this.state.treeData,n,i);this.setUncontrolledState({flattenNodes:e})}).catch(()=>{let{expandedKeys:e}=this.state,t=X(e,c);this.setExpandedKeys(t)})}};onListChangeStart=()=>{this.setUncontrolledState({listChanging:!0})};onListChangeEnd=()=>{setTimeout(()=>{this.setUncontrolledState({listChanging:!1})})};onActiveChange=e=>{let{activeKey:t}=this.state,{onActiveChange:n,itemScrollOffset:r=0}=this.props;t!==e&&(this.setState({activeKey:e}),e!==null&&this.scrollTo({key:e,offset:r}),n?.(e))};getActiveItem=()=>{let{activeKey:e,flattenNodes:t}=this.state;return e===null?null:t.find(({key:t})=>t===e)||null};offsetActiveKey=e=>{let{flattenNodes:t,activeKey:n}=this.state,r=t.findIndex(({key:e})=>e===n);r===-1&&e<0&&(r=t.length),r=(r+e+t.length)%t.length;let i=t[r];if(i){let{key:e}=i;this.onActiveChange(e)}else this.onActiveChange(null)};onKeyDown=e=>{let{activeKey:t,expandedKeys:n,checkedKeys:r,flattenNodes:i,keyEntities:a}=this.state,{onKeyDown:o,checkable:s,selectable:c,disabled:l,loadData:u}=this.props;if(l)return;switch(e.key){case`ArrowUp`:this.offsetActiveKey(-1),e.preventDefault();break;case`ArrowDown`:this.offsetActiveKey(1),e.preventDefault();break;case`Home`:this.onActiveChange(i?.[0]?.key),e.preventDefault();break;case`End`:this.onActiveChange(i?.[i.length-1]?.key),e.preventDefault()}let d=this.getActiveItem();if(d&&d.data){let i=q({...Se(t,this.getTreeNodeRequiredProps()),data:d.data,active:!0}),o=!!W(a,t)?.children?.length,l=!xe(d.data.isLeaf,u,o,i.loaded),f=s&&!i.disabled&&i.checkable!==!1&&!i.disableCheckbox,p=!s&&c&&!i.disabled&&i.selectable!==!1;switch(e.key){case`ArrowLeft`:l&&n.includes(t)?this.onNodeExpand({},i):d.parent&&this.onActiveChange(d.parent.key),e.preventDefault();break;case`ArrowRight`:l&&!n.includes(t)?this.onNodeExpand({},i):d.children&&d.children.length&&this.onActiveChange(d.children[0].key),e.preventDefault();break;case`Enter`:l?(e.preventDefault(),this.onNodeExpand({},i)):f?r.includes(t)||(e.preventDefault(),this.onNodeCheck({},i,!0)):p&&!i.selected&&(e.preventDefault(),this.onNodeSelect({},i));break;case` `:f?(e.preventDefault(),this.onNodeCheck({},i,!r.includes(t))):p&&(e.preventDefault(),this.onNodeSelect({},i))}}o?.(e)};setUncontrolledState=(e,t=!1,n=null)=>{if(!this.destroyed){let r=!1,i=!0,a={};Object.keys(e).forEach(t=>{if(this.props.hasOwnProperty(t)){i=!1;return}r=!0,a[t]=e[t]}),r&&(!t||i)&&this.setState({...a,...n})}};scrollTo=e=>{e&&typeof e==`object`&&e.autoExpand&&this.setExpandedKeys(Z(this.state.expandedKeys,e.key)),this.listRef.current.scrollTo(e)};render(){let{flattenNodes:e,keyEntities:t,draggingNodeKey:n,dropLevelOffset:r,dropContainerKey:i,dropTargetKey:a,dropPosition:o,dragOverNodeKey:s,indent:c}=this.state,{prefixCls:l,className:u,style:f,styles:p,classNames:m,showLine:h,focusable:g,tabIndex:_=0,selectable:y,showIcon:b,icon:x,switcherIcon:S,draggable:C,checkable:w,checkStrictly:T,disabled:E,motion:D,loadData:O,filterTreeNode:ee,height:k,itemHeight:A,scrollWidth:j,virtual:M,titleRender:N,dropIndicatorRender:te,onContextMenu:P,onScroll:F,direction:I,rootClassName:ne,rootStyle:re}=this.props,L=v(this.props,{aria:!0,data:!0}),R;C&&(R=typeof C==`object`?C:typeof C==`function`?{nodeDraggable:C}:{});let z={styles:p,classNames:m,prefixCls:l,selectable:y,showIcon:b,icon:x,switcherIcon:S,draggable:R,draggingNodeKey:n,checkable:w,checkStrictly:T,disabled:E,keyEntities:t,dropLevelOffset:r,dropContainerKey:i,dropTargetKey:a,dropPosition:o,dragOverNodeKey:s,indent:c,direction:I,dropIndicatorRender:te,loadData:O,filterTreeNode:ee,titleRender:N,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop};return U.createElement(de.Provider,{value:z},U.createElement(`div`,{className:d(l,u,ne,{[`${l}-show-line`]:h}),style:re},U.createElement(Re,Qe({ref:this.listRef,prefixCls:l,style:f,data:e,disabled:E,selectable:y,checkable:!!w,motion:D,dragging:n!==null,height:k,itemHeight:A,virtual:M,focusable:g,tabIndex:_,activeItem:this.getActiveItem(),onFocus:this.onFocus,onMouseDown:this.onMouseDown,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:P,onScroll:F,scrollWidth:j},this.getTreeNodeRequiredProps(),L))))}};function tt(e,t){let{fieldNames:n}=t,r=U.useMemo(()=>{let{keyEntities:t}=be(e,{fieldNames:n});return t},[e,n]);return{getPath:x(e=>{let t=[],n=W(r,e);for(;n;)t.unshift(n),n=n.parent;return t})}}var nt=et,rt=e=>{let{checkboxCls:t,checkboxSize:n,lineWidth:r}=e,a=`${t}-wrapper`,o=`@media (hover: hover) and (pointer: fine)`;return[{[`${t}-group`]:{...i(e),display:`inline-flex`,flexWrap:`wrap`,columnGap:e.marginXS,[`> ${e.antCls}-row`]:{flex:1}},[a]:{...i(e),display:`inline-flex`,alignItems:`baseline`,cursor:`pointer`,"&:after":{display:`inline-block`,width:0,overflow:`hidden`,content:`'\\a0'`},[`& + ${a}`]:{marginInlineStart:0}},[t]:{...i(e),position:`relative`,whiteSpace:`nowrap`,lineHeight:1,cursor:`pointer`,alignSelf:`center`,boxSizing:`border-box`,display:`block`,width:n,height:n,direction:`ltr`,backgroundColor:e.colorBgContainer,border:`${u(r)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,borderCollapse:`separate`,transition:`all ${e.motionDurationSlow}`,flex:`none`,...R(),"&:after":{boxSizing:`border-box`,position:`absolute`,top:`calc(${n} / 2 - ${r})`,insetInlineStart:`calc(${n} / 4 - ${r})`,display:`table`,width:e.calc(n).div(14).mul(5).equal(),height:e.calc(n).div(14).mul(8).equal(),border:`${u(e.lineWidthBold)} solid ${e.colorWhite}`,borderTop:0,borderInlineStart:0,transform:`rotate(45deg) scale(0) translate(-50%,-50%)`,opacity:0,content:`""`,transition:`all ${e.motionDurationFast} ${e.motionEaseInBack}, opacity ${e.motionDurationFast}`,...L()},[`${t}-input`]:{position:`absolute`,inset:`calc(-1 * (${r}))`,zIndex:1,cursor:`pointer`,opacity:0,margin:0},[`&:has(${t}-input:focus-visible)`]:m(e),"& + span":{paddingInlineStart:e.paddingXS,paddingInlineEnd:e.paddingXS}}},{[o]:{[`
          ${a}:not(${a}-disabled),
          ${t}:not(${t}-disabled)
        `]:{[`&:hover ${t}`]:{borderColor:e.colorPrimary}},[`${a}:not(${a}-disabled)`]:{[`&:hover ${t}-checked:not(${t}-disabled)`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}}},{[`${t}-checked`]:{backgroundColor:e.colorPrimary,borderColor:e.colorPrimary,"&:after":{opacity:1,transform:`rotate(45deg) scale(1) translate(-50%,-50%)`,transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack} ${e.motionDurationFast}`,...L()},[o]:{[`&:not(${t}-disabled):hover`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}}},{[t]:{"&-indeterminate":{backgroundColor:e.colorBgContainer,borderColor:e.colorBorder,"&:after":{top:`50%`,insetInlineStart:`50%`,width:e.calc(e.fontSizeLG).div(2).equal(),height:e.calc(e.fontSizeLG).div(2).equal(),backgroundColor:e.colorPrimary,border:0,transform:`translate(-50%, -50%) scale(1)`,opacity:1,content:`""`},[o]:{[`&:not(${t}-disabled):hover`]:{backgroundColor:e.colorBgContainer,borderColor:e.colorPrimary}}}}},{[`${a}-disabled`]:{cursor:`not-allowed`},[`${t}-disabled`]:{[`&, ${t}-input`]:{cursor:`not-allowed`,pointerEvents:`none`},background:e.colorBgContainerDisabled,borderColor:e.colorBorder,"&:after":{borderColor:e.colorTextDisabled},"& + span":{color:e.colorTextDisabled},[`&${t}-indeterminate::after`]:{background:e.colorTextDisabled}}}]};function it(e,t){return rt(c(t,{checkboxCls:`.${e}`,checkboxSize:t.controlInteractiveSize}))}p(`Checkbox`,(e,{prefixCls:t})=>[it(t,e)]);var at={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z`}}]},name:`folder-open`,theme:`outlined`};function ot(){return ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ot.apply(this,arguments)}var st=U.forwardRef((e,t)=>U.createElement(I,ot({},e,{ref:t,icon:at}))),ct={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z`}}]},name:`folder`,theme:`outlined`};function lt(){return lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lt.apply(this,arguments)}var ut=U.forwardRef((e,t)=>U.createElement(I,lt({},e,{ref:t,icon:ct}))),dt={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M300 276.5a56 56 0 1056-97 56 56 0 00-56 97zm0 284a56 56 0 1056-97 56 56 0 00-56 97zM640 228a56 56 0 10112 0 56 56 0 00-112 0zm0 284a56 56 0 10112 0 56 56 0 00-112 0zM300 844.5a56 56 0 1056-97 56 56 0 00-56 97zM640 796a56 56 0 10112 0 56 56 0 00-112 0z`}}]},name:`holder`,theme:`outlined`};function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ft.apply(this,arguments)}var pt=U.forwardRef((e,t)=>U.createElement(I,ft({},e,{ref:t,icon:dt}))),mt=({treeCls:e,treeNodeCls:t,directoryNodeSelectedBg:n,directoryNodeSelectedColor:r,motionDurationMid:i,borderRadius:a,controlItemBgHover:o})=>({[`${e}${e}-directory ${t}`]:{[`${e}-node-content-wrapper`]:{position:`static`,[`&:has(${e}-drop-indicator)`]:{position:`relative`},[`> *:not(${e}-drop-indicator)`]:{position:`relative`},"&:hover":{background:`transparent`},"&:before":{position:`absolute`,inset:0,transition:`background-color ${i}`,content:`""`,borderRadius:a},"&:hover:before":{background:o}},[`${e}-switcher, ${e}-checkbox, ${e}-draggable-icon`]:{zIndex:1},"&-selected":{background:n,borderRadius:a,[`${e}-switcher, ${e}-draggable-icon`]:{color:r},[`${e}-node-content-wrapper`]:{color:r,background:`transparent`,"&, &:hover":{color:r},"&:before, &:hover:before":{background:n}}}}}),ht=new D(`ant-tree-node-fx-do-not-use`,{"0%":{opacity:0},"100%":{opacity:1}}),gt=(e,t)=>({[`.${e}-switcher-icon`]:{display:`inline-block`,fontSize:10,verticalAlign:`baseline`,svg:{transition:`transform ${t.motionDurationSlow}`}}}),_t=(e,t)=>({[`.${e}-drop-indicator`]:{position:`absolute`,zIndex:1,height:2,backgroundColor:t.colorPrimary,borderRadius:1,pointerEvents:`none`,"&:after":{position:`absolute`,top:-3,insetInlineStart:-6,width:8,height:8,backgroundColor:`transparent`,border:`${u(t.lineWidthBold)} solid ${t.colorPrimary}`,borderRadius:`50%`,content:`""`}}}),vt=(e,t)=>{let{treeCls:n,treeNodeCls:r,treeNodePadding:a,titleHeight:o,indentSize:s,switcherSize:c,motionDurationMid:l,nodeSelectedBg:d,nodeHoverBg:f,colorTextQuaternary:p,controlItemBgActiveDisabled:h}=t;return{[n]:{...i(t),"--rc-virtual-list-scrollbar-bg":t.colorSplit,background:t.colorBgContainer,borderRadius:t.borderRadius,transition:`background-color ${t.motionDurationSlow}`,"&-rtl":{direction:`rtl`},[`&${n}-rtl ${n}-switcher_close ${n}-switcher-icon svg`]:{transform:`rotate(90deg)`},[`${n}-list`]:{"&:focus-visible":{outline:`none`,[`${r}-active ${n}-node-content-wrapper`]:{...m(t)}}},[`${n}-list-scrollbar`]:{cursor:`pointer`,"&:hover":{backgroundColor:t.colorFillQuaternary}},[`${n}-list-holder-inner`]:{alignItems:`flex-start`},[`&${n}-block-node`]:{[`${n}-list-holder-inner`]:{alignItems:`stretch`,[`${n}-node-content-wrapper`]:{flex:`auto`},[`${r}.dragging:after`]:{position:`absolute`,inset:0,border:`${u(t.lineWidth)} ${t.lineType} ${t.colorPrimary}`,opacity:0,animationName:ht,animationDuration:t.motionDurationSlow,animationPlayState:`running`,animationFillMode:`forwards`,content:`""`,pointerEvents:`none`,borderRadius:t.borderRadius}}},[r]:{display:`flex`,alignItems:`flex-start`,marginBottom:a,lineHeight:u(o),position:`relative`,"&:before":{content:`""`,position:`absolute`,zIndex:1,insetInlineStart:0,width:`100%`,top:`100%`,height:a},[`&-disabled ${n}-node-content-wrapper`]:{color:t.colorTextDisabled,cursor:`not-allowed`,"&:hover":{background:`transparent`}},[`${n}-checkbox-disabled + ${n}-node-selected,&${r}-disabled${r}-selected ${n}-node-content-wrapper`]:{backgroundColor:h},[`${n}-checkbox-disabled`]:{pointerEvents:`unset`},[`&:not(${r}-disabled)`]:{[`${n}-node-content-wrapper`]:{"&:hover":{color:t.nodeHoverColor}}},[`&-active ${n}-node-content-wrapper`]:{background:t.controlItemBgHover},[`&:not(${r}-disabled).filter-node ${n}-title`]:{color:t.colorPrimary,fontWeight:t.fontWeightStrong},"&-draggable":{cursor:`grab`,[`${n}-draggable-icon`]:{flexShrink:0,width:c,textAlign:`center`,visibility:`visible`,color:p},[`&${r}-disabled ${n}-draggable-icon`]:{visibility:`hidden`}}},[`${n}-indent`]:{alignSelf:`stretch`,whiteSpace:`nowrap`,userSelect:`none`,"&-unit":{display:`inline-block`,width:s}},[`${n}-draggable-icon`]:{visibility:`hidden`},[`${n}-switcher, ${n}-checkbox`]:{marginInlineEnd:t.calc(t.calc(c).sub(t.controlInteractiveSize)).div(2).equal()},[`${n}-checkbox`]:{flexShrink:0,alignSelf:`flex-start`,marginBlockStart:t.calc(t.calc(o).sub(t.controlInteractiveSize)).div(2).equal()},[`${n}-switcher`]:{...gt(e,t),position:`relative`,flex:`none`,alignSelf:`stretch`,width:c,textAlign:`center`,cursor:`pointer`,userSelect:`none`,transition:`all ${t.motionDurationSlow}`,"&-noop":{cursor:`unset`},"&:before":{pointerEvents:`none`,content:`""`,width:c,height:o,position:`absolute`,left:{_skip_check_:!0,value:0},top:0,borderRadius:t.borderRadius,transition:`all ${t.motionDurationSlow}`},[`&:not(${n}-switcher-noop):hover:before`]:{backgroundColor:t.colorBgTextHover},[`&_close ${n}-switcher-icon svg`]:{transform:`rotate(-90deg)`},"&-loading-icon":{color:t.colorPrimary},"&-leaf-line":{position:`relative`,zIndex:1,display:`inline-block`,width:`100%`,height:`100%`,"&:before":{position:`absolute`,top:0,insetInlineEnd:t.calc(c).div(2).equal(),bottom:t.calc(a).mul(-1).equal(),marginInlineStart:t.calc(t.lineWidth).mul(-1).equal(),borderInlineEnd:`${u(t.lineWidth)} ${t.lineType} ${t.colorBorder}`,content:`""`},"&:after":{position:`absolute`,width:t.calc(t.calc(c).div(2).equal()).mul(.8).equal(),height:t.calc(o).div(2).equal(),borderBottom:`${u(t.lineWidth)} ${t.lineType} ${t.colorBorder}`,content:`""`}}},[`${n}-node-content-wrapper`]:{position:`relative`,minHeight:o,paddingBlock:0,paddingInline:t.paddingXS,background:`transparent`,borderRadius:t.borderRadius,cursor:`pointer`,transition:[`all ${l}`,`border 0s`,`line-height 0s`,`box-shadow 0s`].join(`, `),..._t(e,t),"&:hover":{backgroundColor:f},[`&${n}-node-selected`]:{color:t.nodeSelectedColor,backgroundColor:d},[`${n}-iconEle`]:{display:`inline-block`,width:c,height:o,textAlign:`center`,verticalAlign:`top`,"&:empty":{display:`none`}}},[`${n}-unselectable ${n}-node-content-wrapper:hover`]:{backgroundColor:`transparent`},[`${r}.drop-container > [draggable]`]:{boxShadow:`0 0 0 2px ${t.colorPrimary}`},"&-show-line":{[`${n}-indent-unit`]:{position:`relative`,height:`100%`,"&:before":{position:`absolute`,top:0,insetInlineEnd:t.calc(c).div(2).equal(),bottom:t.calc(a).mul(-1).equal(),borderInlineEnd:`${u(t.lineWidth)} ${t.lineType} ${t.colorBorder}`,content:`""`},"&-end:before":{display:`none`}},[`${n}-switcher`]:{background:`transparent`,"&-line-icon":{verticalAlign:`-0.15em`}}},[`${r}-leaf-last ${n}-switcher-leaf-line:before`]:{top:`auto !important`,bottom:`auto !important`,height:`${u(t.calc(o).div(2).equal())} !important`}}}},yt=(e,t,n=!0)=>{let r=`.${e}`,i=`${r}-treenode`,a=t.calc(t.paddingXS).div(2).equal(),o=c(t,{treeCls:r,treeNodeCls:i,treeNodePadding:a});return[vt(e,o),n&&mt(o)].filter(Boolean)},bt=e=>{let{controlHeightSM:t,controlItemBgHover:n,controlItemBgActive:r}=e,i=t;return{titleHeight:i,switcherSize:i,indentSize:i,nodeHoverBg:n,nodeHoverColor:e.colorText,nodeSelectedBg:r,nodeSelectedColor:e.colorText}},xt=p(`Tree`,(e,{prefixCls:t})=>[{[e.componentCls]:it(`${t}-checkbox`,e)},yt(t,e),H(e)],e=>{let{colorTextLightSolid:t,colorPrimary:n}=e;return{...bt(e),directoryNodeSelectedColor:t,directoryNodeSelectedBg:n}}),St=e=>{let{dropPosition:t,dropLevelOffset:n,prefixCls:r,indent:i,direction:a=`ltr`}=e,o=a===`ltr`?`left`:`right`,s=a===`ltr`?`right`:`left`,c={[o]:-n*i+4,[s]:0};switch(t){case-1:c.top=-3;break;case 1:c.bottom=-3;break;default:c.bottom=-3,c[o]=i+4}return U.createElement(`div`,{style:c,className:`${r}-drop-indicator`})},Ct={icon:{tag:`svg`,attrs:{viewBox:`0 0 1024 1024`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z`}}]},name:`caret-down`,theme:`filled`};function wt(){return wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wt.apply(this,arguments)}var Tt=U.forwardRef((e,t)=>U.createElement(I,wt({},e,{ref:t,icon:Ct}))),Et={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z`}},{tag:`path`,attrs:{d:`M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z`}}]},name:`minus-square`,theme:`outlined`};function Dt(){return Dt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Dt.apply(this,arguments)}var Ot=U.forwardRef((e,t)=>U.createElement(I,Dt({},e,{ref:t,icon:Et}))),kt={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z`}},{tag:`path`,attrs:{d:`M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z`}}]},name:`plus-square`,theme:`outlined`};function At(){return At=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},At.apply(this,arguments)}var jt=U.forwardRef((e,t)=>U.createElement(I,At({},e,{ref:t,icon:kt}))),Mt=e=>{let{prefixCls:t,switcherIcon:n,treeNodeProps:r,showLine:i,switcherLoadingIcon:a}=e,{isLeaf:o,expanded:s,loading:c}=r;if(c)return U.isValidElement(a)?a:U.createElement(re,{className:`${t}-switcher-loading-icon`});let l;if(_(i)&&(l=i.showLeafIcon),o){if(!i)return null;if(typeof l!=`boolean`&&l){let e=S(l)?l(r):l,n=`${t}-switcher-line-custom-icon`;return U.isValidElement(e)?y(e,{className:d(e.props?.className,n)}):e}return l?U.createElement(B,{className:`${t}-switcher-line-icon`}):U.createElement(`span`,{className:`${t}-switcher-leaf-line`})}let u=`${t}-switcher-icon`,f=S(n)?n(r):n;return U.isValidElement(f)?y(f,{className:d(f.props?.className,i?`${t}-switcher-line-icon`:u)}):f===void 0?i?s?U.createElement(Ot,{className:`${t}-switcher-line-icon`}):U.createElement(jt,{className:`${t}-switcher-line-icon`}):U.createElement(Tt,{className:u}):f},Nt=U.forwardRef((e,t)=>{let{getPrefixCls:n,direction:r,className:i,style:o,classNames:c,styles:u}=l(`tree`),{virtual:f}=U.useContext(s),{prefixCls:p,className:m,showIcon:h=!1,showLine:_,switcherIcon:v,switcherLoadingIcon:y,blockNode:b=!1,children:x,checkable:S=!1,selectable:w=!0,draggable:T,disabled:E,motion:D,style:O,rootClassName:ee,rootStyle:k,classNames:A,styles:j,icon:M}=e,N=U.useContext(ne),te=E??N,F=n(`tree`,p),I=n(),re=D??{...P(I),motionAppear:!1},L={...e,showIcon:h,blockNode:b,checkable:S,selectable:w,disabled:te,motion:re},R=g(k),[z,B]=C([c,A],[u,R,j],{props:L}),ie={...L,showLine:!!_,icon:M,dropIndicatorRender:St},[ae,oe]=xt(F),[,V]=a(),se=V.paddingXS/2+(V.Tree?.titleHeight||V.controlHeightSM),ce=U.useMemo(()=>{if(!T)return!1;let e={};switch(typeof T){case`function`:e.nodeDraggable=T;break;case`object`:e={...T}}return e.icon!==!1&&(e.icon=e.icon||U.createElement(pt,null)),e},[T]),le=e=>U.createElement(Mt,{prefixCls:F,switcherIcon:v,switcherLoadingIcon:y,treeNodeProps:e,showLine:_});return U.createElement(nt,{itemHeight:se,ref:t,virtual:f,...ie,prefixCls:F,className:d({[`${F}-icon-hide`]:!h,[`${F}-block-node`]:b,[`${F}-unselectable`]:!w,[`${F}-rtl`]:r===`rtl`,[`${F}-disabled`]:te},i,m,ae,oe),style:{...o,...O},rootClassName:d(z.root,ee),rootStyle:B.root,classNames:z,styles:B,direction:r,checkable:S&&U.createElement(`span`,{className:`${F}-checkbox-inner`}),selectable:w,switcherIcon:le,draggable:ce},x)}),Pt=0,Ft=1,It=2;function Lt(e,t,n){let{key:r,children:i}=n;function a(e){let a=e[r],o=e[i];t(a,e)!==!1&&Lt(o||[],t,n)}e.forEach(a)}function Rt({treeData:e,expandedKeys:t,startKey:n,endKey:r,fieldNames:i}){let a=[],o=Pt;if(!w(n)||!w(r))return[];if(n===r)return[n];function s(e){return e===n||e===r}return Lt(e,e=>{if(o===It)return!1;if(s(e)){if(a.push(e),o===Pt)o=Ft;else if(o===Ft)return o=It,!1}else o===Ft&&a.push(e);return t.includes(e)},K(i)),a}function zt(e,t,n){let r=f(t),i=[];return Lt(e,(e,t)=>{let n=r.indexOf(e);return n!==-1&&(i.push(t),r.splice(n,1)),!!r.length},K(n)),i}function Bt(e){let{isLeaf:t,expanded:n}=e;return t?U.createElement(B,null):n?U.createElement(st,null):U.createElement(ut,null)}function Vt({treeData:e,children:t}){return e||_e(t)}var Ht=U.forwardRef((e,t)=>{let{defaultExpandAll:n,defaultExpandParent:r=!0,defaultExpandedKeys:i,...a}=e,o=U.useRef(null),c=U.useRef(null),l=()=>{let{keyEntities:e}=be(Vt(a),{fieldNames:a.fieldNames}),t,o=a.expandedKeys||i||[];return t=n?Object.keys(e):r?Ke(o,e):o,t},[u,p]=T(a.defaultSelectedKeys||[],a.selectedKeys),[m,h]=T(l,a.expandedKeys),g=(e,t)=>(h(e),a.onExpand?.(e,t)),_=(e,t)=>{let{multiple:n,fieldNames:r}=a,{node:i,nativeEvent:s}=t,{key:l=``}=i,u=Vt(a),d={...t,selected:!0},h=s?.ctrlKey||s?.metaKey,g=s?.shiftKey,_;n&&h?(_=e,o.current=l,c.current=_,d.selectedNodes=zt(u,_,r)):n&&g?(_=Array.from(new Set([].concat(f(c.current||[]),f(Rt({treeData:u,expandedKeys:m,startKey:l,endKey:o.current,fieldNames:r}))))),d.selectedNodes=zt(u,_,r)):(_=[l],o.current=l,c.current=_,d.selectedNodes=zt(u,_,r)),a.onSelect?.(_,d),p(_)},{getPrefixCls:v,direction:y}=U.useContext(s),{prefixCls:b,className:x,showIcon:S=!0,expandAction:C=`click`,...w}=a,E=v(`tree`,b),D=d(`${E}-directory`,{[`${E}-directory-rtl`]:y===`rtl`},x);return U.createElement(Nt,{icon:Bt,ref:t,blockNode:!0,...w,showIcon:S,expandAction:C,prefixCls:E,className:D,defaultExpandParent:r,expandedKeys:m,selectedKeys:u,onSelect:_,onExpand:g})}),Ut=Nt;Ut.DirectoryTree=Ht,Ut.TreeNode=J,Ut.useTree=tt;var Wt={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Wt.node;var Gt=ie(Wt),Kt={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};Kt.node;var qt=ie(Kt),Jt={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Jt.node;var Yt=ie(Jt),Xt=t(M(),1),Q=n(),Zt=160;function Qt(e,t=0){let n=e.bottom+4;t>0&&n+t>window.innerHeight-8&&e.top>t+4&&(n=e.top-t-4);let r=Math.min(Math.max(8,e.right-Zt),window.innerWidth-Zt-8);return{top:n,left:r}}function $t({items:e,open:t,anchorRef:n,onClose:r}){let i=(0,U.useRef)(null);return(0,U.useLayoutEffect)(()=>{if(!t)return;let e=()=>{let e=n.current,t=i.current;if(!e||!t)return;let r=Qt(e.getBoundingClientRect(),t.offsetHeight);t.style.top=`${r.top}px`,t.style.left=`${r.left}px`,t.style.visibility=`visible`};return e(),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[t,e.length,n]),ce(i,t,r),!t||!e.length?null:(0,Xt.createPortal)((0,Q.jsx)(`div`,{ref:i,className:`fixed ${A.global} w-40 rounded-lg border border-slate-100 bg-white py-1 shadow-xl`,style:{top:0,left:0,visibility:`hidden`},onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:e.map((t,n)=>(0,Q.jsxs)(`div`,{children:[t.danger&&e.slice(0,n).some(e=>!e.danger)&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-slate-100`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{r(),t.onClick()},className:t.danger?`flex w-full items-center gap-2 px-3 py-2 text-xs text-rose-500 transition-colors hover:bg-rose-50`:`flex w-full items-center gap-2 px-3 py-2 text-xs text-slate-600 transition-colors hover:bg-slate-50`,children:[t.icon,t.label]})]},t.key))}),document.body)}function en({open:e,onOpenChange:t,items:n}){let r=(0,U.useRef)(null);return(0,Q.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Q.jsx)(`button`,{ref:r,type:`button`,className:e?`relative ${A.chrome} p-1 text-slate-600 opacity-100`:`p-1 text-slate-400 opacity-0 transition-opacity group-hover:opacity-100 hover:text-slate-600`,onMouseDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),t(!e)},children:(0,Q.jsx)(ae,{size:18,className:`text-slate-400`})}),(0,Q.jsx)($t,{open:e,anchorRef:r,onClose:()=>t(!1),items:n})]})}function tn({title:e,onClose:t,onConfirm:n,initialValue:r=``,placeholder:i=`请输入`}){let[a,o]=(0,U.useState)(r),[s,c]=(0,U.useState)(!1),l=()=>{s||t()},u=async()=>{if(!s){c(!0);try{await n(a.trim())}finally{c(!1)}}};return(0,Q.jsxs)(`div`,{className:`fixed inset-0 ${A.global} flex items-center justify-center p-4`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:l}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl border border-slate-100 bg-white p-6 shadow-2xl`,children:[(0,Q.jsx)(`h4`,{className:`mb-4 text-base font-bold text-slate-800`,children:e}),(0,Q.jsx)(`input`,{autoFocus:!0,value:a,disabled:s,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!s&&u()},placeholder:i,className:`mb-4 w-full rounded-lg border border-slate-200 px-4 py-3 text-sm outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 disabled:bg-slate-50`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:s,onClick:l,className:`rounded-lg px-4 py-2 text-sm text-slate-600 hover:bg-slate-100 disabled:opacity-50`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>void u(),className:`rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50`,children:s?`处理中...`:`确定`})]})]})]})}function nn(e){let t=e.trim();return t.length>=1&&t.length<=20}function rn(e){return e.map(e=>({key:e.id,title:e.name,isLeaf:e.children.length===0,children:rn(e.children)}))}function $(e,t){for(let n of e){if(n.id===t)return n;let e=$(n.children,t);if(e)return e}return null}function an(e){return e.length===0?1:Math.max(...e.map(e=>e.sort))+1}function on(e){let t=[];for(let n of e)n.children.length>0&&(t.push(n.id),t.push(...on(n.children)));return t}function sn(e,t,n){return e.map(e=>e.id===t?n(e):e.children.length===0?e:{...e,children:sn(e.children,t,n)})}function cn(e,t){let n=[];for(let r of e)r.id!==t&&n.push({...r,children:cn(r.children,t)});return n}function ln(e,t,n){return t===0?[n,...e]:sn(e,t,e=>({...e,children:[n,...e.children]}))}function un(e,t){return{...e,level:t,children:e.children.map(e=>un(e,t+1))}}function dn(e,t,n){let r=$(e,t),i=cn(e,t);return[un({...r,parentId:0,sort:n},1),...i]}function fn(e,t,n){return sn(e,t,e=>({...e,name:n}))}function pn(e,t){return t===0?e:$(e,t).children}function mn(e){return e.children.length===0?0:1+Math.max(...e.children.map(mn))}function hn(e,t,n,r){let i=$(e,t),a=$(e,n);return t===n||$(i.children,n)?!1:(r?a.level+1:a.level)+mn(i)<=3}function gn(e,t,n,r,i){let a=$(e,t),o=$(e,n),s=r?o.parentId:o.id,c=r?o.level:o.level+1,l=pn(e,s).filter(e=>e.id!==t),u=0;if(r){let e=l.findIndex(e=>e.id===n);u=i===-1?e:e+1}if(a.parentId===s&&pn(e,a.parentId).findIndex(e=>e.id===t)===u)return null;let d,f=[];return l.length===0||u===0?d=an(l):u===l.length?d=Math.min(...l.map(e=>e.sort))-1:(d=l[u].sort+1,f=l.slice(0,u).map(e=>({id:e.id,sort:e.sort+1}))),{id:t,parentId:s,level:c,sort:d,bumps:f}}function _n(e,t){let n=$(e,t.id),r=cn(e,t.id),i=un({...n,parentId:t.parentId,sort:t.sort},t.level),a=new Map(t.bumps.map(e=>[e.id,e.sort])),o=[...pn(r,t.parentId).map(e=>a.has(e.id)?{...e,sort:a.get(e.id)}:e),i].sort((e,t)=>t.sort-e.sort);return t.parentId===0?o:sn(r,t.parentId,e=>({...e,children:o}))}var vn={order:`DESC`,sort:`sort`};async function yn(e,t){return(await N({level:e,parentId:t,...vn})).map(e=>({...e,children:[]}))}async function bn(){let e=await yn(1,0),t=e;for(let e=2;e<=3&&t.length!==0;e++)await Promise.all(t.map(async t=>{t.children=await yn(e,t.id)})),t=t.flatMap(e=>e.children);return e}function xn(){let[e,t]=(0,U.useState)([]),[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(!0);return(0,U.useEffect)(()=>{(async()=>{a(!0);try{let e=await bn();t(e),r(on(e))}catch(e){console.error(e)}finally{a(!1)}})()},[]),{folders:e,loading:i,expandedKeys:n,setExpandedKeys:r,createFolder:async(n,i)=>{let a=n===0?null:$(e,n),o=an(a?a.children:e),s=await O({parentId:n,name:i,level:a?a.level+1:1,sort:o});return t(e=>ln(e,n,{...s,children:[]})),a&&r(e=>e.includes(a.id)?e:[...e,a.id]),s},renameFolder:async(e,n)=>{await k(e,{name:n}),t(t=>fn(t,e,n))},deleteFolder:async e=>{await ee(e),t(t=>cn(t,e))},moveToRoot:async n=>{let r=an(e);await k(n,{parentId:0,level:1,sort:r}),t(e=>dn(e,n,r))},moveFolder:async e=>{await Promise.all([k(e.id,{parentId:e.parentId,level:e.level,sort:e.sort}),...e.bumps.map(e=>k(e.id,{sort:e.sort}))]),t(t=>_n(t,e)),e.parentId!==0&&r(t=>t.includes(e.parentId)?t:[...t,e.parentId])}}}function Sn({folder:e,selectedDictId:t,allowManage:n,menuOpen:r,menuItems:i,onMenuOpenChange:a}){let o=t===e.id;return(0,Q.jsxs)(`div`,{className:`group relative flex h-9 w-full items-center gap-2 pr-1`,"data-folder-menu-open":r?`true`:void 0,children:[(0,Q.jsx)(Gt,{size:18,className:o?`shrink-0 text-blue-500`:`shrink-0 text-blue-300`,fill:o?`currentColor`:`none`,fillOpacity:.2}),(0,Q.jsx)(`span`,{className:o?`min-w-0 flex-1 truncate text-sm font-medium text-blue-600`:`min-w-0 flex-1 truncate text-sm text-slate-700`,children:e.name}),n&&(0,Q.jsx)(en,{open:r,onOpenChange:a,items:i})]})}function Cn({title:e,onClose:t,onConfirm:n,allowManage:r=!1}){let{modal:i}=ue.useApp(),{folders:a,loading:o,expandedKeys:s,setExpandedKeys:c,createFolder:l,renameFolder:u,deleteFolder:d}=xn(),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(null),b=()=>{m||(p(null),_(null),t())},x=async()=>{if(!m){if(f==null){j.error(`请选择文件夹`);return}h(!0);try{await n(f)}finally{h(!1)}}},S=e=>{y({type:`create`,parentId:e})},C=e=>{y({type:`rename`,id:e.id,initialName:e.name})},w=()=>{y(null)},T=async e=>{if(v==null)return;if(!nn(e)){j.error(`文件名必须为1-20个字符`);return}if(v.type===`create`){try{await l(v.parentId,e),j.success(`添加成功!`),w()}catch(e){console.error(e)}return}let t=$(a,v.id);if(!t){j.error(`文件夹不存在`),w();return}if(e===t.name){w();return}try{await u(v.id,e),j.success(`重命名成功`),w()}catch(e){console.error(e),j.error(`重命名失败,请重试`)}},E=e=>{i.confirm({title:`提示`,content:`此操作将移除此文件夹内收藏的所有报告,确定继续?`,centered:!0,okText:`确定`,cancelText:`取消`,onOk:async()=>{try{await d(e),f===e&&p(null),j.success(`删除成功`)}catch(e){console.error(e),j.error(`删除失败,请重试`)}}})},D=e=>{let t=[];return e.level<3&&t.push({key:`createSubfolder`,label:`新建子文件夹`,icon:(0,Q.jsx)(oe,{size:14}),onClick:()=>S(e.id)}),t.push({key:`rename`,label:`重命名`,icon:(0,Q.jsx)(qt,{size:14}),onClick:()=>C({id:e.id,name:e.name})},{key:`delete`,label:`删除`,icon:(0,Q.jsx)(Yt,{size:14}),onClick:()=>E(e.id),danger:!0}),t},O=rn(a);return(0,Q.jsxs)(`div`,{className:`fixed inset-0 ${A.overlay} flex items-center justify-center p-4`,children:[(0,Q.jsx)(se.div,{initial:{opacity:0},animate:{opacity:1},onClick:m?void 0:b,className:`absolute inset-0 bg-black/40 backdrop-blur-sm`}),(0,Q.jsxs)(se.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},className:`relative flex w-full max-w-md flex-col overflow-hidden rounded-xl bg-white shadow-2xl`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-slate-100 px-6 py-4`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-bold text-slate-800`,children:e}),(0,Q.jsx)(`button`,{type:`button`,disabled:m,onClick:b,className:`text-slate-400 transition-colors hover:text-slate-600 disabled:cursor-not-allowed disabled:opacity-50`,children:(0,Q.jsx)(V,{size:20})})]}),r&&(0,Q.jsx)(`div`,{className:`shrink-0 px-6 pt-3`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(0),className:`flex w-full items-center justify-center gap-2 rounded-md border border-blue-600 px-4 py-2 text-sm font-medium text-blue-600 transition-colors hover:bg-blue-50`,children:[(0,Q.jsx)(oe,{size:16}),`新建文件夹`]})}),(0,Q.jsx)(`div`,{className:`max-h-80 min-h-50 overflow-y-auto px-3 py-3`,children:o?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(z,{description:`加载中...`})}):a.length===0?(0,Q.jsx)(`div`,{className:`py-10 text-center text-sm text-slate-400`,children:r?`暂无文件夹,请先新建`:`暂无文件夹`}):(0,Q.jsx)(Ut,{className:`favorite-folder-picker-tree`,classNames:{itemSwitcher:`self-center! mr-0!`},blockNode:!0,treeData:O,selectedKeys:f==null?[]:[f],expandedKeys:s,onExpand:c,onSelect:(e,{node:t})=>{p(Number(t.key))},titleRender:e=>{let t=$(a,Number(e.key));return t?(0,Q.jsx)(Sn,{folder:t,selectedDictId:f,allowManage:r,menuOpen:g===t.id,menuItems:D(t),onMenuOpenChange:e=>_(e?t.id:null)}):null}})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-3 border-t border-slate-100 bg-slate-50 px-6 py-4`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:m,onClick:b,className:`rounded-lg px-6 py-2 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-200 disabled:cursor-not-allowed disabled:opacity-50`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>void x(),className:`rounded-lg bg-blue-600 px-6 py-2 text-sm font-medium text-white shadow-lg shadow-blue-600/20 transition-all hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:m?`处理中...`:`确定`})]})]}),v&&(0,Q.jsx)(tn,{title:v.type===`create`?`新建文件夹`:`重命名文件夹`,placeholder:`文件夹名称(1-20个字符)`,initialValue:v.type===`rename`?v.initialName:``,onClose:w,onConfirm:T})]})}export{nn as a,tn as c,qt as d,Gt as f,$ as i,en as l,xn as n,gn as o,Ut as p,hn as r,rn as s,Cn as t,Yt as u};