
/* Smart UI v14.2.101 (2022-09-23) 
Copyright (c) 2011-2021 jQWidgets. 
License: https://htmlelements.com/license/ */ //

(()=>{"use strict";class e{_setRowProperty(e,r,o){const t=this.rowById[e];t&&(t[r]=o)}_setRowsProperty(e,r,o){const t=this;t._refreshLayout(),t._refreshRowHierarchy(!0);const s=t._recyclingRows;t.rows.canNotify=!1;for(let t=0;t<s.length;t++){const c=s[t];o&&-1===o.indexOf(c.id)||(c[e]=r)}t.rows.canNotify=!0,t.refresh()}expandRowsToGroupLevel(e){this._expandCollapseGroupsToLevel(!0,e)}_expandCollapseGroupsToLevel(e,r){const o=this;o._refreshLayout(),o._refreshRowHierarchy(!0);const t=o._recyclingRows;o.rows.canNotify=!1;for(let s=0;s<t.length;s++){const c=t[s];c.data.level<r&&(c.expanded=c.data.expanded=e,o.dataSource&&(e?o.dataSource._expandedRowIds[c.data.$.id]=!0:delete o.dataSource._expandedRowIds[c.data.$.id]))}o.rows.canNotify=!0,o.refresh()}_applyThreeStates(e){const r=this,o=e!==r.rowHierarchy;if(!r.rowHierarchy)return;const t=o?e.children:r.rowHierarchy.filter((e=>{if(0===e.level)return e}));let s=0,c=0;for(let n=0;n<t.length;n++){const a=t[n];e.checked&&(a.checked=!0),!1===a.leaf&&r._applyThreeStates(a),o&&(a.checked?s++:null===a.checked&&c++)}o&&(s===e.children.length?e.checked=!0:0===s&&0===c?e.checked=!1:r.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1)}_hasThreeStates(e,r){const o=this;let t=e;for(e!==r&&(e.checked?e.checked=!1:e.checked=!0);t.parent;){const e=t.parent,r=e.children;let s=0,c=0;for(let e=0;e<r.length;e++)r[e].checked?s++:o.checkBoxes.hasThreeStates&&null===r[e].checked&&c++;s===e.children.length?e.checked=!0:0===s&&0===c?e.checked=!1:o.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1,t=e}e.leaf||function e(r,o){const t=r.children;for(let r=0;r<t.length;r++){const s=t[r];s.checked=o,!1===s.leaf&&e(s,o)}}(e,e.checked)}_expandCollapseGroup(e,r){const o=this;if(!o.grouping.enabled)return;const t=(""+e).split(".");let s=o.rowHierarchy[t[0]];if(!s)return;const c=o.rows.canNotify;o.rows.canNotify=!1,null===r&&(r=!s.expanded),s.expanded=s.data.expanded=r;for(let e=1;e<t.length&&(s=s.children[t[e]],s&&!s.leaf);e++)s.expanded=s.data.expanded=r;o.rows.canNotify=c,o._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(){const e=this;e.grouping.enabled?e._expandCollapseGroupsToLevel(!0,99):e._setRowsProperty("expanded",!0)}collapseAllRows(){const e=this;e.grouping.enabled?e._expandCollapseGroupsToLevel(!1,99):e._setRowsProperty("expanded",!1)}toggleRow(e){const r=this;if(r.grouping.enabled)return void r._expandCollapseGroup(e,null);const o=r.rowById[e];o&&(o.expanded?o.expanded=!1:o.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})();