smart-webcomponents-react
Version:
[](https://jqwidgets.com/license/)
6 lines (4 loc) • 91.2 kB
JavaScript
/* Smart UI v23.0.8 (2025-05-13)
Copyright (c) 2011-2024 jQWidgets.
License: https://htmlelements.com/license/ */ //
Smart.Utilities.Assign("Grid.Select",class{_refreshSelection(){const e=this;if(e.selection.enabled&&(e._selectionColumn.refresh(),!e._isVirtualMode()&&e._selection&&e._selection.rows))for(let t in e._selection.rows)e.rowById[t]||delete e._selection.rows[t];e._refreshCellSelectionRect()}_toggleColumnSelection(e){const t=this;if(!t.selection.enabled||"none"===t.selection.checkBoxes.selectAllMode)return void(t._inputOverlay&&t._inputOverlay.parentNode&&t._inputOverlay.parentNode.removeChild(t._inputOverlay));let l=e.element.getAttribute("selected");l="indeterminate"===l||""!==l;let n=t._recyclingRows;if(t._selectionColumn._selecting=!0,t.beginUpdate(),t.paging.enabled&&"page"===t.selection.checkBoxes.selectAllMode){let e=t.paging.pageIndex*t.paging.pageSize,l=(t.paging.pageIndex+1)*t.paging.pageSize;for(let n=e;n<l;n++)delete t._selection.indexes[n]}else t._selection.indexes=[];if(t.paging.enabled&&"all"===t.selection.checkBoxes.selectAllMode){let e=t.getVisibleRows();for(let t=0;t<e.length;t++)e[t].selected=l}else for(let e=0;e<n.length;e++)n[e].selected=l;if(t._selectionColumn._selecting=!1,t.endUpdate(!1),t._isVirtualMode())if(l)for(let e=0;e<t.dataSource.virtualDataSourceLength;e++){if(t.paging.enabled&&"page"===t.selection.checkBoxes.selectAllMode){let l=t.paging.pageIndex*t.paging.pageSize,n=(t.paging.pageIndex+1)*t.paging.pageSize;if(e<l||e>=n)continue}l&&(t._selection.indexes[e]=e,t._selection.rows[e]=e)}else{let e=!0;t.paging.enabled&&"page"===t.selection.checkBoxes.selectAllMode&&(e=!1),e&&(t._selection.indexes=[],t._selection.rows=[])}if(t._recycle(!1),t.$.fireEvent("change",{started:!1,finished:!0}),t.selection.enabled&&t.selection.checkBoxes.enabled&&"none"!==t.selection.checkBoxes.selectAllMode){const l=e.element,n=l.querySelector(".smart-input");t._inputOverlay?t._inputOverlay.parentNode!==t.$.columnHeader&&(t._inputOverlay.parentNode&&t._inputOverlay.parentNode.removeChild(t._inputOverlay),t._inputOverlay=document.createElement("div"),t.$.columnHeader.appendChild(t._inputOverlay)):(t._inputOverlay=document.createElement("div"),t.$.columnHeader.appendChild(t._inputOverlay)),t._inputOverlay.column=e,t._inputOverlay.onpointerdown=function(){t._inputOverlay||(t._inputOverlay.onpointerdown=null);const e=t._inputOverlay.column;t._inputOverlay.classList.remove("smart-animate"),t._selectionColumn._selecting=!0,t.beginUpdate();let l=e.element.hasAttribute("selected"),n=t._recyclingRows;t.paging.enabled&&"all"===t.selection.checkBoxes.selectAllMode&&(n=t.getVisibleRows());for(let e=0;e<n.length;e++)n[e].selected=!l;t._selectionColumn._selecting=!1;const o=t._inputOverlay;if(t.endUpdate(!1),t._isVirtualMode())if(l)t._selection.indexes=[],t._selection.rows=[];else for(let e=0;e<t.dataSource.virtualDataSourceLength;e++){if(t.paging.enabled&&"page"===t.selection.checkBoxes.selectAllMode){let l=t.paging.pageIndex*t.paging.pageSize,n=(t.paging.pageIndex+1)*t.paging.pageSize;if(e<l||e>=n)continue}t._selection.indexes[e]=e,t._selection.rows[e]=e}return t._recycle(),t.$.fireEvent("change",{started:!1,finished:!0}),t.$.fireEvent("columnClick",{column:e,dataField:e.dataField}),t.$.columnHeader.appendChild(o),t._inputOverlay=o,t._inputOverlay.classList.add("smart-animate"),!1},t._inputOverlay.classList.add("smart-input-overlay"),t._inputOverlay.classList.add("smart-input-overlay-column"),t.appearance.allowCheckBoxesSelectionAnimation&&t._inputOverlay.classList.add("smart-animate"),t._inputOverlay.style.top=(l.offsetHeight-n.offsetHeight)/4+1+"px";const o=t._selectionColumn.element.parentElement.offsetLeft+t._selectionColumn.element.offsetLeft;t.rightToLeft?t._inputOverlay.style.right=o+"px":t._inputOverlay.style.left=o+"px",t._inputOverlay.style.height=l.offsetWidth+"px",t._inputOverlay.style.width=l.offsetWidth+"px",t._inputOverlay.onmousedown=null,t._inputOverlay.classList.add("smart-input-overlay-on"),t._selectionColumn.refresh()}}_refreshCheckBoxColumnSelection(){const e=this;if(e.selection.enabled&&e.selection.checkBoxes.enabled){const t=e._selectionColumn.element;t&&("none"===e.selection.checkBoxes.selectAllMode?(t.removeAttribute("checkbox"),t.label.classList.remove("smart-input")):(t.setAttribute("checkbox",""),t.label.classList.add("smart-input"))),e._selectionColumn.refresh()}}_handleExtendedRowSelection(e,t){const l=this;if(!e)return;let n=l._recyclingRows;if(l.paging.enabled&&"page"===l.selection.selectAllMode&&(n=n.slice(l.paging.pageIndex*l.paging.pageSize,(l.paging.pageIndex+1)*l.paging.pageSize)),!t||t.ctrlKey||t.metaKey||(l._selection.rows=[],l._selection.indexes=[]),t&&!t.shiftKey&&(l._rangeSelectionStartRow=e,l._rangeSelectionEndRow=e),t&&t.shiftKey){l._rangeSelectionEndRow=e;const t=n.indexOf(l._rangeSelectionStartRow),o=n.indexOf(l._rangeSelectionEndRow),i=Math.min(t,o),a=Math.max(t,o);if(-1===t||-1===o)return;for(let e=i;e<=a;e++){const t=n[e];t.allowSelect&&t.setProperty("selected",!0)}}else!1!==e.allowSelect&&(t&&(t.ctrlKey||t.metaKey)?null===e.selected?e.setProperty("selected",!0):e.setProperty("selected",!e.selected):e.setProperty("selected",!0))}_setSelection(e,t,l){const n=this;if(!n.selection.enabled)return;if(delete n._areAllRowsSelected,n._lastColumnSelectionRange=null,n._lastRowSelectionRange=null,n.closeMenu(),null===e&&null===t)return void n.clearSelection();const o=function(){if(l&&!l.ctrlKey&&!l.metaKey&&!l.shiftKey||"one"===n.selection.mode){if("many"!==n.selection.mode){for(let e in n._selection.rows){const t=n.rowById[e];t&&(t.canNotify=!1,t.selected=!1,t.canNotify=!0)}n._selection.indexes=[],n._selection.rows=[],n._selection.columns=[],n._selection.cells=[]}n._selection.focusedCell=null}if(n._selection.selectionRect){const e=n._selection.selectionRect;e.parentNode.removeChild(e);const t={down:"pointerdown",move:"pointermove",up:"pointerup"};Smart.Utilities.Core.isMobile&&(t.down="touchstart",t.move="touchmove",t.up="touchend"),document.removeEventListener(t.move,e.onMove),document.removeEventListener(t.up,e.onUp),document.removeEventListener(t.down,e.onDown),n._selection.selectionRect=null}};n.beginUpdate();const i=n.columnByDataField[t],a=()=>{const t=n.rowById[e];t&&(t.allowSelect||null===t.allowSelect&&!l)&&(n.selection.checkBoxes.enabled&&l&&l.originalEvent&&l.originalEvent.target&&l.originalEvent.target.parentNode&&l.originalEvent.target.parentNode.hasAttribute("checkbox")&&(l.ctrlKey=!0),n.selection.allowRowHeaderSelection&&"extended"===n.selection.mode?(!Object.keys(n._selection.cells).length>0&&n.appearance.showRowHeaderSelectIcon,o(),n._selectRow(e,l)):(o(),n._selectRow(e,l)))};if(n.selection.allowCellSelection&&null!=e&&i&&!i.autoGenerated){const i=n.rowById[e];if(!i)return n.endUpdate(!1),void n._recycle();let a=i.getCell(t);const s=n._getParentCell(i,t);s&&(a=s.row.getCell(s.column.dataField)),a&&a.column.allowSelect&&(o(),!l||l.ctrlKey||l.metaKey||(n._selection.rows=[],n._selection.indexes=[],n._selection.columns=[],"many"!==n.selection.mode&&(n._selection.cells=[])),"extended"===n.selection.mode?l&&(l.ctrlKey||l.metaKey)?a.selected=!a.selected:a.selected=!0:"one"===n.selection.mode?a.selected=!0:a.selected=!a.selected,(l&&!l.shiftKey||!n._selection.focusedCell)&&(n._selection.focusedCell={id:a.row.id,value:a.value,index:a.row.index,dataField:a.column.dataField}),l&&(l.shiftKey||n._selection.focusedCell.id===a.row.id&&n._selection.focusedCell.dataField===a.column.dataField&&"extended"===n.selection.mode)&&(s?n._renderCellSelectionRect(a.row,a.column,s.endRow,s.endColumn):n._renderCellSelectionRect(a.row,a.column,a.row,a.column)))}else n.selection.allowRowHeaderSelection&&null!=e&&void 0===n.columnByDataField[t]||n.selection.checkBoxes.enabled&&null!=e&&"_checkBoxColumn"===t&&void 0===n.columnByDataField[t]?a():null==e||null!=t&&void 0===n.columnByDataField[t]||!n.selection.allowRowSelection?n.selection.allowColumnHeaderSelection&&i&&(o(),n._selectColumn(t,l||new KeyboardEvent("keydown"))):a();n.endUpdate(!1,!1),n._recycle(!0,!0,!1),null==e||i||n._renderInputOverlay(e,l),n.__selectionStarted=new Date}_deleteCopyRects(){const e=this;e._copyRects&&e._copyRects.forEach((e=>{e.remove()})),delete e._copiedRows,e._copyRects=[]}_createCopyRects(){const e=this,t=e._getSelectedRows();let l=[],n=null;e._deleteCopyRects();for(let o=0;o<t.length;o++){const i=t[o];i&&(n?(n&&n.visibleIndex===i.visibleIndex-1||n&&n.visibleIndex===i.visibleIndex+1||(l.length&&e._createCopyRect(l[0],l[l.length-1]),l=[]),l.push(i.id)):l.push(i.id),n=i)}l.length&&e._createCopyRect(l[0],l[l.length-1])}_createCopyRect(e,t,l,n){const o=this,i=document.createElement("div"),a=document.createElement("div"),s=document.createElement("div");s.classList.add("smart-selection-overlay","marching-ants"),s.appendChild(a),a.appendChild(i),i.classList.add("smart-selection-overlay-content"),a.classList.add("smart-selection-overlay-border-content");const r=o.rowById[e],d=o.rowById[t];if(o._deleteCopyRects(),!r||!d)return;const c=r.top,u=d.top-r.top+d.height;let f=o.columns[0].left,p=o.columns[o.columns.length-1].left+o.columns[o.columns.length-1].computedWidth-f;if(l){let e=o.columnByDataField[l],t=o.columnByDataField[n];e.left>t.left&&(e=o.columnByDataField[n],t=o.columnByDataField[l]),e&&(f=e.left,p=t.left+t.computedWidth-f)}const m=s;return m.style.top=c-o.scrollTop-1+"px",m.style.left=Math.max(0,f-o.scrollLeft)+"px",0===r.visibleIndex&&0===c&&0===o.scrollTop&&(m.style.top="0px"),m.style.height=u+1+"px",m.style.width=p+1+"px",p>300&&m.style.setProperty("--alt-duration",12*Math.ceil(p/180)+"s"),u>60&&m.style.setProperty("--duration",12*Math.ceil(u/180)+"s"),o.$.scrollView.appendChild(s),o._copyRects||(o._copyRects=[]),s.onpointerdown=e=>{o._deleteCopyRects(),o._rowDownHandler(e)},m.row=r,m.lastRow=d,m.dataField=l,m.lastDataField=n,o._copyRects.push(m),s}_refreshCopyRects(){const e=this;e._copyRects&&e._copyRects.forEach((t=>{const l=t.row,n=t.lastRow,o=l.top,i=n.top-l.top+n.height;let a=e.columns[0].left,s=e.columns[e.columns.length-1].left+e.columns[e.columns.length-1].computedWidth-a,r=t.dataField,d=t.lastDataField,c=a-e.scrollLeft;const u=e.columns[e.columns.length-1];if(c<e._frozenColumnsNearWidth&&(c=e._frozenColumnsNearWidth,s=u.left+u.computedWidth-e.scrollLeft-e._frozenColumnsNearWidth),s=u.left+u.computedWidth-e.scrollLeft-e._frozenColumnsNearWidth,r){let t=e.columnByDataField[r],l=e.columnByDataField[d];t.left>l.left&&(t=e.columnByDataField[d],l=e.columnByDataField[r]),t&&(a=t.left,s=l.left+l.computedWidth-a,c=a-e.scrollLeft,c<e._frozenColumnsNearWidth&&(c=e._frozenColumnsNearWidth,s=l.left+l.computedWidth-e.scrollLeft-e._frozenColumnsNearWidth))}const f=t;f.style.top=o-e.scrollTop-1+"px",f.style.left=c+"px",0===l.visibleIndex&&0===o&&0===e.scrollTop&&(f.style.top="0px"),f.style.height=i+1+"px",f.style.width=s+1+"px",s<5?f.classList.add("smart-visibility-hidden"):f.classList.remove("smart-visibility-hidden")}))}_renderCellSelectionRect(e,t,l,n,o){const i=this;let a=i._recyclingRows;const s=a.indexOf(e),r=a.indexOf(l);if(!(i.grouping.enabled&&"advanced"===i.grouping.renderMode&&i.dataSource&&i.dataSource.groupBy.length>0)&&!i._mobile&&s>=0&&r>=0){if(!i._selection.selectionRect){const e=function(e){const t=document.createElement("div"),l=document.createElement("div"),n=document.createElement("div");return n.classList.add("smart-selection-overlay"),n.appendChild(l),l.appendChild(t),t.classList.add("smart-selection-overlay-content"),l.classList.add("smart-selection-overlay-border-content"),o&&n.classList.add(o),i.selection.allowCellDragSelectionHandle&&e&&l.classList.add("handle"),i.$.scrollView.appendChild(n),n},t=i._selection.selectionRect=e(!0);if(i.selection.allowCellDragSelectionHandle){let e=null,l=null,n=null;t.onMove=function(t){const o=i._selection.selectionRect;let s=t.clientX,r=t.clientY;t.touches&&(s=t.touches[0].clientX,r=t.touches[0].clientY);const d=function(e){const t=(i.enableShadowDOM?i.shadowRoot:i.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let l=null;for(let e=0;e<t.length;e++){const n=t[e];if(n.getAttribute("data-field")){l=n.getAttribute("data-field");break}}let n=null;for(let e=0;e<t.length;e++){const l=t[e];if(l.getAttribute("data-id")){n=l.row;break}}return{column:i.columnByDataField[l],row:n}};if(o&&o.capturedDrag){let e=d({clientX:s,clientY:r}),l=d({clientX:s,clientY:r+o.top}).row,n=d({clientX:s+o.left,clientY:r}).column;if(l||(l=a[a.length-1]),n||(n=e.column),l&&n&&e.row&&e.column){o.row=e.row,o.rowId=o.row.id,o.column=e.column,o.endDragRow=o.endRow=l,o.endDragColumn=o.endColumn=n,o.endDragRowId=o.endDragRow.id,i._dragSelectionStartDataField=o.column.dataField,i._dragSelectionStartRow=o.row;const t=o.row.getCell(o.column.dataField);i._selection.focusedCell={index:t.row.index,id:t.row.id,dataField:t.column.dataField,value:t.value}}i._resizeSelectionRect(),t.preventDefault()}else if(o&&o.captured)if(i._dragSelectionStartDataField=i._selection.focusedCell.dataField,i._dragSelectionStartRow=i.rowById[i._selection.focusedCell.id],null===l&&null===n&&(Math.abs(s-e.left)>=30?l=!0:Math.abs(r-e.top)>=20&&(n=!0)),o.lastPoint&&Math.abs(o.lastPoint.top-r)>=30?(l=null,n=!0):o.lastPoint&&Math.abs(o.lastPoint.left-s)>=30&&(n=null,l=!0),l){const t=o.endDragColumn.dataField,l=d({clientX:s,clientY:e.top-5});l.row&&l.column&&(o.endDragRow=o.endRow,o.endDragColumn=l.column,o.endDragColumn.dataField!==t&&(o.lastPoint={left:s,top:r}),i._resizeSelectionRect())}else if(n){const t=o.endDragRow,l=d({clientX:e.left-5,clientY:r});l.row&&l.column&&(o.endDragRow=l.row,o.endDragColumn=o.endColumn,o.endDragRow.id&&o.endDragRow.id!==t.id&&(o.lastPoint={left:s,top:r}),i._resizeSelectionRect())}o&&o.captured&&i.selection.allowDragSelectionAutoScroll&&(i._autoScrollSelectionDragInterval&&clearInterval(i._autoScrollSelectionDragInterval),i.selection.isDragging=!0,i._autoScrollSelectionDragInterval=setInterval((function(){const e=i.$.scrollView.getBoundingClientRect();s<=e.left+20?(i.scrollLeft-=15,i._resizeSelectionRect()):s>=e.left+e.width-20&&(i.scrollLeft+=15,i._resizeSelectionRect()),r<=e.top+20?(i.scrollTop-=15,i._resizeSelectionRect()):r>=e.top+e.height-20&&(i.scrollTop+=15,i._resizeSelectionRect())}),25))},t.onUp=function(){if(!t.captured)return;i._autoScrollSelectionDragInterval&&clearInterval(i._autoScrollSelectionDragInterval),i.editing.editCell||i.editing.editRow||i.focus(),t.capturedDrag=!1,t.captured=!1,l=null,n=null,e=null,t.lastPoint=null;const o=t.cellValues;t.minRow&&t.maxRow&&t.maxRow&&t.maxColumn&&(i._selectCellsRange(t.minRow,t.maxRow,t.minColumn.dataField,t.maxColumn.dataField),t.row=t.minRow,t.rowId=t.row.id,t.column=t.minColumn,t.endColumn=t.maxColumn,t.endRow=t.maxRow,t.endRowId=t.maxRow.id,t.cellValues=o,i._resizeSelectionRect(),i.selection.allowCellDragSelectionAutoFill&&i._pasteSelectedCells({row:t.row,endRow:t.endDragRow,column:t.column,endColumn:t.endColumn},o)),t.endDragColumn=null,t.endDragRow=null,t.minColumn=null,t.minRow=null,t.maxColumn=null,t.maxRow=null},t.onDown=function(l){if(t.captured&&!e){let t=l.clientX,n=l.clientY;l.touches&&(t=l.touches[0].clientX,n=l.touches[0].clientY),e={left:t,top:n}}};const o={down:"pointerdown",move:"pointermove",up:"pointerup"};Smart.Utilities.Core.isMobile&&(o.down="touchstart",o.move="touchmove",o.up="touchend"),t["on"+o.down]=function(e){const l=t.getBoundingClientRect();let n=e.clientX,o=e.clientY;e.touches&&(n=e.touches[0].clientX,o=e.touches[0].clientY),n>=l.right-5&&o>=l.bottom-5?(t.captured=!0,t.endDragRow=t.endRow,t.endDragColumn=t.endColumn):i.selection.allowCellDragDropSelectionHandle&&o>=l.bottom-5?(t.captured=!0,t.capturedDrag=!0,t.endDragRow=t.endRow,t.endDragColumn=t.endColumn,t.left=t.endColumn.left-t.column.left,t.top=t.endRow.top-t.row.top):t.captured||i._rowDownHandler(e)},document.addEventListener(o.move,t.onMove,{passive:!1}),document.addEventListener(o.up,t.onUp,{passive:!1}),document.addEventListener(o.down,t.onDown,{passive:!1})}}const e=i._selection.selectionRect;e.row=i.rowById[i._selection.focusedCell.id],e.rowId=i._selection.focusedCell.id,e.column=i.columnByDataField[i._selection.focusedCell.dataField],e.endRow=l,e.endRowId=l.id,e.endDragRow=l,e.endColumn=n,e.endDragColumn=n,i._refreshCellSelectionRect()}}_resizeSelectionRect(){const e=this,t=e._selection.selectionRect;if(!t)return;let l=e._recyclingRows,n=t.row,o=t.endDragRow,i=t.column,a=t.endDragColumn;const s=e.viewColumns,r=l.indexOf(n),d=l.indexOf(o),c=l.indexOf(t.endRow),u=s.indexOf(i),f=s.indexOf(a),p=s.indexOf(t.endColumn),m=Math.min(c,Math.min(r,d)),g=Math.max(c,Math.max(r,d)),_=Math.min(p,Math.min(u,f)),h=Math.max(p,Math.max(u,f));c<=Math.min(r,d)?t.minRow=t.endRow:t.minRow=r<=d?n:o,c>=Math.max(r,d)?t.maxRow=t.endRow:t.maxRow=r>=d?n:o,p<=Math.min(u,f)?t.minColumn=t.endColumn:t.minColumn=u<=f?i:a,p>=Math.max(u,f)?t.maxColumn=t.endColumn:t.maxColumn=u>=f?i:a;let w=0,y=0,v=0,S=0;for(let e=m;e<=g;e++){const t=l[e];if(t){e===m&&(w=t.top),e===g&&(y=t.top+t.height-w);for(let e=_;e<=h;e++){const l=s[e].dataField,n=t.getCell(l);e===_&&(v=n.column.left),e===h&&(S=n.column.left+n.column.computedWidth-v)}}}t.style.top=w-e.scrollTop-1+"px",0===m&&0===w&&0===e.scrollTop&&(t.style.top="0px"),e._isVirtualMode()&&(t.style.top=w+parseFloat(e.$.rowContainer.style.top)-1+"px"),e.rightToLeft?t.style.right=v-e.scrollLeft+"px":t.style.left=v-e.scrollLeft+"px",t.style.height=y+1+"px",t.style.width=S+1+"px"}_getPatternValue(e,t,l){let n=[],o=0,i=[],a=[],s=[],r=[];const d={names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],namesAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],namesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]},c={names:["January","February","March","April","May","June","July","August","September","October","November","December",""],namesAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]},u=function(e){if(void 0!==e&&!(e.toString().indexOf("GMT+")>=0||e.toString().indexOf("GMT-")>=0)){if(!isNaN(parseFloat(e)))return/[A-Za-z]/.test(e.toString())?void 0:parseFloat(e);if(d.names.indexOf(e)>=0)return r=d.names,d.names.indexOf(e);if(d.namesAbbr.indexOf(e)>=0)return r=d.namesAbbr,d.namesAbbr.indexOf(e);if(d.namesShort.indexOf(e)>=0)return r=d.namesShort,d.namesShort.indexOf(e);if(c.names.indexOf(e)>=0)return r=c.names,c.names.indexOf(e);if(c.namesAbbr.indexOf(e)>=0)return r=c.namesAbbr,c.namesAbbr.indexOf(e);if(void 0!==e&&(null===e&&(e=""),/\d+/.test(e.toString()))){s.push(e.toString().replace(/[0-9]/,"#")),s[s.length-1]=s[s.length-1].replace(/[0-9]/g,"");const t=parseFloat(e.toString().replace(/\D/g,""));return isNaN(t)?0:t}}};let f=0;for(let e in l){let t=l[e];n[o]=[],f=0;for(let e in t){let l=u(t[e]);void 0!==l&&(n[o].push(l),f++)}if(0===n[o].length)continue;let a=n[o][0],d=0;for(let e=0;e<n[o].length;e++){let t=u(n[o][e-1]),l=u(n[o][e]);0===e&&(t=l),a+=l,d+=l-t}a/=n[o].length,a-=n[o][0],a+=n[o][n[o].length-1],0!==d&&(d/=n[o].length-1),(r.length>0||s.length>0)&&(d=1,a=n[o][0]),n[o].length<=2&&(a=n[o][n[o].length-1]+d),i.push({step:d,stepStart:a}),o++}for(let e=0;e<f;e++){let t=n[0][e],l=0;for(let o=1;o<n.length;o++){const i=u(n[o-1][e]),a=u(n[o][e]);t+=a,l+=a-i}t/=n.length,t-=n[0][e],t+=n[n.length-1][e],0!==l&&(l/=n.length-1),(r.length>0||s.length>0)&&(l=1,t=n[0][e]),n.length<=2&&(t=n[n.length-1][e]+l),a.push({step:l,stepStart:t})}if(!n[e]){let l=n.length;for(let o=l;o<=e;o++){n[o]=[];for(let e=0;e<=t;e++)a[e]||(a[e]=a[e-1]),a[e]&&(o===l?n[o][e]=a[e].stepStart:(n[o][e]=n[o-1][e]+a[e].step,r.length>1&&n[o][e]>=r.length&&(n[o][e]=0)))}return r.length>0?r[n[e][t]]:s.length>0?s[e%s.length].replace("#",n[e][t]):n[e][t]}if(!n[e][t]){let l=f;for(let o=l;o<=t;o++)i[e]&&(o===l?n[e].push(i[e].stepStart):(n[e][o]=n[e][o-1]+i[e].step,r.length>1&&n[e][o]>=r.length&&(n[e][o]=0)));return r.length>0?r[n[e][t]]:s.length>0?s[e%s.length].replace("#",n[e][t]):n[e][t]}return n[e]&&n[e][t]?s.length>0?s[e%s.length].replace("#",n[e][t]):n[e][t]:0}_pasteDataType(e){const t=this.dataSource&&"number"==typeof this.dataSource.dataSource,l=e.cell,n=e.value;let o=l.column.dataType;return o&&!t||(o=isNaN(parseFloat(n))?"string":n instanceof Date?"date":"true"===n||"false"===n?"boolean":"number"),o}_getCellEditorDataSource(e){const t=this;if(e.column.editor){if(e.column.editor.dataSource)return e.column._dataSource=e.column.editor.dataSource,e.column.editor.dataSource;switch(e.column.editor.template){case"list":case"dropDownList":case"comboBox":case"autoComplete":case"multiInput":case"checkInput":case"multiComboInput":case"tags":if(!e.editor.dataSource){const l=t.getVisibleRows(),n=[],o=[];for(let i=0;i<l.length;i++){let a=t.dataSource[l[i].index];if(a){if(e.column.displayField!==e.column.dataField){const t=a[e.column.displayField],l=a[e.column.dataField];-1===o.indexOf(t)&&(n.push({label:t,value:l}),o.push(t));continue}if(a=a[e.column.dataField],!a)continue;-1===n.indexOf(a)&&n.push(a)}}return e.column._dataSource=n,n}if(e.column.editor.collaborator){let l=[];for(let e=0;e<t.users.length;e++)l.push({color:t.users[e].color,label:t.users[e].name,id:t.users[e].id,value:t.users[e].id,name:t.users[e].name,image:t.users[e].image});return e.column._dataSource=l,l}}}return null}_pasteModeCopy(e){const t=this,l=t.dataSource&&"number"==typeof t.dataSource.dataSource,n=t._pasteDataType(e),o=e.cell;let i=e.value;if(i&&"string"==typeof i&&(i=i.replace(/["]/g,"")),o.column.editor&&(o.column.editor.dataSource||t._getCellEditorDataSource(o))&&i){const e=e=>{let l;const n=t._getCellEditorDataSource(o);for(let t=0;t<n.length;t++){const i=n[t];if("string"!=typeof i&&(i.label===e||i.name===e))return l=i.value,o.column.editor.collaborator&&(l=i.id),l;if("string"!=typeof i&&i.label&&i.label.toLowerCase()===e)return l=i.value,o.column.editor.collaborator&&(l=i.id),l;if("string"!=typeof i&&i.value===e)return l=i.value,o.column.editor.collaborator&&(l=i.id),l;if("string"==typeof i&&i===e)return e;if("object"==typeof i&&i.label===e)return i;if("object"==typeof i&&o.column.editor.relationField&&""+e==""+t)return e}return-1};let l=-1;if(i&&-1!==i.indexOf(",")?(l=[],i.split(",").forEach((t=>{const n=e(t.trim());-1!==n&&l.push(n)})),l=l.join(",")):l=e(i),-1!==l&&(i=l),-1===l)return}if(o.column.editor)switch(o.column.editor.template){case"custom":return}let a=i;const s=e.dataField;if(a&&"string"==typeof a&&a.indexOf("[{")>=0&&"image"!==o.column.template&&"attachment"!==o.column.template)return;if(a&&"string"==typeof a&&a.indexOf("<")>=0&&(""===o.column.template&&"string"===n?a=t.clearPaste(a,"text/html","plainText"):"richText"===o.column.template&&"string"===n&&a&&a.indexOf("data-block")>=0||(a=t.clearPaste(a))),a&&"string"==typeof a&&"richText"===o.column.template&&/^(https?:\/\/)?([\w.-]+\.[a-z]{2,})(\/[^\s]*)?$/i.test(a.trim())){const e=document.createElement("a");e.innerHTML=a,e.href=a,e.target="_blank",e.title="Ctrl + Click to open link",a=e.outerHTML}let r=a,d=!1;if("string"===n){if(r=a,r){if((""+r).indexOf("&#")>=0&&(r=t._fromHTMLEntities(r)),(""+r).indexOf("GMT")>=0&&-1===a.indexOf("[{")){const e=new Smart.Utilities.DateTime(r).toString("d");e&&e.length&&(r=e)}"image"!==o.column.editor.template&&"attachment"!==o.column.editor.template&&"textarea"!==o.column.editor.template&&"richText"!==o.column.editor.template&&(r=t._unescapeString(r),o.column.editor.collaborator||(r=r.replaceAll("\\"," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/'/g,""").replace(/[\r\n]+/g," ").replace(/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/gi,(e=>"&#"+e.codePointAt(0)+";"))))}d=!0}else if("bool"===n||"boolean"===n)1!==a&&"1"!==a&&!0!==a&&"true"!==a&&"TRUE"!==a&&"True"!==a||(r=!0,d=!0);else if("date"===n||"time"===n||"dateTime"===n){const e=t.columnByDataField[s];l?(r=a,d=!0):e&&e.dataType!==n?(r=null,d=!0):(r=a,"string"==typeof a&&(r=o&&o.column.cellsFormat&&"string"==typeof a?Smart.Utilities.DateTime.ParseDate(a,o.column.cellsFormat):new Date(a)),o&&"duration"===o.column.template&&(r=[r,r]),d=!0)}else if("number"===n||"float"===n||"int"===n){const e=t.columnByDataField[s];l?(r=a,d=!0):e&&e.dataType!==n?(r=null,d=!0):null!==a?"int"===n||"integer"===n?(r=parseInt(a),d=!0):(r=parseFloat(a),isNaN(r)&&(r=null),d=!0):(r=null,d=!0)}if(!1!==o.column.allowEdit&&!1!==t.editing.enabled||(d=!1),d)if(t.dataSource&&t.dataSource.virtualDataSource){const e={};e[o.column.dataField]=r,t.editing.batch?t._batchUpdateCell(o.row,o.column,r,o.value):t.updateRow(o.row.id,e)}else{const e=o.value;if(t._setCellUndoRedo(o,e,r),t.onCellUpdate){t._pasteTempValues||(t._pasteTempValues=[]),t._pasteTempValues.push({id:o.row.id,cell:o,dataField:o.column.dataField,oldValue:e,newValue:r}),t._pasteTimer&&clearTimeout(t._pasteTimer);const l=(e,l)=>{const n=e.row;if(n){let o=null;if(t.storeHistory&&(o=t._stringifyRow(n)),l!==(void 0!==e.value?e.value:"")&&(n.updatedDate=new Date,n.updatedBy=t.currentUser,t.storeHistory)){e.value=l;const i=t._stringifyRow(n);t._updateRowHistory(n,o,i)}}};t._pasteTimer=setTimeout((()=>{if(t._pasteTempValues&&t._pasteTempValues.length>1){let e=[],n=[],o=[];for(let l=0;l<t._pasteTempValues.length;l++){const i=t._pasteTempValues[l];e.push(i.cell),n.push(i.oldValue),o.push(i.newValue)}t.onCellUpdate(e,n,o,(function(n){if(n){const n=t.onRowHistory;t.onRowHistory=null,t.beginUpdate();for(let n=0;n<e.length;n++){const i=e[n];l(i,o[n]),t.formulas&&"string"==typeof o[n]&&o[n].startsWith("=")&&/=.+/.test(o[n])?i.formula=t._fromHTMLEntities(o[n]):i.value=o[n],t.flashCell(i.row.id,i.column.dataField)}t.endUpdate(!1),t.onRowHistory=n}}),t)}else t.onCellUpdate([o],[e],[r],(function(e){if(e){const e=t.onRowHistory;t.onRowHistory=null,l(o,r),t.formulas&&"string"==typeof r&&r.startsWith("=")&&/=.+/.test(r)&&-1===r.indexOf("[{")?o.formula=t._fromHTMLEntities(r):o.value=r,t.flashCell(o.row.id,o.column.dataField),t.onRowHistory=e}}),t);delete t._pasteTempValues}),100)}else if(t.onRowUpdate){const e=Object.assign({},o.row.data),l=Object.assign({},o.row.data);l[o.column.dataField]=r,o.row.updatedDate=new Date,o.row.updatedBy=t.currentUser,t.onRowUpdate([o.row.index],[o.row],[e],[l],(function(e){e&&(o.value=r)}),t)}else t.formulas&&"string"==typeof r&&r.startsWith("=")&&/=.+/.test(r)&&-1===r.indexOf("[{")?o.formula=t._fromHTMLEntities(r):t.editing.batch?t._batchUpdateCell(o.row,o.column,r,o.value):o.value=r,t.flashCell(o.row.id,o.column.dataField)}}_pasteModeFill(e){const t=this,l=t.dataSource&&"number"==typeof t.dataSource.dataSource,n=t._pasteDataType(e),o=e.cell,i=e.selectedValues,a=e.minRowIndex,s=e.minColumnIndex,r=e.currentRowIndex,d=e.currentColumnIndex,c=e.dataField;let u=e.value;if("string"===n)/\d+/.test(u.toString())?(u=t._getPatternValue(r-a,d-s,i),void 0===u&&i[r-a]&&i[r-a][d-s]&&(u=i[r-a][d-s])):(u=t._getPatternValue(r-a,d-s,i),void 0===u&&(u=i[r-a]?i[r-a][d-s]:e.value),void 0===u&&(u=e.value)),void 0!==u&&(o.value=u);else if("bool"===n||"boolean"===n)1!==u&&"1"!==u&&!0!==u&&"true"!==u&&"TRUE"!==u&&"True"!==u||(o.value=!0);else if("date"===n||"time"===n||"dateTime"===n){const e=t.columnByDataField[c];l?o.value=u:e&&e.dataType!==n&&(o.value=null),i[r-a]&&(u=i[r-a][d-s],void 0!==u&&(o.value=u))}else if("number"===n||"float"===n||"int"===n){u=t._getPatternValue(r-a,d-s,i);const e=t.columnByDataField[c];l?o.value=u:e&&e.dataType!==n?o.value=null:o.value=null!==u?"int"===n||"integer"===n?parseInt(u):parseFloat(u):null}}_pasteSelectedCells(e,t){const l=this;l.beginUpdate();let n=l._recyclingRows,o=e.row,i=e.endRow,a=e.column,s=e.endColumn;l._deleteCopyRects();const r=n.indexOf(o),d=n.indexOf(i),c=n.indexOf(e.endRow),u=l.viewColumns,f=u.indexOf(a),p=u.indexOf(s),m=u.indexOf(e.endColumn),g=Math.min(c,Math.min(r,d));let _=Math.max(c,Math.max(r,d)),h=!1,w=Object.keys(t).length;_-g<w&&(_=g+w-1,h=!0);const y=Math.min(m,Math.min(f,p));let v=Math.max(m,Math.max(f,p));if(t[0]){const e=Object.keys(t[0]).length;v-y<e-1&&(v=v+e-1,h=!0)}let S=0,R=0,C=0,x=0;for(let e in t)0===S&&(R+=Object.keys(t[e]).length),S++;let b=!1;l._selection&&l._selection.columns&&Object.keys(l._selection.columns).length>0&&(b=!0);for(let e=g;e<=_;e++){const o=n[e];if(o){C=0;for(let n=y;n<=v;n++){if(!u[n])continue;const i=u[n].dataField,a=o.getCell(i);let s=0;b&&(s=x);for(let r in t){if(s===x){let d=0,c=t[r];b&&(c=t[s]);for(let s in c){if(C===d){let r=c[s],d=!0;if(t[o.id]&&t[o.id][i]&&(d=!1),d&&"none"!==l.clipboard.autoFillMode){if(!a)continue;const o={value:r,targetValue:a.value,dataField:s,index:a.row.visibleIndex,targetDataField:i,targetRowIndex:e};if(l.clipboard.onPasteValue){l.clipboard.onPasteValue(o);const e=a.value;a.value=o.value,l._setCellUndoRedo(a,e,o.value)}else if(o.cell=a,o.selectedValues=t,o.minRowIndex=g,o.maxRowIndex=_,o.minColumnIndex=y,o.maxColumnIndex=v,o.currentColumnIndex=n,o.currentRowIndex=e,"copy"===l.clipboard.autoFillMode)if(o.value&&o.value.indexOf("<")>=0){const e=document.createElement("textarea");e.value=o.value,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),setTimeout((()=>{document.execCommand("copy"),o.value=e.value,e.remove(),l.focus(),l._pasteModeCopy(o)}),25)}else l._pasteModeCopy(o);else"fillSeries"===l.clipboard.autoFillMode&&l._pasteModeFill(o)}}d++}}s++}C++,C>=R&&(C=0)}x++,x>=S&&(x=0)}}l.endUpdate(!1),h&&l.viewColumns[v]&&l.viewColumns[y]&&n[_]&&n[g]&&l._selectCellsRange(n[g],n[_],l.viewColumns[y].dataField,l.viewColumns[v].dataField),setTimeout((()=>{l._conditionalColors&&l._conditionalColors.update&&(l._conditionalColors.update(),l._recycle(!1))}),100),l._recycle(!1),l._refreshDataFilters()}_refreshCellSelectionRect(){const e=this,t=e._selection.selectionRect;if(e._copyRects&&e._copyRects.length&&e._refreshCopyRects(),!t||t&&t.captured)return;let l=e._recyclingRows,n=t.row,o=t.endRow,i=t.column,a=t.endColumn;const s=e.viewColumns;if(!a||!i)return;if(e._isVirtualMode()){if(n.id!==t.rowId&&!e.rowById[t.rowId])return t.style.height="0px",void(t.style.width="0px");if(n=e.rowById[t.rowId],o=e.rowById[t.endRowId],!o)return}if(!i.allowSelect||!a.allowSelect){if(i===a)return t.style.width="0px",void(t.style.height="0px");{const e=s.indexOf(i),l=s.indexOf(a);i=null,a=null;for(let t=e;t<l;t++){const e=s[t];e.allowSelect&&!i&&(i=e),a=e}if(!i||!a)return t.style.width="0px",void(t.style.height="0px")}}const r=l.indexOf(n),d=l.indexOf(o),c=s.indexOf(i),u=s.indexOf(a);let f=Math.min(r,d),p=Math.max(r,d),m=Math.min(c,u),g=Math.max(c,u);m=Math.max(0,m),f=Math.max(0,f);const _=function(e){const t=l.indexOf(e.row),n=l.indexOf(e.endRow),o=s.indexOf(e.column),i=s.indexOf(e.endColumn);f=Math.min(f,t),f=Math.min(f,n),f=Math.max(0,f),p=Math.max(p,t),p=Math.max(p,n),m=Math.min(m,o),m=Math.min(m,i),m=Math.max(0,m),g=Math.max(g,o),g=Math.max(g,i)},h=e._getParentCell(n,i.dataField),w=e._getParentCell(n,a.dataField),y=e._getParentCell(o,a.dataField),v=e._getParentCell(o,i.dataField);h&&_(h),w&&_(w),y&&_(y),v&&_(v);let S=0,R=0,C=0,x=0;t.cellValues=[];let b=[],F=[];for(let n=f;n<=p;n++){const o=l[n];if(n===f&&(S=o.top,!0!==o.freeze&&"near"!==o.freeze&&(S+=e.__frozenNearHeight),"far"===o.freeze&&(S=o.top+e.__scrollHeight+e.scrollTop-e._scrollView.hScrollBar.offsetHeight)),n===p){let t=o.top;"far"===o.freeze&&(t=o.top+e.__scrollHeight+e.scrollTop-e._scrollView.hScrollBar.offsetHeight),R=t+o.height-S,!0!==o.freeze&&"near"!==o.freeze&&(R+=e.__frozenNearHeight)}t.cellValues[o.id]=[];const i=e._isUpdating;e._isUpdating=!0,t.style.zIndex="";for(let l=m;l<=g;l++){const n=s[l].dataField,i=o.getCell(n);let a=i?i.value:"";if(void 0===a&&(a=""),s[l].freeze?b.push(s[l]):F.push(s[l]),"tags"===s[l].template)if(null!=a)if("number"==typeof a)a=null;else{const t=a.trim().split(","),n=[];if(s[l].editor&&s[l].editor.dataSource){const o=s[l].editor.collaborator?e.users:s[l].editor.dataSource;for(let e=0;e<t.length;e++)for(let l=0;l<o.length;l++){const i=o[l],a=i.value;if(t[e]===i.value||t[e]===i.id){n.push(i.label||i.name);break}if(a&&(t[e]===a.toLowerCase()||t[e]===i.id)){n.push(i.label||i.name);break}}}a=n.join(", ")}else a=null;else if("createdBy"===s[l].template||"updatedBy"===s[l].template){for(let t=0;t<e.users.length;t++)if(e.users[t].id===o[s[l].template]){a=e.users[t].label||e.users[t].name;break}}else"createdTime"===s[l].template||"createdDate"===s[l].template?(a=o.createdDate,a&&(a=new Smart.Utilities.DateTime(a).toString("d"))):"updatedTime"!==s[l].template&&"updatedDate"!==s[l].template||(a=o.updatedTime,!a)||(a=new Smart.Utilities.DateTime(a).toString("d"));if(i.formula&&(a=i.formula),t.cellValues[o.id][n]=a,l===m&&(C=i.column.left,i.column.freeze&&"far"===i.column.freeze&&(C=e.__clientSize.width-e.__frozenFarWidth+C+e.scrollLeft-e._scrollView.vScrollBar.offsetWidth)),l===g){let t=i.column.left;i.column.freeze&&"far"===i.column.freeze&&(t=e.__clientSize.width-e.__frozenFarWidth+t+e.scrollLeft-e._scrollView.vScrollBar.offsetWidth),x=t+i.column.computedWidth-C}let c=!0;-1!==r&&-1!==d||(c=!1),c&&(i.selected=!0)}e._isUpdating=i}if(S-e.scrollTop<e.layout.rowMinHeight&&e.filtering.enabled&&e.filtering.filterRow.visible){const t=S;S=e.layout.rowMinHeight+e.scrollTop,R-=S-t}if(R<=0)t.classList.add("smart-visibility-hidden");else{if(t.classList.remove("smart-visibility-hidden"),0===b.length&&(t.style.zIndex=5),t.style.top=S-e.scrollTop-1+"px",0===f&&0===S&&0===e.scrollTop&&(t.style.top="0px"),e._isVirtualMode(),e.rightToLeft)t.style.right=C-e.scrollLeft+"px";else if(t.style.left=C-e.scrollLeft+"px",C-e.scrollLeft<e.__frozenNearWidth-1){let l=0;for(let t=0;t<e._frozenNearColumns.length;t++){const n=e._frozenNearColumns[t];n&&n.autoGenerated&&n.visible&&(l+=n.width)}if(C-e.scrollLeft<l){const n=l-C+e.scrollLeft;!F.length&&b.length&&(x+=n),x-=n,t.style.left=n+C-e.scrollLeft+"px"}}t.style.height=R+1+"px",t.style.width=x+1+"px",x<0?t.classList.add("smart-visibility-hidden"):t.classList.remove("smart-visibility-hidden")}}_renderInputOverlay(e,t,l){const n=this,o=n.rowById[e];if(o&&!1!==o.allowSelect&&!o.label&&t&&n.selection.checkBoxes.enabled){n._inputOverlay&&n._inputOverlay.classList.contains("smart-input-overlay-column")&&(n._inputOverlay.parentNode&&n._inputOverlay.parentNode.removeChild(n._inputOverlay),n._inputOverlay=null),n._inputOverlay||(n._inputOverlay=document.createElement("div"),n.$.scrollView.appendChild(n._inputOverlay),n._inputOverlay.classList.add("smart-input-overlay"));let e=o.freeze?o.top:n.__frozenNearHeight+o.top;const t=Math.round((o.cellHeight-n._selectionColumn.computedWidth)/2),i=n._selectionColumn.element.parentElement.offsetLeft+n._selectionColumn.element.offsetLeft;if(n._inputOverlay.style.left=i+"px",n._inputOverlay.style.height=n._selectionColumn.computedWidth+"px",n._inputOverlay.style.width=n._selectionColumn.computedWidth+"px",n._inputOverlay.style.top=e+t-n.scrollTop+"px",o&&o.element){const e=o.element.querySelector("smart-grid-cell");e&&(n._inputOverlay.cell=e.cell)}n._inputOverlay.row=o,n._inputOverlay.onpointerdown=function(e){n._inputOverlay||(n._inputOverlay.onpointerdown=null);const t=n._inputOverlay.row,l=n._inputOverlay.cell;n.beginUpdate(),t.selected=!t.selected,n.endUpdate(!1),n.$.fireEvent("change",{started:!1,finished:!0}),n._refreshSummary(!1);const o=e.originalEvent?e.originalEvent:e,i=3===o.which;n.$.fireEvent("rowClick",{row:t,id:t.id,isRightClick:i,originalEvent:o,pageX:parseInt(o.pageX),pageY:parseInt(o.pageY)}),l&&n.$.fireEvent("cellClick",{cell:l,id:t.id,dataField:l.column.dataField,isRightClick:i,originalEvent:o,pageX:parseInt(o.pageX),pageY:parseInt(o.pageY)}),n._recycle(),n._renderInputOverlay(t.id,e,!0),e.preventDefault()},n.appearance.allowCheckBoxesSelectionAnimation&&void 0===l&&n._inputOverlay.classList.add("smart-animate"),requestAnimationFrame((()=>{n._inputOverlay&&n._inputOverlay.classList.add("smart-input-overlay-on")}))}}_selectRow(e,t){const l=this,n=l.rowById[e];if(n&&l.selection.enabled&&(!n.header||"row-resize"!==n.header.style.cursor)){if(t&&(!t.shiftKey||!l._selection.focusedCell)){const t=n.getCell(l.columns[0].dataField);l._selection.focusedCell={index:t.row.index,id:e,dataField:t.column.dataField,value:t.value}}l._lastRowsSelectionRange=null,"extended"===l.selection.mode?l._handleExtendedRowSelection(n,t):"one"===l.selection.mode?n.select():n.selected?n.unselect():n.select()}}_getParentCell(e,t){const l=this;let n=l._recyclingRows;for(let o=0;o<l._cellsMerge.length;o++){const i=l._cellsMerge[o];let a=[],s=[];if(a.push(i.row),i.rowSpan>1){const e=n.indexOf(i.row);if(e>=0)for(let t=e;t<e+i.rowSpan;t++)n[t]&&-1===a.indexOf(n[t])&&a.push(n[t])}if(s.push(i.column.dataField),i.colSpan>1){const e=l.viewColumns,t=e.indexOf(l.columnByDataField[i.column.dataField]);for(let l=t;l<t+i.colSpan;l++)e[l]&&-1===s.indexOf(e[l].dataField)&&s.push(e[l].dataField)}if(a.indexOf(e)>=0&&s.indexOf(t)>=0)return{row:i.row,column:i.column,endRow:a[a.length-1],endColumn:l.columnByDataField[s[s.length-1]]}}if(l._cellRowSpan)for(let o=0;o<l._cellRowSpan.length;o++){const o=e.visibleIndex;let i=-1,a=null;for(let e=0;e<l._cellRowSpan.length;e++){const t=l._cellRowSpan[e];if(o>t[0]&&o<t[1]){i=t[0],a=t[2];break}}if(i>=0&&a===t){const e=n[i];if(e)return{row:e,column:l.columnByDataField[t],endRow:e,endColumn:l.columnByDataField[t]}}}return null}_selectCellsRange(e,t,l,n){const o=this,i=o._selection.selectionRect;if(!e||!t)return;if(o._lastRowsSelectionRange&&o._lastRowsSelectionRange.id===e.id&&o._lastRowsSelectionRange.endId===t.id&&o._lastColumnSelectionRange&&o._lastColumnSelectionRange.dataField===l&&o._lastColumnSelectionRange.endDataField===n)return;o.beginUpdate(),o._clearSelection(),o._lastRowsSelectionRange={id:e.id,endId:t.id},o._lastColumnSelectionRange={dataField:l,endDataField:n},(!i||i&&!i.captured)&&o._selection.focusedCell&&o._renderCellSelectionRect(o.rowById[o._selection.focusedCell.id],o.columnByDataField[o._selection.focusedCell.dataField],o.rowById[o._lastRowsSelectionRange.endId],o.columnByDataField[o._lastColumnSelectionRange.endDataField]);let a=o._recyclingRows;const s=o.viewColumns;let r=-1,d=-1,c=a.indexOf(e),u=a.indexOf(t),f=-1;for(let e=0;e<s.length;e++){const t=s[e];t.allowSelect&&(-1===f&&(f=e),t.dataField===l&&(r=e),t.dataField===n&&(d=e))}if(-1===f)return o.endUpdate(!1),void o._recycle();-1===r?r=f:-1===d&&(d=f);let p=Math.min(c,u),m=Math.max(c,u),g=Math.min(r,d),_=Math.max(r,d);const h=function(e){const t=a.indexOf(e.row),l=a.indexOf(e.endRow),n=s.indexOf(e.column),o=s.indexOf(e.endColumn);p=Math.min(p,t),p=Math.min(p,l),m=Math.max(m,t),m=Math.max(m,l),g=Math.min(g,n),g=Math.min(g,o),_=Math.max(_,n),_=Math.max(_,o)},w=o._getParentCell(e,l),y=o._getParentCell(t,n);if(w&&h(w),y&&h(y),m<0||p<0||g<0||_<0)return o.endUpdate(!1),void o._recycle();for(let e=p;e<=m;e++){const t=a[e];if(t.allowSelect)for(let e=0;e<s.length;e++){const l=s[e];l.allowSelect&&e>=g&&e<=_&&(t.getCell(l.dataField).selected=!0)}}o.endUpdate(!1,!1),o._recycle(!0,!0,!1),o._selectionTimer&&clearTimeout(o._selectionTimer),o._selectionTimer=setTimeout((()=>{o.editing.isEditing||o._recycle(!0,!0,!1)}),50)}_selectRowsRange(e,t,l){const n=this;if(n._lastRowsSelectionRange&&n._lastRowsSelectionRange.id===e.id&&n._lastRowsSelectionRange.endId===t.id)return;if(n._dragDrop&&n._dragDrop.dragDetails)return;n.beginUpdate(),n._clearSelection(),n._lastRowsSelectionRange={id:e.id,endId:t.id};let o=n._recyclingRows;const i=o.indexOf(e),a=o.indexOf(t),s=Math.min(i,a),r=Math.max(i,a);if(r<0)return n.endUpdate(!1),void n._recycle();for(let e=s;e<=r;e++){const t=o[e];t&&t.allowSelect&&(t.selected=!1!==l)}n.endUpdate(!1),n._recycle()}_selectColumnsRange(e,t){const l=this;if(l._lastColumnSelectionRange&&l._lastColumnSelectionRange.dataField===e&&l._lastColumnSelectionRange.endDataField===t)return;if(l._dragDrop&&l._dragDrop.dragDetails)return;l.beginUpdate(),l._clearSelection(),l._lastColumnSelectionRange={dataField:e,endDataField:t};const n=l.viewColumns;let o=-1,i=n.length;for(let l=0;l<n.length;l++){const a=n[l];a.allowSelect&&(a.dataField===e&&(o=l),a.dataField===t&&(i=l))}const a=Math.min(o,i),s=Math.max(o,i);for(let e=0;e<n.length;e++){const t=n[e];t.allowSelect&&e>=a&&e<=s&&(t.selected=!0)}l.endUpdate(!1),l._recycle()}_selectColumn(e,t){const l=this,n=l.columnByDataField[e],o=l.viewColumns;if(!n||!l.selection.enabled||!1===n.allowSelect||!l.selection.allowColumnHeaderSelection)return;if(n&&"col-resize"===n.element.style.cursor)return;let i=!1;if(n&&(n.allowSelect||null===n.allowSelect&&!t)&&(i=!0),i&&t)if("extended"===l.selection.mode){if(t.ctrlKey||t.metaKey||t.shiftKey||(l._rangeSelectionStartColumn=n,l._rangeSelectionEndColumn=n),t.ctrlKey||t.metaKey?n.selected=!n.selected:n.selected=!0,t&&t.shiftKey){l._rangeSelectionStartColumn||(l._rangeSelectionStartColumn=n),l._rangeSelectionEndColumn=n,l._selection.columns=[];const e=o.indexOf(l._rangeSelectionStartColumn),t=o.indexOf(l._rangeSelectionEndColumn),i=Math.min(e,t),a=Math.max(e,t);for(let e=i;e<=a;e++){const t=o[e];t&&!1!==t.allowSelect&&(t.selected=!0)}}}else"one"===l.selection.mode||null===n.selected?n.selected=!0:n.selected=!n.selected}selectAllRows(){const e=this;let t=e.rows;e._selectionColumn._selecting=!0,delete e._areAllRowsSelected,e.beginUpdate();for(let e=0;e<t.length;e++)t[e].selected=!0;e._selectionColumn._selecting=!1,e.endUpdate(!1),e._refreshSummary(!1),e._recycle(!1),e._refreshCheckBoxColumnSelection(),e.$.fireEvent("change",{started:!1,finished:!0})}hasSelectedRows(){const e=this.getVisibleRows(),t=this._getSelectedRows(!0,!1);return t.length===e.length||t.length>0&&t.length<e.length||0!==t.length&&0!==e.length&&void 0}areAllRowsSelected(){const e=this;if(e._areAllRowsSelected!==this.undefined)return e._areAllRowsSelected;const t=e.getVisibleRows(),l=Object.keys(e._selection.rows).length;if(0===l||l<t.length)return!1;const n=e._getSelectedRows(!0,!1);return n.length>0&&n.length===t.length?(e._areAllRowsSelected=!0,!0):(e._areAllRowsSelected=!1,e._areAllRowsSelected)}_getSelectedRows(e,t){const l=this,n=[];let o=l.rows;if(l.rows.canNotify=!1,e&&(o=l.getVisibleRows()),l._isVirtualMode()){let e=l._selection.indexes;return l.paging.enabled&&t&&l._isVirtualMode()&&(e=e.slice(0,l.paging.pageSize)),l.rows.canNotify=!0,Object.keys(e).length}l.paging.enabled&&t&&(o=l._isVirtualMode()?o.slice(0,l.paging.pageSize):o.slice(l.paging.pageIndex*l.paging.pageSize,(l.paging.pageIndex+1)*l.paging.pageSize));for(let e=0;e<o.length;e++){const t=o[e];t.getProperty("selected")?n.push(t):(t.canNotify=!1,t.selected=!1,t.canNotify=!0)}return l.rows.canNotify=!0,n}_dragSelectionEnd(e){const t=this;t._dragSelectionStartDataField=null,t._dragSelectionStartRow=null,t.__selectionStarted&&(t.$.fireEvent("change",{started:!1,finished:!0,originalEvent:e}),t._refreshSummary(),delete t.__selectionStarted,delete t.__selectionStartedFired,t.autoSaveState()),t.selection.allowDragSelection&&t.selection.isDragging&&(t.selection.isDragging=!1,t._autoScrollSelectionDragInterval&&(clearInterval(t._autoScrollSelectionDragInterval),t.editing.isEditing||t._recycle()))}_dragSelection(e){const t=this;if("extended"!==t.selection.mode||!1===t.selection.allowDragSelection)return;if(!t._dragSelectionStartDataField&&!t._dragSelectionStartRow)return;const l=()=>{t.__selectionStarted&&!t.__selectionStartedFired&&(t.$.fireEvent("change",{started:!0,finished:!1,originalEvent:e}),t.__selectionStartedFired=!0),t.$.fireEvent("change",{started:!1,finished:!1,originalEvent:e})};if(!t.selection.allowCellSelection||!t._dragSelectionStartDataField||t._columnResizeLine||t._dragSelectionStartDataField.startsWith("_")||!t._dragSelectionStartRow||t._rowResizeLine){if(t._dragSelectionStartRow&&!t._rowResizeLine&&(t.selection.allowRowSelection&&!t._dragSelectionStartDataField.startsWith("_")||t.selection.allowRowHeaderSelection&&t._dragSelectionStartDataField.startsWith("_"))){const n=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let o=null;for(let e=0;e<n.length;e++){const t=n[e];if(t.getAttribute("data-id")){o=t.row,!o&&t.cell&&(o=t.cell.row);break}}let i=!0;t._lastRowsSelectionRange&&t._lastRowsSelectionRange.id===t._dragSelectionStartRow.id&&o&&t._lastRowsSelectionRange.endId===o.id&&(i=!1),o&&!o.allowSelect&&(i=!1),o&&o.allowSelect&&t._selectRowsRange(t._dragSelectionStartRow,o),t._autoScrollSelectionDragInterval&&clearInterval(t._autoScrollSelectionDragInterval),t.selection.isDragging=!0,i&&l(),t._autoScrollSelectionDragInterval=setInterval((function(){const l=t.$.scrollView.getBoundingClientRect();e.clientY<=l.top+20?t.scrollTop-=15:e.clientY>=l.top+l.height-20&&(t.scrollTop+=15)}),25)}else if(t._dragSelectionStartDataField&&!t._columnResizeLine&&!t._dragSelectionStartDataField.startsWith("_")&&t.selection.allowColumnHeaderSelection){const n=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let o=null;for(let e=0;e<n.length;e++){const t=n[e];if(t.getAttribute("data-field")){o=t.getAttribute("data-field");break}}o&&t._selectColumnsRange(t._dragSelectionStartDataField,o),t._autoScrollSelectionDragInterval&&clearInterval(t._autoScrollSelectionDragInterval);let i=!0;t._lastColumnSelectionRange&&t._lastColumnSelectionRange.dataField===t._dragSelectionStartDataField&&t._lastColumnSelectionRange.endDataField===o&&(i=!1),i&&l(),t.selection.isDragging=!0,t._autoScrollSelectionDragInterval=setInterval((function(){const l=t.$.scrollView.getBoundingClientRect();e.clientX<=l.left+20?t.scrollLeft-=15:e.clientX>=l.left+l.width-20&&(t.scrollLeft+=15)}),25)}}else{const n=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let o=null;for(let e=0;e<n.length;e++){const t=n[e];if(t.getAttribute("data-field")){o=t.getAttribute("data-field");break}}let i=null;for(let e=0;e<n.length;e++){const t=n[e];if(t.getAttribute("data-id")){i=t.row;break}}if(!i&&n.length&&n[0].classList.contains("smart-grid-scroll-view")){i=t._recyclingRows[t._recyclingRows.length-1];const l=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,i.element.getBoundingClientRect().top);for(let e=0;e<l.length;e++){const t=l[e];if(t.getAttribute("data-field")){o=t.getAttribute("data-field");break}}}if(o&&i){if(i.id===t._dragSelectionStartRow.id&&t._dragSelectionStartDataField===o&&t._lastRowsSelectionRange&&t._lastRowsSelectionRange.id===t._dragSelectionStartRow.id&&t._lastRowsSelectionRange.endId===i.id&&t._lastColumnSelectionRange&&t._lastColumnSelectionRange.dataField===t._dragSelectionStartDataField&&t._lastColumnSelectionRange.endDataField===o)return;if(o&&o.startsWith("_"))return;let e=!0;if(t._lastRowsSelectionRange&&t._lastRowsSelectionRange.id===t._dragSelectionStartRow.id&&t._lastRowsSelectionRange.endId===i.id&&t._lastColumnSelectionRange&&t._lastColumnSelectionRange.dataField===t._dragSelectionStartDataField&&t._lastColumnSelectionRange.endDataField===o&&(e=!1),t._lastRowsSelectionRange&&t._lastRowsSelectionRange.id===t._dragSelectionStartRow.id&&t._lastRowsSelectionRange.endId===i.id&&t._lastColumnSelectionRange&&t._lastColumnSelectionRange.dataField===t._dragSelectionStartDataField&&t._lastColumnSelectionRange.endDataField===o)return;t._selectCellsRange(t._dragSelectionStartRow,i,t._dragSelectionStartDataField,o),t._removeCellContentPopup(),e&&l()}t.selection.allowDragSelectionAutoScroll&&(t._autoScrollSelectionDragInterval&&clearInterval(t._autoScrollSelectionDragInterval),t.selection.isDragging=!0,t._autoScrollSelectionDragInterval=setInterval((function(){const l=t.$.scrollView.getBoundingClientRect();e.clientX<=l.left+20?t.scrollLeft-=15:e.clientX>=l.left+l.width-20&&(t.scrollLeft+=15),e.clientY<=l.top+20?t.scrollTop-=15:e.clientY>=l.top+l.height-20&&(t.scrollTop+=15)}),25))}}select(e,t){const l=this;l.isInitialized&&(!t&&void 0!==e&&l._selection&&l._selection.rows[e]||(l._setSelection(e,t),l.$.fireEvent("change",{started:!1,finished:!0}),l._refreshSummary()))}selectRowsByIndex(e){const t=this;e||(e=[]),requestAnimationFrame((()=>{if("extended"!==t.selection.mode&&"many"!==t.selection.mode&&t._clearSelection(),t._isVirtualMode()){let l=[];for(let t=0;t<e.length;t++)l[e[t]]=!0;return t._selection.indexes=l,void t._recycle()}t.beginUpdate();for(let l in e){const n=e[l],o=t.rows[n];o&&t._setSelection(o.id)}t.endUpdate(!1),t._recycle()}))}selectRowsRange(e,t){const l=this,n=l.rowById[e],o=l.rowById[t];n&&o&&(l._selectRowsRange(n,o),l.$.fireEvent("change",{started:!1,finished:!0}),l._refreshSummary())}selectCellsByQuery(e,t){const l=this,n=e?l.findCells(e):t;requestAnimationFrame((()=>{"extended"!==l.selection.mode&&"many"!==l.selection.mode&&l._clearSelection(),l.beginUpdate();for(let e in n){const t=n[e][0],o=n[e][1];l._setSelection(t,o)}l.endUpdate(!1),l._recycle()}))}selectRowsByQuery(e,t,l){const n=this,o=n.find(e,t,l).map((e=>e.$.id));o.length&&n.selectRows(o)}selectRow(e){const t=this;"extended"!==t.selection.mode&&"many"!==t.selection.mode&&t._clearSelection(),t._setSelection(e),t._recycle(!1)}selectRows(e){const t=this;e||(e=[]),requestAnimationFrame((()=>{"extended"!==t.selection.mode&&"many"!==t.selection.mode&&t._clearSelection(),t.beginUpdate();for(let l in e)t._setSelection(e[l]);t.endUpdate(!1),t._recycle()}))}selectCellsById(e){this.selectCellsByQuery(null,e)}selectCells(e,t){const l=this;e||(e=[]),requestAnimationFrame((()=>{"extended"!==l.selection.mode&&"many"!==l.selection.mode&&l._clearSelection(),l.beginUpdate();for(let n in e)for(let o=0;o<t.length;o++)l._setSelection(e[n],t[o]);l.endUpdate(!1),l._recycle()}))}selectRange(e,t,l,n){const o=this;!function(){const i=new KeyboardEvent("keydown",{shiftKey:!0});requestAnimationFrame((()=>{"extended"!==o.selection.mode&&"many"!==o.selection.mode&&o._clearSelection(),o.beginUpdate(),o._setSelection(e,t),o._setSelection(l,n,i),o.ensureVisible(e,t),o.endUpdate(!1),o._refreshSummary(!1),o._recycle()}))}(),o.$.fireEvent("change",{started:!1,finished:!0})}unselect(e,t){const l=this;if(l._selection){if(l._selection.rows&&l._selection.rows[e]){delete l._selection.rows[e];const t=l.rowById[e];t&&t.unselect()}l._selection.columns&&l._selection.columns[t]&&delete l._selection.columns