smart-webcomponents-angular
Version:
[](https://jqwidgets.com/license/)
6 lines (4 loc) • 121 kB
JavaScript
/* Smart UI v20.0.2 (2024-09-06)
Copyright (c) 2011-2024 jQWidgets.
License: https://htmlelements.com/license/ */ //
(()=>{Smart.Utilities.Assign("Grid.Cell",class{constructor(e,t){const l=this;if(l.row=e,l.column=t,l.grid=e.grid,l.rowSpan=1,l.colSpan=1,l.value=void 0,l.fontSize=null,l.fontWeight=null,l.fontFamily=null,l.fontStyle=null,l.color=null,l.background=null,l.textDecoration=null,l.tooltip=null,l.align=null,l.verticalAlign=null,l.readonly=!1,l.oldValue=void 0,l._updating=!1,l.styleChanged=!0,l.editor=null,l.template=null,l.isEditing=!1,l.canNotify=!0,l.selected=!1,l.focused=!1,l.error=!1,l.format=null,l.formula=null,e._style){const t=e._style;l.color=t.color,l.background=t.background,l.fontFamily=t.fontFamily,l.fontSize=t.fontSize,l.fontStyle=t.fontStyle,l.textDecoration=t.textDecoration,l.fontWeight=t.fontWeight}if(l.grid&&l.grid.formulas){let a=e.data[t.dataField];t.formula&&(l.formula=l._parseFormula(t.formula)),a&&(""+a).startsWith("=")&&(l.formula=l._parseFormula(""+a))}return new Proxy(l,{deleteProperty:function(e,t){return delete e[t],!0},get:function(e,t){if("value"===t){const e=l.column.displayField?l.row.data[l.column.displayField]:l.row.data[l.column.dataField];if(l.grid&&l.grid.formulas&&l.formula){const e=l.grid._formulaParser;if(e){return e.parse(l.formula.slice(1))}}return e}if("editor"===t||"template"===t)return e[t]||l.column[t];if("focused"===t){if(l.grid.selection.allowCellSelection&&l.grid._selection.focusedCell&&l.grid._selection.focusedCell.id===l.row.id&&l.grid._selection.focusedCell.dataField===l.column.dataField)return!(l.grid&&l.grid.dataSource.virtualDataSource&&!l.grid.dataSource.id)||l.grid._selection.focusedCell.id===l.row.index;if(l.grid.selection.allowRowSelection&&l.grid._selection.focusedCell&&l.grid._selection.focusedCell.id===l.row.id&&l.grid._selection.focusedCell.dataField===l.column.dataField)return!(l.grid&&l.grid.dataSource.virtualDataSource&&!l.grid.dataSource.id)||l.grid._selection.focusedCell.id===l.row.index;const e=l.parent();return!!(e&&l.grid.selection.allowCellSelection&&l.grid._selection.focusedCell&&l.grid._selection.focusedCell.id===e.row.id&&l.grid._selection.focusedCell.dataField===e.column.dataField)}if("selected"===t)return!0===l.row.getProperty("selected")||(!0===l.column.getProperty("selected")||!!l.grid._selection.cells["row"+l.row.id]&&l.grid._selection.cells["row"+l.row.id][l.column.dataField]);if("modifiedValue"===t){l.grid._cellsUpdatedValues||(l.grid._cellsUpdatedValues=[]);const t=l.grid._cellsUpdatedValues[l.row.id+"_"+l.column.dataField];return void 0!==t?t:e.value}return e[t]},set:function(e,a,i){const r=this.get(e,a);if(r===i)return!0;if(e[a]=i,"element"===a||"isEditing"===a||"oldValue"===a||"_updating"===a||"notifyFn"===a||a.startsWith("_")||"canNotify"===a)return!0;if("error"===a)return!0;if("focused"===a&&(l.grid._selection.focusedCell={id:l.row.id,dataField:l.column.dataField,value:l.value,index:l.row.index}),"colSpan"!==a&&"rowSpan"!==a||i>=0&&-1===l.grid._cellsMerge.indexOf(l)&&l.grid._cellsMerge.push(l),"row"===a||"column"===a||"grid"===a||"styleChanged"===a||"formula"===a)return"formula"===a&&(l.formula=l._parseFormula(l.formula)),!0;if("background"!==a&&"fontSize"!==a&&"fontWeight"!==a&&"fontFamily"!==a&&"textDecoration"!==a&&"color"!==a&&"fontStyle"!==a||(l.grid._cellStyles["row"+l.row.id]=!0,l.grid._cellStyles.length++,l._styleChanged=!0),"value"===a){void 0===l.oldValue&&(l.oldValue=r);(()=>{if(l.grid.dataSource.boundSource.canNotify=!1,null===i&&(l.column.allowNull||(i="number"===l.column.dataType||"int"===l.column.dataType||"float"===l.column.dataType||"integer"===l.column.dataType?0:"date"===l.column.dataType?new Date:"boolean"!==l.column.dataType&&"bool"!==t.dataType&&"")),void 0===i&&(i=null),null!==i&&void 0!==i.label&&void 0!==i.value)l.row.data[l.column.displayField]=i.label,l.row.data[l.column.dataField]=i.value;else if(l.column.valueField&&(l.row.data[l.column.valueField]=i),l.row.data[l.column.dataField]=i,l.column.displayField!==l.column.dataField&&"object"!=typeof i)if(l.column._dataSource){let e=i;for(let t=0;t<l.column._dataSource.length;t++)if(l.column._dataSource[t].value===i){e=l.column._dataSource[t].label;break}l.row.data[l.column.displayField]=e}else l.row.data[l.column.displayField]=i;const e=l.grid.dataSource.dataItemById[l.row.id];if(e){const t=e.$.index;l.grid.dataSource&&(null!==i&&i.label&&i.value&&l.column.displayField!==l.column.dataField?l.grid._sortedColumns&&l.grid._sortedColumns.length>0?(e[l.column.dataField]=i.value,e[l.column.displayField]=i.label):(l.grid.dataSource.boundSource[t][l.column.dataField]=i.value,l.grid.dataSource.boundSource[t][l.column.displayField]=i.label):i!==l.grid.dataSource.boundSource[t][l.column.dataField]&&(l.grid._sortedColumns&&l.grid._sortedColumns.length>0?e[l.column.dataField]=i:l.grid.dataSource.boundSource[t][l.column.dataField]=i))}l.grid.dataSource.boundSource.canNotify=!0})()}return"selected"===a?(l.grid._selection.cells["row"+l.row.id]&&(delete l.grid._selection.cells["row"+l.row.id][l.column.dataField],1===Object.getOwnPropertyNames(l.grid._selection.cells["row"+l.row.id]).length&&delete l.grid._selection.cells["row"+l.row.id]),l.grid._selection.cells["column"+l.column.dataField]&&(delete l.grid._selection.cells["column"+l.column.dataField][l.row.id],1===Object.getOwnPropertyNames(l.grid._selection.cells["column"+l.column.dataField]).length&&delete l.grid._selection.cells["column"+l.column.dataField]),i&&(l.grid._selection.cells["row"+l.row.id]||(l.grid._selection.cells["row"+l.row.id]=[]),l.grid._selection.cells["column"+l.column.dataField]||(l.grid._selection.cells["column"+l.column.dataField]=[]),l.grid._selection.cells["row"+l.row.id][l.column.dataField]=!0,l.grid._selection.cells["column"+l.column.dataField][l.row.id]=!0),l.grid._recycle(!1,!0,!1),l.propertyChanged&&l.propertyChanged(name.substring(1),r),!0):!(!l._updating&&l.canNotify)||(l.grid._recycle(),!l.row.canNotify||(l.propertyChanged&&l.propertyChanged(name.substring(1),r),!0))}})}_parseFormula(e){let t=0;const l=this.row;if(!e)return e;for("string"!=typeof e&&(e=""+e),!1===e.startsWith("=")&&(e="="+e);e.indexOf("COL")>=0;){const a=e.indexOf("COL"),i=a+e.substring(a).indexOf(")"),r=e.substring(a,i+2),n=e.substring(i+2,i+3);let s="";if(s=isNaN(parseInt(n))?r.replace("COL(","").replace(")",1+l.index):r.replace("COL(","").replace(")",""),e=e.replace(r,s),t++,t>10)break}return e}setStyle(e){this.setProperties(e)}_setStyle(e){const t=this;if(t._styleChanged){if(!t.grid._cellStyles.length)return;let l="";const a={background:"background",color:"color",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",fontStyle:"font-style",textDecoration:"text-decoration"},i=e=>{const i=t[e];if(""===i||null===i)return;const r=a[e];l+=`${r}: ${i};`},r=["background","color","fontSize","fontFamily","fontWeight","fontStyle","textDecoration"];for(let e=0;e<r.length;e++)i(r[e]);e.getAttribute("style")!==l&&(""===l?e.removeAttribute("style"):e.setAttribute("style",l)),""!==e.style.paddingBottom&&(e.style.paddingBottom=""),t._styleChanged=!1}t.grid&&!t.grid.appearance.showSelectionOnTop||t.selected&&(t.background||t.color)&&(e.style.background="",e.style.color="")}getFormattedValue(e,t){const l=this;if(null==e||""===e)return e;if(!t)return""+e;if(l.column._cellsCachedValues||(l.column._cellsCachedValues=[]),l.column._cellsCachedValues[""+e+t+l.column.grid.locale])return l.column._cellsCachedValues[""+e+t+l.column.grid.locale];if("date"===l.column.dataType||"datetime"===l.column.dataType||"time"===l.column.dataType){if("dateRangeInput"===l.column.editor.template){if(Array.isArray(e)){const a=l.formatDate(e[0],t)+" - "+l.formatDate(e[1],t);return l.column._cellsCachedValues[""+e+t+l.column.grid.locale]=a,a}{const a=l.formatDate(e,t);return l.column._cellsCachedValues[""+e+t+l.column.grid.locale]=a,a}}let a=l.formatDate(e,t);return"1/1/0001 12:00 AM"===a&&(a=""),l.column._cellsCachedValues[""+e+t+l.column.grid.locale]=a,a}if("int"===l.column.dataType||"int64"===l.column.dataType||"float"===l.column.dataType||"number"===l.column.dataType){let a=l.formatNumber(e,t);return"NaN"===a&&(a=""),l.column._cellsCachedValues[""+e+t+l.column.grid.locale]=a,a}if("any"===l.column.dataType||"string"===l.column.dataType&&t&&t.length){let a=!1;if(t.indexOf("d")>=0&&t.indexOf("M")>=0&&(a=!0),(t.indexOf("d")>=0||t.indexOf("M")>=0||t.indexOf("y")>=0||t.indexOf("h")>=0||t.indexOf("H")>=0||t.indexOf("m")>=0)&&(a=!0),a){let a=l.formatDate(e,t);return"1/1/0001 12:00 AM"===a&&(a=""),l.column._cellsCachedValues[""+e+t+l.column.grid.locale]=a,a}{"string"==typeof e&&(e=parseFloat(e));let a=l.formatNumber(e,t);return"NaN"===a&&(a=""),l.column._cellsCachedValues[""+e+t+l.column.grid.locale]=a,a}}return e}formatDate(e,t){if(!Smart.Utilities.DateTime)return e;const l=this,a=l.grid;if(l.column.formatSettings.Intl&&l.column.formatSettings.Intl.DateTimeFormat){return new Intl.DateTimeFormat(this.grid.locale,l.column.formatSettings.Intl.DateTimeFormat).format(e)}!t&&l.column.formatSettings.dateFormat&&(t=l.column.formatSettings.dateFormat);try{const l=new Smart.Utilities.DateTime(e);l.calendar.locale=a.locale,a.messages[a.locale]&&a.messages[a.locale].calendar&&(a.messages[a.locale].calendar.months&&(l.calendar.months=a.messages[a.locale].calendar.months),a.messages[a.locale].calendar.days&&(l.calendar.days=a.messages[a.locale].calendar.days),void 0!==a.messages[a.locale].calendar.firstDay&&(l.calendar.firstDay=a.messages[a.locale].calendar.firstDay),void 0!==a.messages[a.locale].calendar.eras&&(l.calendar.eras=a.messages[a.locale].calendar.eras),void 0!==a.messages[a.locale].calendar.AM&&(l.calendar.AM=a.messages[a.locale].calendar.AM),void 0!==a.messages[a.locale].calendar.PM&&(l.calendar.PM=a.messages[a.locale].calendar.PM),void 0!==a.messages[a.locale].calendar["/"]&&(l.calendar["/"]=a.messages[a.locale].calendar["/"]),void 0!==a.messages[a.locale].calendar[":"]&&(l.calendar[":"]=a.messages[a.locale].calendar[":"]),l.calendar.today=a.messages[a.locale].today);let i=l.toString(t);return i!==a.messages[a.locale].today||a.showTodayDateAsString||(l.showTodayDateAsString=!1,i=l.toString(t),delete l.showTodayDateAsString),i}catch(t){return e}}formatNumber(e,t){if(!Smart.Utilities.NumberRenderer)return e;const l=this,a=l.grid;if(l.column.formatSettings.Intl&&l.column.formatSettings.Intl.NumberFormat){if(l.column.formatSettings.Intl.NumberFormat.currency&&Smart.Utilities.CurrencyFormatter){const t=void 0!==l.column.formatSettings.Intl.NumberFormat.maximumFractionDigits?l.column.formatSettings.Intl.NumberFormat.maximumFractionDigits:2,a=(new Smart.Utilities.CurrencyFormatter).format(e,{decimalPlaces:t,currency:l.column.formatSettings.Intl.NumberFormat.currency});return"accounting"===l.column.formatSettings.Intl.NumberFormat.currency.currencySign&&e<0?"("+a.replace("-","")+")":a}if(l.column.formatSettings.Intl.NumberFormat.locale){return new Intl.NumberFormat(l.column.formatSettings.Intl.NumberFormat.locale,l.column.formatSettings.Intl.NumberFormat).format(e)}{const t=new Intl.NumberFormat(this.grid.locale,l.column.formatSettings.Intl.NumberFormat).format(e);return"squaremeter"===l.column.formatSettings.Intl.NumberFormat.type?t+" m²":"cubicmeter"===l.column.formatSettings.Intl.NumberFormat.type?t+" m³":t}}const i=new Smart.Utilities.NumberRenderer;if(i.localizationObject){const e=l.column.formatSettings,t=a.messages[a.locale]?a.messages[a.locale].calendar:{};e.decimalPlaces&&(i.localizationObject.decimalPlaces=e.decimalPlaces),(e.decimalSeparator||t.decimalSeparator)&&(i.localizationObject.decimalSeparator=e.decimalSeparator||t.decimalSeparator,i.localizationObject.decimalseparator=i.localizationObject.decimalSeparator),(e.thousandsSeparator||t.thousandsSeparator)&&(i.localizationObject.thousandsSeparator=e.thousandsSeparator||t.thousandsSeparator,i.localizationObject.thousandsseparator=i.localizationObject.thousandsSeparator),i.localizationObject.currencysymbol=t.currencySymbol,i.localizationObject.currencysymbolposition=t.currencySymbolPosition,e.prefix&&(i.localizationObject.currencysymbol=e.prefix),e.sufix&&(i.localizationObject.currencysymbol=e.sufix,i.localizationObject.currencysymbolposition="after")}const r=i.formatNumber(e,t);return void 0===r?e:e<0&&l.column.formatSettings.negativeWithBrackets?"("+r+")":r}refresh(){const e=this;if(e.element){const t=e.element.firstChild;e._setStyle(t)}}autoWrap(){const e=this;e.element&&e.element._autoWrap()}setProperties(e){const t=this;t._updating=!0;for(let l in e)t[l]=e[l];t._updating=!1,t.grid._recycle()}createElement(){const e=document.createElement("smart-grid-cell");return e.setAttribute("role","gridcell"),this.element=e,e._initialize(this),e}render(){this.element&&this.element._render()}parent(e){const t=this,l=t.row,a=t.column.dataField,i=t.grid;if(!i._cellsMerge.length)return null;if(t.__parentCells&&void 0!==t.__parentCells["row"+l.id+"_column_"+a])return t.__parentCells["row"+l.id+"_column_"+a];let r=i.getVisibleRows();i.paging.enabled&&"page"===i.selection.selectAllMode&&(r=r.slice(i.paging.pageIndex*i.paging.pageSize,(i.paging.pageIndex+1)*i.paging.pageSize)),t.__parentCells||(t.__parentCells=[]);for(let n=0;n<i._cellsMerge.length;n++){const s=i._cellsMerge[n];let o=[],d=[];if(o.push(s.row),s.rowspan>1){const e=r.indexOf(s.row);if(e>=0)for(let t=e;t<e+s.rowSpan;t++)r[t]&&-1===o.indexOf(r[t])&&o.push(r[t])}if(d.push(s.column.dataField),s.colspan>1){const e=i.columns.indexOf(i.columnByDataField[s.column.dataField]);for(let t=e;t<e+s.colSpan;t++)i.columns[t]&&-1===d.indexOf(i.columns[t].dataField)&&d.push(i.columns[t].dataField)}if(o.indexOf(l)>=0&&d.indexOf(a)>=0){if(e){const e={cell:s.row.getCell(s.column.dataField),rows:o,columns:d,row:s.row,column:s.column,endRow:o[o.length-1],endColumn:i.columnByDataField[d[d.length-1]]};return t.__parentCells["row"+l.id+"_column_"+a]=e,e}const r=s.row.getCell(s.column.dataField);return t.__parentCells["row"+l.id+"_column_"+a]=r,r}}return t.__parentCells["row"+l.id+"_column_"+a]=null,null}}),Smart("smart-grid-cell",class extends Smart.BaseElement{static get properties(){return{}}get hasStyleObserver(){return!1}get enableShadowDOM(){return!1}addThemeClass(){}addDefaultClass(){}get isUtilityElement(){return!0}_refresh(){const e=this;e.innerHTML="",e._initialize(e.cell)}_createToggleButton(e,t){const l=this,a=document.createElement("div"),i=document.createElement("button"),r=document.createElement("div"),n=document.createElement("div"),s=document.createElement("div"),o=document.createElement("span"),d=t.grid;t.row.expanded?i.setAttribute("toggled",""):i.removeAttribute("toggled",""),i.tabIndex=-1,l.toggleButton=i,l.checkbox=s,e.appendChild(a),e.appendChild(n),n.setAttribute("content",""),a.setAttribute("indent",""),r.setAttribute("label",""),i.setAttribute("toggle-button",""),s.setAttribute("checkbox",""),s.setAttribute("role","checkbox"),l.setAttribute("has-toggle-button",""),n.appendChild(i),n.appendChild(s),o.classList.add("smart-input"),s.appendChild(o),d.checkBoxes.visible?o.classList.remove("smart-hidden"):o.classList.add("smart-hidden"),n.appendChild(r),l.content=r}_initialize(e){const t=this,l=document.createElement("div"),a=e.column,i=e.grid;t._properties=[],t.cell=e,t.appendChild(l);let r=!1;if(a&&a._treeColumn&&i.dataSource.boundHierarchy&&(r=!0,e.row.filterRow&&(r=!1),!i.grouping.enabled&&i.dataSource.groupBy&&i.dataSource.groupBy.length>0&&(r=!1),i.grouping.enabled&&i.dataSource.groupBy&&0===i.dataSource.groupBy.length&&(r=!1)),r)return t._createToggleButton(l,e),void(t.isRendered=!0);{const e=document.createElement("div");l.appendChild(e)}t.content=l,t.isRendered=!0}_renderCommands(){const e=this,t=e.cell.grid;if(t.__cellsCommandTemplate)return e.firstChild.innerHTML=t.__cellsCommandTemplate,void t._updateCommandColumnCommandsVisibility(e.firstChild,e.cell.row);const l=t._getCommandColumnCommandsTemplate();e.firstChild.innerHTML=l,t._updateCommandColumnCommandsVisibility(e.firstChild,e.cell.row),t.__cellsCommandTemplate=l}_renderGroupCell(){const e=this,t=e.cell.grid,l=e.cell.column,a=e.cell.row;[...e.attributes].forEach((t=>e.removeAttribute(t.name))),e.setAttribute("group","");const i=l===t._firstRenderedColumn;e.style.width!==l.computedWidth+"px"&&(e.style.width=l.computedWidth+"px"),i||(t.rightToLeft?e.style.right!==l.left+"px"&&(e.style.right=l.left+"px"):e.style.left!==l.left+"px"&&(e.style.left=l.left+"px")),e.classList.contains("smart-hidden")&&e.classList.remove("smart-hidden"),l===t._firstRenderedColumn||a.summaryRow||e.classList.add("smart-hidden"),l.autoGenerated&&(e.style.width="0px");let r=a.label;const n=function(e,t,l){if(!t)return[];for(let a=0;a<t.length;a++){const i=t[a];i.$&&!1===i.$.filtered||(void 0!==i[e]&&l.push(i),i.summaryRow||(i.children||i.data&&i.data.children)&&n(e,i.children,l))}return l};if(void 0!==a.label){let s="",o=[];if(t.grouping.summaryRow.visible){let r=[];const d={},c=i?l.summary.length>0?l.summary:["count"]:l.summary;c.length&&(r=n(l.dataField,a.summaryRow?a.parent.data.children:a.data.children,[])),d[l.dataField]=c;const m=c.length>0?t.dataSource.summarize([d],r):null;if(m)for(let r=0;r<c.length;r++){const n=c[r];r>0&&(s+=", ");let u=m[l.dataField][n];const p=l.cellsFormat;if(p&&(u=e.cell.getFormattedValue(u,p)),i){const i=t.columnByDataField[a.groupDataField];if(i){d[i.dataField]=c,m[i.dataField]=m[l.dataField],u=m[i.dataField][n];const t=i.cellsFormat;t&&(u=e.cell.getFormattedValue(u,t))}}s+=t.localize(n,{value:u}),o.push(m[l.dataField][n])}}if(t.dataSource.virtualDataSourceOnExpand&&(s=""),i){const l=t.columnByDataField[a.groupDataField],i=l?l.label:"";if("advanced"===t.grouping.renderMode){if(a.summaryRow)r="<div header group-advanced><span group></span><span value></span>",s&&(r+="<div summary>",r+=s,r+="</div>");else{let e=a.label?a.label:t.localize("blankSummary");a.label||"taskStatus"!==a.groupDataField||(e="");let n="";if(l&&l.editor&&l.editor.dataSource){const t=l.editor.dataSource.find((t=>t.value===e||t.label===e));t&&t.color?(n=`--smart-primary: ${t.color}`,t.label&&(e=t.label)):t&&t.label&&(e=t.label)}if(a.label||"taskStatus"!==a.groupDataField||(e=t.localize("uncategorized")),"object"==typeof e&&l.cellsFormat){const t=a.getCell(l.dataField);e=t.getFormattedValue(e,l.cellsFormat)}else if("object"==typeof e&&e&&e instanceof Date){const t=a.getCell(l.dataField);e=t.getFormattedValue(e,"d")}const o=t.editing.addNewRow.visible?'<span add-row class="smart-grid-icon smart-icon-plus-circled show"></span>':"";if(r=`<div style="${n}" header group-advanced><span group>${o}${i}: </span><span value>${e}</span>`,e&&e.indexOf(",")>=0){let t="";r=`<div style="display: flex;" header group-advanced><span group>${o}${i}: </span>`;let a=e.split(",");for(let e=0;e<a.length;e++){let i=a[e].trim();if(l&&l.editor&&l.editor.dataSource){const e=l.editor.dataSource.find((e=>e.value===i||e.label===i));e&&e.color?(n=`--smart-primary: ${e.color}`,e.label&&(i=e.label)):e&&e.label&&(i=e.label),t+=`<span style="${n}" value>${i}</span>`}}r+=t}s&&t.grouping.summaryRow.inline&&(r+="<span summary>",r+=""+s,r+="</span>")}r+="</div>",e.classList.add("smart-grid-column-border-collapse")}else if("compact"===t.grouping.renderMode){if(a.summaryRow)r="<div header><span group></span><span value></span>",s&&(r+="<div summary>",r+=s,r+="</div>");else{let e=a.label;if(l.displayField!==l.dataField&&a.data.data&&(e=a.data.data[l.displayField]),"object"==typeof e&&l.cellsFormat){e=a.getCell(l.dataField).getFormattedValue(e,l.cellsFormat)}r="<div header><span group>"+i+": </span><span value>"+e+"</span>",s&&t.grouping.summaryRow.inline&&(r+="<span summary>",r+=" ("+o+")",r+="</span>")}r+="</div>",e.classList.add("smart-grid-column-border-collapse")}else if("basic"===t.grouping.renderMode){if(r=a.label,l.displayField!==l.dataField&&a.data.data&&(r=a.data.data[l.displayField]),"object"==typeof r&&l.cellsFormat){r=a.getCell(l.dataField).getFormattedValue(r,l.cellsFormat)}a.summaryRow?s&&(r+="<div summary>",r+=s,r+="</div>"):s&&t.grouping.summaryRow.inline&&(r+="<span summary>",r+=" ("+o+")",r+="</span>"),e.classList.add("smart-grid-column-border-collapse")}else if("multipleColumns"===t.grouping.renderMode){if(r=a.label,"object"==typeof r&&l.cellsFormat){r=a.getCell(l.dataField).getFormattedValue(r,l.cellsFormat)}a.summaryRow?s&&(r+="<div summary>",r+=s,r+="</div>"):s&&t.grouping.summaryRow.inline&&(r+="<span summary>",r+=" ("+o+")",r+="</span>"),e.classList.add("smart-grid-column-border-collapse")}e.setAttribute("has-toggle-button","")}else e.removeAttribute("has-toggle-button",""),r=s}let s=e.firstChild;if(t.dataSource.boundHierarchy&&i){s.children.length<=1&&(e.innerHTML="<div></div>",s=e.firstChild,e._createToggleButton(s,e.cell),s=e.firstChild);const n=s.children[0],o=s.children[1].children[0],d=s.children[1].children[1].firstChild,c=s.children[1].children[2];n.setAttribute("indent",""),a.checked?d.setAttribute("checked",""):!1===a.checked?d.removeAttribute("checked"):null===a.checked&&d.setAttribute("checked","indeterminate"),a.leaf?o.classList.add("smart-visibility-hidden"):(o.classList.remove("smart-visibility-hidden"),a.expanded?o.setAttribute("toggled",""):o.removeAttribute("toggled",""));let m="";if(!l._treeColumn||a.summaryRow||a.filterRow?e.toggleButton.classList.add("smart-hidden"):e.toggleButton.classList.remove("smart-hidden"),l._treeColumn)if(t.grouping.enabled){let e=a.level-1;if(1+e===0)m+="",n.classList.add("smart-hidden");else{if("multipleColumns"===t.grouping.renderMode){let l=0;for(let a=0;a<t.columns.length;a++)a<1+e&&(l+=t.columns[a].computedWidth);m+='<div style="width: '+l+'px;"></div>'}else m+='<div style="width: '+(1+e)*t.grouping.groupIndent+'px;"></div>';n.classList.remove("smart-hidden")}}else for(let e=0;e<a.level;e++)m+="<div class='smart-indent'></div>";if(void 0===a.label||a.summaryRow||a.filterRow?o.classList.add("smart-hidden"):(o.classList.remove("smart-hidden"),o.style.marginLeft=""),n.innerHTML=m,c.innerHTML=r,i&&t.grouping.formatFunction){const i={row:a,column:l,groupDataField:a.groupDataField,cell:e.cell,value:r,template:null};t.grouping.formatFunction(i),i.value!==r?c.innerHTML=i.value:i.template&&(c.innerHTML=i.template)}t.appearance.showTooltips?c.setAttribute("title",a.label?a.label:t._unescapeString(r)):c.hasAttribute("title")&&c.removeAttribute("title")}else void 0!==a.label&&t.grouping.enabled&&!i&&(s.innerHTML=r);let o="smart-label";e.style.zIndex="";const d=t.editing.addNewColumn.visible?t._addNewColumn.width-1:0;if(i){const l=t.columnByDataField[a.groupDataField];l.cellsAlign&&(o+=" align-"+l.cellsAlign),l.cellsVerticalAlign&&(o+=" align-"+l.cellsVerticalAlign),e.setAttribute("header",""),a.summaryRow||(e.style.width="calc(100% - "+d+"px)"),void 0!==a.label&&(e.style.zIndex=11)}else l===t._firstRenderedColumn&&(e.style.zIndex=4),e.setAttribute("header",""),a.summaryRow||(e.style.width="calc(100% - "+d+"px)");if(a.summaryRow&&(e.setAttribute("header",""),e.classList.add("smart-grid-column-border-collapse"),l.cellsAlign&&(o+=" align-"+l.cellsAlign),l.cellsVerticalAlign&&(o+=" align-"+l.cellsVerticalAlign)),s.className!==o&&(s.className=o),l.formatFunction){const t={row:a,column:l,cell:e.cell,value:null,template:null,group:{value:r,template:null}};if(l.formatFunction(t),t.group.value!==r)if(l._treeColumn){s.children[1].children[2].innerHTML=t.group.value}else s.innerHTML=t.group.value;null!==t.group.template&&(s.innerHTML=t.group.template)}}_renderFilterCell(e){const t=this,l=t.cell.grid,a=t.cell.column;let i;const r=(e,t)=>{l._handleFilterMenuClick(e,t)};l._filterInfo||(l._filterInfo={},l._filterInfo.stringConditions=[{icon:"smart-icon-contains",command:r,value:"CONTAINS",label:l.localize("CONTAINS")},{icon:"smart-icon-does-not-contain",command:r,value:"DOES_NOT_CONTAIN",label:l.localize("DOES_NOT_CONTAIN")},{icon:"smart-icon-starts-with",command:r,value:"STARTS_WITH",label:l.localize("STARTS_WITH")},{icon:"smart-icon-ends-with",command:r,value:"ENDS_WITH",label:l.localize("ENDS_WITH")},{icon:"smart-icon-equals",command:r,value:"EQUAL",label:l.localize("EQUAL")},{icon:"smart-icon-delete",command:r,value:"CLEAR_FILTER",label:l.localize("CLEAR_FILTER")}],l._filterInfo.numberAndDateConditions=[{icon:"smart-icon-equals",command:r,value:"EQUAL",label:l.localize("EQUAL")},{icon:"smart-icon-not-equal",command:r,value:"NOT_EQUAL",label:l.localize("NOT_EQUAL")},{icon:"smart-icon-less-than",command:r,value:"LESS_THAN",label:l.localize("LESS_THAN")},{icon:"smart-icon-less-than-equal",command:r,value:"LESS_THAN_OR_EQUAL",label:l.localize("LESS_THAN_OR_EQUAL")},{icon:"smart-icon-greater-than",command:r,value:"GREATER_THAN",label:l.localize("GREATER_THAN")},{icon:"smart-icon-greater-than-equal",command:r,value:"GREATER_THAN_OR_EQUAL",label:l.localize("GREATER_THAN_OR_EQUAL")},{icon:"smart-icon-between",command:r,value:"RANGE",label:l.localize("RANGE")},{icon:"smart-icon-delete",command:r,value:"CLEAR_FILTER",label:l.localize("CLEAR_FILTER")}]),i="string"===a.dataType?l._filterInfo.stringConditions:l._filterInfo.numberAndDateConditions;let n="smart-icon-search";if(a._filterInfo||(a._filterInfo={condition:""}),a.filterEditor&&a.filterEditor.condition&&(a._filterInfo.condition=a.filterEditor.condition),a.filterEditor&&a.filterEditor.value&&(a._filterInfo.value=a.filterEditor.value),a._filterInfo.dataSource=i,null===a._filterInfo.condition||void 0===a._filterInfo.condition)a._filterInfo.condition="",n="smart-icon-search";else switch(a._filterInfo.condition.toLowerCase()){case"equal":n="smart-icon-equals";break;case"starts_with":n="smart-icon-starts-with";break;case"ends_with":n="smart-icon-ends-with";break;case"not_equal":n="smart-icon-not-equal";break;case"less_than":n="smart-icon-less-than";break;case"less_than_or_equal":n="smart-icon-less-than-or-equal";break;case"greater_than":n="smart-icon-greater-than";break;case"greater_than_or_equal":n="smart-icon-greater-than-or-equal";break;case"contains":n="smart-icon-contains";break;case"does_not_contain":n="smart-icon-does-not-contain";break;case"range":n="smart-icon-between";break;default:n="smart-icon-search"}let s=`<div class="smart-filter-input-type"><i class="smart-grid-icon ${n} show"></i></div> `;if("string"===a.dataType)s+=`<input class="smart-filter-input-value" data-type="${a.dataType}" /> `,e.innerHTML=s;else if("date"===a.dataType){const i=new Smart.Utilities.DateTime;s+=`<input placeholder = "${i.expandFormat(i.calendar,a.cellsFormat||"d")}" class="smart-filter-input-value" data-type="${a.dataType}"/><div class="smart-filter-input-type"><i class="smart-grid-icon smart-icon-calendar show"></i></div>`,e.innerHTML=s,e.lastElementChild.onpointerdown=function(){l._handleFilterCalendarCellClick(t.cell)}}else if("number"===a.dataType)s+='<div class="smart-grid-cell-editor smart-filter-input-value smart-grid-number-input-cell-editor"><input class="smart-input" type="number"><div tabindex="-1" class="nav"><div tabindex="-1" class="up"></div><div tabindex="-1" class="down"></div></div></div>',e.innerHTML=s,l._handleFilterNumberCellEditor(this.cell,e);else if("boolean"===a.dataType||"bool"===a.dataType){const i=document.createElement("div");i.classList.add("smart-input"),i.classList.add("smart-grid-check-box-cell-editor"),i.classList.add("smart-filter-input-value"),e.tabIndex=0,e.style.outline="none",t.setAttribute("template","checkBox"),i.setAttribute("checked","indeterminate"),a._filterInfo&&a._filterInfo.value?i.setAttribute("checked",""):a._filterInfo&&!1===a._filterInfo.value&&i.removeAttribute("checked"),s=i.outerHTML,e.innerHTML=s,e.classList.add("align-center"),e.classList.add("smart-label"),e.onfocus=()=>{e.setAttribute("focus","")},e.onblur=()=>{e.removeAttribute("focus","")},e.onclick=e=>{e.target.classList.contains("smart-input")&&l._handleFilterCellCheckBoxClick(this.cell)}}const o=e.querySelector("input");if(o&&(e.firstElementChild.onpointerdown=function(){l._handleFilterCellIconClick(this.cell)}.bind(this),o.onpaste=function(e){setTimeout((()=>{l._handleFilterCellKeyUp(this.cell,e)}))}.bind(this),o.onfocus=function(){l._handleFilterCellFocus(this.cell)}.bind(this),o.onblur=function(){l._handleFilterCellBlur(this.cell)}.bind(this),o.onkeyup=function(e){l._handleFilterCellKeyUp(this.cell,e)}.bind(this),o.onkeydown=function(e){l._handleFilterCellKeyDown(this.cell,e)}.bind(this)),e.classList.add("smart-filter-input-container"),a._filterInfo.input=o,a._filterInfo.cell=t.cell,a._filterInfo.editor=e,a._filterInfo.value&&o&&(o.value=a._filterInfo.value,"date"===a.dataType&&(o.value=t.cell.getFormattedValue(a._filterInfo.value,a.cellsFormat))),a.allowFilter||(o.disabled=!0),a.filterEditor)if(a.filterEditor.template){const t=a.filterEditor.template,l=document.createElement("div");a.filterTemplate instanceof HTMLTemplateElement?l.appendChild(t.content.cloneNode(!0)):t instanceof HTMLElement?l.appendChild(t):l.innerHTML=t,e.innerHTML="",e.appendChild(l),l.style.height="100%",l.style.width="100%";const i=e.querySelector("input");i&&(i.onfocus=()=>{e.setAttribute("focus","")},i.onblur=()=>{e.removeAttribute("focus","")}),a.filterEditor.onInit&&a.filterEditor.onInit(a,l)}else void 0!==a.filterEditor.min&&(o.min=a.filterEditor.min),void 0!==a.filterEditor.max&&(o.max=a.filterEditor.max),void 0!==a.filterEditor.minLength&&(o.minLength=a.filterEditor.minLength),void 0!==a.filterEditor.maxLength&&(o.maxLength=a.filterEditor.maxLength),void 0!==a.filterEditor.placeholder&&(o.placeholder=a.filterEditor.placeholder),void 0!==a.filterEditor.value&&(o.value=a.filterEditor.value),void 0!==a.filterEditor.step&&(o.step=a.filterEditor.step),void 0!==a.filterEditor.disabled&&(o.disabled=a.filterEditor.disabled),void 0!==a.filterEditor.condition&&(a._filterInfo.condition=a.filterEditor.condition),a.filterEditor.onInit&&a.filterEditor.onInit(a,e)}_setTemplate(t,l,a){const i=this,r=i.cell.grid,n=i.cell.column;let s=null;switch((!r.editing.enabled||!n.allowEdit||i.cell.readonly||"none"===r.editing.action||r.editing.enabled&&r.editing.commandColumn.visible&&r.editing.editRow!==i.cell.row)&&i.setAttribute("readonly",""),l){case"checkBox":case"radioButton":case"switchButton":if(a.firstElementChild&&a.firstElementChild.classList.contains("smart-input")){if(s=a.firstElementChild,t?s.setAttribute("checked",""):null===t?s.setAttribute("checked","indeterminate"):s.removeAttribute("checked"),i.setAttribute("template",i.cell.template),s.removeAttribute("icon"),s.removeAttribute("color"),s.style.setProperty("--smart-check-template-color","var(--smart-primary)"),i.cell.column.templateSettings&&i.cell.column.templateSettings.icon){if("ok-squared"!==i.cell.column.templateSettings.icon)s.setAttribute("icon",i.cell.column.templateSettings.icon);else{const e=new Smart.Color(i.cell.column.templateSettings.color).getInvertedColor();s.style.setProperty("--smart-check-template-forecolor",e)}s.style.setProperty("--smart-check-template-color",i.cell.column.templateSettings.color),s.setAttribute("color","")}return}if(s=document.createElement("span"),s.className="smart-input",t?s.setAttribute("checked",""):null===t?s.setAttribute("checked","indeterminate"):s.removeAttribute("checked"),i.setAttribute("template",i.cell.template),s.removeAttribute("icon"),s.removeAttribute("color"),s.style.setProperty("--smart-check-template-color","var(--smart-primary)"),i.cell.column.templateSettings&&i.cell.column.templateSettings.icon){if("ok-squared"!==i.cell.column.templateSettings.icon)s.setAttribute("icon",i.cell.column.templateSettings.icon);else{const e=new Smart.Color(i.cell.column.templateSettings.color).getInvertedColor();s.style.setProperty("--smart-check-template-forecolor",e)}s.setAttribute("color",""),s.style.setProperty("--smart-check-template-color",i.cell.column.templateSettings.color)}a.innerHTML="",a.appendChild(s),i.cell._setStyle(a);break;case"checklist":if(t&&t.indexOf("[")>=0&&(t=JSON.parse(t)),a.firstElementChild&&a.firstElementChild.hasAttribute("value")){const e=a.firstElementChild.getAttribute("value");if(t&&e===t.length)return i.cell._setStyle(a),void i.setAttribute("template",i.cell.template)}if(t&&Array.isArray(t)&&t.length>0){const e=t.filter((e=>e.completed)).length,l=["#D50000","#F4511E","#F6BF26","#33B679"],a=e+"/"+t.length;let i=l[0];e===t.length?i=l[3]:e>0&&e<t.length&&(i=l[2]),t=`<div style="display: grid; grid-template-columns: 25px auto"><div style="margin-left: 4px; align-self: center; border-radius: 50%; display: flex; align-content: center; background: ${i}; width:16px; height: 16px;"><span title="${a}" style="align-content: center; font-size: 13px; color: white;" class="smart-grid-icon show smart-icon-check"></span></div>${a}</span></div>`}else t="";s=document.createElement("span"),s.innerHTML=t,i.setAttribute("template",i.cell.template),s.setAttribute("value",t.length);break;case"createdBy":case"updatedBy":{const e=i.cell.row;let t=null,o=null;if(t="createdBy"===l?e.createdBy:e.updatedBy,a.firstElementChild&&a.firstElementChild.hasAttribute("user-id")){if(t===parseInt(a.firstElementChild.getAttribute("user-id")))return i.cell._setStyle(a),void i.setAttribute("template",i.cell.template);if(null!=t&&-1!==t){o=r.users.find((e=>e.id===t));const e=o;if(e){const l=a.firstElementChild.firstElementChild&&a.firstElementChild.firstElementChild.firstElementChild?a.firstElementChild.firstElementChild.firstElementChild.firstElementChild:null;if(l){a.firstElementChild.setAttribute("user-id",t);const i="string"==typeof e?e:e.name,r="string"==typeof e?null:e.color;if(("string"==typeof e?null:e.image)&&(l.firstElementChild.style.backgroundImage=`url('${e.image}')`),r){const e=new Smart.Color(r).getInvertedColor();l.setAttribute("data-item",i),l.setAttribute("title",i),l.setAttribute("backgroundColor",r),l.setAttribute("color",e),l.lastElementChild.textContent=i}else l.setAttribute("data-item",i),l.setAttribute("title",i),l.setAttribute("backgroundColor",""),l.setAttribute("color","");return}}}}const d=document.createElement("div");d.classList.add("smart-multi-combo-input"),d.setAttribute("data-field",n.dataField),d.setAttribute("row-id",i.cell.row.id),d.style.width="100%",d.style.paddingRight="6px";let c='<div class="smart-flex smart-flex-auto smart-tokens-layout">';if(null!=t&&-1!==t){o=r.users.find((e=>e.id===t));const e=o;if(e){const t="string"==typeof e?e:e.name,l="string"==typeof e?null:e.color,a="string"==typeof e?null:e.image,i=document.createElement("span");if(a&&(i.style.backgroundImage=`url('${e.image}')`,i.className="smart-drop-down-list-selection-image"),l){c+='<span title="'+t+'" data-item="'+t+'" style="background: '+l+"; color: "+new Smart.Color(l).getInvertedColor()+'; overflow: visible;" class="smart-truncate smart-token">'+i.outerHTML+"<span class='smart-drop-down-list-selection-label' role=\"presentation\">"+t+"</span></span>"}else c+='<span title="'+t+'" data-item="'+t+'" class="smart-truncate smart-token">'+i.outerHTML+"<span class='smart-drop-down-list-selection-label' role=\"presentation\">"+t+"</span></span>"}else c=""}d.innerHTML=c+"</div>";const m=document.createElement("div");m.classList.add("smart-multi-combo-input-container","tokens","smart-flex","smart-flex-auto"),d.classList.add("smart-flex-auto"),m.appendChild(d),s=m,s.setAttribute("user-id",t),i.setAttribute("template",i.cell.template);break}case"collaborator":case"tags":{let e=[];"number"==typeof t&&(t=""+t);let o=!1===r.editing.enabled?"smart-visibility-hidden":"";!0!==r.editing.enabled||i.cell.column.allowEdit||(o="smart-visibility-hidden");let d=n.editor.dataSource&&n.editor.dataSource.length;if(n.editor.collaborator&&(d=r.users&&r.users.length),d||(o="smart-visibility-hidden"),""===t||null===t||"uncategorized"===t){let e=`\n <div class="smart-multi-combo-input-container tokens smart-flex smart-flex-auto" data-field="${n.dataField}" row-id="${i.cell.row.id}"> \n <div class="smart-multi-combo-input" data-field="${n.dataField}" row-id="${i.cell.row.id}" class="tokens smart-flex smart-flex-auto">\n <div class=" smart-flex-auto smart-flex"></div>\n </div>\n <span class="smart-arrow-down arrowbtn ${o}"></span>\n </div>\n `;a.innerHTML!==e&&(a.firstElementChild&&a.firstElementChild.firstElementChild&&a.firstElementChild.firstElementChild.firstElementChild&&""===a.firstElementChild.firstElementChild.firstElementChild.textContent?(a.firstElementChild.setAttribute("row-id",i.cell.row.id),a.firstElementChild.firstElementChild.setAttribute("row-id",i.cell.row.id)):a.innerHTML=e);const t=a.querySelector(".smart-arrow-down");return t&&(t.onpointerdown=e=>{if(r.editing.enabled&&i.cell.column.allowEdit){const t=e.target.previousElementSibling,l=t.getAttribute("data-field"),a=t.closest("smart-grid-row").getAttribute("data-id");r.beginEdit(a,l)}e.stopPropagation(),e.preventDefault()}),i.cell._setStyle(a),void i.setAttribute("template",i.cell.template)}if(null!==t&&(e=Array.isArray(t)?e.map((e=>e.trim())):t.indexOf("{")>=0||"[]"===t?JSON.parse(t):t.split(",").map((e=>e.trim()))),a.firstElementChild&&a.firstElementChild.hasAttribute("value")&&n.editor._items){if(a.firstElementChild.getAttribute("value")===t){if(i.cell._setStyle(a),i.setAttribute("template",i.cell.template),a.firstElementChild&&a.firstElementChild.firstElementChild&&a.firstElementChild.firstElementChild.firstElementChild)if(a.firstElementChild.firstElementChild.firstElementChild.classList.remove("smart-flex-wrap"),i.cell.row.height>45){a.firstElementChild.firstElementChild.firstElementChild.classList.add("smart-flex-wrap");const e=a.firstElementChild.firstElementChild.firstElementChild;if(e.children&&e.children.length>1)for(let t=0;t<e.children.length;t++)e.children[t].style.maxWidth&&(e.children[t].style.maxWidth="")}else if(r.layout.rowHeight<=45&&i.cell.row.height<=45){const e=a.firstElementChild.firstElementChild.firstElementChild;if(e.children&&e.children.length>1){const t=parseInt(n.computedWidth/e.children.length)-5;let l=0;for(let t=0;t<e.children.length;t++)l+=e.children[t].textContent.length,e.children[t].style.maxWidth="";if(14*l*.52+20*e.children.length>n.computedWidth)for(let l=0;l<e.children.length;l++)e.children[l].style.maxWidth=t+"px"}}return}}const c=document.createElement("div");c.classList.add("smart-multi-combo-input"),c.setAttribute("data-field",n.dataField),c.setAttribute("row-id",i.cell.row.id);let m='<div class="smart-tokens-layout smart-flex smart-flex-auto">';if(e.length>2&&i.cell.row.height>45){m='<div style="max-width: '+(n.computedWidth-10+"px")+'" class="smart-flex smart-flex-wrap">'}let u=0;if(t)for(let t=0;t<e.length;t++){const a=e[t];let i=null;if("collaborator"===l||n.editor&&n.editor.collaborator)i=r.users.find((e=>{if("string"==typeof a||"number"==typeof a){if(e.value===a||parseInt(e.value)===parseInt(a))return e;if(e.id===a||parseInt(e.id)===parseInt(a))return e}else if("object"==typeof a&&e.value===a.value)return e})),i&&(i.label=i.name);else if(n.editor.dataSource)if("string"==typeof a&&n.editor._items&&n.editor._items[a])i=n.editor._items[a];else for(let e=0;e<n.editor.dataSource.length;e++){const t=n.editor.dataSource[e];if(void 0!==t.value&&void 0!==a&&void 0!==a.value&&t.value===a.value){i=t,n.editor._items||(n.editor._items=[]),n.editor._items[a]=t;break}if(void 0===t.value&&t===a||void 0!==t.value&&""+t.value===a){i=t,n.editor._items||(n.editor._items=[]),n.editor._items[a]=t;break}}else i=a;if(!i)continue;const s="string"==typeof i?i:i.label,o="string"==typeof i?null:i.color,d="string"==typeof i?null:i.image;if(""===s)continue;const c=document.createElement("span");d&&(c.style.backgroundImage=`url('${i.image}')`,c.className="smart-drop-down-list-selection-image");const p="smart-truncate";if(o&&n.editor.colorItems){m+='<span title="'+s+'" data-item="'+s+'" style="background: '+o+"; color: "+new Smart.Color(o).getInvertedColor()+'; overflow: visible;" class="'+p+' smart-token">'+c.outerHTML+"<span class='smart-drop-down-list-selection-label' role=\"presentation\">"+s+"</span>"}else m+='<span title="'+s+'" data-item="'+s+'" class="'+p+' smart-token">'+c.outerHTML+"<span class='smart-drop-down-list-selection-label' role=\"presentation\">"+s+"</span>";if(u+=s.length,n.editor.dataSource){if(n.editor.singleSelect){m+="</span>";break}m+='<span class=\'smart-hidden smart-drop-down-list-unselect-button\' role="button" aria-label="Unselect"></span></span>'}else m+="</span>"}c.innerHTML=m+"</div>";const p=14*u*.52,g=c.firstElementChild;if(r.layout.rowHeight<=45&&i.cell.row.height<=45&&c&&g.children.length>1&&p+20*g.children.length>n.computedWidth){const e=parseInt(n.computedWidth/g.children.length)-5;for(let t=0;t<g.children.length;t++)g.children[t].style.maxWidth=e+"px"}if(c.style.width="100%",i.onmouseenter=()=>{!0===i.cell.column.allowEdit&&!0===r.editing.enabled&&(c.style.width="calc(100% - 25px)")},i.onmouseleave=()=>{c.style.width="100%"},c.style.paddingRight="6px",c.onpointerdown=t=>{if(!r._mobile)if(t.target&&"#text"!==t.target.nodeName&&t.target.classList.contains("smart-drop-down-list-unselect-button")){let l=t.target.parentNode.getAttribute("data-item");if(n.editor.dataSource&&"string"==typeof l&&n.editor.dataSource)for(let e=0;e<n.editor.dataSource.length;e++)n.editor.dataSource[e].label===l&&(l=n.editor.dataSource[e],l.value&&(l=l.value));if(e[0]&&e[0].label){const a=e.map((e=>e.value)).indexOf(l);if(a>=0){e.splice(a,1);const l=i.cell.value,s=e.join(", ");r.setCellValue(i.cell.row.id,n.dataField,JSON.stringify(e)),r.onCellUpdate&&r.onCellUpdate([i.cell],[l],[s],(function(){}),i),t.preventDefault(),t.stopPropagation()}}else if(e.indexOf(l)>=0){e.splice(e.indexOf(l),1);const a=i.cell.value,s=e.join(", ");r.setCellValue(i.cell.row.id,n.dataField,s),r.onCellUpdate&&r.onCellUpdate([i.cell],[a],[s],(function(){}),i),t.preventDefault(),t.stopPropagation()}}else if(t.target.classList.contains("smart-drop-down-list-selection-label")){if(r.editing.enabled){const e=t.target.parentElement.parentElement,l=e.getAttribute("data-field"),a=e.getAttribute("row-id");r.beginEdit(a,l)}t.stopPropagation(),t.preventDefault()}},!n.cellsWrap&&n.allowEdit&&r.editing.enabled&&"card"!==r.view){const t=document.createElement("span");t.classList.add("smart-arrow-down","arrowbtn");let l=n.editor.dataSource&&n.editor.dataSource.length;n.editor.collaborator&&(l=r.users&&r.users.length),l||t.classList.add("smart-visibility-hidden");const a=document.createElement("div");a.classList.add("smart-multi-combo-input-container","tokens","smart-flex","smart-flex-auto"),c.classList.add("smart-flex-auto"),c.classList.remove("smart-flex-wrap"),e.length>2&&r.layout.rowHeight>45&&(c.classList.add("smart-flex-wrap"),c.style.maxWidth=n.computedWidth-10+"px"),r.rightToLeft&&(c.style.direction="rtl"),a.appendChild(c),"input"!==n.editor.template&&a.appendChild(t),s=a,t.onpointerdown=e=>{if(!r._mobile){if(r.editing.enabled){const t=e.target.previousElementSibling,l=t.getAttribute("data-field"),a=t.closest("smart-grid-row").getAttribute("data-id");r.beginEdit(a,l)}e.stopPropagation(),e.preventDefault()}}}else if(n.cellsWrap||n.allowEdit){const t=document.createElement("div");t.classList.add("smart-multi-combo-input-container","tokens","smart-flex","smart-flex-auto"),c.classList.add("smart-flex-auto"),c.classList.remove("smart-flex-wrap"),e.length>2&&r.layout.rowHeight>45&&(c.classList.add("smart-flex-wrap"),c.style.maxWidth=n.computedWidth-10+"px"),r.rightToLeft&&(c.style.direction="rtl"),t.appendChild(c),s=t}else c.classList.add("smart-flex-auto","smart-flex","tokens"),s=c;i.setAttribute("template",i.cell.template),s.setAttribute("value",t);break}case"dropdownGrid":case"dropDownList":case"dropdownlist":case"list":{const e=document.createElement("div");if(a.firstElementChild&&a.firstElementChild.hasAttribute("value")){if(a.firstElementChild.getAttribute("value")===t)return i.cell._setStyle(a),void i.setAttribute("template",i.cell.template)}if("dropdownGrid"===i.cell.template){const l=i.cell.column.templateSettings.dataFields,a=i.cell.editor.dataSource[t];if(e.classList.add("smart-flex","center"),e.style.alignItems="center",e.onmouseenter=()=>{e.querySelectorAll("i").forEach((e=>e.classList.add("show")))},e.onmouseleave=()=>{e.querySelectorAll("i").forEach((e=>e.classList.remove("show")))},a){e.style.justifyContent="space-between";let t="";for(let e=0;e<l.length;e++){const i=a[l[e]];i&&(t+='<span style="" class="smart-truncate smart-token smart-flex middle center ">'+i+"</span>")}e.innerHTML=t}else e.style.justifyContent="",e.innerHTML='<span class="smart-truncate"></span>'}else"card"===r.view?e.textContent=t:e.innerHTML='<span class="smart-truncate">'+t+"</span>";if(n.allowEdit&&r.editing.enabled&&"card"!==r.view){const t=document.createElement("span");t.classList.add("smart-arrow-down","arrowbtn");const l=document.createElement("div");l.classList.add("smart-multi-combo-input-container","tokens","smart-flex","smart-flex-auto"),e.classList.add("smart-flex-auto","smart-multi-combo-input"),l.appendChild(e),l.appendChild(t),l.classList.add(i.cell.template.toLowerCase()),s=l,t.onpointerdown=e=>{if(!r._mobile){if(r.editing.enabled){const t=e.target.closest("smart-grid-cell"),l=e.target.closest("smart-grid-row"),a=t.getAttribute("data-field"),n=l.getAttribute("data-id");if(r.beginEdit(n,a),i.cell.column.editor&&i.cell.column.editor.instance){const e=i.cell.column.editor,t=e.instance.element;!e.autoOpen&&t.open?t.open():!e.autoOpen&&t.firstElementChild&&t.firstElementChild.open&&setTimeout((()=>{t.firstElementChild.open()}),250)}}e.stopPropagation(),e.preventDefault()}}}else s=e;i.setAttribute("template",i.cell.template.toLowerCase()),s.setAttribute("value",t);break}case"password":a.innerHTML=t?'<span class="smart-truncate">'+t.replace(/./g,"*")+"</span>":"",i.setAttribute("template",i.cell.template);break;case"richText":if(a.innerHTML=t?'<div class="textwrap" style="height: 100%; padding-top: 5px; padding-left: 5px;">'+r._unescapeString(t)+"</div>":"",r.layout.autoWrap&&i.cell.row.height>40&&1===i.cell.colSpan&&"string"===n.dataType){null==t&&(t="");if(14*t.length*.52>n.computedWidth){const e=parseInt(i.cell.row.height/20);a.firstElementChild.style["-webkit-line-clamp"]=e}}i.setAttribute("template",i.cell.template);break;case"color":a.innerHTML=`<span style="left: calc(50% - 12px); top: calc(50% - 12px); position: absolute; border-radius: 50%; width: 24px; height: 24px; display: block; background:${t};"></span>`,i.setAttribute("template",i.cell.template);break;case"autoNumber":s=document.createElement("span"),s.innerHTML=1+i.cell.row.visibleIndex,i.setAttribute("template",i.cell.template);break;case"uuid":{if(a.firstElementChild&&a.firstElementChild.hasAttribute("value")){const e=a.firstElementChild.getAttribute("value");if(t===e)return i.cell._setStyle(a),void i.setAttribute("template",i.cell.template)}s=document.createElement("span"),s.style.paddingLeft="7px";const e=r._generateUUID(),l=i.cell.canNotify;i.cell.canNotify=!1,t||(i.cell.value=e,r.onCellUpdate&&!r.editing.editRow&&r.onCellUpdate([i.cell],[e],[e],(function(){r.onCellUpdated&&r.onCellUpdated([i.cell.row.index],[i.cell.row],[i.cell.column],[i.cell.row.data],[i.cell.value],[i.cell.value],i)}),i)),s.textContent=i.cell.value,i.cell.canNotify=l,i.setAttribute("template",i.cell.template),s.setAttribute("value",e);break}case"ai":{if(a.firstElementChild&&a.firstElementChild.hasAttribute("value")){const e=a.firstElementChild.getAttribute("value");if(t===e)return i.cell._setStyle(a),void i.setAttribute("template",i.cell.template)}const e=(e,t)=>{const l=r.ai.url,a=r.ai.key;e.stopPropagation(),e.preventDefault();const i=e.target.closest("smart-grid-cell"),n=e.target.closest("smart-grid-row"),o=i.getAttribute("data-field"),d=n.getAttribute("data-id");t?(e.target.classList.remove("smart-icon-reload"),e.target.classList.add("smart-grid-loading")):e.target.classList.add("smart-grid-loading");let c=""+r.columnByDataField[o].AIQuery;r.columnByDataField[c]&&(c=""+r.getCellValue(d,c)),c&&l&&a?async function(e){const t=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({model:r.ai.model,prompt:e,max_tokens:r.ai.tokens,temperature:r.ai.temperature})});if(!t.ok)throw new Error(`Error: ${t.statusText}`);return(await t.json()).choices[0].text.trim()}(c).then((e=>{const t=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");r.setCellValue(d,o,t),s.setAttribute("value",t)})).catch((e=>{console.error("Error:",e)})):(r.setCellValue(d,o,r.localize("noResults")),s.setAttribute("value",r.localize("noResults")))};if(t){s=document.createElement("span"),s.style.paddingLeft="7px";const l=i.cell.canNotify;i.cell.canNotify=!1,s.textContent=i.cell.value,i.cell.canNotify=l;const a=document.createElement("span");s.appendChild(a),a.classList.add("smart-grid-icon","show","smart-icon-reload","smart-visibility-hidden"),a.style.position="absolute",a.style.right=a.style.top="0px",s.onmouseenter=()=>{a.classList.remove("smart-visibility-hidden")},s.onmouseleave=()=>{a.classList.add("smart-visibility-hidden")},a.onpointerdown=t=>{e(t,!0)},i.setAttribute("template",i.cell.template),s.setAttribute("value",t)}else s=document.createElement("div"),s.classList.add("smart-flex","center","middle"),s.style.height="100%",s.innerHTML=`<button style="height: 24px; padding-inline: 24px; padding-block: 2px;" class="smart-button" type="button">${r.localize("generate")}</button\n `,s.onpointerdown=t=>{e(t)},i.setAttribute("template",i.cell.template);break}case"createdDate":case"createdTime":{const e=i.cell.getFormattedValue(i.cell.row.createdDate,"d"),t=i.cell.getFormattedValue(i.cell.row.createdDate,"t");if(a.firstElementChild&&a.firstElementChild.hasAttribute("created-date")){const l=e+" "+t;l!==a.firstElementChild.textContent&&(a.firstElementChild.textContent=l)}else a.innerHTML='<span created-date class="align-left smart-truncate">'+e+"