const e=require("../_virtual/_rolldown/runtime.js"),t=require("../_util/type.js"),n=require("../_util/classNames.js"),r=require("../_util/props-util/initDefaultProps.js"),i=require("../_util/props-util/index.js"),a=require("../config-provider/hooks/useConfigInject.js"),o=require("../vc-tree/util.js"),s=require("../vc-tree/utils/treeUtil.js"),c=require("./Tree.js"),l=require("./utils/dictUtil.js");let u=require("vue"),d=require("@antsoo-lib/icons"),f=require("lodash-es/debounce");f=e.__toESM(f,1);var p=()=>({...c.treeProps(),expandAction:t.someType([Boolean,String])});function m(e){let{isLeaf:t,expanded:n}=e;return t?(0,u.createVNode)(d.FileOutlined,null,null):n?(0,u.createVNode)(d.FolderOpenOutlined,null,null):(0,u.createVNode)(d.FolderOutlined,null,null)}var h=(0,u.defineComponent)({compatConfig:{MODE:3},name:`ADirectoryTree`,inheritAttrs:!1,props:r.default(p(),{showIcon:!0,expandAction:`click`}),slots:Object,setup(e,{attrs:t,slots:r,emit:d,expose:p}){let h=(0,u.ref)(e.treeData||s.convertTreeToData(i.filterEmpty(r.default?.())));(0,u.watch)(()=>e.treeData,()=>{h.value=e.treeData}),(0,u.onUpdated)(()=>{(0,u.nextTick)(()=>{e.treeData===void 0&&r.default&&(h.value=s.convertTreeToData(i.filterEmpty(r.default?.())))})});let g=(0,u.ref)(),_=(0,u.ref)(),v=(0,u.computed)(()=>s.fillFieldNames(e.fieldNames)),y=(0,u.ref)();p({scrollTo:e=>{y.value?.scrollTo(e)},selectedKeys:(0,u.computed)(()=>y.value?.selectedKeys),checkedKeys:(0,u.computed)(()=>y.value?.checkedKeys),halfCheckedKeys:(0,u.computed)(()=>y.value?.halfCheckedKeys),loadedKeys:(0,u.computed)(()=>y.value?.loadedKeys),loadingKeys:(0,u.computed)(()=>y.value?.loadingKeys),expandedKeys:(0,u.computed)(()=>y.value?.expandedKeys)});let b=()=>{let{keyEntities:t}=s.convertDataToEntities(h.value,{fieldNames:v.value}),n;return n=e.defaultExpandAll?Object.keys(t):e.defaultExpandParent?o.conductExpandParent(e.expandedKeys||e.defaultExpandedKeys||[],t):e.expandedKeys||e.defaultExpandedKeys,n},x=(0,u.ref)(e.selectedKeys||e.defaultSelectedKeys||[]),S=(0,u.ref)(b());(0,u.watch)(()=>e.selectedKeys,()=>{e.selectedKeys!==void 0&&(x.value=e.selectedKeys)},{immediate:!0}),(0,u.watch)(()=>e.expandedKeys,()=>{e.expandedKeys!==void 0&&(S.value=e.expandedKeys)},{immediate:!0});let C=(0,f.default)((e,t)=>{let{isLeaf:n}=t;n||e.shiftKey||e.metaKey||e.ctrlKey||y.value.onNodeExpand(e,t)},200,{leading:!0}),w=(t,n)=>{e.expandedKeys===void 0&&(S.value=t),d(`update:expandedKeys`,t),d(`expand`,t,n)},T=(t,n)=>{let{expandAction:r}=e;r===`click`&&C(t,n),d(`click`,t,n)},E=(t,n)=>{let{expandAction:r}=e;(r===`dblclick`||r===`doubleclick`)&&C(t,n),d(`doubleclick`,t,n),d(`dblclick`,t,n)},D=(t,n)=>{let{multiple:r}=e,{node:i,nativeEvent:a}=n,o=i[v.value.key],s={...n,selected:!0},c=a?.ctrlKey||a?.metaKey,u=a?.shiftKey,f;r&&c?(f=t,g.value=o,_.value=f,s.selectedNodes=l.convertDirectoryKeysToNodes(h.value,f,v.value)):r&&u?(f=Array.from(new Set([..._.value||[],...l.calcRangeKeys({treeData:h.value,expandedKeys:S.value,startKey:o,endKey:g.value,fieldNames:v.value})])),s.selectedNodes=l.convertDirectoryKeysToNodes(h.value,f,v.value)):(f=[o],g.value=o,_.value=f,s.selectedNodes=l.convertDirectoryKeysToNodes(h.value,f,v.value)),d(`update:selectedKeys`,f),d(`select`,f,s),e.selectedKeys===void 0&&(x.value=f)},O=(e,t)=>{d(`update:checkedKeys`,e),d(`check`,e,t)},{prefixCls:k,direction:A}=a.default(`tree`,e);return()=>{let i=n.default(`${k.value}-directory`,{[`${k.value}-directory-rtl`]:A.value===`rtl`},t.class),{icon:a=r.icon,blockNode:o=!0,...s}=e;return(0,u.createVNode)(c.default,{...t,icon:a||m,ref:y,blockNode:o,...s,prefixCls:k.value,class:i,expandedKeys:S.value,selectedKeys:x.value,onSelect:D,onClick:T,onDblclick:E,onExpand:w,onCheck:O},r)}}});exports.default=h,exports.directoryTreeProps=p;