
/* Smart UI v13.1.26 (2022-04-05) 
Copyright (c) 2011-2021 jQWidgets. 
License: https://htmlelements.com/license/ */ //

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