Files
qhmes/web-dist/js/useMaxLevel-DE205ncc.js
2026-06-16 18:19:57 +08:00

2 lines
8.0 KiB
Java

import{a as w,fb as D,fc as F,c8 as G}from"./index-X7Y8jykP.js";import{w as M,s as z,r as B}from"./vue-vendor-DNhG1Cve.js";function Q(e,t){if(!e)return[];const o=e.slice(),n=o.indexOf(t);return n>=0&&o.splice(n,1),o}function Z(e,t){const o=(e||[]).slice();return o.indexOf(t)===-1&&o.push(t),o}function T(e){return e.split("-")}function _(e,t){return`${e}-${t}`}function R(e){return e&&e.type&&e.type.isTreeNode}function ee(e,t){const o=[],n=t[e];function r(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(d=>{let{key:f,children:u}=d;o.push(f),r(u)})}return r(n.children),o}function $(e){if(e.parent){const t=T(e.pos);return Number(t[t.length-1])===e.parent.children.length-1}return!1}function U(e){const t=T(e.pos);return Number(t[t.length-1])===0}function te(e,t,o,n,r,s,d,f,u,l){var a;const{clientX:i,clientY:c}=e,{top:p,height:h}=e.target.getBoundingClientRect(),g=((l==="rtl"?-1:1)*(((r==null?void 0:r.x)||0)-i)-12)/n;let y=f[o.eventKey];if(c<p+h/2){const C=d.findIndex(L=>L.key===y.key),E=C<=0?0:C-1,I=d[E].key;y=f[I]}const m=y.key,b=y,k=y.key;let K=0,N=0;if(!u.has(m))for(let C=0;C<g&&$(y);C+=1)y=y.parent,N+=1;const P=t.eventData,O=y.node;let S=!0;return U(y)&&y.level===0&&c<p+h/2&&s({dragNode:P,dropNode:O,dropPosition:-1})&&y.key===o.eventKey?K=-1:(b.children||[]).length&&u.has(k)?s({dragNode:P,dropNode:O,dropPosition:0})?K=0:S=!1:N===0?g>-1.5?s({dragNode:P,dropNode:O,dropPosition:1})?K=1:S=!1:s({dragNode:P,dropNode:O,dropPosition:0})?K=0:s({dragNode:P,dropNode:O,dropPosition:1})?K=1:S=!1:s({dragNode:P,dropNode:O,dropPosition:1})?K=1:S=!1,{dropPosition:K,dropLevelOffset:N,dropTargetKey:y.key,dropTargetPos:y.pos,dragOverNodeKey:k,dropContainerKey:K===0?null:((a=y.parent)===null||a===void 0?void 0:a.key)||null,dropAllowed:S}}function ne(e,t){if(!e)return;const{multiple:o}=t;return o?e.slice():e.length?[e[0]]:e}function re(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 null;return t}function oe(e,t){const o=new Set;function n(r){if(o.has(r))return;const s=t[r];if(!s)return;o.add(r);const{parent:d,node:f}=s;f.disabled||d&&n(d.key)}return(e||[]).forEach(r=>{n(r)}),[...o]}var V=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};function x(e,t){return e!=null?e:t}function j(e){const{title:t,_title:o,key:n,children:r}=e||{},s=t||"title";return{title:s,_title:o||[s],key:n||"key",children:r||"children"}}function se(e){function t(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return D(o).map(r=>{var s,d,f,u;if(!R(r))return null;const l=r.children||{},a=r.key,i={};for(const[C,E]of Object.entries(r.props))i[F(C)]=E;const{isLeaf:c,checkable:p,selectable:h,disabled:v,disableCheckbox:g}=i,y={isLeaf:c||c===""||void 0,checkable:p||p===""||void 0,selectable:h||h===""||void 0,disabled:v||v===""||void 0,disableCheckbox:g||g===""||void 0},m=w(w({},i),y),{title:b=(s=l.title)===null||s===void 0?void 0:s.call(l,m),icon:k=(d=l.icon)===null||d===void 0?void 0:d.call(l,m),switcherIcon:K=(f=l.switcherIcon)===null||f===void 0?void 0:f.call(l,m)}=i,N=V(i,["title","icon","switcherIcon"]),P=(u=l.default)===null||u===void 0?void 0:u.call(l),O=w(w(w({},N),{title:b,icon:k,switcherIcon:K,key:a,isLeaf:c}),y),S=t(P);return S.length&&(O.children=S),O})}return t(e)}function ie(e,t,o){const{_title:n,key:r,children:s}=j(o),d=new Set(t===!0?[]:t),f=[];function u(l){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return l.map((i,c)=>{const p=_(a?a.pos:"0",c),h=x(i[r],p);let v;for(let y=0;y<n.length;y+=1){const m=n[y];if(i[m]!==void 0){v=i[m];break}}const g=w(w({},G(i,[...n,r,s])),{title:v,key:h,parent:a,pos:p,children:null,data:i,isStart:[...a?a.isStart:[],c===0],isEnd:[...a?a.isEnd:[],c===l.length-1]});return f.push(g),t===!0||d.has(h)?g.children=u(i[s]||[],g):g.children=[],g})}return u(e),f}function W(e,t,o){let n={};typeof o=="object"?n=o:n={externalGetKey:o},n=n||{};const{childrenPropName:r,externalGetKey:s,fieldNames:d}=n,{key:f,children:u}=j(d),l=r||u;let a;s?typeof s=="string"?a=c=>c[s]:typeof s=="function"&&(a=c=>s(c)):a=(c,p)=>x(c[f],p);function i(c,p,h,v){const g=c?c[l]:e,y=c?_(h.pos,p):"0",m=c?[...v,c]:[];if(c){const b=a(c,y),k={node:c,index:p,pos:y,key:b,parentPos:h.node?h.pos:null,level:h.level+1,nodes:m};t(k)}g&&g.forEach((b,k)=>{i(b,k,{node:c,pos:y,level:h?h.level+1:-1},m)})}i(null)}function le(e){let{initWrapper:t,processEntity:o,onProcessFinished:n,externalGetKey:r,childrenPropName:s,fieldNames:d}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=arguments.length>2?arguments[2]:void 0;const u=r||f,l={},a={};let i={posEntities:l,keyEntities:a};return t&&(i=t(i)||i),W(e,c=>{const{node:p,index:h,pos:v,key:g,parentPos:y,level:m,nodes:b}=c,k={node:p,nodes:b,index:h,key:g,pos:v,level:m},K=x(g,v);l[v]=k,a[K]=k,k.parent=l[y],k.parent&&(k.parent.children=k.parent.children||[],k.parent.children.push(k)),o&&o(k,i)},{externalGetKey:u,childrenPropName:s,fieldNames:d}),n&&n(i),i}function ae(e,t){let{expandedKeysSet:o,selectedKeysSet:n,loadedKeysSet:r,loadingKeysSet:s,checkedKeysSet:d,halfCheckedKeysSet:f,dragOverNodeKey:u,dropPosition:l,keyEntities:a}=t;const i=a[e];return{eventKey:e,expanded:o.has(e),selected:n.has(e),loaded:r.has(e),loading:s.has(e),checked:d.has(e),halfChecked:f.has(e),pos:String(i?i.pos:""),parent:i.parent,dragOver:u===e&&l===0,dragOverGapTop:u===e&&l===-1,dragOverGapBottom:u===e&&l===1}}function ce(e){const{data:t,expanded:o,selected:n,checked:r,loaded:s,loading:d,halfChecked:f,dragOver:u,dragOverGapTop:l,dragOverGapBottom:a,pos:i,active:c,eventKey:p}=e,h=w(w({dataRef:t},t),{expanded:o,selected:n,checked:r,loaded:s,loading:d,halfChecked:f,dragOver:u,dragOverGapTop:l,dragOverGapBottom:a,pos:i,active:c,eventKey:p,key:p});return"props"in h||Object.defineProperty(h,"props",{get(){return e}}),h}function A(e,t){const o=new Set;return e.forEach(n=>{t.has(n)||o.add(n)}),o}function X(e){const{disabled:t,disableCheckbox:o,checkable:n}=e||{};return!!(t||o)||n===!1}function Y(e,t,o,n){const r=new Set(e),s=new Set;for(let f=0;f<=o;f+=1)(t.get(f)||new Set).forEach(l=>{const{key:a,node:i,children:c=[]}=l;r.has(a)&&!n(i)&&c.filter(p=>!n(p.node)).forEach(p=>{r.add(p.key)})});const d=new Set;for(let f=o;f>=0;f-=1)(t.get(f)||new Set).forEach(l=>{const{parent:a,node:i}=l;if(n(i)||!l.parent||d.has(l.parent.key))return;if(n(l.parent.node)){d.add(a.key);return}let c=!0,p=!1;(a.children||[]).filter(h=>!n(h.node)).forEach(h=>{let{key:v}=h;const g=r.has(v);c&&!g&&(c=!1),!p&&(g||s.has(v))&&(p=!0)}),c&&r.add(a.key),p&&s.add(a.key),d.add(a.key)});return{checkedKeys:Array.from(r),halfCheckedKeys:Array.from(A(s,r))}}function q(e,t,o,n,r){const s=new Set(e);let d=new Set(t);for(let u=0;u<=n;u+=1)(o.get(u)||new Set).forEach(a=>{const{key:i,node:c,children:p=[]}=a;!s.has(i)&&!d.has(i)&&!r(c)&&p.filter(h=>!r(h.node)).forEach(h=>{s.delete(h.key)})});d=new Set;const f=new Set;for(let u=n;u>=0;u-=1)(o.get(u)||new Set).forEach(a=>{const{parent:i,node:c}=a;if(r(c)||!a.parent||f.has(a.parent.key))return;if(r(a.parent.node)){f.add(i.key);return}let p=!0,h=!1;(i.children||[]).filter(v=>!r(v.node)).forEach(v=>{let{key:g}=v;const y=s.has(g);p&&!y&&(p=!1),!h&&(y||d.has(g))&&(h=!0)}),p||s.delete(i.key),h&&d.add(i.key),f.add(i.key)});return{checkedKeys:Array.from(s),halfCheckedKeys:Array.from(A(d,s))}}function de(e,t,o,n,r,s){let d;s?d=s:d=X;const f=new Set(e.filter(l=>!!o[l]));let u;return t===!0?u=Y(f,r,n,d):u=q(f,t.halfCheckedKeys,r,n,d),u}function fe(e){const t=B(0),o=z();return M(()=>{const n=new Map;let r=0;const s=e.value||{};for(const d in s)if(Object.prototype.hasOwnProperty.call(s,d)){const f=s[d],{level:u}=f;let l=n.get(u);l||(l=new Set,n.set(u,l)),l.add(f),r=Math.max(r,u)}t.value=r,o.value=n}),{maxLevel:t,levelEntities:o}}export{le as a,oe as b,se as c,de as d,ce as e,j as f,ae as g,x as h,Q as i,ee as j,te as k,Z as l,ie as m,ne as n,re as o,T as p,fe as u};