-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsmart.kanban.js
6 lines (4 loc) · 179 KB
/
smart.kanban.js
1
2
3
4
5
6
/* Smart UI v15.2.0 (2023-04-20)
Copyright (c) 2011-2023 jQWidgets.
License: https://htmlelements.com/license/ */ //
Smart("smart-kanban",class extends Smart.DataView{static get properties(){return{addNewButton:{value:!1,type:"boolean"},addNewButtonDisplayMode:{value:"top",allowedValues:["top","bottom","both"],type:"string"},addNewColumn:{value:!1,type:"boolean"},autoColumnHeight:{value:!1,type:"boolean"},applyColumnColorToTasks:{value:!1,type:"boolean"},addNewColumnWidth:{value:null,type:"any"},allowColumnEdit:{value:!1,type:"boolean"},allowColumnHide:{value:!0,type:"boolean"},allowColumnRemove:{value:!1,type:"boolean"},allowColumnReorder:{value:!1,type:"boolean"},allowCustomTags:{value:!0,type:"boolean"},allowDrag:{value:!0,type:"boolean",defaultReflectToAttribute:!0},allowDrop:{value:!0,type:"boolean",defaultReflectToAttribute:!0},autoLoadState:{value:!1,type:"boolean"},autoSaveState:{value:!1,type:"boolean"},cardHeight:{value:null,type:"number?"},currentUser:{value:null,type:"any"},columnColorEntireSurface:{value:!1,type:"boolean"},columnFooter:{value:!1,type:"boolean"},columnActions:{value:!1,type:"boolean"},columnColors:{value:!1,type:"boolean"},columnWidth:{value:null,type:"any"},columnSummary:{value:!1,type:"boolean"},columnEditMode:{value:"headerAndMenu",allowedValues:["header","menu","headerAndMenu"],type:"string"},columnHeaderTemplate:{value:null,type:"any"},disableDialog:{value:!1,type:"boolean"},dataSourceMap:{value:{checklist:"checklist",color:"color",comments:"comments",dueDate:"dueDate",id:"id",priority:"priority",progress:"progress",startDate:"startDate",status:"status",swimlane:"swimlane",tags:"tags",text:"text",description:"description",userId:"userId",history:"history",createdUserId:"createdUserId",createdDate:"createdDate",updatedUserId:"updatedUserId",updatedDate:"updatedDate"},type:"any",reflectToAttribute:!1},editable:{value:!1,type:"boolean"},dragOffset:{value:"auto",type:"any"},formatStringDate:{value:"d",type:"string"},formatStringTime:{value:"MMM d, HH:mm",type:"string"},hierarchy:{value:"columns",allowedValues:["columns","tabs"],type:"string"},messages:{value:{en:{actionsIcon:"Actions icon",actionsList:"Open actions list",unassignedTask:"Unassigned task",unassigned:"unassigned",assignedTask:"Assigned to {{userName}}",addNewStatus:"New status",addNewColumn:"Add new status",addNewTask:"Add new task",addSubtask:"Add subtask",assignedTo:"Assigned to",createdBy:"Created by",updatedBy:"Updated by",createdByDate:"Created",updatedByDate:"Updated",checklist:"Sub tasks",color:"Color",commentsIcon:"Comments icon",copy:"Copy",customize:"Customize tasks",customizeColumn:"Customize column",dueDate:"Due date",days:"days",edit:"Edit",editTask:"ID: {{taskId}} {{text}}",expand:"Expand column",collapse:"Collapse column",high:"High",low:"Low",critical:"Critical",newComment:"New comment",newSubtask:"New subtask",overdue:"Overdue",average:"Average",priority:"Priority",priorityIcon:"Priority icon",progress:"Progress",promptComment:"Are you sure you want to remove this comment?",promptTask:'Are you sure you want to remove the task "{{taskText}}"?',promptColumn:"Are you sure you want to remove this column?",remove:"Remove",removeSubtask:"Remove subtask",removeColumn:"Remove column",hideColumn:"Hide column",removeComment:"Remove comment",removeTask:"Remove task",showAllColumns:"Show all columns",send:"Send",startDate:"Start date",status:"Status",swimlane:"Swimlane",tags:"Tags",text:"Name",description:"Description",taskProgress:"Task progress: {{value}}%",taskDescription:"Task description: {{value}}",taskCompleted:"Tasks completed: {{value}}/{{count}}",tasksSummary:"{{summary}} tasks",tasksSummaryOne:"1 task",userId:"User ID",userIcon:"User icon",guestUser:"Guest",detailsTab:"Details",commentsTab:"Comments",fieldsTab:"Fields",historyTab:"History",subtasksTab:"Subtasks",historyEvent:"Event",historyAuthor:"Author",historyDetails:"Details",range:'From "{{oldValue}}" to "{{newValue}}"',nullRange:'Changed to "{{newValue}}"',invalidRange:'"{{start}}" should be less than "{{end}}"',historyDate:"Date",ok:"ok",cancel:"Cancel",delete:"Delete",taskDeadlineChanged:"Deadline changed",tagsChanged:"Tags changed",taskMoved:"Task moved",taskUpdated:"Task updated",taskCreated:"Task created",taskUserChanged:"Assignee changed",taskUserRemoved:"Assignee removed",taskDescriptionChanged:"Description changed",taskSubtasksChanged:"Subtasks changed",taskProgressChanged:"Progress changed",taskPriorityChanged:"Priority changed",taskSubtasksCompleted:"Completed {{value}}",taskStatusChanged:"Status changed",taskTagsChanged:"Tags changed",taskNameChanged:"Name changed",taskColorChanged:"Color changed",empty:"No tasks"}}},onColumnHeaderRender:{value:null,type:"any",reflectToAttribute:!1},onColumnFooterRender:{value:null,type:"any",reflectToAttribute:!1},onTaskRender:{value:null,type:"any",reflectToAttribute:!1},onSortPrepare:{value:null,type:"any",reflectToAttribute:!1},onFilterPrepare:{value:null,type:"any",reflectToAttribute:!1},priority:{value:[],type:"array",reflectToAttribute:!1},priorityList:{value:!0,type:"boolean"},readonly:{value:!1,type:"boolean"},selectionMode:{value:"zeroOrOne",allowedValues:["zeroOrOne","zeroOrManyExtended"],type:"string"},storeHistory:{value:!0,type:"boolean"},storeHistoryItems:{value:20,type:"number"},swimlanes:{value:[],type:"array",reflectToAttribute:!1},swimlanesFrom:{value:0,type:"number"},swimlanesTo:{value:null,type:"number?"},tags:{value:[],type:"array"},taskActions:{value:!1,type:"boolean"},taskActionsRendered:{value:null,type:"any"},taskComments:{value:!1,type:"boolean"},taskDue:{value:!1,type:"boolean"},taskPosition:{value:"all",allowedValues:["all","leaf"],type:"string"},taskPriority:{value:!0,type:"boolean",defaultReflectToAttribute:!0},taskProgress:{value:!1,type:"boolean"},taskTags:{value:!0,type:"boolean",defaultReflectToAttribute:!0},taskSubTasks:{allowedValues:["none","onePerRow","onlyUnfinished"],value:"none",type:"string"},taskSubTasksInput:{value:!0,type:"boolean"},taskUserIcon:{value:!0,type:"boolean",defaultReflectToAttribute:!0},taskCustomFields:{value:[],type:"array",reflectToAttribute:!1},taskCustomFieldsHide:{value:!1,type:"boolean"},taskColor:{value:!0,type:"boolean"},taskColorEntireSurface:{value:!1,type:"boolean"},textTemplate:{value:null,type:"any"},userList:{value:!1,type:"boolean"},users:{value:[],type:"array",reflectToAttribute:!1},dialogCustomizationFunction:{value:null,type:"any"},dialogRendered:{value:null,type:"any"},dialogEditors:{value:["checklist","color","dueDate","priority","progress","startDate","status","swimlane","tags","text","description","userId"],type:"any"}}}static get listeners(){return{"body.focusin":"_bodyFocusinHandler",keyup:"_keyupHandler","container.click":"_containerClickHandler","container.down":"_containerDownHandler","container.keydown":"_containerKeydownHandler","container.touchmove":"_scrollViewerTouchmoveHandler"}}template(){const e=this._tabindex;return`<div id="container" role="presentation">\n <div id="header" class="smart-data-view-header" role="toolbar">\n <div id="customizeButton" class="smart-data-view-header-button smart-data-view-customize-button smart-unselectable"${e} role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Customize tasks"><div role="presentation"></div></div>\n <div id="filterButton" class="smart-data-view-header-button smart-data-view-filter-button smart-unselectable"${e} role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Filter"><div role="presentation"></div></div>\n <div id="sortButton" class="smart-data-view-header-button smart-data-view-sort-button smart-unselectable"${e} role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Sort"><div role="presentation"></div></div>\n <div id="searchButton" class="smart-data-view-header-button smart-data-view-search-button smart-unselectable"${e} role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Search"></div>\n <div id="headerDropDown" class="smart-data-view-header-drop-down smart-visibility-hidden" role="dialog">\n <div id="customize" class="smart-hidden" role="presentation"></div>\n <div id="filter" class="smart-hidden" role="presentation"></div>\n <div id="sort" class="smart-hidden" role="presentation"></div>\n <div id="search" class="smart-data-view-search-box smart-hidden" role="presentation">\n <input type="text" id="searchInput" spellcheck="false" aria-label="Search" />\n <div id="searchLabel" class="smart-data-view-search-label smart-unselectable"></div>\n <div id="searchPrev" class="smart-data-view-search-prev"${e} role="button" aria-label="Previous"></div>\n <div id="searchNext" class="smart-data-view-search-next"${e} role="button" aria-label="Next"></div>\n <div id="searchClose" class="smart-data-view-search-close"${e} role="button" aria-label="Close search box"></div>\n </div>\n </div>\n </div>\n <smart-scroll-viewer auto-refresh vertical-scroll-bar-visibility="hidden" class="smart-kanban-scroll-viewer" id="scrollViewer">\n <div id="body" class="smart-kanban-body" role="presentation"></div>\n </smart-scroll-viewer>\n </div>`}_keyupHandler(e){const t=this;if("Escape"===e.key&&t._dragDetails){const e=t._dragDetails,a=Smart.Kanban.hoveredKanban,s=Smart.Kanban.hoveredItem;if(delete t._dragDetails,delete Smart.Kanban.kanbanTaskDragged,delete Smart.Kanban.hoveredKanban,delete Smart.Kanban.hoveredItem,e.ScrollViewer&&e.ScrollViewer._scrollView&&(e.ScrollViewer._scrollView.disableSwipeScroll=!1),!e.FeedbackShown)return;a&&clearInterval(a._dragInterval),t._preventSelection=!0;const l=t.isInShadowDOM?t.getRootNode().host:document.body;return l.classList.remove("smart-dragging"),l.style.overflow=t._originalBodyOverflow.overflow,l.style.eoverflowX=t._originalBodyOverflow.overflowX,l.style.overflowY=t._originalBodyOverflow.overflowY,delete t._originalBodyOverflow,e.Feedback.remove(),e.Items.forEach((e=>e.classList.remove("dragged"))),s.classList.remove("drop-target"),void(s.classList.contains("before")?s.classList.remove("before"):s.classList.contains("after")&&s.classList.remove("after"))}}render(){const e=this;Object.defineProperty(e,"dataSource",{get:function(){return e.context===e?e.properties.dataSource.value:e._getCurrentDataSource()},set(t){e.updateProperty(e,e._properties.dataSource,t)}}),e.isInitialized=!1,e._render(),super.render(),e.isInitialized=!0}_getPriority(){const e=this;if(!e.priority||e.priority&&0===e.priority.length)e.priority=[{menuIcon:'<span style="margin-left: 0px; margin-right: 5px;" class="priority"></span>',label:"",value:""},{menuIcon:'<span style="margin-left: 0px; margin-right: 5px;" class="priority low"></span>',label:e.localize("low"),value:"low"},{menuIcon:'<span style="margin-left: 0px; margin-right: 5px;" class="priority average"></span>',label:e.localize("average"),value:"average"},{menuIcon:'<span style="margin-left: 0px; margin-right: 5px;" class="priority high"></span>',label:e.localize("high"),value:"high"},{menuIcon:'<span style="margin-left: 0px; margin-right: 5px;" class="priority critical"></span>',label:e.localize("critical"),value:"critical"}];else if(e.priority){const t=e=>{switch(e.value){case"":return'<span style="margin-left: 0px; margin-right: 5px;" class="priority"></span>';case"low":return'<span style="margin-left: 0px; margin-right: 5px;" class="priority low"></span>';case"average":return'<span style="margin-left: 0px; margin-right: 5px;" class="priority average"></span>';case"high":return'<span style="margin-left: 0px; margin-right: 5px;" class="priority high"></span>';case"critical":return'<span style="margin-left: 0px; margin-right: 5px;" class="priority critical"></span>'}let t="margin-left: 1px; margin-right: 5px;";return t+="height: 0px;",t+="width: 0px;",t+="border-left-color: transparent;",t+="border-left-style: solid;",t+="border-left-width: 7px;",t+="border-right-color: transparent;",t+="border-right-style: solid;",t+="border-right-width: 7px;","low"!==e.value?(t+="border-bottom-color: "+e.color+";"||0,t+="border-bottom-style: solid;",t+="border-bottom-width: 12px;"):(t+="border-top-color: "+e.color+";"||0,t+="border-top-style: solid;",t+="border-top-width: 12px;"),t+="border-radius: 3px;",`<span class="${e.value} priority" style="${t}"></span>`};for(let a=0;a<e.priority.length;a++){const s=e.priority[a];s.menuIcon=t(s)}}for(let t=0;t<e.priority.length;t++){const a=e.priority[t];a.menuLabel=`<div priority="${a.value}" class="smart-kanban-task-text">${a.menuIcon}${a.label}</div>`}return e.priority}_getTags(){const e=this,t=[];if(e.tags){for(let a=0;a<e.tags.length;a++){const s=e.tags[a];if(s&&"string"==typeof s)t.push({label:s.trim(),value:s.trim()});else{const e={};s.label&&(e.label=s.label),s.value?e.value=s.value:e.value=s.label,s.color&&(e.color=s.color),t.push(e)}}e.tags=t}}_render(){const e=this,t=getComputedStyle(e);if(e.columnColorEntireSurface?e.classList.add("smart-kanban-column-color"):e.classList.remove("smart-kanban-column-color"),e.$.body.innerHTML="",e._autoScrollCoefficient=Smart.Utilities.Core.Browser.Firefox?4:Smart.Utilities.Core.Browser.Edge?8:2,e._kanbanTaskMinWidth=parseFloat(t.getPropertyValue("--smart-kanban-task-min-width")),e._dataViewPadding=parseFloat(t.getPropertyValue("--smart-data-view-padding")),e.uiTasksByDataField=[],e.tasksByDataField=[],e.taskById=[],e._allColumns=[],e._customTags=[],e._selectedTasks=[],e._dblclickObject={numberOfClicks:0},e._appliedFiltering={filterGroups:[],filters:[],operator:"and"},e._appliedSorting={dataFields:[],dataTypes:[],orderBy:[]},e._sortPanelDataSource=[{label:e.localize("text"),dataField:"text",dataType:"string",allowFilter:!0,allowSort:!0},{label:e.localize("userId"),dataField:"userId",dataType:"string",allowFilter:!0,allowSort:!0},{label:e.localize("tags"),dataField:"tags",dataType:"string",allowFilter:!0,allowSort:!0},{label:e.localize("priority"),dataField:"priority",dataType:"string",allowFilter:!0,allowSort:!0},{label:e.localize("progress"),dataField:"progress",dataType:"number",allowFilter:!0,allowSort:!0},{label:e.localize("startDate"),dataField:"startDate",dataType:"date",allowFilter:!0,allowSort:!0},{label:e.localize("dueDate"),dataField:"dueDate",dataType:"date",allowFilter:!0,allowSort:!0}],e.taskCustomFields){const t=e.dataSource&&e.dataSource.length>0?e.dataSource[0]:null;for(let a=0;a<e.taskCustomFields.length;a++){const s=e.taskCustomFields[a].label;if(t){const l=typeof t[e.taskCustomFields[a].dataField];"number"===l?e._sortPanelDataSource.push({dataField:e.taskCustomFields[a].dataField,allowFilter:!0,allowSort:!0,label:s,dataType:"number"}):"date"===l?e._sortPanelDataSource.push({dataField:e.taskCustomFields[a].dataField,allowFilter:!0,allowSort:!0,label:s,dataType:"date"}):e._sortPanelDataSource.push({dataField:e.taskCustomFields[a].dataField,allowFilter:!0,allowSort:!0,label:s,dataType:"string"})}else e._sortPanelDataSource.push({dataField:e.taskCustomFields[a].dataField,allowFilter:!0,allowSort:!0,label:s,dataType:"string"})}}const a={checklist:"checklist",color:"color",comments:"comments",dueDate:"dueDate",id:"id",priority:"priority",progress:"progress",startDate:"startDate",status:"status",swimlane:"swimlane",tags:"tags",text:"text",description:"description",userId:"userId",history:"history",createdUserId:"createdUserId",createdDate:"createdDate",updatedUserId:"updatedUserId",updatedDate:"updatedDate"};for(let t in a)e.dataSourceMap[t]||(e.dataSourceMap[t]=a[t]);e._getPriority(),e._getTags(),e._validateDataSourceMap(),e._getInnerElementMessages(),e._localizeHeader(),e._handleHeaderPosition(e.$.scrollViewer),e._validateSwimlanes(),e._renderColumns(),e._handleSwimlanes();let s=!1;e.autoLoadState&&(s=e.loadState()),e._getCurrentUser(),s||e._processDataSource(),e._setPriorityList(),e._setUserList(),e._setActionsList(),e._setColumnActionsList(),e._setCommentsList(),e._autoSaveState(),e._createAddNewButton(),e.$.scrollViewer.refresh()}attached(){const e=this;super.attached(),e.isCompleted&&e._dialog&&(e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(e._dialog))}detached(){const e=this;if(super.detached(),!e._dialog)return;const t=e._dialog;t.removeEventListener("open",e._dialogEventHandler),t.removeEventListener("closing",e._dialogEventHandler),t.removeEventListener("close",e._dialogEventHandler),t.removeEventListener("click",e._dialogClickHandler),t.remove()}addTask(e={}){const t=this,a=t.columns;if("object"!=typeof e||0===a.length||!t._currentUser.allowAdd)return;const s=t.dataSourceMap;void 0===e[s.status]&&(e[s.status]=a[0].dataField),t._currentUser.info&&(void 0===e[s.createdUserId]?(e[s.createdUserId]=t._currentUser.info.id,e[s.createdDate]=new Date):e[s.createdDate]||(e[s.createdDate]=new Date));const l={value:e,id:e.id};t.$.fireEvent("taskBeforeAdd",l),t.dataSource&&t.dataSource.virtualDataSource?t._requestVirtualDataSource("add",e,(function(e){return e})):(t.dataSource||(t.dataSource=[]),t.dataSource.push(e),t._createTask(e,!0),t._autoSaveState("dataSource")),t.$.fireEvent("taskAdd",l),t._refreshButtonsAndSummaries(),t.virtualization&&t._refreshColumns()}addSort(e,t){const a=this,s=a.dataSource;let l;function o(e,s){const o=a._sortPanelDataSource.find((t=>t.dataField===e));if(o){let a=Array.isArray(t)?t[s]:"string"==typeof t?t:"ascending";l.dataFields.push(e),l.dataTypes.push(o.dataType),a=a&&-1!==a.indexOf("desc")?"descending":"ascending",l.orderBy.push(a)}}if(0!==arguments.length&&s&&0!==s.length){if(a.closePanel(),1===arguments.length&&"object"==typeof e)l=e;else if(l={dataFields:[],dataTypes:[],orderBy:[]},Array.isArray(e))e.forEach(o);else{if("string"!=typeof e)return;o(e,0)}super.addSort(l)}}beginEdit(e){const t=this;t.disabled||(e=t._validateTaskArgument(e))&&(t.editable||t.readonly)&&t._openDialog(e,"edit")}cancelEdit(){const e=this._dialog;e&&e.opened&&e.classList.contains("edit")&&e.close()}hide(e){const t=this;void 0!==e&&"number"==typeof e&&(e=t.columns[e]),e&&!1!==e.visible&&(e.visible=!1,t.$.fireEvent("columnHide",{column:e}),t.refresh())}show(e){const t=this;void 0!==e&&"number"==typeof e&&(e=t.columns[e]),e&&!0!==e.visible&&(e.visible=!0,t.$.fireEvent("columnShow",{column:e}),t.refresh())}showAllColumns(){const e=this;for(let t=0;t<e.columns.length;t++)e.columns[t].visible=!0;e.refresh()}collapse(e){const t=this;if(!t.collapsible)return;if(!(e=t._validateColumnArgument(e))||e.collapsed||!e.collapsible)return;const a=t._columnToElement.get(e),s=a.siblingColumns;let l=0;e.collapsed=!0,a.classList.add("collapsed");const o=e.collapsed?t.localize("expand"):t.localize("collapse"),i=a.querySelector(".smart-kanban-column-header-toggle-button");if(i&&i.setAttribute("title",o),s.forEach((e=>e.collapsed&&l++)),l===s.length){const a=0!==s.indexOf(e)?0:1,l=s[a],o=t._columnToElement.get(l);l&&(l.collapsed=!1),o&&(o.classList.remove("collapsed"),t._updateColumnWidths(s,o.parentElement))}else t._updateColumnWidths(s,a.parentElement);t._allColumns.forEach((e=>t._refreshScrollViewer(e))),t._autoSaveState("collapsed"),t._handleSwimlanes(!0),t._createAddNewButton(),t._doNotFireEvents||t.$.fireEvent("columnCollapse",{column:e})}copyTask(e){const t=this;if(!t._currentUser.allowAdd)return;if(!(e=t._validateTaskArgument(e)))return;const a=JSON.parse(JSON.stringify(e.data));a.history=[],t.dataSource&&t.dataSource.virtualDataSource?t._requestVirtualDataSource("add",a,(function(e){return t.$.fireEvent("taskAdd",{value:a}),e})):(a[t.dataSourceMap.id]=Math.floor(9e4*Math.random()+1e4),t._createTask(a,!0),t._autoSaveState("dataSource"),t.$.fireEvent("taskAdd",{value:a})),t.dataSource||(t.dataSource=[]),t.dataSource.push(a),t._refreshButtonsAndSummaries()}endEdit(){const e=this._dialog;e&&e.opened&&e.classList.contains("edit")&&(e.ok=!0,e.close())}ensureVisible(e){const t=this;if(e&&"number"==typeof e){const a=t.getTask(e);if(!a)return;const s=a[t.dataSourceMap.status],l=t.querySelector('.smart-kanban-column[data-field="'+s+'"]');if(l){const e=l.querySelector("smart-scroll-viewer");e&&(a.top<e.scrollTop||a.top>e.scrollTop+e.offsetHeight?e.scrollTop=a.top:t._refreshScrollHeight(e,s))}return}if(!(e=t._validateTaskArgument(e))||e.filteredOut)return;const a=e.closest("smart-scroll-viewer");if(0===a.scrollHeight)return e;const s=a.scrollTop,l=e.offsetTop;return s<=l&&s+a.offsetHeight>=l+e.offsetHeight||(a.scrollTop=l),e}expand(e){const t=this;if(!(e=t._validateColumnArgument(e))||!e.collapsed)return;const a=t._columnToElement.get(e);e.collapsed=!1,a.classList.remove("collapsed");const s=e.collapsed?t.localize("expand"):t.localize("collapse"),l=a.querySelector(".smart-kanban-column-header-toggle-button");l&&l.setAttribute("title",s),t._updateColumnWidths(a.siblingColumns,a.parentElement),t._allColumns.forEach((e=>t._refreshScrollViewer(e))),t._autoSaveState("collapsed"),t._handleSwimlanes(!0),t._createAddNewButton(),t.$.fireEvent("columnExpand",{column:e})}expandAll(){const e=this;e._allColumns.forEach((t=>{t.collapsed=!1,e._columnToElement.get(t).classList.remove("collapsed")})),e._allColumns.forEach((t=>e._refreshScrollViewer(t))),e._columnContainers.forEach((t=>e._updateColumnWidths(t.children,t))),e._autoSaveState("collapsed"),e._handleSwimlanes(!0)}exportData(e,t,a){const s=this,l=getComputedStyle(s),o=l.borderRightColor,i=s.swimlanes,r=new Smart.Utilities.DataExporter,n=s._getCurrentDataSource(),d=s.dataSourceMap,c=[{id:"Task ID",text:"Text",status:"Status",swimlane:"Swimlane",asignee:"Asignee",priority:"Priority",progress:"Progress",startDate:"Start date",dueDate:"Due date",subTasks:"Completed sub-tasks",tags:"Tags"}],u={},m={},p={};if(s.taskCustomFields)for(let e=0;e<s.taskCustomFields.length;e++)c[0][s.taskCustomFields[e].dataField]=s.taskCustomFields[e].label;r.style={border:"1px solid "+o,borderCollapse:"collapse",backgroundColor:l.backgroundColor,color:l.color,fontFamily:"Helvetica",header:{border:"1px solid "+o,fontWeight:"bold"},columns:{border:"1px solid "+o,progress:{format:"p0"},startDate:{format:s.formatStringDate},dueDate:{format:s.formatStringDate}},rows:{}},0===i.length&&delete c[0].swimlane;for(let e=0;e<n.length;e++){const t=n[e];let a=t[d.status],l=t[d.swimlane],o=t[d.userId],h=t[d.progress];u[a]?a=u[a]:(a=s._allColumns.find((e=>e.dataField===a)).label,u[t[d.status]]=a),null===o?o="":p[o]?o=p[o]:(o=s.users.find((e=>e.id===o)).name,p[t[d.userId]]=o),null===h?h="":h/=100;let g=t[d.tags];g&&"string"!=typeof g&&(g=g.map((e=>"string"==typeof e?e:e.label)));const f={id:t[d.id],text:t[d.text],description:t[d.description]||"",status:a,asignee:o,priority:t[d.priority]||"",progress:h,startDate:t[d.startDate]||"",dueDate:t[d.dueDate]||"",subTasks:s._getCompletedSubTasks(t[d.checklist]),tags:g};if(s.taskCustomFields)for(let e=0;e<s.taskCustomFields.length;e++)f[s.taskCustomFields[e].dataField]=`"${t[s.taskCustomFields[e].dataField]}"`.replaceAll(","," ");i.length&&(l?m[l]?l=m[l]:(l=i.find((e=>e.dataField===l)).label,m[t[d.swimlane]]=l):l="",f.swimlane=l),c.push(f),t[d.color]&&(r.style.rows[e]={backgroundColor:t[d.color]})}return r.exportData(c,e,t,a)}getState(e){const t=this,a={},s={collapsed:a,dataSource:t._getCurrentDataSource(),filtering:t._appliedFiltering,selection:{selected:t._selectedTasks,selectionStart:t._selectionStart?t._selectionStart:null},sorting:t._appliedSorting,tabs:t._selectedTabs,visibility:{taskActions:t.taskActions,taskComments:t.taskComments,taskDue:t.taskDue,taskPriority:t.taskPriority,taskProgress:t.taskProgress,taskTags:t.taskTags,taskUserIcon:t.taskUserIcon}};let l=null,o=null;t._selectionInView&&(l=t._selectionInView.closest(".smart-kanban-column").column.dataField,o=t._selectionInView.getAttribute("swimlane")),s.selection.selectionInColumn=l,s.selection.swimlane=o;const i={};for(let e in t.tasksByDataField){i[e]=[];const a=t.tasksByDataField[e];for(let t=0;t<a.length;t++)i[e].push(a[t].id)}if(s.order=i,t._allColumns.forEach((e=>a[e.dataField]=e.collapsed)),e){const t={};for(let a in e){const l=e[a];s[l]&&(t[l]=s[l])}return t}return s}loadState(e,t){const a=this;if(!e&&!(e=window.localStorage.getItem("smartKanban"+a.id)))return!1;"string"==typeof e&&(e=JSON.parse(e,((e,t)=>t&&-1!==["startDate","dueDate","time"].indexOf(e)?new Date(t):t))),e.dataSource||(t=!1),a._doNotFireEvents=!0,a._selectedTasks=[],delete a._selectionStart,delete a._selectionInView,a.expandAll(),!1!==t&&Array.from(a.$.container.querySelectorAll("smart-scroll-viewer.smart-kanban-column-content-tasks")).forEach((e=>e.clearContent())),a._allColumns.forEach((t=>{e.collapsed&&e.collapsed[t.dataField]&&a.collapse(t)}));for(let t in e.visibility)a[t]=e.visibility[t];if(!1!==t&&(a.dataSource=e.dataSource,a.uiTasksByDataField=[],a.tasksByDataField=[],a._processDataSource()),e.order){let t=!1,s=[];for(let s in e.order){const l=e.order[s];let o=a._getTasksByDataField(s);for(let e=0;e<l.length;e++){const i=l[e],r=a.taskById[i];if(r){const l=o.indexOf(r);if(l!==e&&l>=0)o.splice(e,0,o.splice(l,1)[0]),t=!0;else if(-1===l){let l=a._getTasksByDataField(r[a.dataSourceMap.status]);const i=l.indexOf(r);i>=0&&(l.splice(i,1),r[a.dataSourceMap.status]=s,o.splice(e,0,r),t=!0)}}}}if(t){const e=Object.keys(a.tasksByDataField);for(let t in e)s=s.concat(a.tasksByDataField[e[t]]);Array.from(a.$.container.querySelectorAll("smart-scroll-viewer.smart-kanban-column-content-tasks")).forEach((e=>e.clearContent())),a.dataSource=s,a.uiTasksByDataField=[],a.tasksByDataField=[],a._processDataSource()}}if(e.filtering&&a.addFilter(a._constructFilterGroups(e.filtering),e.filtering.operator),e.sorting&&a.addSort(e.sorting),!1!==t&&a._autoSaveState(e),e.selection&&(e.selection.selected.forEach((e=>{const t=a.$.container.querySelector(`.smart-kanban-task[data-id="${e}"]`);t&&(t.setAttribute("selected",""),a._selectedTasks.push(t.data.id))})),e.selection.selectionStart&&(a._selectionStart=a.$.container.querySelector(`.smart-kanban-task[data-id="${e.selection.selectionStart}"]`)),e.selection.selectionInColumn)){const t=a._columnToElement.get(a._allColumns.find((t=>t.dataField===e.selection.selectionInColumn)));e.selection.swimlane?a._selectionInView=t.querySelector(`smart-scroll-viewer[swimlane=${e.selection.swimlane}]`):a._selectionInView=t.querySelector("smart-scroll-viewer")}if(e.tabs){const t="tabs"===a.hierarchy;a._allColumns.forEach((s=>{if(void 0!==s.selected){const l=a._columnToElement.get(s),o=-1!==e.tabs.indexOf(s.dataField);s.selected=o,t&&(l.classList.toggle("smart-hidden",!o),l.tab.classList.toggle("selected",o),l.tab.setAttribute("aria-selected",o))}}))}return a._doNotFireEvents=!1,!0}moveTask(e,t){const a=this;if(a.disabled||""!==t&&!t)return;const s=a.dataSourceMap;if(!(e=a._validateTaskArgument(e))||!a._updateTaskInProgress&&e.data[s.status]===t)return;const l=a._allColumns.find((e=>e.dataField===t));function o(){const o=e.closest("smart-scroll-viewer"),i=a._columnToElement.get(l),r=e.data,n=a.getTaskScrollViewer(i,r);if(a.virtualization){const l=r,i=e.column.dataField,d=a._getTasksByDataField(i),c=d.findIndex((e=>e.id===l.id));return c>=0&&(d.splice(c,1),a._getTasksByDataField(t).push(l)),r[s.status]=t,a._refreshScrollViewer(o,!0),a._refreshScrollViewer(n,!0),e.hasAttribute("selected")&&(e.removeAttribute("selected"),a._selectedTasks=a._selectedTasks.filter((t=>t!==e.data.id)),a._autoSaveState("selection")),e.removeAttribute("focus"),void((a.shadowRoot||a.getRootNode()).activeElement===o&&a._focusTask(a._getFirstItem(o.$.content)))}r[s.status]=t,n.appendChild(e),a._dialog&&a._dialog.ok||(a.textTemplate&&a._renderTask(e),a._autoSaveState("dataSource")),a._refreshScrollViewer(o,!0),a._refreshScrollViewer(n,!0),e.hasAttribute("selected")&&(e.removeAttribute("selected"),a._selectedTasks=a._selectedTasks.filter((t=>t!==e.data.id)),a._autoSaveState("selection")),e.removeAttribute("focus"),(a.shadowRoot||a.getRootNode()).activeElement===o&&a._focusTask(a._getFirstItem(o.$.content))}l&&(a.dataSource&&a.dataSource.virtualDataSource&&!a._ignoreVirtualDataSource?a._requestVirtualDataSource("update",Object.assign({},e.data,{status:t}),(function(e){return e&&o(),e})):o())}_getCustomizeColumnPanelDataSource(){const e=this;return e._customizeColumns=[{label:e.localize("actionsIcon"),dataField:"taskActions",allowHide:!0,disableDrag:!0,visible:e.taskActions},{label:e.localize("commentsIcon"),dataField:"taskComments",allowHide:!0,disableDrag:!0,visible:e.taskComments},{label:e.localize("dueDate"),dataField:"taskDue",allowHide:!0,disableDrag:!0,visible:e.taskDue},{label:e.localize("priorityIcon"),dataField:"taskPriority",allowHide:!0,disableDrag:!0,visible:e.taskPriority},{label:e.localize("progress"),dataField:"taskProgress",allowHide:!0,disableDrag:!0,visible:e.taskProgress},{label:e.localize("tags"),dataField:"taskTags",allowHide:!0,disableDrag:!0,visible:e.taskTags},{label:e.localize("userIcon"),dataField:"taskUserIcon",allowHide:!0,disableDrag:!0,visible:e.taskUserIcon}],e._customizeColumns}openCustomizePanel(){const e=this,t=e.dataSource;if(!t||0===t.length||e.disabled||"none"===e.headerPosition)return;const a=e.$.customize,s=[{label:e.localize("actionsIcon"),dataField:"taskActions",visible:e.taskActions},{label:e.localize("commentsIcon"),dataField:"taskComments",visible:e.taskComments},{label:e.localize("dueDate"),dataField:"taskDue",visible:e.taskDue},{label:e.localize("priorityIcon"),dataField:"taskPriority",visible:e.taskPriority},{label:e.localize("progress"),dataField:"taskProgress",visible:e.taskProgress},{label:e.localize("tags"),dataField:"taskTags",visible:e.taskTags},{label:e.localize("userIcon"),dataField:"taskUserIcon",visible:e.taskUserIcon}];let l;e._closeDialog(),e.$.headerDropDown.classList.add("customize-panel"),e.$.headerDropDown.classList.remove("filter-panel","sort-panel","search-panel"),a.classList.remove("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e._closeSearchPanel(),e._customizePartCreated?(l=a.firstElementChild,l.set("dataSource",s),l.propertyChangedHandler("dataSource",void 0,s),l.rightToLeft=e.rightToLeft):(l=document.createElement("smart-column-panel"),l.animation=e.animation,l.dataSource=s,l.locale=e.locale,l.messages=e._innerElementMessages.columnPanel,l.rightToLeft=e.rightToLeft,l.theme=e.theme,e.$.customize.appendChild(l),l.classList.add("smart-kanban-column-panel"),e._customizePartCreated=!0),e._openHeaderDropDown(e.$.customizeButton)}_getFilterPanelDataSource(){const e=this,t=[{label:e.localize("text"),dataField:"text",dataType:"string",allowSort:!0,allowFilter:!0},{label:e.localize("userId"),dataField:"userId",dataType:"string",allowSort:!0,allowFilter:!0},{label:e.localize("tags"),dataField:"tags",dataType:"string",allowSort:!0,allowFilter:!0},{label:e.localize("priority"),dataField:"priority",dataType:"enum",allowSort:!0,allowFilter:!0,options:e._getPriority()},{label:e.localize("progress"),dataField:"progress",dataType:"number",allowSort:!0,allowFilter:!0},{label:e.localize("startDate"),dataField:"startDate",dataType:"date",allowSort:!0,allowFilter:!0},{label:e.localize("dueDate"),dataField:"dueDate",dataType:"date",allowSort:!0,allowFilter:!0}];if(e.taskCustomFields){const a=e.dataSource&&e.dataSource.length>0?e.dataSource[0]:null;for(let s=0;s<e.taskCustomFields.length;s++){const l=e.taskCustomFields[s].label;if(a){const o=typeof a[e.taskCustomFields[s].dataField];"number"===o?t.push({dataField:e.taskCustomFields[s].dataField,allowFilter:!0,allowSort:!0,label:l,dataType:"number"}):"date"===o?t.push({dataField:e.taskCustomFields[s].dataField,allowFilter:!0,allowSort:!0,label:l,dataType:"date"}):t.push({dataField:e.taskCustomFields[s].dataField,allowFilter:!0,allowSort:!0,label:l,dataType:"string"})}else t.push({dataField:e.taskCustomFields[s].dataField,allowFilter:!0,allowSort:!0,label:l,dataType:"string"})}}return e.onFilterPrepare&&e.onFilterPrepare(t),t}openFilterPanel(){const e=this,t=e._getFilterPanelDataSource();super.openFilterPanel(t,(function(t,a){"progress"===a.dataField?(t.min=0,t.max=100,t.showUnit=!0,t.unit="%"):"date"===a.dataType&&(t.formatString=e.formatStringDate)}))}_getSortPanelDataSource(){const e=this;return e.onSortPrepare&&e.onSortPrepare(this._sortPanelDataSource),this._sortPanelDataSource}openSortPanel(){const e=this,t=e._getSortPanelDataSource().map((t=>{const a=e._appliedSorting.dataFields.indexOf(t.dataField);return Object.assign({},t,{sortIndex:a,sortDirection:-1===a?"ascending":e._appliedSorting.orderBy[a]})}));super.openSortPanel(t)}removeTask(e,t){const a=this;function s(){const t=e.closest("smart-scroll-viewer"),s=e.data;if(a.virtualization||(e.remove(),a._refreshScrollViewer(t,!0)),a._autoSaveState("dataSource"),a.$.fireEvent("taskRemove",{value:s,id:e.data.id}),a.dataSource){const e=a.dataSource.findIndex((e=>e.id===s.id));if(e>-1){const t=s[a.dataSourceMap.status],l=a.tasksByDataField[t].findIndex((e=>e.id===s.id));l>=0&&a.tasksByDataField[t].splice(l,1),a.dataSource.splice(e,1)}}if(a._selectedTasks&&a._selectedTasks.indexOf(s.id)>=0){const e=a._selectedTasks.indexOf(s.id);a._selectedTasks.splice(e,1)}a._refreshSummaries(),a._refreshColumns()}a._currentUser.allowRemove&&(e=a._validateTaskArgument(e))&&(t?a._openDialog(e,"prompt"):a.dataSource&&a.dataSource.virtualDataSource?a._requestVirtualDataSource("remove",e.data,(function(e){return e&&s(),e})):s())}saveState(e){const t=this.getState(e);return window.localStorage.setItem("smartKanban"+this.id,JSON.stringify(t)),t}addHistory(e,t){const a=this;if(!e||!t)return;const s=a.dataSourceMap;a.storeHistory?(void 0!==e[s.history]&&null!==e[s.history]||(e[s.history]=[]),e[s.history].length===a.storeHistoryItems&&e[s.history].splice(0,1),e[s.history].push(t)):e[s.history]=[]}clearHistory(e){e&&(e.history=[])}updateTask(e,t){const a=this;if(!a._currentUser.allowEdit||!t)return;if(!(e=a._validateTaskArgument(e)))return;const s=a.dataSourceMap,l=e.data;function o(){if(e.data=t,t[s.status]!==l[s.status]&&(a._updateTaskInProgress=!0,a.moveTask(e,t[s.status]),delete a._updateTaskInProgress),t[s.swimlane]!==l[s.swimlane]){const o=e.closest(".smart-kanban-column");a._hasSwimlane(o.index)?(o.querySelector(`smart-scroll-viewer[swimlane=${t[s.swimlane]}]`).appendChild(e),l[s.swimlane]&&a._refreshScrollViewer(o.querySelector(`smart-scroll-viewer[swimlane=${l[s.swimlane]}]`))):delete t[s.swimlane]}const o=()=>{if(!a._currentUser||a._currentUser&&!a._currentUser.info)return;const e=()=>({user:a._currentUser.info.id,date:t[s.updatedDate]});if(t[s.userId]!==l[s.userId]){const o=e();o.action="user";let i=!0;l[s.userId]||t[s.userId]||(i=!1),i&&(o.details={oldValue:l[s.userId],value:t[s.userId]},a.addHistory(t,o))}if(""+t[s.dueDate]!=""+l[s.dueDate]){const o=e();o.action="deadline",o.details={oldValue:l[s.dueDate]?l[s.dueDate].toLocaleDateString():"",value:t[s.dueDate]?t[s.dueDate].toLocaleDateString():""},a.addHistory(t,o)}if(""+t[s.startDate]!=""+l[s.startDate]){const o=e();o.action="deadline",o.details={oldValue:l[s.startDate]?l[s.startDate].toLocaleDateString():"",value:t[s.startDate]?t[s.startDate].toLocaleDateString():""},a.addHistory(t,o)}if(t[s.color]!==l[s.color]){const o=e();o.action="color",o.details={oldValue:l[s.color],value:t[s.color]},a.addHistory(t,o)}if(t[s.status]!==l[s.status]){const o=e();o.action="status",o.details={oldValue:l[s.status],value:t[s.status]},a.addHistory(t,o)}if(JSON.stringify(t[s.checklist])!==JSON.stringify(l[s.checklist])){const o=e();o.action="subtasks",o.details={oldValue:l[s.checklist],value:t[s.checklist]},a.addHistory(t,o)}if(parseFloat(t[s.progress])!==parseFloat(l[s.progress])){let o=!0;if(null===l[s.progress]&&0===parseFloat(t[s.progress])&&(o=!1),o){const o=e();o.action="progress",o.details={oldValue:l[s.progress]?l[s.progress]+"%":"0%",value:t[s.progress]+"%"},a.addHistory(t,o)}}if(t[s.description]!==l[s.description]){const o=e();o.action="description",o.details={oldValue:l[s.description],value:t[s.description]},a.addHistory(t,o)}if(t[s.priority]!==l[s.priority]){const o=e();o.action="priority",o.details={oldValue:l[s.priority],value:t[s.priority]},a.addHistory(t,o)}if(t[s.tags]!==l[s.tags]){const o=e();o.action="tags",o.details={oldValue:l[s.tags],value:t[s.tags]},a.addHistory(t,o)}if(t[s.text]!==l[s.text]){const o=e();o.action="text",o.details={oldValue:l[s.text],value:t[s.text]},a.addHistory(t,o)}for(let s=0;s<a.taskCustomFields.length;s++){const o=a.taskCustomFields[s];let i=l[o.dataField],r=t[o.dataField];if(i!==r&&""+i!=""+r){const s=e();if(s.action=o.name?o.name:o.dataField,o.dataSource){const e=e=>{const t=o.dataSource.find((t=>t.value===e||t===e?t:void 0));return void 0!==t?t.label:""},t=t=>{if(void 0===t||t.length){if(void 0!==t&&t.length&&"string"!=typeof t){let a=[];return t.forEach((t=>{a.push(e(t))})),a.toString()}if(t&&t.indexOf(",")>0){t=t.split(",");let a=[];return t.forEach((t=>{a.push(e(t))})),a.toString()}return t}return e(t)};r=t(r),i=t(i)}s.details={oldValue:i,value:r},a.addHistory(t,s)}}};a.textTemplate||t[s.text]!==l[s.text]||t[s.tags]!==l[s.tags]||t[s.priority]!==l[s.priority]||t[s.description]!==l[s.description]?(a._renderTask(e),o()):(o(),t[s.userId]!==l[s.userId]&&a._updateUserIcon(e),t[s.dueDate]!==l[s.dueDate]&&a._updateTaskDueDate(e),t[s.color]!==l[s.color]&&a._updateTaskColor(e),JSON.stringify(t[s.checklist])!==JSON.stringify(l[s.checklist])?(a._updateTaskChecked(e),a._updateTaskProgress(e)):parseFloat(t[s.progress])!==parseFloat(l[s.progress])&&a._updateTaskProgress(e),a._updateTaskSubtasks(e),a._updateTaskCustomFields(e));const i=a.getColumn(t.status);i&&(t.statusLabel=i.label);const r=a.getColumn(l.status);r&&(l.statusLabel=r.label);const n=JSON.parse(JSON.stringify(t)),d=JSON.parse(JSON.stringify(l));if(n.history=t.history,d.history=l.history,a.$.fireEvent("change",{task:e,id:n.id,value:n,oldValue:d}),a.virtualization){const t=e.data[s.status],l=a.tasksByDataField[t].findIndex((t=>t.id===e.data.id));if(l>=0){a.tasksByDataField[t][l]=e.data;const s=a._getTasksByDataField(t),o=s.findIndex((t=>t.id===e.data.id));o>=0&&(s[o]=e.data)}}a._refreshScrollViewer(e.closest("smart-scroll-viewer"));const c=a.dataSource.findIndex((t=>e.data.id===t.id));c>=0&&(a.dataSource[c]=e.data),a._refreshSummaries(),a._updateTaskComments(e),a._autoSaveState("dataSource"),a.$.fireEvent("taskUpdate",{id:n.id,value:n,oldValue:d})}(t=Object.assign({},l,t))[s.checklist]&&0===t[s.checklist].length&&(t[s.checklist]=null),JSON.stringify(t)!==JSON.stringify(l)&&(a.dataSource&&a.dataSource.virtualDataSource?a._requestVirtualDataSource("update",t,(function(e){return e&&(a._ignoreVirtualDataSource=!0,o(),delete a._ignoreVirtualDataSource),e})):o())}_refreshSelection(){const e=this;if("zeroOrOne"===e.selectionMode){const t=e._selectionStart;e._selectedTasks.forEach((a=>{if(a!==t){e.getTask(a).selected=!1;const t=e.querySelector('[data-id="'+a+'"]');t&&t.removeAttribute("selected")}})),e._selectedTasks=[t]}e._selectedTasks.forEach((t=>{const a=e.querySelector('[data-id="'+t+'"]');a&&a.setAttribute("selected","")})),e._refreshColumns()}propertyChangedHandler(e,t,a){const s=this,l=s._dialog;function o(){if(s.cancelEdit(),l&&l.close(),s._closeList(s._commentsList,"_commentSelectionFor"),s._getCurrentUser(),s.taskSubTasks){const e=s.querySelectorAll(".smart-kanban-task-input");s._currentUser&&!s._currentUser.allowEdit||s.disabled||!s.taskSubTasksInput?e.forEach((e=>{e.classList.add("smart-hidden")})):e.forEach((e=>{e.classList.remove("smart-hidden")}))}}switch(super.propertyChangedHandler(e,t,a),e){case"columnColorEntireSurface":a?s.classList.add("smart-kanban-column-color"):s.classList.remove("smart-kanban-column-color");break;case"columnFooter":case"addNewButton":case"addNewButtonDisplayMode":s._reset(),s._createAddNewButton();break;case"taskTags":s._reset();break;case"taskCustomFields":s._resetFields=!0,s._reset();break;case"autoColumnHeight":case"applyColumnColorToTasks":case"columnWidth":case"addNewColumn":s._reset();break;case"allowDrag":s._getCurrentUser();break;case"animation":case"theme":{let t=Array.from(s.$.container.querySelectorAll("smart-column-panel, smart-multi-column-filter-panel, smart-sort-panel"));l&&(t.push(l),t=t.concat(Array.from(l.$.footer.children)),l.editPanelPopulated&&(t=t.concat(Array.from(l.$.container.querySelectorAll(".smart-element.editor"))))),t.forEach((t=>t[e]=a)),Array.from(s.$.container.getElementsByClassName("smart-kanban-task")).forEach((e=>s._updateTaskColor(e)));break}case"autoSaveState":s._autoSaveState();break;case"collapsible":a||s.expandAll();break;case"columnSummary":s._refreshSummaries();break;case"columns":s._render(),l&&l.editPanelPopulated&&(l.editors.status.dataSource=s._allColumns.map((e=>({color:e.color,label:e.label,value:e.dataField}))));break;case"currentUser":o();break;case"dataSource":case"dataSourceMap":if("dataSourceMap"===e&&s._validateDataSourceMap(),s._customTags=[],s._selectedTasks=[],s.cancelEdit(),s.closePanel(),s._closeList(s._actionsList,"_actionSelectionFor"),s._closeList(s._columnActionsList,"_columnActionSelectionFor"),s._closeList(s._commentsList,"_commentSelectionFor"),s._closeList(s._userList,"_userSelectionFor"),s._closeList(s._priorityList,"_prioritySelectionFor"),0===s.columns.length)return s._renderColumns(),s._handleSwimlanes(),void s._processDataSource();Array.from(s.$.container.querySelectorAll("smart-scroll-viewer.smart-kanban-column-content-tasks")).forEach((e=>{e.clearContent(),e.refresh(),s._refreshScrollViewer(e,!0)})),s._processDataSource(),s.dataSource||s._refresh(),s.columnSummary&&s._refreshSummaries();break;case"disabled":s.cancelEdit(),s.closePanel(),s._closeList(s._actionsList,"_actionSelectionFor"),s._closeList(s._columnActionsList,"_columnActionSelectionFor"),s._closeList(s._commentsList,"_commentSelectionFor"),s._closeList(s._userList,"_userSelectionFor"),s._closeList(s._priorityList,"_prioritySelectionFor"),s._setFocusable();break;case"formatStringDate":Array.from(s.$.container.getElementsByClassName("smart-kanban-task")).forEach((e=>s._updateTaskDueDate(e))),l&&(l.editors.startDate.formatString=a,l.editors.dueDate.formatString=a);break;case"formatStringTime":s._closeList(s._commentsList,"_commentSelectionFor");break;case"editable":s.cancelEdit(),s._actionsList.classList.contains("edit-comment")||s._closeList(s._actionsList,"_actionSelectionFor"),s._getCurrentUser();break;case"headerPosition":s._handleHeaderPosition(s.$.body),s._allColumns.forEach((e=>s._refreshScrollViewer(e)));break;case"hierarchy":0===s.swimlanes.length&&s.columns.length!==s._allColumns.length&&s._reset();break;case"locale":case"messages":s.closePanel(),s._localizeHeader(),s._getInnerElementMessages(),s._closeList(s._actionsList,"_actionSelectionFor"),s._closeList(s._columnActionsList,"_columnActionSelectionFor"),s._closeList(s._commentsList,"_commentSelectionFor"),s._setActionsList(),s._setColumnActionsList(),s._setCommentsList(),l&&(s.cancelEdit(),l.close(),l.$.footer.firstElementChild.innerHTML=s.localize("ok"),l.$.footer.children[1].innerHTML=s.localize("cancel"),l.$.footer.children[2].innerHTML=s.localize("delete"),l.editPanelPopulated&&(l.editors.priority.dataSource=s._getPriority(),l.$.container.querySelector(".new-subtask").placeholder=s.localize("newSubtask"),l.$.container.querySelector("smart-button.add").title=s.localize("addSubtask"),Array.from(l.$.container.getElementsByClassName("editor-label")).forEach((e=>{let t=e.id.slice(s.id.length+5);t=t.slice(0,1).toLowerCase()+t.slice(1),e.innerHTML=s.localize(t)})))),s._customizePartCreated&&(s.$.customize.firstElementChild.messages=s._innerElementMessages.columnPanel,s.$.customize.firstElementChild.locale=s.locale),s._filterPartCreated&&(s.$.filter.firstElementChild.messages=s._innerElementMessages.multiColumnFilterPanel,s.$.filter.firstElementChild.locale=s.locale,s.$.filter.firstElementChild.editorPlaceholder=s.localize("filterValuePlaceholder")),s._sortPartCreated&&(s.$.sort.firstElementChild.messages=s._innerElementMessages.sortPanel,s.$.sort.firstElementChild.locale=s.locale);break;case"rightToLeft":s._reset(!0);break;case"selectionMode":"zeroOrOne"===a&&s._selectedTasks.length>1&&s._refreshSelection();break;case"swimlanes":if(s._validateSwimlanes(),JSON.stringify(s.swimlanes)===JSON.stringify(t))return;s._reset(),l&&l.editPanelPopulated&&(l.editors.swimlane.dataSource=s.swimlanes.map((e=>({label:e.label,value:e.dataField}))));break;case"swimlanesFrom":case"swimlanesTo":{const e=s.swimlanesFrom,t=s.swimlanesTo;e<0&&(s.swimlanesFrom=0),null!==t&&e>t&&(s.swimlanesFrom=t),s.swimlanes.length>0&&s._reset();break}case"taskCustomFieldsHide":case"taskProgress":case"taskSubTasksInput":case"taskSubTasks":case"taskUserIcon":case"taskComments":case"taskDue":case"taskPriority":case"tags":case"taskColor":case"taskColorEntireSurface":case"textTemplate":Array.from(s.$.container.getElementsByClassName("smart-kanban-task")).forEach((e=>s._renderTask(e))),s._allColumns.forEach((e=>s._refreshScrollViewer(e)));break;case"unfocusable":s._setFocusable();break;case"priority":s._closeList(s._priorityList,"_prioritySelectionFor"),s._setPriorityList();break;case"users":s._closeList(s._userList,"_userSelectionFor"),s._setUserList(),Array.from(s.$.container.getElementsByClassName("smart-kanban-task")).forEach((e=>s._updateUserIcon(e))),l&&l.editPanelPopulated&&(l.editors.userId.dataSource=s.users.map((e=>({label:e.name,value:e.id})))),o()}}_reset(e){const t=this,a=t.getState();t._allColumns=[],t._customTags=[],t._selectedTasks=[],t._dialog&&(t.cancelEdit(),e&&(t._dialog.remove(),delete t._dialog)),t.closePanel(),t._closeList(t._actionsList,"_actionSelectionFor"),t._closeList(t._columnActionsList,"_columnActionSelectionFor"),t._closeList(t._commentsList,"_commentSelectionFor"),t._closeList(t._userList,"_userSelectionFor"),t.$.body.innerHTML="",Array.from(t.$.container.getElementsByClassName("swimlane")).forEach((e=>e.remove())),t._renderColumns(),t._handleSwimlanes(),t._createAddNewButton(),t.loadState(a),t.$.scrollViewer.refresh()}_refresh(){const e=this;e._allColumns=[],e._customTags=[],e._selectedTasks=[],e.closePanel(),e._closeList(e._actionsList,"_actionSelectionFor"),e._closeList(e._columnActionsList,"_columnActionSelectionFor"),e._closeList(e._commentsList,"_commentSelectionFor"),e._closeList(e._userList,"_userSelectionFor"),e.$.body.innerHTML="",Array.from(e.$.container.getElementsByClassName("swimlane")).forEach((e=>e.remove())),e._renderColumns(),e._handleSwimlanes(),e._createAddNewButton(),e.$.scrollViewer.refresh()}_containerClickHandler(e){const t=this,a=t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target;if(t.$.header.contains(a))return void t._headerClickHandler(a,t.$.body);const s=a.closest(".smart-kanban-column-header");if(s){const e=s.parentElement.column;if(a instanceof HTMLInputElement)return;if(t.columnActions&&a.classList.contains("smart-kanban-column-actions")){if(!t._columnActionsList.parentElement||t._columnActionsList.classList.contains("smart-visibility-hidden")){if(t._columnActionsListDate&&new Date-t._columnActionsListDate<300)return;t._openColumnActionsList(a,e)}return}if(a.closest(".smart-kanban-column-header-add")&&e)return void t._openDialog(e,"add","column");if(t.collapsible&&e&&e.collapsible&&a.closest(".smart-kanban-column-header-toggle-button"))return void t[e.collapsed?"expand":"collapse"](e)}const l=a.closest(".smart-kanban-tab");if(l){if(l.classList.contains("selected"))return;const e=l.parentElement.querySelector(".selected");return e.classList.remove("selected"),e.setAttribute("aria-selected",!1),e.columnElement.classList.add("smart-hidden"),e.columnElement.column.selected=!1,l.classList.add("selected"),l.setAttribute("aria-selected",!0),l.columnElement.classList.remove("smart-hidden"),l.columnElement.column.selected=!0,t._selectedTabs=t._allColumns.filter((e=>e.selected)).map((e=>e.dataField)),t._autoSaveState("tabs"),void t._allColumns.forEach((e=>t._refreshScrollViewer(e)))}if(t.addNewColumn){const e=a.closest(".smart-kanban-add-new-column"),s=a.closest(".smart-color-input"),l=a.closest(".smart-kanban-column-header");if(!s&&e&&!e.querySelector(".pending")&&l)return void t._addNewColumnDynamically()}const o=a.closest(".smart-kanban-list .item");if(o){const e=o.getAttribute("data-id"),a=t._userSelectionFor,s=t._prioritySelectionFor;if(a){const s=t.dataSourceMap,l=a.data[s.userId],o=JSON.parse(JSON.stringify(a.data));if(a.data[s.userId]=e,t._updateUserIcon(a),t._closeList(t._userList,"_userSelectionFor"),a.data[s.userId]!==l){t.dataSource&&t.dataSource.virtualDataSource&&t._requestVirtualDataSource("update",a.data,(function(e){return e||(a.data[s.userId]=l,t._updateUserIcon(a)),e}));const e=a.data;if(t._currentUser.info){a.data[s.updatedUserId]=t._currentUser.info.id,a.data[s.updatedDate]=new Date;const l={user:t._currentUser.info.id,label:e[s.text],date:e[s.updatedDate]};e[s.userId]!==o[s.userId]&&(l.action="user",l.details={oldValue:o[s.userId],value:e[s.userId]},t.addHistory(e,l))}const i=JSON.parse(JSON.stringify(e));t.$.fireEvent("change",{task:a,id:i.id,value:i,oldValue:o}),t.$.fireEvent("taskUpdate",{id:i.id,value:i,oldValue:o}),t._autoSaveState("dataSource")}return}if(s){const e=t.dataSourceMap,a=s.data[e.priority],l=JSON.parse(JSON.stringify(s.data));if(s.data[e.priority]=o.getAttribute("priority"),t._closeList(t._priorityList,"_prioritySelectionFor"),s.data[e.priority]!==a){t._currentUser.info&&(s.data[e.updatedUserId]=t._currentUser.info.id,s.data[e.updatedDate]=new Date);const a=s.data,o=JSON.parse(JSON.stringify(a));if(t._currentUser.info){s.data[e.updatedUserId]=t._currentUser.info.id,s.data[e.updatedDate]=new Date;const o={user:t._currentUser.info.id,date:a[e.updatedDate]};a[e.priority]!==l[e.priority]&&(o.action="priority",o.details={oldValue:l[e.priority],value:a[e.priority]},t.addHistory(a,o))}t.$.fireEvent("change",{task:s,id:o.id,value:o,oldValue:l}),t.$.fireEvent("taskUpdate",{id:o.id,value:o,oldValue:l}),t._updateTaskPriority(s),t._autoSaveState("dataSource")}}const l=t._actionSelectionFor,i=t._columnActionSelectionFor;if(l){switch(parseFloat(e)){case 0:o.hasAttribute("edit")&&(t._actionsList.classList.contains("edit-comment")?(t._commentsList.textarea.value=l.comment.text,t._commentsList.textarea.focus(),t._commentsList.editing=l,l.parentElement.scrollTop=l.offsetTop):t.beginEdit(l));break;case 1:o.hasAttribute("copy")&&t.copyTask(l);break;case 2:o.hasAttribute("remove")&&(t._actionsList.classList.contains("edit-comment")?t._openDialog(l,"prompt","comment"):t.removeTask(l,!0))}return void t._closeList(t._actionsList,"_actionSelectionFor")}if(i){switch(parseFloat(e)){case 0:t._handleColumnEditing(i.dataField);break;case 1:t._openDialog(i,"add","column");break;case 2:t.collapse(i);break;case 3:t._openDialog(i,"prompt","column");break;case 4:t.hide(i);break;case 5:t.showAllColumns()}return void t._closeList(t._columnActionsList,"columnActionSelectionFor")}}if(a.closest(".smart-kanban-list.comments")){const e=a.closest(".send");if(e){if(e.disabled)return;const a=JSON.parse(JSON.stringify(t._commentSelectionFor.data)),s=t._createComment();t._commentsList.textarea.value="",e.disabled=!0;const l=JSON.parse(JSON.stringify(t._commentSelectionFor.data));t.$.fireEvent("change",{task:t._commentSelectionFor,id:l.id,value:l,oldValue:a}),t.$.fireEvent("taskUpdate",{id:l.id,value:l,oldValue:a}),t.$.fireEvent("commentAdd",{id:l.id,value:s})}else if(a.classList.contains("remove-button")&&a.classList.contains("enabled")){const e=a.closest(".smart-comment");t._actionSelectionFor&&(t._actionSelectionFor===e||t._actionSelectionFor.classList.contains("smart-kanban-task")||t._actionsList.parentElement&&!t._actionsList.classList.contains("smart-visibility-hidden"))||t._openActionsList(a,void 0,e)}return}const i=a.closest(".smart-kanban-task");if(i)if(a.classList.contains("smart-kanban-task-user"))!t.userList||!t._currentUser.allowEdit||t._userSelectionFor&&(t._userSelectionFor===i||t._userList.parentElement&&!t._userList.classList.contains("smart-visibility-hidden"))||t._openUserList(a,i);else if(a.classList.contains("priority")&&t.priorityList)!t._priorityList||!t._currentUser.allowEdit||t._prioritySelectionFor&&(t._prioritySelectionFor===i||t._priorityList.parentElement&&!t._priorityList.classList.contains("smart-visibility-hidden"))||t._openPriorityList(a,i);else if(t.taskActions&&a.classList.contains("smart-kanban-task-actions"))t._actionSelectionFor&&(t._actionSelectionFor===i||t._actionSelectionFor.classList.contains("comment")||t._actionsList.parentElement&&!t._actionsList.classList.contains("smart-visibility-hidden"))||t._openActionsList(a,i);else if(t.taskComments&&a.classList.contains("smart-kanban-task-comments"))t.users.length>0&&(!t._commentSelectionFor||t._commentSelectionFor!==i&&(!t._commentsList.parentElement||t._commentsList.classList.contains("smart-visibility-hidden")))&&t._openCommentsList(a,i);else if(t.$.fireEvent("taskClick",{id:i.data.id,value:i.data,element:i}),t._preventSelection||t._selectTask(e,i),e.type)if(clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks){if(t._dblclickObject.numberOfClicks=0,i.hasAttribute("selected")||t._selectTask(e,i),t.$.fireEvent("taskDoubleClick",{id:i.data.id,value:i.data,element:i}).defaultPrevented)return;t.beginEdit(i)}else t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300)}_selectTask(e,t){const a=this,s=a.selectionMode,l=()=>{a._selectedTasks.forEach((e=>{if(e!==t.data.id){const t=a.querySelector('[data-id="'+e+'"]');t&&t.removeAttribute("selected")}}))};function o(){l(),t.hasAttribute("selected")||(t.setAttribute("selected",""),a._selectedTasks=[t.data.id]),a._selectionStart=t.data.id,a._selectionInView=t.closest("smart-scroll-viewer"),a._autoSaveState("selection"),a._focusTask(t)}if("zeroOrOne"===s)l(),t.hasAttribute("selected")?(a._focusTask(t),t.removeAttribute("selected"),a._selectedTasks=[],delete a._selectionInView):(t.setAttribute("selected",""),a._selectedTasks=[t.data.id],a._selectionStart=t.data.id,a._selectionInView=t.closest("smart-scroll-viewer"),a._focusTask(t)),a.virtualization&&a._refreshColumns();else{if(!e.ctrlKey&&!e.shiftKey&&!e.metaKey||0===a._selectedTasks.length||t.closest("smart-scroll-viewer")!==a._selectionInView)return void o();if(e.ctrlKey||e.metaKey)t.hasAttribute("selected")?(t.removeAttribute("selected"),a._selectedTasks=a._selectedTasks.filter((e=>e!==t.data.id))):(t.setAttribute("selected",""),a._selectedTasks.push(t.data.id),a._selectionStart=t.data.id);else if(e.shiftKey){if(t&&t.id===a._selectionStart)return a._selectedTasks.length>1&&o(),void(a.virtualization&&a._refreshColumns());const e=t[a.dataSourceMap.status],s=a._getTasksByDataField(e),l=a.getTask(a._selectionStart);let i=s.indexOf(l),r=s.indexOf(t.id);const n=i;i=Math.min(i,r),r=Math.max(n,r),a._selectedTasks=[],s.forEach(((e,t)=>{const s=a.querySelector('[data-id="'+e.id+'"]');t>=i&&t<=r&&!e.filteredOut?(s&&s.setAttribute("selected",""),a._selectedTasks.push(e.id)):s&&s.removeAttribute("selected")}))}a._focusTask(t)}a.virtualization&&a._refreshColumns(),a._autoSaveState("selection")}_processDataSource(){const e=this;let t=e.dataSource;if(0!==e.columns.length&&null!=t){if(t instanceof Smart.DataAdapter){if(t.virtualDataSource)return void e._requestVirtualDataSource("dataBind");t=t.dataSource}t.length>500&&(e.virtualization=!0),t.forEach((t=>{e._createTask(t)})),e.virtualization&&(e._measureCardHeight(),e._refreshColumns()),e.whenRendered((()=>e._allColumns.forEach((t=>e._refreshScrollViewer(t)))))}}_requestVirtualDataSource(e,t,a){const s=this,l=s.dataSourceMap,o=[],i=[],r={},n=s._appliedFiltering;let d=null;if(n&&n.filterGroups.length>0&&(n.filterGroups.forEach((e=>i[e[0]]=e[1])),i.length=n.filterGroups.length,d=n.operator),s._appliedSorting&&s._appliedSorting.dataFields.length>0&&(s._appliedSorting.dataFields.forEach(((e,t)=>{let a=s._appliedSorting.orderBy[t].replace("ending","");o[e]={sortOrder:a,sortIndex:t}})),o.length=s._appliedSorting.dataFields.length),void 0!==t){const e=Object.assign({},t);e[l.checklist]=JSON.stringify(e[l.checklist]),e[l.history]=JSON.stringify(e[l.history],(function(e,t){return"date"===e?new Date(t).toISOString().slice(0,19).replace("T"," "):t})),e[l.comments]=JSON.stringify(e[l.comments],(function(e,t){return"time"===e?new Date(t).toISOString().slice(0,19).replace("T"," "):t})),e[l.updatedDate]&&(e[l.updatedDate]=e[l.updatedDate].toISOString().slice(0,10)),e[l.createdDate]&&(e[l.createdDate]=e[l.createdDate].toISOString().slice(0,10)),e[l.dueDate]&&(e[l.dueDate]=e[l.dueDate].toISOString().slice(0,10)),e[l.startDate]&&(e[l.startDate]=e[l.startDate].toISOString().slice(0,10)),r.row=e}s.dataSource.onVirtualDataSourceRequested((function(t){let l=!0;-1!==["add","update","remove"].indexOf(e)&&a&&(l=a(t.result),"add"!==e)||l&&(Array.from(s.$.container.querySelectorAll("smart-scroll-viewer.smart-kanban-column-content-tasks")).forEach((e=>e.clearContent())),s.dataSource.dataSource.forEach((e=>{s._createTask(e)})),s._allColumns.forEach((e=>s._refreshScrollViewer(e))),s._autoSaveState("dataSource"))}),{first:0,last:0,sorting:o,filtering:i,filterOperator:d,grouping:[],edit:r,action:e})}_setUserList(){const e=this,t=document.createElement("div");t.id=e.id+"UserList",t.className="smart-kanban-list users smart-visibility-hidden",t.setAttribute("role","listbox"),e.disabled||e.unfocusable||(t.tabIndex=0),e.users.forEach((e=>{const a=document.createElement("div"),s=e?e.image:null,l=s?`background-image: url('${s}');`:"";a.className="item",a.innerHTML=`<div class="icon" style="${l}"></div><div class="name">${e.name}</div>`,a.setAttribute("data-id",e.id),a.setAttribute("role","option"),t.appendChild(a)})),e._userList=t}_setPriorityList(){const e=this,t=document.createElement("div");t.id=e.id+"PriorityList",t.className="smart-kanban-list priority smart-visibility-hidden",t.setAttribute("role","listbox"),e.disabled||e.unfocusable||(t.tabIndex=0),e._getPriority().forEach((e=>{const a=document.createElement("div");a.className="item",e.menuLabel?a.innerHTML=e.menuLabel:a.innerHTML=`<div priority="${e.value}" class="smart-kanban-task-text">${e.menuIcon}${e.label}</div>`,a.setAttribute("priority",e.value),a.setAttribute("role","option"),t.appendChild(a)})),e._priorityList=t;const a=e._dialog;a&&a.editPanelPopulated&&(a.editors.priority.dataSource=e._getPriority())}_openList(e,t,a){const s=this,l=e.getBoundingClientRect();let o,i,r=l.left,n=l.top+e.offsetHeight;a=s.rightToLeft?!a:a,1===window.devicePixelRatio?(o=document.documentElement.clientWidth,i=document.documentElement.clientHeight):(o=window.innerWidth,i=window.innerHeight),t.classList.add("dialog"),document.body.appendChild(t),a&&(r=l.right-t.offsetWidth),r+t.offsetWidth>o&&(r=o-t.offsetWidth),n+t.offsetHeight>i&&(n=i-t.offsetHeight),t.style.left=Math.max(0,r)+"px",t.style.top=n+"px",t.classList.remove("smart-visibility-hidden"),e.setAttribute("aria-expanded",!0),e.setAttribute("aria-controls",t.id),s.unfocusable||requestAnimationFrame((function e(){0===t.getBoundingClientRect().height?requestAnimationFrame(e):t.focus()})),t.openedFrom=e,t.onclick=e=>{s._containerClickHandler(e)}}_openUserList(e,t){const a=this;if(0===a.users.length)return;const s=t.data[a.dataSourceMap.userId],l=a._userList,o=l.querySelector(".selected");if(o&&(o.classList.remove("selected"),o.removeAttribute("aria-selected")),a._openList(e,l),null!==s){const e=Array.from(l.children).find((e=>e.getAttribute("data-id")===s.toString()));e&&(e.classList.add("selected"),e.setAttribute("aria-selected",!0),l.scrollTop=e.offsetTop)}a._userSelectionFor=t}_openPriorityList(e,t){const a=this,s=t.data[a.dataSourceMap.priority],l=a._priorityList,o=l.querySelector(".selected");if(o&&(o.classList.remove("selected"),o.removeAttribute("aria-selected")),a._openList(e,l),null!=s){const e=Array.from(l.children).find((e=>e.getAttribute("priority")===s.toString()));e&&(e.classList.add("selected"),e.setAttribute("aria-selected",!0),l.scrollTop=e.offsetTop)}a._prioritySelectionFor=t}_closeList(e,t){const a=this;if(!e||!e.parentElement)return;const s=a.$.container.querySelector(`[aria-expanded="true"][aria-controls="${e.id}"]`);e.classList.add("smart-visibility-hidden"),requestAnimationFrame((function s(){e.classList.contains("smart-visibility-hidden")&&(e.getBoundingClientRect().height>0?requestAnimationFrame(s):(e.remove(),delete e.openedFrom,delete a[t]))})),s&&(s.removeAttribute("aria-expanded"),s.removeAttribute("aria-controls"))}_setActionsList(){const e=this,t=document.createElement("div");if(t.id=e.id+"ActionsList",t.className="smart-kanban-list actions smart-visibility-hidden",t.setAttribute("role","menu"),e.disabled||e.unfocusable||(t.tabIndex=0),t.innerHTML=`<div class="item" edit data-id="0" role="menuitem"><div class="name">${e.localize("edit")}</div></div>\n<div class="item" copy data-id="1" role="menuitem"><div class="name">${e.localize("copy")}</div></div>\n<div class="item" remove data-id="2" role="menuitem"><div class="name">${e.localize("remove")}</div></div>`,e.taskActionsRendered){e.taskActionsRendered(t);const a=Array.from(t.children);for(let e=0;e<a.length;e++){const t=a[e];t.classList.add("item"),t.setAttribute("data-id",e),t.setAttribute("role","menuitem"),t.firstElementChild&&t.firstElementChild.classList.add("name")}}e._actionsList=t}_setColumnActionsList(){const e=this,t=document.createElement("div");t.id=e.id+"ColumnActionsList",t.className="smart-kanban-list actions smart-visibility-hidden",t.setAttribute("role","menu"),e.disabled||e.unfocusable||(t.tabIndex=0),t.innerHTML=`<div class="item" data-id="0" role="menuitem"><div class="name">${e.localize("edit")}</div></div>\n <div class="item" data-id="1" role="menuitem"><div class="name">${e.localize("addNewTask")}</div></div>\n <div class="item" data-id="2" role="menuitem"><div class="name">${e.localize("collapse")}</div></div>\n <div class="item" data-id="3" role="menuitem"><div class="name">${e.localize("removeColumn")}</div></div>\n <div class="item" data-id="4" role="menuitem"><div class="name">${e.localize("hideColumn")}</div></div>\n <div class="item" data-id="5" role="menuitem"><div class="name">${e.localize("showAllColumns")}</div></div>`,e._columnActionsList=t}_openActionsList(e,t,a){const s=this,l=s._currentUser,o=s._actionsList;s._openList(e,o,a),o.classList.toggle("edit-comment",!!a),s._actionSelectionFor=t||a,o.children[0]&&o.children[0].hasAttribute("edit")&&(t&&!l.allowEdit?o.children[0].classList.add("smart-hidden"):o.children[0].classList.remove("smart-hidden")),o.children[1]&&o.children[1].hasAttribute("add")&&(t&&!l.allowAdd?o.children[1].classList.add("smart-hidden"):o.children[1].classList.remove("smart-hidden")),o.children[2]&&o.children[0].hasAttribute("remove")&&(t&&!l.allowRemove?o.children[2].classList.add("smart-hidden"):o.children[2].classList.remove("smart-hidden")),Array.from(o.children).forEach((e=>e.classList.remove("selected")))}_openColumnActionsList(e,t){const a=this,s=a._columnActionsList,l=s.children;a.allowColumnEdit&&t.editable&&"header"!==a.columnEditMode?l[0].classList.remove("smart-hidden"):l[0].classList.add("smart-hidden"),a.addNewButton&&t.addNewButton?l[1].classList.remove("smart-hidden"):l[1].classList.add("smart-hidden"),a.allowColumnRemove&&t.allowRemove&&a._allColumns.length>1?l[3].classList.remove("smart-hidden"):l[3].classList.add("smart-hidden"),a.collapsible&&t.collapsible?l[2].classList.remove("smart-hidden"):l[2].classList.add("smart-hidden"),a.allowColumnHide&&t.allowHide&&a._allColumns.length>1?(l[4].classList.remove("smart-hidden"),l[5].classList.remove("smart-hidden")):(l[4].classList.add("smart-hidden"),l[5].classList.add("smart-hidden")),a._openList(e,s),a._columnActionSelectionFor=t,Array.from(s.children).forEach((e=>e.classList.remove("selected")))}_setCommentsList(){const e=this,t=document.createElement("div");t.id=e.id+"CommentsList",t.className="smart-kanban-list comments smart-visibility-hidden",t.setAttribute("role","dialog"),e.disabled||e.unfocusable||(t.tabIndex=0),t.innerHTML=`<div class="smart-kanban-comments" role="list"></div>\n<div class="smart-kanban-new-comment" role="presentation">\n <textarea placeholder="${e.localize("newComment")}"></textarea>\n <smart-button class="send primary" disabled${e._rtlAttr}>${e.localize("send")}</smart-button>\n</div>`;const a=t.querySelector("textarea"),s=t.querySelector("smart-button");s.tabIndex=0,a.onfocus=()=>{t.classList.add("expanded"),s.disabled=""===a.value},a.onblur=e=>{s.contains(e.relatedTarget)||t.classList.remove("expanded")},a.onkeyup=()=>{s.disabled=""===a.value},a.oncut=()=>{s.disabled=""===a.value},a.onpaste=()=>{s.disabled=""===a.value},t.textarea=a,t.button=s,e._commentsList=t}_openCommentsList(e,t){const a=this,s=a._commentsList;s.classList.remove("expanded"),s.firstElementChild.innerHTML="",s.textarea.value="",s.textarea.disabled=!a._currentUser.allowComment,a.unfocusable?s.textarea.tabIndex=-1:s.textarea.removeAttribute("tabindex"),delete s.editing,t.data[a.dataSourceMap.comments].forEach((e=>a._createComment(e))),a._openList(e,s),a._commentSelectionFor=t}_getCommentsList(e){const t=this,a=t._commentsList;return a.classList.remove("expanded"),a.firstElementChild.innerHTML="",a.textarea.value="",a.textarea.disabled=!t._currentUser.allowComment,t.unfocusable?a.textarea.tabIndex=-1:a.textarea.removeAttribute("tabindex"),delete a.editing,e.data[t.dataSourceMap.comments].forEach((e=>t._createComment(e))),t._commentSelectionFor=e,a.classList.remove("smart-visibility-hidden"),a}_createComment(e){const t=this,a=document.createElement("div");let s,l;function o(){const o=t._commentsList.firstElementChild,i=l?l.image:null,r=l?l.name||l.id:t.localize("guestUser"),n=l?l.name:t.localize("guestUser");a.classList="smart-comment",a.setAttribute("role","listitem");const d=i?`background-image: url('${i}');`:"";a.innerHTML=`<div class="comment-indent" role="presentation">\n <div class="user-icon" style="${d}" role="img" aria-label="Icon of user ${r}"></div>\n</div>\n<div class="comment-main" role="presentation">\n <div class="comment-header" role="presentation">\n <div class="user-name" aria-label="User name">${n}</div>\n <div class="time" aria-label="Comment time">${e.time?new Smart.Utilities.DateTime(e.time).toString(t.formatStringTime):""}</div>\n <div class="remove-button${t._currentUser.info&&l.id===t._currentUser.info.id&&t._currentUser.allowComment?" enabled":""}"${t._tabindex} role="button" aria-haspopup="menu" aria-label="Comment settings"></div>\n </div>\n <div class="comment-body" aria-label="Comment text">${e.text||""}</div >\n</div>`,a.comment=e,i||a.querySelector(".user-icon").classList.add("empty"),o.appendChild(a),s&&(o.scrollTop=o.scrollHeight-o.offsetHeight)}if(e)l=t.users.find((t=>t.id===e.userId));else{const a=t.dataSourceMap,i=t.dataSource&&t.dataSource.virtualDataSource,r=t._commentsList.textarea.value,n=t._commentsList.editing,d=t._commentSelectionFor.data,c=JSON.parse(JSON.stringify(d));if(n){if(i){const e=Object.assign({},d);e[a.comments]=e[a.comments].slice(0),e[a.comments][e[a.comments].indexOf(n.comment)]=Object.assign({},n.comment,{text:r}),t._requestVirtualDataSource("update",e,(function(a){return a&&(t._commentSelectionFor.data=e,n.querySelector(".comment-body").innerHTML=r),delete t._commentsList.editing,a}))}else n.querySelector(".comment-body").innerHTML=r,n.comment.text=r,delete t._commentsList.editing;return t.$.fireEvent("commentUpdate",{id:d.id,value:n.comment}),t.$.fireEvent("taskUpdate",{id:d.id,value:d,oldValue:c}),void t.$.fireEvent("change",{task:t._commentSelectionFor,id:d.id,value:d,oldValue:c})}if(s=!0,e={text:r,id:function(){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()}(),userId:t._currentUser.info?t._currentUser.info.id:-1,time:new Date},l=t._currentUser.info,i){const s=Object.assign({},d);s[a.comments]=s[a.comments].slice(0),s[a.comments].push(e),t._requestVirtualDataSource("update",s,(function(e){return e&&(t._commentSelectionFor.data=s,t._commentSelectionFor.querySelector(".smart-kanban-task-comments").setAttribute("num",s[a.comments].length||""),o()),e}))}else d[a.comments].push(e),t._commentSelectionFor.querySelector(".smart-kanban-task-comments").setAttribute("num",d[a.comments].length||"")}return e.time instanceof Date==0&&(e.time=new Date(e.time),e.time.setTime(e.time.getTime()-1*e.time.getTimezoneOffset()*60*1e3)),o(),e}_getTaskIndexByPosition(e,t){const a=(e,t)=>{const a=e.top,s=e.top+e.height,l=a<=t&&s>t;return 0!==e.height&&l};return(t=>{let s=0,l=t.length-1;if(e<=0)return 0;const o=t[t.length-1];if(-1!==o.top&&o.top<=e)return t.length-1;for(;;){const o=Math.floor((s+l)/2),i=t[o];if(a(i,e))return o;i.top<e?s=o+1:i.top>e?l=o-1:s=o+1}})(t)}_refreshColumns(){const e=this;e.virtualization&&e._allColumns.forEach((t=>{e._refreshColumn(t.dataField)}))}_refreshColumn(e){const t=this.getColumn(e),a=this._columnToElement.get(t);if(!a)return;const s=a.querySelector("smart-scroll-viewer");this._refreshScrollHeight(s,e)}_getTasksByDataField(e){const t=this;let a=t.tasksByDataField[e];return a?a._filtered?a._filtered:a._sorted?a._sorted:a:(t.tasksByDataField[e]=[],t.tasksByDataField[e])}_refreshEmptyColumnState(e,t){const a=this;e&&(e.querySelector(".smart-kanban-task")||e.querySelector(".smart-kanban-task")&&!t?(e.removeAttribute("empty",a.localize("empty")),e.classList.remove("empty")):(e.setAttribute("empty",a.localize("empty")),e.classList.add("empty")))}_refreshScrollHeight(e,t){const a=this;if(a._refreshEmptyColumnState(e,t),!a.virtualization)return;const s=a._getTasksByDataField(t);if(!s)return;const l=a._autoCardHeight?a._autoCardHeight:a.cardHeight;e.scrollHeight=e.virtualScrollHeight=s.length*l-e.offsetHeight;for(let e=0;e<s.length;e++){const t=s[e];t.top=e*l,t.height=l}const o=e.querySelector(".smart-scroll-viewer-content-container"),i=e=>{const l=a._getTaskIndexByPosition(e,s),i=a.uiTasksByDataField[t].length;for(let e=0;e<i;e++){const i=s[l+e],r=a.uiTasksByDataField[t][e];r&&(a._dragDetails&&(r.classList.remove("dragged"),i&&a._dragDetails.ItemsData.forEach((e=>{e.id===i.id&&r.classList.add("dragged")}))),i?r.classList.remove("smart-hidden"):r.classList.add("smart-hidden"),0===e&&(o.style.marginTop=i?i.top+"px":"0px"),i)&&(r.hasAttribute("selected")&&r.removeAttribute("selected"),r.hasAttribute("focus")&&r.removeAttribute("focus"),JSON.stringify(i)!==JSON.stringify(r.data)&&(r.data=i,a._renderTask(r)),a._selectedTasks&&a._selectedTasks.indexOf(i.id)>=0&&r.setAttribute("selected",""),a._focusedTask===i.id&&r.setAttribute("focus",""))}};e.onVerticalChange=e=>{const t=e.detail.value;i(t)},a.uiTasksByDataField[t]||(a.uiTasksByDataField[t]=[]);const r=Math.round(e.offsetHeight/l)+2,n=a.uiTasksByDataField[t].length;if(0===n||n<r){const o=Math.round(e.offsetHeight/l)+2;for(let e=0;e<o;e++){const l=s[e];if(!l)continue;const o=a._createVirtualTask(l);a.uiTasksByDataField[t].push(o)}e.refresh(),e.scrollHeight=e.virtualScrollHeight=s.length*l-e.offsetHeight,i(e.scrollTop)}else i(e.scrollTop)}_createVirtualTask(e,t){const a=this,s=a.dataSourceMap,l=a._allColumns.find((t=>t.dataField===e[s.status]));if(!l)return;const o=document.createElement("div"),i=a._columnToElement.get(l),r=a.getTaskScrollViewer(i,e);return void 0===e[s.id]&&(e[s.id]=Math.floor(9e4*Math.random()+1e4)),o.className="smart-kanban-task smart-unselectable",o.setAttribute("role","listitem"),o.setAttribute("data-id",e[s.id]),a._currentUser.info&&(void 0===e[s.createdUserId]?(e[s.createdUserId]=a._currentUser.info.id,e[s.createdDate]=new Date):e[s.createdDate]||(e[s.createdDate]=new Date),e[s.history]=[],a.addHistory(e,{action:"created",user:a._currentUser.info.id,details:{value:e[s.text]},date:e[s.createdDate]})),o.data=e,o.column=l,a._renderTask(o),e.class&&"string"==typeof e.class&&o.classList.add(e.class),r.appendChild(o),a._updateTaskColor(o),t&&(l.collapsed?r.toRefresh=!0:r.refresh()),o}_measureCardHeight(){const e=this,t=Object.keys(e.tasksByDataField);if(0===t.length||0===e.columns.length)return null;if(null===e.cardHeight&&!e._autoCardHeight){const a=e.tasksByDataField[t[0]],s=e._createVirtualTask(a[0]);e._renderTask(s),a.class&&"string"==typeof a.class&&s.classList.add(a.class);const l=e.columns[0],o=e._columnToElement.get(l),i=e.getTaskScrollViewer(o,a);i.appendChild(s);const r=i.querySelector(".smart-scroll-viewer-content-container"),n=getComputedStyle(r).rowGap;e._autoCardHeight=s.offsetHeight+parseInt(n),s.remove()}}_createTask(e,t){const a=this,s=a.dataSourceMap,l=a._allColumns.find((t=>t.dataField===e[s.status]));if(!l)return;const o=document.createElement("div"),i=a._columnToElement.get(l),r=a.getTaskScrollViewer(i,e);void 0===e[s.id]&&(e[s.id]=Math.floor(9e4*Math.random()+1e4)),o.className="smart-kanban-task smart-unselectable",o.setAttribute("role","listitem"),o.setAttribute("data-id",e[s.id]),a._currentUser&&a._currentUser.info&&(void 0===e[s.createdUserId]?(e[s.createdUserId]=a._currentUser.info.id,e[s.createdDate]=new Date):e[s.createdDate]||(e[s.createdDate]=new Date),e[s.history]||(e[s.history]=[],a.addHistory(e,{action:"created",user:a._currentUser.info.id,details:{value:e[s.text]},date:e[s.createdDate]}))),o.data=e,o.column=l,a.tasksByDataField[l.dataField]||(a.tasksByDataField[l.dataField]=[]),a.tasksByDataField[l.dataField].push(e),a.taskById[e.id]=e,a.virtualization||(a._renderTask(o),e.class&&"string"==typeof e.class&&o.classList.add(e.class),r.appendChild(o),a._updateTaskColor(o),t&&(l.collapsed?r.toRefresh=!0:r.refresh()))}getTaskScrollViewer(e,t){const a=this,s=a.dataSourceMap;let l;return a._hasSwimlane(e.index)?void 0!==t[s.swimlane]&&a.swimlanes.find((e=>e.dataField===t[s.swimlane]))?l=e.querySelector(`smart-scroll-viewer[swimlane="${t[s.swimlane]}"]`):(l=e.querySelector("smart-scroll-viewer"),t[s.swimlane]=l.getAttribute("swimlane")):(l=e.querySelector("smart-scroll-viewer"),delete t[s.swimlane]),l}_renderTask(e){const t=this;t._applyTaskTemplate(e),t._updateUserIcon(e),t._updateTaskChecked(e),t._updateTaskProgress(e),t._updateTaskDueDate(e),e.parentElement&&t._updateTaskColor(e),t._updateTaskPriority(e),e.column&&t.columnSummary&&t._updateColumnSummary(e.column),t.onTaskRender&&t.onTaskRender(e,e.data)}_refreshSummaries(){const e=this,t=e.querySelectorAll(".smart-kanban-column");for(let a=0;a<t.length;a++){const s=t[a].column;e._updateColumnSummary(s)}}_updateColumnSummary(e){const t=this,a=t._columnToElement.get(e);if(!a||!t.columnSummary)return;const s=t._getColumnSummary(e),l=a.querySelector(".summary");if(l&&(l.innerHTML=s),t.columnFooter){const l=a.querySelector(".smart-kanban-column-footer");if(s.length){let e=parseInt(s.replace("(","").replace(")","").trim());l.innerHTML=1===e?t.localize("tasksSummaryOne"):t.localize("tasksSummary",{summary:e})}else l.innerHTML="";t.onColumnFooterRender&&t.onColumnFooterRender(l,e,e.dataField)}}_createImageModal(e,t){const a=this,s=document.createElement("smart-window");s.animation=a.animation,s.headerButtons=["close"],s.rightToLeft=a.rightToLeft,s.resizeMode="none",s.theme=a.theme,s.style.height="auto",s.style.width="auto",s.style.maxWidth="1200px",s.style.maxHeight="1200px",document.body.appendChild(s),s.onclose=()=>{document.body.removeChild(s)},s.innerHTML="",s.label=e.title;const l=e.cloneNode(!0);l.removeAttribute("onpointerdown"),l.removeAttribute("width"),l.removeAttribute("height"),l.style.maxWidth="1000px",l.style.maxHeight="1000px",s.appendChild(l),s.open(),t.stopPropagation(),t.preventDefault()}_applyTagsContent(e,t,a){const s=this,l=s.tags,o=s.dataSourceMap;let i="";if(e&&e.indexOf&&e.indexOf("{")>=0&&(e=JSON.parse(e)),e&&"string"==typeof e){e=e.split(",");for(let t=0;t<e.length;t++)e[t]=e[t].trim();l.length>0?(e=e.filter((e=>{if(-1!==l.indexOf(e))return!0})),t[o.tags]=e.join(", ")):s.allowCustomTags?e.forEach((e=>{-1===s._customTags.indexOf(e)&&"[objectObject]"!==e&&s._customTags.push(e)})):e=[],i=e.map((e=>`<span class="smart-kanban-task-tag" role="listitem">${e}</span>`)).join("")}else e&&"object"==typeof e?(Array.isArray(e)||(e=[e],t[o.tags]=e),l.length>0?(e=e.filter((e=>{if(-1!==l.indexOf(e))return!0;if(e.value){let t=!1;if(l.find((a=>{a===e.value&&(t=!0),a.value===e.value&&(t=!0)})),t)return!0}})),t[o.tags]=e):s.allowCustomTags?e.forEach((e=>{-1===s._customTags.indexOf(e)&&"[objectObject]"!==e&&s._customTags.push(e)})):e=[],i=e.map((e=>{if(e.color){const t=e.color||"rgba(var(--smart-primary-rgb), 0.15)",a=document.createElement("div");document.body.appendChild(a),a.style.backgroundColor=t;const s=getComputedStyle(a).backgroundColor;return a.remove(),`<span style="color: ${new Smart.Color(s).getInvertedColor()}; background: ${t} " class="smart-kanban-task-tag" role="listitem">${e.label}</span>`}return`<span class="smart-kanban-task-tag" role="listitem">${"string"==typeof e?e:e.label}</span>`})).join("")):t[o.tags]="";return i}_applyTaskTemplate(e){const t=this,a=t.dataSourceMap,s=(t.tags,e.data),l=t._tabindex;let o=s[a.text],i=s[a.description],r=s[a.tags],n="",d=o;void 0===o&&(o="",s[a.text]="",d=o),void 0===i&&(i="",s[a.description]=""),o=t._applyTextTemplate(o,s,e),n=t._applyTagsContent(r,s,e),"string"==typeof s[a.priority]&&(s[a.priority]=s[a.priority].toLowerCase());const c=t._getPriority();let u=c.findIndex((e=>e.value===s[a.priority]));const m=c.length>0&&u>=0?c[u]:null;s[a.comments]&&Array.isArray(s[a.comments])||(s[a.comments]=[]);const p=t.localize(s[a.priority])+" "+t.localize("priority");let h=d?`${d}: ${p}`:`${p}`;t.taskPriority||(h=d);let g=`<div class="smart-kanban-task-cover"></div><div title="${h}" class="smart-kanban-task-content" role="presentation">\n <div class="smart-kanban-task-text">${o}`;g+=m?`${m.menuIcon}`:'<span style="margin-left: 0px; margin-right: 5px;" class="priority"></span>',g+=`</div>\n <div class="smart-kanban-task-user"${l} role="button" aria-haspopup="listbox"></div>\n</div>\n<div class="smart-kanban-task-info" role="presentation">\n <div class="smart-kanban-task-progress-container">\n <div class="smart-kanban-task-progress" role="progressbar" aria-label="Task progress" aria-valuemin="0" aria-valuemax="100"></div>\n <div class="smart-kanban-task-checked" aria-label="Completed sub-tasks"></div>\n </div>\n <div class="smart-kanban-task-due" aria-label="Task due date"></div>\n</div>\n<div class="smart-kanban-task-fields"></div>\n<div class="smart-hidden smart-kanban-task-subtasks">\n <div class="smart-kanban-task-subtasks-container"></div>\n <div><input class="smart-kanban-task-input smart-input" placeholder="${t.localize("newSubtask")}"/></div>\n</div>\n<div class="smart-hidden smart-kanban-task-custom-fields"></div>\n<div class="smart-kanban-task-footer" role="toolbar" aria-label="Task footer">\n <div class="smart-kanban-task-tags" role="list" aria-label="Tags list">${n}</div>\n <div class="smart-kanban-task-edit smart-hidden"${l} title="${t.localize("edit")}" role="button" aria-label="Edit"></div>\n <div title="${t.localize("actionsList")}" class="smart-kanban-task-actions"${l} role="button" aria-haspopup="menu" aria-label="Open actions list"></div>\n <div class="smart-kanban-task-comments"${l} num="${s[a.comments].length||""}" role="button" aria-haspopup="dialog" aria-label="Open comments list"></div>\n <div class="smart-kanban-task-description smart-hidden"${l} title="${t.localize("taskDescription",{value:s[a.description]})}" num="${s[a.description].length||""}" role="button" aria-label="Show description"></div>\n</div>`,e.innerHTML=g,e.setAttribute("aria-label",s[a.text]);const f=e.querySelector(".smart-kanban-task-description");s[a.description]?f.classList.remove("smart-hidden"):f.classList.add("smart-hidden");const b=e.querySelector(".smart-kanban-task-edit");t.editable?b.classList.remove("smart-hidden"):b.classList.add("smart-hidden"),b.onpointerdown=a=>{t.beginEdit(e),a.preventDefault(),a.stopPropagation()},t._updateTaskCustomFields(e),t._updateTaskSubtasks(e)}_updateTaskCustomFields(e){const t=this,a=e.data;if(t.taskCustomFieldsHide){const t=e.querySelector(".smart-kanban-task-custom-fields");t&&t.classList.remove("smart-hidden")}else if(t.taskCustomFields.length>0&&!t.taskCustomFieldsHide){const s=e.querySelector(".smart-kanban-task-custom-fields");s.classList.remove("smart-hidden");for(let l=0;l<t.taskCustomFields.length;l++){const o=t.taskCustomFields[l];let i=a[o.dataField],r="";if(t.dataSourceMap[o.dataField])continue;if("password"===o.editor)continue;if(null==i||!1===o.visible){const t=e.querySelector("[data-field="+o.dataField+"]");t&&t.classList.add("smart-hidden");continue}if(void 0===o.visible&&(o.visible=!0),void 0===o.allowHide&&(o.allowHide=!0),"string"==typeof i&&(!o.dataSource||o.dataSource&&0===o.dataSource.length)){if(i.length>50)if(i.indexOf("base64")>=0){i=JSON.parse(i),window.Smart._createSmartImageModal=t._createImageModal;let e="";for(let t=0;t<i.length;t++){const a=i[t];e+=`<img style="margin-left: 5px;" onpointerdown="Smart._createSmartImageModal(this, event)" src="${a.value}" title="${a.label}"/>`}i=e}else if(o.image&&i.indexOf("http")>=0){if(window.Smart._createSmartImageModal=t._createImageModal,i.indexOf(",")>=0){let e="";i=i.split(",");for(let t=0;t<i.length;t++)e+=`<img style="margin-left: 5px;" onpointerdown="Smart._createSmartImageModal(this, event)" src="${i[t]}"/>`;i=e}else i=`<img style="margin-left: 5px;" onpointerdown="Smart._createSmartImageModal(this, event)" src="${i}"/>`;if(o.cover){const t=e.querySelector(".smart-kanban-task-cover");t.classList.add("smart-kanban-task-cover-content"),t.innerHTML=i}}else r=i,i=i.substring(0,50)+"..."}else if(o.image){if(i=`<img style="margin-left: 5px;" onpointerdown="Smart._createSmartImageModal(this, event)" src="${i}"/>`,o.cover){const t=e.querySelector(".smart-kanban-task-cover");t.classList.add("smart-kanban-task-cover-content"),t.innerHTML=i}}else if("dateInput"===o.editor)i=new Smart.Utilities.DateTime(i).toString(this.formatStringDate);else if(o.dataSource)if(i&&i.indexOf(",")>0&&(i=i.split(",")),void 0!==i&&Array.isArray(i)){let e=[];for(let t=0;t<i.length;t++){const a=o.dataSource.find((e=>{if(e.value===i[t])return e}));a&&e.push(a.label)}i=e.toString()}else{const e=o.dataSource.find((e=>{if(e.value===i)return e}));e&&e.label&&(i=e.label)}const n=e.querySelector("[data-field="+o.dataField+"]");if(n)n.innerHTML=`<div class="smart-kanban-task-field-label">${o.label}</div><div title="${r}" class="smart-kanban-task-field-value">${i}</div>`,n.classList.remove("smart-hidden");else{const e=document.createElement("div");e.classList.add("smart-kanban-task-field"),e.setAttribute("data-field",o.dataField),e.innerHTML=`<div class="smart-kanban-task-field-label">${o.label}</div><div title="${r}" class="smart-kanban-task-field-value">${i}</div>`,s.appendChild(e)}}}}_updateTaskSubtasks(e){const t=this;if("none"===t.taskSubTasks)return void e.querySelector(".smart-kanban-task-subtasks").classList.add("smart-hidden");const a=e.data,s=t.dataSourceMap,l=[],o=[];(a[s.checklist]||[]).forEach(((e,t)=>{e.completed&&l.push(t),o.push({label:e.text,selected:!0===e.completed})}));const i=e.querySelector(".smart-kanban-task-subtasks"),r=e.querySelector(".smart-kanban-task-subtasks-container");r.innerHTML="",i.classList.remove("smart-hidden");const n=e.querySelector(".smart-kanban-task-input");t._currentUser&&!t._currentUser.allowEdit||t.disabled||!t.taskSubTasksInput?n.classList.add("smart-hidden"):n.classList.remove("smart-hidden"),n.onchange=function(){a[s.checklist]||(a[s.checklist]=[]);const l=JSON.parse(JSON.stringify(a));a[s.checklist].push({text:n.value,completed:!1}),n.value="",t._updateTaskSubtasks(e);const o=JSON.parse(JSON.stringify(a));t.$.fireEvent("change",{task:e,id:o.id,value:o,oldValue:l}),t.$.fireEvent("taskUpdate",{id:o.id,value:o,oldValue:l})},o.length&&o.forEach(((l,i)=>{const n=document.createElement("div"),d=l.label;n.innerHTML=`<div data-index="${i}" class="smart-kanban-sub-task"><span title="${d}" class="smart-truncate label">${d}</span><span class="remove-subtask" aria-label="Remove subtask" title="${t.localize("removeSubtask")}"></span></div>`,l.selected&&n.firstChild.classList.add("selected"),"onlyUnfinished"===t.taskSubTasks&&l.selected&&n.classList.add("smart-hidden");let c=!0;(t._currentUser&&!t._currentUser.allowEdit||t.disabled)&&(c=!1),n.querySelector(".remove-subtask").style.opacity=c?1:0,n.onclick=l=>{let i=!0;if((t._currentUser&&!t._currentUser.allowEdit||t.disabled)&&(i=!1),!i)return;const r=JSON.parse(JSON.stringify(a)),d=parseInt(n.firstChild.getAttribute("data-index")),c=o[d];l.target.classList.contains("remove-subtask")?(o.splice(d,1),n.classList.add("smart-hidden"),a[s.checklist].splice(d,1)):(n.firstChild.classList.toggle("selected"),c.selected=!c.selected,a[s.checklist][d].completed=c.selected,"onlyUnfinished"===t.taskSubTasks&&c.selected&&n.classList.add("smart-hidden")),t._updateTaskChecked(e);const u=JSON.parse(JSON.stringify(a));t.$.fireEvent("change",{task:e,id:u.id,value:u,oldValue:r}),t.$.fireEvent("taskUpdate",{id:u.id,value:u,oldValue:r}),l.preventDefault(),l.stopPropagation()},r.appendChild(n)}))}_applyTextTemplate(e,t,a){const s=this;let l=this.textTemplate;if(!l)return e;let o="";if("function"==typeof l){const s={data:t,task:a,text:e,template:null};if(l(s),e=s.text,null===s.template)return e;l=s.template}if(l.startsWith("#")){const a=document.querySelector(l);if(a&&a instanceof HTMLTemplateElement){const l=a.content.cloneNode(!0),i=document.createElement("div");return i.appendChild(l),e=(e=(e=e.toString()).replace(/'/gi,"\\'")).replace(/"/gi,'\\"'),o=i.innerHTML.replace(/{{text}}/gi,e).replace(/{{id}}/gi,t[s.dataSourceMap.id]),o.indexOf("{{text=")>=0&&(e?(o=o.substring(0,o.indexOf("{{text="))+e+o.substring(o.indexOf("}")),o=o.replace(/}/gi,""),o=o.replace(/{/gi,"")):(o=o.replace(/{{text=/gi,""),o=o.replace(/}}/gi,""))),o}}return o=l.replace(/{{text}}/gi,e).replace(/{{id}}/gi,t[s.dataSourceMap.id]),o}_updateUserIcon(e){const t=this,a=this.dataSourceMap,s=e.data,l=e.getElementsByClassName("smart-kanban-task-user")[0];if(void 0!==s[a.userId]&&null!==s[a.userId]){const e=this.users.find((e=>e.id.toString()===s[a.userId].toString()));if(e)return s[a.userId]!==e.id&&(s[a.userId]=e.id),l.classList.remove("empty"),l.style.backgroundImage='url("'+e.image+'")',l.setAttribute("title",t.localize("assignedTask",{userName:e.name||e.id})),void l.setAttribute("aria-label","Icon of user "+(e.name||e.id))}s[a.userId]=null,l.classList.add("empty"),l.style.backgroundImage=null,l.setAttribute("aria-label","Empty user icon"),l.setAttribute("title",t.localize("unassignedTask"))}_updateTaskComments(e){const t=this.dataSourceMap,a=e.data;e.querySelector(".smart-kanban-task-comments").setAttribute("num",a[t.comments].length||"")}_updateTaskProgress(e){const t=this.dataSourceMap,a=e.data,s=e.querySelector(".smart-kanban-task-progress");let l=a[t.progress];if(void 0===l){a[t.progress]=null,s.setAttribute("aria-valuenow",0);const e=this.localize("taskProgress",{value:0});return void s.parentElement.setAttribute("title",e)}if(l=parseFloat(l),isNaN(l)){a[t.progress]=null,s.setAttribute("aria-valuenow",0);const e=this.localize("taskProgress",{value:0});return void s.parentElement.setAttribute("title",e)}l=Math.max(0,Math.min(parseFloat(l),100)),a[t.progress]=l,s.style.width=l+"%",s.classList.toggle("bottom",null!==a[t.checklist]),s.setAttribute("aria-valuenow",l);const o=this.localize("taskProgress",{value:l});s.parentElement.setAttribute("title",o)}_updateTaskChecked(e){const t=this.dataSourceMap,a=e.data,s=a[t.checklist],l=e.querySelector(".smart-kanban-task-checked");if(s&&Array.isArray(s)&&s.length>0?l.innerHTML=this._getCompletedSubTasks(s):(a[t.checklist]=null,l.innerHTML=""),l.innerHTML.length>0){let e=0;s.forEach((t=>t.completed&&e++));const t=e,a=s.length,o=this.localize("taskCompleted",{value:t,count:a});l.setAttribute("title",o)}else l.removeAttribute("title")}_getCompletedSubTasks(e){if(null===e)return"";let t=0;return e.forEach((e=>e.completed&&t++)),t+"/"+e.length}_updateTaskDueDate(e){const t=this.dataSourceMap;let a=e.data,s=a[t.dueDate],l=e.querySelector(".smart-kanban-task-due");if(s&&"string"==typeof s&&(s=new Date(s),s.setTime(s.getTime()-1*s.getTimezoneOffset()*60*1e3),a[t.dueDate]=s),s)if(l.innerHTML=new Smart.Utilities.DateTime(s).toString(this.formatStringDate),l.classList.toggle("overdue",s.getTime()<(new Date).getTime()&&100!==a[t.progress]),l.classList.contains("overdue")){const e=Math.abs(new Date-s),t=Math.ceil(e/864e5);l.setAttribute("title",this.localize("overdue")+" "+t+" "+this.localize("days"))}else l.removeAttribute("title");else a[t.dueDate]=null,l.innerHTML="",l.classList.remove("overdue"),l.removeAttribute("title");a[t.startDate]?"string"==typeof a[t.startDate]&&(a[t.startDate]=new Date(a[t.startDate]),a[t.startDate].setTime(a[t.startDate].getTime()-1*a[t.startDate].getTimezoneOffset()*60*1e3)):a[t.startDate]=null}_updateTaskColor(e){const t=this,a=t.dataSourceMap,s=e.data,l=e.querySelector(".smart-kanban-task-progress-container"),o=e.querySelector(".smart-kanban-task-progress"),i=t.rightToLeft?"borderRightColor":"borderLeftColor";function r(e){let t=parseFloat(e).toString(16);return t="0".repeat(2-t.length)+t,t.toUpperCase()}if(e.style.borderLeftColor=null,e.style.borderRightColor=null,e.style.borderLeftWidth="",e.style.borderRightWidth="",s[a.color]){e.style[i]=s[a.color];const d=getComputedStyle(e)[i],c="dark"===t.theme?.4:.1;t.taskColor?e.style[i]=s[a.color]:(e.style[i]="var(--smart-border)",e.style[t.rightToLeft?"borderRightWidth":"borderLeftWidth"]="1px"),s[a.color]=(n=(n=d).match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))?"#"+r(n[1])+r(n[2])+r(n[3]):null,l&&(l.style.backgroundColor=`rgba(${d.slice(4,d.length-1)}, ${c})`,o.style.backgroundColor=d),t.taskColorEntireSurface&&(e.style.backgroundColor=`rgba(${d.slice(4,d.length-1)}, ${c})`)}else{if(s[a.color]=null,l&&(l.style.backgroundColor=null,o.style.backgroundColor=null),t.taskColorEntireSurface){const a=getComputedStyle(e)[i],s="dark"===t.theme?.4:.1;e.style.backgroundColor=`rgba(${a.slice(4,a.length-1)}, ${s})`}t.taskColor||(e.style[i]="var(--smart-border)",e.style[t.rightToLeft?"borderRightWidth":"borderLeftWidth"]="1px")}var n}_updateTaskPriority(e){const t=this,a=t.dataSourceMap,s=e.data,l=e.querySelector(".priority");l.className="priority";let o="";s[a.priority]&&(l.className+=" "+s[a.priority],o=t.localize(s[a.priority])+" "+t.localize("priority"));const i=s[a.text],r=e.querySelector(".smart-kanban-task-content");t.taskPriority?l.classList.remove("smart-hidden"):l.classList.add("smart-hidden"),r&&(i&&t.taskPriority&&o?r.setAttribute("title",`${i}: ${o}`):r.removeAttribute("title"))}_validateSwimlanes(){const e=this,t=e.swimlanesFrom,a=e.swimlanesTo,s=[];t<0&&(e.swimlanesFrom=0),null!==a&&t>a&&(e.swimlanesFrom=a),e.swimlanes.forEach((e=>{"string"==typeof e&&(e={dataField:e,label:e}),(e.dataField||e.label)&&(e.label||(e.label=e.dataField),e.dataField||(e.dataField=e.label),s.push(e))})),e.swimlanes=s}_handleSwimlanes(e){const t=this,a=t.swimlanes;if(0===a.length||0===t.columns.length)return;const s=t.columns,l=parseFloat(getComputedStyle(t).getPropertyValue("--smart-kanban-header-size")),o=t.$.container,i=t.$.container.getBoundingClientRect(),r=t.$.container.querySelectorAll(".smart-kanban-column.has-swimlane");let n=r[0],d=r[r.length-1];if(t.rightToLeft){let e=n;n=d,d=e}const c=n.getBoundingClientRect(),u=r.length>1?d.getBoundingClientRect():c,m=Array.from(n.getElementsByTagName("smart-scroll-viewer"));let p,h,g,f,b=!1,v=!0,k=t.swimlanesTo;null===k&&(k=s.length-1),e&&(p=o.getElementsByClassName("swimlane")),n.column.collapsed&&(n.classList.remove("collapsed"),b=!0);for(let e=t.swimlanesFrom;e<=k;e++)v=v&&s[e].collapsed;v||(h=u.right-c.left+"px",g=c.left-i.left+"px",f=m.map((e=>e.getBoundingClientRect().top-i.top-l-t._dataViewPadding+"px"))),a.forEach(((t,a)=>{let s;e?s=p[a]:(s=document.createElement("div"),s.innerHTML=`<div class="swimlane-label">${t.label}</div>`,s.className="swimlane",s.setAttribute("role","heading"),s.setAttribute("aria-level",2),t.color&&(s.style.backgroundColor=t.color)),s.classList.toggle("smart-visibility-hidden",v),v||(s.style.width=h,s.style.left=g,s.style.top=f[a]),e||o.appendChild(s)})),b&&n.classList.add("collapsed")}_renderColumns(){const e=this,t=e.collapsible,a=[],s=e.$.body,l=document.createDocumentFragment();let o=e.columns;const i=e.context;if(e.context=e,e._columnToElement=new Map,e._columnContainers=[],0===o.length){const t=e.dataSource;t&&0!==t.length&&(o=[],t.forEach((t=>{const a=t[e.dataSourceMap.status];a&&-1===o.indexOf(a)&&o.push(a)})))}!function e(a,s,l){const o=[];let i=0;if(a.forEach((a=>{"string"==typeof a&&(a={dataField:a,label:a}),void 0!==a.dataField&&(void 0===a.label&&(a.label=a.dataField),void 0===a.dataField&&(a.dataField=a.label),"horizontal"!==a.orientation&&(a.orientation="vertical"),!1!==a.collapsible&&(a.collapsible=!0),a.collapsed&&t&&a.collapsible?i++:a.collapsed=!1,!1!==a.addNewButton&&(a.addNewButton=!0),!1!==a.allowRemove&&(a.allowRemove=!0),!1!==a.allowHide&&(a.allowHide=!0),!1!==a.editable&&(a.editable=!0),!1!==a.reorder&&(a.reorder=!0),0===l?delete a.selected:!0===a.selected?o.push(a):a.selected=!1,a.columns&&(a.validColumns=[],e(a.columns,a.validColumns,l+1),a.columns=a.validColumns,delete a.validColumns),s.push(a))})),i&&i===s.length&&(s[0].collapsed=!1),o.length>1)for(let e=o.length-2;e>=0;e--)o[e].selected=!1;else l>0&&0===o.length&&s.length>0&&(s[0].selected=!0)}(o,a,0),0===e.swimlanes.length?"columns"===e.hierarchy?e._createColumnElements(a,l,s,1):e._createColumnElementsTabs(a,l,s):e._createColumnElementsSwimlanes(a,l,s),s.appendChild(l),e._selectedTabs=e._allColumns.filter((e=>e.selected)).map((e=>e.dataField)),e._autoSaveState("tabs"),e.context=i}_createAddNewButton(){const e=this,t=e.querySelectorAll(".smart-kanban-add-new-button");t.length&&t.forEach((e=>{e.remove()})),e.addNewButton&&"top"!==e.addNewButtonDisplayMode&&(e.addNewButtons=[],e.querySelectorAll(".smart-kanban-column").forEach((t=>{const a=t.querySelector(".smart-scroll-viewer");if(a){const s=(()=>{const t=document.createElement("div");return t.setAttribute("add-new-button",""),t.classList.add("smart-kanban-add-new-button"),t.title=e.localize("addNewTask"),t.onclick=()=>{if(t.column){const e=t.column.querySelector(".smart-kanban-column-header-add");e&&e.click()}},t})(),l=t.column;if(!l||l&&l.collapsed||l&&!l.addNewButton)return;t.appendChild(s);const o=()=>{const l=a.getBoundingClientRect(),o=t.querySelectorAll(".smart-kanban-task"),i=e.offset(e);if(0===o.length){const a=t.querySelector(".smart-kanban-column-header"),l=e.offset(a).top-i.top,o=e.autoColumnHeight?60:0;s.style.top=l+o+a.offsetHeight+"px"}else{const t=o[o.length-1],r=e.offset(t),n=e.offsetHeight-2*s.offsetHeight,d=r.top-i.top+t.offsetHeight;if(a.computedVerticalScrollBarVisibility){const t=e.getBoundingClientRect();s.style.top=Math.min(l.top-t.top+a.offsetHeight,n)+"px"}else s.style.top=Math.min(d,n)+"px"}const r=t.offsetWidth-a.offsetWidth;s.style.left=l.left+a.offsetWidth/2-r-s.offsetWidth/2-i.left+e.$.scrollViewer.scrollLeft+"px"};s.refresh=o,s.column=t,t.addNewButton=s,s.refresh(),e.addNewButtons.push(s),requestAnimationFrame((()=>{s.classList.add("show")}))}})),e._refreshSummaries())}_refreshColumnHeights(){const e=this;e.autoColumnHeight&&e.querySelectorAll(".smart-kanban-column").forEach((t=>{const a=t.querySelector(".smart-scroll-viewer");if(a){const s=t.column;if(!s||s&&s.collapsed||s&&!s.addNewButton)return;const l=t.querySelectorAll(".smart-kanban-task"),o=t.querySelector(".smart-kanban-column-header"),i=t.querySelector(".smart-kanban-column-footer"),r=i?i.offsetHeight:0;if(0===l.length)t.style.height=100+r+o.offsetHeight+"px";else{const a=e.offset(e),s=l[l.length-1],i=e.offset(s),n=e.offsetHeight,d=o.offsetHeight+r+i.top-a.top+s.offsetHeight;t.style.height=n<d?"":d-r+"px"}a.refresh(),e._refreshEmptyColumnState(a)}}))}_offsetTop(e){return e?e.offsetTop+this._offsetTop(e.offsetParent):0}_offsetLeft(e){return e?e.offsetLeft+this._offsetLeft(e.offsetParent):0}offset(e){return{left:this._offsetLeft(e),top:this._offsetTop(e)}}_getColorInput(){const e=document.createElement("smart-color-input");return e.dataSource=["#D50000","#E67C73","#F4511E","#F6BF26","#33B679","#0B8043","#039BE5","#3F51B5","#7986CB","#8E24AA","#616161","#FFFFFF","#000000",""],e.valueDisplayMode="colorBox",e.classList.add("smart-kanban-color-input"),e.style.width="auto",e.style.height="auto",e.readonly=!0,e.onRender=()=>{const t=e.$.scrollView;t&&t.classList.add("smart-kanban-color-input")},e}_createColumnElements(e,t,a,s){const l=this,o=l.id,i=[],r=[];let n=0;const d=e=>"number"==typeof e?e+"px":"string"==typeof e?e:void 0;if(e.forEach(((a,c)=>{const u=document.createElement("div");let m=`${l._getColumnHeader(a,c<e.length-1,s)}\n <div class="smart-kanban-column-contentAAA" role="presentation">\n <smart-scroll-viewer class="smart-kanban-column-content-tasks"${l._rtlAttr}${l._tabindex} role="list"></smart-scroll-viewer>BBB\n </div>`,p=0;if(l.columnFooter&&(m+='<div class="smart-kanban-column-footer"></div>'),a.columns?(m=m.replace("AAA",""),m=m.replace("BBB",'<div class="smart-kanban-column-content-columns" role="presentation"></div>')):(m=m.replace("AAA"," no-sub-columns"),m=m.replace("BBB","")),u.className="smart-kanban-column",u.setAttribute("data-field",a.dataField),u.setAttribute("role","group"),u.setAttribute("aria-labelledby",`${o}ColumnHeaderLabel${a.dataField}`),u.setAttribute("orientation",a.orientation),a.color&&l.applyColumnColorToTasks&&u.style.setProperty("--smart-primary",a.color),a.collapsible&&u.setAttribute("collapsible",""),a.addNewButton&&u.setAttribute("add-new-button",""),u.innerHTML=m,u.siblingColumns=e,t.appendChild(u),u.column=a,u.index=c,l.onColumnHeaderRender&&l.onColumnHeaderRender(u.querySelector(".smart-kanban-column-header"),a,a.dataField),l._columnToElement.set(a,u),a.columns){const e=u.querySelector(".smart-kanban-column-content-columns");p=l._createColumnElements(a.columns,e,e,s+1),n+=p}else n+=1;let h=(p||1)+"fr";l.columnWidth?h=d(l.columnWidth):a.width&&(h=d(a.width)),!1!==a.visible?(a.collapsed?(u.classList.add("collapsed"),i.push("auto")):i.push(h),r.push(h)):u.classList.add("smart-hidden"),l._allColumns.push(a)})),1===s&&l.addNewColumn)if(l._appendAddNewColumn(t),l.columnWidth){let e="1fr";const t=l.addNewColumnWidth?l.addNewColumnWidth:l.columnWidth;e=d(t),i.push(e)}else i.push("var(--smart-kanban-add-new-column-width)");return a.style.gridTemplateColumns=i.join(" "),a.fractions=r,l._columnContainers.push(a),n}_createColumnElementsTabs(e,t,a,s){const l=this,o=l.id,i=[],r=[];if(e.forEach(((a,n)=>{const d=document.createElement("div");let c=`<div class="smart-kanban-column-contentAAA" role="presentation">\n <smart-scroll-viewer class="smart-kanban-column-content-tasks"${l._rtlAttr}${l._tabindex} role="list"></smart-scroll-viewer>BBB\n </div>`;if(a.columns?(c=c.replace("AAA",""),c=c.replace("BBB",'<div class="smart-kanban-column-content-columns has-tabs" role="presentation"></div>')):(c=c.replace("AAA"," no-sub-columns"),c=c.replace("BBB","")),d.className="smart-kanban-column",d.setAttribute("orientation",a.orientation),a.collapsible&&d.setAttribute("collapsible",""),a.addNewButton&&d.setAttribute("add-new-button",""),s){const e=document.createElement("div"),t=`${o}Tab${a.dataField}`,i=`${o}Column${a.dataField}`;e.id=t,e.className="smart-kanban-tab smart-unselectable",l.disabled||l.unfocusable||(e.tabIndex=0),e.setAttribute("role","tab"),e.setAttribute("aria-controls",i),e.innerHTML=`<div class="smart-kanban-tab-label">${a.label}</div>`,e.columnElement=d,d.id=i,d.setAttribute("role","tabpanel"),d.setAttribute("aria-labelledby",t),d.tab=e,s.appendChild(e),a.selected?e.classList.add("selected"):d.classList.add("smart-hidden"),e.setAttribute("aria-selected",a.selected)}else c=l._getColumnHeader(a,n<e.length-1)+c,d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${o}ColumnHeaderLabel${a.dataField}`);if(d.innerHTML=c,d.siblingColumns=e,t.appendChild(d),d.column=a,d.index=n,l._columnToElement.set(a,d),a.columns){const e=d.querySelector(".smart-kanban-column-content-columns"),t=document.createElement("div");t.className="smart-kanban-tab-strip",t.setAttribute("role","tablist"),e.appendChild(t),l._createColumnElementsTabs(a.columns,e,e,t)}s||(a.collapsed?(d.classList.add("collapsed"),i.push("auto")):i.push("1fr"),r.push("1fr")),l._allColumns.push(a)})),!s){if(l.addNewColumn)if(l._appendAddNewColumn(t),l.columnWidth){let e="1fr";const t=e=>"number"==typeof e?e+"px":"string"==typeof e?e:void 0;e=t(l.addNewColumnWidth?l.addNewColumnWidth:l.columnWidth),i.push(e)}else i.push("var(--smart-kanban-add-new-column-width)");a.style.gridTemplateColumns=i.join(" "),a.fractions=r,l._columnContainers.push(a)}}_createColumnElementsSwimlanes(e,t,a){const s=this,l=s.id,o=s.swimlanes,i=[],r=[];if(e.forEach(((a,n)=>{const d=document.createElement("div");let c=`${s._getColumnHeader(a,n<e.length-1)}\n <div class="smart-kanban-column-content no-sub-columns" role="presentation"></div>`;d.className="smart-kanban-column",d.setAttribute("role","group"),d.setAttribute("aria-labelledby",`${l}ColumnHeaderLabel${a.dataField}`),d.setAttribute("orientation",a.orientation),a.collapsible&&d.setAttribute("collapsible",""),a.addNewButton&&d.setAttribute("add-new-button",""),d.innerHTML=c,d.siblingColumns=e;const u=d.children[1];let m="";if(s._hasSwimlane(n)){let e=[];for(let t=0;t<o.length;t++)m+=`<smart-scroll-viewer class="smart-kanban-column-content-tasks" swimlane="${o[t].dataField}"${s._rtlAttr}${s._tabindex} role="list"></smart-scroll-viewer>`,e.push("1fr");d.classList.add("has-swimlane"),u.classList.add("has-swimlane"),u.style.gridTemplateRows=e.join(" ")}else m=`<smart-scroll-viewer class="smart-kanban-column-content-tasks"${s._rtlAttr}${s._tabindex} role="list"></smart-scroll-viewer>`;u.innerHTML=m,t.appendChild(d),d.column=a,d.index=n,s._columnToElement.set(a,d),a.collapsed?(d.classList.add("collapsed"),i.push("auto")):i.push("1fr"),r.push("1fr"),s._allColumns.push(a)})),s.addNewColumn)if(s._appendAddNewColumn(t),s.columnWidth){let e="1fr";const t=e=>"number"==typeof e?e+"px":"string"==typeof e?e:void 0;e=t(s.addNewColumnWidth?s.addNewColumnWidth:s.columnWidth),i.push(e)}else i.push("var(--smart-kanban-add-new-column-width)");a.style.gridTemplateColumns=i.join(" "),a.fractions=r,s._columnContainers.push(a)}_getColumnSummary(e){const t=this.getColumnDataItems(e.dataField);return this.columnSummary&&t.length?" ("+t.length+")":""}_getColumnHeaderTemplate(e,t){const a=e.headerTemplate||this.columnHeaderTemplate;if(a){const s=document.createElement("div");let l;if("string"==typeof a&&a.startsWith("#")?l=document.querySelector(a):"string"==typeof a&&(l=a),"function"==typeof a){const s=a(e,t);return s||t}if(l instanceof HTMLTemplateElement){s.appendChild(l.content.cloneNode(!0));const t=/{{\w+}}/g;let a=s.innerHTML;const o=t.exec(a);for(let t=0;t<o.length;t++){const t=e[o[0].replace("{{","").replace("}}","")];a=a.replace(o[0],t)}return a}return l instanceof HTMLElement?s.appendChild(l):s.innerHTML=l,s.innerHTML}return null}_getColumnHeader(e,t,a=1){const s=this,l=s._tabindex,o=e.collapsed?s.localize("expand"):s.localize("collapse"),i=s.localize("addNewTask"),r=s.allowColumnEdit||s.allowColumnRemove||s.allowColumnHide?"settings":"",n=s.localize("customizeColumn");let d=e.label;""===d&&(d=" ");const c=s._getColumnSummary(e);let u=`<span class="smart-kanban-title">${d}</span><span class='summary'>${c}</span>`,m="smart-kanban-column-header-label";if(void 0!==e.color){if(e.color){const t=new Smart.Color(e.color).getInvertedColor();u=`<div class="heading" style="background: ${e.color}; color: ${t};"><span class="smart-kanban-title">${d}</span><span class='summary'>${c}</span></div>`}else u=`<div class="heading"><span class="smart-kanban-title">${d}</span><span class='summary'>${c}</span></div>`;m+=" pill"}const p=null!==s.columnHeaderTemplate||e.headerTemplate?s._getColumnHeaderTemplate(e,u):u,h="bottom"===s.addNewButtonDisplayMode?"":"add-new-button";return`<div status="${e.dataField}" ${r} ${h} class="smart-kanban-column-header smart-unselectable"${l} role="heading" aria-level=${a}>\n <div title="${i}" class="smart-kanban-column-header-add ${h}"${l} role="button" aria-label="Add new task"></div>\n <div id="${s.id}ColumnHeaderLabel${e.dataField}" class="${m}">${p}</div>\n <div title="${o}" class="smart-kanban-column-header-toggle-button smart-arrow smart-arrow-${t?"left":"right"}" role="button" aria-hidden="true"></div>\n <div title="${n}" class="smart-kanban-column-actions smart-kanban-column-header-settings-button" role="button" aria-haspopup="menu" aria-label="Open actions list" aria-hidden="true"></div>\n </div>`}_hasSwimlane(e){const t=this;if(0===t.swimlanes.length)return!1;const a=t.swimlanesFrom;let s=t.swimlanesTo;return null===s&&(s=t.columns.length-1),e>=a&&e<=s}_updateColumnWidths(e,t){const a=this,s=t.fractions,l=[];let o=0,i=0;for(let t=0;t<e.length;t++){const r=e[t];!1!==r.visible&&(l.push(e[t].collapsed?"auto":s[o++]),!r.collapsed&&a.columnWidth&&(i+=r.width?r.width:a.columnWidth))}if(t===a.$.body&&a.addNewColumn)if(a.columnWidth){let e="1fr";const t=e=>"number"==typeof e?e+"px":"string"==typeof e?e:void 0;e=t(a.addNewColumnWidth?a.addNewColumnWidth:a.columnWidth),l.push(e)}else l.push("var(--smart-kanban-add-new-column-width)");i<a.offsetWidth&&a.columnWidth&&l.push("1fr"),t.style.gridTemplateColumns=l.join(" "),a.columnWidth&&a.$.scrollViewer.refresh()}_validateColumnArgument(e){if(!isNaN(e))return this.columns[e];const t=this._allColumns;return"string"==typeof e?t.find((t=>t.dataField===e)):"object"==typeof e?t.find((t=>t===e)):null}_resizeHandler(){this.$.scrollViewer&&(this.$.scrollViewer.scrollLeft=0),this.refresh("resize")}refresh(e){const t=this;"resize"===e?(clearTimeout(t._resizeTimeout),t._resizeTimeout=setTimeout((function(){t._allColumns.forEach((e=>t._refreshScrollViewer(e)))}),50),t._handleSwimlanes(!0)):(t.closePanel(),t._closeList(t._actionsList,"_actionSelectionFor"),t._closeList(t._columnActionsList,"_columnActionSelectionFor"),t._closeList(t._commentsList,"_commentSelectionFor"),t._closeList(t._userList,"_userSelectionFor"),t._closeList(t._priorityList,"_prioritySelectionFor"),t._resetFields=!0,t._render()),t.$.scrollViewer.refresh()}_refreshScrollViewer(e,t){const a=this,s=e instanceof HTMLElement?e:this._columnToElement.get(e);function l(l,o){if(!t&&l&&l.$.scrollViewerContentContainer&&""===l.$.scrollViewerContentContainer.innerHTML.trim())return a.virtualization&&a._refreshScrollHeight(l,e.dataField),void a._refreshEmptyColumnState(l);if(e.collapsed?l.toRefresh=!0:(delete l.toRefresh,requestAnimationFrame((()=>{if(l.refresh(),void 0===e.dataField){const t=e.closest(".smart-kanban-column");if(t){const e=t.getAttribute("data-field");a._refreshScrollHeight(l,e)}}else a._refreshScrollHeight(l,e.dataField);0===o&&"horizontal"===e.orientation&&(a.columnWidth||(l.$.content.offsetWidth<=2*a._kanbanTaskMinWidth+a._dataViewPadding?s.setAttribute("orientation","vertical"):"vertical"===s.getAttribute("orientation")&&s.setAttribute("orientation","horizontal")))}))),a._refreshButtonsAndSummaries(),void 0===e.dataField){const t=e.closest(".smart-kanban-column");if(t){const e=t.getAttribute("data-field");a._refreshScrollHeight(l,e)}}else a._refreshScrollHeight(l,e.dataField)}e instanceof Smart.ScrollViewer?l(e):this.swimlanes.length>0?Array.from(s.querySelectorAll("smart-scroll-viewer")).forEach(((e,t)=>l(e,t))):l(s.querySelector("smart-scroll-viewer"),0)}_containerDownHandler(e){const t=this,a=t.isInShadowDOM||t.shadowRoot?e.originalEvent.composedPath()[0]:e.originalEvent.target,s=a.closest(".smart-kanban-task");if(delete t._preventSelection,t.allowColumnReorder){const l=a.closest(".smart-kanban-column-header")&&!a.classList.contains("smart-kanban-column-header-add")&&!a.classList.contains("smart-kanban-column-header-toggle-button");if(!s&&l&&!t._columnEditing){const s=a.closest(".smart-kanban-column");if(s){const a=e.originalEvent.composedPath();let l=0;for(let e=0;e<a.length;e++)a[e].classList&&a[e].classList.contains("smart-kanban-column")&&l++;s.column.reorder&&l<=1&&(t._columnDragDetails={x:e.pageX,y:e.pageY,event:e,kanbanColumn:s})}}}const l=a.closest(".smart-kanban-column"),o=a.closest(".smart-kanban-column-header")&&!a.classList.contains("smart-kanban-column-header-add")&&!a.classList.contains("smart-kanban-column-header-toggle-button"),i=l?l.column:null;if(i){if(o&&t.$.fireEvent("columnClick",{column:i}),new Date-t._clickTime<=300)return!s&&o&&!t._columnEditing&&t.allowColumnEdit&&(t._columnDragDetails=null,!1===i.collapsed&&i.editable&&"menu"!==t.columnEditMode&&t._handleColumnEditing(i.dataField)),void(o&&(i.collapsed?t.expand(i):(!t.allowColumnEdit||t.allowColumnEdit&&"menu"===t.columnEditMode)&&t.collapse(i),t.$.fireEvent("columnDoubleClick",{column:i})));t._clickTime=new Date}s&&(t.virtualization?(t.focusTask(s.data.id),t._refreshColumns()):t._focusTask(s),t._startDragging(s,e))}_containerKeydownHandler(e){const t=this;if(t._dragDetails)return;const a=e.key,s=t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target;function l(a=s){delete t._preventSelection,t._documentUpHandler({originalEvent:{target:a}}),t._containerClickHandler({target:a,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}),e.preventDefault()}if(s.closest(".smart-kanban-column, .smart-kanban-add-new-column"))return s.classList.contains("smart-kanban-column-content-tasks")?void t._selectViaKeyboard(s.$.content,e,l):void("Enter"!==a&&" "!==a||s instanceof HTMLInputElement!=0||l());if(t.$.headerDropDown.contains(s))"Escape"===a&&(t.closePanel(),t.$[/\s?([a-z]+)-panel/g.exec(t.$.headerDropDown.className)[1]+"Button"].focus());else if(!(s.classList.contains("smart-data-view-header-button")||s.closest(".smart-data-view-search-box")||s.classList.contains("remove-button"))||"Enter"!==a&&" "!==a||l(),s.classList.contains("smart-kanban-list")){const o=s;switch(a){case"ArrowDown":t._selectListItem(t._getNextItem(o));break;case"ArrowUp":t._selectListItem(t._getPrevItem(o));break;case"Home":t._selectListItem(t._getFirstItem(o));break;case"End":t._selectListItem(t._getLastItem(o));break;case"Escape":o.openedFrom.focus(),t._closeList(o,o===t._actionsList?"_actionSelectionFor":o===t._commentsList?"_commentSelectionFor":"_userSelectionFor"),o===t._columnActionsList&&t._closeList(t._columnActionsList,"_columnActionSelectionFor");break;case"Enter":case" ":{const e=t._getSelectedItem(o);e&&l(e);break}default:return}e.preventDefault()}}getTaskIndex(e){const t=this,a=t.getTask(e);if(!a)return-1;const s=a[t.dataSourceMap.status];return t._getTasksByDataField(s).findIndex((t=>{if(t.id===e)return!0}))}_getNextPrevColumn(e,t){const a=this;let s=null;return a._allColumns.forEach(((l,o)=>{if(l.dataField===e)if(t){if(o<a._allColumns.length-1)return s=a._allColumns[o+1],!0}else if(o>0)return s=a._allColumns[o-1],!0})),s}focusTask(e){const t=this;t._focusedTask=e,t.ensureVisible(e),t._refreshColumns()}_selectViaKeyboard(e,t,a){const s=this;let l=t.key;s.rightToLeft&&("ArrowRight"===l?l="ArrowLeft":"ArrowLeft"===l&&(l="ArrowRight"));const o=s._focusedTask,i=s.getTask(o);if(!i)return;const r=i[s.dataSourceMap.status],n=s._getTasksByDataField(r),d=s.getTaskIndex(o);switch(l){case"ArrowRight":{const e=s._getNextPrevColumn(r,!0);if(e)if(s.virtualization){const t=s._getTasksByDataField(e.dataField);t.length>0&&s.focusTask(t[0].id)}else{const t=s._columnToElement.get(e),a=t.querySelector(".smart-kanban-task");s._focusTask(a),t.focus()}break}case"ArrowLeft":{const e=s._getNextPrevColumn(r,!1);if(e)if(s.virtualization){const t=s._getTasksByDataField(e.dataField);t.length>0&&s.focusTask(t[0].id)}else{const t=s._columnToElement.get(e).querySelector(".smart-kanban-task");s._focusTask(t)}break}case"ArrowDown":if(s.virtualization)d<n.length-1&&s.focusTask(n[d+1].id);else{const e=s.getColumn(r),t=s._columnToElement.get(e);s._focusTask(s._getNextItem(t,!0))}break;case"ArrowUp":if(s.virtualization)d>0&&s.focusTask(n[d-1].id);else{const e=s.getColumn(r),t=s._columnToElement.get(e);s._focusTask(s._getPrevItem(t,!0))}break;case"Home":s.virtualization?s.focusTask(n[0].id):s._focusTask(s._getFirstItem(e));break;case"End":s.virtualization?s.focusTask(n[n.length-1].id):s._focusTask(s._getLastItem(e));break;case"Enter":case" ":case"F2":case"Delete":{const e=s.querySelector("[focus]");e&&("F2"===l||"Enter"===l?s.beginEdit(e):"Delete"===l?s.removeTask(e,!0):a(e));break}default:return}t.preventDefault()}_getFirstItem(e){const t=e.children;for(let e=0;e<t.length;e++){const a=t[e];if(!a.hasAttribute("disabled")&&"none"!==getComputedStyle(a).display)return a}}_getLastItem(e){const t=e.children;for(let e=t.length-1;e>=0;e--){const a=t[e];if(!a.hasAttribute("disabled")&&"none"!==getComputedStyle(a).display)return a}}_getPrevItem(e,t){const a=this._getSelectedItem(e,t);let s=a?a.previousElementSibling:this._getLastItem(e);for(;s;){if(!s.hasAttribute("disabled")&&"none"!==getComputedStyle(s).display)return s;s=s.previousElementSibling}}_getNextItem(e,t){const a=this._getSelectedItem(e,t);let s=a?a.nextElementSibling:this._getFirstItem(e);for(;s;){if(!s.hasAttribute("disabled")&&"none"!==getComputedStyle(s).display)return s;s=s.nextElementSibling}}_getSelectedItem(e,t){return e?t?e.querySelector("[focus]"):e.querySelector(".selected"):null}_selectListItem(e){if(!e)return;const t=e.parentElement,a=t.querySelector(".selected");a&&(a.classList.remove("selected"),a.removeAttribute("aria-selected")),e.classList.add("selected"),e.setAttribute("aria-selected",!0),t.scrollTop=e.offsetTop}_focusTask(e){if(!e)return;const t=this;Array.from(t.querySelectorAll("[focus]")).forEach((e=>e.removeAttribute("focus"))),e.setAttribute("focus",""),this._focusedTask=e.data.id,t.virtualization?t.ensureVisible(t._focusedTask):this.ensureVisible(e)}_setFocusable(){const e=this,t=e.$.container,a=e.disabled||e.unfocusable;let s=[e.$.customizeButton,e.$.filterButton,e.$.sortButton,e.$.searchButton,e.$.searchPrev,e.$.searchNext,e.$.searchClose,e._actionsList,e._userList];if(s=s.concat(Array.from(t.querySelectorAll(".smart-kanban-column-header, .smart-kanban-column-header-add, .smart-kanban-tab, .smart-kanban-column-content-tasks, .smart-kanban-task-user, .smart-kanban-task-actions, .smart-kanban-task-comments, .smart-kanban-add-new-column"))),s.forEach((e=>{a?e.removeAttribute("tabindex"):(null===e.getAttribute("tabindex")||e.getAttribute("tabindex")<0)&&e.setAttribute("tabindex",0)})),e._dialog&&e._dialog.editPanelPopulated){const t=Array.from(e._dialog.$.container.querySelectorAll(".text-editor, .new-subtask"));a?t.forEach((e=>e.tabIndex=-1)):t.forEach((e=>e.removeAttribute("tabindex"))),Array.from(e._dialog.$.container.querySelectorAll(".smart-element.editor, smart-button.add, smart-button.ok, smart-button.cancel")).forEach((e=>e.unfocusable=a)),e._dialog.unfocusable=a}}_startDragging(e,t){const a=this;if(!a._currentUser.allowDrag)return;const s=e.closest("smart-scroll-viewer"),l=e.getBoundingClientRect();let o=e.hasAttribute("selected")?Array.from(e.parentElement.querySelectorAll("[selected]")):[e],i=o.map((e=>e.data));a._dragDetails={StartPosition:{left:t.pageX,top:t.pageY},Items:o,ItemsData:i,ItemData:e.data,Item:e,FeedbackShown:!1,OriginalEvent:t,Column:e.classList.contains("smart-kanban-column")?e:null,PointerOffset:[l.x-t.clientX,l.y-t.clientY],ScrollViewer:s,StartTime:new Date,Dragging:!0},Smart.Kanban.kanbanTaskDragged=!0,s&&s._scrollView&&(s._scrollView.disableSwipeScroll=!0),a.allowDrop&&(Smart.Kanban.hoveredKanban=a,Smart.Kanban.hoveredItem=e)}_documentMoveHandler(e){const t=this,a=t._dragDetails;function s(){delete t._dragDetails,delete Smart.Kanban.kanbanTaskDragged,delete Smart.Kanban.hoveredKanban,delete Smart.Kanban.hoveredItem,a.ScrollViewer._scrollView.disableSwipeScroll=!1}if(t.allowColumnReorder&&t._columnDragDetails&&(Math.abs(e.pageX-t._columnDragDetails.x)>=3||Math.abs(e.pageY-t._columnDragDetails.y)>=3)&&(t._startDragging(t._columnDragDetails.kanbanColumn,t._columnDragDetails.event),t._columnDragDetails=null),!a)return;if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,o=Math.abs(a.StartPosition.left-e.pageX)>5||Math.abs(a.StartPosition.top-e.pageY)>5;if(!o||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&o&&!l&&s());if(t.$.fireEvent("dragStart",{item:a.Item,items:a.Items,data:a,container:t,previousContainer:t,originalEvent:a.OriginalEvent}).defaultPrevented)return void s();t.closePanel(),t._hideBodyOverflow(),a.Feedback=t._addDragFeedback(),a.FeedbackShown=!0,a.Items.forEach((e=>e.classList.add("dragged")))}const l=a=>{a.scrollWidth&&(t._autoScrollDragInterval&&clearInterval(t._autoScrollDragInterval),t._autoScrollDragInterval=setInterval((function(){const t=a.getBoundingClientRect();e.clientX<=t.left+20?a.scrollLeft-=15:e.clientX>=t.left+t.width-20&&(a.scrollLeft+=15)}),25))};Smart.Kanban.hoveredKanban?l(Smart.Kanban.hoveredKanban.$.scrollViewer):l(t.$.scrollViewer);let o,i=t.dragOffset;if(i="auto"!==i&&Array.isArray(i)?i:a.PointerOffset,t.$.fireEvent("dragging",{item:a.Item,items:a.Items,data:a,originalEvent:e}),a.Feedback.style.left=e.pageX+(i[0]||0)+"px",a.Feedback.style.top=e.pageY+(i[1]||0)+"px",Smart.Kanban.hoveredKanban&&(clearInterval(Smart.Kanban.hoveredKanban._dragInterval),delete Smart.Kanban.hoveredKanban),Smart.Kanban.hoveredItem&&(Smart.Kanban.hoveredItem.classList.remove("drop-target"),Smart.Kanban.hoveredItem.classList.remove("before","after"),delete Smart.Kanban.hoveredItem),o=t._isMobile?(t.shadowRoot||t.getRootNode()).elementFromPoint(e.clientX,e.clientY):t.isInShadowDOM||t.shadowRoot?e.originalEvent.composedPath()[0]:e.originalEvent.target,!o)return;const r=(t.shadowRoot?o.getRootNode().host:o).closest("smart-kanban");if(!r||!r.allowDrop)return;const n=o.closest(".smart-kanban-column-content-tasks");if(Smart.Kanban.hoveredKanban=r,a.Column)return void t._handleColumnDragging(e);if(!n)return;const d=n.parentElement.parentElement.getAttribute("orientation"),c=Array.from(n.$.content.children);let u=0;if(c.forEach((e=>e.filteredOut&&u++)),0===c.length||c.length===u)return Smart.Kanban.hoveredItem=n.$.scrollViewerContainer,void Smart.Kanban.hoveredItem.classList.add("drop-target");n.scrollHeight>0&&(r._dragInterval=setInterval((function(){const a=n.getBoundingClientRect();a.left<=e.clientX&&a.left+a.width>=e.clientX?e.clientY>=a.top&&e.clientY<=a.top+20?n.scrollTop-=t._autoScrollCoefficient:e.clientY>=a.top+a.height-20&&e.clientY<=a.top+a.height?n.scrollTop+=t._autoScrollCoefficient:clearInterval(r._dragInterval):clearInterval(r._dragInterval)}),2));let m=o.closest(".smart-kanban-task");if(m&&-1===a.Items.indexOf(m)){const t=m.getBoundingClientRect();"vertical"===d&&e.clientY-t.top<=t.height/2||"horizontal"===d&&e.clientX-t.left<=t.width/2?m.classList.add("before"):m.classList.add("after")}else{if(m&&1===c.length)return;m=m&&1===a.Items.length?t[`_${d}ClosestTaskToHover`]([m.previousElementSibling,m.nextElementSibling],e,!0):t[`_${d}ClosestTaskToHover`](c,e,m||o===n.$.content)}m&&(m.classList.add("drop-target"),Smart.Kanban.hoveredItem=m)}_handleColumnDragging(e){const t=this.querySelectorAll(".smart-kanban-column");let a;for(let s=0;s<t.length;s++){const l=t[s],o=l.getBoundingClientRect();e.clientX>=o.left&&e.clientX<=o.right&&e.clientY>=o.top&&e.clientY<=o.bottom&&(a=l)}if(a){const s=a.getBoundingClientRect();e.clientX-s.left<=s.width&&(a.classList.add("before"),a.classList.add("drop-target")),e.clientX-s.left>=s.width/2&&a===t[t.length-1]&&(a.classList.remove("before"),a.classList.add("after"),a.classList.add("drop-target")),Smart.Kanban.hoveredItem=a}}_hideBodyOverflow(){const e=this,t=(document.scrollingElement||document.documentElement).scrollHeight>document.documentElement.clientHeight,a=(document.scrollingElement||document.documentElement).scrollWidth>document.documentElement.clientWidth,s=e.isInShadowDOM?e.getRootNode().host:document.body;e._originalBodyOverflow={overflowX:s.style.overflowX,overflowY:s.style.overflowY,overflow:s.style.overflow},s.classList.add("smart-dragging"),s.style.overflow=s.style.overflowX=s.style.overflowY="",t&&!a?s.style.overflowX="hidden":a&&!t?s.style.overflowY="hidden":a||t||(s.style.overflow="hidden")}_verticalClosestTaskToHover(e,t,a){const s=this._dragDetails.Items,l=t.clientY;let o,i,r=1/0,n=0,d=e.length-1,c=1;for(a||(n=d,d=0,c=-1);n!==d+c;){const t=e[n];if(n+=c,!t||t.filteredOut||-1!==s.indexOf(t))continue;if(!a){o=t,i="after";break}const d=t.getBoundingClientRect(),u=d.top+d.height/2,m=Math.abs(l-u);if(!(m<r))break;r=m,o=t,i=l<=u?"before":"after"}return o&&o.classList.add(i),o}_horizontalClosestTaskToHover(e,t){const a=this._dragDetails.Items,s=t.clientY,l=t.clientX;let o,i,r;return e.forEach((e=>{if(!e||e.filteredOut||-1!==a.indexOf(e))return;const t=e.getBoundingClientRect(),n=Math.abs(s-t.top),d=Math.abs(s-t.bottom),c=Math.min(n,d),u=Math.abs(l-t.left),m=Math.abs(l-t.right),p=Math.min(u,m),h=Math.sqrt(Math.pow(p,2)+Math.pow(c,2));(void 0===i||h<i)&&(o=e,i=h,r=u<m?"before":"after")})),o&&o.classList.add(r),o}_scrollViewerTouchmoveHandler(e){const t=this;t._dragDetails&&(t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target).closest("smart-scroll-viewer")&&e.cancelable&&(e.preventDefault(),e.stopPropagation())}_documentUpHandler(e){const t=this,a=t._dragDetails;if(t._columnDragDetails=null,t.$.container.hasAttribute("modal"))return;const s=t.isInShadowDOM||t.shadowRoot?e.originalEvent.composedPath()[0]:e.originalEvent.target,l=t.$.header;if(t._userSelectionFor&&!t._userList.contains(s)&&t._closeList(t._userList,"_userSelectionFor"),t._prioritySelectionFor&&!t._priorityList.contains(s)&&t._closeList(t._priorityList,"_prioritySelectionFor"),t._actionSelectionFor&&!t._actionsList.contains(s)&&t._closeList(t._actionsList,"_actionSelectionFor"),t._columnActionSelectionFor&&!t._columnActionsList.contains(s)&&(t._columnActionsList.classList.contains("smart-visibility-hidden")||(t._closeList(t._columnActionsList,"_columnActionSelectionFor"),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),t._columnActionsListDate=new Date)),t._commentSelectionFor){const e=t._commentsList;(t.shadowRoot||t.getRootNode()).activeElement!==e.textarea&&(t._actionSelectionFor||e.contains(s)?!e.classList.contains("expanded")||s===e.textarea||e.button.contains(s)||s.classList.contains("remove-button")||e.classList.remove("expanded"):t._closeList(e,"_commentSelectionFor"))}if(!("none"===t.headerPosition||t.$.headerDropDown.classList.contains("smart-visibility-hidden")||t.$.headerDropDown.classList.contains("search-panel")||s!==l&&l.contains(s))){const e=s.closest("smart-scroll-viewer"),a=s.closest(".smart-drop-down");e&&l.contains(e.ownerElement)||a&&(!a.ownerElement||l.contains(a.ownerElement))||t.closePanel()}if(!a)return;const o=Smart.Kanban.hoveredKanban,i=Smart.Kanban.hoveredItem;if(delete t._dragDetails,delete Smart.Kanban.kanbanTaskDragged,delete Smart.Kanban.hoveredKanban,delete Smart.Kanban.hoveredItem,a.ScrollViewer&&a.ScrollViewer._scrollView&&(a.ScrollViewer._scrollView.disableSwipeScroll=!1),!a.FeedbackShown)return;const r=o||(t.shadowRoot||t.getRootNode()).elementFromPoint(e.clientX,e.clientY);t._preventSelection=!0;const n=t.isInShadowDOM?t.getRootNode().host:document.body;n.classList.remove("smart-dragging"),n.style.overflow=t._originalBodyOverflow.overflow,n.style.eoverflowX=t._originalBodyOverflow.overflowX,n.style.overflowY=t._originalBodyOverflow.overflowY,delete t._originalBodyOverflow,a.Feedback.remove(),o&&clearInterval(o._dragInterval);const d=a.Item,c=a.Items;if(c.forEach((e=>e.classList.remove("dragged"))),!r)return;if(!i)return void t.$.fireEvent("dragEnd",{item:d,items:c,target:r,data:a,previousContainer:t,container:r,originalEvent:e});if(!o||!o.allowDrop||o.disabled)return;let u=!1;if(i.classList.remove("drop-target"),i.classList.contains("before")?i.classList.remove("before"):i.classList.contains("after")&&(i.classList.remove("after"),u=!0),a.DropDetails={item:i,after:u},t.$.fireEvent("dragEnd",{item:d,items:c,target:i,data:a,previousContainer:t,container:o,originalEvent:e}).defaultPrevented)return;function m(e,s){t._requestVirtualDataSource("update",Object.assign({},e.data,{status:s}),(function(s){return s&&t._moveDraggedItems(Object.assign({},a,{Item:e,Items:[e]})),s}))}const p=i.closest(".smart-kanban-column"),h=p.column.dataField;if(a.Column){const e=()=>Array.from(p.parentElement.querySelectorAll(".smart-kanban-column")).filter((e=>e.parentElement===p.parentElement)),s=e().indexOf(a.Column);a.DropDetails.after?p.parentElement.appendChild(a.Column):p.parentElement.insertBefore(a.Column,p);const l=e().indexOf(a.Column),o=[],i=e();for(let e=0;e<i.length;e++)i[e].column&&!i[e].classList.contains("smart-kanban-add-new-column")&&o.push(i[e].column);return t.columns=o,t.$.fireEvent("columnReorder",{column:a.Column.column,oldIndex:s,index:l}),t._reset(),void t._createAddNewButton()}if(d&&d.data&&h!==d.data[t.dataSourceMap.status]){const e=Object.assign({},d.data);e[t.dataSourceMap.status]=h;const a=t.getColumn(h);a&&(e.statusLabel=a.label);const s=t.getColumn(d.data[t.dataSourceMap.status]);s&&(d.data.statusLabel=s.label);const l=JSON.parse(JSON.stringify(e)),o=JSON.parse(JSON.stringify(d.data));if(t.$.fireEvent("change",{task:d,id:l.id,value:l,oldValue:o}),t.$.fireEvent("taskUpdate",{id:l.id,value:l,oldValue:o}),t._currentUser.info){const e=t.dataSourceMap;d.data[e.updatedUserId]=t._currentUser.info.id,d.data[e.updatedDate]=new Date,t.addHistory(d.data,{action:"moved",user:t._currentUser.info.id,details:{id:d.data[e.id],oldValue:o[e.status],value:l[e.status]},label:d.data[e.text],date:d.data[e.updatedDate]})}}if(t.dataSource&&t.dataSource.virtualDataSource&&h!==d.data[t.dataSourceMap.status])if(u)for(let e=c.length-1;e>=0;e--)m(c[e],h);else for(const e of c)m(e,h);else if(t._moveDraggedItems(a),d&&d.data){const e=Object.assign({},d.data),a=JSON.parse(JSON.stringify(e));t.$.fireEvent("taskReorder",{id:a.id,value:a})}}_refreshButtonsAndSummaries(){const e=this;e._refreshColumnHeights(),e.addNewButtons&&(e.addNewButtons.forEach((e=>{e.refresh()})),e._refreshSummaries())}_addDragFeedback(){const e=this,t=e._dragDetails.Item,a=e._dragDetails.Items.length,s=document.createElement("div"),l=t.offsetWidth+"px",o=t.offsetHeight+"px";let i=t.cloneNode(!0);if(i.style.width=l,i.style.height=o,t.classList.contains("smart-kanban-column")){i=document.createElement("smart-kanban");const a=Object.assign({},t.column);a.collapsed=!1;const o=[a];i.columns=o,i.dataSource=e.dataSource,i.users=e.users,i.taskActions=e.taskActions,i.taskDue=e.taskDue,i.taskProgress=e.taskProgress,i.style.height="100%",i.style.width=l,i.style.minWidth="250px",s.setAttribute("column-drag","")}if(s.className="smart-kanban-feedback",s.setAttribute("parent-kanban-id",e.id),e.theme&&s.setAttribute("theme",e.theme),["rightToLeft","taskActions","taskComments","taskDue","taskPriority","taskProgress","taskTags","taskUserIcon"].forEach((t=>{e[t]&&s.setAttribute(Smart.Utilities.Core.toDash(t),"")})),s.appendChild(i),a>1){const e=document.createElement("div");e.style.width=l,e.style.height=o,e.className="smart-kanban-feedback-additional",s.insertBefore(e,i),i.setAttribute("num",a),a>2&&e.classList.add("multiple")}return e.getShadowRootOrBody().appendChild(s),s}_moveDraggedItems(e){const t=this,a=t.dataSourceMap;let s,l=e.DropDetails,o=l.item,i=o.closest(".smart-kanban-column"),r=e.Item.closest("smart-scroll-viewer"),n=i.column;if(o.classList.contains("smart-kanban-task")?(s=o.parentElement,l.after&&(o=o.nextElementSibling,o&&o.classList.contains("smart-hidden")&&(o=null)),e.Items.forEach(((l,i)=>{if(t.virtualization){const s=e.ItemsData[i],r=s[a.status],d=t._getTasksByDataField(r),c=d.findIndex((e=>e.id===s.id));if(o){if(o.data!==l.data){d.splice(c,1);const e=t._getTasksByDataField(n.dataField),a=e.indexOf(o.data);e.splice(a,0,s)}}else c>=0&&(d.splice(c,1),t._getTasksByDataField(n.dataField).push(s))}else{s.insertBefore(l,o);const r=e.ItemsData[i],d=r[a.status],c=t._getTasksByDataField(d),u=c.findIndex((e=>e.id===r.id));if(o){if(o.data!==l.data){c.splice(u,1);const e=t._getTasksByDataField(n.dataField),a=e.indexOf(o.data);e.splice(a,0,r)}}else u>=0&&(c.splice(u,1),t._getTasksByDataField(n.dataField).push(r))}l.data[a.status]=n.dataField,l.data.statusLabel=n.label,l.column=n}))):(s=o.firstElementChild,e.Items.forEach((e=>{if(t.virtualization){const s=e.data[a.status],l=t._getTasksByDataField(s),o=l.findIndex((t=>t.id===e.data.id));l.splice(o,1),t._getTasksByDataField(n.dataField).push(e.data)}else{s.appendChild(e);const l=e.data[a.status],o=t._getTasksByDataField(l),i=o.findIndex((t=>t.id===e.data.id));o.splice(i,1),t._getTasksByDataField(n.dataField).push(e.data)}e.data[a.status]=n.dataField,e.data.statusLabel=n.label,e.column=n}))),s=s.closest("smart-scroll-viewer"),t.swimlanes.length>0){const t=s.getAttribute("swimlane");t?e.Items.forEach((e=>e.data[a.swimlane]=t)):e.Items.forEach((e=>delete e.data[a.swimlane]))}t.virtualization?(t._refreshColumns(),t.focusTask(e.ItemData.id)):t._focusTask(e.Item),r!==s?(s.focus(),t.textTemplate&&e.Items.forEach((e=>t._renderTask(e))),e.Item.hasAttribute("selected")&&(e.Items.forEach((e=>e.removeAttribute("selected"))),t._selectedTasks=[],t._autoSaveState("selection")),t._refreshScrollViewer(r,!0),t._refreshScrollViewer(s,!0)):t.virtualization&&t._refreshScrollViewer(r,!0),t._refreshSummaries(),t._autoSaveState("dataSource")}_getCurrentDataSource(){const e=Array.from(this.$.container.getElementsByClassName("smart-kanban-task")),t=[],a=this;if(a.virtualization){const e=Object.keys(a.tasksByDataField);let t=[];for(let s=0;s<e.length;s++){const l=e[s];let o=a._getTasksByDataField(l);t=[...t,...o]}return t}for(let a=0;a<e.length;a++)t.push(e[a].data);return t}_validateTaskArgument(e){const t=this;return e instanceof HTMLElement&&t.$.container.contains(e)&&e.classList.contains("smart-kanban-task")?e:null===e||"number"!=typeof e&&"string"!=typeof e?void 0:t.$.container.querySelector(`.smart-kanban-task[data-id="${e}"]`)}_openDialog(e,t,a="task"){const s=this,l={purpose:t};if(l[a]=e,s.$.fireEvent("opening",l).defaultPrevented)return;if(s.disableDialog)return;s._dialog||s._createDialog();const o=s._dialog,i="prompt"===t;o.refreshFieldsDirty=!0,o.openedFrom=(s.shadowRoot||s.getRootNode()).activeElement,o.classList.toggle("prompt",i),o.classList.toggle("edit",!i),o.style.top="",o.style.left="",o.style.width="",o.style.height="auto","edit"!==t||!s.readonly&&s._currentUser.allowEdit?o.removeAttribute("readonly"):o.setAttribute("readonly",""),s.offsetWidth<600&&(o.style.top="0px",o.style.left="0px",o.style.width="100%",o.style.height="100%");const r=e=>{s.applyColumnColorToTasks&&(e&&e.color?(o.style.setProperty("--smart-primary",e.color),o.style.setProperty("--smart-ui-state-active",e.color)):(o.style.setProperty("--smart-primary",""),o.style.setProperty("--smart-ui-state-active","")))};if(e&&e.column?r(e.column):"add"===t&&r(e),o.taskOrComment=e,"edit"===t?s._currentUser&&s._currentUser.allowRemove&&o.querySelector(".delete").classList.remove("smart-hidden"):o.querySelector(".delete").classList.add("smart-hidden"),o.editPanelPopulated&&(o.selectTab(0),o.editors.historyTab&&o.editors.historyTab.classList.add("smart-hidden")),i){let t="task"===a?s.localize("promptTask",{taskText:e.data[s.dataSourceMap.text]}):s.localize("promptComment"),l="task"===a?s.localize("removeTask",{taskText:e.data[s.dataSourceMap.text]}):s.localize("removeComment");"column"===a&&(t=s.localize("promptColumn"),l=s.localize("removeColumn")),o.label=l,o.setAttribute("aria-label",t),o.$.container.querySelector(".prompt").innerHTML=t}else{let a=!0;o.removeAttribute("aria-label"),o.headerPosition="top",o.editPanelPopulated||(s._initEditPanel(),a=!1),"edit"===t?s._beginEdit(e):"add"===t&&(o.label=s.localize("addNewTask"),delete o.taskOrComment,a&&s._clearEditors(),s._showHideDialogEditors(),o.refreshTabs(!1),o.selectTab(0),o.editors.status.selectedValues=[e.dataField],0===s.swimlanes.length?(o.editors.swimlane.classList.add("smart-hidden"),o.editors.swimlaneLabel.classList.add("smart-hidden"),o.editors.swimlane.parentElement.classList.add("single-column")):(o.editors.swimlane.classList.remove("smart-hidden"),o.editors.swimlaneLabel.classList.remove("smart-hidden"),o.editors.swimlane.parentElement.classList.remove("single-column")),o.editors.created.parentElement.classList.add("smart-hidden"),o.editors.updated.parentElement.classList.add("smart-hidden"))}s.$.container.setAttribute("modal","");const n=s.offset(s);s.offsetWidth>600&&(o.offsetHeight>s.offsetHeight?o.style.top=s.getBoundingClientRect().top+"px":o.style.top=n.top+s.offsetHeight/2-o.offsetHeight/2+"px",o.offsetWidth>s.offsetWidth?o.style.left=s.getBoundingClientRect().left+"px":o.style.left=n.left+s.offsetWidth/2-o.offsetWidth/2+"px"),s.dialogCustomizationFunction&&s.dialogCustomizationFunction(o,e,o.editors,o.labels,t,a),o.open()}_createDialog(){const e=this,t=document.createElement("smart-window"),a=document.createElement("template"),s=` animation="${e.animation}"${e._rtlAttr} theme="${e.theme}"${e.unfocusable?" unfocusable":""}`;a.innerHTML=`<smart-button class="ok primary"${s}><span class="smart-icon"></span>${e.localize("ok")}</smart-button>\n<smart-button class="cancel"${s}><span class="smart-icon"></span>${e.localize("cancel")}</smart-button><smart-button class="smart-hidden delete secondary"${s}><span class="smart-icon"></span>${e.localize("delete")}</smart-button>`,t.animation=e.animation,t.footerTemplate=a,t.headerButtons=["close"],t.rightToLeft=e.rightToLeft,t.resizeMode="both",t.liveResize=!0,t.theme=e.theme,t.className="smart-kanban-window",t.innerHTML='<div class="prompt"></div>\n<div class="edit"></div>',t.ownerElement=e,e._dialog=t,e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(t)}_addDialogHandlers(){const e=this,t=e._dialog;t.addEventListener("open",e._dialogEventHandler),t.addEventListener("closing",e._dialogEventHandler),t.addEventListener("close",e._dialogEventHandler),t.addEventListener("click",e._dialogClickHandler),t.addEventListener("keydown",(e=>{if("Enter"===e.key){const e=t.querySelector(".ok"),a=t.querySelector('.smart-kanban-tab[view="details"]');a&&a.classList.contains("selected")&&(e.disabled||e.click())}}))}_dialogEventHandler(e){const t=this,a=t.ownerElement,s=e.type,l=a.context;(t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target)===t&&(a.context=a,"open"===s?(a.$.fireEvent("open"),t.classList.contains("edit")&&(a.hasAnimation?t.addEventListener("transitionend",(function(){setTimeout((()=>{!a.readonly&&a._currentUser.allowEdit&&t.editors.text.focus()}),100)}),{once:!0}):requestAnimationFrame((()=>t.editors.text.focus())))):"closing"===s?a.$.fireEvent("closing").defaultPrevented&&(e.preventDefault(),delete t.ok):"close"===s&&(a.$.fireEvent("close"),a._dialogCloseHandler(e)),a.context=l)}_dialogClickHandler(e){const t=this,a=t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target;if(a.closest(".ok"))t.ok=!0,t.close();else if(a.closest(".cancel"))t.close();else if(a.closest(".delete"))t.ownerElement.removeTask(t.taskOrComment),t.close();else if(a.closest(".add")){const e=t.editors.newSubtask,a=e.value;if(""===a)return;const s=t.editors.checklist;s.insert(s.items.length,{label:a}),e.value="",t.$.content.scrollTop=t.$.content.scrollHeight-t.$.content.offsetHeight,t.refreshTabs()}else if(a.classList.contains("remove-subtask"))t.editors.checklist.removeChild(a.closest("smart-list-item")),t.refreshTabs();else if(a.classList.contains("remove-button")){const e=t.ownerElement,s=t.ownerElement.dataSourceMap,l=t.taskOrComment.data[s.comments],o=a.closest(".smart-comment").comment,i=JSON.parse(JSON.stringify(t.taskOrComment.data));t.taskOrComment.comment=o,t.taskOrComment.data[s.comments]=l.filter((e=>e!==t.taskOrComment.comment)),t.refreshComments();const r=JSON.parse(JSON.stringify(t.taskOrComment.data));e.$.fireEvent("change",{task:t.taskOrComment,id:r.id,value:r,oldValue:i}),e.$.fireEvent("taskUpdate",{id:r.id,value:r,oldValue:i}),e.$.fireEvent("commentRemove",{id:r.id,value:t.taskOrComment.comment})}}_dialogCloseHandler(){const e=this,t=e.dataSourceMap,a=e._dialog;function s(s){const l=JSON.parse(JSON.stringify(s.data));a.taskOrComment.remove(),s.querySelector(".smart-kanban-task-comments").setAttribute("num",s.data[t.comments].length||""),e._commentsList.editing&&(e._commentsList.textarea.value="",delete e._commentsList.editing);const o=JSON.parse(JSON.stringify(s.data));e.$.fireEvent("change",{task:s,id:o.id,value:o,oldValue:l}),e.$.fireEvent("taskUpdate",{id:o.id,value:o,oldValue:l}),e.$.fireEvent("commentRemove",{id:o.id,value:a.taskOrComment.comment})}if(e.$.container.removeAttribute("modal"),a.ok){if(a.classList.contains("prompt")){const l=e._commentSelectionFor;if(l){const o=l.data;if(e.dataSource&&e.dataSource.virtualDataSource){const i=Object.assign({},o);i[t.comments]=i[t.comments].filter((e=>e!==a.taskOrComment.comment)),e._requestVirtualDataSource("update",i,(function(e){return e&&(l.data=i,s(l)),e}))}else o[t.comments]=o[t.comments].filter((e=>e!==a.taskOrComment.comment)),s(l)}else e._columnActionSelectionFor&&a.taskOrComment.dataField?e.removeColumn(a.taskOrComment.dataField):e.removeTask(a.taskOrComment)}else e._endEdit();delete a.ok}a.openedFrom&&requestAnimationFrame((()=>{e.getRootNode().contains(a.openedFrom)&&a.openedFrom.focus&&a.openedFrom.focus(),delete a.openedFrom})),delete a.taskOrComment}_closeDialog(){const e=this;e._dialog&&e._dialog.close()}_getHistoryItemLabel(e){const t=this;let a;switch(e.action){case"created":a=t.localize("taskCreated");break;case"tags":a=t.localize("taskTagsChanged");break;case"description":a=t.localize("taskDescriptionChanged");break;case"progress":a=t.localize("taskProgressChanged");break;case"text":a=t.localize("taskNameChanged");break;case"color":a=t.localize("taskColorChanged");break;case"priority":a=t.localize("taskPriorityChanged");break;case"deadline":a=t.localize("taskDeadlineChanged");break;case"subtasks":a=t.localize("taskSubtasksChanged");break;case"user":a=e.details.value?t.localize("taskUserChanged"):t.localize("taskUserRemoved");break;case"moved":a=t.localize("taskMoved");break;case"status":a=t.localize("taskStatusChanged");break;default:a=t.localize("taskUpdated")}return a}_initEditPanel(){const e=this,t=e.id,a=e._dialog,s=a.$.container.querySelector(".edit"),l=[""].concat(e.users.map((e=>({label:e.name,value:e.id,color:e.color,image:e.image})))),o=e._allColumns.map((e=>({color:e.color,label:e.label,value:e.dataField}))),i=e._getPriority(),r=e.swimlanes.map((e=>({label:e.label,value:e.dataField}))),n=document.createElement("template"),d=` animation="${e.animation}"${e._rtlAttr} theme="${e.theme}"${e.unfocusable?" unfocusable":""}`;n.innerHTML=`<div class="smart-kanban-sub-task"><span class="label">{{label}}</span><span class="remove-subtask" aria-label="Remove subtask" title="${e.localize("removeSubtask")}"></span></div>`,n.id=e.id+"ChecklistTemplate",a.$.container.appendChild(n),s.innerHTML=`\n <div tabindex="0" class="smart-kanban-tab-strip">\n <div tabindex="0" view="details" class="selected smart-kanban-tab"><div class="smart-kanban-tab-label">${e.localize("detailsTab")}</div></div>\n <div tabindex="0" view="subtasks" class="smart-kanban-tab"><div class="smart-kanban-tab-label">${e.localize("subtasksTab")}</div></div>\n <div tabindex="0" view="comments" class="smart-kanban-tab"><div class="smart-kanban-tab-label">${e.localize("commentsTab")}</div></div>\n <div tabindex="0" view="history" class="smart-kanban-tab smart-hidden"><div class="smart-kanban-tab-label">${e.localize("historyTab")}</div></div>\n <div tabindex="0" view="fields" class="smart-kanban-tab smart-hidden"><div class="smart-kanban-tab-label">${e.localize("fieldsTab")}</div></div>\n </div>\n <div class="smart-kanban-tab-content details">\n <div class="layout">\n <div class="column">\n <div id="${t}LabelText" class="editor-label">${e.localize("text")}</div>\n <smart-input class="editor text-editor" aria-labelledby="${t}LabelText"></smart-input>\n <div id="${t}LabelDescription" class="editor-label">${e.localize("description")}</div>\n <textarea class="editor description-editor" aria-labelledby="${t}LabelDescription"></textarea> \n <div id="${t}LabelStatus" class="editor-label">${e.localize("status")}</div>\n <smart-multi-combo-input single-select pills color-items class="editor status-editor" drop-down-open-position="auto" data-source='${JSON.stringify(o)}' drop-down-button-position="right" readonly${d} aria-labelledby="${t}LabelStatus"></smart-multi-combo-input>\n <div id="${t}LabelSwimlane" class="editor-label swimlane-label">${e.localize("swimlane")}</div>\n <smart-input class="editor swimlane-editor" drop-down-open-position="auto" data-source='${JSON.stringify(r)}'${0===r.length?" disabled":""} drop-down-button-position="right" readonly${d} aria-labelledby="${t}LabelSwimlane"></smart-input>\n </div>\n <div class="column">\n <div class="editor-container">\n <div id="${t}LabelAssignedTo" class="editor-label">${e.localize("assignedTo")}</div>\n <div id="${t}LabelProgress" class="editor-label">${e.localize("progress")}</div>\n <smart-multi-combo-input readonly pills class="editor asignee-editor" single-select data-source='${JSON.stringify(l)}'${0===l.length?" disabled":""} drop-down-button-position="right"${d} aria-labelledby="${t}LabelAssignedTo"></smart-multi-combo-input>\n <smart-numeric-text-box class="editor progress-editor" input-format="floatingPoint" min="0" max="100" show-unit unit="%"${d} aria-labelledby="${t}LabelProgress"></smart-numeric-text-box>\n </div>\n <div class="editor-container">\n <div id="${t}LabelStartDate" class="editor-label">${e.localize("startDate")}</div>\n <div id="${t}LabelDueDate" class="editor-label">${e.localize("dueDate")}</div>\n <smart-date-time-picker auto-close auto-open class="editor start-date-editor" calendar-button drop-down-append-to="body" drop-down-display-mode="calendar" format-string="${e.formatStringDate}" nullable${d} value="null" aria-labelledby="${t}LabelStartDate"></smart-date-time-picker>\n <smart-date-time-picker auto-close auto-open class="editor due-date-editor" calendar-button drop-down-append-to="body" drop-down-display-mode="calendar" format-string="${e.formatStringDate}" nullable${d} value="null" aria-labelledby="${t}LabelDueDate"></smart-date-time-picker>\n </div>\n <div class="editor-error-container smart-hidden" style="color: var(--smart-error);">\n <label id="${t}LabelRange">${e.localize("invalidRange",{start:e.localize("startDate"),end:e.localize("dueDate")})}</label>\n <br/> <br/>\n </div>\n <div class="editor-container">\n <div id="${t}LabelPriority" class="editor-label">${e.localize("priority")}</div>\n <div id="${t}LabelColor" class="editor-label">${e.localize("color")}</div>\n <smart-input class="editor priority-editor" data-source='${JSON.stringify(i)}' drop-down-height="auto" drop-down-open-position="auto" drop-down-button-position="right" readonly${d} aria-labelledby="${t}LabelPriority"></smart-input>\n <smart-color-input value-display-mode="colorBox" class="editor color-editor" drop-down-open-position="auto" drop-down-button-position="right"${d} aria-labelledby="${t}LabelColor"></smart-color-input>\n </div>\n <div id="${t}LabelTags" class="editor-label">${e.localize("tags")}</div>\n <smart-multi-combo-input color-items readonly pills class="editor tags-editor" drop-down-button-position="right" drop-down-open-position="auto" ${d} aria-labelledby="${t}LabelTags"></smart-multi-combo-input>\n </div>\n </div>\n </div>\n <div class="smart-kanban-tab-content smart-hidden subtasks">\n <div id="${t}LabelChecklist" class="editor-label">${e.localize("checklist")}</div>\n <div class="new-container">\n <input type="text" class="new-subtask" placeholder="${e.localize("newSubtask")}" />\n <smart-button class="add primary" title="${e.localize("addSubtask")}" aria-label="Add subtask"${d}>+</smart-button>\n </div>\n <smart-list-box class="editor checklist-editor" item-template="${n.id}" selection-mode="checkBox"${d} aria-labelledby="${t}LabelChecklist"></smart-list-box>\n <br/>\n </div>\n <div class="smart-kanban-tab-content comments">\n </div>\n <div class="smart-kanban-tab-content smart-hidden history">\n <div class="editor-container">\n <div id="${t}LabelCreatedBy" class="editor-label">${e.localize("createdBy")}</div>\n <div id="${t}LabelCreatedByDate" class="editor-label">${e.localize("createdByDate")}</div>\n <div class="editor created" aria-labelledby="${t}LabelCreatedBy"></div>\n <div class="editor created-date" aria-labelledby="${t}LabelCreatedByDate"></div>\n </div>\n <div class="editor-container">\n <div id="${t}LabelUpdatedBy" class="editor-label">${e.localize("updatedBy")}</div>\n <div id="${t}LabelUpdatedBy" class="editor-label">${e.localize("updatedByDate")}</div>\n <div class="editor updated" aria-labelledby="${t}LabelUpdatedBy"></div>\n <div class="editor updated-date" aria-labelledby="${t}LabelUpdatedByDate"></div>\n </div>\n <div class="history-table smart-hidden editor-container">\n </div>\n </div>\n <div class="smart-kanban-tab-content fields">\n </div> \n<div class="template-container">\n</div>\n`,a.layout=s.querySelector(".layout"),a.editors={text:s.querySelector(".text-editor"),description:s.querySelector(".description-editor"),tags:s.querySelector(".tags-editor"),userId:s.querySelector(".asignee-editor"),status:s.querySelector(".status-editor"),swimlane:s.querySelector(".swimlane-editor"),swimlaneLabel:s.querySelector(".swimlane-label"),startDate:s.querySelector(".start-date-editor"),dueDate:s.querySelector(".due-date-editor"),progress:s.querySelector(".progress-editor"),priority:s.querySelector(".priority-editor"),color:s.querySelector(".color-editor"),newSubtask:s.querySelector(".new-subtask"),checklist:s.querySelector(".checklist-editor"),template:s.querySelector(".template-container"),created:s.querySelector(".created"),createdDate:s.querySelector(".created-date"),updated:s.querySelector(".updated"),updatedDate:s.querySelector(".updated-date"),tabs:s.querySelector(".smart-kanban-tab-strip"),detailsTab:s.querySelector('[view="details"]'),commentsTab:s.querySelector('[view="comments"]'),subtasksTab:s.querySelector('[view="subtasks"]'),historyTab:s.querySelector('[view="history"]'),fieldsTab:s.querySelector('[view="fields"]')},a.labels={};for(let e in a.editors){const t=a.editors[e].getAttribute("aria-labelledby"),l=s.querySelector("#"+t);l&&(a.labels[e]=l)}a.tabs={all:a.editors.tabs,detail:a.editors.detailsTab,comments:a.editors.commentsTab,history:a.editors.historyTab,subtasks:a.editors.subtasksTab,fields:a.editors.fieldsTab};const c=()=>{a.editors.status.classList.contains("smart-hidden")&&a.editors.text.classList.contains("smart-hidden")&&a.editors.description.classList.contains("smart-hidden")?(a.editors.description.closest(".column").classList.add("smart-hidden"),a.editors.description.closest(".layout").classList.add("single-column")):e.dialogEditors&&3===e.dialogEditors.length&&e.dialogEditors.indexOf("text")>=0&&e.dialogEditors.indexOf("description")>=0&&e.dialogEditors.indexOf("status")>=0?a.editors.description.closest(".layout").classList.add("single-column"):(a.editors.description.closest(".column").classList.remove("smart-hidden"),a.editors.description.closest(".column").classList.remove("single-column"),a.editors.description.closest(".layout").classList.remove("single-column"))};a.showEditor=e=>{const t=e=>{if(e){const t=[...e.children];let a=0;for(let e=0;e<t.length;e++)t[e].classList.contains("smart-hidden")||a++;a===t.length&&e.classList.remove("single-column")}};a.editors[e]&&(a.editors[e].classList.remove("smart-hidden"),t(a.editors[e].closest(".editor-container"))),a.labels[e]&&(a.labels[e].classList.remove("smart-hidden"),t(a.labels[e].closest(".editor-container"))),"checklist"===e&&a.tabs.subtasks.classList.remove("smart-hidden"),c()},a.hideEditor=e=>{if(a.editors[e]){a.editors[e].classList.add("smart-hidden");const t=a.editors[e].closest(".editor-container");t&&t.classList.add("single-column")}a.labels[e]&&a.labels[e].classList.add("smart-hidden"),"checklist"===e&&a.tabs.subtasks.classList.add("smart-hidden"),c()};const u=a.editors.tabs.querySelectorAll(".smart-kanban-tab");a.selectTab=e=>{if(u[e]&&!u[e].classList.contains("smart-hidden")&&u[e].click(),0===e){const e=[...a.tabs.all.children];for(let t=0;t<e.length;t++)if(e[t]&&!e[t].classList.contains("smart-hidden")){e[t].click();break}}},a.refreshTabs=t=>{const s=a.taskOrComment?a.taskOrComment.data[e.dataSourceMap.comments]:0,l=s&&s.length?'<span class="summary"> ('+s.length+")</span>":"";let o=a.taskOrComment?a.taskOrComment.data[e.dataSourceMap.checklist]:0,i=o&&o.length?'<span class="summary"> ('+o.length+")</span>":"";t||(o=a.editors.checklist.items.length,o&&(i=o?'<span class="summary"> ('+o+")</span>":"")),a.editors.commentsTab.innerHTML=`${e.localize("commentsTab")}${l}`,a.editors.subtasksTab.innerHTML=`${e.localize("subtasksTab")}${i}`,e._currentUser.allowComment&&a.taskOrComment?a.editors.commentsTab.classList.remove("smart-hidden"):a.editors.commentsTab.classList.add("smart-hidden"),e.readonly&&!o?a.editors.subtasksTab.classList.add("smart-hidden"):a.editors.checklist.classList.contains("smart-hidden")||a.editors.subtasksTab.classList.remove("smart-hidden"),e.taskCustomFields.length>0?a.editors.fieldsTab.classList.remove("smart-hidden"):a.editors.fieldsTab.classList.add("smart-hidden"),a.taskOrComment&&(a.taskOrComment.data[e.dataSourceMap.updatedDate]||a.taskOrComment.data[e.dataSourceMap.createdDate])?a.editors.historyTab.classList.remove("smart-hidden"):a.editors.historyTab.classList.add("smart-hidden");const r=["checklist","color","dueDate","priority","progress","startDate","status","swimlane","tags","text","description","userId"];let n=0;for(let e=0;e<r.length;e++){const t=r[e];a.editors[t].classList.contains("smart-hidden")&&n++}n===r.length?a.tabs.detail.classList.add("smart-hidden"):a.tabs.detail.classList.remove("smart-hidden")},a.refreshFields=()=>{const t=a.querySelector(".fields"),s=a.taskOrComment?a.taskOrComment.data:{},l=e.taskCustomFields.length,o=a.querySelectorAll(["[container-for]"]).length;if(e._resetFields&&(delete e._resetFields,a.refreshFieldsDirty=!0,t.innerHTML=""),!0===a.refreshFieldsDirty)if(a.refreshFieldsDirty=!1,t.firstElementChild&&l<=o)for(let t=0;t<e.taskCustomFields.length;t++){const l=e.taskCustomFields[t];let o=s[l.dataField];const i=a.querySelector("[container-for="+l.dataField+"]");if(!i)continue;e.dataSourceMap[l.dataField]?i.classList.add("smart-hidden"):i.classList.remove("smart-hidden"),null==o&&(o="");const r=i.lastElementChild.firstElementChild;r.removeAttribute("dirty"),o&&o instanceof Date&&"dateInput"===l.editor?r.value=o:r.value=""+o}else{const a=document.createDocumentFragment(),l=(t,a,s)=>{null==a&&(a="");const l=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div");void 0===s.visible&&(s.visible=!0),void 0===s.allowHide&&(s.allowHide=!0),s.allowHide?o.innerHTML=t+'<span class="icon"></span>':o.innerHTML=t,o.classList.add("editor-label"),s.allowHide&&(!1===s.visible&&o.lastElementChild.classList.add("hide"),o.lastElementChild.onpointerdown=()=>{s.visible=!s.visible,o.lastElementChild.classList.toggle("hide")}),i.classList.add("editor");let r=document.createElement("input");if(r.classList.add("smart-input"),void 0!==s.minLength&&(r.minLength=s.minLength),void 0!==s.maxLength&&(r.maxLength=s.maxLength),"textarea"===s.editor)r=document.createElement("smart-text-area"),void 0!==s.minLength&&(r.minLength=s.minLength),void 0!==s.maxLength&&(r.maxLength=s.maxLength);else if("password"===s.editor)r.type="password";else if("phone"===s.editor||"tel"===s.editor)Smart.PhoneInput?r=document.createElement("smart-phone-input"):r.type="tel";else if("url"===s.editor)r.type="url";else if("email"===s.editor)r.type="email";else if("date"===s.dataType||"dateInput"===s.editor)r=document.createElement("smart-date-input"),r.autoClose=!0,""===a&&(a=new Date),void 0!==s.minDate&&(r.min=s.minDate),void 0!==s.maxDate&&(r.max=s.maxDate);else if("boolean"===s.dataType)r=document.createElement("smart-check-box"),""===a&&(a=!1);else if("number"===s.dataType||"numberInput"===s.editor)r=document.createElement("smart-number-input"),a||(a=0),void 0!==s.min&&(r.min=s.min),void 0!==s.max&&(r.max=s.max);else if("string"===s.dataType&&s.options)r=document.createElement("smart-input"),r.readonly=!0,r.dropDownButtonPosition="right",r.dataSource=s.options;else if("string"===s.dataType&&"multiComboInput"===s.editor)r=document.createElement("smart-multi-combo-input"),r.readonly=!0,r.dropDownButtonPosition="right",r.dataSource=s.dataSource,r.pills=!0,r.selectedValues=[""+a],s.singleSelect&&(r.singleSelect=!0),s.colorItems&&(r.colorItems=!0);else if("string"===s.dataType&&("image"===s.editor||"images"===s.editor)&&a.length>50)if(a.indexOf("base64")>=0){a=JSON.parse(a),window.Smart._createSmartImageModal=e._createImageModal;let t="";for(let e=0;e<a.length;e++){const s=a[e];t+=`<img style="margin-left: 5px;" onpointerdown="Smart._createSmartImageModal(this, event)" width="20" height="20" src="${s.value}" title="${s.label}"/>`}r=document.createElement("div"),r.innerHTML=t}else a=a.substring(0,50)+"...";return r.setAttribute("data-field",s.dataField),r.classList.add("smart-kanban-task-field-editor"),r.value=""+a,r.onchange=()=>{r.setAttribute("dirty","")},i.appendChild(r),l.appendChild(o),l.appendChild(i),l.setAttribute("container-for",s.dataField),l},o=document.createElement("div");o.classList.add("editor-container"),a.appendChild(o);for(let t=0;t<e.taskCustomFields.length;t++){const a=e.taskCustomFields[t],i=l(a.label,s[a.dataField],a);o.appendChild(i),e.dataSourceMap[a.dataField]&&i.classList.add("smart-hidden")}t.innerHTML="",t.appendChild(a)}},a.refreshHistory=()=>{const t=a.querySelector(".history-table");if(!e.storeHistory)return void t.classList.add("smart-hidden");t.classList.remove("smart-hidden");const s=a.taskOrComment.data.history;let l=`<table><tr>\n <th>${e.localize("historyEvent")}</th>\n <th>${e.localize("historyAuthor")}</th>\n <th>${e.localize("historyDetails")}</th>\n <th>${e.localize("historyDate")}</th>\n </tr>\n `;for(let t=s.length-1;t>=0;t--){const a=s[t];if(l+=`<tr>\n <td>${e._getHistoryItemLabel(a)}</td>`,void 0!==a.user){const t=(t=>{const a=t?t.image:null;return{image:a?`background-image: url('${a}');`:"",label:t?t.name||t.id:e.localize("guestUser")}})(e.users.find((e=>e.id===a.user)));l+=`<td><div class="smart-kanban-task-user-history"><div class="icon smart-kanban-task-user" style="${t.image}"></div><div class="name">${t.label}</div></div></td>`}else l+="<td></td>";if("created"!==a.action){let t=a.details.oldValue,s=a.details.value;if("user"===a.action){const a=e.users.find((e=>e.id===t)),l=e.users.find((e=>e.id===s));t=a?a.name:e.localize("unassigned"),s=l?l.name:e.localize("unassigned")}if(t&&t instanceof Date&&(t=t.toLocaleString()),s&&s instanceof Date&&(s=s.toLocaleString()),"subtasks"===a.action){const t=a.details.value.filter((e=>e.completed));l+=`<td><span class="smart-truncate">${e.localize("taskSubtasksCompleted",{value:t.length+"/"+a.details.value.length})}</span></td>`}else l+=t?`<td><span class="smart-truncate">${e.localize("range",{oldValue:t,newValue:s})}</span></td>`:`<td><span class="smart-truncate">${e.localize("nullRange",{oldValue:t,newValue:s})}</span></td>`}else l+=`<td>${a.details.value}</td>`;l+=`\n <td>${a.date.toLocaleString()}</td>\n </tr>`}l+="</table>",t.innerHTML=l,a.refreshTabs()},a.refreshComments=()=>{if(!a.taskOrComment)return;const t=a.querySelector(".comments");t.classList.remove("smart-hidden");const s=e._getCommentsList(a.taskOrComment);s.classList.remove("dialog");const l=s.querySelector(".send");l&&(l.onclick=t=>{if(l.disabled)return;const s=JSON.parse(JSON.stringify(e._commentSelectionFor.data)),o=e._createComment();e._commentsList.textarea.value="",l.disabled=!0,a.refreshTabs();const i=JSON.parse(JSON.stringify(e._commentSelectionFor.data));e.$.fireEvent("change",{task:e._commentSelectionFor,id:i.id,value:i,oldValue:s}),e.$.fireEvent("taskUpdate",{id:i.id,value:i,oldValue:s}),e.$.fireEvent("commentAdd",{id:i.id,value:o}),t.stopPropagation(),t.preventDefault()}),t.innerHTML="",t.appendChild(s),a.refreshTabs()},u.forEach((e=>{e.onfocus=()=>{e.setAttribute("focus","")},e.onblur=()=>{e.removeAttribute("focus")},e.onkeydown=t=>{"Enter"===t.key&&(e.click(),t.stopPropagation())},e.onclick=e=>{const t=e.target.closest(".smart-kanban-tab"),s=t.getAttribute("view");switch(u.forEach((e=>{e.classList.remove("selected")})),t.focus(),t.classList.add("selected"),a.querySelectorAll(".smart-kanban-tab-content").forEach((e=>{e.classList.add("smart-hidden")})),s){case"details":a.querySelector(".details").classList.remove("smart-hidden");break;case"subtasks":a.querySelector(".subtasks").classList.remove("smart-hidden");break;case"comments":a.refreshComments();break;case"history":a.querySelector(".history").classList.remove("smart-hidden"),a.refreshHistory();break;case"fields":a.querySelector(".fields").classList.remove("smart-hidden"),a.refreshFields()}}})),(()=>{const e=a.editors.color;e.dataSource=["#D50000","#E67C73","#F4511E","#F6BF26","#33B679","#0B8043","#039BE5","#3F51B5","#7986CB","#8E24AA","#616161","#FFFFFF","#000000",""],e.valueDisplayMode="colorBox",e.classList.add("smart-kanban-color-input"),e.style.width="auto",e.style.height="auto",e.readonly=!0,e.dropDownWidth=50;const t=e.$.scrollView;t&&t.classList.add("smart-kanban-color-input"),e.onRender=()=>{const t=e.$.scrollView;t&&t.classList.add("smart-kanban-color-input")}})(),a.editors.newSubtask.onchange=()=>{a.editors.newSubtask.nextElementSibling.click()},a.editPanelPopulated=!0,e.dialogRendered&&e.dialogRendered(a,a.editors,a.labels,a.tabs,a.layout,a.taskOrComment)}_showHideDialogEditors(){const e=this,t=e._dialog,a=["checklist","color","dueDate","priority","progress","startDate","status","swimlane","tags","text","description","userId"];for(let s=0;s<a.length;s++){const l=a[s];e.dialogEditors.indexOf(l)>=0?t.showEditor(l):t.hideEditor(l)}const s=e._allColumns.map((e=>({color:e.color,label:e.label,value:e.dataField})));s.length<=1&&t.hideEditor("status"),t.editors.status.dataSource=s,0===e.users.length&&t.hideEditor("userId")}_unescapeValue(e){if(null==e)return e;const t=[{regex:"&",entity:"&"},{regex:">",entity:">"},{regex:"<",entity:"<"},{regex:'"',entity:"""},{regex:"'",entity:"'"},{regex:"=",entity:"="},{regex:"/",entity:"/"},{regex:"`",entity:"`"}];let a;for(let s in t)a=new RegExp(t[s].entity,"g"),e=e.replace(a,t[s].regex);return e}_escapeValue(e){return e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")}_beginEdit(e){const t=this,a=t.dataSourceMap,s=e.data,l=t._dialog,o=l.editors,i=t.tags.length>0?t.tags:t._customTags,r=t._allColumns.find((e=>e.dataField===s[a.status]));if(l.label=t.localize("editTask",{taskId:s[a.id],text:s[a.text]}),o.text.value=t._unescapeValue(s[a.text]),o.description.value=t._unescapeValue(s[a.description]),o.tags.dataSource=i,t._showHideDialogEditors(),t.allowCustomTags,s[a.tags]){const e=e=>{let a=[];e.indexOf(",")>=0?a=e.split(","):Array.isArray(e)?a=a.concat(e):a.push(e);const s=[];for(let e=0;e<a.length;e++)"string"==typeof a[e]?(a[e]=t._unescapeValue(a[e].trim()),s.push(a[e])):(a[e].label=t._unescapeValue(a[e].label),s.push(a[e].value));return s};if(!t.allowCustomTags){const l=t.tags.length>0?t.tags:e(s[a.tags]);o.tags.dataSource=l}o.tags.selectedValues=e(s[a.tags])}else o.tags.selectedValues=[];l.editors.created.parentElement.classList.add("smart-hidden"),l.editors.updated.parentElement.classList.add("smart-hidden");const n=void 0!==s[a.createdUserId]?t.users.find((e=>e.id===s[a.createdUserId])):"",d=s[a.createdDate],c=void 0!==s[a.updatedUserId]?t.users.find((e=>e.id===s[a.updatedUserId])):"",u=s[a.updatedDate],m=e=>{const a=e?e.image:null;return{image:a?`background-image: url('${a}');`:"",label:e?e.name||e.id:t.localize("guestUser")}};if(n){const e=m(n);l.editors.created.parentElement.classList.remove("smart-hidden"),l.editors.created.innerHTML=`<div class="icon smart-kanban-task-user" style="${e.image}"></div><div class="name">${e.label}</div>`,d&&(l.editors.createdDate.innerHTML=d.toLocaleString())}if(c){const e=m(c);l.editors.updated.parentElement.classList.remove("smart-hidden"),l.editors.updated.innerHTML=`<div class="icon smart-kanban-task-user" style="${e.image}"></div><div class="name">${e.label}</div>`,u&&(l.editors.updatedDate.innerHTML=u.toLocaleString())}const p=null!==s[a.userId]?t.users.find((e=>e.id===s[a.userId])):"";p?o.userId.selectedItems=[{label:p.name,value:p.id,image:p.image?p.image:null}]:o.userId.value="",delete o.userId.$.input.dataValue,o.status.selectedValues=[r.dataField],t.readonly||!t._currentUser.allowEdit?(o.status.readonly=!1,o.priority.readonly=!1):(o.status.readonly=!0,o.priority.readonly=!0),delete o.status.$.input.dataValue,t._hasSwimlane(t.columns.indexOf(r))?o.swimlane.value=t.swimlanes.find((e=>e.dataField===s[a.swimlane])).label:o.swimlane.value="",delete o.swimlane.$.input.dataValue,o.startDate.value=s[a.startDate]||null,o.dueDate.value=s[a.dueDate]||null,o.progress.value=parseFloat(s[a.progress])||0;const h=t.localize(s[a.priority]);o.priority.value=null!=h?h:"",delete o.priority.$.input.dataValue,o.color.value=s[a.color]||"";const g=[],f=[];(s[a.checklist]||[]).forEach(((e,t)=>{e.completed&&g.push(t),f.push({label:e.text,selected:!0===e.completed})})),0===t.swimlanes.length?(l.editors.swimlane.classList.add("smart-hidden"),l.editors.swimlaneLabel.classList.add("smart-hidden"),l.editors.swimlane.parentElement.classList.add("single-column")):(l.editors.swimlane.classList.remove("smart-hidden"),l.editors.swimlaneLabel.classList.remove("smart-hidden"),l.editors.swimlane.parentElement.classList.remove("single-column")),o.dueDate.onchange=o.startDate.onchange=()=>{o.startDate.value>=o.dueDate.value&&o.dueDate.value?(l.$.footer.firstElementChild.disabled=!0,l.querySelector(".editor-error-container").classList.remove("smart-hidden")):(l.$.footer.firstElementChild.disabled=!1,l.querySelector(".editor-error-container").classList.add("smart-hidden"))},o.startDate.value&&o.startDate.value>=o.dueDate.value&&o.dueDate.value&&(l.$.footer.firstElementChild.disabled=!0,l.querySelector(".editor-error-container").classList.remove("smart-hidden")),o.newSubtask.value="",o.checklist.dataSource=f,o.checklist.selectedIndexes=g,l.refreshTabs(!0),l.selectTab(0)}_endEdit(){const e=this,t=e.dataSourceMap,a=e._dialog,s=a.editors,l=a.taskOrComment,o=l?l.data:void 0,i=Object.assign({},o);let r=s.startDate.value,n=s.dueDate.value;i[t.text]=e._escapeValue(s.text.value),i[t.description]=e._escapeValue(s.description.value);const d=[];for(let t=0;t<s.tags.dataSource.length;t++){const a=s.tags.dataSource[t];"string"==typeof a?s.tags.selectedValues.indexOf(a)>=0&&d.push(e._escapeValue(a)):s.tags.selectedValues.indexOf(a.value)>=0&&(a.label=e._escapeValue(a.label),d.push(a))}if(i[t.tags]=d,i[t.progress]=parseFloat(s.progress.value),i[t.color]=s.color.value,e._currentUser.info&&(i[t.updatedUserId]=e._currentUser.info.id,i[t.updatedDate]=new Date),i[t.color]||""===i[t.color]||delete i[t.color],void 0!==s.userId.$.input.dataValue&&(i[t.userId]=parseFloat(s.userId.$.input.dataValue)),void 0!==s.status.$.input.dataValue&&(i[t.status]=s.status.$.input.dataValue),s.swimlane.$.input.dataValue&&(i[t.swimlane]=s.swimlane.$.input.dataValue),r&&(r=r.toDate()),n&&(n=n.toDate()),i[t.startDate]=r,i[t.dueDate]=n,void 0!==s.priority.$.input.dataValue&&(i[t.priority]=s.priority.$.input.dataValue),i[t.checklist]=s.checklist.items.map((e=>({text:e.label,completed:e.selected}))),e.taskCustomFields&&e.taskCustomFields.length>0)for(let t=0;t<e.taskCustomFields.length;t++){const s=e.taskCustomFields[t],l=a.querySelector("[data-field="+s.dataField+"]");if(l){let t=l.value;l.dataSource&&l.dataSource.length>0&&l.selectedValues.length>0&&(t=l.selectedValues.toString()),"smart-number-input"===l.nodeName.toLowerCase()&&(t=l.getValue()),"smart-date-input"===l.nodeName.toLowerCase()&&(t=l.getValue()),(l.hasAttribute("dirty")||e.dialogCustomizationFunction)&&(i[s.dataField]=t)}}l?e.updateTask(l,i):e.addTask(i),s.tags.close()}_clearEditors(){const e=this,t=e._dialog.editors,a=e.tags.length>0?e.tags:e._customTags;t.text.value="",t.description.value="",t.tags.dataSource=a,t.tags.selectedValues=[],t.status.selectedValues=[],delete t.status.$.input.dataValue,t.swimlane.value="",delete t.swimlane.$.input.dataValue,t.userId.value="",delete t.userId.$.input.dataValue,t.progress.value=0,t.startDate.value=null,t.dueDate.value=null,t.priority.value=e.localize("average"),t.priority.$.input.dataValue="average",t.color.value="",t.newSubtask.value="",t.created.innerHTML="",t.updated.innerHTML="",t.createdDate.innerHTML="",t.updatedDate.innerHTML="",t.checklist.dataSource=[],t.checklist.selectedIndexes=[]}_getCurrentUser(){const e=this,t=e.users;let a=e.currentUser,s=!0,l=!0,o=e.allowDrag,i=e.editable,r=!0;t&&null!==a&&(a=t.find((e=>e.id===a)),a&&(s=!1!==a.allowAdd,l=!1!==a.allowComment,o=o&&!1!==a.allowDrag,i=i&&!1!==a.allowEdit,r=!1!==a.allowRemove)),e._currentUser={allowAdd:s,allowComment:l,allowDrag:o,allowEdit:i,allowRemove:r,info:a}}_autoSaveState(e){const t=this;if(t.autoSaveState)if("object"!=typeof e)if(e&&t._autoSavedState){switch(e){case"collapsed":t._allColumns.forEach((e=>t._autoSavedState.collapsed[e.dataField]=e.collapsed));break;case"dataSource":t._autoSavedState.dataSource=t._getCurrentDataSource();break;case"filtering":t._autoSavedState.filtering=t._appliedFiltering;break;case"selection":{const e=t.dataSourceMap;let a=null,s=null;t._selectionInView&&(a=t._selectionInView.closest(".smart-kanban-column").column.dataField,s=t._selectionInView.getAttribute("swimlane")),t._autoSavedState.selection={selected:t._selectedTasks,selectionStart:t._selectionStart?t._selectionStart.data[e.id]:null,selectionInColumn:a,swimlane:s};break}case"sorting":t._autoSaveState.sorting=t._appliedSorting;break;case"tabs":t._autoSaveState.tabs=t._selectedTabs;break;case"visibility":t._autoSavedState.visibility={taskActions:t.taskActions,taskComments:t.taskComments,taskDue:t.taskDue,taskPriority:t.taskPriority,taskProgress:t.taskProgress,taskTags:t.taskTags,taskUserIcon:t.taskUserIcon}}window.localStorage.setItem("smartKanban"+t.id,JSON.stringify(t._autoSavedState))}else t._autoSavedState=t.saveState();else t._autoSavedState=e}_getCurrentDataFields(e){const t=this,a=[{name:"text",dataType:"string"},{name:"tags",dataType:"string"},{name:"priority",dataType:"string"},{name:"progress",dataType:"number"},{name:"startDate",dataType:"date"},{name:"dueDate",dataType:"date"},{name:"userId",dataType:"string"}],s=e&&e.length>0?e[0]:null;for(let e=0;e<t.taskCustomFields.length;e++)if(s){const l=typeof s[t.taskCustomFields[e].dataField];"number"===l?a.push({name:t.taskCustomFields[e].dataField,dataType:"number"}):"date"===l?a.push({name:t.taskCustomFields[e].dataField,dataType:"date"}):a.push({name:t.taskCustomFields[e].dataField,dataType:"string"})}else a.push({name:t.taskCustomFields[e].dataField,dataType:"string"});return a}_applyFilter(e,t){const a=this;if(a.dataSource&&a.dataSource.virtualDataSource)return a._requestVirtualDataSource("filter"),void a._autoSaveState("filtering");const s=a._getCurrentDataSource(),l=a._getCurrentDataFields(s),o=new Smart.DataAdapter({dataSource:s,dataFields:l,id:"id"});try{o._filter(e,t)}catch(e){return}if(a.virtualization){if(e&&e.length>0){const e=Object.keys(a.tasksByDataField);for(let t=0;t<e.length;t++){const s=e[t];delete a.tasksByDataField[s]._filtered;let l=a._getTasksByDataField(s),i=[];for(let e=0;e<l.length;e++){const t=l[e],a=o.dataItemById[t.id];a&&a.$.filtered&&i.push(t)}a.tasksByDataField[s]._filtered=i}}else{const e=Object.keys(a.tasksByDataField);for(let t=0;t<e.length;t++){const s=e[t];delete a.tasksByDataField[s]._filtered}}a._refreshColumns()}else{const e=Array.from(a.$.container.getElementsByClassName("smart-kanban-task"));for(let t=0;t<o.length;t++){const a=e[t],s=!o[t].$.filtered;a.classList.toggle("smart-hidden",s),a.filteredOut=s}a._allColumns.forEach((e=>a._refreshScrollViewer(e)))}a._autoSaveState("filtering")}_applyHandler(e,t){const a=this,s=a.isInShadowDOM||a.shadowRoot?e.composedPath()[0]:e.target,l=e.detail;a.$.customize.contains(s)||"customize"===t?(l.value.forEach((e=>a[e.dataField]=e.visible)),a._allColumns.forEach((e=>a._refreshScrollViewer(e))),a.virtualization&&(delete a._autoCardHeight,a._measureCardHeight(),a._refreshColumns()),a._autoSaveState("visibility")):a.$.filter.contains(s)||"filter"===t?a.addFilter(l.filters,l.operator,l.value):(a.$.sort.contains(s)||"sort"===t)&&a.addSort(l.sortByInfo),a.closePanel()}_applySort(){const e=this,t=e._appliedSorting;if(e._autoSaveState("sorting"),e.dataSource&&e.dataSource.virtualDataSource)e._requestVirtualDataSource("sort");else if(0!==t.dataFields.length)e._allColumns.forEach((a=>{const s=e._columnToElement.get(a).querySelector(".smart-scroll-viewer-content-container"),l=Array.from(s.children),o=[];if(l.length<2)return;let i;if(e.virtualization?e.tasksByDataField[a.dataField].forEach(((t,a)=>{const s=e.dataSourceMap,l=Object.assign({taskIndex:a},t);"low"===l[s.priority]&&(l[s.priority]="z"),o.push(l)})):l.forEach(((t,a)=>{const s=e.dataSourceMap,l=Object.assign({taskIndex:a},t.data);"low"===l[s.priority]&&(l[s.priority]="z"),o.push(l)})),e.taskCustomFields.length){const t=e._getCurrentDataFields(o);t.push({name:"taskIndex",dataType:"number"}),i=new Smart.DataAdapter({dataSource:o,observable:!1,dataFields:t,id:"id"})}else i=new Smart.DataAdapter({dataSource:o,observable:!1,dataFields:["taskIndex: number","text: string","tags: string","priority: string","progress: number","startDate: date","dueDate: date","userId: string"],id:"id"});if(i.sortBy(t.dataFields,t.dataTypes,t.orderBy),e.virtualization){if(e.tasksByDataField[a.dataField]._sorted=Smart.DataAdapter.Sort(e.tasksByDataField[a.dataField],t.dataFields,t.orderBy),e.tasksByDataField[a.dataField]._filtered){e.tasksByDataField[a.dataField]._originalFilteredData=JSON.parse(JSON.stringify(e.tasksByDataField[a.dataField]._filtered));const s=Smart.DataAdapter.Sort([...e.tasksByDataField[a.dataField]._filtered],t.dataFields,t.orderBy);e.tasksByDataField[a.dataField]._filtered=s||[]}e._refreshColumn(a.dataField)}else for(let e=0;e<i.length;e++)s.appendChild(l[i[e].taskIndex])}));else if(e.virtualization){const t=Object.keys(e.tasksByDataField);for(let a=0;a<t.length;a++){const s=t[a];delete e.tasksByDataField[s]._sorted,e.tasksByDataField[s]._filtered&&e.tasksByDataField[s]._originalFilteredData&&(e.tasksByDataField[s]._filtered=e.tasksByDataField[s]._originalFilteredData,delete e.tasksByDataField[s]._originalFilteredData),e._refreshColumn(s)}}}_closeSearchPanel(){const e=this;e._searchInfo&&(Array.from(e.$.container.querySelectorAll(".smart-kanban-task.smart-data-view-found, .smart-kanban-task.smart-data-view-highlighted")).forEach((e=>e.classList.remove("smart-data-view-found","smart-data-view-highlighted"))),delete e._searchInfo)}_constructFilterGroups(e){const t={text:"string",tags:"string",priority:"string",progress:"number",startDate:"date",dueDate:"date"},a={},s=[];e.filters.forEach((s=>{const l=s[0],o=t[l];let i=s[2],r=a[l];void 0===r&&(r=new Smart.Utilities.FilterGroup,a[l]=r),"date"===o&&"string"==typeof i&&(i=new Date(i));const n=r.createFilter(o,i,s[1]);r.addFilter(e.operator,n)}));for(let e in a)s.push([e,a[e]]);return s}_openSearchPanel(){const e=this;e.$.headerDropDown.classList.add("search-panel"),e.$.headerDropDown.classList.remove("customize-panel","filter-panel","sort-panel"),e.$.search.classList.remove("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e._openHeaderDropDown(e.$.searchButton),e._searchInfo={source:e._getCurrentDataSource(),stringDataFields:["text","tags"]},""!==e.$.searchInput.value&&e._search(e.$.searchInput.value,!1)}_search(e,t=!0){const a=this;if(a._searchInfo.query=e,Array.from(a.$.container.querySelectorAll(".smart-kanban-task.smart-data-view-found, .smart-kanban-task.smart-data-view-highlighted")).forEach((e=>e.classList.remove("smart-data-view-found","smart-data-view-highlighted"))),""===e)return a.$.search.classList.remove("matches","no-matches"),delete a._searchInfo.foundIdsArray,delete a._searchInfo.foundIdsObject,void delete a._searchInfo.highlighted;const s=new Smart.DataAdapter({dataSource:a._searchInfo.source,dataFields:["text: string","tags: string"],id:"id"}),l=[],o=[],i={};a._searchInfo.stringDataFields.forEach((t=>{const a=new Smart.Utilities.FilterGroup,s=a.createFilter("string",e,"CONTAINS");a.addFilter("or",s),l.push([t,a])})),s._filter(l,"or");for(let e=0;e<s.length;e++){const t=s[e];!1!==t.$.filtered&&(o.push(t.$.id),i[t.$.id]=!0)}if(a._searchInfo.foundIdsArray=o,a._searchInfo.foundIdsObject=i,Array.from(a.$.container.getElementsByClassName("smart-kanban-task")).forEach((e=>{const s=e.data[a.dataSourceMap.id];if(i[s]){if(e.filteredOut)return o.splice(o.indexOf(s),1),void delete i[s];t&&o[0]===s&&e.classList.add("smart-data-view-highlighted"),e.classList.add("smart-data-view-found")}})),o.length>0){if(t){let e=o[0];a._searchInfo.highlighted=e,a.ensureVisible(e)}return a.$.search.classList.remove("no-matches"),a.$.search.classList.add("matches"),void(a.$.searchLabel.innerHTML=a.localize("found",{nth:t?1:0,n:o.length}))}a.$.search.classList.remove("matches"),a.$.search.classList.add("no-matches"),a.$.searchLabel.innerHTML=a.localize("found",{nth:0,n:0})}_bodyFocusinHandler(e){const t=this;let a=t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target;if(a.classList.contains("smart-kanban-column-content-tasks")&&(a=a.$.content,!t._getSelectedItem(a,!0))){if(t.virtualization){const e=t._focusedTask;return void t.focusTask(e)}if(void 0!==t._focusedTask)return void t.focusTask(t._focusedTask);t._focusTask(t._getFirstItem(a))}}get _rtlAttr(){return this.rightToLeft?" right-to-left":""}get _tabindex(){return this.disabled||this.unfocusable?"":' tabindex="0"'}_appendAddNewColumn(e){const t=document.createElement("div");t.classList.add("smart-kanban-column","smart-kanban-add-new-column","smart-unselectable"),t.innerHTML=`<div class="smart-kanban-column-header smart-unselectable" > <div title="${this.localize("addNewColumn")}" class="smart-kanban-add-new-column-label smart-kanban-column-header-label"><span>+ ${this.localize("addNewStatus")}</span></div></div >\n <div class="smart-kanban-column-content no-sub-columns"><smart-scroll-viewer></smart-scroll-viewer></div>\n `,this.disabled||this.unfocusable||t.setAttribute("tabindex",0),t.column={dataField:"newStatus",label:"New Status"},e.appendChild(t)}selectTask(e){const t=this;t._selectedTasks.push(e),t._selectionStart=e,t._focusedTask=e,t._refreshSelection(),t.ensureVisible(e)}unselectTask(e){const t=this,a=t._selectedTasks.indexOf(e);a>=0&&t._selectedTasks.splice(a,1),t._refreshSelection()}clearSelection(){const e=this;e._selectionStart=null,e._selectedTasks=[],e._refreshSelection()}getSelectedTasks(){return this._selectedTasks||(this._selectedTasks=[]),this._selectedTasks}getTask(e){return this.dataSource?this.dataSource.find((t=>{if(t.id===e)return t})):null}getColumn(e){const t=this;let a=null;for(let s=0;s<t.columns.length;s++)if(t.columns[s].dataField===e){a=t.columns[s];break}return a}getColumnDataItems(e){const t=this;let a=[];if(!t.getColumn(e)||!t.dataSource)return[];for(let s=0;s<t.dataSource.length;s++){const l=t.dataSource[s];l[t.dataSourceMap.status]===e&&a.push(l)}return a}updateColumn(e,t){const a=this;let s=null;for(let t=0;t<a.columns.length;t++)if(a.columns[t].dataField===e){s=a.columns[t];break}if(s){const e=s.label;void 0!==t.label&&(s.label=t.label),void 0!==t.collapsed&&(s.collapsed=t.collapsed),void 0!==t.collapsible&&(s.collapsible=t.collapsible),void 0!==t.orientation&&(s.orientation=t.orientation),void 0!==t.width&&(s.width=t.width),a._reset(),a.$.fireEvent("columnUpdate",{columnData:t,oldValue:e,value:s.label})}}addColumn(e){const t=this;e?(t.columns.push(e),t._reset(),t._createAddNewButton(),t.$.fireEvent("columnAdd",{columnData:e})):t._addNewColumnDynamically()}removeColumn(e){const t=this;let a=null,s=-1;for(let l=0;l<t.columns.length;l++)if(t.columns[l].dataField===e){a=t.columns[l],s=l;break}if(a&&t.columns.splice(s,1),t.dataSource)for(let a=0;a<t.dataSource.length;a++){const s=t.dataSource[a];if(s[t.dataSourceMap.status]===e){const e=JSON.parse(JSON.stringify(s));s[t.dataSourceMap.status]=t.columns[0].value;const a=JSON.parse(JSON.stringify(s));t.$.fireEvent("change",{task:s,id:a.id,value:a,oldValue:e}),t.$.fireEvent("taskUpdate",{id:a.id,value:a,oldValue:e})}}t._reset(),t._createAddNewButton(),t.$.fireEvent("columnRemove",{column:a})}_addNewColumnDynamically(){const e=this,t=e._dialog,a=Math.floor(9e4*Math.random()+1e4),s={label:e.localize("addNewStatus")+" "+a,dataField:"newStatus"+a,addNewButton:!0,collapsed:!1,collapsible:!0,orientation:"vertical"},l=e.$.body.querySelector(".smart-kanban-add-new-column").querySelector(".smart-kanban-add-new-column-label"),o=document.createElement("input");if(l.classList.add("pending"),l.appendChild(o),o.classList.add("smart-kanban-column-header-input"),e.columnColors){l.classList.add("colors");const t=e._getColorInput();l.appendChild(t)}function i(a){let i=o.value,r=l.querySelector("smart-color-input");r&&r.opened?e._columnAddTimer&&clearTimeout(e._columnAddTimer):(!1===/^\s*$/.test(i)?(i=i.trim(),s.label=i,s.dataField="dataField"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)):""===i&&(i="",s.label="",s.dataField="dataField"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),l.classList.contains("pending")&&(e._columnAddTimer&&clearTimeout(e._columnAddTimer),e._columnAddTimer=setTimeout((()=>{if(l.classList.remove("pending"),o.parentNode&&o.parentNode.removeChild(o),r){s.color=r.value;const e=l.querySelector(".heading");if(e){const t=new Smart.Color(s.color).getInvertedColor();e.style.backgroundColor=s.color,e.style.color=t}r.remove()}e.columns.push(s),e._reset(),e._createAddNewButton(),t&&t.editPanelPopulated&&(t.editors.status.dataSource=e._allColumns.map((e=>({color:e.color,label:e.label,value:e.dataField})))),e.$.fireEvent("columnAdd",{newColumn:s}),delete e._columnAddTimer}),50),a.stopPropagation()))}o.focus(),o.onkeydown=e=>{"Escape"===e.key?(l.classList.remove("pending"),o&&o.parentElement&&(o.nextElementSibling&&"Smart-COLOR-INPUT"===o.nextElementSibling.nodeName&&o.nextElementSibling.remove(),o.parentElement.removeChild(o),e.stopPropagation(),e.preventDefault())):"Enter"===e.key&&i(e)},o.addEventListener("blur",i),o.addEventListener("change",i)}_handleColumnEditing(e){const t=this,a=t.columns.find((t=>t.dataField===e));if(t._columnEditing)return;const s=Array.from(t.$.body.getElementsByClassName("smart-kanban-column")).find((t=>t.column.dataField===e)).querySelector(".smart-kanban-column-header-label"),l=document.createElement("input");s.classList.add("pending"),s.appendChild(l);const o=a.label,i=a.color;if(l.value=a.label,l.classList.add("smart-kanban-column-header-input"),t.columnColors){s.classList.add("colors");const e=t._getColorInput();e.value=a.color||"transparent",s.appendChild(e)}function r(e){let r=l.value,n=s.querySelector("smart-color-input");if(!n||!n.opened){if(!1===/^\s*$/.test(r)?(r=r.trim(),a.label=r,s.querySelector(".smart-kanban-title").innerHTML=r):""===r&&(a.label="",s.querySelector(".smart-kanban-title").innerHTML=" "),n){a.color=n.value;const e=s.querySelector(".heading");if(e){const t=new Smart.Color(a.color).getInvertedColor();""===a.color?(e.style.backgroundColor="",e.style.color=""):(e.style.backgroundColor=a.color,e.style.color=t)}t.applyColumnColorToTasks&&s.closest(".smart-kanban-column").style.setProperty("--smart-primary",a.color),n.remove()}s.classList.remove("pending");try{l.parentNode&&l.parentNode.removeChild(l)}catch(e){t._error=e}t._columnEditTimer&&clearTimeout(t._columnEditTimer),t._columnEditing=!1,t._columnEditTimer=setTimeout((()=>{o===a.label&&i===a.color||t.$.fireEvent("columnUpdate",{column:a,oldValue:o,value:a.label}),delete t._columnEditTimer}),50),e.stopPropagation()}}t._columnEditing=!0,setTimeout((()=>{l.focus()}),50),l.onkeydown=e=>{if("Escape"===e.key){s.classList.remove("pending"),l.value=o;try{l.parentNode&&l.parentNode.removeChild(l)}catch(e){t._error=e}t._columnEditing=!1}else"Enter"===e.key&&r(e)},l.addEventListener("blur",r),l.addEventListener("change",r)}_validateDataSourceMap(){this.dataSourceMap=Object.assign({},{checklist:"checklist",color:"color",comments:"comments",dueDate:"dueDate",id:"id",priority:"priority",progress:"progress",startDate:"startDate",status:"status",swimlane:"swimlane",tags:"tags",text:"text",userId:"userId"},this.dataSourceMap)}});