"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("../../_util/omit.js"),O=require("../../_util/props-util/index.js"),k=require("../util.js"),S=require("../../_util/util.js");function D(e,s){return e??s}function E(e){const{title:s,_title:d,key:r,children:c}=e||{},o=s||"title";return{title:o,_title:d||[o],key:r||"key",children:c||"children"}}function x(e){function s(d=[]){return O.filterEmpty(d).map(c=>{if(!k.isTreeNode(c))return null;const o=c.children||{},g=c.key,a={};for(const[N,C]of Object.entries(c.props))a[S.camelize(N)]=C;const{isLeaf:f,checkable:h,selectable:n,disabled:i,disableCheckbox:t}=a,p={isLeaf:f||f===""||void 0,checkable:h||h===""||void 0,selectable:n||n===""||void 0,disabled:i||i===""||void 0,disableCheckbox:t||t===""||void 0},l={...a,...p},{title:T=o.title?.(l),icon:v=o.icon?.(l),switcherIcon:m=o.switcherIcon?.(l),...y}=a,b=o.default?.(),u={...y,title:T,icon:v,switcherIcon:m,key:g,isLeaf:f,...p},P=s(b);return P.length&&(u.children=P),u})}return s(e)}function w(e,s,d){const{_title:r,key:c,children:o}=E(d),g=new Set(s===!0?[]:s),a=[];function f(h,n=null){return h.map((i,t)=>{const p=k.getPosition(n?n.pos:"0",t),l=D(i[c],p);let T;for(let m=0;m<r.length;m+=1){const y=r[m];if(i[y]!==void 0){T=i[y];break}}const v={...G.default(i,[...r,c,o]),title:T,key:l,parent:n,pos:p,children:null,data:i,isStart:[...n?n.isStart:[],t===0],isEnd:[...n?n.isEnd:[],t===h.length-1]};return a.push(v),s===!0||g.has(l)?v.children=f(i[o]||[],v):v.children=[],v})}return f(e),a}function K(e,s,d){let r={};typeof d=="object"?r=d:r={externalGetKey:d},r=r||{};const{childrenPropName:c,externalGetKey:o,fieldNames:g}=r,{key:a,children:f}=E(g),h=c||f;let n;o?typeof o=="string"?n=t=>t[o]:typeof o=="function"&&(n=t=>o(t)):n=(t,p)=>D(t[a],p);function i(t,p,l,T){const v=t?t[h]:e,m=t?k.getPosition(l.pos,p):"0",y=t?[...T,t]:[];if(t){const b=n(t,m),u={node:t,index:p,pos:m,key:b,parentPos:l.node?l.pos:null,level:l.level+1,nodes:y};s(u)}v&&v.forEach((b,u)=>{i(b,u,{node:t,pos:m,level:l?l.level+1:-1},y)})}i(null)}function j(e,{initWrapper:s,processEntity:d,onProcessFinished:r,externalGetKey:c,childrenPropName:o,fieldNames:g}={},a){const f=c||a,h={},n={};let i={posEntities:h,keyEntities:n};return s&&(i=s(i)||i),K(e,t=>{const{node:p,index:l,pos:T,key:v,parentPos:m,level:y,nodes:b}=t,u={node:p,nodes:b,index:l,key:v,pos:T,level:y},P=D(v,T);h[T]=u,n[P]=u,u.parent=h[m],u.parent&&(u.parent.children=u.parent.children||[],u.parent.children.push(u)),d&&d(u,i)},{externalGetKey:f,childrenPropName:o,fieldNames:g}),r&&r(i),i}function q(e,{expandedKeysSet:s,selectedKeysSet:d,loadedKeysSet:r,loadingKeysSet:c,checkedKeysSet:o,halfCheckedKeysSet:g,dragOverNodeKey:a,dropPosition:f,keyEntities:h}){const n=h[e];return{eventKey:e,expanded:s.has(e),selected:d.has(e),loaded:r.has(e),loading:c.has(e),checked:o.has(e),halfChecked:g.has(e),pos:String(n?n.pos:""),parent:n.parent,dragOver:a===e&&f===0,dragOverGapTop:a===e&&f===-1,dragOverGapBottom:a===e&&f===1}}function L(e){const{data:s,expanded:d,selected:r,checked:c,loaded:o,loading:g,halfChecked:a,dragOver:f,dragOverGapTop:h,dragOverGapBottom:n,pos:i,active:t,eventKey:p}=e,l={dataRef:s,...s,expanded:d,selected:r,checked:c,loaded:o,loading:g,halfChecked:a,dragOver:f,dragOverGapTop:h,dragOverGapBottom:n,pos:i,active:t,eventKey:p,key:p};return"props"in l||Object.defineProperty(l,"props",{get(){return e}}),l}exports.convertDataToEntities=j;exports.convertNodePropsToEventData=L;exports.convertTreeToData=x;exports.fillFieldNames=E;exports.flattenTreeData=w;exports.getKey=D;exports.getTreeNodeProps=q;exports.traverseDataNodes=K;
