Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-accessible-treeview

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-accessible-treeview - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

dist/__tests__/TreeViewOnSelect.test.d.ts

2

dist/react-accessible-treeview.cjs.js

@@ -1,1 +0,1 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("classnames")),a=e(require("prop-types")),n=require("react"),l=e(n);function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,l,r=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(r.push(n.value),!t||r.length!==t);d=!0);}catch(e){i=!0,l=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw l}}return r}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function u(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=c(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,l=function(){};return{s:l,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,r=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw r}}}}function f(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)t.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(e,n[l])&&(a[n[l]]=e[n[l]])}return a}var h=function(){},p=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=u(t);try{for(n.s();!(a=n.n()).done;){var l=a.value;if(l&&l(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},v=function(e,t){var a,n=new Set,l=u(e);try{for(l.s();!(a=l.n()).done;){var r=a.value;t.has(r)||n.add(r)}}catch(e){l.e(e)}finally{l.f()}return n},b=function(e,t){return new Set([].concat(s(v(e,t)),s(v(t,e))))},I=function(e){var t=n.useRef();return n.useEffect((function(){t.current=e}),[e]),t.current},S=function(e,t){var a;return!!(null===(a=k(e,t).children)||void 0===a?void 0:a.length)},y=function(e,t){return k(e,t).parent},g=function(e,t,a){for(var n=t,l=[];;){var r=y(e,n);if(0===r||null==r||null!=r&&a.has(r))break;l.push(r),n=r}return l},m=function(e,t,a){var n=[];return function e(t,l){var r=k(t,l);if(null!=r.children){var d,i=u(r.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},w=function(e,t){var a=k(e,t);return null==a.children?[]:a.children},E=function(e,t,a){var n=y(e,t);if(null!=n){var l=k(e,n),r=l.children.indexOf(t)+a;if(l.children[r])return l.children[r]}return null},A=function(e,t,a){var n=k(e,t);for(L(e).id===t&&(n=k(e,k(e,t).children[k(e,t).children.length-1]));a.has(n.id)&&S(e,n.id);)n=k(e,n.children[n.children.length-1]);return n.id},O=function(e,t,a){if(t===L(e).children[0])return null;var n=E(e,t,-1);return null==n?y(e,t):A(e,n,a)},W=function(e,t,a){var n=k(e,t).id;if(S(e,n)&&a.has(n))return k(e,n).children[0];for(;;){var l=E(e,n,1);if(null!=l)return l;if(null==(n=y(e,n)))return null}},x=function(e){var t=e.data,a=e.expandedIds,n=e.from,l=e.to,r=[],d=t.length,i=0,s=n;if(r.push(n),n<l)for(;i<d&&(null!=(s=W(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;else if(n>l)for(;i<d&&(null!=(s=O(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;return r},T=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},j=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,l=e.multiSelect;return a?t:n?"mixed":l?t:!!t||void 0},N=function(e,t,a){return t.concat.apply(t,s(t.filter((function(t){return S(e,t)})).map((function(t){return m(e,t,a)}))))},D=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},C=function(e,t,a){return S(e,t)&&a.has(t)&&m(e,t,new Set).some((function(e){return a.has(e)}))},U=function(e,t,a){var n=w(e,t);return S(e,t)&&!a.has(t)&&1===n.length&&n.every((function(e){return a.has(e)}))},M=function(e,t,a){var n=w(e,t);return S(e,t)&&a.has(t)&&1===n.length&&n.every((function(e){return a.has(e)}))},L=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},k=function(e,t){var a=e.find((function(e){return e.id===t}));if(null==a)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return a},R=function(e){var t=Array.from(new Set(e));return e.length!==t.length},_="COLLAPSE",F="COLLAPSE_MANY",B="EXPAND",z="EXPAND_MANY",K="HALF_SELECT",H="SELECT",P="DESELECT",G="TOGGLE",V="TOGGLE_SELECT",q="SELECT_MANY",Y="EXCLUSIVE_CHANGE_SELECT_MANY",X="FOCUS",$="BLUR",J="DISABLE",Q="ENABLE",Z="CLEAR_MANUALLY_TOGGLED",ee="CONTROLLED_SELECT_MANY",te="UPDATE_TREE_STATE_WHEN_DATA_CHANGED",ae=function(e,t){switch(t.type){case _:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:var n,l=new Set(e.expandedIds),r=u(t.ids);try{for(r.s();!(n=r.n()).done;){var d=n.value;l.delete(d)}}catch(e){r.e(e)}finally{r.f()}return Object.assign(Object.assign({},e),{expandedIds:l,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:var c=new Set([].concat(s(e.expandedIds),s(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case G:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return f.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:f,tabbableId:t.keepFocus?e.tabbableId:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id});case H:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var p;t.multiSelect?(p=new Set(e.selectedIds)).add(t.id):(p=new Set).add(t.id);var b=new Set(e.halfSelectedIds);return b.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0!==t.NotUserAction,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case P:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var I,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(I=new Set(e.halfSelectedIds)).delete(t.id):I=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case V:if(e.disabledIds.has(t.id))return e;var y,g=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),g?y.delete(t.id):y.add(t.id)):(y=new Set,g||y.add(t.id));var m=new Set(e.halfSelectedIds);return m.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:m,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case q:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(s(e.selectedIds),s(E))):v(e.selectedIds,new Set(E));var A=v(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case Y:var O,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){O=t.select?new Set(W):v(e.selectedIds,new Set(W));var x=v(e.halfSelectedIds,O);return Object.assign(Object.assign({},e),{selectedIds:O,halfSelectedIds:x,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case ee:var T,j=e.lastInteractedWith,N=e.tabbableId;if(t.multiSelect)T=new Set(t.ids),t.ids.length&&(j=t.ids[t.ids.length-1],N=t.ids[t.ids.length-1]);else{T=new Set,t.ids.length>1&&console.warn("Tree in singleSelect mode, only the first item from selectedIds will be selected.");var D=t.ids[0];D&&T.add(D),j=null!=D?D:j,N=null!=D?D:j}var C=new Set(e.halfSelectedIds);t.ids.every((function(e){return C.delete(e)}));var U=new Set(t.ids);return Object.assign(Object.assign({},e),{selectedIds:T,halfSelectedIds:C,controlledIds:U,isFocused:!0,lastAction:t.type,tabbableId:N,lastInteractedWith:j});case X:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case $:return Object.assign(Object.assign({},e),{isFocused:!1});case J:var M=new Set(e.disabledIds);return M.add(t.id),Object.assign(Object.assign({},e),{disabledIds:M});case Q:var L=new Set(e.disabledIds);return L.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:L});case Z:return Object.assign(Object.assign({},e),{lastManuallyToggled:null});case te:return Object.assign(Object.assign({},e),{tabbableId:t.tabbableId,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.lastUserSelect});default:throw new Error("Invalid action passed to the reducer")}},ne={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},le={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},re=Object.freeze(Object.values(le)),de=Object.freeze(Object.values({check:"check",select:"select"})),ie=function(e){var a=e.element,n=e.dispatch,r=e.data,i=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,v=e.disabledIds,b=e.halfSelectedIds,I=e.lastUserSelect,y=e.nodeRefs,g=e.leafRefs,w=e.baseClassNames,E=e.nodeRenderer,A=e.nodeAction,O=e.setsize,W=e.posinset,D=e.level,U=e.propagateCollapse,L=e.propagateSelect,k=e.multiSelect,R=e.togglableSelect,_=e.clickAction,B=e.state,z=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&U){var t=[a.id].concat(s(m(r,a.id,new Set)));n({type:F,ids:t,lastInteractedWith:a.id})}else n({type:G,id:a.id,lastInteractedWith:a.id})},P=function(){return n({type:X,id:a.id,lastInteractedWith:a.id})},$=function(e){if(e.shiftKey){var t=x({data:r,expandedIds:u,from:I,to:a.id}).filter((function(e){return!v.has(e)}));t=L?N(r,t,v):t,n({type:Y,select:!0,multiSelect:k,ids:t,lastInteractedWith:a.id,lastManuallyToggled:a.id})}else if(e.ctrlKey||_===le.select){var l=C(r,a.id,i),d=M(r,a.id,i);n({type:R?l&&!d?K:V:H,id:a.id,multiSelect:k,lastInteractedWith:a.id,lastManuallyToggled:a.id}),L&&!v.has(a.id)&&n({type:q,ids:N(r,[a.id],v),select:!R||!i.has(a.id),multiSelect:k,lastInteractedWith:a.id,lastManuallyToggled:a.id})}else _===le.exclusiveSelect?n({type:R?V:H,id:a.id,multiSelect:!1,lastInteractedWith:a.id,lastManuallyToggled:a.id}):_===le.focus&&n({type:X,id:a.id,lastInteractedWith:a.id})},J=function(e){var n;return t(e,(d(n={},"".concat(e,"--expanded"),u.has(a.id)),d(n,"".concat(e,"--selected"),i.has(a.id)),d(n,"".concat(e,"--focused"),c===a.id&&o),n))},Q="select"===A?{"aria-selected":T({isSelected:i.has(a.id),isDisabled:v.has(a.id),multiSelect:k})}:{"aria-checked":j({isSelected:i.has(a.id),isDisabled:v.has(a.id),isHalfSelected:b.has(a.id),multiSelect:k})};return S(r,a.id)||a.isBranch?l.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":O,"aria-posinset":W,"aria-level":D,"aria-disabled":v.has(a.id),tabIndex:c===a.id?0:-1,ref:function(e){null!=(null==y?void 0:y.current)&&null!=e&&(y.current[a.id]=e)},className:w.branchWrapper},Q),l.createElement(l.Fragment,null,E({element:a,isBranch:!0,isSelected:i.has(a.id),isHalfSelected:b.has(a.id),isExpanded:u.has(a.id),isDisabled:v.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return{onClick:null==n?p($,z,P):p(n,P),className:t(J(w.node),w.branch),ref:function(e){null!=(null==g?void 0:g.current)&&(g.current[a.id]=e)}}},setsize:O,posinset:W,level:D,handleSelect:$,handleExpand:z,treeState:B}),l.createElement(se,Object.assign({getClasses:J},function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])}(e))))):l.createElement("li",{role:"none",className:J(w.leafListItem)},E({element:a,isBranch:!1,isSelected:i.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:v.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return Object.assign({role:"treeitem",tabIndex:c===a.id?0:-1,onClick:p(null==n?$:n,P),ref:function(e){null!=(null==y?void 0:y.current)&&null!=(null==g?void 0:g.current)&&(y.current[a.id]=e,g.current[a.id]=e)},className:t(J(w.node),w.leaf),"aria-setsize":O,"aria-posinset":W,"aria-level":D,disabled:v.has(a.id),"aria-disabled":v.has(a.id)},Q)},setsize:O,posinset:W,level:D,handleSelect:$,handleExpand:h,treeState:B}))},se=function(e){var t=e.data,a=e.element,n=e.expandedIds,d=e.getClasses,i=e.baseClassNames,s=e.level,c=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return l.createElement("ul",{role:"group",className:d(i.nodeGroup)},n.has(a.id)&&a.children.length>0&&a.children.map((function(e,d){return l.createElement(ie,Object.assign({data:t,expandedIds:n,baseClassNames:i,key:"".concat(e,"-").concat(r(e)),element:k(t,e),setsize:a.children.length,posinset:d+1,level:s+1},c))})))},ce=function(e){var t=e.data,a=e.controlledSelectedIds,l=e.controlledExpandedIds,r=e.defaultExpandedIds,d=e.defaultSelectedIds,c=e.defaultDisabledIds,o=e.nodeRefs,f=e.leafRefs,p=e.onSelect,w=e.onNodeSelect,E=e.onExpand,A=e.onLoadData,O=e.togglableSelect,W=e.multiSelect,x=e.propagateSelect,T=e.propagateSelectUpwards,j=L(t),D=i(n.useReducer(ae,{selectedIds:new Set(a||d),controlledIds:new Set(a),tabbableId:j.children[0],isFocused:!1,expandedIds:new Set(l||r),halfSelectedIds:new Set,lastUserSelect:j.children[0],lastInteractedWith:null,lastManuallyToggled:null,disabledIds:new Set(c)}),2),C=D[0],M=D[1],R=C.selectedIds,V=C.controlledIds,Y=C.expandedIds,$=C.disabledIds,J=C.tabbableId,Q=C.halfSelectedIds,ne=C.lastAction,le=C.lastInteractedWith,re=C.lastManuallyToggled,de=I(R)||new Set,ie=b(R,de);n.useEffect((function(){var e;if(null!=p&&p!==h){var a,n=u(ie);try{for(n.s();!(a=n.n()).done;){var l=a.value,r=S(t,l)||!!(null===(e=k(t,J))||void 0===e?void 0:e.isBranch);p({element:k(t,l),isBranch:r,isExpanded:!!r&&Y.has(l),isSelected:R.has(l),isDisabled:$.has(l),isHalfSelected:!!r&&Q.has(l),treeState:C})}}catch(e){n.e(e)}finally{n.f()}}}),[t,R,Y,$,Q,ie,p,C]),n.useEffect((function(){null!=w&&w!==h&&null!=re&&ie.size&&(w({element:k(t,re),isSelected:R.has(re),isBranch:S(t,re),treeState:C}),M({type:Z}))}),[re,R,ie]);var se=I(Y)||new Set;n.useEffect((function(){var e=b(Y,se);if(null!=E&&E!==h){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;E({element:k(t,l),isExpanded:Y.has(l),isSelected:R.has(l),isDisabled:$.has(l),isHalfSelected:Q.has(l),treeState:C})}}catch(e){n.e(e)}finally{n.f()}}}),[t,R,Y,$,Q,se,E,C]);var ce,oe,ue=(ce=t,oe=n.useRef(),n.useEffect((function(){oe.current=ce})),oe.current||new Map);n.useEffect((function(){var e=b(Y,se);if(A){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;A({element:k(t,l),isExpanded:Y.has(l),isSelected:R.has(l),isDisabled:$.has(l),isHalfSelected:Q.has(l),treeState:C})}}catch(e){n.e(e)}finally{n.f()}if(ue!==t&&O&&x){var r,d=u(Y);try{for(d.s();!(r=d.n()).done;){var i=r.value;R.has(i)&&M({type:q,ids:N(t,[i],$),select:!0,multiSelect:W,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,R,Y,$,Q,se,A,C]),n.useEffect((function(){if(ue!==t){var e=L(t);e.children.length&&M({type:te,tabbableId:t.find((function(e){return e.id===C.tabbableId}))?C.tabbableId:e.children[0],lastInteractedWith:t.find((function(e){return e.id===C.lastInteractedWith}))?C.lastInteractedWith:null,lastManuallyToggled:t.find((function(e){return e.id===C.lastManuallyToggled}))?C.lastManuallyToggled:null,lastUserSelect:t.find((function(e){return e.id===C.lastUserSelect}))?C.lastUserSelect:e.children[0]})}}),[t]);var fe=b(new Set(a),R);return n.useEffect((function(){if(a){fe.size&&M({type:ee,ids:a,multiSelect:W});var e,n=u(a);try{for(n.s();!(e=n.n()).done;){var l=e.value;x&&!$.has(l)&&M({type:q,ids:N(t,[l],$),select:!0,multiSelect:W,lastInteractedWith:l})}}catch(e){n.e(e)}finally{n.f()}}}),[a]),n.useEffect((function(){var e=new Set(l),a=v(e,se),n=v(se,e);if(n.size){var r,d=u(n);try{for(d.s();!(r=d.n()).done;){var i=r.value;if(S(t,i)||k(t,i).isBranch){var c=[i].concat(s(m(t,i,new Set)));M({type:F,ids:c,lastInteractedWith:i})}}}catch(e){d.e(e)}finally{d.f()}}if(a.size){var o,f=u(a);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(S(t,h)||k(t,h).isBranch){var p=y(t,h);M(p?{type:z,ids:[h,p],lastInteractedWith:h}:{type:B,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[l]),n.useEffect((function(){if(T){var e=new Set([].concat(s(ie),s(V)));le&&ne!==X&&ne!==_&&ne!==B&&ne!==G&&e.add(le);var a=[];e.forEach((function(e){t.find((function(t){return t.id===e}))||a.push(e)})),a.forEach((function(t){return e.delete(t)}));var n,l=function(e,t,a,n,l,r){var d,i={every:new Set,some:new Set,none:new Set},s=u(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=y(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var f=k(e,o).children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||l.has(e)&&!i.none.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=g(e,c,n).find((function(e){return a.has(e)}));if(!r&&h){m(e,h,n).forEach((function(e){l.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,R,$,Q,W),r=l.every,d=l.some,i=l.none,c=u(r);try{for(c.s();!(n=c.n()).done;){var o=n.value;R.has(o)||M({type:H,id:o,multiSelect:W||U(t,o,R),keepFocus:!0,NotUserAction:!0,lastInteractedWith:le})}}catch(e){c.e(e)}finally{c.f()}var f,h=u(d);try{for(h.s();!(f=h.n()).done;){var p=f.value;Q.has(p)||M({type:K,id:p,lastInteractedWith:le,keepFocus:!0,NotUserAction:!0})}}catch(e){h.e(e)}finally{h.f()}var v,b=u(i);try{for(b.s();!(v=b.n()).done;){var I=v.value;(R.has(I)||Q.has(I))&&M({type:P,id:I,multiSelect:W,keepFocus:!0,NotUserAction:!0,lastInteractedWith:le,lastManuallyToggled:re})}}catch(e){b.e(e)}finally{b.f()}}}),[t,W,T,R,Y,$,Q,ne,de,ie,le,fe]),n.useEffect((function(){if(null!=le&&null!=J&&null!=(null==o?void 0:o.current)&&null!=(null==f?void 0:f.current)){var e=o.current[J];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[le]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[J,o,f,le]),[C,M]},oe=l.forwardRef((function(e,a){var d=e.data,s=e.selectedIds,c=e.nodeRenderer,o=e.onSelect,u=void 0===o?h:o,p=e.onNodeSelect,v=void 0===p?h:p,b=e.onExpand,I=void 0===b?h:b,S=e.onLoadData,y=e.className,g=void 0===y?"":y,m=e.multiSelect,w=void 0!==m&&m,E=e.propagateSelect,A=void 0!==E&&E,O=e.propagateSelectUpwards,W=void 0!==O&&O,x=e.propagateCollapse,T=void 0!==x&&x,j=e.expandOnKeyboardSelect,N=void 0!==j&&j,C=e.togglableSelect,U=void 0!==C&&C,M=e.defaultExpandedIds,_=void 0===M?[]:M,F=e.defaultSelectedIds,B=void 0===F?[]:F,z=e.defaultDisabledIds,K=void 0===z?[]:z,H=e.clickAction,P=void 0===H?le.select:H,G=e.nodeAction,V=void 0===G?"select":G,q=e.expandedIds,Y=e.onBlur,X=f(e,["data","selectedIds","nodeRenderer","onSelect","onNodeSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(R(e.map((function(e){return e.id}))))throw Error("Multiple TreeView nodes have the same ID. IDs must be unique.");if(e.forEach((function(e){if(e.id===e.parent)throw Error("Node with id=".concat(e.id," has parent reference to itself."));if(R(e.children))throw Error("Node with id=".concat(e.id," contains duplicate ids in its children."))})),0===e.filter((function(e){return null===e.parent})).length)throw Error("TreeView must have one root node.");if(e.filter((function(e){return null===e.parent})).length>1)throw Error("TreeView can have only one root node.");L(e).children.length||console.warn("TreeView have no nodes to display.")}(d);var J=n.useRef({}),Q=n.useRef({}),Z=i(ce({data:d,controlledSelectedIds:s,controlledExpandedIds:q,defaultExpandedIds:_,defaultSelectedIds:B,defaultDisabledIds:K,nodeRefs:J,leafRefs:Q,onSelect:u,onNodeSelect:v,onExpand:I,onLoadData:S,togglableSelect:U,multiSelect:w,propagateSelect:A,propagateSelectUpwards:W}),2),ee=Z[0],te=Z[1];A=A&&w;var ae=n.useRef(null);return null!=a&&(ae=a),l.createElement("ul",Object.assign({className:t(ne.root,g),role:"tree","aria-multiselectable":"select"===V?w:void 0,ref:ae,onBlur:function(e){D(e,ae.current,(function(){Y&&Y({treeState:ee,dispatch:te}),te({type:$})}))},onKeyDown:ue({data:d,tabbableId:ee.tabbableId,expandedIds:ee.expandedIds,selectedIds:ee.selectedIds,disabledIds:ee.disabledIds,halfSelectedIds:ee.halfSelectedIds,clickAction:P,dispatch:te,propagateCollapse:T,propagateSelect:A,multiSelect:w,expandOnKeyboardSelect:N,togglableSelect:U})},X),L(d).children.map((function(e,t){return l.createElement(ie,Object.assign({key:"".concat(e,"-").concat(r(e)),data:d,element:k(d,e),setsize:L(d).children.length,posinset:t+1,level:1},ee,{state:ee,dispatch:te,nodeRefs:J,leafRefs:Q,baseClassNames:ne,nodeRenderer:c,propagateCollapse:T,propagateSelect:A,propagateSelectUpwards:W,multiSelect:w,togglableSelect:U,clickAction:P,nodeAction:V}))})))})),ue=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,l=e.disabledIds,r=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=k(t,r),v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var b=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!l.has(e)}));d({type:q,multiSelect:o,select:Array.from(n).filter((function(e){return!l.has(e)})).length!==b.length,ids:b,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var I="Home"===e.key?L(t).children[0]:A(t,v,a),g=x({data:t,expandedIds:a,from:v,to:I}).filter((function(e){return!l.has(e)}));d({type:q,multiSelect:o,select:!0,ids:c?N(t,g,l):g}),d({type:X,id:I,lastInteractedWith:I})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var w=O(t,v,a);return void(null==w||l.has(w)||(d({type:q,ids:c?N(t,[w],l):[w],select:!0,multiSelect:o,lastInteractedWith:w,lastManuallyToggled:w}),d({type:X,id:w,lastInteractedWith:w})));case"ArrowDown":e.preventDefault();var E=W(t,v,a);return void(null==E||l.has(E)||(d({type:q,ids:c?N(t,[E],l):[E],multiSelect:o,select:!0,lastInteractedWith:E,lastManuallyToggled:E}),d({type:X,id:E,lastInteractedWith:E})))}switch(e.key){case"ArrowDown":e.preventDefault();var T=W(t,v,a);return void(null!=T&&d({type:X,id:T,lastInteractedWith:T}));case"ArrowUp":e.preventDefault();var j=O(t,v,a);return void(null!=j&&d({type:X,id:j,lastInteractedWith:j}));case"ArrowLeft":if(e.preventDefault(),(S(t,v)||p.isBranch)&&a.has(r))if(i){var D=[v].concat(s(m(t,v,new Set)));d({type:F,ids:D,lastInteractedWith:p.id})}else d({type:_,id:v,lastInteractedWith:v});else if(!L(t).children.includes(v)){var U=y(t,v);if(null==U)throw new Error("parentId of root element is null");d({type:X,id:U,lastInteractedWith:U})}return;case"ArrowRight":return e.preventDefault(),void((S(t,v)||p.isBranch)&&(a.has(r)?d({type:X,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:B,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:X,id:L(t).children[0],lastInteractedWith:L(t).children[0]});break;case"End":e.preventDefault();var R=A(t,L(t).id,a);return void d({type:X,id:R,lastInteractedWith:R});case"*":e.preventDefault();var P=y(t,v);if(null==P)throw new Error("parentId of element is null");var Y=k(t,P).children.filter((function(e){return S(t,e)||k(t,e).isBranch}));return void d({type:z,ids:Y,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===le.focus)return;var $=C(t,p.id,n),J=M(t,p.id,n);return d({type:f?$&&!J?K:V:H,id:v,multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),c&&!l.has(p.id)&&d({type:q,ids:N(t,[v],l),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),void(u&&d({type:G,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var Q=W(t,v,a);Q!==v;)if(null!=Q){if(k(t,Q).name[0].toLowerCase()===e.key.toLowerCase())return void d({type:X,id:Q,lastInteractedWith:v});Q=W(t,Q,a)}else Q=L(t).children[0];return}}}};oe.propTypes={data:a.array.isRequired,onSelect:a.func,onNodeSelect:a.func,onExpand:a.func,className:a.string,nodeRenderer:a.func.isRequired,defaultExpandedIds:a.array,defaultSelectedIds:a.array,expandedIds:a.array,selectedIds:a.array,defaultDisabledIds:a.array,propagateCollapse:a.bool,propagateSelect:a.bool,propagateSelectUpwards:a.bool,multiSelect:a.bool,expandOnKeyboardSelect:a.bool,togglableSelect:a.bool,nodeAction:a.oneOf(de),clickAction:a.oneOf(re),onBlur:a.func,onLoadData:a.func},exports.CLICK_ACTIONS=re,exports.default=oe,exports.flattenTree=function(e){var t=0,a=[];return function e(n,l){var r,d={id:n.id||t,name:n.name,children:[],parent:l,metadata:n.metadata?Object.assign({},n.metadata):void 0};if(a.find((function(e){return e.id===d.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(d.id,"). IDs must be unique."));if(a.push(d),t+=1,null===(r=n.children)||void 0===r?void 0:r.length){var i,s=u(n.children);try{for(s.s();!(i=s.n()).done;){e(i.value,d.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=u(a.values());try{for(o.s();!(c=o.n()).done;){var f=c.value;f.parent===d.id&&d.children.push(f.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),a};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("classnames")),n=e(require("prop-types")),a=require("react"),l=e(a);function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var a,l,r=[],d=!0,i=!1;try{for(n=n.call(e);!(d=(a=n.next()).done)&&(r.push(a.value),!t||r.length!==t);d=!0);}catch(e){i=!0,l=e}finally{try{d||null==n.return||n.return()}finally{if(i)throw l}}return r}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function u(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=c(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,l=function(){};return{s:l,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,d=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return d=e.done,e},e:function(e){i=!0,r=e},f:function(){try{d||null==n.return||n.return()}finally{if(i)throw r}}}}function f(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(a=Object.getOwnPropertySymbols(e);l<a.length;l++)t.indexOf(a[l])<0&&Object.prototype.propertyIsEnumerable.call(e,a[l])&&(n[a[l]]=e[a[l]])}return n}var h={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},p={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},v=Object.freeze(Object.values(p)),b=Object.freeze(Object.values({check:"check",select:"select"})),y="COLLAPSE",S="COLLAPSE_MANY",I="EXPAND",g="EXPAND_MANY",m="HALF_SELECT",w="SELECT",E="DESELECT",A="TOGGLE",O="TOGGLE_SELECT",W="SELECT_MANY",x="EXCLUSIVE_CHANGE_SELECT_MANY",T="FOCUS",j="BLUR",N="DISABLE",D="ENABLE",C="CLEAR_MANUALLY_TOGGLED",U="CONTROLLED_SELECT_MANY",M="UPDATE_TREE_STATE_WHEN_DATA_CHANGED",L=function(){},k=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){var n,a=u(t);try{for(a.s();!(n=a.n()).done;){var l=n.value;if(l&&l(e),e.defaultPrevented)break}}catch(e){a.e(e)}finally{a.f()}}},R=function(e,t){var n,a=new Set,l=u(e);try{for(l.s();!(n=l.n()).done;){var r=n.value;t.has(r)||a.add(r)}}catch(e){l.e(e)}finally{l.f()}return a},_=function(e,t){return new Set([].concat(s(R(e,t)),s(R(t,e))))},F=function(e){var t=a.useRef();return a.useEffect((function(){t.current=e}),[e]),t.current},B=function(e,t){var n;return!!(null===(n=ae(e,t).children)||void 0===n?void 0:n.length)},z=function(e,t){return ae(e,t).parent},K=function(e,t,n){for(var a=t,l=[];;){var r=z(e,a);if(0===r||null==r||null!=r&&n.has(r))break;l.push(r),a=r}return l},H=function(e,t,n){var a=[];return function e(t,l){var r=ae(t,l);if(null!=r.children){var d,i=u(r.children.filter((function(e){return!n.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;a.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),a},P=function(e,t){var n=ae(e,t);return null==n.children?[]:n.children},G=function(e,t,n){var a=z(e,t);if(null!=a){var l=ae(e,a),r=l.children.indexOf(t)+n;if(l.children[r])return l.children[r]}return null},V=function(e,t,n){var a=ae(e,t);for(ne(e).id===t&&(a=ae(e,ae(e,t).children[ae(e,t).children.length-1]));n.has(a.id)&&B(e,a.id);)a=ae(e,a.children[a.children.length-1]);return a.id},q=function(e,t,n){if(t===ne(e).children[0])return null;var a=G(e,t,-1);return null==a?z(e,t):V(e,a,n)},Y=function(e,t,n){var a=ae(e,t).id;if(B(e,a)&&n.has(a))return ae(e,a).children[0];for(;;){var l=G(e,a,1);if(null!=l)return l;if(null==(a=z(e,a)))return null}},X=function(e){var t=e.data,n=e.expandedIds,a=e.from,l=e.to,r=[],d=t.length,i=0,s=a;if(r.push(a),a<l)for(;i<d&&(null!=(s=Y(t,s,n))&&r.push(s),null!=s&&s!==l);)i+=1;else if(a>l)for(;i<d&&(null!=(s=q(t,s,n))&&r.push(s),null!=s&&s!==l);)i+=1;return r},$=function(e){var t=e.isSelected,n=e.isDisabled,a=e.multiSelect;return n||a?t:!!t||void 0},J=function(e){var t=e.isSelected,n=e.isDisabled,a=e.isHalfSelected,l=e.multiSelect;return n?t:a?"mixed":l?t:!!t||void 0},Q=function(e,t,n){return t.concat.apply(t,s(t.filter((function(t){return B(e,t)})).map((function(t){return H(e,t,n)}))))},Z=function(e,t,n){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&n()}),0):!t.contains(e.nativeEvent.relatedTarget)&&n():console.warn("ref not set on <ul>")},ee=function(e,t,n){var a=P(e,t);return B(e,t)&&!n.has(t)&&1===a.length&&a.every((function(e){return n.has(e)}))},te=function(e,t,n,a){var l=function(e,t,n){return B(e,t)&&n.has(t)&&H(e,t,new Set).some((function(e){return n.has(e)}))}(e,t,n),r=function(e,t,n){var a=P(e,t);return B(e,t)&&n.has(t)&&1===a.length&&a.every((function(e){return n.has(e)}))}(e,t,n);return function(e,t,n,a){var l=H(e,t,new Set);return B(e,t)&&n.has(t)&&l.every((function(e){return n.has(e)}))&&l.every((function(e){return!a.has(e)}))}(e,t,n,a)?O:l&&!r?m:O},ne=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},ae=function(e,t){var n=e.find((function(e){return e.id===t}));if(null==n)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return n},le=function(e){var t=Array.from(new Set(e));return e.length!==t.length},re=function(e,t){switch(t.type){case y:var n=new Set(e.expandedIds);return n.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:n,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case S:var a,l=new Set(e.expandedIds),r=u(t.ids);try{for(r.s();!(a=r.n()).done;){var d=a.value;l.delete(d)}}catch(e){r.e(e)}finally{r.f()}return Object.assign(Object.assign({},e),{expandedIds:l,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case I:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case g:var c=new Set([].concat(s(e.expandedIds),s(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case A:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case m:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return f.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:f,tabbableId:t.keepFocus?e.tabbableId:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id});case w:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var p;t.multiSelect?(p=new Set(e.selectedIds)).add(t.id):(p=new Set).add(t.id);var v=new Set(e.halfSelectedIds);return v.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:v,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0!==t.NotUserAction,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case E:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var b,L=new Set(e.selectedIds);return L.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:L,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case O:if(e.disabledIds.has(t.id))return e;var k,_=e.selectedIds.has(t.id);t.multiSelect?(k=new Set(e.selectedIds),_?k.delete(t.id):k.add(t.id)):(k=new Set,_||k.add(t.id));var F=new Set(e.halfSelectedIds);return F.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:k,halfSelectedIds:F,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case W:var B,z=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){B=t.select?new Set([].concat(s(e.selectedIds),s(z))):R(e.selectedIds,new Set(z));var K=R(e.halfSelectedIds,B);return Object.assign(Object.assign({},e),{selectedIds:B,halfSelectedIds:K,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case x:var H,P=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){H=t.select?new Set(P):R(e.selectedIds,new Set(P));var G=R(e.halfSelectedIds,H);return Object.assign(Object.assign({},e),{selectedIds:H,halfSelectedIds:G,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case U:var V,q=e.lastInteractedWith,Y=e.tabbableId;if(t.multiSelect)V=new Set(t.ids),t.ids.length&&(q=t.ids[t.ids.length-1],Y=t.ids[t.ids.length-1]);else{V=new Set,t.ids.length>1&&console.warn("Tree in singleSelect mode, only the first item from selectedIds will be selected.");var X=t.ids[0];X&&V.add(X),q=null!=X?X:q,Y=null!=X?X:q}var $=new Set(e.halfSelectedIds);t.ids.every((function(e){return $.delete(e)}));var J=new Set(t.ids);return Object.assign(Object.assign({},e),{selectedIds:V,halfSelectedIds:$,controlledIds:J,isFocused:!0,lastAction:t.type,tabbableId:Y,lastInteractedWith:q});case T:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case j:return Object.assign(Object.assign({},e),{isFocused:!1});case N:var Q=new Set(e.disabledIds);return Q.add(t.id),Object.assign(Object.assign({},e),{disabledIds:Q});case D:var Z=new Set(e.disabledIds);return Z.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:Z});case C:return Object.assign(Object.assign({},e),{lastManuallyToggled:null});case M:return Object.assign(Object.assign({},e),{tabbableId:t.tabbableId,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.lastUserSelect});default:throw new Error("Invalid action passed to the reducer")}},de=function(e){var n=e.element,a=e.dispatch,r=e.data,i=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,h=e.disabledIds,v=e.halfSelectedIds,b=e.lastUserSelect,y=e.nodeRefs,I=e.leafRefs,g=e.baseClassNames,m=e.nodeRenderer,E=e.nodeAction,j=e.setsize,N=e.posinset,D=e.level,C=e.propagateCollapse,U=e.propagateSelect,M=e.multiSelect,R=e.togglableSelect,_=e.clickAction,F=e.state,z=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&C){var t=[n.id].concat(s(H(r,n.id,new Set)));a({type:S,ids:t,lastInteractedWith:n.id})}else a({type:A,id:n.id,lastInteractedWith:n.id})},K=function(){return a({type:T,id:n.id,lastInteractedWith:n.id})},P=function(e){if(e.shiftKey){var t=X({data:r,expandedIds:u,from:b,to:n.id}).filter((function(e){return!h.has(e)}));t=U?Q(r,t,h):t,a({type:x,select:!0,multiSelect:M,ids:t,lastInteractedWith:n.id,lastManuallyToggled:n.id})}else e.ctrlKey||_===p.select?(a({type:R?te(r,n.id,i,h):w,id:n.id,multiSelect:M,lastInteractedWith:n.id,lastManuallyToggled:n.id}),U&&!h.has(n.id)&&a({type:W,ids:Q(r,[n.id],h),select:!R||!i.has(n.id),multiSelect:M,lastInteractedWith:n.id,lastManuallyToggled:n.id})):_===p.exclusiveSelect?a({type:R?O:w,id:n.id,multiSelect:!1,lastInteractedWith:n.id,lastManuallyToggled:n.id}):_===p.focus&&a({type:T,id:n.id,lastInteractedWith:n.id})},G=function(e){var a;return t(e,(d(a={},"".concat(e,"--expanded"),u.has(n.id)),d(a,"".concat(e,"--selected"),i.has(n.id)),d(a,"".concat(e,"--focused"),c===n.id&&o),a))},V="select"===E?{"aria-selected":$({isSelected:i.has(n.id),isDisabled:h.has(n.id),multiSelect:M})}:{"aria-checked":J({isSelected:i.has(n.id),isDisabled:h.has(n.id),isHalfSelected:v.has(n.id),multiSelect:M})};return B(r,n.id)||n.isBranch?l.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":j,"aria-posinset":N,"aria-level":D,"aria-disabled":h.has(n.id),tabIndex:c===n.id?0:-1,ref:function(e){null!=(null==y?void 0:y.current)&&null!=e&&(y.current[n.id]=e)},className:g.branchWrapper},V),l.createElement(l.Fragment,null,m({element:n,isBranch:!0,isSelected:i.has(n.id),isHalfSelected:v.has(n.id),isExpanded:u.has(n.id),isDisabled:h.has(n.id),dispatch:a,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=e.onClick;return{onClick:null==a?k(P,z,K):k(a,K),className:t(G(g.node),g.branch),ref:function(e){null!=(null==I?void 0:I.current)&&(I.current[n.id]=e)}}},setsize:j,posinset:N,level:D,handleSelect:P,handleExpand:z,treeState:F}),l.createElement(ie,Object.assign({getClasses:G},function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])}(e))))):l.createElement("li",{role:"none",className:G(g.leafListItem)},m({element:n,isBranch:!1,isSelected:i.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:h.has(n.id),dispatch:a,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=e.onClick;return Object.assign({role:"treeitem",tabIndex:c===n.id?0:-1,onClick:k(null==a?P:a,K),ref:function(e){null!=(null==y?void 0:y.current)&&null!=(null==I?void 0:I.current)&&(y.current[n.id]=e,I.current[n.id]=e)},className:t(G(g.node),g.leaf),"aria-setsize":j,"aria-posinset":N,"aria-level":D,disabled:h.has(n.id),"aria-disabled":h.has(n.id)},V)},setsize:j,posinset:N,level:D,handleSelect:P,handleExpand:L,treeState:F}))},ie=function(e){var t=e.data,n=e.element,a=e.expandedIds,d=e.getClasses,i=e.baseClassNames,s=e.level,c=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return l.createElement("ul",{role:"group",className:d(i.nodeGroup)},a.has(n.id)&&n.children.length>0&&n.children.map((function(e,d){return l.createElement(de,Object.assign({data:t,expandedIds:a,baseClassNames:i,key:"".concat(e,"-").concat(r(e)),element:ae(t,e),setsize:n.children.length,posinset:d+1,level:s+1},c))})))},se=function(e){var t=e.data,n=e.controlledSelectedIds,l=e.controlledExpandedIds,r=e.defaultExpandedIds,d=e.defaultSelectedIds,c=e.defaultDisabledIds,o=e.nodeRefs,f=e.leafRefs,h=e.onSelect,p=e.onNodeSelect,v=e.onExpand,b=e.onLoadData,O=e.togglableSelect,x=e.multiSelect,j=e.propagateSelect,N=e.propagateSelectUpwards,D=ne(t),k=i(a.useReducer(re,{selectedIds:new Set(n||d),controlledIds:new Set(n),tabbableId:D.children[0],isFocused:!1,expandedIds:new Set(l||r),halfSelectedIds:new Set,lastUserSelect:D.children[0],lastInteractedWith:null,lastManuallyToggled:null,disabledIds:new Set(c)}),2),P=k[0],G=k[1],V=P.selectedIds,q=P.expandedIds,Y=P.disabledIds,X=P.tabbableId,$=P.halfSelectedIds,J=P.lastAction,Z=P.lastInteractedWith,te=P.lastManuallyToggled,le=F(V)||new Set,de=_(V,le);a.useEffect((function(){var e;if(null!=h&&h!==L){var n,a=u(de);try{for(a.s();!(n=a.n()).done;){var l=n.value,r=B(t,l)||!!(null===(e=ae(t,X))||void 0===e?void 0:e.isBranch);h({element:ae(t,l),isBranch:r,isExpanded:!!r&&q.has(l),isSelected:V.has(l),isDisabled:Y.has(l),isHalfSelected:!!r&&$.has(l),treeState:P})}}catch(e){a.e(e)}finally{a.f()}}}),[t,V,q,Y,$,de,h,P]),a.useEffect((function(){null!=p&&p!==L&&null!=te&&de.size&&(p({element:ae(t,te),isSelected:V.has(te),isBranch:B(t,te),treeState:P}),G({type:C}))}),[te,V,de]);var ie=F(q)||new Set;a.useEffect((function(){var e=_(q,ie);if(null!=v&&v!==L){var n,a=u(e);try{for(a.s();!(n=a.n()).done;){var l=n.value;v({element:ae(t,l),isExpanded:q.has(l),isSelected:V.has(l),isDisabled:Y.has(l),isHalfSelected:$.has(l),treeState:P})}}catch(e){a.e(e)}finally{a.f()}}}),[t,V,q,Y,$,ie,v,P]);var se,ce,oe=(se=t,ce=a.useRef(),a.useEffect((function(){ce.current=se})),ce.current||new Map);a.useEffect((function(){var e=_(q,ie);if(b){var n,a=u(e);try{for(a.s();!(n=a.n()).done;){var l=n.value;b({element:ae(t,l),isExpanded:q.has(l),isSelected:V.has(l),isDisabled:Y.has(l),isHalfSelected:$.has(l),treeState:P})}}catch(e){a.e(e)}finally{a.f()}if(oe!==t&&O&&j){var r,d=u(q);try{for(d.s();!(r=d.n()).done;){var i=r.value;V.has(i)&&G({type:W,ids:Q(t,[i],Y),select:!0,multiSelect:x,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,V,q,Y,$,ie,b,P]),a.useEffect((function(){if(oe!==t){var e=ne(t);e.children.length&&G({type:M,tabbableId:t.find((function(e){return e.id===P.tabbableId}))?P.tabbableId:e.children[0],lastInteractedWith:t.find((function(e){return e.id===P.lastInteractedWith}))?P.lastInteractedWith:null,lastManuallyToggled:t.find((function(e){return e.id===P.lastManuallyToggled}))?P.lastManuallyToggled:null,lastUserSelect:t.find((function(e){return e.id===P.lastUserSelect}))?P.lastUserSelect:e.children[0]})}}),[t]);var ue=_(new Set(n),V);return a.useEffect((function(){if(n){ue.size&&G({type:U,ids:n,multiSelect:x});var e,a=u(n);try{for(a.s();!(e=a.n()).done;){var l=e.value;j&&!Y.has(l)&&G({type:W,ids:Q(t,[l],Y),select:!0,multiSelect:x,lastInteractedWith:l})}}catch(e){a.e(e)}finally{a.f()}}}),[n]),a.useEffect((function(){var e=new Set(l),n=R(e,ie),a=R(ie,e);if(a.size){var r,d=u(a);try{for(d.s();!(r=d.n()).done;){var i=r.value;if(B(t,i)||ae(t,i).isBranch){var c=[i].concat(s(H(t,i,new Set)));G({type:S,ids:c,lastInteractedWith:i})}}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var o,f=u(n);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(B(t,h)||ae(t,h).isBranch){var p=z(t,h);G(p?{type:g,ids:[h,p],lastInteractedWith:h}:{type:I,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[l]),a.useEffect((function(){if(N){var e=new Set(s(de));Z&&J!==T&&J!==y&&J!==I&&J!==A&&e.add(Z);var n=[];e.forEach((function(e){t.find((function(t){return t.id===e}))||n.push(e)})),n.forEach((function(t){return e.delete(t)}));var a,l=function(e,t,n,a,l,r){var d,i={every:new Set,some:new Set,none:new Set},s=u(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=z(e,c);if(0===o||null==o||null!=o&&a.has(o))break;var f=ae(e,o).children.filter((function(e){return!a.has(e)}));if(0===f.length)break;if(f.some((function(e){return n.has(e)||i.some.has(e)&&!i.none.has(e)||l.has(e)&&!i.none.has(e)})))f.every((function(e){return n.has(e)}))?i.every.add(o):i.some.add(o);else{var h=K(e,c,a).find((function(e){return n.has(e)}));if(!r&&h){H(e,h,a).forEach((function(e){l.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,V,Y,$,x),r=l.every,d=l.some,i=l.none,c=u(r);try{for(c.s();!(a=c.n()).done;){var o=a.value;V.has(o)||G({type:w,id:o,multiSelect:x||ee(t,o,V),keepFocus:!0,NotUserAction:!0,lastInteractedWith:Z})}}catch(e){c.e(e)}finally{c.f()}var f,h=u(d);try{for(h.s();!(f=h.n()).done;){var p=f.value;$.has(p)||G({type:m,id:p,lastInteractedWith:Z,keepFocus:!0,NotUserAction:!0})}}catch(e){h.e(e)}finally{h.f()}var v,b=u(i);try{for(b.s();!(v=b.n()).done;){var S=v.value;(V.has(S)||$.has(S))&&G({type:E,id:S,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:Z,lastManuallyToggled:te})}}catch(e){b.e(e)}finally{b.f()}}}),[t,x,N,V,q,Y,$,J,le,de,Z,ue]),a.useEffect((function(){if(null!=Z&&null!=X&&null!=(null==o?void 0:o.current)&&null!=(null==f?void 0:f.current)){var e=o.current[X];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[Z]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[X,o,f,Z]),[P,G]},ce=l.forwardRef((function(e,n){var d=e.data,s=e.selectedIds,c=e.nodeRenderer,o=e.onSelect,u=void 0===o?L:o,v=e.onNodeSelect,b=void 0===v?L:v,y=e.onExpand,S=void 0===y?L:y,I=e.onLoadData,g=e.className,m=void 0===g?"":g,w=e.multiSelect,E=void 0!==w&&w,A=e.propagateSelect,O=void 0!==A&&A,W=e.propagateSelectUpwards,x=void 0!==W&&W,T=e.propagateCollapse,N=void 0!==T&&T,D=e.expandOnKeyboardSelect,C=void 0!==D&&D,U=e.togglableSelect,M=void 0!==U&&U,k=e.defaultExpandedIds,R=void 0===k?[]:k,_=e.defaultSelectedIds,F=void 0===_?[]:_,B=e.defaultDisabledIds,z=void 0===B?[]:B,K=e.clickAction,H=void 0===K?p.select:K,P=e.nodeAction,G=void 0===P?"select":P,V=e.expandedIds,q=e.onBlur,Y=f(e,["data","selectedIds","nodeRenderer","onSelect","onNodeSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(le(e.map((function(e){return e.id}))))throw Error("Multiple TreeView nodes have the same ID. IDs must be unique.");if(e.forEach((function(e){if(e.id===e.parent)throw Error("Node with id=".concat(e.id," has parent reference to itself."));if(le(e.children))throw Error("Node with id=".concat(e.id," contains duplicate ids in its children."))})),0===e.filter((function(e){return null===e.parent})).length)throw Error("TreeView must have one root node.");if(e.filter((function(e){return null===e.parent})).length>1)throw Error("TreeView can have only one root node.");ne(e).children.length||console.warn("TreeView have no nodes to display.")}(d);var X=a.useRef({}),$=a.useRef({}),J=i(se({data:d,controlledSelectedIds:s,controlledExpandedIds:V,defaultExpandedIds:R,defaultSelectedIds:F,defaultDisabledIds:z,nodeRefs:X,leafRefs:$,onSelect:u,onNodeSelect:b,onExpand:S,onLoadData:I,togglableSelect:M,multiSelect:E,propagateSelect:O,propagateSelectUpwards:x}),2),Q=J[0],ee=J[1];O=O&&E;var te=a.useRef(null);return null!=n&&(te=n),l.createElement("ul",Object.assign({className:t(h.root,m),role:"tree","aria-multiselectable":"select"===G?E:void 0,ref:te,onBlur:function(e){Z(e,te.current,(function(){q&&q({treeState:Q,dispatch:ee}),ee({type:j})}))},onKeyDown:oe({data:d,tabbableId:Q.tabbableId,expandedIds:Q.expandedIds,selectedIds:Q.selectedIds,disabledIds:Q.disabledIds,halfSelectedIds:Q.halfSelectedIds,clickAction:H,dispatch:ee,propagateCollapse:N,propagateSelect:O,multiSelect:E,expandOnKeyboardSelect:C,togglableSelect:M})},Y),ne(d).children.map((function(e,t){return l.createElement(de,Object.assign({key:"".concat(e,"-").concat(r(e)),data:d,element:ae(d,e),setsize:ne(d).children.length,posinset:t+1,level:1},Q,{state:Q,dispatch:ee,nodeRefs:X,leafRefs:$,baseClassNames:h,nodeRenderer:c,propagateCollapse:N,propagateSelect:O,propagateSelectUpwards:x,multiSelect:E,togglableSelect:M,clickAction:H,nodeAction:G}))})))})),oe=function(e){var t=e.data,n=e.expandedIds,a=e.selectedIds,l=e.disabledIds,r=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var v=ae(t,r),b=v.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var m=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!l.has(e)}));d({type:W,multiSelect:o,select:Array.from(a).filter((function(e){return!l.has(e)})).length!==m.length,ids:m,lastInteractedWith:v.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var E="Home"===e.key?ne(t).children[0]:V(t,b,n),O=X({data:t,expandedIds:n,from:b,to:E}).filter((function(e){return!l.has(e)}));d({type:W,multiSelect:o,select:!0,ids:c?Q(t,O,l):O}),d({type:T,id:E,lastInteractedWith:E})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var x=q(t,b,n);return void(null==x||l.has(x)||(d({type:W,ids:c?Q(t,[x],l):[x],select:!0,multiSelect:o,lastInteractedWith:x,lastManuallyToggled:x}),d({type:T,id:x,lastInteractedWith:x})));case"ArrowDown":e.preventDefault();var j=Y(t,b,n);return void(null==j||l.has(j)||(d({type:W,ids:c?Q(t,[j],l):[j],multiSelect:o,select:!0,lastInteractedWith:j,lastManuallyToggled:j}),d({type:T,id:j,lastInteractedWith:j})))}switch(e.key){case"ArrowDown":e.preventDefault();var N=Y(t,b,n);return void(null!=N&&d({type:T,id:N,lastInteractedWith:N}));case"ArrowUp":e.preventDefault();var D=q(t,b,n);return void(null!=D&&d({type:T,id:D,lastInteractedWith:D}));case"ArrowLeft":if(e.preventDefault(),(B(t,b)||v.isBranch)&&n.has(r))if(i){var C=[b].concat(s(H(t,b,new Set)));d({type:S,ids:C,lastInteractedWith:v.id})}else d({type:y,id:b,lastInteractedWith:b});else if(!ne(t).children.includes(b)){var U=z(t,b);if(null==U)throw new Error("parentId of root element is null");d({type:T,id:U,lastInteractedWith:U})}return;case"ArrowRight":return e.preventDefault(),void((B(t,b)||v.isBranch)&&(n.has(r)?d({type:T,id:v.children[0],lastInteractedWith:v.children[0]}):d({type:I,id:b,lastInteractedWith:b})));case"Home":e.preventDefault(),d({type:T,id:ne(t).children[0],lastInteractedWith:ne(t).children[0]});break;case"End":e.preventDefault();var M=V(t,ne(t).id,n);return void d({type:T,id:M,lastInteractedWith:M});case"*":e.preventDefault();var L=z(t,b);if(null==L)throw new Error("parentId of element is null");var k=ae(t,L).children.filter((function(e){return B(t,e)||ae(t,e).isBranch}));return void d({type:g,ids:k,lastInteractedWith:b});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===p.focus)return;return d({type:f?te(t,b,a,l):w,id:b,multiSelect:o,lastInteractedWith:b,lastManuallyToggled:b}),c&&!l.has(v.id)&&d({type:W,ids:Q(t,[b],l),select:!f||!a.has(b),multiSelect:o,lastInteractedWith:b,lastManuallyToggled:b}),void(u&&d({type:A,id:b,lastInteractedWith:b}));default:if(1===e.key.length)for(var R=Y(t,b,n);R!==b;)if(null!=R){if(ae(t,R).name[0].toLowerCase()===e.key.toLowerCase())return void d({type:T,id:R,lastInteractedWith:b});R=Y(t,R,n)}else R=ne(t).children[0];return}}}};ce.propTypes={data:n.array.isRequired,onSelect:n.func,onNodeSelect:n.func,onExpand:n.func,className:n.string,nodeRenderer:n.func.isRequired,defaultExpandedIds:n.array,defaultSelectedIds:n.array,expandedIds:n.array,selectedIds:n.array,defaultDisabledIds:n.array,propagateCollapse:n.bool,propagateSelect:n.bool,propagateSelectUpwards:n.bool,multiSelect:n.bool,expandOnKeyboardSelect:n.bool,togglableSelect:n.bool,nodeAction:n.oneOf(b),clickAction:n.oneOf(v),onBlur:n.func,onLoadData:n.func},exports.CLICK_ACTIONS=v,exports.default=ce,exports.flattenTree=function(e){var t=0,n=[];return function e(a,l){var r,d={id:a.id||t,name:a.name,children:[],parent:l,metadata:a.metadata?Object.assign({},a.metadata):void 0};if(n.find((function(e){return e.id===d.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(d.id,"). IDs must be unique."));if(n.push(d),t+=1,null===(r=a.children)||void 0===r?void 0:r.length){var i,s=u(a.children);try{for(s.s();!(i=s.n()).done;){e(i.value,d.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=u(n.values());try{for(o.s();!(c=o.n()).done;){var f=c.value;f.parent===d.id&&d.children.push(f.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),n};

@@ -1,1 +0,1 @@

import e from"classnames";import t from"prop-types";import a,{useRef as n,useEffect as l,useReducer as r}from"react";function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,l,r=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(r.push(n.value),!t||r.length!==t);d=!0);}catch(e){i=!0,l=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw l}}return r}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return u(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function f(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=o(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,l=function(){};return{s:l,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,r=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw r}}}}function h(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)t.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(e,n[l])&&(a[n[l]]=e[n[l]])}return a}var p=function(){},v=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=f(t);try{for(n.s();!(a=n.n()).done;){var l=a.value;if(l&&l(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},b=function(e,t){var a,n=new Set,l=f(e);try{for(l.s();!(a=l.n()).done;){var r=a.value;t.has(r)||n.add(r)}}catch(e){l.e(e)}finally{l.f()}return n},S=function(e,t){return new Set([].concat(c(b(e,t)),c(b(t,e))))},I=function(e){var t=n();return l((function(){t.current=e}),[e]),t.current},y=function(e,t){var a;return!!(null===(a=F(e,t).children)||void 0===a?void 0:a.length)},g=function(e,t){return F(e,t).parent},m=function(e,t,a){for(var n=t,l=[];;){var r=g(e,n);if(0===r||null==r||null!=r&&a.has(r))break;l.push(r),n=r}return l},w=function(e,t,a){var n=[];return function e(t,l){var r=F(t,l);if(null!=r.children){var d,i=f(r.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},E=function(e,t){var a=F(e,t);return null==a.children?[]:a.children},A=function(e,t,a){var n=g(e,t);if(null!=n){var l=F(e,n),r=l.children.indexOf(t)+a;if(l.children[r])return l.children[r]}return null},O=function(e,t,a){var n=F(e,t);for(_(e).id===t&&(n=F(e,F(e,t).children[F(e,t).children.length-1]));a.has(n.id)&&y(e,n.id);)n=F(e,n.children[n.children.length-1]);return n.id},W=function(e,t,a){if(t===_(e).children[0])return null;var n=A(e,t,-1);return null==n?g(e,t):O(e,n,a)},x=function(e,t,a){var n=F(e,t).id;if(y(e,n)&&a.has(n))return F(e,n).children[0];for(;;){var l=A(e,n,1);if(null!=l)return l;if(null==(n=g(e,n)))return null}},T=function(e){var t=e.data,a=e.expandedIds,n=e.from,l=e.to,r=[],d=t.length,i=0,s=n;if(r.push(n),n<l)for(;i<d&&(null!=(s=x(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;else if(n>l)for(;i<d&&(null!=(s=W(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;return r},j=function(e){var t=0,a=[];return function e(n,l){var r,d={id:n.id||t,name:n.name,children:[],parent:l,metadata:n.metadata?Object.assign({},n.metadata):void 0};if(a.find((function(e){return e.id===d.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(d.id,"). IDs must be unique."));if(a.push(d),t+=1,null===(r=n.children)||void 0===r?void 0:r.length){var i,s=f(n.children);try{for(s.s();!(i=s.n()).done;){e(i.value,d.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=f(a.values());try{for(o.s();!(c=o.n()).done;){var u=c.value;u.parent===d.id&&d.children.push(u.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),a},N=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},D=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,l=e.multiSelect;return a?t:n?"mixed":l?t:!!t||void 0},C=function(e,t,a){return t.concat.apply(t,c(t.filter((function(t){return y(e,t)})).map((function(t){return w(e,t,a)}))))},U=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},M=function(e,t,a){return y(e,t)&&a.has(t)&&w(e,t,new Set).some((function(e){return a.has(e)}))},k=function(e,t,a){var n=E(e,t);return y(e,t)&&!a.has(t)&&1===n.length&&n.every((function(e){return a.has(e)}))},L=function(e,t,a){var n=E(e,t);return y(e,t)&&a.has(t)&&1===n.length&&n.every((function(e){return a.has(e)}))},_=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},F=function(e,t){var a=e.find((function(e){return e.id===t}));if(null==a)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return a},R=function(e){var t=Array.from(new Set(e));return e.length!==t.length},B="COLLAPSE",z="COLLAPSE_MANY",H="EXPAND",K="EXPAND_MANY",P="HALF_SELECT",G="SELECT",V="DESELECT",Y="TOGGLE",q="TOGGLE_SELECT",X="SELECT_MANY",$="EXCLUSIVE_CHANGE_SELECT_MANY",J="FOCUS",Q="BLUR",Z="DISABLE",ee="ENABLE",te="CLEAR_MANUALLY_TOGGLED",ae="CONTROLLED_SELECT_MANY",ne="UPDATE_TREE_STATE_WHEN_DATA_CHANGED",le=function(e,t){switch(t.type){case B:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:var n,l=new Set(e.expandedIds),r=f(t.ids);try{for(r.s();!(n=r.n()).done;){var d=n.value;l.delete(d)}}catch(e){r.e(e)}finally{r.f()}return Object.assign(Object.assign({},e),{expandedIds:l,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case H:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:var s=new Set([].concat(c(e.expandedIds),c(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:s,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case Y:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case P:if(e.disabledIds.has(t.id))return e;var u=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return u.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:u,tabbableId:t.keepFocus?e.tabbableId:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id});case G:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var p;t.multiSelect?(p=new Set(e.selectedIds)).add(t.id):(p=new Set).add(t.id);var v=new Set(e.halfSelectedIds);return v.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:v,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0!==t.NotUserAction,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case V:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var S,I=new Set(e.selectedIds);return I.delete(t.id),t.multiSelect?(S=new Set(e.halfSelectedIds)).delete(t.id):S=new Set,Object.assign(Object.assign({},e),{selectedIds:I,halfSelectedIds:S,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case q:if(e.disabledIds.has(t.id))return e;var y,g=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),g?y.delete(t.id):y.add(t.id)):(y=new Set,g||y.add(t.id));var m=new Set(e.halfSelectedIds);return m.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:m,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case X:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(c(e.selectedIds),c(E))):b(e.selectedIds,new Set(E));var A=b(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case $:var O,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){O=t.select?new Set(W):b(e.selectedIds,new Set(W));var x=b(e.halfSelectedIds,O);return Object.assign(Object.assign({},e),{selectedIds:O,halfSelectedIds:x,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case ae:var T,j=e.lastInteractedWith,N=e.tabbableId;if(t.multiSelect)T=new Set(t.ids),t.ids.length&&(j=t.ids[t.ids.length-1],N=t.ids[t.ids.length-1]);else{T=new Set,t.ids.length>1&&console.warn("Tree in singleSelect mode, only the first item from selectedIds will be selected.");var D=t.ids[0];D&&T.add(D),j=null!=D?D:j,N=null!=D?D:j}var C=new Set(e.halfSelectedIds);t.ids.every((function(e){return C.delete(e)}));var U=new Set(t.ids);return Object.assign(Object.assign({},e),{selectedIds:T,halfSelectedIds:C,controlledIds:U,isFocused:!0,lastAction:t.type,tabbableId:N,lastInteractedWith:j});case J:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case Q:return Object.assign(Object.assign({},e),{isFocused:!1});case Z:var M=new Set(e.disabledIds);return M.add(t.id),Object.assign(Object.assign({},e),{disabledIds:M});case ee:var k=new Set(e.disabledIds);return k.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:k});case te:return Object.assign(Object.assign({},e),{lastManuallyToggled:null});case ne:return Object.assign(Object.assign({},e),{tabbableId:t.tabbableId,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.lastUserSelect});default:throw new Error("Invalid action passed to the reducer")}},re={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},de={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},ie=Object.freeze(Object.values(de)),se=Object.freeze(Object.values({check:"check",select:"select"})),ce=function(t){var n=t.element,l=t.dispatch,r=t.data,d=t.selectedIds,s=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,b=t.halfSelectedIds,S=t.lastUserSelect,I=t.nodeRefs,g=t.leafRefs,m=t.baseClassNames,E=t.nodeRenderer,A=t.nodeAction,O=t.setsize,W=t.posinset,x=t.level,j=t.propagateCollapse,U=t.propagateSelect,k=t.multiSelect,_=t.togglableSelect,F=t.clickAction,R=t.state,B=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&j){var t=[n.id].concat(c(w(r,n.id,new Set)));l({type:z,ids:t,lastInteractedWith:n.id})}else l({type:Y,id:n.id,lastInteractedWith:n.id})},H=function(){return l({type:J,id:n.id,lastInteractedWith:n.id})},K=function(e){if(e.shiftKey){var t=T({data:r,expandedIds:u,from:S,to:n.id}).filter((function(e){return!f.has(e)}));t=U?C(r,t,f):t,l({type:$,select:!0,multiSelect:k,ids:t,lastInteractedWith:n.id,lastManuallyToggled:n.id})}else if(e.ctrlKey||F===de.select){var a=M(r,n.id,d),i=L(r,n.id,d);l({type:_?a&&!i?P:q:G,id:n.id,multiSelect:k,lastInteractedWith:n.id,lastManuallyToggled:n.id}),U&&!f.has(n.id)&&l({type:X,ids:C(r,[n.id],f),select:!_||!d.has(n.id),multiSelect:k,lastInteractedWith:n.id,lastManuallyToggled:n.id})}else F===de.exclusiveSelect?l({type:_?q:G,id:n.id,multiSelect:!1,lastInteractedWith:n.id,lastManuallyToggled:n.id}):F===de.focus&&l({type:J,id:n.id,lastInteractedWith:n.id})},V=function(t){var a;return e(t,(i(a={},"".concat(t,"--expanded"),u.has(n.id)),i(a,"".concat(t,"--selected"),d.has(n.id)),i(a,"".concat(t,"--focused"),s===n.id&&o),a))},Q="select"===A?{"aria-selected":N({isSelected:d.has(n.id),isDisabled:f.has(n.id),multiSelect:k})}:{"aria-checked":D({isSelected:d.has(n.id),isDisabled:f.has(n.id),isHalfSelected:b.has(n.id),multiSelect:k})};return y(r,n.id)||n.isBranch?a.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":O,"aria-posinset":W,"aria-level":x,"aria-disabled":f.has(n.id),tabIndex:s===n.id?0:-1,ref:function(e){null!=(null==I?void 0:I.current)&&null!=e&&(I.current[n.id]=e)},className:m.branchWrapper},Q),a.createElement(a.Fragment,null,E({element:n,isBranch:!0,isSelected:d.has(n.id),isHalfSelected:b.has(n.id),isExpanded:u.has(n.id),isDisabled:f.has(n.id),dispatch:l,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return{onClick:null==a?v(K,B,H):v(a,H),className:e(V(m.node),m.branch),ref:function(e){null!=(null==g?void 0:g.current)&&(g.current[n.id]=e)}}},setsize:O,posinset:W,level:x,handleSelect:K,handleExpand:B,treeState:R}),a.createElement(oe,Object.assign({getClasses:V},function(e){e.setsize,e.posinset;return h(e,["setsize","posinset"])}(t))))):a.createElement("li",{role:"none",className:V(m.leafListItem)},E({element:n,isBranch:!1,isSelected:d.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(n.id),dispatch:l,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return Object.assign({role:"treeitem",tabIndex:s===n.id?0:-1,onClick:v(null==a?K:a,H),ref:function(e){null!=(null==I?void 0:I.current)&&null!=(null==g?void 0:g.current)&&(I.current[n.id]=e,g.current[n.id]=e)},className:e(V(m.node),m.leaf),"aria-setsize":O,"aria-posinset":W,"aria-level":x,disabled:f.has(n.id),"aria-disabled":f.has(n.id)},Q)},setsize:O,posinset:W,level:x,handleSelect:K,handleExpand:p,treeState:R}))},oe=function(e){var t=e.data,n=e.element,l=e.expandedIds,r=e.getClasses,i=e.baseClassNames,s=e.level,c=h(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return a.createElement("ul",{role:"group",className:r(i.nodeGroup)},l.has(n.id)&&n.children.length>0&&n.children.map((function(e,r){return a.createElement(ce,Object.assign({data:t,expandedIds:l,baseClassNames:i,key:"".concat(e,"-").concat(d(e)),element:F(t,e),setsize:n.children.length,posinset:r+1,level:s+1},c))})))},ue=function(e){var t=e.data,a=e.controlledSelectedIds,d=e.controlledExpandedIds,i=e.defaultExpandedIds,o=e.defaultSelectedIds,u=e.defaultDisabledIds,h=e.nodeRefs,v=e.leafRefs,E=e.onSelect,A=e.onNodeSelect,O=e.onExpand,W=e.onLoadData,x=e.togglableSelect,T=e.multiSelect,j=e.propagateSelect,N=e.propagateSelectUpwards,D=_(t),U=s(r(le,{selectedIds:new Set(a||o),controlledIds:new Set(a),tabbableId:D.children[0],isFocused:!1,expandedIds:new Set(d||i),halfSelectedIds:new Set,lastUserSelect:D.children[0],lastInteractedWith:null,lastManuallyToggled:null,disabledIds:new Set(u)}),2),M=U[0],L=U[1],R=M.selectedIds,q=M.controlledIds,$=M.expandedIds,Q=M.disabledIds,Z=M.tabbableId,ee=M.halfSelectedIds,re=M.lastAction,de=M.lastInteractedWith,ie=M.lastManuallyToggled,se=I(R)||new Set,ce=S(R,se);l((function(){var e;if(null!=E&&E!==p){var a,n=f(ce);try{for(n.s();!(a=n.n()).done;){var l=a.value,r=y(t,l)||!!(null===(e=F(t,Z))||void 0===e?void 0:e.isBranch);E({element:F(t,l),isBranch:r,isExpanded:!!r&&$.has(l),isSelected:R.has(l),isDisabled:Q.has(l),isHalfSelected:!!r&&ee.has(l),treeState:M})}}catch(e){n.e(e)}finally{n.f()}}}),[t,R,$,Q,ee,ce,E,M]),l((function(){null!=A&&A!==p&&null!=ie&&ce.size&&(A({element:F(t,ie),isSelected:R.has(ie),isBranch:y(t,ie),treeState:M}),L({type:te}))}),[ie,R,ce]);var oe=I($)||new Set;l((function(){var e=S($,oe);if(null!=O&&O!==p){var a,n=f(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;O({element:F(t,l),isExpanded:$.has(l),isSelected:R.has(l),isDisabled:Q.has(l),isHalfSelected:ee.has(l),treeState:M})}}catch(e){n.e(e)}finally{n.f()}}}),[t,R,$,Q,ee,oe,O,M]);var ue,fe,he=(ue=t,fe=n(),l((function(){fe.current=ue})),fe.current||new Map);l((function(){var e=S($,oe);if(W){var a,n=f(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;W({element:F(t,l),isExpanded:$.has(l),isSelected:R.has(l),isDisabled:Q.has(l),isHalfSelected:ee.has(l),treeState:M})}}catch(e){n.e(e)}finally{n.f()}if(he!==t&&x&&j){var r,d=f($);try{for(d.s();!(r=d.n()).done;){var i=r.value;R.has(i)&&L({type:X,ids:C(t,[i],Q),select:!0,multiSelect:T,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,R,$,Q,ee,oe,W,M]),l((function(){if(he!==t){var e=_(t);e.children.length&&L({type:ne,tabbableId:t.find((function(e){return e.id===M.tabbableId}))?M.tabbableId:e.children[0],lastInteractedWith:t.find((function(e){return e.id===M.lastInteractedWith}))?M.lastInteractedWith:null,lastManuallyToggled:t.find((function(e){return e.id===M.lastManuallyToggled}))?M.lastManuallyToggled:null,lastUserSelect:t.find((function(e){return e.id===M.lastUserSelect}))?M.lastUserSelect:e.children[0]})}}),[t]);var pe=S(new Set(a),R);return l((function(){if(a){pe.size&&L({type:ae,ids:a,multiSelect:T});var e,n=f(a);try{for(n.s();!(e=n.n()).done;){var l=e.value;j&&!Q.has(l)&&L({type:X,ids:C(t,[l],Q),select:!0,multiSelect:T,lastInteractedWith:l})}}catch(e){n.e(e)}finally{n.f()}}}),[a]),l((function(){var e=new Set(d),a=b(e,oe),n=b(oe,e);if(n.size){var l,r=f(n);try{for(r.s();!(l=r.n()).done;){var i=l.value;if(y(t,i)||F(t,i).isBranch){var s=[i].concat(c(w(t,i,new Set)));L({type:z,ids:s,lastInteractedWith:i})}}}catch(e){r.e(e)}finally{r.f()}}if(a.size){var o,u=f(a);try{for(u.s();!(o=u.n()).done;){var h=o.value;if(y(t,h)||F(t,h).isBranch){var p=g(t,h);L(p?{type:K,ids:[h,p],lastInteractedWith:h}:{type:H,id:h,lastInteractedWith:h})}}}catch(e){u.e(e)}finally{u.f()}}}),[d]),l((function(){if(N){var e=new Set([].concat(c(ce),c(q)));de&&re!==J&&re!==B&&re!==H&&re!==Y&&e.add(de);var a=[];e.forEach((function(e){t.find((function(t){return t.id===e}))||a.push(e)})),a.forEach((function(t){return e.delete(t)}));var n,l=function(e,t,a,n,l,r){var d,i={every:new Set,some:new Set,none:new Set},s=f(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=g(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var u=F(e,o).children.filter((function(e){return!n.has(e)}));if(0===u.length)break;if(u.some((function(e){return a.has(e)||i.some.has(e)||l.has(e)&&!i.none.has(e)})))u.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=m(e,c,n).find((function(e){return a.has(e)}));if(!r&&h){w(e,h,n).forEach((function(e){l.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,R,Q,ee,T),r=l.every,d=l.some,i=l.none,s=f(r);try{for(s.s();!(n=s.n()).done;){var o=n.value;R.has(o)||L({type:G,id:o,multiSelect:T||k(t,o,R),keepFocus:!0,NotUserAction:!0,lastInteractedWith:de})}}catch(e){s.e(e)}finally{s.f()}var u,h=f(d);try{for(h.s();!(u=h.n()).done;){var p=u.value;ee.has(p)||L({type:P,id:p,lastInteractedWith:de,keepFocus:!0,NotUserAction:!0})}}catch(e){h.e(e)}finally{h.f()}var v,b=f(i);try{for(b.s();!(v=b.n()).done;){var S=v.value;(R.has(S)||ee.has(S))&&L({type:V,id:S,multiSelect:T,keepFocus:!0,NotUserAction:!0,lastInteractedWith:de,lastManuallyToggled:ie})}}catch(e){b.e(e)}finally{b.f()}}}),[t,T,N,R,$,Q,ee,re,se,ce,de,pe]),l((function(){if(null!=de&&null!=Z&&null!=(null==h?void 0:h.current)&&null!=(null==v?void 0:v.current)){var e=h.current[Z];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(v.current[de]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[Z,h,v,de]),[M,L]},fe=a.forwardRef((function(t,l){var r=t.data,i=t.selectedIds,c=t.nodeRenderer,o=t.onSelect,u=void 0===o?p:o,f=t.onNodeSelect,v=void 0===f?p:f,b=t.onExpand,S=void 0===b?p:b,I=t.onLoadData,y=t.className,g=void 0===y?"":y,m=t.multiSelect,w=void 0!==m&&m,E=t.propagateSelect,A=void 0!==E&&E,O=t.propagateSelectUpwards,W=void 0!==O&&O,x=t.propagateCollapse,T=void 0!==x&&x,j=t.expandOnKeyboardSelect,N=void 0!==j&&j,D=t.togglableSelect,C=void 0!==D&&D,M=t.defaultExpandedIds,k=void 0===M?[]:M,L=t.defaultSelectedIds,B=void 0===L?[]:L,z=t.defaultDisabledIds,H=void 0===z?[]:z,K=t.clickAction,P=void 0===K?de.select:K,G=t.nodeAction,V=void 0===G?"select":G,Y=t.expandedIds,q=t.onBlur,X=h(t,["data","selectedIds","nodeRenderer","onSelect","onNodeSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(R(e.map((function(e){return e.id}))))throw Error("Multiple TreeView nodes have the same ID. IDs must be unique.");if(e.forEach((function(e){if(e.id===e.parent)throw Error("Node with id=".concat(e.id," has parent reference to itself."));if(R(e.children))throw Error("Node with id=".concat(e.id," contains duplicate ids in its children."))})),0===e.filter((function(e){return null===e.parent})).length)throw Error("TreeView must have one root node.");if(e.filter((function(e){return null===e.parent})).length>1)throw Error("TreeView can have only one root node.");_(e).children.length||console.warn("TreeView have no nodes to display.")}(r);var $=n({}),J=n({}),Z=s(ue({data:r,controlledSelectedIds:i,controlledExpandedIds:Y,defaultExpandedIds:k,defaultSelectedIds:B,defaultDisabledIds:H,nodeRefs:$,leafRefs:J,onSelect:u,onNodeSelect:v,onExpand:S,onLoadData:I,togglableSelect:C,multiSelect:w,propagateSelect:A,propagateSelectUpwards:W}),2),ee=Z[0],te=Z[1];A=A&&w;var ae=n(null);return null!=l&&(ae=l),a.createElement("ul",Object.assign({className:e(re.root,g),role:"tree","aria-multiselectable":"select"===V?w:void 0,ref:ae,onBlur:function(e){U(e,ae.current,(function(){q&&q({treeState:ee,dispatch:te}),te({type:Q})}))},onKeyDown:he({data:r,tabbableId:ee.tabbableId,expandedIds:ee.expandedIds,selectedIds:ee.selectedIds,disabledIds:ee.disabledIds,halfSelectedIds:ee.halfSelectedIds,clickAction:P,dispatch:te,propagateCollapse:T,propagateSelect:A,multiSelect:w,expandOnKeyboardSelect:N,togglableSelect:C})},X),_(r).children.map((function(e,t){return a.createElement(ce,Object.assign({key:"".concat(e,"-").concat(d(e)),data:r,element:F(r,e),setsize:_(r).children.length,posinset:t+1,level:1},ee,{state:ee,dispatch:te,nodeRefs:$,leafRefs:J,baseClassNames:re,nodeRenderer:c,propagateCollapse:T,propagateSelect:A,propagateSelectUpwards:W,multiSelect:w,togglableSelect:C,clickAction:P,nodeAction:V}))})))})),he=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,l=e.disabledIds,r=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,s=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=F(t,r),v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var b=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!l.has(e)}));d({type:X,multiSelect:o,select:Array.from(n).filter((function(e){return!l.has(e)})).length!==b.length,ids:b,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var S="Home"===e.key?_(t).children[0]:O(t,v,a),I=T({data:t,expandedIds:a,from:v,to:S}).filter((function(e){return!l.has(e)}));d({type:X,multiSelect:o,select:!0,ids:s?C(t,I,l):I}),d({type:J,id:S,lastInteractedWith:S})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var m=W(t,v,a);return void(null==m||l.has(m)||(d({type:X,ids:s?C(t,[m],l):[m],select:!0,multiSelect:o,lastInteractedWith:m,lastManuallyToggled:m}),d({type:J,id:m,lastInteractedWith:m})));case"ArrowDown":e.preventDefault();var E=x(t,v,a);return void(null==E||l.has(E)||(d({type:X,ids:s?C(t,[E],l):[E],multiSelect:o,select:!0,lastInteractedWith:E,lastManuallyToggled:E}),d({type:J,id:E,lastInteractedWith:E})))}switch(e.key){case"ArrowDown":e.preventDefault();var A=x(t,v,a);return void(null!=A&&d({type:J,id:A,lastInteractedWith:A}));case"ArrowUp":e.preventDefault();var j=W(t,v,a);return void(null!=j&&d({type:J,id:j,lastInteractedWith:j}));case"ArrowLeft":if(e.preventDefault(),(y(t,v)||p.isBranch)&&a.has(r))if(i){var N=[v].concat(c(w(t,v,new Set)));d({type:z,ids:N,lastInteractedWith:p.id})}else d({type:B,id:v,lastInteractedWith:v});else if(!_(t).children.includes(v)){var D=g(t,v);if(null==D)throw new Error("parentId of root element is null");d({type:J,id:D,lastInteractedWith:D})}return;case"ArrowRight":return e.preventDefault(),void((y(t,v)||p.isBranch)&&(a.has(r)?d({type:J,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:H,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:J,id:_(t).children[0],lastInteractedWith:_(t).children[0]});break;case"End":e.preventDefault();var U=O(t,_(t).id,a);return void d({type:J,id:U,lastInteractedWith:U});case"*":e.preventDefault();var k=g(t,v);if(null==k)throw new Error("parentId of element is null");var R=F(t,k).children.filter((function(e){return y(t,e)||F(t,e).isBranch}));return void d({type:K,ids:R,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===de.focus)return;var V=M(t,p.id,n),$=L(t,p.id,n);return d({type:f?V&&!$?P:q:G,id:v,multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),s&&!l.has(p.id)&&d({type:X,ids:C(t,[v],l),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),void(u&&d({type:Y,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var Q=x(t,v,a);Q!==v;)if(null!=Q){if(F(t,Q).name[0].toLowerCase()===e.key.toLowerCase())return void d({type:J,id:Q,lastInteractedWith:v});Q=x(t,Q,a)}else Q=_(t).children[0];return}}}};fe.propTypes={data:t.array.isRequired,onSelect:t.func,onNodeSelect:t.func,onExpand:t.func,className:t.string,nodeRenderer:t.func.isRequired,defaultExpandedIds:t.array,defaultSelectedIds:t.array,expandedIds:t.array,selectedIds:t.array,defaultDisabledIds:t.array,propagateCollapse:t.bool,propagateSelect:t.bool,propagateSelectUpwards:t.bool,multiSelect:t.bool,expandOnKeyboardSelect:t.bool,togglableSelect:t.bool,nodeAction:t.oneOf(se),clickAction:t.oneOf(ie),onBlur:t.func,onLoadData:t.func};export default fe;export{ie as CLICK_ACTIONS,j as flattenTree};
import e from"classnames";import t from"prop-types";import n,{useRef as a,useEffect as l,useReducer as r}from"react";function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var a,l,r=[],d=!0,i=!1;try{for(n=n.call(e);!(d=(a=n.next()).done)&&(r.push(a.value),!t||r.length!==t);d=!0);}catch(e){i=!0,l=e}finally{try{d||null==n.return||n.return()}finally{if(i)throw l}}return r}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function f(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=o(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,l=function(){};return{s:l,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,d=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return d=e.done,e},e:function(e){i=!0,r=e},f:function(){try{d||null==n.return||n.return()}finally{if(i)throw r}}}}function h(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(a=Object.getOwnPropertySymbols(e);l<a.length;l++)t.indexOf(a[l])<0&&Object.prototype.propertyIsEnumerable.call(e,a[l])&&(n[a[l]]=e[a[l]])}return n}var p={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},v={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},b=Object.freeze(Object.values(v)),S=Object.freeze(Object.values({check:"check",select:"select"})),y="COLLAPSE",I="COLLAPSE_MANY",g="EXPAND",m="EXPAND_MANY",w="HALF_SELECT",E="SELECT",A="DESELECT",O="TOGGLE",W="TOGGLE_SELECT",x="SELECT_MANY",T="EXCLUSIVE_CHANGE_SELECT_MANY",j="FOCUS",N="BLUR",D="DISABLE",C="ENABLE",U="CLEAR_MANUALLY_TOGGLED",M="CONTROLLED_SELECT_MANY",k="UPDATE_TREE_STATE_WHEN_DATA_CHANGED",L=function(){},_=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){var n,a=f(t);try{for(a.s();!(n=a.n()).done;){var l=n.value;if(l&&l(e),e.defaultPrevented)break}}catch(e){a.e(e)}finally{a.f()}}},F=function(e,t){var n,a=new Set,l=f(e);try{for(l.s();!(n=l.n()).done;){var r=n.value;t.has(r)||a.add(r)}}catch(e){l.e(e)}finally{l.f()}return a},R=function(e,t){return new Set([].concat(c(F(e,t)),c(F(t,e))))},B=function(e){var t=a();return l((function(){t.current=e}),[e]),t.current},z=function(e,t){var n;return!!(null===(n=re(e,t).children)||void 0===n?void 0:n.length)},H=function(e,t){return re(e,t).parent},K=function(e,t,n){for(var a=t,l=[];;){var r=H(e,a);if(0===r||null==r||null!=r&&n.has(r))break;l.push(r),a=r}return l},P=function(e,t,n){var a=[];return function e(t,l){var r=re(t,l);if(null!=r.children){var d,i=f(r.children.filter((function(e){return!n.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;a.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),a},G=function(e,t){var n=re(e,t);return null==n.children?[]:n.children},V=function(e,t,n){var a=H(e,t);if(null!=a){var l=re(e,a),r=l.children.indexOf(t)+n;if(l.children[r])return l.children[r]}return null},Y=function(e,t,n){var a=re(e,t);for(le(e).id===t&&(a=re(e,re(e,t).children[re(e,t).children.length-1]));n.has(a.id)&&z(e,a.id);)a=re(e,a.children[a.children.length-1]);return a.id},q=function(e,t,n){if(t===le(e).children[0])return null;var a=V(e,t,-1);return null==a?H(e,t):Y(e,a,n)},X=function(e,t,n){var a=re(e,t).id;if(z(e,a)&&n.has(a))return re(e,a).children[0];for(;;){var l=V(e,a,1);if(null!=l)return l;if(null==(a=H(e,a)))return null}},$=function(e){var t=e.data,n=e.expandedIds,a=e.from,l=e.to,r=[],d=t.length,i=0,s=a;if(r.push(a),a<l)for(;i<d&&(null!=(s=X(t,s,n))&&r.push(s),null!=s&&s!==l);)i+=1;else if(a>l)for(;i<d&&(null!=(s=q(t,s,n))&&r.push(s),null!=s&&s!==l);)i+=1;return r},J=function(e){var t=0,n=[];return function e(a,l){var r,d={id:a.id||t,name:a.name,children:[],parent:l,metadata:a.metadata?Object.assign({},a.metadata):void 0};if(n.find((function(e){return e.id===d.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(d.id,"). IDs must be unique."));if(n.push(d),t+=1,null===(r=a.children)||void 0===r?void 0:r.length){var i,s=f(a.children);try{for(s.s();!(i=s.n()).done;){e(i.value,d.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=f(n.values());try{for(o.s();!(c=o.n()).done;){var u=c.value;u.parent===d.id&&d.children.push(u.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),n},Q=function(e){var t=e.isSelected,n=e.isDisabled,a=e.multiSelect;return n||a?t:!!t||void 0},Z=function(e){var t=e.isSelected,n=e.isDisabled,a=e.isHalfSelected,l=e.multiSelect;return n?t:a?"mixed":l?t:!!t||void 0},ee=function(e,t,n){return t.concat.apply(t,c(t.filter((function(t){return z(e,t)})).map((function(t){return P(e,t,n)}))))},te=function(e,t,n){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&n()}),0):!t.contains(e.nativeEvent.relatedTarget)&&n():console.warn("ref not set on <ul>")},ne=function(e,t,n){var a=G(e,t);return z(e,t)&&!n.has(t)&&1===a.length&&a.every((function(e){return n.has(e)}))},ae=function(e,t,n,a){var l=function(e,t,n){return z(e,t)&&n.has(t)&&P(e,t,new Set).some((function(e){return n.has(e)}))}(e,t,n),r=function(e,t,n){var a=G(e,t);return z(e,t)&&n.has(t)&&1===a.length&&a.every((function(e){return n.has(e)}))}(e,t,n);return function(e,t,n,a){var l=P(e,t,new Set);return z(e,t)&&n.has(t)&&l.every((function(e){return n.has(e)}))&&l.every((function(e){return!a.has(e)}))}(e,t,n,a)?W:l&&!r?w:W},le=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},re=function(e,t){var n=e.find((function(e){return e.id===t}));if(null==n)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return n},de=function(e){var t=Array.from(new Set(e));return e.length!==t.length},ie=function(e,t){switch(t.type){case y:var n=new Set(e.expandedIds);return n.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:n,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case I:var a,l=new Set(e.expandedIds),r=f(t.ids);try{for(r.s();!(a=r.n()).done;){var d=a.value;l.delete(d)}}catch(e){r.e(e)}finally{r.f()}return Object.assign(Object.assign({},e),{expandedIds:l,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case g:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case m:var s=new Set([].concat(c(e.expandedIds),c(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:s,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case O:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case w:if(e.disabledIds.has(t.id))return e;var u=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return u.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:u,tabbableId:t.keepFocus?e.tabbableId:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id});case E:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var p;t.multiSelect?(p=new Set(e.selectedIds)).add(t.id):(p=new Set).add(t.id);var v=new Set(e.halfSelectedIds);return v.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:v,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0!==t.NotUserAction,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case A:if(!t.NotUserAction&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case W:if(e.disabledIds.has(t.id))return e;var L,_=e.selectedIds.has(t.id);t.multiSelect?(L=new Set(e.selectedIds),_?L.delete(t.id):L.add(t.id)):(L=new Set,_||L.add(t.id));var R=new Set(e.halfSelectedIds);return R.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:L,halfSelectedIds:R,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case x:var B,z=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){B=t.select?new Set([].concat(c(e.selectedIds),c(z))):F(e.selectedIds,new Set(z));var H=F(e.halfSelectedIds,B);return Object.assign(Object.assign({},e),{selectedIds:B,halfSelectedIds:H,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case T:var K,P=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){K=t.select?new Set(P):F(e.selectedIds,new Set(P));var G=F(e.halfSelectedIds,K);return Object.assign(Object.assign({},e),{selectedIds:K,halfSelectedIds:G,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case M:var V,Y=e.lastInteractedWith,q=e.tabbableId;if(t.multiSelect)V=new Set(t.ids),t.ids.length&&(Y=t.ids[t.ids.length-1],q=t.ids[t.ids.length-1]);else{V=new Set,t.ids.length>1&&console.warn("Tree in singleSelect mode, only the first item from selectedIds will be selected.");var X=t.ids[0];X&&V.add(X),Y=null!=X?X:Y,q=null!=X?X:Y}var $=new Set(e.halfSelectedIds);t.ids.every((function(e){return $.delete(e)}));var J=new Set(t.ids);return Object.assign(Object.assign({},e),{selectedIds:V,halfSelectedIds:$,controlledIds:J,isFocused:!0,lastAction:t.type,tabbableId:q,lastInteractedWith:Y});case j:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case N:return Object.assign(Object.assign({},e),{isFocused:!1});case D:var Q=new Set(e.disabledIds);return Q.add(t.id),Object.assign(Object.assign({},e),{disabledIds:Q});case C:var Z=new Set(e.disabledIds);return Z.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:Z});case U:return Object.assign(Object.assign({},e),{lastManuallyToggled:null});case k:return Object.assign(Object.assign({},e),{tabbableId:t.tabbableId,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled,lastUserSelect:t.lastUserSelect});default:throw new Error("Invalid action passed to the reducer")}},se=function(t){var a=t.element,l=t.dispatch,r=t.data,d=t.selectedIds,s=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,p=t.halfSelectedIds,b=t.lastUserSelect,S=t.nodeRefs,y=t.leafRefs,g=t.baseClassNames,m=t.nodeRenderer,w=t.nodeAction,A=t.setsize,N=t.posinset,D=t.level,C=t.propagateCollapse,U=t.propagateSelect,M=t.multiSelect,k=t.togglableSelect,F=t.clickAction,R=t.state,B=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&C){var t=[a.id].concat(c(P(r,a.id,new Set)));l({type:I,ids:t,lastInteractedWith:a.id})}else l({type:O,id:a.id,lastInteractedWith:a.id})},H=function(){return l({type:j,id:a.id,lastInteractedWith:a.id})},K=function(e){if(e.shiftKey){var t=$({data:r,expandedIds:u,from:b,to:a.id}).filter((function(e){return!f.has(e)}));t=U?ee(r,t,f):t,l({type:T,select:!0,multiSelect:M,ids:t,lastInteractedWith:a.id,lastManuallyToggled:a.id})}else e.ctrlKey||F===v.select?(l({type:k?ae(r,a.id,d,f):E,id:a.id,multiSelect:M,lastInteractedWith:a.id,lastManuallyToggled:a.id}),U&&!f.has(a.id)&&l({type:x,ids:ee(r,[a.id],f),select:!k||!d.has(a.id),multiSelect:M,lastInteractedWith:a.id,lastManuallyToggled:a.id})):F===v.exclusiveSelect?l({type:k?W:E,id:a.id,multiSelect:!1,lastInteractedWith:a.id,lastManuallyToggled:a.id}):F===v.focus&&l({type:j,id:a.id,lastInteractedWith:a.id})},G=function(t){var n;return e(t,(i(n={},"".concat(t,"--expanded"),u.has(a.id)),i(n,"".concat(t,"--selected"),d.has(a.id)),i(n,"".concat(t,"--focused"),s===a.id&&o),n))},V="select"===w?{"aria-selected":Q({isSelected:d.has(a.id),isDisabled:f.has(a.id),multiSelect:M})}:{"aria-checked":Z({isSelected:d.has(a.id),isDisabled:f.has(a.id),isHalfSelected:p.has(a.id),multiSelect:M})};return z(r,a.id)||a.isBranch?n.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":A,"aria-posinset":N,"aria-level":D,"aria-disabled":f.has(a.id),tabIndex:s===a.id?0:-1,ref:function(e){null!=(null==S?void 0:S.current)&&null!=e&&(S.current[a.id]=e)},className:g.branchWrapper},V),n.createElement(n.Fragment,null,m({element:a,isBranch:!0,isSelected:d.has(a.id),isHalfSelected:p.has(a.id),isExpanded:u.has(a.id),isDisabled:f.has(a.id),dispatch:l,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick;return{onClick:null==n?_(K,B,H):_(n,H),className:e(G(g.node),g.branch),ref:function(e){null!=(null==y?void 0:y.current)&&(y.current[a.id]=e)}}},setsize:A,posinset:N,level:D,handleSelect:K,handleExpand:B,treeState:R}),n.createElement(ce,Object.assign({getClasses:G},function(e){e.setsize,e.posinset;return h(e,["setsize","posinset"])}(t))))):n.createElement("li",{role:"none",className:G(g.leafListItem)},m({element:a,isBranch:!1,isSelected:d.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(a.id),dispatch:l,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick;return Object.assign({role:"treeitem",tabIndex:s===a.id?0:-1,onClick:_(null==n?K:n,H),ref:function(e){null!=(null==S?void 0:S.current)&&null!=(null==y?void 0:y.current)&&(S.current[a.id]=e,y.current[a.id]=e)},className:e(G(g.node),g.leaf),"aria-setsize":A,"aria-posinset":N,"aria-level":D,disabled:f.has(a.id),"aria-disabled":f.has(a.id)},V)},setsize:A,posinset:N,level:D,handleSelect:K,handleExpand:L,treeState:R}))},ce=function(e){var t=e.data,a=e.element,l=e.expandedIds,r=e.getClasses,i=e.baseClassNames,s=e.level,c=h(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return n.createElement("ul",{role:"group",className:r(i.nodeGroup)},l.has(a.id)&&a.children.length>0&&a.children.map((function(e,r){return n.createElement(se,Object.assign({data:t,expandedIds:l,baseClassNames:i,key:"".concat(e,"-").concat(d(e)),element:re(t,e),setsize:a.children.length,posinset:r+1,level:s+1},c))})))},oe=function(e){var t=e.data,n=e.controlledSelectedIds,d=e.controlledExpandedIds,i=e.defaultExpandedIds,o=e.defaultSelectedIds,u=e.defaultDisabledIds,h=e.nodeRefs,p=e.leafRefs,v=e.onSelect,b=e.onNodeSelect,S=e.onExpand,W=e.onLoadData,T=e.togglableSelect,N=e.multiSelect,D=e.propagateSelect,C=e.propagateSelectUpwards,_=le(t),G=s(r(ie,{selectedIds:new Set(n||o),controlledIds:new Set(n),tabbableId:_.children[0],isFocused:!1,expandedIds:new Set(d||i),halfSelectedIds:new Set,lastUserSelect:_.children[0],lastInteractedWith:null,lastManuallyToggled:null,disabledIds:new Set(u)}),2),V=G[0],Y=G[1],q=V.selectedIds,X=V.expandedIds,$=V.disabledIds,J=V.tabbableId,Q=V.halfSelectedIds,Z=V.lastAction,te=V.lastInteractedWith,ae=V.lastManuallyToggled,de=B(q)||new Set,se=R(q,de);l((function(){var e;if(null!=v&&v!==L){var n,a=f(se);try{for(a.s();!(n=a.n()).done;){var l=n.value,r=z(t,l)||!!(null===(e=re(t,J))||void 0===e?void 0:e.isBranch);v({element:re(t,l),isBranch:r,isExpanded:!!r&&X.has(l),isSelected:q.has(l),isDisabled:$.has(l),isHalfSelected:!!r&&Q.has(l),treeState:V})}}catch(e){a.e(e)}finally{a.f()}}}),[t,q,X,$,Q,se,v,V]),l((function(){null!=b&&b!==L&&null!=ae&&se.size&&(b({element:re(t,ae),isSelected:q.has(ae),isBranch:z(t,ae),treeState:V}),Y({type:U}))}),[ae,q,se]);var ce=B(X)||new Set;l((function(){var e=R(X,ce);if(null!=S&&S!==L){var n,a=f(e);try{for(a.s();!(n=a.n()).done;){var l=n.value;S({element:re(t,l),isExpanded:X.has(l),isSelected:q.has(l),isDisabled:$.has(l),isHalfSelected:Q.has(l),treeState:V})}}catch(e){a.e(e)}finally{a.f()}}}),[t,q,X,$,Q,ce,S,V]);var oe,ue,fe=(oe=t,ue=a(),l((function(){ue.current=oe})),ue.current||new Map);l((function(){var e=R(X,ce);if(W){var n,a=f(e);try{for(a.s();!(n=a.n()).done;){var l=n.value;W({element:re(t,l),isExpanded:X.has(l),isSelected:q.has(l),isDisabled:$.has(l),isHalfSelected:Q.has(l),treeState:V})}}catch(e){a.e(e)}finally{a.f()}if(fe!==t&&T&&D){var r,d=f(X);try{for(d.s();!(r=d.n()).done;){var i=r.value;q.has(i)&&Y({type:x,ids:ee(t,[i],$),select:!0,multiSelect:N,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,q,X,$,Q,ce,W,V]),l((function(){if(fe!==t){var e=le(t);e.children.length&&Y({type:k,tabbableId:t.find((function(e){return e.id===V.tabbableId}))?V.tabbableId:e.children[0],lastInteractedWith:t.find((function(e){return e.id===V.lastInteractedWith}))?V.lastInteractedWith:null,lastManuallyToggled:t.find((function(e){return e.id===V.lastManuallyToggled}))?V.lastManuallyToggled:null,lastUserSelect:t.find((function(e){return e.id===V.lastUserSelect}))?V.lastUserSelect:e.children[0]})}}),[t]);var he=R(new Set(n),q);return l((function(){if(n){he.size&&Y({type:M,ids:n,multiSelect:N});var e,a=f(n);try{for(a.s();!(e=a.n()).done;){var l=e.value;D&&!$.has(l)&&Y({type:x,ids:ee(t,[l],$),select:!0,multiSelect:N,lastInteractedWith:l})}}catch(e){a.e(e)}finally{a.f()}}}),[n]),l((function(){var e=new Set(d),n=F(e,ce),a=F(ce,e);if(a.size){var l,r=f(a);try{for(r.s();!(l=r.n()).done;){var i=l.value;if(z(t,i)||re(t,i).isBranch){var s=[i].concat(c(P(t,i,new Set)));Y({type:I,ids:s,lastInteractedWith:i})}}}catch(e){r.e(e)}finally{r.f()}}if(n.size){var o,u=f(n);try{for(u.s();!(o=u.n()).done;){var h=o.value;if(z(t,h)||re(t,h).isBranch){var p=H(t,h);Y(p?{type:m,ids:[h,p],lastInteractedWith:h}:{type:g,id:h,lastInteractedWith:h})}}}catch(e){u.e(e)}finally{u.f()}}}),[d]),l((function(){if(C){var e=new Set(c(se));te&&Z!==j&&Z!==y&&Z!==g&&Z!==O&&e.add(te);var n=[];e.forEach((function(e){t.find((function(t){return t.id===e}))||n.push(e)})),n.forEach((function(t){return e.delete(t)}));var a,l=function(e,t,n,a,l,r){var d,i={every:new Set,some:new Set,none:new Set},s=f(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=H(e,c);if(0===o||null==o||null!=o&&a.has(o))break;var u=re(e,o).children.filter((function(e){return!a.has(e)}));if(0===u.length)break;if(u.some((function(e){return n.has(e)||i.some.has(e)&&!i.none.has(e)||l.has(e)&&!i.none.has(e)})))u.every((function(e){return n.has(e)}))?i.every.add(o):i.some.add(o);else{var h=K(e,c,a).find((function(e){return n.has(e)}));if(!r&&h){P(e,h,a).forEach((function(e){l.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,q,$,Q,N),r=l.every,d=l.some,i=l.none,s=f(r);try{for(s.s();!(a=s.n()).done;){var o=a.value;q.has(o)||Y({type:E,id:o,multiSelect:N||ne(t,o,q),keepFocus:!0,NotUserAction:!0,lastInteractedWith:te})}}catch(e){s.e(e)}finally{s.f()}var u,h=f(d);try{for(h.s();!(u=h.n()).done;){var p=u.value;Q.has(p)||Y({type:w,id:p,lastInteractedWith:te,keepFocus:!0,NotUserAction:!0})}}catch(e){h.e(e)}finally{h.f()}var v,b=f(i);try{for(b.s();!(v=b.n()).done;){var S=v.value;(q.has(S)||Q.has(S))&&Y({type:A,id:S,multiSelect:N,keepFocus:!0,NotUserAction:!0,lastInteractedWith:te,lastManuallyToggled:ae})}}catch(e){b.e(e)}finally{b.f()}}}),[t,N,C,q,X,$,Q,Z,de,se,te,he]),l((function(){if(null!=te&&null!=J&&null!=(null==h?void 0:h.current)&&null!=(null==p?void 0:p.current)){var e=h.current[J];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(p.current[te]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[J,h,p,te]),[V,Y]},ue=n.forwardRef((function(t,l){var r=t.data,i=t.selectedIds,c=t.nodeRenderer,o=t.onSelect,u=void 0===o?L:o,f=t.onNodeSelect,b=void 0===f?L:f,S=t.onExpand,y=void 0===S?L:S,I=t.onLoadData,g=t.className,m=void 0===g?"":g,w=t.multiSelect,E=void 0!==w&&w,A=t.propagateSelect,O=void 0!==A&&A,W=t.propagateSelectUpwards,x=void 0!==W&&W,T=t.propagateCollapse,j=void 0!==T&&T,D=t.expandOnKeyboardSelect,C=void 0!==D&&D,U=t.togglableSelect,M=void 0!==U&&U,k=t.defaultExpandedIds,_=void 0===k?[]:k,F=t.defaultSelectedIds,R=void 0===F?[]:F,B=t.defaultDisabledIds,z=void 0===B?[]:B,H=t.clickAction,K=void 0===H?v.select:H,P=t.nodeAction,G=void 0===P?"select":P,V=t.expandedIds,Y=t.onBlur,q=h(t,["data","selectedIds","nodeRenderer","onSelect","onNodeSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(de(e.map((function(e){return e.id}))))throw Error("Multiple TreeView nodes have the same ID. IDs must be unique.");if(e.forEach((function(e){if(e.id===e.parent)throw Error("Node with id=".concat(e.id," has parent reference to itself."));if(de(e.children))throw Error("Node with id=".concat(e.id," contains duplicate ids in its children."))})),0===e.filter((function(e){return null===e.parent})).length)throw Error("TreeView must have one root node.");if(e.filter((function(e){return null===e.parent})).length>1)throw Error("TreeView can have only one root node.");le(e).children.length||console.warn("TreeView have no nodes to display.")}(r);var X=a({}),$=a({}),J=s(oe({data:r,controlledSelectedIds:i,controlledExpandedIds:V,defaultExpandedIds:_,defaultSelectedIds:R,defaultDisabledIds:z,nodeRefs:X,leafRefs:$,onSelect:u,onNodeSelect:b,onExpand:y,onLoadData:I,togglableSelect:M,multiSelect:E,propagateSelect:O,propagateSelectUpwards:x}),2),Q=J[0],Z=J[1];O=O&&E;var ee=a(null);return null!=l&&(ee=l),n.createElement("ul",Object.assign({className:e(p.root,m),role:"tree","aria-multiselectable":"select"===G?E:void 0,ref:ee,onBlur:function(e){te(e,ee.current,(function(){Y&&Y({treeState:Q,dispatch:Z}),Z({type:N})}))},onKeyDown:fe({data:r,tabbableId:Q.tabbableId,expandedIds:Q.expandedIds,selectedIds:Q.selectedIds,disabledIds:Q.disabledIds,halfSelectedIds:Q.halfSelectedIds,clickAction:K,dispatch:Z,propagateCollapse:j,propagateSelect:O,multiSelect:E,expandOnKeyboardSelect:C,togglableSelect:M})},q),le(r).children.map((function(e,t){return n.createElement(se,Object.assign({key:"".concat(e,"-").concat(d(e)),data:r,element:re(r,e),setsize:le(r).children.length,posinset:t+1,level:1},Q,{state:Q,dispatch:Z,nodeRefs:X,leafRefs:$,baseClassNames:p,nodeRenderer:c,propagateCollapse:j,propagateSelect:O,propagateSelectUpwards:x,multiSelect:E,togglableSelect:M,clickAction:K,nodeAction:G}))})))})),fe=function(e){var t=e.data,n=e.expandedIds,a=e.selectedIds,l=e.disabledIds,r=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,s=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=re(t,r),b=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var S=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!l.has(e)}));d({type:x,multiSelect:o,select:Array.from(a).filter((function(e){return!l.has(e)})).length!==S.length,ids:S,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var w="Home"===e.key?le(t).children[0]:Y(t,b,n),A=$({data:t,expandedIds:n,from:b,to:w}).filter((function(e){return!l.has(e)}));d({type:x,multiSelect:o,select:!0,ids:s?ee(t,A,l):A}),d({type:j,id:w,lastInteractedWith:w})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var W=q(t,b,n);return void(null==W||l.has(W)||(d({type:x,ids:s?ee(t,[W],l):[W],select:!0,multiSelect:o,lastInteractedWith:W,lastManuallyToggled:W}),d({type:j,id:W,lastInteractedWith:W})));case"ArrowDown":e.preventDefault();var T=X(t,b,n);return void(null==T||l.has(T)||(d({type:x,ids:s?ee(t,[T],l):[T],multiSelect:o,select:!0,lastInteractedWith:T,lastManuallyToggled:T}),d({type:j,id:T,lastInteractedWith:T})))}switch(e.key){case"ArrowDown":e.preventDefault();var N=X(t,b,n);return void(null!=N&&d({type:j,id:N,lastInteractedWith:N}));case"ArrowUp":e.preventDefault();var D=q(t,b,n);return void(null!=D&&d({type:j,id:D,lastInteractedWith:D}));case"ArrowLeft":if(e.preventDefault(),(z(t,b)||p.isBranch)&&n.has(r))if(i){var C=[b].concat(c(P(t,b,new Set)));d({type:I,ids:C,lastInteractedWith:p.id})}else d({type:y,id:b,lastInteractedWith:b});else if(!le(t).children.includes(b)){var U=H(t,b);if(null==U)throw new Error("parentId of root element is null");d({type:j,id:U,lastInteractedWith:U})}return;case"ArrowRight":return e.preventDefault(),void((z(t,b)||p.isBranch)&&(n.has(r)?d({type:j,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:g,id:b,lastInteractedWith:b})));case"Home":e.preventDefault(),d({type:j,id:le(t).children[0],lastInteractedWith:le(t).children[0]});break;case"End":e.preventDefault();var M=Y(t,le(t).id,n);return void d({type:j,id:M,lastInteractedWith:M});case"*":e.preventDefault();var k=H(t,b);if(null==k)throw new Error("parentId of element is null");var L=re(t,k).children.filter((function(e){return z(t,e)||re(t,e).isBranch}));return void d({type:m,ids:L,lastInteractedWith:b});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===v.focus)return;return d({type:f?ae(t,b,a,l):E,id:b,multiSelect:o,lastInteractedWith:b,lastManuallyToggled:b}),s&&!l.has(p.id)&&d({type:x,ids:ee(t,[b],l),select:!f||!a.has(b),multiSelect:o,lastInteractedWith:b,lastManuallyToggled:b}),void(u&&d({type:O,id:b,lastInteractedWith:b}));default:if(1===e.key.length)for(var _=X(t,b,n);_!==b;)if(null!=_){if(re(t,_).name[0].toLowerCase()===e.key.toLowerCase())return void d({type:j,id:_,lastInteractedWith:b});_=X(t,_,n)}else _=le(t).children[0];return}}}};ue.propTypes={data:t.array.isRequired,onSelect:t.func,onNodeSelect:t.func,onExpand:t.func,className:t.string,nodeRenderer:t.func.isRequired,defaultExpandedIds:t.array,defaultSelectedIds:t.array,expandedIds:t.array,selectedIds:t.array,defaultDisabledIds:t.array,propagateCollapse:t.bool,propagateSelect:t.bool,propagateSelectUpwards:t.bool,multiSelect:t.bool,expandOnKeyboardSelect:t.bool,togglableSelect:t.bool,nodeAction:t.oneOf(S),clickAction:t.oneOf(b),onBlur:t.func,onLoadData:t.func};export default ue;export{b as CLICK_ACTIONS,J as flattenTree};

@@ -21,1 +21,21 @@ export declare const baseClassNames: {

export declare const NODE_ACTIONS: readonly ("select" | "check")[];
export declare const treeTypes: {
readonly collapse: "COLLAPSE";
readonly collapseMany: "COLLAPSE_MANY";
readonly expand: "EXPAND";
readonly expandMany: "EXPAND_MANY";
readonly halfSelect: "HALF_SELECT";
readonly select: "SELECT";
readonly deselect: "DESELECT";
readonly toggle: "TOGGLE";
readonly toggleSelect: "TOGGLE_SELECT";
readonly changeSelectMany: "SELECT_MANY";
readonly exclusiveChangeSelectMany: "EXCLUSIVE_CHANGE_SELECT_MANY";
readonly focus: "FOCUS";
readonly blur: "BLUR";
readonly disable: "DISABLE";
readonly enable: "ENABLE";
readonly clearLastManuallyToggled: "CLEAR_MANUALLY_TOGGLED";
readonly controlledSelectMany: "CONTROLLED_SELECT_MANY";
readonly updateTreeStateWhenDataChanged: "UPDATE_TREE_STATE_WHEN_DATA_CHANGED";
};
import { NodeId } from "./types";
export declare const treeTypes: {
readonly collapse: "COLLAPSE";
readonly collapseMany: "COLLAPSE_MANY";
readonly expand: "EXPAND";
readonly expandMany: "EXPAND_MANY";
readonly halfSelect: "HALF_SELECT";
readonly select: "SELECT";
readonly deselect: "DESELECT";
readonly toggle: "TOGGLE";
readonly toggleSelect: "TOGGLE_SELECT";
readonly changeSelectMany: "SELECT_MANY";
readonly exclusiveChangeSelectMany: "EXCLUSIVE_CHANGE_SELECT_MANY";
readonly focus: "FOCUS";
readonly blur: "BLUR";
readonly disable: "DISABLE";
readonly enable: "ENABLE";
readonly clearLastManuallyToggled: "CLEAR_MANUALLY_TOGGLED";
readonly controlledSelectMany: "CONTROLLED_SELECT_MANY";
readonly updateTreeStateWhenDataChanged: "UPDATE_TREE_STATE_WHEN_DATA_CHANGED";
};
export type TreeViewAction = {

@@ -23,0 +3,0 @@ type: "COLLAPSE";

@@ -55,5 +55,6 @@ import { EventCallback, INode, INodeRef, NodeId } from "./types";

export declare const isBranchSelectedAndHasSelectedDescendants: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>) => boolean;
export declare const isBranchNotSelectedAndHasAllSelectedDescendants: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>) => boolean;
export declare const isBranchSelectedAndHasAllSelectedEnabledDescendants: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>, disabledIds: Set<NodeId>) => boolean;
export declare const isBranchNotSelectedAndHasOnlySelectedChild: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>) => boolean;
export declare const isBranchSelectedAndHasOnlySelectedChild: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>) => boolean;
export declare const getOnSelectTreeAction: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>, disabledIds: Set<NodeId>) => "HALF_SELECT" | "TOGGLE_SELECT";
export declare const getTreeParent: (data: INode[]) => INode;

@@ -60,0 +61,0 @@ export declare const getTreeNode: (data: INode[], id: NodeId) => INode;

{
"name": "react-accessible-treeview",
"description": "A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.",
"version": "2.7.0",
"version": "2.8.0",
"author": "lissitz (https://github.com/lissitz)",

@@ -6,0 +6,0 @@ "main": "dist/react-accessible-treeview.cjs.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc