function K(k,h){const d=new Set;return k.forEach(e=>{h.has(e)||d.add(e)}),d}function S(k){const{disabled:h,disableCheckbox:d,checkable:e}=k||{};return!!(h||d)||e===!1}function p(k,h,d,e){const r=new Set(k),f=new Set;for(let o=0;o<=d;o+=1)(h.get(o)||new Set).forEach(i=>{const{key:n,node:s,children:u=[]}=i;r.has(n)&&!e(s)&&u.filter(a=>!e(a.node)).forEach(a=>{r.add(a.key)})});const t=new Set;for(let o=d;o>=0;o-=1)(h.get(o)||new Set).forEach(i=>{const{parent:n,node:s}=i;if(e(s)||!i.parent||t.has(i.parent.key))return;if(e(i.parent.node)){t.add(n.key);return}let u=!0,a=!1;(n.children||[]).filter(l=>!e(l.node)).forEach(({key:l})=>{const y=r.has(l);u&&!y&&(u=!1),!a&&(y||f.has(l))&&(a=!0)}),u&&r.add(n.key),a&&f.add(n.key),t.add(n.key)});return{checkedKeys:Array.from(r),halfCheckedKeys:Array.from(K(f,r))}}function C(k,h,d,e,r){const f=new Set(k);let t=new Set(h);for(let c=0;c<=e;c+=1)(d.get(c)||new Set).forEach(n=>{const{key:s,node:u,children:a=[]}=n;!f.has(s)&&!t.has(s)&&!r(u)&&a.filter(l=>!r(l.node)).forEach(l=>{f.delete(l.key)})});t=new Set;const o=new Set;for(let c=e;c>=0;c-=1)(d.get(c)||new Set).forEach(n=>{const{parent:s,node:u}=n;if(r(u)||!n.parent||o.has(n.parent.key))return;if(r(n.parent.node)){o.add(s.key);return}let a=!0,l=!1;(s.children||[]).filter(y=>!r(y.node)).forEach(({key:y})=>{const w=f.has(y);a&&!w&&(a=!1),!l&&(w||t.has(y))&&(l=!0)}),a||f.delete(s.key),l&&t.add(s.key),o.add(s.key)});return{checkedKeys:Array.from(f),halfCheckedKeys:Array.from(K(t,f))}}function E(k,h,d,e,r,f){let t;f?t=f:t=S;const o=new Set(k.filter(i=>!!d[i]));let c;return h===!0?c=p(o,r,e,t):c=C(o,h.halfCheckedKeys,r,e,t),c}export{E as conductCheck,S as isCheckDisabled};
