
/* Smart UI v9.3.56 (2021-05-12) 
Copyright (c) 2011-2021 jQWidgets. 
License: https://htmlelements.com/license/ */ //

Smart.Utilities.Assign("Grid.Tree",class{_setRowProperty(e,c,t){const r=this.rowById[e];r&&(r[c]=t)}_setRowsProperty(e,c,t){const r=this;r._refreshLayout(),r._refreshRowHierarchy(!0);const s=r._recyclingRows;r.rows.canNotify=!1;for(let r=0;r<s.length;r++){const o=s[r];t&&-1===t.indexOf(o.id)||(o[e]=c)}r.rows.canNotify=!0,r.refresh()}_applyThreeStates(e){const c=this,t=e!==c.rowHierarchy;if(!c.rowHierarchy)return;const r=t?e.children:c.rowHierarchy.filter((e=>{if(0===e.level)return e}));let s=0,o=0;for(let h=0;h<r.length;h++){const d=r[h];e.checked&&(d.checked=!0),!1===d.leaf&&c._applyThreeStates(d),t&&(d.checked?s++:null===d.checked&&o++)}t&&(s===e.children.length?e.checked=!0:0===s&&0===o?e.checked=!1:c.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1)}_hasThreeStates(e,c){const t=this;let r=e;for(e!==c&&(e.checked?e.checked=!1:e.checked=!0);r.parent;){const e=r.parent,c=e.children;let s=0,o=0;for(let e=0;e<c.length;e++)c[e].checked?s++:t.checkBoxes.hasThreeStates&&null===c[e].checked&&o++;s===e.children.length?e.checked=!0:0===s&&0===o?e.checked=!1:t.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1,r=e}e.leaf||function e(c,t){const r=c.children;for(let c=0;c<r.length;c++){const s=r[c];s.checked=t,!1===s.leaf&&e(s,t)}}(e,e.checked)}expandRow(e){const c=this;e&&Array.isArray(e)?c._setRowsProperty("expanded",!0,e):c._setRowProperty(e,"expanded",!0)}expandAllRows(){this._setRowsProperty("expanded",!0)}collapseAllRows(){this._setRowsProperty("expanded",!1)}toggleRow(e){const c=this.rowById[e];c&&(c.expanded?c.expanded=!1:c.expanded=!0)}collapseRow(e){const c=this;e&&Array.isArray(e)?c._setRowsProperty("expanded",!1,e):c._setRowProperty(e,"expanded",!1)}checkRow(e){const c=this;e&&Array.isArray(e)?c._setRowsProperty("checked",!0,e):c._setRowProperty(e,"checked",!0)}uncheckRow(e){const c=this;e&&Array.isArray(e)?c._setRowsProperty("checked",!1,e):c._setRowProperty(e,"checked",!1)}checkAllRows(){this._setRowsProperty("checked",!0)}uncheckAllRows(){this._setRowsProperty("checked",!1)}});