smart-webcomponents-react 18.0.0 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/accordion/accordion.esm.js +1 -4
  2. package/alertwindow/alertwindow.esm.js +1 -4
  3. package/array/array.esm.js +1 -4
  4. package/barcode/barcode.esm.js +1 -4
  5. package/breadcrumb/breadcrumb.esm.js +1 -4
  6. package/button/button.esm.js +1 -4
  7. package/buttongroup/buttongroup.esm.js +1 -4
  8. package/calendar/calendar.esm.js +1 -4
  9. package/card/card.esm.js +1 -4
  10. package/cardview/cardview.esm.js +1 -4
  11. package/carousel/carousel.esm.js +1 -4
  12. package/chart/chart.esm.js +1 -4
  13. package/checkbox/checkbox.esm.js +1 -4
  14. package/checkinput/checkinput.esm.js +1 -4
  15. package/chip/chip.esm.js +1 -4
  16. package/colorinput/colorinput.esm.js +1 -4
  17. package/colorpanel/colorpanel.esm.js +1 -4
  18. package/colorpicker/colorpicker.esm.js +1 -4
  19. package/columnpanel/columnpanel.esm.js +1 -4
  20. package/combobox/combobox.esm.js +1 -4
  21. package/countryinput/countryinput.esm.js +1 -4
  22. package/customizationdialog/customizationdialog.esm.js +1 -4
  23. package/dateinput/dateinput.esm.js +1 -4
  24. package/daterangeinput/daterangeinput.esm.js +1 -4
  25. package/datetimepicker/datetimepicker.esm.js +1 -4
  26. package/dialogwindow/dialogwindow.esm.js +1 -4
  27. package/dockinglayout/dockinglayout.esm.js +1 -4
  28. package/dropdownbutton/dropdownbutton.esm.js +1 -4
  29. package/dropdownlist/dropdownlist.esm.js +1 -4
  30. package/editor/editor.esm.js +1 -4
  31. package/element/element.esm.js +1 -4
  32. package/fileupload/fileupload.esm.js +1 -4
  33. package/filterbuilder/filterbuilder.esm.js +1 -4
  34. package/filterpanel/filterpanel.esm.js +1 -4
  35. package/form/form.esm.js +1 -4
  36. package/ganttchart/ganttchart.esm.js +1 -4
  37. package/gauge/gauge.esm.js +1 -4
  38. package/grid/grid.esm.js +1 -4
  39. package/grouppanel/grouppanel.esm.js +1 -4
  40. package/input/input.esm.js +1 -4
  41. package/kanban/kanban.esm.js +1 -4
  42. package/layout/layout.esm.js +1 -4
  43. package/led/led.esm.js +1 -4
  44. package/listbox/listbox.esm.js +1 -4
  45. package/listmenu/listmenu.esm.js +1 -4
  46. package/map/map.esm.js +1 -4
  47. package/maskedtextbox/maskedtextbox.esm.js +1 -4
  48. package/menu/menu.esm.js +1 -4
  49. package/multicolumnfilterpanel/multicolumnfilterpanel.esm.js +1 -4
  50. package/multicomboinput/multicomboinput.esm.js +1 -4
  51. package/multiinput/multiinput.esm.js +1 -4
  52. package/multilinetextbox/multilinetextbox.esm.js +1 -4
  53. package/multilinewindow/multilinewindow.esm.js +1 -4
  54. package/multisplitbutton/multisplitbutton.esm.js +1 -4
  55. package/numberinput/numberinput.esm.js +1 -4
  56. package/numerictextbox/numerictextbox.esm.js +1 -4
  57. package/package.json +1 -1
  58. package/pager/pager.esm.js +1 -4
  59. package/passwordinput/passwordinput.esm.js +1 -4
  60. package/passwordtextbox/passwordtextbox.esm.js +1 -4
  61. package/path/path.esm.js +1 -4
  62. package/phoneinput/phoneinput.esm.js +1 -4
  63. package/pivottable/pivottable.esm.js +1 -4
  64. package/progressbar/progressbar.esm.js +1 -4
  65. package/progresswindow/progresswindow.esm.js +1 -4
  66. package/promptwindow/promptwindow.esm.js +1 -4
  67. package/qrcode/qrcode.esm.js +1 -4
  68. package/querybuilder/querybuilder.esm.js +1 -4
  69. package/radiobutton/radiobutton.esm.js +1 -4
  70. package/rating/rating.esm.js +1 -4
  71. package/ribbon/ribbon.esm.js +1 -4
  72. package/scheduler/scheduler.esm.js +1 -4
  73. package/scrollbar/scrollbar.esm.js +1 -4
  74. package/slider/slider.esm.js +1 -4
  75. package/sortable/sortable.esm.js +1 -4
  76. package/sortpanel/sortpanel.esm.js +1 -4
  77. package/source/modules/smart.3dchart.js +3 -3
  78. package/source/modules/smart.accordion.js +3 -3
  79. package/source/modules/smart.array.js +3 -3
  80. package/source/modules/smart.barcode.js +3 -3
  81. package/source/modules/smart.breadcrumb.js +3 -3
  82. package/source/modules/smart.button.js +3 -3
  83. package/source/modules/smart.buttongroup.js +3 -3
  84. package/source/modules/smart.calendar.js +3 -3
  85. package/source/modules/smart.card.js +3 -3
  86. package/source/modules/smart.cardview.js +3 -3
  87. package/source/modules/smart.carousel.js +3 -3
  88. package/source/modules/smart.chart.js +3 -3
  89. package/source/modules/smart.checkbox.js +3 -3
  90. package/source/modules/smart.checkinput.js +3 -3
  91. package/source/modules/smart.chip.js +3 -3
  92. package/source/modules/smart.colorinput.js +3 -3
  93. package/source/modules/smart.colorpanel.js +3 -3
  94. package/source/modules/smart.colorpicker.js +3 -3
  95. package/source/modules/smart.combobox.js +3 -3
  96. package/source/modules/smart.common.js +3 -3
  97. package/source/modules/smart.countryinput.js +3 -3
  98. package/source/modules/smart.dateinput.js +3 -3
  99. package/source/modules/smart.daterangeinput.js +3 -3
  100. package/source/modules/smart.datetimepicker.js +3 -3
  101. package/source/modules/smart.dockinglayout.js +3 -3
  102. package/source/modules/smart.dropdownbutton.js +3 -3
  103. package/source/modules/smart.dropdownlist.js +3 -3
  104. package/source/modules/smart.editor.js +3 -3
  105. package/source/modules/smart.element.js +3 -3
  106. package/source/modules/smart.fileupload.js +3 -3
  107. package/source/modules/smart.form.js +3 -3
  108. package/source/modules/smart.formulaparser.js +3 -3
  109. package/source/modules/smart.ganttchart.js +4 -4
  110. package/source/modules/smart.gauge.js +3 -3
  111. package/source/modules/smart.grid.js +5 -5
  112. package/source/modules/smart.gridpanel.js +3 -3
  113. package/source/modules/smart.input.js +3 -3
  114. package/source/modules/smart.kanban.js +3 -3
  115. package/source/modules/smart.layout.js +3 -3
  116. package/source/modules/smart.led.js +3 -3
  117. package/source/modules/smart.listbox.js +3 -3
  118. package/source/modules/smart.listmenu.js +3 -3
  119. package/source/modules/smart.map.js +3 -3
  120. package/source/modules/smart.maskedtextbox.js +3 -3
  121. package/source/modules/smart.menu.js +3 -3
  122. package/source/modules/smart.multicomboinput.js +3 -3
  123. package/source/modules/smart.multiinput.js +3 -3
  124. package/source/modules/smart.multilinetextbox.js +3 -3
  125. package/source/modules/smart.multisplitbutton.js +3 -3
  126. package/source/modules/smart.numberinput.js +3 -3
  127. package/source/modules/smart.numerictextbox.js +3 -3
  128. package/source/modules/smart.pager.js +3 -3
  129. package/source/modules/smart.passwordinput.js +3 -3
  130. package/source/modules/smart.passwordtextbox.js +3 -3
  131. package/source/modules/smart.path.js +3 -3
  132. package/source/modules/smart.phoneinput.js +3 -3
  133. package/source/modules/smart.pivottable.js +3 -3
  134. package/source/modules/smart.progressbar.js +3 -3
  135. package/source/modules/smart.qrcode.js +3 -3
  136. package/source/modules/smart.querybuilder.js +3 -3
  137. package/source/modules/smart.radiobutton.js +3 -3
  138. package/source/modules/smart.rating.js +3 -3
  139. package/source/modules/smart.ribbon.js +3 -3
  140. package/source/modules/smart.router.js +3 -3
  141. package/source/modules/smart.scheduler.js +3 -3
  142. package/source/modules/smart.scrollbar.js +3 -3
  143. package/source/modules/smart.slider.js +3 -3
  144. package/source/modules/smart.sortable.js +3 -3
  145. package/source/modules/smart.splitter.js +3 -3
  146. package/source/modules/smart.switchbutton.js +3 -3
  147. package/source/modules/smart.table.js +3 -3
  148. package/source/modules/smart.tabs.js +3 -3
  149. package/source/modules/smart.tank.js +3 -3
  150. package/source/modules/smart.textarea.js +3 -3
  151. package/source/modules/smart.textbox.js +3 -3
  152. package/source/modules/smart.timeinput.js +3 -3
  153. package/source/modules/smart.timepicker.js +3 -3
  154. package/source/modules/smart.toast.js +3 -3
  155. package/source/modules/smart.tooltip.js +3 -3
  156. package/source/modules/smart.tree.js +3 -3
  157. package/source/modules/smart.validator.js +3 -3
  158. package/source/modules/smart.window.js +3 -3
  159. package/source/smart.3dchart.js +1 -1
  160. package/source/smart.accordion.js +1 -1
  161. package/source/smart.ajax.js +1 -1
  162. package/source/smart.array.js +1 -1
  163. package/source/smart.barcode.js +1 -1
  164. package/source/smart.bootstrap.js +1 -1
  165. package/source/smart.breadcrumb.js +1 -1
  166. package/source/smart.button.js +1 -1
  167. package/source/smart.buttongroup.js +1 -1
  168. package/source/smart.calendar.js +1 -1
  169. package/source/smart.card.js +1 -1
  170. package/source/smart.cardview.js +1 -1
  171. package/source/smart.carousel.js +1 -1
  172. package/source/smart.chart.annotations.js +1 -1
  173. package/source/smart.chart.api.js +1 -1
  174. package/source/smart.chart.core.js +1 -1
  175. package/source/smart.chart.js +1 -1
  176. package/source/smart.chart.rangeselector.js +1 -1
  177. package/source/smart.chart.waterfall.js +1 -1
  178. package/source/smart.checkbox.js +1 -1
  179. package/source/smart.checkinput.js +1 -1
  180. package/source/smart.chip.js +1 -1
  181. package/source/smart.colorinput.js +1 -1
  182. package/source/smart.colorpanel.js +1 -1
  183. package/source/smart.colorpicker.js +1 -1
  184. package/source/smart.combobox.js +1 -1
  185. package/source/smart.complex.js +1 -1
  186. package/source/smart.core.js +1 -1
  187. package/source/smart.countryinput.js +1 -1
  188. package/source/smart.data.js +1 -1
  189. package/source/smart.date.js +1 -1
  190. package/source/smart.dateformatpanel.js +1 -1
  191. package/source/smart.dateinput.js +1 -1
  192. package/source/smart.daterangeinput.js +1 -1
  193. package/source/smart.datetimepicker.js +1 -1
  194. package/source/smart.dockinglayout.js +1 -1
  195. package/source/smart.draw.js +1 -1
  196. package/source/smart.dropdownbutton.js +1 -1
  197. package/source/smart.dropdownlist.js +1 -1
  198. package/source/smart.editor.js +1 -1
  199. package/source/smart.element.js +1 -1
  200. package/source/smart.elements.js +4 -4
  201. package/source/smart.export.js +1 -1
  202. package/source/smart.fileupload.js +1 -1
  203. package/source/smart.filter.js +1 -1
  204. package/source/smart.filterbuilder.js +1 -1
  205. package/source/smart.filterpanel.js +1 -1
  206. package/source/smart.form.js +1 -1
  207. package/source/smart.format.js +1 -1
  208. package/source/smart.formulaparser.js +1 -1
  209. package/source/smart.ganttchart.js +2 -2
  210. package/source/smart.gauge.js +1 -1
  211. package/source/smart.grid.cell.js +1 -1
  212. package/source/smart.grid.chart.js +1 -1
  213. package/source/smart.grid.column.js +1 -1
  214. package/source/smart.grid.core.js +2 -2
  215. package/source/smart.grid.dialog.js +1 -1
  216. package/source/smart.grid.edit.js +1 -1
  217. package/source/smart.grid.export.js +1 -1
  218. package/source/smart.grid.filter.js +1 -1
  219. package/source/smart.grid.group.js +1 -1
  220. package/source/smart.grid.js +1 -1
  221. package/source/smart.grid.menu.js +1 -1
  222. package/source/smart.grid.pager.js +1 -1
  223. package/source/smart.grid.reorder.js +1 -1
  224. package/source/smart.grid.resize.js +1 -1
  225. package/source/smart.grid.row.js +1 -1
  226. package/source/smart.grid.select.js +1 -1
  227. package/source/smart.grid.sort.js +1 -1
  228. package/source/smart.grid.toolbar.js +2 -2
  229. package/source/smart.grid.tree.js +1 -1
  230. package/source/smart.grid.view.js +1 -1
  231. package/source/smart.gridpanel.js +1 -1
  232. package/source/smart.input.js +1 -1
  233. package/source/smart.kanban.js +1 -1
  234. package/source/smart.layout.js +1 -1
  235. package/source/smart.led.js +1 -1
  236. package/source/smart.listbox.js +1 -1
  237. package/source/smart.listmenu.js +1 -1
  238. package/source/smart.map.js +1 -1
  239. package/source/smart.maskedtextbox.js +1 -1
  240. package/source/smart.math.js +1 -1
  241. package/source/smart.menu.js +1 -1
  242. package/source/smart.multicomboinput.js +1 -1
  243. package/source/smart.multiinput.js +1 -1
  244. package/source/smart.multilinetextbox.js +1 -1
  245. package/source/smart.multisplitbutton.js +1 -1
  246. package/source/smart.numberformatpanel.js +1 -1
  247. package/source/smart.numberinput.js +1 -1
  248. package/source/smart.numeric.js +1 -1
  249. package/source/smart.numerictextbox.js +1 -1
  250. package/source/smart.pager.js +1 -1
  251. package/source/smart.passwordinput.js +1 -1
  252. package/source/smart.passwordtextbox.js +1 -1
  253. package/source/smart.path.js +1 -1
  254. package/source/smart.phoneinput.js +1 -1
  255. package/source/smart.pivottable.js +1 -1
  256. package/source/smart.powerbutton.js +1 -1
  257. package/source/smart.progressbar.js +1 -1
  258. package/source/smart.qrcode.js +1 -1
  259. package/source/smart.radiobutton.js +1 -1
  260. package/source/smart.rating.js +1 -1
  261. package/source/smart.ribbon.js +1 -1
  262. package/source/smart.router.js +1 -1
  263. package/source/smart.scheduler.js +1 -1
  264. package/source/smart.scrollbar.js +1 -1
  265. package/source/smart.slider.js +1 -1
  266. package/source/smart.sortable.js +1 -1
  267. package/source/smart.splitter.js +1 -1
  268. package/source/smart.switchbutton.js +1 -1
  269. package/source/smart.table.js +1 -1
  270. package/source/smart.tabs.js +1 -1
  271. package/source/smart.tank.js +1 -1
  272. package/source/smart.textarea.js +1 -1
  273. package/source/smart.textbox.js +1 -1
  274. package/source/smart.tickintervalhandler.js +1 -1
  275. package/source/smart.timeinput.js +1 -1
  276. package/source/smart.timepicker.js +1 -1
  277. package/source/smart.toast.js +1 -1
  278. package/source/smart.tooltip.js +1 -1
  279. package/source/smart.tree.js +1 -1
  280. package/source/smart.validationpanel.js +1 -1
  281. package/source/smart.validator.js +1 -1
  282. package/source/smart.window.js +1 -1
  283. package/splitter/splitter.esm.js +1 -4
  284. package/switchbutton/switchbutton.esm.js +1 -4
  285. package/table/table.esm.js +1 -4
  286. package/tabs/tabs.esm.js +1 -4
  287. package/tabswindow/tabswindow.esm.js +1 -4
  288. package/tank/tank.esm.js +1 -4
  289. package/textarea/textarea.esm.js +1 -4
  290. package/textbox/textbox.esm.js +1 -4
  291. package/threedchart/threedchart.esm.js +1 -4
  292. package/timeinput/timeinput.esm.js +1 -4
  293. package/timepicker/timepicker.esm.js +1 -4
  294. package/toast/toast.esm.js +1 -4
  295. package/tooltip/tooltip.esm.js +1 -4
  296. package/tree/tree.esm.js +1 -4
  297. package/validator/validator.esm.js +1 -4
  298. package/waitwindow/waitwindow.esm.js +1 -4
  299. package/window/window.esm.js +1 -4
@@ -1,5 +1,5 @@
1
1
 
2
- /* Smart UI v18.0.0 (2024-01-22)
2
+ /* Smart UI v18.0.1 (2024-01-23)
3
3
  Copyright (c) 2011-2023 jQWidgets.
4
4
  License: https://htmlelements.com/license/ */ //
5
5
 
@@ -61,8 +61,8 @@ Smart.Utilities.Assign("Grid.Dialog",class{_createOverlay(){const e=document.cre
61
61
  (()=>{"use strict";class e{_setRowProperty(e,t,o){const r=this,s=r.rowById[e];s&&(s[t]=o,r.stateSettings.autoSave&&r.stateSettings.current&&!r.stateSettings.loading&&r.saveState())}_setRowsProperty(e,t,o){const r=this;r._refreshLayout(),r._refreshRowHierarchy(!0);const s=r._recyclingRows;r.rows.canNotify=!1;for(let r=0;r<s.length;r++){const a=s[r];o&&-1===o.indexOf(a.id)||(a[e]=t)}r.rows.canNotify=!0,r.refresh()}expandRowsToGroupLevel(e){this._expandCollapseGroupsToLevel(!0,e)}_expandCollapseGroupsToLevel(e,t){const o=this;o._refreshLayout(),o._refreshRowHierarchy(!0);const r=o._recyclingRows;o.rows.canNotify=!1;for(let s=0;s<r.length;s++){const a=r[s];a.data.level<t&&(a.expanded=a.data.expanded=e,o.dataSource&&(e?o.dataSource._expandedRowIds[a.data.$.id]=!0:delete o.dataSource._expandedRowIds[a.data.$.id]))}o.rows.canNotify=!0,o.refresh()}_applyThreeStates(e){const t=this,o=e!==t.rowHierarchy;if(!t.rowHierarchy)return;const r=o?e.children:t.rowHierarchy.filter((e=>{if(0===e.level)return e}));let s=0,a=0;for(let c=0;c<r.length;c++){const d=r[c];e.checked&&(d.checked=!0),!1===d.leaf&&t._applyThreeStates(d),o&&(d.checked?s++:null===d.checked&&a++)}o&&(s===e.children.length?e.checked=!0:0===s&&0===a?e.checked=!1:t.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1)}_hasThreeStates(e,t){const o=this;let r=e;for(e!==t&&(e.checked?e.checked=!1:e.checked=!0);r.parent;){const e=r.parent,t=e.children;let s=0,a=0;for(let e=0;e<t.length;e++)t[e].checked?s++:o.checkBoxes.hasThreeStates&&null===t[e].checked&&a++;s===e.children.length?e.checked=!0:0===s&&0===a?e.checked=!1:o.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1,r=e}e.leaf||function e(t,o){const r=t.children;for(let t=0;t<r.length;t++){const s=r[t];s.checked=o,!1===s.leaf&&e(s,o)}}(e,e.checked)}_expandCollapseGroup(e,t){const o=this;if(!o.grouping.enabled||!o.rowHierarchy)return;e&&e.indexOf&&e.indexOf("Item")>=0&&(e=e.replace("Item",""));const r=(""+e).split(".");let s=o.rowHierarchy[r[0]];if(!s)return;const a=o.rows.canNotify;o.rows.canNotify=!1,null===t&&(t=!s.expanded),s.expanded=s.data.expanded=t,o._saveRowState(s.id,!s.expanded);for(let e=1;e<r.length&&(s=s.children[r[e]],s&&!s.leaf);e++)s.expanded=s.data.expanded=t;o.rows.canNotify=a,o._refresh(),o.stateSettings.autoSave&&o.stateSettings.current&&!o.stateSettings.loading&&o.saveState()}_saveRowState(e,t=!1){const o=this,r=o.rowById[e];if(r&&o.dataSource){if(t)return void delete o.dataSource._expandedRowIds[r.data.$.id];o.dataSource._expandedRowIds[r.data.$.id]=!0}}expandRow(e){const t=this;t.grouping.enabled?t._expandCollapseGroup(e,!0):e&&Array.isArray(e)?t._setRowsProperty("expanded",!0,e):(t._setRowProperty(e,"expanded",!0),t._saveRowState(e))}expandAllRows(){const e=this;e.grouping.enabled?e._expandCollapseGroupsToLevel(!0,99):e._setRowsProperty("expanded",!0)}collapseAllRows(){const e=this;e.grouping.enabled?e._expandCollapseGroupsToLevel(!1,99):e._setRowsProperty("expanded",!1)}toggleRow(e){const t=this;if(t.grouping.enabled)return void t._expandCollapseGroup(e,null);const o=t.rowById[e];o&&(o.expanded?o.expanded=!1:o.expanded=!0)}collapseRow(e){const t=this;t.grouping.enabled?t._expandCollapseGroup(e,!1):e&&Array.isArray(e)?t._setRowsProperty("expanded",!1,e):(t._setRowProperty(e,"expanded",!1),t._saveRowState(e,!0))}checkRow(e){const t=this;e&&Array.isArray(e)?t._setRowsProperty("checked",!0,e):t._setRowProperty(e,"checked",!0)}uncheckRow(e){const t=this;e&&Array.isArray(e)?t._setRowsProperty("checked",!1,e):t._setRowProperty(e,"checked",!1)}checkAllRows(){this._setRowsProperty("checked",!0)}uncheckAllRows(){this._setRowsProperty("checked",!1)}}Smart.Utilities.Grid.Tree=e})();
62
62
  Smart.Utilities.Assign("Grid.Export",class{exportData(t,e){const o=this,a=new Smart.Utilities.DataExporter({exportHeader:o.dataExport.header}),r=[];a.expandChar=o.dataExport.expandChar,a.collapseChar=o.dataExport.collapseChar,a.pageOrientation=o.dataExport.pageOrientation,a.style=o.dataExport.style,a.filterBy=o.dataExport.filterBy,a.groupBy=o.dataExport.groupBy;const n=o.columns.toArray().slice(0).filter((t=>!1!==t.allowExport));if(a.header={columns:n,columngroups:o.columnGroups.slice(0)},!o.dataExport.style){const e=window.getComputedStyle(o),n=window.getComputedStyle(o.columns.length>0&&o.columns[0].element?o.columns[0].element:o.$.columnHeader),l=window.getComputedStyle(o.$.columnHeader);if(0!==o.offsetWidth&&0!==o.offsetHeight){const i=t=>{const e=t.fontSize,o=t.borderRightColor,a=t.backgroundColor,r=t.color,n=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");function l(t){return(t=t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))?"#"+i(t[1])+i(t[2])+i(t[3]).toUpperCase():"#ffffff"}function i(t){return isNaN(t)?"00":n[(t-t%16)/16]+n[t%16]}return{borderColor:l(o),fontSize:e,fontFamily:"Helvetica",color:l(r),backgroundColor:l(a)}},d=i(e),c=i(n),s=i(l),p={height:o.$.columnHeader.offsetHeight+"px",border:"1px solid "+d.borderColor,fontFamily:s.fontFamily,fontSize:s.fontSize,color:s.color,backgroundColor:c.backgroundColor,fontWeight:"400"},f={border:"1px solid "+d.borderColor,fontFamily:d.fontFamily,fontSize:d.fontSize},u={height:o.rowMinHeight+"px"};for(let e=0;e<o.columns.length;e++){const a=o.columns[e];if(!a.allowExport)continue;if(!a.visible)continue;p[a.dataField]={textAlign:a.align,width:a.computedWidth+"px",format:a.cellsFormat||""};let n=a.cellsFormat||"";n||("date"===a.dataType?n="d":"dateTime"===a.dataType?n="D":"time"===a.dataType&&(n="t")),o.locale&&n&&n.indexOf("c")>=0&&"xlsx"===t&&""!==o.locale&&"en"!==o.locale&&(n=o._getCurrencyByLocale(o.locale)+"x"+n);const l={textAlign:a.cellsAlign,format:n};if(f[a.dataField]=l,o.dataExport.view&&-1!==["html","jpeg","pdf","png"].indexOf(t)&&(a.template||a.formatFunction))for(let t=0;t<o.rows.length;t++){const e=o.rows[t];let n=o.rows[t]["column_"+a.dataField];if(o.dataExport.viewStart&&t<o.dataExport.viewStart||o.dataExport.viewEnd&&t>o.dataExport.viewEnd)continue;if(!n||e&&e.element&&e.element.classList.contains("smart-hidden")){const t=o._rowElements[0];if(!t)continue;if(e.element=t,e.grid=o,e.render(),n=e["column_"+a.dataField],!n)continue}const i={};i.border=n.borderColor,i.background=n.background,i.color=n.color;const d=void 0!==o.dataExport.viewStart?t-o.dataExport.viewStart:t;r[t]=Object.assign({},e.data),r[t][a.dataField]=n.element.textContent,l[d]=i}}o.appearance.alternationCount>0&&(u.alternationCount=o.appearance.alternationCount,u.alternationStart=o.appearance.alternationStart,u.alternationEnd=o.appearance.alternationEnd,u.alternationIndex0Color=d.color,u.alternationIndex0BackgroundColor=d.backgroundColor,u.alternationIndex1Color=d.color,u.alternationIndex1BackgroundColor="#F5F5F5"),a.style={border:"1px solid "+d.borderColor,borderCollapse:"collapse",header:p,columns:f,rows:u}}}const l=!o.rowHierarchy||o.grouping.enabled?o.rows.toArray():o.rowHierarchy,i=o.dataExport.rowIds,d=null!==i;let c=[];if(o.dataExport.view)o._recyclingRows.forEach(((t,e)=>{if(o.dataExport.viewStart&&e<o.dataExport.viewStart||o.dataExport.viewEnd&&e>o.dataExport.viewEnd)return!0;r[e]?c.push(r[e]):c.push(t.data)}));else{for(let e=0;e<l.length;e++){const a=l[e];if(a.visible&&(!1!==a.filtered||void 0===a.filtered)){if(d&&-1===i.indexOf(a.id))continue;const e={};for(let r=0;r<o.columns.length;r++){const n=o.columns[r];if(!n.allowExport)continue;const l=n.dataField;let i=a.data[l];if("taskChecklist"===l)if(i){const t=i.map((t=>{let e=t.text;return t.completed?e="✓ "+e:e+="X "+e,e}));i=t.toString()}else i="";if("taskUserId"===l){const t=o.users.find((t=>t.id===parseInt(i)||parseInt(t.id)===parseInt(i)));t&&(i=t.name)}if(void 0===i)if("createdBy"===n.template){const t=o.users.find((t=>t.id===a.createdBy));if(t){const o=t,a="string"==typeof o?o:o.name;e[l]=a}else e[l]=""}else if("createdTime"===n.template){const t=a.getCell(l).getFormattedValue(a.createdTime,"d")+" "+a.getCell(l).getFormattedValue(a.createdTime,"t");e[l]=t}else if("modifiedBy"===n.template){const t=o.users.find((t=>t.id===a.modifiedBy));if(t){const o=t,a="string"==typeof o?o:o.name;e[l]=a}else e[l]=""}else if("modifiedTime"===n.template){const t=a.getCell(l).getFormattedValue(a.modifiedTime,"d")+" "+a.getCell(l).getFormattedValue(a.modifiedTime,"t");e[l]=t}else e[l]="";else if(i&&i.indexOf&&(i.indexOf("{")>=0||"[]"===i)){const t=i.indexOf("{")>=0||"[]"===i?JSON.parse(i):i.split(", "),o=[];for(let e=0;e<t.length;e++)"string"==typeof t[e]?o.push(t[e]):o.push(t[e].label);e[l]=o.join(",")}else if("csv"===t||"tsv"===t)if(n.cellsFormat){const t=a.getCell(l).getFormattedValue(i,n.cellsFormat);e[l]=t}else e[l]=i;else e[l]=i}c.push(e)}}l!==o.rowHierarchy||d||(c=o.dataSource.boundHierarchy,a.hierarchical=!0)}!o.dataExport.groupBy&&o.grouping.enabled&&o.dataSource&&o.dataSource.groupBy&&(a.groupBy=o.dataSource.groupBy&&o.dataSource.groupBy.toArray?o.dataSource.groupBy.toArray():null),o.checkLicense(!0);const s=a.exportData(c,t,o.dataExport.fileName,e);return o.dataExport.view&&o._recycle(!1),s}print(){const t=this,e=t.dataExport.fileName;t.dataExport.fileName=null;const o=t.exportData("html"),a=window.open("","","width=800,height=500"),r=a.document.open(),n='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+e+"</title></head><body>"+o+"</body></html>";try{r.write(n),r.close(),setTimeout((function(){a.print(),a.close()}),100)}catch(t){}t.dataExport.fileName=e}});
63
63
  Smart.Utilities.Assign("Grid.Chart",class{_getChartDataFields(e){const t=this,i=e[0];let a,n=!0,o=[];for(let e in i)"$"!==e&&("string"===t.dataSource.dataFields.find((t=>t.name===e)).dataType?0===t.columns.findIndex((t=>t.dataField===e))&&(a=e):(n=!1,o.push({dataField:e,displayText:e})));return{xAxisDataField:a,series:o,stringOnly:n}}createChart(e,t){const i=this,a=i.getSelection(),n=a.rows,o=a.columns,s=a.cells,l=document.createElement("smart-chart"),r=[],d={};let c,h=[],g=[];if(s&&s.length>1&&s.forEach((e=>{-1===h.indexOf(e.row.index)&&h.push(e.row.index),-1===g.indexOf(e.dataField)&&g.push(e.dataField)})),t)r.concat(t);else for(let e=0;e<i.dataSource.length;e++){const t={};if(n){if(!n.find((t=>t.row.index===e)))continue}else{if(o){o.forEach((a=>{t[a.dataField]=i.dataSource[e][a.dataField]})),r.push(t);continue}if(s&&s.length>1){if(-1===h.indexOf(e))continue;g.forEach((a=>{t[a]=i.dataSource[e][a]})),r.push(t);continue}}i.columns.forEach((a=>t[a.dataField]=i.dataSource[e][a.dataField])),r.push(t)}const f=i._getChartDataFields(r);if(f.stringOnly){if(i.header.visible&&i.$.header.firstElementChild){const t=i.enableShadowDOM?i.shadowRoot.getElementById(e):i.querySelector("#"+e);i.$.header.firstElementChild.classList.add("warning"),t&&t.classList.add("warning"),setTimeout((function(){i.$.header.firstElementChild.classList.remove("warning"),t&&t.classList.remove("warning")}),1e3)}}else{if(c=f.series,l.caption="",l.description="",l.clip=!1,l.showLegend=!0,l.showBorderLine=!1,l.padding={left:5,top:10,right:5,bottom:5},l.dataSource=r,l.xAxis={dataField:f.xAxisDataField,gridLines:{visible:!0}},l.valueAxis={displayValueAxis:!0,description:i.charting.description,axisSize:"auto",formatSettings:i.charting.formatSettings},l.colorScheme=i.charting.colorScheme,l.seriesGroups=[d],d.formatSettings=i.charting.formatSettings,d.series=c,"line"===e)c.forEach((function(e){e.symbolSize=8,e.symbolType="square"}));else if("pie"===e){const e=c[0].dataField;delete d.formatSettings,d.formatFunction=function(e,t){return isNaN(e)&&"object"==typeof e?t:e},d.showLabels=!0,c.length=0,c.push({dataField:e,displayText:f.xAxisDataField,initialAngle:0})}else if("bar"===e)e="column",d.orientation="horizontal",l.xAxis.textRotationAngle=90,l.valueAxis.textRotationAngle=30,l.valueAxis.flip=!0;else if("area"===e){let e=1;for(let t=0;t<c.length;t++)c[t].opacity=e,e-=.2,e=Math.max(.3,e)}if(d.type=e,i.onChartInit&&i.onChartInit(l),i.charting.appendTo){const e="string"===i.charting.appendTo?document.querySelector(i.charting.appendTo):i.charting.appendTo;e&&e.appendChild(l)}else i._openChartDialog(l,e)}}_openChartDialog(e,t){const i=this;if(!i.charting.dialog.enabled)return!1;const a=i._dialogChart||i._createDialog(i.charting.dialog),n=t.substring(0,1).toUpperCase()+t.substring(1),o="{{message}}"===i.charting.dialog.header?i.localize("dialogChartHeader",{value:n}):i.charting.dialog.header;e.style.width="100%",e.style.height="100%",a.header.innerHTML=o,a.content.innerHTML="",a.content.style.width="100%",a.content.style.height="100%",a.btnCancel.classList.add("smart-hidden"),i._dialogChart||(a.modal=!0,a.onOpen=function(){i.charting.dialog.visible=!0},a.onClose=function(){i.charting.dialog.visible=!1},a.btnConfirm.onclick=function(){a.close()},a.btnClose.onclick=function(){a.close()},a.onkeydown=function(e){"Escape"===e.key&&a.close()},i._dialogChart=a),a.open(),setTimeout((function(){a.btnConfirm.focus(),a.content.appendChild(e)}),100)}});
64
- Smart("smart-grid-toolbar",class extends Smart.DataView{template(){return'<div id="container" role="presentation">\n <div id="header" class="smart-data-view-header" role="toolbar">\n <div id="viewStatesButton" class="smart-data-view-header-button smart-data-view-states-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="ViewStates"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="viewsButton" class="smart-data-view-header-button smart-data-view-views-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Views"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="customizeButton" class="smart-data-view-header-button smart-data-view-customize-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Customize cards"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="filterButton" class="smart-data-view-header-button smart-data-view-filter-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Filter"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="sortButton" class="smart-data-view-header-button smart-data-view-sort-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Sort"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="groupButton" class="smart-data-view-header-button smart-data-view-group-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Group"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="formatButton" class="smart-data-view-header-button smart-data-view-format-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Format"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="deleteButton" class="smart-data-view-header-button smart-data-view-delete-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Delete"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="customButton" class="smart-data-view-header-button smart-data-view-custom-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Custom"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="downloadButton" class="smart-data-view-header-button smart-data-view-download-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Download"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="searchButton" class="smart-data-view-header-button smart-data-view-search-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Search"></div>\n <div id="headerDropDown" owner 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="group" class="smart-hidden" role="presentation"></div>\n <div id="format" 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" role="button" aria-label="Previous"></div>\n <div id="searchNext" class="smart-data-view-search-next" role="button" aria-label="Next"></div>\n <div id="searchClose" class="smart-data-view-search-close" role="button" aria-label="Close search box"></div>\n </div>\n </div>\n </div>\n </div>'}_refreshMobileViewTools(){const e=this;e.grid.offsetWidth<600?e.querySelectorAll(".smart-tool-label").forEach((e=>{e.classList.add("smart-hidden")})):e.querySelectorAll(".smart-tool-label").forEach((e=>{e.classList.remove("smart-hidden")}))}refreshTools(){const e=this;if(e.isRendered&&e.grid&&(e._refreshMobileViewTools(),e.refreshHeaderDropDownPosition(),e.grid)){const t=e.grid;if(t.dataSource&&t.dataSource.boundSource){const a=t.dataSource&&t.dataSource.virtualDataSource&&!t.dataSource.virtualDataSourceOnExpand&&t.dataSource.length>t.virtualModeCachedRowsCount&&"infinite"!==t.scrolling;if(e.dataSource&&t.dataSource&&e.dataSource.length!==t.dataSource.length||a)if(a){const a=Array.isArray(t.dataSource.boundSource)?t.dataSource.boundSource:t.dataSource.boundSource.toArray();e.dataSource=new Smart.DataAdapter({observable:!1,dataSource:[...a],dataFields:t.dataSource.dataFields})}else e.dataSource=t.dataSource;const s=t=>{const a=t?"add":"remove";e.$.filterButton.classList[a]("smart-disabled"),e.$.sortButton.classList[a]("smart-disabled"),e.$.groupButton.classList[a]("smart-disabled"),e.$.formatButton.classList[a]("smart-disabled"),e.$.searchButton.classList[a]("smart-disabled"),e.$.downloadButton.classList[a]("smart-disabled")};s(e.dataSource&&0===e.dataSource.length),t.dataSource&&t.dataSource.virtualDataSource&&!t.dataSource.virtualDataSourceOnExpand&&"infinite"!==t.scrolling&&s(!1),0===t.columns.length?e.$.customizeButton.classList.add("smart-disabled"):e.$.customizeButton.classList.remove("smart-disabled")}}}get hasStyleObserver(){return!1}render(){const e=this;e._appliedFiltering={filters:[],operator:"and"},e._appliedSorting={dataFields:[],dataTypes:[],orderBy:[]},e._localizeHeader(),e._getInnerElementMessages(),super.render()}openFormatPanel(){const e=this,t=e.dataSource;if(!t||0===t.length||e.disabled||"none"===e.headerPosition)return;let a;if(e._refreshColumns("format"),e.grid.closeMenu(),e._editInfo&&e._editInfo.window.close(),e._closeDownloadMenu(),e._closeViewsMenu(),e.$.headerDropDown.classList.add("format-panel"),e.$.headerDropDown.classList.remove("customize-panel","sort-panel","search-panel","filter-panel"),e.$.format.classList.remove("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.group&&e.$.group.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e._closeSearchPanel(),e._formatPartCreated)a=e.$.format.firstElementChild,a.columns=e.columns,a.dataSource=e.dataSource,a.locale=e.locale,a.messages=e._innerElementMessages.formattingPanel,a.rightToLeft=e.rightToLeft;else{a=document.createElement("smart-formatting-panel"),a.animation=e.animation,a.columns=e.columns,a.dataSource=e.dataSource,a.locale=e.locale,a.messages=e._innerElementMessages.formattingPanel,a.rightToLeft=e.rightToLeft,a.theme=e.theme,a.unfocusable=!1,a.ownerElement=e,a.dropDownAppendTo="body",e._formattingPanel=a,e.$.format.appendChild(a);const t=document.createElement("div");t.className="smart-format-panel smart-grid-panel-container-footer",t.setAttribute("role","presentation"),t.innerHTML=`<div id="buttonsContainer" class="smart-grid-panel-buttons-container smart-unselectable" role="presentation"><span class="smart-grid-panel-cancel-button" role="button">${e.localize("cancel")}</span><span class="smart-grid-panel-apply-button" role="button">${e.localize("apply")}</span></div>`,e._formattingPanel.$.apply=t.querySelector(".smart-grid-panel-apply-button"),e._formattingPanel.$.cancel=t.querySelector(".smart-grid-panel-cancel-button"),e.$.format.appendChild(t),e._formatPartCreated=!0,t.applyButton=t.querySelector(".smart-grid-panel-apply-button"),t.cancelButton=t.querySelector(".smart-grid-panel-cancel-button"),t.applyButton.onclick=()=>{a.$.fireEvent("apply"),e.grid._conditionalFormattingChanged=!0,e.grid._conditionalFormatting=a.apply(),e.grid.conditionalFormatting=a.getItems(),e.grid._recycle(!1),e.grid._conditionalFormattingChanged=!1},t.cancelButton.onclick=()=>{a.$.fireEvent("cancel")},e.grid.conditionalFormatting&&(a.items=e.grid.conditionalFormatting)}a.focus(),e._openHeaderDropDown(e.$.formatButton)}_openHeaderDropDown(e){const t=this;t.$.headerDropDown.parentElement!==document.body&&(document.body.appendChild(t.$.headerDropDown),t.$.headerDropDown.addEventListener("apply",(e=>{const a=t._getDropDownType();t._applyHandler(e),t.grid.$.fireEvent("batchChange",{type:a})})),t.$.headerDropDown.addEventListener("cancel",(()=>{const e=t._getDropDownType();t.closePanel(),t.grid.$.fireEvent("batchCancel",{type:e})}))),super._openHeaderDropDown(e),t.refreshHeaderDropDownPosition(e)}refreshHeaderDropDownPosition(e){const t=this;if(!t.$.headerDropDown||t.$.headerDropDown&&!t.$.headerDropDown.classList.contains("open"))return void(t._dropDownTarget=e);e?t._dropDownTarget=e:t._dropDownTarget&&(e=t._dropDownTarget);const a=t.grid.parentElement,s=a?a.scrollTop:0;t.$.headerDropDown.style.top=t.grid.offset(t.grid).top+t.grid.$.header.offsetHeight-s+"px";const o=()=>{if(e){const a=t.grid.offset(e);if(a.left+t.$.headerDropDown.offsetWidth<document.body.scrollLeft+document.body.offsetWidth?t.$.headerDropDown.style.left=a.left+"px":t.$.headerDropDown.style.left=document.body.scrollLeft+document.body.offsetWidth-t.$.headerDropDown.offsetWidth+"px",a.top+t.$.headerDropDown.offsetHeight>=document.documentElement.clientHeight-40){let e=t.grid.offset(t.grid).top-t.$.headerDropDown.offsetHeight;e<0&&(e=0),t.$.headerDropDown.style.top=e+"px"}}else t.$.headerDropDown.style.left=t.grid.offset(t.grid).left+"px"};t.grid.offsetWidth<600&&t.$.headerDropDown.offsetWidth>t.grid.offsetWidth?(t.$.headerDropDown.style.width="90%",t.$.headerDropDown.style.left=t.grid.offset(t.grid).left+"px"):(t.$.headerDropDown.style.width="",o())}openFilterPanel(e){const t=this,a=t.dataSource;t._refreshColumns("filter");const s=this.columns.map((e=>{const t=Object.assign({},e),s=a.dataFields.find((e=>e.name===t.dataField));return s&&(t.dataType=s.dataType),t})).filter((e=>e.allowFilter));if(super.openFilterPanel(s,null),t._closeDownloadMenu(),t._closeViewsMenu(),t.grid.closeMenu(),e){const a=t.$.headerDropDown.querySelector("smart-multi-column-filter-panel");a.$.itemsContainer.appendChild(a._createItem(t.columns.find((t=>t.dataField===e.dataField)),"string"===e.dataType?"CONTAINS":"EQUAL",""));const s=a.querySelectorAll(".smart-grid-panel-item");setTimeout((()=>{s[s.length-1].querySelector(".editor").focus()}),350)}}openSortPanel(e){const t=this,a=t.dataSource;t._refreshColumns("sort");const s=t.columns.map((e=>{const s=Object.assign({},e),o=t._appliedSorting.dataFields.indexOf(s.dataField),n=a.dataFields.find((e=>e.name===s.dataField));return n&&(s.dataType=n.dataType,s.sortIndex=o,-1!==o&&(s.sortDirection=t._appliedSorting.orderBy[o])),s})).filter((e=>e.allowSort));if(e&&t._appliedSorting&&-1===t._appliedSorting.dataFields.indexOf(e.dataField)){const a=s.find((t=>t.dataField===e.dataField));a.sortDirection="ascending",a.sortIndex=t._appliedSorting.dataFields.length}super.openSortPanel(s),t._closeDownloadMenu(),t._closeViewsMenu();const o=t.grid;o.closeMenu();const n=t.$.headerDropDown.querySelector("smart-sort-panel");if(!n)return;n.grid=o,n.$.maintainSortContainer.classList.remove("smart-hidden"),o.sorting.maintainSort?n.$.maintainSortContainer.firstElementChild.setAttribute("active",""):n.$.maintainSortContainer.firstElementChild.removeAttribute("active"),n._changeApplyButtonText();const i=n.$.inputNotSorted,r=()=>{const e=n.querySelectorAll(".smart-grid-panel-item");"many"===t.grid.sorting.mode||e.length<1?i.classList.remove("smart-visibility-hidden"):e.length>=1&&i.classList.add("smart-visibility-hidden")};n.onDataSourceChange=()=>{r()},r()}openCustomizePanel(){const e=this;if(e.disabled||"none"===e.headerPosition)return;e._closeDownloadMenu(),e._closeViewsMenu(),e._refreshColumns("customize");let t=e.columns;const a=e.grid;a.closeMenu(),a.appearance.showColumnGroupsInColumnPanel&&(t=[],a.columns.forEach((e=>{if(!e.columnGroup){const a={label:e.label,dataField:e.dataField,level:0,parentDataField:null,dataType:e.dataType||"string",columnGroup:e.columnGroup||null,allowHide:void 0===e.allowHide||e.allowHide,allowSort:void 0===e.allowSort||e.allowSort,allowFilter:void 0===e.allowFilter||e.allowFilter,allowGroup:void 0===e.allowGroup||e.allowGroup,visible:void 0===e.visible||e.visible};t.push(a)}})),a._columnGroups.forEach((e=>{const a={dataField:e.name,label:e.label,level:0,disableDrag:!0,disableToggle:!1,allowHide:!0};if(t.push(a),e.columns){let s=e.columns.length,o=0,n=[],i=[];e.columns.forEach((a=>{const r={label:a.label,dataField:a.dataField,level:1,parentDataField:e.name,dataType:a.dataType||"string",columnGroup:a.columnGroup||null,allowHide:void 0===a.allowHide||a.allowHide,allowSort:void 0===a.allowSort||a.allowSort,allowFilter:void 0===a.allowFilter||a.allowFilter,allowGroup:void 0===a.allowGroup||a.allowGroup,visible:void 0===a.visible||a.visible};!1===r.allowHide&&(s--,i.push(r.dataField)),r.visible||(o++,n.push(r.dataField)),t.push(r)})),s<=0&&(a.allowHide=!1,a.disableToggle=!0),e.columns.length===o||s===o&&i.toString()!==n.toString()?a.visible=!1:a.visible=!0}})));const s=e.$.customize,o=t.map((t=>{const a={};return a.visible=t.visible,a.label=t.label,a.dataField=t.dataField,-1!==[e.coverField,e.titleField].indexOf(a.dataField)?a.disableToggle=!0:a.disableToggle=!1,void 0!==t.level&&(a.level=t.level),t.disableDrag&&(a.disableDrag=!0),t.parentDataField&&(a.parentDataField=t.parentDataField),t.allowHide||(a.disableToggle=!0),a}));let n;if(e._closeDialog(),e.$.headerDropDown.classList.add("customize-panel"),e.$.headerDropDown.classList.remove("filter-panel","sort-panel","search-panel","group-panel","format-panel"),s.classList.remove("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e.$.group.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e._closeSearchPanel(),e._customizePartCreated)n=s.querySelector("smart-column-panel"),n.locale=e.locale,n.messages=e._innerElementMessages.columnPanel,n.set("dataSource",o),n.propertyChangedHandler("dataSource",void 0,o),n.rightToLeft=e.rightToLeft;else{const t=document.createDocumentFragment(),a=document.createElement("smart-column-panel");a.rightToLeft=e.rightToLeft,a.animation=e.animation,a.dataSource=o,a.locale=e.locale,a.messages=e._innerElementMessages.columnPanel,a.theme=e.theme,t.appendChild(a),e.$.customize.appendChild(t),e._customizePartCreated=!0}e._changedVisibility=new Map,e._openHeaderDropDown(e.$.customizeButton)}_applyFilter(e,t){const a=this;a.grid.beginUpdate(),a.grid.context=a.grid,a.grid.clearFilter();for(let t=0;t<e.length;t++){const s=e[t],o=s[0],n=s[1];a.grid.columnByDataField[o].filter=n}a.grid._filterOperator=t,a.grid.endUpdate(),a.grid.refreshFilters(),a.grid.context=document,a.grid.autoSaveState()}_applySort(){const e=this,t=e._appliedSorting;e.grid.beginUpdate(),e.grid.sorting.maintainSort=t.maintainSort,e.grid.context=e.grid,e.grid.clearSort();for(let a=0;a<t.dataFields.length;a++)e.grid.sortBy(t.dataFields[a],t.orderBy[a]);e.grid.endUpdate(),e.grid.context=document,e.grid.autoSaveState()}_getDropDownType(){const e=this;let t=null;return e.$.headerDropDown.classList.contains("filter-panel")?t="filter":e.$.headerDropDown.classList.contains("sort-panel")?t="sort":e.$.headerDropDown.classList.contains("search-panel")?t="search":e.$.headerDropDown.classList.contains("group-panel")?t="group":e.$.headerDropDown.classList.contains("format-panel")?t="format":e.$.headerDropDown.classList.contains("customize-panel")&&(t="customize"),t}_applyHandler(e){const t=this,a=e.target,s=e.detail,o=t.$.customize;if(t.grid&&"kanban"===t.grid.view&&t.grid._kanban&&o.contains(a))return t.grid._kanban._applyHandler(e,"customize"),void t.closePanel();o.contains(a)?t._applyColumns(s.value,s.moves):t.$.filter.contains(a)?t.addFilter(s.filters,s.operator,s.value):t.$.sort.contains(a)&&t.addSort(s.sortByInfo),t.closePanel()}_documentUpHandler(e){const t=this;let a=e.originalEvent.target;const s=t.grid.$.header;t.shadowRoot&&a===t&&(a=e.originalEvent.composedPath()[0]);const o=e.originalEvent.composedPath();for(let e=0;e<o.length;e++){const t=o[e];if(t&&t.classList&&t.classList.contains("smart-menu-item")){const e=t.closest("smart-menu");if(e&&e.classList.contains("smart-grid-views-menu"))return;if(e&&e.classList.contains("smart-grid-download-menu"))return}}if(t._closeDownloadMenu(),t._closeViewsMenu(),!("none"===t.headerPosition||t.$.headerDropDown.classList.contains("smart-visibility-hidden")||a!==s&&s.contains(a))){const o=a.closest("smart-scroll-viewer"),n=a.closest(".smart-drop-down");if((!o||!s.contains(o.ownerElement))&&(!n||n.ownerElement&&!s.contains(n.ownerElement))){const a=e.originalEvent.composedPath();for(let e=0;e<a.length;e++){const t=a[e];if(t&&t.classList&&t.classList.contains("smart-data-view-header-drop-down"))return;if(t&&t.classList&&t.classList.contains("smart-formatting-panel-popup"))return}if(o&&o.ownerElement){const e=o.ownerElement.parents;for(let t=0;t<e.length;t++){const a=e[t];if(a&&a.classList&&a.classList.contains("smart-data-view-header-drop-down"))return}}if(n&&n.ownerElement){const e=n.ownerElement.parents;for(let t=0;t<e.length;t++){const a=e[t];if(a&&a.classList&&a.classList.contains("smart-data-view-header-drop-down"))return}}if(t.$.headerDropDown.querySelector("[open]"))return;t.closePanel()}}}_refreshColumns(e){const t=this,a=t.grid;let s,o=new Map;if("kanban"===a.view&&a._kanban)switch(e){case"customize":return s=a._kanban._getCustomizeColumnPanelDataSource(),s=JSON.parse(JSON.stringify(s)),t._refreshCustomizeButton(),void(t.columns=s)}s=Array.isArray(a.columns)?[...a.columns]:[...a.columns.toArray()],s=s.filter((t=>!1!==t._visible&&!(("filter"===e||"sort"===e)&&("sort"===e&&!t.sortOrder||"filter"===e&&!t.filter)&&!1===t.visible))),s=s.map((e=>{let t=e.allowHide;return a.grouping&&a.grouping.autoHideGroupColumn&&a.dataSource.groupBy.indexOf(e.dataField)>=0&&(t=!1),{label:e.label,dataField:e.dataField,dataType:e.dataType||"string",columnGroup:e.columnGroup||null,allowHide:void 0===e.allowHide||t,allowSort:void 0===e.allowSort||e.allowSort,allowFilter:void 0===e.allowFilter||e.allowFilter,allowGroup:void 0===e.allowGroup||e.allowGroup,visible:void 0===e.visible||e.visible,sortIndex:void 0!==e.sortIndex&&null!==e.sortIndex?e.sortIndex:-1,sortDirection:void 0!==e.sortOrder?e.sortOrder:null,options:e.editor&&e.editor.dataSource?e.editor.dataSource:null}})),s=JSON.parse(JSON.stringify(s)),s.forEach((e=>{let t=e.columnGroup?e.columnGroup+"."+e.label:e.label,a=1;for(;o.get(t);)t=e.columnGroup?e.columnGroup+"."+e.label+` (${a})`:e.label+` (${a})`,a++;o.set(t,e),e.label=t})),t.columns=s,t._refreshCustomizeButton()}_init(e){const t=this;if(t.grid=e,e.dataSource&&e.dataSource.boundSource){t._refreshColumns("init");const a=Array.isArray(e.dataSource.boundSource)?e.dataSource.boundSource:e.dataSource.boundSource.toArray();t.dataSource=new Smart.DataAdapter({observable:!1,dataSource:[...a],dataFields:e.dataSource.dataFields})}t.grid._openRowSettingsDialog=t._openRowSettingsDialog,t.rightToLeft=t.grid.rightToLeft,t.refreshTools(),t.$.headerDropDown.onclick=e=>{t.grid._headerClickHandler(e),e.stopPropagation(),e.preventDefault()},t.grid.removeEventListener("change",t._refreshFromSelection),t.grid.addEventListener("change",t._refreshFromSelection),t._updateViews(),e.header.onInit&&e.header.onInit(t)}_removeMenu(){const e=this;if(e.downloadMenu){const t=e.downloadMenu.querySelector("smart-menu");t&&e.downloadMenu.removeChild(t)}}_removeViewsMenu(){const e=this;if(e.viewsMenu){const t=e.viewsMenu.querySelector("smart-menu");t&&e.viewsMenu.removeChild(t);const a=e.viewsMenu.querySelector(".label");a&&e.viewsMenu.removeChild(a)}}_createViewsMenuItems(){const e=this,t=e.grid;e._removeViewsMenu();const a=document.createElement("smart-menu"),s=document.createDocumentFragment();a.classList.add("smart-grid-views-menu"),a.checkable=!0,a.checkboxes=!0,a.style.width="100%",a.mode="vertical",a.dropDownAppendTo="body",a.rightToLeft=t.rightToLeft,a.style.minWidth="150px";const o=(e,a,s)=>{const o=document.createElement("smart-menu-item");let n="#D50000",i="smart-icon-table-alt";switch(a){case"grid":n="#3f51b5",i="smart-icon-table-alt","grid"===t.view&&s&&(o.setAttribute("focus",""),o.checked=!0),o.title=t.localize("gridView");break;case"kanban":n="#8E24AA",i="smart-icon-kanban","kanban"===t.view&&s&&(o.setAttribute("focus",""),o.checked=!0),o.title=t.localize("kanbanView");break;case"card":n="#33B679",i="smart-icon-card","card"===t.view&&s&&(o.setAttribute("focus",""),o.checked=!0),o.title=t.localize("cardView")}return o.label='<span style="color: '+n+'" class="smart-grid-icon '+i+'"></span>'+e,o.value=a,o};s.appendChild(o(t.localize("viewGrid"),"grid",!0)),s.appendChild(o(t.localize("viewKanban"),"kanban",!0)),s.appendChild(o(t.localize("viewCard"),"card",!0)),a.appendChild(s),e.viewsMenu.insertBefore(a,e.viewsMenu.children[e.viewsMenu.children.length-1]),e.viewsMenu.onpointerup=()=>!1,a.onItemClick=a=>{e._setView(a.detail.value),e._closeViewsMenu(),t.autoSaveState(),e._updateViews()}}_updateViews(){const e=this,t=e.grid;if(e.$.viewStatesButton.removeAttribute("aria-expanded"),t.stateSettings.enabled&&t.appearance.showViewBar){const a=e=>{delete t.stateSettings.storage[e.valueName],t.stateSettings.current===e.valueName&&(t.stateSettings.current=""),t.stateSettings.onStateChange&&t.stateSettings.onStateChange(t.stateSettings.storage[t.stateSettings.current],e.valueName,t.stateSettings.storage,t.stringify_object),e.remove()},s=e=>{const a=document.createElement("input");a.value=e.valueName;const s=()=>{if(a.value){if(t.stateSettings.storage[a.value])return;const s=t.stateSettings.storage[e.valueName];t.stateSettings.current===e.valueName&&(t.stateSettings.current=a.value),delete t.stateSettings.storage[s.name],s.name=a.value,t.stateSettings.storage[s.name]=s,t.stateSettings.onStateChange&&t.stateSettings.onStateChange(t.stateSettings.storage[t.stateSettings.current],s.name,t.stateSettings.storage,t.stringify_object),delete t.stateSettings.storage[e.valueName],a.remove();const o=a.value;e.valueName=o;let n="smart-icon-table-alt";switch(s.view){case"grid":n="smart-icon-table-alt";break;case"kanban":n="smart-icon-kanban";break;case"card":n="smart-icon-card"}o===t.stateSettings.current?(e.checked=!0,e.label='<span class="show smart-grid-icon '+n+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+o+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'):e.label='<span class="show smart-grid-icon '+n+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+o+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="show smart-grid-icon smart-icon-delete"></span>'}};a.onselectstart=e=>{e.stopPropagation()},a.onpointerdown=a.onpointerup=e=>{e.stopPropagation()},a.onkeydown=e=>{e.stopPropagation()},a.onkeyup=e=>{"Escape"===e.key&&(a.onchange=a.onblur=null,a.remove()),"Enter"===e.key&&(a.onchange=a.onblur=null,s()),e.stopPropagation()},a.onchange=()=>{a.onblur=null,a.onkeyup=null,s()},a.onblur=()=>{a.remove()},a.style.width="100%",a.style.height="100%",a.style.position="absolute",a.style.left="0px",a.style.top="0px",a.style.zIndex=99,a.classList.add("smart-input"),a.classList.add("underlined"),e.querySelector(".smart-menu-item-label-element").appendChild(a),setTimeout((()=>{a.focus()}),50)},o=(e,o,n)=>{const i=document.createElement("smart-menu-item");let r="smart-icon-table-alt";switch(o){case"grid":r="smart-icon-table-alt";break;case"kanban":r="smart-icon-kanban";break;case"card":r="smart-icon-card"}return i.value=n,i.valueName=e,e===t.stateSettings.current?(i.checked=!0,i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'):i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="show smart-grid-icon smart-icon-delete"></span>',!1!==t.currentUser&&null!==t.currentUser&&void 0!==t.currentUser||(e===t.stateSettings.current?(i.checked=!0,i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'):i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'),i.ondblclick=e=>{const t=e.target.closest("smart-menu-item");s(t)},i.onclick=e=>{if(e.target&&e.target.classList.contains("smart-icon-delete")){const t=e.target.closest("smart-menu-item");a(t),e.preventDefault(),e.stopPropagation()}else if(e.target&&e.target.classList.contains("smart-icon-mode-edit")){const t=e.target.closest("smart-menu-item");s(t),e.preventDefault(),e.stopPropagation()}else if("INPUT"===e.target.nodeName)return},i};if(e.$.viewStatesButton.setAttribute("aria-expanded",!0),!t.$.viewBar.querySelector(".smart-grid-view-chooser-container")){const a=document.createElement("div");a.classList.add("smart-grid-view-chooser-container");const s=document.createElement("div");s.classList.add("new-view"),!1===t.editing.enabled&&s.classList.add("smart-hidden");const o=(a,s)=>{a.stopPropagation(),a.preventDefault(),t.beginUpdate(),t.stateSettings.current||(t.stateSettings.current=t.$.viewBar._input.value),t.saveState(),t.stateSettings.current=t.$.viewBar._input.value,e._closeViewsMenu(),t.resetState(),t._kanban&&t._kanban._reset(),delete t.columnByDataField.taskStatus,"kanban"===s?e._setView("kanban"):"card"===s&&e._setView("card"),t.saveState(),t.endUpdate(),e._updateViews(),t.$.fireEvent("viewChanged",{view:t.view})},n=document.createElement("smart-button");n.classList.add("selected"),n.classList.add("view"),n.innerHTML='<span style="display: flex; align-items: center;"><span style="color: #3f51b5" class="show smart-grid-icon smart-icon-table-alt"></span>'+t.localize("newGrid")+'</span><span style="font-size: 12px; color: rgba(var(--smart-secondary-rgb), 0.6);" class="show smart-grid-icon smart-icon-plus"></span>',n.title=t.localize("gridView");const i=document.createElement("smart-button");i.innerHTML='<span style="display: flex; align-items: center;"><span style="color: #8E24AA;" class="show smart-grid-icon smart-icon-kanban"></span>'+t.localize("newKanban")+'</span><span style="font-size: 12px; color: rgba(var(--smart-secondary-rgb), 0.6);" class="show smart-grid-icon smart-icon-plus"></span>',i.classList.add("view"),i.title=t.localize("kanbanView");const r=document.createElement("smart-button");r.classList.add("selected"),r.classList.add("view"),r.innerHTML='<span style="display: flex; align-items: center;"><span style="color: #33B679" class="show smart-grid-icon smart-icon-card"></span>'+t.localize("newCard")+'</span><span style="font-size: 12px; color: rgba(var(--smart-secondary-rgb), 0.6);" class="show smart-grid-icon smart-icon-plus"></span>',r.title=t.localize("cardView");const l=document.createElement("div");l.classList.add("smart-grid-view-storage"),a.appendChild(l);const d=document.createElement("smart-input");d.classList.add("underlined"),d.placeholder=t.localize("viewNamePlaceholder"),d.hint=t.localize("viewNamePlaceholder"),d.onselectstart=e=>{e.stopPropagation()};const c=document.createElement("div");c.innerHTML="<span>"+t.localize("settings")+"</span>",c.classList.add("view-label");const u=document.createElement("div");s.appendChild(u),u.classList.add("footer"),t.users&&t.users.length&&(!1!==t.currentUser&&null!==t.currentUser&&void 0!==t.currentUser||u.classList.add("smart-hidden")),u.appendChild(n),u.appendChild(i),u.appendChild(r);const p=document.createElement("div");p.innerHTML='<span class="smart-grid-icon show smart-icon-plus"></span><span><a href="javascript:void();">'+t.localize("createView")+"</a></span>",p.classList.add("view-button"),p.onclick=e=>{let t="grid";i.classList.contains("selected")&&(t="kanban"),r.classList.contains("selected")&&(t="card"),o(e,t,s)},i.onpointerdown=()=>{i.classList.add("selected"),n.classList.remove("selected"),r.classList.remove("selected"),p.click()},n.onpointerdown=()=>{n.classList.add("selected"),i.classList.remove("selected"),r.classList.remove("selected"),p.click()},r.onpointerdown=()=>{n.classList.remove("selected"),i.classList.remove("selected"),r.classList.add("selected"),p.click()};const m=()=>{t.stateSettings.storage&&!t.stateSettings.storage[d.value]||d.value&&!t.stateSettings.storage?p.classList.remove("disabled"):p.classList.add("disabled")};d.update=()=>m(),d.onkeyup=d.onchange=()=>{m()},m(),a.appendChild(s),t.$.viewBar._storage=l,t.$.viewBar._input=d,t.$.viewBar.appendChild(a)}let n=t.stateSettings.storage;(n&&0===Object.keys(n).length||!n)&&(t.$.viewBar._input.value||(t.$.viewBar._input.value=t.localize("view")+" 1"),t.stateSettings.current||(t.stateSettings.current=t.$.viewBar._input.value),t.saveState(),t.stateSettings.current=t.$.viewBar._input.value,n=t.stateSettings.storage);const i=t.$.viewBar._storage;if(i.innerHTML="",n){let e=1;const a=document.createDocumentFragment();let r=[],l=[];for(let e in n){const t=n[e];l[t.name]||(l[t.name]=t,r.push({name:e,value:t}))}r.sort(((e,t)=>{const a=new Date(e.value.date),s=new Date(t.value.date);if(e.value&&e.value.date&&t.value&&t.value.date){if(!e.value.date||!t.value.date)return-1;if(a<s)return-1;if(a>s)return 1;if(a===s)return 0}else{if(e.name<t.name)return-1;if(e.name>t.name)return 1;if(e.name===t.name)return 0}}));for(let t in r){const s=r[t],n=s.name,i=s.value;e++,a.appendChild(o(n,i.view,i))}if(e){const e=document.createElement("smart-menu");e.style.width="100%",e.mode="vertical",e.classList.add("smart-grid-views-menu"),e.checkable=!0,e.checkboxes=!0,e.checkMode="radioButton",e.disableAutoCheck=!0,e.rightToLeft=t.rightToLeft,e.appendChild(a),e.onItemCheckChange=a=>{if(a.detail.checked){const s=a.detail.item;t.loadState(s.valueName),e.querySelectorAll("smart-menu-item").forEach((e=>{e.querySelector(".smart-icon-delete").classList.add("show")})),s.querySelector(".smart-icon-delete").classList.remove("show"),t.stateSettings.onStateChange&&t.stateSettings.onStateChange(t.stateSettings.storage[t.stateSettings.current],s.valueName,t.stateSettings.storage,t.stringify_object)}},e.onkeydown=t=>{const a=e.querySelector("smart-menu-item[checked]");a&&"F2"===t.key&&s(a)};const o=document.createElement("div");o.style.display="flex",o.style.marginTop="10px",o.innerHTML='<span class="smart-grid-icon show smart-icon-filter"></span><span>'+t.localize("noViews")+"</span>";const n=document.createElement("smart-input");n.classList.add("underlined"),n.prefix='<span class="smart-grid-icon smart-icon-search show"></span>',n.placeholder=t.localize("commandBarSearch"),n.value=t.$.viewBar.filterValue||"",n.onkeydown=e=>{e.stopPropagation()},n.onselectstart=e=>{e.stopPropagation()},n.onAffixClick=n.onkeyup=()=>{const a=e.querySelectorAll("smart-menu-item");let s=0;o.classList.add("smart-hidden"),e.classList.remove("smart-hidden"),t.$.viewBar.filterValue=n.value,a.forEach((e=>{n.value.length>0?e.valueName.toLowerCase().startsWith(n.value.toLowerCase())?e.classList.remove("smart-hidden"):(e.classList.add("smart-hidden"),s++):e.classList.remove("smart-hidden")})),s===[...a].length&&(o.classList.remove("smart-hidden"),e.classList.add("smart-hidden"))},n.value&&n.onAffixClick(),i.appendChild(n),i.appendChild(e),i.appendChild(o),o.classList.add("smart-hidden")}if(t.stateSettings.storage)for(;t.stateSettings.storage[t.localize("view")+" "+e];)e++;t.$.viewBar._input.value=t.localize("view")+" "+e,t.$.viewBar._input.update()}}}_setView(e,t){const a=this,s=a.grid;if(s.view===e&&!0!==t)return;s.view;const o=s.context;if("kanban"===e)if(s.context=s,s.view="kanban",s.context=o,s._kanbanInitialized&&s.columnByDataField.taskStatus)if(s.columnByDataField.taskStatus&&s._stackedBy&&s.columnByDataField.taskStatus.dataField!==s._stackedBy){s.beginUpdate(),delete s.columnByDataField.taskStatus;const e=s.columnByDataField[s._stackedBy];s.columnByDataField.taskStatus=e,s._createKanban(e),s._refreshHeaderBar(),s.endUpdate(!1),s._showKanbanView(),a._refresh()}else s._showKanbanView(),a._refresh();else delete s._kanbanInitialized,s._initKanbanView("dynamic","grid");else"grid"===e?(s.context=s,s.view="grid",s.context=o,s._hideKanbanView(),a._refresh(),s.layout.isDirty=!0,s._resetCachedLayout(),s._refreshLayout(),s.refresh()):"card"===e&&(s.context=s,s.view="card",s.context=o,s._hideKanbanView(),a._refresh(),s.layout.isDirty=!0,s._resetCachedLayout(),s._refreshLayout(),s.refresh());s.$.fireEvent("viewChanged",{view:e}),a._refresh()}_createMenuItems(){const e=this,t=e.grid;e._removeMenu();const a=document.createElement("smart-menu"),s=document.createDocumentFragment();a.mode="vertical",a.dropDownAppendTo="body",a.classList.add("smart-grid-download-menu"),a.rightToLeft=t.rightToLeft;const o=(e,t)=>{const a=document.createElement("smart-menu-item");let s="#D50000";switch(t){case"csv":s="#3f51b5";break;case"pdf":s="#f4511e";break;case"xlsx":s="#0b8043";break;case"json":s="#8e24aa"}const o='<span style="position: absolute; top: 0px; font-size: 10px; color: '+s+'">'+t+"</span>";return a.label='<span style="color: '+s+'" class="smart-grid-icon smart-icon-docs"></span>'+o+e,a.value=t,a};s.appendChild(o(t.localize("download")+" CSV","csv")),s.appendChild(o(t.localize("download")+" XLSX","xlsx")),s.appendChild(o(t.localize("download")+" JSON","json")),a.appendChild(s),e.downloadMenu.appendChild(a),a.onItemClick=e=>{const a=new Date;t.dataExport.fileName="data_"+a.getFullYear()+"-"+a.getMonth()+"-"+a.getDate(),t.exportData(e.detail.value)}}closePanel(){const e=this;super.closePanel(),e.grid&&e.grid.focus(),e.downloadMenu&&e.downloadMenu.classList.contains("open")?e._closeDownloadMenu():e.viewsMenu&&e.viewsMenu.classList.contains("open")&&e._closeViewsMenu()}_closeDownloadMenu(){const e=this,t=e.downloadMenu;t&&(t.parentNode&&(t.classList.remove("open"),setTimeout((()=>{t&&t.parentNode&&t.parentNode.removeChild(t)}),100)),e.$.downloadButton.classList.remove("selected"),e.$.downloadButton.removeAttribute("aria-expanded"),t.classList.remove("open"))}_openDownloadMenu(){const e=this;if(e.grid.editing.isEditing&&e.grid.cancelEdit(),e.downloadMenu&&e.downloadMenu.classList.contains("open"))return void e._closeDownloadMenu();e.$.headerDropDown.classList.remove("group-panel","customize-panel","filter-panel","sort-panel","search-panel","format-panel"),e.$.group.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e.closePanel(),e.$.downloadButton.classList.add("selected"),e.$.downloadButton.setAttribute("aria-expanded",!0),e.downloadMenu||(e.downloadMenu=document.createElement("div"),e.downloadMenu.classList.add("smart-grid-column-menu","smart-grid-download-menu"),e.downloadMenu.setAttribute("theme",e.getAttribute("theme")),e.downloadMenu.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.downloadMenu.classList.add("smart-animate"),e._createMenuItems(),e.downloadMenu.style.height="auto",e.isInShadowDOM?e.getRootNode().appendChild(e.downloadMenu):document.body.appendChild(e.downloadMenu);const t=e.$.downloadButton.getBoundingClientRect();let a=t.left+window.pageXOffset,s=t.bottom+window.pageYOffset;a+e.downloadMenu.offsetWidth>window.innerWidth&&(a=t.right+window.pageXOffset-e.downloadMenu.offsetWidth,a+e.downloadMenu.offsetWidth>window.innerWidth&&(a=window.innerWidth-e.downloadMenu.offsetWidth)),e.downloadMenu.style.left=a+"px",e.downloadMenu.style.top=s+"px",e.downloadMenu.classList.remove("smart-hidden"),e.downloadMenu.classList.add("open")}_closeViewsMenu(){const e=this,t=e.viewsMenu;t&&(t.parentNode&&(t.classList.remove("open"),setTimeout((()=>{t&&t.parentNode&&t.parentNode.removeChild(t)}),100)),t.classList.remove("open"),e.$.viewsButton.classList.remove("selected"),e.$.viewsButton.removeAttribute("aria-expanded"))}_openViewsMenu(){const e=this;if(e.grid.editing.isEditing&&e.grid.cancelEdit(),e.viewsMenu&&e.viewsMenu.classList.contains("open"))return void e._closeViewsMenu();e.$.headerDropDown.classList.remove("group-panel","customize-panel","filter-panel","sort-panel","search-panel","format-panel"),e.$.group.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e.closePanel(),e.$.viewsButton.classList.add("selected"),e.$.viewsButton.setAttribute("aria-expanded",!0),e.viewsMenu||(e.viewsMenu=document.createElement("div"),e.viewsMenu.classList.add("smart-grid-column-menu","smart-grid-download-menu","smart-grid-view-chooser"),e.viewsMenu.setAttribute("theme",e.getAttribute("theme")),e.viewsMenu.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.viewsMenu.classList.add("smart-animate"),e._createViewsMenuItems("views"),e.viewsMenu.style.height="auto",e.isInShadowDOM?e.getRootNode().appendChild(e.viewsMenu):document.body.appendChild(e.viewsMenu);const t=e.$.viewsButton.getBoundingClientRect();let a=t.left+window.pageXOffset,s=t.bottom+window.pageYOffset;a+e.viewsMenu.offsetWidth>window.innerWidth&&(a=t.right+window.pageXOffset-e.downloadMenu.offsetWidth,a+e.viewsMenu.offsetWidth>window.innerWidth&&(a=window.innerWidth-e.viewsMenu.offsetWidth)),e.viewsMenu.style.left=a+"px",e.viewsMenu.style.top=s+"px",e.viewsMenu.classList.remove("smart-hidden"),e.viewsMenu.classList.add("open")}_refresh(){const e=this,t=e.grid;e._refreshColumns("refresh");let a=!1;for(let t=0;t<e.columns.length;t++)if("number"===e.columns[t].dataType){a=!0;break}if(t.header.buttons.indexOf("sort")>=0&&t.sorting.enabled?e.$.sortButton.classList.remove("smart-hidden"):e.$.sortButton.classList.add("smart-hidden"),t.header.buttons.indexOf("filter")>=0&&t.filtering.enabled?e.$.filterButton.classList.remove("smart-hidden"):e.$.filterButton.classList.add("smart-hidden"),t.header.buttons.indexOf("group")>=0&&t.grouping.enabled?e.$.groupButton.classList.remove("smart-hidden"):e.$.groupButton.classList.add("smart-hidden"),t.header.buttons.indexOf("columns")>=0?e.$.customizeButton.classList.remove("smart-hidden"):e.$.customizeButton.classList.add("smart-hidden"),t.header.buttons.indexOf("search")>=0?e.$.searchButton.classList.remove("smart-hidden"):e.$.searchButton.classList.add("smart-hidden"),t.header.buttons.indexOf("format")>=0&&a?e.$.formatButton.classList.remove("smart-hidden"):e.$.formatButton.classList.add("smart-hidden"),t.header.buttons.indexOf("delete")>=0&&t.editing.enabled?e.$.deleteButton.classList.remove("smart-hidden"):e.$.deleteButton.classList.add("smart-hidden"),t.header.buttons.indexOf("download")>=0?e.$.downloadButton.classList.remove("smart-hidden"):e.$.downloadButton.classList.add("smart-hidden"),t.header.buttons.indexOf("views")>=0?e.$.viewsButton.classList.remove("smart-hidden"):e.$.viewsButton.classList.add("smart-hidden"),t.header.buttons.indexOf("views")>=0&&t.stateSettings.enabled?e.$.viewStatesButton.classList.remove("smart-hidden"):e.$.viewStatesButton.classList.add("smart-hidden"),e.$.downloadButton.onpointerup=a=>{t.closeMenu(),e._openDownloadMenu(),a.stopPropagation()},e.$.viewsButton.onpointerup=a=>{t.closeMenu(),e._openViewsMenu(),a.stopPropagation()},e.$.viewStatesButton.onpointerup=a=>{t.closeMenu(),e._closeDownloadMenu(),e._closeViewsMenu(),t.appearance.showViewBar=!t.appearance.showViewBar,"kanban"===t.view&&t._refreshContentHeight(),a.stopPropagation(),e._updateViews()},t._sortedColumns){const a=[],s=[],o=[];for(let e=0;e<t._sortedColumns.length;e++){const n=t._sortedColumns[e];a.push(n.dataField),s.push(n.sortOrder),o.push(n.dataType)}e._appliedSorting={dataFields:a,dataTypes:o,orderBy:s},e._refreshSortButton()}if("grid"===t.view||"card"===t.view){const a={filters:[],operator:"and"},s=t.getFilteredColumns();if(s)for(let e in s){const t=s[e];for(let s=0;s<t.filters.length;s++){const o=t.filters[s];a.filters.push([e,o.condition,o.value])}}e._appliedFiltering&&(a.operator=e._appliedFiltering.operator),e._appliedFiltering=a,e._refreshFilterButton()}else e.$.sortButton.classList.add("smart-hidden"),e.$.filterButton.classList.add("smart-hidden");e._appliedGrouping?e._appliedGrouping.dataFields=t.dataSource.groupBy:e._appliedGrouping={dataFields:t.dataSource.groupBy,expandAll:!1,collapseAll:!1},e._refreshCustomButton(),e._refreshGroupButton(),e._refreshDeleteButton(),e._refreshDownloadButton(),e._refreshCustomizeButton(),e._refreshViewsButton(),e.refreshTools(),Smart.Utilities.Core.isMobile&&(e.$.searchButton.classList.add("smart-hidden"),e.$.formatButton.classList.add("smart-hidden"),e.$.customButton.classList.add("smart-hidden"),e.$.headerDropDown.classList.add("smart-mobile"),t.$.viewBar.classList.add("smart-mobile")),!1===t.editing.enabled&&(e.$.customButton.classList.add("smart-hidden"),e.$.downloadButton.classList.add("smart-hidden"),e.$.viewsButton.classList.add("smart-hidden"))}_refreshCustomButton(){const e=this,t=e.grid;t.header.customButton.visible?(e.$.customButton.style.paddingLeft="0px",e.$.customButton.classList.remove("smart-hidden")):e.$.customButton.classList.add("smart-hidden"),t.header.customButton.enabled?e.$.customButton.classList.remove("smart-disabled"):e.$.customButton.classList.add("smart-disabled"),e.$.customButton.innerHTML=`<span class="smart-grid-icon show ${t.header.customButton.icon}"></span><div class="smart-tool-label" role="presentation">${t.header.customButton.label}</div>`,e.$.customButton.onclick=()=>{t.header.customButton.command&&t.header.customButton.command()}}_refreshViewsButton(){const e=this;let t=e.grid.localize("viewGrid");switch(e.$.viewsButton.classList.remove("kanban"),e.$.viewsButton.classList.remove("card"),e.grid.view){case"kanban":t=e.grid.localize("viewKanban"),e.$.viewsButton.classList.add("kanban");break;case"grid":t=e.grid.localize("viewGrid");break;case"card":e.$.viewsButton.classList.add("card"),t=e.grid.localize("viewCard")}e.$.viewsButton.innerHTML='<div class="smart-tool-label" role="presentation">'+t+"</div>",e.$.viewStatesButton.innerHTML='<div class="smart-tool-label" role="presentation">'+this.grid.localize("views")+"</div>"}_refreshDownloadButton(){this.$.downloadButton.innerHTML='<div class="smart-tool-label" role="presentation">'+this.grid.localize("download")+"</div>"}_openRowSettingsDialog(e){let t=this;t.getSelectedRows||(t=t.grid);const a=t.editing.dialog.enabled,s=t.editing.mode,o=t.context;t.context=t,t.editing.dialog.enabled=!0,t.editing.mode="row",t._settingsDialogRowId=e;let n=t._isUpdating;"grid"!==t.view&&"card"!==t.view&&(t._isUpdating=0),t.beginEdit(e),t._isUpdating=n,t._endToolbarEdit?(t.removeEventListener("endEdit",t._endToolbarEdit,null),t.removeEventListener("cancelEdit",t._endToolbarEdit,null)):t._endToolbarEdit=()=>{t.context=t,t.editing.dialog.enabled=a,t.editing.mode=s,t.editing.isEditing=!1,t.context=o,delete t._settingsDialogRowId,delete t._dialogEdit},t.addEventListener("endEdit",t._endToolbarEdit),t.addEventListener("cancelEdit",t._endToolbarEdit)}_refreshDeleteButton(){let e=this;if(e.getSelectedRows||(e=e.grid),-1===e.header.buttons.indexOf("delete"))return;const t=e.getSelectedRows().length,a=e.querySelector("smart-grid-toolbar").$.deleteButton;0!==t?(!0===e.editing.enabled?a.classList.remove("smart-hidden"):a.classList.add("smart-hidden"),a.firstElementChild.innerHTML=1===t?e.localize("deleteByOne"):e.localize("deleteByMultiple",{n:t}),a.classList.add("selected"),a.onclick=()=>{const t=e.getSelectedRows().map((e=>e[0]));this.grid.removeRow(t)}):a.classList.add("smart-hidden")}_refreshFromSelection(){this.querySelector("smart-grid-toolbar")._refreshDeleteButton()}openGroupPanel(e){const t=this;let a;const s=t.grid;if("kanban"===s.view)return;t.$.headerDropDown.classList.add("group-panel"),t.$.headerDropDown.classList.remove("customize-panel","filter-panel","sort-panel","search-panel","format-panel"),t.$.group.classList.remove("smart-hidden"),t.$.filter.classList.add("smart-hidden"),t.$.customize.classList.add("smart-hidden"),t.$.sort.classList.add("smart-hidden"),t.$.search.classList.add("smart-hidden"),t.$.format.classList.add("smart-hidden"),t._closeDownloadMenu(),t._closeViewsMenu(),t._refreshColumns("group"),s.closeMenu();const o=t.columns.map((e=>{const a=Object.assign({},e);if(t._appliedGrouping&&t._appliedGrouping.dataFields){const e=t._appliedGrouping.dataFields.indexOf(a.dataField);a.groupIndex=e}return a})).filter((e=>e.allowGroup));e&&t._appliedGrouping&&-1===t._appliedGrouping.dataFields.indexOf(e.dataField)&&(o.find((t=>t.dataField===e.dataField)).groupIndex=t._appliedGrouping.dataFields.length),t._groupPartCreated?(a=t.$.group.firstElementChild,a.rightToLeft=t.rightToLeft,a.dataSource=o,a.locale=t.locale,a.messages=t._innerElementMessages.groupPanel):(a=document.createElement("smart-group-panel"),a.rightToLeft=t.rightToLeft,a.animation=t.animation,a.locale=t.locale,a.messages=t._innerElementMessages.groupPanel,a.theme=t.theme,a.dataSource=o,t.$.group.appendChild(a),t._groupPartCreated=!0,a.onExpandAll=()=>{if(t._appliedGrouping.expandAll)return t._appliedGrouping.expandAll=!1,void a.querySelector(".smart-group-panel-expand-button").removeAttribute("active");t._appliedGrouping.expandAll=!0,t._appliedGrouping.collapseAll=!1,a.querySelector(".smart-group-panel-expand-button").setAttribute("active",""),a.querySelector(".smart-group-panel-collapse-button").removeAttribute("active")},a.onCollapseAll=()=>{if(t._appliedGrouping.collapseAll)return t._appliedGrouping.collapseAll=!1,void a.querySelector(".smart-group-panel-collapse-button").removeAttribute("active");t._appliedGrouping.expandAll=!1,t._appliedGrouping.collapseAll=!0,a.querySelector(".smart-group-panel-collapse-button").setAttribute("active",""),a.querySelector(".smart-group-panel-expand-button").removeAttribute("active")},a.addEventListener("apply",(e=>{const a=e.detail.sortByInfo,o=t._appliedGrouping.dataFields;t._appliedGrouping.dataFields=a.dataFields;const n=s.onRowInserted;if(s.onRowInserted=null,s.beginUpdate(),s.grouping.autoHideGroupColumn&&o)for(let e=0;e<o.length;e++){const t=s.columnByDataField[o[e]];t&&(t.visible=!0)}s.clearGroups();for(let e=0;e<a.dataFields.length;e++){const t=a.dataFields[e];s.addGroup(t)}t._appliedGrouping.expandAll&&s.expandAllRows(),t._appliedGrouping.collapseAll&&s.collapseAllRows(),s.endUpdate(),s.autoSaveState();const i=[];for(let e=0;e<s.dataSource.groupBy.length;e++)i.push(s.dataSource.groupBy[e]);s.$.fireEvent("group",{groups:i}),s.paging.enabled&&s._refreshPagesCount(),s.onRowInserted=n}))),t._refreshGroupButton(),t._openHeaderDropDown(t.$.groupButton)}_refreshGroupButton(){const e=this,t=e._appliedGrouping.dataFields?e._appliedGrouping.dataFields.length:0;if(e.grid&&"kanban"===e.grid.view){e.$.groupButton.onclick=()=>{"kanban"===e.grid.view&&e.grid._initKanbanView("dynamic","kanban")};const t=e.grid.columnByDataField[e.grid._stackedBy];t?(e.$.groupButton.firstElementChild.innerHTML=e.localize("groupedBy",{column:t.label}),e.$.groupButton.classList.add("grouped")):e.$.groupButton.classList.remove("grouped")}else{if(0===t){const t=e.localize("group");return e.$.groupButton.firstElementChild.innerHTML!==t&&(e.$.groupButton.firstElementChild.innerHTML=t),void e.$.groupButton.classList.remove("grouped")}e.$.groupButton.firstElementChild.innerHTML=1===t?e.localize("groupedByOne"):e.localize("groupedByMultiple",{n:t}),e.$.groupButton.classList.add("grouped")}}openSearchPanel(){this._openSearchPanel()}_closeSearchPanel(){this._search(this.$.searchInput.value,!1),super._closeSearchPanel()}_openSearchPanel(){const e=this,t=e.grid;if(e.$.headerDropDown.classList.add("search-panel"),e.$.headerDropDown.classList.remove("customize-panel","filter-panel","sort-panel","group-panel","format-panel"),e.$.search.classList.remove("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.group.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e._openHeaderDropDown(e.$.searchButton),e._closeDownloadMenu(),e._closeViewsMenu(),t.closeMenu(),"filter"===t.header.searchCommand){const t=e.$.headerDropDown.querySelector(".smart-data-view-search-prev"),a=e.$.headerDropDown.querySelector(".smart-data-view-search-next");t.classList.add("smart-hidden"),a.classList.add("smart-hidden")}const a=[],s=t.getVisibleRows();for(let e=0;e<s.length;e++)a.push(Object.assign(s[e].data));const o=new Smart.DataAdapter({id:"id",observable:!1,dataSource:a,dataFields:t.dataSource.dataFields});e._searchInfo={source:o,stringDataFields:e.dataSource.dataFields.filter((e=>"string"===e.dataType)).map((e=>e.name))},""!==e.$.searchInput.value&&e._search(e.$.searchInput.value,!1)}_search(e,t=!0){const a=this;if(!a._searchInfo)return;if(a._searchInfo.query=e,""===e)return a.$.search.classList.remove("matches","no-matches"),delete a._searchInfo.foundIdsArray,delete a._searchInfo.foundIdsObject,delete a._searchInfo.highlighted,a.grid.highlighted=null,a.grid._recycle(!1),void("filter"===a.grid.header.searchCommand&&a.grid.clearFilter());const s=a._searchInfo.source,o=[],n=[],i={};a._searchInfo.stringDataFields.forEach((t=>{const a=new Smart.Utilities.FilterGroup,s=a.createFilter("string",e,"CONTAINS");a.addFilter("or",s),o.push([t,a])})),s._filter(o,"or");for(let e=0;e<s.length;e++){const t=s[e];!1!==t.$.filtered&&(n.push(t.$.id),i[t.$.id]=!0)}if(a._searchInfo.foundIdsArray=n,a._searchInfo.foundIdsObject=i,a.grid.highlighted=null,"filter"===a.grid.header.searchCommand){a.grid.beginUpdate();const t=a.grid.filtering.operator;return a.grid.filtering.operator="or",a.grid.clearFilter(),a._searchInfo.stringDataFields.forEach((t=>{const s=new Smart.Utilities.FilterGroup,o=s.createFilter("string",e,"CONTAINS"),n=a.grid.columnByDataField[t];if(n&&n.editor&&n.editor.dataSource)return!1;n&&(s.addFilter("or",o),a.grid.addFilter(t,s),n._filterInfo&&(n._filterInfo.value=n.filter.filters[0].value,n._filterInfo.condition=n.filter.filters[0].condition))})),a.grid.endUpdate(),a.grid.refreshFilters(),void(a.grid.filtering.operator=t)}if(n.length>0)return a.$.search.classList.remove("no-matches"),a.$.search.classList.add("matches"),a.$.searchLabel.innerHTML=a.localize("found",{nth:t?1:0,n:n.length}),a._searchInfo.highlighted=n[0],a.grid.highlighted=a._searchInfo.highlighted,a.grid.ensureVisible(a._searchInfo.highlighted),void a.grid._recycle(!1);a.$.search.classList.remove("matches"),a.$.search.classList.add("no-matches"),a.$.searchLabel.innerHTML=a.localize("found",{nth:0,n:0})}_refreshCustomizeButton(){const e=this,t=e.grid;let a=0;if("kanban"===t.view&&t._kanban)return e.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+t._kanban.localize("customize")+"</div>",e.$.customizeButton.classList.remove("hidden"),void e.$.customizeButton.classList.add("smart-hidden");for(let e=0;e<t.columns.length;e++){const s=t.columns[e];s.autoGenerated||!1!==s._visible&&(t.grouping&&t.grouping.autoHideGroupColumn&&t.dataSource.groupBy.indexOf(s.dataField)>=0||s.visible||a++)}a>0?(e.$.customizeButton.innerHTML=1===a?'<div class="smart-tool-label" role="presentation">'+t.localize("customizeOne",{n:a})+"</div>":'<div class="smart-tool-label" role="presentation">'+t.localize("customizeHidden",{n:a})+"</div>",e.$.customizeButton.classList.add("hidden")):(e.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+t.localize("customize")+"</div>",e.$.customizeButton.classList.remove("hidden")),e._refreshMobileViewTools()}_applyColumns(e,t){const a=this,s=a.grid;s.beginUpdate();let o=0,n=[],i=[],r=[];const l=s.onColumnChange;s.onColumnChange=null;for(let t in e){const a=e[t],l=s.columnByDataField[a.dataField];l&&(l.visible!==a.visible&&(n.push(a),i.push(l.visible),r.push(a.visible)),l.visible=a.visible,a.visible||o++)}s.onColumnChange=l,s.onColumnChange?s.onColumnChange(n,"visible",i,r):s.$.fireEvent("columnChange",{column:n,propertyName:"visible",oldValue:i,value:r}),o>0?(a.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+s.localize("customizeHidden",{n:o})+"</div>",a.$.customizeButton.classList.add("hidden")):(a.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+s.localize("customize")+"</div>",a.$.customizeButton.classList.remove("hidden"));for(let e=0;e<t.length;e++){const a=t[e],o=a.oldIndex,n=a.newIndex,i=s.columns[n+1],r=s.columns[n-1],l=s.columns[o];i?l.columnGroup=i.columnGroup:r&&(l.columnGroup=r.columnGroup),s.reorderColumns(o,n,!0)}if(s.filtering.enabled&&s.filtering.filterRow)for(let e=0;e<s.columns.length;e++)s.columns[e]._filterEditorInitialized=!1;s.endUpdate();const d=s.grouping.enabled;d&&s._filters&&s.refreshFilters(d),s.autoSaveState()}});
65
- Smart("smart-grid",class extends Smart.ScrollViewer{static get properties(){return{appearance:{value:{alternationStart:{value:0,type:"int"},alternationEnd:{value:0,type:"int"},alternationCount:{value:0,type:"int"},allowHover:{value:!1,type:"boolean",defaultReflectToAttribute:!0},allowHeaderHover:{value:!0,type:"boolean",defaultReflectToAttribute:!0},allowRowToggleAnimation:{value:!1,type:"boolean"},allowRowDetailToggleAnimation:{value:!1,type:"boolean"},allowSortAnimation:{value:!1,type:"boolean"},allowColumnLabelAnimation:{value:!0,type:"boolean"},allowCheckBoxesSelectionAnimation:{value:!0,type:"boolean"},allowColumnMenuAnimation:{value:!0,type:"boolean"},allowColumnSortButtonAnimation:{value:!0,type:"boolean"},allowColumnActionButtonAnimation:{value:!0,type:"boolean"},allowColumnFilterButtonAnimation:{value:!0,type:"boolean"},allowColumnStickyPosition:{value:!1,type:"boolean"},autoShowColumnSortButton:{value:!0,type:"boolean"},autoShowColumnActionButton:{value:!0,type:"boolean"},autoGenerateRowLabelMode:{value:"number",type:"string"},autoGenerateColumnLabelMode:{value:"letter",type:"string"},autoShowColumnFilterButton:{value:!0,type:"boolean"},displayLoadingIndicator:{value:!1,type:"boolean"},loadingIndicatorPlaceholder:{value:"Loading...",type:"string"},placeholder:{value:"No Rows",type:"string"},sortAnimationDuration:{value:500,type:"number"},showRowHeader:{value:!1,type:"boolean"},showRowStatus:{value:!1,type:"boolean"},showRowHeaderNumber:{value:!1,type:"boolean"},showRowHeaderEditIcon:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showRowHeaderDragIcon:{value:!1,type:"boolean"},showColumnHeaderDragIcon:{value:!1,type:"boolean"},showRowHeaderSelectIcon:{value:!1,type:"boolean"},showRowHeaderFocusIcon:{value:!1,type:"boolean"},showColumnHeaderLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showColumnGroupLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showColumnGroupCellLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showColumnLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showRowLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showFilterColumnBackground:{value:!1,type:"boolean"},showSortColumnBackground:{value:!1,type:"boolean"},showFrozenColumnBackground:{value:!0,type:"boolean"},showFrozenRowBackground:{value:!0,type:"boolean"},showSelectionOnTop:{value:!1,type:"boolean"},showColumnSortButton:{value:!0,type:"boolean"},showColumnFilterButton:{value:!0,type:"boolean"},showColumnDescriptionButton:{value:!1,type:"boolean"},showColumnIcon:{value:!1,type:"boolean"},showColumnCustomButton:{value:!1,type:"boolean"},showColumnActionButton:{value:!0,type:"boolean"},showColumnGroupsInColumnPanel:{value:!1,type:"boolean"},showTooltips:{value:!1,type:"boolean"},showTooltipsOverflow:{value:!0,type:"boolean"},showResizeTooltips:{value:!0,type:"boolean"},showHorizontalScrollBarOnFixedColumns:{value:!1,type:"boolean"},showVerticalScrollBarOnFixedColumns:{value:!1,type:"boolean"},showTreeRowHeader:{value:!1,type:"boolean"},showTodayDateAsString:{value:!0,type:"boolean"},showViewBar:{value:!1,type:"boolean"}},type:"object"},behavior:{value:{allowColumnAutoSizeOnDoubleClick:{value:!0,type:"boolean"},allowRowAutoSizeOnDoubleClick:{value:!0,type:"boolean"},allowColumnReorder:{value:!1,type:"boolean"},allowColumnFreeze:{value:!0,type:"boolean"},allowRowReorder:{value:!1,type:"boolean"},doubleClickTimingDelay:{value:300,type:"number"},columnResizeMode:{value:"none",type:"string",allowedValues:["none","split","growAndShrink"]},rowResizeMode:{value:"none",type:"string",allowedValues:["none","split","growAndShrink"]}},type:"object"},layout:{value:{autoWrap:{value:!0,type:"boolean"},autoWidth:{value:!1,type:"boolean"},autoHeight:{value:!1,type:"boolean"},allowCellsWrap:{value:!1,type:"boolean"},allowCellsWrapShortcut:{value:!0,type:"boolean"},autoGenerateColumnWidth:{value:null,type:"number?"},autoSizeNewColumn:{value:!1,type:"boolean",reflectToAttribute:!1},autoSizeNewColumnMinWidth:{value:180,type:"number",reflectToAttribute:!1},cardMinWidth:{value:250,type:"any",reflectToAttribute:!1},cardsPerRow:{value:"auto",type:"any",reflectToAttribute:!1},cardCompact:{value:!1,type:"boolean",reflectToAttribute:!1},columnWidth:{value:null,type:"any",reflectToAttribute:!1},columnHeight:{value:null,type:"any",reflectToAttribute:!1},columnMinHeight:{value:30,type:"any",reflectToAttribute:!1},isDirty:{value:!1,type:"boolean"},loadingIndicatorPosition:{value:"center",allowedValues:["bottom","center","top"],type:"string"},rowMinHeight:{value:30,type:"number"},rowHeight:{value:null,type:"any",reflectToAttribute:!1},viewBarWidth:{value:200,type:"number"}},type:"object"},dataExport:{value:{header:{value:!0,type:"boolean"},filterBy:{value:null,type:"object"},groupBy:{value:null,type:"object"},style:{value:null,type:"object"},fileName:{value:"smartGrid",type:"string?"},pageOrientation:{value:"portrait",type:"string"},expandChar:{value:"+",type:"string"},collapseChar:{value:"-",type:"string"},view:{value:!1,type:"boolean"},viewStart:{value:null,type:"number?"},viewEnd:{value:null,type:"number?"},rowIds:{value:null,type:"array?"}},type:"object"},clipboard:{value:{enabled:{value:!0,type:"boolean"},autoFillMode:{value:"copy",allowedValues:["none","copy","fillSeries"],type:"string"},onPasteValue:{value:null,type:"any"}},type:"object"},conditionalFormatting:{value:null,type:"array?",reflectToAttribute:!1},columns:{value:[],type:"any",reflectToAttribute:!1},contextMenu:{value:{selector:{value:"",type:"string"},enabled:{value:!1,type:"boolean"},width:{value:150,type:"number"},height:{value:null,type:"number?"},dataSource:{value:{contextMenuItemDelete:{value:{command:{value:"contextMenuItemDeleteCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!0,type:"boolean"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},contextMenuItemEdit:{value:{command:{value:"contextMenuItemEditCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!0,type:"boolean"},icon:{value:"smart-icon-mode-edit",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},contextMenuItemCustom:{value:{command:{value:null,type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"boolean"},icon:{value:"smart-icon-settings",type:"string"},label:{value:"",type:"string"}},type:"object",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1},columnMenu:{value:{autoClose:{value:!0,type:"boolean"},dataSource:{value:{columnMenuCustomizeType:{value:{command:{value:"customizeTypeCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-settings",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemClone:{value:{command:{value:"duplicateCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-duplicate",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemInsertLeft:{value:{command:{value:"insertLeftCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-insert-left",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemInsertRight:{value:{command:{value:"insertRightCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-insert-right",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemSortAsc:{value:{command:{value:"sortAscCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-sort-name-up",type:"string"},iconAlt:{value:"smart-icon-sort-number-up",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemSortDesc:{value:{command:{value:"sortDescCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-sort-name-down",type:"string"},iconAlt:{value:"smart-icon-sort-number-down",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemRemoveSort:{value:{command:{value:"removeSortCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-cancel-circled",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemSort:{value:{command:{value:"addSortCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-sort",type:"string"},iconAlt:{value:"smart-icon-sort",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemFilter:{value:{command:{value:"addFilterCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-add-filter",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemRemoveFilter:{value:{command:{value:"removeFilterCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-cancel-circled",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemGroupBy:{value:{command:{value:"groupByCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-group",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemRemoveGroupBy:{value:{command:{value:"removeGroupByCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-ungroup",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemHide:{value:{command:{value:"hideColumnCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-visibility-off",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemDelete:{value:{command:{value:"deleteColumnCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1},visible:{value:!1,type:"boolean"},enabled:{value:!0,type:"boolean"},width:{value:250,type:"number"},height:{value:null,type:"number?"}},type:"object",reflectToAttribute:!1},columnGroups:{value:[],type:"array",reflectToAttribute:!1},charting:{value:{appendTo:{value:null,type:"any"},enabled:{value:!1,type:"boolean"},colorScheme:{value:"scheme01",type:"string"},description:{value:"",type:"string"},dialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:400,type:"any"},width:{value:400,type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},formatSettings:{value:{},type:"object"}},type:"object"},view:{value:"grid",allowedValues:["grid","kanban","card"],type:"string"},currentUser:{value:null,type:"any"},dataSource:{value:null,type:"any",reflectToAttribute:!1},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},dataSourceSettings:{value:{autoGenerateColumns:{value:!1,type:"boolean"},sanitizeHTML:{value:"blackList",allowedValues:["all","blackList","none"],type:"string"},root:{value:"",type:"string"},record:{value:"",type:"string"},keyDataField:{value:"",type:"string"},parentDataField:{value:"",type:"string"},childrenDataField:{value:"",type:"string"},groupBy:{value:[],type:"array"},dataFields:{value:[],type:"array"},mapChar:{value:".",type:"string"},id:{value:"",type:"string"},relations:{value:[],type:"any",reflectToAttribute:!1},virtualDataSource:{value:null,type:"any"},virtualDataSourceOnExpand:{value:null,type:"any"}},type:"object"},formulas:{value:!1,type:"boolean"},uploadSettings:{value:{url:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1},existsUrl:{value:"",type:"string",reflectToAttribute:!1},name:{value:"userfile[]",type:"string",reflectToAttribute:!1},uploadMaxCount:{value:5,type:"number",reflectToAttribute:!1},uploadMaxSize:{value:2097152,type:"number",reflectToAttribute:!1},data:{value:null,type:"object",reflectToAttribute:!1},onUploadStarted:{value:null,type:"any",reflectToAttribute:!1},onUploadCompleted:{value:null,type:"any",reflectToAttribute:!1},onUploadRemove:{value:null,type:"any",reflectToAttribute:!1},onUploadError:{value:null,type:"any",reflectToAttribute:!1},onChange:{value:null,type:"any",reflectToAttribute:!1},onProgress:{value:null,type:"any",reflectToAttribute:!1},onAbort:{value:null,type:"any",reflectToAttribute:!1},onError:{value:null,type:"any",reflectToAttribute:!1},onSetHeaders:{value:null,type:"any",reflectToAttribute:!1},singleFilePost:{value:!0,type:"boolean",reflectToAttribute:!1},userFiles:{value:[],type:"array",reflectToAttribute:!1}},reflectToAttribute:!1,type:"object"},grouping:{value:{enabled:{value:!1,type:"boolean",reflectToAttribute:!1},allowCollapse:{value:!1,type:"boolean",reflectToAttribute:!1},autoHideGroupColumn:{value:!1,type:"boolean",reflectToAttribute:!1},autoExpandAll:{value:!1,type:"boolean",reflectToAttribute:!1},autoExpandToLevel:{value:0,type:"number",reflectToAttribute:!1},onGroupDefaultExpanded:{value:null,type:"any",reflectToAttribute:!1},expandMode:{value:"buttonClick",type:"string",allowedValues:["buttonClick","rowClick"],reflectToAttribute:!1},renderMode:{type:"string",value:"advanced",allowedValues:["basic","compact","advanced","multipleColumns"]},groupBy:{value:[],type:"array",reflectToAttribute:!1},groupRowHeight:{value:50,type:"any",reflectToAttribute:!1},toggleButtonIndent:{value:27,type:"number",reflectToAttribute:!1},groupIndent:{value:27,type:"number",reflectToAttribute:!1},groupBar:{value:{visible:{value:!1,type:"boolean",reflectToAttribute:!1},allowColumnDragDrop:{value:!0,type:"boolean",reflectToAttribute:!0},allowColumnCloseButtons:{value:!0,type:"boolean",reflectToAttribute:!0}},type:"object"},formatFunction:{value:null,type:"any",reflectToAttribute:!1},summaryRow:{value:{inline:{value:!0,type:"boolean"},visible:{value:!0,type:"boolean"}},type:"object"}},type:"object"},messages:{extend:!0,value:{en:{invalidColumnProperty:'{{elementType}}: Invalid property name "{{propertyName}}" set for Column: "{{type}}"',invalidRowProperty:'{{elementType}}: Invalid property name "{{propertyName}}" set for Row"',invalidCellValue:'Invalid cell value "{{value}}", Validation rule: "{{validationRule}}"',invalidValue:"Invalid value",invalidMinValue:"{{value}} above {{min}} must be filled out",invalidMaxValue:"{{value}} below {{max}} must be filled out",invalidMinLengthValue:"{{value}} is shorter than the minimum length of {{min}} characters",invalidMaxLengthValue:"{{value}} is longer than the maximum length of {{max}} characters",requiredValue:"{{value}} must be filled out",frozenColumns:"{{elementType}}: To Pin/Freeze a column group, all columns within it should be frozen.",frozenRows:"{{elementType}}: To Pin/Freeze a special cell, all rows within it should be frozen.",columnGroups:"{{elementType}}: Please, check the initialization of the smartGrid's columns array. The columns in a column group are expected to be siblings in the columns array.",viewGrid:"Grid",viewKanban:"Kanban",viewCard:"Cards",kanbanNone:"Blank",kanbanDescription:'Start from a project board with columns generated by the "{{column}}" column options.',kanbanNoneDescription:"Create a new column and start from scratch with a completely blank project board. You can add columns and configure settings yourself.",kanbanBasic:"Template",kanbanBasicDescription:'Create a new column and start from a project board with columns for "To do", "in progress" and "Done".',uncategorized:"Uncategorized",toDo:"To do",inProgress:"In progress",done:"Done",min:"Min: {{value}}",max:"Max: {{value}} ",sum:"Sum: {{value}} ",avg:"Avg: {{value}} ",cells:"{{value}} cells selected",rows:"{{value}} rows",oneRow:"1 row",unique:"Unique: {{value}}",blank:"Empty: {{value}}",filled:"Filled: {{value}}",summary:"Summary",countSummary:"Count",minSummary:"Min",maxSummary:"Max",avgSummary:"Avg",blankSummary:"Empty",uniqueSummary:"Unique",filledSummary:"Filled",statusSummary:"Status",sumSummary:"Sum",completed:"Tasks Completed: {{value}}",count:"Count: {{value}} ",pagerFirstButton:"First",pagerLastButton:"Last",pagerPreviousButton:"Previous",pagerNextButton:"Next",pagerNavigateToLabel:"Go to:",pagerPageSizeLabel:"Show:",pagerNavigateToInputPlaceholder:"",pagerEllipsis:"...",pagerSummaryString:"of",pagerSummaryPrefix:"of",pagerSummarySuffix:"",columnMenuCustomizeType:"Column settings",columnMenuItemClone:"Clone column",columnMenuItemInsertLeft:"Insert left",columnMenuItemInsertRight:"Insert right",columnMenuItemSortAsc:"Sort {{mode}}",columnMenuItemSortDesc:"Sort {{mode}}",columnMenuItemRemoveSort:"Remove Sort",columnMenuItemFilter:"Filter column",columnMenuItemSort:"Sort column",columnMenuItemRemoveFilter:"Remove Filter",columnMenuItemGroupBy:"Group column",columnMenuItemRemoveGroupBy:"Remove Group",columnMenuItemHide:"Hide column",columnMenuItemShow:"Show column",columnMenuItemDelete:"Delete column",columnResizeTooltip:"width: {{value}}px",rowResizeTooltip:"height: {{value}}px",commandBarAddRow:"Add",commandBarDeleteRow:"Delete row",commandBarBatchRevert:"Revert",commandBarBatchSave:"Save",commandBarFilter:"Filter",commandBarSort:"Sort",commandBarSearch:"Search",commandBarCustomize:"Customize",commandBarGroup:"Group",commandColumnEdit:"Edit",commandColumnDelete:"Delete",commandColumnCancel:"Cancel",commandColumnUpdate:"Update",contextMenuItemDelete:"Delete row",contextMenuItemEditCell:"Edit cell",contextMenuItemEditRow:"Edit row",commandColumnMenu:"",expandRow:"Expand row (Shift + Enter)",expandRowComments:"Expand row and see {{value}} comments",collapseRow:"Collapse row",addNewRow:"Click here to add a new row",addNewRowAlt:"<span>Add new empty row</span> <code>Shift</code> + <code>Space</code>",addNewRowAltSmall:"Add new empty row",addNewColumn:"Click here to add a new column",dialogChartHeader:"{{value}} Chart",dialogRowDetailHeader:"Row Id: {{value}}",dialogDescriptionHeader:"Column: {{value}}",dialogRowDetailButtonConfirm:"OK",dialogRowDetailButtonCancel:"CANCEL",dialogEditHeaderDisabled:"Row: {{value}}",dialogEditHeader:"Row: {{value}}",dialogEditHeaderMenu:"Toggle Sidebar",dialogExpandRowHeader:"Edit Record",dialogAddButtonConfirm:"ADD",dialogAddButtonCancel:"CANCEL",dialogEditButtonConfirm:"OK",dialogEditButtonSave:"Save",dialogEditButtonAutoSave:"Auto Save",dialogEditButtonCancel:"Cancel",dialogFilterButtonConfirm:"FILTER",dialogFilterButtonCancel:"CLEAR",dialogDeleteButtonConfirm:"DELETE",dialogDeleteButtonCancel:"CANCEL",dialogEditColumn:"Column: {{value}}",dialogNewColumn:"New column",dialogAddColumn:"Add Column",dialogAddColumnStatus:"Choose a grouping column",dialogAddColumnStatusDescription:"Represent the status of each record",dialogAddColumnStatusNotes:"Your records will be grouped based on this column",dialogAddHeader:"Add Row",dialogDeleteHeader:"Delete Row",dialogFilterHeader:"Filter by",dialogFilterMinLabel:"Min",dialogFilterMaxLabel:"Max",dialogFileHeader:"File",dialogImageFileHeader:"Image",dialogFileDrop:"or drag and drop file(s) to upload",dialogFileUpload:"Select Files(s) to Upload",dialogFileURL:"You can also provide the URL to a file",dialogFileURLUpload:"Upload",dialogFileLink:"Link (URL)",dialogFileDevice:"My Device",dialogMyFiles:"My Files",dialogMyFilesTitle:"Select files from your already uploaded files.",dialogFileSize:'No file currently added. The "{{value}}" file cannot be uploaded. Maximum file size is {{fileSize}}.',dialogFileCount:'The following files cannot be added "{{files}}". Maximum files allowed is {{fileCount}}.',dialogFileFileUpload:"No files currently selected",dialogAddColumnName:"Name",dialogAddColumnNameInfo:"Name of the column. The name of the column will be displayed in the column header.",dialogAddColumnDescription:"Description",dialogAddColumnDescriptionInfo:"Description of the column. When the description is set, an icon will be displayed in the column header. A tooltip with the description will be displayed when you point at the icon.",dialogAddColumnNamePlaceholder:"Column name (optional)",dialogAddColumnDescriptionPlaceholder:"Describe this column (optional)",dialogAddColumnType:"Type",dialogAddColumnTypeInfo:'Type of the data in the column. Unlike a spreadsheet, Columns have specific "types" that allow you to store rich content in each record. For example, a table can contain records (rows) with images, long texts, checkboxes.',dialogAddColumnTypeText:"Text",dialogAddColumnTypeMultilineText:"Multiline text",dialogAddColumnTypeImage:"Image",dialogAddColumnTypeNumber:"Number",dialogAddColumnTypeSelect:"Select",dialogAddColumnTypeMultipleSelect:"Multiple select",dialogAddColumnTypeDate:"Date",dialogAddColumnTypeTime:"Time",dialogAddColumnTypeRating:"Rating",dialogAddColumnTypeDuration:"Duration",dialogAddColumnTypeCheckBox:"CheckBox",dialogAddColumnTypeCreatedTime:"Created time",dialogAddColumnTypeLastUpdatedTime:"Last modified time",dialogAddColumnTypeCreatedBy:"Created by",dialogAddColumnTypeLastUpdatedBy:"Last modified by",dialogAddColumnTypeCollaborator:"User",dialogAddColumnTypeFormula:"Formula",dialogAddColumnTypeFormulaInfo:'Example: COL(Name) & "-" & COL(Price) or IF(COL(Price) * COL(Quantity) > 5, "Yes", "No")',dialogAddColumnTypeSlider:"Slider",dialogAddColumnTypeStatus:"Choose a status column",dialogAddColumnTypeStatusInfo:"Connect with the relevant status column",dialogAddColumnTypeAutoNumber:"Auto number",dialogAddColumnTypeRowLink:"Link to table",dialogAddColumnTypeURL:"URL",dialogAddColumnTypeEmail:"Email",dialogAddColumnTypePassword:"Password",dialogAddColumnTypePhone:"Phone",dialogAddColumnTypeNone:"None",dialogAddColumnTypeStartDate:"Start Date",dialogAddColumnTypeDueDate:"Due Date",dialogAddColumnTypeDueDateSettings:"Set as a deadline",dialogAddColumnTypeDueDateSettingsInfo:"Set a deadline with start date or due date templates.",dialogAddColumnTypeProgress:"Progress",dialogAddColumnTypePriority:"Priority",dialogAddColumnTypeDescription:"Description",dialogAddColumnTypeTags:"Tags",dialogAddColumnTypeName:"Name",dialogAddColumnTypeColor:"Color",dialogAddColumnTypeChecklist:"Checklist",dialogAddColumnTypeAssigned:"Assignee",dialogAddColumnTypeAttachment:"Attachment",dialogAddColumnDateFormat:"Date format",dialogAddColumnDateFormatInfo:"Choose the dates display format",dialogAddColumnDateFormatShort:"Short",dialogAddColumnDateFormatLong:"Long",dialogAddColumnDateFormatEU:"EU",dialogAddColumnDateFormatISO:"ISO",dialogAddColumnDateFormatAS:"AS",dialogAddColumnDateFormatFull:"Full",dialogAddColumnDateFormatSlash:"Slash",dialogAddColumnDateFormatHyphen:"Hyphen",dialogAddColumnDateFormatDot:"Dot",dialogAddColumnTimeFormat:"Time format",dialogAddColumnTimeFormatInfo:"Choose the time display format",dialogAddColumnTimeFormatHour:"hour",dialogAddColumnAllowTimeFormat:"Include a time field",dialogAddColumnCustomDateSeparator:"Set a custom separator",dialogAddColumnNumberFormat:"Number format",dialogAddColumnNumberFormatInfo:"Choose the number display format",dialogAddColumnNumberFormatInteger:"Integer",dialogAddColumnNumberFormatNumber:"Number",dialogAddColumnNumberFormatPercent:"Percent",dialogAddColumnNumberFormatPercentRounded:"Percent(rounded)",dialogAddColumnNumberFormatScientific:"Scientific",dialogAddColumnNumberFormatEngineering:"Engineering",dialogAddColumnNumberFormatAccounting:"Accounting",dialogAddColumnNumberFormatUnit:"Unit",dialogAddColumnNumberFormatUnitInfo:"Units of measurement",dialogAddColumnNumberFormatUnitAcre:"Acre",dialogAddColumnNumberFormatUnitCelsius:"Celsius",dialogAddColumnNumberFormatUnitFahrenheit:"Fahrenheit",dialogAddColumnNumberFormatUnitPercent:"Percent",dialogAddColumnNumberFormatUnitDegree:"Degree",dialogAddColumnNumberFormatUnitMegaByte:"Mega byte",dialogAddColumnNumberFormatUnitCentimeter:"Centimeter",dialogAddColumnNumberFormatUnitMeter:"Meter",dialogAddColumnNumberFormatUnitKilometer:"Kilometer",dialogAddColumnNumberFormatUnitMile:"Mile",dialogAddColumnNumberFormatUnitKilogram:"Kilogram",dialogAddColumnNumberFormatUnitPound:"Pound",dialogAddColumnNumberFormatUnitLiter:"Liter",dialogAddColumnNumberFormatUnitGallon:"Gallon",dialogAddColumnNumberFormatUnitSecond:"Second",dialogAddColumnNumberFormatUnitMinute:"Minute",dialogAddColumnNumberFormatUnitHour:"Hour",dialogAddColumnNumberFormatUnitDay:"Day",dialogAddColumnNumberFormatUnitWeek:"Week",dialogAddColumnNumberFormatUnitMonth:"Month",dialogAddColumnNumberFormatUnitYear:"Year",dialogAddColumnNumberFormatCurrency:"Currency",dialogAddColumnNumberFormatCurrencyRounded:"Currency(rounded)",dialogAddColumnNumberFormatCurrencyInfo:"Choose the currency display format",dialogAddColumnNumberFormatSeparator:"Use 1000 Separator (,)",dialogAddColumnMinLength:"Minimum length",dialogAddColumnMinLengthInfo:"Minimum text length",dialogAddColumnMaxLength:"Maximum length",dialogAddColumnMaxLengthInfo:"Maximum text length",dialogAddColumnMinValue:"Minimum value",dialogAddColumnMinValueInfo:"Minimum number",dialogAddColumnMaxValue:"Maximum value",dialogAddColumnMaxValueInfo:"Maximum number",dialogAddColumnMinDate:"Minimum date",dialogAddColumnMinDateInfo:"Minimum date",dialogAddColumnMaxDate:"Maximum date",dialogAddColumnMaxDateInfo:"Maximum date",dialogAddColumnColorItems:"Color items",dialogAddColumnListItems:"List items",dialogAddColumnLinkListItems:"Choose a table to link to",dialogAddColumnLinkField:"Choose a lookup field",dialogAddColumnLinkSelect:"Allow linking to multiple rows",dialogAddColumnFormula:"Please enter a formula",dialogAddColumnListItemsError:"You cannot delete an item while in use.",dialogAddColumnDefault:"Default value",dialogAddColumnDefaultDateCurrent:"Current Date",dialogAddColumnDefaultDateSpecific:"Specific Date",dialogAddColumnAlign:"Align",dialogAddColumnAlignLeft:"Left",dialogAddColumnAlignRight:"Right",dialogAddColumnAlignCenter:"Center",dialogAddColumnAlignInfo:"Table cells text alignment",dialogAddColumnResizable:"Resizable",dialogAddColumnResizableInfo:"Select if you want to make the column resizable",dialogAddColumnRequired:"Required",dialogAddColumnRequiredInfo:"Select if you want to make the column required",dialogAddColumnSortable:"Sortable",dialogAddColumnSortableInfo:"Select if you want to sort by this column",dialogAddColumnFilterable:"Filterable",dialogAddColumnFilterableInfo:"Select if you want to filter by this column",dialogAddColumnEditable:"Editable",dialogAddColumnEditableInfo:"Select if you want to edit by this column",dialogAddColumnMultipleCollaborators:"Multiple Collaborators",dialogAddColumnMultipleCollaboratorsInfo:"Select if you want to allow multiple collaborators",dialogAddColumnCheckItems:"Show Checkbox",dialogAddColumnFormatting:"Rich Formatting",priority_low:"Low",priority_average:"Average",priority_high:"High",priority_critical:"Critical",bold:"Bold",fontStyle:"Font Style",italic:"Italic",send:"Send",copy:"copy",status:"Status",underline:"Underline",comments:"Comments",comment:"Comment",commentPlaceholder:"Leave a comment",noComments:"Leave a comment and collaborate with your team.",guestUser:"Guest",background:"Background",starred:"Starred",resetFormat:"Reset Format",notStarred:"Not starred",color:"Color",coloredItems:"Colored items",conditionalFormatting:"Conditional Formatting",groupBarLabel:"Drag a column header here to group by that column",dialogDeleteContent:"Are you sure you want to delete this row?",detailsTab:"Format",commentsTab:"Comments",historyTab:"History",historyEvent:"Event",historyAuthor:"Author",historyDetails:"Details",range:"Changed {{column}} from {{oldValue}} to {{newValue}}",nullRange:"Changed {{column}} to {{newValue}}",rowCreated:"Row Created",propertyUpdated:"{{value}} updated",propertyRemoved:"{{value}} removed",dropImages:"Drop images here",addImages:"Add images",dropFiles:"Drop files here",addFiles:"Add files",unassigned:"Unassigned",historyDate:"Date",copyURL:"Copy row URL",calendar:{"/":"/",":":":",firstDay:0,days:{names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],namesAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],namesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]},months:{names:["January","February","March","April","May","June","July","August","September","October","November","December",""],namesAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]},AM:["AM","am","AM"],PM:["PM","pm","PM"],eras:[{name:"A.D.",start:null,offset:0}],currencySymbol:"$",currency:"USD",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","},CONTAINS:"Contains",DOES_NOT_CONTAIN:"Does not contain",ENDS_WITH:"Ends with",EQUAL:"Equal",GREATER_THAN:"Greater than",GREATER_THAN_OR_EQUAL:"Greater than or equal",LESS_THAN:"Less than",LESS_THAN_OR_EQUAL:"Less than or equal",NOT_EQUAL:"Not equal",RANGE:"Range",CLEAR_FILTER:"Clear Filter",STARTS_WITH:"Starts with",addFilter:"+ Add filter",and:"And",apply:"Apply",applyOnce:"Apply once",booleanFirst:"☐",booleanLast:"☑",cancel:"Cancel",CONTAINS_CASE_SENSITIVE:"Contains (case sensitive)",dateFirst:"1",dateLast:"9",DOES_NOT_CONTAIN_CASE_SENSITIVE:"does not contain (case sensitive)",EMPTY:"empty",ENDS_WITH_CASE_SENSITIVE:"ends with (case sensitive)",EQUAL_CASE_SENSITIVE:"equal (case sensitive)",filter:"Filter",customize:"Hide columns",customizeOne:"1 hidden column",customizeHidden:"{{n}} hidden columns",filteredByMultiple:"{{n}} filters",filteredByOne:"1 filter",filterValuePlaceholder:"Value",find:"Find a field",findInView:"Find in view",firstBy:"Sort by",found:"{{nth}} of {{n}}",from:"from",noFilters:"No filters applied",noResults:"No results",noSorting:"No sorting applied",noOptions:"No options",NOT_EMPTY:"not empty",NOT_NULL:"not null",NULL:"null",numberFirst:"1",numberLast:"9",ok:"OK",or:"Or",pickAnother:"Pick another field to sort by",maintainSort:"Maintain sort",sort:"Sort",group:"Group",sortedByMultiple:"Sorted by {{n}} columns",sortedByOne:"Sorted by 1 column",STARTS_WITH_CASE_SENSITIVE:"starts with (case sensitive)",stringFirst:"A",stringLast:"Z",thenBy:"then by",where:"Where",collapseAll:"Collapse all",expandAll:"Expand all",noGrouping:"No grouping",groupedByMultiple:"{{n}} groups",groupedByOne:"1 group",groupedBy:"Grouped by {{column}}",deleteByMultiple:"Delete {{n}} rows",deleteByOne:"Delete 1 row",download:"Download",firstByGroup:"Group by",expandRecord:"Expand row",expandCell:"Expand cell",pickAnotherGroupBy:"Pick another field to group by",add:"Add condition",all:"All columns",between:"Between",close:"Close",column:"Column:",condition:"Condition:",equal:"equal",fontFamily:"Font family:",fontSize:"Font size:",format:"Format:",greaterThan:"greater than",highlight:"Highlight",lessThan:"less than",notEqual:"not equal",remove:"Remove condition",secondValue:"Second value:",text:"Text",value:"Value:",addCondition:"Add Condition",addGroup:"Add Group",blanks:"(Blanks)",clear:"Clear",contains:"contains",containsCaseSensitive:"contains (case sensitive)",dateTabLabel:"DATE",doesNotContain:"does not contain",doesNotContainCaseSensitive:"does not contain (case sensitive)",empty:"empty",endsWith:"ends with",endsWithCaseSensitive:"ends with (case sensitive)",equalCaseSensitive:"equal (case sensitive)",greaterThanOrEqual:"greater than or equal",lessThanOrEqual:"less than or equal",mismatchedProperties:'smartFilterPanel: The "filterType" and the data type of the selected "dataField" are mismatched.',missingProperty:'smartFilterPanel: When mode is \'excel\', either "data" and "dataField" or "dataSource" of type Array have to be set.',notEmpty:"not empty",notNull:"not null",null:"null ",placeholderBoolean:"Select value",placeholderDate:"Enter date",placeholderNumber:"Enter number",placeholderTime:"Enter time",placeholderValue:"Enter value",selectAll:"(Select All)",showRows:"Show rows where:",startsWith:"starts with",startsWithCaseSensitive:"starts with (case sensitive)",matchCase:"Match Case",timeTabLabel:"TIME",today:"Today",tomorrow:"Tomorrow",yesterday:"Yesterday",formatColumn:"Format Column",formating:"Conditional Formatting",reset:"Reset",filteredRecords:"All rows are filtered",duplicateCells:"Clone column cells and settings",duplicateSettings:"Clone column settings",views:"Views",createView:"New View",newGrid:"Grid",newKanban:"Kanban",newCard:"Cards",layout:"Layout",settings:"Name",viewNamePlaceholder:"View name",view:"View",noViews:"Found no views",kanbanView:"View your records as cards on a Kanban board",gridView:"View your records in a Table",cardView:"View your records in a Card view",days:"{{value}}d",daysOverdue:"{{value}} days overdue",daysLeft:"{{value}} days left"}},type:"object"},onCellValue:{value:null,type:"any",reflectToAttribute:!1},onCellUpdate:{value:null,type:"any",reflectToAttribute:!1},onCellRender:{value:null,type:"any",reflectToAttribute:!1},onBeforeInit:{value:null,type:"any",reflectToAttribute:!1},onInit:{value:null,type:"any",reflectToAttribute:!1},onAfterInit:{value:null,type:"any",reflectToAttribute:!1},onKey:{value:null,type:"any",reflectToAttribute:!1},onKeyUp:{value:null,type:"any",reflectToAttribute:!1},onRender:{value:null,type:"any",reflectToAttribute:!1},onLoad:{value:null,type:"any",reflectToAttribute:!1},onChartInit:{value:null,type:"any",reflectToAttribute:!1},onComment:{value:null,type:"any",reflectToAttribute:!1},onRowInit:{value:null,type:"any",reflectToAttribute:!1},onRowClass:{value:null,type:"any",reflectToAttribute:!1},onRowChange:{value:null,type:"any",reflectToAttribute:!1},onRowDetailInit:{value:null,type:"any",reflectToAttribute:!1},onRowDetailUpdated:{value:null,type:"any",reflectToAttribute:!1},onRowInserted:{value:null,type:"any",reflectToAttribute:!1},onRowRemoved:{value:null,type:"any",reflectToAttribute:!1},onRowUpdate:{value:null,type:"any",reflectToAttribute:!1},onRowUpdated:{value:null,type:"any",reflectToAttribute:!1},onRowStarred:{value:null,type:"any",reflectToAttribute:!1},onRowHistory:{value:null,type:"any",reflectToAttribute:!1},onRowStyle:{value:null,type:"any",reflectToAttribute:!1},onRowResize:{value:null,type:"any",reflectToAttribute:!1},onColumnInit:{value:null,type:"any",reflectToAttribute:!1},onColumnInserted:{value:null,type:"any",reflectToAttribute:!1},onColumnRemoved:{value:null,type:"any",reflectToAttribute:!1},onColumnResize:{value:null,type:"any",reflectToAttribute:!1},onColumnReorder:{value:null,type:"any",reflectToAttribute:!1},onColumnSummaryChange:{value:null,type:"any",reflectToAttribute:!1},onColumnUpdated:{value:null,type:"any",reflectToAttribute:!1},onColumnClone:{value:null,type:"any",reflectToAttribute:!1},onColumnChange:{value:null,type:"any",reflectToAttribute:!1},onCommand:{value:null,reflectToAttribute:!1,type:"any"},onViewInit:{value:null,type:"any",reflectToAttribute:!1},filtering:{value:{enabled:{value:!1,type:"boolean"},operator:{value:"and",type:"string"},filter:{value:[],type:"array",reflectToAttribute:!1},filterRow:{value:{visible:{value:!1,type:"boolean"},menuVisible:{value:!1,type:"boolean"},applyMode:{value:"auto",type:"string",allowedValues:["auto","click"]},autoApplyModeDelay:{value:800,type:"number"}},type:"object"},filterMenu:{value:{visible:{value:!0,type:"boolean"},buttons:{value:["cancel","clear","filter"],type:"array"},dataSource:{value:null,type:"any"},width:{value:250,type:"number"},height:{value:200,type:"number"},mode:{value:"default",allowedValues:["default","excel"],type:"string"},messages:{value:null,type:"object"}},type:"object"}},type:"object"},editing:{value:{allowRowHeaderEdit:{value:!1,type:"boolean"},allowColumnHeaderEdit:{value:!1,type:"boolean"},autoUpdateFilterAndSort:{value:!0,type:"boolean"},active:{value:!1,readonly:!0,type:"boolean"},enabled:{value:!1,type:"boolean"},batch:{value:!1,type:"boolean"},action:{value:"click",type:"string",allowedValues:["none","click","doubleClick"]},commandKeys:{value:{commandKeyCancel:{value:{command:"commandKeyCancelCommand",key:"Escape"},type:"object"},commandKeyUpdate:{value:{command:"commandKeyUpdateCommand",key:"Enter | Tab"},type:"object"}},type:"object"},commandBar:{value:{visible:{value:!1,type:"boolean"},position:{value:"near",allowedValues:["near","far","both"],type:"string"},displayMode:{value:"labelAndIcon",allowedValues:["label","icon","labelAndIcon"],type:"string"},dataSource:{value:{commandBarAddRow:{value:{command:{value:"commandBarAddRowCommand",type:"any"},icon:{value:"smart-icon-plus",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandBarDeleteRow:{value:{command:{value:"commandBarDeleteRowCommand",type:"any"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandBarBatchSave:{value:{command:{value:"commandBarBatchSaveCommand",type:"any"},icon:{value:"smart-icon-ok-squared",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!0,type:"any"}},type:"object"},commandBarBatchRevert:{value:{command:{value:"commandBarBatchRevertCommand",type:"any"},icon:{value:"smart-icon-reload",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!0,type:"any"}},type:"object"},commandBarCustom:{value:{command:{value:"",type:"any"},icon:{value:"smart-icon-ellipsis-vert",type:"string"},label:{value:"",type:"string"},visible:{value:!1,type:"any"}},type:"object"}},type:"object"}},type:"object"},commandColumn:{value:{visible:{value:!1,type:"boolean"},inline:{value:!1,type:"boolean"},position:{value:"far",allowedValues:["near","far"],type:"string"},displayMode:{value:"icon",allowedValues:["label","icon","labelAndIcon"],type:"string"},dataSource:{value:{commandColumnMenu:{value:{command:{value:"commandColumnMenuCommand",type:"any"},icon:{value:"smart-icon-menu",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandColumnEdit:{value:{command:{value:"commandColumnEditCommand",type:"any"},icon:{value:"smart-icon-mode-edit",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:"auto",type:"any"}},type:"object"},commandColumnDelete:{value:{command:{value:"commandColumnDeleteCommand",type:"any"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!0,type:"any"}},type:"object"},commandColumnUpdate:{value:{command:{value:"commandColumnUpdateCommand",type:"any"},icon:{value:"smart-icon-ok-squared",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:"auto",type:"any"}},type:"object"},commandColumnCancel:{value:{command:{value:"commandColumnCancelCommand",type:"any"},icon:{value:"smart-icon-cancel-circled",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:"auto",type:"any"}},type:"object"},commandColumnRowMenu:{value:{command:{value:"commandColumnRowMenuCommand",type:"any",reflectToAttribute:!1},icon:{value:"smart-icon-ellipsis-vert",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandColumnCustom:{value:{command:{value:"",type:"any",reflectToAttribute:!1},icon:{value:"smart-icon-ellipsis-vert",type:"string"},label:{value:"",type:"string"},visible:{value:!1,type:"any"}},type:"object"}},type:"object"},width:{value:null,type:"number?"}},reflectToAttribute:!1,type:"object"},mode:{value:"cell",allowedValues:["cell","row"],type:"string"},addNewColumn:{value:{visible:{value:!1,type:"boolean"}},type:"object"},addNewRow:{value:{position:{value:"both",allowedValues:["near","far","both"],type:"string"},visible:{value:!1,type:"boolean"},autoEdit:{value:!0,type:"boolean"},autoCreate:{value:!1,type:"boolean"},autoSave:{value:!0,type:"boolean"},label:{value:"{{message}}",type:"string"},displayMode:{value:"row",allowedValues:["row","button"],type:"string"}},type:"object"},dialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:"auto",type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},addDialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:"auto",type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},addColumnDialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:430,type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},deleteDialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:"auto",type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"}},type:"object"},paging:{value:{enabled:{value:!1,type:"boolean"},spinner:{value:{enabled:{value:!1,type:"boolean"},step:{value:1,type:"number"}},type:"object"},pageHierarchySize:{value:2,type:"int"},pageSize:{value:10,type:"int"},pageIndex:{value:0,type:"int",validator:"pageIndexValidator"}},type:"object"},pager:{value:{autoEllipsis:{value:"both",allowedValues:["none","before","after","both"],type:"string"},position:{value:"far",allowedValues:["near","far","both"],type:"string"},template:{value:"",type:"string"},pageSizeSelector:{value:{visible:{value:!1,type:"boolean"},dataSource:{value:[10,20,50],type:"object"},position:{value:"far",allowedValues:["near","far"],type:"string"}},type:"object"},summary:{value:{position:{value:"far",allowedValues:["near","far"],type:"string"},visible:{value:!1,type:"boolean"}},type:"object"},navigationButtons:{value:{position:{value:"both",allowedValues:["near","far","both"],type:"string"},prevNextButtons:{value:{visible:{value:!0,type:"boolean"}},type:"object"},firstLastButtons:{value:{visible:{value:!0,type:"boolean"}},type:"object"},labels:{value:{visible:{value:!1,type:"boolean"}},type:"object"}},type:"object"},navigationInput:{value:{position:{value:"far",allowedValues:["near","far"],type:"string"},visible:{value:!1,type:"boolean"}},type:"object"},pageIndexSelectors:{value:{visible:{value:!0,type:"boolean"},dataSource:{value:10,type:"any"}},type:"object"},visible:{value:!1,type:"boolean"}},type:"object",reflectToAttribute:!1},rowDetail:{value:{enabled:{value:!1,type:"boolean"},height:{value:200,type:"number"},position:{value:"near",allowedValues:["near","far"],type:"string"},template:{value:"",type:"any",reflectToAttribute:!1},visible:{value:!0,type:"boolean"},dialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:300,type:"any"},width:{value:360,type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"}},type:"object"},rowCSSRules:{value:null,type:"any"},summaryRow:{value:{position:{value:"far",allowedValues:["near","far"],type:"string"},visible:{value:!1,type:"boolean"},editing:{value:!1,type:"boolean"},template:{value:"",type:"string"}},type:"object"},scrolling:{value:"physical",allowedValues:["physical","virtual","infinite","deferred"],type:"string"},columnHeader:{value:{visible:{value:!0,type:"boolean"}},type:"object"},groupHeader:{value:{visible:{value:!1,type:"boolean"},template:{value:"",type:"string"}},type:"object"},header:{value:{visible:{value:!1,type:"boolean"},template:{value:"",type:"any"},buttons:{value:["columns","filter","group","sort","format","search"],type:"array"},searchCommand:{value:"search",allowedValues:["search","filter"],type:"string"},customButton:{value:{command:{value:null,type:"any",reflectToAttribute:!1},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"boolean"},icon:{value:"smart-icon-settings",type:"string"},label:{value:"",type:"string"}},type:"object",reflectToAttribute:!1},onInit:{value:null,reflectToAttribute:!1,type:"any"}},type:"object"},footer:{value:{visible:{value:!1,type:"boolean"},template:{value:"",type:"any"}},type:"object"},stateSettings:{value:{enabled:{value:!0,type:"boolean",reflectToAttribute:!1},current:{value:"",type:"string",reflectToAttribute:!1},storage:{value:null,type:"any",reflectToAttribute:!1},autoSave:{value:!1,type:"boolean",reflectToAttribute:!1},autoLoad:{value:!1,type:"boolean",reflectToAttribute:!1},allowLocalStorage:{value:!0,type:"boolean",reflectToAttribute:!1},options:{value:[],type:"array",reflectToAttribute:!1},onStateChange:{value:null,type:"any",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1},checkBoxes:{value:{visible:{value:!1,type:"boolean"},hasThreeStates:{value:!1,type:"boolean"}},type:"object"},selection:{value:{enabled:{value:!1,type:"boolean"},allowRowHeaderSelection:{value:!1,type:"boolean"},allowColumnHeaderSelection:{value:!1,type:"boolean"},allowRowSelection:{value:!0,type:"boolean"},allowCellSelection:{value:!1,type:"boolean"},allowDragSelection:{value:!0,type:"boolean"},allowDragSelectionAutoScroll:{value:!0,type:"boolean"},allowCellDragSelectionHandle:{value:!0,type:"boolean"},allowCellDragDropSelectionHandle:{value:!0,type:"boolean"},allowCellDragSelectionAutoFill:{value:!0,type:"boolean"},selectAllMode:{value:"page",allowedValues:["none","page","all"],type:"string"},mode:{value:"many",type:"string",allowedValues:["one","many","extended"]},action:{value:"click",type:"string",allowedValues:["none","click","doubleClick"]},checkBoxes:{value:{enabled:{value:!1,type:"boolean"},autoShow:{value:!1,type:"boolean"},action:{value:"click",type:"string",allowedValues:["none","click","doubleClick"]},selectAllMode:{value:"page",allowedValues:["none","page","all"],type:"string"},position:{value:"near",allowedValues:["near","far"],type:"string"}},type:"object"},selected:{value:"",type:"string"},tabKeyBehavior:{value:"default",allowedValues:["none","default"],type:"string"},defaultSelection:{value:!1,type:"boolean"}},type:"object"},sorting:{value:{enabled:{value:!1,type:"boolean"},sort:{value:[],type:"array"},mode:{value:"one",allowedValues:["one","many"],type:"string"},maintainSort:{value:!0,type:"boolean"},commandKey:{value:"",allowedValues:["","Shift","Control","Alt"],type:"string"},sortToggleThreeStates:{value:!0,type:"boolean"},sortToggleOnClick:{value:!0,type:"boolean"},sortToggleOnClickAndCommandKey:{value:!1,type:"boolean"}},type:"object"},storeHistory:{value:!1,type:"boolean"},storeHistoryItems:{value:20,type:"number"},users:{value:[],type:"array",reflectToAttribute:!1},virtualModeCachedRowsCount:{value:100,type:"int"}}}static get requires(){return{}}static get styleUrls(){return["smart.menu.css","smart.filterpanel.css","smart.pager.css","smart.grid.css","smart.textbox.css"]}template(){return"<div class='smart-container'id='container' disabled='[[disabled]]' role='grid'>\n <div id='header' role=\"toolbar\" class='smart-grid-header smart-hidden'>\n </div>\n <div id='groupHeader' role=\"presentation\" class='smart-grid-group-header smart-hidden'></div>\n <div id='headerPager' top class='smart-grid-pager smart-hidden'></div>\n <div id='headerCommandBar' header top class='smart-grid-header smart-grid-command-bar smart-hidden'></div>\n <div id='content' class='smart-grid-content'>\n <div id='columnHeader' role=\"rowgroup\" class='smart-grid-column-header'>\n <div id='columnNearContainer' role=\"row\" class='near smart-hidden smart-grid-column-header-cell-container'>\n </div>\n <div id='columnContainer' role=\"row\" class='center smart-grid-column-header-cell-container'>\n </div>\n <div id='columnFarContainer' role=\"row\" class='far smart-hidden smart-grid-column-header-cell-container'>\n </div>\n </div>\n <div id='scrollView' role=\"rowgroup\" class ='smart-grid-scroll-view'>\n <div id='rowNearContainer' role=\"presentation\" class='near smart-hidden smart-grid-row-container'>\n </div>\n <div id='rowContainer' role=\"presentation\" class='center smart-grid-row-container'>\n </div>\n <div id='rowFarContainer' role=\"presentation\" class='far smart-hidden smart-grid-row-container'>\n </div>\n <div id='placeholder' class ='smart-hidden smart-placeholder smart-grid-placeholder'></div>\n <smart-scroll-bar right-to-left=\"[[rightToLeft]]\" theme=\"[[theme]]\" id='verticalScrollBar' class='smart-grid-scroll-bar' wait disabled='[[disabled]]' orientation='vertical'></smart-scroll-bar>\n <smart-scroll-bar right-to-left=\"[[rightToLeft]]\" theme=\"[[theme]]\" id='horizontalScrollBar' class='smart-grid-scroll-bar' wait disabled='[[disabled]]'></smart-scroll-bar>\n </div>\n <div id='filterFooter' class='smart-grid-filter-footer smart-hidden'></div>\n </div>\n <div class=\"smart-grid-view-content smart-hidden\" id=\"viewContent\"></div>\n <div class=\"smart-grid-view-bar smart-hidden\" id=\"viewBar\"></div>\n <div id='loadingIndicatorContainer' class='smart-loader-container'>\n <span id='loadingIndicator' class='smart-grid-loader smart-loader'></span>\n <span id='loadingIndicatorPlaceholder' class ='smart-loader-label smart-hidden'></span>\n </div>\n <div id='footerCommandBar' footer class='smart-grid-footer smart-grid-command-bar smart-hidden'></div>\n <div id='footerPager' class='smart-grid-pager smart-hidden'></div>\n <div id='footer' class='smart-grid-footer smart-hidden'></div>\n </div>"}static get listeners(){return{focus:"_focusHandler",blur:"_blurHandler",wheel:"_mouseWheelHandler","document.up":"_upHandler","document.down":"_downHandler","document.move":"_moveHandler","document.scroll":"_scrollHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",resize:"_resizeHandler","header.click":"_headerClickHandler","columnHeader.down":"_columnDownHandler","columnHeader.click":"_columnClickHandler","columnHeader.move":"_columnMoveHandler","columnHeader.mouseleave":"_columnMouseLeaveHandler","rowNearContainer.down":"_rowDownHandler","rowContainer.down":"_rowDownHandler","rowFarContainer.down":"_rowDownHandler","container.selectstart":"_selectStartHandler",styleChanged:"_styleChangedHandler",swipeleft:"_swipeLeftHandler",swiperight:"_swipeRightHandler",contextmenu:"_contextMenuHandler","document.paste":"_clipboardPasteHandler"}}_clipboardPasteHandler(e){if("paste"===e.type){const t=this;if(document.activeElement!==t)return;if(t._selection&&t._selection.focusedCell){const o=t._selection.focusedCell.id,l=t._selection.focusedCell.dataField,a=t.columnByDataField[l];if(!a)return;if(a&&("image"===a.template||"attachment"===a.template)){e.preventDefault();let a=(e.clipboardData||e.originalEvent.clipboardData).items,n=null,i=0,r=0,s=[];for(let e=0;e<a.length;e++)if(0===a[e].type.indexOf("image")&&(n=a[e].getAsFile(),i++,null!==n)){let e={label:n.name,size:n.size},a=new FileReader;a.onload=function(a){r++;const n=a.target.result;e.value=n;let d=!1;for(let o=0;o<t.uploadSettings.userFiles.length;o++){const l=t.uploadSettings.userFiles[o];if(l.name===e.label||l.label===e.label){d=!0;break}}if(d||t.uploadSettings.userFiles.push(e),s.push(e),r===i){let e=t.getCellValue(o,l);e||(e=[]),"string"==typeof e&&(e=JSON.parse(e)),e=[...e,...s],t.setCellValue(o,l,e)}},a.readAsDataURL(n)}}}}}_contextMenuHandler(e){if(this.contextMenu.enabled)return e.preventDefault(),e.stopPropagation(),!1}get _tabindex(){return this.disabled||this.unfocusable?"":' tabindex="0"'}pageIndexValidator(e,t){const o=this;if(t<0)return 0;if(o.dataSource){if(o.dataSource.virtualDataSource)return t;const e=Math.ceil(o.dataSource.length/o._pageSize);if(t>e-1)return e-1}}_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)}}getBoundingRect(e){const t=this;let o=window.pageXOffset,l=window.pageYOffset,a=e.getBoundingClientRect();if(e!==document.body){let a=e.parentNode;for(;a!==document.body&&a;){a&&(o+=a.scrollLeft,l+=a.scrollTop);let e=a;a?(a=a.parentNode,t.enableShadowDOM&&a===t.shadowRoot?a=t:!t.isInShadowDOM||a!==t.getRootNode()&&e!==t.getRootNode()||(a=t.getRootNode().host)):t.isInShadowDOM&&(a=t.getRootNode().host)}}return{bottom:a.bottom+l,height:a.height,left:a.left+o,right:a.right+o,top:a.top+l,width:a.width}}_downHandler(e){this._downTarget=e.originalEvent.target}_removeCellContentPopup(){const e=this;e._cellContentPopup&&(e._cellContentPopup.remove(),e._cellContentPopup=null),e._cellContentPopupTimer&&(clearTimeout(e._cellContentPopupTimer),e._cellContentPopupTimer=null)}_upHandler(e){const t=this,o=t.getBoundingRect(t);super._upHandler(),t._tapTimer&&clearTimeout(t._tapTimer);const l=()=>{t.editing.isEditing&&!t.editing.dialog.enabled&&setTimeout((()=>{if(!e.defaultPrevented){if(t.editing.editCell&&t.editing.editCell.editor.instance){const o=t.editing.editCell.editor.instance;if(o.element&&o.element.hasAttribute("aria-owns")){const t=o.element.getAttribute("aria-owns"),l=document.getElementById(t);if(l&&l.contains(e.originalEvent.target))return}if(t.editing.editCell.editor.instance.blur(e),e.defaultPrevented)return}t.isAttached&&t.endEdit()}}),50)};if(e.originalEvent&&(e.originalEvent.target===t.$.scrollView&&t._downTarget===e.originalEvent.target&&l(),e.originalEvent.target.closest(".smart-grid-dialog")))t._dialogDragDetails&&(t._dialogDragDetails.started=!1);else{if(e.pageX<o.left||e.pageX>o.right||e.pageY<o.top||e.pageY>o.bottom){let o=!1,a=e.originalEvent.target;for(;a;)if(a=a.parentNode,a===t){o=!0;break}if(o)return t._dragSelectionEnd(e),t._endResize(e),void t._endDrag(e);if(t._summaryRowDialog&&t._summaryRowDialog.classList.contains("open")&&t._summaryRowDialog.confirm(),t._inputOverlay&&(t._inputOverlay.classList.remove("smart-input-overlay-on"),setTimeout((()=>{t._inputOverlay&&(t._inputOverlay.parentNode&&t._inputOverlay.parentNode.removeChild(t._inputOverlay),t._inputOverlay=null)}),t.behavior.doubleClickTimingDelay)),l(),t.menu){let o,l,a,n;if(t.enableShadowDOM||t.isInShadowDOM?(o=e.originalEvent.composedPath()[0],l=function(){let e=o.getRootNode().host;for(;e;){if(e===t)return e;e=e.getRootNode().host}}(),a=t.menu.contains(o)||t.menu.firstElementChild.shadowRoot.contains(o),n=t.menu.firstElementChild.shadowRoot):(o=e.originalEvent.target,l=t.contains(o),a=t.menu.contains(o),n=t.menu),!l&&!a){const e=n.querySelectorAll("smart-drop-down-list"),l=n.querySelectorAll("smart-date-time-picker"),a=n.querySelectorAll("smart-date-input"),i=n.querySelectorAll("smart-input");for(let t=0;t<e.length;t++)if(e[t].$.dropDownContainer.contains(o))return;for(let e=0;e<l.length;e++)if(l[e].$.dropDownContainer.contains(o))return;for(let e=0;e<a.length;e++)if(a[e].$.scrollView.contains(o))return;for(let e=0;e<i.length;e++)if(i[e].$.scrollView.contains(o))return;return void t.closeMenu()}}}t._summaryRowDialog&&t._summaryRowDialog.classList.contains("open")&&t._summaryRowDialog.confirm(),t._dragSelectionEnd(e),t._endResize(e),t._endDrag(e)}}_nextColumn(e){const t=this;for(let o=0;o<t.viewColumns.length;o++){const l=t.viewColumns[o];if(l.visibleIndex===e.visibleIndex+1)return l}return null}_nextRow(e){const t=this._recyclingRows,o=t.indexOf(e);return o>=0?t[o+1]:null}_moveHandler(e){const t=this;if(t.isInitialized&&t._selection){if(t.selection.enabled&&t.selection.allowDragSelection&&!t.editing.isEditing&&(!t._selection.selectionRect||t._selection.selectionRect&&!t._selection.selectionRect.captured)&&(!0!==t._mobile&&t._dragSelection(e),e.originalEvent)){const o=e.originalEvent.target.closest?e.originalEvent.target:void 0;Smart.Utilities.Core.isMobile&&o&&o.closest("smart-grid")===t&&e.originalEvent.preventDefault()}t.isScrolling||("none"===t.behavior.columnResizeMode||t.classList.contains("smart-grid-row-resize-mode")||t._columnMoveResizeHandler(e),"none"===t.behavior.rowResizeMode||t.classList.contains("smart-grid-column-resize-mode")||t._rowMoveResizeHandler(e),t._drag(e))}}_hideActionButtons(){const e=this;if(e._columnElements){for(let t=0;t<e._columnElements.length;t++){const o=e._columnElements[t],l=o.column;l&&l.autoShowActionButton&&o._hideActionButton()}for(let t=0;t<e._frozenNearColumns.length;t++){const o=e._frozenNearColumns[t],l=o.element;o&&o.autoShowActionButton&&l._hideActionButton()}}}_columnMouseLeaveHandler(){this._mobile||this._hideActionButtons()}_columnMoveHandler(e){const t=this;if(!t.isInitialized)return;if(t._columnResizeStartLine||t._rowResizeStartLine)return;if(t._mobile)return;const o=(o,l)=>{if(o&&o.autoShowActionButton){const a=l.getBoundingClientRect(),n=t.offset(l),i=t.parentElement,r=i?i.scrollTop:0;if(n.left<=e.pageX&&n.left+a.width-6>=e.pageX)if(n.top-r<=e.pageY&&n.top-r+a.height>=e.pageY){if(!t.hasColumnMenu(o))return;l._showActionButton()}else l._hideActionButton();else l._hideActionButton()}};for(let e=0;e<t._columnElements.length;e++){const l=t._columnElements[e];o(l.column,l)}for(let e=0;e<t._frozenNearColumns.length;e++){const l=t._frozenNearColumns[e];o(l,l.element)}}_headerClickHandler(e){const t=this;if(t.$.headerBar){const o=t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target;t.$.headerBar._headerClickHandler(o,t)}}_columnClickHandler(e){const t=this;if(t._overlay)return;if(void 0===e.clientX)return;const o=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let l=null,a=null;const n=new Date-t._columnClickTime<t.behavior.doubleClickTimingDelay;t._columnClickTime=new Date;for(let e=0;e<o.length;e++){const t=o[e];if(t.classList.contains("smart-action-button"))return;if(t.getAttribute("data-field")){l=t.getAttribute("data-field"),a=t;break}}if(l){const o=a.column;if(!o)return;if(e.srcElement.classList.contains("smart-filter-button"))return;if("_addNewColumn"===o.dataField)return void t._openAddColumnDialog();if(Smart.Utilities.Core.isMobile)n&&t.sorting.sortToggleOnClick&&o.allowSortToggleOnClick&&t.sorting.enabled&&(t.sortBy(l),t.autoSaveState()),t._columnMoveHandler(e),e.originalEvent&&e.originalEvent.preventDefault();else if(!n&&t.sorting.sortToggleOnClick&&o.allowSortToggleOnClick&&t.sorting.enabled){if("none"!==t.behavior.columnResizeMode&&"col-resize"===o.element.style.cursor)return;if(t._canSort=!0,""!==t.sorting.commandKey){if("Alt"===t.sorting.commandKey&&!1===e.altKey&&(t._canSort=!1),"Shift"===t.sorting.commandKey&&!1===e.shiftKey&&(t._canSort=!1),"Control"===t.sorting.commandKey&&!1===e.metaKey&&!1===e.ctrlKey&&(t._canSort=!1),"Control"!==t.sorting.commandKey&&e.ctrlKey)return;if(!0===t.sorting.sortToggleOnClickAndCommandKey&&!t._canSort)return}t.sortBy(l),t.autoSaveState()}}}_columnDownHandler(e){const t=this,o=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let l=null,a=null;const n=new Date-t._clickTime<t.behavior.doubleClickTimingDelay;t.$.headerBar&&t.$.headerBar.closePanel(),t._doubleClickHandler(e);for(let e=0;e<o.length;e++){const t=o[e];if(t.classList.contains("smart-action-button"))return;if(t.getAttribute("data-field")){l=t.getAttribute("data-field"),a=t;break}}if(l){const o=a.column;if(!o)return;if("_commandColumn"===l)return void(t.editing.commandColumn.dataSource.commandColumnMenu.visible&&t._applyCommand(t.editing.commandColumn.dataSource.commandColumnMenu.command));const i=function(a){const n=o.selectionColumn?t.selection.checkBoxes.action===a&&t.selection.enabled:t.selection.action===a&&t.selection.enabled;if("col-resize"!==o.element.style.cursor&&(!t.appearance.showColumnHeaderDragIcon||!e.originalEvent.target.classList.contains("smart-drag-handle"))&&n){if(t.editing.enabled&&t.editing.editColumn===o)return;if(e.shiftKey||e.ctrlKey?t._dragSelectionStartDataField=null:t._dragSelectionStartDataField=l,"_checkBoxColumn"===l)return void t._toggleColumnSelection(o);"_rowHeaderColumn"===l&&t.selection.enabled&&t.selection.allowRowHeaderSelection&&t.appearance.showRowHeaderSelectIcon&&(delete t._areAllRowsSelected,t.areAllRowsSelected()?t.clearSelection():t.selectAllRows(),o.refresh()),t.selection.allowColumnHeaderSelection&&o.allowSelect&&t._setSelection(null,o.dataField,e)}};if(t.editing.isEditing&&t.endEdit(),i("click"),t._mobile){t._hideActionButtons();const o=(o,l)=>{if(o&&o.autoShowActionButton){const a=l.getBoundingClientRect(),n=t.offset(l);if(n.left<=e.pageX&&n.left+a.width-6>=e.pageX){if(!t.hasColumnMenu(o))return;l._showActionButton()}else l._hideActionButton()}};for(let e=0;e<t._columnElements.length;e++){const l=t._columnElements[e];o(l.column,l)}}if(t.$.fireEvent("columnClick",{column:o,dataField:o.dataField}),n&&(t.$.fireEvent("columnDoubleClick",{column:o,dataField:o.dataField}),i("doubleClick"),t._onColumnDoubleClick(o,e)),t._columnToResizeElement&&!t._columnResizeLine)return t._columnDownResizeHandler(e),void(t._clickTime=new Date);if(t._beginDrag(e,o),o.menu)return void(t._clickTime=new Date)}t.closeMenu(),t._clickTime=new Date}addTransformMoveStyle(e,t,o,l,a,n){e.style.opacity=n,e.style["transition-duration"]=t,e.style.transform="translate3d("+o+"px,"+l+"px,"+a+"px)"}removeTransformMoveStyle(e){e.style.opacity="",e.style["transition-duration"]="",e.style.transform=""}_rowDownHandler(e){const t=this;if(t._inputOverlay&&t._inputOverlay.classList.remove("smart-input-overlay-on"),t._doubleClickHandler(e),t._closeMenu(t.menu),t._rowResizeHandler(e),t._removeCellContentPopup(),t._toggledRow&&t.appearance.allowRowToggleAnimation)return;if(e.target&&!e.target.classList.contains("smart-grid-row-container")&&!e.target.classList.contains("smart-grid-selection-overlay")&&!e.target.classList.contains("smart-selection-overlay-content"))return;let o=e.clientX,l=e.clientY;e.touches&&(o=e.touches[0].clientX,l=e.touches[0].clientY);const a=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(o,l);let n=null,i=null,r=null,s=null,d=null,u=null,c=null;t._lastPointerDownTime=new Date;for(let e=0;e<a.length;e++){const t=a[e];if(t.hasAttribute("toggle-button")&&(i=t),t.hasAttribute("add-row")&&(d=t),t.hasAttribute("checkbox")&&(r=t),t.hasAttribute("rating-value")&&(u=t),s||"smart-grid-cell"!==t.nodeName.toLowerCase()||(s=t),!c&&t.classList.contains("smart-card")&&(c=t),!n&&"smart-grid-row"===t.nodeName.toLowerCase()){n=t;break}}if("card"!==t.view){if(u&&(t._ratingElement=u),n&&s){const o=s?s.cell:null;if(o.row.filterRow||t._closeMenu(t.filterRowMenu),i&&o&&!o.column.rowDetailColumn&&i!==o.row.toggleDetailButton&&!i.classList.contains("row-detail"))n.row.toggle(e);else if(t.rowDetail.enabled&&t.rowDetail.visible&&i&&o&&o.column.rowDetailColumn){const e=n.row;t.editing.isEditing&&t.cancelEdit(),e.showDetail?t.hideDetail(e.id):t.showDetail(e.id)}else if(d){const e=n.row,o=e.data;let l=o.parent;const a={};for(a[o.groupDataField]=null!==e.label?e.label:null,void 0!==e.labelValue&&(a[o.groupDataField]=e.labelValue);l;){let e=null!==l.label?l.label:null;l.labelValue&&void 0!==e&&(e=l.labelValue),a[l.groupDataField]=e,l=l.parent}t.addRow(a)}else{const o=n.row,l=s?s.cell:null;if(l.column._treeColumn&&r)return void(o.checked=!o.checked);l.element===o.header&&t.behavior.allowRowReorder&&t._beginDrag(e,o),t._tapTimer&&clearTimeout(t._tapTimer),t._tapTimer=setTimeout((function(){t._clickedRow===n&&t.$.fireEvent("rowTap",{row:o,id:o.id,originalEvent:e.originalEvent}),t._clickedCell===s&&t.$.fireEvent("cellTap",{cell:l,id:o.id,dataField:l.column.dataField,originalEvent:e.originalEvent})}),t.behavior.doubleClickTimingDelay);const a=function(a){if(!t.selection.enabled||o.autoGenerated||!0!==o.allowSelect)return void delete t.__selectionStarted;if(o.header&&"row-resize"===o.header.style.cursor){const l=t.offset(o.header);if(t._rowToResize&&l.left<=e.originalEvent.pageX&&e.originalEvent.pageX<=l.left+o.header.offsetWidth)return;o.header.style.cursor=""}const i=t.editing.isEditing;if(i&&t.editing.editCell&&t.editing.editCell.row.id===o.id&&t.editing.editCell.column.dataField===l.column.dataField)return;if(i&&t.editing.editRow&&t.editing.editRow.id===o.id)return;const r=()=>{t.focus(),setTimeout((function(){t.focus()}),50)};if(t.selection.action===a){if(e.shiftKey||e.ctrlKey||!t.selection.allowRowHeaderSelection&&l.column.autoGenerated?t._dragSelectionStartRow=null:t._dragSelectionStartRow=n.row,e.shiftKey||e.ctrlKey?t._dragSelectionStartDataField=null:t._dragSelectionStartDataField=l.column.dataField,l.column.rowHeaderColumn&&!t.selection.allowRowHeaderSelection)return t._dragSelectionStartRow=null,void r();t._setSelection(o.id,l.column.dataField,e),r()}else(l.column.selectionColumn&&t.selection.checkBoxes.enabled&&t.selection.checkBoxes.action===a||l.column.rowHeaderColumn&&t.selection.allowRowHeaderSelection)&&(t._setSelection(o.id,l.column.dataField,e),r())},i=l.selected;t._clickTime||(t._clickTime=new Date);const d=t._clickedCell===s&&new Date-t._clickTime<t.behavior.doubleClickTimingDelay,u=e.originalEvent?e.originalEvent:e,c=3===u.which;if(c||"_commandColumn"===l.column.dataField||a("click"),t.$.fireEvent("rowClick",{row:o,id:o.id,data:t.getRowData(o.id),isRightClick:c,originalEvent:u,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}),t.$.fireEvent("cellClick",{cell:l,id:o.id,dataField:l.column.dataField,value:l.value,isRightClick:c,originalEvent:u,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}),c&&t.contextMenu.enabled)return t.contextMenu.id=o.id,t.contextMenu.dataField=l.column.dataField,t._focusCell(o.id,l.column.dataField),t.openContextMenu(u.pageX+10,u.pageY+10),void(t.contextMenu.selector&&(u.stopPropagation(),u.preventDefault()));if(o.autoGenerated||l.column.autoGenerated||"checkBox"===l.template&&e.originalEvent&&e.originalEvent.target&&e.originalEvent.target.classList.contains("smart-input"))t._onRowClick(o.index,o,e),t._onCellClick(l,e);else if(t.selection.enabled)if(t.selection.allowCellSelection)if("extended"===t.selection.mode){if(!0===i&&i===l.selected&&!t.selection.isDragging){const a=t._selection.focusedCell;a&&t._clickedCell&&a.id===l.row.id&&a.dataField===l.column.dataField&&a.id===t._clickedCell.cell.row.id&&a.dataField===t._clickedCell.cell.column.dataField&&(t._onRowClick(o.index,o,e),t._onCellClick(l,e))}}else d||(t._onRowClick(o.index,o,e),t._onCellClick(l,e));else if(t.selection.allowRowSelection)if("extended"===t.selection.mode){if(!0===i&&i===l.selected&&!t.selection.isDragging){const a=t._selection.focusedCell;t._clickedCell&&a.id===l.row.id&&a.id===t._clickedCell.cell.row.id&&(t._onRowClick(o.index,o,e),t._onCellClick(l,e))}}else d||(t._onRowClick(o.index,o,e),t._onCellClick(l,e));else t._onRowClick(o.index,o,e),t._onCellClick(l,e);else t._onRowClick(o.index,o,e),t._onCellClick(l,e);new Date-t._clickTime<t.behavior.doubleClickTimingDelay&&(t._clickedRow===n&&(t._onRowDoubleClick(o.index,o,e,e),t.$.fireEvent("rowDoubleClick",{row:o,id:o.id,data:t.getRowData(o.id),isRightClick:c,originalEvent:e.originalEvent,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}),a("doubleClick")),t._clickedCell===s&&(t._onCellDoubleClick(l,e),t.$.fireEvent("cellDoubleClick",{cell:l,id:o.id,dataField:l.column.dataField,value:l.value,isRightClick:c,originalEvent:e.originalEvent,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}))),t._clickedRow=n,t._clickedCell=s,t._clickTime=new Date,t.layout.allowCellsWrapShortcut&&t._clickedCell.hasAttribute("focus")&&t._clickedCell.hasAttribute("selected")&&e.shiftKey&&(t._cellContentPopupTimer&&clearTimeout(t._cellContentPopupTimer),t.selection.isDragging?t._removeCellContentPopup():l.autoWrap())}}}else if(c){const o=c.getAttribute("row-id"),l=t.rowById[o];if(l){const a=e.originalEvent?e.originalEvent:e,n=3===a.which;if(l.element||l.createElement(),t.$.fireEvent("rowClick",{row:l,id:l.id,data:t.getRowData(l.id),isRightClick:n,originalEvent:a,pageX:parseInt(a.pageX),pageY:parseInt(a.pageY)}),s){const e=s.getAttribute("data-field");if(e){const o=t.columnByDataField[e],i=new Smart.Grid.Cell(l,o,this);s.cell=i,i.element=s,i&&t.$.fireEvent("cellClick",{cell:i,id:l.id,dataField:i.column.dataField,value:i.value,isRightClick:n,originalEvent:a,pageX:parseInt(a.pageX),pageY:parseInt(a.pageY)})}}const i=e.originalEvent.target;if(c.classList.contains("smart-card-header"))l.element&&l.element.row!==l&&(l.element.row=l),l.toggle();else if(l.children&&l.children.length>0&&(i.classList.contains("smart-icon-ungroup")||i.classList.contains("smart-icon-group")))l.element&&l.element.row!==l&&(l.element.row=l),l.toggle();else if(t.editing.enabled){const e=t.editing.dialog.enabled,l=t.editing.mode,a=t.context;t.context=t,t.editing.dialog.enabled=!0,t.editing.mode="row",t._settingsDialogRowId=o;let n=t._isUpdating;c.setAttribute("edit",""),t.beginEdit(o),t._isUpdating=n,t._endCardRowEdit?(t.removeEventListener("endEdit",t._endCardRowEdit,null),t.removeEventListener("cancelEdit",t._endCardRowEdit,null)):t._endCardRowEdit=()=>{t.context=t,t.editing.dialog.enabled=e,t.editing.mode=l,t.editing.isEditing=!1,t.context=a,delete t._settingsDialogRowId,delete t._dialogEdit},t.addEventListener("endEdit",t._endCardRowEdit),t.addEventListener("cancelEdit",t._endCardRowEdit)}}}}showDetail(e){const t=this.rowById[e];t&&(t.showDetail=!0)}hideDetail(e){const t=this.rowById[e];t&&(t.showDetail=!1)}_focusHandler(){this._focused=!0,this.setAttribute("focus","")}_blurHandler(){this._focused=!1,this.removeAttribute("focus")}_notify(e,t,o){const l=this;if(l.notifyFn)for(let a=0;a<l.notifyFn.length;a++)l.notifyFn[a](e,t,o)}notify(e){const t=this;e&&(t.notifyFn||(t.notifyFn=[]),t.notifyFn.push(e))}_applyTemplate(e,t){let o=null;if(null!==e&&""!==e)if(e&&"function"==typeof e)e(t);else if((e.startsWith("#")||e.startsWith("."))&&(o=document.querySelector(e)),o)t.innerHTML="",o instanceof HTMLElement&&!(o instanceof HTMLTemplateElement)?t.appendChild(o):t.appendChild(o.content.cloneNode(!0).firstElementChild);else{const o=function(e){const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild}(e);o&&(t.innerHTML="",t.appendChild(o))}else t.innerHTML=""}propertyChangedHandler(e,t,o){const l=this;if(l.isInitialized){switch(l._notify(e,t,o),e){case"onRowHistory":case"onRowInserted":case"stateSettings_current":return;case"view":return void(l.$.headerBar&&l.$.headerBar._setView&&l.$.headerBar._setView(o,!0));case"users":case"currentUser":l._refreshCurrentUser(),l._recycle();break;case"summaryRow_visible":{for(let e=0;e<l.columns.length;e++)l._summaryRowCount=Math.max(l._summaryRowCount,l.columns[e].summary.length);const e=l.onRowInserted;l.onRowInserted=null,l._renderRows(!0),l.onRowInserted=e;break}case"conditionalFormatting":return l._renderConditionalFormatting(),void l.refresh();case"appearance_displayLoadingIndicator":return void l._setLoadingIndicatorVisibility();case"appearance_placeholder":return void(l.$.placeholder.innerHTML=o);case"appearance_showColumnHeaderLines":case"appearance_showColumnGroupLines":case"appearance_showColumnLines":case"appearance_showRowLines":return void l._recycle();case"appearance_allowColumnStickyPosition":o?l._stickHeader():l._unstickHeader();break;case"appearance_showColumnIcon":for(let e=0;e<l.columns.length;e++)l.columns[e].setProperty("showIcon",l.appearance.showColumnIcon);l._recycle();break;case"appearance_showRowHeaderNumber":case"appearance_showRowHeader":{l._initializeRowNumberColumn();const e=l._frozenNearColumns[0];e.rowHeaderColumn&&e.element&&!e.element.parentNode&&l.$.columnNearContainer.appendChild(e.element),l.refresh();break}case"header_visible":l.header.visible&&""===l.header.template&&(l.$.header.innerHTML='<smart-grid-toolbar header-position="top"></smart-grid-toolbar>',l.$.headerBar=l.$.header.firstElementChild,l.$.headerBar._init(l),l.header.onInit&&l.header.onInit(l.$.headerBar));break;case"header_buttons":l.header.visible&&""===l.header.template&&l._refreshHeaderBar();break;case"header_template":l._applyTemplate(o,l.$.header);break;case"footer_template":l._applyTemplate(o,l.$.footer);break;case"layout_columnWidth":case"columnWidth":{l.columns.canNotify=!1;let e=parseInt(o);if(isNaN(e)&&(e=null),e>=30||null===e)for(let t=0;t<l.columns.length;t++)l.columns[t].width=e;l.columns.canNotify=!0,l.refresh();break}case"checkBoxes_visible":return void l._recycle();case"checkBoxes_hasThreeStates":return l.rows.canNotify=!1,l._applyThreeStates(l.rowHierarchy),l.rows.canNotify=!0,void l._recycle();case"columnHeader_visible":l.__columnHeaderHeight=null,l.refresh();break;case"selection_checkBoxes_enabled":l._selectionColumn.visible=o;break;case"selection_checkBoxes_autoShow":l._selectionColumn.element&&(o?l._selectionColumn.element.setAttribute("auto-show",""):l._selectionColumn.element.removeAttribute("auto-show"));break;case"selection_checkBoxes_position":{let e=l.viewColumns.indexOf(l._selectionColumn);l.viewColumns.canNotify=!1,l.viewColumns.splice(e,1);const t=l._frozenNearColumns.indexOf(l._selectionColumn),a=l._frozenFarColumns.indexOf(l._selectionColumn);if(t>=0&&l._frozenNearColumns.splice(t,1),a>=0&&l._frozenFarColumns.splice(a,1),"far"===o)l._selectionColumn.canNotify=!1,l._selectionColumn.freeze="far",l._selectionColumn.canNotify=!0,l._frozenFarColumns.splice(0,0,l._selectionColumn),l.viewColumns.push(l._selectionColumn),l.$.columnFarContainer.appendChild(l._selectionColumn.element);else{let e=0,t=0;for(let o=0;o<l.viewColumns.length&&(l.viewColumns[o].autoGenerated||l.viewColumns[o].dataField!==l.columns[t++].dataField);o++)l.viewColumns[o].autoGenerated&&e++;l._selectionColumn.canNotify=!1,l._selectionColumn.freeze="near",l._selectionColumn.canNotify=!0,l._frozenNearColumns.splice(e,0,l._selectionColumn),l.viewColumns.splice(e,0,l._selectionColumn),l.$.columnNearContainer.appendChild(l._selectionColumn.element)}l.viewColumns.canNotify=!0;break}case"selection_mode":if(l._selection&&(l._selection.focusedCell=null),l.selection.allowCellSelection)l.clearSelection();else if("one"===o){const e=l.getSelection();if(l.clearSelection(),e.rows&&e.rows[0]){e.rows[0].row.selected=!0;const t=l.rowById[e.rows[0].row.id].getCell(l.columns[0].dataField);l._selection.focusedCell={id:t.row.id,dataField:t.column.dataField,value:t.value,index:t.row.index}}}break;case"grouping_groupBy":return l.dataSource&&l.dataSource.groupBy&&(l.dataSource.groupBy=o),void l.refresh();case"sorting_enabled":return void l.refresh();case"sorting_maintainSort":return void l._recycle(!1);case"filtering_enabled":return o&&0===l._filterPanels.length&&l._createFilterPanels(),void(l.header.visible&&l.refresh());case"filtering_filterRow_visible":return l._initializeRows(),l._initializeRowElements(),void l.refresh();case"filtering_operator":return void l.refreshFilters();case"filtering_filter":for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.canNotify=!1,t.setProperty("filter",null),t.canNotify=!0}for(let e=0;e<l.filtering.filter.length;e++){const t=l.filtering.filter[e];if(t&&t.splice){const e=t[0],o=t.splice(1);let a=null;if(o instanceof Smart.FilterGroup)a=o;else{const t=l.columnByDataField[e];t&&(a=l.dataSource._createFilter(t.dataType,o))}a&&l.addFilter(e,a,!1)}}return void l.refreshFilters();case"messages":case"locale":{if(l.columns)for(let e=0;e<l.columns.length;e++)l.columns[e]._cellsCachedValues=[];l._dialogEdit&&(l._dialogEdit.close(),l._dialogEdit=null),l._dialogDelete&&(l._dialogDelete.close(),l._dialogDelete=null),l._dialogAddRow&&(l._dialogAddRow.close(),l._dialogAddRow=null);const e=l.$.headerPager.querySelector("smart-pager"),t=l.$.footerPager.querySelector("smart-pager");e&&(e.locale=l.locale),t&&(t.locale=l.locale);const o=(e,t)=>{l._handleFilterMenuClick(e,t)};l._filterInfo||(l._filterInfo={}),l._filterInfo.stringConditions=[{icon:"smart-icon-contains",command:o,value:"CONTAINS",label:l.localize("CONTAINS")},{icon:"smart-icon-does-not-contain",command:o,value:"DOES_NOT_CONTAIN",label:l.localize("DOES_NOT_CONTAIN")},{icon:"smart-icon-starts-with",command:o,value:"STARTS_WITH",label:l.localize("STARTS_WITH")},{icon:"smart-icon-ends-with",command:o,value:"ENDS_WITH",label:l.localize("ENDS_WITH")},{icon:"smart-icon-equals",command:o,value:"EQUAL",label:l.localize("EQUAL")},{icon:"smart-icon-delete",command:o,value:"CLEAR_FILTER",label:l.localize("CLEAR_FILTER")}],l._filterInfo.numberAndDateConditions=[{icon:"smart-icon-equals",command:o,value:"EQUAL",label:l.localize("EQUAL")},{icon:"smart-icon-not-equal",command:o,value:"NOT_EQUAL",label:l.localize("NOT_EQUAL")},{icon:"smart-icon-less-than",command:o,value:"LESS_THAN",label:l.localize("LESS_THAN")},{icon:"smart-icon-less-than-equal",command:o,value:"LESS_THAN_OR_EQUAL",label:l.localize("LESS_THAN_OR_EQUAL")},{icon:"smart-icon-greater-than",command:o,value:"GREATER_THAN",label:l.localize("GREATER_THAN")},{icon:"smart-icon-greater-than-equal",command:o,value:"GREATER_THAN_OR_EQUAL",label:l.localize("GREATER_THAN_OR_EQUAL")},{icon:"smart-icon-between",command:o,value:"RANGE",label:l.localize("RANGE")},{icon:"smart-icon-delete",command:o,value:"CLEAR_FILTER",label:l.localize("CLEAR_FILTER")}],l._refreshHeaderBar(),l.$.headerBar&&(l.$.headerBar.messages=l.messages,l.$.headerBar.locale=l.locale,l.$.headerBar._localizeHeader(),l.$.headerBar._getInnerElementMessages()),l.grouping.groupBar.visible&&l._renderGroupBar(),l._recycle();break}case"paging_spinner_enabled":l._refresh();break;case"pager_visible":return l._renderPagers(),void l._refreshPaging(!1);case"paging_pageIndex":case"pager_position":case"paging_enabled":return void l._refreshPaging(!0);case"paging_pageSize":return void l._refreshPaging(!1);case"columns":{l.__measuredColumnHeight=null,l.editing&&l.editing.isEditing&&l.cancelEdit(),l._cellEditors=[];let e=!1;if(t&&t.length)for(let o=0;o<t.length;o++)if(t[o].freeze){e=!0;break}if(l.columns&&l.columns.length)for(let t=0;t<l.columns.length;t++)if(l.columns[t].freeze){e=!0;break}if(e&&l._initializeRowElements(),l.columns&&l._sortedColumns){const e=[];l.columns.forEach((t=>{t.sortOrder&&e.push(t)})),l._sortedColumns=JSON.parse(JSON.stringify(e))}l._renderColumns(),l._refreshHeaderBar();const o=l._sortedColumns;if(o){l.clearSort();for(let e=0;e<l.columns.length;e++)delete l.columns[e]._cellsCachedValues;l._refreshSort(o)}if(l.columns&&l.filtering.enabled){l.beginUpdate();for(let e=0;e<l.columns.length;e++){const t=l.columns[e];if(t.canNotify=!1,l.removeFilter(t.dataField),t.filtered=!1,t.canNotify=!0,t.filter){let e=null,o=t.filter;e=o instanceof Smart.FilterGroup?o:l.dataSource._createFilter(t.dataType||"string",o),e&&l.addFilter(t.dataField,e,!1)}}l.refreshFilters(),l.endUpdate()}return l.layout.isDirty=!0,l._resetCachedLayout(),void l._refreshLayout()}case"columnGroups":if(l._columnGroups=[],l._columnHeights=0,l.viewColumns)for(let e=0;e<l.viewColumns.length;e++){const t=l.viewColumns[e],o=t.element;t.top=0,t.level=0,o&&(o.style.top="",o.style.height="",o.style.lineHeight="")}return l.columns.canNotify=!1,l.columns=l._initColumns,l._renderColumns(),l.columns.canNotify=!0,l.__columnHeaderHeight=null,void l.refresh();case"dataSource":if(delete l._isFirstVirtualDataSourceRequest,"dataSource"===e&&t&&o){const e=l.dataSource&&l.dataSource.virtualDataSource&&!l.dataSource.virtualDataSourceOnExpand&&"infinite"!==l.scrolling;if(t instanceof Smart.DataAdapter&&!e&&t.length===o.length&&t.length>0&&o.length>0&&!l.dataSourceSettings.childrenDataField&&!l.dataSourceSettings.parentDataField&&!t.parentDataField){if(l.dataSource=t,l._cachedDataSource===o)return;return setTimeout((()=>{let e=null;if(t&&l.dataSource&&l.dataSource._expandedRowIds){let t={};for(let e in l.dataSource._expandedRowIds){let o=""+e;o=o.replace("Item","").replace(/_/gi,"."),t[o]=!0}e=t}if(l.beginUpdate(),l._sortedColumns&&l._sortedColumns.length>0&&void 0===l._getId())for(let e=0;e<o.length;e++){const t=l.dataSource[e],a=o[e];l._updateRow(t,a,!0)}else for(let e=0;e<o.length;e++){const t=o[e],a=l.dataSource[e].$.id;l._updateRow(a,t,!0)}delete l.__autoRowHeight,l._virtualOnExpandCache=[],l._cellsMerge=[],l._cellStyles=[];const a=l._filters,n=l._sortedColumns;if(l.clearSort(),l.filtering.filterRow)for(let e=0;e<l.columns.length;e++)l.columns[e]._filterEditorInitialized=!1;for(let e=0;e<l.columns.length;e++)delete l.columns[e]._cellsCachedValues;if(n&&l._refreshSort(n),a&&a.length>0&&(l._filters=null,l.refreshFilters()),l.grouping.enabled)for(let t in e)l._expandCollapseGroup(t,!0);l.endUpdate()})),l._cachedDataSource=o,void(l.header.visible&&""===l.header.template&&l.$.headerBar._init(l))}}return l.dataSource.length>1e4?(l.appearance.displayLoadingIndicator=!0,l._setLoadingIndicatorVisibility(),setTimeout((()=>{l.dataBind()}),100),setTimeout((()=>{l.appearance.displayLoadingIndicator=!1,l._setLoadingIndicatorVisibility(),l._recycle(!1)}),200)):l.dataBind(),void(l.header.visible&&""===l.header.template&&l.$.headerBar._init(l));case"rowDetail_dialog_width":case"rowDetail_dialog_height":case"rowDetail_dialog_enabled":case"rowDetail_dialog_visible":return;case"rowDetail_height":case"rowDetail_enabled":{l.beginUpdate(),l.rows.canNotify=!1;const e=l.appearance.allowRowDetailToggleAnimation;l.appearance.allowRowDetailToggleAnimation=!1;for(let e=0;e<l._recyclingRows.length;e++){const t=l._recyclingRows[e];t.height=null,t.setProperty("showDetail",!1),t.detailHeight=l.rowDetail.height}if(l.rows.canNotify=!0,l.rowDetail.enabled){let t=!1;for(let e=0;e<l.viewColumns.length;e++)if(l.viewColumns[e].rowDetailColumn){t=!0;break}if(!t)return l.appearance.allowRowDetailToggleAnimation=e,l.endUpdate(),void l._renderColumns(!0)}else for(let e=0;e<l.viewColumns.length;e++){const t=l.viewColumns[e];if(t.rowDetailColumn){t.visible=!1;break}}return l.appearance.allowRowDetailToggleAnimation=e,void l.endUpdate()}case"rowDetail_visible":for(let e=0;e<l.viewColumns.length;e++){const t=l.viewColumns[e];if(t.rowDetailColumn){t.visible=o;break}}return;case"displayLoadingIndicator":return void l._setLoadingIndicatorVisibility();case"filterable":return void l._refreshLayout();case"layout_allowCellsWrap":{const e=l.columns.canNotify;l.columns.canNotify=!1;for(let e=0;e<l.columns.length;e++)l.columns[e].cellsWrap=o;return l.layout.isDirty=!0,l._resetCachedLayout(),l._refreshLayout(),l.refresh(),void(l.columns.canNotify=e)}case"showViewBar":return l.layout.isDirty=!0,l._resetCachedLayout(),l._refreshLayout(),void l.refresh();case"layout_autoHeight":case"layout_autoWidth":case"layout_columnMinHeight":case"layout_rowMinHeight":case"layout_columnHeight":case"layout_rowHeight":return l.layout.isDirty=!0,l._resetCachedLayout(),l._refreshLayout(),void l.refresh();case"rightToLeft":return void l.refresh();case"selectionMode":return;case"editing_addNewColumn_visible":l._addNewColumn?(l._addNewColumn.visible=o,l.refresh()):l._renderColumns();break;case"editing_addNewRow_displayMode":{"row"===l.editing.addNewRow.displayMode&&l.editing.addNewRow._addButton&&(l.editing.addNewRow._addButton.remove(),delete l.editing.addNewRow._addButton);const e=l._scrollView.vScrollBar;return e.style.height="",e.style.top="",e.style.setProperty("--smart-scroll-bar-near-size","0px"),l._renderAddNewRow(),void l.refresh(!0)}case"editing_addNewRow_label":case"editing_addNewRow_visible":case"editing_addNewRow_position":return!1===l.editing.addNewRow.visible&&"button"===l.editing.addNewRow.displayMode&&(l.editing.addNewRow._addButton&&l.editing.addNewRow._addButton.remove(),l._newRow&&l._newRow.element.classList.add("smart-hidden")),l._renderAddNewRow(),void l.refresh();case"editing_enabled":o?l.removeAttribute("aria-readonly"):l.setAttribute("aria-readonly",!0);break;case"editing_dialog_visible":return;case"editing_commandBar_dataSource_commandBarAddRow_visible":case"editing_commandBar_dataSource_commandBarDeleteRow_visible":case"editing_commandBar_dataSource_commandBarBatchSave_visible":case"editing_commandBar_dataSource_commandBarBatchRevert_visible":case"editing_commandBar_visible":case"editing_commandBar_displayMode":case"editing_commandBar_position":l._renderCommandBar();break;case"editing_commandColumn_position":l._renderColumns(!0);break;case"editing_commandColumn_visible":return void l.refresh(!0);case"editing_commandColumn_inline":return l._commandColumn.visible=l.editing.commandColumn.visible&&!l.editing.commandColumn.inline,void l.refresh(!0);case"editing_commandColumn_dataSource_commandColumnCustom_label":case"editing_commandColumn_dataSource_commandColumnCustom_icon":case"editing_commandColumn_dataSource_commandColumnCustom_visible":case"editing_commandColumn_dataSource_commandColumnUpdate_label":case"editing_commandColumn_dataSource_commandColumnUpdate_icon":case"editing_commandColumn_dataSource_commandColumnUpdate_visible":case"editing_commandColumn_dataSource_commandColumnEdit_label":case"editing_commandColumn_dataSource_commandColumnEdit_icon":case"editing_commandColumn_dataSource_commandColumnEdit_visible":case"editing_commandColumn_dataSource_commandColumnDelete_label":case"editing_commandColumn_dataSource_commandColumnDelete_icon":case"editing_commandColumn_dataSource_commandColumnDelete_visible":case"editing_commandColumn_displayMode":return delete l.__cellsCommandTemplate,void l.refresh(!0)}l.refresh()}}ready(){super.ready();const e=this,t=e._scrollView.vScrollBar,o=e._scrollView.hScrollBar;t.hasStyleObserver=!1,o.hasStyleObserver=!1,t.hasResizeObserver=!1,o.hasResizeObserver=!1,t.wait=!1,o.wait=!1,t.onChange=e._verticalScrollbarHandler.bind(e),o.onChange=e._horizontalScrollbarHandler.bind(e),e.setFocusable(!0),e.$.loadingIndicatorPlaceholder.innerHTML=e.appearance.loadingIndicatorPlaceholder,e.$.placeholder.innerHTML=e.appearance.placeholder,e._setLoadingIndicatorVisibility(),e._cellsMerge=[],e._cellStyles=[],e.checkLicense()}_createFilterPanels(){const e=this;if(e._filterPanels){if(e._filterPanels.length>0)return}else e._filterPanels=[];e.filtering.enabled&&0===e._filterPanels.length&&requestAnimationFrame((()=>{const t=document.createElement("smart-filter-panel"),o=document.createElement("smart-filter-panel"),l=document.createElement("smart-filter-panel"),a=document.createElement("smart-filter-panel");o.filterType="boolean",l.filterType="numeric",a.filterType="date",e._filterPanels.bool=o,e._filterPanels.date=a,e._filterPanels.numeric=l,e._filterPanels.string=t;for(let t in e._filterPanels){const o=e._filterPanels[t];o.rightToLeft=e.rightToLeft,o.classList.add("smart-hidden"),e.$.content.appendChild(o),o.parentNode.removeChild(o)}}))}_applyScrolling(){const e=this,t=e._scrollView.vScrollBar;requestAnimationFrame((()=>{switch(t.largeStep=e.$.scrollView.offsetHeight,e.scrolling){case"physical":case"infinite":case"virtual":t.step=e.layout.rowMinHeight,t.mechanicalAction="switchWhileDragging";break;case"deferred":t.step=10,t.mechanicalAction="switchWhenReleased";break;case"logical":t.step=e.layout.rowMinHeight,t.mechanicalAction="switchWhileDragging"}}))}_measureRowElement(e){const t=new Smart.Grid.Row({data:e,index:999999,grid:this});if(!t)return null;const o=t.createElement();return o.classList.add("smart-grid-measure-row"),this.$.scrollView.appendChild(o),o.style.height="",o.style.lineHeight="",o.style.height="",o.style.lineHeight="",t._isMeasureRow=!0,t.render(),o}get _autoRowHeight(){const e=this;if(e.__autoRowHeight)return e.__autoRowHeight;let t=e.layout.rowMinHeight;if(!e.dataSource||e.dataSource&&0===e.dataSource.length)return t;const o=new Smart.Grid.Row({index:0,grid:e}),l=o.createElement();e.$.scrollView.appendChild(l),e.removeAttribute("grouped"),e.removeAttribute("tree"),e.grouping.enabled&&e.dataSource.groupBy&&e.dataSource.groupBy.length>0?e.setAttribute("grouped",""):e.dataSource.boundHierarchy&&e.setAttribute("tree","");const a={};for(let t=0;t<e.dataSource.dataFields.length;t++)a[e.dataSource.dataFields[t].name]="ABCDEFHIJLMNOPQRSTUVWXYZ1234567910|";o.data=a,o._isMeasureRow=!0,o.render(),l.style.height="",l.style.lineHeight="",t=Math.max(l.offsetHeight,t);for(let e=0;e<l.children.length;e++)l.children[e].style.height="";for(let a=0;a<l.children[1].children.length;a++){if(l.children[1].children[a].style.height="auto",e.columns[0]){const t=o.getCell(e.columns[0].dataField);t&&t.render()}t=Math.max(t,8+l.children[1].children[a].offsetHeight);break}return e.$.scrollView.removeChild(l),e.__autoRowHeight=t,e.layout.rowMinHeight&&t<e.layout.rowMinHeight&&(e.__autoRowHeight=e.layout.rowMinHeight),t}get _scrollHeight(){const e=this,t="card"===e.view;let o=e._recyclingRows,l=0,a=e._autoRowHeight,n=0,i=0;if(e.__scrollHeight)return e.__scrollHeight;if(0===o.length||0===e.columns.length||!e.hasVisibleColumn())return 0;let r=35,s=1,d=0;if(t){for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.visible&&!o.autoGenerated&&(e.layout.cardCompact?t%2==0&&(r+=e.layout.rowMinHeight+5):r+=e.layout.rowMinHeight+5,d++,o.cardHeight&&(r+=o.cardHeight*e.layout.rowMinHeight))}let t=e.offsetWidth;e.appearance.showViewBar&&(t-=e.layout.viewBarWidth+5),s=t<e.layout.cardMinWidth?1:"auto"===e.layout.cardsPerRow?Math.floor(t/e.layout.cardMinWidth):e.layout.cardsPerRow,1===s&&(r+=5*d),e._cardHeight=r}e._cardsPerRow=s,e.rows.canNotify=!1;const u=e._measureRowElement(o[0].data),c=o.length;for(let s=0;s<c;s++){let d=o[s];if(!d.visible||!1===d.filtered){d.height=0,d.cellHeight=0,d.top=l;continue}const c=e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled;let m=!d.height||!d.cellHeight||c||"auto"===d.height||"auto"===d._height||"auto"===e.layout.rowHeight||e.layout.isDirty;if(t&&d.height!==r&&(d.height=d.cellHeight=r),m&&!d.expandHeight){if(d.detailHeight||(d.detailHeight=200),t)d.height=d.cellHeight=r;else if(e.layout.rowHeight){if(e.layout.rowHeight)if("number"==typeof e.layout.rowHeight)e.layout.rowHeight<e.layout.rowMinHeight&&(e.layout.rowHeight=e.layout.rowMinHeight),d.height=e.layout.rowHeight,d.computedHeight&&(d.height=d.computedHeight),d.minHeight>d.height&&(d.height=d.minHeight),void 0!==d.label&&"advanced"===e.grouping.renderMode&&(d.height=e.grouping.groupRowHeight),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight);else if("auto"===e.layout.rowHeight){e.layout.rowHeight<e.layout.rowMinHeight&&(e.layout.rowHeight=e.layout.rowMinHeight),d.element=u,d.grid=e,d.element&&d.element.classList.contains("smart-hidden")&&d.element.classList.remove("smart-hidden");const t=d.data&&e.isRendered?d._autoSize(d):a,o=d.canNotify;d.canNotify=!1,d.height=t,d.computedHeight&&(d.height=d.computedHeight),void 0!==d.label&&"advanced"===e.grouping.renderMode&&(d.height=e.grouping.groupRowHeight),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight),d.canNotify=o}else e.layout.rowHeight(s,d),d.height||(d.height=a),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight)}else{if("auto"===d.height||"auto"===d._height){d.element=u,d.element&&d.element.classList.contains("smart-hidden")&&d.element.classList.remove("smart-hidden");const t=d.data&&e.isRendered?d._autoSize(d):a;d.height=t,d._height="auto"}else d.height=a;void 0===d.label||d.summaryRow||"advanced"!==e.grouping.renderMode||(d.height=e.grouping.groupRowHeight),d.computedHeight&&(d.height=d.computedHeight),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight)}e._rowGap&&s<e.rows.length-1&&(d.height+=e._rowGap)}!t&&(!0===d.freeze||"near"===d.freeze?d.visible&&(n+=d.height):"far"===d.freeze&&d.visible&&(i+=d.height),d.freeze&&d.visible)?d.top=l:(d.top!==l&&(d.top=l),d.expandHeight?l+=d.cellHeight:l+=d.height)}if(e._summaryRowCount&&e.summaryRow.visible&&(l+=1*a),e.editing.addNewRow&&"button"===e.editing.addNewRow.displayMode&&(l+=1*a),e.filtering&&e.filtering.filterRow.visible&&(n+=a),e.editing.addNewRow&&"button"!==e.editing.addNewRow.displayMode&&e.rowHierarchy&&e.editing.addNewRow.visible&&(l+=a,"far"!==e.editing.addNewRow.position&&(n+=a)),e.dataSource&&e.dataSource.virtualDataSource&&!1===e.paging.enabled){let t=e.dataSource.length>e.virtualModeCachedRowsCount?e.virtualModeCachedRowsCount:e.dataSource.length;"infinite"===e.scrolling&&(t=e.dataSource.length),"virtual"===e.scrolling&&t>=e.virtualModeCachedRowsCount&&(l=e.rows[0]?e.rows[0].height*e.dataSource.length:e.layout.rowMinHeight*e.dataSource.length)}return t&&(l=r*Math.ceil(o.length/s)),e.__scrollHeight=l,e.__frozenNearHeight=n,e.__frozenFarHeight=i,e._scrollView.scrollHeight=l-e.$.scrollView.offsetHeight+n+i,l=e.__scrollHeight+n+i-1,e.grouping.enabled&&e.dataSource.groupBy.length>0&&e.grouping.groupIndent>0&&"advanced"===e.grouping.renderMode&&(l+=parseInt(e.grouping.groupIndent/2)),e.__scrollHeight=l,u.remove(),o[0]&&delete o[0]._isMeasureRow,e.rows.canNotify=!0,l}_measureColumnHeight(){const e=this;if(e.__measuredColumnHeight)return e.__measuredColumnHeight;const t=document.createElement("smart-grid-column");t.style.height="auto",t.style.position="static";const o=document.createElement("div");o.classList.add("smart-label"),o.innerHTML="aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRwWxXyYzZ1234567890",t.appendChild(o),e.$.columnHeader.appendChild(t);let l=e.$.columnHeader.offsetHeight;return e.$.columnHeader.removeChild(t),e._columnHeights&&e._columnHeights.length>1&&(l=e._columnHeights[0]),l<e.layout.columnMinHeight&&(l=e.layout.columnMinHeight),e.__measuredColumnHeight=l,l}_initializeColumnGroupsHierarchy(){const e=this;let t=0;e.$.columnContainer.innerHTML="";const o=JSON.parse(JSON.stringify(e.columnGroups));if(o.length>0){for(let t=0;t<o.length;t++)o[t].parent=null,o[t].groups=null,o[t].labelTemplate=e.columnGroups[t].labelTemplate;for(let t=0;t<e.viewColumns.length;t++)e.viewColumns[t].parent=null,e.viewColumns[t].groups=null;const l=function(e){for(let t=0;t<o.length;t++){let l=o[t];if(l.name===e)return l}return null},a=function(e){let t=new Array;if(e.columnGroup&&t.push(e),e.groups)for(let o=0;o<e.groups.length;o++)if(e.groups[o].columnGroup)t.push(e.groups[o]);else if(e.groups[o].groups){let l=a(e.groups[o]);for(let e=0;e<l.length;e++)t.push(l[e])}return t};for(let e=0;e<o.length;e++){let t=o[e];if(t.groups||(t.groups=null),t.parentGroup){let e=l(t.parentGroup);e&&(t.parent=e,e.groups||(e.groups=new Array),-1===e.groups.indexOf(t)&&e.groups.push(t))}}for(let t=0;t<e.viewColumns.length;t++){let o=e.viewColumns[t];if(o.columnGroup){let e=l(o.columnGroup);e&&(e.groups||(e.groups=new Array),o.parent=e,-1===e.groups.indexOf(o)&&e.groups.push(o))}}for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];let a=l;for(l.level=0;a.parent;)a=a.parent,l.level++;a=l;let n=l.level;for(t=Math.max(t,l.level);a.parent;)a=a.parent,a&&(a.level=--n)}for(let t=0;t<o.length;t++){const l=o[t],n=a(l);l.columns=n;let i=new Array,r=0,s="near";0===n.length&&(r=-1,l.visible=!1);for(let t=0;t<n.length;t++)i.push(e.viewColumns.indexOf(n[t])),n[t].freeze&&("far"===n[t].freeze&&(s="far"),r++);r===n.length?l.freeze=s:r>0&&r<n.length&&(e.classList.add("smart-visibility-hidden"),e.error(e.localize("frozenColumns",{elementType:"Grid"}))),i.sort((function(e,t){return(e=parseInt(e))<(t=parseInt(t))?-1:e>t?1:0}));for(let t=1;t<i.length;t++)i[t]!==i[t-1]+1&&(e.classList.add("smart-visibility-hidden"),e.error(e.localize("columnGroups",{elementType:"Grid"})))}}e._columnGroupsLevel=1+t,e._columnGroups=o}_refreshColumnHeights(){const e=this;if("card"===e.view)return;e.$.columnHeader.style.height="",e._viewColumnsHeight=e._measureColumnHeight(),e._columnHeights=[];let t=0;for(let o=0;o<e._columnGroupsLevel;o++){let l=e._viewColumnsHeight;e.layout.columnHeight&&(l="number"==typeof e.layout.columnHeight?e.layout.columnHeight?e.layout.columnHeight:e._viewColumnsHeight:e.layout.columnHeight?e.columnHeight(o):e._viewColumnsHeight),l<e.layout.columnMinHeight&&(l=e.layout.columnMinHeight),l?(e._columnHeights.push(l),t+=l):(t+=e._viewColumnsHeight,e._columnHeights.push(e._viewColumnsHeight))}e._columnHeaderHeight=e._columnGroupsLevel*e._viewColumnsHeight,e._columnHeaderHeight=t,e.$.columnHeader.style.height=e._columnHeaderHeight+"px";const o=function(t){let o=0;for(let l=0;l<t.level;l++)o+=e._columnHeights[l];return o},l=function(t){let l=o(t),a=e._columnHeaderHeight-l;for(let o=t.level+1;o<e._columnHeights.length;o++){const l=o;for(let o=0;o<e.viewColumns.length;o++){const n=e.viewColumns[o];let i=!1;if(n.level===l){let o=n;for(;o.parent;){if(o.parent===t){a=e._columnHeights[l],i=!0;break}o=o.parent}if(i)break}}}return a};for(let t=0;t<e.viewColumns.length;t++){const a=e.viewColumns[t],n=l(a);a.computedHeight=n,a.top=o(a)}for(let t=0;t<e._columnGroupsLevel-1;t++)for(let a=0;a<e._columnGroups.length;a++){const n=e._columnGroups[a];if(n.level!==t)continue;if(n.groups){const e=l(n),t=o(n);n.top=t,n.computedHeight=e}const i=n.element;i&&(i.style.width=n.computedWidth+"px",e.rightToLeft?i.style.right=n.left+"px":i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=n.computedHeight+"px",i.style.lineHeight=n.computedHeight+"px")}}_refreshColumnWidths(){const e=this;e.__clientSize=null;const t=e.$.verticalScrollBar.offsetWidth>0?e.$.verticalScrollBar.offsetWidth:0,o=e.dataSource.groupBy||[];let l=e.grouping.enabled&&"advanced"===e.grouping.renderMode?e.grouping.groupIndent*(1+o.length):0,a=0;e.selection.checkBoxes.enabled&&(a=e._selectionColumn.computedWidth?e._selectionColumn.computedWidth:e._selectionColumn.minWidth);const n=e._clientSize.width-t-l;let i=0,r=[],s=0,d=0,u=0;if(e.editing.enabled&&!e.editing.commandColumn.inline){const t=function(){const t=document.createElement("div"),o=document.createElement("div"),l=e.editing.commandColumn.dataSource;let a=0,n="",i=0;o.classList.add("smart-label");for(let t in l){const o=l[t];let a=!1;if("commandColumnMenu"===t)continue;let r=!1;a||(!0===o.visible?(i++,r=!0):"auto"===o.visible&&((e.editing.editRow||e.editing.editCell)&&!e.editing.dialog.enabled||"commandColumnEdit"!==t?!e.editing.editRow&&!e.editing.editCell||e.editing.dialog.enabled||("commandColumnUpdate"===t||"commandColumnCancel"===t)&&(i++,r=!0):(i++,r=!0)),a=!0),r&&"icon"!==e.editing.commandColumn.displayMode&&(n+="<span>"+("{{messages}}"===o.label?e.localize(t):o.label)+"</span>")}return o.innerHTML="<span>"+n+"</span>",t.appendChild(o),t.style.width="auto",t.style.position="static",e.$.columnHeader.appendChild(t),a=10+o.firstChild.offsetWidth,e.$.columnHeader.removeChild(t),"icon"===e.editing.commandColumn.displayMode?a=20+20*i:"labelAndIcon"===e.editing.commandColumn.displayMode?a+=25*i:a+=10*i,a};if(e._commandColumn.visible=e.editing.commandColumn.visible,e.editing.commandColumn.visible){const o=e.editing.commandColumn.width?e.editing.commandColumn.width:t();e.columns.canNotify=!1,e._commandColumn.width=o,e.columns.canNotify=!0}}for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];let l;"number"==typeof o.width?l=o.width:o.width&&o.width.toString().indexOf("%")>=0?(l=parseFloat(o.width)/100,l*=n-a):o.width&&(o.width.toString().indexOf("em")>=0||o.width.toString().indexOf("pt")>=0||o.width.toString().indexOf("fr")>=0)?(l=parseFloat(o.width),l*=16):"auto"===o.width?l=o._autoSize():o.visible&&(r.push(o),l=0),o.overflowWidth&&(l-=o.overflowWidth),o.visible&&(i+=l),l<o.minWidth&&(l=o.minWidth),o.computedWidth=l}if(r){let e=n-i,t=0;e<0&&(e=60*r.length);for(let o=0;o<r.length;o++){const l=r[o];let a;a=e/r.length,o===r.length-1&&(a=e-t),l.overflowWidth&&(a-=l.overflowWidth),a<l.minWidth&&(a=l.minWidth),l.computedWidth=a,t+=a}}for(let t=0;t<e.viewColumns.length;t++){let o=e.viewColumns[t];o.visible&&(l>0&&!o.autoGenerated&&(o.computedWidth+=l,l=0),o.freeze?!0===o.freeze||"near"===o.freeze?(o.left=s,u+=o.computedWidth,s+=o.computedWidth):"far"===o.freeze&&(o.left=d,d+=o.computedWidth):(o.left=u,u+=o.computedWidth))}for(let t=0;t<e._columnGroupsLevel-1;t++)for(let o=0;o<e._columnGroups.length;o++){const l=e._columnGroups[o];if(l.level!==t)continue;let a=99999;if(l.groups){const e=function(t){let o=0;for(let l=0;l<t.groups.length;l++){let n=t.groups[l];n.groups?o+=e(n):n.visible&&(a=Math.min(n.left,a),o+=n.computedWidth)}return o};l.computedWidth=e(l),l.left=a}}}_createColumnHeaderCellElements(){const e=this,t=e.$.columnContainer,o=document.createDocumentFragment();let l=0;e._columnElements=[],e.$.columnContainer.innerHTML="",e.$.columnNearContainer.innerHTML="",e.$.columnFarContainer.innerHTML="",e.rightToLeft?(e.$.columnNearContainer.classList.remove("near"),e.$.columnNearContainer.classList.add("far"),e.$.columnFarContainer.classList.remove("far"),e.$.columnFarContainer.classList.add("near")):(e.$.columnNearContainer.classList.remove("far"),e.$.columnNearContainer.classList.add("near"),e.$.columnFarContainer.classList.remove("near"),e.$.columnFarContainer.classList.add("far"));for(let t=0;t<e._frozenNearColumns.length;t++)e._frozenNearColumns[t].createElement();for(let t=0;t<e._frozenFarColumns.length;t++)e._frozenFarColumns[t].createElement();for(let t=0;t<e.viewColumns.length;t++){const a=e.viewColumns[t];if(a.freeze)continue;const n=a.createElement();void 0!==a.computedWidth?(a.parent&&n.setAttribute("column-group",a.parent.name),a.parent&&a.parent.columns&&a.parent.columns[0].dataField===a.dataField&&n.setAttribute("column-group-first-child",""),l+=a.computedWidth,e._columnElements.push(n),l<2*e._clientSize.width&&o.appendChild(n)):(e._columnElements.push(n),o.appendChild(n))}for(let t=0;t<e._columnGroups.length;t++){const l=e._columnGroups[t],a=new Smart.Grid.Column({visible:void 0===l.visible||l.visible,allowSort:!1,allowFilter:!1,allowSelect:!1,grid:e,dataField:l.name,label:l.label,labelTemplate:l.labelTemplate,align:l.align,verticalAlign:l.verticalAlign,showIcon:!1});l.column=a;const n=a.createElement();n.style.width=l.computedWidth+"px",e.rightToLeft?n.style.right=l.right+"px":n.style.left=l.left+"px",n.style.top=l.top+"px",n.style.height=l.computedHeight+"px",n.style.lineHeight=l.computedHeight+"px",o.appendChild(n),l.element=n,l.grid=this,n.onpointerdown=()=>{if(e.selection.allowColumnHeaderSelection){const t=function(e){let o=new Array;if(e.columnGroup&&o.push(e),e.groups)for(let l=0;l<e.groups.length;l++)if(e.groups[l].columnGroup)o.push(e.groups[l]);else if(e.groups[l].groups){let a=t(e.groups[l]);for(let e=0;e<a.length;e++)o.push(a[e])}return o},o=t(l);e._selectColumnsRange(o[0].dataField,o[o.length-1].dataField)}}}e.htmlColumnLastChild||(e.htmlColumnLastChild=document.createElement("smart-grid-column"),e.htmlColumnLastChild.classList.add("top-far-corner"),e.htmlColumnLastChild.onpointerdown=e=>{e.stopPropagation(),e.preventDefault()},e.$.columnHeader.appendChild(e.htmlColumnLastChild)),t.appendChild(o),t.style.width=e._computedColumnsWidth+"px",!1===e.appearance.showColumnGroupLines&&e.setAttribute("appearance_hide-column-group-lines",""),e._refreshFrozenColumns()}_refreshFrozenColumns(){const e=this;e.$.columnNearContainer.style.width=e._frozenColumnsNearWidth+"px",e.$.columnFarContainer.style.width=e._frozenColumnsFarWidth+"px";for(let t=0;t<e._columnGroups.length;t++){const o=e._columnGroups[t];o.freeze&&o.element&&(!0===o.freeze||"near"===o.freeze?e.$.columnNearContainer.appendChild(o.element):"far"===o.freeze&&e.$.columnFarContainer.appendChild(o.element))}for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.freeze&&o.element&&(!0===o.freeze||"near"===o.freeze?e.$.columnNearContainer.appendChild(o.element):"far"===o.freeze&&e.$.columnFarContainer.appendChild(o.element))}}get _clientSize(){const e=this;if(e.__clientSize)return e.__clientSize;const t=getComputedStyle(e.$.container),o=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),l=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),a=parseFloat(t.borderLeftWidth)+parseFloat(t.borderRightWidth),n=parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth);return e.__clientSize={width:e.$.container.offsetWidth-o-a,height:e.$.container.offsetHeight-l-n},e.__clientSize}_initializeRowElements(){const e=this;if(!e.rows)return;e.rows.canNotify=!1;let t=0,o=e._clientSize.height;e.$.rowNearContainer.innerHTML="",e.$.rowFarContainer.innerHTML="",e.$.rowContainer.innerHTML="",e._rowElements=[],e._overflowOffset=Math.max(o,300),e.rightToLeft?(e.$.rowNearContainer.classList.remove("near"),e.$.rowNearContainer.classList.add("far"),e.$.rowFarContainer.classList.remove("far"),e.$.rowFarContainer.classList.add("near")):(e.$.rowFarContainer.classList.remove("near"),e.$.rowFarContainer.classList.add("far"),e.$.rowNearContainer.classList.remove("far"),e.$.rowNearContainer.classList.add("near"));const l=e.offsetHeight;e.$.container.classList.add("smart-hidden");const a=e.offsetHeight;e.$.container.classList.remove("smart-hidden"),"hidden"!==e.verticalScrollBarVisibility&&l===a||(o=e._scrollHeight);const n=function(){const l=document.createDocumentFragment();if(e.rows&&0===e.rows.length)return;for(let a=0;a<e.rows.length;a++){const n=e.rows[a];if(n.freeze&&n.visible)continue;const i=n.createElement();if(l.appendChild(i),t+=e.layout.rowMinHeight,t>e._overflowOffset+o)break}e.$.rowContainer.appendChild(l);const a=e.$.rowContainer.children;for(let t=0;t<a.length;t++){const o=a[t];e.rows[t]&&(e.rows[t].element=o),e._rowElements[t]=o}};for(let t=0;t<e._frozenNearRows.length;t++){const o=e._frozenNearRows[t];o.grid=e;const l=o.createElement();o.element=l,e.$.rowNearContainer.appendChild(l)}for(let t=0;t<e._frozenFarRows.length;t++){const o=e._frozenFarRows[t];o.grid=e;const l=o.createElement();o.element=l,e.$.rowFarContainer.appendChild(l)}n();let i=0;for(;t<1.5*o&&++i<50;)n();e.rows.canNotify=!0}_refreshSummary(e){const t=this;t.summaryRow.visible&&(t._summaryUpdateTimer&&clearTimeout(t._summaryUpdateTimer),t._summaryUpdateTimer=setTimeout((()=>{!0!==t.editing.isEditing&&(t._calculateSummary(),!1!==e&&t._recycle(!1,!0,!1))}),100))}_initializeRows(){const e=this;let t=0;e._frozenNearDefaultRows=[],e._frozenFarDefaultRows=[],e.rows=[],e.rowById=[],e._frozenFarRows=[],e._frozenNearRows=[];let o=e._createdDate||new Date,l=void 0!==e._createdBy?e._createdBy:e.currentUser;const a=function(){let t=[],o=!1;for(let l=0;l<e.columns.length;l++){const a=e.columns[l];let n={};a.summary&&a.summary.length>0&&(o=!0,n[a.dataField]=a.summary,t.push(n))}if(!o)return void(e._summaryItems=[]);const l=e.getSelectedRowIds();if(l.length>=1){const o=[];for(let t=0;t<l.length;t++){const a=e.dataSource.dataItemById[l[t]];a&&o.push(a)}e._summaryItems=e.dataSource.summarize(t,o)}else if(e._selection&&e._selection.cells&&Object.keys(e._selection.cells).length>2){const o=e.getSelectedCells(!1),l=[],a=[];for(let t=0;t<o.length;t++){const n=o[t],i=n[0],r=e.dataSource.dataItemById[i];-1===l.indexOf(r)&&l.push(r),-1===a.indexOf(n[1])&&a.push(n[1])}e._summaryItems=e.dataSource.summarize(t,l);const n=Object.keys(e._summaryItems);for(let t=0;t<n.length;t++){const o=n[t];-1===a.indexOf(o)&&delete e._summaryItems[o]}}else e._summaryItems=e.dataSource.summarize(t)};e._calculateSummary=a;const n=e.columns?e.columns.filter((e=>void 0!==e.getCellValue)):[],i=function(a,i,r){let s=null;if(e.isInitialized&&(o=new Date),s=a?a.grid?a:new Smart.Grid.Row({data:a,index:i,grid:e,createdBy:l,createdDate:o}):new Smart.Grid.Row({data:{},index:i,grid:e,createdBy:l,createdDate:o}),n)for(let e=0;e<n.length;e++){const t=n[e],o=t.getCellValue(s.id,t.dataField,a);void 0!==o&&(s.data[t.dataField]=o)}if(e.rowById[s.id]&&(s.id=e.rows.length,e.rowById[s.id])){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};s.id=e()}if(e.onRowInit){e.onRowInit(i,s,e),30!==s.height&&(s.cellHeight=s.height);for(let t in s)-1!==s.properties.indexOf(t)||t.startsWith("_")||e.error(e.localize("invalidRowProperty",{elementType:"Grid",propertyName:t}))}if(s.selected&&(e._selection.rows[s.id]=!0,e._selection.indexes[s.index]=s.index),s.freeze&&s.visible){if(!0===s.freeze||"near"===s.freeze){e.rows.splice(t++,0,s);const o=e.rows[t-1];-1===e._frozenNearRows.indexOf(o)&&e._frozenNearRows.push(o)}else if("far"===s.freeze){e.rows.push(s);const t=e.rows[e.rows.length-1];-1===e._frozenFarRows.indexOf(t)&&e._frozenFarRows.push(t)}}else e.rows[i]?e.rows.splice(i,0,s):e.rows.push(s),s.data&&s.data.$&&(s.data.$.history=s.history,s.data.$.starred=s.starred,s.data.$.comments=s.comments,s.data.$.style=s.style);if(!("virtual"===e.scrolling||e.paging.enabled&&e.dataSource&&e.dataSource.virtualDataSource))if(e.onRowInserted){const t=void 0===i?e.rows[e.rows.length-1]:e.rows[i],o=o=>{const l=t;if(void 0!==o&&Array.isArray(o)&&(o=o[0]),void 0===o){if(e.rowById[l.id]){const t=e.dataSource.dataItemById[l.id],o=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};l.id=o(),l.data&&l.data.$?l.data.$.id=l.id:l.data.id=l.id,e._getId()&&(l.data[e._getId()]=l.id),t&&(e.dataSource.dataItemById[l.id]=l.data)}e.rowById[l.id]=l}else{const t=e.dataSource.dataItemById[l.id];l.id=o,l.data&&l.data.$?l.data.$.id=l.id:l.data.id=l.id;const a=e._getId();a&&(l.data[e._getId()]=l.id),t&&(t[a]=o,e.dataSource.dataItemById[l.id]=t,l.data=t),e.rowById[l.id]=l}-1!==l.index&&void 0!==l.index||(l.index=e.rows.length),e._setAddUndoRedo(l),!e.editing.isEditing&&e.isInitialized&&(e._recycle(!1,!0),e.grouping.groupBy.length&&e.refresh()),e._onRowInserted&&e._onRowInserted(l),r&&r(l)};if(void 0===i&&(i=e.rows.length-1,void 0!==t.index&&-1!==t.index||(t.index=i)),e.isInitialized){e._rowInsertTimer&&clearTimeout(e._rowInsertTimer),e._rowInsert||(e._rowInsert=[]),e._rowInsert.push({row:t,index:i});const l=e._keyboardAdd?300:150;e._rowInsertTimer=setTimeout((()=>{if(1===e._rowInsert.length)e.onRowInserted([i],[t],o,e),delete e._rowInsert,delete e._undoRedoAction;else{let t=[],o=[];for(let l=0;l<e._rowInsert.length;l++)t.push(e._rowInsert[l].index),o.push(e._rowInsert[l].row);delete e._rowInsert,e.onRowInserted(t,o,(t=>{e.beginUpdate();for(let l=0;l<o.length;l++){const a=o[l],n=t?t[l]:void 0;if(void 0!==n){const t=e.dataSource.dataItemById[a.id];a.id=a.data.id=n;const o=e._getId();o&&(a.data[e._getId()]=a.id),e.rowById[a.id]=a,t&&(t[o]=n,e.dataSource.dataItemById[a.id]=t,a.data=t)}e._setAddUndoRedo(a),-1!==a.index&&void 0!==a.index||(a.index=e.rows.length),e._onRowInserted&&e._onRowInserted(a),r&&r(a)}delete e._undoRedoAction,e.endUpdate(!1)}),e)}}),l)}else e.onRowInserted([i],[t],o,e)}else{const t=void 0===i?e.rows[e.rows.length-1]:e.rows[i];void 0===i&&(i=e.rows.length-1,void 0!==t.index&&-1!==t.index||(t.index=i)),r&&r(t)}},r=function(){const t=e.rows[e.rows.length-1];e.rows.pop(),e.onRowRemoved&&e.onRowRemoved([t.id],[t.index],e),e._onRowRemoved&&e._onRowRemoved([t.id],[t.index],e),e._setRemoveUndoRedo(t)},s=function(t){const o=e.rows[t];o.selected&&o.setProperty("selected",!1),e.rows.splice(t,1),e.onRowRemoved&&e.onRowRemoved([o.id],[t],e),e._onRowRemoved&&e._onRowRemoved([o.id],[t],e),e._setRemoveUndoRedo(o)};e._add=i,e._removeLastRow=r,e._removeAt=s,e._rowHeight=e._autoRowHeight;const d=e.dataSource.length,u=e.onRowInserted;e.onRowInserted=null,e.setAttribute("aria-rowcount",d);const c=e.dataSource&&e.dataSource.virtualDataSource&&!e.dataSource.virtualDataSourceOnExpand&&e.dataSource.length>e.virtualModeCachedRowsCount&&"infinite"!==e.scrolling;if(e.dataSource&&e.dataSource.virtualDataSource&&e.paging.enabled&&!e.dataSource.virtualDataSourceOnExpand)for(let t=0;t<e.dataSource.boundSource.length;t++){const o=e.dataSource[t],l=t+e.paging.pageIndex*e.paging.pageSize;e.dataSource.id||(o.$.id=l),i(o,l)}else if(c){let t=e.dataSource.length>e.virtualModeCachedRowsCount?e.virtualModeCachedRowsCount:e.dataSource.length;"infinite"===e.scrolling&&(t=e.dataSource.length);for(let o=0;o<t;o++){const t=e.dataSource[o];i(t,o)}}else for(let t=0;t<e.dataSource.length;t++){const o=e.dataSource[t];i(o,t)}for(let t=0;t<e._frozenFarRows.length;t++){const o=e._frozenFarRows[t];e.rows.splice(e.rows.indexOf(o),1),e.rows.push(o)}if(a(),e.onRowInserted=u,e.dataSource.notify((function(t){if(e.dataSource._updating)return;const o=t.data;e.rows.canNotify=!1;let l=!1;switch(t.action){case"add":if(!o)return;if(void 0!==o.length)for(let t=0;t<o.length;t++)i(o[t],e.dataSource.length-o.length+t);else i(o,e.dataSource.length-1);break;case"update":if(o.length){let o=[],a=[],n=[];for(let r=0;r<n.length;r++){const s=t.index[r];e.rows[s]?(e.rows[s].data=n[r],o.push(s),a.push(e.rows[s]),n.push(e.rows[s].data)):(i(n[r],n[r].$.index),l=!0)}e.onRowUpdated&&e.onRowUpdated(o,a,n,e)}else{const l=t.index;e.rows[l]?e.rows[l].data=o:i(o,e.dataSource.length-1),e.onRowUpdated&&e.onRowUpdated([l],[e.rows[l]],[e.rows[l].data],e)}break;case"insert":i(o,t.index);for(let t=0;t<e.rows.length;t++)e.rows[t].index=t;break;case"remove":s(t.index);break;case"removeLast":r();break;case"bindingComplete":if(e.dataSource&&e.dataSource.url||e.dataSource&&!e.dataSource.virtualDataSource){if(e.appearance.displayLoadingIndicator=!1,e._setLoadingIndicatorVisibility(),e._toggledRow=null,e.dataSource.length!==d){if(e.paging.enabled){const t=e.$.headerPager.querySelector("smart-pager"),o=e.$.footerPager.querySelector("smart-pager");t&&(t.pagesCount=Math.ceil(e.dataSource.length/e._pageSize)),o&&(o.pagesCount=Math.ceil(e.dataSource.length/e._pageSize))}if(0===d&&0===e.columns.length&&e.dataSource.dataFields.length>0){const t=e.context;e.context=e,e.columns.canNotify=!1,e.columns=[],e._renderColumns(),e._resetCachedLayout(),e.columns.canNotify=!0,e.context=t}e._initializeRows(),e._initializeRowElements(),e.refresh()}e._recycle(),e.onLoad&&(e.onLoad(),delete e.onLoad)}}a(),("update"!==t.action||l)&&e._refreshLayout(),e._recycle(),e.rows.canNotify=!0})),e._observeRows(),e.summaryRow.visible){const t=new Smart.Grid.Row({height:e.layout.rowMinHeight,freeze:"near",visible:"near"===e.summaryRow.position,summaryRowIndex:0,summaryRow:!0}),o=new Smart.Grid.Row({height:e.layout.rowMinHeight,freeze:"far",visible:"far"===e.summaryRow.position,summaryRowIndex:0,summaryRow:!0});"near"===e.summaryRow.position&&e._frozenNearRows.splice(0,0,t),"far"===e.summaryRow.position&&e._frozenFarRows.push(o)}if(e.filtering.enabled&&e.filtering.filterRow.visible){const t=new Smart.Grid.Row({freeze:!0,autoGenerated:!0,filterRow:!0});e._frozenNearRows.splice(0,0,t)}e._renderAddNewRow()}_observeRows(){const e=this;e._frozenNearRows=[],e._frozenFarRows=[],e.rows=new Smart.ObservableArray(e.rows,null,{allowToggle:!0,allowResize:!0,allowCheck:!0,allowSelect:!0,allowReorder:!0,expanded:!0,selected:!0,checked:!0,visible:!0,enabled:!0,minHeight:!0,height:!0,freeze:!0,showDetail:!0,data:!0,visibleIndex:!0,index:!0,comments:!0,style:!0,starred:!0,updatedBy:!0,updatedDate:!0,createdDate:!0,createdBy:!0,history:!0});for(let t=0;t<e.rows.length;t++){const o=e.rows[t];!0===o.freeze||"near"===o.freeze?e._frozenNearRows.push(o):"far"===o.freeze&&e._frozenFarRows.push(o),e.rowById[e.rows[t].id]=o}e.rows.notify((function(t){if(!e.rows.canNotify)return;const o=t.action;if("length"===o)return;if(t.path)return e.rows.canNotify=!1,(e.rowById[t.target.id]||"selected"===t.propertyName)&&(l=t.target,a=t.propertyName,n=t.oldValue,i=t.newValue,n===i&&"selected"!==a&&"showDetail"!==a||(l.propertyChanged(a,n,i),e.onRowChange&&l.properties.indexOf(a)>=0&&e.onRowChange(l,a,n,i,e))),void(e.rows.canNotify=!0);var l,a,n,i;if(e.rows.canNotify=!1,!e.dataSource)return;switch(e.dataSource.canNotify=!1,o){case"add":{const o=function(o){let l=e.rows[o];if(l instanceof Smart.Grid.Row==0){l=new Smart.Grid.Row(l);const a=e.rows.canNotify;e.rows.canNotify=!1,t.object[o]=l,l=t.object[o],e.rows.canNotify=a}if(l.grid=e,e.dataSource&&e.dataSource.virtualDataSource){e.rows.canNotify=!1;for(let t=0;t<e.rows.length;t++){const o=e.dataSource.boundSource[t],l=e.rows[t];o&&(l.data=o,l.id=o.$.id),e.rowById[l.id]=l}e.rows.canNotify=!0}else(()=>{if(0===e.dataSource.length&&e.dataSource.dataFields&&0===e.dataSource.dataFields.length&&e.columns&&e.columns.length){let t=[];for(let o=0;o<e.columns.length;o++){const l=e.columns[o];t.push({name:l.dataField,dataType:l.dataType||"string"}),l.displayField&&l.displayField!==l.dataField&&t.push({name:l.displayField,dataType:l.dataType||"string"})}e.dataSource.dataFields=t}if(o<e.dataSource.length?e.dataSource.insert(o,e.rows[o].data):e.dataSource.add(e.rows[o].data),e.dataSource[o]){l.data=e.dataSource[o];for(let t=0;t<e.dataSource.dataFields.length;t++){const o=e.dataSource.dataFields[t].name;e.columnByDataField[o]||delete l.data[o]}void 0!==e.dataSource[o].$.id&&(l.id=e.dataSource[o].$.id,e.rowById[l.id]=l),l.data.$&&l.history&&(l.data.$.history=l.history)}-1!==l.index&&void 0!==l.index||(l.index=o),l.selected&&(e._selection.rows[l.id]=!0,e._selection.indexes[l.index]=l.index),l.freeze&&(!0===l.freeze||"near"===l.freeze?e._frozenNearRows.push(l):"far"===l.freeze&&e._frozenFarRows.push(l))})()};for(let e=0;e<t.addedCount;e++)o(t.index+e);break}case"update":if(t.target){const o=e.rowById[t.target.id],l=e.rows.indexOf(o);e.dataSource.update(l,o)}else{const o=e.rows.indexOf(t.index);e.dataSource.update(t.index,o)}break;case"remove":{if(e.dataSource&&e.dataSource.virtualDataSource){e.rows.canNotify=!1;const o=t.removed&&t.removed.length>0?t.removed[0]:null;o&&delete e.rowById[o.id];for(let t=0;t<e.dataSource.boundSource.length;t++){const o=e.dataSource.boundSource[t],l=e.rows[t];l&&(l.data=o,l.id=o.$.id,e.rowById[l.id]=l)}return e.rows.canNotify=!0,e.refresh(),void e._refreshPaging(!1)}const o=t.removed&&t.removed.length>0?t.removed[0]:null;o&&delete e.rowById[o.id],e.dataSource.removeAt(t.index);break}}if(e.dataSource.canNotify=!0,e.rows.canNotify=!0,!o)return;let r=e.isInitialized&&e._rowElements&&e._rowElements.length<e.rows.length;"add"===o&&1===t.addedCount&&r&&e._rowElements.length>0&&e._rowElements[e._rowElements.length-1].classList.contains("smart-hidden")&&(r=!1),r&&e._initializeRowElements(),e.refresh(),e._refreshPagesCount(),e._sortedColumns&&e._sortedColumns.length>0&&e.refreshSort()}))}render(){const e=this,t=()=>0===e.offsetWidth||0===e.offsetHeight;if(t())return requestAnimationFrame((()=>{e.isInitialized||t()||e._render()})),e.setAttribute("role","grid"),e.editing.enabled||e.setAttribute("aria-readonly",!0),void super.render();const o=e.context;e.context=e,e.setAttribute("role","grid"),"grid"!==e.view&&e.setAttribute("view",e.view),e.editing.enabled||e.setAttribute("aria-readonly",!0),e._undoRedo=[],e._refreshCurrentUser(),e._render(),e.context=o,super.render()}_renderColumns(e){const t=this;t._initializeColumns(),t._initializeColumnGroupsHierarchy(),t._refreshColumnsResponsiveVisibility(),t._createColumnHeaderCellElements(),t._renderColumnGroupHeaders(),!1!==e&&t._refresh()}_renderRows(e){const t=this;t._initializeRows(),t._initializeRowElements(),!1!==e&&t._refresh()}_setupMobile(){const e=this;if(void 0===e._mobile&&(e._mobile=Smart.Utilities.Core.isMobile),e._mobile){e.editing.addNewColumn.visible=!1,e.layout.rowMinHeight=e.layout.rowHeight=48,e.behavior.columnResizeMode="none",e.behavior.rowResizeMode="none",e.behavior.allowRowReorder=!1,e.behavior.allowColumnReorder=!1,e.editing.action="none",e.appearance.showViewBar=!1,e._scrollView.vScrollBar.showButtons=!1,e._scrollView.hScrollBar.showButtons=!1,e.style.setProperty("--smart-scroll-bar-size","12px"),document.body.style.setProperty("--smart-data-view-sort-panel-width","345px"),e._scrollContent=document.createElement("div"),e._scrollContent.style.width="100%",e._scrollContent.style.height="100%",e._scrollContent.style.position="absolute",e._scrollContent.style.left="0px",e._scrollContent.style.top="0px",e._scrollContent.style.background="white",e._scrollContent.style.zIndex=9999,e._scrollContent.style.opacity=.1,e._scrollContent.style.overflow="auto",e.addEventListener("viewChange",(()=>{"grid"===e.view?e._scrollContent.classList.remove("smart-hidden"):e._scrollContent.classList.add("smart-hidden")})),e.addEventListener("beginEdit",(()=>{e._scrollContent.classList.add("smart-hidden")})),e.addEventListener("endEdit",(()=>{e._scrollContent.classList.remove("smart-hidden")})),e._scrollContent.ontouchmove=e=>{e.stopPropagation()},e._scrollContent.ontouchstart=e=>{e.stopPropagation()},e._scrollContent.onpointerdown=t=>{e._scrollContentScroll=!1,setTimeout((()=>{const o=e=>new PointerEvent(e,{bubbles:!0,cancelable:!0,composed:!0,pointerId:42,pointerType:"mouse",clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY});if(e._scrollContentScroll)e._hideActionButtons();else{const l=(e.enableShadowDOM?e.shadowRoot:e.getRootNode()).elementsFromPoint(t.clientX,t.clientY);if(l[2])if(l[2].classList.contains("smart-grid-add-row-button"))e._hideActionButtons(),l[2].dispatchEvent(o("click"));else if(l[2].classList.contains("smart-summary-placeholder")||l[2].classList.contains("summary-value-part"))e._hideActionButtons(),l[2].dispatchEvent(o("pointerup"));else if(l[2].closest("smart-menu-item")){e._hideActionButtons();const t=l[2].closest("smart-menu-item");l[2].closest("smart-menu")._menuItemSelectionHandler(t)}else{if(l[2].dispatchEvent(o("pointerdown")),e._lastMobileClickRange){const o=e._lastMobileClickRange;let l=!0;o.left<=t.pageX&&o.left+o.right>=t.pageX&&(l=!1),l&&e._hideActionButtons()}else e._hideActionButtons();const a=(o,l)=>{if(o&&o.autoShowActionButton){const a=l.getBoundingClientRect(),n=e.offset(l);if(n.left<=t.pageX&&n.left+a.width-6>=t.pageX){if(!e.hasColumnMenu(o))return;e._lastMobileClickRange={left:n.left,right:n.left+a.width-6},l._showActionButton()}else l._hideActionButton()}};for(let t=0;t<e._columnElements.length;t++){const o=e._columnElements[t];a(o.column,o)}}}}),300),t.stopPropagation()};let t=0;const o=()=>{const t=e._scrollContent.scrollLeft,o=e._scrollContent.scrollTop;e._scrollView.vScrollBar.value=o,e._scrollView.hScrollBar.value=t,e._scrollContentScroll=!0};e._scrollContent.onscroll=()=>{cancelAnimationFrame(t),t=0,t=requestAnimationFrame(o)},e._scrollContentView=document.createElement("div"),e._scrollContentView.style.width=e._scrollView.scrollWidth+"px",e._scrollContentView.style.height=e._scrollView.scrollHeight+"px",e._scrollContent.appendChild(e._scrollContentView),e.$.scrollView.appendChild(e._scrollContent)}}_render(){const e=this;if(e.isInitialized||(e.onBeforeInit&&(e.onBeforeInit(e),e.onBeforeInit=null),e.$.fireEvent("beforeInit",{grid:e}),e.header.visible&&e.header.buttons.indexOf("views")>=0&&e._updateKanbanTaskFields()),e._setupMobile(),(()=>{if(null===e.dataSource)e.dataSource=new Smart.DataAdapter;else if(Array.isArray(e.dataSource)||"string"==typeof e.dataSource){let t=[];if(e.dataSourceSettings.dataFields&&e.dataSourceSettings.dataFields.length>0)e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataSourceType:e.dataSourceSettings.dataSourceType,dataFields:e.dataSourceSettings.dataFields,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy||e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand});else if(e.columns&&e.columns.length){for(let o=0;o<e.columns.length;o++){const l=e.columns[o];t.push({name:l.dataField,dataType:l.dataType||"string"}),l.displayField&&l.displayField!==l.dataField&&t.push({name:l.displayField,dataType:l.dataType||"string"})}e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataFields:t,dataSourceType:e.dataSourceSettings.dataSourceType,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy||e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand})}else e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource})}})(),e._selection={rows:[],indexes:[],columns:[],cells:[]},e.dataSource&&e.dataSource.url&&(e.appearance.displayLoadingIndicator=!0,e._setLoadingIndicatorVisibility(),e.dataSource.data={sorting:e.getSortedColumns(),filtering:e.getFilteredColumns(),grouping:e.grouping.groupBy}),e.filtering.filterRow)for(let t=0;t<e.columns.length;t++)e.columns[t]._filterEditorInitialized&&(e.columns[t]._filterEditorInitialized=!1);const t=!e.isInitialized;if(t&&(e.onInit&&(e.onInit(e),e.onInit=null),e.$.fireEvent("init",{grid:e})),e._renderColumns(!1),e._renderRows(!1),e._renderPagers(),e._renderCommandBar(),e._renderConditionalFormatting(),e._initFormulaParser(),t&&e.grouping.enabled&&e.grouping.groupBy.length&&e.dataSource&&(e.dataSource.groupBy=e.grouping.groupBy),e.appearance.allowColumnStickyPosition&&e._stickHeader(),e.header.visible&&""===e.header.template){const t=document.createElement("smart-grid-toolbar");t.headerPosition="top",t.messages=e.messages,t.locale=e.locale,e.$.header.appendChild(t),e.$.headerBar=e.$.header.firstElementChild,e.$.headerBar._init(e)}if(e.isInitialized)e.refreshFilters();else{let t=!1;if(e.stateSettings.autoLoad){let o=e.stateSettings.current;!o&&e.stateSettings.allowLocalStorage&&(e.stateSettings.current="View 1",o=e.stateSettings.current);let l=null;e.stateSettings.storage&&(l=e.stateSettings.storage[o]),l&&(t=!0),!l&&e.stateSettings.allowLocalStorage&&(l=window.localStorage.getItem(o),l&&(t=!0))}if(!t){const t=[];for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];l.allowSort&&l.sortOrder&&t.push(l)}if(0===t.length&&e.sorting.sort)for(let o=0;o<e.sorting.sort.length;o++){const l=e.sorting.sort[o],a=Object.keys(l)[0],n=l[a],i=e.columnByDataField[a];i&&(t.push(i),i.sortOrder=n||"asc")}t.sort(((e,t)=>e.sortIndex-t.sortIndex));for(let o=0;o<t.length;o++){const l=t[o],a=e.appearance.allowSortAnimation;e.appearance.allowSortAnimation=!1,e.sortBy(l.dataField,l.sortOrder),e.appearance.allowSortAnimation=a}if(e.filtering.filter.length>0){for(let t=0;t<e.filtering.filter.length;t++){const o=e.filtering.filter[t];if(o){if("string"==typeof o){const t=e.filtering.filter[0],o=e.columnByDataField[t],l=e.filtering.filter[1];let a=null;if(o&&(a=e.dataSource._createFilter(o.dataType,l)),a){if(e.filtering.filterRow.visible&&!o._filterInfo){let e=[];for(let t=0;t<a.filters.length;t++)e.push(a.filters[t].value),t<a.filters.length-1&&e.push(a.logicalOperators[t]);o._filterInfo={condition:a.filters[0].condition,value:e.join(" ")}}e.addFilter(t,a,!1)}break}const t=o[0],l=o.splice(1);let a=null;if(l instanceof Smart.FilterGroup)a=l;else{const o=e.columnByDataField[t];o&&(a=e.dataSource._createFilter(o.dataType,l))}if(a){if(e.filtering.filterRow.visible&&!column._filterInfo){let e=[];for(let t=0;t<a.filters.length;t++)e.push(a.filters[t].value),t<a.filters.length-1&&e.push(a.logicalOperators[t]);column._filterInfo={condition:a.filters[0].condition,value:e.join(" ")}}e.addFilter(t,a,!1)}}}e.refreshFilters()}else{for(let t=0;t<e.columns.length;t++){const o=e.columns[t];if(o.filter){let t=null,l=o.filter;if(t=l instanceof Smart.FilterGroup?l:e.dataSource._createFilter(o.dataType,l),t){if(e.filtering.filterRow.visible&&!o._filterInfo){let e=[];for(let o=0;o<t.filters.length;o++)e.push(t.filters[o].value),o<t.filters.length-1&&e.push(t.logicalOperators[o]);o._filterInfo={condition:t.filters[0].condition,value:e.join(" ")}}e.addFilter(o.dataField,t,!1)}}}e.refreshFilters()}}}if(e.viewColumns.canNotify=!0,e.isInitialized=!0,("virtual"===e.scrolling||e.paging.enabled&&e.dataSource&&e.dataSource.virtualDataSource||e.dataSource&&e.dataSource.virtualDataSource)&&e._virtualDataRequest("dataBind"),""!==e.header.template&&e._applyTemplate(e.header.template,e.$.header),""!==e.footer.template&&e._applyTemplate(e.footer.template,e.$.footer),e._createFilterPanels(),e._refresh(),e._applyScrolling(),e.grouping.enabled&&e.grouping.autoExpandAll&&e.rowHierarchy?e.expandAllRows():e.grouping.enabled&&e.grouping.autoExpandToLevel&&e.rowHierarchy&&e.expandRowsToGroupLevel(e.grouping.autoExpandToLevel),e.onRender&&(e.onRender(t),e.onRender=null),e.isRendered=!0,"auto"===e.layout.rowHeight&&(e._refreshLayout(),e._recycle()),t){if(e.stateSettings.autoLoad){let t=e.stateSettings.current,o=null;e.stateSettings.storage&&(o=e.stateSettings.storage[t]),!t&&e.stateSettings.allowLocalStorage&&(e.stateSettings.current="smartGrid"+e.id,t=e.stateSettings.current),!o&&e.stateSettings.allowLocalStorage&&(o=window.localStorage.getItem(t)),o&&("string"==typeof o&&(o=JSON.parse(o)),e._loadState(o))}if(e.onAfterInit&&(e.onAfterInit(e),e.onAfterInit=null),e.$.fireEvent("afterInit",{grid:e}),e.isRendering=!1,e.whenRenderedCallbacks){for(let t=0;t<e.whenRenderedCallbacks.length;t++)e.whenRenderedCallbacks[t]();e.whenRenderedCallbacks=[]}!e.dataSource||e.dataSource.url||e.dataSource.virtualDataSource||e.onLoad&&e.onLoad(e)}"kanban"===e.view&&e._initKanbanView()}_initFormulaParser(){const e=this;if(e.formulas){class t{constructor(e){const t=this;let o;try{o=new formulaParser.Parser}catch(e){throw new Error("Smart.FormulaParser: Missing reference to 'formula-parser.min.js'.")}o.on("callCellValue",t._callCellValue.bind(t)),o.on("callRangeValue",t._callRangeValue.bind(t)),t.dataTable=e,t.parser=o}_getFormula(e){const t=this,o="A".charCodeAt(0);let l=0,a="";const n=e;if(t.dataTable._formulas||(t.dataTable._formulas=[]),t.dataTable._formulas[e])return t.dataTable._formulas[e];for(let n=0;n<t.dataTable.columns.length;n++){const i=t.dataTable.columns[n],r=String.fromCharCode(o+l);l++,l>=26&&(l=0,a+="A"),e.indexOf(i.label)>=0?e=e.replaceAll(i.label,a+r):e.indexOf(i.dataField)>=0&&(e=e.replaceAll(i.dataField,a+r))}return t.dataTable._formulas[n]=e,e}_callCellValue(e,t){const o=this,l=o.dataTable,a=e.column.index,n=e.row.index,i=l.columns[a].dataField;let r=l.dataSource[n][i];const s=l.rows[n];if(s){const e=s.getCell(i);e&&e.formula&&(r=o._getFormula(e.formula))}"string"==typeof r&&/=.+/.test(r)&&(r=o.parse(r.slice(1))),t(r)}_callRangeValue(e,t,o){const l=this.dataTable,a=l.dataSource,n=[];for(let o=e.row.index;o<=t.row.index;o++){const i=a[o],r=[];for(let o=e.column.index;o<=t.column.index;o++){let e=i[l.columns[o].dataField];e=isNaN(e)?0:parseFloat(e),isNaN(e)&&(e=0),r.push(e)}n.push(r)}n&&o(n)}parse(e){const t=this.parser.parse(this._getFormula(e));return null!==t.result?t.result:t.error}}e._formulaParser=new t(e)}}get _viewRows(){const e=this;if(e.__viewRows)return e.__viewRows;e._nearRowsAdded||(e._nearRowsAdded=[],e._farRowsAdded=[]);const t=e.rows.toArray?e.rows.toArray():[],o=e.rowHierarchy?e.rowHierarchy:t,l=[].concat(e._frozenNearDefaultRows,e._nearRowsAdded,o,e._farRowsAdded,e._frozenFarDefaultRows);return e.__viewRows=l,l}_toHex(e){if(-1!==e.indexOf("#"))return e;const t=/rgb\((\d+), (\d+), (\d+)\)/g.exec(e);return t?"#"+(parseFloat(t[1]).toString(16).padStart(2,"0")+parseFloat(t[2]).toString(16).padStart(2,"0")+parseFloat(t[3]).toString(16).padStart(2,"0")).toUpperCase():"#FFFFFF"}_renderConditionalFormatting(){const e=this,t=e.conditionalFormatting;if(!t||0===t.length)return;if(!e._defaults){const t=getComputedStyle(e);e._defaults={fontFamily:t.fontFamily,fontSize:t.fontSize,text:e._toHex(t.color),highlight:e._toHex(t.backgroundColor)}}e._formatter||(e._formatter=new Smart.Utilities.ConditionalFormatter(e.dataSource));const o=e._defaults,l=e._formatter,a=[],n=function(t){if("all"===t){if(e.columns&&e.columns.map){const t=[];for(let o=0;o<e.columns.length;o++){const l=e.columns[o];l.dataField.startsWith("task")||l.autoGenerated||"number"!==l.dataType&&"date"!==l.dataType||t.push(l.dataField)}return t}return[]}return[t]};for(let e=0;e<t.length;e++){t[e]=Object.assign({column:"all",condition:"lessThan",firstValue:0,secondValue:1,fontFamily:o.fontFamily,fontSize:o.fontSize,text:o.text,highlight:o.highlight},t[e]);const i=t[e],r=n(i.column),s=i.condition;l.color=i.highlight,l.comparator=i.firstValue,l.min=i.firstValue,l.max=i.secondValue;const d=l.format(s,r);for(let e in d){const t=d[e];for(let e in t){const o=t[e];o.color=i.text,o.fontFamily=i.fontFamily,o.fontSize=i.fontSize}}a.push(d)}if(e._formattingPanel&&(e._formattingPanel.items=t),0===a.length)return a[0];const i={};for(let e=0;e<a.length;e++){const t=a[e];for(let e in t){const o=t[e];if(0!==Object.keys(o).length){i[e]||(i[e]={});for(let t in o)i[e][t]=Object.assign({},i[e][t],o[t])}}}e._conditionalFormatting=i}_stickHeader(){const e=this;e._stickyHeaderHandler=function(){e._handleStickyHeader()},e.$.columnHeader.style.top="",e.$.columnHeader.classList.remove("smart-columns-sticky");let t=e.parentNode;for(e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);t!==document&&t;)t.addEventListener("scroll",e._stickyHeaderHandler),t=t.parentNode,e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);try{null!==window.top&&window.top!==window.self&&window.top.document.addEventListener("scroll",e._stickyHeaderHandler)}catch(e){}e._handleStickyHeader()}_unstickHeader(){const e=this;e.$.columnHeader.style.top="",e.$.columnHeader.classList.remove("smart-columns-sticky");let t=e.parentNode;for(;t!==document.body;)t.removeEventListener("scroll",e._stickyHeaderHandler),t=t.parentNode,e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);try{(""!==document.referrer||window.frameElement)&&null!==window.top&&window.top!==window.self&&window.top.document.removeEventListener("scroll",e._stickyHeaderHandler)}catch(e){}}_handleStickyHeader(){const e=this;if(e.appearance.allowColumnStickyPosition)if(e.$.columnHeader.classList.add("smart-columns-sticky"),0===document.scrollTop&&0===e.parentElement.scrollTop)e.$.columnHeader.style.top="";else{let t=e.parentNode,o=0;for(;t!==document.body;)o+=parseInt(t.scrollTop),t=t.parentNode,e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);const l=parseInt(e.clientTop+o);e.$.columnHeader.style.top=l+"px";let a=0;window.top!==window.self&&parseInt(window.top.scrollY)>parseInt(e._offsetTop(window.frameElement))&&(a=parseInt(window.top.scrollY)-parseInt(e._offsetTop(window.frameElement))),window.scrollY+a>e.offsetTop&&(e.$.columnHeader.style.top=parseInt(window.scrollY)-parseInt(e.offsetTop)+l+a+"px")}}_scrollHandler(){this._handleStickyHeader()}_initializeRowNumberColumn(){const e=this;if(e._frozenNearColumns&&e._frozenNearColumns.length>0&&e._frozenNearColumns[0].rowHeaderColumn)return void(e._frozenNearColumns[0].visible=e.appearance.showRowHeaderNumber||e.appearance.showRowHeader);const t=new Smart.Grid.Column({dataField:"_rowHeaderColumn",label:"",allowSelect:!1,freeze:!0,visible:!0,grid:e,autoGenerated:!0,rowHeaderColumn:!0,cellsAlign:"center"}),o=e.rows?e.rows.length:e.dataSource?e.dataSource.length:0;let l=e.appearance.showRowHeaderNumber?t._measureSize(o):30;e.layout.autoGenerateColumnWidth&&(l=e.layout.autoGenerateColumnWidth),t.width=l,t.createElement();const a=new Smart.Observable(t,t.observables);e.viewColumns.splice(0,0,a),e._frozenNearColumns.splice(0,0,a)}_initializeColumns(){const e=this;if("number"==typeof e.columns){const t=[],o="A".charCodeAt(0);let l="",a=0;for(let n=0;n<e.columns;n++){let i=n+1;const r=String.fromCharCode(o+a);a++;const s=l+r;"number"!==e.appearance.autoGenerateColumnLabelMode&&(i=l+r),t.push({align:"center",label:i,dataField:s,width:100}),a>=26&&(a=0,l+="A")}e._boundColumns=t}else e._boundColumns=Array.isArray(e.columns)?[...e.columns]:[...e.columns.toArray()];e._initColumns=e.columns,e.columnByDataField=[],e.viewColumns=[],e.columns=new Smart.ObservableArray,e._frozenFarColumns=[],e._frozenNearColumns=[],e._summaryRowCount=1;let t=0;const o=function(t){if(e.dataSource.dataFields){const o=e.dataSource.dataFields.find((e=>{if(e.name===t.dataField)return e})),l=o&&o.dataType||"string";t.dataType||(t.dataType=l)}};if(0===e._boundColumns.length&&e.dataSource&&e.dataSource[0]&&!1!==e.dataSource.autoGenerateColumns){const t=e.dataSource[0];if(t.$&&t.$.isEmpty&&e.dataSource.dataFields)for(let t=0;t<e.dataSource.dataFields.length;t++){const o=e.dataSource.dataFields[t],l=e._boundColumns.length,a={index:l,visibleIndex:l,label:o.name,dataField:o.name,dataType:o.dataType};e._boundColumns.push(a)}else for(let l in t){if(l.startsWith("_")||"$"===l)continue;const t=e._boundColumns.length,a={index:t,visibleIndex:t,label:l,dataField:l};o(a),e._boundColumns.push(a)}}for(let l=0;l<e._boundColumns.length;l++){let a=e._boundColumns[l];if("string"==typeof a){if(e.dataSource.dataFields){const t=e.dataSource.dataFields.find((e=>{if(e.name===a)return e}));a={label:a,dataField:a,dataType:t&&t.dataType||"string"}}}else o(a);a.visibleIndex=l,a.index=l,a.grid=e,a.label&&/<.+?>/.test(a.label)&&a.label.replace&&("all"===e.dataSourceSettings.sanitizeHTML?a.label=a.label.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===e.dataSourceSettings.sanitizeHTML&&(a.label=window.Smart.Utilities.Core.escapeHTML(a.label)));const n=new Smart.Grid.Column(a);e.onColumnInit&&e.onColumnInit(l,n);for(let t in n)-1!==n.properties.indexOf(t)||t.startsWith("_")||e.error(e.localize("invalidColumnProperty",{elementType:"Grid",propertyName:t,type:n.dataField||"Column"}));delete a.grid,delete a.dataType,delete a.index,delete a.visibleIndex,n.grid=e,e.columns.push(n),n._dataField&&(e.columnByDataField[n._dataField]=n);const i=e.columns[e.columns.length-1];e._summaryRowCount=Math.max(e._summaryRowCount,n.summary.length),n.freeze?!0===n.freeze||"near"===n.freeze?(e.viewColumns.splice(t++,0,i),e._frozenNearColumns.push(i)):"far"===n.freeze&&e._frozenFarColumns.push(i):e.viewColumns.push(i),e.columnByDataField[n.dataField]?(i.parent=e.columnByDataField[n.dataField],e.columnByDataField[n.dataField].children||(e.columnByDataField[n.dataField].children=[]),e.columnByDataField[n.dataField].children.push(i),n.valueField=n.dataField,n.dataField+="_"+e.columnByDataField[n.dataField].children.length,n.displayField=n.valueField,e.columnByDataField[n.dataField]=i):e.columnByDataField[n.dataField]=i,e.onColumnInserted&&!e.isInitialized&&e.onColumnInserted(l,n.getState())}e.viewColumns=e.viewColumns.concat(e._frozenFarColumns),e.setAttribute("aria-colcount",e._boundColumns.length);let l=0;if((e.appearance.showRowHeaderNumber||e.appearance.showRowHeader)&&(e._initializeRowNumberColumn(),l++),e.rowDetail.enabled){const t=20,o=new Smart.Grid.Column({dataField:"_rowDetailColumn",allowSelect:!1,visible:e.rowDetail.visible,label:"",grid:e,freeze:!0,rowDetailColumn:!0,autoGenerated:!0,cellsAlign:"center",width:t,minWidth:t}),a=new Smart.Observable(o,o.observables);"near"===e.rowDetail.position?(o.freeze="near",a.freeze="near",e.viewColumns.splice(l,0,a),e._frozenNearColumns.splice(l,0,a)):(e.viewColumns.push(a),e._frozenFarColumns.splice(0,0,a)),l++}const a=new Smart.Grid.Column({dataField:"_adaptiveColumn",allowSelect:!1,visible:!1,label:"",grid:e,freeze:"far",adaptiveColumn:!0,autoGenerated:!0,cellsAlign:"center",width:30}),n=new Smart.Observable(a,a.observables);n.canNotify=!1,e.viewColumns.push(n),e._frozenFarColumns.splice(0,0,n);const i=new Smart.Grid.Column({dataField:"_commandColumn",allowSelect:!1,visible:e.editing.enabled&&e.editing.commandColumn.visible&&!e.editing.commandColumn.inline,label:"",grid:e,freeze:"far",commandColumn:!0,autoGenerated:!0,align:"center",cellsAlign:"center",width:""}),r=new Smart.Observable(i,i.observables);r.canNotify=!1,"near"===e.editing.commandColumn.position?(i.freeze="near",r.freeze="near",e.viewColumns.splice(l,0,r),e._frozenNearColumns.splice(l,0,r)):(e.viewColumns.push(r),e._frozenFarColumns.splice(0,0,r)),e._commandColumn=r;const s=new Smart.Grid.Column({allowSelect:!1,visible:e.selection.enabled&&e.selection.checkBoxes.enabled,dataField:"_checkBoxColumn",label:"",freeze:e.selection.checkBoxes.position,grid:e,selectionColumn:!0,autoGenerated:!0,cellsAlign:"center",width:32}),d=new Smart.Observable(s,s.observables);if("near"===s.freeze?(e.viewColumns.splice(l,0,d),e._frozenNearColumns.splice(l,0,d)):(e.viewColumns.push(d),e._frozenFarColumns.splice(0,0,d)),e._selectionColumn=d,e._selectionColumn.canNotify=!1,e.editing.addNewColumn.visible){const t=new Smart.Grid.Column({dataField:"_addNewColumn",allowSelect:!1,visible:!0,title:e.localize("addNewColumn"),label:"",cellsClassName:"smart-add-new-column",className:"smart-add-new-column smart-icon smart-grid-icon show smart-icon-plus",grid:e,adaptiveColumn:!1,autoGenerated:!0,cellsAlign:"center",width:90}),o=new Smart.Observable(t,t.observables);e.viewColumns.push(o),e._addNewColumn=o,e._addNewColumn.canNotify=!1}e._observeColumns(),e._templateColumns()}get styleProperties(){return["grid-template-columns","--smart-grid-row-height","--smart-grid-column-header-height","--smart-grid-group-header-height","--smart-grid-filter-footer-height","--smart-grid-group-row-vertical","--smart-grid-group-row-horizontal-offset","--smart-grid-freeze-splitter-size","--smart-grid-resize-line-size","--smart-grid-footer-height","--smart-grid-header-height"]}_templateColumns(){const e=this,t=getComputedStyle(e),o=t.getPropertyValue("--smart-grid-template-columns").trim();if(e._rowGap=0,e._columnGap=0,e._maxHeight=parseInt(t.maxHeight),e._minHeight=parseInt(t.minHeight),"none"!==o){let t=0;for(let o=0;o<e.viewColumns.length;o++)e.viewColumns[o].autoGenerated&&(t+=e.viewColumns[o].visible?e.viewColumns[o].width:0);let l=[];const a=document.createElement("div");a.style.display="grid",a.style.gridTemplateColumns=o;for(let t=0;t<e.columns.length;t++)a.innerHTML+="<div></div>";a.style.width=e.clientWidth-t+"px",e.$.root.appendChild(a);const n=o.split(" ");for(let t=0;t<e.columns.length;t++)l[t]=a.children[t].offsetWidth,"auto"===n[t]&&(l[t]=null);a.parentNode.removeChild(a);let i=0;for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.autoGenerated||l[i]&&(o.width=o.templateWidth=l[i++])}}else for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.autoGenerated||o.templateWidth&&(o.width=o.templateWidth=null)}}setColumns(e){const t=this;if(null===e)return void(t.columns=[]);t.beginUpdate(),t.columns.canNotify=!1;let o=[],l=[];for(let l=0;l<e.length;l++){const a=e[l];let n=!0;for(let e=0;e<t.columns.length;e++)if(t.columns[e].dataField===a.dataField){n=!1;break}n&&o.push(a)}const a=e.map((e=>e.dataField));for(let e=0;e<t.columns.length;e++){const o=t.columns[e];-1===a.indexOf(o.dataField)&&l.push(o)}l.forEach((e=>{const o=t.columns.indexOf(e);o>=0&&t.columns.splice(o,1)}));for(let e=0;e<o.length;e++)t.columns.push(o[e]);if(t.columns.canNotify=!0,t.endUpdate(),t._columnGroups=[],t._columnHeights=0,t.viewColumns)for(let e=0;e<t.viewColumns.length;e++){const o=t.viewColumns[e],l=o.element;o.top=0,o.level=0,l&&(l.style.top="",l.style.height="",l.style.lineHeight="")}if(t._renderColumns(),t.__columnHeaderHeight=null,e){t.beginUpdate();const o=t.context;t.context=document;for(let o=0;o<e.length;o++){const l=e[o],a=t.columnByDataField[l.dataField];["allowExport","allowFreeze","allowNull","allowGroup","allowSelect","verticalAlign","columnGroup","cellsVerticalAlign","autoCloseMenu","autoShowActionButton","autoShowSortButton","autoShowFilterButton","allowLabelAnimation","allowActionButtonAnimation","allowSortButtonAnimation","allowHide","allowDelete","allowEdit","allowSummary","allowHeaderEdit","allowFilter","allowSort","allowSortToggleOnClick","allowResize","allowReorder","description","icon","menuItems","summary","cellsFormat","className","rowSpan","cellsClassName","cellsCSSRules","formatSettings","formatFunction","sortIndex","sortOrder","sortComparator","groups","group","filtered","filterEditor","filter","filterMenuMode","defaultValue","dataField","displayField","label","labelTemplate","dataType","align","cellsWrap","cellsAlign","minWidth","width","visible","_visible","freeze","showActionButton","selected","showIcon","highlight","showDescriptionButton","treeColumn","statusColumn","value","valueField","onAction","title","showCustomButton","showFilterButton","showSortButton","editor","template","visibleIndex","validationRules"].forEach((e=>{void 0!==l[e]&&(a[e]=l[e])}))}t.context=o,t.endUpdate(!1)}t.refresh()}onAttached(){const e=this;if(!e._scrollView){e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar);const t=e._scrollView.hScrollBar;e._scrollView.vScrollBar.onChange=e._verticalScrollbarHandler.bind(e),t.onChange=e._horizontalScrollbarHandler.bind(e)}e.isRendered&&e.isCompleted&&e._render()}onDetached(){const e=this;if(!e.isRendered)return;["_dialogChart","_dialogAddRow","_dialogEdit","_dialogDelete","_dialogRowDetail","_dialogAddColumn"].forEach((t=>{e[t]&&(e[t].close(),e[t]=null)})),e.menu&&(e.menu.ownerElement=null,e.menu.remove(),e.menu=null);const t=e.querySelector("smart-grid-toolbar");if(t){const e=t.$.headerDropDown;e&&e.remove()}e._resetCachedLayout();const o=e._scrollView.hScrollBar,l=e._scrollView.vScrollBar;if(l.ownerElement=null,o.ownerElement=null,l.onChange=null,o.onChange=null,e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),e._columnElements)for(let t=0;t<e._columnElements.length;t++)e._columnElements[t]._detach();if(e._columnElements=null,e._rowElements)for(let t=0;t<e._rowElements.length;t++)e._rowElements[t]._detach();e._rowElements=null,e.rows=[],e.rowById=[],e._initColumns=[],e.columnByDataField=[],e.viewColumns=[],e._columnToResizeElement=null;let a=Array.isArray(e.columns)?[...e.columns]:[...e.columns.toArray()];a=a.map((e=>e.data?(void 0!==e.data.visibleIndex&&delete e.data.visibleIndex,void 0!==e.data.index&&delete e.data.index,void 0!==e.data.grid&&delete e.data.grid,e.data):e)),e.rows.notifyFn=null,e.columns.notifyFn=null,e.columns.notify=null,e.columns._array=[],e.columns=a,e._boundColumns=[],e._filterPanels=[],e._frozenFarColumns=[],e._frozenNearColumns=[],e._frozenNearDefaultRows=[],e._frozenFarDefaultRows=[],e._frozenFarRows=[],e._frozenNearRows=[],e._selection={rows:[],indexes:[],columns:[],cells:[]},e.__autoHeightRows=null,e._visibleRows=null,e.__viewRows=null,e.__clientSize=null,e.__scrollHeight=null,e.__scrollWidth=null,e.__parentCells=null,e._selectionColumn=null,e._adaptiveColumn=null,e._commandColumn=null,delete e._columnFarContainerComputedStyle,delete e._columnContainerComputedStyle,delete e._columnNearContainerComputedStyle,e._inputOverlay&&(e._inputOverlay.parentNode&&e._inputOverlay.parentNode.removeChild(e._inputOverlay),e._inputOverlay=null),e._firstVisibleColumn=null,e._lastVisibleColumn=null,e._toggledRow=null,Smart(e._selector)&&(delete Smart(e._selector)._properties,Smart(e._selector)),delete e._selector,delete e._initProperties}_observeColumns(){const e=this,t=function(t,o,l,a){l===a&&"selected"!==o||(t.propertyChanged(o,l,a),e.onColumnChange?t.stateProps.indexOf(o)>=0&&e.onColumnChange(t,o,l,a):e.$.fireEvent("columnChange",{column:t,propertyName:o,oldValue:l,value:a}))};for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];l.rowHeaderColumn||(l.onAction=function(){e._openMenu(this)}),l.autoGenerated&&l.notify((function(e){l.canNotify=!1,t(l,e.propertyName,e.oldValue,e.newValue),l.canNotify=!0}))}e.columns.notify((function(o){let l=null;if(o.path)return e.columns.canNotify=!1,t(o.target,o.propertyName,o.oldValue,o.newValue),void(e.columns.canNotify=!0);e.columns.canNotify=!1;let a=0;switch(o.action){case"length":return void(e.columns.canNotify=!0);case"add":{const t=function(t){if(l=o.object[t],l instanceof Smart.Grid.Column==0){l.grid=e,l=new Smart.Grid.Column(l);const a=e.columns.canNotify;e.columns.canNotify=!1,o.object[t]=l,l=o.object[t],e.columns.canNotify=a}l.grid=e,l.onAction=function(){e._openMenu(this)},l.freeze?e._frozenNearColumns.push(l):"far"===l.freeze&&e._frozenFarColumns.push(l);let a=e.viewColumns.length-e._frozenFarColumns.length,n=0;if(e._frozenNearColumns.forEach((e=>{e.autoGenerated&&n++})),t<e.columns.length?e.viewColumns.splice(t+n,0,l):e.viewColumns.splice(a,0,l),e.columnByDataField[l.dataField]){e.columnByDataField[l.dataField].children.push(l),l.parent=e.columnByDataField[l.dataField],l.valueField=l.dataField;const t=l.dataField+"_"+l.parent.children.length;e.columnByDataField[t]=l,l.dataField=t}else e.columnByDataField[l.dataField]=l;if(e.dataSource&&e.dataSource.dataFields){let t=!1;for(let o=0;o<e.dataSource.dataFields.length;o++)e.dataSource.dataFields[o].name===l.dataField&&(t=!0);t||e.dataSource.dataFields.push({name:l.dataField,dataType:l.dataType||"string"})}if(!e._dragDrop&&e.onColumnInserted){e._onColumnInsertData||(e._onColumnInsertData=[],e._onColumnInsertIndexes=[]);const o=l.getState();o.dataField=l.dataField,e._onColumnInsertData.push(o),e._onColumnInsertIndexes.push(t),e._onColumnInsertTimer&&clearTimeout(e._onColumnInsertTimer),e._onColumnInsertTimer=setTimeout((()=>{e.onColumnInserted(e._onColumnInsertIndexes,e._onColumnInsertData),delete e._onColumnInsertIndexes,delete e._onColumnInsertData}),50)}};delete e.__measuredColumnHeight;for(let e=0;e<o.addedCount;e++)t(o.index+e);break}case"update":l=o.object[o.index],l instanceof Smart.Grid.Column==0&&(l=new Smart.Grid.Column(l)),l.grid=e;for(let t=0;t<o.index;t++)e.viewColumns[t].autoGenerated&&a++;e.viewColumns[a+o.index]=l,e.columnByDataField[l.dataField]=l,e.onColumnUpdated&&e.onColumnUpdated(o.index,l);break;case"remove":{l=o.removed[0];let t=o.index,n=e.viewColumns.indexOf(l);if(-1===n){for(let o=0;o<=t;o++)e.viewColumns[o].autoGenerated&&a++;e.viewColumns.splice(a+t,1)}else e.viewColumns.splice(n,1);if(l){if(l.filter&&e.removeFilter(l.dataField),l.sortOrder&&e.removeSort(l.dataField),e.removeGroup(l.dataField),l._dataField){const t=e.columnByDataField[l._dataField];t&&t.dataField===l.dataField&&delete e.columnByDataField[l._dataField]}delete e.columnByDataField[l.dataField]}if(e._dragDrop||e.onColumnRemoved&&e.onColumnRemoved(o.index,l),e.columnGroups&&(e._columnGroups=[],e._columnHeights=0,e.viewColumns))for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t],l=o.element;o.top=0,o.level=0,l&&(l.style.top="",l.style.height="",l.style.lineHeight="")}break}}e._initializeColumnGroupsHierarchy(),e._refreshColumnsResponsiveVisibility(),e._createColumnHeaderCellElements(),e._templateColumns(),e.refresh(),e.columnGroups&&e._columnGroups.length>0&&e._renderColumnGroupHeaders(),e.columns.canNotify=!0}))}get _scrollWidth(){const e=this;if(e.__scrollWidth)return e.__scrollWidth;let t=0;for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];l.visible&&(t+=l.computedWidth)}return t=parseInt(t),"card"===e.view&&(t=0),e.__scrollWidth=t,e._scrollView.scrollWidth=t-e._clientSize.width,e.__scrollWidth}_horizontalScrollbarHandler(){const e=this;e.closeMenu(),e.isScrolling=!0,e.isHScrolling=!0,requestAnimationFrame((()=>{e._summaryRowDialog&&e._summaryRowDialog.classList.contains("open")&&e._summaryRowDialog.close(),e._recycle(),e.isScrolling=!1,e.isHScrolling=!1}))}_mouseWheelNative(e,t){const o=this;void 0===o._scrollWheelContent&&(o._scrollWheelContent=document.createElement("div"),o._scrollWheelContent.style.width="100%",o._scrollWheelContent.style.height="100%",o._scrollWheelContent.style.position="absolute",o._scrollWheelContent.style.left="0px",o._scrollWheelContent.style.top="0px",o._scrollWheelContent.style.background="white",o._scrollWheelContent.style.zIndex=9999,o._scrollWheelContent.style.opacity=0,o._scrollWheelContent.style.overflow="auto",o._scrollWheelContent.style.visibility="hidden");let l=0;const a=()=>{if(t){const t=o._scrollWheelContent.scrollLeft;o._scrollView.hScrollBar.value=t,t===e&&o._scrollWheelContent.remove()}else{const t=o._scrollWheelContent.scrollTop;o._scrollView.vScrollBar.value=t,t===e&&o._scrollWheelContent.remove()}};o._scrollWheelContent.onscroll=()=>{cancelAnimationFrame(l),l=0,l=requestAnimationFrame(a)},o._scrollWheelContentView||(o._scrollWheelContentView=document.createElement("div"),o._scrollWheelContent.appendChild(o._scrollWheelContentView)),o._scrollWheelContentView.style.width=o.offsetWidth+o._scrollView.scrollWidth+"px",o._scrollWheelContentView.style.height=o.offsetHeight+o._scrollView.scrollHeight+"px",o.$.scrollView.appendChild(o._scrollWheelContent),o._scrollWheelContent.scrollTop=o._scrollView.vScrollBar.value,o._scrollWheelContent.scrollLeft=o._scrollView.hScrollBar.value,!0===t?o._scrollWheelContent.scrollTo({top:o._scrollView.vScrollBar.value,left:e,behavior:"smooth"}):o._scrollWheelContent.scrollTo({top:e,left:o._scrollView.hScrollBar.value,behavior:"smooth"})}_mouseWheelHandler(e){const t=this;if(t._scrollView.hScrollBar.$.hasClass("smart-hidden")&&t._scrollView.vScrollBar.$.hasClass("smart-hidden"))return;if(42===e.pointerId)return;if(t._isUpdating)return;if(t.editing.isEditing)return;const o=t.querySelector("smart-grid-toolbar");if(o&&o.$.headerDropDown.classList.contains("open"))return;let l=!1;if(e.wheelDeltaY?120!==Math.abs(e.wheelDeltaY)&&240!==Math.abs(e.wheelDeltaY)&&360!==Math.abs(e.wheelDeltaY)&&(l=!0):0===e.deltaMode&&(l=!0),t.disabled||t._scrollView.vScrollBar.$.hasClass("smart-hidden")||e.shiftKey||!e.deltaY){if(!t.disabled&&(!t._scrollView.hScrollBar.$.hasClass("smart-hidden")||e.shiftKey)){e.stopPropagation(),e.preventDefault();let o=160;const a=0===e.deltaX?e.wheelDelta:e.deltaX;a<0&&(o=-160),Math.abs(a)>=100&&!l&&!Smart.Utilities.Core.Browser.Firefox?t._mouseWheelNative(t._scrollView.scrollLeft+o,!0):t._scrollView.scrollLeft+=a}}else{const o=t.scrollTop;if(0===o&&e.deltaY<0||o===t.scrollHeight&&e.deltaY>0)return;e.stopPropagation(),e.preventDefault();let a=7*t.layout.rowMinHeight;if(e.deltaY<=0&&(a=-7*t.layout.rowMinHeight),Math.abs(e.deltaY)>=100&&!l&&!Smart.Utilities.Core.Browser.Firefox)t._mouseWheelNative(t._scrollView.scrollTop+a);else{t._wheelrafId=0;const o=()=>{t._scrollView.scrollTop+=e.deltaY};cancelAnimationFrame(t._wheelrafId),t._wheelrafId=0,t._wheelrafId=requestAnimationFrame(o)}}}_refresh(){const e=this;if(e._isUpdating)return;const t=e.$.verticalScrollBar.offsetWidth;e.removeAttribute("grouped"),e.removeAttribute("tree");let o=!0;e.__autoHeightRows&&(e.__autoHeightRows=null,e._refreshColumnsResponsiveVisibility(),e._recycle(),o=!1),e._groups||(e._groups=[]),e.grouping.enabled&&e.dataSource.groupBy&&e.dataSource.groupBy.length>=0&&("advanced"===e.grouping.renderMode?e.setAttribute("grouped",""):e.setAttribute("tree",""),e._groups||(e._groups=[].concat(e.dataSource.groupBy.toArray())||[]),e._renderGroupBar()),e.grouping.enabled&&e.dataSource.groupBy&&0===e.dataSource.groupBy.length?e.$.breadcrumb&&(e.$.breadcrumb.dataSource=[]):e.dataSource.boundHierarchy&&(e.setAttribute("tree",""),e.setAttribute("role","treegrid")),(e.isInitialized||o)&&e._refreshColumnsResponsiveVisibility(),e._refreshLayout(),t!==e.$.verticalScrollBar.offsetWidth&&(e.__scrollWidth=null,e._refreshColumnsResponsiveVisibility(),e._refreshScrollBars(),0===e.$.verticalScrollBar.offsetWidth&&e.isRendered&&requestAnimationFrame((()=>{e._refreshScrollBars()}))),e._refreshSelection(),e._recycle(),e._refreshHeaderBar(),e._recyclingRows&&0===e._recyclingRows.length&&(e.$.placeholder.classList.remove("smart-hidden"),e.scrollHeight=0,e.$.placeholder.innerHTML=e.appearance.placeholder,e.filtering.filterRow.visible&&(e.$.placeholder.style.top="0px",e.$.placeholder.style.position="relative",e._filters&&e._filters.length&&(e.$.placeholder.style.top="12px")),e._filters&&e._filters.length&&(e.$.placeholder.innerHTML=`<span class="smart-grid-icon show smart-icon-filter" style="\n font-size: calc(2 * var(--smart-font-size));\n cursor: default;\n margin-right: 10px;\n "></span>${e.localize("filteredRecords")}`)),requestAnimationFrame((()=>{e._width=e.offsetWidth,e._height=e.offsetHeight}))}_refreshHeaderBar(){const e=this;e.$.headerBar&&e.header.visible&&e.$.headerBar._refresh()}_resizeHandler(e){const t=this;if((t.enableShadowDOM?e.composedPath()[0]:e.target)===t&&!t._isUpdatingScrollBars){if(!t.isInitialized)return void t._render();if(!1===t._resizeHandling||!t.offsetHeight)return void(!1===t._resizeHandling&&(t.layout.isDirty=!0));t._isUpdatingScrollBars=!0,t._autoHeight=!1,t.$.content&&t.$.content.classList.remove("auto-height");const e=t._rowElements?t._rowElements.length*t.layout.rowMinHeight:0;(e>0||"grid"!==t.view&&"card"!==t.view)&&(t.offsetHeight>=e?(t._refreshLayout(),t._initializeRowElements()):"grid"!==t.view&&t._refreshLayout()),t.refresh(),t.$.headerBar&&t.$.headerBar.refreshTools(),t._dialogAddColumn&&t._dialogAddColumn.classList.contains("open")&&t._dialogAddColumn.refresh(),t._isUpdatingScrollBars=!1}}_refreshColumnsResponsiveVisibility(){const e=this,t=e.$.columnContainer,o=e.$.columnNearContainer,l=e.$.columnFarContainer;let a=0,n=0,i=0,r=!1;const s=e.columns.canNotify;e.columns.canNotify=!1;for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.setProperty("_treeColumn",!1,!1),e.grouping.enabled&&e.grouping.autoHideGroupColumn&&e.dataSource.groupBy&&e.dataSource.groupBy.indexOf(o.dataField)>=0&&o.setProperty("visible",!1,!1),o.visible&&!o.autoGenerated&&!r&&e.dataSource.boundHierarchy&&(o.setProperty("_treeColumn",!0,!1),r=!0)}e._refreshColumnWidths(),e.columns.canNotify=s;let d=0,u=0;for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.visible&&(o.freeze&&(!0===o.freeze||"near"===o.freeze?(a+=o.computedWidth,o.autoGenerated&&(d+=o.computedWidth)):"far"===o.freeze&&(n+=o.computedWidth,o.autoGenerated&&(u+=o.computedWidth))),i+=o.computedWidth)}t.style.width=i+"px",o.style.width=a+"px",l.style.width=n+"px",l.classList.remove("smart-hidden"),o.classList.remove("smart-hidden"),0===n&&l.classList.add("smart-hidden"),0===a&&o.classList.add("smart-hidden"),l.classList.remove("border-collapse"),n===u&&l.classList.add("border-collapse"),e._autoGeneratedColumnsNearWidth=d,e._autoGeneratedColumnsFarWidth=u,e._computedColumnsWidth=i,e._frozenColumnsNearWidth=a,e._frozenColumnsFarWidth=n}_selectStartHandler(e){const t=this;t.isScrolling||t.editing.isEditing||"grid"!==t.view||t.selection.defaultSelection||e.preventDefault()}setFocusable(e){const t=this;!t.disabled&&e?t.tabIndex=0:t.removeAttribute("tabindex")}_setLoadingIndicatorVisibility(){const e=this;e.appearance.displayLoadingIndicator?e.$.loadingIndicatorContainer.classList.remove("smart-visibility-hidden"):e.$.loadingIndicatorContainer.classList.add("smart-visibility-hidden")}_refreshElementsVisibility(){const e=this,t=function(e,t){e&&(t?e.classList.remove("smart-hidden"):e.classList.add("smart-hidden"))};if(t(e.$.placeholder,!e.rows||e.rows&&0===e.rows.length||0===e.columns.length),t(e.$.footer,e.footer.visible),t(e.$.header,e.header.visible),t(e.$.groupHeader,e.groupHeader.visible||e.grouping.groupBar.visible),t(e.$.columnHeader,e.columnHeader.visible&&e.columns.length>0),t(e.$.headerCommandBar,e.editing.commandBar.visible&&"far"!==e.editing.commandBar.position),t(e.$.footerCommandBar,e.editing.commandBar.visible&&"near"!==e.editing.commandBar.position),t(e.$.breadcrumb,e.groupHeader.visible||e.grouping.groupBar.visible),e.htmlColumnLastChild.classList.add("smart-visibility-hidden"),e.pager&&e.pager.visible&&e.paging.enabled)switch(e.pager.position){case"near":t(e.$.headerPager,!0),t(e.$.footerPager,!1);break;case"far":t(e.$.headerPager,!1),t(e.$.footerPager,!0);break;case"both":t(e.$.headerPager,!0),t(e.$.footerPager,!0)}else t(e.$.footerPager,!1),t(e.$.headerPager,!1)}_getId(){const e=this;return e.dataSource&&e.dataSource.id?e.dataSource.id:e.dataSourceSettings.id?e.dataSourceSettings.id:void 0}_refreshRowHierarchy(e,t=!1){const o=this;o.rowHierarchy=null;let l=0,a=!1;if(!o.grouping.enabled&&o.dataSource.groupBy&&o.dataSource.groupBy.length>0&&(a=!0),o.grouping.enabled&&o.dataSource.groupBy&&0===o.dataSource.groupBy.length)return;let n=!1;if(o.grouping.enabled&&o.dataSource.groupBy&&o.dataSource.groupBy.length>0&&o.dataSource.virtualDataSourceOnExpand&&(n=!0),o.dataSource.boundHierarchy){const i=o.dataSource.reservedNames,r=function(e){return new Smart.Grid.Row({data:e,grid:o,index:o.rows.length})};let s=0;const d=function(t,l){for(let u=0;u<t.length;u++){const c=t[u];let m=o.rowById[c.$.id];if(n&&(m=o.rows[s],m||(m=r(c),o.rows.push(m)),c[i.leaf]?m.id=c.$.id:m.id="Group_"+c.$.id,o.rowById[m.id]=m),m||(m=r(c),o.rowById[m.id]=m),m.data=c,m.leaf=c[i.leaf]||!1,m.level=c[i.level],m.groupDataField=c.groupDataField,!m.groupDataField&&o.appearance.showTreeRowHeader&&(m.groupDataField=o.columns[m.level].dataField),m.label=c.label,m.groupDataField){const e=o.columnByDataField[m.groupDataField];if(e&&e.editor.dataSource)for(let t=0;t<e.editor.dataSource.length;t++){const o=e.editor.dataSource[t];if(""+o.value===m.label){void 0!==o.label?(m.label=o.label,m.labelValue=o.value):void 0!==o.name&&(m.label=o.name,m.labelValue=o.value);break}}}if(m.children=[],m.data&&(m.filtered=void 0===m.data.$.filtered||m.data.$.filtered),c.summaryRow&&(m.summaryRow=!0),(null===o._toggledRow||o._toggledRow&&o._toggledRow.id!==m.id)&&(m.expandHeight=0),c.parent?(m.parent=o.rowById[c.parent.$.id],m.parentId=c.parent.$.id):(m.parent=null,m.parentId=null),o.grouping.onGroupDefaultExpanded&&!o.isRendered){const e=o.grouping.onGroupDefaultExpanded(c);e&&(m.expanded=c[i.expanded]=e)}o.appearance.allowRowToggleAnimation||void 0!==c[i.expanded]&&(m.expanded=c[i.expanded]);let g=!!e||m.expanded;a&&(g=!0);const p=o.dataSource&&o.dataSource.id||o.dataSourceSettings.id;if(p&&!m.data[p]&&o.grouping.enabled&&o.dataSource&&o.dataSource.groupBy.length){const e=o.dataSource.groupBy[m.level];c.parent&&c.parent.expanded&&(""===m.data[e]&&o.dataSource.id&&!m.data.data[o.dataSource.id]||m.leaf&&!m.data[p])&&(s++,m.filtered=!1)}if(!0===m.visible&&!1!==m.filtered)if(s++,g||c[i.leaf])if(l.push(m),c.children&&c.children.length>0){const e=d(c.children,new Array);0===e.length&&(m.leaf=!0);for(let t=0;t<e.length;t++)l.push(e[t]);m.children=e}else c.children&&0===c.children.length&&(o.dataSource.virtualDataSource&&o.dataSource.virtualDataSourceOnExpand?m.data._loaded&&(m.leaf=!0):m.leaf=!0);else if(l.push(m),c.children&&c.children.length>0){const e=d(c.children,new Array);0===e.length&&(m.leaf=!0),m.children=e}else c.children&&0===c.children.length&&(o.dataSource.virtualDataSource&&o.dataSource.virtualDataSourceOnExpand?m.data._loaded&&(m.leaf=!0):m.leaf=!0)}return l};let u=o.dataSource.boundHierarchy;if(o.paging.enabled&&!t){let e=[];const t=e=>{let l=[];if(0===o.dataSource.groupBy.length)return e;for(let o=0;o<e.length;o++){const a=e[o];(!a.$||void 0===a.$.filtered||a.$.filtered)&&(l.push(a),a.children&&(l=l.concat(t(a.children))))}return l};if(o.dataSource&&!o.dataSource.virtualDataSource){for(let o=0;o<u.length;o++){let l=u[o],a=!l.$||void 0===l.$.filtered||l.$.filtered;!a&&null!==a||0!==l.level||l.parent||(t(l.children).length,e.push(l))}u=e.slice(o.paging.pageIndex*o._pageSize,(o.paging.pageIndex+1)*o._pageSize)}}const c=o.rows.canNotify;o.rows.canNotify=!1,o.rowHierarchy=d(u,new Array),o.rows.canNotify=c;let m=[];for(let e=0;e<o.rowHierarchy.length;e++){const t=o.rowHierarchy[e],a=t.canNotify;t.leaf&&m.push(t),t.canNotify=!1,o.grouping.enabled&&o.dataSource&&o.dataSource.groupBy.length?t.leaf?t.visibleIndex=l++:t.visibleIndex=-1:t.visibleIndex=l++,t.canNotify=a}if(a&&(o.rowHierarchy=m),o._rowElements.length<o.rowHierarchy.length&&!o._toggledRow&&o._initializeRowElements(),o.grouping.summaryRow.visible&&!o.grouping.summaryRow.inline){const e=function(t,o,l,a){if(0!==t&&o.length>0&&o[o.length-1]&&!o[o.length-1].summaryRow){let e={label:" ",boundSource:[],groupDataField:l.data.groupDataField,$:{},summaryRow:!0,leaf:!0,level:t,expandHeight:0,siblings:o};e.$.id="SubRow"+a+"_"+l.data.$.id,l&&(e.parent=l.data,e.parentId=l.data.$.id),e.data=Object.assign(e),o.push(e)}for(let t=0;t<o.length;t++)o[t]&&o[t].data&&o[t].data.children&&e(o[t].level+1,o[t].data.children,o[t],t)};e(0,o.rowHierarchy,null,0)}}}applyContent(){}_refreshContentHeight(){const e=this;let t=e._clientSize.height;const o=window.scrollY;let l,a,n=!1;if((!e._contentHeight||e._maxHeight||e._autoHeight||e.__autoHeight||"hidden"===e.verticalScrollBarVisibility)&&(n=!0),n&&(l=e.offsetHeight,e.$.container.classList.add("smart-hidden"),a=e.offsetHeight,e.$.container.classList.remove("smart-hidden")),window.scrollY!==o&&window.scrollTo(window.scrollX,o),"hidden"===e.verticalScrollBarVisibility||e.layout.autoHeight||l!==a||e._minHeight&&e._minHeight===l)return t=e._scrollHeight+e.$.columnHeader.offsetHeight+e.$.filterFooter.offsetHeight,e.header.visible&&(t+=e.$.header.offsetHeight),e.summaryRow.visible&&(t+=e.layout.rowMinHeight),0===e._recyclingRows.length&&0===e._scrollHeight&&(t+=e.$.scrollView.offsetTop),e._minHeight>t&&(t=e._minHeight),e.$.content.style.height=t+"px",e._contentHeight=t,void(e._maxHeight<t?(e._autoHeight=!1,e.$.content.classList.remove("auto-height"),e.$.content.style.height=e._maxHeight+"px",e.header.visible?(e.$.content.style.height=e._maxHeight-e.$.header.offsetHeight+"px",e._contentHeight=e._maxHeight-e.$.header.offsetHeight):e._contentHeight=e._maxHeight):(e._autoHeight=!0,e.__autoHeight=!0,e.$.content.classList.add("auto-height"),e.filtering.filterRow.visible&&(e.filtering.filterRow.visible&&(t+=e.layout.rowMinHeight),e._contentHeight=t,e.$.content.style.height=e._contentHeight+"px"),e.header.visible?(e._contentHeight=t-e.$.header.offsetHeight,e.$.content.style.height=e._contentHeight+"px"):e.summaryRow.visible&&(e.$.content.style.height=e._contentHeight+"px")));if(e.header.visible&&(t-=e.$.header.offsetHeight),(e.groupHeader.visible||e.grouping.groupBar.visible)&&(t-=e.$.groupHeader.offsetHeight),e.footer.visible&&(t-=e.$.footer.offsetHeight),e.pager.visible&&(t-=e.$.headerPager.offsetHeight,t-=e.$.footerPager.offsetHeight),e.editing.enabled&&e.editing.commandBar.visible&&(t-=e.$.headerCommandBar.offsetHeight,t-=e.$.footerCommandBar.offsetHeight),e.$.content.style.height!==t+"px"&&(e.$.content.style.height=t+"px"),e.$.viewContent.style.height!==t+"px"&&(e.$.viewContent.style.height=t+"px"),e._contentHeight=t,e.appearance.showViewBar){const o=e.layout.viewBarWidth+5;e.$.viewBar.classList.remove("smart-hidden"),e._mobile||(e.$.content.style.width="calc(100% - "+o+"px)",e.$.viewContent.style.width="calc(100% - "+o+"px)",e.$.content.style.marginLeft=o+"px",e.$.viewContent.style.marginLeft=o+"px"),e.$.viewBar.style.width=o+"px";let l=0;e.header.visible&&(l+=e.$.header.offsetHeight),(e.groupHeader.visible||e.grouping.groupBar.visible)&&(l+=e.$.groupHeader.offsetHeight),e.pager.visible&&(l+=e.$.headerPager.offsetHeight),e.$.viewBar.style.top=l+"px",e.$.viewBar.style.height=t+"px"}else e.$.viewBar.classList.add("smart-hidden"),e.$.content.style.width="",e.$.viewContent.style.width="",e.$.content.style.marginLeft="",e.$.viewContent.style.marginLeft=""}appendChild(){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(this,e.concat(Array.prototype.slice.call(arguments)))}removeChild(){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(this,e.concat(Array.prototype.slice.call(arguments)))}get _contentBorder(){const e=this;if(e.__contentBorder)return e.__contentBorder;const t=getComputedStyle(e.$.content),o={left:parseFloat(t.borderLeftWidth)+parseFloat(t.borderRightWidth),top:parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth)};return e.__contentBorder=o,o}_refreshAutoSize(){const e=this;if(e.layout.autoWidth){const t=e._isUpdatingScrollBars;e._isUpdatingScrollBars=!0;let o=2;for(let t=0;t<e.viewColumns.length;t++){const l=e.viewColumns[t];l.visible&&(o+=l.computedWidth)}o+=e.$.verticalScrollBar.offsetWidth>0?e.$.verticalScrollBar.offsetWidth:0,e.style.width=o+"px",requestAnimationFrame((()=>{e._isUpdatingScrollBars=t}))}e.layout.autoHeight&&(e.style.height="auto")}_refreshLayout(){const e=this,t=e.rows;if(e._layoutSuspended)return;e._visibleRows=null,e.__viewRows=null,e.__clientSize=null,e.__scrollHeight=null,e.__scrollWidth=null,e.__parentCells=null,e.$.columnFarContainer.classList.remove("vscroll"),e.$.columnNearContainer.classList.remove("vscroll"),e.$.scrollView.classList.remove("hscroll"),e.$.scrollView.classList.remove("vscroll"),e._refreshAutoSize(),e._refreshElementsVisibility(),e._refreshRowHierarchy(),e._refreshColumnHeights(),e._refreshContentHeight();const o=()=>{e.$.placeholder.classList.remove("smart-hidden"),e.$.placeholder.innerHTML=e.appearance.placeholder,e._filters&&e._filters.length&&(e.$.placeholder.innerHTML=e.localize("filteredRecords")),e.__filterFooterOffsetHeight||(e.__filterFooterOffsetHeight=e.$.filterFooter.classList.contains("smart-hidden")?0:e.$.filterFooter.offsetHeight),!e.__columnHeaderHeight&&e.$.columnHeader.offsetHeight&&(e.__columnHeaderHeight=e.$.columnHeader.offsetHeight);let t=e._contentHeight-e.__filterFooterOffsetHeight-e.__columnHeaderHeight;e.$.scrollView.style.height=t+"px",e.scrollWidth=0,e.scrollHeight=0,e.clearSelection(),e._showAddNewRowButton("float"),e.$.content.classList.contains("auto-height")&&(e.$.placeholder.style.height=t+"px")};if(t&&t.url)e._showAddNewRowButton("float");else{if(!t||null===t||0===t.length||0===e.columns.length)return o(),0!==e.columns.length&&e.hasVisibleColumn()?e.editing.addNewColumn._addButton&&e.editing.addNewColumn._addButton.classList.remove("show"):(e._showAddNewColumnButton(),e.$.columnHeader.classList.add("smart-hidden"),e.__columnHeaderHeight=0),void e._refreshScrollBars();e._showAddNewRowButton("float"),e.editing.addNewColumn._addButton&&e.editing.addNewColumn._addButton.classList.remove("show")}0!==e.columns.length&&e.hasVisibleColumn()?e.editing.addNewColumn._addButton&&e.editing.addNewColumn._addButton.classList.remove("show"):(o(),0!==e.columns.length&&e.hasVisibleColumn()||(e._showAddNewColumnButton(),e.$.columnHeader.classList.add("smart-hidden"),e.__columnHeaderHeight=0),e._showAddNewColumnButton()),"card"===e.view&&(e.__columnHeaderHeight=0),!e.__columnHeaderHeight&&e.$.columnHeader.offsetHeight&&(e.__columnHeaderHeight=e.$.columnHeader.offsetHeight),e.__filterFooterOffsetHeight||(e.__filterFooterOffsetHeight=e.$.filterFooter.classList.contains("smart-hidden")?0:e.$.filterFooter.offsetHeight);let l=e._contentHeight-e.__filterFooterOffsetHeight-e.__columnHeaderHeight;if(e.$.scrollView.style.height=l+"px",e.htmlColumnLastChild.style.height=e.__columnHeaderHeight+"px",e.paging.spinner.enabled&&e.paging.enabled){if(!e.pageScroll){const t=document.createElement("smart-scroll-bar");t.orientation="vertical",t.style.height="100%",t.style.width="100%",t.max=Math.ceil(e.dataSource.length/e._pageSize),t.step=e.paging.spinner.step,t.largeStep=e.paging.spinner.step,t.setAttribute("spinner",""),t.setAttribute("smart-id","spinner"),t.ownerElement=e,e.addPropertyBinding("[[paging_spinner_step]]","step",t,e.$.columnHeader),t.addEventListener("change",(function(t){e.paging.pageIndex=t.detail.value,e._refreshLayout(),e._refreshSelection(),e.dataSource&&e.dataSource.virtualDataSource?e._virtualDataRequest("pageIndexChange"):(e._recycle(),e._scrollUpdate&&clearTimeout(e._scrollUpdate),e._scrollUpdate=setTimeout((function(){e.isScrolling||(e.$.rowContainer.style.top=parseInt(e.$.rowContainer.style.top)+.01+"px")}),50))})),e.pageScroll=t}e.htmlColumnLastChild.appendChild(e.pageScroll)}else e.htmlColumnLastChild.innerHTML="";e._refreshScrollBars()}_refreshScrollBars(){const e=this;if(!e._scrollView)return;const t=e._scrollView.vScrollBar,o=e._scrollView.hScrollBar,l=e._contentHeight-e.__filterFooterOffsetHeight-e.__columnHeaderHeight,a=e.$.scrollView.offsetWidth,n=e._scrollWidth-a-e._contentBorder.left,i=e._scrollHeight-l-e._contentBorder.top,r=e._columnNearContainerComputedStyle?e._columnNearContainerComputedStyle:getComputedStyle(e.$.columnNearContainer),s=e._columnFarContainerComputedStyle?e._columnFarContainerComputedStyle:getComputedStyle(e.$.columnFarContainer),d=parseInt(e.$.columnNearContainer.style.width)+parseInt(r.borderRightWidth),u=parseInt(e.$.columnFarContainer.style.width)+parseInt(s.borderLeftWidth);if(e.__frozenNearWidth=d,e.__frozenFarWidth=u,e._columnNearContainerComputedStyle=r,e._columnFarContainerComputedStyle=s,e._refreshHorizontalScrollBarVisibility(n),e._refreshVerticalScrollBarVisibility(i),t.style.height=l+"px",e.computedVerticalScrollBarVisibility?(e.__scrollBarSize||(e.__scrollBarSize=t.offsetWidth),e.__scrollWidth+=e.__scrollBarSize,e._refreshHorizontalScrollBarVisibility(e._scrollWidth-a-1),e.rightToLeft?e.$.columnNearContainer.classList.add("vscroll"):e.$.columnFarContainer.classList.add("vscroll"),e._refreshVerticalScrollBarVisibility(i),e.htmlColumnLastChild.classList.remove("smart-visibility-hidden"),e.$.scrollView.classList.add("has-vscroll")):e.$.scrollView.classList.remove("has-vscroll"),o.style.width=a+"px",e.rightToLeft?o.style.right="0px":o.style.left="0px",e.computedVerticalScrollBarVisibility&&e.computedHorizontalScrollBarVisibility&&(o.style.width=a-t.offsetWidth+"px",t.style.height=l-o.offsetHeight+"px"),e.computedHorizontalScrollBarVisibility?(e.$.scrollView.classList.add("hscroll"),e._autoHeight?(e.$.content.style.height="auto",e.$.scrollView.style.height="auto",e.$.scrollView.style.paddingBottom=o.offsetHeight+"px",e.$.placeholder.style.marginTop=o.offsetHeight+"px",e.summaryRow.visible&&(e.$.scrollView.style.paddingBottom=o.offsetHeight+e.layout.rowMinHeight+"px"),e.filtering.enabled&&e.filtering.filterRow.visible&&(e.$.scrollView.style.paddingBottom=o.offsetHeight+e.layout.rowMinHeight+"px")):(e.$.scrollView.style.paddingBottom="",e.$.placeholder.style.marginTop="")):e.$.scrollView.classList.remove("hscroll"),(e.__frozenNearHeight>0||e._frozenNearRows&&e._frozenNearRows.length>0)&&!e.appearance.showVerticalScrollBarOnFixedColumns){const o=getComputedStyle(e.$.rowNearContainer),l=e.__frozenNearHeight+parseInt(o.borderBottomWidth);t.style.height=parseInt(t.style.height)-l+"px",t.style.top=l+"px",t.style.setProperty("--smart-scroll-bar-near-size",l+"px")}else e.appearance.showVerticalScrollBarOnFixedColumns&&(t.style.top="0px");if((e.__frozenFarHeight>0||e._frozenFarRows&&e._frozenFarRows.length>0)&&!e.appearance.showVerticalScrollBarOnFixedColumns){const o=getComputedStyle(e.$.rowFarContainer),l=-2+e.__frozenFarHeight+parseInt(o.borderTopWidth);t.style.height=parseInt(t.style.height)-l+"px",t.style.setProperty("--smart-scroll-bar-far-size",l+"px"),0===e.__frozenNearHeight&&(t.style.top="0px")}(d>0||u>0)&&!e.appearance.showHorizontalScrollBarOnFixedColumns&&(o.style.width=parseInt(o.style.width)-d-u+"px",e.rightToLeft?o.style.right=d+"px":o.style.left=d+"px",o.style.setProperty("--smart-scroll-bar-near-size",d+parseInt(r.borderRightWidth)+"px"),o.style.setProperty("--smart-scroll-bar-far-size",u+parseInt(r.borderLeftWidth)+"px"),e.computedVerticalScrollBarVisibility&&(e.__scrollBarSize||(e.__scrollBarSize=t.offsetWidth),o.style.setProperty("--smart-scroll-bar-far-size",u+e.__scrollBarSize+"px"))),t.refresh(),o.refresh(),e._mobile&&(e._scrollContentView.style.width=e.$.scrollView.offsetWidth+e._scrollView.scrollWidth+"px",e._scrollContentView.style.height=e.$.scrollView.offsetHeight+e._scrollView.scrollHeight+"px")}_refreshHorizontalScrollBarVisibility(e){const t=this;t.scrollWidth=e,t.computedHorizontalScrollBarVisibility||(t.scrollLeft=0)}_refreshVerticalScrollBarVisibility(e){const t=this;if(t._autoHeight)return t.scrollTop=0,void(t.scrollHeight=0);t.computedHorizontalScrollBarVisibility&&(e+=t.$.horizontalScrollBar.offsetHeight),t.scrollHeight=e,t.paging.enabled&&t.paging.spinner.visible&&t.$.verticalScrollBarVisibility.classList.remove("smart-hidden"),t.computedVerticalScrollBarVisibility||(t.scrollTop=0)}_styleChangedHandler(e){const t=this;if(!e.detail.styleProperties.overflow&&!t.classList.contains("smart-grid-resize-mode")){if(e.detail.styleProperties["grid-template-columns"])return t._templateColumns(),void t.refresh();if(e.detail.styleProperties["font-size"])return t.layout.isDirty=!0,t._resetCachedLayout(),void t.refresh();(e.detail.styleProperties["--smart-grid-row-height"]||e.detail.styleProperties["--smart-font-size"]||e.detail.styleProperties["--smart-grid-column-header-height"]||e.detail.styleProperties["--smart-grid-group-header-height"]||e.detail.styleProperties["--smart-grid-filter-footer-height"]||e.detail.styleProperties["--smart-grid-group-row-vertical"]||e.detail.styleProperties["--smart-grid-group-row-horizontal-offset"]||e.detail.styleProperties["--smart-grid-freeze-splitter-size"]||e.detail.styleProperties["--smart-grid-resize-line-size"]||e.detail.styleProperties["--smart-grid-footer-height"]||e.detail.styleProperties["--smart-grid-header-height"])&&(t.layout.isDirty=!0),t.offsetWidth&&t.offsetHeight>0&&(t._resetCachedLayout(),t._refreshLayout(),t._recycle())}}_resetCachedLayout(){const e=this;delete e._columnHeights,e.__cellsCommandTemplate=null,e.__autoRowHeight=null,e.__autoHeightRows=null,e.__measuredColumnHeight=null,e.__columnHeaderHeight=null,e.__filterFooterOffsetHeight=null}_swipeLeftHandler(){}_swipeRightHandler(){}_getRowIndexByPosition(e){const t=this;return(o=>{let l=0,a=o.length-1;if(e<=0)return 0;const n=o[o.length-1];if(-1!==n.top&&n.top<=e)return o.length-1;for(;;){const n=Math.floor((l+a)/2),i=o[n];if(t._isRowInPosition(i,e))return n;i.top<e?l=n+1:i.top>e?a=n-1:l=n+1}})(t._recyclingRows)}_getVirtualRowIndexByPosition(e){let t=this.rows[0].height;const o=(e,o)=>0!==t&&e<=o&&e+t>o;return(l=>{let a=0,n=l.length-1;if(e<=0)return 0;const i=(l.length-1)*t;if(-1!==i&&i<=e)return l.length-1;for(;;){const l=Math.floor((a+n)/2),i=l*t;if(o(i,e))return l;i<e?a=l+1:i>e?n=l-1:a=l+1}})(this.dataSource)}getRows(){return this.getViewRows()}getViewRows(){const e=this;return e.rowHierarchy?e.rowHierarchy:e.getVisibleRows()}getData(){const e=this;if(!e.dataSource)return[];const t=[];for(let o=0;o<e.dataSource.length;o++){const l=e.dataSource[o];if(l.$){const o={};for(let t=0;t<e.dataSource.dataFields.length;t++){const a=e.dataSource.dataFields[t].name;o[a]=l[a]}t.push(o)}else t.push(l)}return t}getDataFields(){const e=this;return e.columns?e.columns.map((e=>e.dataField)):[]}getColumns(){const e=this,t=[];if(!e.isInitialized)return t;if(e.columns)for(let o=0;o<e.columns.length;o++){const l=e.columns[o].getState();t.push(l)}return t}resetState(){const e=this;e._isUpdating=0,e.beginUpdate(),e.clearSort(),e.clearFilter(),e.clearGroups(),e.clearSelection(),e.columns.canNotify=!1;let t=[],o=!1;for(let l=0;l<e.columns.length;l++){const a=e.columns[l];a.visible=!0,a.width=180,a.freeze=!1,a.index>=0?t[a.index]=a:t.push(a),a.index!==l&&(o=!0)}o&&(e.columns=t),"grid"!==e.view&&(e.view="grid",e._hideKanbanView()),e.columns.canNotify=!0,e._scrollView.scrollLeft=e._scrollView.scrollTop=0,e.paging.enabled&&(e.paging.pageIndex=0),e.$.headerBar&&e.$.headerBar._setView&&e.$.headerBar._setView("grid"),e._kanban&&e._kanban._reset(),e.endUpdate(),o&&(e._renderColumns(),e._refreshHeaderBar())}_loadState(e){const t=this;let o=!1;t.stateSettings.loading=!0;let l=!1;if("grid"===t.view){if(e.expandedRows&&Object.keys(e.expandedRows).length>0){o=!0,t.beginUpdate();const l=[];if(e.groups){t.dataSource.groupBy=e.groups,t._groups=[].concat(t.dataSource.groupBy.toArray())||[],t._refreshRowHierarchy();for(let o in e.expandedRows)l["Item"+o.replaceAll(".","_")]=!0,t._expandCollapseGroup(o,!0)}t.dataSource&&(t.dataSource._expandedRowIds=l)}else if(e.groups&&e.groups.length){o=!0,t.beginUpdate();const l=[];t.dataSource&&(t.dataSource._expandedRowIds=l),e.groups&&(t.dataSource.groupBy=e.groups,t._refreshRowHierarchy())}else if(e.groups&&0===e.groups.length&&t.dataSource.groupBy.length>0){o=!0,t.beginUpdate();const e=[];t.dataSource&&(t.dataSource._expandedRowIds=e),t.dataSource.groupBy=[],t._refreshRowHierarchy(),l=!0}if(e.paging&&t.paging.enabled&&(t.paging.index=e.paging.index,t.paging.size=e.paging.size),e.columns&&e.columns.length>0){o||(o=!0,t.beginUpdate());for(let o=0;o<e.columns.length;o++){const l=e.columns[o];if(l.dataField){const e=t.columnByDataField[l.dataField];if(e){const t=e.canNotify;e.canNotify=!1,l.width?e.width=l.width:e.width=180,e.visible=void 0===l.visible||l.visible,e._state&&(e._state.visible=void 0===l.visible||l.visible,e._state.freeze=void 0!==l.freeze&&l.freeze,e._state.width=l.width?l.width:180),e.freeze=void 0!==l.freeze&&l.freeze,e.canNotify=t}}}}}if(e.sort&&Object.keys(e.sort).length>0){o||(o=!0,t.beginUpdate());const l=t.appearance.allowSortAnimation;t.appearance.allowSortAnimation=!1;let a=t.columns.canNotify;t.columns.canNotify=!1;for(let e=0;e<t.columns.length;e++)t.columns[e].sortOrder="";t.columns.canNotify=a;for(let o in e.sort)if(e.sort[o]){const l=e.sort[o].sortOrder,a=t.columnByDataField[o];t.sortBy(a.dataField,l)}t.appearance.allowSortAnimation=l}if(e.filter&&Object.keys(e.filter).length>0){o||(o=!0,t.beginUpdate());for(let o in e.filter){const l=e.filter[o];if(l){t.addFilter(o,l,!1);const e=t.columnByDataField[o];e&&e._filterInfo&&e.filter&&e.filter.filters&&e.filter.filters[0]&&(e._filterInfo.value=e.filter.filters[0].value,e._filterInfo.condition=e.filter.filters[0].condition)}}if(t.filtering.filterRow)for(let e=0;e<t.columns.length;e++)t.columns[e]._filterEditorInitialized&&(t.columns[e]._filterEditorInitialized=!1)}if(o){t.endUpdate(!1,!1);let o=!1;e.view&&"kanban"===e.view&&(o=!0),o||(l?t.refresh(!0):t._refresh())}let a=!1;e.kanban&&e.kanban.stackedBy&&(void 0===t._stackedBy&&(t._stackedBy=e.kanban.stackedBy),t._stackedBy!==e.kanban.stackedBy&&(a=!0),t._stackedBy=e.kanban.stackedBy),(a||e.view&&t.view!==e.view)&&t.$.headerBar&&t.$.headerBar._setView&&t.$.headerBar._setView(e.view,!0),e.filter&&Object.keys(e.filter).length>0&&t.refreshFilters(),e.name&&(t.stateSettings.current=e.name),t.stateSettings.loading=!1}loadState(e){const t=this;if(e){if(t.stateSettings.loading=!0,t._isUpdating=0,t.beginUpdate(),t.clearSort(),t.clearFilter(),t.clearGroups(),t.clearSelection(),t._scrollView.scrollLeft=t._scrollView.scrollTop=0,t.paging.enabled&&(t.paging.pageIndex=0),t.endUpdate(!1,!1),"string"==typeof e){const o=t.stateSettings.storage[e];o&&t._loadState(o)}else t._loadState(e);t.stateSettings.loading=!1}else if(!t.stateSettings.autoSave){let e=t.getCurrentState();e&&t.loadState(e)}}saveState(e,t){const o=this;let l=o.getCurrentState(),a=t;!t&&o.stateSettings.options.length&&(t=o.stateSettings.options);const n=o.getState(t);let i;if(e?(i=e,o.stateSettings.current||(o.stateSettings.current=e)):i=o.stateSettings.current?o.stateSettings.current:o.stateSettings.current="View 1",l&&a)for(let e in a)l[a[e]]=n[a[e]];else l=n;function r(e,t=0,o=10){if(t>o)return"Object";const l={};if(e&&e instanceof Smart.FilterGroup)return e=e.toString();for(let a in e){let n=e[a];if(n instanceof Node)n={id:n.id};else if(n instanceof Window)n="Window";else if(n instanceof Date)n=n.toJSON();else{if(n&&Array.isArray(n)&&void 0!==n[0]&&("string"==typeof n[0]||"number"==typeof n[0]||n[0]instanceof Date||"boolean"==typeof n[0])){l[a]=n;continue}if(n&&Array.isArray(n)&&0===n.length){l[a]=n;continue}if(n&&n&&Array.isArray(n)&&void 0!==n[0]&&"object"==typeof n[0]&&"path"!==a&&!(n[0]instanceof HTMLElement))for(let e=0;e<n.length;e++)n[e]=r(n[e],t+1,o);else n instanceof Object&&(n=r(n,t+1,o))}l[a]=n}return t?l:JSON.stringify(l)}l.name=i,o.stringify_object=r;const s=r(l);return o.stateSettings.allowLocalStorage&&window.localStorage.setItem(i,s),o.stateSettings.storage||(o.stateSettings.storage={}),o.stateSettings.storage[o.stateSettings.current]&&!l.date&&o.stateSettings.storage[o.stateSettings.current].date?l.date=o.stateSettings.storage[o.stateSettings.current].date:l.date=(new Date).toJSON(),o.stateSettings.storage[o.stateSettings.current]=l,o.stateSettings.onStateChange&&(o._isUpdating<=0||void 0===this._isUpdating)&&o.isCompleted&&o.stateSettings.onStateChange(l,i,o.stateSettings.storage,r),l}autoSaveState(){const e=this;if(!e.stateSettings.current&&e.stateSettings.autoSave&&!e.stateSettings.loading){const t=e.stateSettings.storage;(t&&0===Object.keys(t).length||!t)&&(e.stateSettings.current=e.localize("view")+" 1")}e.stateSettings.autoSave&&e.stateSettings.current&&!e.stateSettings.loading&&e.saveState()}getCurrentState(){const e=this,t=e.stateSettings.current;return e.stateSettings.storage||(e.stateSettings.storage={}),e.stateSettings.storage[t]?e.stateSettings.storage[t]:null}getState(e){const t=this;if(e&&!e.includes)return;const o=!e||e&&e.includes("sort")?t.getSortedColumns():null,l=!e||e&&e.includes("filter")?t.getFilteredColumns():null,a=!e||e&&e.includes("groups")?t.getGroups():null,n=!e||e&&e.includes("selection")?t.getSelectedCells():null,i=!e||e&&e.includes("selection")?t.getSelectedRows():null,r=!e||e&&e.includes("pager")?t.$.headerPager.querySelector("smart-pager"):null;let s=0;r&&(s=r.pagesCount);const d={sort:o,filter:l,groups:a,paging:{count:s,index:t.paging.pageIndex,size:t._pageSize},selectedCells:n,selectedRows:i};t.header.visible&&t.header.buttons.indexOf("views")>=0&&(d.kanban=t.getKanbanState(),d.view=t.view);const u=[];if(!e||e&&e.includes("columns")){for(let e=0;e<t.columns.length;e++){const o=t.columns[e];u.push({dataField:o.dataField,width:o.computedWidth,visible:o.visible,freeze:o.freeze})}d.columns=u}if((!e||e&&e.includes("expandedRows"))&&t.dataSource&&t.dataSource._expandedRowIds){let e={};for(let o in t.dataSource._expandedRowIds){let t=""+o;t=t.replace("Item","").replace(/_/gi,"."),e[t]=!0}d.expandedRows=e}if(e){const t={};for(let o in e){const l=e[o];d[l]&&(t[l]=d[l])}return t}return d}get _pageSize(){const e=this;return e.dataSource&&e.grouping.enabled&&e.dataSource.groupBy.length>0?e.paging.pageHierarchySize:e.paging.pageSize}get _recyclingRows(){const e=this;if(e.rowHierarchy)return e.rowHierarchy;let t=e.getVisibleRows();if(e.paging.enabled)if(e.dataSource.virtualDataSource)t=t.slice(0,e._pageSize);else if(t=t.slice(e.paging.pageIndex*e._pageSize,(e.paging.pageIndex+1)*e._pageSize),e.editing.addNewRow&&e.editing.addNewRow.visible&&"button"!==e.editing.addNewRow.displayMode){let t=e.getVisibleRows();return t=0===e.paging.pageIndex&&"far"!==e.editing.addNewRow.position?t.slice(1+e.paging.pageIndex*e._pageSize,1+(e.paging.pageIndex+1)*e._pageSize):0===e.paging.pageIndex&&"far"===e.editing.addNewRow.position?t.slice(e.paging.pageIndex*e._pageSize,1+(e.paging.pageIndex+1)*e._pageSize):t.slice(1+e.paging.pageIndex*e._pageSize,1+(e.paging.pageIndex+1)*e._pageSize),[].concat(e._frozenNearDefaultRows,t,e._frozenFarDefaultRows)}return t}_isRowInPosition(e,t){const o=e.top,l=e.top+e.height,a=o<=t&&l>t;return 0!==e.height&&a}_renderColumnGroupHeaders(){const e=this;for(let t=0;t<e._columnGroups.length;t++){const o=e._columnGroups[t];o.column.render(),o.column.allowReorder=!1,o.column.element.setAttribute("columnHeader",""),o.column.element.setAttribute("level",o.level),0===o.columns.length&&o.column.element.classList.add("smart-hidden"),0===t&&0===e.columns.indexOf(o.columns[0])&&o.column.element.classList.add("smart-grid-column-border-collapse")}}hasVisibleColumn(){const e=this;for(let t=e.viewColumns.length-1;t>=0;t--){const o=e.viewColumns[t];if(o.visible&&!o.autoGenerated)return!0}return!1}_isLastVisibleColumn(e){const t=this;for(let o=t.viewColumns.length-1;o>=0;o--){const l=t.viewColumns[o];if(l.visible)return l===e}return!1}_clearCachedTemplates(){const e=this;if(e._cachedTemplates&&Object.keys(e._cachedTemplates).length>0){e._tableCachedTemplates||(e._tableCachedTemplates=document.createElement("div"),e._tableCachedTemplates.style.display="none",document.body.appendChild(e._tableCachedTemplates));const t=document.createDocumentFragment();for(let o in e._cachedTemplates)t.appendChild(e._cachedTemplates[o]);e._tableCachedTemplates.appendChild(t)}}_recycle(e,t,o,l){const a=this;if(a._layoutSuspended||!1===a.isAttached)return;if(a._isUpdating)return;if(a.editing.isEditing&&(!0!==a._disableEndEdit&&a.endEdit(),a._isUpdating))return;a._recycleValues=void 0===o||o,a._removeCellContentPopup(),a._inputOverlay&&(a._inputOverlay.parentNode&&a._inputOverlay.parentNode.removeChild(a._inputOverlay),a._inputOverlay=null),a._selection.selectionRect&&a._refreshCellSelectionRect();const n=a._scrollView.scrollTop;let i,r=l||a._getRowIndexByPosition(n),s=a._recyclingRows,d=s[r],u=d?d.top:0,c=0,m=0,g=0,p=0;if(a._cellRowSpan&&a._cellRowSpan.maxSpan>0){let e=0;if(r>=5?e=5:r>=4?e=4:r>=3?e=3:r>=2?e=2:r>=1&&(e=1),e>0){const t=s[r-e];t&&(d=t,u=d?d.top:0,g=e*d.height,r-=e)}}a._cellRowSpan=[];for(let e=0;e<a._cellsMerge.length;e++){const t=a._cellsMerge[e],o=s.indexOf(t.row);if(r>o&&r<=o+t.rowSpan&&(r=o,d=t.row,g=Math.max(g,u-d.top),u=d.top,a.$.rowContainer.style.top=a.__frozenNearHeight-n+u+"px"),t.colSpan>1)for(let e=0;e<a.viewColumns.length;e++){const o=a.viewColumns[e];let l=o.autoGenerated?o:a.columnByDataField[o.dataField];if(l.visible&&l.left+l.computedWidth-a._scrollView.scrollLeft>=c&&l.left-l.computedWidth-a._scrollView.scrollLeft<a._clientSize.width){let e=a.columnByDataField[t.column.dataField];p=Math.max(p,l.left-e.left+l.computedWidth);break}}}a.isHScrolling&&a._clearCachedTemplates();let h=null;if(!1!==e||a._cellsMerge.length>0){if(a._columnElements)for(let e=0;e<a._columnElements.length;e++){const t=a._columnElements[e];if(!t.parentNode)break;t.set("column",null,!1),t.classList.add("smart-visibility-hidden")}for(let e=0;e<a._columnGroups.length;e++){const t=a._columnGroups[e],o=t.element;o&&(a.rightToLeft?o.style.right=t.right+"px":o.style.left=t.left+"px",o.style.width=t.computedWidth+"px")}a._firstVisibleColumn=null,a._lastVisibleColumn=null;for(let e=0;e<a.viewColumns.length;e++){let t=a.viewColumns[e];if(t.visible&&(a._firstVisibleColumn||(a._firstVisibleColumn=t),a._lastVisibleColumn=t),t.element&&(t===a._firstVisibleColumn||t.rowDetailColumn?t.element.classList.add("smart-grid-column-border-collapse"):t.element.classList.remove("smart-grid-column-border-collapse"),!1!==a.appearance.showColumnGroupCellLines&&!1!==a.appearance.showColumnGroupLines||(t.parent&&t.parent.columns&&t.parent.columns[0].dataField===t.dataField?t.element.setAttribute("column-group-first-child",""):t.parent&&t.element.removeAttribute("column-group-first-child")),t.element.removeAttribute("aria-colindex")),t.freeze){if(!0!==t.freeze&&"near"!==t.freeze||t.visible&&(c+=t.computedWidth),!t.element)continue;t.visible?(t.element.classList.remove("smart-visibility-hidden"),t.render()):t.element.classList.add("smart-visibility-hidden")}else if(t.visible&&t.left+t.computedWidth-a._scrollView.scrollLeft>=c-p&&t.left-t.computedWidth-a._scrollView.scrollLeft<a._clientSize.width){a._columnElements||(a._columnElements=[]);const o=a._columnElements[m++];o&&(o.set("column",t,!1),o.parentNode||a.$.columnContainer.appendChild(o),h||(h=t,a._firstRenderedColumn=t),t.element=o,t.render(),o.setAttribute("aria-colindex",e+1),void 0===i&&(i=t.left))}}}if(void 0===i&&(i=0),a.rightToLeft){const e=a._scrollView.scrollWidth-a._scrollView.scrollLeft-a._scrollView.vScrollBar.offsetWidth;a.$.columnContainer.style.right=e+"px",e<=0&&!a._scrollView.scrollWidth&&(a.$.columnContainer.style.right=-a.offsetWidth+a._computedColumnsWidth+"px")}else a.$.columnContainer.style.left=-a._scrollView.scrollLeft+"px";if(a.$.rowContainer.style.top=a.__frozenNearHeight-n+u+"px",a.isScrolling&&!a.isHScrolling&&(a._scrollUpdate&&clearTimeout(a._scrollUpdate),a._scrollUpdate=setTimeout((function(){a.isScrolling||(a.$.rowContainer.style.top=parseInt(a.$.rowContainer.style.top)+.01+"px")}),50)),!1===t)return;if(!a._rowElements)return;const f=a.dataSource&&a.dataSource.virtualDataSource&&!a.dataSource.virtualDataSourceOnExpand&&a.dataSource.length>a.virtualModeCachedRowsCount&&"infinite"!==a.scrolling;if(r>=0){m=0;let e=Math.max(a._clientSize.height,a._overflowOffset),t=0;f&&(a.rowById=[],a.rows&&a.rows.length>0&&void 0===a.rows[a.rows.length-1].top&&(a.rows[a.rows.length-1].top=(a.rows.length-1)*a.rows[0].height),a.rows&&a.rows.length>0&&(t=a._getVirtualRowIndexByPosition(n),u=t*a.rows[0].height,a.$.rowContainer.style.top=a.__frozenNearHeight-n+u+"px",a.paging.enabled||(r=0)),a.paging.enabled&&(t=a.paging.pageIndex*a._pageSize)),"card"===a.view&&a._cardHeight&&(e+=a._cardHeight);for(let o=r;o<s.length;o++){const l=s[o];if(0===l.height||!l.visible||!1===l.filtered||l.freeze&&l.visible)continue;const i=l.height;if(l.expandHeight&&(e+=a.offsetHeight+l.expandHeight),!(u+i>=n-g&&u<=n+e||a._autoHeight))break;{const e=a._rowElements[m++];if(!e)break;if(e.setAttribute("aria-rowindex",t+o+1),l.element=e,l.grid=a,f){if(l.index=o+t,l.visibleIndex=o+t,a.selection.enabled&&a._selection){const e=a._selection.indexes,t=l.canNotify;l.canNotify=!1,l.selected=e.indexOf(l.index)>=0,l.canNotify=t}a.paging.enabled?(l.data=a.dataSource[r+m-1],l.data&&(l.id=l.data.$.id,a.rowById[l.id]=l)):(l.data=a.dataSource[m-1],l.data&&(l.id=l.data.$.id,a.rowById[l.id]=l))}l.render()}u+=i}}a._renderFrozenRows();let y=m;if(m<a._rowElements.length)for(let e=m;e<a._rowElements.length;e++){const e=a._rowElements[m++];e.classList.add("smart-hidden"),e.removeAttribute("aria-rowindex")}a.editing.addNewRow&&a.editing.addNewRow.visible&&"button"===a.editing.addNewRow.displayMode&&a._rowElements[y]&&(a._newRow||(a._newRow=new Smart.Grid.Row({data:{},index:9999999,grid:a,addNewRow:!0,inline:!0,autoGenerated:!0})),a._newRow.element=a._rowElements[y],a._newRow.element.classList.remove("smart-hidden"),a._newRow.render()),f&&a._selection.selectionRect&&a._refreshCellSelectionRect()}_renderFrozenRows(){const e=this;let t=!1,o=!1;if("card"===e.view)return e.$.rowNearContainer.classList.add("smart-hidden"),void e.$.rowFarContainer.classList.add("smart-hidden");0===e._frozenNearRows.length?e.$.rowNearContainer.classList.add("smart-hidden"):e.$.rowNearContainer.classList.remove("smart-hidden");for(let o=0;o<e._frozenNearRows.length;o++){const l=e._frozenNearRows[o];l.visible||(l.element=e.$.rowNearContainer.children[o],l.element||(l.element=l.createElement(),e.$.rowNearContainer.appendChild(l.element)),l.element.classList.add("smart-hidden")),l.visible&&l.filtered&&(t=!0,l.element=e.$.rowNearContainer.children[o],l.element||(l.element=l.createElement(),e.$.rowNearContainer.appendChild(l.element)),l.render())}t||e.$.rowNearContainer.classList.add("smart-hidden"),0===e._frozenFarRows.length?e.$.rowFarContainer.classList.add("smart-hidden"):e.$.rowFarContainer.classList.remove("smart-hidden");for(let t=0;t<e._frozenFarRows.length;t++){const l=e._frozenFarRows[t];l.visible&&(o=!0),l.element=e.$.rowFarContainer.children[t],l.element||(l.element=l.createElement(),e.$.rowFarContainer.appendChild(l.element)),l.render()}o||e.$.rowFarContainer.classList.add("smart-hidden"),0!==e.columns.length&&e.hasVisibleColumn()||(e.$.rowNearContainer.classList.add("smart-hidden"),e.$.rowFarContainer.classList.add("smart-hidden"));const l=e.rows;l&&null!==l&&0!==l.length||(e.$.rowNearContainer.classList.add("smart-hidden"),e.$.rowFarContainer.classList.add("smart-hidden"),e._filters&&e._filters.length&&e.filtering.filterRow.visible&&e.$.rowNearContainer.classList.remove("smart-hidden"))}_recycleRotate(e,t,o,l,a){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect();let r=0,s=0;return 0===i.width?(e.innerHTML=a,!1):(n.left>i.left&&(r=i.left-n.left),n.top<i.top&&(s=i.top-n.top),"left"!==o&&""!==o||(r=4),"center"===o&&(r+=i.width/2-n.width/2),"right"===o&&(r+=i.width-n.width-4),"top"!==l&&""!==l||(s=4),"center"!==l&&"middle"!==l||(s+=i.height/2-n.height/2),"bottom"===l&&(s+=i.height-n.height-4),t.style.left=r+"px",t.style.top=s+"px",!0)}_virtualDataRequest(e,t){const o=this;let l=-1,a=-1;if(!o._rowElements&&"infinite"!==o.scrolling)return;if("virtual"===o.scrolling){for(let e=0;e<o._rowElements.length;e++){const t=o._rowElements[e],n=t.row,i=0===e?n.visibleIndex:l+e;t.classList.contains("smart-hidden")||(-1===l&&(l=i),-1!==i&&(a=1+i))}0===o._rowElements.length&&(l=0,a=Math.max(20,parseInt(o.offsetHeight/o.layout.rowMinHeight*1.5)))}else"infinite"===o.scrolling?(l=1/0,a=1/0):(l=0,a=o.dataSource.length);a!==1/0&&(o.dataSource.virtualDataSourceLength||o.dataSource.length)&&(a=Math.min(a,o.dataSource.length)),o.paging.enabled&&(l=o.paging.pageIndex*o._pageSize,a=l+o._pageSize),o._toggledRow||(o.appearance.displayLoadingIndicator=!0,o._setLoadingIndicatorVisibility()),o._groups||(o._groups=[].concat(o.dataSource.groupBy.toArray())||[]);const n={first:l,last:a,edit:o._editInfo||null,sorting:o.getSortedColumns(),filtering:o.getFilteredColumns(),filterOperator:o.filtering.operator,grouping:o._groups,row:o._toggledRow?o._toggledRow.data:null,action:e},i=o.dataSource.length,r=o.dataSource.boundSource.length;void 0===o._isFirstVirtualDataSourceRequest&&(o._isFirstVirtualDataSourceRequest=!0),o.dataSource.onVirtualDataSourceRequested((function(e){if(o.appearance.displayLoadingIndicator=!1,o._setLoadingIndicatorVisibility(),o._toggledRow=null,!e)return o._initializeRows(),o._initializeRowElements(),o.refresh(),o._refreshPagesCount(),void(o._autoHeight&&o._initializeRowElements());if("add"===e.action)return void(t&&t(e.result));if("update"===e.action)return void(t&&t(e.result));if("remove"===e.action)return void(t&&t(e.result));const l=o.context;if(o.context=o,o._isFirstVirtualDataSourceRequest&&0===o._initColumns.length&&(o.columns.canNotify=!1,o.columns=[],o._renderColumns(),o.columns.canNotify=!0),"scroll"===e.action)if("infinite"===o.scrolling){const e=o._viewRows;for(let t=0;t<e.length;t++){const l=e[t];l.data&&!l.addNewRow&&l.data.$&&(o.rowById[l.data.$.id]||(o.rowById[l.data.$.id]=l))}o._recycle(!1,!1)}else{const t=e.first>=0?e.first:0,l=e.last!==1/0?e.last:0;let a=0;for(let e=t;e<l;e++)o.rows[e]&&(o.rows[e].data=o.dataSource[a++]);o._recycle(!1,!1)}else if(o.dataSource.length!==i||o.dataSource.boundSource.length!==r||o._isFirstVirtualDataSourceRequest||"expand"===e.action||"filter"===e.action||"sort"===e.action||"pageIndexChange"===e.action||"pageSizeChange"===e.action||"sort"===e.action||"group"===e.action){o.paging.enabled&&o.$.headerPager.querySelector("smart-pager")&&(o.$.headerPager.querySelector("smart-pager").pagesCount=Math.ceil(o.dataSource.length/o._pageSize),o.$.footerPager.querySelector("smart-pager").pagesCount=Math.ceil(o.dataSource.length/o._pageSize));const e=o.filtering.filterRow&&o.filtering.filterRow.visible&&o.filtering.filterRow.cell?o.filtering.filterRow.cell.column.dataField:null;if(o._initializeRows(),o._initializeRowElements(),o.refresh(),o._refreshPagesCount(),o._autoHeight&&o._initializeRowElements(),o.filtering.filterRow){for(let e=0;e<o.columns.length;e++)o.columns[e]._filterEditorInitialized&&(o.columns[e]._filterEditorInitialized=!1);e&&setTimeout((()=>{const t=o.columnByDataField[e];t&&t._filterInfo&&t._filterInfo.input&&t._filterInfo.input.focus()}),100)}}else o.dataSource.virtualDataSourceOnExpand&&o.refresh();o._isFirstVirtualDataSourceRequest&&o.onLoad&&(o.onLoad(o),delete o.onLoad),o._isFirstVirtualDataSourceRequest=!1,o._recycle(),o.context=l,o._onDataUpdated&&o._onDataUpdated()}),n)}_createAddNewRowButton(){const e=this,t=document.createElement("div");return t.className="smart-grid-add-row-button smart-grid-icon smart-icon-plus",t.title=e.localize("addNewRow"),t.style.left=e.appearance.showViewBar&&!e._mobile?10+e.layout.viewBarWidth+"px":"",e._addNewGridRow=t.onclick=()=>{e._addRowTimer&&clearTimeout(e._addRowTimer),e._addRowTimer=setTimeout((()=>{if(e.dataSource&&e.dataSource.virtualDataSource)return void e._insertNewRowAfter();const t={};for(let o=0;o<e.columns.length;o++){const l=e.columns[o];void 0!==l.defaultValue&&null!==l.defaultValue&&("today"===l.defaultValue&&"date"===l.dataType?(e._today||(e._today=new Date,e._todayYear=e._today.getFullYear(),e._todayMonth=e._today.getMonth(),e._todayDate=e._today.getDate()),t[l.dataField]=new Date(e._todayYear,e._todayMonth,e._todayDate)):t[l.dataField]=l.defaultValue)}e._addingNewRow=!0,e._add(t),e._mobile||(e._scrollView.vScrollBar.value=e._scrollView.vScrollBar.max),e.closeMenu(),e._addingNewRow=!1,e.editing.addNewRow.visible&&e.$.placeholder.classList.contains("smart-hidden")&&"button"!==e.editing.addNewRow.displayMode&&e.editing.addNewRow._addButton.classList.remove("show")}),0)},t}addColumn(e,t,o=!0){const l=this;if(e){let a=-1;if(t)for(let e=0;e<l.columns.length;e++)if(l.columns[e].dataField===t){a=e,!1===o&&(a=e+1);break}if("string"==typeof e){const t=l._getKanbanTaskField(e);if(t){if(a>=0)return void l.columns.splice(a,0,t);l.columns.push(t)}return}if(a>=0&&a<l.columns.length)return void l.columns.splice(a,0,e);l.columns.push(e)}}insertColumnAfter(e,t){e&&this.addColumn(e,t,!1)}insertColumnBefore(e,t){e&&this.addColumn(e,t,!0)}addNewColumn(e){e&&this.addColumn(e)}_createAddNewColumnButton(){const e=this,t=document.createElement("div");return t.className="smart-grid-add-column-button smart-grid-icon smart-icon-plus",t.title=e.localize("addNewColumn"),t.onclick=()=>{e._openAddColumnDialog(),e.addEventListener("closeColumnDialog",(()=>{e.layout.isDirty=!0,e._resetCachedLayout(),e._refreshLayout()}))},t}_showAddNewRowButton(e){const t=this;if(!t.columns.length)return;if("grid"!==t.view&&t.editing.addNewRow._addButton)return void t.editing.addNewRow._addButton.classList.add("smart-hidden");if("grid"===t.view&&t.editing.addNewRow._addButton&&t.editing.addNewRow._addButton.classList.remove("smart-hidden"),"float"===e&&t.computedVerticalScrollBarVisibility&&t.editing.addNewRow._addButton&&!t.editing.addNewRow._addButton.classList.contains("show"))return;if("float"===e&&t._addingNewRow)return;const o=()=>{t.editing.addNewRow._addButton&&t.editing.addNewRow._addButton&&("float"!==e&&(t.appearance.showRowHeader||t.appearance.showRowHeaderNumber)&&"card"!==t.view?t.editing.addNewRow._addButton.classList.remove("float"):t.computedVerticalScrollBarVisibility?(t.computedVerticalScrollBarVisibility&&"float"===e||"card"===t.view)&&t.editing.addNewRow._addButton.classList.add("float"):t.editing.addNewRow._addButton.classList.add("float"),t.computedHorizontalScrollBarVisibility?t.pager.visible?t.editing.addNewRow._addButton.style.bottom="68px":t.editing.addNewRow._addButton.style.bottom="20px":t.pager.visible?t.editing.addNewRow._addButton.style.bottom="48px":t.editing.addNewRow._addButton.style.bottom="",t.grouping.enabled&&t.dataSource)&&(!(t.dataSource.groupBy.length>0)||t.editing.addNewRow._addButton.classList.remove("show"))};t.editing.addNewRow._addButton&&t.editing.addNewRow.visible&&t.$.placeholder.classList.contains("smart-hidden")&&"button"!==t.editing.addNewRow.displayMode&&t.editing.addNewRow._addButton.classList.remove("show"),!t.editing.addNewRow.visible||"button"!==t.editing.addNewRow.displayMode&&t.$.placeholder.classList.contains("smart-hidden")||(t.editing.addNewRow._addButton?requestAnimationFrame((()=>{t.editing.addNewRow._addButton&&(t.editing.addNewRow._addButton.classList.add("show"),t.editing.addNewRow._addButton.style.left=t.appearance.showViewBar&&!t._mobile?10+t.layout.viewBarWidth+"px":"",o())})):(t.editing.addNewRow._addButton=t._createAddNewRowButton(),t.appendChild(t.editing.addNewRow._addButton),requestAnimationFrame((()=>{t.editing.addNewRow._addButton&&(t.editing.addNewRow._addButton.classList.add("show"),o(),t.editing.addNewRow.visible&&t.$.placeholder.classList.contains("smart-hidden")&&"button"!==t.editing.addNewRow.displayMode&&t.editing.addNewRow._addButton.classList.remove("show"))}))))}_showAddNewColumnButton(){const e=this,t=()=>{e.editing.addNewColumn._addButton.classList.add("float")};e.editing.addNewColumn.visible&&(e.editing.addNewColumn._addButton||(e.editing.addNewColumn._addButton=e._createAddNewColumnButton(),e.appendChild(e.editing.addNewColumn._addButton)),requestAnimationFrame((()=>{e.editing.addNewColumn._addButton.classList.add("show"),t()})))}_verticalScrollRecycle(e,t){const o=this;if(o._layoutSuspended||!1===o.isAttached)return;if(o._isUpdating)return;if(o.editing.isEditing&&(!0!==o._disableEndEdit&&o.endEdit(),o._isUpdating))return;o._removeCellContentPopup(),o._inputOverlay&&(o._inputOverlay.parentNode&&o._inputOverlay.parentNode.removeChild(o._inputOverlay),o._inputOverlay=null),o._selection.selectionRect&&o._refreshCellSelectionRect();const l=o._recyclingRows;let a=l[t],n=a.top,i=!1;for(let r=0;r<o._cellsMerge.length;r++){const s=o._cellsMerge[r],d=l.indexOf(s.row);t>d&&t<=d+s.rowSpan&&(t=d,a=s.row,n=a.top,o.$.rowContainer.style.top=o.__frozenNearHeight-e+n+"px",i=!0)}i||(o.$.rowContainer.style.top=o.__frozenNearHeight-e+n+"px")}_verticalScrollbarHandler(e){const t=this;t.menu&&t.menu.column&&t.closeMenu(),t.isScrolling=!0,t._scrollTimer&&clearTimeout(t._scrollTimer),t._layoutSuspended||(t._scrollTimer=setTimeout((()=>{if("virtual"===t.scrolling)t._recycle(!1);else{const e=t._scrollView.scrollTop;let o=t._getRowIndexByPosition(e);o!==t._scrollRowIndex?(t._recycle(!1,!0,!0,o),t._scrollRowIndex=o):t._verticalScrollRecycle(e,o)}if(t.isScrolling=!1,e.max===e.value&&e.max>0){if(t.$.fireEvent("scrollBottomReached"),"infinite"===t.scrolling)return t.appearance.displayLoadingIndicator=!0,t._setLoadingIndicatorVisibility(),t._virtualScrollTimer&&clearTimeout(t._virtualScrollTimer),void(t._virtualScrollTimer=setTimeout((()=>{t._virtualDataRequest("scroll"),t.appearance.displayLoadingIndicator=!1,t._setLoadingIndicatorVisibility()}),50));t.editing.addNewRow._addButton&&"card"!==t.view&&t.editing.addNewRow._addButton.classList.remove("show")}else t.editing.addNewRow.visible&&"button"===t.editing.addNewRow.displayMode&&t.editing.addNewRow._addButton&&e.max>0&&(t.editing.addNewRow._addButton.classList.add("show"),t.editing.addNewRow._addButton.classList.remove("scroll"),t.editing.addNewRow._addButton.classList.add("float"));"virtual"===t.scrolling&&(t.appearance.displayLoadingIndicator=!0,t._setLoadingIndicatorVisibility(),t._virtualScrollTimer&&clearTimeout(t._virtualScrollTimer),t._virtualScrollTimer=setTimeout((()=>{t._virtualDataRequest("scroll"),t.appearance.displayLoadingIndicator=!1,t._setLoadingIndicatorVisibility()}),50)),e.min===e.value&&t.$.fireEvent("scrollTopReached")}),0))}getVerticalScrollMax(){return this.scrollHeight}getHorizontalScrollMax(){return this.scrollWidth}getHorizontalScrollValue(){return this.scrollLeft}setHorizontalScrollValue(e){this.scrollLeft=e}getVerticalScrollValue(){return this.scrollTop}setVerticalScrollValue(e){this.scrollTop=e}clearRows(){const e=this;e.dataSource=new Smart.DataAdapter({dataSource:[]}),e.rowHierarchy=null,e._visibleRows=null,e.__viewRows=null,e.rows.canNotify=!1,e.rows.length=0,e.rows.canNotify=!0,e.clearSelection(),e._refresh()}isEmpty(){const e=this;return!!(null===e.dataSource||e.dataSource&&e.dataSource.dataFields&&0===e.dataSource.length&&0===e.dataSource.dataSource.length&&!e.dataSource.virtualDataSource)}setRowStyle(e,t){const o=this,l=o.rowById[e];l&&(l.style=t,o._recycle(!1,!0))}setCellStyle(e,t,o){const l=this,a=l.rowById[e];if(a){const e=a.getCell(t);if(e){const t=e.canNotify;if(e.canNotify=!1,o)for(let t in o)void 0!==e[t]&&(e[t]=o[t]);else e.background=null,e.color=null,e.fontSize=null,e.fontFamily=null,e.fontWeight=null,e.textDecoration=null,e.fontStyle=null;e.canNotify=t,l._recycle(!1,!0)}}}setCellFormula(e,t,o){const l=this,a=l.rowById[e];if(a){const e=a.getCell(t);if(e){const t=e.canNotify;e.canNotify=!1,e.formula=o,e.canNotify=t,l._recycle(!1,!0)}}}dataBind(){const e=this;if(delete e.__autoRowHeight,e._virtualOnExpandCache=[],e._cellsMerge=[],e._cellStyles=[],null===e.dataSource||e.dataSource&&e.dataSource.dataFields&&0===e.dataSource.length&&0===e.dataSource.dataSource.length&&!e.dataSource.virtualDataSource)e.clearRows();else if(Array.isArray(e.dataSource))if(e.dataSourceSettings.dataFields&&e.dataSourceSettings.dataFields.length>0)e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataSourceType:e.dataSourceSettings.dataSourceType,dataFields:e.dataSourceSettings.dataFields,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy&&e.dataSourceSettings.groupBy.length?e.dataSourceSettings.groupBy:e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand});else if(e.columns&&e.columns.length){let t=[];for(let o=0;o<e.columns.length;o++){const l=e.columns[o];t.push({name:l.dataField,dataType:l.dataType||"string"}),l.displayField!==l.dataField&&t.push({name:l.displayField,dataType:l.dataType||"string"})}e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataFields:t,dataSourceType:e.dataSourceSettings.dataSourceType,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy&&e.dataSourceSettings.groupBy.length?e.dataSourceSettings.groupBy:e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand})}else e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource});const t=e._filters,o=e._sortedColumns;if(e.clearSort(),e.filtering.filterRow)for(let t=0;t<e.columns.length;t++)e.columns[t]._filterEditorInitialized=!1;for(let t=0;t<e.columns.length;t++)delete e.columns[t]._cellsCachedValues;e._initColumns&&0===e._initColumns.length&&(e.columns=[],e._renderColumns(!0)),e._renderRows(),"virtual"===e.scrolling||e.paging.enabled&&e.dataSource&&e.dataSource.virtualDataSource||e.dataSource&&e.dataSource.virtualDataSource?e._virtualDataRequest("dataBind"):e.paging.enabled&&(!e.dataSource||e.dataSource&&!e.dataSource.url)&&e._refreshPagesCount(),o&&e._refreshSort(o),t&&t.length>0&&(e._filters=null,e.refreshFilters())}refresh(e){const t=this;t.isInitialized&&(e&&(t._initializeRows(),t._initializeRowElements()),t._refresh(),t._refreshSummary())}refreshView(){const e=this;e._recycleFiles=!0,e._recycle(),delete e._recycleFiles}beginUpdate(){const e=this;e._isUpdating||(e._isUpdating=0),e._isUpdating++}endUpdate(e,t){const o=this;o._isUpdating--,o._isUpdating<0&&(o._isUpdating=0),!1!==e?o.refresh():!1!==t&&o.refreshView()}}),Smart.Grid.Extend=function(e){if(!e)return;const t=Object.getOwnPropertyNames(e.prototype);for(let o in t){const l=t[o];"constructor"!==l&&(Smart.Grid.prototype[l]=e.prototype[l])}},Smart.Grid.Extend(Smart.Utilities.Grid.Resize),Smart.Grid.Extend(Smart.Utilities.Grid.Reorder),Smart.Grid.Extend(Smart.Utilities.Grid.Pager),Smart.Grid.Extend(Smart.Utilities.Grid.Filter),Smart.Grid.Extend(Smart.Utilities.Grid.Sort),Smart.Grid.Extend(Smart.Utilities.Grid.Menu),Smart.Grid.Extend(Smart.Utilities.Grid.Select),Smart.Grid.Extend(Smart.Utilities.Grid.Edit),Smart.Grid.Extend(Smart.Utilities.Grid.Dialog),Smart.Grid.Extend(Smart.Utilities.Grid.Group),Smart.Grid.Extend(Smart.Utilities.Grid.Tree),Smart.Grid.Extend(Smart.Utilities.Grid.Export),Smart.Grid.Extend(Smart.Utilities.Grid.Chart),Smart.Grid.Extend(Smart.Utilities.Grid.View),Smart.Grid.Cell=Smart.Utilities.Grid.Cell,Smart.Grid.Row=Smart.Utilities.Grid.Row,Smart.Grid.Column=Smart.Utilities.Grid.Column;
64
+ Smart("smart-grid-toolbar",class extends Smart.DataView{template(){return'<div id="container" role="presentation">\n <div id="header" class="smart-data-view-header" role="toolbar">\n <div id="viewStatesButton" class="smart-data-view-header-button smart-data-view-states-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="ViewStates"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="viewsButton" class="smart-data-view-header-button smart-data-view-views-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Views"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="customizeButton" class="smart-data-view-header-button smart-data-view-customize-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Customize cards"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="filterButton" class="smart-data-view-header-button smart-data-view-filter-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Filter"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="sortButton" class="smart-data-view-header-button smart-data-view-sort-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Sort"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="groupButton" class="smart-data-view-header-button smart-data-view-group-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Group"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="formatButton" class="smart-data-view-header-button smart-data-view-format-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Format"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="deleteButton" class="smart-data-view-header-button smart-data-view-delete-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Delete"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="customButton" class="smart-data-view-header-button smart-data-view-custom-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Custom"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="downloadButton" class="smart-data-view-header-button smart-data-view-download-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Download"><div class="smart-tool-label" role="presentation"></div></div>\n <div id="searchButton" class="smart-data-view-header-button smart-data-view-search-button smart-unselectable" role="button" aria-expanded="false" aria-haspopup="dialog" aria-label="Search"></div>\n <div id="headerDropDown" owner 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="group" class="smart-hidden" role="presentation"></div>\n <div id="format" 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" role="button" aria-label="Previous"></div>\n <div id="searchNext" class="smart-data-view-search-next" role="button" aria-label="Next"></div>\n <div id="searchClose" class="smart-data-view-search-close" role="button" aria-label="Close search box"></div>\n </div>\n </div>\n </div>\n </div>'}_refreshMobileViewTools(){const e=this;e.grid.offsetWidth<600?e.querySelectorAll(".smart-tool-label").forEach((e=>{e.classList.add("smart-hidden")})):e.querySelectorAll(".smart-tool-label").forEach((e=>{e.classList.remove("smart-hidden")}))}refreshTools(){const e=this;if(e.isRendered&&e.grid&&(e._refreshMobileViewTools(),e.refreshHeaderDropDownPosition(),e.grid)){const t=e.grid;if(t.dataSource&&t.dataSource.boundSource){const a=t.dataSource&&t.dataSource.virtualDataSource&&!t.dataSource.virtualDataSourceOnExpand&&t.dataSource.length>t.virtualModeCachedRowsCount&&"infinite"!==t.scrolling;if(e.dataSource&&t.dataSource&&e.dataSource.length!==t.dataSource.length||a)if(a){const a=Array.isArray(t.dataSource.boundSource)?t.dataSource.boundSource:t.dataSource.boundSource.toArray();e.dataSource=new Smart.DataAdapter({observable:!1,dataSource:[...a],dataFields:t.dataSource.dataFields})}else e.dataSource=t.dataSource;const s=t=>{const a=t?"add":"remove";e.$.filterButton.classList[a]("smart-disabled"),e.$.sortButton.classList[a]("smart-disabled"),e.$.groupButton.classList[a]("smart-disabled"),e.$.formatButton.classList[a]("smart-disabled"),e.$.searchButton.classList[a]("smart-disabled"),e.$.downloadButton.classList[a]("smart-disabled")};s(e.dataSource&&0===e.dataSource.length),t.dataSource&&t.dataSource.virtualDataSource&&!t.dataSource.virtualDataSourceOnExpand&&"infinite"!==t.scrolling&&s(!1),0===t.columns.length?e.$.customizeButton.classList.add("smart-disabled"):e.$.customizeButton.classList.remove("smart-disabled")}}}get hasStyleObserver(){return!1}render(){const e=this;e._appliedFiltering={filters:[],operator:"and"},e._appliedSorting={dataFields:[],dataTypes:[],orderBy:[]},e._localizeHeader(),e._getInnerElementMessages(),super.render()}openFormatPanel(){const e=this,t=e.dataSource;if(!t||0===t.length||e.disabled||"none"===e.headerPosition)return;let a;if(e._refreshColumns("format"),e.grid.closeMenu(),e._editInfo&&e._editInfo.window.close(),e._closeDownloadMenu(),e._closeViewsMenu(),e.$.headerDropDown.classList.add("format-panel"),e.$.headerDropDown.classList.remove("customize-panel","sort-panel","search-panel","filter-panel"),e.$.format.classList.remove("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.group&&e.$.group.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e._closeSearchPanel(),e._formatPartCreated)a=e.$.format.firstElementChild,a.columns=e.columns,a.dataSource=e.dataSource,a.locale=e.locale,a.messages=e._innerElementMessages.formattingPanel,a.rightToLeft=e.rightToLeft;else{a=document.createElement("smart-formatting-panel"),a.animation=e.animation,a.columns=e.columns,a.dataSource=e.dataSource,a.locale=e.locale,a.messages=e._innerElementMessages.formattingPanel,a.rightToLeft=e.rightToLeft,a.theme=e.theme,a.unfocusable=!1,a.ownerElement=e,a.dropDownAppendTo="body",e._formattingPanel=a,e.$.format.appendChild(a);const t=document.createElement("div");t.className="smart-format-panel smart-grid-panel-container-footer",t.setAttribute("role","presentation"),t.innerHTML=`<div id="buttonsContainer" class="smart-grid-panel-buttons-container smart-unselectable" role="presentation"><span class="smart-grid-panel-cancel-button" role="button">${e.localize("cancel")}</span><span class="smart-grid-panel-apply-button" role="button">${e.localize("apply")}</span></div>`,e._formattingPanel.$.apply=t.querySelector(".smart-grid-panel-apply-button"),e._formattingPanel.$.cancel=t.querySelector(".smart-grid-panel-cancel-button"),e.$.format.appendChild(t),e._formatPartCreated=!0,t.applyButton=t.querySelector(".smart-grid-panel-apply-button"),t.cancelButton=t.querySelector(".smart-grid-panel-cancel-button"),t.applyButton.onclick=()=>{a.$.fireEvent("apply"),e.grid._conditionalFormattingChanged=!0,e.grid._conditionalFormatting=a.apply(),e.grid.conditionalFormatting=a.getItems(),e.grid._recycle(!1),e.grid._conditionalFormattingChanged=!1},t.cancelButton.onclick=()=>{a.$.fireEvent("cancel")},e.grid.conditionalFormatting&&(a.items=e.grid.conditionalFormatting)}a.focus(),e._openHeaderDropDown(e.$.formatButton)}_openHeaderDropDown(e){const t=this;t.$.headerDropDown.parentElement!==document.body&&(document.body.appendChild(t.$.headerDropDown),t.$.headerDropDown.addEventListener("apply",(e=>{const a=t._getDropDownType();t._applyHandler(e),t.grid.$.fireEvent("batchChange",{type:a})})),t.$.headerDropDown.addEventListener("cancel",(()=>{const e=t._getDropDownType();t.closePanel(),t.grid.$.fireEvent("batchCancel",{type:e})}))),super._openHeaderDropDown(e),t.refreshHeaderDropDownPosition(e)}refreshHeaderDropDownPosition(e){const t=this;if(!t.$.headerDropDown||t.$.headerDropDown&&!t.$.headerDropDown.classList.contains("open"))return void(t._dropDownTarget=e);e?t._dropDownTarget=e:t._dropDownTarget&&(e=t._dropDownTarget);const a=t.grid.parentElement,s=a?a.scrollTop:0;t.$.headerDropDown.style.top=t.grid.offset(t.grid).top+t.grid.$.header.offsetHeight-s+"px";const o=()=>{if(e){const a=t.grid.offset(e);if(a.left+t.$.headerDropDown.offsetWidth<document.body.scrollLeft+document.body.offsetWidth?t.$.headerDropDown.style.left=a.left+"px":t.$.headerDropDown.style.left=document.body.scrollLeft+document.body.offsetWidth-t.$.headerDropDown.offsetWidth+"px",a.top+t.$.headerDropDown.offsetHeight>=document.documentElement.clientHeight-40){let e=t.grid.offset(t.grid).top-t.$.headerDropDown.offsetHeight;e<0&&(e=0),t.$.headerDropDown.style.top=e+"px"}}else t.$.headerDropDown.style.left=t.grid.offset(t.grid).left+"px"};t.grid.offsetWidth<600&&t.$.headerDropDown.offsetWidth>t.grid.offsetWidth?(t.$.headerDropDown.style.width="90%",t.$.headerDropDown.style.left=t.grid.offset(t.grid).left+"px"):(t.$.headerDropDown.style.width="",o())}openFilterPanel(e){const t=this,a=t.dataSource;t._refreshColumns("filter");const s=this.columns.map((e=>{const t=Object.assign({},e),s=a.dataFields.find((e=>e.name===t.dataField));return s&&(t.dataType=s.dataType),t})).filter((e=>e.allowFilter));if(super.openFilterPanel(s,null),t._closeDownloadMenu(),t._closeViewsMenu(),t.grid.closeMenu(),e){const a=t.$.headerDropDown.querySelector("smart-multi-column-filter-panel");a.$.itemsContainer.appendChild(a._createItem(t.columns.find((t=>t.dataField===e.dataField)),"string"===e.dataType?"CONTAINS":"EQUAL",""));const s=a.querySelectorAll(".smart-grid-panel-item");setTimeout((()=>{s[s.length-1].querySelector(".editor").focus()}),350)}}openSortPanel(e){const t=this,a=t.dataSource;t._refreshColumns("sort");const s=t.columns.map((e=>{const s=Object.assign({},e),o=t._appliedSorting.dataFields.indexOf(s.dataField),n=a.dataFields.find((e=>e.name===s.dataField));return n&&(s.dataType=n.dataType,s.sortIndex=o,-1!==o&&(s.sortDirection=t._appliedSorting.orderBy[o])),s})).filter((e=>e.allowSort));if(e&&t._appliedSorting&&-1===t._appliedSorting.dataFields.indexOf(e.dataField)){const a=s.find((t=>t.dataField===e.dataField));a.sortDirection="ascending",a.sortIndex=t._appliedSorting.dataFields.length}super.openSortPanel(s),t._closeDownloadMenu(),t._closeViewsMenu();const o=t.grid;o.closeMenu();const n=t.$.headerDropDown.querySelector("smart-sort-panel");if(!n)return;n.grid=o,n.$.maintainSortContainer.classList.remove("smart-hidden"),o.sorting.maintainSort?n.$.maintainSortContainer.firstElementChild.setAttribute("active",""):n.$.maintainSortContainer.firstElementChild.removeAttribute("active"),n._changeApplyButtonText();const i=n.$.inputNotSorted,r=()=>{const e=n.querySelectorAll(".smart-grid-panel-item");"many"===t.grid.sorting.mode||e.length<1?i.classList.remove("smart-visibility-hidden"):e.length>=1&&i.classList.add("smart-visibility-hidden")};n.onDataSourceChange=()=>{r()},r()}openCustomizePanel(){const e=this;if(e.disabled||"none"===e.headerPosition)return;e._closeDownloadMenu(),e._closeViewsMenu(),e._refreshColumns("customize");let t=e.columns;const a=e.grid;a.closeMenu(),a.appearance.showColumnGroupsInColumnPanel&&(t=[],a.columns.forEach((e=>{if(!e.columnGroup){const a={label:e.label,dataField:e.dataField,level:0,parentDataField:null,dataType:e.dataType||"string",columnGroup:e.columnGroup||null,allowHide:void 0===e.allowHide||e.allowHide,allowSort:void 0===e.allowSort||e.allowSort,allowFilter:void 0===e.allowFilter||e.allowFilter,allowGroup:void 0===e.allowGroup||e.allowGroup,visible:void 0===e.visible||e.visible};t.push(a)}})),a._columnGroups.forEach((e=>{const a={dataField:e.name,label:e.label,level:0,disableDrag:!0,disableToggle:!1,allowHide:!0};if(t.push(a),e.columns){let s=e.columns.length,o=0,n=[],i=[];e.columns.forEach((a=>{const r={label:a.label,dataField:a.dataField,level:1,parentDataField:e.name,dataType:a.dataType||"string",columnGroup:a.columnGroup||null,allowHide:void 0===a.allowHide||a.allowHide,allowSort:void 0===a.allowSort||a.allowSort,allowFilter:void 0===a.allowFilter||a.allowFilter,allowGroup:void 0===a.allowGroup||a.allowGroup,visible:void 0===a.visible||a.visible};!1===r.allowHide&&(s--,i.push(r.dataField)),r.visible||(o++,n.push(r.dataField)),t.push(r)})),s<=0&&(a.allowHide=!1,a.disableToggle=!0),e.columns.length===o||s===o&&i.toString()!==n.toString()?a.visible=!1:a.visible=!0}})));const s=e.$.customize,o=t.map((t=>{const a={};return a.visible=t.visible,a.label=t.label,a.dataField=t.dataField,-1!==[e.coverField,e.titleField].indexOf(a.dataField)?a.disableToggle=!0:a.disableToggle=!1,void 0!==t.level&&(a.level=t.level),t.disableDrag&&(a.disableDrag=!0),t.parentDataField&&(a.parentDataField=t.parentDataField),t.allowHide||(a.disableToggle=!0),a}));let n;if(e._closeDialog(),e.$.headerDropDown.classList.add("customize-panel"),e.$.headerDropDown.classList.remove("filter-panel","sort-panel","search-panel","group-panel","format-panel"),s.classList.remove("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e.$.group.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e._closeSearchPanel(),e._customizePartCreated)n=s.querySelector("smart-column-panel"),n.locale=e.locale,n.messages=e._innerElementMessages.columnPanel,n.set("dataSource",o),n.propertyChangedHandler("dataSource",void 0,o),n.rightToLeft=e.rightToLeft;else{const t=document.createDocumentFragment(),a=document.createElement("smart-column-panel");a.rightToLeft=e.rightToLeft,a.animation=e.animation,a.dataSource=o,a.locale=e.locale,a.messages=e._innerElementMessages.columnPanel,a.theme=e.theme,t.appendChild(a),e.$.customize.appendChild(t),e._customizePartCreated=!0}e._changedVisibility=new Map,e._openHeaderDropDown(e.$.customizeButton)}_applyFilter(e,t){const a=this;a.grid.beginUpdate(),a.grid.context=a.grid,a.grid.clearFilter();for(let t=0;t<e.length;t++){const s=e[t],o=s[0],n=s[1];a.grid.columnByDataField[o].filter=n}a.grid._filterOperator=t,a.grid.endUpdate(),a.grid.refreshFilters(),a.grid.context=document,a.grid.autoSaveState()}_applySort(){const e=this,t=e._appliedSorting;e.grid.beginUpdate(),e.grid.sorting.maintainSort=t.maintainSort,e.grid.context=e.grid,e.grid.clearSort();for(let a=0;a<t.dataFields.length;a++)e.grid.sortBy(t.dataFields[a],t.orderBy[a]);e.grid.endUpdate(),e.grid.context=document,e.grid.autoSaveState()}_getDropDownType(){const e=this;let t=null;return e.$.headerDropDown.classList.contains("filter-panel")?t="filter":e.$.headerDropDown.classList.contains("sort-panel")?t="sort":e.$.headerDropDown.classList.contains("search-panel")?t="search":e.$.headerDropDown.classList.contains("group-panel")?t="group":e.$.headerDropDown.classList.contains("format-panel")?t="format":e.$.headerDropDown.classList.contains("customize-panel")&&(t="customize"),t}_applyHandler(e){const t=this,a=e.target,s=e.detail,o=t.$.customize;if(t.grid&&"kanban"===t.grid.view&&t.grid._kanban&&o.contains(a))return t.grid._kanban._applyHandler(e,"customize"),void t.closePanel();o.contains(a)?t._applyColumns(s.value,s.moves):t.$.filter.contains(a)?t.addFilter(s.filters,s.operator,s.value):t.$.sort.contains(a)&&t.addSort(s.sortByInfo),t.closePanel()}_documentUpHandler(e){const t=this;let a=e.originalEvent.target;const s=t.grid?t.grid.$.header:null;if(!s)return;t.shadowRoot&&a===t&&(a=e.originalEvent.composedPath()[0]);const o=e.originalEvent.composedPath();for(let e=0;e<o.length;e++){const t=o[e];if(t&&t.classList&&t.classList.contains("smart-menu-item")){const e=t.closest("smart-menu");if(e&&e.classList.contains("smart-grid-views-menu"))return;if(e&&e.classList.contains("smart-grid-download-menu"))return}}if(t._closeDownloadMenu(),t._closeViewsMenu(),!("none"===t.headerPosition||t.$.headerDropDown.classList.contains("smart-visibility-hidden")||a!==s&&s.contains(a))){const o=a.closest("smart-scroll-viewer"),n=a.closest(".smart-drop-down");if((!o||!s.contains(o.ownerElement))&&(!n||n.ownerElement&&!s.contains(n.ownerElement))){const a=e.originalEvent.composedPath();for(let e=0;e<a.length;e++){const t=a[e];if(t&&t.classList&&t.classList.contains("smart-data-view-header-drop-down"))return;if(t&&t.classList&&t.classList.contains("smart-formatting-panel-popup"))return}if(o&&o.ownerElement){const e=o.ownerElement.parents;for(let t=0;t<e.length;t++){const a=e[t];if(a&&a.classList&&a.classList.contains("smart-data-view-header-drop-down"))return}}if(n&&n.ownerElement){const e=n.ownerElement.parents;for(let t=0;t<e.length;t++){const a=e[t];if(a&&a.classList&&a.classList.contains("smart-data-view-header-drop-down"))return}}if(t.$.headerDropDown.querySelector("[open]"))return;t.closePanel()}}}_refreshColumns(e){const t=this,a=t.grid;let s,o=new Map;if("kanban"===a.view&&a._kanban)switch(e){case"customize":return s=a._kanban._getCustomizeColumnPanelDataSource(),s=JSON.parse(JSON.stringify(s)),t._refreshCustomizeButton(),void(t.columns=s)}s=Array.isArray(a.columns)?[...a.columns]:[...a.columns.toArray()],s=s.filter((t=>!1!==t._visible&&!(("filter"===e||"sort"===e)&&("sort"===e&&!t.sortOrder||"filter"===e&&!t.filter)&&!1===t.visible))),s=s.map((e=>{let t=e.allowHide;return a.grouping&&a.grouping.autoHideGroupColumn&&a.dataSource.groupBy.indexOf(e.dataField)>=0&&(t=!1),{label:e.label,dataField:e.dataField,dataType:e.dataType||"string",columnGroup:e.columnGroup||null,allowHide:void 0===e.allowHide||t,allowSort:void 0===e.allowSort||e.allowSort,allowFilter:void 0===e.allowFilter||e.allowFilter,allowGroup:void 0===e.allowGroup||e.allowGroup,visible:void 0===e.visible||e.visible,sortIndex:void 0!==e.sortIndex&&null!==e.sortIndex?e.sortIndex:-1,sortDirection:void 0!==e.sortOrder?e.sortOrder:null,options:e.editor&&e.editor.dataSource?e.editor.dataSource:null}})),s=JSON.parse(JSON.stringify(s)),s.forEach((e=>{let t=e.columnGroup?e.columnGroup+"."+e.label:e.label,a=1;for(;o.get(t);)t=e.columnGroup?e.columnGroup+"."+e.label+` (${a})`:e.label+` (${a})`,a++;o.set(t,e),e.label=t})),t.columns=s,t._refreshCustomizeButton()}_init(e){const t=this;if(t.grid=e,e.dataSource&&e.dataSource.boundSource){t._refreshColumns("init");const a=Array.isArray(e.dataSource.boundSource)?e.dataSource.boundSource:e.dataSource.boundSource.toArray();t.dataSource=new Smart.DataAdapter({observable:!1,dataSource:[...a],dataFields:e.dataSource.dataFields})}t.grid._openRowSettingsDialog=t._openRowSettingsDialog,t.rightToLeft=t.grid.rightToLeft,t.refreshTools(),t.$.headerDropDown.onclick=e=>{t.grid._headerClickHandler(e),e.stopPropagation(),e.preventDefault()},t.grid.removeEventListener("change",t._refreshFromSelection),t.grid.addEventListener("change",t._refreshFromSelection),t._updateViews(),e.header.onInit&&e.header.onInit(t)}_removeMenu(){const e=this;if(e.downloadMenu){const t=e.downloadMenu.querySelector("smart-menu");t&&e.downloadMenu.removeChild(t)}}_removeViewsMenu(){const e=this;if(e.viewsMenu){const t=e.viewsMenu.querySelector("smart-menu");t&&e.viewsMenu.removeChild(t);const a=e.viewsMenu.querySelector(".label");a&&e.viewsMenu.removeChild(a)}}_createViewsMenuItems(){const e=this,t=e.grid;e._removeViewsMenu();const a=document.createElement("smart-menu"),s=document.createDocumentFragment();a.classList.add("smart-grid-views-menu"),a.checkable=!0,a.checkboxes=!0,a.style.width="100%",a.mode="vertical",a.dropDownAppendTo="body",a.rightToLeft=t.rightToLeft,a.style.minWidth="150px";const o=(e,a,s)=>{const o=document.createElement("smart-menu-item");let n="#D50000",i="smart-icon-table-alt";switch(a){case"grid":n="#3f51b5",i="smart-icon-table-alt","grid"===t.view&&s&&(o.setAttribute("focus",""),o.checked=!0),o.title=t.localize("gridView");break;case"kanban":n="#8E24AA",i="smart-icon-kanban","kanban"===t.view&&s&&(o.setAttribute("focus",""),o.checked=!0),o.title=t.localize("kanbanView");break;case"card":n="#33B679",i="smart-icon-card","card"===t.view&&s&&(o.setAttribute("focus",""),o.checked=!0),o.title=t.localize("cardView")}return o.label='<span style="color: '+n+'" class="smart-grid-icon '+i+'"></span>'+e,o.value=a,o};s.appendChild(o(t.localize("viewGrid"),"grid",!0)),s.appendChild(o(t.localize("viewKanban"),"kanban",!0)),s.appendChild(o(t.localize("viewCard"),"card",!0)),a.appendChild(s),e.viewsMenu.insertBefore(a,e.viewsMenu.children[e.viewsMenu.children.length-1]),e.viewsMenu.onpointerup=()=>!1,a.onItemClick=a=>{e._setView(a.detail.value),e._closeViewsMenu(),t.autoSaveState(),e._updateViews()}}_updateViews(){const e=this,t=e.grid;if(e.$.viewStatesButton.removeAttribute("aria-expanded"),t.stateSettings.enabled&&t.appearance.showViewBar){const a=e=>{delete t.stateSettings.storage[e.valueName],t.stateSettings.current===e.valueName&&(t.stateSettings.current=""),t.stateSettings.onStateChange&&t.stateSettings.onStateChange(t.stateSettings.storage[t.stateSettings.current],e.valueName,t.stateSettings.storage,t.stringify_object),e.remove()},s=e=>{const a=document.createElement("input");a.value=e.valueName;const s=()=>{if(a.value){if(t.stateSettings.storage[a.value])return;const s=t.stateSettings.storage[e.valueName];t.stateSettings.current===e.valueName&&(t.stateSettings.current=a.value),delete t.stateSettings.storage[s.name],s.name=a.value,t.stateSettings.storage[s.name]=s,t.stateSettings.onStateChange&&t.stateSettings.onStateChange(t.stateSettings.storage[t.stateSettings.current],s.name,t.stateSettings.storage,t.stringify_object),delete t.stateSettings.storage[e.valueName],a.remove();const o=a.value;e.valueName=o;let n="smart-icon-table-alt";switch(s.view){case"grid":n="smart-icon-table-alt";break;case"kanban":n="smart-icon-kanban";break;case"card":n="smart-icon-card"}o===t.stateSettings.current?(e.checked=!0,e.label='<span class="show smart-grid-icon '+n+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+o+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'):e.label='<span class="show smart-grid-icon '+n+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+o+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="show smart-grid-icon smart-icon-delete"></span>'}};a.onselectstart=e=>{e.stopPropagation()},a.onpointerdown=a.onpointerup=e=>{e.stopPropagation()},a.onkeydown=e=>{e.stopPropagation()},a.onkeyup=e=>{"Escape"===e.key&&(a.onchange=a.onblur=null,a.remove()),"Enter"===e.key&&(a.onchange=a.onblur=null,s()),e.stopPropagation()},a.onchange=()=>{a.onblur=null,a.onkeyup=null,s()},a.onblur=()=>{a.remove()},a.style.width="100%",a.style.height="100%",a.style.position="absolute",a.style.left="0px",a.style.top="0px",a.style.zIndex=99,a.classList.add("smart-input"),a.classList.add("underlined"),e.querySelector(".smart-menu-item-label-element").appendChild(a),setTimeout((()=>{a.focus()}),50)},o=(e,o,n)=>{const i=document.createElement("smart-menu-item");let r="smart-icon-table-alt";switch(o){case"grid":r="smart-icon-table-alt";break;case"kanban":r="smart-icon-kanban";break;case"card":r="smart-icon-card"}return i.value=n,i.valueName=e,e===t.stateSettings.current?(i.checked=!0,i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'):i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="show smart-grid-icon smart-icon-mode-edit"></span><span class="show smart-grid-icon smart-icon-delete"></span>',!1!==t.currentUser&&null!==t.currentUser&&void 0!==t.currentUser||(e===t.stateSettings.current?(i.checked=!0,i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'):i.label='<span class="show smart-grid-icon '+r+'"></span><span style="overflow: hidden; text-overflow: ellipsis;">'+e+'</span><span class="smart-grid-icon smart-icon-mode-edit"></span><span class="smart-grid-icon smart-icon-delete"></span>'),i.ondblclick=e=>{const t=e.target.closest("smart-menu-item");s(t)},i.onclick=e=>{if(e.target&&e.target.classList.contains("smart-icon-delete")){const t=e.target.closest("smart-menu-item");a(t),e.preventDefault(),e.stopPropagation()}else if(e.target&&e.target.classList.contains("smart-icon-mode-edit")){const t=e.target.closest("smart-menu-item");s(t),e.preventDefault(),e.stopPropagation()}else if("INPUT"===e.target.nodeName)return},i};if(e.$.viewStatesButton.setAttribute("aria-expanded",!0),!t.$.viewBar.querySelector(".smart-grid-view-chooser-container")){const a=document.createElement("div");a.classList.add("smart-grid-view-chooser-container");const s=document.createElement("div");s.classList.add("new-view"),!1===t.editing.enabled&&s.classList.add("smart-hidden");const o=(a,s)=>{a.stopPropagation(),a.preventDefault(),t.beginUpdate(),t.stateSettings.current||(t.stateSettings.current=t.$.viewBar._input.value),t.saveState(),t.stateSettings.current=t.$.viewBar._input.value,e._closeViewsMenu(),t.resetState(),t._kanban&&t._kanban._reset(),delete t.columnByDataField.taskStatus,"kanban"===s?e._setView("kanban"):"card"===s&&e._setView("card"),t.saveState(),t.endUpdate(),e._updateViews(),t.$.fireEvent("viewChanged",{view:t.view})},n=document.createElement("smart-button");n.classList.add("selected"),n.classList.add("view"),n.innerHTML='<span style="display: flex; align-items: center;"><span style="color: #3f51b5" class="show smart-grid-icon smart-icon-table-alt"></span>'+t.localize("newGrid")+'</span><span style="font-size: 12px; color: rgba(var(--smart-secondary-rgb), 0.6);" class="show smart-grid-icon smart-icon-plus"></span>',n.title=t.localize("gridView");const i=document.createElement("smart-button");i.innerHTML='<span style="display: flex; align-items: center;"><span style="color: #8E24AA;" class="show smart-grid-icon smart-icon-kanban"></span>'+t.localize("newKanban")+'</span><span style="font-size: 12px; color: rgba(var(--smart-secondary-rgb), 0.6);" class="show smart-grid-icon smart-icon-plus"></span>',i.classList.add("view"),i.title=t.localize("kanbanView");const r=document.createElement("smart-button");r.classList.add("selected"),r.classList.add("view"),r.innerHTML='<span style="display: flex; align-items: center;"><span style="color: #33B679" class="show smart-grid-icon smart-icon-card"></span>'+t.localize("newCard")+'</span><span style="font-size: 12px; color: rgba(var(--smart-secondary-rgb), 0.6);" class="show smart-grid-icon smart-icon-plus"></span>',r.title=t.localize("cardView");const l=document.createElement("div");l.classList.add("smart-grid-view-storage"),a.appendChild(l);const d=document.createElement("smart-input");d.classList.add("underlined"),d.placeholder=t.localize("viewNamePlaceholder"),d.hint=t.localize("viewNamePlaceholder"),d.onselectstart=e=>{e.stopPropagation()};const c=document.createElement("div");c.innerHTML="<span>"+t.localize("settings")+"</span>",c.classList.add("view-label");const u=document.createElement("div");s.appendChild(u),u.classList.add("footer"),t.users&&t.users.length&&(!1!==t.currentUser&&null!==t.currentUser&&void 0!==t.currentUser||u.classList.add("smart-hidden")),u.appendChild(n),u.appendChild(i),u.appendChild(r);const p=document.createElement("div");p.innerHTML='<span class="smart-grid-icon show smart-icon-plus"></span><span><a href="javascript:void();">'+t.localize("createView")+"</a></span>",p.classList.add("view-button"),p.onclick=e=>{let t="grid";i.classList.contains("selected")&&(t="kanban"),r.classList.contains("selected")&&(t="card"),o(e,t,s)},i.onpointerdown=()=>{i.classList.add("selected"),n.classList.remove("selected"),r.classList.remove("selected"),p.click()},n.onpointerdown=()=>{n.classList.add("selected"),i.classList.remove("selected"),r.classList.remove("selected"),p.click()},r.onpointerdown=()=>{n.classList.remove("selected"),i.classList.remove("selected"),r.classList.add("selected"),p.click()};const m=()=>{t.stateSettings.storage&&!t.stateSettings.storage[d.value]||d.value&&!t.stateSettings.storage?p.classList.remove("disabled"):p.classList.add("disabled")};d.update=()=>m(),d.onkeyup=d.onchange=()=>{m()},m(),a.appendChild(s),t.$.viewBar._storage=l,t.$.viewBar._input=d,t.$.viewBar.appendChild(a)}let n=t.stateSettings.storage;(n&&0===Object.keys(n).length||!n)&&(t.$.viewBar._input.value||(t.$.viewBar._input.value=t.localize("view")+" 1"),t.stateSettings.current||(t.stateSettings.current=t.$.viewBar._input.value),t.saveState(),t.stateSettings.current=t.$.viewBar._input.value,n=t.stateSettings.storage);const i=t.$.viewBar._storage;if(i.innerHTML="",n){let e=1;const a=document.createDocumentFragment();let r=[],l=[];for(let e in n){const t=n[e];l[t.name]||(l[t.name]=t,r.push({name:e,value:t}))}r.sort(((e,t)=>{const a=new Date(e.value.date),s=new Date(t.value.date);if(e.value&&e.value.date&&t.value&&t.value.date){if(!e.value.date||!t.value.date)return-1;if(a<s)return-1;if(a>s)return 1;if(a===s)return 0}else{if(e.name<t.name)return-1;if(e.name>t.name)return 1;if(e.name===t.name)return 0}}));for(let t in r){const s=r[t],n=s.name,i=s.value;e++,a.appendChild(o(n,i.view,i))}if(e){const e=document.createElement("smart-menu");e.style.width="100%",e.mode="vertical",e.classList.add("smart-grid-views-menu"),e.checkable=!0,e.checkboxes=!0,e.checkMode="radioButton",e.disableAutoCheck=!0,e.rightToLeft=t.rightToLeft,e.appendChild(a),e.onItemCheckChange=a=>{if(a.detail.checked){const s=a.detail.item;t.loadState(s.valueName),e.querySelectorAll("smart-menu-item").forEach((e=>{e.querySelector(".smart-icon-delete").classList.add("show")})),s.querySelector(".smart-icon-delete").classList.remove("show"),t.stateSettings.onStateChange&&t.stateSettings.onStateChange(t.stateSettings.storage[t.stateSettings.current],s.valueName,t.stateSettings.storage,t.stringify_object)}},e.onkeydown=t=>{const a=e.querySelector("smart-menu-item[checked]");a&&"F2"===t.key&&s(a)};const o=document.createElement("div");o.style.display="flex",o.style.marginTop="10px",o.innerHTML='<span class="smart-grid-icon show smart-icon-filter"></span><span>'+t.localize("noViews")+"</span>";const n=document.createElement("smart-input");n.classList.add("underlined"),n.prefix='<span class="smart-grid-icon smart-icon-search show"></span>',n.placeholder=t.localize("commandBarSearch"),n.value=t.$.viewBar.filterValue||"",n.onkeydown=e=>{e.stopPropagation()},n.onselectstart=e=>{e.stopPropagation()},n.onAffixClick=n.onkeyup=()=>{const a=e.querySelectorAll("smart-menu-item");let s=0;o.classList.add("smart-hidden"),e.classList.remove("smart-hidden"),t.$.viewBar.filterValue=n.value,a.forEach((e=>{n.value.length>0?e.valueName.toLowerCase().startsWith(n.value.toLowerCase())?e.classList.remove("smart-hidden"):(e.classList.add("smart-hidden"),s++):e.classList.remove("smart-hidden")})),s===[...a].length&&(o.classList.remove("smart-hidden"),e.classList.add("smart-hidden"))},n.value&&n.onAffixClick(),i.appendChild(n),i.appendChild(e),i.appendChild(o),o.classList.add("smart-hidden")}if(t.stateSettings.storage)for(;t.stateSettings.storage[t.localize("view")+" "+e];)e++;t.$.viewBar._input.value=t.localize("view")+" "+e,t.$.viewBar._input.update()}}}_setView(e,t){const a=this,s=a.grid;if(s.view===e&&!0!==t)return;s.view;const o=s.context;if("kanban"===e)if(s.context=s,s.view="kanban",s.context=o,s._kanbanInitialized&&s.columnByDataField.taskStatus)if(s.columnByDataField.taskStatus&&s._stackedBy&&s.columnByDataField.taskStatus.dataField!==s._stackedBy){s.beginUpdate(),delete s.columnByDataField.taskStatus;const e=s.columnByDataField[s._stackedBy];s.columnByDataField.taskStatus=e,s._createKanban(e),s._refreshHeaderBar(),s.endUpdate(!1),s._showKanbanView(),a._refresh()}else s._showKanbanView(),a._refresh();else delete s._kanbanInitialized,s._initKanbanView("dynamic","grid");else"grid"===e?(s.context=s,s.view="grid",s.context=o,s._hideKanbanView(),a._refresh(),s.layout.isDirty=!0,s._resetCachedLayout(),s._refreshLayout(),s.refresh()):"card"===e&&(s.context=s,s.view="card",s.context=o,s._hideKanbanView(),a._refresh(),s.layout.isDirty=!0,s._resetCachedLayout(),s._refreshLayout(),s.refresh());s.$.fireEvent("viewChanged",{view:e}),a._refresh()}_createMenuItems(){const e=this,t=e.grid;e._removeMenu();const a=document.createElement("smart-menu"),s=document.createDocumentFragment();a.mode="vertical",a.dropDownAppendTo="body",a.classList.add("smart-grid-download-menu"),a.rightToLeft=t.rightToLeft;const o=(e,t)=>{const a=document.createElement("smart-menu-item");let s="#D50000";switch(t){case"csv":s="#3f51b5";break;case"pdf":s="#f4511e";break;case"xlsx":s="#0b8043";break;case"json":s="#8e24aa"}const o='<span style="position: absolute; top: 0px; font-size: 10px; color: '+s+'">'+t+"</span>";return a.label='<span style="color: '+s+'" class="smart-grid-icon smart-icon-docs"></span>'+o+e,a.value=t,a};s.appendChild(o(t.localize("download")+" CSV","csv")),s.appendChild(o(t.localize("download")+" XLSX","xlsx")),s.appendChild(o(t.localize("download")+" JSON","json")),a.appendChild(s),e.downloadMenu.appendChild(a),a.onItemClick=e=>{const a=new Date;t.dataExport.fileName="data_"+a.getFullYear()+"-"+a.getMonth()+"-"+a.getDate(),t.exportData(e.detail.value)}}closePanel(){const e=this;super.closePanel(),e.grid&&e.grid.focus(),e.downloadMenu&&e.downloadMenu.classList.contains("open")?e._closeDownloadMenu():e.viewsMenu&&e.viewsMenu.classList.contains("open")&&e._closeViewsMenu()}_closeDownloadMenu(){const e=this,t=e.downloadMenu;t&&(t.parentNode&&(t.classList.remove("open"),setTimeout((()=>{t&&t.parentNode&&t.parentNode.removeChild(t)}),100)),e.$.downloadButton.classList.remove("selected"),e.$.downloadButton.removeAttribute("aria-expanded"),t.classList.remove("open"))}_openDownloadMenu(){const e=this;if(e.grid.editing.isEditing&&e.grid.cancelEdit(),e.downloadMenu&&e.downloadMenu.classList.contains("open"))return void e._closeDownloadMenu();e.$.headerDropDown.classList.remove("group-panel","customize-panel","filter-panel","sort-panel","search-panel","format-panel"),e.$.group.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e.closePanel(),e.$.downloadButton.classList.add("selected"),e.$.downloadButton.setAttribute("aria-expanded",!0),e.downloadMenu||(e.downloadMenu=document.createElement("div"),e.downloadMenu.classList.add("smart-grid-column-menu","smart-grid-download-menu"),e.downloadMenu.setAttribute("theme",e.getAttribute("theme")),e.downloadMenu.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.downloadMenu.classList.add("smart-animate"),e._createMenuItems(),e.downloadMenu.style.height="auto",e.isInShadowDOM?e.getRootNode().appendChild(e.downloadMenu):document.body.appendChild(e.downloadMenu);const t=e.$.downloadButton.getBoundingClientRect();let a=t.left+window.pageXOffset,s=t.bottom+window.pageYOffset;a+e.downloadMenu.offsetWidth>window.innerWidth&&(a=t.right+window.pageXOffset-e.downloadMenu.offsetWidth,a+e.downloadMenu.offsetWidth>window.innerWidth&&(a=window.innerWidth-e.downloadMenu.offsetWidth)),e.downloadMenu.style.left=a+"px",e.downloadMenu.style.top=s+"px",e.downloadMenu.classList.remove("smart-hidden"),e.downloadMenu.classList.add("open")}_closeViewsMenu(){const e=this,t=e.viewsMenu;t&&(t.parentNode&&(t.classList.remove("open"),setTimeout((()=>{t&&t.parentNode&&t.parentNode.removeChild(t)}),100)),t.classList.remove("open"),e.$.viewsButton.classList.remove("selected"),e.$.viewsButton.removeAttribute("aria-expanded"))}_openViewsMenu(){const e=this;if(e.grid.editing.isEditing&&e.grid.cancelEdit(),e.viewsMenu&&e.viewsMenu.classList.contains("open"))return void e._closeViewsMenu();e.$.headerDropDown.classList.remove("group-panel","customize-panel","filter-panel","sort-panel","search-panel","format-panel"),e.$.group.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.search.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e.closePanel(),e.$.viewsButton.classList.add("selected"),e.$.viewsButton.setAttribute("aria-expanded",!0),e.viewsMenu||(e.viewsMenu=document.createElement("div"),e.viewsMenu.classList.add("smart-grid-column-menu","smart-grid-download-menu","smart-grid-view-chooser"),e.viewsMenu.setAttribute("theme",e.getAttribute("theme")),e.viewsMenu.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.viewsMenu.classList.add("smart-animate"),e._createViewsMenuItems("views"),e.viewsMenu.style.height="auto",e.isInShadowDOM?e.getRootNode().appendChild(e.viewsMenu):document.body.appendChild(e.viewsMenu);const t=e.$.viewsButton.getBoundingClientRect();let a=t.left+window.pageXOffset,s=t.bottom+window.pageYOffset;a+e.viewsMenu.offsetWidth>window.innerWidth&&(a=t.right+window.pageXOffset-e.downloadMenu.offsetWidth,a+e.viewsMenu.offsetWidth>window.innerWidth&&(a=window.innerWidth-e.viewsMenu.offsetWidth)),e.viewsMenu.style.left=a+"px",e.viewsMenu.style.top=s+"px",e.viewsMenu.classList.remove("smart-hidden"),e.viewsMenu.classList.add("open")}_refresh(){const e=this,t=e.grid;e._refreshColumns("refresh");let a=!1;for(let t=0;t<e.columns.length;t++)if("number"===e.columns[t].dataType){a=!0;break}if(t.header.buttons.indexOf("sort")>=0&&t.sorting.enabled?e.$.sortButton.classList.remove("smart-hidden"):e.$.sortButton.classList.add("smart-hidden"),t.header.buttons.indexOf("filter")>=0&&t.filtering.enabled?e.$.filterButton.classList.remove("smart-hidden"):e.$.filterButton.classList.add("smart-hidden"),t.header.buttons.indexOf("group")>=0&&t.grouping.enabled?e.$.groupButton.classList.remove("smart-hidden"):e.$.groupButton.classList.add("smart-hidden"),t.header.buttons.indexOf("columns")>=0?e.$.customizeButton.classList.remove("smart-hidden"):e.$.customizeButton.classList.add("smart-hidden"),t.header.buttons.indexOf("search")>=0?e.$.searchButton.classList.remove("smart-hidden"):e.$.searchButton.classList.add("smart-hidden"),t.header.buttons.indexOf("format")>=0&&a?e.$.formatButton.classList.remove("smart-hidden"):e.$.formatButton.classList.add("smart-hidden"),t.header.buttons.indexOf("delete")>=0&&t.editing.enabled?e.$.deleteButton.classList.remove("smart-hidden"):e.$.deleteButton.classList.add("smart-hidden"),t.header.buttons.indexOf("download")>=0?e.$.downloadButton.classList.remove("smart-hidden"):e.$.downloadButton.classList.add("smart-hidden"),t.header.buttons.indexOf("views")>=0?e.$.viewsButton.classList.remove("smart-hidden"):e.$.viewsButton.classList.add("smart-hidden"),t.header.buttons.indexOf("views")>=0&&t.stateSettings.enabled?e.$.viewStatesButton.classList.remove("smart-hidden"):e.$.viewStatesButton.classList.add("smart-hidden"),e.$.downloadButton.onpointerup=a=>{t.closeMenu(),e._openDownloadMenu(),a.stopPropagation()},e.$.viewsButton.onpointerup=a=>{t.closeMenu(),e._openViewsMenu(),a.stopPropagation()},e.$.viewStatesButton.onpointerup=a=>{t.closeMenu(),e._closeDownloadMenu(),e._closeViewsMenu(),t.appearance.showViewBar=!t.appearance.showViewBar,"kanban"===t.view&&t._refreshContentHeight(),a.stopPropagation(),e._updateViews()},t._sortedColumns){const a=[],s=[],o=[];for(let e=0;e<t._sortedColumns.length;e++){const n=t._sortedColumns[e];a.push(n.dataField),s.push(n.sortOrder),o.push(n.dataType)}e._appliedSorting={dataFields:a,dataTypes:o,orderBy:s},e._refreshSortButton()}if("grid"===t.view||"card"===t.view){const a={filters:[],operator:"and"},s=t.getFilteredColumns();if(s)for(let e in s){const t=s[e];for(let s=0;s<t.filters.length;s++){const o=t.filters[s];a.filters.push([e,o.condition,o.value])}}e._appliedFiltering&&(a.operator=e._appliedFiltering.operator),e._appliedFiltering=a,e._refreshFilterButton()}else e.$.sortButton.classList.add("smart-hidden"),e.$.filterButton.classList.add("smart-hidden");e._appliedGrouping?e._appliedGrouping.dataFields=t.dataSource.groupBy:e._appliedGrouping={dataFields:t.dataSource.groupBy,expandAll:!1,collapseAll:!1},e._refreshCustomButton(),e._refreshGroupButton(),e._refreshDeleteButton(),e._refreshDownloadButton(),e._refreshCustomizeButton(),e._refreshViewsButton(),e.refreshTools(),Smart.Utilities.Core.isMobile&&(e.$.searchButton.classList.add("smart-hidden"),e.$.formatButton.classList.add("smart-hidden"),e.$.customButton.classList.add("smart-hidden"),e.$.headerDropDown.classList.add("smart-mobile"),t.$.viewBar.classList.add("smart-mobile")),!1===t.editing.enabled&&(e.$.customButton.classList.add("smart-hidden"),e.$.downloadButton.classList.add("smart-hidden"),e.$.viewsButton.classList.add("smart-hidden"))}_refreshCustomButton(){const e=this,t=e.grid;t.header.customButton.visible?(e.$.customButton.style.paddingLeft="0px",e.$.customButton.classList.remove("smart-hidden")):e.$.customButton.classList.add("smart-hidden"),t.header.customButton.enabled?e.$.customButton.classList.remove("smart-disabled"):e.$.customButton.classList.add("smart-disabled"),e.$.customButton.innerHTML=`<span class="smart-grid-icon show ${t.header.customButton.icon}"></span><div class="smart-tool-label" role="presentation">${t.header.customButton.label}</div>`,e.$.customButton.onclick=()=>{t.header.customButton.command&&t.header.customButton.command()}}_refreshViewsButton(){const e=this;let t=e.grid.localize("viewGrid");switch(e.$.viewsButton.classList.remove("kanban"),e.$.viewsButton.classList.remove("card"),e.grid.view){case"kanban":t=e.grid.localize("viewKanban"),e.$.viewsButton.classList.add("kanban");break;case"grid":t=e.grid.localize("viewGrid");break;case"card":e.$.viewsButton.classList.add("card"),t=e.grid.localize("viewCard")}e.$.viewsButton.innerHTML='<div class="smart-tool-label" role="presentation">'+t+"</div>",e.$.viewStatesButton.innerHTML='<div class="smart-tool-label" role="presentation">'+this.grid.localize("views")+"</div>"}_refreshDownloadButton(){this.$.downloadButton.innerHTML='<div class="smart-tool-label" role="presentation">'+this.grid.localize("download")+"</div>"}_openRowSettingsDialog(e){let t=this;t.getSelectedRows||(t=t.grid);const a=t.editing.dialog.enabled,s=t.editing.mode,o=t.context;t.context=t,t.editing.dialog.enabled=!0,t.editing.mode="row",t._settingsDialogRowId=e;let n=t._isUpdating;"grid"!==t.view&&"card"!==t.view&&(t._isUpdating=0),t.beginEdit(e),t._isUpdating=n,t._endToolbarEdit?(t.removeEventListener("endEdit",t._endToolbarEdit,null),t.removeEventListener("cancelEdit",t._endToolbarEdit,null)):t._endToolbarEdit=()=>{t.context=t,t.editing.dialog.enabled=a,t.editing.mode=s,t.editing.isEditing=!1,t.context=o,delete t._settingsDialogRowId,delete t._dialogEdit},t.addEventListener("endEdit",t._endToolbarEdit),t.addEventListener("cancelEdit",t._endToolbarEdit)}_refreshDeleteButton(){let e=this;if(e.getSelectedRows||(e=e.grid),-1===e.header.buttons.indexOf("delete"))return;const t=e.getSelectedRows().length,a=e.querySelector("smart-grid-toolbar").$.deleteButton;0!==t?(!0===e.editing.enabled?a.classList.remove("smart-hidden"):a.classList.add("smart-hidden"),a.firstElementChild.innerHTML=1===t?e.localize("deleteByOne"):e.localize("deleteByMultiple",{n:t}),a.classList.add("selected"),a.onclick=()=>{const t=e.getSelectedRows().map((e=>e[0]));this.grid.removeRow(t)}):a.classList.add("smart-hidden")}_refreshFromSelection(){this.querySelector("smart-grid-toolbar")._refreshDeleteButton()}openGroupPanel(e){const t=this;let a;const s=t.grid;if("kanban"===s.view)return;t.$.headerDropDown.classList.add("group-panel"),t.$.headerDropDown.classList.remove("customize-panel","filter-panel","sort-panel","search-panel","format-panel"),t.$.group.classList.remove("smart-hidden"),t.$.filter.classList.add("smart-hidden"),t.$.customize.classList.add("smart-hidden"),t.$.sort.classList.add("smart-hidden"),t.$.search.classList.add("smart-hidden"),t.$.format.classList.add("smart-hidden"),t._closeDownloadMenu(),t._closeViewsMenu(),t._refreshColumns("group"),s.closeMenu();const o=t.columns.map((e=>{const a=Object.assign({},e);if(t._appliedGrouping&&t._appliedGrouping.dataFields){const e=t._appliedGrouping.dataFields.indexOf(a.dataField);a.groupIndex=e}return a})).filter((e=>e.allowGroup));e&&t._appliedGrouping&&-1===t._appliedGrouping.dataFields.indexOf(e.dataField)&&(o.find((t=>t.dataField===e.dataField)).groupIndex=t._appliedGrouping.dataFields.length),t._groupPartCreated?(a=t.$.group.firstElementChild,a.rightToLeft=t.rightToLeft,a.dataSource=o,a.locale=t.locale,a.messages=t._innerElementMessages.groupPanel):(a=document.createElement("smart-group-panel"),a.rightToLeft=t.rightToLeft,a.animation=t.animation,a.locale=t.locale,a.messages=t._innerElementMessages.groupPanel,a.theme=t.theme,a.dataSource=o,t.$.group.appendChild(a),t._groupPartCreated=!0,a.onExpandAll=()=>{if(t._appliedGrouping.expandAll)return t._appliedGrouping.expandAll=!1,void a.querySelector(".smart-group-panel-expand-button").removeAttribute("active");t._appliedGrouping.expandAll=!0,t._appliedGrouping.collapseAll=!1,a.querySelector(".smart-group-panel-expand-button").setAttribute("active",""),a.querySelector(".smart-group-panel-collapse-button").removeAttribute("active")},a.onCollapseAll=()=>{if(t._appliedGrouping.collapseAll)return t._appliedGrouping.collapseAll=!1,void a.querySelector(".smart-group-panel-collapse-button").removeAttribute("active");t._appliedGrouping.expandAll=!1,t._appliedGrouping.collapseAll=!0,a.querySelector(".smart-group-panel-collapse-button").setAttribute("active",""),a.querySelector(".smart-group-panel-expand-button").removeAttribute("active")},a.addEventListener("apply",(e=>{const a=e.detail.sortByInfo,o=t._appliedGrouping.dataFields;t._appliedGrouping.dataFields=a.dataFields;const n=s.onRowInserted;if(s.onRowInserted=null,s.beginUpdate(),s.grouping.autoHideGroupColumn&&o)for(let e=0;e<o.length;e++){const t=s.columnByDataField[o[e]];t&&(t.visible=!0)}s.clearGroups();for(let e=0;e<a.dataFields.length;e++){const t=a.dataFields[e];s.addGroup(t)}t._appliedGrouping.expandAll&&s.expandAllRows(),t._appliedGrouping.collapseAll&&s.collapseAllRows(),s.endUpdate(),s.autoSaveState();const i=[];for(let e=0;e<s.dataSource.groupBy.length;e++)i.push(s.dataSource.groupBy[e]);s.$.fireEvent("group",{groups:i}),s.paging.enabled&&s._refreshPagesCount(),s.onRowInserted=n}))),t._refreshGroupButton(),t._openHeaderDropDown(t.$.groupButton)}_refreshGroupButton(){const e=this,t=e._appliedGrouping.dataFields?e._appliedGrouping.dataFields.length:0;if(e.grid&&"kanban"===e.grid.view){e.$.groupButton.onclick=()=>{"kanban"===e.grid.view&&e.grid._initKanbanView("dynamic","kanban")};const t=e.grid.columnByDataField[e.grid._stackedBy];t?(e.$.groupButton.firstElementChild.innerHTML=e.localize("groupedBy",{column:t.label}),e.$.groupButton.classList.add("grouped")):e.$.groupButton.classList.remove("grouped")}else{if(0===t){const t=e.localize("group");return e.$.groupButton.firstElementChild.innerHTML!==t&&(e.$.groupButton.firstElementChild.innerHTML=t),void e.$.groupButton.classList.remove("grouped")}e.$.groupButton.firstElementChild.innerHTML=1===t?e.localize("groupedByOne"):e.localize("groupedByMultiple",{n:t}),e.$.groupButton.classList.add("grouped")}}openSearchPanel(){this._openSearchPanel()}_closeSearchPanel(){this._search(this.$.searchInput.value,!1),super._closeSearchPanel()}_openSearchPanel(){const e=this,t=e.grid;if(e.$.headerDropDown.classList.add("search-panel"),e.$.headerDropDown.classList.remove("customize-panel","filter-panel","sort-panel","group-panel","format-panel"),e.$.search.classList.remove("smart-hidden"),e.$.customize.classList.add("smart-hidden"),e.$.group.classList.add("smart-hidden"),e.$.filter.classList.add("smart-hidden"),e.$.sort.classList.add("smart-hidden"),e.$.format.classList.add("smart-hidden"),e._openHeaderDropDown(e.$.searchButton),e._closeDownloadMenu(),e._closeViewsMenu(),t.closeMenu(),"filter"===t.header.searchCommand){const t=e.$.headerDropDown.querySelector(".smart-data-view-search-prev"),a=e.$.headerDropDown.querySelector(".smart-data-view-search-next");t.classList.add("smart-hidden"),a.classList.add("smart-hidden")}const a=[],s=t.getVisibleRows();for(let e=0;e<s.length;e++)a.push(Object.assign(s[e].data));const o=new Smart.DataAdapter({id:"id",observable:!1,dataSource:a,dataFields:t.dataSource.dataFields});e._searchInfo={source:o,stringDataFields:e.dataSource.dataFields.filter((e=>"string"===e.dataType)).map((e=>e.name))},""!==e.$.searchInput.value&&e._search(e.$.searchInput.value,!1)}_search(e,t=!0){const a=this;if(!a._searchInfo)return;if(a._searchInfo.query=e,""===e)return a.$.search.classList.remove("matches","no-matches"),delete a._searchInfo.foundIdsArray,delete a._searchInfo.foundIdsObject,delete a._searchInfo.highlighted,a.grid.highlighted=null,a.grid._recycle(!1),void("filter"===a.grid.header.searchCommand&&a.grid.clearFilter());const s=a._searchInfo.source,o=[],n=[],i={};a._searchInfo.stringDataFields.forEach((t=>{const a=new Smart.Utilities.FilterGroup,s=a.createFilter("string",e,"CONTAINS");a.addFilter("or",s),o.push([t,a])})),s._filter(o,"or");for(let e=0;e<s.length;e++){const t=s[e];!1!==t.$.filtered&&(n.push(t.$.id),i[t.$.id]=!0)}if(a._searchInfo.foundIdsArray=n,a._searchInfo.foundIdsObject=i,a.grid.highlighted=null,"filter"===a.grid.header.searchCommand){a.grid.beginUpdate();const t=a.grid.filtering.operator;return a.grid.filtering.operator="or",a.grid.clearFilter(),a._searchInfo.stringDataFields.forEach((t=>{const s=new Smart.Utilities.FilterGroup,o=s.createFilter("string",e,"CONTAINS"),n=a.grid.columnByDataField[t];if(n&&n.editor&&n.editor.dataSource)return!1;n&&(s.addFilter("or",o),a.grid.addFilter(t,s),n._filterInfo&&(n._filterInfo.value=n.filter.filters[0].value,n._filterInfo.condition=n.filter.filters[0].condition))})),a.grid.endUpdate(),a.grid.refreshFilters(),void(a.grid.filtering.operator=t)}if(n.length>0)return a.$.search.classList.remove("no-matches"),a.$.search.classList.add("matches"),a.$.searchLabel.innerHTML=a.localize("found",{nth:t?1:0,n:n.length}),a._searchInfo.highlighted=n[0],a.grid.highlighted=a._searchInfo.highlighted,a.grid.ensureVisible(a._searchInfo.highlighted),void a.grid._recycle(!1);a.$.search.classList.remove("matches"),a.$.search.classList.add("no-matches"),a.$.searchLabel.innerHTML=a.localize("found",{nth:0,n:0})}_refreshCustomizeButton(){const e=this,t=e.grid;let a=0;if("kanban"===t.view&&t._kanban)return e.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+t._kanban.localize("customize")+"</div>",e.$.customizeButton.classList.remove("hidden"),void e.$.customizeButton.classList.add("smart-hidden");for(let e=0;e<t.columns.length;e++){const s=t.columns[e];s.autoGenerated||!1!==s._visible&&(t.grouping&&t.grouping.autoHideGroupColumn&&t.dataSource.groupBy.indexOf(s.dataField)>=0||s.visible||a++)}a>0?(e.$.customizeButton.innerHTML=1===a?'<div class="smart-tool-label" role="presentation">'+t.localize("customizeOne",{n:a})+"</div>":'<div class="smart-tool-label" role="presentation">'+t.localize("customizeHidden",{n:a})+"</div>",e.$.customizeButton.classList.add("hidden")):(e.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+t.localize("customize")+"</div>",e.$.customizeButton.classList.remove("hidden")),e._refreshMobileViewTools()}_applyColumns(e,t){const a=this,s=a.grid;s.beginUpdate();let o=0,n=[],i=[],r=[];const l=s.onColumnChange;s.onColumnChange=null;for(let t in e){const a=e[t],l=s.columnByDataField[a.dataField];l&&(l.visible!==a.visible&&(n.push(a),i.push(l.visible),r.push(a.visible)),l.visible=a.visible,a.visible||o++)}s.onColumnChange=l,s.onColumnChange?s.onColumnChange(n,"visible",i,r):s.$.fireEvent("columnChange",{column:n,propertyName:"visible",oldValue:i,value:r}),o>0?(a.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+s.localize("customizeHidden",{n:o})+"</div>",a.$.customizeButton.classList.add("hidden")):(a.$.customizeButton.innerHTML='<div class="smart-tool-label" role="presentation">'+s.localize("customize")+"</div>",a.$.customizeButton.classList.remove("hidden"));for(let e=0;e<t.length;e++){const a=t[e],o=a.oldIndex,n=a.newIndex,i=s.columns[n+1],r=s.columns[n-1],l=s.columns[o];i?l.columnGroup=i.columnGroup:r&&(l.columnGroup=r.columnGroup),s.reorderColumns(o,n,!0)}if(s.filtering.enabled&&s.filtering.filterRow)for(let e=0;e<s.columns.length;e++)s.columns[e]._filterEditorInitialized=!1;s.endUpdate();const d=s.grouping.enabled;d&&s._filters&&s.refreshFilters(d),s.autoSaveState()}});
65
+ Smart("smart-grid",class extends Smart.ScrollViewer{static get properties(){return{appearance:{value:{alternationStart:{value:0,type:"int"},alternationEnd:{value:0,type:"int"},alternationCount:{value:0,type:"int"},allowHover:{value:!1,type:"boolean",defaultReflectToAttribute:!0},allowHeaderHover:{value:!0,type:"boolean",defaultReflectToAttribute:!0},allowRowToggleAnimation:{value:!1,type:"boolean"},allowRowDetailToggleAnimation:{value:!1,type:"boolean"},allowSortAnimation:{value:!1,type:"boolean"},allowColumnLabelAnimation:{value:!0,type:"boolean"},allowCheckBoxesSelectionAnimation:{value:!0,type:"boolean"},allowColumnMenuAnimation:{value:!0,type:"boolean"},allowColumnSortButtonAnimation:{value:!0,type:"boolean"},allowColumnActionButtonAnimation:{value:!0,type:"boolean"},allowColumnFilterButtonAnimation:{value:!0,type:"boolean"},allowColumnStickyPosition:{value:!1,type:"boolean"},autoShowColumnSortButton:{value:!0,type:"boolean"},autoShowColumnActionButton:{value:!0,type:"boolean"},autoGenerateRowLabelMode:{value:"number",type:"string"},autoGenerateColumnLabelMode:{value:"letter",type:"string"},autoShowColumnFilterButton:{value:!0,type:"boolean"},displayLoadingIndicator:{value:!1,type:"boolean"},loadingIndicatorPlaceholder:{value:"Loading...",type:"string"},placeholder:{value:"No Rows",type:"string"},sortAnimationDuration:{value:500,type:"number"},showRowHeader:{value:!1,type:"boolean"},showRowStatus:{value:!1,type:"boolean"},showRowHeaderNumber:{value:!1,type:"boolean"},showRowHeaderEditIcon:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showRowHeaderDragIcon:{value:!1,type:"boolean"},showColumnHeaderDragIcon:{value:!1,type:"boolean"},showRowHeaderSelectIcon:{value:!1,type:"boolean"},showRowHeaderFocusIcon:{value:!1,type:"boolean"},showColumnHeaderLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showColumnGroupLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showColumnGroupCellLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showColumnLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showRowLines:{value:!0,type:"boolean",defaultReflectToAttribute:!0},showFilterColumnBackground:{value:!1,type:"boolean"},showSortColumnBackground:{value:!1,type:"boolean"},showFrozenColumnBackground:{value:!0,type:"boolean"},showFrozenRowBackground:{value:!0,type:"boolean"},showSelectionOnTop:{value:!1,type:"boolean"},showColumnSortButton:{value:!0,type:"boolean"},showColumnFilterButton:{value:!0,type:"boolean"},showColumnDescriptionButton:{value:!1,type:"boolean"},showColumnIcon:{value:!1,type:"boolean"},showColumnCustomButton:{value:!1,type:"boolean"},showColumnActionButton:{value:!0,type:"boolean"},showColumnGroupsInColumnPanel:{value:!1,type:"boolean"},showTooltips:{value:!1,type:"boolean"},showTooltipsOverflow:{value:!0,type:"boolean"},showResizeTooltips:{value:!0,type:"boolean"},showHorizontalScrollBarOnFixedColumns:{value:!1,type:"boolean"},showVerticalScrollBarOnFixedColumns:{value:!1,type:"boolean"},showTreeRowHeader:{value:!1,type:"boolean"},showTodayDateAsString:{value:!0,type:"boolean"},showViewBar:{value:!1,type:"boolean"}},type:"object"},behavior:{value:{allowColumnAutoSizeOnDoubleClick:{value:!0,type:"boolean"},allowRowAutoSizeOnDoubleClick:{value:!0,type:"boolean"},allowColumnReorder:{value:!1,type:"boolean"},allowColumnFreeze:{value:!0,type:"boolean"},allowRowReorder:{value:!1,type:"boolean"},doubleClickTimingDelay:{value:300,type:"number"},columnResizeMode:{value:"none",type:"string",allowedValues:["none","split","growAndShrink"]},rowResizeMode:{value:"none",type:"string",allowedValues:["none","split","growAndShrink"]}},type:"object"},layout:{value:{autoWrap:{value:!0,type:"boolean"},autoWidth:{value:!1,type:"boolean"},autoHeight:{value:!1,type:"boolean"},allowCellsWrap:{value:!1,type:"boolean"},allowCellsWrapShortcut:{value:!0,type:"boolean"},autoGenerateColumnWidth:{value:null,type:"number?"},autoSizeNewColumn:{value:!1,type:"boolean",reflectToAttribute:!1},autoSizeNewColumnMinWidth:{value:180,type:"number",reflectToAttribute:!1},cardMinWidth:{value:250,type:"any",reflectToAttribute:!1},cardsPerRow:{value:"auto",type:"any",reflectToAttribute:!1},cardCompact:{value:!1,type:"boolean",reflectToAttribute:!1},columnWidth:{value:null,type:"any",reflectToAttribute:!1},columnHeight:{value:null,type:"any",reflectToAttribute:!1},columnMinHeight:{value:30,type:"any",reflectToAttribute:!1},isDirty:{value:!1,type:"boolean"},loadingIndicatorPosition:{value:"center",allowedValues:["bottom","center","top"],type:"string"},rowMinHeight:{value:30,type:"number"},rowHeight:{value:null,type:"any",reflectToAttribute:!1},viewBarWidth:{value:200,type:"number"}},type:"object"},dataExport:{value:{header:{value:!0,type:"boolean"},filterBy:{value:null,type:"object"},groupBy:{value:null,type:"object"},style:{value:null,type:"object"},fileName:{value:"smartGrid",type:"string?"},pageOrientation:{value:"portrait",type:"string"},expandChar:{value:"+",type:"string"},collapseChar:{value:"-",type:"string"},view:{value:!1,type:"boolean"},viewStart:{value:null,type:"number?"},viewEnd:{value:null,type:"number?"},rowIds:{value:null,type:"array?"}},type:"object"},clipboard:{value:{enabled:{value:!0,type:"boolean"},autoFillMode:{value:"copy",allowedValues:["none","copy","fillSeries"],type:"string"},onPasteValue:{value:null,type:"any"}},type:"object"},conditionalFormatting:{value:null,type:"array?",reflectToAttribute:!1},columns:{value:[],type:"any",reflectToAttribute:!1},contextMenu:{value:{selector:{value:"",type:"string"},enabled:{value:!1,type:"boolean"},width:{value:150,type:"number"},height:{value:null,type:"number?"},dataSource:{value:{contextMenuItemDelete:{value:{command:{value:"contextMenuItemDeleteCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!0,type:"boolean"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},contextMenuItemEdit:{value:{command:{value:"contextMenuItemEditCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!0,type:"boolean"},icon:{value:"smart-icon-mode-edit",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},contextMenuItemCustom:{value:{command:{value:null,type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"boolean"},icon:{value:"smart-icon-settings",type:"string"},label:{value:"",type:"string"}},type:"object",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1},columnMenu:{value:{autoClose:{value:!0,type:"boolean"},dataSource:{value:{columnMenuCustomizeType:{value:{command:{value:"customizeTypeCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-settings",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemClone:{value:{command:{value:"duplicateCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-duplicate",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemInsertLeft:{value:{command:{value:"insertLeftCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-insert-left",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemInsertRight:{value:{command:{value:"insertRightCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-insert-right",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemSortAsc:{value:{command:{value:"sortAscCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-sort-name-up",type:"string"},iconAlt:{value:"smart-icon-sort-number-up",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemSortDesc:{value:{command:{value:"sortDescCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-sort-name-down",type:"string"},iconAlt:{value:"smart-icon-sort-number-down",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemRemoveSort:{value:{command:{value:"removeSortCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-cancel-circled",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemSort:{value:{command:{value:"addSortCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-sort",type:"string"},iconAlt:{value:"smart-icon-sort",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemFilter:{value:{command:{value:"addFilterCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-add-filter",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemRemoveFilter:{value:{command:{value:"removeFilterCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-cancel-circled",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemGroupBy:{value:{command:{value:"groupByCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-group",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemRemoveGroupBy:{value:{command:{value:"removeGroupByCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:"auto",type:"any"},icon:{value:"smart-icon-ungroup",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemHide:{value:{command:{value:"hideColumnCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-visibility-off",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1},columnMenuItemDelete:{value:{command:{value:"deleteColumnCommand",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"any"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"}},type:"object",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1},visible:{value:!1,type:"boolean"},enabled:{value:!0,type:"boolean"},width:{value:250,type:"number"},height:{value:null,type:"number?"}},type:"object",reflectToAttribute:!1},columnGroups:{value:[],type:"array",reflectToAttribute:!1},charting:{value:{appendTo:{value:null,type:"any"},enabled:{value:!1,type:"boolean"},colorScheme:{value:"scheme01",type:"string"},description:{value:"",type:"string"},dialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:400,type:"any"},width:{value:400,type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},formatSettings:{value:{},type:"object"}},type:"object"},view:{value:"grid",allowedValues:["grid","kanban","card"],type:"string"},currentUser:{value:null,type:"any"},dataSource:{value:null,type:"any",reflectToAttribute:!1},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},dataSourceSettings:{value:{autoGenerateColumns:{value:!1,type:"boolean"},sanitizeHTML:{value:"blackList",allowedValues:["all","blackList","none"],type:"string"},root:{value:"",type:"string"},record:{value:"",type:"string"},keyDataField:{value:"",type:"string"},parentDataField:{value:"",type:"string"},childrenDataField:{value:"",type:"string"},groupBy:{value:[],type:"array"},dataFields:{value:[],type:"array"},mapChar:{value:".",type:"string"},id:{value:"",type:"string"},relations:{value:[],type:"any",reflectToAttribute:!1},virtualDataSource:{value:null,type:"any"},virtualDataSourceOnExpand:{value:null,type:"any"}},type:"object"},formulas:{value:!1,type:"boolean"},uploadSettings:{value:{url:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1},existsUrl:{value:"",type:"string",reflectToAttribute:!1},name:{value:"userfile[]",type:"string",reflectToAttribute:!1},uploadMaxCount:{value:5,type:"number",reflectToAttribute:!1},uploadMaxSize:{value:2097152,type:"number",reflectToAttribute:!1},data:{value:null,type:"object",reflectToAttribute:!1},onUploadStarted:{value:null,type:"any",reflectToAttribute:!1},onUploadCompleted:{value:null,type:"any",reflectToAttribute:!1},onUploadRemove:{value:null,type:"any",reflectToAttribute:!1},onUploadError:{value:null,type:"any",reflectToAttribute:!1},onChange:{value:null,type:"any",reflectToAttribute:!1},onProgress:{value:null,type:"any",reflectToAttribute:!1},onAbort:{value:null,type:"any",reflectToAttribute:!1},onError:{value:null,type:"any",reflectToAttribute:!1},onSetHeaders:{value:null,type:"any",reflectToAttribute:!1},singleFilePost:{value:!0,type:"boolean",reflectToAttribute:!1},userFiles:{value:[],type:"array",reflectToAttribute:!1}},reflectToAttribute:!1,type:"object"},grouping:{value:{enabled:{value:!1,type:"boolean",reflectToAttribute:!1},allowCollapse:{value:!1,type:"boolean",reflectToAttribute:!1},autoHideGroupColumn:{value:!1,type:"boolean",reflectToAttribute:!1},autoExpandAll:{value:!1,type:"boolean",reflectToAttribute:!1},autoExpandToLevel:{value:0,type:"number",reflectToAttribute:!1},onGroupDefaultExpanded:{value:null,type:"any",reflectToAttribute:!1},expandMode:{value:"buttonClick",type:"string",allowedValues:["buttonClick","rowClick"],reflectToAttribute:!1},renderMode:{type:"string",value:"advanced",allowedValues:["basic","compact","advanced","multipleColumns"]},groupBy:{value:[],type:"array",reflectToAttribute:!1},groupRowHeight:{value:50,type:"any",reflectToAttribute:!1},toggleButtonIndent:{value:27,type:"number",reflectToAttribute:!1},groupIndent:{value:27,type:"number",reflectToAttribute:!1},groupBar:{value:{visible:{value:!1,type:"boolean",reflectToAttribute:!1},allowColumnDragDrop:{value:!0,type:"boolean",reflectToAttribute:!0},allowColumnCloseButtons:{value:!0,type:"boolean",reflectToAttribute:!0}},type:"object"},formatFunction:{value:null,type:"any",reflectToAttribute:!1},summaryRow:{value:{inline:{value:!0,type:"boolean"},visible:{value:!0,type:"boolean"}},type:"object"}},type:"object"},messages:{extend:!0,value:{en:{invalidColumnProperty:'{{elementType}}: Invalid property name "{{propertyName}}" set for Column: "{{type}}"',invalidRowProperty:'{{elementType}}: Invalid property name "{{propertyName}}" set for Row"',invalidCellValue:'Invalid cell value "{{value}}", Validation rule: "{{validationRule}}"',invalidValue:"Invalid value",invalidMinValue:"{{value}} above {{min}} must be filled out",invalidMaxValue:"{{value}} below {{max}} must be filled out",invalidMinLengthValue:"{{value}} is shorter than the minimum length of {{min}} characters",invalidMaxLengthValue:"{{value}} is longer than the maximum length of {{max}} characters",requiredValue:"{{value}} must be filled out",frozenColumns:"{{elementType}}: To Pin/Freeze a column group, all columns within it should be frozen.",frozenRows:"{{elementType}}: To Pin/Freeze a special cell, all rows within it should be frozen.",columnGroups:"{{elementType}}: Please, check the initialization of the smartGrid's columns array. The columns in a column group are expected to be siblings in the columns array.",viewGrid:"Grid",viewKanban:"Kanban",viewCard:"Cards",kanbanNone:"Blank",kanbanDescription:'Start from a project board with columns generated by the "{{column}}" column options.',kanbanNoneDescription:"Create a new column and start from scratch with a completely blank project board. You can add columns and configure settings yourself.",kanbanBasic:"Template",kanbanBasicDescription:'Create a new column and start from a project board with columns for "To do", "in progress" and "Done".',uncategorized:"Uncategorized",toDo:"To do",inProgress:"In progress",done:"Done",min:"Min: {{value}}",max:"Max: {{value}} ",sum:"Sum: {{value}} ",avg:"Avg: {{value}} ",cells:"{{value}} cells selected",rows:"{{value}} rows",oneRow:"1 row",unique:"Unique: {{value}}",blank:"Empty: {{value}}",filled:"Filled: {{value}}",summary:"Summary",countSummary:"Count",minSummary:"Min",maxSummary:"Max",avgSummary:"Avg",blankSummary:"Empty",uniqueSummary:"Unique",filledSummary:"Filled",statusSummary:"Status",sumSummary:"Sum",completed:"Tasks Completed: {{value}}",count:"Count: {{value}} ",pagerFirstButton:"First",pagerLastButton:"Last",pagerPreviousButton:"Previous",pagerNextButton:"Next",pagerNavigateToLabel:"Go to:",pagerPageSizeLabel:"Show:",pagerNavigateToInputPlaceholder:"",pagerEllipsis:"...",pagerSummaryString:"of",pagerSummaryPrefix:"of",pagerSummarySuffix:"",columnMenuCustomizeType:"Column settings",columnMenuItemClone:"Clone column",columnMenuItemInsertLeft:"Insert left",columnMenuItemInsertRight:"Insert right",columnMenuItemSortAsc:"Sort {{mode}}",columnMenuItemSortDesc:"Sort {{mode}}",columnMenuItemRemoveSort:"Remove Sort",columnMenuItemFilter:"Filter column",columnMenuItemSort:"Sort column",columnMenuItemRemoveFilter:"Remove Filter",columnMenuItemGroupBy:"Group column",columnMenuItemRemoveGroupBy:"Remove Group",columnMenuItemHide:"Hide column",columnMenuItemShow:"Show column",columnMenuItemDelete:"Delete column",columnResizeTooltip:"width: {{value}}px",rowResizeTooltip:"height: {{value}}px",commandBarAddRow:"Add",commandBarDeleteRow:"Delete row",commandBarBatchRevert:"Revert",commandBarBatchSave:"Save",commandBarFilter:"Filter",commandBarSort:"Sort",commandBarSearch:"Search",commandBarCustomize:"Customize",commandBarGroup:"Group",commandColumnEdit:"Edit",commandColumnDelete:"Delete",commandColumnCancel:"Cancel",commandColumnUpdate:"Update",contextMenuItemDelete:"Delete row",contextMenuItemEditCell:"Edit cell",contextMenuItemEditRow:"Edit row",commandColumnMenu:"",expandRow:"Expand row (Shift + Enter)",expandRowComments:"Expand row and see {{value}} comments",collapseRow:"Collapse row",addNewRow:"Click here to add a new row",addNewRowAlt:"<span>Add new empty row</span> <code>Shift</code> + <code>Space</code>",addNewRowAltSmall:"Add new empty row",addNewColumn:"Click here to add a new column",dialogChartHeader:"{{value}} Chart",dialogRowDetailHeader:"Row Id: {{value}}",dialogDescriptionHeader:"Column: {{value}}",dialogRowDetailButtonConfirm:"OK",dialogRowDetailButtonCancel:"CANCEL",dialogEditHeaderDisabled:"Row: {{value}}",dialogEditHeader:"Row: {{value}}",dialogEditHeaderMenu:"Toggle Sidebar",dialogExpandRowHeader:"Edit Record",dialogAddButtonConfirm:"ADD",dialogAddButtonCancel:"CANCEL",dialogEditButtonConfirm:"OK",dialogEditButtonSave:"Save",dialogEditButtonAutoSave:"Auto Save",dialogEditButtonCancel:"Cancel",dialogFilterButtonConfirm:"FILTER",dialogFilterButtonCancel:"CLEAR",dialogDeleteButtonConfirm:"DELETE",dialogDeleteButtonCancel:"CANCEL",dialogEditColumn:"Column: {{value}}",dialogNewColumn:"New column",dialogAddColumn:"Add Column",dialogAddColumnStatus:"Choose a grouping column",dialogAddColumnStatusDescription:"Represent the status of each record",dialogAddColumnStatusNotes:"Your records will be grouped based on this column",dialogAddHeader:"Add Row",dialogDeleteHeader:"Delete Row",dialogFilterHeader:"Filter by",dialogFilterMinLabel:"Min",dialogFilterMaxLabel:"Max",dialogFileHeader:"File",dialogImageFileHeader:"Image",dialogFileDrop:"or drag and drop file(s) to upload",dialogFileUpload:"Select Files(s) to Upload",dialogFileURL:"You can also provide the URL to a file",dialogFileURLUpload:"Upload",dialogFileLink:"Link (URL)",dialogFileDevice:"My Device",dialogMyFiles:"My Files",dialogMyFilesTitle:"Select files from your already uploaded files.",dialogFileSize:'No file currently added. The "{{value}}" file cannot be uploaded. Maximum file size is {{fileSize}}.',dialogFileCount:'The following files cannot be added "{{files}}". Maximum files allowed is {{fileCount}}.',dialogFileFileUpload:"No files currently selected",dialogAddColumnName:"Name",dialogAddColumnNameInfo:"Name of the column. The name of the column will be displayed in the column header.",dialogAddColumnDescription:"Description",dialogAddColumnDescriptionInfo:"Description of the column. When the description is set, an icon will be displayed in the column header. A tooltip with the description will be displayed when you point at the icon.",dialogAddColumnNamePlaceholder:"Column name (optional)",dialogAddColumnDescriptionPlaceholder:"Describe this column (optional)",dialogAddColumnType:"Type",dialogAddColumnTypeInfo:'Type of the data in the column. Unlike a spreadsheet, Columns have specific "types" that allow you to store rich content in each record. For example, a table can contain records (rows) with images, long texts, checkboxes.',dialogAddColumnTypeText:"Text",dialogAddColumnTypeMultilineText:"Multiline text",dialogAddColumnTypeImage:"Image",dialogAddColumnTypeNumber:"Number",dialogAddColumnTypeSelect:"Select",dialogAddColumnTypeMultipleSelect:"Multiple select",dialogAddColumnTypeDate:"Date",dialogAddColumnTypeTime:"Time",dialogAddColumnTypeRating:"Rating",dialogAddColumnTypeDuration:"Duration",dialogAddColumnTypeCheckBox:"CheckBox",dialogAddColumnTypeCreatedTime:"Created time",dialogAddColumnTypeLastUpdatedTime:"Last modified time",dialogAddColumnTypeCreatedBy:"Created by",dialogAddColumnTypeLastUpdatedBy:"Last modified by",dialogAddColumnTypeCollaborator:"User",dialogAddColumnTypeFormula:"Formula",dialogAddColumnTypeFormulaInfo:'Example: COL(Name) & "-" & COL(Price) or IF(COL(Price) * COL(Quantity) > 5, "Yes", "No")',dialogAddColumnTypeSlider:"Slider",dialogAddColumnTypeStatus:"Choose a status column",dialogAddColumnTypeStatusInfo:"Connect with the relevant status column",dialogAddColumnTypeAutoNumber:"Auto number",dialogAddColumnTypeRowLink:"Link to table",dialogAddColumnTypeURL:"URL",dialogAddColumnTypeEmail:"Email",dialogAddColumnTypePassword:"Password",dialogAddColumnTypePhone:"Phone",dialogAddColumnTypeNone:"None",dialogAddColumnTypeStartDate:"Start Date",dialogAddColumnTypeDueDate:"Due Date",dialogAddColumnTypeDueDateSettings:"Set as a deadline",dialogAddColumnTypeDueDateSettingsInfo:"Set a deadline with start date or due date templates.",dialogAddColumnTypeProgress:"Progress",dialogAddColumnTypePriority:"Priority",dialogAddColumnTypeDescription:"Description",dialogAddColumnTypeTags:"Tags",dialogAddColumnTypeName:"Name",dialogAddColumnTypeColor:"Color",dialogAddColumnTypeChecklist:"Checklist",dialogAddColumnTypeAssigned:"Assignee",dialogAddColumnTypeAttachment:"Attachment",dialogAddColumnDateFormat:"Date format",dialogAddColumnDateFormatInfo:"Choose the dates display format",dialogAddColumnDateFormatShort:"Short",dialogAddColumnDateFormatLong:"Long",dialogAddColumnDateFormatEU:"EU",dialogAddColumnDateFormatISO:"ISO",dialogAddColumnDateFormatAS:"AS",dialogAddColumnDateFormatFull:"Full",dialogAddColumnDateFormatSlash:"Slash",dialogAddColumnDateFormatHyphen:"Hyphen",dialogAddColumnDateFormatDot:"Dot",dialogAddColumnTimeFormat:"Time format",dialogAddColumnTimeFormatInfo:"Choose the time display format",dialogAddColumnTimeFormatHour:"hour",dialogAddColumnAllowTimeFormat:"Include a time field",dialogAddColumnCustomDateSeparator:"Set a custom separator",dialogAddColumnNumberFormat:"Number format",dialogAddColumnNumberFormatInfo:"Choose the number display format",dialogAddColumnNumberFormatInteger:"Integer",dialogAddColumnNumberFormatNumber:"Number",dialogAddColumnNumberFormatPercent:"Percent",dialogAddColumnNumberFormatPercentRounded:"Percent(rounded)",dialogAddColumnNumberFormatScientific:"Scientific",dialogAddColumnNumberFormatEngineering:"Engineering",dialogAddColumnNumberFormatAccounting:"Accounting",dialogAddColumnNumberFormatUnit:"Unit",dialogAddColumnNumberFormatUnitInfo:"Units of measurement",dialogAddColumnNumberFormatUnitAcre:"Acre",dialogAddColumnNumberFormatUnitCelsius:"Celsius",dialogAddColumnNumberFormatUnitFahrenheit:"Fahrenheit",dialogAddColumnNumberFormatUnitPercent:"Percent",dialogAddColumnNumberFormatUnitDegree:"Degree",dialogAddColumnNumberFormatUnitMegaByte:"Mega byte",dialogAddColumnNumberFormatUnitCentimeter:"Centimeter",dialogAddColumnNumberFormatUnitMeter:"Meter",dialogAddColumnNumberFormatUnitKilometer:"Kilometer",dialogAddColumnNumberFormatUnitMile:"Mile",dialogAddColumnNumberFormatUnitKilogram:"Kilogram",dialogAddColumnNumberFormatUnitPound:"Pound",dialogAddColumnNumberFormatUnitLiter:"Liter",dialogAddColumnNumberFormatUnitGallon:"Gallon",dialogAddColumnNumberFormatUnitSecond:"Second",dialogAddColumnNumberFormatUnitMinute:"Minute",dialogAddColumnNumberFormatUnitHour:"Hour",dialogAddColumnNumberFormatUnitDay:"Day",dialogAddColumnNumberFormatUnitWeek:"Week",dialogAddColumnNumberFormatUnitMonth:"Month",dialogAddColumnNumberFormatUnitYear:"Year",dialogAddColumnNumberFormatCurrency:"Currency",dialogAddColumnNumberFormatCurrencyRounded:"Currency(rounded)",dialogAddColumnNumberFormatCurrencyInfo:"Choose the currency display format",dialogAddColumnNumberFormatSeparator:"Use 1000 Separator (,)",dialogAddColumnMinLength:"Minimum length",dialogAddColumnMinLengthInfo:"Minimum text length",dialogAddColumnMaxLength:"Maximum length",dialogAddColumnMaxLengthInfo:"Maximum text length",dialogAddColumnMinValue:"Minimum value",dialogAddColumnMinValueInfo:"Minimum number",dialogAddColumnMaxValue:"Maximum value",dialogAddColumnMaxValueInfo:"Maximum number",dialogAddColumnMinDate:"Minimum date",dialogAddColumnMinDateInfo:"Minimum date",dialogAddColumnMaxDate:"Maximum date",dialogAddColumnMaxDateInfo:"Maximum date",dialogAddColumnColorItems:"Color items",dialogAddColumnListItems:"List items",dialogAddColumnLinkListItems:"Choose a table to link to",dialogAddColumnLinkField:"Choose a lookup field",dialogAddColumnLinkSelect:"Allow linking to multiple rows",dialogAddColumnFormula:"Please enter a formula",dialogAddColumnListItemsError:"You cannot delete an item while in use.",dialogAddColumnDefault:"Default value",dialogAddColumnDefaultDateCurrent:"Current Date",dialogAddColumnDefaultDateSpecific:"Specific Date",dialogAddColumnAlign:"Align",dialogAddColumnAlignLeft:"Left",dialogAddColumnAlignRight:"Right",dialogAddColumnAlignCenter:"Center",dialogAddColumnAlignInfo:"Table cells text alignment",dialogAddColumnResizable:"Resizable",dialogAddColumnResizableInfo:"Select if you want to make the column resizable",dialogAddColumnRequired:"Required",dialogAddColumnRequiredInfo:"Select if you want to make the column required",dialogAddColumnSortable:"Sortable",dialogAddColumnSortableInfo:"Select if you want to sort by this column",dialogAddColumnFilterable:"Filterable",dialogAddColumnFilterableInfo:"Select if you want to filter by this column",dialogAddColumnEditable:"Editable",dialogAddColumnEditableInfo:"Select if you want to edit by this column",dialogAddColumnMultipleCollaborators:"Multiple Collaborators",dialogAddColumnMultipleCollaboratorsInfo:"Select if you want to allow multiple collaborators",dialogAddColumnCheckItems:"Show Checkbox",dialogAddColumnFormatting:"Rich Formatting",priority_low:"Low",priority_average:"Average",priority_high:"High",priority_critical:"Critical",bold:"Bold",fontStyle:"Font Style",italic:"Italic",send:"Send",copy:"copy",status:"Status",underline:"Underline",comments:"Comments",comment:"Comment",commentPlaceholder:"Leave a comment",noComments:"Leave a comment and collaborate with your team.",guestUser:"Guest",background:"Background",starred:"Starred",resetFormat:"Reset Format",notStarred:"Not starred",color:"Color",coloredItems:"Colored items",conditionalFormatting:"Conditional Formatting",groupBarLabel:"Drag a column header here to group by that column",dialogDeleteContent:"Are you sure you want to delete this row?",detailsTab:"Format",commentsTab:"Comments",historyTab:"History",historyEvent:"Event",historyAuthor:"Author",historyDetails:"Details",range:"Changed {{column}} from {{oldValue}} to {{newValue}}",nullRange:"Changed {{column}} to {{newValue}}",rowCreated:"Row Created",propertyUpdated:"{{value}} updated",propertyRemoved:"{{value}} removed",dropImages:"Drop images here",addImages:"Add images",dropFiles:"Drop files here",addFiles:"Add files",unassigned:"Unassigned",historyDate:"Date",copyURL:"Copy row URL",calendar:{"/":"/",":":":",firstDay:0,days:{names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],namesAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],namesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]},months:{names:["January","February","March","April","May","June","July","August","September","October","November","December",""],namesAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]},AM:["AM","am","AM"],PM:["PM","pm","PM"],eras:[{name:"A.D.",start:null,offset:0}],currencySymbol:"$",currency:"USD",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","},CONTAINS:"Contains",DOES_NOT_CONTAIN:"Does not contain",ENDS_WITH:"Ends with",EQUAL:"Equal",GREATER_THAN:"Greater than",GREATER_THAN_OR_EQUAL:"Greater than or equal",LESS_THAN:"Less than",LESS_THAN_OR_EQUAL:"Less than or equal",NOT_EQUAL:"Not equal",RANGE:"Range",CLEAR_FILTER:"Clear Filter",STARTS_WITH:"Starts with",addFilter:"+ Add filter",and:"And",apply:"Apply",applyOnce:"Apply once",booleanFirst:"☐",booleanLast:"☑",cancel:"Cancel",CONTAINS_CASE_SENSITIVE:"Contains (case sensitive)",dateFirst:"1",dateLast:"9",DOES_NOT_CONTAIN_CASE_SENSITIVE:"does not contain (case sensitive)",EMPTY:"empty",ENDS_WITH_CASE_SENSITIVE:"ends with (case sensitive)",EQUAL_CASE_SENSITIVE:"equal (case sensitive)",filter:"Filter",customize:"Hide columns",customizeOne:"1 hidden column",customizeHidden:"{{n}} hidden columns",filteredByMultiple:"{{n}} filters",filteredByOne:"1 filter",filterValuePlaceholder:"Value",find:"Find a field",findInView:"Find in view",firstBy:"Sort by",found:"{{nth}} of {{n}}",from:"from",noFilters:"No filters applied",noResults:"No results",noSorting:"No sorting applied",noOptions:"No options",NOT_EMPTY:"not empty",NOT_NULL:"not null",NULL:"null",numberFirst:"1",numberLast:"9",ok:"OK",or:"Or",pickAnother:"Pick another field to sort by",maintainSort:"Maintain sort",sort:"Sort",group:"Group",sortedByMultiple:"Sorted by {{n}} columns",sortedByOne:"Sorted by 1 column",STARTS_WITH_CASE_SENSITIVE:"starts with (case sensitive)",stringFirst:"A",stringLast:"Z",thenBy:"then by",where:"Where",collapseAll:"Collapse all",expandAll:"Expand all",noGrouping:"No grouping",groupedByMultiple:"{{n}} groups",groupedByOne:"1 group",groupedBy:"Grouped by {{column}}",deleteByMultiple:"Delete {{n}} rows",deleteByOne:"Delete 1 row",download:"Download",firstByGroup:"Group by",expandRecord:"Expand row",expandCell:"Expand cell",pickAnotherGroupBy:"Pick another field to group by",add:"Add condition",all:"All columns",between:"Between",close:"Close",column:"Column:",condition:"Condition:",equal:"equal",fontFamily:"Font family:",fontSize:"Font size:",format:"Format:",greaterThan:"greater than",highlight:"Highlight",lessThan:"less than",notEqual:"not equal",remove:"Remove condition",secondValue:"Second value:",text:"Text",value:"Value:",addCondition:"Add Condition",addGroup:"Add Group",blanks:"(Blanks)",clear:"Clear",contains:"contains",containsCaseSensitive:"contains (case sensitive)",dateTabLabel:"DATE",doesNotContain:"does not contain",doesNotContainCaseSensitive:"does not contain (case sensitive)",empty:"empty",endsWith:"ends with",endsWithCaseSensitive:"ends with (case sensitive)",equalCaseSensitive:"equal (case sensitive)",greaterThanOrEqual:"greater than or equal",lessThanOrEqual:"less than or equal",mismatchedProperties:'smartFilterPanel: The "filterType" and the data type of the selected "dataField" are mismatched.',missingProperty:'smartFilterPanel: When mode is \'excel\', either "data" and "dataField" or "dataSource" of type Array have to be set.',notEmpty:"not empty",notNull:"not null",null:"null ",placeholderBoolean:"Select value",placeholderDate:"Enter date",placeholderNumber:"Enter number",placeholderTime:"Enter time",placeholderValue:"Enter value",selectAll:"(Select All)",showRows:"Show rows where:",startsWith:"starts with",startsWithCaseSensitive:"starts with (case sensitive)",matchCase:"Match Case",timeTabLabel:"TIME",today:"Today",tomorrow:"Tomorrow",yesterday:"Yesterday",formatColumn:"Format Column",formating:"Conditional Formatting",reset:"Reset",filteredRecords:"All rows are filtered",duplicateCells:"Clone column cells and settings",duplicateSettings:"Clone column settings",views:"Views",createView:"New View",newGrid:"Grid",newKanban:"Kanban",newCard:"Cards",layout:"Layout",settings:"Name",viewNamePlaceholder:"View name",view:"View",noViews:"Found no views",kanbanView:"View your records as cards on a Kanban board",gridView:"View your records in a Table",cardView:"View your records in a Card view",days:"{{value}}d",daysOverdue:"{{value}} days overdue",daysLeft:"{{value}} days left"}},type:"object"},onCellValue:{value:null,type:"any",reflectToAttribute:!1},onCellUpdate:{value:null,type:"any",reflectToAttribute:!1},onCellRender:{value:null,type:"any",reflectToAttribute:!1},onBeforeInit:{value:null,type:"any",reflectToAttribute:!1},onInit:{value:null,type:"any",reflectToAttribute:!1},onAfterInit:{value:null,type:"any",reflectToAttribute:!1},onKey:{value:null,type:"any",reflectToAttribute:!1},onKeyUp:{value:null,type:"any",reflectToAttribute:!1},onRender:{value:null,type:"any",reflectToAttribute:!1},onLoad:{value:null,type:"any",reflectToAttribute:!1},onChartInit:{value:null,type:"any",reflectToAttribute:!1},onComment:{value:null,type:"any",reflectToAttribute:!1},onRowInit:{value:null,type:"any",reflectToAttribute:!1},onRowClass:{value:null,type:"any",reflectToAttribute:!1},onRowChange:{value:null,type:"any",reflectToAttribute:!1},onRowDetailInit:{value:null,type:"any",reflectToAttribute:!1},onRowDetailUpdated:{value:null,type:"any",reflectToAttribute:!1},onRowInserted:{value:null,type:"any",reflectToAttribute:!1},onRowRemoved:{value:null,type:"any",reflectToAttribute:!1},onRowUpdate:{value:null,type:"any",reflectToAttribute:!1},onRowUpdated:{value:null,type:"any",reflectToAttribute:!1},onRowStarred:{value:null,type:"any",reflectToAttribute:!1},onRowHistory:{value:null,type:"any",reflectToAttribute:!1},onRowStyle:{value:null,type:"any",reflectToAttribute:!1},onRowResize:{value:null,type:"any",reflectToAttribute:!1},onColumnInit:{value:null,type:"any",reflectToAttribute:!1},onColumnInserted:{value:null,type:"any",reflectToAttribute:!1},onColumnRemoved:{value:null,type:"any",reflectToAttribute:!1},onColumnResize:{value:null,type:"any",reflectToAttribute:!1},onColumnReorder:{value:null,type:"any",reflectToAttribute:!1},onColumnSummaryChange:{value:null,type:"any",reflectToAttribute:!1},onColumnUpdated:{value:null,type:"any",reflectToAttribute:!1},onColumnClone:{value:null,type:"any",reflectToAttribute:!1},onColumnChange:{value:null,type:"any",reflectToAttribute:!1},onCommand:{value:null,reflectToAttribute:!1,type:"any"},onViewInit:{value:null,type:"any",reflectToAttribute:!1},filtering:{value:{enabled:{value:!1,type:"boolean"},operator:{value:"and",type:"string"},filter:{value:[],type:"array",reflectToAttribute:!1},filterRow:{value:{visible:{value:!1,type:"boolean"},menuVisible:{value:!1,type:"boolean"},applyMode:{value:"auto",type:"string",allowedValues:["auto","click"]},autoApplyModeDelay:{value:800,type:"number"}},type:"object"},filterMenu:{value:{visible:{value:!0,type:"boolean"},buttons:{value:["cancel","clear","filter"],type:"array"},dataSource:{value:null,type:"any"},width:{value:250,type:"number"},height:{value:200,type:"number"},mode:{value:"default",allowedValues:["default","excel"],type:"string"},messages:{value:null,type:"object"}},type:"object"}},type:"object"},editing:{value:{allowRowHeaderEdit:{value:!1,type:"boolean"},allowColumnHeaderEdit:{value:!1,type:"boolean"},autoUpdateFilterAndSort:{value:!0,type:"boolean"},active:{value:!1,readonly:!0,type:"boolean"},enabled:{value:!1,type:"boolean"},batch:{value:!1,type:"boolean"},action:{value:"click",type:"string",allowedValues:["none","click","doubleClick"]},commandKeys:{value:{commandKeyCancel:{value:{command:"commandKeyCancelCommand",key:"Escape"},type:"object"},commandKeyUpdate:{value:{command:"commandKeyUpdateCommand",key:"Enter | Tab"},type:"object"}},type:"object"},commandBar:{value:{visible:{value:!1,type:"boolean"},position:{value:"near",allowedValues:["near","far","both"],type:"string"},displayMode:{value:"labelAndIcon",allowedValues:["label","icon","labelAndIcon"],type:"string"},dataSource:{value:{commandBarAddRow:{value:{command:{value:"commandBarAddRowCommand",type:"any"},icon:{value:"smart-icon-plus",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandBarDeleteRow:{value:{command:{value:"commandBarDeleteRowCommand",type:"any"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandBarBatchSave:{value:{command:{value:"commandBarBatchSaveCommand",type:"any"},icon:{value:"smart-icon-ok-squared",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!0,type:"any"}},type:"object"},commandBarBatchRevert:{value:{command:{value:"commandBarBatchRevertCommand",type:"any"},icon:{value:"smart-icon-reload",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!0,type:"any"}},type:"object"},commandBarCustom:{value:{command:{value:"",type:"any"},icon:{value:"smart-icon-ellipsis-vert",type:"string"},label:{value:"",type:"string"},visible:{value:!1,type:"any"}},type:"object"}},type:"object"}},type:"object"},commandColumn:{value:{visible:{value:!1,type:"boolean"},inline:{value:!1,type:"boolean"},position:{value:"far",allowedValues:["near","far"],type:"string"},displayMode:{value:"icon",allowedValues:["label","icon","labelAndIcon"],type:"string"},dataSource:{value:{commandColumnMenu:{value:{command:{value:"commandColumnMenuCommand",type:"any"},icon:{value:"smart-icon-menu",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandColumnEdit:{value:{command:{value:"commandColumnEditCommand",type:"any"},icon:{value:"smart-icon-mode-edit",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:"auto",type:"any"}},type:"object"},commandColumnDelete:{value:{command:{value:"commandColumnDeleteCommand",type:"any"},icon:{value:"smart-icon-delete",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!0,type:"any"}},type:"object"},commandColumnUpdate:{value:{command:{value:"commandColumnUpdateCommand",type:"any"},icon:{value:"smart-icon-ok-squared",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:"auto",type:"any"}},type:"object"},commandColumnCancel:{value:{command:{value:"commandColumnCancelCommand",type:"any"},icon:{value:"smart-icon-cancel-circled",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:"auto",type:"any"}},type:"object"},commandColumnRowMenu:{value:{command:{value:"commandColumnRowMenuCommand",type:"any",reflectToAttribute:!1},icon:{value:"smart-icon-ellipsis-vert",type:"string"},label:{value:"{{messages}}",type:"string"},visible:{value:!1,type:"any"}},type:"object"},commandColumnCustom:{value:{command:{value:"",type:"any",reflectToAttribute:!1},icon:{value:"smart-icon-ellipsis-vert",type:"string"},label:{value:"",type:"string"},visible:{value:!1,type:"any"}},type:"object"}},type:"object"},width:{value:null,type:"number?"}},reflectToAttribute:!1,type:"object"},mode:{value:"cell",allowedValues:["cell","row"],type:"string"},addNewColumn:{value:{visible:{value:!1,type:"boolean"}},type:"object"},addNewRow:{value:{position:{value:"both",allowedValues:["near","far","both"],type:"string"},visible:{value:!1,type:"boolean"},autoEdit:{value:!0,type:"boolean"},autoCreate:{value:!1,type:"boolean"},autoSave:{value:!0,type:"boolean"},label:{value:"{{message}}",type:"string"},displayMode:{value:"row",allowedValues:["row","button"],type:"string"}},type:"object"},dialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:"auto",type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},addDialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:"auto",type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},addColumnDialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:430,type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"},deleteDialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:"auto",type:"any"},width:{value:"auto",type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"}},type:"object"},paging:{value:{enabled:{value:!1,type:"boolean"},spinner:{value:{enabled:{value:!1,type:"boolean"},step:{value:1,type:"number"}},type:"object"},pageHierarchySize:{value:2,type:"int"},pageSize:{value:10,type:"int"},pageIndex:{value:0,type:"int",validator:"pageIndexValidator"}},type:"object"},pager:{value:{autoEllipsis:{value:"both",allowedValues:["none","before","after","both"],type:"string"},position:{value:"far",allowedValues:["near","far","both"],type:"string"},template:{value:"",type:"string"},pageSizeSelector:{value:{visible:{value:!1,type:"boolean"},dataSource:{value:[10,20,50],type:"object"},position:{value:"far",allowedValues:["near","far"],type:"string"}},type:"object"},summary:{value:{position:{value:"far",allowedValues:["near","far"],type:"string"},visible:{value:!1,type:"boolean"}},type:"object"},navigationButtons:{value:{position:{value:"both",allowedValues:["near","far","both"],type:"string"},prevNextButtons:{value:{visible:{value:!0,type:"boolean"}},type:"object"},firstLastButtons:{value:{visible:{value:!0,type:"boolean"}},type:"object"},labels:{value:{visible:{value:!1,type:"boolean"}},type:"object"}},type:"object"},navigationInput:{value:{position:{value:"far",allowedValues:["near","far"],type:"string"},visible:{value:!1,type:"boolean"}},type:"object"},pageIndexSelectors:{value:{visible:{value:!0,type:"boolean"},dataSource:{value:10,type:"any"}},type:"object"},visible:{value:!1,type:"boolean"}},type:"object",reflectToAttribute:!1},rowDetail:{value:{enabled:{value:!1,type:"boolean"},height:{value:200,type:"number"},position:{value:"near",allowedValues:["near","far"],type:"string"},template:{value:"",type:"any",reflectToAttribute:!1},visible:{value:!0,type:"boolean"},dialog:{value:{header:{value:"{{message}}",type:"string"},height:{value:300,type:"any"},width:{value:360,type:"any"},left:{value:"center",type:"any"},top:{value:"center",type:"any"},enabled:{value:!1,type:"boolean"},visible:{value:!1,type:"boolean"}},type:"object"}},type:"object"},rowCSSRules:{value:null,type:"any"},summaryRow:{value:{position:{value:"far",allowedValues:["near","far"],type:"string"},visible:{value:!1,type:"boolean"},editing:{value:!1,type:"boolean"},template:{value:"",type:"string"}},type:"object"},scrolling:{value:"physical",allowedValues:["physical","virtual","infinite","deferred"],type:"string"},columnHeader:{value:{visible:{value:!0,type:"boolean"}},type:"object"},groupHeader:{value:{visible:{value:!1,type:"boolean"},template:{value:"",type:"string"}},type:"object"},header:{value:{visible:{value:!1,type:"boolean"},template:{value:"",type:"any"},buttons:{value:["columns","filter","group","sort","format","search"],type:"array"},searchCommand:{value:"search",allowedValues:["search","filter"],type:"string"},customButton:{value:{command:{value:null,type:"any",reflectToAttribute:!1},enabled:{value:!0,type:"boolean"},visible:{value:!1,type:"boolean"},icon:{value:"smart-icon-settings",type:"string"},label:{value:"",type:"string"}},type:"object",reflectToAttribute:!1},onInit:{value:null,reflectToAttribute:!1,type:"any"}},type:"object"},footer:{value:{visible:{value:!1,type:"boolean"},template:{value:"",type:"any"}},type:"object"},stateSettings:{value:{enabled:{value:!0,type:"boolean",reflectToAttribute:!1},current:{value:"",type:"string",reflectToAttribute:!1},storage:{value:null,type:"any",reflectToAttribute:!1},autoSave:{value:!1,type:"boolean",reflectToAttribute:!1},autoLoad:{value:!1,type:"boolean",reflectToAttribute:!1},allowLocalStorage:{value:!0,type:"boolean",reflectToAttribute:!1},options:{value:[],type:"array",reflectToAttribute:!1},onStateChange:{value:null,type:"any",reflectToAttribute:!1}},type:"object",reflectToAttribute:!1},checkBoxes:{value:{visible:{value:!1,type:"boolean"},hasThreeStates:{value:!1,type:"boolean"}},type:"object"},selection:{value:{enabled:{value:!1,type:"boolean"},allowRowHeaderSelection:{value:!1,type:"boolean"},allowColumnHeaderSelection:{value:!1,type:"boolean"},allowRowSelection:{value:!0,type:"boolean"},allowCellSelection:{value:!1,type:"boolean"},allowDragSelection:{value:!0,type:"boolean"},allowDragSelectionAutoScroll:{value:!0,type:"boolean"},allowCellDragSelectionHandle:{value:!0,type:"boolean"},allowCellDragDropSelectionHandle:{value:!0,type:"boolean"},allowCellDragSelectionAutoFill:{value:!0,type:"boolean"},selectAllMode:{value:"page",allowedValues:["none","page","all"],type:"string"},mode:{value:"many",type:"string",allowedValues:["one","many","extended"]},action:{value:"click",type:"string",allowedValues:["none","click","doubleClick"]},checkBoxes:{value:{enabled:{value:!1,type:"boolean"},autoShow:{value:!1,type:"boolean"},action:{value:"click",type:"string",allowedValues:["none","click","doubleClick"]},selectAllMode:{value:"page",allowedValues:["none","page","all"],type:"string"},position:{value:"near",allowedValues:["near","far"],type:"string"}},type:"object"},selected:{value:"",type:"string"},tabKeyBehavior:{value:"default",allowedValues:["none","default"],type:"string"},defaultSelection:{value:!1,type:"boolean"}},type:"object"},sorting:{value:{enabled:{value:!1,type:"boolean"},sort:{value:[],type:"array"},mode:{value:"one",allowedValues:["one","many"],type:"string"},maintainSort:{value:!0,type:"boolean"},commandKey:{value:"",allowedValues:["","Shift","Control","Alt"],type:"string"},sortToggleThreeStates:{value:!0,type:"boolean"},sortToggleOnClick:{value:!0,type:"boolean"},sortToggleOnClickAndCommandKey:{value:!1,type:"boolean"}},type:"object"},storeHistory:{value:!1,type:"boolean"},storeHistoryItems:{value:20,type:"number"},users:{value:[],type:"array",reflectToAttribute:!1},virtualModeCachedRowsCount:{value:100,type:"int"}}}static get requires(){return{}}static get styleUrls(){return["smart.menu.css","smart.filterpanel.css","smart.pager.css","smart.grid.css","smart.textbox.css"]}template(){return"<div class='smart-container'id='container' disabled='[[disabled]]' role='grid'>\n <div id='header' role=\"toolbar\" class='smart-grid-header smart-hidden'>\n </div>\n <div id='groupHeader' role=\"presentation\" class='smart-grid-group-header smart-hidden'></div>\n <div id='headerPager' top class='smart-grid-pager smart-hidden'></div>\n <div id='headerCommandBar' header top class='smart-grid-header smart-grid-command-bar smart-hidden'></div>\n <div id='content' class='smart-grid-content'>\n <div id='columnHeader' role=\"rowgroup\" class='smart-grid-column-header'>\n <div id='columnNearContainer' role=\"row\" class='near smart-hidden smart-grid-column-header-cell-container'>\n </div>\n <div id='columnContainer' role=\"row\" class='center smart-grid-column-header-cell-container'>\n </div>\n <div id='columnFarContainer' role=\"row\" class='far smart-hidden smart-grid-column-header-cell-container'>\n </div>\n </div>\n <div id='scrollView' role=\"rowgroup\" class ='smart-grid-scroll-view'>\n <div id='rowNearContainer' role=\"presentation\" class='near smart-hidden smart-grid-row-container'>\n </div>\n <div id='rowContainer' role=\"presentation\" class='center smart-grid-row-container'>\n </div>\n <div id='rowFarContainer' role=\"presentation\" class='far smart-hidden smart-grid-row-container'>\n </div>\n <div id='placeholder' class ='smart-hidden smart-placeholder smart-grid-placeholder'></div>\n <smart-scroll-bar right-to-left=\"[[rightToLeft]]\" theme=\"[[theme]]\" id='verticalScrollBar' class='smart-grid-scroll-bar' wait disabled='[[disabled]]' orientation='vertical'></smart-scroll-bar>\n <smart-scroll-bar right-to-left=\"[[rightToLeft]]\" theme=\"[[theme]]\" id='horizontalScrollBar' class='smart-grid-scroll-bar' wait disabled='[[disabled]]'></smart-scroll-bar>\n </div>\n <div id='filterFooter' class='smart-grid-filter-footer smart-hidden'></div>\n </div>\n <div class=\"smart-grid-view-content smart-hidden\" id=\"viewContent\"></div>\n <div class=\"smart-grid-view-bar smart-hidden\" id=\"viewBar\"></div>\n <div id='loadingIndicatorContainer' class='smart-loader-container'>\n <span id='loadingIndicator' class='smart-grid-loader smart-loader'></span>\n <span id='loadingIndicatorPlaceholder' class ='smart-loader-label smart-hidden'></span>\n </div>\n <div id='footerCommandBar' footer class='smart-grid-footer smart-grid-command-bar smart-hidden'></div>\n <div id='footerPager' class='smart-grid-pager smart-hidden'></div>\n <div id='footer' class='smart-grid-footer smart-hidden'></div>\n </div>"}static get listeners(){return{focus:"_focusHandler",blur:"_blurHandler",wheel:"_mouseWheelHandler","document.up":"_upHandler","document.down":"_downHandler","document.move":"_moveHandler","document.scroll":"_scrollHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",resize:"_resizeHandler","header.click":"_headerClickHandler","columnHeader.down":"_columnDownHandler","columnHeader.click":"_columnClickHandler","columnHeader.move":"_columnMoveHandler","columnHeader.mouseleave":"_columnMouseLeaveHandler","rowNearContainer.down":"_rowDownHandler","rowContainer.down":"_rowDownHandler","rowFarContainer.down":"_rowDownHandler","container.selectstart":"_selectStartHandler",styleChanged:"_styleChangedHandler",swipeleft:"_swipeLeftHandler",swiperight:"_swipeRightHandler",contextmenu:"_contextMenuHandler","document.paste":"_clipboardPasteHandler"}}_clipboardPasteHandler(e){if("paste"===e.type){const t=this;if(document.activeElement!==t)return;if(t._selection&&t._selection.focusedCell){const o=t._selection.focusedCell.id,l=t._selection.focusedCell.dataField,a=t.columnByDataField[l];if(!a)return;if(a&&("image"===a.template||"attachment"===a.template)){e.preventDefault();let a=(e.clipboardData||e.originalEvent.clipboardData).items,n=null,i=0,r=0,s=[];for(let e=0;e<a.length;e++)if(0===a[e].type.indexOf("image")&&(n=a[e].getAsFile(),i++,null!==n)){let e={label:n.name,size:n.size},a=new FileReader;a.onload=function(a){r++;const n=a.target.result;e.value=n;let d=!1;for(let o=0;o<t.uploadSettings.userFiles.length;o++){const l=t.uploadSettings.userFiles[o];if(l.name===e.label||l.label===e.label){d=!0;break}}if(d||t.uploadSettings.userFiles.push(e),s.push(e),r===i){let e=t.getCellValue(o,l);e||(e=[]),"string"==typeof e&&(e=JSON.parse(e)),e=[...e,...s],t.setCellValue(o,l,e)}},a.readAsDataURL(n)}}}}}_contextMenuHandler(e){if(this.contextMenu.enabled)return e.preventDefault(),e.stopPropagation(),!1}get _tabindex(){return this.disabled||this.unfocusable?"":' tabindex="0"'}pageIndexValidator(e,t){const o=this;if(t<0)return 0;if(o.dataSource){if(o.dataSource.virtualDataSource)return t;const e=Math.ceil(o.dataSource.length/o._pageSize);if(t>e-1)return e-1}}_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)}}getBoundingRect(e){const t=this;let o=window.pageXOffset,l=window.pageYOffset,a=e.getBoundingClientRect();if(e!==document.body){let a=e.parentNode;for(;a!==document.body&&a;){a&&(o+=a.scrollLeft,l+=a.scrollTop);let e=a;a?(a=a.parentNode,t.enableShadowDOM&&a===t.shadowRoot?a=t:!t.isInShadowDOM||a!==t.getRootNode()&&e!==t.getRootNode()||(a=t.getRootNode().host)):t.isInShadowDOM&&(a=t.getRootNode().host)}}return{bottom:a.bottom+l,height:a.height,left:a.left+o,right:a.right+o,top:a.top+l,width:a.width}}_downHandler(e){this._downTarget=e.originalEvent.target}_removeCellContentPopup(){const e=this;e._cellContentPopup&&(e._cellContentPopup.remove(),e._cellContentPopup=null),e._cellContentPopupTimer&&(clearTimeout(e._cellContentPopupTimer),e._cellContentPopupTimer=null)}_upHandler(e){const t=this,o=t.getBoundingRect(t);super._upHandler(),t._tapTimer&&clearTimeout(t._tapTimer);const l=()=>{t.editing.isEditing&&!t.editing.dialog.enabled&&setTimeout((()=>{if(!e.defaultPrevented){if(t.editing.editCell&&t.editing.editCell.editor.instance){const o=t.editing.editCell.editor.instance;if(o.element&&o.element.hasAttribute("aria-owns")){const t=o.element.getAttribute("aria-owns"),l=document.getElementById(t);if(l&&l.contains(e.originalEvent.target))return}if(t.editing.editCell.editor.instance.blur(e),e.defaultPrevented)return}t.isAttached&&t.endEdit()}}),50)};if(e.originalEvent&&(e.originalEvent.target===t.$.scrollView&&t._downTarget===e.originalEvent.target&&l(),e.originalEvent.target.closest(".smart-grid-dialog")))t._dialogDragDetails&&(t._dialogDragDetails.started=!1);else{if(e.pageX<o.left||e.pageX>o.right||e.pageY<o.top||e.pageY>o.bottom){let o=!1,a=e.originalEvent.target;for(;a;)if(a=a.parentNode,a===t){o=!0;break}if(o)return t._dragSelectionEnd(e),t._endResize(e),void t._endDrag(e);if(t._summaryRowDialog&&t._summaryRowDialog.classList.contains("open")&&t._summaryRowDialog.confirm(),t._inputOverlay&&(t._inputOverlay.classList.remove("smart-input-overlay-on"),setTimeout((()=>{t._inputOverlay&&(t._inputOverlay.parentNode&&t._inputOverlay.parentNode.removeChild(t._inputOverlay),t._inputOverlay=null)}),t.behavior.doubleClickTimingDelay)),l(),t.menu){let o,l,a,n;if(t.enableShadowDOM||t.isInShadowDOM?(o=e.originalEvent.composedPath()[0],l=function(){let e=o.getRootNode().host;for(;e;){if(e===t)return e;e=e.getRootNode().host}}(),a=t.menu.contains(o)||t.menu.firstElementChild.shadowRoot.contains(o),n=t.menu.firstElementChild.shadowRoot):(o=e.originalEvent.target,l=t.contains(o),a=t.menu.contains(o),n=t.menu),!l&&!a){const e=n.querySelectorAll("smart-drop-down-list"),l=n.querySelectorAll("smart-date-time-picker"),a=n.querySelectorAll("smart-date-input"),i=n.querySelectorAll("smart-input");for(let t=0;t<e.length;t++)if(e[t].$.dropDownContainer.contains(o))return;for(let e=0;e<l.length;e++)if(l[e].$.dropDownContainer.contains(o))return;for(let e=0;e<a.length;e++)if(a[e].$.scrollView.contains(o))return;for(let e=0;e<i.length;e++)if(i[e].$.scrollView.contains(o))return;return void t.closeMenu()}}}t._summaryRowDialog&&t._summaryRowDialog.classList.contains("open")&&t._summaryRowDialog.confirm(),t._dragSelectionEnd(e),t._endResize(e),t._endDrag(e)}}_nextColumn(e){const t=this;for(let o=0;o<t.viewColumns.length;o++){const l=t.viewColumns[o];if(l.visibleIndex===e.visibleIndex+1)return l}return null}_nextRow(e){const t=this._recyclingRows,o=t.indexOf(e);return o>=0?t[o+1]:null}_moveHandler(e){const t=this;if(t.isInitialized&&t._selection){if(t.selection.enabled&&t.selection.allowDragSelection&&!t.editing.isEditing&&(!t._selection.selectionRect||t._selection.selectionRect&&!t._selection.selectionRect.captured)&&(!0!==t._mobile&&t._dragSelection(e),e.originalEvent)){const o=e.originalEvent.target.closest?e.originalEvent.target:void 0;Smart.Utilities.Core.isMobile&&o&&o.closest("smart-grid")===t&&e.originalEvent.preventDefault()}t.isScrolling||("none"===t.behavior.columnResizeMode||t.classList.contains("smart-grid-row-resize-mode")||t._columnMoveResizeHandler(e),"none"===t.behavior.rowResizeMode||t.classList.contains("smart-grid-column-resize-mode")||t._rowMoveResizeHandler(e),t._drag(e))}}_hideActionButtons(){const e=this;if(e._columnElements){for(let t=0;t<e._columnElements.length;t++){const o=e._columnElements[t],l=o.column;l&&l.autoShowActionButton&&o._hideActionButton()}for(let t=0;t<e._frozenNearColumns.length;t++){const o=e._frozenNearColumns[t],l=o.element;o&&o.autoShowActionButton&&l._hideActionButton()}}}_columnMouseLeaveHandler(){this._mobile||this._hideActionButtons()}_columnMoveHandler(e){const t=this;if(!t.isInitialized)return;if(t._columnResizeStartLine||t._rowResizeStartLine)return;if(t._mobile)return;const o=(o,l)=>{if(o&&o.autoShowActionButton){const a=l.getBoundingClientRect(),n=t.offset(l),i=t.parentElement,r=i?i.scrollTop:0;if(n.left<=e.pageX&&n.left+a.width-6>=e.pageX)if(n.top-r<=e.pageY&&n.top-r+a.height>=e.pageY){if(!t.hasColumnMenu(o))return;l._showActionButton()}else l._hideActionButton();else l._hideActionButton()}};for(let e=0;e<t._columnElements.length;e++){const l=t._columnElements[e];o(l.column,l)}for(let e=0;e<t._frozenNearColumns.length;e++){const l=t._frozenNearColumns[e];o(l,l.element)}}_headerClickHandler(e){const t=this;if(t.$.headerBar){const o=t.isInShadowDOM||t.shadowRoot?e.composedPath()[0]:e.target;t.$.headerBar._headerClickHandler(o,t)}}_columnClickHandler(e){const t=this;if(t._overlay)return;if(void 0===e.clientX)return;const o=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let l=null,a=null;const n=new Date-t._columnClickTime<t.behavior.doubleClickTimingDelay;t._columnClickTime=new Date;for(let e=0;e<o.length;e++){const t=o[e];if(t.classList.contains("smart-action-button"))return;if(t.getAttribute("data-field")){l=t.getAttribute("data-field"),a=t;break}}if(l){const o=a.column;if(!o)return;if(e.srcElement.classList.contains("smart-filter-button"))return;if("_addNewColumn"===o.dataField)return void t._openAddColumnDialog();if(Smart.Utilities.Core.isMobile)n&&t.sorting.sortToggleOnClick&&o.allowSortToggleOnClick&&t.sorting.enabled&&(t.sortBy(l),t.autoSaveState()),t._columnMoveHandler(e),e.originalEvent&&e.originalEvent.preventDefault();else if(!n&&t.sorting.sortToggleOnClick&&o.allowSortToggleOnClick&&t.sorting.enabled){if("none"!==t.behavior.columnResizeMode&&"col-resize"===o.element.style.cursor)return;if(t._canSort=!0,""!==t.sorting.commandKey){if("Alt"===t.sorting.commandKey&&!1===e.altKey&&(t._canSort=!1),"Shift"===t.sorting.commandKey&&!1===e.shiftKey&&(t._canSort=!1),"Control"===t.sorting.commandKey&&!1===e.metaKey&&!1===e.ctrlKey&&(t._canSort=!1),"Control"!==t.sorting.commandKey&&e.ctrlKey)return;if(!0===t.sorting.sortToggleOnClickAndCommandKey&&!t._canSort)return}t.sortBy(l),t.autoSaveState()}}}_columnDownHandler(e){const t=this,o=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(e.clientX,e.clientY);let l=null,a=null;const n=new Date-t._clickTime<t.behavior.doubleClickTimingDelay;t.$.headerBar&&t.$.headerBar.closePanel(),t._doubleClickHandler(e);for(let e=0;e<o.length;e++){const t=o[e];if(t.classList.contains("smart-action-button"))return;if(t.getAttribute("data-field")){l=t.getAttribute("data-field"),a=t;break}}if(l){const o=a.column;if(!o)return;if("_commandColumn"===l)return void(t.editing.commandColumn.dataSource.commandColumnMenu.visible&&t._applyCommand(t.editing.commandColumn.dataSource.commandColumnMenu.command));const i=function(a){const n=o.selectionColumn?t.selection.checkBoxes.action===a&&t.selection.enabled:t.selection.action===a&&t.selection.enabled;if("col-resize"!==o.element.style.cursor&&(!t.appearance.showColumnHeaderDragIcon||!e.originalEvent.target.classList.contains("smart-drag-handle"))&&n){if(t.editing.enabled&&t.editing.editColumn===o)return;if(e.shiftKey||e.ctrlKey?t._dragSelectionStartDataField=null:t._dragSelectionStartDataField=l,"_checkBoxColumn"===l)return void t._toggleColumnSelection(o);"_rowHeaderColumn"===l&&t.selection.enabled&&t.selection.allowRowHeaderSelection&&t.appearance.showRowHeaderSelectIcon&&(delete t._areAllRowsSelected,t.areAllRowsSelected()?t.clearSelection():t.selectAllRows(),o.refresh()),t.selection.allowColumnHeaderSelection&&o.allowSelect&&t._setSelection(null,o.dataField,e)}};if(t.editing.isEditing&&t.endEdit(),i("click"),t._mobile){t._hideActionButtons();const o=(o,l)=>{if(o&&o.autoShowActionButton){const a=l.getBoundingClientRect(),n=t.offset(l);if(n.left<=e.pageX&&n.left+a.width-6>=e.pageX){if(!t.hasColumnMenu(o))return;l._showActionButton()}else l._hideActionButton()}};for(let e=0;e<t._columnElements.length;e++){const l=t._columnElements[e];o(l.column,l)}}if(t.$.fireEvent("columnClick",{column:o,dataField:o.dataField}),n&&(t.$.fireEvent("columnDoubleClick",{column:o,dataField:o.dataField}),i("doubleClick"),t._onColumnDoubleClick(o,e)),t._columnToResizeElement&&!t._columnResizeLine)return t._columnDownResizeHandler(e),void(t._clickTime=new Date);if(t._beginDrag(e,o),o.menu)return void(t._clickTime=new Date)}t.closeMenu(),t._clickTime=new Date}addTransformMoveStyle(e,t,o,l,a,n){e.style.opacity=n,e.style["transition-duration"]=t,e.style.transform="translate3d("+o+"px,"+l+"px,"+a+"px)"}removeTransformMoveStyle(e){e.style.opacity="",e.style["transition-duration"]="",e.style.transform=""}_rowDownHandler(e){const t=this;if(t._inputOverlay&&t._inputOverlay.classList.remove("smart-input-overlay-on"),t._doubleClickHandler(e),t._closeMenu(t.menu),t._rowResizeHandler(e),t._removeCellContentPopup(),t._toggledRow&&t.appearance.allowRowToggleAnimation)return;if(e.target&&!e.target.classList.contains("smart-grid-row-container")&&!e.target.classList.contains("smart-grid-selection-overlay")&&!e.target.classList.contains("smart-selection-overlay-content"))return;let o=e.clientX,l=e.clientY;e.touches&&(o=e.touches[0].clientX,l=e.touches[0].clientY);const a=(t.enableShadowDOM?t.shadowRoot:t.getRootNode()).elementsFromPoint(o,l);let n=null,i=null,r=null,s=null,d=null,u=null,c=null;t._lastPointerDownTime=new Date;for(let e=0;e<a.length;e++){const t=a[e];if(t.hasAttribute("toggle-button")&&(i=t),t.hasAttribute("add-row")&&(d=t),t.hasAttribute("checkbox")&&(r=t),t.hasAttribute("rating-value")&&(u=t),s||"smart-grid-cell"!==t.nodeName.toLowerCase()||(s=t),!c&&t.classList.contains("smart-card")&&(c=t),!n&&"smart-grid-row"===t.nodeName.toLowerCase()){n=t;break}}if("card"!==t.view){if(u&&(t._ratingElement=u),n&&s){const o=s?s.cell:null;if(o.row.filterRow||t._closeMenu(t.filterRowMenu),i&&o&&!o.column.rowDetailColumn&&i!==o.row.toggleDetailButton&&!i.classList.contains("row-detail"))n.row.toggle(e);else if(t.rowDetail.enabled&&t.rowDetail.visible&&i&&o&&o.column.rowDetailColumn){const e=n.row;t.editing.isEditing&&t.cancelEdit(),e.showDetail?t.hideDetail(e.id):t.showDetail(e.id)}else if(d){const e=n.row,o=e.data;let l=o.parent;const a={};for(a[o.groupDataField]=null!==e.label?e.label:null,void 0!==e.labelValue&&(a[o.groupDataField]=e.labelValue);l;){let e=null!==l.label?l.label:null;l.labelValue&&void 0!==e&&(e=l.labelValue),a[l.groupDataField]=e,l=l.parent}t.addRow(a)}else{const o=n.row,l=s?s.cell:null;if(l.column._treeColumn&&r)return void(o.checked=!o.checked);l.element===o.header&&t.behavior.allowRowReorder&&t._beginDrag(e,o),t._tapTimer&&clearTimeout(t._tapTimer),t._tapTimer=setTimeout((function(){t._clickedRow===n&&t.$.fireEvent("rowTap",{row:o,id:o.id,originalEvent:e.originalEvent}),t._clickedCell===s&&t.$.fireEvent("cellTap",{cell:l,id:o.id,dataField:l.column.dataField,originalEvent:e.originalEvent})}),t.behavior.doubleClickTimingDelay);const a=function(a){if(!t.selection.enabled||o.autoGenerated||!0!==o.allowSelect)return void delete t.__selectionStarted;if(o.header&&"row-resize"===o.header.style.cursor){const l=t.offset(o.header);if(t._rowToResize&&l.left<=e.originalEvent.pageX&&e.originalEvent.pageX<=l.left+o.header.offsetWidth)return;o.header.style.cursor=""}const i=t.editing.isEditing;if(i&&t.editing.editCell&&t.editing.editCell.row.id===o.id&&t.editing.editCell.column.dataField===l.column.dataField)return;if(i&&t.editing.editRow&&t.editing.editRow.id===o.id)return;const r=()=>{t.focus(),setTimeout((function(){t.focus()}),50)};if(t.selection.action===a){if(e.shiftKey||e.ctrlKey||!t.selection.allowRowHeaderSelection&&l.column.autoGenerated?t._dragSelectionStartRow=null:t._dragSelectionStartRow=n.row,e.shiftKey||e.ctrlKey?t._dragSelectionStartDataField=null:t._dragSelectionStartDataField=l.column.dataField,l.column.rowHeaderColumn&&!t.selection.allowRowHeaderSelection)return t._dragSelectionStartRow=null,void r();t._setSelection(o.id,l.column.dataField,e),r()}else(l.column.selectionColumn&&t.selection.checkBoxes.enabled&&t.selection.checkBoxes.action===a||l.column.rowHeaderColumn&&t.selection.allowRowHeaderSelection)&&(t._setSelection(o.id,l.column.dataField,e),r())},i=l.selected;t._clickTime||(t._clickTime=new Date);const d=t._clickedCell===s&&new Date-t._clickTime<t.behavior.doubleClickTimingDelay,u=e.originalEvent?e.originalEvent:e,c=3===u.which;if(c||"_commandColumn"===l.column.dataField||a("click"),t.$.fireEvent("rowClick",{row:o,id:o.id,data:t.getRowData(o.id),isRightClick:c,originalEvent:u,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}),t.$.fireEvent("cellClick",{cell:l,id:o.id,dataField:l.column.dataField,value:l.value,isRightClick:c,originalEvent:u,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}),c&&t.contextMenu.enabled)return t.contextMenu.id=o.id,t.contextMenu.dataField=l.column.dataField,t._focusCell(o.id,l.column.dataField),t.openContextMenu(u.pageX+10,u.pageY+10),void(t.contextMenu.selector&&(u.stopPropagation(),u.preventDefault()));if(o.autoGenerated||l.column.autoGenerated||"checkBox"===l.template&&e.originalEvent&&e.originalEvent.target&&e.originalEvent.target.classList.contains("smart-input"))t._onRowClick(o.index,o,e),t._onCellClick(l,e);else if(t.selection.enabled)if(t.selection.allowCellSelection)if("extended"===t.selection.mode){if(!0===i&&i===l.selected&&!t.selection.isDragging){const a=t._selection.focusedCell;a&&t._clickedCell&&a.id===l.row.id&&a.dataField===l.column.dataField&&a.id===t._clickedCell.cell.row.id&&a.dataField===t._clickedCell.cell.column.dataField&&(t._onRowClick(o.index,o,e),t._onCellClick(l,e))}}else d||(t._onRowClick(o.index,o,e),t._onCellClick(l,e));else if(t.selection.allowRowSelection)if("extended"===t.selection.mode){if(!0===i&&i===l.selected&&!t.selection.isDragging){const a=t._selection.focusedCell;t._clickedCell&&a.id===l.row.id&&a.id===t._clickedCell.cell.row.id&&(t._onRowClick(o.index,o,e),t._onCellClick(l,e))}}else d||(t._onRowClick(o.index,o,e),t._onCellClick(l,e));else t._onRowClick(o.index,o,e),t._onCellClick(l,e);else t._onRowClick(o.index,o,e),t._onCellClick(l,e);new Date-t._clickTime<t.behavior.doubleClickTimingDelay&&(t._clickedRow===n&&(t._onRowDoubleClick(o.index,o,e,e),t.$.fireEvent("rowDoubleClick",{row:o,id:o.id,data:t.getRowData(o.id),isRightClick:c,originalEvent:e.originalEvent,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}),a("doubleClick")),t._clickedCell===s&&(t._onCellDoubleClick(l,e),t.$.fireEvent("cellDoubleClick",{cell:l,id:o.id,dataField:l.column.dataField,value:l.value,isRightClick:c,originalEvent:e.originalEvent,pageX:parseInt(u.pageX),pageY:parseInt(u.pageY)}))),t._clickedRow=n,t._clickedCell=s,t._clickTime=new Date,t.layout.allowCellsWrapShortcut&&t._clickedCell.hasAttribute("focus")&&t._clickedCell.hasAttribute("selected")&&e.shiftKey&&(t._cellContentPopupTimer&&clearTimeout(t._cellContentPopupTimer),t.selection.isDragging?t._removeCellContentPopup():l.autoWrap())}}}else if(c){const o=c.getAttribute("row-id"),l=t.rowById[o];if(l){const a=e.originalEvent?e.originalEvent:e,n=3===a.which;if(l.element||l.createElement(),t.$.fireEvent("rowClick",{row:l,id:l.id,data:t.getRowData(l.id),isRightClick:n,originalEvent:a,pageX:parseInt(a.pageX),pageY:parseInt(a.pageY)}),s){const e=s.getAttribute("data-field");if(e){const o=t.columnByDataField[e],i=new Smart.Grid.Cell(l,o,this);s.cell=i,i.element=s,i&&t.$.fireEvent("cellClick",{cell:i,id:l.id,dataField:i.column.dataField,value:i.value,isRightClick:n,originalEvent:a,pageX:parseInt(a.pageX),pageY:parseInt(a.pageY)})}}const i=e.originalEvent.target;if(c.classList.contains("smart-card-header"))l.element&&l.element.row!==l&&(l.element.row=l),l.toggle();else if(l.children&&l.children.length>0&&(i.classList.contains("smart-icon-ungroup")||i.classList.contains("smart-icon-group")))l.element&&l.element.row!==l&&(l.element.row=l),l.toggle();else if(t.editing.enabled){const e=t.editing.dialog.enabled,l=t.editing.mode,a=t.context;t.context=t,t.editing.dialog.enabled=!0,t.editing.mode="row",t._settingsDialogRowId=o;let n=t._isUpdating;c.setAttribute("edit",""),t.beginEdit(o),t._isUpdating=n,t._endCardRowEdit?(t.removeEventListener("endEdit",t._endCardRowEdit,null),t.removeEventListener("cancelEdit",t._endCardRowEdit,null)):t._endCardRowEdit=()=>{t.context=t,t.editing.dialog.enabled=e,t.editing.mode=l,t.editing.isEditing=!1,t.context=a,delete t._settingsDialogRowId,delete t._dialogEdit},t.addEventListener("endEdit",t._endCardRowEdit),t.addEventListener("cancelEdit",t._endCardRowEdit)}}}}showDetail(e){const t=this.rowById[e];t&&(t.showDetail=!0)}hideDetail(e){const t=this.rowById[e];t&&(t.showDetail=!1)}_focusHandler(){this._focused=!0,this.setAttribute("focus","")}_blurHandler(){this._focused=!1,this.removeAttribute("focus")}_notify(e,t,o){const l=this;if(l.notifyFn)for(let a=0;a<l.notifyFn.length;a++)l.notifyFn[a](e,t,o)}notify(e){const t=this;e&&(t.notifyFn||(t.notifyFn=[]),t.notifyFn.push(e))}_applyTemplate(e,t){let o=null;if(null!==e&&""!==e)if(e&&"function"==typeof e)e(t);else if((e.startsWith("#")||e.startsWith("."))&&(o=document.querySelector(e)),o)t.innerHTML="",o instanceof HTMLElement&&!(o instanceof HTMLTemplateElement)?t.appendChild(o):t.appendChild(o.content.cloneNode(!0).firstElementChild);else{const o=function(e){const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild}(e);o&&(t.innerHTML="",t.appendChild(o))}else t.innerHTML=""}propertyChangedHandler(e,t,o){const l=this;if(l.isInitialized){switch(l._notify(e,t,o),e){case"onRowHistory":case"onRowInserted":case"stateSettings_current":return;case"view":return void(l.$.headerBar&&l.$.headerBar._setView&&l.$.headerBar._setView(o,!0));case"users":case"currentUser":l._refreshCurrentUser(),l._recycle();break;case"summaryRow_visible":{for(let e=0;e<l.columns.length;e++)l._summaryRowCount=Math.max(l._summaryRowCount,l.columns[e].summary.length);const e=l.onRowInserted;l.onRowInserted=null,l._renderRows(!0),l.onRowInserted=e;break}case"conditionalFormatting":return l._renderConditionalFormatting(),void l.refresh();case"appearance_displayLoadingIndicator":return void l._setLoadingIndicatorVisibility();case"appearance_placeholder":return void(l.$.placeholder.innerHTML=o);case"appearance_showColumnHeaderLines":case"appearance_showColumnGroupLines":case"appearance_showColumnLines":case"appearance_showRowLines":return void l._recycle();case"appearance_allowColumnStickyPosition":o?l._stickHeader():l._unstickHeader();break;case"appearance_showColumnIcon":for(let e=0;e<l.columns.length;e++)l.columns[e].setProperty("showIcon",l.appearance.showColumnIcon);l._recycle();break;case"appearance_showRowHeaderNumber":case"appearance_showRowHeader":{l._initializeRowNumberColumn();const e=l._frozenNearColumns[0];e.rowHeaderColumn&&e.element&&!e.element.parentNode&&l.$.columnNearContainer.appendChild(e.element),l.refresh();break}case"header_visible":l.header.visible&&""===l.header.template&&(l.$.header.innerHTML='<smart-grid-toolbar header-position="top"></smart-grid-toolbar>',l.$.headerBar=l.$.header.firstElementChild,l.$.headerBar._init(l),l.header.onInit&&l.header.onInit(l.$.headerBar));break;case"header_buttons":l.header.visible&&""===l.header.template&&l._refreshHeaderBar();break;case"header_template":l._applyTemplate(o,l.$.header);break;case"footer_template":l._applyTemplate(o,l.$.footer);break;case"layout_columnWidth":case"columnWidth":{l.columns.canNotify=!1;let e=parseInt(o);if(isNaN(e)&&(e=null),e>=30||null===e)for(let t=0;t<l.columns.length;t++)l.columns[t].width=e;l.columns.canNotify=!0,l.refresh();break}case"checkBoxes_visible":return void l._recycle();case"checkBoxes_hasThreeStates":return l.rows.canNotify=!1,l._applyThreeStates(l.rowHierarchy),l.rows.canNotify=!0,void l._recycle();case"columnHeader_visible":l.__columnHeaderHeight=null,l.refresh();break;case"selection_checkBoxes_enabled":l._selectionColumn.visible=o;break;case"selection_checkBoxes_autoShow":l._selectionColumn.element&&(o?l._selectionColumn.element.setAttribute("auto-show",""):l._selectionColumn.element.removeAttribute("auto-show"));break;case"selection_checkBoxes_position":{let e=l.viewColumns.indexOf(l._selectionColumn);l.viewColumns.canNotify=!1,l.viewColumns.splice(e,1);const t=l._frozenNearColumns.indexOf(l._selectionColumn),a=l._frozenFarColumns.indexOf(l._selectionColumn);if(t>=0&&l._frozenNearColumns.splice(t,1),a>=0&&l._frozenFarColumns.splice(a,1),"far"===o)l._selectionColumn.canNotify=!1,l._selectionColumn.freeze="far",l._selectionColumn.canNotify=!0,l._frozenFarColumns.splice(0,0,l._selectionColumn),l.viewColumns.push(l._selectionColumn),l.$.columnFarContainer.appendChild(l._selectionColumn.element);else{let e=0,t=0;for(let o=0;o<l.viewColumns.length&&(l.viewColumns[o].autoGenerated||l.viewColumns[o].dataField!==l.columns[t++].dataField);o++)l.viewColumns[o].autoGenerated&&e++;l._selectionColumn.canNotify=!1,l._selectionColumn.freeze="near",l._selectionColumn.canNotify=!0,l._frozenNearColumns.splice(e,0,l._selectionColumn),l.viewColumns.splice(e,0,l._selectionColumn),l.$.columnNearContainer.appendChild(l._selectionColumn.element)}l.viewColumns.canNotify=!0;break}case"selection_mode":if(l._selection&&(l._selection.focusedCell=null),l.selection.allowCellSelection)l.clearSelection();else if("one"===o){const e=l.getSelection();if(l.clearSelection(),e.rows&&e.rows[0]){e.rows[0].row.selected=!0;const t=l.rowById[e.rows[0].row.id].getCell(l.columns[0].dataField);l._selection.focusedCell={id:t.row.id,dataField:t.column.dataField,value:t.value,index:t.row.index}}}break;case"grouping_groupBy":return l.dataSource&&l.dataSource.groupBy&&(l.dataSource.groupBy=o),void l.refresh();case"sorting_enabled":return void l.refresh();case"sorting_maintainSort":return void l._recycle(!1);case"filtering_enabled":return o&&0===l._filterPanels.length&&l._createFilterPanels(),void(l.header.visible&&l.refresh());case"filtering_filterRow_visible":return l._initializeRows(),l._initializeRowElements(),void l.refresh();case"filtering_operator":return void l.refreshFilters();case"filtering_filter":for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.canNotify=!1,t.setProperty("filter",null),t.canNotify=!0}for(let e=0;e<l.filtering.filter.length;e++){const t=l.filtering.filter[e];if(t&&t.splice){const e=t[0],o=t.splice(1);let a=null;if(o instanceof Smart.FilterGroup)a=o;else{const t=l.columnByDataField[e];t&&(a=l.dataSource._createFilter(t.dataType,o))}a&&l.addFilter(e,a,!1)}}return void l.refreshFilters();case"messages":case"locale":{if(l.columns)for(let e=0;e<l.columns.length;e++)l.columns[e]._cellsCachedValues=[];l._dialogEdit&&(l._dialogEdit.close(),l._dialogEdit=null),l._dialogDelete&&(l._dialogDelete.close(),l._dialogDelete=null),l._dialogAddRow&&(l._dialogAddRow.close(),l._dialogAddRow=null);const e=l.$.headerPager.querySelector("smart-pager"),t=l.$.footerPager.querySelector("smart-pager");e&&(e.locale=l.locale),t&&(t.locale=l.locale);const o=(e,t)=>{l._handleFilterMenuClick(e,t)};l._filterInfo||(l._filterInfo={}),l._filterInfo.stringConditions=[{icon:"smart-icon-contains",command:o,value:"CONTAINS",label:l.localize("CONTAINS")},{icon:"smart-icon-does-not-contain",command:o,value:"DOES_NOT_CONTAIN",label:l.localize("DOES_NOT_CONTAIN")},{icon:"smart-icon-starts-with",command:o,value:"STARTS_WITH",label:l.localize("STARTS_WITH")},{icon:"smart-icon-ends-with",command:o,value:"ENDS_WITH",label:l.localize("ENDS_WITH")},{icon:"smart-icon-equals",command:o,value:"EQUAL",label:l.localize("EQUAL")},{icon:"smart-icon-delete",command:o,value:"CLEAR_FILTER",label:l.localize("CLEAR_FILTER")}],l._filterInfo.numberAndDateConditions=[{icon:"smart-icon-equals",command:o,value:"EQUAL",label:l.localize("EQUAL")},{icon:"smart-icon-not-equal",command:o,value:"NOT_EQUAL",label:l.localize("NOT_EQUAL")},{icon:"smart-icon-less-than",command:o,value:"LESS_THAN",label:l.localize("LESS_THAN")},{icon:"smart-icon-less-than-equal",command:o,value:"LESS_THAN_OR_EQUAL",label:l.localize("LESS_THAN_OR_EQUAL")},{icon:"smart-icon-greater-than",command:o,value:"GREATER_THAN",label:l.localize("GREATER_THAN")},{icon:"smart-icon-greater-than-equal",command:o,value:"GREATER_THAN_OR_EQUAL",label:l.localize("GREATER_THAN_OR_EQUAL")},{icon:"smart-icon-between",command:o,value:"RANGE",label:l.localize("RANGE")},{icon:"smart-icon-delete",command:o,value:"CLEAR_FILTER",label:l.localize("CLEAR_FILTER")}],l._refreshHeaderBar(),l.$.headerBar&&(l.$.headerBar.messages=l.messages,l.$.headerBar.locale=l.locale,l.$.headerBar._localizeHeader(),l.$.headerBar._getInnerElementMessages()),l.grouping.groupBar.visible&&l._renderGroupBar(),l._recycle();break}case"paging_spinner_enabled":l._refresh();break;case"pager_visible":return l._renderPagers(),void l._refreshPaging(!1);case"paging_pageIndex":case"pager_position":case"paging_enabled":return void l._refreshPaging(!0);case"paging_pageSize":return void l._refreshPaging(!1);case"columns":{l.__measuredColumnHeight=null,l.editing&&l.editing.isEditing&&l.cancelEdit(),l._cellEditors=[];let e=!1;if(t&&t.length)for(let o=0;o<t.length;o++)if(t[o].freeze){e=!0;break}if(l.columns&&l.columns.length)for(let t=0;t<l.columns.length;t++)if(l.columns[t].freeze){e=!0;break}if(e&&l._initializeRowElements(),l.columns&&l._sortedColumns){const e=[];l.columns.forEach((t=>{t.sortOrder&&e.push(t)})),l._sortedColumns=JSON.parse(JSON.stringify(e))}l._renderColumns(),l._refreshHeaderBar();const o=l._sortedColumns;if(o){l.clearSort();for(let e=0;e<l.columns.length;e++)delete l.columns[e]._cellsCachedValues;l._refreshSort(o)}if(l.columns&&l.filtering.enabled){l.beginUpdate();for(let e=0;e<l.columns.length;e++){const t=l.columns[e];if(t.canNotify=!1,l.removeFilter(t.dataField),t.filtered=!1,t.canNotify=!0,t.filter){let e=null,o=t.filter;e=o instanceof Smart.FilterGroup?o:l.dataSource._createFilter(t.dataType||"string",o),e&&l.addFilter(t.dataField,e,!1)}}l.refreshFilters(),l.endUpdate()}return l.layout.isDirty=!0,l._resetCachedLayout(),void l._refreshLayout()}case"columnGroups":if(l._columnGroups=[],l._columnHeights=0,l.viewColumns)for(let e=0;e<l.viewColumns.length;e++){const t=l.viewColumns[e],o=t.element;t.top=0,t.level=0,o&&(o.style.top="",o.style.height="",o.style.lineHeight="")}return l.columns.canNotify=!1,l.columns=l._initColumns,l._renderColumns(),l.columns.canNotify=!0,l.__columnHeaderHeight=null,void l.refresh();case"dataSource":if(delete l._isFirstVirtualDataSourceRequest,"dataSource"===e&&t&&o){const e=l.dataSource&&l.dataSource.virtualDataSource&&!l.dataSource.virtualDataSourceOnExpand&&"infinite"!==l.scrolling;if(t instanceof Smart.DataAdapter&&!e&&t.length===o.length&&t.length>0&&o.length>0&&!l.dataSourceSettings.childrenDataField&&!l.dataSourceSettings.parentDataField&&!t.parentDataField){if(l.dataSource=t,l._cachedDataSource===o)return;return setTimeout((()=>{let e=null;if(t&&l.dataSource&&l.dataSource._expandedRowIds){let t={};for(let e in l.dataSource._expandedRowIds){let o=""+e;o=o.replace("Item","").replace(/_/gi,"."),t[o]=!0}e=t}if(l.beginUpdate(),l._sortedColumns&&l._sortedColumns.length>0&&void 0===l._getId())for(let e=0;e<o.length;e++){const t=l.dataSource[e],a=o[e];l._updateRow(t,a,!0)}else for(let e=0;e<o.length;e++){const t=o[e],a=l.dataSource[e].$.id;l._updateRow(a,t,!0)}delete l.__autoRowHeight,l._virtualOnExpandCache=[],l._cellsMerge=[],l._cellStyles=[];const a=l._filters,n=l._sortedColumns;if(l.clearSort(),l.filtering.filterRow)for(let e=0;e<l.columns.length;e++)l.columns[e]._filterEditorInitialized=!1;for(let e=0;e<l.columns.length;e++)delete l.columns[e]._cellsCachedValues;if(n&&l._refreshSort(n),a&&a.length>0&&(l._filters=null,l.refreshFilters()),l.grouping.enabled)for(let t in e)l._expandCollapseGroup(t,!0);l.endUpdate()})),l._cachedDataSource=o,void(l.header.visible&&""===l.header.template&&l.$.headerBar._init(l))}}return l.dataSource.length>1e4?(l.appearance.displayLoadingIndicator=!0,l._setLoadingIndicatorVisibility(),setTimeout((()=>{l.dataBind()}),100),setTimeout((()=>{l.appearance.displayLoadingIndicator=!1,l._setLoadingIndicatorVisibility(),l._recycle(!1)}),200)):l.dataBind(),void(l.header.visible&&""===l.header.template&&l.$.headerBar._init(l));case"rowDetail_dialog_width":case"rowDetail_dialog_height":case"rowDetail_dialog_enabled":case"rowDetail_dialog_visible":return;case"rowDetail_height":case"rowDetail_enabled":{l.beginUpdate(),l.rows.canNotify=!1;const e=l.appearance.allowRowDetailToggleAnimation;l.appearance.allowRowDetailToggleAnimation=!1;for(let e=0;e<l._recyclingRows.length;e++){const t=l._recyclingRows[e];t.height=null,t.setProperty("showDetail",!1),t.detailHeight=l.rowDetail.height}if(l.rows.canNotify=!0,l.rowDetail.enabled){let t=!1;for(let e=0;e<l.viewColumns.length;e++)if(l.viewColumns[e].rowDetailColumn){t=!0;break}if(!t)return l.appearance.allowRowDetailToggleAnimation=e,l.endUpdate(),void l._renderColumns(!0)}else for(let e=0;e<l.viewColumns.length;e++){const t=l.viewColumns[e];if(t.rowDetailColumn){t.visible=!1;break}}return l.appearance.allowRowDetailToggleAnimation=e,void l.endUpdate()}case"rowDetail_visible":for(let e=0;e<l.viewColumns.length;e++){const t=l.viewColumns[e];if(t.rowDetailColumn){t.visible=o;break}}return;case"displayLoadingIndicator":return void l._setLoadingIndicatorVisibility();case"filterable":return void l._refreshLayout();case"layout_allowCellsWrap":{const e=l.columns.canNotify;l.columns.canNotify=!1;for(let e=0;e<l.columns.length;e++)l.columns[e].cellsWrap=o;return l.layout.isDirty=!0,l._resetCachedLayout(),l._refreshLayout(),l.refresh(),void(l.columns.canNotify=e)}case"showViewBar":return l.layout.isDirty=!0,l._resetCachedLayout(),l._refreshLayout(),void l.refresh();case"layout_autoHeight":case"layout_autoWidth":case"layout_columnMinHeight":case"layout_rowMinHeight":case"layout_columnHeight":case"layout_rowHeight":return l.layout.isDirty=!0,l._resetCachedLayout(),l._refreshLayout(),void l.refresh();case"rightToLeft":return void l.refresh();case"selectionMode":return;case"editing_addNewColumn_visible":l._addNewColumn?(l._addNewColumn.visible=o,l.refresh()):l._renderColumns();break;case"editing_addNewRow_displayMode":{"row"===l.editing.addNewRow.displayMode&&l.editing.addNewRow._addButton&&(l.editing.addNewRow._addButton.remove(),delete l.editing.addNewRow._addButton);const e=l._scrollView.vScrollBar;return e.style.height="",e.style.top="",e.style.setProperty("--smart-scroll-bar-near-size","0px"),l._renderAddNewRow(),void l.refresh(!0)}case"editing_addNewRow_label":case"editing_addNewRow_visible":case"editing_addNewRow_position":return!1===l.editing.addNewRow.visible&&"button"===l.editing.addNewRow.displayMode&&(l.editing.addNewRow._addButton&&l.editing.addNewRow._addButton.remove(),l._newRow&&l._newRow.element.classList.add("smart-hidden")),l._renderAddNewRow(),void l.refresh();case"editing_enabled":o?l.removeAttribute("aria-readonly"):l.setAttribute("aria-readonly",!0);break;case"editing_dialog_visible":return;case"editing_commandBar_dataSource_commandBarAddRow_visible":case"editing_commandBar_dataSource_commandBarDeleteRow_visible":case"editing_commandBar_dataSource_commandBarBatchSave_visible":case"editing_commandBar_dataSource_commandBarBatchRevert_visible":case"editing_commandBar_visible":case"editing_commandBar_displayMode":case"editing_commandBar_position":l._renderCommandBar();break;case"editing_commandColumn_position":l._renderColumns(!0);break;case"editing_commandColumn_visible":return void l.refresh(!0);case"editing_commandColumn_inline":return l._commandColumn.visible=l.editing.commandColumn.visible&&!l.editing.commandColumn.inline,void l.refresh(!0);case"editing_commandColumn_dataSource_commandColumnCustom_label":case"editing_commandColumn_dataSource_commandColumnCustom_icon":case"editing_commandColumn_dataSource_commandColumnCustom_visible":case"editing_commandColumn_dataSource_commandColumnUpdate_label":case"editing_commandColumn_dataSource_commandColumnUpdate_icon":case"editing_commandColumn_dataSource_commandColumnUpdate_visible":case"editing_commandColumn_dataSource_commandColumnEdit_label":case"editing_commandColumn_dataSource_commandColumnEdit_icon":case"editing_commandColumn_dataSource_commandColumnEdit_visible":case"editing_commandColumn_dataSource_commandColumnDelete_label":case"editing_commandColumn_dataSource_commandColumnDelete_icon":case"editing_commandColumn_dataSource_commandColumnDelete_visible":case"editing_commandColumn_displayMode":return delete l.__cellsCommandTemplate,void l.refresh(!0)}l.refresh()}}ready(){super.ready();const e=this,t=e._scrollView.vScrollBar,o=e._scrollView.hScrollBar;t.hasStyleObserver=!1,o.hasStyleObserver=!1,t.hasResizeObserver=!1,o.hasResizeObserver=!1,t.wait=!1,o.wait=!1,t.onChange=e._verticalScrollbarHandler.bind(e),o.onChange=e._horizontalScrollbarHandler.bind(e),e.setFocusable(!0),e.$.loadingIndicatorPlaceholder.innerHTML=e.appearance.loadingIndicatorPlaceholder,e.$.placeholder.innerHTML=e.appearance.placeholder,e._setLoadingIndicatorVisibility(),e._cellsMerge=[],e._cellStyles=[],e.checkLicense()}_createFilterPanels(){const e=this;if(e._filterPanels){if(e._filterPanels.length>0)return}else e._filterPanels=[];e.filtering.enabled&&0===e._filterPanels.length&&requestAnimationFrame((()=>{const t=document.createElement("smart-filter-panel"),o=document.createElement("smart-filter-panel"),l=document.createElement("smart-filter-panel"),a=document.createElement("smart-filter-panel");o.filterType="boolean",l.filterType="numeric",a.filterType="date",e._filterPanels.bool=o,e._filterPanels.date=a,e._filterPanels.numeric=l,e._filterPanels.string=t;for(let t in e._filterPanels){const o=e._filterPanels[t];o.rightToLeft=e.rightToLeft,o.classList.add("smart-hidden"),e.$.content.appendChild(o),o.parentNode.removeChild(o)}}))}_applyScrolling(){const e=this,t=e._scrollView.vScrollBar;requestAnimationFrame((()=>{switch(t.largeStep=e.$.scrollView.offsetHeight,e.scrolling){case"physical":case"infinite":case"virtual":t.step=e.layout.rowMinHeight,t.mechanicalAction="switchWhileDragging";break;case"deferred":t.step=10,t.mechanicalAction="switchWhenReleased";break;case"logical":t.step=e.layout.rowMinHeight,t.mechanicalAction="switchWhileDragging"}}))}_measureRowElement(e){const t=new Smart.Grid.Row({data:e,index:999999,grid:this});if(!t)return null;const o=t.createElement();return o.classList.add("smart-grid-measure-row"),this.$.scrollView.appendChild(o),o.style.height="",o.style.lineHeight="",o.style.height="",o.style.lineHeight="",t._isMeasureRow=!0,t.render(),o}get _autoRowHeight(){const e=this;if(e.__autoRowHeight)return e.__autoRowHeight;let t=e.layout.rowMinHeight;if(!e.dataSource||e.dataSource&&0===e.dataSource.length)return t;const o=new Smart.Grid.Row({index:0,grid:e}),l=o.createElement();e.$.scrollView.appendChild(l),e.removeAttribute("grouped"),e.removeAttribute("tree"),e.grouping.enabled&&e.dataSource.groupBy&&e.dataSource.groupBy.length>0?e.setAttribute("grouped",""):e.dataSource.boundHierarchy&&e.setAttribute("tree","");const a={};for(let t=0;t<e.dataSource.dataFields.length;t++)a[e.dataSource.dataFields[t].name]="ABCDEFHIJLMNOPQRSTUVWXYZ1234567910|";o.data=a,o._isMeasureRow=!0,o.render(),l.style.height="",l.style.lineHeight="",t=Math.max(l.offsetHeight,t);for(let e=0;e<l.children.length;e++)l.children[e].style.height="";for(let a=0;a<l.children[1].children.length;a++){if(l.children[1].children[a].style.height="auto",e.columns[0]){const t=o.getCell(e.columns[0].dataField);t&&t.render()}t=Math.max(t,8+l.children[1].children[a].offsetHeight);break}return e.$.scrollView.removeChild(l),e.__autoRowHeight=t,e.layout.rowMinHeight&&t<e.layout.rowMinHeight&&(e.__autoRowHeight=e.layout.rowMinHeight),t}get _scrollHeight(){const e=this,t="card"===e.view;let o=e._recyclingRows,l=0,a=e._autoRowHeight,n=0,i=0;if(e.__scrollHeight)return e.__scrollHeight;if(0===o.length||0===e.columns.length||!e.hasVisibleColumn())return 0;let r=35,s=1,d=0;if(t){for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.visible&&!o.autoGenerated&&(e.layout.cardCompact?t%2==0&&(r+=e.layout.rowMinHeight+5):r+=e.layout.rowMinHeight+5,d++,o.cardHeight&&(r+=o.cardHeight*e.layout.rowMinHeight))}let t=e.offsetWidth;e.appearance.showViewBar&&(t-=e.layout.viewBarWidth+5),s=t<e.layout.cardMinWidth?1:"auto"===e.layout.cardsPerRow?Math.floor(t/e.layout.cardMinWidth):e.layout.cardsPerRow,1===s&&(r+=5*d),e._cardHeight=r}e._cardsPerRow=s,e.rows.canNotify=!1;const u=e._measureRowElement(o[0].data),c=o.length;for(let s=0;s<c;s++){let d=o[s];if(!d.visible||!1===d.filtered){d.height=0,d.cellHeight=0,d.top=l;continue}const c=e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled;let m=!d.height||!d.cellHeight||c||"auto"===d.height||"auto"===d._height||"auto"===e.layout.rowHeight||e.layout.isDirty;if(t&&d.height!==r&&(d.height=d.cellHeight=r),m&&!d.expandHeight){if(d.detailHeight||(d.detailHeight=200),t)d.height=d.cellHeight=r;else if(e.layout.rowHeight){if(e.layout.rowHeight)if("number"==typeof e.layout.rowHeight)e.layout.rowHeight<e.layout.rowMinHeight&&(e.layout.rowHeight=e.layout.rowMinHeight),d.height=e.layout.rowHeight,d.computedHeight&&(d.height=d.computedHeight),d.minHeight>d.height&&(d.height=d.minHeight),void 0!==d.label&&"advanced"===e.grouping.renderMode&&(d.height=e.grouping.groupRowHeight),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight);else if("auto"===e.layout.rowHeight){e.layout.rowHeight<e.layout.rowMinHeight&&(e.layout.rowHeight=e.layout.rowMinHeight),d.element=u,d.grid=e,d.element&&d.element.classList.contains("smart-hidden")&&d.element.classList.remove("smart-hidden");const t=d.data&&e.isRendered?d._autoSize(d):a,o=d.canNotify;d.canNotify=!1,d.height=t,d.computedHeight&&(d.height=d.computedHeight),void 0!==d.label&&"advanced"===e.grouping.renderMode&&(d.height=e.grouping.groupRowHeight),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight),d.canNotify=o}else e.layout.rowHeight(s,d),d.height||(d.height=a),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight)}else{if("auto"===d.height||"auto"===d._height){d.element=u,d.element&&d.element.classList.contains("smart-hidden")&&d.element.classList.remove("smart-hidden");const t=d.data&&e.isRendered?d._autoSize(d):a;d.height=t,d._height="auto"}else d.height=a;void 0===d.label||d.summaryRow||"advanced"!==e.grouping.renderMode||(d.height=e.grouping.groupRowHeight),d.computedHeight&&(d.height=d.computedHeight),d.cellHeight=d.height,e.rowDetail.enabled&&d.showDetail&&!e.rowDetail.dialog.enabled&&(d.height+=d.detailHeight)}e._rowGap&&s<e.rows.length-1&&(d.height+=e._rowGap)}!t&&(!0===d.freeze||"near"===d.freeze?d.visible&&(n+=d.height):"far"===d.freeze&&d.visible&&(i+=d.height),d.freeze&&d.visible)?d.top=l:(d.top!==l&&(d.top=l),d.expandHeight?l+=d.cellHeight:l+=d.height)}if(e._summaryRowCount&&e.summaryRow.visible&&(l+=1*a),e.editing.addNewRow&&"button"===e.editing.addNewRow.displayMode&&(l+=1*a),e.filtering&&e.filtering.filterRow.visible&&(n+=a),e.editing.addNewRow&&"button"!==e.editing.addNewRow.displayMode&&e.rowHierarchy&&e.editing.addNewRow.visible&&(l+=a,"far"!==e.editing.addNewRow.position&&(n+=a)),e.dataSource&&e.dataSource.virtualDataSource&&!1===e.paging.enabled){let t=e.dataSource.length>e.virtualModeCachedRowsCount?e.virtualModeCachedRowsCount:e.dataSource.length;"infinite"===e.scrolling&&(t=e.dataSource.length),"virtual"===e.scrolling&&t>=e.virtualModeCachedRowsCount&&(l=e.rows[0]?e.rows[0].height*e.dataSource.length:e.layout.rowMinHeight*e.dataSource.length)}return t&&(l=r*Math.ceil(o.length/s)),e.__scrollHeight=l,e.__frozenNearHeight=n,e.__frozenFarHeight=i,e._scrollView.scrollHeight=l-e.$.scrollView.offsetHeight+n+i,l=e.__scrollHeight+n+i-1,e.grouping.enabled&&e.dataSource.groupBy.length>0&&e.grouping.groupIndent>0&&"advanced"===e.grouping.renderMode&&(l+=parseInt(e.grouping.groupIndent/2)),e.__scrollHeight=l,u.remove(),o[0]&&delete o[0]._isMeasureRow,e.rows.canNotify=!0,l}_measureColumnHeight(){const e=this;if(e.__measuredColumnHeight)return e.__measuredColumnHeight;const t=document.createElement("smart-grid-column");t.style.height="auto",t.style.position="static";const o=document.createElement("div");o.classList.add("smart-label"),o.innerHTML="aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRwWxXyYzZ1234567890",t.appendChild(o),e.$.columnHeader.appendChild(t);let l=e.$.columnHeader.offsetHeight;return e.$.columnHeader.removeChild(t),e._columnHeights&&e._columnHeights.length>1&&(l=e._columnHeights[0]),l<e.layout.columnMinHeight&&(l=e.layout.columnMinHeight),e.__measuredColumnHeight=l,l}_initializeColumnGroupsHierarchy(){const e=this;let t=0;e.$.columnContainer.innerHTML="";const o=JSON.parse(JSON.stringify(e.columnGroups));if(o.length>0){for(let t=0;t<o.length;t++)o[t].parent=null,o[t].groups=null,o[t].labelTemplate=e.columnGroups[t].labelTemplate;for(let t=0;t<e.viewColumns.length;t++)e.viewColumns[t].parent=null,e.viewColumns[t].groups=null;const l=function(e){for(let t=0;t<o.length;t++){let l=o[t];if(l.name===e)return l}return null},a=function(e){let t=new Array;if(e.columnGroup&&t.push(e),e.groups)for(let o=0;o<e.groups.length;o++)if(e.groups[o].columnGroup)t.push(e.groups[o]);else if(e.groups[o].groups){let l=a(e.groups[o]);for(let e=0;e<l.length;e++)t.push(l[e])}return t};for(let e=0;e<o.length;e++){let t=o[e];if(t.groups||(t.groups=null),t.parentGroup){let e=l(t.parentGroup);e&&(t.parent=e,e.groups||(e.groups=new Array),-1===e.groups.indexOf(t)&&e.groups.push(t))}}for(let t=0;t<e.viewColumns.length;t++){let o=e.viewColumns[t];if(o.columnGroup){let e=l(o.columnGroup);e&&(e.groups||(e.groups=new Array),o.parent=e,-1===e.groups.indexOf(o)&&e.groups.push(o))}}for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];let a=l;for(l.level=0;a.parent;)a=a.parent,l.level++;a=l;let n=l.level;for(t=Math.max(t,l.level);a.parent;)a=a.parent,a&&(a.level=--n)}for(let t=0;t<o.length;t++){const l=o[t],n=a(l);l.columns=n;let i=new Array,r=0,s="near";0===n.length&&(r=-1,l.visible=!1);for(let t=0;t<n.length;t++)i.push(e.viewColumns.indexOf(n[t])),n[t].freeze&&("far"===n[t].freeze&&(s="far"),r++);r===n.length?l.freeze=s:r>0&&r<n.length&&(e.classList.add("smart-visibility-hidden"),e.error(e.localize("frozenColumns",{elementType:"Grid"}))),i.sort((function(e,t){return(e=parseInt(e))<(t=parseInt(t))?-1:e>t?1:0}));for(let t=1;t<i.length;t++)i[t]!==i[t-1]+1&&(e.classList.add("smart-visibility-hidden"),e.error(e.localize("columnGroups",{elementType:"Grid"})))}}e._columnGroupsLevel=1+t,e._columnGroups=o}_refreshColumnHeights(){const e=this;if("card"===e.view)return;e.$.columnHeader.style.height="",e._viewColumnsHeight=e._measureColumnHeight(),e._columnHeights=[];let t=0;for(let o=0;o<e._columnGroupsLevel;o++){let l=e._viewColumnsHeight;e.layout.columnHeight&&(l="number"==typeof e.layout.columnHeight?e.layout.columnHeight?e.layout.columnHeight:e._viewColumnsHeight:e.layout.columnHeight?e.columnHeight(o):e._viewColumnsHeight),l<e.layout.columnMinHeight&&(l=e.layout.columnMinHeight),l?(e._columnHeights.push(l),t+=l):(t+=e._viewColumnsHeight,e._columnHeights.push(e._viewColumnsHeight))}e._columnHeaderHeight=e._columnGroupsLevel*e._viewColumnsHeight,e._columnHeaderHeight=t,e.$.columnHeader.style.height=e._columnHeaderHeight+"px";const o=function(t){let o=0;for(let l=0;l<t.level;l++)o+=e._columnHeights[l];return o},l=function(t){let l=o(t),a=e._columnHeaderHeight-l;for(let o=t.level+1;o<e._columnHeights.length;o++){const l=o;for(let o=0;o<e.viewColumns.length;o++){const n=e.viewColumns[o];let i=!1;if(n.level===l){let o=n;for(;o.parent;){if(o.parent===t){a=e._columnHeights[l],i=!0;break}o=o.parent}if(i)break}}}return a};for(let t=0;t<e.viewColumns.length;t++){const a=e.viewColumns[t],n=l(a);a.computedHeight=n,a.top=o(a)}for(let t=0;t<e._columnGroupsLevel-1;t++)for(let a=0;a<e._columnGroups.length;a++){const n=e._columnGroups[a];if(n.level!==t)continue;if(n.groups){const e=l(n),t=o(n);n.top=t,n.computedHeight=e}const i=n.element;i&&(i.style.width=n.computedWidth+"px",e.rightToLeft?i.style.right=n.left+"px":i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=n.computedHeight+"px",i.style.lineHeight=n.computedHeight+"px")}}_refreshColumnWidths(){const e=this;e.__clientSize=null;const t=e.$.verticalScrollBar.offsetWidth>0?e.$.verticalScrollBar.offsetWidth:0,o=e.dataSource.groupBy||[];let l=e.grouping.enabled&&"advanced"===e.grouping.renderMode?e.grouping.groupIndent*(1+o.length):0,a=0;e.selection.checkBoxes.enabled&&(a=e._selectionColumn.computedWidth?e._selectionColumn.computedWidth:e._selectionColumn.minWidth);const n=e._clientSize.width-t-l;let i=0,r=[],s=0,d=0,u=0;if(e.editing.enabled&&!e.editing.commandColumn.inline){const t=function(){const t=document.createElement("div"),o=document.createElement("div"),l=e.editing.commandColumn.dataSource;let a=0,n="",i=0;o.classList.add("smart-label");for(let t in l){const o=l[t];let a=!1;if("commandColumnMenu"===t)continue;let r=!1;a||(!0===o.visible?(i++,r=!0):"auto"===o.visible&&((e.editing.editRow||e.editing.editCell)&&!e.editing.dialog.enabled||"commandColumnEdit"!==t?!e.editing.editRow&&!e.editing.editCell||e.editing.dialog.enabled||("commandColumnUpdate"===t||"commandColumnCancel"===t)&&(i++,r=!0):(i++,r=!0)),a=!0),r&&"icon"!==e.editing.commandColumn.displayMode&&(n+="<span>"+("{{messages}}"===o.label?e.localize(t):o.label)+"</span>")}return o.innerHTML="<span>"+n+"</span>",t.appendChild(o),t.style.width="auto",t.style.position="static",e.$.columnHeader.appendChild(t),a=10+o.firstChild.offsetWidth,e.$.columnHeader.removeChild(t),"icon"===e.editing.commandColumn.displayMode?a=20+20*i:"labelAndIcon"===e.editing.commandColumn.displayMode?a+=25*i:a+=10*i,a};if(e._commandColumn.visible=e.editing.commandColumn.visible,e.editing.commandColumn.visible){const o=e.editing.commandColumn.width?e.editing.commandColumn.width:t();e.columns.canNotify=!1,e._commandColumn.width=o,e.columns.canNotify=!0}}for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];let l;"number"==typeof o.width?l=o.width:o.width&&o.width.toString().indexOf("%")>=0?(l=parseFloat(o.width)/100,l*=n-a):o.width&&(o.width.toString().indexOf("em")>=0||o.width.toString().indexOf("pt")>=0||o.width.toString().indexOf("fr")>=0)?(l=parseFloat(o.width),l*=16):"auto"===o.width?l=o._autoSize():o.visible&&(r.push(o),l=0),o.overflowWidth&&(l-=o.overflowWidth),o.visible&&(i+=l),l<o.minWidth&&(l=o.minWidth),o.computedWidth=l}if(r){let e=n-i,t=0;e<0&&(e=60*r.length);for(let o=0;o<r.length;o++){const l=r[o];let a;a=e/r.length,o===r.length-1&&(a=e-t),l.overflowWidth&&(a-=l.overflowWidth),a<l.minWidth&&(a=l.minWidth),l.computedWidth=a,t+=a}}for(let t=0;t<e.viewColumns.length;t++){let o=e.viewColumns[t];o.visible&&(l>0&&!o.autoGenerated&&(o.computedWidth+=l,l=0),o.freeze?!0===o.freeze||"near"===o.freeze?(o.left=s,u+=o.computedWidth,s+=o.computedWidth):"far"===o.freeze&&(o.left=d,d+=o.computedWidth):(o.left=u,u+=o.computedWidth))}for(let t=0;t<e._columnGroupsLevel-1;t++)for(let o=0;o<e._columnGroups.length;o++){const l=e._columnGroups[o];if(l.level!==t)continue;let a=99999;if(l.groups){const e=function(t){let o=0;for(let l=0;l<t.groups.length;l++){let n=t.groups[l];n.groups?o+=e(n):n.visible&&(a=Math.min(n.left,a),o+=n.computedWidth)}return o};l.computedWidth=e(l),l.left=a}}}_createColumnHeaderCellElements(){const e=this,t=e.$.columnContainer,o=document.createDocumentFragment();let l=0;e._columnElements=[],e.$.columnContainer.innerHTML="",e.$.columnNearContainer.innerHTML="",e.$.columnFarContainer.innerHTML="",e.rightToLeft?(e.$.columnNearContainer.classList.remove("near"),e.$.columnNearContainer.classList.add("far"),e.$.columnFarContainer.classList.remove("far"),e.$.columnFarContainer.classList.add("near")):(e.$.columnNearContainer.classList.remove("far"),e.$.columnNearContainer.classList.add("near"),e.$.columnFarContainer.classList.remove("near"),e.$.columnFarContainer.classList.add("far"));for(let t=0;t<e._frozenNearColumns.length;t++)e._frozenNearColumns[t].createElement();for(let t=0;t<e._frozenFarColumns.length;t++)e._frozenFarColumns[t].createElement();for(let t=0;t<e.viewColumns.length;t++){const a=e.viewColumns[t];if(a.freeze)continue;const n=a.createElement();void 0!==a.computedWidth?(a.parent&&n.setAttribute("column-group",a.parent.name),a.parent&&a.parent.columns&&a.parent.columns[0].dataField===a.dataField&&n.setAttribute("column-group-first-child",""),l+=a.computedWidth,e._columnElements.push(n),l<2*e._clientSize.width&&o.appendChild(n)):(e._columnElements.push(n),o.appendChild(n))}for(let t=0;t<e._columnGroups.length;t++){const l=e._columnGroups[t],a=new Smart.Grid.Column({visible:void 0===l.visible||l.visible,allowSort:!1,allowFilter:!1,allowSelect:!1,grid:e,dataField:l.name,label:l.label,labelTemplate:l.labelTemplate,align:l.align,verticalAlign:l.verticalAlign,showIcon:!1});l.column=a;const n=a.createElement();n.style.width=l.computedWidth+"px",e.rightToLeft?n.style.right=l.right+"px":n.style.left=l.left+"px",n.style.top=l.top+"px",n.style.height=l.computedHeight+"px",n.style.lineHeight=l.computedHeight+"px",o.appendChild(n),l.element=n,l.grid=this,n.onpointerdown=()=>{if(e.selection.allowColumnHeaderSelection){const t=function(e){let o=new Array;if(e.columnGroup&&o.push(e),e.groups)for(let l=0;l<e.groups.length;l++)if(e.groups[l].columnGroup)o.push(e.groups[l]);else if(e.groups[l].groups){let a=t(e.groups[l]);for(let e=0;e<a.length;e++)o.push(a[e])}return o},o=t(l);e._selectColumnsRange(o[0].dataField,o[o.length-1].dataField)}}}e.htmlColumnLastChild||(e.htmlColumnLastChild=document.createElement("smart-grid-column"),e.htmlColumnLastChild.classList.add("top-far-corner"),e.htmlColumnLastChild.onpointerdown=e=>{e.stopPropagation(),e.preventDefault()},e.$.columnHeader.appendChild(e.htmlColumnLastChild)),t.appendChild(o),t.style.width=e._computedColumnsWidth+"px",!1===e.appearance.showColumnGroupLines&&e.setAttribute("appearance_hide-column-group-lines",""),e._refreshFrozenColumns()}_refreshFrozenColumns(){const e=this;e.$.columnNearContainer.style.width=e._frozenColumnsNearWidth+"px",e.$.columnFarContainer.style.width=e._frozenColumnsFarWidth+"px";for(let t=0;t<e._columnGroups.length;t++){const o=e._columnGroups[t];o.freeze&&o.element&&(!0===o.freeze||"near"===o.freeze?e.$.columnNearContainer.appendChild(o.element):"far"===o.freeze&&e.$.columnFarContainer.appendChild(o.element))}for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.freeze&&o.element&&(!0===o.freeze||"near"===o.freeze?e.$.columnNearContainer.appendChild(o.element):"far"===o.freeze&&e.$.columnFarContainer.appendChild(o.element))}}get _clientSize(){const e=this;if(e.__clientSize)return e.__clientSize;const t=getComputedStyle(e.$.container),o=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),l=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),a=parseFloat(t.borderLeftWidth)+parseFloat(t.borderRightWidth),n=parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth);return e.__clientSize={width:e.$.container.offsetWidth-o-a,height:e.$.container.offsetHeight-l-n},e.__clientSize}_initializeRowElements(){const e=this;if(!e.rows)return;e.rows.canNotify=!1;let t=0,o=e._clientSize.height;e.$.rowNearContainer.innerHTML="",e.$.rowFarContainer.innerHTML="",e.$.rowContainer.innerHTML="",e._rowElements=[],e._overflowOffset=Math.max(o,300),e.rightToLeft?(e.$.rowNearContainer.classList.remove("near"),e.$.rowNearContainer.classList.add("far"),e.$.rowFarContainer.classList.remove("far"),e.$.rowFarContainer.classList.add("near")):(e.$.rowFarContainer.classList.remove("near"),e.$.rowFarContainer.classList.add("far"),e.$.rowNearContainer.classList.remove("far"),e.$.rowNearContainer.classList.add("near"));const l=e.offsetHeight;e.$.container.classList.add("smart-hidden");const a=e.offsetHeight;e.$.container.classList.remove("smart-hidden"),"hidden"!==e.verticalScrollBarVisibility&&l===a||(o=e._scrollHeight);const n=function(){const l=document.createDocumentFragment();if(e.rows&&0===e.rows.length)return;for(let a=0;a<e.rows.length;a++){const n=e.rows[a];if(n.freeze&&n.visible)continue;const i=n.createElement();if(l.appendChild(i),t+=e.layout.rowMinHeight,t>e._overflowOffset+o)break}e.$.rowContainer.appendChild(l);const a=e.$.rowContainer.children;for(let t=0;t<a.length;t++){const o=a[t];e.rows[t]&&(e.rows[t].element=o),e._rowElements[t]=o}};for(let t=0;t<e._frozenNearRows.length;t++){const o=e._frozenNearRows[t];o.grid=e;const l=o.createElement();o.element=l,e.$.rowNearContainer.appendChild(l)}for(let t=0;t<e._frozenFarRows.length;t++){const o=e._frozenFarRows[t];o.grid=e;const l=o.createElement();o.element=l,e.$.rowFarContainer.appendChild(l)}n();let i=0;for(;t<1.5*o&&++i<50;)n();e.rows.canNotify=!0}_refreshSummary(e){const t=this;t.summaryRow.visible&&(t._summaryUpdateTimer&&clearTimeout(t._summaryUpdateTimer),t._summaryUpdateTimer=setTimeout((()=>{!0!==t.editing.isEditing&&(t._calculateSummary(),!1!==e&&t._recycle(!1,!0,!1))}),100))}_initializeRows(){const e=this;let t=0;e._frozenNearDefaultRows=[],e._frozenFarDefaultRows=[],e.rows=[],e.rowById=[],e._frozenFarRows=[],e._frozenNearRows=[];let o=e._createdDate||new Date,l=void 0!==e._createdBy?e._createdBy:e.currentUser;const a=function(){let t=[],o=!1;for(let l=0;l<e.columns.length;l++){const a=e.columns[l];let n={};a.summary&&a.summary.length>0&&(o=!0,n[a.dataField]=a.summary,t.push(n))}if(!o)return void(e._summaryItems=[]);const l=e.getSelectedRowIds();if(l.length>=1){const o=[];for(let t=0;t<l.length;t++){const a=e.dataSource.dataItemById[l[t]];a&&o.push(a)}e._summaryItems=e.dataSource.summarize(t,o)}else if(e._selection&&e._selection.cells&&Object.keys(e._selection.cells).length>2){const o=e.getSelectedCells(!1),l=[],a=[];for(let t=0;t<o.length;t++){const n=o[t],i=n[0],r=e.dataSource.dataItemById[i];-1===l.indexOf(r)&&l.push(r),-1===a.indexOf(n[1])&&a.push(n[1])}e._summaryItems=e.dataSource.summarize(t,l);const n=Object.keys(e._summaryItems);for(let t=0;t<n.length;t++){const o=n[t];-1===a.indexOf(o)&&delete e._summaryItems[o]}}else e._summaryItems=e.dataSource.summarize(t)};e._calculateSummary=a;const n=e.columns?e.columns.filter((e=>void 0!==e.getCellValue)):[],i=function(a,i,r){let s=null;if(e.isInitialized&&(o=new Date),s=a?a.grid?a:new Smart.Grid.Row({data:a,index:i,grid:e,createdBy:l,createdDate:o}):new Smart.Grid.Row({data:{},index:i,grid:e,createdBy:l,createdDate:o}),n)for(let e=0;e<n.length;e++){const t=n[e],o=t.getCellValue(s.id,t.dataField,a);void 0!==o&&(s.data[t.dataField]=o)}if(e.rowById[s.id]&&(s.id=e.rows.length,e.rowById[s.id])){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};s.id=e()}if(e.onRowInit){e.onRowInit(i,s,e),30!==s.height&&(s.cellHeight=s.height);for(let t in s)-1!==s.properties.indexOf(t)||t.startsWith("_")||e.error(e.localize("invalidRowProperty",{elementType:"Grid",propertyName:t}))}if(s.selected&&(e._selection.rows[s.id]=!0,e._selection.indexes[s.index]=s.index),s.freeze&&s.visible){if(!0===s.freeze||"near"===s.freeze){e.rows.splice(t++,0,s);const o=e.rows[t-1];-1===e._frozenNearRows.indexOf(o)&&e._frozenNearRows.push(o)}else if("far"===s.freeze){e.rows.push(s);const t=e.rows[e.rows.length-1];-1===e._frozenFarRows.indexOf(t)&&e._frozenFarRows.push(t)}}else e.rows[i]?e.rows.splice(i,0,s):e.rows.push(s),s.data&&s.data.$&&(s.data.$.history=s.history,s.data.$.starred=s.starred,s.data.$.comments=s.comments,s.data.$.style=s.style);if(!("virtual"===e.scrolling||e.paging.enabled&&e.dataSource&&e.dataSource.virtualDataSource))if(e.onRowInserted){const t=void 0===i?e.rows[e.rows.length-1]:e.rows[i],o=o=>{const l=t;if(void 0!==o&&Array.isArray(o)&&(o=o[0]),void 0===o){if(e.rowById[l.id]){const t=e.dataSource.dataItemById[l.id],o=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};l.id=o(),l.data&&l.data.$?l.data.$.id=l.id:l.data.id=l.id,e._getId()&&(l.data[e._getId()]=l.id),t&&(e.dataSource.dataItemById[l.id]=l.data)}e.rowById[l.id]=l}else{const t=e.dataSource.dataItemById[l.id];l.id=o,l.data&&l.data.$?l.data.$.id=l.id:l.data.id=l.id;const a=e._getId();a&&(l.data[e._getId()]=l.id),t&&(t[a]=o,e.dataSource.dataItemById[l.id]=t,l.data=t),e.rowById[l.id]=l}-1!==l.index&&void 0!==l.index||(l.index=e.rows.length),e._setAddUndoRedo(l),!e.editing.isEditing&&e.isInitialized&&(e._recycle(!1,!0),e.grouping.groupBy.length&&e.refresh()),e._onRowInserted&&e._onRowInserted(l),r&&r(l)};if(void 0===i&&(i=e.rows.length-1,void 0!==t.index&&-1!==t.index||(t.index=i)),e.isInitialized){e._rowInsertTimer&&clearTimeout(e._rowInsertTimer),e._rowInsert||(e._rowInsert=[]),e._rowInsert.push({row:t,index:i});const l=e._keyboardAdd?300:150;e._rowInsertTimer=setTimeout((()=>{if(1===e._rowInsert.length)e.onRowInserted([i],[t],o,e),delete e._rowInsert,delete e._undoRedoAction;else{let t=[],o=[];for(let l=0;l<e._rowInsert.length;l++)t.push(e._rowInsert[l].index),o.push(e._rowInsert[l].row);delete e._rowInsert,e.onRowInserted(t,o,(t=>{e.beginUpdate();for(let l=0;l<o.length;l++){const a=o[l],n=t?t[l]:void 0;if(void 0!==n){const t=e.dataSource.dataItemById[a.id];a.id=a.data.id=n;const o=e._getId();o&&(a.data[e._getId()]=a.id),e.rowById[a.id]=a,t&&(t[o]=n,e.dataSource.dataItemById[a.id]=t,a.data=t)}e._setAddUndoRedo(a),-1!==a.index&&void 0!==a.index||(a.index=e.rows.length),e._onRowInserted&&e._onRowInserted(a),r&&r(a)}delete e._undoRedoAction,e.endUpdate(!1)}),e)}}),l)}else e.onRowInserted([i],[t],o,e)}else{const t=void 0===i?e.rows[e.rows.length-1]:e.rows[i];void 0===i&&(i=e.rows.length-1,void 0!==t.index&&-1!==t.index||(t.index=i)),r&&r(t)}},r=function(){const t=e.rows[e.rows.length-1];e.rows.pop(),e.onRowRemoved&&e.onRowRemoved([t.id],[t.index],e),e._onRowRemoved&&e._onRowRemoved([t.id],[t.index],e),e._setRemoveUndoRedo(t)},s=function(t){const o=e.rows[t];o.selected&&o.setProperty("selected",!1),e.rows.splice(t,1),e.onRowRemoved&&e.onRowRemoved([o.id],[t],e),e._onRowRemoved&&e._onRowRemoved([o.id],[t],e),e._setRemoveUndoRedo(o)};e._add=i,e._removeLastRow=r,e._removeAt=s,e._rowHeight=e._autoRowHeight;const d=e.dataSource.length,u=e.onRowInserted;e.onRowInserted=null,e.setAttribute("aria-rowcount",d);const c=e.dataSource&&e.dataSource.virtualDataSource&&!e.dataSource.virtualDataSourceOnExpand&&e.dataSource.length>e.virtualModeCachedRowsCount&&"infinite"!==e.scrolling;if(e.dataSource&&e.dataSource.virtualDataSource&&e.paging.enabled&&!e.dataSource.virtualDataSourceOnExpand)for(let t=0;t<e.dataSource.boundSource.length;t++){const o=e.dataSource[t],l=t+e.paging.pageIndex*e.paging.pageSize;e.dataSource.id||(o.$.id=l),i(o,l)}else if(c){let t=e.dataSource.length>e.virtualModeCachedRowsCount?e.virtualModeCachedRowsCount:e.dataSource.length;"infinite"===e.scrolling&&(t=e.dataSource.length);for(let o=0;o<t;o++){const t=e.dataSource[o];i(t,o)}}else for(let t=0;t<e.dataSource.length;t++){const o=e.dataSource[t];i(o,t)}for(let t=0;t<e._frozenFarRows.length;t++){const o=e._frozenFarRows[t];e.rows.splice(e.rows.indexOf(o),1),e.rows.push(o)}if(a(),e.onRowInserted=u,e.dataSource.notify((function(t){if(e.dataSource._updating)return;const o=t.data;e.rows.canNotify=!1;let l=!1;switch(t.action){case"add":if(!o)return;if(void 0!==o.length)for(let t=0;t<o.length;t++)i(o[t],e.dataSource.length-o.length+t);else i(o,e.dataSource.length-1);break;case"update":if(o.length){let o=[],a=[],n=[];for(let r=0;r<n.length;r++){const s=t.index[r];e.rows[s]?(e.rows[s].data=n[r],o.push(s),a.push(e.rows[s]),n.push(e.rows[s].data)):(i(n[r],n[r].$.index),l=!0)}e.onRowUpdated&&e.onRowUpdated(o,a,n,e)}else{const l=t.index;e.rows[l]?e.rows[l].data=o:i(o,e.dataSource.length-1),e.onRowUpdated&&e.onRowUpdated([l],[e.rows[l]],[e.rows[l].data],e)}break;case"insert":i(o,t.index);for(let t=0;t<e.rows.length;t++)e.rows[t].index=t;break;case"remove":s(t.index);break;case"removeLast":r();break;case"bindingComplete":if(e.dataSource&&e.dataSource.url||e.dataSource&&!e.dataSource.virtualDataSource){if(e.appearance.displayLoadingIndicator=!1,e._setLoadingIndicatorVisibility(),e._toggledRow=null,e.dataSource.length!==d){if(e.paging.enabled){const t=e.$.headerPager.querySelector("smart-pager"),o=e.$.footerPager.querySelector("smart-pager");t&&(t.pagesCount=Math.ceil(e.dataSource.length/e._pageSize)),o&&(o.pagesCount=Math.ceil(e.dataSource.length/e._pageSize))}if(0===d&&0===e.columns.length&&e.dataSource.dataFields.length>0){const t=e.context;e.context=e,e.columns.canNotify=!1,e.columns=[],e._renderColumns(),e._resetCachedLayout(),e.columns.canNotify=!0,e.context=t}e._initializeRows(),e._initializeRowElements(),e.refresh()}e._recycle(),e.onLoad&&(e.onLoad(),delete e.onLoad)}}a(),("update"!==t.action||l)&&e._refreshLayout(),e._recycle(),e.rows.canNotify=!0})),e._observeRows(),e.summaryRow.visible){const t=new Smart.Grid.Row({height:e.layout.rowMinHeight,freeze:"near",visible:"near"===e.summaryRow.position,summaryRowIndex:0,summaryRow:!0}),o=new Smart.Grid.Row({height:e.layout.rowMinHeight,freeze:"far",visible:"far"===e.summaryRow.position,summaryRowIndex:0,summaryRow:!0});"near"===e.summaryRow.position&&e._frozenNearRows.splice(0,0,t),"far"===e.summaryRow.position&&e._frozenFarRows.push(o)}if(e.filtering.enabled&&e.filtering.filterRow.visible){const t=new Smart.Grid.Row({freeze:!0,autoGenerated:!0,filterRow:!0});e._frozenNearRows.splice(0,0,t)}e._renderAddNewRow()}_observeRows(){const e=this;e._frozenNearRows=[],e._frozenFarRows=[],e.rows=new Smart.ObservableArray(e.rows,null,{allowToggle:!0,allowResize:!0,allowCheck:!0,allowSelect:!0,allowReorder:!0,expanded:!0,selected:!0,checked:!0,visible:!0,enabled:!0,minHeight:!0,height:!0,freeze:!0,showDetail:!0,data:!0,visibleIndex:!0,index:!0,comments:!0,style:!0,starred:!0,updatedBy:!0,updatedDate:!0,createdDate:!0,createdBy:!0,history:!0});for(let t=0;t<e.rows.length;t++){const o=e.rows[t];!0===o.freeze||"near"===o.freeze?e._frozenNearRows.push(o):"far"===o.freeze&&e._frozenFarRows.push(o),e.rowById[e.rows[t].id]=o}e.rows.notify((function(t){if(!e.rows.canNotify)return;const o=t.action;if("length"===o)return;if(t.path)return e.rows.canNotify=!1,(e.rowById[t.target.id]||"selected"===t.propertyName)&&(l=t.target,a=t.propertyName,n=t.oldValue,i=t.newValue,n===i&&"selected"!==a&&"showDetail"!==a||(l.propertyChanged(a,n,i),e.onRowChange&&l.properties.indexOf(a)>=0&&e.onRowChange(l,a,n,i,e))),void(e.rows.canNotify=!0);var l,a,n,i;if(e.rows.canNotify=!1,!e.dataSource)return;switch(e.dataSource.canNotify=!1,o){case"add":{const o=function(o){let l=e.rows[o];if(l instanceof Smart.Grid.Row==0){l=new Smart.Grid.Row(l);const a=e.rows.canNotify;e.rows.canNotify=!1,t.object[o]=l,l=t.object[o],e.rows.canNotify=a}if(l.grid=e,e.dataSource&&e.dataSource.virtualDataSource){e.rows.canNotify=!1;for(let t=0;t<e.rows.length;t++){const o=e.dataSource.boundSource[t],l=e.rows[t];o&&(l.data=o,l.id=o.$.id),e.rowById[l.id]=l}e.rows.canNotify=!0}else(()=>{if(0===e.dataSource.length&&e.dataSource.dataFields&&0===e.dataSource.dataFields.length&&e.columns&&e.columns.length){let t=[];for(let o=0;o<e.columns.length;o++){const l=e.columns[o];t.push({name:l.dataField,dataType:l.dataType||"string"}),l.displayField&&l.displayField!==l.dataField&&t.push({name:l.displayField,dataType:l.dataType||"string"})}e.dataSource.dataFields=t}if(o<e.dataSource.length?e.dataSource.insert(o,e.rows[o].data):e.dataSource.add(e.rows[o].data),e.dataSource[o]){l.data=e.dataSource[o];for(let t=0;t<e.dataSource.dataFields.length;t++){const o=e.dataSource.dataFields[t].name;e.columnByDataField[o]||delete l.data[o]}void 0!==e.dataSource[o].$.id&&(l.id=e.dataSource[o].$.id,e.rowById[l.id]=l),l.data.$&&l.history&&(l.data.$.history=l.history)}-1!==l.index&&void 0!==l.index||(l.index=o),l.selected&&(e._selection.rows[l.id]=!0,e._selection.indexes[l.index]=l.index),l.freeze&&(!0===l.freeze||"near"===l.freeze?e._frozenNearRows.push(l):"far"===l.freeze&&e._frozenFarRows.push(l))})()};for(let e=0;e<t.addedCount;e++)o(t.index+e);break}case"update":if(t.target){const o=e.rowById[t.target.id],l=e.rows.indexOf(o);e.dataSource.update(l,o)}else{const o=e.rows.indexOf(t.index);e.dataSource.update(t.index,o)}break;case"remove":{if(e.dataSource&&e.dataSource.virtualDataSource){e.rows.canNotify=!1;const o=t.removed&&t.removed.length>0?t.removed[0]:null;o&&delete e.rowById[o.id];for(let t=0;t<e.dataSource.boundSource.length;t++){const o=e.dataSource.boundSource[t],l=e.rows[t];l&&(l.data=o,l.id=o.$.id,e.rowById[l.id]=l)}return e.rows.canNotify=!0,e.refresh(),void e._refreshPaging(!1)}const o=t.removed&&t.removed.length>0?t.removed[0]:null;o&&delete e.rowById[o.id],e.dataSource.removeAt(t.index);break}}if(e.dataSource.canNotify=!0,e.rows.canNotify=!0,!o)return;let r=e.isInitialized&&e._rowElements&&e._rowElements.length<e.rows.length;"add"===o&&1===t.addedCount&&r&&e._rowElements.length>0&&e._rowElements[e._rowElements.length-1].classList.contains("smart-hidden")&&(r=!1),r&&e._initializeRowElements(),e.refresh(),e._refreshPagesCount(),e._sortedColumns&&e._sortedColumns.length>0&&e.refreshSort()}))}render(){const e=this,t=()=>0===e.offsetWidth||0===e.offsetHeight;if(t())return requestAnimationFrame((()=>{e.isInitialized||t()||e._render()})),e.setAttribute("role","grid"),e.editing.enabled||e.setAttribute("aria-readonly",!0),void super.render();const o=e.context;e.context=e,e.setAttribute("role","grid"),"grid"!==e.view&&e.setAttribute("view",e.view),e.editing.enabled||e.setAttribute("aria-readonly",!0),e._undoRedo=[],e._refreshCurrentUser(),e._render(),e.context=o,super.render()}_renderColumns(e){const t=this;t._initializeColumns(),t._initializeColumnGroupsHierarchy(),t._refreshColumnsResponsiveVisibility(),t._createColumnHeaderCellElements(),t._renderColumnGroupHeaders(),!1!==e&&t._refresh()}_renderRows(e){const t=this;t._initializeRows(),t._initializeRowElements(),!1!==e&&t._refresh()}_setupMobile(){const e=this;if(void 0===e._mobile&&(e._mobile=Smart.Utilities.Core.isMobile),e._mobile){e.editing.addNewColumn.visible=!1,e.layout.rowMinHeight=e.layout.rowHeight=48,e.behavior.columnResizeMode="none",e.behavior.rowResizeMode="none",e.behavior.allowRowReorder=!1,e.behavior.allowColumnReorder=!1,e.editing.action="none",e.appearance.showViewBar=!1,e._scrollView.vScrollBar.showButtons=!1,e._scrollView.hScrollBar.showButtons=!1,e.style.setProperty("--smart-scroll-bar-size","12px"),document.body.style.setProperty("--smart-data-view-sort-panel-width","345px"),e._scrollContent=document.createElement("div"),e._scrollContent.style.width="100%",e._scrollContent.style.height="100%",e._scrollContent.style.position="absolute",e._scrollContent.style.left="0px",e._scrollContent.style.top="0px",e._scrollContent.style.background="white",e._scrollContent.style.zIndex=9999,e._scrollContent.style.opacity=.1,e._scrollContent.style.overflow="auto",e.addEventListener("viewChange",(()=>{"grid"===e.view?e._scrollContent.classList.remove("smart-hidden"):e._scrollContent.classList.add("smart-hidden")})),e.addEventListener("beginEdit",(()=>{e._scrollContent.classList.add("smart-hidden")})),e.addEventListener("endEdit",(()=>{e._scrollContent.classList.remove("smart-hidden")})),e._scrollContent.ontouchmove=e=>{e.stopPropagation()},e._scrollContent.ontouchstart=e=>{e.stopPropagation()},e._scrollContent.onpointerdown=t=>{e._scrollContentScroll=!1,setTimeout((()=>{const o=e=>new PointerEvent(e,{bubbles:!0,cancelable:!0,composed:!0,pointerId:42,pointerType:"mouse",clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY});if(e._scrollContentScroll)e._hideActionButtons();else{const l=(e.enableShadowDOM?e.shadowRoot:e.getRootNode()).elementsFromPoint(t.clientX,t.clientY);if(l[2])if(l[2].classList.contains("smart-grid-add-row-button"))e._hideActionButtons(),l[2].dispatchEvent(o("click"));else if(l[2].classList.contains("smart-summary-placeholder")||l[2].classList.contains("summary-value-part"))e._hideActionButtons(),l[2].dispatchEvent(o("pointerup"));else if(l[2].closest("smart-menu-item")){e._hideActionButtons();const t=l[2].closest("smart-menu-item");l[2].closest("smart-menu")._menuItemSelectionHandler(t)}else{if(l[2].dispatchEvent(o("pointerdown")),e._lastMobileClickRange){const o=e._lastMobileClickRange;let l=!0;o.left<=t.pageX&&o.left+o.right>=t.pageX&&(l=!1),l&&e._hideActionButtons()}else e._hideActionButtons();const a=(o,l)=>{if(o&&o.autoShowActionButton){const a=l.getBoundingClientRect(),n=e.offset(l);if(n.left<=t.pageX&&n.left+a.width-6>=t.pageX){if(!e.hasColumnMenu(o))return;e._lastMobileClickRange={left:n.left,right:n.left+a.width-6},l._showActionButton()}else l._hideActionButton()}};for(let t=0;t<e._columnElements.length;t++){const o=e._columnElements[t];a(o.column,o)}}}}),300),t.stopPropagation()};let t=0;const o=()=>{const t=e._scrollContent.scrollLeft,o=e._scrollContent.scrollTop;e._scrollView.vScrollBar.value=o,e._scrollView.hScrollBar.value=t,e._scrollContentScroll=!0};e._scrollContent.onscroll=()=>{cancelAnimationFrame(t),t=0,t=requestAnimationFrame(o)},e._scrollContentView=document.createElement("div"),e._scrollContentView.style.width=e._scrollView.scrollWidth+"px",e._scrollContentView.style.height=e._scrollView.scrollHeight+"px",e._scrollContent.appendChild(e._scrollContentView),e.$.scrollView.appendChild(e._scrollContent)}}_render(){const e=this;if(e.isInitialized||(e.onBeforeInit&&(e.onBeforeInit(e),e.onBeforeInit=null),e.$.fireEvent("beforeInit",{grid:e}),e.header.visible&&e.header.buttons.indexOf("views")>=0&&e._updateKanbanTaskFields()),e._setupMobile(),(()=>{if(null===e.dataSource)e.dataSource=new Smart.DataAdapter;else if(Array.isArray(e.dataSource)||"string"==typeof e.dataSource){let t=[];if(e.dataSourceSettings.dataFields&&e.dataSourceSettings.dataFields.length>0)e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataSourceType:e.dataSourceSettings.dataSourceType,dataFields:e.dataSourceSettings.dataFields,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy||e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand});else if(e.columns&&e.columns.length){for(let o=0;o<e.columns.length;o++){const l=e.columns[o];t.push({name:l.dataField,dataType:l.dataType||"string"}),l.displayField&&l.displayField!==l.dataField&&t.push({name:l.displayField,dataType:l.dataType||"string"})}e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataFields:t,dataSourceType:e.dataSourceSettings.dataSourceType,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy||e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand})}else e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource})}})(),e._selection={rows:[],indexes:[],columns:[],cells:[]},e.dataSource&&e.dataSource.url&&(e.appearance.displayLoadingIndicator=!0,e._setLoadingIndicatorVisibility(),e.dataSource.data={sorting:e.getSortedColumns(),filtering:e.getFilteredColumns(),grouping:e.grouping.groupBy}),e.filtering.filterRow)for(let t=0;t<e.columns.length;t++)e.columns[t]._filterEditorInitialized&&(e.columns[t]._filterEditorInitialized=!1);const t=!e.isInitialized;if(t&&(e.onInit&&(e.onInit(e),e.onInit=null),e.$.fireEvent("init",{grid:e})),e._renderColumns(!1),e._renderRows(!1),e._renderPagers(),e._renderCommandBar(),e._renderConditionalFormatting(),e._initFormulaParser(),t&&e.grouping.enabled&&e.grouping.groupBy.length&&e.dataSource&&(e.dataSource.groupBy=e.grouping.groupBy),e.appearance.allowColumnStickyPosition&&e._stickHeader(),e.header.visible&&""===e.header.template){const t=document.createElement("smart-grid-toolbar");t.headerPosition="top",t.messages=e.messages,t.locale=e.locale,e.$.header.appendChild(t),e.$.headerBar=e.$.header.firstElementChild,e.$.headerBar._init(e)}if(e.isInitialized)e.refreshFilters();else{let t=!1;if(e.stateSettings.autoLoad){let o=e.stateSettings.current;!o&&e.stateSettings.allowLocalStorage&&(e.stateSettings.current="View 1",o=e.stateSettings.current);let l=null;e.stateSettings.storage&&(l=e.stateSettings.storage[o]),l&&(t=!0),!l&&e.stateSettings.allowLocalStorage&&(l=window.localStorage.getItem(o),l&&(t=!0))}if(!t){const t=[];for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];l.allowSort&&l.sortOrder&&t.push(l)}if(0===t.length&&e.sorting.sort)for(let o=0;o<e.sorting.sort.length;o++){const l=e.sorting.sort[o],a=Object.keys(l)[0],n=l[a],i=e.columnByDataField[a];i&&(t.push(i),i.sortOrder=n||"asc")}t.sort(((e,t)=>e.sortIndex-t.sortIndex));for(let o=0;o<t.length;o++){const l=t[o],a=e.appearance.allowSortAnimation;e.appearance.allowSortAnimation=!1,e.sortBy(l.dataField,l.sortOrder),e.appearance.allowSortAnimation=a}if(e.filtering.filter.length>0){for(let t=0;t<e.filtering.filter.length;t++){const o=e.filtering.filter[t];if(o){if("string"==typeof o){const t=e.filtering.filter[0],o=e.columnByDataField[t],l=e.filtering.filter[1];let a=null;if(o&&(a=e.dataSource._createFilter(o.dataType,l)),a){if(e.filtering.filterRow.visible&&!o._filterInfo){let e=[];for(let t=0;t<a.filters.length;t++)e.push(a.filters[t].value),t<a.filters.length-1&&e.push(a.logicalOperators[t]);o._filterInfo={condition:a.filters[0].condition,value:e.join(" ")}}e.addFilter(t,a,!1)}break}const t=o[0],l=o.splice(1);let a=null;if(l instanceof Smart.FilterGroup)a=l;else{const o=e.columnByDataField[t];o&&(a=e.dataSource._createFilter(o.dataType,l))}if(a){if(e.filtering.filterRow.visible&&!column._filterInfo){let e=[];for(let t=0;t<a.filters.length;t++)e.push(a.filters[t].value),t<a.filters.length-1&&e.push(a.logicalOperators[t]);column._filterInfo={condition:a.filters[0].condition,value:e.join(" ")}}e.addFilter(t,a,!1)}}}e.refreshFilters()}else{for(let t=0;t<e.columns.length;t++){const o=e.columns[t];if(o.filter){let t=null,l=o.filter;if(t=l instanceof Smart.FilterGroup?l:e.dataSource._createFilter(o.dataType,l),t){if(e.filtering.filterRow.visible&&!o._filterInfo){let e=[];for(let o=0;o<t.filters.length;o++)e.push(t.filters[o].value),o<t.filters.length-1&&e.push(t.logicalOperators[o]);o._filterInfo={condition:t.filters[0].condition,value:e.join(" ")}}e.addFilter(o.dataField,t,!1)}}}e.refreshFilters()}}}if(e.viewColumns.canNotify=!0,e.isInitialized=!0,("virtual"===e.scrolling||e.paging.enabled&&e.dataSource&&e.dataSource.virtualDataSource||e.dataSource&&e.dataSource.virtualDataSource)&&e._virtualDataRequest("dataBind"),""!==e.header.template&&e._applyTemplate(e.header.template,e.$.header),""!==e.footer.template&&e._applyTemplate(e.footer.template,e.$.footer),e._createFilterPanels(),e._refresh(),e._applyScrolling(),e.grouping.enabled&&e.grouping.autoExpandAll&&e.rowHierarchy?e.expandAllRows():e.grouping.enabled&&e.grouping.autoExpandToLevel&&e.rowHierarchy&&e.expandRowsToGroupLevel(e.grouping.autoExpandToLevel),e.onRender&&(e.onRender(t),e.onRender=null),e.isRendered=!0,"auto"===e.layout.rowHeight&&(e._refreshLayout(),e._recycle()),t){if(e.stateSettings.autoLoad){let t=e.stateSettings.current,o=null;e.stateSettings.storage&&(o=e.stateSettings.storage[t]),!t&&e.stateSettings.allowLocalStorage&&(e.stateSettings.current="smartGrid"+e.id,t=e.stateSettings.current),!o&&e.stateSettings.allowLocalStorage&&(o=window.localStorage.getItem(t)),o&&("string"==typeof o&&(o=JSON.parse(o)),e._loadState(o))}if(e.onAfterInit&&(e.onAfterInit(e),e.onAfterInit=null),e.$.fireEvent("afterInit",{grid:e}),e.isRendering=!1,e.whenRenderedCallbacks){for(let t=0;t<e.whenRenderedCallbacks.length;t++)e.whenRenderedCallbacks[t]();e.whenRenderedCallbacks=[]}!e.dataSource||e.dataSource.url||e.dataSource.virtualDataSource||e.onLoad&&e.onLoad(e)}"kanban"===e.view&&e._initKanbanView()}_initFormulaParser(){const e=this;if(e.formulas){class t{constructor(e){const t=this;let o;try{o=new formulaParser.Parser}catch(e){throw new Error("Smart.FormulaParser: Missing reference to 'formula-parser.min.js'.")}o.on("callCellValue",t._callCellValue.bind(t)),o.on("callRangeValue",t._callRangeValue.bind(t)),t.dataTable=e,t.parser=o}_getFormula(e){const t=this,o="A".charCodeAt(0);let l=0,a="";const n=e;if(t.dataTable._formulas||(t.dataTable._formulas=[]),t.dataTable._formulas[e])return t.dataTable._formulas[e];for(let n=0;n<t.dataTable.columns.length;n++){const i=t.dataTable.columns[n],r=String.fromCharCode(o+l);l++,l>=26&&(l=0,a+="A"),e.indexOf(i.label)>=0?e=e.replaceAll(i.label,a+r):e.indexOf(i.dataField)>=0&&(e=e.replaceAll(i.dataField,a+r))}return t.dataTable._formulas[n]=e,e}_callCellValue(e,t){const o=this,l=o.dataTable,a=e.column.index,n=e.row.index,i=l.columns[a].dataField;let r=l.dataSource[n][i];const s=l.rows[n];if(s){const e=s.getCell(i);e&&e.formula&&(r=o._getFormula(e.formula))}"string"==typeof r&&/=.+/.test(r)&&(r=o.parse(r.slice(1))),t(r)}_callRangeValue(e,t,o){const l=this.dataTable,a=l.dataSource,n=[];for(let o=e.row.index;o<=t.row.index;o++){const i=a[o],r=[];for(let o=e.column.index;o<=t.column.index;o++){let e=i[l.columns[o].dataField];e=isNaN(e)?0:parseFloat(e),isNaN(e)&&(e=0),r.push(e)}n.push(r)}n&&o(n)}parse(e){const t=this.parser.parse(this._getFormula(e));return null!==t.result?t.result:t.error}}e._formulaParser=new t(e)}}get _viewRows(){const e=this;if(e.__viewRows)return e.__viewRows;e._nearRowsAdded||(e._nearRowsAdded=[],e._farRowsAdded=[]);const t=e.rows.toArray?e.rows.toArray():[],o=e.rowHierarchy?e.rowHierarchy:t,l=[].concat(e._frozenNearDefaultRows,e._nearRowsAdded,o,e._farRowsAdded,e._frozenFarDefaultRows);return e.__viewRows=l,l}_toHex(e){if(-1!==e.indexOf("#"))return e;const t=/rgb\((\d+), (\d+), (\d+)\)/g.exec(e);return t?"#"+(parseFloat(t[1]).toString(16).padStart(2,"0")+parseFloat(t[2]).toString(16).padStart(2,"0")+parseFloat(t[3]).toString(16).padStart(2,"0")).toUpperCase():"#FFFFFF"}_renderConditionalFormatting(){const e=this,t=e.conditionalFormatting;if(!t||0===t.length)return;if(!e._defaults){const t=getComputedStyle(e);e._defaults={fontFamily:t.fontFamily,fontSize:t.fontSize,text:e._toHex(t.color),highlight:e._toHex(t.backgroundColor)}}e._formatter||(e._formatter=new Smart.Utilities.ConditionalFormatter(e.dataSource));const o=e._defaults,l=e._formatter,a=[],n=function(t){if("all"===t){if(e.columns&&e.columns.map){const t=[];for(let o=0;o<e.columns.length;o++){const l=e.columns[o];l.dataField.startsWith("task")||l.autoGenerated||"number"!==l.dataType&&"date"!==l.dataType||t.push(l.dataField)}return t}return[]}return[t]};for(let e=0;e<t.length;e++){t[e]=Object.assign({column:"all",condition:"lessThan",firstValue:0,secondValue:1,fontFamily:o.fontFamily,fontSize:o.fontSize,text:o.text,highlight:o.highlight},t[e]);const i=t[e],r=n(i.column),s=i.condition;l.color=i.highlight,l.comparator=i.firstValue,l.min=i.firstValue,l.max=i.secondValue;const d=l.format(s,r);for(let e in d){const t=d[e];for(let e in t){const o=t[e];o.color=i.text,o.fontFamily=i.fontFamily,o.fontSize=i.fontSize}}a.push(d)}if(e._formattingPanel&&(e._formattingPanel.items=t),0===a.length)return a[0];const i={};for(let e=0;e<a.length;e++){const t=a[e];for(let e in t){const o=t[e];if(0!==Object.keys(o).length){i[e]||(i[e]={});for(let t in o)i[e][t]=Object.assign({},i[e][t],o[t])}}}e._conditionalFormatting=i}_stickHeader(){const e=this;e._stickyHeaderHandler=function(){e._handleStickyHeader()},e.$.columnHeader.style.top="",e.$.columnHeader.classList.remove("smart-columns-sticky");let t=e.parentNode;for(e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);t!==document&&t;)t.addEventListener("scroll",e._stickyHeaderHandler),t=t.parentNode,e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);try{null!==window.top&&window.top!==window.self&&window.top.document.addEventListener("scroll",e._stickyHeaderHandler)}catch(e){}e._handleStickyHeader()}_unstickHeader(){const e=this;e.$.columnHeader.style.top="",e.$.columnHeader.classList.remove("smart-columns-sticky");let t=e.parentNode;for(;t!==document.body;)t.removeEventListener("scroll",e._stickyHeaderHandler),t=t.parentNode,e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);try{(""!==document.referrer||window.frameElement)&&null!==window.top&&window.top!==window.self&&window.top.document.removeEventListener("scroll",e._stickyHeaderHandler)}catch(e){}}_handleStickyHeader(){const e=this;if(e.appearance.allowColumnStickyPosition)if(e.$.columnHeader.classList.add("smart-columns-sticky"),0===document.scrollTop&&0===e.parentElement.scrollTop)e.$.columnHeader.style.top="";else{let t=e.parentNode,o=0;for(;t!==document.body;)o+=parseInt(t.scrollTop),t=t.parentNode,e.isInShadowDOM&&t===e.getRootNode()&&(t=e.getRootNode().host);const l=parseInt(e.clientTop+o);e.$.columnHeader.style.top=l+"px";let a=0;window.top!==window.self&&parseInt(window.top.scrollY)>parseInt(e._offsetTop(window.frameElement))&&(a=parseInt(window.top.scrollY)-parseInt(e._offsetTop(window.frameElement))),window.scrollY+a>e.offsetTop&&(e.$.columnHeader.style.top=parseInt(window.scrollY)-parseInt(e.offsetTop)+l+a+"px")}}_scrollHandler(){this._handleStickyHeader()}_initializeRowNumberColumn(){const e=this;if(e._frozenNearColumns&&e._frozenNearColumns.length>0&&e._frozenNearColumns[0].rowHeaderColumn)return void(e._frozenNearColumns[0].visible=e.appearance.showRowHeaderNumber||e.appearance.showRowHeader);const t=new Smart.Grid.Column({dataField:"_rowHeaderColumn",label:"",allowSelect:!1,freeze:!0,visible:!0,grid:e,autoGenerated:!0,rowHeaderColumn:!0,cellsAlign:"center"}),o=e.rows?e.rows.length:e.dataSource?e.dataSource.length:0;let l=e.appearance.showRowHeaderNumber?t._measureSize(o):30;e.layout.autoGenerateColumnWidth&&(l=e.layout.autoGenerateColumnWidth),t.width=l,t.createElement();const a=new Smart.Observable(t,t.observables);e.viewColumns.splice(0,0,a),e._frozenNearColumns.splice(0,0,a)}_initializeColumns(){const e=this;if("number"==typeof e.columns){const t=[],o="A".charCodeAt(0);let l="",a=0;for(let n=0;n<e.columns;n++){let i=n+1;const r=String.fromCharCode(o+a);a++;const s=l+r;"number"!==e.appearance.autoGenerateColumnLabelMode&&(i=l+r),t.push({align:"center",label:i,dataField:s,width:100}),a>=26&&(a=0,l+="A")}e._boundColumns=t}else e._boundColumns=Array.isArray(e.columns)?[...e.columns]:[...e.columns.toArray()];e._initColumns=e.columns,e.columnByDataField=[],e.viewColumns=[],e.columns=new Smart.ObservableArray,e._frozenFarColumns=[],e._frozenNearColumns=[],e._summaryRowCount=1;let t=0;const o=function(t){if(e.dataSource.dataFields){const o=e.dataSource.dataFields.find((e=>{if(e.name===t.dataField)return e})),l=o&&o.dataType||"string";t.dataType||(t.dataType=l)}};if(0===e._boundColumns.length&&e.dataSource&&e.dataSource[0]&&!1!==e.dataSource.autoGenerateColumns){const t=e.dataSource[0];if(t.$&&t.$.isEmpty&&e.dataSource.dataFields)for(let t=0;t<e.dataSource.dataFields.length;t++){const o=e.dataSource.dataFields[t],l=e._boundColumns.length,a={index:l,visibleIndex:l,label:o.name,dataField:o.name,dataType:o.dataType};e._boundColumns.push(a)}else for(let l in t){if(l.startsWith("_")||"$"===l)continue;const t=e._boundColumns.length,a={index:t,visibleIndex:t,label:l,dataField:l};o(a),e._boundColumns.push(a)}}for(let l=0;l<e._boundColumns.length;l++){let a=e._boundColumns[l];if("string"==typeof a){if(e.dataSource.dataFields){const t=e.dataSource.dataFields.find((e=>{if(e.name===a)return e}));a={label:a,dataField:a,dataType:t&&t.dataType||"string"}}}else o(a);a.visibleIndex=l,a.index=l,a.grid=e,a.label&&/<.+?>/.test(a.label)&&a.label.replace&&("all"===e.dataSourceSettings.sanitizeHTML?a.label=a.label.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===e.dataSourceSettings.sanitizeHTML&&(a.label=window.Smart.Utilities.Core.escapeHTML(a.label)));const n=new Smart.Grid.Column(a);e.onColumnInit&&e.onColumnInit(l,n);for(let t in n)-1!==n.properties.indexOf(t)||t.startsWith("_")||e.error(e.localize("invalidColumnProperty",{elementType:"Grid",propertyName:t,type:n.dataField||"Column"}));delete a.grid,delete a.dataType,delete a.index,delete a.visibleIndex,n.grid=e,e.columns.push(n),n._dataField&&(e.columnByDataField[n._dataField]=n);const i=e.columns[e.columns.length-1];e._summaryRowCount=Math.max(e._summaryRowCount,n.summary.length),n.freeze?!0===n.freeze||"near"===n.freeze?(e.viewColumns.splice(t++,0,i),e._frozenNearColumns.push(i)):"far"===n.freeze&&e._frozenFarColumns.push(i):e.viewColumns.push(i),e.columnByDataField[n.dataField]?(i.parent=e.columnByDataField[n.dataField],e.columnByDataField[n.dataField].children||(e.columnByDataField[n.dataField].children=[]),e.columnByDataField[n.dataField].children.push(i),n.valueField=n.dataField,n.dataField+="_"+e.columnByDataField[n.dataField].children.length,n.displayField=n.valueField,e.columnByDataField[n.dataField]=i):e.columnByDataField[n.dataField]=i,e.onColumnInserted&&!e.isInitialized&&e.onColumnInserted(l,n.getState())}e.viewColumns=e.viewColumns.concat(e._frozenFarColumns),e.setAttribute("aria-colcount",e._boundColumns.length);let l=0;if((e.appearance.showRowHeaderNumber||e.appearance.showRowHeader)&&(e._initializeRowNumberColumn(),l++),e.rowDetail.enabled){const t=20,o=new Smart.Grid.Column({dataField:"_rowDetailColumn",allowSelect:!1,visible:e.rowDetail.visible,label:"",grid:e,freeze:!0,rowDetailColumn:!0,autoGenerated:!0,cellsAlign:"center",width:t,minWidth:t}),a=new Smart.Observable(o,o.observables);"near"===e.rowDetail.position?(o.freeze="near",a.freeze="near",e.viewColumns.splice(l,0,a),e._frozenNearColumns.splice(l,0,a)):(e.viewColumns.push(a),e._frozenFarColumns.splice(0,0,a)),l++}const a=new Smart.Grid.Column({dataField:"_adaptiveColumn",allowSelect:!1,visible:!1,label:"",grid:e,freeze:"far",adaptiveColumn:!0,autoGenerated:!0,cellsAlign:"center",width:30}),n=new Smart.Observable(a,a.observables);n.canNotify=!1,e.viewColumns.push(n),e._frozenFarColumns.splice(0,0,n);const i=new Smart.Grid.Column({dataField:"_commandColumn",allowSelect:!1,visible:e.editing.enabled&&e.editing.commandColumn.visible&&!e.editing.commandColumn.inline,label:"",grid:e,freeze:"far",commandColumn:!0,autoGenerated:!0,align:"center",cellsAlign:"center",width:""}),r=new Smart.Observable(i,i.observables);r.canNotify=!1,"near"===e.editing.commandColumn.position?(i.freeze="near",r.freeze="near",e.viewColumns.splice(l,0,r),e._frozenNearColumns.splice(l,0,r)):(e.viewColumns.push(r),e._frozenFarColumns.splice(0,0,r)),e._commandColumn=r;const s=new Smart.Grid.Column({allowSelect:!1,visible:e.selection.enabled&&e.selection.checkBoxes.enabled,dataField:"_checkBoxColumn",label:"",freeze:e.selection.checkBoxes.position,grid:e,selectionColumn:!0,autoGenerated:!0,cellsAlign:"center",width:32}),d=new Smart.Observable(s,s.observables);if("near"===s.freeze?(e.viewColumns.splice(l,0,d),e._frozenNearColumns.splice(l,0,d)):(e.viewColumns.push(d),e._frozenFarColumns.splice(0,0,d)),e._selectionColumn=d,e._selectionColumn.canNotify=!1,e.editing.addNewColumn.visible){const t=new Smart.Grid.Column({dataField:"_addNewColumn",allowSelect:!1,visible:!0,title:e.localize("addNewColumn"),label:"",cellsClassName:"smart-add-new-column",className:"smart-add-new-column smart-icon smart-grid-icon show smart-icon-plus",grid:e,adaptiveColumn:!1,autoGenerated:!0,cellsAlign:"center",width:90}),o=new Smart.Observable(t,t.observables);e.viewColumns.push(o),e._addNewColumn=o,e._addNewColumn.canNotify=!1}e._observeColumns(),e._templateColumns()}get styleProperties(){return["grid-template-columns","--smart-grid-row-height","--smart-grid-column-header-height","--smart-grid-group-header-height","--smart-grid-filter-footer-height","--smart-grid-group-row-vertical","--smart-grid-group-row-horizontal-offset","--smart-grid-freeze-splitter-size","--smart-grid-resize-line-size","--smart-grid-footer-height","--smart-grid-header-height"]}_templateColumns(){const e=this,t=getComputedStyle(e),o=t.getPropertyValue("--smart-grid-template-columns").trim();if(e._rowGap=0,e._columnGap=0,e._maxHeight=parseInt(t.maxHeight),e._minHeight=parseInt(t.minHeight),"none"!==o){let t=0;for(let o=0;o<e.viewColumns.length;o++)e.viewColumns[o].autoGenerated&&(t+=e.viewColumns[o].visible?e.viewColumns[o].width:0);let l=[];const a=document.createElement("div");a.style.display="grid",a.style.gridTemplateColumns=o;for(let t=0;t<e.columns.length;t++)a.innerHTML+="<div></div>";a.style.width=e.clientWidth-t+"px",e.$.root.appendChild(a);const n=o.split(" ");for(let t=0;t<e.columns.length;t++)l[t]=a.children[t].offsetWidth,"auto"===n[t]&&(l[t]=null);a.parentNode.removeChild(a);let i=0;for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.autoGenerated||l[i]&&(o.width=o.templateWidth=l[i++])}}else for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.autoGenerated||o.templateWidth&&(o.width=o.templateWidth=null)}}setColumns(e){const t=this;if(null===e)return void(t.columns=[]);t.beginUpdate(),t.columns.canNotify=!1;let o=[],l=[];for(let l=0;l<e.length;l++){const a=e[l];let n=!0;for(let e=0;e<t.columns.length;e++)if(t.columns[e].dataField===a.dataField){n=!1;break}n&&o.push(a)}const a=e.map((e=>e.dataField));for(let e=0;e<t.columns.length;e++){const o=t.columns[e];-1===a.indexOf(o.dataField)&&l.push(o)}l.forEach((e=>{const o=t.columns.indexOf(e);o>=0&&t.columns.splice(o,1)}));for(let e=0;e<o.length;e++)t.columns.push(o[e]);if(t.columns.canNotify=!0,t.endUpdate(),t._columnGroups=[],t._columnHeights=0,t.viewColumns)for(let e=0;e<t.viewColumns.length;e++){const o=t.viewColumns[e],l=o.element;o.top=0,o.level=0,l&&(l.style.top="",l.style.height="",l.style.lineHeight="")}if(t._renderColumns(),t.__columnHeaderHeight=null,e){t.beginUpdate();const o=t.context;t.context=document;for(let o=0;o<e.length;o++){const l=e[o],a=t.columnByDataField[l.dataField];["allowExport","allowFreeze","allowNull","allowGroup","allowSelect","verticalAlign","columnGroup","cellsVerticalAlign","autoCloseMenu","autoShowActionButton","autoShowSortButton","autoShowFilterButton","allowLabelAnimation","allowActionButtonAnimation","allowSortButtonAnimation","allowHide","allowDelete","allowEdit","allowSummary","allowHeaderEdit","allowFilter","allowSort","allowSortToggleOnClick","allowResize","allowReorder","description","icon","menuItems","summary","cellsFormat","className","rowSpan","cellsClassName","cellsCSSRules","formatSettings","formatFunction","sortIndex","sortOrder","sortComparator","groups","group","filtered","filterEditor","filter","filterMenuMode","defaultValue","dataField","displayField","label","labelTemplate","dataType","align","cellsWrap","cellsAlign","minWidth","width","visible","_visible","freeze","showActionButton","selected","showIcon","highlight","showDescriptionButton","treeColumn","statusColumn","value","valueField","onAction","title","showCustomButton","showFilterButton","showSortButton","editor","template","visibleIndex","validationRules"].forEach((e=>{void 0!==l[e]&&(a[e]=l[e])}))}t.context=o,t.endUpdate(!1)}t.refresh()}onAttached(){const e=this;if(!e._scrollView){e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar);const t=e._scrollView.hScrollBar;e._scrollView.vScrollBar.onChange=e._verticalScrollbarHandler.bind(e),t.onChange=e._horizontalScrollbarHandler.bind(e)}e.isRendered&&e.isCompleted&&(e.header.visible&&""===e.header.template&&(e.$.header.innerHTML='<smart-grid-toolbar header-position="top"></smart-grid-toolbar>',e.$.headerBar=e.$.header.firstElementChild,e.$.headerBar._init(e),e.header.onInit&&e.header.onInit(e.$.headerBar)),e._render())}onDetached(){const e=this;if(!e.isRendered)return;["_dialogChart","_dialogAddRow","_dialogEdit","_dialogDelete","_dialogRowDetail","_dialogAddColumn"].forEach((t=>{e[t]&&(e[t].close(),e[t]=null)})),e.menu&&(e.menu.ownerElement=null,e.menu.remove(),e.menu=null);const t=e.querySelector("smart-grid-toolbar");if(t){const e=t.$.headerDropDown;e&&e.remove()}e._resetCachedLayout();const o=e._scrollView.hScrollBar,l=e._scrollView.vScrollBar;if(l.ownerElement=null,o.ownerElement=null,l.onChange=null,o.onChange=null,e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),e._columnElements)for(let t=0;t<e._columnElements.length;t++)e._columnElements[t]._detach();if(e._columnElements=null,e._rowElements)for(let t=0;t<e._rowElements.length;t++)e._rowElements[t]._detach();e._rowElements=null,e.rows=[],e.rowById=[],e._initColumns=[],e.columnByDataField=[],e.viewColumns=[],e._columnToResizeElement=null;let a=Array.isArray(e.columns)?[...e.columns]:[...e.columns.toArray()];a=a.map((e=>e.data?(void 0!==e.data.visibleIndex&&delete e.data.visibleIndex,void 0!==e.data.index&&delete e.data.index,void 0!==e.data.grid&&delete e.data.grid,e.data):e)),e.rows.notifyFn=null,e.columns.notifyFn=null,e.columns.notify=null,e.columns._array=[],e.columns=a,e._boundColumns=[],e._filterPanels=[],e._frozenFarColumns=[],e._frozenNearColumns=[],e._frozenNearDefaultRows=[],e._frozenFarDefaultRows=[],e._frozenFarRows=[],e._frozenNearRows=[],e._selection={rows:[],indexes:[],columns:[],cells:[]},e.__autoHeightRows=null,e._visibleRows=null,e.__viewRows=null,e.__clientSize=null,e.__scrollHeight=null,e.__scrollWidth=null,e.__parentCells=null,e._selectionColumn=null,e._adaptiveColumn=null,e._commandColumn=null,delete e._columnFarContainerComputedStyle,delete e._columnContainerComputedStyle,delete e._columnNearContainerComputedStyle,e._inputOverlay&&(e._inputOverlay.parentNode&&e._inputOverlay.parentNode.removeChild(e._inputOverlay),e._inputOverlay=null),e._firstVisibleColumn=null,e._lastVisibleColumn=null,e._toggledRow=null,Smart(e._selector)&&(delete Smart(e._selector)._properties,Smart(e._selector)),delete e._selector,delete e._initProperties}_observeColumns(){const e=this,t=function(t,o,l,a){l===a&&"selected"!==o||(t.propertyChanged(o,l,a),e.onColumnChange?t.stateProps.indexOf(o)>=0&&e.onColumnChange(t,o,l,a):e.$.fireEvent("columnChange",{column:t,propertyName:o,oldValue:l,value:a}))};for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];l.rowHeaderColumn||(l.onAction=function(){e._openMenu(this)}),l.autoGenerated&&l.notify((function(e){l.canNotify=!1,t(l,e.propertyName,e.oldValue,e.newValue),l.canNotify=!0}))}e.columns.notify((function(o){let l=null;if(o.path)return e.columns.canNotify=!1,t(o.target,o.propertyName,o.oldValue,o.newValue),void(e.columns.canNotify=!0);e.columns.canNotify=!1;let a=0;switch(o.action){case"length":return void(e.columns.canNotify=!0);case"add":{const t=function(t){if(l=o.object[t],l instanceof Smart.Grid.Column==0){l.grid=e,l=new Smart.Grid.Column(l);const a=e.columns.canNotify;e.columns.canNotify=!1,o.object[t]=l,l=o.object[t],e.columns.canNotify=a}l.grid=e,l.onAction=function(){e._openMenu(this)},l.freeze?e._frozenNearColumns.push(l):"far"===l.freeze&&e._frozenFarColumns.push(l);let a=e.viewColumns.length-e._frozenFarColumns.length,n=0;if(e._frozenNearColumns.forEach((e=>{e.autoGenerated&&n++})),t<e.columns.length?e.viewColumns.splice(t+n,0,l):e.viewColumns.splice(a,0,l),e.columnByDataField[l.dataField]){e.columnByDataField[l.dataField].children.push(l),l.parent=e.columnByDataField[l.dataField],l.valueField=l.dataField;const t=l.dataField+"_"+l.parent.children.length;e.columnByDataField[t]=l,l.dataField=t}else e.columnByDataField[l.dataField]=l;if(e.dataSource&&e.dataSource.dataFields){let t=!1;for(let o=0;o<e.dataSource.dataFields.length;o++)e.dataSource.dataFields[o].name===l.dataField&&(t=!0);t||e.dataSource.dataFields.push({name:l.dataField,dataType:l.dataType||"string"})}if(!e._dragDrop&&e.onColumnInserted){e._onColumnInsertData||(e._onColumnInsertData=[],e._onColumnInsertIndexes=[]);const o=l.getState();o.dataField=l.dataField,e._onColumnInsertData.push(o),e._onColumnInsertIndexes.push(t),e._onColumnInsertTimer&&clearTimeout(e._onColumnInsertTimer),e._onColumnInsertTimer=setTimeout((()=>{e.onColumnInserted(e._onColumnInsertIndexes,e._onColumnInsertData),delete e._onColumnInsertIndexes,delete e._onColumnInsertData}),50)}};delete e.__measuredColumnHeight;for(let e=0;e<o.addedCount;e++)t(o.index+e);break}case"update":l=o.object[o.index],l instanceof Smart.Grid.Column==0&&(l=new Smart.Grid.Column(l)),l.grid=e;for(let t=0;t<o.index;t++)e.viewColumns[t].autoGenerated&&a++;e.viewColumns[a+o.index]=l,e.columnByDataField[l.dataField]=l,e.onColumnUpdated&&e.onColumnUpdated(o.index,l);break;case"remove":{l=o.removed[0];let t=o.index,n=e.viewColumns.indexOf(l);if(-1===n){for(let o=0;o<=t;o++)e.viewColumns[o].autoGenerated&&a++;e.viewColumns.splice(a+t,1)}else e.viewColumns.splice(n,1);if(l){if(l.filter&&e.removeFilter(l.dataField),l.sortOrder&&e.removeSort(l.dataField),e.removeGroup(l.dataField),l._dataField){const t=e.columnByDataField[l._dataField];t&&t.dataField===l.dataField&&delete e.columnByDataField[l._dataField]}delete e.columnByDataField[l.dataField]}if(e._dragDrop||e.onColumnRemoved&&e.onColumnRemoved(o.index,l),e.columnGroups&&(e._columnGroups=[],e._columnHeights=0,e.viewColumns))for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t],l=o.element;o.top=0,o.level=0,l&&(l.style.top="",l.style.height="",l.style.lineHeight="")}break}}e._initializeColumnGroupsHierarchy(),e._refreshColumnsResponsiveVisibility(),e._createColumnHeaderCellElements(),e._templateColumns(),e.refresh(),e.columnGroups&&e._columnGroups.length>0&&e._renderColumnGroupHeaders(),e.columns.canNotify=!0}))}get _scrollWidth(){const e=this;if(e.__scrollWidth)return e.__scrollWidth;let t=0;for(let o=0;o<e.viewColumns.length;o++){const l=e.viewColumns[o];l.visible&&(t+=l.computedWidth)}return t=parseInt(t),"card"===e.view&&(t=0),e.__scrollWidth=t,e._scrollView.scrollWidth=t-e._clientSize.width,e.__scrollWidth}_horizontalScrollbarHandler(){const e=this;e.closeMenu(),e.isScrolling=!0,e.isHScrolling=!0,requestAnimationFrame((()=>{e._summaryRowDialog&&e._summaryRowDialog.classList.contains("open")&&e._summaryRowDialog.close(),e._recycle(),e.isScrolling=!1,e.isHScrolling=!1}))}_mouseWheelNative(e,t){const o=this;void 0===o._scrollWheelContent&&(o._scrollWheelContent=document.createElement("div"),o._scrollWheelContent.style.width="100%",o._scrollWheelContent.style.height="100%",o._scrollWheelContent.style.position="absolute",o._scrollWheelContent.style.left="0px",o._scrollWheelContent.style.top="0px",o._scrollWheelContent.style.background="white",o._scrollWheelContent.style.zIndex=9999,o._scrollWheelContent.style.opacity=0,o._scrollWheelContent.style.overflow="auto",o._scrollWheelContent.style.visibility="hidden");let l=0;const a=()=>{if(t){const t=o._scrollWheelContent.scrollLeft;o._scrollView.hScrollBar.value=t,t===e&&o._scrollWheelContent.remove()}else{const t=o._scrollWheelContent.scrollTop;o._scrollView.vScrollBar.value=t,t===e&&o._scrollWheelContent.remove()}};o._scrollWheelContent.onscroll=()=>{cancelAnimationFrame(l),l=0,l=requestAnimationFrame(a)},o._scrollWheelContentView||(o._scrollWheelContentView=document.createElement("div"),o._scrollWheelContent.appendChild(o._scrollWheelContentView)),o._scrollWheelContentView.style.width=o.offsetWidth+o._scrollView.scrollWidth+"px",o._scrollWheelContentView.style.height=o.offsetHeight+o._scrollView.scrollHeight+"px",o.$.scrollView.appendChild(o._scrollWheelContent),o._scrollWheelContent.scrollTop=o._scrollView.vScrollBar.value,o._scrollWheelContent.scrollLeft=o._scrollView.hScrollBar.value,!0===t?o._scrollWheelContent.scrollTo({top:o._scrollView.vScrollBar.value,left:e,behavior:"smooth"}):o._scrollWheelContent.scrollTo({top:e,left:o._scrollView.hScrollBar.value,behavior:"smooth"})}_mouseWheelHandler(e){const t=this;if(t._scrollView.hScrollBar.$.hasClass("smart-hidden")&&t._scrollView.vScrollBar.$.hasClass("smart-hidden"))return;if(42===e.pointerId)return;if(t._isUpdating)return;if(t.editing.isEditing)return;const o=t.querySelector("smart-grid-toolbar");if(o&&o.$.headerDropDown.classList.contains("open"))return;let l=!1;if(e.wheelDeltaY?120!==Math.abs(e.wheelDeltaY)&&240!==Math.abs(e.wheelDeltaY)&&360!==Math.abs(e.wheelDeltaY)&&(l=!0):0===e.deltaMode&&(l=!0),t.disabled||t._scrollView.vScrollBar.$.hasClass("smart-hidden")||e.shiftKey||!e.deltaY){if(!t.disabled&&(!t._scrollView.hScrollBar.$.hasClass("smart-hidden")||e.shiftKey)){e.stopPropagation(),e.preventDefault();let o=160;const a=0===e.deltaX?e.wheelDelta:e.deltaX;a<0&&(o=-160),Math.abs(a)>=100&&!l&&!Smart.Utilities.Core.Browser.Firefox?t._mouseWheelNative(t._scrollView.scrollLeft+o,!0):t._scrollView.scrollLeft+=a}}else{const o=t.scrollTop;if(0===o&&e.deltaY<0||o===t.scrollHeight&&e.deltaY>0)return;e.stopPropagation(),e.preventDefault();let a=7*t.layout.rowMinHeight;if(e.deltaY<=0&&(a=-7*t.layout.rowMinHeight),Math.abs(e.deltaY)>=100&&!l&&!Smart.Utilities.Core.Browser.Firefox)t._mouseWheelNative(t._scrollView.scrollTop+a);else{t._wheelrafId=0;const o=()=>{t._scrollView.scrollTop+=e.deltaY};cancelAnimationFrame(t._wheelrafId),t._wheelrafId=0,t._wheelrafId=requestAnimationFrame(o)}}}_refresh(){const e=this;if(e._isUpdating)return;const t=e.$.verticalScrollBar.offsetWidth;e.removeAttribute("grouped"),e.removeAttribute("tree");let o=!0;e.__autoHeightRows&&(e.__autoHeightRows=null,e._refreshColumnsResponsiveVisibility(),e._recycle(),o=!1),e._groups||(e._groups=[]),e.grouping.enabled&&e.dataSource.groupBy&&e.dataSource.groupBy.length>=0&&("advanced"===e.grouping.renderMode?e.setAttribute("grouped",""):e.setAttribute("tree",""),e._groups||(e._groups=[].concat(e.dataSource.groupBy.toArray())||[]),e._renderGroupBar()),e.grouping.enabled&&e.dataSource.groupBy&&0===e.dataSource.groupBy.length?e.$.breadcrumb&&(e.$.breadcrumb.dataSource=[]):e.dataSource.boundHierarchy&&(e.setAttribute("tree",""),e.setAttribute("role","treegrid")),(e.isInitialized||o)&&e._refreshColumnsResponsiveVisibility(),e._refreshLayout(),t!==e.$.verticalScrollBar.offsetWidth&&(e.__scrollWidth=null,e._refreshColumnsResponsiveVisibility(),e._refreshScrollBars(),0===e.$.verticalScrollBar.offsetWidth&&e.isRendered&&requestAnimationFrame((()=>{e._refreshScrollBars()}))),e._refreshSelection(),e._recycle(),e._refreshHeaderBar(),e._recyclingRows&&0===e._recyclingRows.length&&(e.$.placeholder.classList.remove("smart-hidden"),e.scrollHeight=0,e.$.placeholder.innerHTML=e.appearance.placeholder,e.filtering.filterRow.visible&&(e.$.placeholder.style.top="0px",e.$.placeholder.style.position="relative",e._filters&&e._filters.length&&(e.$.placeholder.style.top="12px")),e._filters&&e._filters.length&&(e.$.placeholder.innerHTML=`<span class="smart-grid-icon show smart-icon-filter" style="\n font-size: calc(2 * var(--smart-font-size));\n cursor: default;\n margin-right: 10px;\n "></span>${e.localize("filteredRecords")}`)),requestAnimationFrame((()=>{e._width=e.offsetWidth,e._height=e.offsetHeight}))}_refreshHeaderBar(){const e=this;e.$.headerBar&&e.header.visible&&e.$.headerBar._refresh()}_resizeHandler(e){const t=this;if((t.enableShadowDOM?e.composedPath()[0]:e.target)===t&&!t._isUpdatingScrollBars){if(!t.isInitialized)return void t._render();if(!1===t._resizeHandling||!t.offsetHeight)return void(!1===t._resizeHandling&&(t.layout.isDirty=!0));t._isUpdatingScrollBars=!0,t._autoHeight=!1,t.$.content&&t.$.content.classList.remove("auto-height");const e=t._rowElements?t._rowElements.length*t.layout.rowMinHeight:0;(e>0||"grid"!==t.view&&"card"!==t.view)&&(t.offsetHeight>=e?(t._refreshLayout(),t._initializeRowElements()):"grid"!==t.view&&t._refreshLayout()),t.refresh(),t.$.headerBar&&t.$.headerBar.refreshTools(),t._dialogAddColumn&&t._dialogAddColumn.classList.contains("open")&&t._dialogAddColumn.refresh(),t._isUpdatingScrollBars=!1}}_refreshColumnsResponsiveVisibility(){const e=this,t=e.$.columnContainer,o=e.$.columnNearContainer,l=e.$.columnFarContainer;let a=0,n=0,i=0,r=!1;const s=e.columns.canNotify;e.columns.canNotify=!1;for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.setProperty("_treeColumn",!1,!1),e.grouping.enabled&&e.grouping.autoHideGroupColumn&&e.dataSource.groupBy&&e.dataSource.groupBy.indexOf(o.dataField)>=0&&o.setProperty("visible",!1,!1),o.visible&&!o.autoGenerated&&!r&&e.dataSource.boundHierarchy&&(o.setProperty("_treeColumn",!0,!1),r=!0)}e._refreshColumnWidths(),e.columns.canNotify=s;let d=0,u=0;for(let t=0;t<e.viewColumns.length;t++){const o=e.viewColumns[t];o.visible&&(o.freeze&&(!0===o.freeze||"near"===o.freeze?(a+=o.computedWidth,o.autoGenerated&&(d+=o.computedWidth)):"far"===o.freeze&&(n+=o.computedWidth,o.autoGenerated&&(u+=o.computedWidth))),i+=o.computedWidth)}t.style.width=i+"px",o.style.width=a+"px",l.style.width=n+"px",l.classList.remove("smart-hidden"),o.classList.remove("smart-hidden"),0===n&&l.classList.add("smart-hidden"),0===a&&o.classList.add("smart-hidden"),l.classList.remove("border-collapse"),n===u&&l.classList.add("border-collapse"),e._autoGeneratedColumnsNearWidth=d,e._autoGeneratedColumnsFarWidth=u,e._computedColumnsWidth=i,e._frozenColumnsNearWidth=a,e._frozenColumnsFarWidth=n}_selectStartHandler(e){const t=this;t.isScrolling||t.editing.isEditing||"grid"!==t.view||t.selection.defaultSelection||e.preventDefault()}setFocusable(e){const t=this;!t.disabled&&e?t.tabIndex=0:t.removeAttribute("tabindex")}_setLoadingIndicatorVisibility(){const e=this;e.appearance.displayLoadingIndicator?e.$.loadingIndicatorContainer.classList.remove("smart-visibility-hidden"):e.$.loadingIndicatorContainer.classList.add("smart-visibility-hidden")}_refreshElementsVisibility(){const e=this,t=function(e,t){e&&(t?e.classList.remove("smart-hidden"):e.classList.add("smart-hidden"))};if(t(e.$.placeholder,!e.rows||e.rows&&0===e.rows.length||0===e.columns.length),t(e.$.footer,e.footer.visible),t(e.$.header,e.header.visible),t(e.$.groupHeader,e.groupHeader.visible||e.grouping.groupBar.visible),t(e.$.columnHeader,e.columnHeader.visible&&e.columns.length>0),t(e.$.headerCommandBar,e.editing.commandBar.visible&&"far"!==e.editing.commandBar.position),t(e.$.footerCommandBar,e.editing.commandBar.visible&&"near"!==e.editing.commandBar.position),t(e.$.breadcrumb,e.groupHeader.visible||e.grouping.groupBar.visible),e.htmlColumnLastChild.classList.add("smart-visibility-hidden"),e.pager&&e.pager.visible&&e.paging.enabled)switch(e.pager.position){case"near":t(e.$.headerPager,!0),t(e.$.footerPager,!1);break;case"far":t(e.$.headerPager,!1),t(e.$.footerPager,!0);break;case"both":t(e.$.headerPager,!0),t(e.$.footerPager,!0)}else t(e.$.footerPager,!1),t(e.$.headerPager,!1)}_getId(){const e=this;return e.dataSource&&e.dataSource.id?e.dataSource.id:e.dataSourceSettings.id?e.dataSourceSettings.id:void 0}_refreshRowHierarchy(e,t=!1){const o=this;o.rowHierarchy=null;let l=0,a=!1;if(!o.grouping.enabled&&o.dataSource.groupBy&&o.dataSource.groupBy.length>0&&(a=!0),o.grouping.enabled&&o.dataSource.groupBy&&0===o.dataSource.groupBy.length)return;let n=!1;if(o.grouping.enabled&&o.dataSource.groupBy&&o.dataSource.groupBy.length>0&&o.dataSource.virtualDataSourceOnExpand&&(n=!0),o.dataSource.boundHierarchy){const i=o.dataSource.reservedNames,r=function(e){return new Smart.Grid.Row({data:e,grid:o,index:o.rows.length})};let s=0;const d=function(t,l){for(let u=0;u<t.length;u++){const c=t[u];let m=o.rowById[c.$.id];if(n&&(m=o.rows[s],m||(m=r(c),o.rows.push(m)),c[i.leaf]?m.id=c.$.id:m.id="Group_"+c.$.id,o.rowById[m.id]=m),m||(m=r(c),o.rowById[m.id]=m),m.data=c,m.leaf=c[i.leaf]||!1,m.level=c[i.level],m.groupDataField=c.groupDataField,!m.groupDataField&&o.appearance.showTreeRowHeader&&(m.groupDataField=o.columns[m.level].dataField),m.label=c.label,m.groupDataField){const e=o.columnByDataField[m.groupDataField];if(e&&e.editor.dataSource)for(let t=0;t<e.editor.dataSource.length;t++){const o=e.editor.dataSource[t];if(""+o.value===m.label){void 0!==o.label?(m.label=o.label,m.labelValue=o.value):void 0!==o.name&&(m.label=o.name,m.labelValue=o.value);break}}}if(m.children=[],m.data&&(m.filtered=void 0===m.data.$.filtered||m.data.$.filtered),c.summaryRow&&(m.summaryRow=!0),(null===o._toggledRow||o._toggledRow&&o._toggledRow.id!==m.id)&&(m.expandHeight=0),c.parent?(m.parent=o.rowById[c.parent.$.id],m.parentId=c.parent.$.id):(m.parent=null,m.parentId=null),o.grouping.onGroupDefaultExpanded&&!o.isRendered){const e=o.grouping.onGroupDefaultExpanded(c);e&&(m.expanded=c[i.expanded]=e)}o.appearance.allowRowToggleAnimation||void 0!==c[i.expanded]&&(m.expanded=c[i.expanded]);let g=!!e||m.expanded;a&&(g=!0);const p=o.dataSource&&o.dataSource.id||o.dataSourceSettings.id;if(p&&!m.data[p]&&o.grouping.enabled&&o.dataSource&&o.dataSource.groupBy.length){const e=o.dataSource.groupBy[m.level];c.parent&&c.parent.expanded&&(""===m.data[e]&&o.dataSource.id&&!m.data.data[o.dataSource.id]||m.leaf&&!m.data[p])&&(s++,m.filtered=!1)}if(!0===m.visible&&!1!==m.filtered)if(s++,g||c[i.leaf])if(l.push(m),c.children&&c.children.length>0){const e=d(c.children,new Array);0===e.length&&(m.leaf=!0);for(let t=0;t<e.length;t++)l.push(e[t]);m.children=e}else c.children&&0===c.children.length&&(o.dataSource.virtualDataSource&&o.dataSource.virtualDataSourceOnExpand?m.data._loaded&&(m.leaf=!0):m.leaf=!0);else if(l.push(m),c.children&&c.children.length>0){const e=d(c.children,new Array);0===e.length&&(m.leaf=!0),m.children=e}else c.children&&0===c.children.length&&(o.dataSource.virtualDataSource&&o.dataSource.virtualDataSourceOnExpand?m.data._loaded&&(m.leaf=!0):m.leaf=!0)}return l};let u=o.dataSource.boundHierarchy;if(o.paging.enabled&&!t){let e=[];const t=e=>{let l=[];if(0===o.dataSource.groupBy.length)return e;for(let o=0;o<e.length;o++){const a=e[o];(!a.$||void 0===a.$.filtered||a.$.filtered)&&(l.push(a),a.children&&(l=l.concat(t(a.children))))}return l};if(o.dataSource&&!o.dataSource.virtualDataSource){for(let o=0;o<u.length;o++){let l=u[o],a=!l.$||void 0===l.$.filtered||l.$.filtered;!a&&null!==a||0!==l.level||l.parent||(t(l.children).length,e.push(l))}u=e.slice(o.paging.pageIndex*o._pageSize,(o.paging.pageIndex+1)*o._pageSize)}}const c=o.rows.canNotify;o.rows.canNotify=!1,o.rowHierarchy=d(u,new Array),o.rows.canNotify=c;let m=[];for(let e=0;e<o.rowHierarchy.length;e++){const t=o.rowHierarchy[e],a=t.canNotify;t.leaf&&m.push(t),t.canNotify=!1,o.grouping.enabled&&o.dataSource&&o.dataSource.groupBy.length?t.leaf?t.visibleIndex=l++:t.visibleIndex=-1:t.visibleIndex=l++,t.canNotify=a}if(a&&(o.rowHierarchy=m),o._rowElements.length<o.rowHierarchy.length&&!o._toggledRow&&o._initializeRowElements(),o.grouping.summaryRow.visible&&!o.grouping.summaryRow.inline){const e=function(t,o,l,a){if(0!==t&&o.length>0&&o[o.length-1]&&!o[o.length-1].summaryRow){let e={label:" ",boundSource:[],groupDataField:l.data.groupDataField,$:{},summaryRow:!0,leaf:!0,level:t,expandHeight:0,siblings:o};e.$.id="SubRow"+a+"_"+l.data.$.id,l&&(e.parent=l.data,e.parentId=l.data.$.id),e.data=Object.assign(e),o.push(e)}for(let t=0;t<o.length;t++)o[t]&&o[t].data&&o[t].data.children&&e(o[t].level+1,o[t].data.children,o[t],t)};e(0,o.rowHierarchy,null,0)}}}applyContent(){}_refreshContentHeight(){const e=this;let t=e._clientSize.height;const o=window.scrollY;let l,a,n=!1;if((!e._contentHeight||e._maxHeight||e._autoHeight||e.__autoHeight||"hidden"===e.verticalScrollBarVisibility)&&(n=!0),n&&(l=e.offsetHeight,e.$.container.classList.add("smart-hidden"),a=e.offsetHeight,e.$.container.classList.remove("smart-hidden")),window.scrollY!==o&&window.scrollTo(window.scrollX,o),"hidden"===e.verticalScrollBarVisibility||e.layout.autoHeight||l!==a||e._minHeight&&e._minHeight===l)return t=e._scrollHeight+e.$.columnHeader.offsetHeight+e.$.filterFooter.offsetHeight,e.header.visible&&(t+=e.$.header.offsetHeight),e.summaryRow.visible&&(t+=e.layout.rowMinHeight),0===e._recyclingRows.length&&0===e._scrollHeight&&(t+=e.$.scrollView.offsetTop),e._minHeight>t&&(t=e._minHeight),e.$.content.style.height=t+"px",e._contentHeight=t,void(e._maxHeight<t?(e._autoHeight=!1,e.$.content.classList.remove("auto-height"),e.$.content.style.height=e._maxHeight+"px",e.header.visible?(e.$.content.style.height=e._maxHeight-e.$.header.offsetHeight+"px",e._contentHeight=e._maxHeight-e.$.header.offsetHeight):e._contentHeight=e._maxHeight):(e._autoHeight=!0,e.__autoHeight=!0,e.$.content.classList.add("auto-height"),e.filtering.filterRow.visible&&(e.filtering.filterRow.visible&&(t+=e.layout.rowMinHeight),e._contentHeight=t,e.$.content.style.height=e._contentHeight+"px"),e.header.visible?(e._contentHeight=t-e.$.header.offsetHeight,e.$.content.style.height=e._contentHeight+"px"):e.summaryRow.visible&&(e.$.content.style.height=e._contentHeight+"px")));if(e.header.visible&&(t-=e.$.header.offsetHeight),(e.groupHeader.visible||e.grouping.groupBar.visible)&&(t-=e.$.groupHeader.offsetHeight),e.footer.visible&&(t-=e.$.footer.offsetHeight),e.pager.visible&&(t-=e.$.headerPager.offsetHeight,t-=e.$.footerPager.offsetHeight),e.editing.enabled&&e.editing.commandBar.visible&&(t-=e.$.headerCommandBar.offsetHeight,t-=e.$.footerCommandBar.offsetHeight),e.$.content.style.height!==t+"px"&&(e.$.content.style.height=t+"px"),e.$.viewContent.style.height!==t+"px"&&(e.$.viewContent.style.height=t+"px"),e._contentHeight=t,e.appearance.showViewBar){const o=e.layout.viewBarWidth+5;e.$.viewBar.classList.remove("smart-hidden"),e._mobile||(e.$.content.style.width="calc(100% - "+o+"px)",e.$.viewContent.style.width="calc(100% - "+o+"px)",e.$.content.style.marginLeft=o+"px",e.$.viewContent.style.marginLeft=o+"px"),e.$.viewBar.style.width=o+"px";let l=0;e.header.visible&&(l+=e.$.header.offsetHeight),(e.groupHeader.visible||e.grouping.groupBar.visible)&&(l+=e.$.groupHeader.offsetHeight),e.pager.visible&&(l+=e.$.headerPager.offsetHeight),e.$.viewBar.style.top=l+"px",e.$.viewBar.style.height=t+"px"}else e.$.viewBar.classList.add("smart-hidden"),e.$.content.style.width="",e.$.viewContent.style.width="",e.$.content.style.marginLeft="",e.$.viewContent.style.marginLeft=""}appendChild(){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(this,e.concat(Array.prototype.slice.call(arguments)))}removeChild(){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(this,e.concat(Array.prototype.slice.call(arguments)))}get _contentBorder(){const e=this;if(e.__contentBorder)return e.__contentBorder;const t=getComputedStyle(e.$.content),o={left:parseFloat(t.borderLeftWidth)+parseFloat(t.borderRightWidth),top:parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth)};return e.__contentBorder=o,o}_refreshAutoSize(){const e=this;if(e.layout.autoWidth){const t=e._isUpdatingScrollBars;e._isUpdatingScrollBars=!0;let o=2;for(let t=0;t<e.viewColumns.length;t++){const l=e.viewColumns[t];l.visible&&(o+=l.computedWidth)}o+=e.$.verticalScrollBar.offsetWidth>0?e.$.verticalScrollBar.offsetWidth:0,e.style.width=o+"px",requestAnimationFrame((()=>{e._isUpdatingScrollBars=t}))}e.layout.autoHeight&&(e.style.height="auto")}_refreshLayout(){const e=this,t=e.rows;if(e._layoutSuspended)return;e._visibleRows=null,e.__viewRows=null,e.__clientSize=null,e.__scrollHeight=null,e.__scrollWidth=null,e.__parentCells=null,e.$.columnFarContainer.classList.remove("vscroll"),e.$.columnNearContainer.classList.remove("vscroll"),e.$.scrollView.classList.remove("hscroll"),e.$.scrollView.classList.remove("vscroll"),e._refreshAutoSize(),e._refreshElementsVisibility(),e._refreshRowHierarchy(),e._refreshColumnHeights(),e._refreshContentHeight();const o=()=>{e.$.placeholder.classList.remove("smart-hidden"),e.$.placeholder.innerHTML=e.appearance.placeholder,e._filters&&e._filters.length&&(e.$.placeholder.innerHTML=e.localize("filteredRecords")),e.__filterFooterOffsetHeight||(e.__filterFooterOffsetHeight=e.$.filterFooter.classList.contains("smart-hidden")?0:e.$.filterFooter.offsetHeight),!e.__columnHeaderHeight&&e.$.columnHeader.offsetHeight&&(e.__columnHeaderHeight=e.$.columnHeader.offsetHeight);let t=e._contentHeight-e.__filterFooterOffsetHeight-e.__columnHeaderHeight;e.$.scrollView.style.height=t+"px",e.scrollWidth=0,e.scrollHeight=0,e.clearSelection(),e._showAddNewRowButton("float"),e.$.content.classList.contains("auto-height")&&(e.$.placeholder.style.height=t+"px")};if(t&&t.url)e._showAddNewRowButton("float");else{if(!t||null===t||0===t.length||0===e.columns.length)return o(),0!==e.columns.length&&e.hasVisibleColumn()?e.editing.addNewColumn._addButton&&e.editing.addNewColumn._addButton.classList.remove("show"):(e._showAddNewColumnButton(),e.$.columnHeader.classList.add("smart-hidden"),e.__columnHeaderHeight=0),void e._refreshScrollBars();e._showAddNewRowButton("float"),e.editing.addNewColumn._addButton&&e.editing.addNewColumn._addButton.classList.remove("show")}0!==e.columns.length&&e.hasVisibleColumn()?e.editing.addNewColumn._addButton&&e.editing.addNewColumn._addButton.classList.remove("show"):(o(),0!==e.columns.length&&e.hasVisibleColumn()||(e._showAddNewColumnButton(),e.$.columnHeader.classList.add("smart-hidden"),e.__columnHeaderHeight=0),e._showAddNewColumnButton()),"card"===e.view&&(e.__columnHeaderHeight=0),!e.__columnHeaderHeight&&e.$.columnHeader.offsetHeight&&(e.__columnHeaderHeight=e.$.columnHeader.offsetHeight),e.__filterFooterOffsetHeight||(e.__filterFooterOffsetHeight=e.$.filterFooter.classList.contains("smart-hidden")?0:e.$.filterFooter.offsetHeight);let l=e._contentHeight-e.__filterFooterOffsetHeight-e.__columnHeaderHeight;if(e.$.scrollView.style.height=l+"px",e.htmlColumnLastChild.style.height=e.__columnHeaderHeight+"px",e.paging.spinner.enabled&&e.paging.enabled){if(!e.pageScroll){const t=document.createElement("smart-scroll-bar");t.orientation="vertical",t.style.height="100%",t.style.width="100%",t.max=Math.ceil(e.dataSource.length/e._pageSize),t.step=e.paging.spinner.step,t.largeStep=e.paging.spinner.step,t.setAttribute("spinner",""),t.setAttribute("smart-id","spinner"),t.ownerElement=e,e.addPropertyBinding("[[paging_spinner_step]]","step",t,e.$.columnHeader),t.addEventListener("change",(function(t){e.paging.pageIndex=t.detail.value,e._refreshLayout(),e._refreshSelection(),e.dataSource&&e.dataSource.virtualDataSource?e._virtualDataRequest("pageIndexChange"):(e._recycle(),e._scrollUpdate&&clearTimeout(e._scrollUpdate),e._scrollUpdate=setTimeout((function(){e.isScrolling||(e.$.rowContainer.style.top=parseInt(e.$.rowContainer.style.top)+.01+"px")}),50))})),e.pageScroll=t}e.htmlColumnLastChild.appendChild(e.pageScroll)}else e.htmlColumnLastChild.innerHTML="";e._refreshScrollBars()}_refreshScrollBars(){const e=this;if(!e._scrollView)return;const t=e._scrollView.vScrollBar,o=e._scrollView.hScrollBar,l=e._contentHeight-e.__filterFooterOffsetHeight-e.__columnHeaderHeight,a=e.$.scrollView.offsetWidth,n=e._scrollWidth-a-e._contentBorder.left,i=e._scrollHeight-l-e._contentBorder.top,r=e._columnNearContainerComputedStyle?e._columnNearContainerComputedStyle:getComputedStyle(e.$.columnNearContainer),s=e._columnFarContainerComputedStyle?e._columnFarContainerComputedStyle:getComputedStyle(e.$.columnFarContainer),d=parseInt(e.$.columnNearContainer.style.width)+parseInt(r.borderRightWidth),u=parseInt(e.$.columnFarContainer.style.width)+parseInt(s.borderLeftWidth);if(e.__frozenNearWidth=d,e.__frozenFarWidth=u,e._columnNearContainerComputedStyle=r,e._columnFarContainerComputedStyle=s,e._refreshHorizontalScrollBarVisibility(n),e._refreshVerticalScrollBarVisibility(i),t.style.height=l+"px",e.computedVerticalScrollBarVisibility?(e.__scrollBarSize||(e.__scrollBarSize=t.offsetWidth),e.__scrollWidth+=e.__scrollBarSize,e._refreshHorizontalScrollBarVisibility(e._scrollWidth-a-1),e.rightToLeft?e.$.columnNearContainer.classList.add("vscroll"):e.$.columnFarContainer.classList.add("vscroll"),e._refreshVerticalScrollBarVisibility(i),e.htmlColumnLastChild.classList.remove("smart-visibility-hidden"),e.$.scrollView.classList.add("has-vscroll")):e.$.scrollView.classList.remove("has-vscroll"),o.style.width=a+"px",e.rightToLeft?o.style.right="0px":o.style.left="0px",e.computedVerticalScrollBarVisibility&&e.computedHorizontalScrollBarVisibility&&(o.style.width=a-t.offsetWidth+"px",t.style.height=l-o.offsetHeight+"px"),e.computedHorizontalScrollBarVisibility?(e.$.scrollView.classList.add("hscroll"),e._autoHeight?(e.$.content.style.height="auto",e.$.scrollView.style.height="auto",e.$.scrollView.style.paddingBottom=o.offsetHeight+"px",e.$.placeholder.style.marginTop=o.offsetHeight+"px",e.summaryRow.visible&&(e.$.scrollView.style.paddingBottom=o.offsetHeight+e.layout.rowMinHeight+"px"),e.filtering.enabled&&e.filtering.filterRow.visible&&(e.$.scrollView.style.paddingBottom=o.offsetHeight+e.layout.rowMinHeight+"px")):(e.$.scrollView.style.paddingBottom="",e.$.placeholder.style.marginTop="")):e.$.scrollView.classList.remove("hscroll"),(e.__frozenNearHeight>0||e._frozenNearRows&&e._frozenNearRows.length>0)&&!e.appearance.showVerticalScrollBarOnFixedColumns){const o=getComputedStyle(e.$.rowNearContainer),l=e.__frozenNearHeight+parseInt(o.borderBottomWidth);t.style.height=parseInt(t.style.height)-l+"px",t.style.top=l+"px",t.style.setProperty("--smart-scroll-bar-near-size",l+"px")}else e.appearance.showVerticalScrollBarOnFixedColumns&&(t.style.top="0px");if((e.__frozenFarHeight>0||e._frozenFarRows&&e._frozenFarRows.length>0)&&!e.appearance.showVerticalScrollBarOnFixedColumns){const o=getComputedStyle(e.$.rowFarContainer),l=-2+e.__frozenFarHeight+parseInt(o.borderTopWidth);t.style.height=parseInt(t.style.height)-l+"px",t.style.setProperty("--smart-scroll-bar-far-size",l+"px"),0===e.__frozenNearHeight&&(t.style.top="0px")}(d>0||u>0)&&!e.appearance.showHorizontalScrollBarOnFixedColumns&&(o.style.width=parseInt(o.style.width)-d-u+"px",e.rightToLeft?o.style.right=d+"px":o.style.left=d+"px",o.style.setProperty("--smart-scroll-bar-near-size",d+parseInt(r.borderRightWidth)+"px"),o.style.setProperty("--smart-scroll-bar-far-size",u+parseInt(r.borderLeftWidth)+"px"),e.computedVerticalScrollBarVisibility&&(e.__scrollBarSize||(e.__scrollBarSize=t.offsetWidth),o.style.setProperty("--smart-scroll-bar-far-size",u+e.__scrollBarSize+"px"))),t.refresh(),o.refresh(),e._mobile&&(e._scrollContentView.style.width=e.$.scrollView.offsetWidth+e._scrollView.scrollWidth+"px",e._scrollContentView.style.height=e.$.scrollView.offsetHeight+e._scrollView.scrollHeight+"px")}_refreshHorizontalScrollBarVisibility(e){const t=this;t.scrollWidth=e,t.computedHorizontalScrollBarVisibility||(t.scrollLeft=0)}_refreshVerticalScrollBarVisibility(e){const t=this;if(t._autoHeight)return t.scrollTop=0,void(t.scrollHeight=0);t.computedHorizontalScrollBarVisibility&&(e+=t.$.horizontalScrollBar.offsetHeight),t.scrollHeight=e,t.paging.enabled&&t.paging.spinner.visible&&t.$.verticalScrollBarVisibility.classList.remove("smart-hidden"),t.computedVerticalScrollBarVisibility||(t.scrollTop=0)}_styleChangedHandler(e){const t=this;if(!e.detail.styleProperties.overflow&&!t.classList.contains("smart-grid-resize-mode")){if(e.detail.styleProperties["grid-template-columns"])return t._templateColumns(),void t.refresh();if(e.detail.styleProperties["font-size"])return t.layout.isDirty=!0,t._resetCachedLayout(),void t.refresh();(e.detail.styleProperties["--smart-grid-row-height"]||e.detail.styleProperties["--smart-font-size"]||e.detail.styleProperties["--smart-grid-column-header-height"]||e.detail.styleProperties["--smart-grid-group-header-height"]||e.detail.styleProperties["--smart-grid-filter-footer-height"]||e.detail.styleProperties["--smart-grid-group-row-vertical"]||e.detail.styleProperties["--smart-grid-group-row-horizontal-offset"]||e.detail.styleProperties["--smart-grid-freeze-splitter-size"]||e.detail.styleProperties["--smart-grid-resize-line-size"]||e.detail.styleProperties["--smart-grid-footer-height"]||e.detail.styleProperties["--smart-grid-header-height"])&&(t.layout.isDirty=!0),t.offsetWidth&&t.offsetHeight>0&&(t._resetCachedLayout(),t._refreshLayout(),t._recycle())}}_resetCachedLayout(){const e=this;delete e._columnHeights,e.__cellsCommandTemplate=null,e.__autoRowHeight=null,e.__autoHeightRows=null,e.__measuredColumnHeight=null,e.__columnHeaderHeight=null,e.__filterFooterOffsetHeight=null}_swipeLeftHandler(){}_swipeRightHandler(){}_getRowIndexByPosition(e){const t=this;return(o=>{let l=0,a=o.length-1;if(e<=0)return 0;const n=o[o.length-1];if(-1!==n.top&&n.top<=e)return o.length-1;for(;;){const n=Math.floor((l+a)/2),i=o[n];if(t._isRowInPosition(i,e))return n;i.top<e?l=n+1:i.top>e?a=n-1:l=n+1}})(t._recyclingRows)}_getVirtualRowIndexByPosition(e){let t=this.rows[0].height;const o=(e,o)=>0!==t&&e<=o&&e+t>o;return(l=>{let a=0,n=l.length-1;if(e<=0)return 0;const i=(l.length-1)*t;if(-1!==i&&i<=e)return l.length-1;for(;;){const l=Math.floor((a+n)/2),i=l*t;if(o(i,e))return l;i<e?a=l+1:i>e?n=l-1:a=l+1}})(this.dataSource)}getRows(){return this.getViewRows()}getViewRows(){const e=this;return e.rowHierarchy?e.rowHierarchy:e.getVisibleRows()}getData(){const e=this;if(!e.dataSource)return[];const t=[];for(let o=0;o<e.dataSource.length;o++){const l=e.dataSource[o];if(l.$){const o={};for(let t=0;t<e.dataSource.dataFields.length;t++){const a=e.dataSource.dataFields[t].name;o[a]=l[a]}t.push(o)}else t.push(l)}return t}getDataFields(){const e=this;return e.columns?e.columns.map((e=>e.dataField)):[]}getColumns(){const e=this,t=[];if(!e.isInitialized)return t;if(e.columns)for(let o=0;o<e.columns.length;o++){const l=e.columns[o].getState();t.push(l)}return t}resetState(){const e=this;e._isUpdating=0,e.beginUpdate(),e.clearSort(),e.clearFilter(),e.clearGroups(),e.clearSelection(),e.columns.canNotify=!1;let t=[],o=!1;for(let l=0;l<e.columns.length;l++){const a=e.columns[l];a.visible=!0,a.width=180,a.freeze=!1,a.index>=0?t[a.index]=a:t.push(a),a.index!==l&&(o=!0)}o&&(e.columns=t),"grid"!==e.view&&(e.view="grid",e._hideKanbanView()),e.columns.canNotify=!0,e._scrollView.scrollLeft=e._scrollView.scrollTop=0,e.paging.enabled&&(e.paging.pageIndex=0),e.$.headerBar&&e.$.headerBar._setView&&e.$.headerBar._setView("grid"),e._kanban&&e._kanban._reset(),e.endUpdate(),o&&(e._renderColumns(),e._refreshHeaderBar())}_loadState(e){const t=this;let o=!1;t.stateSettings.loading=!0;let l=!1;if("grid"===t.view){if(e.expandedRows&&Object.keys(e.expandedRows).length>0){o=!0,t.beginUpdate();const l=[];if(e.groups){t.dataSource.groupBy=e.groups,t._groups=[].concat(t.dataSource.groupBy.toArray())||[],t._refreshRowHierarchy();for(let o in e.expandedRows)l["Item"+o.replaceAll(".","_")]=!0,t._expandCollapseGroup(o,!0)}t.dataSource&&(t.dataSource._expandedRowIds=l)}else if(e.groups&&e.groups.length){o=!0,t.beginUpdate();const l=[];t.dataSource&&(t.dataSource._expandedRowIds=l),e.groups&&(t.dataSource.groupBy=e.groups,t._refreshRowHierarchy())}else if(e.groups&&0===e.groups.length&&t.dataSource.groupBy.length>0){o=!0,t.beginUpdate();const e=[];t.dataSource&&(t.dataSource._expandedRowIds=e),t.dataSource.groupBy=[],t._refreshRowHierarchy(),l=!0}if(e.paging&&t.paging.enabled&&(t.paging.index=e.paging.index,t.paging.size=e.paging.size),e.columns&&e.columns.length>0){o||(o=!0,t.beginUpdate());for(let o=0;o<e.columns.length;o++){const l=e.columns[o];if(l.dataField){const e=t.columnByDataField[l.dataField];if(e){const t=e.canNotify;e.canNotify=!1,l.width?e.width=l.width:e.width=180,e.visible=void 0===l.visible||l.visible,e._state&&(e._state.visible=void 0===l.visible||l.visible,e._state.freeze=void 0!==l.freeze&&l.freeze,e._state.width=l.width?l.width:180),e.freeze=void 0!==l.freeze&&l.freeze,e.canNotify=t}}}}}if(e.sort&&Object.keys(e.sort).length>0){o||(o=!0,t.beginUpdate());const l=t.appearance.allowSortAnimation;t.appearance.allowSortAnimation=!1;let a=t.columns.canNotify;t.columns.canNotify=!1;for(let e=0;e<t.columns.length;e++)t.columns[e].sortOrder="";t.columns.canNotify=a;for(let o in e.sort)if(e.sort[o]){const l=e.sort[o].sortOrder,a=t.columnByDataField[o];t.sortBy(a.dataField,l)}t.appearance.allowSortAnimation=l}if(e.filter&&Object.keys(e.filter).length>0){o||(o=!0,t.beginUpdate());for(let o in e.filter){const l=e.filter[o];if(l){t.addFilter(o,l,!1);const e=t.columnByDataField[o];e&&e._filterInfo&&e.filter&&e.filter.filters&&e.filter.filters[0]&&(e._filterInfo.value=e.filter.filters[0].value,e._filterInfo.condition=e.filter.filters[0].condition)}}if(t.filtering.filterRow)for(let e=0;e<t.columns.length;e++)t.columns[e]._filterEditorInitialized&&(t.columns[e]._filterEditorInitialized=!1)}if(o){t.endUpdate(!1,!1);let o=!1;e.view&&"kanban"===e.view&&(o=!0),o||(l?t.refresh(!0):t._refresh())}let a=!1;e.kanban&&e.kanban.stackedBy&&(void 0===t._stackedBy&&(t._stackedBy=e.kanban.stackedBy),t._stackedBy!==e.kanban.stackedBy&&(a=!0),t._stackedBy=e.kanban.stackedBy),(a||e.view&&t.view!==e.view)&&t.$.headerBar&&t.$.headerBar._setView&&t.$.headerBar._setView(e.view,!0),e.filter&&Object.keys(e.filter).length>0&&t.refreshFilters(),e.name&&(t.stateSettings.current=e.name),t.stateSettings.loading=!1}loadState(e){const t=this;if(e){if(t.stateSettings.loading=!0,t._isUpdating=0,t.beginUpdate(),t.clearSort(),t.clearFilter(),t.clearGroups(),t.clearSelection(),t._scrollView.scrollLeft=t._scrollView.scrollTop=0,t.paging.enabled&&(t.paging.pageIndex=0),t.endUpdate(!1,!1),"string"==typeof e){const o=t.stateSettings.storage[e];o&&t._loadState(o)}else t._loadState(e);t.stateSettings.loading=!1}else if(!t.stateSettings.autoSave){let e=t.getCurrentState();e&&t.loadState(e)}}saveState(e,t){const o=this;let l=o.getCurrentState(),a=t;!t&&o.stateSettings.options.length&&(t=o.stateSettings.options);const n=o.getState(t);let i;if(e?(i=e,o.stateSettings.current||(o.stateSettings.current=e)):i=o.stateSettings.current?o.stateSettings.current:o.stateSettings.current="View 1",l&&a)for(let e in a)l[a[e]]=n[a[e]];else l=n;function r(e,t=0,o=10){if(t>o)return"Object";const l={};if(e&&e instanceof Smart.FilterGroup)return e=e.toString();for(let a in e){let n=e[a];if(n instanceof Node)n={id:n.id};else if(n instanceof Window)n="Window";else if(n instanceof Date)n=n.toJSON();else{if(n&&Array.isArray(n)&&void 0!==n[0]&&("string"==typeof n[0]||"number"==typeof n[0]||n[0]instanceof Date||"boolean"==typeof n[0])){l[a]=n;continue}if(n&&Array.isArray(n)&&0===n.length){l[a]=n;continue}if(n&&n&&Array.isArray(n)&&void 0!==n[0]&&"object"==typeof n[0]&&"path"!==a&&!(n[0]instanceof HTMLElement))for(let e=0;e<n.length;e++)n[e]=r(n[e],t+1,o);else n instanceof Object&&(n=r(n,t+1,o))}l[a]=n}return t?l:JSON.stringify(l)}l.name=i,o.stringify_object=r;const s=r(l);return o.stateSettings.allowLocalStorage&&window.localStorage.setItem(i,s),o.stateSettings.storage||(o.stateSettings.storage={}),o.stateSettings.storage[o.stateSettings.current]&&!l.date&&o.stateSettings.storage[o.stateSettings.current].date?l.date=o.stateSettings.storage[o.stateSettings.current].date:l.date=(new Date).toJSON(),o.stateSettings.storage[o.stateSettings.current]=l,o.stateSettings.onStateChange&&(o._isUpdating<=0||void 0===this._isUpdating)&&o.isCompleted&&o.stateSettings.onStateChange(l,i,o.stateSettings.storage,r),l}autoSaveState(){const e=this;if(!e.stateSettings.current&&e.stateSettings.autoSave&&!e.stateSettings.loading){const t=e.stateSettings.storage;(t&&0===Object.keys(t).length||!t)&&(e.stateSettings.current=e.localize("view")+" 1")}e.stateSettings.autoSave&&e.stateSettings.current&&!e.stateSettings.loading&&e.saveState()}getCurrentState(){const e=this,t=e.stateSettings.current;return e.stateSettings.storage||(e.stateSettings.storage={}),e.stateSettings.storage[t]?e.stateSettings.storage[t]:null}getState(e){const t=this;if(e&&!e.includes)return;const o=!e||e&&e.includes("sort")?t.getSortedColumns():null,l=!e||e&&e.includes("filter")?t.getFilteredColumns():null,a=!e||e&&e.includes("groups")?t.getGroups():null,n=!e||e&&e.includes("selection")?t.getSelectedCells():null,i=!e||e&&e.includes("selection")?t.getSelectedRows():null,r=!e||e&&e.includes("pager")?t.$.headerPager.querySelector("smart-pager"):null;let s=0;r&&(s=r.pagesCount);const d={sort:o,filter:l,groups:a,paging:{count:s,index:t.paging.pageIndex,size:t._pageSize},selectedCells:n,selectedRows:i};t.header.visible&&t.header.buttons.indexOf("views")>=0&&(d.kanban=t.getKanbanState(),d.view=t.view);const u=[];if(!e||e&&e.includes("columns")){for(let e=0;e<t.columns.length;e++){const o=t.columns[e];u.push({dataField:o.dataField,width:o.computedWidth,visible:o.visible,freeze:o.freeze})}d.columns=u}if((!e||e&&e.includes("expandedRows"))&&t.dataSource&&t.dataSource._expandedRowIds){let e={};for(let o in t.dataSource._expandedRowIds){let t=""+o;t=t.replace("Item","").replace(/_/gi,"."),e[t]=!0}d.expandedRows=e}if(e){const t={};for(let o in e){const l=e[o];d[l]&&(t[l]=d[l])}return t}return d}get _pageSize(){const e=this;return e.dataSource&&e.grouping.enabled&&e.dataSource.groupBy.length>0?e.paging.pageHierarchySize:e.paging.pageSize}get _recyclingRows(){const e=this;if(e.rowHierarchy)return e.rowHierarchy;let t=e.getVisibleRows();if(e.paging.enabled)if(e.dataSource.virtualDataSource)t=t.slice(0,e._pageSize);else if(t=t.slice(e.paging.pageIndex*e._pageSize,(e.paging.pageIndex+1)*e._pageSize),e.editing.addNewRow&&e.editing.addNewRow.visible&&"button"!==e.editing.addNewRow.displayMode){let t=e.getVisibleRows();return t=0===e.paging.pageIndex&&"far"!==e.editing.addNewRow.position?t.slice(1+e.paging.pageIndex*e._pageSize,1+(e.paging.pageIndex+1)*e._pageSize):0===e.paging.pageIndex&&"far"===e.editing.addNewRow.position?t.slice(e.paging.pageIndex*e._pageSize,1+(e.paging.pageIndex+1)*e._pageSize):t.slice(1+e.paging.pageIndex*e._pageSize,1+(e.paging.pageIndex+1)*e._pageSize),[].concat(e._frozenNearDefaultRows,t,e._frozenFarDefaultRows)}return t}_isRowInPosition(e,t){const o=e.top,l=e.top+e.height,a=o<=t&&l>t;return 0!==e.height&&a}_renderColumnGroupHeaders(){const e=this;for(let t=0;t<e._columnGroups.length;t++){const o=e._columnGroups[t];o.column.render(),o.column.allowReorder=!1,o.column.element.setAttribute("columnHeader",""),o.column.element.setAttribute("level",o.level),0===o.columns.length&&o.column.element.classList.add("smart-hidden"),0===t&&0===e.columns.indexOf(o.columns[0])&&o.column.element.classList.add("smart-grid-column-border-collapse")}}hasVisibleColumn(){const e=this;for(let t=e.viewColumns.length-1;t>=0;t--){const o=e.viewColumns[t];if(o.visible&&!o.autoGenerated)return!0}return!1}_isLastVisibleColumn(e){const t=this;for(let o=t.viewColumns.length-1;o>=0;o--){const l=t.viewColumns[o];if(l.visible)return l===e}return!1}_clearCachedTemplates(){const e=this;if(e._cachedTemplates&&Object.keys(e._cachedTemplates).length>0){e._tableCachedTemplates||(e._tableCachedTemplates=document.createElement("div"),e._tableCachedTemplates.style.display="none",document.body.appendChild(e._tableCachedTemplates));const t=document.createDocumentFragment();for(let o in e._cachedTemplates)t.appendChild(e._cachedTemplates[o]);e._tableCachedTemplates.appendChild(t)}}_recycle(e,t,o,l){const a=this;if(a._layoutSuspended||!1===a.isAttached)return;if(a._isUpdating)return;if(a.editing.isEditing&&(!0!==a._disableEndEdit&&a.endEdit(),a._isUpdating))return;a._recycleValues=void 0===o||o,a._removeCellContentPopup(),a._inputOverlay&&(a._inputOverlay.parentNode&&a._inputOverlay.parentNode.removeChild(a._inputOverlay),a._inputOverlay=null),a._selection.selectionRect&&a._refreshCellSelectionRect();const n=a._scrollView.scrollTop;let i,r=l||a._getRowIndexByPosition(n),s=a._recyclingRows,d=s[r],u=d?d.top:0,c=0,m=0,g=0,p=0;if(a._cellRowSpan&&a._cellRowSpan.maxSpan>0){let e=0;if(r>=5?e=5:r>=4?e=4:r>=3?e=3:r>=2?e=2:r>=1&&(e=1),e>0){const t=s[r-e];t&&(d=t,u=d?d.top:0,g=e*d.height,r-=e)}}a._cellRowSpan=[];for(let e=0;e<a._cellsMerge.length;e++){const t=a._cellsMerge[e],o=s.indexOf(t.row);if(r>o&&r<=o+t.rowSpan&&(r=o,d=t.row,g=Math.max(g,u-d.top),u=d.top,a.$.rowContainer.style.top=a.__frozenNearHeight-n+u+"px"),t.colSpan>1)for(let e=0;e<a.viewColumns.length;e++){const o=a.viewColumns[e];let l=o.autoGenerated?o:a.columnByDataField[o.dataField];if(l.visible&&l.left+l.computedWidth-a._scrollView.scrollLeft>=c&&l.left-l.computedWidth-a._scrollView.scrollLeft<a._clientSize.width){let e=a.columnByDataField[t.column.dataField];p=Math.max(p,l.left-e.left+l.computedWidth);break}}}a.isHScrolling&&a._clearCachedTemplates();let h=null;if(!1!==e||a._cellsMerge.length>0){if(a._columnElements)for(let e=0;e<a._columnElements.length;e++){const t=a._columnElements[e];if(!t.parentNode)break;t.set("column",null,!1),t.classList.add("smart-visibility-hidden")}for(let e=0;e<a._columnGroups.length;e++){const t=a._columnGroups[e],o=t.element;o&&(a.rightToLeft?o.style.right=t.right+"px":o.style.left=t.left+"px",o.style.width=t.computedWidth+"px")}a._firstVisibleColumn=null,a._lastVisibleColumn=null;for(let e=0;e<a.viewColumns.length;e++){let t=a.viewColumns[e];if(t.visible&&(a._firstVisibleColumn||(a._firstVisibleColumn=t),a._lastVisibleColumn=t),t.element&&(t===a._firstVisibleColumn||t.rowDetailColumn?t.element.classList.add("smart-grid-column-border-collapse"):t.element.classList.remove("smart-grid-column-border-collapse"),!1!==a.appearance.showColumnGroupCellLines&&!1!==a.appearance.showColumnGroupLines||(t.parent&&t.parent.columns&&t.parent.columns[0].dataField===t.dataField?t.element.setAttribute("column-group-first-child",""):t.parent&&t.element.removeAttribute("column-group-first-child")),t.element.removeAttribute("aria-colindex")),t.freeze){if(!0!==t.freeze&&"near"!==t.freeze||t.visible&&(c+=t.computedWidth),!t.element)continue;t.visible?(t.element.classList.remove("smart-visibility-hidden"),t.render()):t.element.classList.add("smart-visibility-hidden")}else if(t.visible&&t.left+t.computedWidth-a._scrollView.scrollLeft>=c-p&&t.left-t.computedWidth-a._scrollView.scrollLeft<a._clientSize.width){a._columnElements||(a._columnElements=[]);const o=a._columnElements[m++];o&&(o.set("column",t,!1),o.parentNode||a.$.columnContainer.appendChild(o),h||(h=t,a._firstRenderedColumn=t),t.element=o,t.render(),o.setAttribute("aria-colindex",e+1),void 0===i&&(i=t.left))}}}if(void 0===i&&(i=0),a.rightToLeft){const e=a._scrollView.scrollWidth-a._scrollView.scrollLeft-a._scrollView.vScrollBar.offsetWidth;a.$.columnContainer.style.right=e+"px",e<=0&&!a._scrollView.scrollWidth&&(a.$.columnContainer.style.right=-a.offsetWidth+a._computedColumnsWidth+"px")}else a.$.columnContainer.style.left=-a._scrollView.scrollLeft+"px";if(a.$.rowContainer.style.top=a.__frozenNearHeight-n+u+"px",a.isScrolling&&!a.isHScrolling&&(a._scrollUpdate&&clearTimeout(a._scrollUpdate),a._scrollUpdate=setTimeout((function(){a.isScrolling||(a.$.rowContainer.style.top=parseInt(a.$.rowContainer.style.top)+.01+"px")}),50)),!1===t)return;if(!a._rowElements)return;const f=a.dataSource&&a.dataSource.virtualDataSource&&!a.dataSource.virtualDataSourceOnExpand&&a.dataSource.length>a.virtualModeCachedRowsCount&&"infinite"!==a.scrolling;if(r>=0){m=0;let e=Math.max(a._clientSize.height,a._overflowOffset),t=0;f&&(a.rowById=[],a.rows&&a.rows.length>0&&void 0===a.rows[a.rows.length-1].top&&(a.rows[a.rows.length-1].top=(a.rows.length-1)*a.rows[0].height),a.rows&&a.rows.length>0&&(t=a._getVirtualRowIndexByPosition(n),u=t*a.rows[0].height,a.$.rowContainer.style.top=a.__frozenNearHeight-n+u+"px",a.paging.enabled||(r=0)),a.paging.enabled&&(t=a.paging.pageIndex*a._pageSize)),"card"===a.view&&a._cardHeight&&(e+=a._cardHeight);for(let o=r;o<s.length;o++){const l=s[o];if(0===l.height||!l.visible||!1===l.filtered||l.freeze&&l.visible)continue;const i=l.height;if(l.expandHeight&&(e+=a.offsetHeight+l.expandHeight),!(u+i>=n-g&&u<=n+e||a._autoHeight))break;{const e=a._rowElements[m++];if(!e)break;if(e.setAttribute("aria-rowindex",t+o+1),l.element=e,l.grid=a,f){if(l.index=o+t,l.visibleIndex=o+t,a.selection.enabled&&a._selection){const e=a._selection.indexes,t=l.canNotify;l.canNotify=!1,l.selected=e.indexOf(l.index)>=0,l.canNotify=t}a.paging.enabled?(l.data=a.dataSource[r+m-1],l.data&&(l.id=l.data.$.id,a.rowById[l.id]=l)):(l.data=a.dataSource[m-1],l.data&&(l.id=l.data.$.id,a.rowById[l.id]=l))}l.render()}u+=i}}a._renderFrozenRows();let y=m;if(m<a._rowElements.length)for(let e=m;e<a._rowElements.length;e++){const e=a._rowElements[m++];e.classList.add("smart-hidden"),e.removeAttribute("aria-rowindex")}a.editing.addNewRow&&a.editing.addNewRow.visible&&"button"===a.editing.addNewRow.displayMode&&a._rowElements[y]&&(a._newRow||(a._newRow=new Smart.Grid.Row({data:{},index:9999999,grid:a,addNewRow:!0,inline:!0,autoGenerated:!0})),a._newRow.element=a._rowElements[y],a._newRow.element.classList.remove("smart-hidden"),a._newRow.render()),f&&a._selection.selectionRect&&a._refreshCellSelectionRect()}_renderFrozenRows(){const e=this;let t=!1,o=!1;if("card"===e.view)return e.$.rowNearContainer.classList.add("smart-hidden"),void e.$.rowFarContainer.classList.add("smart-hidden");0===e._frozenNearRows.length?e.$.rowNearContainer.classList.add("smart-hidden"):e.$.rowNearContainer.classList.remove("smart-hidden");for(let o=0;o<e._frozenNearRows.length;o++){const l=e._frozenNearRows[o];l.visible||(l.element=e.$.rowNearContainer.children[o],l.element||(l.element=l.createElement(),e.$.rowNearContainer.appendChild(l.element)),l.element.classList.add("smart-hidden")),l.visible&&l.filtered&&(t=!0,l.element=e.$.rowNearContainer.children[o],l.element||(l.element=l.createElement(),e.$.rowNearContainer.appendChild(l.element)),l.render())}t||e.$.rowNearContainer.classList.add("smart-hidden"),0===e._frozenFarRows.length?e.$.rowFarContainer.classList.add("smart-hidden"):e.$.rowFarContainer.classList.remove("smart-hidden");for(let t=0;t<e._frozenFarRows.length;t++){const l=e._frozenFarRows[t];l.visible&&(o=!0),l.element=e.$.rowFarContainer.children[t],l.element||(l.element=l.createElement(),e.$.rowFarContainer.appendChild(l.element)),l.render()}o||e.$.rowFarContainer.classList.add("smart-hidden"),0!==e.columns.length&&e.hasVisibleColumn()||(e.$.rowNearContainer.classList.add("smart-hidden"),e.$.rowFarContainer.classList.add("smart-hidden"));const l=e.rows;l&&null!==l&&0!==l.length||(e.$.rowNearContainer.classList.add("smart-hidden"),e.$.rowFarContainer.classList.add("smart-hidden"),e._filters&&e._filters.length&&e.filtering.filterRow.visible&&e.$.rowNearContainer.classList.remove("smart-hidden"))}_recycleRotate(e,t,o,l,a){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect();let r=0,s=0;return 0===i.width?(e.innerHTML=a,!1):(n.left>i.left&&(r=i.left-n.left),n.top<i.top&&(s=i.top-n.top),"left"!==o&&""!==o||(r=4),"center"===o&&(r+=i.width/2-n.width/2),"right"===o&&(r+=i.width-n.width-4),"top"!==l&&""!==l||(s=4),"center"!==l&&"middle"!==l||(s+=i.height/2-n.height/2),"bottom"===l&&(s+=i.height-n.height-4),t.style.left=r+"px",t.style.top=s+"px",!0)}_virtualDataRequest(e,t){const o=this;let l=-1,a=-1;if(!o._rowElements&&"infinite"!==o.scrolling)return;if("virtual"===o.scrolling){for(let e=0;e<o._rowElements.length;e++){const t=o._rowElements[e],n=t.row,i=0===e?n.visibleIndex:l+e;t.classList.contains("smart-hidden")||(-1===l&&(l=i),-1!==i&&(a=1+i))}0===o._rowElements.length&&(l=0,a=Math.max(20,parseInt(o.offsetHeight/o.layout.rowMinHeight*1.5)))}else"infinite"===o.scrolling?(l=1/0,a=1/0):(l=0,a=o.dataSource.length);a!==1/0&&(o.dataSource.virtualDataSourceLength||o.dataSource.length)&&(a=Math.min(a,o.dataSource.length)),o.paging.enabled&&(l=o.paging.pageIndex*o._pageSize,a=l+o._pageSize),o._toggledRow||(o.appearance.displayLoadingIndicator=!0,o._setLoadingIndicatorVisibility()),o._groups||(o._groups=[].concat(o.dataSource.groupBy.toArray())||[]);const n={first:l,last:a,edit:o._editInfo||null,sorting:o.getSortedColumns(),filtering:o.getFilteredColumns(),filterOperator:o.filtering.operator,grouping:o._groups,row:o._toggledRow?o._toggledRow.data:null,action:e},i=o.dataSource.length,r=o.dataSource.boundSource.length;void 0===o._isFirstVirtualDataSourceRequest&&(o._isFirstVirtualDataSourceRequest=!0),o.dataSource.onVirtualDataSourceRequested((function(e){if(o.appearance.displayLoadingIndicator=!1,o._setLoadingIndicatorVisibility(),o._toggledRow=null,!e)return o._initializeRows(),o._initializeRowElements(),o.refresh(),o._refreshPagesCount(),void(o._autoHeight&&o._initializeRowElements());if("add"===e.action)return void(t&&t(e.result));if("update"===e.action)return void(t&&t(e.result));if("remove"===e.action)return void(t&&t(e.result));const l=o.context;if(o.context=o,o._isFirstVirtualDataSourceRequest&&0===o._initColumns.length&&(o.columns.canNotify=!1,o.columns=[],o._renderColumns(),o.columns.canNotify=!0),"scroll"===e.action)if("infinite"===o.scrolling){const e=o._viewRows;for(let t=0;t<e.length;t++){const l=e[t];l.data&&!l.addNewRow&&l.data.$&&(o.rowById[l.data.$.id]||(o.rowById[l.data.$.id]=l))}o._recycle(!1,!1)}else{const t=e.first>=0?e.first:0,l=e.last!==1/0?e.last:0;let a=0;for(let e=t;e<l;e++)o.rows[e]&&(o.rows[e].data=o.dataSource[a++]);o._recycle(!1,!1)}else if(o.dataSource.length!==i||o.dataSource.boundSource.length!==r||o._isFirstVirtualDataSourceRequest||"expand"===e.action||"filter"===e.action||"sort"===e.action||"pageIndexChange"===e.action||"pageSizeChange"===e.action||"sort"===e.action||"group"===e.action){o.paging.enabled&&o.$.headerPager.querySelector("smart-pager")&&(o.$.headerPager.querySelector("smart-pager").pagesCount=Math.ceil(o.dataSource.length/o._pageSize),o.$.footerPager.querySelector("smart-pager").pagesCount=Math.ceil(o.dataSource.length/o._pageSize));const e=o.filtering.filterRow&&o.filtering.filterRow.visible&&o.filtering.filterRow.cell?o.filtering.filterRow.cell.column.dataField:null;if(o._initializeRows(),o._initializeRowElements(),o.refresh(),o._refreshPagesCount(),o._autoHeight&&o._initializeRowElements(),o.filtering.filterRow){for(let e=0;e<o.columns.length;e++)o.columns[e]._filterEditorInitialized&&(o.columns[e]._filterEditorInitialized=!1);e&&setTimeout((()=>{const t=o.columnByDataField[e];t&&t._filterInfo&&t._filterInfo.input&&t._filterInfo.input.focus()}),100)}}else o.dataSource.virtualDataSourceOnExpand&&o.refresh();o._isFirstVirtualDataSourceRequest&&o.onLoad&&(o.onLoad(o),delete o.onLoad),o._isFirstVirtualDataSourceRequest=!1,o._recycle(),o.context=l,o._onDataUpdated&&o._onDataUpdated()}),n)}_createAddNewRowButton(){const e=this,t=document.createElement("div");return t.className="smart-grid-add-row-button smart-grid-icon smart-icon-plus",t.title=e.localize("addNewRow"),t.style.left=e.appearance.showViewBar&&!e._mobile?10+e.layout.viewBarWidth+"px":"",e._addNewGridRow=t.onclick=()=>{e._addRowTimer&&clearTimeout(e._addRowTimer),e._addRowTimer=setTimeout((()=>{if(e.dataSource&&e.dataSource.virtualDataSource)return void e._insertNewRowAfter();const t={};for(let o=0;o<e.columns.length;o++){const l=e.columns[o];void 0!==l.defaultValue&&null!==l.defaultValue&&("today"===l.defaultValue&&"date"===l.dataType?(e._today||(e._today=new Date,e._todayYear=e._today.getFullYear(),e._todayMonth=e._today.getMonth(),e._todayDate=e._today.getDate()),t[l.dataField]=new Date(e._todayYear,e._todayMonth,e._todayDate)):t[l.dataField]=l.defaultValue)}e._addingNewRow=!0,e._add(t),e._mobile||(e._scrollView.vScrollBar.value=e._scrollView.vScrollBar.max),e.closeMenu(),e._addingNewRow=!1,e.editing.addNewRow.visible&&e.$.placeholder.classList.contains("smart-hidden")&&"button"!==e.editing.addNewRow.displayMode&&e.editing.addNewRow._addButton.classList.remove("show")}),0)},t}addColumn(e,t,o=!0){const l=this;if(e){let a=-1;if(t)for(let e=0;e<l.columns.length;e++)if(l.columns[e].dataField===t){a=e,!1===o&&(a=e+1);break}if("string"==typeof e){const t=l._getKanbanTaskField(e);if(t){if(a>=0)return void l.columns.splice(a,0,t);l.columns.push(t)}return}if(a>=0&&a<l.columns.length)return void l.columns.splice(a,0,e);l.columns.push(e)}}insertColumnAfter(e,t){e&&this.addColumn(e,t,!1)}insertColumnBefore(e,t){e&&this.addColumn(e,t,!0)}addNewColumn(e){e&&this.addColumn(e)}_createAddNewColumnButton(){const e=this,t=document.createElement("div");return t.className="smart-grid-add-column-button smart-grid-icon smart-icon-plus",t.title=e.localize("addNewColumn"),t.onclick=()=>{e._openAddColumnDialog(),e.addEventListener("closeColumnDialog",(()=>{e.layout.isDirty=!0,e._resetCachedLayout(),e._refreshLayout()}))},t}_showAddNewRowButton(e){const t=this;if(!t.columns.length)return;if("grid"!==t.view&&t.editing.addNewRow._addButton)return void t.editing.addNewRow._addButton.classList.add("smart-hidden");if("grid"===t.view&&t.editing.addNewRow._addButton&&t.editing.addNewRow._addButton.classList.remove("smart-hidden"),"float"===e&&t.computedVerticalScrollBarVisibility&&t.editing.addNewRow._addButton&&!t.editing.addNewRow._addButton.classList.contains("show"))return;if("float"===e&&t._addingNewRow)return;const o=()=>{t.editing.addNewRow._addButton&&t.editing.addNewRow._addButton&&("float"!==e&&(t.appearance.showRowHeader||t.appearance.showRowHeaderNumber)&&"card"!==t.view?t.editing.addNewRow._addButton.classList.remove("float"):t.computedVerticalScrollBarVisibility?(t.computedVerticalScrollBarVisibility&&"float"===e||"card"===t.view)&&t.editing.addNewRow._addButton.classList.add("float"):t.editing.addNewRow._addButton.classList.add("float"),t.computedHorizontalScrollBarVisibility?t.pager.visible?t.editing.addNewRow._addButton.style.bottom="68px":t.editing.addNewRow._addButton.style.bottom="20px":t.pager.visible?t.editing.addNewRow._addButton.style.bottom="48px":t.editing.addNewRow._addButton.style.bottom="",t.grouping.enabled&&t.dataSource)&&(!(t.dataSource.groupBy.length>0)||t.editing.addNewRow._addButton.classList.remove("show"))};t.editing.addNewRow._addButton&&t.editing.addNewRow.visible&&t.$.placeholder.classList.contains("smart-hidden")&&"button"!==t.editing.addNewRow.displayMode&&t.editing.addNewRow._addButton.classList.remove("show"),!t.editing.addNewRow.visible||"button"!==t.editing.addNewRow.displayMode&&t.$.placeholder.classList.contains("smart-hidden")||(t.editing.addNewRow._addButton?requestAnimationFrame((()=>{t.editing.addNewRow._addButton&&(t.editing.addNewRow._addButton.classList.add("show"),t.editing.addNewRow._addButton.style.left=t.appearance.showViewBar&&!t._mobile?10+t.layout.viewBarWidth+"px":"",o())})):(t.editing.addNewRow._addButton=t._createAddNewRowButton(),t.appendChild(t.editing.addNewRow._addButton),requestAnimationFrame((()=>{t.editing.addNewRow._addButton&&(t.editing.addNewRow._addButton.classList.add("show"),o(),t.editing.addNewRow.visible&&t.$.placeholder.classList.contains("smart-hidden")&&"button"!==t.editing.addNewRow.displayMode&&t.editing.addNewRow._addButton.classList.remove("show"))}))))}_showAddNewColumnButton(){const e=this,t=()=>{e.editing.addNewColumn._addButton.classList.add("float")};e.editing.addNewColumn.visible&&(e.editing.addNewColumn._addButton||(e.editing.addNewColumn._addButton=e._createAddNewColumnButton(),e.appendChild(e.editing.addNewColumn._addButton)),requestAnimationFrame((()=>{e.editing.addNewColumn._addButton.classList.add("show"),t()})))}_verticalScrollRecycle(e,t){const o=this;if(o._layoutSuspended||!1===o.isAttached)return;if(o._isUpdating)return;if(o.editing.isEditing&&(!0!==o._disableEndEdit&&o.endEdit(),o._isUpdating))return;o._removeCellContentPopup(),o._inputOverlay&&(o._inputOverlay.parentNode&&o._inputOverlay.parentNode.removeChild(o._inputOverlay),o._inputOverlay=null),o._selection.selectionRect&&o._refreshCellSelectionRect();const l=o._recyclingRows;let a=l[t],n=a.top,i=!1;for(let r=0;r<o._cellsMerge.length;r++){const s=o._cellsMerge[r],d=l.indexOf(s.row);t>d&&t<=d+s.rowSpan&&(t=d,a=s.row,n=a.top,o.$.rowContainer.style.top=o.__frozenNearHeight-e+n+"px",i=!0)}i||(o.$.rowContainer.style.top=o.__frozenNearHeight-e+n+"px")}_verticalScrollbarHandler(e){const t=this;t.menu&&t.menu.column&&t.closeMenu(),t.isScrolling=!0,t._scrollTimer&&clearTimeout(t._scrollTimer),t._layoutSuspended||(t._scrollTimer=setTimeout((()=>{if("virtual"===t.scrolling)t._recycle(!1);else{const e=t._scrollView.scrollTop;let o=t._getRowIndexByPosition(e);o!==t._scrollRowIndex?(t._recycle(!1,!0,!0,o),t._scrollRowIndex=o):t._verticalScrollRecycle(e,o)}if(t.isScrolling=!1,e.max===e.value&&e.max>0){if(t.$.fireEvent("scrollBottomReached"),"infinite"===t.scrolling)return t.appearance.displayLoadingIndicator=!0,t._setLoadingIndicatorVisibility(),t._virtualScrollTimer&&clearTimeout(t._virtualScrollTimer),void(t._virtualScrollTimer=setTimeout((()=>{t._virtualDataRequest("scroll"),t.appearance.displayLoadingIndicator=!1,t._setLoadingIndicatorVisibility()}),50));t.editing.addNewRow._addButton&&"card"!==t.view&&t.editing.addNewRow._addButton.classList.remove("show")}else t.editing.addNewRow.visible&&"button"===t.editing.addNewRow.displayMode&&t.editing.addNewRow._addButton&&e.max>0&&(t.editing.addNewRow._addButton.classList.add("show"),t.editing.addNewRow._addButton.classList.remove("scroll"),t.editing.addNewRow._addButton.classList.add("float"));"virtual"===t.scrolling&&(t.appearance.displayLoadingIndicator=!0,t._setLoadingIndicatorVisibility(),t._virtualScrollTimer&&clearTimeout(t._virtualScrollTimer),t._virtualScrollTimer=setTimeout((()=>{t._virtualDataRequest("scroll"),t.appearance.displayLoadingIndicator=!1,t._setLoadingIndicatorVisibility()}),50)),e.min===e.value&&t.$.fireEvent("scrollTopReached")}),0))}getVerticalScrollMax(){return this.scrollHeight}getHorizontalScrollMax(){return this.scrollWidth}getHorizontalScrollValue(){return this.scrollLeft}setHorizontalScrollValue(e){this.scrollLeft=e}getVerticalScrollValue(){return this.scrollTop}setVerticalScrollValue(e){this.scrollTop=e}clearRows(){const e=this;e.dataSource=new Smart.DataAdapter({dataSource:[]}),e.rowHierarchy=null,e._visibleRows=null,e.__viewRows=null,e.rows.canNotify=!1,e.rows.length=0,e.rows.canNotify=!0,e.clearSelection(),e._refresh()}isEmpty(){const e=this;return!!(null===e.dataSource||e.dataSource&&e.dataSource.dataFields&&0===e.dataSource.length&&0===e.dataSource.dataSource.length&&!e.dataSource.virtualDataSource)}setRowStyle(e,t){const o=this,l=o.rowById[e];l&&(l.style=t,o._recycle(!1,!0))}setCellStyle(e,t,o){const l=this,a=l.rowById[e];if(a){const e=a.getCell(t);if(e){const t=e.canNotify;if(e.canNotify=!1,o)for(let t in o)void 0!==e[t]&&(e[t]=o[t]);else e.background=null,e.color=null,e.fontSize=null,e.fontFamily=null,e.fontWeight=null,e.textDecoration=null,e.fontStyle=null;e.canNotify=t,l._recycle(!1,!0)}}}setCellFormula(e,t,o){const l=this,a=l.rowById[e];if(a){const e=a.getCell(t);if(e){const t=e.canNotify;e.canNotify=!1,e.formula=o,e.canNotify=t,l._recycle(!1,!0)}}}dataBind(){const e=this;if(delete e.__autoRowHeight,e._virtualOnExpandCache=[],e._cellsMerge=[],e._cellStyles=[],null===e.dataSource||e.dataSource&&e.dataSource.dataFields&&0===e.dataSource.length&&0===e.dataSource.dataSource.length&&!e.dataSource.virtualDataSource)e.clearRows();else if(Array.isArray(e.dataSource))if(e.dataSourceSettings.dataFields&&e.dataSourceSettings.dataFields.length>0)e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataSourceType:e.dataSourceSettings.dataSourceType,dataFields:e.dataSourceSettings.dataFields,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy&&e.dataSourceSettings.groupBy.length?e.dataSourceSettings.groupBy:e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand});else if(e.columns&&e.columns.length){let t=[];for(let o=0;o<e.columns.length;o++){const l=e.columns[o];t.push({name:l.dataField,dataType:l.dataType||"string"}),l.displayField!==l.dataField&&t.push({name:l.displayField,dataType:l.dataType||"string"})}e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource,dataFields:t,dataSourceType:e.dataSourceSettings.dataSourceType,keyDataField:e.dataSourceSettings.keyDataField,parentDataField:e.dataSourceSettings.parentDataField,childrenDataField:e.dataSourceSettings.childrenDataField,groupBy:e.dataSourceSettings.groupBy&&e.dataSourceSettings.groupBy.length?e.dataSourceSettings.groupBy:e.grouping.groupBy,mapChar:e.dataSourceSettings.mapChar,root:e.dataSourceSettings.root,record:e.dataSourceSettings.record,autoGenerateColumns:e.autoGenerateColumns,id:e.dataSourceSettings.id,virtualDataSource:e.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:e.dataSourceSettings.virtualDataSourceOnExpand})}else e.dataSource=new Smart.DataAdapter({dataSource:e.dataSource});const t=e._filters,o=e._sortedColumns;if(e.clearSort(),e.filtering.filterRow)for(let t=0;t<e.columns.length;t++)e.columns[t]._filterEditorInitialized=!1;for(let t=0;t<e.columns.length;t++)delete e.columns[t]._cellsCachedValues;e._initColumns&&0===e._initColumns.length&&(e.columns=[],e._renderColumns(!0)),e._renderRows(),"virtual"===e.scrolling||e.paging.enabled&&e.dataSource&&e.dataSource.virtualDataSource||e.dataSource&&e.dataSource.virtualDataSource?e._virtualDataRequest("dataBind"):e.paging.enabled&&(!e.dataSource||e.dataSource&&!e.dataSource.url)&&e._refreshPagesCount(),o&&e._refreshSort(o),t&&t.length>0&&(e._filters=null,e.refreshFilters())}refresh(e){const t=this;t.isInitialized&&(e&&(t._initializeRows(),t._initializeRowElements()),t._refresh(),t._refreshSummary())}refreshView(){const e=this;e._recycleFiles=!0,e._recycle(),delete e._recycleFiles}beginUpdate(){const e=this;e._isUpdating||(e._isUpdating=0),e._isUpdating++}endUpdate(e,t){const o=this;o._isUpdating--,o._isUpdating<0&&(o._isUpdating=0),!1!==e?o.refresh():!1!==t&&o.refreshView()}}),Smart.Grid.Extend=function(e){if(!e)return;const t=Object.getOwnPropertyNames(e.prototype);for(let o in t){const l=t[o];"constructor"!==l&&(Smart.Grid.prototype[l]=e.prototype[l])}},Smart.Grid.Extend(Smart.Utilities.Grid.Resize),Smart.Grid.Extend(Smart.Utilities.Grid.Reorder),Smart.Grid.Extend(Smart.Utilities.Grid.Pager),Smart.Grid.Extend(Smart.Utilities.Grid.Filter),Smart.Grid.Extend(Smart.Utilities.Grid.Sort),Smart.Grid.Extend(Smart.Utilities.Grid.Menu),Smart.Grid.Extend(Smart.Utilities.Grid.Select),Smart.Grid.Extend(Smart.Utilities.Grid.Edit),Smart.Grid.Extend(Smart.Utilities.Grid.Dialog),Smart.Grid.Extend(Smart.Utilities.Grid.Group),Smart.Grid.Extend(Smart.Utilities.Grid.Tree),Smart.Grid.Extend(Smart.Utilities.Grid.Export),Smart.Grid.Extend(Smart.Utilities.Grid.Chart),Smart.Grid.Extend(Smart.Utilities.Grid.View),Smart.Grid.Cell=Smart.Utilities.Grid.Cell,Smart.Grid.Row=Smart.Utilities.Grid.Row,Smart.Grid.Column=Smart.Utilities.Grid.Column;
66
66
  Smart("smart-menu-item",class extends Smart.BaseElement{static get properties(){return{checked:{value:!1,type:"boolean"},label:{value:"",type:"any"},level:{value:null,type:"number?"},separator:{value:!1,type:"boolean"},shortcut:{value:"",type:"string"},value:{value:null,type:"any"}}}get enableShadowDOM(){return!1}template(){return""}ready(){const e=this;if(super.ready(),e.$.addClass("smart-unselectable"),e.setAttribute("role","menuitem"),e.checked&&e.setAttribute("aria-checked",!0),!1===e.isDirty)return;const t=e.closest("smart-menu, smart-tree");t&&t.isRendered&&(cancelAnimationFrame(Smart.Menu.processTimer),Smart.Menu.processTimer=requestAnimationFrame((()=>{t._lazyInitItems()})))}propertyChangedHandler(e,t,n){const o=this;if(super.propertyChangedHandler(e,t,n),"smart-tree-item"===o.tagName.toLowerCase())return;const i=o.menu,r=o.parentItem,a=r||i;if("label"===e)return""===n?void(o.label=t):(o.setAttribute("aria-label",n),void(i&&i._setItemLabel(o,n)));if(!i)return;if("separator"===e)return void i._refreshCheckableItems(a);if("disabled"!==e||!1===n||!o.checked)return;super.propertyChangedHandler(e,t,n),o.checked=!1;const s=a.checkMode;"radioButton"===s?i._validateRadioButtonSelection(r,o.level,[]):"checkbox"!==s&&i._refreshCheckableItems(a)}}),Smart("smart-menu-items-group",class extends Smart.BaseElement{static get properties(){return{checkable:{value:!1,type:"boolean"},checked:{value:!1,type:"boolean"},checkMode:{value:"checkbox",type:"string"},dropDownHeight:{value:null,type:"number?"},expanded:{value:!1,type:"boolean"},label:{value:"",type:"any"},level:{value:null,type:"number?"},separator:{value:!1,type:"boolean"},value:{value:null,type:"any"}}}get enableShadowDOM(){return!1}template(){return""}ready(){const e=this;if(super.ready(),e.$.addClass("smart-unselectable"),e.setAttribute("role","menuitem"),e.setAttribute("aria-haspopup",!0),e.setAttribute("aria-expanded",e.expanded),e.checked&&e.setAttribute("aria-checked",!0),!1===e.isDirty)return;const t=e.closest("smart-menu, smart-tree");t&&t.isRendered&&(cancelAnimationFrame(Smart.Menu.processTimer),Smart.Menu.processTimer=requestAnimationFrame((()=>{t._lazyInitItems()})))}propertyChangedHandler(e,t,n){const o=this;if(super.propertyChangedHandler(e,t,n),"smart-tree-items-group"===o.tagName.toLowerCase())return;const i=o.menu,r=o.parentItem,a=r||i;if("label"===e)return""===n?void(o.label=t):(o.setAttribute("aria-label",n),void(i&&i._setItemLabel(o,n)));if(i&&-1!==["checkable","checkMode","disabled","separator"].indexOf(e))switch(e){case"checkable":n?o.itemContainer.setAttribute("checkable",""):o.itemContainer.removeAttribute("checkable"),i._isContainerOpened(o.container.level,o.container)&&"tree"!==i.mode&&!i._minimized&&i._closeSubContainers(o.level+2),i._updateItemRoles(o);break;case"checkMode":o.itemContainer.setAttribute("check-mode",n),i._changeToRadioButtonMode(n,o.itemContainer,o),i._updateItemRoles(o);break;case"disabled":{if(Smart.ListMenu&&i instanceof Smart.ListMenu){if(i._view)for(;o.contains(i._view);)i._backButtonClickHandler()}else i._isContainerOpened(o.container.level,o.container)&&i._closeSubContainers(o.level+1,o.container);if(!o.checked)return;o.checked=!1;const e=a.checkMode;"radioButton"===e?i._validateRadioButtonSelection(r,o.level,[]):"checkbox"!==e&&i._refreshCheckableItems(a);break}case"separator":i._refreshCheckableItems(a)}}}),Smart("smart-menu",class extends Smart.BaseElement{static get properties(){return{autoCloseDelay:{value:100,type:"number"},autoFocusOnMouseenter:{value:!1,type:"boolean"},checkable:{value:!1,type:"boolean"},checkboxes:{value:!1,type:"boolean"},checkMode:{value:"checkbox",type:"string"},closeAction:{value:"up",allowedValues:["up","down","none"],type:"string"},disableAutoCheck:{value:!1,type:"boolean"},dataSource:{value:null,type:"array?",reflectToAttribute:!1},displayMember:{value:"label",type:"string"},dropDownAppendTo:{value:null,type:"any?"},dropDownOverlay:{value:!1,type:"boolean"},dropDownPosition:{value:"auto",allowedValues:["top-left","top-right","bottom-left","bottom-right","overlay-left","overlay-right","auto"],type:"string"},enableMouseWheelAction:{value:!1,type:"boolean"},innerHTML:{type:"string",reflectToAttribute:!1},itemsMember:{value:"items",type:"string"},minimizeIconTemplate:{value:null,type:"string?"},minimizeWidth:{value:null,type:"number?"},mode:{value:"horizontal",allowedValues:["horizontal","vertical","dropDown","tree"],type:"string"},opened:{value:!1,type:"boolean"},overflow:{value:"auto",allowedValues:["auto","hidden","scroll"],type:"string"},preventCloseOnCheck:{value:!1,type:"boolean"},selectionMode:{value:"click",allowedValues:["click","mouseenter"],type:"string"},valueMember:{value:"value",type:"string"}}}static get listeners(){return{"container.click":"_selectionHandler",keydown:"_keydownHandler",mouseenter:"_mouseenterHandler",mouseleave:"_mouseleaveHandler","container.mouseout":"_mouseoutMouseoverHandler","container.mouseover":"_mouseoutMouseoverHandler",resize:"_resizeHandler",transitionend:"_transitionendHandler","hamburgerIcon.click":"_hamburgerIconClickHandler","mainContainer.click":"_mainContainerHandler","mainContainer.mouseleave":"_mainContainerHandler","mainContainer.mouseout":"_mainContainerHandler","mainContainer.mouseover":"_mainContainerHandler","document.down":"_documentDownHandler","document.up":"_documentUpHandler"}}static get requires(){return{"Smart.RepeatButton":"smart.button.js"}}static get styleUrls(){return["smart.button.css","smart.menu.css"]}get items(){return this._menuItems}template(){return'<div id="container" role="presentation">\n <div id="minimizedHeader" class="smart-header smart-minimized-header smart-hidden" role="presentation">\n <div id="hamburgerIcon" class="smart-hamburger-icon smart-hidden" role="button" aria-label="Toggle minimized menu" aria-haspopup="true">\n <div id="hamburgerIconLineTop" class="smart-hamburger-icon-line smart-hamburger-icon-line-top" role="presentation"></div>\n <div id="hamburgerIconLineCenter" class="smart-hamburger-icon-line smart-hamburger-icon-line-center" role="presentation"></div>\n <div id="hamburgerIconLineBottom" class="smart-hamburger-icon-line smart-hamburger-icon-line-bottom" role="presentation"></div>\n <div id="customIconContainer" class="smart-hamburger-icon-custom-container smart-hidden" role="presentation"></div>\n </div>\n </div>\n <smart-repeat-button id="scrollButtonNear" class="smart-menu-scroll-button smart-spin-button smart-scroll-button-near smart-hidden" animation="[[animation]]" unfocusable right-to-left="[[rightToLeft]]">\n <div id="arrowNear" class="smart-arrow" aria-hidden="true"></div>\n </smart-repeat-button>\n <div id="mainContainer" class="smart-menu-main-container" role="presentation">\n <content></content>\n </div>\n <smart-repeat-button id="scrollButtonFar" class="smart-menu-scroll-button smart-spin-button smart-scroll-button-far smart-hidden" animation="[[animation]]" unfocusable right-to-left="[[rightToLeft]]">\n <div id="arrowFar" class="smart-arrow" aria-hidden="true"></div>\n </smart-repeat-button>\n </div>'}attached(){const e=this;if(super.attached(),!e.isCompleted||!e.isRendered||"tree"===e._element||Smart.ListMenu&&e instanceof Smart.ListMenu)return;const t=e._scrollInfo;if(null!==e.dropDownAppendTo){if(e._minimized)e._dropDownParent.appendChild(e.$.mainContainer);else for(let t=0;t<e._containersInBody.length;t++)e._dropDownParent.appendChild(e._containersInBody[t]);"dropDown"===e.mode&&(e._dropDownParent===e.parentElement?e._dynamicallyReparented?delete e._dynamicallyReparented:e._positionRelativeTo=null:(e._positionRelativeTo=e.parentElement,e._dynamicallyReparented=!0,setTimeout((function(){e._dropDownParent.appendChild(e)}),0)))}t&&t.forEach((function(e,t){t.scrollLeft=e.left,t.scrollTop=e.top}))}detached(){const e=this;super.detached(),"tree"===e._element||Smart.ListMenu&&e instanceof Smart.ListMenu||(e._close(),null!==e.dropDownAppendTo&&(e._minimized?e._dropDownParent.removeChild(e.$.mainContainer):e._removeContainersInBody()))}ready(){super.ready()}render(){const e=this;e._element="menu",e._edgeMacFF=Smart.Utilities.Core.Browser.Edge||Smart.Utilities.Core.Browser.Firefox&&-1!==navigator.platform.toLowerCase().indexOf("mac"),e._containers=[],e._containersInBody=[],e._openedContainers=[],e._containersFixedHeight=[],e._menuItemsGroupsToExpand=[],e._additionalScrollButtons=[],e._scrollInfo=new Map,e._createElement(),super.render()}addItem(e,t){const n=this;if(!(e instanceof Smart.MenuItem||e instanceof Smart.MenuItemsGroup))if("string"==typeof e){const t=document.createElement("smart-menu-item");t.label=e,e=t}else{if(!e||!e.label)return;{const t=document.createElement("smart-menu-item");t.label=e.label,e=t}}let o,i,r;if(e.isDirty=!1,void 0===t)o=n,i=1,r=t=n.$.mainContainer;else{if((t=n.getItem(t))instanceof Smart.MenuItemsGroup==0)return;o=t,i=t.level+1,r=t.itemContainer}if(n._createItemHTMLStructure(e,i,t,r.childElementCount,0),e instanceof Smart.MenuItemsGroup&&(n._processHTML(e,i+1),n._checkContainersLength()),r.appendChild(e),n._checkOverflowAddRemove(e.level,r),e instanceof Smart.MenuItemsGroup&&("tree"===n.mode||n._minimized)){const t=e.getElementsByClassName("smart-menu-items-group-arrow");for(let e=0;e<t.length;e++)t[e].className="smart-menu-items-group-arrow down smart-arrow-down";n._expandItemsByDefault()}n._checkOverflow(n.$.mainContainer,"horizontal"===n.mode,[n.$.scrollButtonNear,n.$.scrollButtonFar]),n._refreshCheckableItems(o)}checkItem(e){void 0===(e=this.getItem(e))||e.checked||e.disabled||e.templateApplied||this._toggleItem(e)}clear(){const e=this;e.$.mainContainer.innerHTML="",e._removeContainersInBody(),e._menuItems={},e._containers=[],e._containersInBody=[],e._openedContainers=[],e._containersFixedHeight=[],e._menuItemsGroupsToExpand=[],e._additionalScrollButtons=[]}clickItem(e){const t=this;"string"==typeof e&&(e=t.getItem(e)),e&&e.nodeName&&t._selectionHandler({type:"click",isTrusted:!0,target:e,stopPropagation:()=>{},preventDefault:()=>{}})}close(){const e=this;"dropDown"!==e.mode||!1===e.opened&&e.$.hasClass("smart-visibility-hidden")||(e.$.fireEvent("closing",arguments[0]||{trigger:"programmatic"}).defaultPrevented?e.opened=!0:(e.opened=!1,e.$.addClass("smart-visibility-hidden"),e._close(),e.$.fireEvent("close")))}collapseItem(e,t){const n=this,o=n.animation,i=!1===t&&n.hasAnimation;if(void 0===e)return i&&(n.animation="none"),n._close(),void(i&&setTimeout((function(){n.animation=o}),0));if(void 0===(e=n.getItem(e))||e instanceof Smart.MenuItem)return;const r=e.level;if(n._openedContainers[r+1]&&n._isContainerOpened(r+1,e.container)){const t=n.mode;i&&(n.animation="none"),n._closeSubContainers(r+1,e.container,void 0,!1!==arguments[2]),1!==r&&"tree"!==t||n._checkOverflow(n.$.mainContainer,"horizontal"===t,[n.$.scrollButtonNear,n.$.scrollButtonFar]),i&&(n.animation=o)}}expandItem(e,t){const n=this;if(void 0===(e=n.getItem(e))||e instanceof Smart.MenuItemsGroup&&n._isContainerOpened(e.level+1,e.container)&&n._isBranchExpanded(e))return;void 0!==Smart.Menu.processTimer&&n._lazyInitItems();const o=[e],i=n.animation,r=!1===t&&n.hasAnimation;let a=e.parentItem;for(r&&(n.animation="none"),n._discardKeyboardHover();a;)o.unshift(a),a=a.parentItem;for(let e=0;e<o.length;e++){const t=o[e];if(e===o.length-1&&t instanceof Smart.MenuItem){t.disabled||t.templateApplied||n._hoverViaKeyboard(t);break}n._isContainerOpened(t.container.level,t.container)||n._menuItemsGroupSelectionHandler(t,{target:t,type:"expand",isTrusted:!0},arguments[2])}r&&(n.animation=i)}getItem(e){const t=this;let n;if(null!=e&&t._menuItems){if("string"==typeof e){if(/^[0-9]*([.]?[0-9]*)*$/gm.test(e))return t._menuItems[e];if(n=t.$.mainContainer.querySelector('[id="'+e+'"]'),null===n)return t._menuItems[e]}else{if(!isNaN(e))return t._menuItems[e.toString()];n=e}if((n instanceof Smart.MenuItem||n instanceof Smart.MenuItemsGroup)&&(t.contains(n)||t.$.mainContainer.contains(n)||n.parentElement.parentElement.ownerElement===t))return n}}maximize(){const e=this;if(!e._minimized)return;const t=e.animation;if(e.$.mainContainer.style.marginTop="",e.$.mainContainer.style.marginLeft="",e.enableShadowDOM&&!e.$.mainContainer.id&&(e.$.mainContainer.id=e.$.mainContainer.getAttribute("smart-id")),"none"!==t&&(e.animation="none"),e._positionDetection.removeOverlay(),e._closeSubContainers(2),e.$minimizedHeader.addClass("smart-hidden"),e._minimized=!1,e._minimizedDropDownOpened&&(e.$hamburgerIcon.removeClass("smart-close-button"),e._minimizedDropDownOpened=!1),null!==e.dropDownAppendTo&&e._appendMinimizedContainerToMenu(e.$.mainContainer,e.$.scrollButtonFar),"tree"!==e.mode){e.$mainContainer.addClass("smart-menu-main-container"),e.$mainContainer.removeClass("smart-menu-minimized-items-container");const t=e.$.mainContainer.getElementsByClassName("smart-menu-items-group-arrow");for(let n=0;n<t.length;n++)e._setArrowDirection(t[n],t[n].parentElement.parentElement.level+1);null!==e.dropDownAppendTo&&e._moveDropDownsToExternalContainer(),e._applyContainerFixedHeight()}e.$mainContainer.removeClass("smart-visibility-hidden"),e.$hamburgerIcon.addClass("smart-hidden"),e.removeAttribute("minimized"),e._checkOverflow(e.$.mainContainer,"horizontal"===e.mode,[e.$.scrollButtonNear,e.$.scrollButtonFar]),"none"!==t&&setTimeout((function(){e.animation=t}),0),e.$.mainContainer.removeAttribute("drop-down"),e.$.hamburgerIcon.removeAttribute("aria-expanded"),e.$.hamburgerIcon.removeAttribute("aria-owns"),e.$.mainContainer.setAttribute("role","presentation"),e.$.mainContainer.removeAttribute("aria-orientation"),e.setAttribute("role","menu"),e.setAttribute("aria-orientation","horizontal"===e.mode?"horizontal":"vertical")}minimize(){const e=this;if(e._minimized||"dropDown"===e.mode)return;e.$minimizedHeader.removeClass("smart-hidden");const t=null!==e.dropDownAppendTo,n=e.animation,o=e.hasAnimation;if(o&&(e.animation="none"),e._positionDetection.removeOverlay(),e._closeSubContainers(2),o&&t&&(e.animation=n),"tree"!==e.mode&&(t&&e._moveDropDownsToMenu(),e._removeContainerFixedHeight()),e._hideMainContainerScrollButtons(),e.$mainContainer.removeClass("smart-menu-main-container"),e.$mainContainer.addClass("smart-visibility-hidden"),e.enableShadowDOM&&e.$.mainContainer.removeAttribute("id"),e._edgeMacFF&&(e.$.mainContainer.style.left="",e.$.mainContainer.style.top="",e.$mainContainer.addClass("not-in-view")),e.$hamburgerIcon.removeClass("smart-hidden"),t&&e._appendMinimizedContainerToExternalElement(e.$.mainContainer),setTimeout((function(){e.$mainContainer.addClass("smart-menu-minimized-items-container"),o&&!t&&(e.animation=n)}),0),e._minimized=!0,e.setAttribute("minimized",""),"tree"!==e.mode)for(let t=0;t<e._containers.length;t++){const n=e._containers[t];n.level>2&&e._setArrowDirection(n.menuItemsGroup.children[0].children[1],n.level)}e.$.mainContainer.setAttribute("drop-down",""),e.setAttribute("role","presentation"),e.removeAttribute("aria-orientation"),e.$.hamburgerIcon.setAttribute("aria-expanded",!1),e.$.hamburgerIcon.setAttribute("aria-owns",e.$.mainContainer.id),e.$.mainContainer.setAttribute("role","menu"),e.$.mainContainer.setAttribute("aria-orientation","vertical")}open(e,t){const n=this;if("dropDown"!==n.mode)return;if(n.$.fireEvent("opening").defaultPrevented)return void(n.opened=!1);let o;if(n.opened=!0,n._positionRelativeTo){const i=n._positionRelativeTo.getBoundingClientRect();e+=i.left,t+=i.top,n._positionedParent?(o=n._positionedParent.getBoundingClientRect(),e-=o.left,t-=o.top):(e+=window.pageXOffset,t+=window.pageYOffset)}let i=e+n.offsetWidth-document.documentElement.clientWidth,r=t+n.offsetHeight-document.documentElement.clientHeight;o?(i+=o.left,r+=o.top):(i-=window.pageXOffset,r-=window.pageYOffset),i>0?e-=i:e=o?Math.max(e,-o.left):Math.max(e,window.pageXOffset),r>0?t-=r:t=o?Math.max(t,-o.top):Math.max(t,window.pageYOffset),n.style.right="",isNaN(e)||(n.rightToLeft&&(n.style.right="initial"),n.style.left=e+"px"),isNaN(t)||(n.style.top=t+"px"),n.$.removeClass("smart-visibility-hidden"),n.$.fireEvent("open"),n.hasAnimation||(n._checkOverflowOnOpen&&(n._checkOverflow(n.$.mainContainer,!1,[n.$.scrollButtonNear,n.$.scrollButtonFar]),delete n._checkOverflowOnOpen),n._noAutoFocus||n.focus())}removeItem(e){const t=this;if(void 0===(e=t.getItem(e)))return;const n=e.parentElement,o=e.parentItem||t;if(e instanceof Smart.MenuItemsGroup){const n=e.container;if(t._isContainerOpened(n.level,n)&&t._closeSubContainers(n.level,n),1===e.level){const e=t._containersInBody.indexOf(n);-1!==e&&(t._containersInBody.splice(e,1),null===t.dropDownAppendTo||"tree"===t.mode||t._minimized||t._dropDownParent.removeChild(n))}}n.removeChild(e),t._refreshContainersArrays(),t._menuItems={},t._refreshItemPaths(t.$.mainContainer,!0),t._checkOverflowAddRemove(e.level,n),t._refreshCheckableItems(o)}uncheckItem(e){void 0===(e=this.getItem(e))||!e.checked||e.disabled||e.templateApplied||this._toggleItem(e)}propertyChangedHandler(e,t,n){super.propertyChangedHandler(e,t,n);const o=this;if("tree"!==o._element)switch(e){case"animation":o.$.mainContainer.setAttribute("animation",n),o._additionalScrollButtons.forEach((function(e){e[0].animation=n,e[1].animation=n})),null!==o._dropDownParent&&o._containers.forEach((function(e){e.setAttribute("animation",n)}));break;case"checkable":"tree"===o.mode||o._minimized?o._minimized&&null!==o.dropDownAppendTo&&r("checkable",o.$.mainContainer,n):o._closeSubContainers(2),o._updateItemRoles(o);break;case"checkboxes":if(o._close(),null!==o.dropDownAppendTo){for(let e=0;e<o._containers.length;e++)r("checkboxes",o._containers[e],n);o._minimized&&r("checkboxes",o.$.mainContainer,n)}o._updateItemRoles();break;case"checkMode":o._changeToRadioButtonMode(n,o.$.mainContainer),o._minimized&&null!==o.dropDownAppendTo&&o.$.mainContainer.setAttribute("check-mode",n),o._updateItemRoles(o);break;case"dataSource":{let e=!1;o._minimized&&(o.maximize(),e=!0),o._removeContainersInBody(),o._containersInBody=[],o._menuItems={},o._processDataSource(),o._checkContainersLength(),e?o.minimize():i(),o._expandItemsByDefault(),o._refreshCheckableItems(),o._suppressResizeHandler=!0,setTimeout((()=>delete o._suppressResizeHandler),500);break}case"innerHTML":o.$.mainContainer.innerHTML=n,o._lazyInitItems();break;case"dropDownAppendTo":{const e=o._dropDownParent;if(o._positionDetection.getDropDownParent(),o._dropDownParent===e||"tree"===o.mode&&!o._minimized)return;if(o._close(),o._minimized)return void(null===n?o._appendMinimizedContainerToMenu(o.$.mainContainer,o.$.scrollButtonFar):o._appendMinimizedContainerToExternalElement(o.$.mainContainer));if(null!==o._dropDownParent&&null===e)o._moveDropDownsToExternalContainer();else if(null===o._dropDownParent&&null!==e)o._moveDropDownsToMenu();else if(null!==o._dropDownParent&&null!==e)for(let e=0;e<o._containersInBody.length;e++)o._dropDownParent.appendChild(o._containersInBody[e]);null!==n||o.$mainContainer.hasClass("simple")?o._checkOverflow(o.$.mainContainer,"horizontal"===o.mode,[o.$.scrollButtonNear,o.$.scrollButtonFar]):o._hideMainContainerScrollButtons();for(let e=0;e<o._containersFixedHeight.length;e++)o._containersFixedHeight[e].itemContainer.checkOverflow=!0;"dropDown"===o.mode&&(o.close({trigger:"internal"}),o._reparentMenu(!0,e));break}case"dropDownOverlay":n||o._positionDetection.removeOverlay();break;case"disabled":n&&o._close(),o._setFocusable(),o.$.scrollButtonNear.disabled=n,o.$.scrollButtonFar.disabled=n,n||null===o.dropDownAppendTo&&!o.$mainContainer.hasClass("simple")&&"tree"!==o.mode||o._updateScrollButtonVisibility(o.$.mainContainer,"horizontal"===o.mode,[o.$.scrollButtonNear,o.$.scrollButtonFar]);break;case"dropDownPosition":case"mode":{if("mode"===e){if(delete o._dynamicallyReparented,"tree"===t||o._minimized?(o._closeSubContainersTreeMode(2,void 0,void 0,void 0,!0),o._openedContainers=[]):o._closeSubContainersDefaultMode(2),o._discardKeyboardHover(!0),o._minimized&&o._minimizedDropDownOpened&&(o.$mainContainer.addClass("smart-visibility-hidden"),o.$hamburgerIcon.removeClass("smart-close-button"),o.$.hamburgerIcon.setAttribute("aria-expanded",!1),o._minimizedDropDownOpened=!1),"horizontal"!==n&&"horizontal"!==t||o._changeScrollButtonsArrows(),o._minimized)return void("dropDown"===n&&(o.mode=t));o.setAttribute("aria-orientation","horizontal"===o.mode?"horizontal":"vertical"),!1===o.opened&&("dropDown"===n?o.$.addClass("smart-visibility-hidden"):"dropDown"===t&&o.$.removeClass("smart-visibility-hidden")),"tree"===t?(null!==o.dropDownAppendTo&&o._moveDropDownsToExternalContainer(),o.$mainContainer.addClass("smart-menu-main-container"),o.$mainContainer.removeClass("smart-menu-minimized-items-container"),o._applyContainerFixedHeight()):"tree"===n&&(null!==o.dropDownAppendTo&&o._moveDropDownsToMenu(),o._applyTreeMode()),"auto"===o.overflow&&o._hideMainContainerScrollButtons(),i()}if("tree"===o.mode||o._minimized)return o._minimizedDropDownOpened&&o._close(),void(o._minimized&&null!==o.dropDownAppendTo&&o.$.mainContainer.setAttribute(o.properties[e].attributeName,n));"dropDownPosition"===e&&o._close();const r=o._containers.map((e=>e.menuItemsGroup));for(let e=0;e<r.length;e++){const t=r[e];o._setArrowDirection(t.children[0].children[1],t.level+1)}if(null!==o.dropDownAppendTo)for(let t=0;t<o._containers.length;t++){const i=o._containers[t];i.setAttribute(Smart.Utilities.Core.toDash(e),n),i.level>2&&o._setArrowDirection(i.menuItemsGroup.children[0].children[1],i.level)}break}case"minimizeIconTemplate":o._applyMinimizeIconTemplate(n,t);break;case"minimizeWidth":o._resizeHandler();break;case"opened":n?o.open():o.close({trigger:"internal"});break;case"overflow":o._handleOverflowChange();break;case"rightToLeft":if("tree"!==o.mode){const e=o._containers.map((e=>e.menuItemsGroup));for(let t=0;t<e.length;t++){const n=e[t];o._setArrowDirection(n.children[0].children[1],n.level+1)}if(null!==o.dropDownAppendTo){n?o.$.mainContainer.setAttribute("right-to-left",""):o.$.mainContainer.removeAttribute("right-to-left");for(let e=0;e<o._containers.length;e++){const t=o._containers[e];n?t.setAttribute("right-to-left",""):t.removeAttribute("right-to-left"),t.level>2&&o._setArrowDirection(t.menuItemsGroup.children[0].children[1],t.level)}}}break;case"theme":if(null===o.dropDownAppendTo||Smart.ListMenu&&o instanceof Smart.ListMenu)return;if(o._minimized)""!==t&&o.$mainContainer.removeClass(t),""!==n&&o.$mainContainer.addClass(n);else for(let e=0;e<o._containers.length;e++){const i=o._containers[e];""!==t&&i.classList.remove(t),""!==n&&i.classList.add(n)}break;case"unfocusable":o._setFocusable()}function i(){null===o.dropDownAppendTo&&"tree"!==o.mode||o._checkOverflow(o.$.mainContainer,"horizontal"===o.mode,[o.$.scrollButtonNear,o.$.scrollButtonFar])}function r(e,t,n){n?t.setAttribute(e,""):t.removeAttribute(e)}}_addOpenedContainer(e,t){const n=this;if("tree"===n.mode||n._minimized){n._openedContainers[e]||(n._openedContainers[e]=[]);const o=t.menuItemsGroup;return o.set("expanded",!0),o.setAttribute("aria-expanded",!0),n._updateState&&n._updateState("expanded",o.id,!0),n._openedContainers[e].push(t)}n._openedContainers[e]=t}_appendMinimizedContainerToExternalElement(e){const t=this;e.ownerElement=t,t._dropDownParent.appendChild(e),e.setAttribute("animation",t.animation),""!==t.theme&&e.$.addClass(t.theme),e.$.addClass("smart-menu-drop-down smart-drop-down"),e.$.addClass("smart-drop-down-repositioned"),e.setAttribute("check-mode",t.checkMode),e.setAttribute("drop-down-position",t.dropDownPosition),e.setAttribute("mode",t.mode),e.setAttribute("loading-indicator-position",t.loadingIndicatorPosition),t.rightToLeft&&e.setAttribute("right-to-left",""),t.checkable&&e.setAttribute("checkable",""),t.checkboxes&&e.setAttribute("checkboxes",""),t.$.view&&t.detachedChildren.indexOf(t.$.view)&&t.detachedChildren.push(t.$.view)}_appendMinimizedContainerToMenu(e,t){const n=this;delete e.ownerElement,n.$.container.insertBefore(e,t),e.removeAttribute("animation"),""!==n.theme&&e.$.removeClass(n.theme),e.$.removeClass("smart-menu-drop-down smart-drop-down"),e.$.removeClass("smart-drop-down-repositioned"),e.removeAttribute("checkable"),e.removeAttribute("checkboxes"),e.removeAttribute("check-mode"),e.removeAttribute("drop-down-position"),e.removeAttribute("mode"),e.removeAttribute("loading-indicator-position"),e.removeAttribute("style"),e.removeAttribute("right-to-left")}_applyContainerFixedHeight(){const e=this;for(let t=0;t<e._containers.length;t++){const n=e._containers[t];-1!==e._containersFixedHeight.indexOf(n)?(n.style.height=n.menuItemsGroup.dropDownHeight+"px",n.itemContainer.checkOverflow=!0):n.style.height=""}}_applyGrouping(e,t){const n=this;let o;o=e===n.$.mainContainer?Array.from(e.children):Array.from(e.container.firstElementChild.children);for(let e=0;e<o.length;e++){const i=o[e];i.originalIndex=e,i instanceof Smart.MenuItemsGroup&&void 0===t&&n._applyGrouping(i)}n._sortItems(e)}_applyMinimizeIconTemplate(e,t){const n=this;if(null===e){if(null===t)return;n.$customIconContainer.addClass("smart-hidden"),n.$.customIconContainer.innerHTML="",n.$hamburgerIconLineTop.removeClass("smart-hidden"),n.$hamburgerIconLineCenter.removeClass("smart-hidden"),n.$hamburgerIconLineBottom.removeClass("smart-hidden")}else{const o=document.getElementById(e);if(null!==o&&"template"===o.tagName.toLowerCase()){const e=document.importNode(o.content,!0);n.$hamburgerIconLineTop.addClass("smart-hidden"),n.$hamburgerIconLineCenter.addClass("smart-hidden"),n.$hamburgerIconLineBottom.addClass("smart-hidden"),n.$.customIconContainer.innerHTML="",n.$.customIconContainer.appendChild(e),n.$customIconContainer.removeClass("smart-hidden")}else n.minimizeIconTemplate=t}}_applyTreeMode(){const e=this,t=e.$.mainContainer.getElementsByClassName("smart-menu-items-group-arrow");if(e.$mainContainer.removeClass("smart-menu-main-container"),e.$mainContainer.addClass("smart-menu-minimized-items-container"),e.isCompleted&&e.isRendered)for(let e=0;e<t.length;e++)t[e].className="smart-menu-items-group-arrow down";e._removeContainerFixedHeight()}_arrowLeftHandler(e,t,n,o){const i=this;1===e?"horizontal"===t&&i._levelOneNavigate("_getLastEnabledChild",n,o):2===e?i._levelOneNavigateFromLowerLevel("_getPreviousEnabledChild",n):i._escapeHandler(n,e,o)}_arrowRightHandler(e,t,n,o){const i=this;1===e?"horizontal"===t?i._levelOneNavigate("_getFirstEnabledChild",n,o):i._levelOneOpenDropDown(n):n instanceof Smart.MenuItemsGroup?i._selectionHandler({target:n,isTrusted:!0}):i._levelOneNavigateFromLowerLevel("_getNextEnabledChild",n)}_browserBoundsDetection(e){const t=this;if("tree"===t.mode&&!t._minimized)return;if(e.style.marginTop="",e.style.marginLeft="","auto"!==t.dropDownPosition)return;const n=1===window.devicePixelRatio?document.documentElement.clientWidth:window.innerWidth,o=1===window.devicePixelRatio?document.documentElement.clientHeight:window.innerHeight,i=e.getBoundingClientRect(),r=n-i.left-e.offsetWidth,a=o-i.top-e.offsetHeight;r<10&&(e.style.marginLeft=Math.min(r-10,-10)+"px"),a<10&&(e.style.marginTop=Math.min(a-10,-10)+"px")}_changeScrollButtonsArrows(){const e=this;"horizontal"===e.mode?(e.$.scrollButtonNear.setAttribute("aria-label","Scroll left"),e.$.scrollButtonFar.setAttribute("aria-label","Scroll right"),e.$arrowNear.removeClass("smart-arrow-up"),e.$arrowFar.removeClass("smart-arrow-down"),e.$arrowNear.addClass("smart-arrow-left"),e.$arrowFar.addClass("smart-arrow-right")):(e.$.scrollButtonNear.setAttribute("aria-label","Scroll up"),e.$.scrollButtonFar.setAttribute("aria-label","Scroll down"),e.$arrowNear.removeClass("smart-arrow-left"),e.$arrowFar.removeClass("smart-arrow-right"),e.$arrowNear.addClass("smart-arrow-up"),e.$arrowFar.addClass("smart-arrow-down"))}_changeToRadioButtonMode(e,t,n){if("radioButton"===e){const e=[];for(let n=0;n<t.childElementCount;n++){const o=t.children[n];!o.checked||o.disabled||o.templateApplied||e.push(o)}this._validateRadioButtonSelection(n,n?n.level+1:1,e)}}_checkContainersLength(e){const t=this;0===t._containers.length?(t.$mainContainer.addClass("simple"),e||t._checkOverflow(t.$.mainContainer,"horizontal"===t.mode,[t.$.scrollButtonNear,t.$.scrollButtonFar])):e||(t.$mainContainer.removeClass("simple"),null===t.dropDownAppendTo&&"tree"!==t.mode&&t.$mainContainer.removeClass("scroll-buttons-shown one-button-shown"))}_checkOverflow(e,t,n){const o=this,i=o.$.mainContainer,r=e===i?o.overflow:"auto";if(o._minimized||"hidden"===r||null===o.dropDownAppendTo&&"tree"!==o.mode&&e===i&&!i.classList.contains("simple"))return;if("dropDown"===o.mode&&!o.opened)return void(o._checkOverflowOnOpen=!0);const a=e.scrollLeft,s=a/(e.scrollWidth-e.offsetWidth),l=e.scrollTop,d=l/(e.scrollHeight-e.offsetHeight);let m,c,u;"auto"===r&&(e.classList.remove("scroll-buttons-shown"),e.classList.remove("one-button-shown"),n[0].$.addClass("smart-hidden"),n[1].$.addClass("smart-hidden")),t?(m=Math.round(e.scrollWidth)>Math.round(e.offsetWidth),c=s>0,u=s<1):(m=Math.round(e.scrollHeight)>Math.round(e.offsetHeight),c=d>0,u=d<1),m?"auto"===r?(e.classList.add("scroll-buttons-shown"),c&&n[0].$.removeClass("smart-hidden"),u&&n[1].$.removeClass("smart-hidden"),!1===(c&&u)&&e.classList.add("one-button-shown"),o.disabled||(n[0].disabled=!1,n[1].disabled=!1),e.scrollLeft=a,e.scrollTop=l):(n[0].$.removeClass("smart-hidden"),n[1].$.removeClass("smart-hidden"),o.disabled?(n[0].disabled=!0,n[1].disabled=!0):(n[0].disabled=!c,n[1].disabled=!u)):"scroll"===r&&(n[0].disabled=!0,n[1].disabled=!0),e===i&&"tree"!==o.mode&&o._close(),o._scrollInfo.set(e,{left:e.scrollLeft,top:e.scrollTop})}_checkOverflowAddRemove(e,t){const n=this;1===e&&null!==n.dropDownAppendTo||"tree"===n.mode?n._checkOverflow(n.$.mainContainer,"horizontal"===n.mode,[n.$.scrollButtonNear,n.$.scrollButtonFar]):e>1&&t.dropDownHeightSet&&(n._isContainerOpened(e,t.container)?n._checkOverflow(t,!1,[t.container.children[0],t.container.children[2]]):t.checkOverflow=!0)}_close(){const e=this;e._positionDetection.removeOverlay(),e._closeSubContainers(2),e._discardKeyboardHover(!0),e._minimized&&e._minimizedDropDownOpened&&(e.$mainContainer.addClass("smart-visibility-hidden"),e._edgeMacFF&&(e.$.mainContainer.style.left="",e.$.mainContainer.style.top="",e.$mainContainer.addClass("not-in-view")),e.$hamburgerIcon.removeClass("smart-close-button"),e.$.hamburgerIcon.setAttribute("aria-expanded",!1),e._minimizedDropDownOpened=!1)}_closeSubContainers(e,t,n,o){const i=this;"tree"===i.mode||i._minimized?i._closeSubContainersTreeMode(e,t,n,o):i._closeSubContainersDefaultMode(e,t,n)}_closeSubContainersDefaultMode(e,t,n){const o=this,i=o._openedContainers;function r(t){const r=i[t].menuItemsGroup;n&&t===e||(r.$.removeClass("focus"),r.removeAttribute("focus"),r.$.removeClass("hover"),r.removeAttribute("hover")),r.$.removeClass("smart-menu-items-group-opened"),r.$.removeClass("smart-menu-items-group-expanded"),r.setAttribute("aria-expanded",!1),i[t].$.addClass("smart-visibility-hidden"),o._edgeMacFF&&2===t&&!o.hasAnimation&&(i[t].style.left="",i[t].style.top="",i[t].$.addClass("not-in-view")),o._minimized&&o._browserBoundsDetection(o.$.mainContainer),o.$.fireEvent("collapse",{item:r,label:r.label,path:r.path,value:r.value,children:r.itemContainer.children}),i[t]=void 0}for(let t=i.length-1;t>=e;t--)void 0!==i[t]&&r(t)}_closeSubContainersTreeMode(e,t,n,o,i){const r=this;if(o){const e=t.menuItemsGroup;if(r.$.fireEvent("collapsing",{item:e,label:e.label,path:e.path,value:e.value,children:t.itemContainer.children}).defaultPrevented)return}if(void 0===t)return void r._collapseAll(!1,i);const a=t.menuItemsGroup;if(a.set("expanded",!1),a.setAttribute("aria-expanded",!1),"menu"===r._element)if(n){const e=r.$.mainContainer.getElementsByClassName("focus")[0];e&&(e.$.removeClass("focus"),e.removeAttribute("focus")),a.$.addClass("focus"),a.setAttribute("focus",""),r._focusedViaKeyboard=a}else a.$.removeClass("focus"),a.removeAttribute("focus");else r._updateState("expanded",a.id,!1);if(a.$.removeClass("smart-"+r._element+"-items-group-opened"),i||!r.hasAnimation?(a.$.removeClass("smart-"+r._element+"-items-group-expanded"),a.setAttribute("aria-expanded",!1),t.$.addClass("smart-visibility-hidden"),r._minimized&&r._browserBoundsDetection(r.$.mainContainer)):r._collapseSection(t),o){const e={item:a,label:a.label,path:a.path,value:a.value,children:a.itemContainer.children};r.toggleCallback?(e.type="collapse",r.toggleCallback(e)):r.$.fireEvent("collapse",e)}if(!r._openedContainers[e])return;const s=r._openedContainers[e].indexOf(t);-1!==s&&r._openedContainers[e].splice(s,1)}_collapseAll(e,t){const n=this;for(let o=n._openedContainers.length-1;o>=2&&void 0!==n._openedContainers[o];o--)for(let i=n._openedContainers[o].length-1;i>=0;i--)n._closeSubContainersTreeMode(o,n._openedContainers[o][i],void 0,e,t);n.hasAnimation||n._checkOverflow(n.$.mainContainer,!1,[n.$.scrollButtonNear,n.$.scrollButtonFar]);for(let e=n._openedContainers.length-1;e>=2;e--){const t=n._openedContainers[e];if(void 0!==t&&0!==t.length)break;n._openedContainers.splice(e,1)}2===n._openedContainers.length&&(n._openedContainers=[])}_collapseSection(e){const t=this,n=e.scrollHeight+"px";t._treeAnimationInProgress=e,e.style.transition="none",requestAnimationFrame((function(){"tree"===t.mode||t._minimized?(e.style.height=n,e.style.transition="",requestAnimationFrame((function(){e.style.height="0px","smart-tree"===t.tagName.toLowerCase()&&e.$.addClass("smart-visibility-hidden"),"0px"===n&&t._transitionendHandlerCollapse(t,e)}))):e.style.transition=""})),e.addEventListener("transitionend",t._transitionendHandlerCollapse)}_createElement(){const e=this,t=e.mode;e.setAttribute("role","menu"),e.$.mainContainer.id=e.id+"MainContainer",e.setAttribute("aria-orientation","horizontal"===e.mode?"horizontal":"vertical"),e._positionDetection=new Smart.Utilities.PositionDetection(e),e._positionDetection.getDropDownParent(),e._reparentMenu(),e.disabled&&(e.$.scrollButtonNear.disabled=!0,e.$.scrollButtonFar.disabled=!0),null===e.dataSource&&e.$.mainContainer.firstElementChild instanceof HTMLUListElement&&e._processUList();const n=(e.shadowRoot||e).querySelectorAll("smart-menu-item, smart-menu-items-group"),o=function(){const n=e.animation;e._changeScrollButtonsArrows(),e._setFocusable(),"dropDown"===t&&!1===e.opened&&(e.hasAnimation?(e.animation="none",e.$.addClass("smart-visibility-hidden"),e.animation=n):e.$.addClass("smart-visibility-hidden")),e._menuItems={},e.$.mainContainer.setAttribute("animation",n),null===e.dataSource?e._processHTML(e.$.mainContainer,1):e._processDataSource(),e._checkContainersLength(!0),null===e.dropDownAppendTo&&!e.$mainContainer.hasClass("simple")&&"tree"!==e.mode||"scroll"!==e.overflow||(e.$mainContainer.addClass("scroll-buttons-shown"),e.$scrollButtonNear.removeClass("smart-hidden"),e.$scrollButtonFar.removeClass("smart-hidden"),e._updateScrollButtonVisibility(e.$.mainContainer,"horizontal"===t,[e.$.scrollButtonNear,e.$.scrollButtonFar])),e._applyMinimizeIconTemplate(e.minimizeIconTemplate,null),"tree"===t&&e._applyTreeMode(),null!==e.minimizeWidth&&e.offsetWidth<=e.minimizeWidth?e.minimize():e._checkOverflow(e.$.mainContainer,"horizontal"===t,[e.$.scrollButtonNear,e.$.scrollButtonFar]),e._expandItemsByDefault(),e._refreshCheckableItems(),e.__onCompleted&&(e._onCompleted=e.__onCompleted,e.__onCompleted=null,e._onCompleted())};0===n.length||e.enableShadowDOM||e.isInShadowDOM?o():(e._onCompleted&&(e.__onCompleted=e._onCompleted,e._onCompleted=null),e._ensureItemsReady(n,o))}_ensureItemsReady(e,t){const n=this,o=function(){const n=function(t){for(let n=0;n<e.length;n++)e[n].context="node"===t?e[n]:document};n("node"),t(),n()};if(0===e.length)o();else{n._nodesReadyListeners=0;for(let t=0;t<e.length;t++){const i=e[t],r=function(){const e=n.context;n.context=n,n._nodesReadyListeners--,0===n._nodesReadyListeners&&(o(),delete n._nodesReadyListeners),n.context=e}.bind(n);i.isCompleted||(n._nodesReadyListeners++,i.completeHandlers=[],i._onCompleted=r)}0===n._nodesReadyListeners&&o()}}_createItemHTMLStructure(e,t,n,o){const i=this,r="smart-"+i._element+"-item-label-container",a="smart-"+i._element+"-item-label-element",s=document.createDocumentFragment(),l=e.children;let d,m,c,u;for(let e=0;e<l.length;e++){const t=l[e];if(t.classList&&(t.classList&&t.classList.contains(r)?d=t:t.classList&&t.classList.contains(a)&&(m=t),d&&m))break}if(d){const t=d.querySelector("."+a);if(null!==t){e.insertBefore(t.firstElementChild,e.children[0]);const n="smart-"+i._element+"-drop-down",o="smart-"+i._element+"-item-container",r=e.querySelector("."+n);if(r){const t=e.querySelector("."+o);for(;t.childNodes.length;)e.appendChild(t.firstChild);r.remove()}}d.remove()}m&&m.remove(),d=document.createElement("div"),m=document.createElement("div");let p=document.createElement("span");e.menu=i,t>1?(e.originalIndex=o,c=n.path+"."+e.originalIndex,e.parentItem=n,u=n):(e.originalIndex=o,c=""+o,u=i),i.checkboxes&&u.checkable&&("checkbox"===u.checkMode?e.setAttribute("role","menuitemcheckbox"):"radioButton"===u.checkMode&&e.setAttribute("role","menuitemradio")),e.path=c,i._menuItems[c]=e,d.className=r,m.className=a,"tree"===i._element&&i._setIndentation(d,t,i.rightToLeft?"paddingRight":"paddingLeft");const h=Array.from(e.childNodes);for(let e=0;e<h.length;e++){const t=h[e];if(t instanceof Smart.MenuItem||t instanceof Smart.MenuItemsGroup)break;p.appendChild(t)}if(""===p.innerHTML.trim()){const t=e.label||e.getAttribute("label");t&&""!==t?i._setLabel(t,p,e,!0):(e.set("label","Item "+o),p.innerHTML="Item "+o)}else e.set("label",p.innerHTML.trim());if(e.setAttribute("aria-label",e.label),e instanceof Smart.MenuItemsGroup&&void 0===e.titleLabel&&(e.titleLabel=e.label),m.appendChild(p),s.appendChild(m),e.set("level",t),e.set("shortcut",e.shortcut||e.getAttribute("shortcut")||""),e.shortcut&&e instanceof Smart.MenuItem){const t=document.createElement("div");t.id=e.id+"Shortcut",t.className="smart-"+i._element+"-item-shortcut",t.innerHTML=e.shortcut,s.appendChild(t),e.setAttribute("aria-describedby",t.id)}d.appendChild(s),e.insertBefore(d,e.children[0]),e.id||(e.id=i.id+"ItemP"+e.path.replace(/\./g,"_")+"L"+e.label.replace(/[^a-zA-Z0-9\-\_]/g,""))}_createMenuItemsGroupContainer(e,t){const n=this,o=e.children,i="smart-"+n._element+"-drop-down",r="smart-"+n._element+"-item-container";let a,s;for(let e=0;e<o.length;e++){const t=o[e];if(t.classList&&(t.classList&&t.classList.contains(i)?a=t:t.classList&&t.classList.contains(r)&&(s=t),a&&s))break}if(a||(a=document.createElement("div")),s||(s=document.createElement("div")),a.innerHTML=s.innerHTML="",a.id=e.id+"Container",a.className="smart-"+n._element+"-drop-down smart-visibility-hidden",n._edgeMacFF&&2===t&&"tree"!==n.mode&&(a.className+=" not-in-view"),a.$||(a.$=Smart.Utilities.Extend(a)),a.level=t,a.setAttribute("level",t),"menu"===n._element?(e.setAttribute("aria-owns",a.id),a.setAttribute("role","menu")):a.setAttribute("role","group"),a.menuItemsGroup=e,s.className=r,s.$||(s.$=Smart.Utilities.Extend(s)),s.container=a,s.menuItemsGroup=e,e.checkable&&s.setAttribute("checkable",""),s.setAttribute("check-mode",e.checkMode),s.setAttribute("role","presentation"),a.itemContainer=s,a.contains(s)||a.appendChild(s),null!==e.dropDownHeight){let t=a.querySelector(".smart-spin-button.smart-scroll-button-near"),o=a.querySelector(".smart-spin-button.smart-scroll-button-far");t||(t=document.createElement("smart-repeat-button")),o||(o=document.createElement("smart-repeat-button")),t.className="smart-menu-scroll-button smart-spin-button smart-scroll-button-near smart-hidden",t.setAttribute("aria-label","Scroll up"),t.innerHTML='<div class="smart-arrow smart-arrow-up" aria-hidden="true"></div>',t.animation=n.animation,t.unfocusable=!0,t.rightToLeft=n.rightToLeft,o.className="smart-menu-scroll-button smart-spin-button smart-scroll-button-far smart-hidden",o.setAttribute("aria-label","Scroll down"),o.innerHTML='<div class="smart-arrow smart-arrow-down" aria-hidden="true"></div>',o.animation=n.animation,o.unfocusable=!0,o.rightToLeft=n.rightToLeft,a.contains(t)||a.insertBefore(t,s),a.contains(o)||a.appendChild(o),a.$.addClass("drop-down-height-set"),s.dropDownHeightSet=!0,s.checkOverflow=!0,a.style.height=e.dropDownHeight+"px",n._containersFixedHeight.push(a),n._additionalScrollButtons.push([t,o])}return a}_discardKeyboardHover(e){const t=this;t._focusedViaKeyboard&&(!e&&t._focusedViaKeyboard instanceof Smart.MenuItemsGroup&&t._isContainerOpened(t._focusedViaKeyboard.level+1,t._focusedViaKeyboard.container)||(t._focusedViaKeyboard.$.removeClass("focus"),t._focusedViaKeyboard.removeAttribute("focus"),t._focusedViaKeyboard.$.removeClass("hover"),t._focusedViaKeyboard.removeAttribute("hover"),t._focusedViaKeyboard=void 0))}_documentDownHandler(e){const t=this;"down"===t.closeAction&&t._closeOnDocumentInteraction(e.originalEvent)}_documentUpHandler(e){const t=this,n=e.originalEvent.target;if(t.disabled||t.displayLoadingIndicator||!n.closest)return;const o="up"===t.closeAction&&t._closeOnDocumentInteraction(e.originalEvent);if(o)return;let i,r;if(t.isInShadowDOM?(i=t.isInShadowDOM?t.getRootNode().activeElement:t.shadowRoot&&t.shadowRoot.activeElement||document.activeElement,r=t.$.container.contains(e.originalEvent.composedPath()[0])):(i=document.activeElement,r=t.contains(n)),!o&&t!==i&&null===i.closest("[template-applied]")){if(r||n.closest(".smart-list-menu-view")===t.$.view)return void t.focus();const e=n.closest(".smart-drop-down-repositioned");e&&e.ownerElement===t&&t.focus()}}_closeOnDocumentInteraction(e){const t=this,n=e.target;let o,i;if(t.isInShadowDOM?(o=e.composedPath()[0],i=t.$.container.contains(o)):i=t.contains(n),"dropDown"===t.mode&&t.opened){const e=n.closest(".smart-drop-down-repositioned");if(!(i||e&&e.ownerElement===t))return t.close({trigger:"interaction",target:t.isInShadowDOM?o:n}),!0}const r=(o||n).closest(".smart-input-drop-down-menu");return(!r||!t.contains(r.ownerElement))&&(!i&&null===n.closest(".smart-menu-drop-down")||o&&o===t.$.mainContainer||n===t.$.mainContainer?("tree"===t.mode||t._close(),!0):void 0)}_ensureVisible(e){const t=this;if(t._minimized)return;const n=t.mode,o=t.$.mainContainer;let i,r;if("tree"!==n&&e.parentElement!==o){if(null===e.dropDownHeight)return;i=e.parentElement,r=[i.container.children[0],i.container.children[2]]}else i=o,r=[t.$.scrollButtonNear,t.$.scrollButtonFar];if(i===o&&(null===t.dropDownAppendTo&&"tree"!==t.mode&&!o.classList.contains("simple")||!i.$.hasClass("scroll-buttons-shown")&&"hidden"!==t.overflow))return;const a=i.getBoundingClientRect(),s=e.getBoundingClientRect();function l(t,n,o){let r=e.firstElementChild[o]+t-i[o];r<0&&(r=t),i["scroll"+n]=r}function d(n,a){let s=e["offset"+n],d=i[a];"Top"!==n||i===o||r[0].$.hasClass("smart-hidden")||(s-=r[0][a]),l(s,n,a),t._updateScrollButtonVisibility(i,"Left"===n,r),d!==i[a]&&l(s,n,a)}"tree"!==n?(i===o&&"horizontal"===n&&(a.left>s.left||a.right<s.right)?d("Left","offsetWidth"):(a.top>s.top||a.bottom<s.bottom)&&d("Top","offsetHeight"),t._scrollInfo.set(i,{left:i.scrollLeft,top:i.scrollTop})):t._ensureVisibleTreeMode(e,s,i,a,0)}_ensureVisibleTreeMode(e,t,n,o,i){const r=this;if(("menu"===r._element||"scrollButtons"===r.scrollMode)&&!n.$.hasClass("scroll-buttons-shown")&&"hidden"!==r.overflow)return;const a=n.offsetHeight,s=r.$scrollButtonNear.hasClass("smart-hidden");let l;if(o.top>t.top)l=r._getOffsetTop(e);else{let n=e.expanded?e.firstElementChild.offsetHeight+parseInt(window.getComputedStyle(e.children[1]).marginTop,10):e.offsetHeight;if("tree"===r._element&&(n+=parseFloat(getComputedStyle(r).getPropertyValue("--smart-tree-item-vertical-offset"))||0),!(o.bottom<t.top+n))return;l=r._getOffsetTop(e)-a+n+i}"tree"===r._element&&"0"===e.path&&(l-=parseFloat(getComputedStyle(r).getPropertyValue("--smart-tree-item-vertical-offset"))),n.scrollTop=l,"menu"!==r._element&&"scrollButtons"!==r.scrollMode||r._updateScrollButtonVisibility(n,!1,[r.$.scrollButtonNear,r.$.scrollButtonFar]),"auto"===r.overflow&&s&&!r.$scrollButtonNear.hasClass("smart-hidden")&&(n.scrollTop+=a-n.offsetHeight),r._scrollInfo.set(n,{left:n.scrollLeft,top:n.scrollTop})}_escapeHandler(e,t,n){e&&(e.$.removeClass("focus"),e.removeAttribute("focus")),this._closeSubContainers(t,void 0,void 0,!0),this._hoverViaKeyboard(n.menuItemsGroup)}_expandItemsByDefault(e){const t=this;if(0===t._menuItemsGroupsToExpand.length&&!e||"tree"!==t.mode&&!t._minimized)return;const n=t.hasAnimation,o=t.animation;n&&(t.animation="none"),e&&t._collapseAll(!1);for(let e=0;e<t._menuItemsGroupsToExpand.length;e++)t.expandItem(t._menuItemsGroupsToExpand[e].path,void 0,!1);n&&(t.animation=o),t._menuItemsGroupsToExpand=[]}_expandSection(e){const t=this,n=e.style.height,o=e.scrollHeight+"px";e.style.height=o,t._treeAnimationInProgress=e,n!==o&&(parseFloat(n)||parseFloat(o))?e.addEventListener("transitionend",t._transitionendHandlerExpand):t._transitionendHandlerExpand(t,e)}_filterInputKeyupHandler(){const e=this;e._filterTimer&&clearTimeout(e._filterTimer),e._filterTimer=setTimeout((function(){const t=e.context;e.context=e,e._applyFilter(e.$.filterInput.value,e._view),e._checkOverflow(),e.context=t}),300)}_findItem(e,t){if(""===t)return e;const n=e[this.filterMember||"label"];if("string"!=typeof n)return null;switch(this.filterMode){case"startsWith":if(0===n.indexOf(t))return e;break;case"startsWithIgnoreCase":if(0===n.toLowerCase().indexOf(t.toLowerCase()))return e;break;case"doesNotContain":if(n.indexOf(t)<0)return e;break;case"doesNotContainIgnoreCase":if(n.toLowerCase().indexOf(t.toLowerCase())<0)return e;break;case"contains":if(n.indexOf(t)>-1)return e;break;case"containsIgnoreCase":if(n.toLowerCase().indexOf(t.toLowerCase())>-1)return e;break;case"equals":if(0===n.localeCompare(t))return e;break;case"equalsIgnoreCase":if(0===n.toLowerCase().localeCompare(t.toLowerCase()))return e;break;case"endsWith":if(n.endsWith(t))return e;break;case"endsWithIgnoreCase":if(n.toLowerCase().endsWith(t.toLowerCase()))return e}return null}_getFirstEnabledChild(e){const t=e.children;for(let e=0;e<t.length;e++)if(this._isChildEnabled(t[e]))return t[e]}_getLastEnabledChild(e){const t=e.children;for(let e=t.length-1;e>=0;e--)if(this._isChildEnabled(t[e]))return t[e]}_getNextEnabledChild(e){if(e)for(;e.nextElementSibling;){const t=e.nextElementSibling;if(this._isChildEnabled(t))return t;e=t}}_getOffsetTop(e){if(!e)return 0;let t=e.offsetTop;for(;e.offsetParent!==this.$.mainContainer;){if(!(e=e.offsetParent))return t;t+=e.offsetTop}return t}_getPreviousEnabledChild(e){if(e)for(;e.previousElementSibling;){const t=e.previousElementSibling;if(this._isChildEnabled(t))return t;e=t}}_hamburgerIconClickHandler(e,t){e&&e.stopPropagation();const n=this;if(void 0===t&&(t=Smart.ListMenu&&n instanceof Smart.ListMenu?n.$.view:n.$.mainContainer),!n.disabled)if(n._minimizedDropDownOpened)n._close();else{if(n._positionDetection.placeOverlay(),null!==n.dropDownAppendTo){const e=n.dropDownPosition,o=n.getBoundingClientRect(),i=n._positionDetection.getDropDownOffset();-1!==e.indexOf("right")||"auto"===e?n.rightToLeft?(t.style.right="initial",t.style.left=o.left+o.width-t.offsetWidth-i.x+"px"):(t.style.left=o.left+i.x+"px",t.style.right="initial"):-1!==e.indexOf("left")&&(t.style.left=o.right-t.offsetWidth+i.x+"px",t.style.right="initial"),-1!==e.indexOf("bottom")||-1!==e.indexOf("overlay")||"auto"===e?t.style.top=o.bottom+i.y+"px":-1!==e.indexOf("top")&&(t.style.top=o.top+i.y+"px")}else t.style.right="";n._edgeMacFF&&t.$.removeClass("not-in-view"),t.$.removeClass("smart-visibility-hidden"),n.$hamburgerIcon.addClass("smart-close-button"),n.$.hamburgerIcon.setAttribute("aria-expanded",!0),n._minimizedDropDownOpened=!0,n._browserBoundsDetection(t)}}_handleOverflowChange(){const e=this,t=e.$.mainContainer;if((e._minimized||null===e.dropDownAppendTo&&!t.classList.contains("simple")&&"tree"!==e.mode)&&!(Smart.ListMenu&&e instanceof Smart.ListMenu))return;const n=e.overflow;let o;"horizontal"===e.mode?(o=!0,t.scrollLeft=0):(o=!1,t.scrollTop=0),"hidden"===n?(t.classList.remove("scroll-buttons-shown"),e.$scrollButtonNear.addClass("smart-hidden"),e.$scrollButtonFar.addClass("smart-hidden")):(e.$.scrollButtonNear.disabled=e.disabled,e.$.scrollButtonFar.disabled=e.disabled,"auto"===n?(e.$scrollButtonNear.addClass("smart-hidden"),e.$scrollButtonFar.addClass("smart-hidden"),e._checkOverflow(t,o,[e.$.scrollButtonNear,e.$.scrollButtonFar])):(t.classList.add("scroll-buttons-shown"),t.classList.remove("one-button-shown"),e.$scrollButtonNear.removeClass("smart-hidden"),e.$scrollButtonFar.removeClass("smart-hidden"),e._updateScrollButtonVisibility(t,o,[e.$.scrollButtonNear,e.$.scrollButtonFar]))),e._scrollInfo.set(t,{left:t.scrollLeft,top:t.scrollTop})}_hideMainContainerScrollButtons(){const e=this;e.$scrollButtonNear.addClass("smart-hidden"),e.$scrollButtonFar.addClass("smart-hidden"),e.$mainContainer.removeClass("scroll-buttons-shown"),e.$mainContainer.removeClass("one-button-shown")}_hoverViaKeyboard(e){e&&(e.$.addClass("focus"),e.setAttribute("focus",""),this._focusedViaKeyboard=e,this._ensureVisible(e))}_isBranchExpanded(e){if("tree"!==this.mode)return!0;let t=!0;for(;e.parentItem;)t=t&&e.parentItem.expanded,e=e.parentItem;return t}_isChildEnabled(e){return!(e.disabled||e.templateApplied||e.hidden||e instanceof HTMLDivElement||0===e.offsetHeight)}_isContainerOpened(e,t){const n=this;return"tree"===n.mode||n._minimized?(n._openedContainers[e]||(n._openedContainers[e]=[]),-1!==n._openedContainers[e].indexOf(t)):n._openedContainers[e]===t}_keydownHandler(e){const t=this;let n=e.key;if(t.getRootNode().activeElement!==t||-1===["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Enter","Escape","Home"," "].indexOf(n)||t.disabled)return;e.preventDefault();const o=t.mode;if("tree"===o||t._minimized)return void t._keydownHandlerTreeMode(n);const i=t.dropDownPosition,r=-1!==i.indexOf("left"),a="top-left"===i||"top-right"===i,s=t._openedContainers;let l,d=t.$.mainContainer,m=1;for(let e=s.length-1;e>=0;e--)if(void 0!==s[e]){d=s[e],m=d.level,d=d.itemContainer;break}switch(l=d.querySelector('[focus][level="'+m+'"]'),t.rightToLeft&&("ArrowLeft"===n?n="ArrowRight":"ArrowRight"===n&&(n="ArrowLeft")),n){case"ArrowDown":1===m?"horizontal"!==o||a?"horizontal"!==o&&t._levelOneNavigate("_getFirstEnabledChild",l,d):t._levelOneOpenDropDown(l):t._navigate("_getNextEnabledChild",l,d);break;case"ArrowLeft":r?1===m?"horizontal"===o?t._levelOneNavigate("_getLastEnabledChild",l,d):t._levelOneOpenDropDown(l):l instanceof Smart.MenuItemsGroup?t._selectionHandler({target:l,isTrusted:!0}):t._levelOneNavigateFromLowerLevel("_getPreviousEnabledChild",l):t._arrowLeftHandler(m,o,l,d);break;case"ArrowRight":r?1===m?"horizontal"===o&&t._levelOneNavigate("_getFirstEnabledChild",l,d):2===m?t._levelOneNavigateFromLowerLevel("_getNextEnabledChild",l):t._escapeHandler(l,m,d):t._arrowRightHandler(m,o,l,d);break;case"ArrowUp":1===m?"horizontal"===o&&a?t._levelOneOpenDropDown(l):"horizontal"!==o&&t._levelOneNavigate("_getLastEnabledChild",l,d):t._navigate("_getPreviousEnabledChild",l,d);break;case"End":case"Home":{const e="End"===n?t._getLastEnabledChild(d):t._getFirstEnabledChild(d);if(!e||l===e)return;l&&(l.$.removeClass("focus"),l.removeAttribute("focus")),t._hoverViaKeyboard(e);break}case"Enter":l&&t._selectionHandler({target:l,isTrusted:!0});break;case"Escape":m>1?(2===m&&t._positionDetection.removeOverlay(),t._escapeHandler(l,m,d)):"dropDown"===o&&t.opened&&t.close({trigger:"interaction",target:"Escape"});break;case" ":l&&t._toggleItem(l)}}_keydownHandlerTreeMode(e){const t=this,n=Array.from(t.$.mainContainer.querySelectorAll("smart-menu-item, smart-menu-items-group")),o=t.$.mainContainer.getElementsByClassName("focus")[0];function i(e){const n=e.level;return!1===e.disabled&&!0!==e.templateApplied&&(1===n||n>1&&t._isContainerOpened(n,e.parentElement.container)&&e.getBoundingClientRect().height>0)}function r(e){for(let r=e;r<n.length;r++){const e=n[r];if(i(e)){if(o){if(o===e)break;o.$.removeClass("focus"),o.removeAttribute("focus")}t._hoverViaKeyboard(e);break}}}function a(e){for(let r=e;r>=0;r--){const e=n[r];if(i(e)){if(o){if(o===e)break;o.$.removeClass("focus"),o.removeAttribute("focus")}t._hoverViaKeyboard(e);break}}}function s(){o.level>1&&(o.$.removeClass("focus"),o.removeAttribute("focus"),t._hoverViaKeyboard(o.parentItem))}let l;switch(e){case"ArrowDown":l=o?n.indexOf(o)+1:0,r(l);break;case"ArrowLeft":if(!o)return;if(o instanceof Smart.MenuItem)s();else{if(t._isContainerOpened(o.level+1,o.container))return void t._closeSubContainers(o.level+1,o.container,!0,!0);s()}break;case"ArrowRight":if(!o||o instanceof Smart.MenuItem)return;t._isContainerOpened(o.level+1,o.container)?(o.$.removeClass("focus"),o.removeAttribute("focus"),t._hoverViaKeyboard(t._getFirstEnabledChild(o.itemContainer))):t._selectionHandler({target:o,type:"keydown",isTrusted:!0},o);break;case"ArrowUp":l=o?n.indexOf(o)-1:n.length-1,a(l);break;case"End":a(n.length-1);break;case"Enter":t._minimized&&!t._minimizedDropDownOpened?t._hamburgerIconClickHandler(void 0,t.$.mainContainer):o&&t._selectionHandler({target:o,type:"keydown",isTrusted:!0});break;case"Escape":t._minimized&&t._minimizedDropDownOpened&&t._close();break;case"Home":r(0);break;case" ":o&&t._toggleItem(o)}}_lazyInitItems(){const e=this;e._inLazyInit||(e._inLazyInit=!0,e._menuItems={},e._processHTML(e.$.mainContainer,1),e._expandItemsByDefault(),e._refreshCheckableItems(),cancelAnimationFrame(Smart.Menu.processTimer),delete Smart.Menu.processTimer,e._inLazyInit=!1,e.$.scrollViewer&&e.$.scrollViewer.refresh())}_levelOneNavigate(e,t,n){const o=this;if(t)"_getLastEnabledChild"===e?o._navigate("_getPreviousEnabledChild",t,n):o._navigate("_getNextEnabledChild",t,n);else{const t=o[e](n);t&&o._hoverViaKeyboard(t)}}_levelOneNavigateFromLowerLevel(e,t){const n=this,o=n[e](n._openedContainers[2].menuItemsGroup);o&&(t&&(t.$.removeClass("focus"),t.removeAttribute("focus")),n._closeSubContainers(2),o instanceof Smart.MenuItemsGroup?n._selectionHandler({target:o,isTrusted:!0}):n._hoverViaKeyboard(o))}_levelOneOpenDropDown(e){e&&e instanceof Smart.MenuItemsGroup&&this._selectionHandler({target:e,isTrusted:!0})}_mainContainerHandler(e){const t=this;if(t._minimized&&null!==t.dropDownAppendTo)switch(e.type){case"click":t._selectionHandler(e);break;case"mouseleave":t._mouseleaveHandler(e);break;case"mouseout":case"mouseover":t._mouseoutMouseoverHandler(e)}}_menuItemSelectionHandler(e,t){const n=this;function o(){n.enableShadowDOM&&(n.shadowRoot.activeElement||document.activeElement)!==n&&null!==n.dropDownAppendTo&&"click"===t.type&&!n.shadowRoot.contains(e)?n.focus():document.activeElement===n||null===n.dropDownAppendTo||"click"!==t.type||n.contains(e)||n.focus()}if(e.disabled||e.templateApplied)o();else{if(!n._toggleItem(e)){if(n.$.fireEvent("itemClick",{item:e,label:e.label,value:e.value}),t.target&&"A"!==t.target.nodeName){const t=e.querySelector("a");t&&t.click()}if("tree"!==n.mode&&(n._close(),"dropDown"===n.mode))return n._ripple(e,t),void n.close({trigger:"interaction",target:e})}n._ripple(e,t),o()}}_menuItemsGroupSelectionHandler(e,t,n){const o=this,i=o.mode,r=e.container,a=r.level,s="tree"!==i&&!o._minimized;if(o._treeAnimationInProgress===r)return;if(o._discardKeyboardHover(),o.getRootNode().activeElement===o||null===o.dropDownAppendTo||"click"!==t.type||o.contains(t.target)||o.focus(),"click"===t.type&&(!t.target.classList.contains("smart-"+o._element+"-items-group-arrow")&&o._toggleItem(e)||"mouseenter"===o.selectionMode&&"tree"!==i&&!o._minimized))return;let l=o.hasAnimation;if(o._isContainerOpened(a,r))o._closeSubContainers(a,r,!0,!1!==n),s&&e.hasAttribute("focus")&&(o._focusedViaKeyboard=e);else{if(o.$.fireEvent("expanding",{item:e,label:e.label,path:e.path,value:e.value,children:e.itemContainer.children}).defaultPrevented)return;if(o._positionDetection.placeOverlay(),s&&o._closeSubContainers(a),l&&!s&&("expand"!==t.type&&(o._ensureVisibleOnTransitionend=e),o._expandSection(r)),o._edgeMacFF&&2===a&&s&&r.$.removeClass("not-in-view"),r.$.removeClass("smart-visibility-hidden"),s||"expand"!==t.type){if(s)"keydown"===t.type&&(o._focusedViaKeyboard=e);else{const t=o.$.mainContainer.getElementsByClassName("focus")[0];t&&(t.$.removeClass("focus"),t.removeAttribute("focus")),o._focusedViaKeyboard=e}e.$.addClass("focus"),e.setAttribute("focus","")}if(e.$.addClass("smart-"+o._element+"-items-group-opened"),e.$.addClass("smart-"+o._element+"-items-group-expanded"),e.setAttribute("aria-expanded",!0),o._addOpenedContainer(a,r),s){if(o._ensureVisible(e),e.level>1&&e.parentElement.dropDownHeightSet){const t=o.dropDownPosition,n=e.getBoundingClientRect().top-e.parentElement.container.getBoundingClientRect().top;-1!==t.indexOf("bottom")||"auto"===t?r.style.top=n+"px":-1!==t.indexOf("top")?r.style.top=n+e.offsetHeight+"px":r.style.top=n+e.offsetHeight/2+"px"}r.itemContainer.checkOverflow&&r.itemContainer.dropDownHeightSet&&(o._checkOverflow(r.itemContainer,!1,[r.children[0],r.children[2]]),delete r.itemContainer.checkOverflow)}o._positionExternalContainer(r,e),"tree"===i||o._minimized?l||o._browserBoundsDetection(o.$.mainContainer):o._browserBoundsDetection(r),void 0===t.type&&o._hoverViaKeyboard(o._getFirstEnabledChild(e.itemContainer)),!1!==n&&o.$.fireEvent("expand",{item:e,label:e.label,path:e.path,value:e.value,children:e.itemContainer.children})}s?o._ripple(e,t):"tree"!==i||l||(o._checkOverflow(o.$.mainContainer,!1,[o.$.scrollButtonNear,o.$.scrollButtonFar]),o._minimized||"expand"===t.type||o._ensureVisible(e))}_mouseenterHandler(){const e=this;e.autoFocusOnMouseenter&&e.getRootNode().activeElement!==e&&e.focus()}_mouseleaveHandler(e){const t=this;if("mouseenter"===t.selectionMode&&"tree"!==t.mode&&!t._minimized){if(null!==t.dropDownAppendTo&&e.relatedTarget)if(t.contains(e.target)){const n=e.relatedTarget.closest(".smart-menu-drop-down");if(n&&n.ownerElement===t)return}else if(t.contains(e.relatedTarget))return;t._isElementHovered=!1,t._autoCloseTimeout=setTimeout((function(){const e=t.context;clearTimeout(t._autoCloseTimeout),t._isElementHovered||(t.context=t,t._close(),t.context=e)}),t.autoCloseDelay)}}_mouseoutMouseoverHandler(e){const t=this;if(t.disabled||t.displayLoadingIndicator)return;let n=e.target.closest("smart-menu-item")||e.target.closest("smart-menu-items-group");if(t.enableShadowDOM&&(n=e.composedPath()[0].closest("smart-menu-item")||e.composedPath()[0].closest("smart-menu-items-group")||n),"mouseover"===e.type&&(t._isElementHovered=!0),null!==n&&!n.disabled&&!n.templateApplied&&("tree"!==t.mode&&!t._minimized||!n.hasAttribute("focus")||!e.relatedTarget||e.target.parentElement!==e.relatedTarget&&e.relatedTarget.parentElement!==e.target))if(t._discardKeyboardHover(!1),"mouseover"===e.type){"mouseenter"!==t.selectionMode||"tree"===t.mode||t._minimized||(n instanceof Smart.MenuItemsGroup&&!n.hasAttribute("hover")?t._selectionHandler(e,n):n instanceof Smart.MenuItem&&t._closeSubContainers(n.level+1));const o=e.target.closest(".smart-menu-drop-down");(!o||o&&!n.contains(o))&&(n.$.addClass("hover"),n.setAttribute("hover",""),t._discardKeyboardHover(!0))}else{if("tree"!==t.mode&&!t._minimized&&("mouseenter"===t.selectionMode&&e.relatedTarget===t.$.mainContainer&&t._close(),n instanceof Smart.MenuItemsGroup&&n.container&&!n.container.$.hasClass("smart-visibility-hidden")))return;n.$.removeClass("hover"),n.removeAttribute("hover")}}_moveDropDownsToExternalContainer(){const e=this;for(let t=0;t<e._containersInBody.length;t++){const n=e._containersInBody[t];e._dropDownParent.appendChild(n),n.$.listen("click",e._selectionHandler.bind(e)),n.$.listen("mouseleave",e._mouseleaveHandler.bind(e)),n.$.listen("mouseout",e._mouseoutMouseoverHandler.bind(e)),n.$.listen("mouseover",e._mouseoutMouseoverHandler.bind(e))}for(let t=0;t<e._containers.length;t++){const n=e._containers[t];n.ownerElement=e,""!==e.theme&&n.classList.add(e.theme),e.rightToLeft&&n.setAttribute("right-to-left",""),n.classList.add("smart-drop-down-repositioned"),n.setAttribute("mode",e.mode),n.setAttribute("drop-down-position",e.dropDownPosition),e.checkboxes&&n.setAttribute("checkboxes","")}}_moveDropDownsToMenu(){const e=this;for(let t=0;t<e._containersInBody.length;t++){const n=e._containersInBody[t];n.$.unlisten("click"),n.$.unlisten("mouseleave"),n.$.unlisten("mouseout"),n.$.unlisten("mouseover"),n.style.left="",n.style.right="",n.style.top="",n.style.marginLeft="",n.style.marginTop="",n.menuItemsGroup.appendChild(n)}for(let t=0;t<e._containers.length;t++){const n=e._containers[t];""!==e.theme&&n.classList.remove(e.theme),n.classList.remove("smart-drop-down-repositioned"),n.removeAttribute("mode"),n.removeAttribute("drop-down-position"),n.removeAttribute("checkboxes"),n.removeAttribute("right-to-left")}}_navigate(e,t,n){const o=this;if(!t)return void("_getNextEnabledChild"===e?o._hoverViaKeyboard(o._getFirstEnabledChild(n)):o._hoverViaKeyboard(o._getLastEnabledChild(n)));const i=o[e](t);i&&(t.$.removeClass("focus"),t.removeAttribute("focus"),o._hoverViaKeyboard(i))}_positionExternalContainer(e,t){const n=this;if(null===n.dropDownAppendTo||2!==e.level)return;const o=n.dropDownPosition,i=n.mode,r=t.getBoundingClientRect(),a=n._positionDetection.getDropDownOffset(),s=r.top+a.y,l=r.bottom+a.y;let d=r.left+a.x,m=r.right+a.x;switch(e.style.top=e.style.left=e.style.right="",n.rightToLeft&&(e.style.right="initial"),-1!==o.indexOf("left")?(d-=e.offsetWidth,"horizontal"!==i&&"overlay-left"!==o||(d+=r.width),e.style.left=d+"px",e.style.right="initial"):"horizontal"===i||"overlay-right"===o?e.style.left=d+"px":n.rightToLeft?e.style.left=m-e.offsetWidth+"px":e.style.left=d+r.width+"px",o){case"bottom-right":case"bottom-left":case"auto":e.style.top="horizontal"===i?l+"px":s+"px";break;case"top-right":case"top-left":e.style.top="horizontal"===i?s-e.offsetHeight+"px":l-e.offsetHeight+"px";break;case"overlay-right":case"overlay-left":e.style.top=s+r.height/2+"px"}}_processDataSource(){const e=this,t=e.dataSource,n=e.displayMember,o=e.itemsMember,i=e.valueMember,r=e.$.mainContainer,a=document.createDocumentFragment();function s(t,r){let a;if(Array.isArray(t[o])&&t[o].length>0){a=document.createElement("smart-"+e._element+"-items-group"),!0===t.checkable&&a.set("checkable",!0),"string"==typeof t.checkMode&&a.set("checkMode",t.checkMode),t.dropDownHeight&&a.set("dropDownHeight",t.dropDownHeight),!0===t.expanded&&"tree"===e.mode&&(a.set("expanded",!0),a.setAttribute("aria-expanded",!0));for(let e=0;e<t[o].length;e++)s(t[o][e],a)}else a=document.createElement("smart-"+e._element+"-item"),void 0!==t.shortcut&&a.set("shortcut",t.shortcut),t.customAttribute&&a.setAttribute(t.customAttribute,"");a.isDirty=!1,void 0!==t.id&&/^[A-Za-z]+[\w\-\:\.]*$/.test(t.id)&&(a.id=t.id),!0===t.checked&&(a.set("checked",!0),a.setAttribute("aria-checked",!0)),!0===t.disabled&&a.set("disabled",!0),void 0!==t[n]?a.set("label",t[n]):"string"==typeof t[o]&&a.set("label",t[o]),!0===t.selected&&a.set("selected",!0),!0===t.separator&&a.set("separator",!0),void 0!==t[i]&&a.set("value",t[i]),r.appendChild(a)}r.innerHTML="",r instanceof Smart.ScrollViewer&&r.removeAll();for(let e=0;e<t.length;e++)s(t[e],a);e.$.mainContainer.appendChild(a),e._processHTML(e.$.mainContainer,1)}_processHTML(e,t,n){const o=this;let i,r;t>1&&(i=o._createMenuItemsGroupContainer(e,t),r=i.itemContainer,(e.expanded||e.hasAttribute("expanded"))&&"tree"===o.mode?o._menuItemsGroupsToExpand.push(e):(e.set("expanded",!1),e.removeAttribute("expanded"),e.setAttribute("aria-expanded",!1)));const a=Array.from(e.children),s=[],l=document.createDocumentFragment();let d=0;for(let n=0;n<a.length;n++){if(t>1&&0===n){d++;continue}const i=a[n];i instanceof Smart.MenuItem||i instanceof Smart.MenuItemsGroup?(o._createItemHTMLStructure(i,t,e,n-d),(i.checked||i.hasAttribute("checked"))&&(i.disabled||i.hasAttribute("disabled")||i.templateApplied?(i.set("checked",!1),i.removeAttribute("checked"),i.removeAttribute("aria-checked")):s.push(i)),t>1&&l.appendChild(i),i instanceof Smart.MenuItemsGroup&&o._processHTML(i,t+1)):(i.parentElement.removeChild(i),d++)}if(t>1){if(r.appendChild(l),e.container=i,e.itemContainer=r,e instanceof Smart.MenuItemsGroup){const n=document.createElement("div");n.className="smart-"+o._element+"-items-group-arrow","menu"===o._element?n.setAttribute("role","presentation"):(n.setAttribute("role","button"),n.setAttribute("aria-label","Toggle")),o._setArrowDirection(n,t),e.firstElementChild.appendChild(n)}o._containers.push(i),2===t&&(o._containersInBody.push(i),o._edgeMacFF&&i.addEventListener("transitionend",(function(e){e.target===this&&this.$.hasClass("smart-visibility-hidden")&&(this.style.left="",this.style.top="",this.$.addClass("not-in-view"))}))),null===o.dropDownAppendTo||"tree"===o.mode||o._minimized?e.appendChild(i):(i.ownerElement=o,o.rightToLeft?i.setAttribute("right-to-left",""):i.removeAttribute("right-to-left"),i.classList.add("smart-drop-down-repositioned"),i.setAttribute("mode",o.mode),i.setAttribute("drop-down-position",o.dropDownPosition),o.checkboxes&&i.setAttribute("checkboxes",""),""!==o.theme&&i.$.addClass(o.theme),i.setAttribute("animation",o.animation),2===t?(o._dropDownParent.appendChild(i),i.$.listen("click",o._selectionHandler.bind(o)),i.$.listen("mouseleave",o._mouseleaveHandler.bind(o)),i.$.listen("mouseout",o._mouseoutMouseoverHandler.bind(o)),i.$.listen("mouseover",o._mouseoutMouseoverHandler.bind(o))):e.appendChild(i))}o._validateRadioButtonSelection(e,t,s),o._sortItems&&!1!==n&&o._sortItems(e)}_processUList(){const e=this,t=new RegExp(/<li>(.(?!<\/li>)|\n)*?<ul>/),n=new RegExp(/<\/ul>(.|\n)*?<\/li>/);let o=e.$.mainContainer.firstElementChild.innerHTML;for(o=o.replace(/\r?\n|\r/g,""),o=o.replace(/<li(.|\n)*?>/g,"<li>"),o=o.replace(/<li><\/li>/g,"<li> </li>"),o=o.replace(/<ul(.|\n)*?>/g,"<ul>");t.test(o);){const n=t.exec(o),i="<smart-"+e._element+"-items-group>"+n[0].slice(4,n[0].length-4);o=o.replace(n[0],i)}for(;n.test(o);){const t=n.exec(o),i="</smart-"+e._element+"-items-group>";o=o.replace(t[0],i)}o=o.replace(/li>/g,"smart-"+e._element+"-item>"),e.$.mainContainer.innerHTML=o}_refreshContainersArrays(){const e=this;for(let t=e._containers.length-1;t>=0;t--){const n=e._containers[t];if(!document.body.contains(n)){e._containers.splice(t,1);const o=e._containersFixedHeight.indexOf(n);o>-1&&(e._containersFixedHeight.splice(o,1),e._additionalScrollButtons.splice(o,1))}}e._checkContainersLength()}_refreshItemPaths(e,t,n,o){const i=this;let r;r=t?e:e.container.itemContainer;const a=n?n(e):r.children;for(let r=0;r<a.length;r++){const s=a[r];let l;o&&(s.originalIndex=r),l=t?""+r:e.path+"."+r,s.path=l,i._menuItems[l]=s,s instanceof Smart.MenuItemsGroup&&i._refreshItemPaths(s,void 0,n,o)}}_removeContainerFixedHeight(){const e=this;for(let t=0;t<e._containersFixedHeight.length;t++){const n=e._containersFixedHeight[t];n.style.height="",n.itemContainer.$.removeClass("scroll-buttons-shown"),n.itemContainer.$.removeClass("one-button-shown"),n.children[0].$.addClass("smart-hidden"),n.children[2].$.addClass("smart-hidden"),n.itemContainer.checkOverflow=!0}}_removeContainersInBody(){const e=this;if(null!==e.dropDownAppendTo&&!e._minimized)for(let t=0;t<e._containersInBody.length;t++)e._containersInBody[t].remove()}_reparentMenu(e,t){const n=this;if("dropDown"===n.mode&&(null!==n._dropDownParent||e)&&n._dropDownParent!==n.parentElement){if(e&&null!==t){if(null===n._dropDownParent)return n._positionRelativeTo.appendChild(n),void(n._positionRelativeTo=null)}else n._positionRelativeTo=n.parentElement;n._dropDownParent.appendChild(n)}}refresh(){const e=this;if(e._suppressResizeHandler)return void delete e._suppressResizeHandler;const t=e.minimizeWidth,n=e.mode;if(null!==t&&"dropDown"!==n){if(e.offsetWidth<=t&&!e._minimized)return void e.minimize();e.offsetWidth>t&&e.maximize()}(null!==e.dropDownAppendTo||"tree"===n||e.$mainContainer.hasClass("simple"))&&e._checkOverflow(e.$.mainContainer,"horizontal"===n,[e.$.scrollButtonNear,e.$.scrollButtonFar])}_resizeHandler(){this.refresh()}_ripple(e,t){if(this.hasRippleAnimation&&"click"===t.type)return Smart.Utilities.Animation.Ripple.animate(e,t.pageX,t.pageY),!0}_scroll(e){if(e.closest("[template-applied]"))return;const t=this,n=t.$.mainContainer,o=t.mode,i=e.classList.contains("smart-scroll-button-near")?-1:1;let r;if(e.parentElement===t.$.container)r=n,"tree"!==o&&t._closeSubContainers(2),"horizontal"===t.mode?(n.scrollLeft=n.scrollLeft+10*i,t._updateScrollButtonVisibility(n,!0,[t.$.scrollButtonNear,t.$.scrollButtonFar])):(n.scrollTop=n.scrollTop+10*i,t._updateScrollButtonVisibility(n,!1,[t.$.scrollButtonNear,t.$.scrollButtonFar]));else{const n=e.parentElement,o=n.itemContainer;r=o,t._closeSubContainers(n.level+1),o.scrollTop=o.scrollTop+10*i,t._updateScrollButtonVisibility(o,!1,[n.children[0],n.children[2]])}t._scrollInfo.set(r,{left:r.scrollLeft,top:r.scrollTop})}_selectionHandler(e,t){const n=this,o=e.target;if(o.closest("[template-applied]")&&e.stopPropagation(),!n.disabled&&!n.displayLoadingIndicator){if(void 0===t){if("click"===e.type){const t=o.closest("smart-repeat-button");if(t)return void n._scroll(t,e)}if(!e.isTrusted)return;const i=o.closest("smart-"+n._element+"-item");if(i)return void n._menuItemSelectionHandler(i,e);if((t=o.closest("smart-"+n._element+"-items-group"))&&(o===t.container||o===t.container.firstElementChild))return}t&&!t.disabled&&n._menuItemsGroupSelectionHandler(t,e)}}_setArrowDirection(e,t){const n=this,o=n.mode;"tree"===o||n._minimized?e.className="smart-"+n._element+"-items-group-arrow down smart-arrow-down":"overlay"!==n.dropDownPosition.slice(0,7)?2===t&&"horizontal"===o?"top"!==n.dropDownPosition.slice(0,3)?e.className="smart-menu-items-group-arrow down smart-arrow-down":e.className="smart-menu-items-group-arrow up smart-arrow-up":e.className="smart-menu-items-group-arrow "+(n.rightToLeft?"left smart-arrow-left":"right smart-arrow-right"):e.className="smart-menu-items-group-arrow minus"}_setFocusable(){const e=this;if(e.disabled||e.unfocusable)return void e.removeAttribute("tabindex");const t=e.getAttribute("tabindex");(null===t||t<0)&&e.setAttribute("tabindex",0)}_setItemLabel(e,t){const n=this,o=n.context,i=e.querySelector(".smart-menu-item-label-element>span");n.context=n,n._setLabel(t,i,e,!0),n._checkOverflow(n.$.mainContainer,"horizontal"===n.mode,[n.$.scrollButtonNear,n.$.scrollButtonFar]),n.context=o}_setLabel(e,t,n,o){const i=document.getElementById(e);if(null!==i&&"template"===i.tagName.toLowerCase()){const r=document.importNode(i.content,!0);if(n instanceof Smart.MenuItem)t.appendChild(r),o&&(n.setAttribute("template-applied",""),n.templateApplied=!0);else if(Smart.ListMenu&&this instanceof Smart.ListMenu){const e=new RegExp(/{{title="(.*)"}}/);for(let t=0;t<r.childNodes.length;t++)e.test(r.childNodes[t].innerHTML)?(n.titleLabel=e.exec(r.childNodes[t].innerHTML)[1],r.childNodes[t].innerHTML=r.childNodes[t].innerHTML.replace(e,"")):e.test(r.childNodes[t].textContent)&&(n.titleLabel=e.exec(r.childNodes[t].textContent)[1],r.childNodes[t].textContent=r.childNodes[t].textContent.replace(e,""));void 0===n.titleLabel&&(n.titleLabel=r.textContent),t.appendChild(r)}else t.innerHTML=e,n.titleLabel=e}else t.innerHTML=e,n instanceof Smart.MenuItemsGroup&&(n.titleLabel=e)}_toggleItem(e){const t=this;if(t.checkboxes){const n=1===e.level?t:e.parentItem;if(n.checkable){const o=t._getItemCheckableInfo(e,n);let i=!1;return"none"!==o.checkMode&&("checkbox"===o.checkMode?(i=!0,e.set("checked",!e.checked),e.checked?e.setAttribute("aria-checked",!0):e.removeAttribute("aria-checked"),t.$.fireEvent("itemCheckChange",{item:e,label:e.label,value:e.value,checked:e.checked})):"radioButton"!==o.checkMode||e.checked||(i=!0,e.set("checked",!0),e.setAttribute("aria-checked",!0),t._uncheckSiblings(e,o.siblings),t.$.fireEvent("itemCheckChange",{item:e,label:e.label,value:e.value,checked:!0})),e instanceof Smart.MenuItem&&i&&t.$.fireEvent("itemClick",{item:e,label:e.label,value:e.value}),"tree"===t.mode||"ListMenu"===t.elementName||t.preventCloseOnCheck||(t._close(),t.close()),!0)}}return!1}_getItemCheckableInfo(e,t){const n=Array.from(e.parentElement.children),o=t.checkMode.replace(/\s/g,"").split(",");let i,r;if(1===o.length)i=o[0],r=n;else{let t=0,a=!1;r=[];for(let o=0;o<n.length;o++){const i=n[o];if(r.push(i),i===e&&(a=!0),i.separator){if(!0===a)break;t++,r=[]}}i=o[t]}return{checkMode:i,siblings:r}}_refreshCheckableItems(e){const t=this,n=!t.checkboxes;(e?[e]:[t].concat(t._containers.map((e=>e.menuItemsGroup)))).forEach((e=>{const o=Array.from((e===t?t.$.mainContainer:e.itemContainer).children);let i=e.checkMode.replace(/\s/g,"").split(",");if(n||!e.checkable||1===i.length)return void o.forEach((e=>e.removeAttribute("check-type")));let r=0;i=i.map((e=>-1===["checkbox","radioButton","none"].indexOf(e)?"none":e));let a=[],s=[];for(let e=0;e<o.length;e++){const n=o[e];let l=i[r];if(void 0===l&&(l=i[r]="none"),"none"!==l&&t._isChildEnabled(n)||(n.checked=!1,n.removeAttribute("aria-checked")),"none"===l?n.setAttribute("role","menuitem"):"checkbox"===l?n.setAttribute("role","menuitemcheckbox"):"radioButton"===l&&(n.setAttribute("role","menuitemradio"),a.push(n),n.checked&&s.push(n)),n.setAttribute("check-type",l),n.separator){if(a.length>0)if(s.length>1)for(let e=0;e<s.length-1;e++)s[e].checked=!1;else if(0===s.length)for(let e=0;e<a.length;e++)if(t._isChildEnabled(a[e])){a[e].checked=!0;break}a=[],s=[],r++}}e.checkMode=i.join(", ")}))}_transitionendHandler(e){const t=this;"dropDown"===t.mode&&t.opened&&e.target===t&&"opacity"===e.propertyName&&(t._checkOverflowOnOpen&&(t._checkOverflow(t.$.mainContainer,!1,[t.$.scrollButtonNear,t.$.scrollButtonFar]),delete t._checkOverflowOnOpen),t.getRootNode().activeElement===t||t._noAutoFocus||t.focus())}_transitionendHandlerCollapse(){let e,t;if(1===arguments.length){if("visibility"===arguments[0].propertyName)return;t=this,e=t.menuItemsGroup.menu}else e=arguments[0],t=arguments[1];t.menuItemsGroup.$.removeClass("smart-"+e._element+"-items-group-expanded"),t.menuItemsGroup.setAttribute("aria-expanded",!1),t.removeEventListener("transitionend",e._transitionendHandlerCollapse),t.style.height=null,t.$.addClass("smart-visibility-hidden"),e._checkOverflow(e.$.mainContainer,!1,[e.$.scrollButtonNear,e.$.scrollButtonFar]),e._minimized&&e._browserBoundsDetection(e.$.mainContainer),delete e._treeAnimationInProgress}_transitionendHandlerExpand(){let e,t;if(1===arguments.length){if("visibility"===arguments[0].propertyName)return;t=this,e=t.menuItemsGroup.menu}else e=arguments[0],t=arguments[1];t.removeEventListener("transitionend",e._transitionendHandlerExpand),t.style.height=null,e._checkOverflow(e.$.mainContainer,!1,[e.$.scrollButtonNear,e.$.scrollButtonFar]),e._minimized&&e._browserBoundsDetection(e.$.mainContainer),e._ensureVisibleOnTransitionend&&(e._ensureVisible(e._ensureVisibleOnTransitionend),delete e._ensureVisibleOnTransitionend),delete e._treeAnimationInProgress}_uncheckSiblings(e,t){for(let n=0;n<t.length;n++){const o=t[n];o!==e&&o.checked&&(o.set("checked",!1),o.removeAttribute("aria-checked"),this.$.fireEvent("itemCheckChange",{item:o,label:o.label,value:o.value,checked:!1}))}}_unsortItems(e,t){const n=this;let o,i,r=[];e===n.$.mainContainer?(i=e,o=e.children):(i=e.container.firstElementChild,o=i.children);for(let e=0;e<o.length;e++){const i=o[e];r[i.originalIndex]=i,i instanceof Smart.MenuItemsGroup&&void 0===t&&n._unsortItems(i)}if(!(r.length<2))for(let e=0;e<r.length;e++)i.appendChild(r[e])}_updateItemRoles(e){const t=this;for(let n in t._menuItems){const o=t._menuItems[n],i=o.parentItem||t;e&&i!==e||(t.checkboxes&&i.checkable?o.setAttribute("role","checkbox"===i.checkMode?"menuitemcheckbox":"menuitemradio"):o.setAttribute("role","menuitem"))}t._refreshCheckableItems(e)}_updateScrollButtonVisibility(e,t,n){const o=this,i=o.overflow,r=e===o.$.mainContainer;if(r&&"hidden"===i)return;let a,s,l,d=!0,m=!0;if(t?(a="scrollLeft",s="offsetWidth",l="scrollWidth"):(a="scrollTop",s="offsetHeight",l="scrollHeight"),0===Math.round(e[a])&&(d=!1),Math.round(e[s]+e[a])>=Math.round(e[l])&&(m=!1),r&&"auto"!==i)"scroll"!==i||o.disabled||(n[0].disabled=!d,n[1].disabled=!m);else{if(d&&m)return n[0].$.removeClass("smart-hidden"),n[1].$.removeClass("smart-hidden"),void e.classList.remove("one-button-shown");d?n[0].$.removeClass("smart-hidden"):n[0].$.addClass("smart-hidden"),m?n[1].$.removeClass("smart-hidden"):n[1].$.addClass("smart-hidden"),e.classList.add("one-button-shown")}}_validateRadioButtonSelection(e,t,n){const o=this;if(o.checkboxes){let i,r;if(1===t?(i=o,r=o.$.mainContainer):(i=e,r=e.itemContainer),"radioButton"===i.checkMode&&i.checkable)if(n.length>1)for(let e=n.length-2;e>=0;e--)n[e].set("checked",!1),n[e].removeAttribute("aria-checked");else if(0===n.length){const e=o._getFirstEnabledChild(r);e&&!o.disableAutoCheck&&(e.set("checked",!0),e.setAttribute("aria-checked",!0))}}}});
67
67
  (()=>{class e extends HTMLElement{constructor(){super(),this._properties={min:50,label:"Item",modifiers:["resize","drag","close"],size:null}}_setProperty(e,t){const i=this;if(i._properties[e]===t)return;if(i._properties[e]=t,i._updating=!0,"disabled"===e||"modifiers"===e?t?i.setAttribute(e,t):i.removeAttribute(e):null===t?i.removeAttribute(e):i.setAttribute(e,t),!i.isCompleted)return;const r=i.closest("smart-layout");r&&(r._resizeDetails||r._updating||!r.isRendered||r.refresh()),i._updating=!1}get label(){return this._properties.label}set label(e){this._setProperty("label",e)}get modifiers(){return this._properties.modifiers}set modifiers(e){this._setProperty("modifiers",e)}get min(){return this._properties.min}set min(e){this._setProperty("min",e)}get size(){return this._properties.size}set size(e){null!==e?"string"==typeof e?this._setProperty("size",e):this._setProperty("size",Math.max(this.min,e)):this._setProperty("size",e)}static get observedAttributes(){return["min","size","label","modifiers"]}attributeChangedCallback(e,t,i){const r=this;if(t!==i&&r.isCompleted)if("size"===e){if(!r._updating){if(null===i)return void(this[e]=null);r[e]=Math.max(r.min,parseInt(i))}}else r[e]=i}connectedCallback(){this.isCompleted||this.render()}whenRendered(e){const t=this;t.isRendered?e():(t.whenRenderedCallbacks||(t.whenRenderedCallbacks=[]),t.whenRenderedCallbacks.push(e))}render(){const e=this;e.hasAttribute("data-id")||e.setAttribute("data-id","id"+Math.random().toString(16).slice(2)),e.hasAttribute("label")||e.setAttribute("label",e.label),e.hasAttribute("min")||e.setAttribute("min",e.min),e.hasAttribute("label")||e.setAttribute("label",e.label),e.hasAttribute("modifiers")||e.setAttribute("modifiers",e.modifiers);for(let t=0;t<e.attributes.length;t++){const i=e.attributes[t],r=i.name,s=i.value;isNaN(s)||"min"!==r&&"size"!==r?e._properties[r]=s:e._properties[r]=parseInt(s)}if(e.classList.add("smart-layout-item"),e.isCompleted=!0,e.whenRenderedCallbacks){for(let t=0;t<e.whenRenderedCallbacks.length;t++)e.whenRenderedCallbacks[t]();e.whenRenderedCallbacks=[]}}}class t extends e{constructor(){super(),this._properties.label="Group",this._properties.orientation="vertical"}get orientation(){return this._properties.orientation}set orientation(e){this._setProperty("orientation",e)}static get observedAttributes(){return["min","size","modifiers","orientation","position"]}render(){const e=this;super.render(),e.className="smart-layout-group",e.hasAttribute("orientation")?e._properties.orientation=e.getAttribute("orientation"):e.setAttribute("orientation",e._properties.orientation)}}class i extends t{constructor(){super(),this._properties.position="top",this._properties.label="TabGroup"}get position(){return this._properties.position}set position(e){this._setProperty("position",e)}render(){const e=this;super.render(),!e.hasAttribute("position")&&e.position&&e.setAttribute("position","top")}static get observedAttributes(){return["min","size","modifiers","orientation","position"]}}class r extends t{constructor(){super(),this._properties.label="TabItem"}}customElements.define("smart-layout-group",t),customElements.define("smart-layout-item",e),customElements.define("smart-tab-layout-group",i),customElements.define("smart-tab-layout-item",r),Smart("smart-layout",class extends Smart.ContentElement{static get properties(){return{allowLiveSplit:{value:!1,type:"boolean"},allowContextMenu:{value:!1,type:"boolean"},contextMenuDataSource:{value:["select","delete"],type:"any"},dataSource:{reflectToAttribute:!1,value:null,type:"any"},messages:{value:{en:{select:"Select Parent",delete:"Delete"}},type:"object",extend:!0},orientation:{value:"vertical",type:"string"},selectedIndex:{value:null,type:"any"}}}static get listeners(){return{contextmenu:"_contextMenuHandler","document.down":"_documentDownHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.selectstart":"_documentSelectStartHandler",mouseleave:"_leaveHandler",mouseenter:"_enterHandler",dragStart:"_dragStart","document.keyup":"_keyUpHandler"}}_dragStart(e){e.stopPropagation(),e.preventDefault()}_leaveHandler(){const e=this;e._resizeDetails||(e._handleButtonsVisibility(null),e._hideSplitter(),requestAnimationFrame((()=>{e.classList.remove("outline")})))}_enterHandler(){const e=this;e._resizeDetails||(e._handleButtonsVisibility(e._selectedItem),e._updateSplitter(),requestAnimationFrame((()=>{e.classList.add("outline")})))}template(){return'<div id="container" role="presentation"><smart-layout-group data-id="root" id="itemsContainer"><content></content></smart-layout-group><div root-splitter id="splitter" class="smart-layout-splitter"></div>'}propertyChangedHandler(e,t,i){const r=this;switch(e){case"contextMenuDataSource":r._contextMenu&&(r._closeContextMenu(),r._contextMenu.innerHTML="");break;case"orientation":r.$.itemsContainer&&(r.$.itemsContainer.orientation=r.orientation);break;case"dataSource":r.dataBind();break;case"selectedIndex":r._handleItemClick(r.getItem(i+""),!0);break;default:super.propertyChangedHandler(e,t,i)}}dataBind(){const e=this;e.$.itemsContainer.innerHTML="";let t="";const i=(e,r)=>{for(let s=0;s<e.length;s++){const n=e[s],o=n.size,a=n.min,l=n.modifiers,d=n.type,c=n.position,u=n.orientation?n.orientation:"vertical";let p="";if(void 0!==o&&(p+=`size="${o}" `),void 0!==a&&(p+=`min="${a}" `),void 0!==l&&(p+=`modifiers="${l}" `),void 0!==c&&(p+=`position="${c}" `),n.items)p+=`orientation=${u} `,"tabs"===d?(t+=`<smart-tab-layout-group ${p}>`,i(n.items,!0),t+="</smart-tab-layout-group>"):(t+=`<smart-layout-group ${p}>`,i(n.items),t+="</smart-layout-group>");else{const e=n.content||"";t+=r?`<smart-tab-layout-item ${p}>`+e+"</smart-tab-layout-item>":`<smart-layout-item ${p}>`+e+"</smart-layout-item>"}}};i(e.dataSource),e.$.itemsContainer.innerHTML=t,e.refresh()}render(){const e=this;e.setAttribute("role","group"),e.selectedIndex&&e._handleItemClick(e.getItem(e.selectedIndex+""),!0),e.checkLicense();const t=()=>{e.dataSource?e.dataBind():e.dataSource=e._getDataSource(e._getLayout()),e.$.itemsContainer.orientation=e.orientation,super.render(),e.refresh(),e._updateSplitter()};"complete"===document.readyState?t():window.addEventListener("load",(()=>{t()}))}getItem(e){if(null==e)return;e=(e+"").split(".");let t,i=this._getDataSource(this._getLayout());for(let r=0;r<e.length&&(t=i[e[r]],t);r++)i=t.items;return t}_contextMenuHandler(e){const i=this;let r=e.target;if(i.allowContextMenu&&r.closest){if(r.closest(".smart-layout-context-menu"))return void e.preventDefault();let s=i.querySelector("[selected][data-id]");if(s||(s=r.closest(".smart-layout-item")||r.closest(".smart-layout-group")),!s)return;e.preventDefault(),i._createContextMenu();const n=i._contextMenu.children;for(let e=0;e<n.length;e++){const i=n[e];"delete"===i.getAttribute("value")?s.hasAttribute("index")&&"0"===s.getAttribute("index")?i.setAttribute("disabled",""):i.removeAttribute("disabled"):"select"===i.getAttribute("value")&&(s.hasAttribute("index")&&"0"===s.getAttribute("index")||!(s.parentElement instanceof t)?i.setAttribute("disabled",""):i.removeAttribute("disabled"))}i._openContextMenu(s,e.pageX,e.pageY)}}_createContextMenu(){const e=this;let t=e._contextMenu;if(t||(t=document.createElement("div"),t.classList.add("smart-layout-context-menu","smart-visibility-hidden"),e._contextMenu=t),!t.innerHTML){const i=e.contextMenuDataSource;for(let r=0;r<i.length;r++){const s=i[r];let n,o;"object"==typeof s?(n=s.label,o=s.value):o=n=s+"",t.innerHTML+=`<div class="smart-layout-context-menu-item" value="${o}">${e.localize(n)||n}</div>`}}}_openContextMenu(e,t,i){const r=this,s=r._contextMenu;if(!s||!s.classList.contains("smart-visibility-hidden"))return;r.$.fireEvent("opening").defaultPrevented||e.parentElement&&(s._target=e,r._opening=!0,r.$.container.appendChild(s),r._positionContextMenu(t,i),s.classList.remove("smart-visibility-hidden"),r.$.fireEvent("open"))}_closeContextMenu(){const e=this,t=e._contextMenu;if(!t||t.classList.contains("smart-visibility-hidden"))return;e.$.fireEvent("closing").defaultPrevented||(delete e._opening,e.hasAnimation&&t.addEventListener("transitionend",e._contextMenuTransitionEndHandler.bind(e),{once:!0}),t.classList.add("smart-visibility-hidden"),e.$.fireEvent("close"))}_contextMenuTransitionEndHandler(){const e=this,t=e._contextMenu;t&&!e._opening&&t.parentElement&&e.$.container.removeChild(t)}_positionContextMenu(e,t){const i=this._contextMenu;if(!i)return;const r=this.$.container.getBoundingClientRect();e-=r.left+window.pageXOffset,t-=r.top+window.pageYOffset,e+i.offsetWidth>r.width&&(e-=e+i.offsetWidth-r.width),t+i.offsetHeight>r.height&&(t-=t+i.offsetHeight-r.height),i.style.left=e+"px",i.style.top=t+"px"}_documentDownHandler(e){const t=this,i=e.originalEvent.target;t.contains(i)&&i.closest&&(t._target=i,t._updateSplitter())}_documentMoveHandler(e){const t=this,s=e.originalEvent.target,n=t._contextMenu;if(n&&!Smart.Utilities.Core.isMobile){if(n.querySelector(".smart-layout-context-menu-item[hover]")){const e=n.children;for(let t=0;t<e.length;t++)e[t].removeAttribute("hover")}n.contains(s)&&s.closest&&s.closest(".smart-layout-context-menu-item")&&s.setAttribute("hover","")}if(t._dragDetails){const s=Math.abs(t._dragDetails.pageX-e.pageX);if(Math.abs(t._dragDetails.pageY-e.pageY)<=5&&s<=5)return;t._dragDetails.feedback.parentElement||(document.body.appendChild(t._dragDetails.feedback),document.body.appendChild(t._dragDetails.overlay),setTimeout((()=>{t._dragDetails.feedback.classList.add("dragging")}),100)),t._dragDetails.dragging=!0,t._dragDetails.feedback.style.left=e.pageX-t._dragDetails.feedback.offsetWidth/2-5+"px",t._dragDetails.feedback.style.top=e.pageY-t._dragDetails.feedback.offsetHeight/2-5+"px";const n=document.elementsFromPoint(e.pageX,e.pageY);let o=null,a=!1;for(let e=0;e<n.length;e++){const s=n[e];if(!t._dragDetails.feedback.contains(s)){if(s.classList.contains("smart-layout-tab-strip")){if(t._dragDetails.element.contains(s))continue;o=s.parentElement,a=!0;break}if((s.parentElement!==t._dragDetails.parent&&s!==t._dragDetails.parent||1!==t._dragDetails.layoutGroup.items.length)&&!t._dragDetails.element.contains(s)){if(s instanceof r){o=s.parentElement;break}if(s instanceof i){o=s;break}}}}const l=(i,r)=>{const s=t.offset(i);let n=null,o=50,a=r,l=r;r?o=0:(l=i.offsetWidth/3,a=i.offsetHeight/3);const d=[{left:s.left,top:s.top,right:s.left+o,bottom:s.top+o,position:"top"},{left:s.left+o,top:s.top,right:s.left+i.offsetWidth-o,bottom:s.top+a-o,position:"top"},{left:s.left+i.offsetWidth-o,top:s.top,right:s.left+i.offsetWidth,bottom:s.top+o,position:"top"},{left:s.left,top:s.top+o,right:s.left+l,bottom:s.top+i.offsetHeight-o,position:"left"},{left:s.left+i.offsetWidth-l,top:s.top+o,right:s.left+i.offsetWidth,bottom:s.top+i.offsetHeight-o,position:"right"},{left:s.left,top:s.top+i.offsetHeight-o,right:s.left+o,bottom:s.top+i.offsetHeight,position:"bottom"},{left:s.left+o,top:s.top+i.offsetHeight-a+o,right:s.left+i.offsetWidth-o,bottom:s.top+i.offsetHeight,position:"bottom"},{left:s.left+i.offsetWidth-o,top:s.top+i.offsetHeight-o,right:s.left+i.offsetWidth,bottom:s.top+i.offsetHeight,position:"bottom"}];for(let t=0;t<d.length;t++){const i=d[t];if(i.left<=e.pageX&&e.pageX<=i.right&&i.top<=e.pageY&&e.pageY<=i.bottom){n=i.position;break}}return n},d=t.querySelector("smart-layout-group");let c=l(d,10),u=null;c?u=d:o?a?o!==t._dragDetails.parent&&(c="center",u=o):(c=l(o)||"center",u=o):t._handleDropArea(null),u&&(t._dragDetails.current=u,t._dragDetails.position=c,t._handleDropArea(u,c))}if(t._resizeDetails){const i=Math.abs(t._resizeDetails.clientX-e.clientX),r=Math.abs(t._resizeDetails.clientY-e.clientY),s=t._resizeDetails.splitter,n=t._resizeDetails.item,o=t._resizeDetails.itemRect,a=t._resizeDetails.previousItemRect,l=t._resizeDetails.previousItem,d=t._resizeDetails.nextItemRect,c=t._resizeDetails.nextItem,u=parseInt(n.getAttribute("min")),p=e=>{e.classList.contains("smart-visibility-hidden")||(e.style.right="",e.style.top="",e.style.left="",e.style.bottom="")};if(p(s),p(t.$.splitter),s.classList.remove("error"),s.classList.add("active"),!t._resizeDetails.dragging){if(s.classList.contains("horizontal")&&r<=5)return;if(s.classList.contains("vertical")&&i<=5)return;t._resizeDetails.dragging=!0}let m={clientPos:"clientX",pos:"x",size:"width",near:"left",far:"right",offsetSize:"offsetWidth"};s.classList.contains("horizontal")&&(m={clientPos:"clientY",pos:"y",size:"height",near:"top",far:"bottom",offsetSize:"offsetHeight"});const f=e=>{const i=t.offset(e),r=t.offset(t);t.$.splitter.style.width=e.offsetWidth+"px",t.$.splitter.style.height=e.offsetHeight+"px",t.$.splitter.className=e.className,t.$.splitter.style.left=i.left-r.left+"px",t.$.splitter.style.top=i.top-r.top+"px",e.setAttribute("drag",""),t.$.splitter.setAttribute("drag","")};if(s.classList.contains("last")){let i=e[m.clientPos]-t._resizeDetails.splitterRect[m.pos],r=o[m.size]-u;if(i>r&&(i=r,s.classList.add("error")),a){const e=parseInt(l.getAttribute("min"));let t=a[m.size]-e;i<-t&&(i=-t,s.classList.add("error"))}s.style[m.near]=i+"px";const d=n[m.offsetSize]-i;if(n.setAttribute("size",d),l){const e=n[m.offsetSize]+l[m.offsetSize]-d;l.setAttribute("size",e)}}else{let i=-e[m.clientPos]+t._resizeDetails.splitterRect[m.pos],r=o[m.size]-u;if(i>r&&(i=r,s.classList.add("error")),d){const e=parseInt(c.getAttribute("min"));let t=-d[m.size]+e;i<t&&(i=t,s.classList.add("error"))}s.style[m.far]=i+"px";const a=n[m.offsetSize]-i;if(n.setAttribute("size",a),c){const e=c[m.offsetSize]+n[m.offsetSize]-a;c.setAttribute("size",e)}}f(s)}}_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)}}_keyUpHandler(e){const t=this;if("Escape"===e.key){if(t._dragDetails&&(t._dragDetails.feedback.remove(),t._dragDetails.overlay.remove(),t._dragDetails=null,t._handleDropArea(null)),t._resizeDetails){const e=t._resizeDetails;return e.splitter.classList.contains("last")?e.previousItem.size=e.previousItemSize:e.nextItem.size=e.nextItem.previousItemSize,e.item.size=e.itemSize,t.refresh(),t._handleItemClick(e.item),void(t._resizeDetails=null)}}else"Delete"===e.key&&t._selectedItem&&t._removeLayoutItem(t._selectedItem)}_endDrag(){const e=this;if(e._handleDropArea(null),!e._dragDetails.dragging)return void(e._dragDetails=null);const t=e._dragDetails.current,i=e._dragDetails.element,r=e._dragDetails.position;if(e._handleDropArea(null),t){if(e._addTabLayoutItem(t,r,i),e._removeLayoutItem(i),t.parentElement&&1===Array.from(t.parentElement.parentElement.children).filter((e=>!!e.classList.contains("smart-layout-group"))).length){const i=t.parentElement,r=i.parentElement,s=r.parentElement;if("root"!==r.getAttribute("data-id")&&"root"!==s.getAttribute("data-id")&&s!==e){const e=Array.from(s.children).indexOf(i.parentElement);e>=0?s.insertBefore(i,s.children[e]):s.appendChild(i),r.remove()}}e.refresh(),e._updateSplitter(),requestAnimationFrame((()=>{e.classList.add("outline"),e.querySelectorAll(".smart-element").forEach((e=>{e.$.fireEvent("resize")}))}))}e.$.fireEvent("stateChange",{type:"insert",item:i}),e._dragDetails.feedback.remove(),e._dragDetails.overlay.remove(),e._dragDetails=null}_documentUpHandler(e){const t=this,i=Smart.Utilities.Core.isMobile,s=i?document.elementFromPoint(e.pageX-window.pageXOffset,e.pageY-window.pageYOffset):e.originalEvent.target;if(2!==e.button){if(t._dragDetails&&t._endDrag(e),t._resizeDetails){const e=t._resizeDetails;return e.item&&(e.item.style.overflow=""),e.previousItem&&(e.previousItem.style.overflow=""),e.nextItem&&(e.nextItem.style.overflow=""),t.refresh(),t._handleItemClick(e.item),t._resizeDetails=null,void t.querySelectorAll(".smart-element").forEach((e=>{e.$.fireEvent("resize")}))}if(t.contains(s)&&(t.classList.add("outline"),t._target&&!s.item&&(s instanceof r?t._handleItemClick(s):t._handleItemClick(s.closest(".smart-layout-item"))),t._target)){if(t._target!==s)return void delete t._target;if(!e.button&&s.closest(".smart-layout-buttons-container")){const i=e.originalEvent.target;t._handleButtonClick(i.item,i.position)}else s.closest(".smart-layout-context-menu")&&(!i&&!e.button||i)&&t._handleMenuItemClick(s.closest(".smart-layout-context-menu-item"));delete t._target}}}_documentSelectStartHandler(e){this._target&&e.preventDefault()}_getDataSource(i,r,s){const n=this;let o=[];s||(s=0),r||(r="");for(let a=0;a<i.length;a++){const l=i[a],d={label:l.label,id:l.getAttribute("data-id"),orientation:l.orientation,size:l.size,min:l.min,type:l.type,modifiers:l.modifiers,position:l.position};if(l.removeAttribute("index"),l instanceof t){if(o.push(d),d.index=""!==r?r+"."+s:s.toString(),l.setAttribute("index",d.index),l.items){const e=n._getDataSource(l.items,d.index,0);d.items=e}}else if(l instanceof e)if(l.items){const e=n._getDataSource(l.items,r,s);o=o.concat(e)}else d.index=""!==r?r+"."+s:s.toString(),l.setAttribute("index",d.index),o.push(d);s++}return o}_getLayout(){const e=this,i=arguments.length?arguments[0]:e.$.itemsContainer;e._buttons&&e._buttons.remove(),e._dropArea&&e._dropArea.remove();const r=e.querySelectorAll(".smart-layout-splitter");for(let t=0;t<r.length;t++){const i=r[t];i!==e.$.splitter&&i.remove()}i.items=Array.from(i.children),i.items=i.items.filter((e=>e!==i.tabs&&e.hasAttribute("data-id")));const s=i.items.map((function(i){if(i.classList.contains("smart-layout-tab-strip"))return null;const r=i,s=i instanceof t?i:null;return s&&(r.items=e._getLayout(s)),r}));if(i!==e.$.itemsContainer)return s.filter((e=>null!==e&&e!==i.tabs));const n=[],o=i;return o.items=s.filter((e=>null!==e&&e!==i.tabs)),n.push(o),n}_updateSplitter(){const e=this;e._buttons&&e._dragDetails&&e._buttons.remove(),e._removeSplitter();const t=e.querySelectorAll("[data-id]");for(let i=0;i<t.length;i++){const r=t[i];if("root"!==r.getAttribute("data-id")){if(r.hasAttribute("role")){const e=r.getAttribute("role");if("gridcell"===e||"row"===e||"columnheader"===e||"rowheader"===e)continue}r.setAttribute("hover",""),e._handleSplitter(r)}}}_hideSplitter(){const e=this.querySelectorAll("[data-id]");for(let t=0;t<e.length;t++){e[t].removeAttribute("hover")}}_removeSplitter(){const e=this,t=e.querySelectorAll(".smart-layout-splitter");for(let i=0;i<t.length;i++){const r=t[i];r!==e.$.splitter&&r.remove()}e._hideSplitter()}_handleItemClick(e){const t=this,i=t.selectedIndex;let r=null;return e?(r=e instanceof HTMLElement?e:t.querySelector("[data-id="+e.id+"]"),r&&r.readonly?(t._closeContextMenu(),void(t.selectedIndex=null)):(t.querySelectorAll("[data-id]").forEach((e=>e.removeAttribute("selected"))),t._closeContextMenu(),void(r?(t.selectedIndex=r.getAttribute("index"),r.setAttribute("selected",""),r.setAttribute("hover",""),t._selectedItem=r,r.classList.contains("smart-hidden")&&t.refresh(),t._handleButtonsVisibility(r),i!==t.selectedIndex&&t.$.fireEvent("change",{selectedIndex:t.selectedIndex,oldSelectedIndex:i}),t._updateSplitter()):t.refresh()))):(t._closeContextMenu(),t.selectedIndex=null,t.querySelectorAll("[data-id]").forEach((e=>e.removeAttribute("selected"))),void(t._selectedItem=null))}_handleButtonClick(e,t){const i=this,r=i._addLayoutItem(e,t);i.$.fireEvent("stateChange",{type:"insert",item:r}),i._handleItemClick(r,!0)}_handleMenuItemClick(e){const t=this;if(!e||e.hasAttribute("disabled"))return;const i=e.getAttribute("value"),r=t._contextMenu;t.$.fireEvent("menuItemClick",{target:r?r._target:null,item:e,label:e.textContent,value:i});const s=r._target;s&&("select"===i&&t._handleItemClick(s.parentElement?s.parentElement:s),"delete"===i&&t._removeLayoutItem(s))}_removeLayoutItem(t){const i=this;if("root"!==t.getAttribute("data-id")){if(t instanceof e&&1===t.parentElement.items.length){let e=t.parentElement,r=e;for(;e&&e.items&&1===e.items.length&&"root"!==e.getAttribute("data-id");)r=e,e=e.parentElement;"root"!==r.getAttribute("data-id")?r.remove():i.allowLiveSplit&&r.appendChild(document.createElement("smart-layout-item"))}else t.remove();i.refresh(),i.$.fireEvent("stateChange",{type:"delete",item:t})}}refresh(){const e=this;if(e._isUpdating)return;e.dataSource=e._getDataSource(e._getLayout()),e.$.splitter.className="smart-visibility-hidden smart-layout-splitter";const t=t=>{const s=e.getItem(t.getAttribute("index"));if(!s)return;t.style.gridTemplateColumns="",t.style.gridTemplateRows="";let n="",o=0,a=0;if(t instanceof i){t.tabs&&t.tabs.remove();const i=document.createElement("div");i.classList.add("smart-layout-tab-strip"),e._selectedItem&&t.contains(e._selectedItem)&&e._selectedItem instanceof r&&(t.selectedIndex=Math.max(0,t.items.indexOf(e._selectedItem))),t.selectedIndex>=t.children.length&&(t.selectedIndex=0);for(let r=0;r<t.children.length;r++){const n=t.children[r],o=e.getItem(n.getAttribute("index"));if(!o)continue;const a=document.createElement("div");a.classList.add("smart-layout-tab"),a.innerHTML="<label>"+o.label+'</label><span class="smart-close-button"></span>',i.appendChild(a),n.setAttribute("tab",""),n.classList.add("smart-hidden"),a.content=n,a.item=o,a.group=s,n.modifiers?-1===n.modifiers.indexOf("close")&&a.querySelector(".smart-close-button").classList.add("smart-hidden"):a.querySelector(".smart-close-button").classList.add("smart-hidden"),void 0!==t.selectedIndex&&r!==t.selectedIndex||(a.classList.add("selected"),n.classList.remove("smart-hidden"),t.selectedIndex=r),a.onpointerup=function(i){i.target.classList.contains("smart-close-button")&&a.close&&(t.selectedIndex=0,e._removeLayoutItem(e._selectedItem),e._handleItemClick(parent))},a.onpointerdown=function(t){const i=this.closest(".smart-layout-group");e._handleItemClick(this.content),a.close=!1,t.target.classList.contains("smart-close-button")?a.close=!0:o.modifiers&&o.modifiers.indexOf("drag")>=0&&e._beginDrag(i,this,t)}}t.tabs=i,"top"===s.position||"left"===s.position?t.insertBefore(i,t.firstChild):t.appendChild(i)}else{for(var l=0;l<t.children.length;l++){var d=t.children[l];if(d.hasAttribute("size")){var c=d.getAttribute("size"),u=parseFloat(c),p="vertical"===t.orientation?t.offsetWidth:t.offsetHeight,m=c.indexOf("%")>=0?parseFloat(c):parseFloat(u/p*100);if(o+=m,a++,a===t.children.length){if(o<100){n+="1fr ",o=100;continue}o>100&&(o-=m,m=100-o,o=100)}else if(o>100||0===m){a=t.children.length,o=0;break}n+=m+"% "}else n+="1fr "}if(a===t.children.length&&(o<99||o>100)){n="";for(let e=0;e<t.children.length;e++){t.children[e].removeAttribute("size"),n+="1fr "}}"vertical"===t.orientation?t.style.gridTemplateColumns=n:t.style.gridTemplateRows=n}t.items=Array.from(t.children),t.items=t.items.filter((e=>e!==t.tabs))},s=e.querySelectorAll(".smart-layout-group");for(let e=0;e<s.length;e++)t(s[e])}_beginDrag(e,t,i){const r=this;r._dragDetails&&r._dragDetails.feedback.remove();const s=document.createElement("div"),n=document.createElement("div"),o=e.querySelector(".smart-layout-tab-strip");let a="";if(o)for(let t=0;t<Array.from(o.children).length;t++)t===e.selectedIndex&&(a=o.children[t].innerText);s.innerHTML=`<smart-layout><smart-tab-layout-group><smart-tab-layout-item label="${a}"></smart-tab-layout-item></smart-tab-layout-group></smart-layout>`,r._feedback=s,r._feedback.classList.add("smart-layout-feedback","smart-layout"),n.classList.add("smart-layout-overlay"),r._dragDetails={element:t.content,item:t.item,layoutGroup:t.group,parent:e,overlay:n,feedback:s,pageX:i.pageX,pageY:i.pageY}}moveChildren(e,t){t.innerHTML="";let i=e;for(;i.firstChild;){const e=i.firstChild;t.appendChild(e)}}createLayoutItem(e,t){const i=this;return"layoutItem"!==e&&e?"tabLayoutItem"!==e&&e?"tabLayoutGroup"===e?(e=>{const t=document.createElement("smart-tab-layout-group"),r="top"===e||"bottom"===e?"horizontal":"vertical";return t.setAttribute("orientation",r),t.orientation=r,i.$.fireEvent("createGroup",{item:t,type:"tabLayoutGroup"}),t})(t):(e=>{const t=document.createElement("smart-layout-group"),r="top"===e||"bottom"===e?"horizontal":"vertical";return i.$.fireEvent("createGroup",{item:t,type:"layoutGroup"}),t.setAttribute("orientation",r),t.orientation=r,t})(t):(()=>{const e=document.createElement("smart-tab-layout-item");return e.innerHTML="",i.$.fireEvent("createItem",{item:e,type:"tabLayoutItem"}),e})():(()=>{const e=document.createElement("smart-layout-item");return e.innerHTML="",i.$.fireEvent("createItem",{item:e,type:"layoutItem"}),e})()}_addTabLayoutItem(s,n,o){const a=this,l=a.createLayoutItem("tabLayoutItem"),d=s.closest("smart-tab-layout-group");let c;o&&(l.label=o.label,l.modifiers=o.modifiers,a.moveChildren(o,l));const u=e=>{for(let t=0;t<e.children.length;t++){e.children[t].removeAttribute("size")}e.removeAttribute("size")},p=e=>{if(s.removeAttribute("size"),s.querySelector("smart-layout-group"))a._addLayoutItem(s.querySelector("smart-layout-group"),e);else{c=a.createLayoutItem("layoutGroup",e);const t=a.createLayoutItem();a.moveChildren(s,t),"top"===e||"left"===e?(c.appendChild(a.createLayoutItem()),c.appendChild(t)):(c.appendChild(t),c.appendChild(a.createLayoutItem())),s.appendChild(c)}},m=(e,t)=>{const i=s.parentElement,r=s,n=a.createLayoutItem("layoutGroup",t);i.insertBefore(n,r),"top"===t||"left"===t?(n.append(e),n.appendChild(r)):(n.appendChild(r),n.append(e)),"root"===r.getAttribute("data-id")&&(r.setAttribute("data-id",n.getAttribute("data-id")),n.setAttribute("data-id","root"),a.$.itemsContainer=n),u(r),u(i)};if(o)switch(n){case"center":if(s instanceof i||s instanceof r)d.appendChild(l);else{const i=a.createLayoutItem("tabLayoutGroup","top");i.appendChild(l),s instanceof t&&!(s instanceof r)?(s.appendChild(i),u(s)):s instanceof e&&(c=a.createLayoutItem("layoutGroup"),s.parentElement.insertBefore(c,s),c.appendChild(s),c.appendChild(i),u(c))}break;case"left":case"right":{const e=a.createLayoutItem("tabLayoutGroup","top");e.appendChild(l),"root"===s.getAttribute("data-id")?(e.position=n,m(e,n)):m(e,n)}break;case"top":case"bottom":{const e=a.createLayoutItem("tabLayoutGroup","top");e.appendChild(l),"root"===s.getAttribute("data-id")?(e.position=n,m(e,n)):m(e,n);break}}else{switch(n){case"center":s instanceof i||s instanceof r?d.appendChild(l):p();break;case"left":case"right":if(s instanceof i){const e=s.querySelector("smart-tab-layout-item");e&&"left"===n?s.insertBefore(l,e):s.appendChild(l)}else if(s instanceof r){const e=a.createLayoutItem("tabLayoutGroup","top"),t=s.parentElement;e.appendChild(l),c=a.createLayoutItem("layoutGroup"),t.parentElement.insertBefore(c,t),"right"===n?(c.appendChild(t),c.appendChild(e)):"left"===n&&(c.appendChild(e),c.appendChild(t))}else if(o){const i=a.createLayoutItem("tabLayoutGroup","top");i.appendChild(l),s instanceof t?s.insertBefore(s.firstChild,i):s instanceof e&&(c=a.createLayoutItem("layoutGroup"),c.orientation=d.orientation,c.setAttribute("orientation",d.orientation),s.removeAttribute("size"),s.parentElement.insertBefore(c,s),c.appendChild(s),c.appendChild(i))}else p(n);break;case"top":case"bottom":s instanceof i?(c=a.createLayoutItem("layoutGroup","top"),s.removeAttribute("size"),s.parentElement.insertBefore(c,s),"top"===n?(c.appendChild(a.createLayoutItem()),c.appendChild(s)):(c.appendChild(s),c.appendChild(a.createLayoutItem()))):p(n)}a.refresh()}}_addLayoutItem(s,n,o){const a=this;if(!s)return;const l=e=>{for(let t=0;t<e.children.length;t++){e.children[t].removeAttribute("size")}e.removeAttribute("size")};if(s instanceof r||s instanceof i||o&&o instanceof r)return a._addTabLayoutItem(s,n,o);const d=a.createLayoutItem(),c=s.closest(".smart-layout-group");let u;if(o&&a.moveChildren(o,d),"center"===n){if(s instanceof t)return u=c,u.appendChild(d),l(u),a.refresh(),d;if(s instanceof e)return u=a.createLayoutItem("layoutGroup"),u.orientation=c.orientation,u.setAttribute("orientation",c.orientation),s.removeAttribute("size"),s.parentElement.insertBefore(u,s),u.appendChild(s),u.appendChild(d),a.refresh(),u}if("vertical"===c.orientation&&("left"===n||"right"===n)||"horizontal"===c.orientation&&("top"===n||"bottom"===n))if(u=c,s instanceof t)"left"===n||"top"===n?u.insertBefore(d,u.children[0]):u.appendChild(d),l(s);else{const e=u.items,t=Math.max(0,e.indexOf(s)+("top"===n||"left"===n?0:1));u.insertBefore(d,e[t]),l(u)}else if(s instanceof t){const e=s.parentElement,t=s,i=a.createLayoutItem("layoutGroup",n);e.insertBefore(i,t),"top"===n||"left"===n?(i.append(d),i.appendChild(t)):(i.appendChild(t),i.append(d)),"root"===t.getAttribute("data-id")&&(t.setAttribute("data-id",i.getAttribute("data-id")),i.setAttribute("data-id","root"),a.$.itemsContainer=i),l(e)}else u=a.createLayoutItem("layoutGroup",n),c.insertBefore(u,s),"top"===n||"left"===n?(u.appendChild(d),u.appendChild(s)):(u.appendChild(s),u.appendChild(d)),l(u);return a.refresh(),d}_handleButtonsVisibility(e){const t=this;if(t._buttons||(t._buttons=document.createElement("div"),t._buttons.classList.add("smart-layout-buttons-container"),t._buttons.innerHTML='<div role="button" position="top"></div>\n <div role="button" position="bottom"></div>\n <div role="button" position="center"></div>\n <div role="button" position="left"></div>\n <div role="button" position="right"></div>'),e||!t._buttons.parentElement){if(e){const i=e._buttonPosition||[],r=t._buttons.children;for(let t=0;t<r.length;t++){const s=r[t];s.position=s.getAttribute("position"),s.item=e,i.length&&i.indexOf(s.getAttribute("position"))<0?s.classList.add("smart-hidden"):s.classList.remove("smart-hidden"),s.onmouseenter=()=>{s.setAttribute("hover","")},s.onmouseleave=()=>{s.removeAttribute("hover")}}t.allowLiveSplit&&t._buttons.parentElement!==e&&e.appendChild(t._buttons)}}else t._buttons.parentElement.removeChild(t._buttons)}_handleDropArea(e,t="center"){const i=this,r=e=>{switch(e){case"left":i._dropArea.style.top="0px",i._dropArea.style.left="0px",i._dropArea.style.width="50%",i._dropArea.style.height="100%";break;case"right":i._dropArea.style.top="0px",i._dropArea.style.left="calc(100% - 50%)",i._dropArea.style.width="50%",i._dropArea.style.height="100%";break;case"top":i._dropArea.style.top="0px",i._dropArea.style.left="0px",i._dropArea.style.width="100%",i._dropArea.style.height="50%";break;case"bottom":i._dropArea.style.top="calc(100% - 50%)",i._dropArea.style.left="0px",i._dropArea.style.width="100%",i._dropArea.style.height="50%";break;case"center":i._dropArea.style.top="0px",i._dropArea.style.left="0px",i._dropArea.style.width="100%",i._dropArea.style.height="100%"}};i._dropArea&&i._dropArea.parentElement===e?r(t):(i._dropArea&&i._dropArea.remove(),i._dragDetails&&e&&(i._dropArea=document.createElement("div"),i._dropArea.classList.add("smart-layout-drop-area"),e.appendChild(i._dropArea),i._dropArea.style.opacity=1,r(t)))}_handleSplitter(e){const t=this;if(!e)return;if(e.hasAttribute("tab")&&(e=e.parentElement),e._splitter&&e._splitter.remove(),e._splitter||(e._splitter=document.createElement("div")),t._dragDetails&&t._dragDetails.dragging)return void e._splitter.remove();if(-1===e.modifiers.indexOf("resize"))return;e.appendChild(e._splitter);const i=e.parentElement;if(i){e._splitter.className="smart-layout-splitter",e._splitter.item=e,e._splitter.removeAttribute("drag");const r=i.orientation;e.nextElementSibling&&e.nextElementSibling.hasAttribute("data-id")?e._splitter.classList.add(r):e.previousElementSibling&&e.previousElementSibling.hasAttribute("data-id")&&(e._splitter.classList.add(r),e._splitter.classList.add("last"));(e=>{e.style.top="",e.style.left="",e.style.bottom="",e.style.right="",e.onpointerdown=e=>{const i=e.target.item;i.style.overflow="hidden",t._resizeDetails={splitter:e.target,splitterRect:e.target.getBoundingClientRect(),itemRect:i.getBoundingClientRect(),item:i,itemSize:i.size,group:i.parentElement,clientX:e.clientX,clientY:e.clientY},t._selectedItem!==i&&(t.querySelectorAll("[data-id]").forEach((e=>e.removeAttribute("selected"))),t.selectedIndex=i.getAttribute("index"),i.setAttribute("selected",""),t._selectedItem=i,t._handleButtonsVisibility(i)),i.previousElementSibling&&i.previousElementSibling.hasAttribute("data-id")?(t._resizeDetails.previousItemRect=i.previousElementSibling.getBoundingClientRect(),t._resizeDetails.previousItem=i.previousElementSibling,t._resizeDetails.previousItemSize=i.previousElementSibling.size,t._resizeDetails.previousItem.style.overflow="hidden"):(t._resizeDetails.previousItemRect=null,t._resizeDetails.previousItem=null),i.nextElementSibling&&i.nextElementSibling.hasAttribute("data-id")?(t._resizeDetails.nextItemRect=i.nextElementSibling.getBoundingClientRect(),t._resizeDetails.nextItem=i.nextElementSibling,t._resizeDetails.nextItemSize=i.nextElementSibling.size,t._resizeDetails.nextItem.style.overflow="hidden"):(t._resizeDetails.nextItemRect=null,t._resizeDetails.nextItem=null)}})(e._splitter)}}})})();
68
68
  Smart("smart-list-menu",class extends Smart.Menu{static get properties(){return{displayLoadingIndicator:{value:!1,type:"boolean"},dropDownPosition:{value:"auto",allowedValues:["top-left","top-right","bottom-left","bottom-right","auto"],type:"string"},enableMouseWheelAction:{value:!0,type:"boolean"},filterable:{value:!1,type:"boolean"},filterInputPlaceholder:{value:"",type:"string"},filterMember:{value:"label",type:"string"},filterMode:{value:"containsIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string"},grouped:{value:!1,type:"boolean"},loadingIndicatorPlaceholder:{value:"Loading...",type:"string"},loadingIndicatorPosition:{value:"center",allowedValues:["bottom","center","top"],type:"string"},scrollMode:{value:"scrollButtons",allowedValues:["scrollbar","scrollButtons"],type:"string"}}}static get listeners(){return{resize:"_resizeHandler","backButton.click":"_backButtonClickHandler","filterInput.keyup":"_filterInputKeyupHandler","mainContainer.down":"_mainContainerDownHandler","mainContainer.move":"_mainContainerMoveHandler","mainContainer.swipeleft":"_mainContainerSwipeHandler","mainContainer.swiperight":"_mainContainerSwipeHandler","mainContainer.touchmove":"_mainContainerTouchmoveHandler","mainContainer.touchstart":"_mainContainerTouchstartHandler","view.click":"_viewHandler","view.mouseout":"_viewHandler","view.mouseover":"_viewHandler","view.transitionend":"_viewHandler"}}static get styleUrls(){return["smart.listmenu.css"]}template(){return`<div id="container" role="presentation">\n <div id="hamburgerIcon" class="smart-hamburger-icon smart-hidden" role="button" aria-label="Toggle minimized menu" aria-haspopup="true">\n <div id="hamburgerIconLineTop" class="smart-hamburger-icon-line smart-hamburger-icon-line-top" role="presentation"></div>\n <div id="hamburgerIconLineCenter" class="smart-hamburger-icon-line smart-hamburger-icon-line-center" role="presentation"></div>\n <div id="hamburgerIconLineBottom" class="smart-hamburger-icon-line smart-hamburger-icon-line-bottom" role="presentation"></div>\n <div id="customIconContainer" class="smart-hamburger-icon-custom-container smart-hidden" role="presentation"></div>\n </div>\n <div id="view" class="smart-list-menu-view" role="presentation">\n <div id="header" class="smart-header smart-hidden" role="heading" aria-level="1">\n <smart-button id="backButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable right-to-left="[[rightToLeft]]" aria-label="Back">\n <div id="backButtonArrow" class="smart-arrow ${this.rightToLeft?"smart-arrow-right":"smart-arrow-left"}" aria-hidden="true"></div>\n </smart-button>\n <div id="title" class="smart-title"></div>\n </div>\n <div class="smart-list-menu-filter-input-container smart-hidden" id="filterInputContainer" role="presentation"><input id="filterInput" class="smart-filter-input" disabled="[[disabled]]" placeholder="[[filterInputPlaceholder]]" type="text" role="searchbox" aria-label="[[filterInputPlaceholder]]" /></div>\n <smart-repeat-button id="scrollButtonNear" class="smart-menu-scroll-button smart-spin-button smart-scroll-button-near smart-hidden" animation="[[animation]]" unfocusable aria-label="Scroll up">\n <div id="arrowNear" class="smart-arrow smart-arrow-up" right-to-left="[[rightToLeft]]"></div>\n </smart-repeat-button>\n <smart-scroll-viewer id="mainContainer" class="smart-menu-main-container" horizontal-scroll-bar-visibility="hidden" right-to-left="[[rightToLeft]]" role="presentation">\n <content></content>\n </smart-scroll-viewer>\n <smart-repeat-button id="scrollButtonFar" class="smart-menu-scroll-button smart-spin-button smart-scroll-button-far smart-hidden" animation="[[animation]]" unfocusable right-to-left="[[rightToLeft]]" aria-label="Scroll down">\n <div id="arrowFar" class="smart-arrow smart-arrow-down"></div>\n </smart-repeat-button>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" role="presentation">\n <span id="loadingIndicator" class="smart-loader" role="img" aria-label="[[loadingIndicatorPlaceholder]]"></span>\n <span id="loadingIndicatorPlaceHolder" class="smart-loader-label smart-hidden">[[loadingIndicatorPlaceholder]]</span>\n </div>\n </div>\n </div>`}attached(){const e=this;super.attached(),e.isCompleted&&null!==e.dropDownAppendTo&&e._minimized&&e._dropDownParent.appendChild(e.$.view)}detached(){const e=this;super.detached(),e._close(),null!==e.dropDownAppendTo&&e._minimized&&e._dropDownParent.removeChild(e.$.view)}addItem(e,t){const i=this;if(!(e instanceof Smart.MenuItem||e instanceof Smart.MenuItemsGroup))return;let r,n,o,a;if(void 0===t)r=void 0,n=1,o=t=i.$.mainContainer,a=i._topLevelFilter;else{if("string"==typeof t&&(t=i.getItem(t)),void 0===t||!(t instanceof Smart.MenuItemsGroup)||!i.contains(t)&&t.closest(".smart-list-menu-view")!==i.$.view)return;r=t,n=t.level+1,o=t.itemContainer,a=t.filter}if(i._createItemHTMLStructure(e,n,t,i._getCurrentViewItems(r).length,0),e instanceof Smart.MenuItemsGroup&&i._processHTML(e,n+1),i._view!==t&&!t.$.hasClass("smart-hidden")&&t.offsetHeight>0&&t.offsetWidth>0&&(!i._view&&!i.$.mainContainer.contains(t)||i._view&&!i._view.contains(t))&&e.$.addClass("smart-hidden"),i.grouped){let e;e=o instanceof Smart.ScrollViewer&&o.isRendered?Array.from(o.$.scrollViewerContentContainer.children):Array.from(o.children);for(let t=e.length-1;t>=0;t--)e[t].$.hasClass("smart-list-menu-group-label")&&o.removeChild(e[t]);i._unsortItems(t,!0)}if(o.appendChild(e),i.grouped){const e=i._view;i._applyGrouping(t,!0),i._home(),e&&i.changePage(e.path)}i.filterable&&void 0!==a&&""!==a&&null===i._findItem(e,a)&&(e.$.addClass("smart-hidden"),e.hidden=!0),i._toggleFilterInputGroupLabelVisibility(),i._checkOverflow()}back(e){const t=this,i=t.animation,r=!1===e&&"none"!==i;r&&(t.animation="none"),t._backButtonClickHandler(),r&&(t.animation=i)}changePage(e){const t=this,i=t.getItem(e);if(void 0===i||i instanceof Smart.MenuItem||i.hidden)return;const r=[i];let n=i.parentItem,o=0;for(t._discardKeyboardHover();n;)r.unshift(n),n=n.parentItem;if(t._view){const e=r.indexOf(t._view);-1===e?t._home():o=e+1}for(let e=o;e<r.length&&!r[e].disabled&&!r[e].hidden;e++)t._menuItemsGroupSelectionHandler(r[e],{type:"expand"},!0)}maximize(){const e=this;if(e._minimized){if(e._positionDetection.removeOverlay(),e._minimized=!1,e._minimizedDropDownOpened&&(e.$hamburgerIcon.removeClass("smart-close-button"),e._minimizedDropDownOpened=!1),null!==e.dropDownAppendTo&&e._appendMinimizedContainerToMenu(e.$.view,null),e.$view.removeClass("smart-visibility-hidden"),e.$view.removeClass("smart-list-menu-view-minimized"),e.$hamburgerIcon.addClass("smart-hidden"),e.removeAttribute("minimized"),e.enableShadowDOM){e.$.view.id=e.$.view.getAttribute("smart-id");const t=e.$.view.querySelectorAll("[smart-id]");for(let e=0;e<t.length;e++)t[e].id=t[e].getAttribute("smart-id")}e.$.mainContainer.scrollTop=0,e._checkOverflow(),e.$.hamburgerIcon.removeAttribute("aria-expanded"),e.$.hamburgerIcon.removeAttribute("aria-owns"),e.$.view.setAttribute("role","presentation"),e.$.view.removeAttribute("aria-orientation"),e.setAttribute("role","menu")}}minimize(){const e=this;if(!e._minimized){if(e.$view.addClass("smart-visibility-hidden"),e.enableShadowDOM){e.$.view.removeAttribute("id");const t=e.$.view.querySelectorAll("[smart-id]");for(let e=0;e<t.length;e++)t[e].removeAttribute("id")}e._edgeMacFF&&e.$view.addClass("not-in-view"),e.$hamburgerIcon.removeClass("smart-hidden"),setTimeout((function(){null!==e.dropDownAppendTo&&e._appendMinimizedContainerToExternalElement(e.$.view),e.$view.addClass("smart-list-menu-view-minimized"),e.$.mainContainer.scrollTop=0,e._checkOverflow()}),0),e._minimized=!0,e.setAttribute("minimized",""),e.setAttribute("role","presentation"),e.removeAttribute("aria-orientation"),e.$.hamburgerIcon.setAttribute("aria-expanded",!1),e.$.hamburgerIcon.setAttribute("aria-owns",e.$.view.id),e.$.view.setAttribute("role","menu"),e.$.view.setAttribute("aria-orientation","vertical")}}removeItem(e){const t=this;if("string"==typeof e&&(e=t.getItem(e)),void 0===e||!(e instanceof Smart.MenuItem||e instanceof Smart.MenuItemsGroup)||!t.contains(e)&&e.closest(".smart-list-menu-view")!==t.$.view)return;const i=e.parentElement;for(;e.contains(t._view);)t._backButtonClickHandler(void 0,!0);const r=t._view;t.grouped&&(t._home(),t._discardGrouping()),i.removeChild(e),t._menuItems={},t._refreshItemPaths(t.$.mainContainer,!0,(function(e){return t._getCurrentViewItems(e===t.$.mainContainer?void 0:e)})),t.grouped&&(t._applyGrouping(t.$.mainContainer),r&&t.changePage(r.path)),t._toggleFilterInputGroupLabelVisibility(),t._checkOverflow()}propertyChangedHandler(e,t,i){if("disabled"===e||"dropDownOverlay"===e||"minimizeIconTemplate"===e||"minimizeWidth"===e||"unfocusable"===e)return void super.propertyChangedHandler(e,t,i);const r=this;switch(e){case"animation":r.$.view.setAttribute("animation",i);break;case"checkable":case"checkboxes":r._minimized&&null!==r.dropDownAppendTo&&(i?r.$.view.setAttribute(e,""):r.$.view.removeAttribute(e));break;case"checkMode":{const e=r.$.mainContainer;r._changeToRadioButtonMode(i,e.isRendered?e.$.scrollViewerContentContainer:e),r._minimized&&null!==r.dropDownAppendTo&&r.$.view.setAttribute("check-mode",i);break}case"dataSource":{r.$header.addClass("smart-hidden"),r.$mainContainer.removeClass("header-shown"),r._view=void 0;const e=r.querySelectorAll("smart-menu-items-group");e.length>0&&e.forEach((e=>{e.remove()})),r._menuItems={},r._topLevelFilter="",r._processDataSource(),r._toggleFilterInputGroupLabelVisibility(),r._checkOverflow();break}case"displayLoadingIndicator":if(i){const e=r.$.mainContainer.querySelector("[hover]");e&&e.removeAttribute("hover"),r._discardKeyboardHover(),r.$loadingIndicatorContainer.removeClass("smart-hidden")}else r.$loadingIndicatorContainer.addClass("smart-hidden");break;case"dropDownAppendTo":{const e=r._dropDownParent;if(r._positionDetection.getDropDownParent(),r._dropDownParent===e||!r._minimized)return;r._close(),null===i?r._appendMinimizedContainerToMenu(r.$.view,null):r._appendMinimizedContainerToExternalElement(r.$.view),r.$.mainContainer.scrollTop=0,r._checkOverflow();break}case"dropDownPosition":r._close(),r._minimized&&null!==r.dropDownAppendTo&&r.$.view.setAttribute("drop-down-position",i);break;case"filterable":if(r._toggleFilterInputGroupLabelVisibility(!0),!1===i){""!==r._topLevelFilter&&r._applyFilter("");for(let e=r._filteredLowerLevelGroups.length-1;e>=0;e--)r._applyFilter("",r._filteredLowerLevelGroups[e])}r._checkOverflow();break;case"filterMode":if(!r.filterable)return;""!==r._topLevelFilter&&r._applyFilter(r._topLevelFilter);for(let e=r._filteredLowerLevelGroups.length-1;e>=0;e--)r._applyFilter(r._filteredLowerLevelGroups[e].filter,r._filteredLowerLevelGroups[e]);break;case"grouped":r._home(),i?r._applyGrouping(r.$.mainContainer):r._discardGrouping(),r._toggleFilterInputGroupLabelVisibility(!1,!0),r._checkOverflow();break;case"loadingIndicatorPosition":null!==r.dropDownAppendTo&&r._minimized&&r.$.view.setAttribute("loading-indicator-position",i),"center"===i?r.$loadingIndicatorPlaceHolder.addClass("smart-hidden"):r.$loadingIndicatorPlaceHolder.removeClass("smart-hidden");break;case"overflow":r.$.mainContainer.verticalScrollBarVisibility="scroll"===i?"visible":i,r._handleOverflowChange();break;case"rightToLeft":i?(r.$backButtonArrow.removeClass("smart-arrow-left"),r.$backButtonArrow.addClass("smart-arrow-right")):(r.$backButtonArrow.removeClass("smart-arrow-right"),r.$backButtonArrow.addClass("smart-arrow-left")),i?r.$.view.setAttribute("right-to-left",""):r.$.view.removeAttribute("right-to-left"),Array.prototype.forEach.call(r.$.mainContainer.querySelectorAll(".smart-menu-items-group-arrow"),(e=>e.className="smart-menu-items-group-arrow "+(r.rightToLeft?"smart-arrow-left left":"smart-arrow-right right")));break;case"scrollMode":r.$.mainContainer.verticalScrollBarVisibility="scrollButtons"===i?"hidden":"scroll"===r.overflow?"visible":r.overflow,r._checkOverflow();break;case"theme":super.propertyChangedHandler(e,t,i),null!==r.dropDownAppendTo&&r._minimized&&(""!==t&&r.$view.removeClass(t),i&&r.$view.addClass(i))}}_appendGroupLabels(e,t){for(let i=0;i<e.length;i++){const r=document.createElement("div");r.$=Smart.Utilities.Extend(r),r.className="smart-list-menu-group-label",r.setAttribute("role","heading"),r.setAttribute("aria-level",1),r.innerHTML=e[i],r.groupChildren=t[i],t[i][0].parentElement.insertBefore(r,t[i][0]);for(let e=0;e<t[i].length;e++)t[i][e].groupLabel=r}}_applyFilter(e,t){const i=this,r=i._getCurrentViewItems(t);for(let n=0;n<r.length;n++){const o=i._findItem(r[n],e);o&&o.hidden?(o.hidden=!1,(t===i._view||void 0!==i._view&&void 0!==t&&!t.contains(i._view)||void 0===i._view)&&o.$.removeClass("smart-hidden")):o||(r[n].hidden=!0,r[n].$.addClass("smart-hidden"))}if(t){t.filter=e;const r=i._filteredLowerLevelGroups.indexOf(t);""===e?-1!==r&&i._filteredLowerLevelGroups.splice(r,1):-1===r&&i._filteredLowerLevelGroups.push(t)}else i._topLevelFilter=e}_backButtonClickHandler(e,t){const i=this,r=i._view;if(e&&e.stopPropagation(),!r||i.disabled&&e||i.displayLoadingIndicator||i._inTransition)return;let n=i.hasAnimation,o=i.animation,a=!1;n&&t&&(n=!1,a=!0,i.animation="none"),i._discardKeyboardHover(),i.$scrollButtonNear.addClass("smart-hidden"),i.$scrollButtonFar.addClass("smart-hidden"),i.$mainContainer.removeClass("scroll-buttons-shown"),r.firstElementChild.classList.remove("smart-hidden"),n?(i._inTransition=!0,r.container.$.addClass("no-transition"),r.container.$.addClass("smart-hidden"),r.$.addClass("right"),r.$.removeClass("right"),r.container.$.removeClass("no-transition")):(r.$.removeClass("smart-menu-items-group-opened"),r.container.$.addClass("smart-hidden")),i._showHideMenuItemsGroupSiblings(r,"removeClass",n),n?setTimeout((function(){r.container.style.top=r.parentElement.getBoundingClientRect().top-r.getBoundingClientRect().top+"px"}),0):a&&(i.animation=o),1===r.level?(i.$header.addClass("smart-hidden"),i.$mainContainer.removeClass("header-shown"),i._view=void 0):(i.$.title.innerHTML=r.parentItem.titleLabel,i._view=r.parentItem),i._toggleFilterInputGroupLabelVisibility(),i.$.mainContainer.scrollTop=0,n||i._checkOverflow(),e&&i.focus()}_bounceBottom(e){const t=this,i=t.$.mainContainer;function r(){i.scrollTop-=5,i.scrollTop>e?window.requestAnimationFrame(r):t.$mainContainer.removeClass("bounce-bottom")}t.$mainContainer.addClass("bounce-bottom"),window.requestAnimationFrame((function e(){i.scrollTop+=5,i.scrollTop!==i.scrollHeight-i.offsetHeight?window.requestAnimationFrame(e):window.requestAnimationFrame(r)}))}_bounceTop(){const e=this,t=e.$.mainContainer;function i(){t.scrollTop+=5,50!==t.scrollTop?window.requestAnimationFrame(i):(t.scrollTop=0,e.$mainContainer.removeClass("bounce-top"))}e.$mainContainer.addClass("bounce-top"),window.requestAnimationFrame((function e(){t.scrollTop-=5,t.scrollTop>0?window.requestAnimationFrame(e):window.requestAnimationFrame(i)}))}_checkOverflow(){const e=this,t=e.overflow,i=e.$.mainContainer,r=i instanceof Smart.ScrollViewer?i.$.content:i;if(r){if("hidden"!==t&&"scrollButtons"===e.scrollMode){const n=Math.round(r.scrollHeight)>Math.round(i.offsetHeight),o=Math.round(i.scrollTop)>0,a=Math.round(i.offsetHeight+i.scrollTop)<Math.round(r.scrollHeight);e.$.mainContainer.verticalScrollBarVisibility="hidden",n?"auto"===t?(e.$mainContainer.hasClass("scroll-buttons-shown")||e.$mainContainer.addClass("scroll-buttons-shown"),o?e.$scrollButtonNear.removeClass("smart-hidden"):e.$scrollButtonNear.addClass("smart-hidden"),a?e.$scrollButtonFar.removeClass("smart-hidden"):e.$scrollButtonFar.addClass("smart-hidden"),!1===(o&&a)?e.$mainContainer.addClass("one-button-shown"):e.$mainContainer.removeClass("one-button-shown"),e.disabled||(e.$.scrollButtonNear.disabled=!1,e.$.scrollButtonFar.disabled=!1)):(e.$scrollButtonNear.removeClass("smart-hidden"),e.$scrollButtonFar.removeClass("smart-hidden"),e.disabled?(e.$.scrollButtonNear.disabled=!0,e.$.scrollButtonFar.disabled=!0):(e.$.scrollButtonNear.disabled=!o,e.$.scrollButtonFar.disabled=!a)):!n&&"auto"===t&&e.$mainContainer.hasClass("scroll-buttons-shown")?(e.$mainContainer.removeClass("scroll-buttons-shown"),e.$mainContainer.removeClass("one-button-shown"),e.$scrollButtonNear.addClass("smart-hidden"),e.$scrollButtonFar.addClass("smart-hidden")):n||"scroll"!==t||(e.$.scrollButtonNear.disabled=!0,e.$.scrollButtonFar.disabled=!0)}else"scrollbar"===e.scrollMode&&(e.$mainContainer.removeClass("scroll-buttons-shown"),e.$mainContainer.removeClass("one-button-shown"),e.$scrollButtonNear.addClass("smart-hidden"),e.$scrollButtonFar.addClass("smart-hidden"));i.refresh()}}_updateScrollButtonVisibility(e,t,i){const r=this,n=r.overflow,o=r.$.mainContainer,a=e===r.$.mainContainer,s=a?o.$.content:e;if(a&&"hidden"===n)return void o.refresh();let l,d,c,m=!0,u=!0;if(t?(l="scrollLeft",d="offsetWidth",c="scrollWidth"):(l="scrollTop",d="offsetHeight",c="scrollHeight"),0===Math.round(e[l])&&(m=!1),Math.round(e[d]+e[l])>=Math.round(s[c])&&(u=!1),a&&"auto"!==n)"scroll"!==n||r.disabled||(i[0].disabled=!m,i[1].disabled=!u);else{if(m&&u)return i[0].$.removeClass("smart-hidden"),i[1].$.removeClass("smart-hidden"),e.classList.remove("one-button-shown"),void o.refresh();m?i[0].$.removeClass("smart-hidden"):i[0].$.addClass("smart-hidden"),u?i[1].$.removeClass("smart-hidden"):i[1].$.addClass("smart-hidden"),e.classList.add("one-button-shown")}o.refresh()}_close(){const e=this;e._discardKeyboardHover(!0),e._minimized&&e._minimizedDropDownOpened&&(e._positionDetection.removeOverlay(),e.$view.addClass("smart-visibility-hidden"),e._edgeMacFF&&(e.$.view.style.left="",e.$.view.style.top="",e.$view.addClass("not-in-view")),e.$hamburgerIcon.removeClass("smart-close-button"),e._minimizedDropDownOpened=!1,e.$.hamburgerIcon.setAttribute("aria-expanded",!1))}_createElement(){const e=this,t=e.$.mainContainer;e.$.title.id||(e.$.title.id=e.id+"Title"),e.$.view.id||(e.$.view.id=e.id+"View"),e.setAttribute("role","menu"),e.setAttribute("aria-labelledby",e.$.title.id),e.setAttribute("aria-orientation","vertical"),e.$.header.setAttribute("aria-labelledby",e.$.title.id),e.mode="vertical",t.verticalScrollBarVisibility="scroll"===e.overflow?"visible":e.overflow,t.refresh=e._scrollViewerRefresh,t._mouseWheelHandler=e._mouseWheelHandler.bind(e),t.onVerticalChange=()=>{"scrollButtons"===e.scrollMode&&e._updateScrollButtonVisibility(t,!1,[e.$.scrollButtonNear,e.$.scrollButtonFar]),t.scrollTop===t.scrollHeight&&e.$.fireEvent("scrollBottomReached")},e._positionDetection=new Smart.Utilities.PositionDetection(e),e._positionDetection.getDropDownParent(),null===e.dataSource&&e.$.mainContainer.firstElementChild instanceof HTMLUListElement&&e._processUList();const i=e.getElementsByTagName("smart-menu-item"),r=function(){e._setFocusable(),e._menuItems={},e._topLevelFilter="",e._filteredLowerLevelGroups=[],e.$.view.setAttribute("animation",e.animation),null===e.dataSource?e._processHTML(void 0,1):e._processDataSource(),e._toggleFilterInputGroupLabelVisibility(),"scroll"===e.overflow&&(e.$mainContainer.addClass("scroll-buttons-shown"),e.$scrollButtonNear.removeClass("smart-hidden"),e.$scrollButtonFar.removeClass("smart-hidden"),e._updateScrollButtonVisibility(e.$.mainContainer,!1,[e.$.scrollButtonNear,e.$.scrollButtonFar])),e._applyMinimizeIconTemplate(e.minimizeIconTemplate,null),null!==e.minimizeWidth&&e.offsetWidth<=e.minimizeWidth?e.minimize():e._checkOverflow(),e.displayLoadingIndicator&&e.$loadingIndicatorContainer.removeClass("smart-hidden"),"center"!==e.loadingIndicatorPosition&&e.$loadingIndicatorPlaceHolder.removeClass("smart-hidden"),e.__onCompleted&&(e._onCompleted=e.__onCompleted,e.__onCompleted=null,e._onCompleted())};0===i.length?r():(e._onCompleted&&(e.__onCompleted=e._onCompleted,e._onCompleted=null),e._ensureItemsReady(i,r))}_createMenuItemsGroupContainer(e,t){const i=document.createElement("div"),r=document.createElement("div");return i.className="smart-menu-drop-down smart-hidden",i.$=Smart.Utilities.Extend(i),i.level=t,i.setAttribute("level",t),i.setAttribute("role","menu"),i.menuItemsGroup=e,r.className="smart-menu-item-container",r.$=Smart.Utilities.Extend(r),r.container=i,r.menuItemsGroup=e,e.checkable&&r.setAttribute("checkable",""),r.setAttribute("check-mode",e.checkMode),i.itemContainer=r,i.appendChild(r),i}_discardGrouping(){const e=this,t=Array.from(e.$.view.getElementsByClassName("smart-list-menu-group-label"));for(let e=0;e<t.length;e++){let i=t[e];i.parentElement.removeChild(i)}e._unsortItems(e.$.mainContainer)}_discardKeyboardHover(){const e=this;e._focusedViaKeyboard&&(e._focusedViaKeyboard===e.$.backButton?(e.$.backButton.removeAttribute("hover"),e.$.backButton.$.button.removeAttribute("hover")):(e._focusedViaKeyboard.removeAttribute("focus"),e._focusedViaKeyboard.removeAttribute("hover")),e._focusedViaKeyboard=void 0)}_documentUpHandler(e){const t=this,i=e.originalEvent.target,r=e=>{"right"===e&&!t.rightToLeft||"left"===e&&t.rightToLeft?t._backButtonClickHandler():t._swipeDetails.target&&t._selectionHandler({target:t._swipeDetails.target},t._swipeDetails.target,!0)};if(delete t._dragStartDetails,t._swipeDetails){const i="pointercancel"===e.originalEvent.type;return"left"===t._swipeDetails.direction?(i||t._swipeDetails.start>e.pageX&&t._swipeDetails.start-e.pageX>t.offsetWidth/4)&&r(t._swipeDetails.direction):(i||t._swipeDetails.start<e.pageX&&e.pageX-t._swipeDetails.start>t.offsetWidth/4)&&r(t._swipeDetails.direction),void delete t._swipeDetails}i===t.$.filterInput||t.disabled||t.displayLoadingIndicator||!i.closest||(t.contains(i)||i.closest(".smart-list-menu-view")===t.$.view?!t.contains(i)&&i.closest(".smart-list-menu-view")!==t.$.view||t===document.activeElement||t.focus():t._close())}_ensureVisible(e){const t=this,i=t.$.mainContainer;if(!i.$.hasClass("scroll-buttons-shown")&&"hidden"!==t.overflow)return;const r=i.getBoundingClientRect(),n=e.getBoundingClientRect(),o=[t.$.scrollButtonNear,t.$.scrollButtonFar],a=i.scrollTop;(r.top>n.top||r.bottom<n.bottom)&&(i.scrollTop=e.offsetTop,t._updateScrollButtonVisibility(i,!1,o)),t._fireScrollBottomReachedEvent(a)}_fireScrollBottomReachedEvent(e){const t=this.$.mainContainer,i=t.scrollTop;e!==i&&i===t.scrollHeight-t.offsetHeight&&this.$.fireEvent("scrollBottomReached")}_getCurrentViewItems(e){const t=this;let i;if(void 0===e&&(i=t.$.mainContainer,i instanceof Smart.ScrollViewer&&(i=i.isRendered?i.$.scrollViewerContentContainer:i)),t.grouped){if(void 0===e)return Array.from(i.children).filter((e=>e instanceof Smart.MenuItem||e instanceof Smart.MenuItemsGroup));{const t=e.container.firstElementChild.children,i=[];for(let e=0;e<t.length;e++){let r=t[e];(r instanceof Smart.MenuItem||r instanceof Smart.MenuItemsGroup)&&i.push(r)}return i}}return void 0===e?i.children:e.container.firstElementChild.children}_sortItems(e){const t=this;if(!t.grouped)return;const i=[],r=t.$.mainContainer,n=[];let o;e instanceof Smart.MenuItemsGroup?o=e.container.firstElementChild:e===t.$.mainContainer&&(o=r instanceof Smart.ScrollViewer?r.$.content:r);const a=Array.from(o.children);a.sort((function(e,t){return e.label.localeCompare(t.label)}));for(let e=a.length-1;e>=0;e--)o.insertBefore(a[e],o.firstElementChild);for(let e=0;e<a.length;e++){const t=a[e],r=t.label.charAt(0),o=i.indexOf(r.toUpperCase());-1===o?(i.push(r.toUpperCase()),n.push([t])):n[o].push(t)}t._appendGroupLabels(i,n)}_home(){const e=this;for(;e._view;)e._backButtonClickHandler(void 0,!0)}_keydownHandler(e){const t=this,i=e.key;if(((t.shadowRoot||t.getRootNode()).activeElement||document.activeElement)!==t||-1===["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Enter","Escape","Home"," "].indexOf(i)||t.disabled||t.displayLoadingIndicator)return;e.preventDefault();const r=t._view,n=t.$.mainContainer;let o;o=r?r.itemContainer:n.isRendered?n.$.scrollViewerContentContainer:n;const a=t.$.backButton.hasAttribute("hover")?t.$.backButton:o.querySelector("[focus]");switch(i){case"ArrowDown":t._navigate("_getNextEnabledChild",a,o);break;case"ArrowLeft":case"ArrowRight":if("ArrowLeft"===i&&!t.rightToLeft||"ArrowRight"===i&&t.rightToLeft){t._backButtonClickHandler();break}("ArrowRight"===i&&!t.rightToLeft||"ArrowLeft"===i&&t.rightToLeft)&&a&&a instanceof Smart.MenuItemsGroup&&t._menuItemsGroupSelectionHandler(a,{type:"keydown"});break;case"ArrowUp":t._navigate("_getPreviousEnabledChild",a,o);break;case"End":case"Home":{if(r&&"Home"===i)return t.$.mainContainer.scrollTop=0,t._checkOverflow(),t.$.backButton.setAttribute("hover",""),t.$.backButton.$.button.setAttribute("hover",""),t._focusedViaKeyboard=t.$.backButton,void(a&&a.removeAttribute("focus"));const e="End"===i?t._getLastEnabledChild(o):t._getFirstEnabledChild(o);if(!e||a===e)return;a&&(a===t.$.backButton?(t.$.backButton.removeAttribute("hover"),t.$.backButton.$.button.removeAttribute("hover")):a.removeAttribute("focus")),t._hoverViaKeyboard(e);break}case"Enter":t._minimized&&!t._minimizedDropDownOpened?t._hamburgerIconClickHandler(void 0,t.$.view):a&&(a===t.$.backButton?t._backButtonClickHandler():t._selectionHandler({target:a}));break;case"Escape":t._minimized&&t._minimizedDropDownOpened&&!t._view?t._close():t._backButtonClickHandler();break;case" ":a&&(a===t.$.backButton?t._backButtonClickHandler():t._toggleItem(a))}}_mainContainerDownHandler(e){const t=this;!Smart.Utilities.Core.isMobile||t.disabled||t.displayLoadingIndicator||(t._dragStartDetails={startY:e.pageY,x:e.pageX,y:e.pageY,startTime:Date.now(),target:e.originalEvent.target})}_mainContainerHandler(){}_mainContainerMoveHandler(){}_mainContainerSwipeHandler(e){const t=this;if(!Smart.Utilities.Core.isMobile||t.disabled||t.displayLoadingIndicator||Math.abs(t._dragStartDetails.startY-e.pageY)>2)return;const i=e.originalEvent.target,r=i.closest("smart-menu-item"),n=i.closest("smart-menu-items-group");if("swiperight"===e.type&&!t.rightToLeft||"swipeleft"===e.type&&t.rightToLeft){const i=r||n;i&&(delete t._dragStartDetails,t._swipeDetails={direction:e.type.replace("swipe",""),start:e.pageX,target:i})}else("swipeleft"===e.type&&!t.rightToLeft||"swiperight"===e.type&&t.rightToLeft&&n&&null===r)&&(delete t._dragStartDetails,t._swipeDetails={direction:e.type.replace("swipe",""),start:e.pageX,target:n})}_mainContainerTouchmoveHandler(){}_mainContainerTouchstartHandler(){}_getRootDetails(e,t){const i=this;if(!e)return;if(!i.enableShadowDOM)return{activeElement:e.activeElement,isInsideElement:i.contains(t.target)};let r,n;for(;e&&(!r&&e.activeElement&&(r=e.activeElement),e.host===i&&(n=!0),e!==document);)e=e.host?e.host.getRootNode():e.getRootNode();return{activeElement:r,isInsideElement:n}}_menuItemsGroupSelectionHandler(e,t,i){const r=this,n=e.container,o=n.level,a=r._getRootDetails(t.target?t.target.getRootNode():null,t);if(r._view===e)return;if(r._discardKeyboardHover(),a&&a.activeElement!==r&&null!==r.dropDownAppendTo&&"click"===t.type&&!a.isInsideElement&&r.focus(),r._inTransition)return;if("click"===t.type&&!t.target.classList.contains("smart-menu-items-group-arrow")&&r._toggleItem(e))return void r._ripple(e,t);let s=r.hasAnimation,l=r.animation,d=!1;s&&i&&(s=!1,d=!0,r.animation="none"),2===o&&(r.$header.removeClass("smart-hidden"),r.$mainContainer.addClass("header-shown")),r.$.title.innerHTML=e.titleLabel,r._view=e,r._toggleFilterInputGroupLabelVisibility(),e.removeAttribute("hover"),e.removeAttribute("focus"),e.$.addClass("smart-menu-items-group-opened"),r._showHideMenuItemsGroupSiblings(e,"addClass",s),s?(r._inTransition=!0,e.firstElementChild.classList.add("animate"),setTimeout((function(){n.style.top=e.parentElement.getBoundingClientRect().top-e.getBoundingClientRect().top+"px"}),0)):e.firstElementChild.classList.add("smart-hidden"),n.$.removeClass("smart-hidden"),d&&(r.animation=l),r.$.mainContainer.scrollTop=0,s||r._checkOverflow(),r.$.fireEvent("expand",{item:e,label:e.label,path:e.path,value:e.value})}_mouseoutMouseoverHandler(e){const t=this;if(t.disabled||t.displayLoadingIndicator)return;const i=e.target.closest("smart-menu-item")||e.target.closest("smart-menu-items-group");null===i||t._view&&i.level<=t._view.level||i.disabled||i.templateApplied||(t._discardKeyboardHover(),"mouseover"===e.type?(i.setAttribute("hover",""),t._discardKeyboardHover(!0)):i.removeAttribute("hover"))}_navigate(e,t,i){const r=this;if(!t)return void("_getNextEnabledChild"===e?r._view?(r.$.backButton.setAttribute("hover",""),r.$.backButton.$.button.setAttribute("hover",""),r._focusedViaKeyboard=r.$.backButton):r._hoverViaKeyboard(r._getFirstEnabledChild(i)):r._hoverViaKeyboard(r._getLastEnabledChild(i)));let n;if("_getNextEnabledChild"===e&&t===r.$.backButton){if(n=r._getFirstEnabledChild(i),!n)return;r.$.backButton.removeAttribute("hover"),r.$.backButton.$.button.removeAttribute("hover")}else{if("_getPreviousEnabledChild"===e&&r._view&&t===r._getFirstEnabledChild(i))return r.$.backButton.setAttribute("hover",""),r.$.backButton.$.button.setAttribute("hover",""),r._focusedViaKeyboard=r.$.backButton,void t.removeAttribute("focus");n=r[e](t)}n&&(t.removeAttribute("focus"),r._hoverViaKeyboard(n))}_processHTML(e,t){const i=this,r=i.$.mainContainer;let n,o,a;void 0===e&&(e=i.$.mainContainer),t>1&&(n=i._createMenuItemsGroupContainer(e,t),o=n.itemContainer),a=e===r?Array.from((r instanceof Smart.ScrollViewer?r.$.content:r).children):Array.from(e.children);const s=[];let l=0;for(let r=0;r<a.length;r++){if(t>1&&0===r){l++;continue}const n=a[r];n instanceof Smart.MenuItem||n instanceof Smart.MenuItemsGroup?(i._createItemHTMLStructure(n,t,e,r-l),n.checked&&(n.disabled||n.templateApplied?n.checked=!1:s.push(n)),t>1&&o.appendChild(n),n instanceof Smart.MenuItemsGroup&&i._processHTML(n,t+1)):(n.parentElement.removeChild(n),l++)}if(t>1){if(e.container=n,e.itemContainer=o,e instanceof Smart.MenuItemsGroup){const t=document.createElement("div");t.className="smart-menu-items-group-arrow "+(i.rightToLeft?"smart-arrow-left left":"smart-arrow-right right"),e.children[0].appendChild(t)}e.appendChild(n)}i._validateRadioButtonSelection(e,t,s),i._sortItems(e)}_resizeHandler(){this.refresh()}refresh(){const e=this,t=e.minimizeWidth;if(null!==t){if(!e._minimized&&e.offsetWidth<=t)return void e.minimize();if(e._minimized&&e.offsetWidth>t)return void e.maximize()}e._checkOverflow()}_scroll(e){const t=this,i=t.$.mainContainer,r=e.classList.contains("smart-scroll-button-near")?-1:1,n=i.scrollTop;i.scrollTop=i.scrollTop+10*r,"scrollbar"!==t.scrollMode&&n!==i.scrollTop&&(t._updateScrollButtonVisibility(i,!1,[t.$.scrollButtonNear,t.$.scrollButtonFar]),t._fireScrollBottomReachedEvent(n))}_selectionHandler(e,t,i){const r=this,n=e.target;if(!r.disabled&&!r.displayLoadingIndicator){if(r._swipeDetails&&!i)return delete r._dragStartDetails,void delete r._swipeDetails;if(void 0===t){if("click"===e.type){const t=n.closest("smart-repeat-button");if(t)return void r._scroll(t,e)}const i=n.closest("smart-menu-item");if(i)return i.disabled||i.templateApplied||(r._toggleItem(i)||r.$.fireEvent("itemClick",{item:i,label:i.label,value:i.value}),r._ensureVisible(i),r._ripple(i,e)),void o();if((t=n.closest("smart-menu-items-group"))&&(n===t.container||n===t.container.firstElementChild))return}t&&!t.disabled&&r._menuItemsGroupSelectionHandler(t,e)}function o(){const t=r._getRootDetails(n.getRootNode(),e);t&&t.activeElement!==r&&null!==r.dropDownAppendTo&&"click"===e.type&&!t.isInsideElement&&r.focus()}}_showHideMenuItemsGroupSiblings(e,t,i){const r=e.parentElement.children;for(let n=0;n<r.length;n++){const o=r[n];o!==e&&(o.hidden||(i?"addClass"===t?o.$.addClass("animate"):(o.$.removeClass("smart-hidden"),o.$.addClass("right"),setTimeout((function(){o.$.removeClass("right")}),0)):o.$[t]("smart-hidden")))}}_toggleFilterInputGroupLabelVisibility(e,t){const i=this,r=i._getCurrentViewItems(i._view).length;if(!0!==t){const e=!i.$filterInputContainer.hasClass("smart-hidden");i.filterable&&r>1?(e||(i.$mainContainer.addClass("filter-input-shown"),i.$filterInputContainer.removeClass("smart-hidden")),i._view?i.$.filterInput.value=i._view.filter||"":i.$.filterInput.value=i._topLevelFilter):e&&(i.$mainContainer.removeClass("filter-input-shown"),i.$filterInputContainer.addClass("smart-hidden"))}if(!e&&i.grouped&&r>0){const e=i._view?i._view.container.firstElementChild.firstElementChild.$:i.$.mainContainer.$.content.firstElementChild.$;1===r?e.addClass("smart-hidden"):e.removeClass("smart-hidden")}}_viewHandler(e){const t=this;if("transitionend"===e.type){const i=e.target;if(i===t.$.view||t.$.backButton.contains(i))return;return i.classList.contains("animate")&&(i.classList.remove("animate"),i.classList.add("smart-hidden")),i.classList.contains("smart-menu-drop-down")&&(i.style.top=""),i.classList.contains("smart-menu-items-group-opened")&&i.classList.remove("smart-menu-items-group-opened"),cancelAnimationFrame(t._refreshScroll),t._refreshScroll=requestAnimationFrame((()=>{t._checkOverflow(),cancelAnimationFrame(t._refreshScroll),delete t._refreshScroll})),void(t._inTransition=!1)}if(t._minimized&&null!==t.dropDownAppendTo)switch(e.type){case"click":t._selectionHandler(e);break;case"mouseout":case"mouseover":t._mouseoutMouseoverHandler(e)}}_mouseWheelHandler(e){let t=this;if(t.enableMouseWheelAction&&!t.disabled&&!t.displayLoadingIndicator&&(t=t.$.mainContainer,t.scrollHeight>0)){const i=t.scrollTop;if(0===i&&e.deltaY<0||i===t.scrollHeight&&e.deltaY>0)return;e.stopPropagation(),e.preventDefault(),t.scrollTo(t.scrollTop+t._getScrollCoefficient(e,t.offsetHeight))}}_scrollViewerRefresh(){const e=this;e.$.scrollViewerContentContainer&&(e.scrollWidth=0,e.scrollHeight=function(){let t;const i=e.$.scrollViewerContainer.classList.contains("hscroll");if(e.$.scrollViewerContainer.classList.remove("hscroll"),Smart.Utilities.Core.Browser.Safari){const i=e.$.scrollViewerContentContainer.getBoundingClientRect().height,r=e.$.scrollViewerContainer.getBoundingClientRect().height;t=i&&r?parseInt(i)-parseInt(r):e.$.scrollViewerContentContainer.scrollHeight-e.$.scrollViewerContainer.offsetHeight}else t=e.$.scrollViewerContentContainer.scrollHeight-e.$.scrollViewerContainer.offsetHeight;return t>0&&"hidden"!==e.verticalScrollBarVisibility||"visible"===e.verticalScrollBarVisibility?e.$.scrollViewerContainer.classList.add("vscroll"):e.$.scrollViewerContainer.classList.remove("vscroll"),i&&e.$.scrollViewerContainer.classList.add("hscroll"),t}(),e.computedVerticalScrollBarVisibility&&(e.scrollHeight+=e._scrollView.hScrollBar.offsetHeight))}});
@@ -80,7 +80,7 @@ Smart("smart-docking-layout",class extends Smart.ContentElement{static get prope
80
80
  Smart("smart-file-upload",class extends Smart.BaseElement{static get properties(){return{accept:{value:null,type:"string?"},appendTo:{value:null,type:"any"},autoUpload:{value:!1,type:"boolean"},directory:{value:!1,type:"boolean"},dropZone:{value:null,type:"any"},hideFooter:{value:!1,type:"boolean"},itemTemplate:{value:null,type:"any"},messages:{value:{en:{browse:"Browse",uploadFile:"Upload File",cancelFile:"Cancel File",pauseFile:"Pause File",uploadAll:"Upload All",cancelAll:"Cancel All",pauseAll:"Pause All",totalFiles:"Total files: ",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long."}},type:"object",extend:!0},multiple:{value:!1,type:"boolean"},name:{value:"userfile[]",type:"string"},postData:{value:null,type:"object"},responseHandler:{value:null,type:"function?",reflectToAttribute:!1},setHeaders:{value:null,type:"function?",reflectToAttribute:!1},showProgress:{value:!1,type:"boolean"},validateFile:{value:null,type:"function?",reflectToAttribute:!1},uploadUrl:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1}}}static get listeners(){return{"browseButton.click":"browse","browseButton.focus":"_focusHandler","browseButton.blur":"_blurHandler","browseInput.change":"_browseInputChangeHandler","selectedFiles.click":"_selectedFilesClickHandler","uploadAllButton.click":"uploadAll","cancelAllButton.click":"cancelAll","pauseAllButton.click":"pauseAll","dropZone.dragenter":"_dropZoneHandler","dropZone.dragleave":"_dropZoneHandler","dropZone.dragover":"_dropZoneHandler","dropZone.drop":"_dropZoneHandler",resize:"_handleComponentsByAvailableHeight"}}_blurHandler(){this.$.fireEvent("blur")}_focusHandler(){this.$.fireEvent("focus")}static get requires(){return{"Smart.Button":"smart.button.js","Smart.ProgressBar":"smart.progressbar.js"}}static get styleUrls(){return["smart.fileupload.css"]}template(){return'<div id="container" role="presentation">\n <div id="fileUploadHeader" class="smart-file-upload-header" role="presentation">\n <smart-button class="smart-browse-button" id="browseButton" disabled="[[disabled]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button>\n <input type="file" class="smart-browse-input" id="browseInput" name="[[name]]" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" multiple="[[multiple]]" webkitdirectory="[[directory]]" mozdirectory="[[directory]]" />\n </div>\n <div id="fileUploadContainer" class="smart-file-upload-container">\n <div id="dropZone" class="smart-drop-zone" aria-label="Drag files here"></div>\n <div id="selectedFiles" class="smart-selected-files" role="list" aria-label="Selected files"></div>\n </div>\n <div id="totalFiles" class="smart-total-files smart-hidden" role="presentation">Total flies: 0</div>\n <div id="fileUploadFooter" class="smart-file-upload-footer smart-hidden"><smart-button class="smart-upload-all-button success" id="uploadAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]"" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button><smart-button class="smart-cancel-all-button error" id="cancelAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button><smart-button class="smart-pause-all-button primary" id="pauseAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button></div>\n </div>'}propertyChangedHandler(e,t,l){const s=this;switch(super.propertyChangedHandler(e,t,l),e){case"accept":s.$.browseInput.accept=l;break;case"dropZone":case"appendTo":s._handleContainers();break;case"messages":case"locale":s._updateTextValues();break;case"multiple":s.$.browseButton.disabled=!!(!s.multiple&&s._selectedFiles.length>0||s.disabled),!l&&s._selectedFiles.length>1&&(s._selectedFiles.splice(1),s._renderSelectedFiles());break;case"itemTemplate":s._items.length>0&&(s._renderSelectedFiles(),s._handleComponentsByAvailableHeight());break;case"rightToLeft":s._items&&s._items.forEach((e=>{const t=e.querySelector("smart-progress-bar");t&&(t.rightToLeft=l),l?e.setAttribute("right-to-left",""):e.removeAttribute("right-to-left")})),l?s.$.dropZone.setAttribute("right-to-left",""):s.$.dropZone.removeAttribute("right-to-left")}}attached(){super.attached(),this._handleContainers()}detached(){super.detached();const e=this;e.$.fileUploadContainer.contains(e.$.dropZone)||e.$.fileUploadContainer.insertBefore(e.$.dropZone,e.$.fileUploadContainer.firstChild),e.$.fileUploadContainer.contains(e.$.selectedFiles)||e.$.fileUploadContainer.appendChild(e.$.selectedFiles)}ready(){super.ready();const e=this;e.$.dropZone.id||(e.$.dropZone.id=e.id+"DropZone"),e.$.selectedFiles.id||(e.$.selectedFiles.id=e.id+"SelectedFiles"),e.$.fileUploadContainer.setAttribute("aria-owns",e.$.dropZone.id+" "+e.$.selectedFiles.id),e.setAttribute("role","dialog"),e.rightToLeft?e.$.dropZone.setAttribute("right-to-left",""):e.$.dropZone.removeAttribute("right-to-left"),e._setInitialValues(),e._updateTextValues(),e._handleContainers(),e._handleComponentsByAvailableHeight()}browse(){const e=this;e.disabled||!e.multiple&&e._selectedFiles.length>0||e.$.browseInput.click()}addFile(e){const t=this,l=t.multiple;let s=t._selectedFiles;s&&(l||!s.length)&&e instanceof File&&("function"!=typeof t.validateFile||t.validateFile(e))&&(s=s.push(e),t._renderSelectedFiles([e]),t.$.browseButton.disabled=!!(!l&&s.length>0||t.disabled),t.$.browseInput.value="")}cancelAll(){const e=this;if(!e.disabled&&0!==e._items.length){for(let t=e._items.length-1;t>=0;t--)e.cancelFile(e._items[t].index);e.$.browseButton.disabled=!!(!e.multiple&&e._selectedFiles.length>0||e.disabled)}}cancelFile(e){const t=this,l=()=>{t.$.selectedFiles.removeChild(s),t._selectedFiles.splice(i,1),t._items.splice(i,1),t.$.fireEvent("uploadCanceled",{filename:s.file.name,type:s.file.type,size:s.file.size,index:s.index}),t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled),0===t._selectedFiles.length&&t.$.fileUploadFooter.classList.add("smart-hidden"),t._handleComponentsByAvailableHeight()};if("number"!=typeof e||t.disabled||0===t._selectedFiles.length)return;const s=t._getFileItem(e,!0);if(!s)return void t.error(t.localize("wrongItemIndex",{elementType:t.nodeName.toLowerCase()}));const i=t._items.indexOf(s),a=t._selectedFiles[i];if(s&&s.xhr&&s.xhr.abort(),!t.removeUrl)return void l();let n=new FormData,r=new XMLHttpRequest;n.append(t.name,a),r.open("POST",t.removeUrl),t.setHeaders&&"function"==typeof t.setHeaders&&t.setHeaders(r,a),r.onload=function(){r.status>=200&&r.status<=299?l():t.$.fireEvent("uploadCanceledError",{filename:s.file.name,type:s.file.type,size:s.file.size,status:r.status,index:s.index})},r.onreadystatechange=function(){t.responseHandler&&"function"==typeof t.responseHandler&&t.responseHandler(r)},r.send(n)}get value(){return this._selectedFiles}get files(){return this._selectedFiles}pauseAll(){const e=this;if(!e.disabled&&0!==e._items.length)for(let t=e._items.length-1;t>=0;t--){let l=e._items[t];l.xhr&&l.xhr.abort()}}pauseFile(e){const t=this;if("number"!=typeof e&&"string"!=typeof e||t.disabled||0===t._items.length)return;const l=t._getFileItem(e,!0);l?(l.classList.remove("smart-uploading-start"),l&&l.xhr&&l.xhr.abort(),t.$.fireEvent("uploadPaused",{filename:l.file.name,type:l.file.type,size:l.file.size,index:l.index})):t.error(t.localize("wrongItemIndex",{elementType:t.nodeName.toLowerCase()}))}uploadAll(){const e=this;if(!e.disabled&&0!==e._items.length)for(let t=e._items.length-1;t>=0;t--)e._items[t].uploading||e.uploadFile(e._items[t].index)}uploadFile(e){const t=this;let l=!1;if("number"!=typeof e||t.disabled||0===t._selectedFiles.length)return;const s=t._getFileItem(e,!0);if(!s)return;let i=new FormData,a=t.showProgress?s.getElementsByTagName("smart-progress-bar")[0]:null,n=s.file,r="";t.postData?r=JSON.stringify(t.postData):t.getAttribute("post-data")&&(r=t.getAttribute("post-data")),r&&""!==r&&i.append("postData",r),s.classList.remove("smart-pause","smart-error"),s.classList.add("smart-uploading-start"),i.append(t.name,n);let o=new XMLHttpRequest;o.open("POST",t.uploadUrl),t.setHeaders&&"function"==typeof t.setHeaders&&t.setHeaders(o,n),t.$.fireEvent("uploadStarted",{filename:s.file.name,type:s.file.type,size:s.file.size,index:s.index}),o.upload.onprogress=function(e){l||(l=!0,s.classList.remove("smart-uploading-start"),s.classList.add("smart-uploading"),s.uploading=!0,s.xhr=o),a&&(a.value=Math.round(e.loaded/e.total*100)),s.classList.remove("smart-pause","smart-error")},o.onabort=function(){s.classList.remove("smart-uploading-start","smart-uploading"),s.classList.add("smart-pause"),s.addEventListener("animationend",(function(){s.classList.remove("smart-pause","smart-error")}))},o.onerror=function(){s.classList.remove("smart-uploading-start","smart-uploading"),s.classList.add("smart-error"),s.addEventListener("animationend",(function(){s.classList.remove("smart-pause","smart-error")}))},o.onload=function(){if(l=!1,s.classList.remove("smart-uploading-start","smart-uploading"),o.status>=200&&o.status<=299){let e=t._items.indexOf(s);t.$.selectedFiles.removeChild(s),t._selectedFiles.splice(t._selectedFiles.indexOf(n),1),t._items.splice(e,1),t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled);let l=t.uploadUrl+"/"+s.file.name;o.fileURL&&(l=o.file_url);let i=!1;o.response&&("string"==typeof o.response?(i=o.response,(i&&i.indexOf("[{")>=0||i&&i.indexOf("{")>=0)&&(i=JSON.parse(i))):i=JSON.parse(o.response),i&&(Array.isArray(i)?i[0].file_url?l=i[0].file_url:i[0].fileURL&&(l=i[0].fileURL):i.file_url?l=i.file_url:i.fileURL&&(l=i.fileURL))),t.$.fireEvent("uploadCompleted",{filename:s.file.name,type:s.file.type,size:s.file.size,status:o.status,index:s.index,fileURL:l,serverResponse:i}),0===t._selectedFiles.length&&t.$.fileUploadFooter.classList.add("smart-hidden")}else{s.classList.add("smart-error"),s.classList.remove("smart-uploading");let e="no server response";o.response&&(e="string"==typeof o.response?o.response:JSON.parse(o.response)),t.$.fireEvent("uploadError",{filename:s.file.name,type:s.file.type,size:s.file.size,status:o.status,index:s.index,serverResponse:e})}},o.onreadystatechange=function(){t.responseHandler&&"function"==typeof t.responseHandler&&t.responseHandler(o)},o.send(i)}_selectedFilesClickHandler(e){const t=this;if(t.disabled)return;const l=e.target,s=l.closest(".smart-item-upload-button"),i=l.closest(".smart-item-cancel-button"),a=l.closest(".smart-item-pause-button"),n=l.closest(".smart-file");s?t.uploadFile(n.index):i?t.cancelFile(n.index):a&&t.pauseFile(n.index)}_browseInputChangeHandler(){const e=this,t=e._filterNewFiles(Array.from(e.$.browseInput.files));let l=[];e.disabled||0===t.length||(l=e.validateFile&&"function"==typeof e.validateFile?t.filter((t=>!!e.validateFile(t)||(e.$.fireEvent("validationError",{filename:t.name,type:t.type,size:t.size}),!1))):t,e._selectedFiles=e._selectedFiles.concat(l),0!==e._selectedFiles.length&&(e._renderSelectedFiles(l),e.$.browseButton.disabled=!!(!e.multiple&&e._selectedFiles.length>0||e.disabled),e.$.browseInput.value="",e.autoUpload&&e.uploadAll()))}_defaultItemTemplate(e,t){const l=this,s=l.localize("uploadFile"),i=l.localize("cancelFile"),a=l.localize("pauseFile"),n=l.rightToLeft?"right-to-left ":"";return`<span id="${l.id+"File"+t+"Name"}" class="smart-item-name">${e}</span><span class="smart-item-upload-button" title="${s}" role="button" aria-label="${s}"></span><span class="smart-item-cancel-button" title="${i}" role="button" aria-label="${i}"></span><span class="smart-item-pause-button" title="${a}" role="button" aria-label="${a}"></span><smart-progress-bar ${n}aria-label="Upload progress"></smart-progress-bar>`}_dropZoneHandler(e){const t=this;if(e.preventDefault(),e.stopPropagation(),!t.disabled)if("dragenter"!==e.type&&"dragleave"!==e.type){if("drop"===e.type){if(t.$.dropZone.classList.remove("smart-drag-over"),!t.multiple&&t._selectedFiles.length>0)return;if(e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){const l=t._filterNewFiles(Array.from(e.dataTransfer.files));if(0===l.length)return;t.multiple||l.splice(1);let s=[];if(t.disabled)return;if(s=t.validateFile&&"function"==typeof t.validateFile?l.filter((e=>!!t.validateFile(e)||(t.$.fireEvent("validationError",{filename:e.name,type:e.type,size:e.size}),!1))):l,t._selectedFiles=t._selectedFiles.concat(s),0===t._selectedFiles.length)return;t._renderSelectedFiles(l),t.autoUpload&&t.uploadAll()}t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled)}}else"dragenter"===e.type?t.$.dropZone.classList.add("smart-drag-over"):t.$.dropZone.classList.remove("smart-drag-over")}_filterNewFiles(e){const t=this;let l=[];for(let s=0;s<e.length;s++){let i=!0;for(let l=0;l<t._selectedFiles.length;l++){const a=t._selectedFiles[l],n=e[s];if(n.name===a.name&&n.size===a.size&&n.type===a.type&&n.lastModified===a.lastModified){i=!1;break}}i&&l.push(e[s])}return l}_getFileItem(e,t){const l=this;let s=null;if(e&&("string"==typeof e||"number"==typeof e)){if(!l._items||0===l._items.length)return null;for(let i=0;i<l._items.length;i++){const a=l._items[i];(t&&a.index===parseInt(e)||a.file.name===e)&&(s=a)}return s}}_handleContainers(){const e=this,t=e._validateDOMElement(e.dropZone),l=e._validateDOMElement(e.appendTo);t?t.appendChild(e.$.dropZone):e.$.fileUploadContainer.insertBefore(e.$.dropZone,e.$.fileUploadContainer.firstChild),l?l.appendChild(e.$.selectedFiles):e.$.fileUploadContainer.appendChild(e.$.selectedFiles)}_handleItemTemplate(e,t){const l=this;let s=l.itemTemplate;if("content"in document.createElement("template")){if(!s)return l._defaultItemTemplate(e,t);if("string"==typeof s&&(s=document.getElementById(s)),null!==s&&"content"in s)return s.innerHTML.replace(/{{\w+}}/g,e);l.error(l.localize("invalidTemplate",{elementType:l.nodeName.toLowerCase(),property:"template"}))}else l.error(l.localize("htmlTemplateNotSuported",{elementType:l.nodeName.toLowerCase()}))}_renderSelectedFiles(e){const t=this,l=document.createDocumentFragment(),s=e||t._selectedFiles;e||(t._items=[],t.$.selectedFiles.innerHTML="");for(let e=0;e<s.length;e++){const i=t.directory?s[e].webkitRelativePath:s[e].name,a=document.createElement("div");t._incrementIndex++,a.className="smart-file",a.index=t._incrementIndex,a.setAttribute("item-id",t._incrementIndex),a.innerHTML=t.itemTemplate?t._handleItemTemplate(i,t._incrementIndex):t._defaultItemTemplate(i,t._incrementIndex),a.file=s[e],a.uploading=!1,a.xhr=null,a.setAttribute("role","listitem"),a.setAttribute("aria-labelledby",t.id+"File"+t._incrementIndex+"Name"),t.rightToLeft&&a.setAttribute("right-to-left",""),l.appendChild(a),t._items.push(a),t.$.fireEvent("fileSelected",{filename:s[e].name,type:s[e].type,size:s[e].size,index:a.index})}t.$.selectedFiles.appendChild(l),t.$.fileUploadFooter.classList.remove("smart-hidden"),t._handleComponentsByAvailableHeight()}_setInitialValues(){const e=this;e.$.browseInput.accept=e.accept,e._selectedFiles=[],e._items=[],e._incrementIndex=0}_updateTextValues(){const e=this,t=["browse","uploadAll","cancelAll","pauseAll"];for(let l=0;l<t.length;l++){const s=t[l],i=s+"Button";e.$[i].innerHTML=e.localize(s)}for(let t=0;t<e._selectedFiles.length;t++){const l=e._items[t];l.querySelector(".smart-item-upload-button").title=e.localize("uploadFile"),l.querySelector(".smart-item-cancel-button").title=e.localize("cancelFile"),l.querySelector(".smart-item-pause-button").title=e.localize("pauseFile")}}_validateDOMElement(e){if(e)return"string"==typeof e?document.getElementById(e):e instanceof HTMLElement?e:void 0}refresh(){this._handleComponentsByAvailableHeight()}_handleComponentsByAvailableHeight(){const e=this;if(e._calculateAvailableContainerHeight(),e._elementsAutoHeight>e.offsetHeight){if(e.$.container.classList.add("smart-overflow"),e._containerOverflows=!0,e._rowHeight){const t=parseInt(e._availableHeight/e._rowHeight);for(let l=0;l<e._items.length;l++){const s=e._items[l];l<t?s.classList.remove("smart-hidden"):s.classList.add("smart-hidden")}e._items.length>t?(e.$.totalFiles.innerHTML=e.localize("totalFiles")+e._items.length,e.$.totalFiles.classList.remove("smart-hidden")):e.$.totalFiles.classList.add("smart-hidden")}}else""===e.dropZone&&e._elementsAutoHeight<e.offsetHeight&&(e.$.container.classList.remove("smart-overflow"),e._containerOverflows=!1)}_calculateAvailableContainerHeight(){const e=this,t=window.getComputedStyle(e.$.fileUploadContainer,null),l=parseInt(t.getPropertyValue("margin-top"))+parseInt(t.getPropertyValue("margin-bottom"))+parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom")),s=e.$.container.querySelector(".smart-file"),i=e.$.fileUploadHeader.offsetHeight,a=e.$.fileUploadFooter.offsetHeight,n=e.style.height;let r=0;s&&(e._rowHeight=s.offsetHeight),e.style.height="auto",e._containerOverflows&&e.$.container.classList.remove("smart-overflow"),e._elementsAutoHeight=e.offsetHeight,e.style.height=n,e._containerOverflows&&e.$.container.classList.add("smart-overflow"),e.$.totalFiles.classList.contains("smart-hidden")&&(e.$.totalFiles.classList.remove("smart-hidden"),r=e.$.totalFiles.offsetHeight,e.$.totalFiles.classList.add("smart-hidden")),e._availableHeight=e.offsetHeight-(i+a)-l-r}});
81
81
  Smart("smart-query-builder",class extends Smart.BaseElement{static get properties(){return{allowDrag:{value:!1,type:"boolean"},autoPrompt:{value:!1,type:"boolean"},applyMode:{allowValues:["immediately","change"],value:"change",type:"string"},autoApplyValue:{value:!1,type:"boolean"},customOperations:{value:[],type:"array",reflectToAttribute:!1},customOperators:{value:{},type:"object",reflectToAttribute:!1},dropDownWidth:{type:"any",value:"auto"},fields:{value:null,type:"array?",reflectToAttribute:!1},fieldsMode:{value:"dynamic",allowedValues:["dynamic","static"],type:"string"},formatStringDate:{value:"dd-MMM-yy",type:"string"},formatStringDateTime:{value:"dd-MMM-yy HH:mm:ss",type:"string"},getDynamicField:{value:null,type:"function?"},icons:{value:{"=":"equals","<>":"notequals",">":"greaterthan",">=":"greaterthanorequal","<":"lessthan","<=":"lessthanorequal",startswith:"startswith",endswith:"endswith",contains:"contains",notcontains:"notcontains",isblank:"isblank",isnotblank:"isnotblank"},type:"object",reflectToAttribute:!1},messages:{value:{en:{add:"Add",addCondition:"Add Condition",addGroup:"Add Group",and:"And",notand:"Not And",or:"Or",notor:"Not Or","=":"Equals","<>":"Does not equal",">":"Greater than",">=":"Greater than or equal to","<":"Less than","<=":"Less than or equal to",startswith:"Starts with",endswith:"Ends with",contains:"Contains",notcontains:"Does not contain",isblank:"Is blank",isnotblank:"Is not blank",wrongParentGroupIndex:'{{elementType}}: Wrong parent group index in "{{method}}" method.',wrongElementNode:'{{elementType}}: Incorect node / node Id in "{{method}}" method.',invalidDataStructure:"{{elementType}}: Used invalid data structure in updateCondition/updateGroup method.",dateTabLabel:"DATE",timeTabLabel:"TIME",queryLabel:"Query"}},type:"object",extend:!0},operatorPlaceholder:{value:"Operator",type:"string"},propertyPlaceholder:{value:"Property",type:"string"},showIcons:{value:!1,type:"boolean"},showFieldNameArrow:{value:!1,type:"boolean"},validateOnInput:{value:!1,type:"boolean"},validationTimeout:{value:100,type:"number"},value:{value:[],type:"any",reflectToAttribute:!1},valueFormatFunction:{value:null,type:"function?",reflectToAttribute:!1},valuePlaceholder:{value:"Value",type:"string"}}}static get requires(){const e={"Smart.Button":"smart.button.js","Smart.Calendar":"smart.calendar.js","Smart.CheckBox":"smart.checkbox.js","Smart.DateTimePicker":"smart.datetimepicker.js","Smart.DropDownList":"smart.dropdownlist.js","Smart.Input":"smart.input.js","Smart.ListBox":"smart.listbox.js","Smart.Menu":"smart.menu.js","Smart.NumericTextBox":"smart.numerictextbox.js","Smart.ScrollBar":"smart.scrollbar.js","Smart.TimePicker":"smart.timepicker.js","Smart.Tooltip":"smart.tooltip.js","Smart.Utilities.BigNumber":"smart.math.js","Smart.Utilities.DateTime":"smart.date.js","Smart.Utilities.Draw":"smart.draw.js","Smart.Utilities.NumericProcessor":"smart.numeric.js"};return window.NIComplex||(e["Smart.Utilities.Complex"]="smart.complex.js"),e}static get listeners(){return{down:"_downHandler",resize:"_resizeHandler","editorsContainer.keydown":"_editorsContainerKeydownHandler","editorsContainer.keyup":"_editorsContainerKeyUpHandler","conditionsMenu.close":"_menuCloseHandler","conditionsMenu.closing":"_menuClosingHandler","conditionsMenu.itemClick":"_menuItemClickHandler","contentContainer.change":"_contentContainerChangeHandler","contentContainer.itemClick":"_contentContainerChangeHandler","scrollableContainer.touchmove":"_scrollableContainerTouchmoveHandler","document.down":"_documentDownHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler"}}static get styleUrls(){return["smart.querybuilder.css"]}template(){return'<div id="container" role="presentation">\n <smart-scroll-viewer id="scrollableContainer" class="smart-scrollable-container" animation="[[animation]]" right-to-left="[[rightToLeft]]">\n <div id="queryLabel" class="smart-query-builder-label smart-unselectable"></div>\n <div id="contentContainer" class="smart-content-container"></div>\n </smart-scroll-viewer>\n <div id="editorsContainer" class="smart-editors-container" role="presentation">\n <div id="customEditor" class="smart-custom-editor smart-hidden"></div>\n </div>\n <smart-menu id="conditionsMenu" mode="dropDown" class="smart-conditions-menu" theme="[[theme]]" animation="[[animation]]" right-to-left="[[rightToLeft]]"></smart-menu>\n </div>'}propertyChangedHandler(e,t,a){super.propertyChangedHandler(e,t,a);const i=this;switch(e){case"animation":case"theme":["textBoxEditor","numericTextBoxEditor","comboBoxEditor","dateTimePickerEditor","checkBoxEditor"].forEach((t=>i.$[t]&&(i.$[t][e]=a)));break;case"formatStringDate":case"formatStringDateTime":case"valueFormatFunction":i._refresh();break;case"operatorPlaceholder":Array.from((i.shadowRoot||i).querySelectorAll(".smart-filter-operation[placeholder]")).forEach((e=>e.firstElementChild.innerHTML=a));break;case"propertyPlaceholder":Array.from((i.shadowRoot||i).querySelectorAll(".smart-filter-field-name[placeholder]")).forEach((e=>e.firstElementChild.innerHTML=a));break;case"showIcons":i._closeEditor(),a?i._filterOperationDescriptions.map((e=>e.icon=i.icons[e.value])):i._filterOperationDescriptions.map((e=>delete e.icon));break;case"customOperations":case"fields":case"value":{const t=JSON.stringify(i._validValue),o=i._queryParser;"customOperations"===e?i._handleCustomOperations():""===e&&i._mapFieldsToMenu(),i._applyValue(),"customOperations"!==e&&"fields"!==e||(o[e]=a),i._oldValueAsString!==t&&(i._oldValueAsString=JSON.stringify(i._validValue),i.$.fireEvent("change",{value:JSON.parse(i._oldValueAsString),linq:o.toLinq(i._validValue)}));break}case"valuePlaceholder":Array.from((i.shadowRoot||i).querySelectorAll(".smart-filter-value[placeholder]")).forEach((e=>e.firstElementChild.innerHTML=a));break;case"locale":case"messages":i._localizeInitialValues(),i._refresh(),i._handleCustomOperations(),i.$.dateTimePickerEditor&&(i.$.dateTimePickerEditor.messages[i.locale]||(i.$.dateTimePickerEditor.messages[i.locale]={}),i.$.dateTimePickerEditor.messages[i.locale].dateTabLabel=i.localize("dateTabLabel"),i.$.dateTimePickerEditor.messages[i.locale].timeTabLabel=i.localize("timeTabLabel"),"locale"===e?i.$.dateTimePickerEditor.locale=i.locale:"messages"===e&&(i.$.dateTimePickerEditor.$.selectDate.innerHTML=i.$.dateTimePickerEditor.messages[i.locale].dateTabLabel,i.$.dateTimePickerEditor.$.selectTime.innerHTML=i.$.dateTimePickerEditor.messages[i.locale].timeTabLabel));break;case"icons":i._closeEditor()}}ready(){super.ready();const e=this;e.$.queryLabel.id||(e.$.queryLabel.id=e.id+"Label"),e.setAttribute("role","dialog"),e.setAttribute("aria-labelledby",e.$.queryLabel.id),-1!==navigator.platform.toLowerCase().lastIndexOf("mac")&&e.$.contentContainer.classList.add("mac"),e._queryParser=new Smart.Utilities.QueryParser,e._setInitialValues(),e._handleCustomOperations(),e._applyValue(),Object.defineProperty(e,"value",{get:function(){return e.context===e?e.properties.value.value:e._validValue},set(t){e.updateProperty(e,e._properties.value,t)}})}getLinq(){const e=this;if(e._validValue)return e._queryParser.customOperations=e.customOperations,e._queryParser.fields=e.fields,e._queryParser.dynamicField="dynamic"===e.fieldsMode?e.getDynamicField:void 0,e._queryParser.toLinq(e._validValue)}get validationStatus(){const e=this;return!e.isReady||void 0===e._validationStatus||e._validationStatus}_setInitialValues(){const e=this;e._autoScrollCoefficient=Smart.Utilities.Core.Browser.Firefox?4:Smart.Utilities.Core.Browser.Edge?8:2,e._isMobile=Smart.Utilities.Core.isMobile,e._manuallyAddedFields=[],e._localizeInitialValues(),e.$.conditionsMenu.dropDownAppendTo=e.$.container,e.$.conditionsMenu.dataSource=e._groupOperationDescriptions,e._valueFlat=[],e._lastProcessedItemInCurrentGroup={parentId:null,id:null,position:null}}_applyValue(){const e=this;e._emptyElementsStructure(!0),e._validateValue(),e._convertValueToFlat(e.value),e._getFieldsFromValue(),e._mapFieldsToMenu(),e._validateValueByType(),e._generateHTMLStructureFromFlatValue(!0),e._restrictNesting(),e._validValue=e._getValidValue(),e._oldValueAsString=JSON.stringify(e._validValue)}_validateValueByType(){const e=this;if(!e._valueFlat||!e._valueFlat.length)return;const t=e._valueFlat;for(let a=0;a<t.length;a++){const i=t[a];if("condition"!==i.type)continue;const o=i.data[0];!o||i.data.length<3||(i.data[2]=e._validateStoredValue(i.data[2],o))}e._generateValue(!0)}_applyValidationOnInput(){const e=this,t=e._editor;if(!t||!e._editorIsOpen)return;const a=t.closest(".filter-builder-item"),i=t.closest(".smart-filter-group-condition");a&&a.classList.contains("smart-filter-value")&&(clearTimeout(e._valueValidationTimeout),e._valueValidationTimeout=setTimeout((()=>{const a=i.getAttribute("node-id"),o=e.value.toString();clearTimeout(e._valueValidationTimeout),e._closeEditor(),o===e.value.toString()&&e._generateValue();const l=e._getItemById(a);l&&(t.setAttribute("focus",""),e._openEditor(l.htmlNode.querySelector(".smart-filter-value"))),delete e._valueValidationTimeout}),e.validationTimeout))}_contentContainerChangeHandler(e){const t=this,a=e.type,i=e.target,o=t._editor,l=t._editorIsOpen,r=t.applyMode;e.stopPropagation(),"change"===a&&t.validateOnInput&&l&&i===o&&t._applyValidationOnInput();let n=i.value;if("string"==typeof n&&(n=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")),"itemClick"===a&&n!==e.detail.label||"immediately"!==r||!l||!o||"immediately"===r&&i!==o)return;const s=t._editor.closest(".filter-builder-item");s.classList.contains("smart-filter-value")||(t._closeEditor(),t._handleAutoPrompt(s))}_handleAutoPrompt(e){const t=this;if(e&&t.autoPrompt&&"immediately"===t.applyMode&&!e.classList.contains("smart-filter-value")){const a=e.closest(".smart-filter-group-condition")||e.closest(".smart-filter-nested-operator")||e.closest(".smart-filter-group");if(!a)return;const i=t._getItemById(a.getAttribute("node-id")),o=a.querySelector(".smart-filter-value");if(!i||!o)return;t._clickHandlerFilterButton(e.classList,i.nodeId,o)}}_mapFieldsToMenu(){const e=this;(e.fields||e._valueFields)&&(e._fields=(e.fields||e._valueFields).concat(e._manuallyAddedFields).map((e=>({label:e.label,value:e.dataField,dataType:e.dataType,filterOperations:e.filterOperations,lookup:e.lookup}))))}_localizeInitialValues(){const e=this;e.$.queryLabel.innerHTML=e.localize("queryLabel"),e._addOptions=[{label:e.localize("addCondition"),value:"addCondition"},{label:e.localize("addGroup"),value:"addGroup"}],e._groupOperationDescriptions=[{label:e.localize("and"),value:"and"},{label:e.localize("or"),value:"or"}],e._defaultFilterOperationDescriptions=e._filterOperationDescriptions=[{label:e.localize("="),value:"=",custom:!1},{label:e.localize("<>"),value:"<>",custom:!1},{label:e.localize(">"),value:">",custom:!1},{label:e.localize(">="),value:">=",custom:!1},{label:e.localize("<"),value:"<",custom:!1},{label:e.localize("<="),value:"<=",custom:!1},{label:e.localize("startswith"),value:"startswith",custom:!1},{label:e.localize("endswith"),value:"endswith",custom:!1},{label:e.localize("contains"),value:"contains",custom:!1},{label:e.localize("notcontains"),value:"notcontains",custom:!1},{label:e.localize("isblank"),value:"isblank",custom:!1},{label:e.localize("isnotblank"),value:"isnotblank",custom:!1}];const t=Smart.Utilities.DateTime.getLocalizedNames(e.locale);e._localizedDays=t.days,e._localizedMonths=t.months}_handleCustomOperations(){const e=this;e._filterOperationDescriptions=e._defaultFilterOperationDescriptions.slice(0);for(let t=0;t<e.customOperations.length;t++){let a=e.customOperations[t],i=e._filterOperationDescriptions.findIndex((e=>e.value===a.name)),o={label:a.label,value:a.name,custom:!0,index:t,editorTemplate:a.editorTemplate,valueTemplate:a.valueTemplate,handleValue:a.handleValue,hideValue:a.hideValue,validateValue:a.validateValue};i>-1?e._filterOperationDescriptions[i]=o:e._filterOperationDescriptions.push(o)}}_editorsContainerKeydownHandler(e){const t=this;if(t._editorIsOpen&&("Escape"===e.key||"Enter"===e.key)){t._closeEditor();const e=t._editor.closest(".filter-builder-item");e&&!e.classList.contains("smart-filter-value")&&t._handleAutoPrompt(e)}}_editorsContainerKeyUpHandler(e){const t=this,a=t._editor;a&&a.contains(e.target)&&t._editorIsOpen&&t.validateOnInput&&t._applyValidationOnInput()}_documentDownHandler(e){const t=this,a=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;if(a.shadowParent&&a.shadowParent.closest(".smart-input-drop-down-menu")||a.closest(".smart-input-drop-down-menu")||t.$.conditionsMenu.contains(a))return;const i=a.closest(".smart-drop-down");if(a.getRootNode().host===t||a.closest("smart-query-builder")===t||i&&t.contains(i.ownerElement))if(t._isMobile){const a=t.$.scrollableContainer.scrollTop,i=t.getBoundingClientRect().top;setTimeout((function(){if(t.$.scrollableContainer.scrollTop===a&&t.getBoundingClientRect().top===i){const a=t.context;t.context=t,t._clickHandler(e.originalEvent),t.context=a}}),250)}else t._clickHandler(e.originalEvent);else t._editorIsOpen&&!t._scrollBarDown&&t._closeEditor(),delete t._scrollBarDown}_emptyElementsStructure(e){const t=this,a=t.$.contentContainer;for(;a.firstChild;)a.removeChild(a.firstChild);t._valueFlat=e?[]:t._valueFlat,t._lastProcessedItemInCurrentGroup={parentId:null,id:null,position:null}}_resizeHandler(){this.$.scrollableContainer.refresh()}_getTotalConditions(){return this.getElementsByClassName("smart-filter-group-condition").length}_parseLinqToValue(){const e=this,t=e._queryParser;t&&(t.customOperations=e.customOperations,t.fields=e.fields,t.dynamicField="dynamic"===e.fieldsMode?e.getDynamicField:void 0,e.set("value",t.toValue(e.value)))}_validateValue(){const e=this;"string"==typeof e.value&&e._parseLinqToValue();const t=e.properties.value.value;if(Array.isArray(t)&&""!==JSON.stringify(t).replace(/[\[\]]/g,"")){for(3===t.length&&"string"==typeof t[0]&&(e.value=[[t]]),Array.isArray(t[0])&&3===t[0].length&&"string"==typeof t[0][0]&&(e.value=[t]);"string"==typeof t[0];)t.shift();for(;"string"==typeof t[t.length-1];)t.pop();e.value.forEach((e=>{Array.isArray(e)&&0===e.length&&e.push([])}))}else e.value=[[[]]]}_convertValueToFlat(e){const t=this,a=["and","or","notAnd","notOr"];if(!e)return;let i=0,o=0;t._valueFlat=[],function e(l,r){let n;for(let s=0;s<l.length;s++){const d=l[s];let c={htmlNode:null};if("string"==typeof d&&(a.indexOf(d)>-1||t.customOperators[d]))n=(t.customOperators[d]||d).trim();else if(n=n||"and",Array.isArray(d)){let a=t._valueFlat.filter((e=>e.parentId+""==r+"")).length;if(d.find((e=>Array.isArray(e))))c.nodeId=(o+=1)+"",c.type="group",c.data=n,t._valueFlat.push(c),e(d,c.nodeId),n="";else{if(t.maxConditions&&i>=t.maxConditions||t.maxConditionsPerGroup&&a>=t.maxConditionsPerGroup)continue;0!==s&&(t._valueFlat.push({nodeId:r+"."+a,type:"operator",data:n,parentId:r+""}),n="",a++),c.nodeId=r+"."+a,c.parentId=r+"",c.type="condition",c.data=d,i++,t._valueFlat.push(c)}}}}(e,0),delete t._totalGroups}_getFieldsFromValue(){const e=this._valueFlat,t=[],a=[];for(let o=0;o<e.length;o++){const l=e[o];if("condition"===l.type){const e=l.data[0];if(e&&-1===t.indexOf(e)){const o={label:e,dataField:e,dataType:(i=l.data[2],"boolean"==typeof i?"boolean":i instanceof Date?i.getHours()>0||i.getMinutes()>0||i.getSeconds()>0?"dateTime":"date":isNaN(i)?"string":"number"),format:null};t.push(e),a.push(o)}}}var i;this._valueFields=a}_addElement(e,t,a,i){const o=this,l=o._valueFlat.filter((e=>e.parentId===t));let r=0,n="";if(a=a||("group"===e?"or":[]),l.length){let e=l.map((e=>{const t=e.nodeId.split(".");return parseInt(t[t.length-1])}));e=0===e.length?[0]:e,r=e.reduce(((e,t)=>Math.max(e,t)))+1}t&&t.length>0&&(n=".");let s=(t||"")+n+("group"===e?o._valueFlat.filter((e=>"group"===e.type)).length+1:r),d=l[0];if(l.length)for(let e=0;e<l.length;e++){const t=l[e],a=t.nodeId.split(".").pop();parseInt(a)>parseInt(d.nodeId.split(".").pop())&&(d=t)}else d=o._valueFlat.find((e=>e.nodeId===t));let c=d?o._valueFlat.indexOf(d)+1:o._valueFlat.length;"condition"===e&&l.length>0&&(o._valueFlat.splice(c,0,{nodeId:s,parentId:t,type:"operator",data:["and"],htmlNode:null}),s=(t||"")+n+(r+1),c++);const u={nodeId:s,parentId:t,type:e,data:a,htmlNode:null},p=o.autoPrompt;if("condition"===e&&p&&o._fields.length){const e=o._fields[0];if(e){const t=o._getFilterOperations(e);a[0]=e.value||e.label||"",t.length&&(a[1]=t[0].value)}}if(o._valueFlat.splice(c,0,u),"group"===e&&o._addElement("condition",s,[],!0),!i&&(o._refresh(),p&&u.htmlNode)){const e=u.htmlNode,t=e.querySelector(".smart-filter-value");t&&o._clickHandlerFilterButton(e.classList,u.nodeId,t)}}_deleteElement(e,t){const a=this,i="string"==typeof e?e:e.getAttribute("node-id");if(i&&1!==i.length&&("group"===t?r(i):l(i),!t||"condition"===t)){let e=i.split(".");if(e.pop(),e=e.join("."),!a._valueFlat.filter((t=>t.parentId===e)).length&&(a._valueFlat.filter((e=>"group"===e.type)).length>1&&r(e),"0"===e)){const e=a._valueFlat.find((e=>"group"===e.type)),t=e.nodeId;e.nodeId="0",e.htmlNode.setAttribute("node-id","0");const i=a._valueFlat.filter((e=>e.parentId===t));for(let e=0;e<i.length;e++){const t=i[e];t.parentId="0",t.nodeId="0."+e,t.htmlNode.setAttribute("node-id",t.nodeId)}}a._generateValue()}function o(e){const t=a._valueFlat[e];if(t&&"operator"===t.type)return a._valueFlat.splice(e,1),t.htmlNode.parentElement.removeChild(t.htmlNode),!0}function l(e){let t,i=0,l=e.split(".");l.pop(),l=l.join(".");for(let o=0;o<a._valueFlat.length;o++){const r=a._valueFlat[o];if("condition"===r.type){if(r.nodeId===e){t=r;break}r.parentId===l&&i++}}const r=a._valueFlat.indexOf(t);a._valueFlat.splice(r,1),t.htmlNode.parentElement.removeChild(t.htmlNode);const n=o(r-1);i||o(r-(n?1:0));const s=a._valueFlat.filter((e=>e.nodeId===l))[0].htmlNode;s.children[1].childElementCount>0&&s.children[2].hasAttribute("limit-selection")&&!s.children[1].lastElementChild.hasAttribute("limit-selection")&&s.children[2].removeAttribute("limit-selection")}function r(e){const t=a._valueFlat.filter((t=>e===t.nodeId&&"group"===t.type))[0];for(let t=0;t<a._valueFlat.length;t++){const i=a._valueFlat[t],o=i.nodeId;i.parentId===e&&("group"===i.type?r(o):l(o))}a._valueFlat.indexOf(t)>-1&&a._valueFlat.splice(a._valueFlat.indexOf(t),1),t.htmlNode.parentElement.removeChild(t.htmlNode)}}_generateHTMLStructureFromFlatValue(e){const t=this,a=document.createDocumentFragment();if(t._valueFlat&&0!==t._valueFlat.length){for(let e=0;e<t._valueFlat.length;e++){const i=t._valueFlat[e],o=!!t.customOperations&&t.customOperations.find((e=>e.name===i.data[1])),l=i.parentId?(t.shadowRoot||t).querySelector('[node-id="'+i.parentId+'"]').querySelector(".smart-filter-group-condition-container"):t.$.contentContainer;if("group"===i.type){const o=document.createElement("div"),l=t.localize(i.data)||"";o.className="smart-filter-group",o.innerHTML='<div class="smart-filter-group-operator" role="button" aria-expanded="false" aria-haspopup="menu">'+l+'</div><div class="smart-filter-group-condition-container" role="group"></div><div class="smart-filter-add-condition-btn" role="button" aria-label="Add condition"><div>'+t.localize("add")+'</div></div><div class="smart-filter-add-btn" role="button" aria-expanded="false" aria-haspopup="menu" aria-label="Add group"></div>',o.firstElementChild.data=l,a.appendChild(o),o.setAttribute("node-id",i.nodeId),t._valueFlat[e].htmlNode=o}else if("condition"===i.type){const l=t._newFilterConditionRow(i.data);if(l.setAttribute("node-id",i.nodeId),a.appendChild(l),t._valueFlat[e].htmlNode=l,void 0!==i.data[0]&&void 0===i.data[1]){const e=t._getFilterOperations(t._fields.find((e=>e.value===i.data[0])));t._handleOnlyOperation(e,i.data,l)}else(-1!==["isblank","isnotblank"].indexOf(i.data[1])||o&&o.hideValue)&&(i.data.splice(2,1),l.children[2].classList.add("smart-visibility-hidden"))}else{const o=document.createElement("div");o.className="smart-filter-nested-operator",o.setAttribute("node-id",i.nodeId),o.setAttribute("role","button"),o.setAttribute("aria-expanded",!1),o.setAttribute("aria-haspopup","menu"),o.innerHTML=t.localize(i.data),a.appendChild(o),t._valueFlat[e].htmlNode=o}l.appendChild(a)}e&&t._validateValueAdvanced(),t.$.scrollableContainer.refresh()}}_validateValueAdvanced(){const e=this,t=e.value;let a=!1,i=!1,o=0;for(let e=0;e<t.length;e++){const l=t[e];if("string"!=typeof l)for(let e=l.length-1;e>=0;e--){let t=l[e];if(Array.isArray(t)&&0===t.length&&e!==l.length-1)l.splice(e,1),0===e&&l.splice(0,1),a=!0;else if("string"==typeof t){t=t.toLowerCase(),o++,(o>1||"and"!==t&&"or"!==t)&&(i=!0);continue}o=0}}a&&(e._emptyElementsStructure(!0),e._convertValueToFlat(e.value),e._generateHTMLStructureFromFlatValue()),i&&e._generateValue(!0)}_restrictNesting(){Array.from(this.getElementsByClassName("smart-filter-add-condition-btn")).forEach((e=>{const t=e.previousElementSibling.lastElementChild;t&&t.hasAttribute("limit-selection")&&e.setAttribute("limit-selection","")}))}_clickHandler(e){const t=this,a=t.shadowRoot||t.isInShadowDOM?e.composedPath()[0]:e.target;if(t.disabled||!a||!a.closest||!t._isMobile&&0!==e.button)return;if(t._scrollBarDown)return void delete t._scrollBarDown;const i=a.closest(".smart-drop-down"),o=t._editor&&t._editor.contains(a)||i&&(t._editor.contains(i.ownerElement)||t._editor===i.ownerElement)||a.closest(".smart-custom-editor");t._editor&&t._editorIsOpen&&!o&&t._closeEditor();const l=a.closest(".smart-filter-group-condition")||a.closest(".smart-filter-nested-operator")||a.closest(".smart-filter-group");if(!l)return;const r=t._getItemById(l.getAttribute("node-id"));if(!r)return;if(t.$.fireEvent("itemClick",{id:r.nodeId,type:r.type,data:r.data}),a.closest(".smart-filter-delete-btn"))return void t._clickHandlerDeleteButton(r.htmlNode);const n=a.closest(".smart-filter-add-btn")||a.closest(".smart-filter-add-condition-btn");if(n){const e=n.closest(".smart-filter-group").getAttribute("node-id");return void(n.classList.contains("smart-filter-add-condition-btn")&&(t.maxConditions&&t._getTotalConditions()<t.maxConditions||!t.maxConditions)?t._addElement("condition",e,[]):t._clickHandlerFilterButton(n.classList,r.nodeId,a))}const s=a.closest(".filter-builder-item")||a.closest(".smart-filter-group-operator")||a.closest(".smart-filter-nested-operator");if(s){const e=s.classList;t._clickHandlerFilterButton(e,r.nodeId,a)}}_downHandler(e){const t=this;if(!e.originalEvent||!t._isMobile&&0!==e.button)return;const a=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target,i=t.rightToLeft?e.pageX>a.getBoundingClientRect().right:e.pageX<a.getBoundingClientRect().left;if(t.allowDrag&&a.classList.contains("smart-filter-group-condition")&&i){const i=t._valueFlat.filter((e=>"condition"===e.type));if(1===i.length||2===i.length&&i[0].parentId===i[1].parentId&&i[1].htmlNode.hasAttribute("limit-selection"))return;return t._dragDetails={coords:{x:e.pageX,y:e.pageY},item:a,originalEvent:e},t.$.scrollableContainer._scrollView.disableSwipeScroll=!0,t._hoveredCondition=a,void window.getSelection().removeAllRanges()}this._scrollBarDown=a.closest("smart-scroll-bar"),e.stopPropagation(),e.preventDefault()}_scrollableContainerTouchmoveHandler(e){this._dragDetails&&e.cancelable&&(e.preventDefault(),e.stopPropagation())}_documentMoveHandler(e){const t=this,a=t._dragDetails;if(!a)return;const i=a.item;if(!a.feedbackShown){if(!(Math.abs(a.coords.x-e.pageX)>5||Math.abs(a.coords.y-e.pageY)>5))return;{const o=t._valueFlat.filter((e=>e.htmlNode===i))[0];if(t.$.fireEvent("dragStart",{data:o.data,item:i,originalEvent:e}).defaultPrevented)return delete t._dragDetails,delete t._hoveredCondition,void(t.$.scrollableContainer._scrollView.disableSwipeScroll=!1);a.allConditions=Array.from((t.shadowRoot||t).querySelectorAll(".smart-filter-group-condition")),a.data=o,a.feedback=t._addDragFeedback(),a.feedbackShown=!0,i.classList.add("dragged")}}const o=e.clientY;let l,r=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;if(t.$.fireEvent("dragging",{data:a.data,item:i,originalEvent:e}),t.setAttribute("dragging",""),a.feedback.style.left=e.pageX+10+"px",a.feedback.style.top=e.pageY+10+"px",t._isMobile){const a=t._hoveredCondition;a&&(a.classList.remove("drop-target","top","bottom"),delete t._hoveredCondition);const i=document.elementFromPoint(e.clientX,o);i&&(r=i)}let n,s=r.closest(".smart-filter-group-condition");if(s){l=s;const e=l.getBoundingClientRect(),t=Math.abs(o-e.top),a=Math.abs(o-e.bottom);n=t<a?"top":"bottom"}else{let e,t;a.allConditions.forEach((a=>{const i=a.getBoundingClientRect(),l=Math.abs(o-i.top),r=Math.abs(o-i.bottom),s=Math.min(l,r);(void 0===t||s<t)&&(e=a,t=s,n=l<r?"top":"bottom")})),s=e}if(s===i||s.hasAttribute("limit-selection")&&"bottom"===n)s=void 0;else{const e=Array.from(s.parentElement.getElementsByClassName("smart-filter-group-condition")),t=e.indexOf(i);-1!==t&&("top"===n&&s===e[t+1]||"bottom"===n&&s===e[t-1])&&(s=void 0)}if(l=s,a.side=n,clearInterval(t._dragInterval),t._dragInterval=setInterval((function(){const a=t.getBoundingClientRect();t.$.scrollableContainer.scrollHeight>0&&a.left<=e.clientX&&a.left+a.width>=e.clientX?o>=a.top&&o<=a.top+36?t.$.scrollableContainer.scrollTop-=t._autoScrollCoefficient:o>=a.top+a.height-36&&o<=a.top+a.height?t.$.scrollableContainer.scrollTop+=t._autoScrollCoefficient:clearInterval(t._dragInterval):clearInterval(t._dragInterval)}),1),l){t._hoveredCondition&&l!==t._hoveredCondition&&t._hoveredCondition.classList.remove("drop-target","top","bottom");const e=l.closest(".smart-filter-group");if(e&&e.hasAttribute("restricted"))return void(t._hoveredCondition=void 0);t._hoveredCondition=l,l.classList.remove("top","bottom"),l.classList.add(n,"drop-target")}else t._hoveredCondition&&(t._hoveredCondition.classList.remove("drop-target","top","bottom"),delete t._hoveredCondition)}_addDragFeedback(){const e=this,t=document.createElement("div");return e.rightToLeft?t.setAttribute("right-to-left",""):t.removeAttribute("right-to-left"),t.className="smart-query-builder-drag-feedback",e.theme&&t.setAttribute("theme",e.theme),document.body.appendChild(t),t}_documentUpHandler(e){const t=this,a=t._dragDetails;if(!a)return void(t.$.conditionsMenu.opened&&t._selectedElement&&!t._selectedElement.classList.contains("smart-filter-add-btn")&&t.$.conditionsMenu._hoverViaKeyboard(t.$.conditionsMenu.querySelector('smart-menu-item[value="'+t._editedItem.data+'"]')));const i=a.item,o=a.data,l=t._hoveredCondition;if(delete t._dragDetails,delete t._hoveredCondition,t.$.scrollableContainer._scrollView.disableSwipeScroll=!1,!t.hasAttribute("dragging"))return;if(clearInterval(t._dragInterval),window.getSelection().removeAllRanges(),t.removeAttribute("dragging"),i.classList.remove("dragged"),a.feedback.remove(),!l)return void t.$.fireEvent("dragEnd",{data:o.data,item:i,originalEvent:e,target:null,targetData:null,targetSide:null});const r=t._valueFlat.filter((e=>e.htmlNode===l))[0],n=t.$.fireEvent("dragEnd",{data:o.data,item:i,originalEvent:e,target:l,targetData:r.data,targetSide:a.side});if(l.classList.remove("drop-target","top","bottom"),n.defaultPrevented)return;const s=t.value,d=o.nodeId.split(".").map((e=>parseFloat(e))),c=s[2*(d[0]-1)],u=r.nodeId.split(".").map((e=>parseFloat(e))),p=s[2*(u[0]-1)];let m="and";c.length>1&&(0===d[1]?(m=c[1],c[1]="!remove!"):(m=c[d[1]-1],c[d[1]-1]="!remove!")),c[d[1]]="!remove!","top"===a.side?p.splice(u[1],0,o.data,m):p.splice(u[1]+1,0,m,o.data);for(let e=0;e<s.length;e++)Array.isArray(s[e])&&(s[e]=s[e].filter((e=>"!remove!"!==e)));for(let e=s.length-1;e>=0;e--)Array.isArray(s[e])&&0===s[e].length&&(0===e?s.splice(0,2):(s.splice(e-1,2),e--));t._emptyElementsStructure(!0),t._convertValueToFlat(s),t._generateHTMLStructureFromFlatValue(),t._validValue=t._getValidValue();const f=JSON.stringify(t._validValue);t._oldValueAsString!==f&&(t._oldValueAsString=f,t.$.fireEvent("change",{value:JSON.parse(f),linq:t._queryParser.toLinq(t._validValue)}))}_clickHandlerDeleteButton(e,t){const a=this;if(e&&e.classList){if(a._closeEditor(),1===a.getElementsByClassName("smart-filter-group-condition").length){const e=a._valueFlat[1].htmlNode.children;a.value=[[[]]],a._validValue=a._getValidValue(),a._valueFlat[1].data=[],a._valueFlat[1].htmlNode.setAttribute("limit-selection",""),e[0].setAttribute("placeholder",""),e[1].setAttribute("placeholder",""),e[2].setAttribute("placeholder",""),e[2].removeAttribute("invalid-value"),e[0].firstElementChild.innerHTML=a.propertyPlaceholder,e[1].firstElementChild.innerHTML=a.operatorPlaceholder,e[2].firstElementChild.innerHTML=a.valuePlaceholder;const t=JSON.stringify(a._validValue);return a._oldValueAsString!==t&&(a._oldValueAsString=t,a.$.fireEvent("change",{value:JSON.parse(t),linq:a._queryParser.toLinq(a._validValue)})),void a._restrictNesting()}if(e.classList.contains("smart-filter-group")){if(t&&a._valueFlat.filter((t=>t.parentId===e.getAttribute("node-id"))).length>0)return;a._deleteElement(e,"group")}else a._deleteElement(e);a._generateValue(),a.$.scrollableContainer.refresh(),Array.from(a.$.contentContainer.children).forEach(((e,t)=>{const i=(t+1).toString();e.setAttribute("node-id",i),a._valueFlat.filter((t=>t.htmlNode===e))[0].nodeId=i,Array.from(e.children[1].children).forEach(((e,t)=>{const o=a._valueFlat.filter((t=>t.htmlNode===e))[0],l=i+"."+t;e.setAttribute("node-id",l),o.parentId=i,o.nodeId=l}))}))}}_menuCloseHandler(){const e=this.$.conditionsMenu.controlledBy;e.setAttribute("aria-expanded",!1),e.removeAttribute("aria-controls"),delete this.$.conditionsMenu.controlledBy}_menuClosingHandler(e){const t=e.detail;"interaction"===t.trigger&&this._selectedElement===t.target&&e.preventDefault()}_menuItemClickHandler(e){const t=this,a=t._selectedElement.closest(".smart-filter-group-operator, .smart-filter-nested-operator"),i=e.detail,o=i.value;let l;if(a){a.innerHTML=t.localize(o)||i.label,a.value=o,l=a.classList.contains("smart-filter-nested-operator")?a.getAttribute("node-id"):a.parentElement.getAttribute("node-id");for(let e=0;e<t._valueFlat.length;e++)if(t._valueFlat[e].nodeId===l){t._valueFlat[e].data=a.value;break}t._generateValue()}else l=t._selectedElement.parentElement.getAttribute("node-id"),t._addElement("group",null,o);t.$.scrollableContainer.refresh()}_newFilterConditionRow(e=[]){const t=this,a=e[0];let i,o=t._fields.find((e=>e.value===a)),l=o?o.label:void 0;void 0===a||!l&&"static"===t.fieldsMode?e.length=0:(l||(o=t._getDynamicFieldInfo(a),l=o.label,e[0]=o.dataField),i=t._getFilterOperations(o).find((t=>t.value===e[1])),i&&(i=i.label));const r=t._formatValueStringRepresentation(e[2],e),n=t._validateValueField(void 0,e[1],e[2]);let s=document.createElement("div"),d="condition"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),c='<div class="filter-builder-item smart-filter-field-name" id="'+d+'Field" '+(l?'><div class="smart-value-container" role="presentation">'+l:'placeholder><div class="smart-value-container" role="presentation">'+t.propertyPlaceholder)+'</div></div><div class="filter-builder-item smart-filter-operation" id="'+d+'Operation" '+(i?'><div class="smart-value-container" role="presentation">'+i:'placeholder><div class="smart-value-container" role="presentation">'+t.operatorPlaceholder)+'</div></div><div class="filter-builder-item smart-filter-value" id="'+d+'Value" '+(n?"":"invalid-value")+(void 0!==e[2]?'><div class="smart-value-container" role="presentation">'+r:'placeholder><div class="smart-value-container" role="presentation">'+t.valuePlaceholder)+'</div></div><div class="smart-filter-delete-btn" role="button" aria-label="Close"></div>';return s.className="smart-filter-group-condition",s.setAttribute("role","group"),s.innerHTML=c,t._setAriaLabel(s),e.length||s.setAttribute("limit-selection",""),s}_setAriaLabel(e){const t=[];for(let a=0;a<e.children.length-1;a++){const i=e.children[a];i.classList.contains("smart-visibility-hidden")||i.hasAttribute("placeholder")||t.push(e.children[a].innerText)}0!==t.length?e.setAttribute("aria-label",t.join(" ")):e.setAttribute("aria-label","Empty condition row")}_formatValueStringRepresentation(e,t){const a=this,i=t[2],o=t[0],l=a._getFieldByFieldName(o);let r,n=t[1];if(!l||!l.dataType)return e;if(null==e)return a.valuePlaceholder;if(void 0!==n&&a.customOperations&&a.customOperations.length>0&&(n=a.customOperations.find((e=>e.name===n)),n&&n.valueTemplate))return"<span>"+n.valueTemplate(a._editor,e)+"</span>";switch(l.dataType.toLowerCase()){case"date":case"datetime":(e=e instanceof Date||"string"==typeof e||"number"==typeof e&&!isNaN(e)?new Smart.Utilities.DateTime(e):e).calendar.days=a._localizedDays,e.calendar.months=a._localizedMonths,e.calendar.locale=a.locale,r=e.toString("date"===l.dataType?a.formatStringDate:a.formatStringDateTime);break;case"array":r="string"==typeof e?e.split(","):e;break;case"object":r="string"==typeof e?e:JSON.stringify(e);break;case"number":r=e;break;case"boolean":r=!!e;break;case"enum":r=e+"",l.lookup&&l.lookup.dataSource&&"function"==typeof l.lookup.dataSource&&l.lookup.dataSource("",(e=>{for(let t=0;t<e.length;t++){const a=e[t];if("object"==typeof a&&a.value&&a.value===i){r=a.label;break}}})),r=r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;");break;default:r=e+"",r=r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")}if(!a.valueFormatFunction)return"<span>"+r+"</span>";const s={label:r,value:i,dataField:o,dataType:l.dataType||"string"};return"<span>"+a.valueFormatFunction(s)+"</span>"}_getFieldByFieldName(e){return Object.assign({},this._fields.find((t=>t.value===e)))}_refresh(){const e=this;e._generateValue(),e._emptyElementsStructure(),e._generateHTMLStructureFromFlatValue(),e._restrictNesting()}_generateValue(e){const t=this;let a=[],i=t._valueFlat.slice(0),o=[];for(let e=0;e<i.length;e++){const t=i[e];let o={};"group"===t.type&&(o.nodeId=t.nodeId,o.parentId=t.parentId,o.data=t.data,o.structure=[],a.push(o))}for(let e=0;e<a.length;e++){const t=a[e];for(let e=0;e<i.length;e++){const a=i[e];if(a.parentId===t.nodeId&&"condition"===a.type){const o=i[e-1];o&&o.parentId===t.nodeId&&"operator"===o.type&&t.structure.push(o.data.toString()),t.structure.push(a.data)}}}a=a.filter((e=>e.structure.length>0)),a.sort((function(e,t){return t.nodeId.split(".").length-e.nodeId.split(".").length}));for(let e=0;e<a.length;e++){const t=a[e],i=a.filter((e=>e.nodeId===t.parentId))[0];i&&i.structure?i.structure.push(t.structure):"0"!==t.nodeId?t.data&&(e>0&&o.push(t.data),o.push(t.structure)):o=o.concat(t.structure)}if(t.set("value",o),t._validateValue(),t._validValue=t._getValidValue(),t._updateValidationStatus(),!e){const e=JSON.stringify(t._validValue);t._oldValueAsString!==e&&(t._oldValueAsString=e,t.$.fireEvent("change",{value:JSON.parse(e),linq:t._queryParser.toLinq(t._validValue)}))}}_updateValidationStatus(){const e=this,t=e.customOperations.filter((e=>"function"==typeof e.validateValue)),a=e._valueFlat,i=!!e._validationStatus;let o=!0;for(let e=0,i=a.length;e<i;e+=1){const i=a[e];if("condition"!==i.type)continue;const l=i.data[1],r=t.find((e=>e.name===l));if(r&&0==!!r.validateValue(i.data[2])){o=!1;break}}if(e._validationStatus!==o){const t=void 0!==e._validationStatus;e._validationStatus=o,t&&e.$.fireEvent("validationChange",{oldValue:i,newValue:o})}}_getItemById(e,t){const a=this._valueFlat.filter((a=>t?a.parentId===e:a.nodeId===e));return a.length>0?a[0]:null}_validateStoredValue(e,t){const a=this;if(!t&&!a._editedItem)return e;if(!t&&!(t=a._editedItem.data[0]))return e;const i=a._getFieldByFieldName(t).dataType;if(void 0===i)return e+"";switch(i.toLowerCase()){case"date":case"datetime":e=new Smart.Utilities.DateTime(e).toDate();break;case"number":"number"!=typeof e&&(e=parseFloat(e));break;case"boolean":"boolean"!=typeof e&&(e=!!e);break;case"object":"object"!=typeof e&&(e={});break;case"array":Array.isArray(e)||(e=[e]);break;default:"string"!=typeof e&&(e+="")}return e}_closeEditor(e,t){const a=this;let i;if(!a._editedItem||!a._editorIsOpen)return;const o=a._editedItem,l=a._editor.closest(".filter-builder-item"),r=l.querySelector(".smart-value-container"),n=l.parentElement,s=n.children[2];if(a._editor===a.$.dateTimePickerEditor)a._editor._inputChangeHandler(),i=a._editor.value,i&&(i=i.toDate());else if(a._editor===a.$.checkBoxEditor)i=a._editor.checked;else if(a._editor===a.$.customEditor)a._editor&&Array.from(a._editor.getElementsByTagName("smart-numeric-text-box")).forEach((e=>e._inputBlurHandler())),i=a._validateStoredValue(a._selectedCustomCondition.handleValue(a._editor));else if(a._editor===a.$.numericTextBoxEditor)a._editor._inputBlurHandler(),i=a._editor.value;else if(l.classList.contains("smart-filter-value")){const e=a._getFieldByFieldName(a._editedItem.data[0]);if("array"===e.dataType)i=a._editor.value.split(",");else if("object"===e.dataType)i=JSON.parse(a._editor.value);else{const t=a._editor.value;i=e.lookup&&e.lookup.dataSource?{label:t,value:a._editor.dataset.value||t}:t}}else i=a._editor.value;if(l.classList.contains("smart-filter-field-name")){if(""===i.trim())return void a._hideEditor(l,void 0===o.data[0]);n.hasAttribute("limit-selection")&&(n.removeAttribute("limit-selection"),n.parentElement.nextElementSibling.removeAttribute("limit-selection"));const e=a._fields.find((e=>e.label===i)),t=o.data[0];if(e)o.data[0]=e.value;else{if("dynamic"!==a.fieldsMode){const e=a._fields.find((e=>e.value===t));return e&&(r.innerHTML=e.label),void a._hideEditor(l)}{const e=a._getDynamicFieldInfo(i);i=e.label,o.data[0]=e.dataField}}r.innerHTML=i,a._handleFieldChange([t,o.data[0]],[s,o,n])}else if(l.classList.contains("smart-filter-operation"))a._handleOperationChange([o,i,a._editor.$.input.dataValue],[r,s]);else{let e,t;"object"==typeof i&&void 0!==i.value?(e=i.label,t=i.value,void 0===e&&(e=t)):e=t=i,o.data[2]=t,r.innerHTML=a._formatValueStringRepresentation(e,o.data)}a._validateValueField(s,o.data[1],o.data[2]),a._generateValue(e),!1!==t&&a._hideEditor(l)}_validateValueField(e,t,a){const i=this.customOperations;let o=!0;if(e&&e.removeAttribute("invalid-value"),i&&i.length>0){const l=i.find((e=>e.name===t));l&&"function"==typeof l.validateValue&&(o=!!l.validateValue(a),!o&&e&&e.setAttribute("invalid-value",""))}return o}_getDynamicFieldInfo(e){const t=this,a={label:e,dataField:e,dataType:"string"};if(t.getDynamicField){const i=t.getDynamicField(e);i.label&&(a.label=i.label),i.dataField&&(a.dataField=i.dataField),i.dataType&&(a.dataType=i.dataType),i.filterOperations&&Array.isArray(i.filterOperations)&&i.filterOperations.length>0&&(a.filterOperations=i.filterOperations),i.lookup&&(a.lookup=i.lookup)}return t._manuallyAddedFields.push(a),t._mapFieldsToMenu(),a}_handleFieldChange(e,t){const a=this,i=e[0],o=t[1],l=t[2],r=t[0],n=a._fields.find((t=>t.value===e[1])),s=a._getFilterOperations(n),d=function(){n.value!==i&&a.$.fireEvent("propertySelected",{label:n.label,value:n.value})};if(!i||void 0===o.data[1])return a._handleOnlyOperation(s,o.data,l),void d();const c=a._fields.find((e=>e.value===i)),u=c.dataType,p=n.dataType;if(n!==c&&(p!==u||"enum"===p||n.filterOperations||c.filterOperations)){if(s.find((e=>e.value===o.data[1]))){if(p===u&&"enum"!==p)return;return"date"===p&&"dateTime"===u||"dateTime"===p&&"date"===u?(r.firstElementChild.innerHTML=a._formatValueStringRepresentation(o.data),void d()):(o.data.splice(2,1),r.setAttribute("placeholder",""),r.firstElementChild.innerHTML=a.valuePlaceholder,void d())}o.data.splice(1,2),l.children[1].setAttribute("placeholder",""),l.children[1].firstElementChild.innerHTML=a.operatorPlaceholder,r.setAttribute("placeholder",""),r.firstElementChild.innerHTML=a.valuePlaceholder,r.classList.remove("smart-visibility-hidden"),a._handleOnlyOperation(s,o.data,l),d()}}_handleOnlyOperation(e,t,a){const i=this.autoPrompt;if(1===e.length||i&&"immediately"===this.applyMode&&e.length>1){const i=e[0];t[1]=i.value,a.children[1].removeAttribute("placeholder",""),a.children[1].firstElementChild.innerHTML=e[0].label,("isblank"===i.value||"isnotblank"===i.value||i.custom&&i.hideValue)&&(t.splice(2,1),a.children[2].classList.add("smart-visibility-hidden"))}}_handleOperationChange(e,t){const a=this,i=e[0],o=e[1],l=e[2],r=t[0],n=t[1],s=void 0!==i.data[1]?a._filterOperationDescriptions.find((e=>e.value===i.data[1])):void 0,d=a._filterOperationDescriptions.find((e=>e.value===l));if(!d||d===s)return;const c=d.value;i.data[1]=c;const u=i.data[0],p=i.data[1],m=i.data[2];if(r.innerHTML=o,"isblank"===c||"isnotblank"===c||d.custom&&d.hideValue)i.data.splice(2,1),n.classList.add("smart-visibility-hidden");else if(n.classList.contains("smart-visibility-hidden"))n.setAttribute("placeholder",""),n.classList.remove("smart-visibility-hidden"),n.firstElementChild.innerHTML=a.valuePlaceholder;else if(d.custom){const e=a._getFieldByFieldName(u);if(d.editorTemplate){const t=d.editorTemplate(e.dataType,p,e);t&&(a.$.customEditor.innerHTML="",a.$.customEditor.appendChild(t))}d.valueTemplate?n.firstElementChild.innerHTML=d.valueTemplate(a.$.customEditor,m):void 0===m?(n.setAttribute("placeholder",""),n.firstElementChild.innerHTML=a.valuePlaceholder):n.firstElementChild.innerHTML=m}else void 0===m?(i.data.splice(2,1),n.setAttribute("placeholder",""),n.firstElementChild.innerHTML=a.valuePlaceholder):d.custom||(n.firstElementChild.innerHTML=a._formatValueStringRepresentation(m,i.data))}_hideEditor(e,t){const a=this;t&&e.setAttribute("placeholder",""),e.removeAttribute("edited"),a.$.editorsContainer.removeAttribute("open"),a._editor.close&&a._editor.close(),a._editor.classList.add("smart-hidden"),a._editorIsOpen=a._enterIsPressedInEditor=!1,a.$.scrollableContainer.refresh(),a._setAriaLabel(e.parentElement)}_clickHandlerFilterButton(e,t,a){const i=this;function o(e,t,a){i._contextMenuOptions=0===t.length?i._defaultFilterOperationDescriptions:t,i._handleContextMenu(e),i.$.conditionsMenu.opened&&(i.$.conditionsMenu._discardKeyboardHover(),i.$.conditionsMenu._hoverViaKeyboard(i.$.conditionsMenu.querySelector('smart-menu-item[value="'+a+'"]')))}a.closest(".smart-editors-container")||(i._closeEditor(),i._editedItem=i._getItemById(t),e.contains("smart-filter-add-btn")?o(a,i._groupOperationDescriptions):(e.contains("smart-filter-field-name")||i._editedItem.data&&i._editedItem.data.length)&&(e.contains("smart-filter-group-operator")||e.contains("smart-filter-nested-operator")?o(a,i._groupOperationDescriptions,i._editedItem.data):(a.closest(".filter-builder-item").removeAttribute("placeholder"),i._openEditor(a))))}_handleContextMenu(e){const t=this;if(t._selectedElement===e&&t.$.conditionsMenu.opened)return void t.$.conditionsMenu.close();if(t._closeEditor(),t.disableContextMenu)return void(t._selectedElement=e);const a=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=a.left+t.$.contentContainer.scrollLeft-i.left,l=a.top+t.$.contentContainer.scrollTop-i.top+a.height;e.hasAttribute("aria-haspopup")&&(t.$.conditionsMenu.controlledBy&&(t.$.conditionsMenu.controlledBy.setAttribute("aria-expanded",!1),t.$.conditionsMenu.controlledBy.removeAttribute("aria-controls")),e.setAttribute("aria-controls",t.$.conditionsMenu.id),e.setAttribute("aria-expanded",!0),t.$.conditionsMenu.controlledBy=e),t.$.conditionsMenu.dataSource=t._contextMenuOptions,t.$.conditionsMenu.open(o,l+3),t._selectedElement=e,t.$.scrollableContainer.refresh()}_openEditor(e){const t=this,a=e&&e.closest(".smart-filter-group-condition")?e.closest(".smart-filter-group-condition").getAttribute("node-id"):null,i=e.closest(".filter-builder-item"),o=t._getItemById(a);let l="";void 0!==o.data[0]?l=o.data[0]:t._fields.length&&(l=t._fields[0].value);let r,n,s=t._getFieldByFieldName(l),d="";if(i.classList.contains("smart-filter-field-name"))n=0,t._fields||t._mapFieldsToMenu(),s.lookup={dataSource:t._fields.slice(),readonly:!1},d=s.label||"",r=s.value;else if(i.classList.contains("smart-filter-operation")){n=1;let e=t._getFilterOperations(s);s.lookup={dataSource:e,readonly:!0};let a=e.find((e=>e.value===o.data[n]))||e[0];d=a.label,r=a.value}else n=2,d=o.data[n],void 0===d&&(d="");t._editorIsOpen&&t._closeEditor(),i.setAttribute("edited",""),t._editedItem=o;const c=t._fields.filter((e=>e.value===l)),u=t._filterOperationDescriptions.filter((e=>e.value===o.data[1]&&e.custom)),p=c.length>0?c[0]:null,m=s.lookup&&s.lookup.dataSource?"lookup":p?p.dataType:void 0;if(2===n&&0!==u.length&&u[0].editorTemplate?(t._selectedCustomCondition=u[0],t._openCustomEditor(m,d,s)):t._openEditorByFieldType(m,d,s,r),i.appendChild(t.$.editorsContainer),t._editor.classList.remove("smart-hidden"),t._editorIsOpen=!0,t.$.editorsContainer.setAttribute("open",""),t.$.scrollableContainer.refresh(),t._editor.classList.contains("smart-custom-editor")){const e=t.customOperations[t._selectedCustomCondition.index].onEditorOpen;e&&e(t._editor)}else"immediately"===t.applyMode?requestAnimationFrame((()=>{t.autoApplyValue&&t._editor.closest(".smart-filter-value")?setTimeout((()=>{t._closeEditor(!1,!1),t._editor.querySelector("input").blur()})):t._editor.focus()})):requestAnimationFrame((()=>t._editor.focus()));s.lookup&&!t._valueValidationTimeout&&setTimeout((()=>{t._editor.open()}),200)}_getFilterOperations(e){const t=this;let a=t._filterOperationDescriptions.slice();if(e.filterOperations)a=t._filterOperationDescriptions.filter((t=>e.filterOperations.indexOf(t.value)>-1));else{let i;switch(e.dataType){case"date":case"dateTime":case"number":i=["=","<>","<",">","<=",">=","isblank","isnotblank"];break;case"boolean":i=["=","<>","isblank","isnotblank"];break;case"object":i=["isblank","isnotblank"];break;case"string":i=["contains","notcontains","startswith","endswith","=","<>","isblank","isnotblank"];break;default:i=["contains","notcontains","startswith","endswith","=","<>","<",">","<=",">=","isblank","isnotblank"]}a=t._filterOperationDescriptions.filter((e=>i.indexOf(e.value)>-1))}return t.showIcons&&a.map((e=>e.icon=t.icons[e.value])),a}_openCustomEditor(e,t,a){const i=this,o=i.customOperations[i._selectedCustomCondition.index].editorTemplate(e,t,a);i.$.customEditor.innerHTML="",o&&i.$.customEditor.appendChild(o),i._editor=i.$.customEditor}_openEditorByFieldType(e,t,a,i){const o=this;if(e)switch(e.toLowerCase()){case"boolean":return o._initializeEditor("checkBox"),void(o._editor.checked=!!t);case"date":case"datetime":return o._initializeEditor("dateTimePicker"),o._editor.formatString="date"===e?o.formatStringDate:o.formatStringDateTime,void(o._editor.value=t);case"number":return o._initializeEditor("numericTextBox"),void(o._editor.value=t||0)}if(o._initializeEditor("input"),o._editor.dropDownWidth=o.dropDownWidth,"lookup"===e){const i=a.lookup.minLength,l=a.lookup.dataSource;if(o._editor.autoCompleteDelay=a.lookup.autoCompleteDelay||100,o._editor.dropDownAppendTo=o.$.container,o._editor.dropDownButtonPosition=o.rightToLeft?"left":"right",o._editor.minLength=isNaN(i)||null===i?1:i,o._editor.readonly=!!a.lookup.readonly,"function"==typeof l?o._editor.dataSource=l:l instanceof Promise?l.then((e=>{if(!(o._editor instanceof Smart.Input))return;const a=o._editor.opened;o._editor.dataSource=e,e.length<12?o._editor.dropDownHeight="auto":o._editor.dropDownHeight=200,a&&(o._editor.open(),""===t&&o._editor.readonly&&e.length&&(o._editor.value=e[0].label||e[0]))})):(o._editor.dataSource=l,l.length<12?o._editor.dropDownHeight="auto":o._editor.dropDownHeight=200),"object"===e)t=JSON.stringify(t||{});else if(""===t&&o._editor.readonly){const e=o._editor.dataSource;if(Array.isArray(e)){const a=e[0];t=a&&(a.value||a.label)||""}else t=""}if("lookup"===e&&"function"==typeof l&&o._editor instanceof Smart.Input&&l("",(e=>{for(let a=0;a<e.length;a++){const i=e[a];if("string"==typeof i)i===t&&(t=i);else if(i.value&&i.value===t){t=i.label;break}}})),o._editor.isRendered){const e=o._editor.$.input.dataValue;null!=e&&e===t||(o._editor.value=void 0!==t?t+"":"")}else o._editor.value=void 0!==t?t+"":""}else o._editor.dataSource=[],o._editor.dropDownButtonPosition="none",o._editor.readonly=!1,o._editor.value=void 0!==t?t+"":"";i&&"object"!==e&&o._editor.isRendered&&(o._editor.$.input.dataValue=i)}_initializeEditor(e){const t=this;if(t.$[e+"Editor"])return void(t._editor=t.$[e+"Editor"]);const a=document.createElement("smart-"+Smart.Utilities.Core.toDash(e));"numericTextBox"===e?(a.spinButtons=!0,a.inputFormat="floatingPoint"):"dateTimePicker"===e&&(a.dropDownAppendTo=t.$.container,a.calendarButton=!0,a.dropDownDisplayMode="auto",a.enableMouseWheelAction=!0,a.locale=t.locale,a.autoClose=!0,a.messages[t.locale]||(a.messages[t.locale]={}),a.messages[t.locale].dateTabLabel=t.localize("dateTabLabel"),a.messages[t.locale].timeTabLabel=t.localize("timeTabLabel")),a.rightToLeft=t.rightToLeft,a.theme=t.theme,a.animation=t.animation,a.$.addClass("smart-hidden underlined"),t.$.editorsContainer.appendChild(a),t._editor=t.$[e+"Editor"]=a}_getValidValue(){const e=this,t=e.properties.value.value,a=[];let i=!1;return t.forEach((t=>{if(Array.isArray(t)){let o=!1,l=!1;const r=[];t.forEach((t=>{if(Array.isArray(t)){const a=t[0],i=t[1],n=t[2];if(void 0===a||void 0===i)return void(l=!0);if(void 0!==n||"isblank"===i||"isnotblank"===i)return o=!0,void r.push(t);const s=e._filterOperationDescriptions.find((e=>e.value===i));s.custom&&s.hideValue?(o=!0,r.push(t)):l=!0}else l?l=!1:r.push(t)})),o?("string"==typeof r[r.length-1]&&r.pop(),a.push(r)):i=!0}else i?i=!1:a.push(t)})),"string"==typeof a[a.length-1]&&a.pop(),a}}),Smart.Utilities.Assign("QueryParser",class{constructor(e,t,a){const i=this;i.customOperations=t||[],i.fields=e||[],i.dynamicField=a}toLinq(e){return Array.isArray(e)&&this._arePropertiesValid()?this._parseQueryToLinq(e):""}toValue(e){return"string"==typeof e&&this._arePropertiesValid()?this._parseLinqToValue(e):[]}_arePropertiesValid(){return Array.isArray(this.customOperations)?!!Array.isArray(this.fields)||(console.log('Invalid "fields" property.'),!1):(console.log('Invalid "customOperations" property.'),!1)}_parseQueryToLinq(e){const t=this,a={and:"&&",or:"||"};let i="";for(let o=0;o<e.length;o++){const l=e[o];if(Array.isArray(l))if(l.indexOf("and")>-1||l.indexOf("or")>-1||1===l.length&&Array.isArray(l[0])){const e=t._parseQueryToLinq(l);e?i+=l.length>1?"("+e+")":e:/\s(&|\|){2}\s$/gm.test(i)&&(i=i.replace(/\s(&|\|){2}\s$/gm,""))}else i+=t._getExpressionFromQuery(l)||"";else i&&(i+=" "+a[l]+" ")}return i}_getExpressionFromQuery(e){const t=e[0],a=e[1];let i=e[2];const o=this.customOperations.find((e=>e.name===a));return o&&o.expressionTemplate?("string"==typeof i&&i.includes('"')&&o.expressionTemplate.includes('"')&&(i=JSON.stringify(i).slice(1,-1)),o.expressionBuilderCallback?o.expressionBuilderCallback(t,a,i):o.expressionTemplate.replace("{0}",t).replace("{1}",i)):""}_parseLinqToValue(e){const t=this;let a,i=0,o=[];for(let t=0;t<e.length;t++)if("("===e[t])i++,void 0===a&&(a=t);else if(")"===e[t]&&i>0&&(i--,0===i)){let i=e.substring(a,t+1).trim();i.length&&(i.includes("&&")||i.includes("||"))&&o.push({expr:i}),a=void 0}let l,r=[];if(o.length)for(let a=0;a<o.length;a++){let i;o[a].query=t._getQueryFromExpression(o[a].expr),i=l?e.substring(e.indexOf(l)+l.length,e.indexOf(o[a].expr)).trim():e.substring(0,e.indexOf(o[a].expr)).trim(),i&&r.push(i),l=o[a].expr}l?r.push(e.substring(e.indexOf(l)+l.length).trim()):r.push(e.trim());for(let e=0;e<r.length;e++){const a=r[e].replace(/^&{2}|^\|{2}|&{2}$|\|{2}$/gm,"").trim();a.length&&o.push({expr:a,query:t._getQueryFromExpression(a),outher:!0})}return t._constructValueFromQueries(e,o)}_getQueryFromExpression(e){const t=this,a=t.fields,i=t.dynamicField;let o=[],l=e;const r=function(e){let l=[];const r=t.customOperations.filter((e=>e.expressionTemplate));r.sort(((e,t)=>t.expressionTemplate.length-e.expressionTemplate.length));for(let t=0;t<r.length;t++){const a=r[t],i=new RegExp(a.expressionTemplate.replace(/\(/gm,"\\(").replace(/\)/gm,"\\)").replace(/\[/gm,"\\[").replace(/\]/gm,"\\]").replace(/"{\d+}"/gm,'\\W*"([^"]*)[^a-zA-Z0-9-\\s\\)]+').replace(/{\d+}/gm,"([@|$]*\\w+[.]*\\w+(?!\\s)*)\\s{0}").replace(/ /gm,"\\s"),"gm");if(i.test(e)){i.lastIndex=0;let t,o,r=i.exec(e);if(r=r.filter(((e,t)=>r.indexOf(e)===t)),a.expressionReaderCallback){let e=a.expressionReaderCallback(r[0],r.slice(1));e&&(t=e.fieldName,o=e.value)}void 0===t&&(t=r[1]||""),void 0===o&&(o=r[2]||""),l.push({operator:a.name,field:t,value:o,query:r[0]})}}let n=l.find((e=>a.find((t=>t.filterOperations.indexOf(e.operator)>-1&&t.dataField===e.field))));if(!n&&i)for(let e=0;e<l.length;e++){const t=l[e],a=i(t.field);if(a&&Array.isArray(a.filterOperations)&&a.filterOperations.indexOf(t.operator)>-1){n=t;break}}if(n)return o.push({expr:n.query,query:[n.field,n.operator,n.value]}),n.query};if(l){for(;l.length;){l&&(l=l.trim(),"("===l[0]&&")"===l[l.length-1]&&(l=l.trim().replace(/^\(|\)$/gm,"")),l=l.replace(/^&{2}|^\|{2}|&{2}$|\|{2}$/gm,"").trim());const e=r(l);if(!e)break;l=l.replace(e,"").trim()}return t._constructValueFromQueries(e,o)}}_constructValueFromQueries(e,t){let a=[];t.sort(((t,a)=>e.indexOf(t.expr)-e.indexOf(a.expr)));for(let i=0;i<t.length;i++){let o=t[i-1];if(o){const l=e.substring(e.indexOf(o.expr)+o.expr.length,e.indexOf(t[i].expr)).trim();a.push("||"===l?"or":"and")}t[i].outher?t[i].query.forEach((e=>a.push(Array.isArray(e)?[e]:e))):a.push(t[i].query)}return a}});
82
82
  Smart("smart-filter-panel",class extends Smart.BaseElement{static get properties(){return{buttons:{value:["clear","filter"],type:"array"},data:{value:null,type:"array?",reflectToAttribute:!1},dataField:{value:null,type:"string?"},dataSource:{value:null,type:"any",reflectToAttribute:!1},evaluateFilterExpression:{value:null,type:"function?",reflectToAttribute:!1},filterType:{value:"string",allowedValues:["numeric","string","date","boolean"],type:"string"},formatString:{value:"d",type:"string"},messages:{value:{en:{addCondition:"Add Condition",addGroup:"Add Group",and:"and",blanks:"(Blanks)",cancel:"Cancel",clear:"Clear",contains:"contains",containsCaseSensitive:"contains (case sensitive)",dateTabLabel:"DATE",doesNotContain:"does not contain",doesNotContainCaseSensitive:"does not contain (case sensitive)",empty:"empty",endsWith:"ends with",endsWithCaseSensitive:"ends with (case sensitive)",equal:"equal",equalCaseSensitive:"equal (case sensitive)",filter:"Filter",greaterThan:"greater than",greaterThanOrEqual:"greater than or equal",lessThan:"less than",lessThanOrEqual:"less than or equal",mismatchedProperties:'smartFilterPanel: The "filterType" and the data type of the selected "dataField" are mismatched.',missingProperty:'smartFilterPanel: When mode is \'excel\', either "data" and "dataField" or "dataSource" of type Array have to be set.',notEmpty:"not empty",notEqual:"not equal",notNull:"not null",null:"null ",or:"or",placeholderBoolean:"Select value",placeholderDate:"Enter date",placeholderNumber:"Enter number",placeholderTime:"Enter time",placeholderValue:"Enter value",selectAll:"(Select All)",showRows:"Show rows where:",startsWith:"starts with",startsWithCaseSensitive:"starts with (case sensitive)",matchCase:"Match Case",timeTabLabel:"TIME"}},type:"object",extend:!0},mode:{value:"default",allowedValues:["basic","default","excel"],type:"string"}}}static get listeners(){return{"cancelButton.click":"cancel","clearButton.click":"clear","filterButton.click":"filter"}}template(){return'<div id="container" class="smart-container" role="presentation">\n <div id="label" class="smart-filter-panel-label"></div>\n <div id="mainContainer" role="presentation"></div>\n <div id="buttonContainer" class="smart-filter-panel-button-container" role="presentation">\n <smart-button id="filterButton" class="primary" animation="[[animation]]" disabled="[[disabled]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" unfocusable="[[unfocusable]]"></smart-button>\n <smart-button id="clearButton" animation="[[animation]]" disabled="[[disabled]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" unfocusable="[[unfocusable]]"></smart-button>\n <smart-button id="cancelButton" animation="[[animation]]" disabled="[[disabled]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" unfocusable="[[unfocusable]]"></smart-button>\n </div>\n </div>'}static get styleUrls(){return["smart.grid.css","smart.dropdownlist.css","smart.menu.css","smart.filterpanel.css","smart.textbox.css"]}ready(){super.ready()}render(){const e=this,t=e.filterType;e.$.label.id||(e.$.label.id=e.id+"Label"),e.setAttribute("role","dialog"),e.setAttribute("aria-labelledby",e.$.label.id),e._localize(),e._setButtonsVisibility(),e._filterType=t+"Filter",e._filterHandler=new(Smart.Utilities[t.slice(0,1).toUpperCase()+t.slice(1)+"FilterHandler"])(e),super.render()}cancel(){const e=this;e._filterHandler[e.mode+"Cancel"](),e.$.fireEvent("cancel")}clear(){const e=this;e._filterHandler[e.mode+"Clear"](),e.$.fireEvent("clear")}reset(){const e=this;e.$.clearButton.removeAttribute("hover"),e.$.filterButton.removeAttribute("hover"),e.$.cancelButton.removeAttribute("hover"),e._filterHandler.firstInputMatchCase&&e._filterHandler.firstInputMatchCase.classList.remove("active"),e._filterHandler.secondInputMatchCase&&e._filterHandler.secondInputMatchCase.classList.remove("active"),e._filterHandler[e.mode+"Clear"](),e._filterHandler.filterObject=new Smart.Utilities.FilterGroup}getFilter(){if(this._filterHandler){const e=new Smart.Utilities.FilterGroup;for(let t in this._filterHandler.filterObject)e[t]=this._filterHandler.filterObject[t];return e}return null}evaluate(e){try{return this._filterHandler.evaluate(e)}catch(e){return!1}}filter(){const e=this;e._filterHandler[e.mode+"Filter"](),e.$.fireEvent("filter")}getState(){return this._filterHandler.cachedFilter}loadState(e){try{const t=this;t._filterHandler.cachedFilter=e,t._filterHandler[t.mode+"Cancel"]()}catch(e){}}propertyChangedHandler(e,t,l){super.propertyChangedHandler(e,t,l);const a=this,i=a._filterHandler;function s(){a.$.mainContainer.innerHTML="",function(){const e=["cachedFilter","caseSensitive","customExcelFilterObjects","customItems","dataSource","defaultListSelection","defaultListSource","displayMode","filterBuilder","filterBuilderObject","filterBuilderOperations","filterObject","firstInput","firstList","operationsMapping","operatorList","secondInput","secondList","timeOnly","tree"];e.forEach((function(t){delete i[e[t]]})),delete a._filterHandler}(),a._filterHandler=new(Smart.Utilities[a.filterType.slice(0,1).toUpperCase()+a.filterType.slice(1)+"FilterHandler"])(a)}switch(e){case"animation":case"disabled":case"rightToLeft":case"unfocusable":switch(a.mode){case"default":case"basic":[i.firstList,i.firstInput,i.logicalOperatorList,i.secondList,i.secondInput].forEach((function(t){t[e]=l}));break;case"excel":i.tree[e]=l;break;case"filterBuilder":i.filterBuilder[e]=l,i.caseSensitive&&(i.caseSensitive[e]=l)}break;case"buttons":a._setButtonsVisibility();break;case"data":case"dataField":"excel"!==a.mode||Array.isArray(a.dataSource)||s();break;case"dataSource":"excel"===a.mode&&s();break;case"filterType":a._filterType=l+"Filter",s();break;case"mode":s();break;case"formatString":if("date"!==a.filterType)return;switch(a.mode){case"default":case"basic":i.firstInput.formatString=l,i.secondInput.formatString=l;break;case"excel":s();break;case"filterBuilder":i.filterBuilder.formatStringDate=l,i.filterBuilder.formatStringDateTime=l}break;case"locale":case"messages":switch(a._localize(),a.mode){case"default":case"basic":{const t=i.firstList.selectedIndex,l=i.logicalOperatorList.selectedIndex,s=i.secondList.selectedIndex,r=[i.firstInput,i.secondInput];switch(i.setDefaults(),i.firstList.dataSource=JSON.parse(JSON.stringify(i.defaultListSource)),i.logicalOperatorList.dataSource=[{value:0,label:a.localize("and")},{value:1,label:a.localize("or")}],i.secondList.dataSource=JSON.parse(JSON.stringify(i.defaultListSource)),a.filterType){case"date":r.forEach((function(t){t.messages[a.locale]||(t.messages[a.locale]={});const l=a.localize("dateTabLabel");l&&(t.messages[a.locale].dateTabLabel=l);const i=a.localize("timeTabLabel");if(i&&(t.messages[a.locale].timeTabLabel=i),"locale"===e&&(t.locale=a.locale),"timePicker"===t._dropDownDisplayMode){const e=a.localize("placeholderTime");e&&(t.placeholder=e,t.placeholder=e)}else{const e=a.localize("placeholderDate");e&&(t.placeholder=e,t.placeholder=e)}}));break;case"numeric":r[0].placeholder=a.localize("placeholderNumber"),r[1].placeholder=a.localize("placeholderNumber");break;case"string":r[0].placeholder=a.localize("placeholderValue"),r[1].placeholder=a.localize("placeholderValue");break;case"boolean":r[0].placeholder=a.localize("placeholderBoolean"),r[1].placeholder=a.localize("placeholderBoolean")}i.firstList.selectedIndex=t,i.logicalOperatorList.selectedIndex=l,i.secondList.selectedIndex=s;break}case"excel":i.tree.selectAll&&(i.tree.selectAll.label=a.localize("selectAll")),i.tree.blanks&&(i.tree.blanks.label=a.localize("blanks"));break;case"filterBuilder":i.localizeFilterBuilder(),"messages"===e&&(i.filterBuilder._localizeInitialValues(),i.filterBuilder._refresh()),i.filterBuilder.$.scrollableContainer.refresh()}}}_localize(){const e=this;e.localize("showRows")&&(e.$.label.innerHTML=e.localize("showRows")),e.localize("filter")&&(e.$.filterButton.innerHTML=e.localize("filter")),e.localize("clear")&&(e.$.clearButton.innerHTML=e.localize("clear")),e.localize("cancel")&&(e.$.cancelButton.innerHTML=e.localize("cancel"))}_setButtonsVisibility(){const e=this,t=e.buttons;["cancel","clear","filter"].forEach((function(l){-1!==t.indexOf(l)?e["$"+l+"Button"].removeClass("smart-hidden"):e["$"+l+"Button"].addClass("smart-hidden")}))}}),Smart.Utilities.Assign("BaseFilterHandler",class{constructor(e){const t=this;if(t.basicFilter=t.defaultFilter,t.basicClear=t.defaultClear,t.basicCancel=t.defaultCancel,t.context=e,t.filterObject=new Smart.Utilities.FilterGroup,t.setDefaults(),"date"===e.filterType){const l=new Smart.Utilities.DateTime,a=e.formatString,i=l.getParseRegExp(l.calendar,a.replace(/y+/g,"yyyyy"));t.displayMode=Smart.Utilities.DateTime.detectDisplayMode(l,a,i),t.timeOnly="timePicker"===t.displayMode}"default"!==e.mode&&"basic"!==e.mode?(t.operationsMapping={"=":"EQUAL","<>":"NOT_EQUAL","<":"LESS_THAN",">":"GREATER_THAN","<=":"LESS_THAN_OR_EQUAL",">=":"GREATER_THAN_OR_EQUAL",isblank:"EMPTY",isnotblank:"NOT_EMPTY",contains:"CONTAINS",notcontains:"DOES_NOT_CONTAIN",startswith:"STARTS_WITH",endswith:"ENDS_WITH",NULL:"NULL",NOT_NULL:"NOT_NULL"},"excel"===e.mode?t.createExcelHTMLStructure():"filterBuilder"===e.mode&&t.createBuilderHTMLStructure()):t.createDefaultHTMLStructure()}setDefaults(){const e=this,t=e.context;e.defaultListSource=[{prefix:'<span class="smart-icon smart-icon-equal"></span>',value:"EQUAL",label:t.localize("equal")},{prefix:'<span class="smart-icon smart-icon-not-equal"></span>',value:"NOT_EQUAL",label:t.localize("notEqual")},{prefix:'<span class="smart-icon smart-icon-less-than"></span>',value:"LESS_THAN",label:t.localize("lessThan")},{prefix:'<span class="smart-icon smart-icon-less-than-equal"></span>',value:"LESS_THAN_OR_EQUAL",label:t.localize("lessThanOrEqual")},{prefix:'<span class="smart-icon smart-icon-greater-than"></span>',value:"GREATER_THAN",label:t.localize("greaterThan")},{prefix:'<span class="smart-icon smart-icon-greater-than-equal"></span>',value:"GREATER_THAN_OR_EQUAL",label:t.localize("greaterThanOrEqual")},{prefix:'<span class="smart-icon smart-icon-null"></span>',value:"NULL",label:t.localize("null")},{prefix:'<span class="smart-icon smart-icon-not-null"></span>',value:"NOT_NULL",label:t.localize("notNull")}],e.filterBuilderOperations=["<","=","<>","<=",">",">=","NULL","NOT_NULL"],e.defaultListSelection=2}createDefaultHTMLStructure(){const e=this,t=e.context,l=document.createElement("smart-input"),a=document.createElement("smart-input"),i=document.createElement("smart-input"),s=document.createDocumentFragment(),r=e=>{e.readonly=!0,e.dropDownButtonPosition="right"};l.classList.add("smart-filter-panel-list"),l.dataSource=JSON.parse(JSON.stringify(this.defaultListSource)),l.selectedIndex=e.defaultListSelection,r(l),a.classList.add("smart-filter-panel-operator-list"),a.dataSource=[{value:0,label:t.localize("and")},{value:1,label:t.localize("or")}],r(a),i.classList.add("smart-filter-panel-list"),i.dataSource=JSON.parse(JSON.stringify(this.defaultListSource)),i.selectedIndex=e.defaultListSelection,r(i),e.firstList=l,e.logicalOperatorList=a,e.secondList=i;const n=document.createElement("span");n.classList.add("smart-icon","smart-icon-font-size"),n.title=t.localize("matchCase");const c=document.createElement("span");c.classList.add("smart-icon","smart-icon-font-size"),c.title=t.localize("matchCase"),e.firstInputMatchCase=n,e.secondInputMatchCase=c,e.appendInputs(),e.firstInput.classList.add("smart-filter-panel-input"),e.secondInput.classList.add("smart-filter-panel-input"),"basic"===t.mode&&(e.secondList.classList.add("smart-hidden"),e.secondInput.classList.add("smart-hidden"),e.logicalOperatorList.classList.add("smart-hidden"),e.secondInputMatchCase.classList.add("smart-hidden")),a.dropDownHeight="auto",a.selectedIndex=0,[l,e.firstInput,e.firstInputMatchCase,a,i,e.secondInput,e.secondInputMatchCase].forEach((function(e){e.animation=t.animation,e.disabled=t.disabled,e.unfocusable=t.unfocusable,e.dropDownPosition="bottom",e.dropDownAppendTo="body",e.dropDownMaxHeight=200,e.rightToLeft=t.rightToLeft,s.appendChild(e)})),e.context.$.mainContainer.appendChild(s),e.cacheFilter(e.defaultListSelection,0,e.defaultListSelection)}cacheFilter(e,t,l){const a=this;a.cachedFilter={firstFilterComparison:e,firstFilterValue:a.firstInput.value,firstFilterCaseSensitive:a.firstInputMatchCase.classList.contains("active"),logicalOperator:t,secondFilterComparison:l,secondFilterValue:a.secondInput.value,secondFilterCaseSensitive:a.secondInputMatchCase.classList.contains("active")}}defaultFilter(){const e=this,t=e.context,l=e.getFilterInputValue(e.firstInput),a=parseFloat(e.logicalOperatorList.selectedValues[0]),i=e.getFilterInputValue(e.secondInput),s=e.filterObject;let r=e.firstList.selectedValues[0],n=e.secondList.selectedValues[0];s.clear();const c=e=>"CONTAINS"===e?"CONTAINS_CASE_SENSITIVE":"DOES_NOT_CONTAIN"===e?"DOES_NOT_CONTAIN_CASE_SENSITIVE":"STARTS_WITH"===e?"STARTS_WITH_CASE_SENSITIVE":"ENDS_WITH"===e?"ENDS_WITH_CASE_SENSITIVE":"EQUAL"===e?"EQUAL_CASE_SENSITIVE":"NOT_EQUAL"===e?"NOT_EQUAL_CASE_SENSITIVE":void 0;if(e.firstInputMatchCase.classList.contains("active")&&(r=c(r)),e.secondInputMatchCase.classList.contains("active")&&(n=c(n)),""!==l||-1!==["NULL","NOT_NULL","EMPTY","NOT_EMPTY"].indexOf(r)){const i=s.createFilter(t._filterType,l,r,void 0,t.formatString,t.locale,"timePicker"===e.firstInput._dropDownDisplayMode);s.addFilter(a,i)}if(""!==i||-1!==["NULL","NOT_NULL","EMPTY","NOT_EMPTY"].indexOf(n)){const l=s.createFilter(t._filterType,i,n,void 0,t.formatString,t.locale,"timePicker"===e.secondInput._dropDownDisplayMode);s.addFilter(a,l)}let o=e.firstList.selectedIndexes[0],d=e.secondList.selectedIndexes[0];const u=s.stringConditions;l&&"string"==typeof l&&(o=u.findIndex((e=>e===r))),i&&"string"==typeof i&&(d=u.findIndex((e=>e===n))),e.cacheFilter(o,e.logicalOperatorList.selectedIndexes[0],d)}getFilterInputValue(e){return e.value}excelFilter(){const e=this,t=e.context;if(Array.isArray(t.dataSource))return void e.customExcelFilter();const l=e.tree,a=e.filterObject;if(a.clear(),e.customItems=[],l._menuItems[0].selected)return void e.excelClear();const i=l.selectedIndexes;if(i.forEach((function(i){const s=l._menuItems[i];if(s instanceof Smart.TreeItem){const l=s.value;if(s.hasAttribute("default-item"))if(l instanceof Date){const i=new Smart.FilterGroup,s=new Date(l.getFullYear(),l.getMonth(),1),r=new Date(l.getFullYear(),l.getMonth()+1,0),n=i.createFilter(t._filterType,s,"GREATER_THAN_OR_EQUAL",void 0,t.formatString,t.locale,e.timeOnly),c=i.createFilter(t._filterType,r,"LESS_THAN_OR_EQUAL",void 0,t.formatString,t.locale,e.timeOnly);i.addFilter("and",n),i.addFilter("and",c),a.addFilter("or",i)}else{const i=e.getExcelComparison(l),s=a.createFilter(t._filterType,l,i,void 0,t.formatString,t.locale,e.timeOnly);a.addFilter("or",s)}else e.customItems.push(s)}})),0===i.length){const l=e.getExcelComparison("Empty Filter"),i=a.createFilter(t._filterType,"Empty Filter",l,void 0,t.formatString,t.locale,e.timeOnly);a.addFilter("or",i)}e.cachedFilter=i.slice(0)}customExcelFilter(){const e=this,t=e.tree;if(delete e.customExcelFilterObjects,t._menuItems[0].selected)return;const l=e.context,a=[],i=t.selectedIndexes;i.forEach((function(i){const s=t._menuItems[i];if(s instanceof Smart.TreeItem){let t=s.value;if(!Array.isArray(t))return;Array.isArray(t[0])||(t=[t]);const i=new Smart.Utilities.FilterGroup;for(let a=0;a<t.length;a++){const s=t[a],r=e.operationsMapping[s[1]],n=i.createFilter(l._filterType,s[2],r,void 0,l.formatString,l.locale,e.timeOnly);i.addFilter("and",n)}a.push(i)}})),e.customExcelFilterObjects=a,e.cachedFilter=i.slice(0)}getExcelComparison(e){return""===e?"NULL":"EQUAL"}filterBuilderFilter(){const e=this,t=e.filterBuilder.value,l="string"===e.context.filterType&&e.caseSensitive.checked,a={filters:[]};!function t(a,i){const s=new Smart.Utilities.FilterGroup,r=a[1];i.logicalOperator=r;for(let n=0;n<a.length;n++){if(1===n)continue;const c=a[n];if(Array.isArray(c))if(Array.isArray(c[0])){const e={filters:[]};i.filters.push(e),t(c,e)}else s.addFilter(r,e.createFilterBuilderFilter(s,c,l))}s.filters.length>0&&i.filters.push(s)}(t,a),e.filterBuilderObject=a,e.cachedFilter={filterBuilder:JSON.parse(JSON.stringify(e.filterBuilder.value),(function(e,t){return/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{3})Z$/.test(t)?new Date(t):t})),caseSensitive:l}}createFilterBuilderFilter(e,t,l){const a=this.context;let i=this.operationsMapping[t[1]];return l&&-1!==["CONTAINS","DOES_NOT_CONTAIN","STARTS_WITH","ENDS_WITH","EQUAL"].indexOf(i)&&(i+="_CASE_SENSITIVE"),e.createFilter(a._filterType,t[2],i,void 0,a.formatString,a.locale,!1)}defaultClear(){const e=this;e.firstList.selectedIndexes=[e.defaultListSelection],e.firstInput.value="",e.logicalOperatorList.selectedIndexes=[0],e.secondList.selectedIndexes=[e.defaultListSelection],e.secondInput.value="",e.filterObject.clear(),e.cacheFilter(e.defaultListSelection,0,e.defaultListSelection)}excelClear(){const e=this;0!==e.tree.offsetHeight&&e.tree.select("0"),e.filterObject.clear(),e.cachedFilter=e.tree.selectedIndexes.slice(0)}filterBuilderClear(){const e=this;e.filterBuilder.value=["and"],"string"===e.context.filterType&&(e.caseSensitive.checked=!1),e.cachedFilter={filterBuilder:["and"],caseSensitive:!1}}defaultCancel(){const e=this;let t=null,l=null;if(e.filterObject){const a=e.filterObject.stringConditions,i=e.filterObject.numericConditions,s=e.filterObject.booleanConditions,r=e.filterObject.dateConditions;t=a[e.cachedFilter.firstFilterComparison],l=a[e.cachedFilter.secondFilterComparison],e.cachedFilter.firstFilterValue&&"string"!=typeof e.cachedFilter.firstFilterValue&&(!0===e.cachedFilter.firstFilterValue||!1===e.cachedFilter.firstFilterValue?(t=s[e.cachedFilter.firstFilterComparison],l=s[e.cachedFilter.secondFilterComparison]):e.cachedFilter.firstFilterValue&&e.cachedFilter.firstFilterValue instanceof Date?(t=r[e.cachedFilter.firstFilterComparison],l=r[e.cachedFilter.secondFilterComparison]):(t=i[e.cachedFilter.firstFilterComparison],l=i[e.cachedFilter.secondFilterComparison]))}let a=-1;e.firstList.dataSource.find(((e,l)=>{if(e.value===t)return a=l,e}));let i=-1;e.secondList.dataSource.find(((e,t)=>{if(e.value===l)return i=t,e})),e.firstList.selectedIndexes=[a],e.firstInput.value=e.cachedFilter.firstFilterValue,e.cachedFilter.firstFilterCaseSensitive&&e.firstInputMatchCase.classList.add("active"),e.logicalOperatorList.selectedIndexes=[e.cachedFilter.logicalOperator],e.secondList.selectedIndexes=[i],e.secondInput.value=e.cachedFilter.secondFilterValue,e.cachedFilter.firstFilterCaseSensitive&&e.firstInputMatchCase.classList.add("active"),e.cachedFilter.secondFilterCaseSensitive&&e.secondInputMatchCase.classList.add("active")}excelCancel(){const e=this;if(e.cachedFilter&&e.cachedFilter.firstFilterValue){const t=e.cachedFilter.firstFilterValue,l=e.cachedFilter.secondFilterValue,a=e.cachedFilter.firstFilterComparison,i=e.cachedFilter.secondFilterComparison;let s=e.filterObject.stringConditions;if(isNaN(parseFloat(t))||(s=e.filterObject.numericConditions),e.dataSource){let r=[];return e.dataSource.forEach(((e,n)=>{r.push("0."+n),e.label===t||e.label===l?("NOT_EQUAL"!==s[a]&&"DOES_NOT_CONTAIN"!==s[a]||r.pop(),"NOT_EQUAL"!==s[i]&&"DOES_NOT_CONTAIN"!==s[i]||r.pop()):e.label===t&&e.label===l||("EQUAL"!==s[a]&&"EQUAL_CASE_SENSITIVE"!==s[a]&&"CONTAINS"!==s[a]&&"ENDS_WITH"!==s[a]&&"STARTS_WITH"!==s[a]||r.pop(),"EQUAL"!==s[i]&&"EQUAL_CASE_SENSITIVE"!==s[i]&&"CONTAINS"!==s[i]&&"ENDS_WITH"!==s[i]&&"STARTS_WITH"!==s[i]||r.pop())})),void setTimeout((()=>{e.tree.selectedIndexes=r}))}}else if(e.cachedFilter&&e.cachedFilter.filters&&e.dataSource){let t=[];return e.dataSource.forEach(((l,a)=>{t.push("0."+a);let i=!1;e.cachedFilter.filters.forEach((e=>{e.value===l.label&&(i=!0)})),i||t.pop()})),void setTimeout((()=>{e.tree.selectedIndexes=t}))}e.tree.selectedIndexes=e.cachedFilter.slice(0)}filterBuilderCancel(){const e=this;e.filterBuilder.value=e.cachedFilter.filterBuilder,"string"===e.context.filterType&&(e.caseSensitive.checked=e.cachedFilter.caseSensitive)}createExcelHTMLStructure(){const e=this,t=e.context,l=document.createElement("smart-tree"),a={data:t.data,dataField:t.dataField,filterType:t._filterType};if(t.dataSource&&Array.isArray(t.dataSource))e.processCustomDataSource(l);else{if(t.data&&t.dataField||t.error(t.localize("missingProperty")),"date"===t.filterType){a.formatString=t.formatString,a.displayMode=e.displayMode,e.dataSource=e.filterObject.getUniqueValues(a,t);try{e.getHierarchicalDataSource(e.displayMode)}catch(e){t.error(t.localize("mismatchedProperties"))}e.timeOnly?l.classList.add("standard-excel"):l.classList.add("date-excel")}else e.dataSource=e.filterObject.getUniqueValues(a,t),l.classList.add("standard-excel");"function"==typeof t.dataSource&&(e.dataSource=t.dataSource(e.dataSource)||e.dataSource)}l.animation=t.animation,l.disabled=t.disabled,l.unfocusable=t.unfocusable,l.dataSource=[{label:t.localize("selectAll"),value:"",items:e.dataSource,expanded:!0,selected:!0}],l.selectionMode="checkBox",l.hasThreeStates=!0,l.theme=t.theme,l.animation="none",l.toggleMode="arrow",l.rightToLeft=t.rightToLeft,l.addEventListener("collapsing",(function(e){1===e.detail.item.level&&e.preventDefault()})),l._onCompleted=function(){if(e.cachedFilter=l.selectedIndexes.slice(0),l.classList.contains("date-excel"))for(let e in l._menuItems){if("0"===e)continue;const t=l._menuItems[e];t.firstElementChild.style.paddingLeft=20*(t.level-1)-10+"px"}else l._menuItems[0].firstElementChild.style.paddingLeft=0;l.selectAll=l._menuItems[0],l.blanks=l.querySelector('[label="'+t.localize("blanks")+'"]'),"en"!==t.locale&&(l.selectAll&&(l.selectAll.label=t.localize("selectAll")),l.blanks&&(l.blanks.label=t.localize("blanks")))},e.tree=l,t.$.mainContainer.appendChild(l)}processCustomDataSource(e){const t=this.context.dataSource;e.classList.add("standard-excel"),this.dataSource=t}createBuilderHTMLStructure(){const e=this,t=e.context,l=document.createElement("smart-filter-builder"),a=t.dataField,i="numeric"===t.filterType?"number":t.filterType;if(e.filterBuilder=l,l.animation=t.animation,l.disabled=t.disabled,l.unfocusable=t.unfocusable,l.value=["and"],l.fields=[{label:a,dataField:a,dataType:i,filterOperations:e.filterBuilderOperations}],e.localizeFilterBuilder(),t.$.mainContainer.appendChild(l),"string"===i){const l=document.createElement("smart-check-box");l.classList.add("case-sensitive"),l.innerHTML="Case sensitive",l.animation=t.animation,l.disabled=t.disabled,l.unfocusable=t.unfocusable,l.checked=!1,e.caseSensitive=l,t.$.mainContainer.appendChild(l)}e.filterBuilderObject={filters:[]},e.cachedFilter={filterBuilder:["and"],caseSensitive:!1}}localizeFilterBuilder(){const e=this.context,t=this.filterBuilder;let l=t.messages[e.locale];l||(l={},t.messages[e.locale]=l),t.customOperations=[{name:"NULL",label:e.localize("null"),hideValue:!0},{name:"NOT_NULL",label:e.localize("notNull"),hideValue:!0}],l.addCondition=e.localize("addCondition"),l.addGroup=e.localize("addGroup"),l["<"]=e.localize("lessThan"),l["<="]=e.localize("lessThanOrEqual"),l["<>"]=e.localize("notEqual"),l["="]=e.localize("equal"),l[">"]=e.localize("greaterThan"),l[">="]=e.localize("greaterThanOrEqual"),l.and=e.localize("and"),l.contains=e.localize("contains"),l.endswith=e.localize("endsWith"),l.isblank=e.localize("empty"),l.isnotblank=e.localize("notEmpty"),l.notcontains=e.localize("doesNotContain"),l.or=e.localize("or"),l.startswith=e.localize("startsWith"),l.dateTabLabel=e.localize("dateTabLabel"),l.timeTabLabel=e.localize("timeTabLabel"),t.formatStringDate=e.formatString,t.formatStringDateTime=e.formatString,t.locale=e.locale,t.valuePlaceholder=e.localize("filterBuilderPlaceholder")}evaluate(e){const t=this,l=t.context;if("default"===l.mode||"basic"===l.mode)return t.filterObject.evaluate(e);if("excel"===l.mode){let a=!1;if(Array.isArray(l.dataSource)){if(!t.customExcelFilterObjects||0===t.customExcelFilterObjects.length)return!0;for(let l=0;l<t.customExcelFilterObjects.length;l++)a=a||t.customExcelFilterObjects[l].evaluate(e);return a}if(t.customItems&&t.customItems.length>0){if(t.filterObject.filters.length>0&&(a=t.filterObject.evaluate(e)),t.customItems&&l.evaluateFilterExpression)for(let i=0;i<t.customItems.length;i++){const s=l.evaluateFilterExpression(e,t.customItems[i].value);void 0!==s&&(a=a||s)}}else a=t.filterObject.evaluate(e);return a}return!t.filterBuilderObject.logicalOperator||function t(l){let a="and"===l.logicalOperator;for(let i=0;i<l.filters.length;i++){let s;s=l.filters[i]instanceof Smart.Utilities.FilterGroup?l.filters[i].evaluate(e):t(l.filters[i]),a="and"===l.logicalOperator?a&&s:a||s}return a}(t.filterBuilderObject)}}),Smart.Utilities.Assign("NumericFilterHandler",class extends Smart.Utilities.BaseFilterHandler{appendInputs(){let e=this,t=document.createElement("smart-number-input"),l=document.createElement("smart-number-input");t.placeholder=e.context.localize("placeholderNumber"),l.placeholder=e.context.localize("placeholderNumber"),t.nullable=!0,t.spinButtons=!0,t.value=null,l.nullable=!0,l.spinButtons=!0,l.value=null,e.firstInput=t,e.secondInput=l}getFilterInputValue(e){return null===e.value||""===e.value?"":parseFloat(e.value)}}),Smart.Utilities.Assign("StringFilterHandler",class extends Smart.Utilities.BaseFilterHandler{setDefaults(){const e=this,t=e.context;e.defaultListSource=[{prefix:'<span class="smart-icon smart-icon-empty"></span>',value:"EMPTY",label:t.localize("empty")},{prefix:'<span class="smart-icon smart-icon-not-empty"></span>',value:"NOT_EMPTY",label:t.localize("notEmpty")},{prefix:'<span class="smart-icon smart-icon-contains"></span>',value:"CONTAINS",label:t.localize("contains")},{prefix:'<span class="smart-icon smart-icon-does-not-contain"></span>',value:"DOES_NOT_CONTAIN",label:t.localize("doesNotContain")},{prefix:'<span class="smart-icon smart-icon-starts-with"></span>',value:"STARTS_WITH",label:t.localize("startsWith")},{prefix:'<span class="smart-icon smart-icon-ends-with"></span>',value:"ENDS_WITH",label:t.localize("endsWith")},{prefix:'<span class="smart-icon smart-icon-equal"></span>',value:"EQUAL",label:t.localize("equal")},{prefix:'<span class="smart-icon smart-icon-not-equal"></span>',value:"NOT_EQUAL",label:t.localize("notEqual")},{prefix:'<span class="smart-icon smart-icon-null"></span>',value:"NULL",label:t.localize("null")},{prefix:'<span class="smart-icon smart-icon-not-null"></span>',value:"NOT_NULL",label:t.localize("notNull")}],e.filterBuilderOperations=["contains","isblank","isnotblank","notcontains","startswith","endswith","=","NULL","NOT_NULL"],e.defaultListSelection=2}appendInputs(){const e=this,t=document.createElement("input"),l=document.createElement("input");t.placeholder=e.context.localize("placeholderValue"),t.setAttribute("aria-label",t.placeholder),l.placeholder=e.context.localize("placeholderValue"),l.setAttribute("aria-label",l.placeholder),t.classList.add("smart-input"),l.classList.add("smart-input"),e.firstInput=t,e.secondInput=l,e.firstInputMatchCase.onclick=()=>{e.firstInputMatchCase.classList.toggle("active")},e.secondInputMatchCase.onclick=()=>{e.secondInputMatchCase.classList.toggle("active")};const a=(e,t,l)=>{if(0===e.selectedValues.length)return t.classList.remove("case-sensitive"),void l.classList.remove("case-sensitive");const a=e.selectedValues[0];t.classList.remove("case-sensitive"),l.classList.remove("case-sensitive"),["EQUAL","NOT_EQUAL","CONTAINS","DOES_NOT_CONTAIN","STARTS_WITH","ENDS_WITH"].indexOf(a)>=0&&(t.classList.add("case-sensitive"),l.classList.add("case-sensitive"))};e.firstList.onchange=()=>{a(e.firstList,e.firstInput,e.firstInputMatchCase)},e.secondList.onchange=()=>{a(e.secondList,e.secondInput,e.secondInputMatchCase)},setTimeout((()=>{a(e.firstList,e.firstInput,e.firstInputMatchCase),a(e.secondList,e.secondInput,e.secondInputMatchCase)}),50)}getExcelComparison(e){return""===e?"EMPTY":"EQUAL_CASE_SENSITIVE"}}),Smart.Utilities.Assign("DateFilterHandler",class extends Smart.Utilities.BaseFilterHandler{cacheFilter(e,t,l){const a=this;a.cachedFilter={firstFilterComparison:e,firstFilterValue:a.firstInput.getValue(),logicalOperator:t,secondFilterComparison:l,secondFilterValue:a.secondInput.getValue()}}appendInputs(){let e=this,t=e.context,l=document.createElement("smart-date-input"),a=document.createElement("smart-date-input");t.formatString&&!(t.formatString.indexOf("d")>=0||t.formatString.indexOf("M")>=0||t.formatString.indexOf("y")>=0)&&(l=document.createElement("smart-time-input"),a=document.createElement("smart-time-input")),l.calendarButton=!0,l.editMode="partial",l.formatString=t.formatString,l.dropDownDisplayMode="auto",l.locale=t.locale,l.autoClose=!0,l.messages[t.locale]||(l.messages[t.locale]={}),l.messages[t.locale].dateTabLabel=t.localize("dateTabLabel"),l.messages[t.locale].timeTabLabel=t.localize("timeTabLabel"),l.nullable=!0,l.value=null,a.autoClose=!0,a.calendarButton=!0,a.formatString=t.formatString,a.dropDownDisplayMode="auto",a.locale=t.locale,a.messages[t.locale]||(a.messages[t.locale]={}),a.messages[t.locale].dateTabLabel=t.localize("dateTabLabel"),a.messages[t.locale].timeTabLabel=t.localize("timeTabLabel"),a.nullable=!0,a.value=null,e.firstInput=l,e.secondInput=a}getFilterInputValue(e){if(null===e.value)return"";const t=e.getDate();return"calendar"===this.displayMode&&t&&t.setHours(0,0,0),t}defaultClear(){const e=this;e.firstList.selectedIndexes=[e.defaultListSelection],e.firstInput.value=null,e.logicalOperatorList.selectedIndexes=[0],e.secondList.selectedIndexes=[e.defaultListSelection],e.secondInput.value=null,e.filterObject.clear(),e.cacheFilter(e.defaultListSelection,0,e.defaultListSelection)}getHierarchicalDataSource(e){const t=this,l=t.dataSource,a={},i=[];let s;if("timePicker"!==e){""===l[l.length-1].value&&(s=l[l.length-1],l.pop()),l.forEach((function(e){const l=e.value,i=l.getFullYear(),s=new Intl.DateTimeFormat(t.context.locale,{month:"long"}).format(l);a[i]||(a[i]={}),a[i][s]||(a[i][s]=e.value)}));for(let e in a){const t={expanded:!0,label:e,items:[],customAttribute:"default-item"};i.push(t);for(let l in a[e]){const i={value:a[e][l],expanded:!0,label:l,items:[],customAttribute:"default-item"};t.items.push(i)}}s&&i.push(s),t.dataSource=i}}}),Smart.Utilities.Assign("BooleanFilterHandler",class extends Smart.Utilities.BaseFilterHandler{cacheFilter(e,t,l){const a=this;a.cachedFilter={firstFilterComparison:e,firstFilterValue:a.firstInput.selectedIndexes.slice(0),logicalOperator:t,secondFilterComparison:l,secondFilterValue:a.secondInput.selectedIndexes.slice(0)}}setDefaults(){const e=this,t=e.context;e.defaultListSource=[{prefix:'<span class="smart-icon smart-icon-equal"></span>',value:"EQUAL",label:t.localize("equal")},{prefix:'<span class="smart-icon smart-icon-not-equal"></span>',value:"NOT_EQUAL",label:t.localize("notEqual")},{prefix:'<span class="smart-icon smart-icon-null"></span>',value:"NULL",label:t.localize("null")},{prefix:'<span class="smart-icon smart-icon-not-null"></span>',value:"NOT_NULL",label:t.localize("notNull")}],e.filterBuilderOperations=["=","<>","NULL","NOT_NULL"],e.defaultListSelection=0}appendInputs(){const e=this,t=document.createElement("smart-input"),l=document.createElement("smart-input");t.dataSource=[{value:!0,label:"true"},{value:!1,label:"false"}],t.placeholder=e.context.localize("placeholderBoolean"),t.selectedIndexes=[],t.selectionMode="zeroOrOne",t.readonly=!0,t.dropDownButtonPosition="right",l.dataSource=[{value:!0,label:"true"},{value:!1,label:"false"}],l.placeholder=e.context.localize("placeholderBoolean"),l.selectedIndexes=[],l.selectionMode="zeroOrOne",l.readonly=!0,l.dropDownButtonPosition="right",e.firstInput=t,e.secondInput=l}getFilterInputValue(e){return 0===e.selectedValues.length?"":!0===e.selectedValues[0]}defaultClear(){const e=this;e.firstList.selectedIndexes=[e.defaultListSelection],e.firstInput.selectedIndexes=[],e.logicalOperatorList.selectedIndexes=[0],e.secondList.selectedIndexes=[e.defaultListSelection],e.secondInput.selectedIndexes=[],e.filterObject.clear(),e.cacheFilter(e.defaultListSelection,0,e.defaultListSelection)}defaultCancel(){const e=this;e.firstList.selectedIndexes=[e.cachedFilter.firstFilterComparison],e.firstInput.selectedIndexes=e.cachedFilter.firstFilterValue,e.logicalOperatorList.selectedIndexes=[e.cachedFilter.logicalOperator],e.secondList.selectedIndexes=[e.cachedFilter.secondFilterComparison],e.secondInput.selectedIndexes=e.cachedFilter.secondFilterValue}});
83
- Smart("smart-gantt-chart",class extends Smart.ScrollViewer{static get properties(){return{adjustToNonworkingTime:{value:!1,type:"boolean"},autoSchedule:{value:!1,type:"boolean"},autoScheduleStrictMode:{value:!1,type:"boolean"},autoScrollStep:{value:5,type:"number"},columnMenu:{value:!1,type:"boolean"},columnMinWidth:{value:"50px",type:"any"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},currentTime:{value:new Date,type:"any",validator:"_dateValidator"},currentTimeIndicator:{value:!1,type:"boolean"},currentTimeIndicatorInterval:{value:1,validator:"_currentTimeIndicatorIntervalValidator",type:"number"},dataExport:{value:{exportFiltered:{value:!1,type:"boolean"},itemType:{value:"task",type:"string"},fileName:{value:"smartGanttChart",type:"string?"}},type:"object"},dataSource:{value:[],type:"any",reflectToAttribute:!1},dateEnd:{value:"",type:"any",validator:"_dateValidator"},dateStart:{value:"",type:"any",validator:"_dateValidator"},dateMarkers:{value:[],reflectToAttribute:!1,type:"array"},dayFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},dayScale:{value:"hour",allowedValues:["hour","halfHour","quarterHour"],type:"string"},disableAutoScroll:{value:!1,type:"boolean"},disableTaskDrag:{value:!1,type:"boolean"},disableTaskProgressChange:{value:!1,type:"boolean"},disableTaskResize:{value:!1,type:"boolean"},disableSelection:{value:!1,type:"boolean"},disableSegmentDrag:{value:!1,type:"boolean"},disableSegmentResize:{value:!1,type:"boolean"},disableWindowEditor:{value:!1,type:"boolean"},durationUnit:{value:"milisecond",allowedValues:["day","week","hour","minute","second","milisecond"],type:"string"},filterRow:{value:!1,type:"boolean"},firstDayOfWeek:{value:-1,type:"number"},groupByResources:{value:!1,type:"boolean"},headerTemplate:{value:null,type:"any"},hourFormat:{value:"default",allowedValues:["default","2-digit","numeric"],type:"string"},hideDateMarkers:{value:!1,type:"boolean"},hideTimelineHeaderDetails:{value:!1,type:"boolean"},hideTimelineSecondHeaderDetails:{value:!0,type:"boolean"},hideTimelineHeader:{value:!1,type:"boolean"},hideResourcePanel:{value:!1,type:"boolean"},showSelectionColumn:{value:!1,type:"boolean"},infiniteTimeline:{value:!1,type:"boolean"},infiniteTimelineStep:{value:5,type:"number"},inverted:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},messages:{extend:!0,value:{en:{duplicateIds:"{{elementType}}: DataSource contains duplicate ids. Tasks should have unique ids. The following ids are duplicating: {{duplicates}}.",invalidNonworkingRange:"{{elementType}}: Invalid {{property}} value. {{property}} should not contain all possible days/hours because it will result in an endless timeline. The value has been validated by removing the last item from the new value range.",invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",outOfBounds:"{{elementType}}: Out of bounds argument {{argumentName}} in method {{methodName}}.",missingReference:"{{elementType}}: Missing reference to {{file}} in method {{methodName}}.",alreadyExists:"{{elementType}}: The item already exists when calling the {{methodName}} method.",notExisting:"{{elementType}}: The item does not exists when calling the {{methodName}} method.",notAProject:"{{elementType}}: The {{argumentName}} argument in {{methodName}} method does not reference an item of type 'project'.",noId:"smartGanttChart requires an id in order to save/load/clear a state.",ok:"Ok",add:"Add",remove:"Remove",cancel:"Cancel",delete:"Delete",confirm:"{{componentName}} will be deleted permanently, <b>are you sure? </b>",taskColumnLabel:"Task Name",resourceColumnLabel:"Resource Name",deleteLink:"Delete link",unassigned:"Unassigned",generalTab:"General",dependencyTab:"Dependency",segmentsTab:"Segments",segment:"Segment",dependencyValidation:"*The Task cannot be connected to itself.",segmentsCountValidation:"*Segmented Tasks must have at least 2 segments. ",segmentConflictError:'*The Segment "{{label}}" is in conflict, because it starts on/before and ends on/after the {{dateConflict}} of Segment "{{conflictLabel}}." ',segmentStartError:'*The Segment "{{label}}" cannot start before it ends and cannot end before it starts.',segmentEndError:'*The Segment "{{label}}" cannot start when it ends.',segmentRangeError:'*The Segment "{{label}}" is out of Task date range. The first segment must start when the task starts and the last segment must end when the task ends.',label:"Label",duration:"Duration",dateStart:"Date Start",dateEnd:"Date End",id:"Id",name:"Name",type:"Type",lag:"Lag",startToStart:"Start-To-Start",endToStart:"End-To-Start",endToEnd:"End-To-End",startToEnd:"Start-To-End",overdue:"Overdue",weeks:"week(s)",days:"day(s)",hours:"hour(s)",minutes:"minute(s)",seconds:"second(s)",miliseconds:"milisecond(s)",task:"Task",resource:"Resource",assignments:"Assignments",startTask:"Task Start",endTask:"Task End",deadline:"Deadline",quarter:"Quarter",quarterShort:"Q"}},type:"object"},monthFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},monthScale:{value:"week",allowedValues:["day","week"],type:"string"},max:{value:new Date(2100,0,1),type:"any",validator:"_dateValidator"},min:{value:new Date(1900,0,1),type:"any",validator:"_dateValidator"},nonworkingDays:{value:[],type:"array",validator:"_nonworkingDayValidator"},nonworkingHours:{value:[],type:"array",validator:"_nonworkingTimeValidator"},onTaskRender:{value:null,reflectToAttribute:!1,type:"function?"},popupWindowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"},popupWindowTabs:{value:["general","dependency","segments"],reflectToAttribute:!1,type:"array"},progressLabelFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resizeHandlesVisibility:{allowedValues:["auto","hidden","visible"],value:"auto",type:"string"},quarterFormat:{value:"short",allowedValues:["long","short","numeric"],type:"string"},resourceColumns:{value:[{label:"resourceColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},resourceFiltering:{value:!1,type:"boolean"},resourceGroupFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourcePanelHeaderTemplate:{value:null,type:"any"},resourcePanelMin:{value:100,type:"any"},resourcePanelSize:{value:"",type:"any"},resourcePanelRefreshRate:{value:0,reflectToAttribute:!1,type:"number"},resourceTimelineFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourceTimelineMode:{allowedValues:["diagram","histogram","custom"],value:"diagram",type:"string"},resourceTimelineView:{allowedValues:["hours","tasks","custom"],value:"hours",type:"string"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},selectedTaskIds:{value:[],type:"array"},selectedResourceIds:{value:[],type:"array"},shadeUntilCurrentTime:{value:!1,type:"boolean"},showBaseline:{value:!1,type:"boolean"},showProgressLabel:{value:!1,type:"boolean"},snapToNearest:{value:!1,type:"boolean"},sortFunction:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",allowedValues:["none","one","many"],type:"string"},taskColumns:{value:[{label:"taskColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},taskFiltering:{value:!1,type:"boolean"},taskPanelMin:{value:200,type:"any"},taskPanelSize:{value:"",type:"any"},timelineHeaderFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},timelineMin:{value:200,type:"any"},treeMin:{value:100,type:"any"},treeSize:{value:"20%",type:"any"},tooltip:{value:{enabled:{value:!1,type:"boolean"},arrow:{value:!1,type:"boolean"},delay:{value:50,type:"number"},offset:{value:[0,5],type:"array"}},type:"object"},verticalScrollBarVisibility:{type:"string",value:"auto",allowedValues:["auto","disabled","hidden","visible"]},view:{value:"year",allowedValues:["day","week","month","quarter","year"],type:"any"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"},weekFormat:{value:"long",allowedValues:["long","numeric"],type:"string"}}}template(){return'<div id="container" role="presentation">\n <smart-splitter id="mainSplitter" auto-fit-mode="end" keep-proportions-on-resize right-to-left="[[rightToLeft]]" animation="[[animation]]" orientation="horizontal">\n <smart-splitter-item id="taskSplitterItem" class="smart-task-splitter-item">\n <div id="taskSplitterItemHeader" class="smart-task-panel-header"></div>\n <smart-splitter id="taskSplitter" class="smart-task-splitter" auto-fit-mode="end">\n <smart-splitter-item id="tableSplitterItem">\n <smart-table right-to-left="[[rightToLeft]]" wait id="taskTable" class="smart-task-table" virtualization animation="none" deferred-scroll-delay="0" ></smart-table>\n </smart-splitter-item>\n <smart-splitter-item id="timelineSplitterItem" class="smart-timeline-splitter-item">\n <div id="timeline" class="smart-timeline">\n <div id="timelineHeader" class="smart-timeline-header" role="rowgroup">\n <div id="timelineHeaderContent" class="smart-timeline-header-content">\n <div class="smart-timeline-view-details" id="timelineViewDetails" role="row"></div>\n <div class="smart-timeline-view-details smart-hidden" id="timelineViewSubDetails" role="row"></div>\n <div class="smart-timeline-view-cells" id="timelineViewCells" role="row"></div>\n </div>\n </div>\n <div id="taskTimelineContainer" class="smart-timeline-content-container">\n <div id="timelineContent" class="smart-timeline-content">\n <div id="taskTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n <div id="taskIndicatorsContainer" class="smart-timeline-indicators-container" role="group"></div>\n <div id="timelineConnectionsContainer" class="smart-timeline-connections-container" role="group"></div>\n <div id="timelineBaselinesContainer" class="smart-timeline-baselines-container" role="group"></div>\n <div id="timelineTasksContainer" class="smart-timeline-tasks-container" role="group"></div>\n <div id="timelineMarkers" class="smart-timeline-markers-container" role="group"></div>\n <div id="timelineDeadlines" class="smart-timeline-deadlines-container" role="group"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar id="verticalScrollBar" class="smart-timeline-scroll-bar" orientation="vertical"\n right-to-left="[[rightToLeft]]" aria-controls="[[id]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>\n </smart-splitter-item>\n </smart-splitter>\n <smart-scroll-bar wait id="horizontalScrollBar" class="smart-timeline-scroll-bar"></smart-scroll-bar>\n </div>'}static get listeners(){return{down:"_downHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","container.wheel":"_mouseWheelHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","verticalScrollBar.change":"_verticalScrollbarHandler","resourceVerticalScrollBar.change":"_verticalScrollbarHandler","mainSplitter.resizeEnd":"_resizeEventHandler","mainSplitter.resize":"_resizeEventHandler",move:"_moveHandler","mainSplitter.change":"_tableChangeHandler","mainSplitter.filter":"_tableSortFilterHandler","mainSplitter.sort":"_tableSortFilterHandler","mainSplitter.columnResize":"_tableColumnResizeHandler","taskTable.group":"_taskTableGroupEventHandler","taskTable.collapse":"_taskTableExpandHandler","taskTable.expand":"_taskTableExpandHandler","taskTable.keydown":"_taskTableKeyDownHandler"}}static get styleUrls(){return["smart.ganttchart.css"]}attached(){const e=this;if(super.attached(),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar)),!e._resourceScrollView&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),e.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);e.$.timelineHeader.scrollLeft=e.$.taskTimelineContainer.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineHeader.scrollLeft=e.$.resourceTimelineContent.scrollLeft=t)}if(e.scrollTop){const t=e.scrollTop;e.$.taskTimelineContainer.scrollTop=t,e.$.timelineContent.scrollTop=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollTop=t)}const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];for(let i=0;i<t.length;i++){const a=t[i];if(e.$[a]&&e.$[a].opened){const t=e["$"+a];e._handleModal(!0),t.listen("close",e._popupWindowCloseHandler.bind(e)),t.listen("closing",e._popupWindowClosingHandler.bind(e)),t.listen("open",e._popupWindowOpenHandler.bind(e)),t.listen("click",e._popupWindowClickHandler.bind(e)),t.listen("change",e._popupWindowChangeHandler.bind(e)),t.listen("transitionend",e._popupWindowTransitionendHandler.bind(e)),e.getShadowRootOrBody().appendChild(e.$[a])}}e._handleTooltipEvents(!0),e._currentTimeIndicatorInterval||!e.currentTimeIndicator&&!e.shadeUntilCurrentTime||e._setCurrentTimeIndicators()}detached(){const e=this;super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView);const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];e._handleModal();for(let i=0;i<t.length;i++){const a=t[i],n=e["$"+a];e.$[a]&&e.$[a].remove(),n&&(n.unlisten("open"),n.unlisten("close"),n.unlisten("closing"),n.unlisten("click"),n.unlisten("change"),n.unlisten("transitionend"))}e._handleTooltipEvents(),clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval}propertyChangedHandler(e,t,i){const a=this;switch(e){case"adjustToNonworkingTime":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline();break;case"animation":break;case"autoSchedule":i?a._autoSchedule():a._autoScheduleRestore();break;case"autoScheduleStrictMode":i&&(a._autoSchedule(),a._refreshTimeline());break;case"columnMinWidth":case"columnResizeFeedback":case"columnResize":{const t=a.$.taskTable,n=a.$.resourceTable;t[e]=i,n&&(n[e]=i);break}case"currentTimeIndicator":case"shadeUntilCurrentTime":a._setCurrentTimeIndicators();break;case"dataSource":if(a.scrollLeft=a.scrollTop=0,a._createTasks(),a._refreshTableDataSource(),a._createTimeline(),a._createResourceTimeline(),a._setAriaControls(),a.snapToNearest){for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline()}break;case"dateMarkers":a._createDateMarkers();break;case"hideDateMarkers":a._recycleDateMarkers();break;case"selectionMode":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selectionMode=a.selectionMode),t&&(t.selectionMode=a.selectionMode);break}case"disableSelection":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selection=!a.disableSelection),t&&(t.selection=!a.disableSelection);break}case"durationUnit":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDuration(t),a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i)}a._createTimelineCells(),a._insertTimelineTasks(),a.taskColumns.some((e=>(e.value+"").toLowerCase().indexOf("duration")>-1))&&a._refreshTableDataSource();break;case"filterRow":a.$.taskTable[e]=i;break;case"groupByResources":a._setTable(a.$.taskTable),a._createTimelineContent(),a._recycleTimelineTasks(),a._refresh();break;case"infiniteTimeline":i?a._scrollView.hScrollBar.value===a._scrollView.hScrollBar.max&&a._handleInfiniteTimeline():a.set("dateEnd","");break;case"keyboardNavigation":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"popupWindowTabs":case"popupWindowCustomizationFunction":{const e=a.$.taskPopupWindow;e&&(e.opened&&(e.close(),delete e._target),e.clear());break}case"taskFiltering":a.$.taskTable.filtering=i,a._refresh();break;case"resourceFiltering":{const e=a.$.resourceTable;e&&(e.filtering=i,a._refresh());break}case"tooltip_enabled":{const e=a.$.tooltip;e&&(i||e.remove(),a._handleTooltipEvents(i));break}case"tooltip_arrow":case"tooltip_delay":case"tooltip_offset":{const t=a.$.tooltip;t&&(t[e.replace("tooltip_","")]=i);break}case"headerTemplate":a._handleHeaderTemplate();break;case"inverted":if(a._handleInverted(),a.scrollLeft){const e=a._getScrollLeft(a.scrollLeft);a.$.timelineHeader.scrollLeft=a.$.taskTimelineContainer.scrollLeft=e,a.$.mainSplitter.contains(a.$.resourceTimelineHeader)&&(a.$.resourceTimelineHeader.scrollLeft=a.$.resourceTimelineContent.scrollLeft=e)}break;case"rightToLeft":Array.from(a.querySelectorAll("smart-splitter, smart-table, smart-scroll-bar")).forEach((t=>t[e]=i)),a.closeWindow(),a._handleInverted(),a._refreshTimeline();break;case"firstDayOfWeek":case"dateStart":case"dateEnd":a._refreshTimeline();break;case"messages":case"locale":case"dayFormat":case"hourFormat":case"timelineHeaderFormatFunction":case"monthFormat":case"yearFormat":a._refreshHeaderDate(!0),a._refreshColumnsHeaders(),a._recycleResourceHeaderCells();break;case"hideResourcePanel":a._createResourceTimeline(),a._refreshTimeline();break;case"nonworkingDays":case"nonworkingHours":a._refreshAfterWorkingTimeChange();break;case"selectedTaskIds":a.$.taskTable.selected=a._getSelection("task",i);break;case"selectedResourceIds":a.$.resourceTable&&(a.$.resourceTable.selected=a._getSelection("resource",i));break;case"resourceColumns":a._setTable(a.$.resourceTable),a._highlightAssignedItem("task",a._getSelection("task",a.selectedTaskIds));break;case"resourcePanelHeaderTemplate":a._handleHeaderTemplate("resource");break;case"resourceTimelineView":case"resourceTimelineMode":case"resourceTimelineFormatFunction":a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._resources.forEach((e=>a._refreshResourceTimelineContent(e)));break;case"showProgressLabel":case"progressLabelFormatFunction":a._tasks.forEach((e=>a._setTaskBarProgress(e)));break;case"sortFunction":a.$.taskTable.sort=i,a.$.resourceTable&&(a.$.resourceTable.sort=i);break;case"showSelectionColumn":a.$.taskTable.hideSelectionColumn=!i,a.$.resourceTable&&(a.$.resourceTable.hideSelectionColumn=!i);break;case"columnMenu":case"hideSelectionColumn":case"sortMode":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"taskColumns":a._setTable(a.$.taskTable);break;case"timelineMin":a.$.timelineSplitterItem.min=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break;case"treeMin":case"treeSize":{const t=e.toLowerCase().indexOf("size")>-1?"size":"min";a.$.tableSplitterItem[t]=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break}case"taskPanelMin":case"taskPanelSize":case"resourcePanelSize":case"resourcePanelMin":{const t=e.indexOf("Min")>-1?"min":"size",n=e.indexOf("resource")>-1?"resource":"task";a.$.mainSplitter.contains(a.$.resourceSplitter)&&(a.$[`${n}SplitterItem`][t]=i,a.$.taskSplitterItem._setSize("size",a.taskPanelSize),a.refresh());break}case"unfocusable":a._setFocusable();break;case"monthScale":case"dayScale":case"view":a._refreshTimeline(t);break;default:super.propertyChangedHandler(e,t,i)}}_predefPropertyGetter(e){const t=this;Object.defineProperty(t,e,{get:function(){switch(e){case"dataSource":{if(t.context===t)return t.properties[e].value;const i=function(e){if(!e.length)return e;for(let a=0;a<e.length;a++){const n=e[a];let s=t._getProjectTasks(n);s&&Array.isArray(s)&&(s=i(s.filter((e=>e.$&&e.$.project===n)))),e[a]=t._cloneObject(n),s&&s.length?e[a].tasks=s:delete e[a].tasks}return e},a=t.properties[e].value;return a instanceof Smart.DataAdapter?a:i(a.slice(0))}case"dateStart":case"dateEnd":{const i=t._timelineCells;if(i.length){const a=t._getCellDateRange({_date:i["dateStart"===e?0:i.length-1].date});return new Date(a[e])}return t.properties[e].value}default:return t.properties[e].value}},set(i){t.updateProperty(t,t._properties[e],i)}})}ready(){this._customScrollView=!0,super.ready()}render(){const e=this,t=window.getComputedStyle(e),i=Smart.Utilities.Core;e._isMobile=i.isMobile,e._isFirefox=i.Firefox,e._taskBarMinWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-min-width"))||0,e._taskDefaultHeight=parseFloat(t.getPropertyValue("--smart-gantt-chart-task-default-height"))||30,e._timelineCellSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-size"))||0,e._timelineCellMinSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-min-size"))||0,e._taskConnectionWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-connection-width"))||1,e._baselineProportion=parseFloat(t.getPropertyValue("--smart-gantt-chart-baseline-proportion"))||0,e._predefPropertyGetter("dataSource"),e._predefPropertyGetter("dateStart"),e._predefPropertyGetter("dateEnd"),e.$.tableSplitterItem.size=e.treeSize,e.$.tableSplitterItem.min=e.treeMin,e.$.timelineSplitterItem.min=e.timelineMin,e._setScrollBars(),e._handleHeaderTemplate(),e._handleInverted(!0),e._createTasks(),e._setTable(),e._createTimeline(),e._createResourceTimeline(),e._setAriaControls(),e._setFocusable(),e.checkLicense(),(e.shadowRoot||e._isFirefox)&&requestAnimationFrame((()=>e.refresh())),super.render()}refresh(e){const t=this;if(e)return t._refreshTimeline(),t._setTable(t.$.taskTable),void t._createResourceTimeline();t.isRendered&&t._resizeEventHandler()}addFilter(e,t){const i=this;if(!i.taskFiltering&&!i.resourceFiltering||!(t instanceof Smart.Utilities.FilterGroup))return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const a=i.taskColumns,n=i.resourceColumns,s=i.$.taskTable,r=i.$.resourceTable;for(let i=0;i<e.length;i++){const o=e[i],l=o.type,[d,c]="resource"===l||n.includes(o)?[r,n]:[s,a],m=c.find((e=>o.value&&e.value===o.value));m&&d.addFilter(m.value,t)}}clearSelection(){this._unselectAll("task"),this._unselectAll("resource")}static get requires(){return{"Smart.Splitter":"smart.splitter.js","Smart.Tree":"smart.tree.js","Smart.Window":"smart.window.js"}}ensureVisible(e,t="task"){const i=this,a=i._getValidItemAndIndex(e,t);(e=a?a.item:void 0)&&(i._ensureVisible(e,t),i._scrollTo(e.dateStart,!0))}removeAllConnections(){const e=this;e.isCompleted&&(e.$.timelineConnectionsContainer.innerHTML="",e._connections=[],e._tasks.map((e=>e.connections=[])))}removeConnection(){const e=this,t=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted)return;let i;if(1===t.length){if("string"==typeof t[0]){const e=document.getElementById(t[0]);e&&(i=e.getAttribute("connection-id"))}i||(i=(t[0]+"").split("-"),i=e._getValidConnectionId(i[0],i[1],i[2],"removeConnection"))}else 3===t.length&&(i=e._getValidConnectionId(t[0],t[1],t[2],"removeConnection"));i&&(e._removeConnection(i),e.$.fireEvent("itemRemove",{type:"connection",id:`${i[0]}-${i[1]}-${i[2]}`,item:{source:i[0],target:i[1],type:i[2]}}))}removeTaskConnection(e,t){const i=this;if(!i.isCompleted)return;if((e+="").indexOf("-")>-1&&!t){const i=e.split("-");t=i[1],e=i[0]}const a=i._getValidItemAndIndex(e),n=i._getValidItemAndIndex(t);e=a?a.index:void 0,t=n?n.index:void 0,isNaN(e)?i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"removeTaskConnection",argumentName:"taskEndIndex"})):i._removeConnection(""+e+(isNaN(t)?"":t))}beginUpdate(){this._isUpdating={started:!0,type:{}},this.$.fireEvent("beginUpdate")}endUpdate(){const e=this;function t(){e._refreshTableDataSource(),e._createTimelineContent(),e._recycleTimelineTasks(),e._setAriaControls();const t=e._resources;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i],void 0,"resource")}function i(){if(e.hideResourcePanel)return;e._refreshTableDataSource("resource"),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._refresh();const t=e._tasks;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i])}if(!e._isUpdating)return;const a=1===Object.keys(e._isUpdating.type).length?Object.keys(e._isUpdating.type)[0]:void 0;let n,s;switch(e._selected&&({task:n,resource:s}=e._selected),delete e._isUpdating,a){case"task":t();break;case"resource":i();break;default:t(),i()}n&&(e._refreshSelectedItems("task",n),e.$.taskTable.selected=e._getSelection("task",e.selectedTaskIds)),s&&(e._refreshSelectedItems("resource",s),e.$.resourceTable.selected=e._getSelection("resource",e.selectedResourceIds)),e.$.fireEvent("endUpdate")}clearFilters(e){this._resetFromAction(e,"clearFilters")}clearSort(e){const t=this;"task"!==e&&"resource"!==e?(t._resetFromAction("task","clearSort"),t._resetFromAction("resource","clearSort")):t._resetFromAction(e,"clearSort")}clearTasks(){this._clearTasks()}_clearTasks(){const e=this;e._selected&&delete e._selected.task,e.set("selectedTaskIds",[]),e._tasks=[],e._timelineCells=[],e._timelineVCells=[],e._timelineHeaderCells=[],e.$.timelineContent.style.width="",e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e.$.timelineViewDetails.innerHTML="",e.$.timelineViewCells.innerHTML="",e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.taskIndicatorsContainer.innerHTML="",e.$.timelineContent.style.height="",delete e._hoveredItem,e.$.taskTable.dataSource=[],e._closeTooltip(),e.closeWindow(),e._refresh()}clearResources(){const e=this;e._unselectAll("resource"),e._resources=[],e.$.resourceTable&&(e.$.resourceTable.dataSource=[]),e.$.resourceTimelineCellsContainer.innerHTML="",e._tasks.forEach((t=>{t.resources=[],e._refreshTableColumnsData(t,["resources"])})),e._refreshTimeline(),e._createResourceTimeline()}createConnection(){const e=this,t=e._tasks;let i,a=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted||0===t.length)return;if(i=1===a.length?(a[0]+"").split("-"):a,!e._getValidConnectionId(i[0],i[1],i[2],"createConnection"))return;const n=parseInt(i[3]);e._connectTask([i[0],i[1],i[2],isNaN(n)?0:n]),e._recycleConnections(),e.$.fireEvent("itemInsert",{type:"connection",item:{source:i[0],target:i[1],type:i[2],lag:n}})}collapse(e){this._handleCollapseExpandMethods(e,"collapse")}expand(e){this._handleCollapseExpandMethods(e,"expand")}exportData(e,t){const i=this;if(!Smart.Utilities.DataExporter)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"smart.export.js"}));try{new JSZip}catch(e){return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"jszip.min.js"}))}if("pdf"===e&!window.pdfMake)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"pdfMake.min.js"}));const a="task"===i.dataExport.itemType?i.$.taskTable:i.$.resourceTable;return a?a.exportData(e,i.dataExport.fileName,i.dataExport.exportFiltered,t):void 0}print(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const i=e.exportData("html"),a=window.open("","","width=800,height=500"),n=a.document.open(),s='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+i+"</body></html>";try{n.write(s),n.close(),setTimeout((function(){a.print(),a.close()}),100)}catch(e){}e.dataExport.fileName=t}getConnectionDetails(e){const t=this;if("string"!=typeof e)return;const i=t._getConnectionObjById(e);if(!i)return;const a=i.startTask,n=i.endTask,s={startTask:t._cloneObject(i.startTask),endTask:t._cloneObject(i.endTask),startTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,type:i.type};return void 0!==i.lag&&(s.lag=i.lag),s}getConnections(){const e=this;return e._connections.map((t=>{const i=t.startTask,a=t.endTask;return{id:t.startIndex+"-"+t.endIndex+"-"+t.type,startTask:e._cloneObject(i),endTask:e._cloneObject(a),startIndex:t.startIndex,startTaskId:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,endIndex:t.endIndex,type:t.type,lag:t.lag}}))}getState(){const e=this,t=e._getTasksJSON(!0)||[];return{tasks:JSON.parse(JSON.stringify(t)),selectedTaskIds:e.selectedTaskIds.slice(0),resources:JSON.parse(JSON.stringify(e._resources.slice(0))),scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}get tasks(){return this.isReady?this.getTasks():[]}get resources(){return this.isReady?this.getResources():[]}getTask(e){const t=this,i=t._getValidItemAndIndex(e);if(i.item)return t._cloneObject(i.item)}getTasks(){const e=this,t=e._tasks;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getResource(e){const t=this,i=t._getValidItemAndIndex(e,"resource");if(i.item)return t._cloneObject(i.item)}getResources(){const e=this,t=e._resources;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getItemPath(e){if(!e||void 0===e.type)return;const t="string"==typeof e.type?"task":"resource",i=this._getValidItemAndIndex(e,t);return i.item?i.item.$.id:void 0}getTaskIndex(e){const t=this;return"string"==typeof e?t._getTaskIndexById(e):t._getItemIndex(e,"task")}getTaskProject(e){const t=this;if((e=t._tasks[t._getItemIndex(e,"task")])&&e.$&&e.$.project)return t._cloneObject(e.$.project)}getTaskConnections(e){const t=this._getValidItemAndIndex(e,"task");return t&&t.item?this._getTaskConnections(t.item).taskConnections.map((e=>({target:e.endIndex,type:e.type,lag:e.lag}))):[]}getResourceIndex(e){return this._getItemIndex(e,"resource")}getResourceTasks(e){const t=this._getValidItemAndIndex(e,"resource");if(e=t?t.item:void 0)return this._getTasksAssigned(e)}getSelectedIds(){const e=this,t=e.selectedTaskIds,i=e.selectedResourceIds;return e.disableSelection||!t.length&&!i.length?null:{task:t.slice(),resources:i.slice()}}getSelectedTasks(){return this._getSelectedItems("task")}getSelectedResources(){return this._getSelectedItems("resource")}getWorkingHours(){const e=this.nonworkingHours;let t=[];for(let i=0,a=23;i<a;i+=1)e.indexOf(i)<0&&t.push(i);return t}isWorkingDay(e){return e=new Date(e),!isNaN(e.getTime())&&this.nonworkingDays.indexOf(e.getDay())<0}clearState(){const e=this;e.id?window.localStorage.removeItem("smartGanttChart"+e.id):e.warn(e.localize("noId"))}loadState(e){const t=this;if(!e){if(!t.id)return;e=JSON.parse(window.localStorage.getItem("smartGanttChart"+t.id))}if(!e)return;let i=JSON.stringify(e.tasks),a=JSON.stringify(e.selectedTaskIds),n=JSON.stringify(e.resources);if(i&&(i=JSON.parse(i)),a&&(a=JSON.parse(a)),n&&(n=JSON.parse(n)),t._noChangeEvent=!0,Array.isArray(i)&&(t._createTasks(i),t.set("dataSource",i)),Array.isArray(n)){let e=n;for(let i=0;i<e.length;i++){const e=n[i];let a=t._resources.find((t=>t.id&&t.id.toString()===e.id.toString()))||{};t._setResource(a,e),Object.values(a).length&&!t._resources.includes(a)&&t._resources.push(a)}t._refreshItemIds("resource")}"number"==typeof e.scrollLeft&&(t.scrollLeft=e.scrollLeft),"number"==typeof e.scrollTop&&(t.scrollTop=e.scrollTop),t._setTable(t.$.taskTable),t._createTimeline(),t._createResourceTimeline(),Array.isArray(a)&&(t.$.taskTable.selected=t._getSelection("task",a)),delete t._noChangeEvent}saveState(){const e=this;e.id?window.localStorage.setItem("smartGanttChart"+e.id,JSON.stringify(e.getState())):e.warn(e.localize("noId"))}insertTask(e,t,i){const a=this;if("object"!=typeof e)return void a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask",argumentName:"newTask"}));const n=a._tasks;if(n.indexOf(e)>-1)return void a.error(a.localize("alreadyExists",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask"}));const s=a._createTasks([e],!0);if(!n)return;let r,o,l;const d=a._getSelection("task",a.selectedTaskIds);if("string"==typeof i&&i.indexOf(!1)){const e=i.split(".");i=parseInt(e.slice(-1)),null==t&&(t=e.slice(0,-1).join("."))}if("string"==typeof t?(r=n.find((e=>e.id&&e.id.toString()===t)),r||(r=a._getItemByTableId("task",t))):"number"==typeof t&&(r=n[t]),r){if("project"!==r.type)return void a.error(a.localize("notAProject",{elementType:a.nodeName.toLowerCase(),argumentName:"project",methodName:"insertTask"}));s[0].$.project=r}return a._synchronizeProjectVisibility(s[0].$.project,s[0]),a._insertTasks(s,r,i),a._refreshItemIds(),a._refreshConnectionIds(),a._isUpdating?(a._isUpdating.type.task=!0,void(a._isUpdating.type.resource=!0)):(a._selected&&a._selected.task&&a._setSelection("task",l=a._selected.task.map((e=>e.$.id))),a._refreshTableDataSource(),a._refreshTimeline(),l&&d.toString()!==l.toString()&&(a.$.taskTable.selected=l.slice(0)),a._refreshTaskResources(o),a._ensureVisible(o),a.$.fireEvent("itemInsert",{type:"task",item:a._cloneObject(s[0])}),s[0].id||s[0].$.id+"")}openWindow(e){const t=this;if(t.disableWindowEditor)return;if("string"==typeof e){if(e.indexOf(".")>-1){const i=t._getVCellById("task",e),a=i?i.task:void 0;return void(a&&t._openPopupWindow(a))}if(e.indexOf("-")>-1){let e=(arguments[0]+"").split("-");if(e=t._getValidConnectionId(e[0],e[1],e[2],"openEditor"),e)return void t._openPopupWindow(e)}}const i=t._getValidItemAndIndex(e);i&&t._openPopupWindow(i.item)}closeWindow(){const e=this,t=["confirm","task","connection"];for(let i=0;i<t.length;i++){const a=e.$[t[i]+"PopupWindow"];a&&(a.close(),delete a._target)}}updateTask(e,t){const i=this,a=i._getValidItemAndIndex(e),n=a?a.item:void 0;"object"==typeof n?"object"==typeof t?i._updateTask(n,t):i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"taskDetails"})):i.error(i.localize("notExisting",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"newTask"}))}removeTask(e){const t=this,i=t._tasks,a=t._getValidItemAndIndex(e),n=a?a.item:void 0;i&&i.length&&("object"==typeof n?t._removeTask(n):t.error(t.localize("notExisting",{elementType:t.nodeName.toLowerCase(),methodName:"removeTask",argumentName:"index"})))}setWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,a=e.length;i<a;i+=1){const a=parseInt(e[i]),n=t.indexOf(a);n>-1&&t.splice(n,1)}return t}))}selectTask(e){this._handleItemSelection(e,"task")}selectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource")}sort(e){const t=this;if("none"===t.sortMode)return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const i=t.taskColumns,a=t.resourceColumns,n=t.$.taskTable,s=t.$.resourceTable;for(let t=0;t<e.length;t++){const r=e[t],o="desc"===r.sortOrder?"desc":"asc",[l,d]="resource"===r.type||a.includes(r)?[s,a]:[n,i],c=d.find((e=>r.value&&e.value===r.value));c&&l.sortBy(c.value,o)}}unselectTask(e){this._handleItemSelection(e,"task",!0)}unselectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource",!0)}unsetWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,a=e.length;i<a;i+=1){const a=parseInt(e[i]);t.indexOf(a)<0&&t.push(a)}return t}),!0)}hideTooltip(){this._closeTooltip()}showTooltip(e,t){this._openTooltip(e,void 0,t)}_getSelectedItems(e="task"){const t=this,i=t[`_${e}s`],a=t._getSelection(e,"task"===e?t.selectedTaskIds:t.selectedResourceIds);if(!a.length)return[];let n=[];for(let e=0,s=i.length;e<s;e+=1){const s=i[e];a.indexOf(s.$.id)>-1&&n.push(t._cloneObject(s))}return n}_getTasksAssigned(e){const t=this,i=t._tasks||[];let a=[];for(let n=0;n<i.length;n++){const s=i[n];!s.disableResources&&s.resources.find((t=>t===e.id))&&a.push(t._cloneObject(s))}return a}_getItemIndex(e,t){t||(t="task");const i=this[`_${t}s`];if(e instanceof HTMLElement&&e.classList.contains("smart-timeline-task"))return i.indexOf(e._cellObj[`_${t}`]);const a="resource"===t?["id","label","value","progress"]:["id","label","type","class","dateStart","dateEnd","resources","connections"];if("object"==typeof e)for(let t=0;t<i.length;t++)if(a.every((a=>Array.isArray(e[a])?JSON.stringify(e[a])===JSON.stringify(i[t][a]):a.indexOf("date")>-1?new Date(e[a]).getTime()===new Date(i[t][a]).getTime():e[a]===i[t][a])))return i.indexOf(i[t]);return-1}_handleItemSelection(e,t="task",i){const a=this,n=a._getValidItemAndIndex(e,t);if(n.item){const s=n.item,r=a._getSelection(t,"task"===t?a.selectedTaskIds:a.selectedResourceIds);if(e=s.$.id,i){const i=r.indexOf(e);i>-1&&(r.splice(i,1),a.$[`${t}Table`].selected=r)}else r.indexOf(e)<0&&(r.push(e),a.$[`${t}Table`].selected=r);return"string"==typeof s.id||"number"==typeof s.id?s.id:s.$.id}}_refreshAfterWorkingTimeChange(){const e=this;if(e.adjustToNonworkingTime)for(let t=0;t<e._tasks.length;t++){const i=e._tasks[t],a=i.$.project;e._validateTaskDates(i,a),e._synchronizeProjectDates(i,a),e._refreshTableColumnsData(i,["dateEnd","duration"])}e._refreshTimeline()}_refreshItemIds(e="task"){const t=this[`_${e}s`];if(!t)return;let i={},a=0;for(let e=0,n=t.length;e<n;e+=1){const n=t[e],s=n.$.project;if(void 0!==s){const e=s.$.id;i[e]||(i[e]=0),n.$.id=e+"."+i[e],i[e]++}else n.$.id=a+"",a++}}_refreshConnectionIds(){const e=this._tasks,t=this._connections;if(t&&t.length)for(let i=0,a=t.length;i<a;i+=1){const n=t[i],s=e.indexOf(n.startTask),r=e.indexOf(n.endTask);(s<0||r<0)&&(t.splice(i,1),a--),n.startIndex=s,n.endIndex=r}}_refreshSelectedItems(e="task",t){const i=this,a=i[`_${e}s`];if(a&&(!t&&i._selected&&i._selected[e]&&(t=i._selected[e]),t)){for(let e=0,i=t.length;e<i;e+=1){const n=t[e];(a.indexOf(n)<0||n.hidden)&&(t.splice(e,1),e-=1,i--)}i._setSelection(e,t.map((e=>e.$.id)))}}_resetFromAction(e="task",t="clearSort"){const i=this;function a(){i.$.taskTable[t](),i._createTimelineContent(),i._recycleTimelineTasks()}function n(){const e=i.$.resourceTable;e&&(e[t](),i._createResourceTimelineVCells(),i._recycleResourceContent())}"resource"===e?n():"task"===e?a():(a(),n())}_setWorkTime(e,t,i){const a=this;if("object"!=typeof e)return;let n,s=e.days,r=e.hours;null!=s&&(Array.isArray(s)||(s=[s]),s=a._nonworkingDayValidator(void 0,s),n=t(s,i?a.nonworkingDays:[0,1,2,3,4,5,6]),a.set("nonworkingDays",7===n.length?[]:n),a._refreshAfterWorkingTimeChange()),null!=r&&(Array.isArray(r)||(r=[r]),r=a._nonworkingTimeValidator(void 0,r),n=t(r,i?a.nonworkingHours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),a.set("nonworkingHours",24===n.length?[]:n),a._refreshAfterWorkingTimeChange())}_getValidConnectionId(e,t,i,a){const n=this,s=n._tasks,r=0===a.indexOf("_");let o;if("string"==typeof e&&(o=n._getTaskIndexById(e),o>=0&&(e=o)),"string"==typeof t&&(o=n._getTaskIndexById(t),o>=0&&(t=o)),e=parseInt(e),t=parseInt(t),i=parseInt(i),isNaN(e)||isNaN(t)||e===t)r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else if(e>=s.length||e<0||t>=s.length||t<0)r||n.error(n.localize("outOfBounds",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else{if(!(isNaN(i)||i<0||i>3))return r?[e,t,i]:e+"-"+t+"-"+i;r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"connectionType"}))}}_autoSchedule(e){const t=this,i=t._tasks;if(t.autoSchedule){e?Array.isArray(e)||(e=[e]):e=i;for(let i=0;i<e.length;i++){const a=e[i];"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}t._isUpdateRequired&&(t._createTimelineCells(),t._recycleTimelineTasks(!0),delete t._isUpdateRequired)}}_getTaskConnections(e){const t=this._tasks,i=this._connections;let a=[],n=[];if(t&&t.length&&i&&i.length){const s=t.indexOf(e);for(let e=0;e<i.length;e+=1){const t=i[e];t.startIndex===s?a.push(t):t.endIndex===s&&n.push(t)}}return{taskConnections:a,connectedTasks:n}}_autoScheduleTasks(e){const t=this,i=t._tasks,a=t._getTaskConnections(e),n=a.taskConnections,s=a.connectedTasks;let r,o,l;for(let a=0;a<n.length;a++)t._isAutoScheduled(e,i[n[a].endIndex],!0);for(let a=0;a<s.length;a++){const n=s[a],d=i[n.startIndex],c=n.type,m=n.lag,u=e.$.project;d&&"project"===d.type&&d.synchronized||(0===c||1===c?(l=new Date((0===c?d.dateStart:d.dateEnd).getTime()+m),e.minDateStart=new Date(e.minDateStart?Math.max(e.minDateStart.getTime(),l.getTime()):l),o=e.minDateStart.getTime()-e.dateStart.getTime(),r=new Date(e.dateEnd.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateStart.getTime()!==e.dateStart.getTime()&&(e.dateStart=e.minDateStart,t._isUpdateRequired=!0)):(l=new Date((2===c?d.dateEnd:d.dateStart).getTime()+m),e.minDateEnd=new Date(e.minDateEnd?Math.min(e.minDateEnd.getTime(),l.getTime()):l),o=e.minDateEnd.getTime()-e.dateEnd.getTime(),r=new Date(e.dateStart.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateStart.getTime()&&(e.dateStart=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateEnd.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=e.minDateEnd,t._isUpdateRequired=!0)),t._validateTaskDates(e,u),t._synchronizeProjectDates(e,u))}for(let e=0;e<n.length;e++){const a=i[n[e].endIndex];!a||"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}}_autoScheduleRestore(e,t){const i=this._tasks;e||(e=i),Array.isArray(e)||(e=[e]);for(let a=0;a<e.length;a++){const n=e[a];i.indexOf(e[a])>-1&&(t?0===t||1===t?n.minDateStart=void 0:n.minDateEnd=void 0:n.minDateStart=n.minDateEnd=void 0)}}_autoScroll(e){const t=this,i=t.hasAttribute("dragged"),a=t.hasAttribute("resized");function n(n,s){if(!t._dragDetails)return clearInterval(t._scrollInterval),t._scrollInterval=void 0,void delete t._autoScrolling;t._autoScrolling=!0,s?i||(t.scrollTop-=t.autoScrollStep*n,t._dragDetails.coordinates.y+=t.autoScrollStep*n):(t.scrollLeft-=(t.rightToLeft?-1:1)*t.autoScrollStep*n,t._dragDetails.coordinates.x+=t.autoScrollStep*n),i?t._handleTaskBarDrag(e):a&&t._handleTaskBarResize(e)}if(t.disableAutoScroll||!e||!i&&!a&&!t.hasAttribute("connecting-task"))return;const s=t.$.timeline.getBoundingClientRect();t._scrollInterval&&clearInterval(t._scrollInterval),t._scrollInterval=setInterval((function(){(t.scrollLeft||t.rightToLeft)&&e.clientX<=s.left+20?n(1):t.scrollLeft!==(t.rightToLeft?0:t.scrollWidth)&&e.clientX>=s.left+s.width-20?n(-1):t.scrollTop&&e.clientY<=s.top+20?n(1,!0):t.scrollTop!==t.scrollHeight&&e.clientY>=s.top+s.height-20?n(-1,!0):(clearInterval(t._scrollInterval),t._scrollInterval=void 0,delete t._autoScrolling)}),1)}_checkTaskBarResizability(e){const t=this;let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const a=t.$.timeline;if(!i.closest)return void a.removeAttribute("task-bar-hovered");let n,s=i.closest(".smart-timeline-row")||i.closest(".smart-timeline-task");if(t.disabled||t.disableTaskResize||!s||!a.contains(s))return void a.removeAttribute("task-bar-hovered");const r=s._cellObj.task,o=t._getTaskDOMIndex(r);if(s.classList.contains("smart-timeline-row")?n=t.$.timelineTasksContainer.children[o]:s.classList.contains("smart-timeline-task")&&(n=s,s=t.$.taskTimelineCellsContainer.children[o]),!n||n.classList.contains("milestone")||r.synchronized||r.disableResize)return;const l=i.closest(".smart-task-segment"),d=r.segments?r.segments.length:1;if(i.classList&&i.classList.contains("smart-task-connection-point")||l&&(d>1&&t.disableSegmentResize||l._segmentObj&&l._segmentObj.disableResize))return void a.removeAttribute("task-bar-hovered");const c=e.pageX-window.pageXOffset,m="visible"===t.resizeHandlesVisibility||t._isMobile?20:5,u=(l||n).getBoundingClientRect(),h=s.getBoundingClientRect(),g=Math.min(m,c-h.left),f=Math.min(m,h.left+h.width-c);Math.round(u.left)+g>=c&&Math.round(u.left)-g<=c?a.setAttribute("task-bar-hovered","left"):Math.round(u.left+u.width)+f>=c&&Math.round(u.left+u.width)-f<=c?a.setAttribute("task-bar-hovered","right"):a.removeAttribute("task-bar-hovered")}_onShadowDomLoaded(e,t,i){requestAnimationFrame((function a(){const n=(e.shadowRoot||e.getRootNode()).querySelectorAll("link");for(let e=0;e<n.length;e++)if(-1!==n[e].href.indexOf(t))return void i();requestAnimationFrame(a)}))}_getConnectionObjById(e){const t=this._connections;if(!e||!t||!t.length)return;const i=e.split("-"),a=parseInt(i[0]),n=parseInt(i[1]),s=parseInt(i[2]);for(let e=0,i=t.length;e<i;e+=1){const i=t[e];if(i.startIndex===a&&i.endIndex===n&&i.type===s)return i}}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),i=[e.$.taskPopupWindow,e.$.connectionPopupWindow,e.$.confirmPopupWindow];for(let a=0;a<i.length;a++){const n=i[a];if(!n||!t.contains(n))continue;const s=e.getBoundingClientRect();n.opened||(n.style.left=n.style.top=""),e._isMobile?(n.setAttribute("mobile",""),n.style.left=s.left+window.pageXOffset+"px",n.style.top=s.top+window.pageYOffset+"px",n.style.width=s.width+"px",n.style.height=s.height+"px"):(n.style.left=Math.max(s.left+window.pageXOffset,s.left+window.pageXOffset+s.width/2-n.offsetWidth/2)+"px",n.style.top=Math.max(s.top+window.pageYOffset,s.top+window.pageYOffset+s.height/2-n.offsetHeight/2)+"px")}}_openPopupWindow(e,t){const i=this;function a(){function t(){i._positionWindow(),s.opened?(s.bringToFront(),s._onOpenCallback?s._onOpenCallback():s._handleActiveState()):s.open()}if(i.popupWindowCustomizationFunction?i.popupWindowCustomizationFunction(s,n,"connection"===n?e.startIndex+"-"+e.endIndex+"-"+e.type:i._cloneObject(e)):s._onOpenCallback=()=>{const e=(s.shadowRoot||s).querySelectorAll(".smart-gantt-chart-popup-window-editor .smart-input, .smart-popup-window-button");(e[0]||e[1]||s).focus({preventScroll:!0}),s._handleActiveState()},i._setPopupWindowTemplate("header",n,e),i._setPopupWindowTemplate("footer",n,e),i._setPopupWindowTemplate("content",n,e),!i._popupWindow[n+"PopupWindow"]){const e=i["$"+n+"PopupWindow"];e.unlisten("transitionend"),e.unlisten("open"),e.unlisten("close"),e.unlisten("closing"),e.unlisten("click"),e.unlisten("change"),e.listen("transitionend",i._popupWindowTransitionendHandler.bind(i)),e.listen("open",i._popupWindowOpenHandler.bind(i)),e.listen("close",i._popupWindowCloseHandler.bind(i)),e.listen("closing",i._popupWindowClosingHandler.bind(i)),e.listen("click",i._popupWindowClickHandler.bind(i)),e.listen("change",i._popupWindowChangeHandler.bind(i))}s.shadowRoot?(s.importStyle(Smart.Utilities.Core.getScriptLocation()+Smart.StyleBaseUrl.replace("/scoped/","/smart.textbox.css")),i._onShadowDomLoaded(s,"smart.window.css",t)):t();const a=(i.getAttribute("aria-owns")||"")+" "+s.id;i.setAttribute("aria-owns",a.trim()),i._popupWindow[n+"PopupWindow"]=s}if(e&&e.classList)if(e.classList.contains("smart-task-connection"))e=i._getConnectionObjById(e.getAttribute("connection-id"));else if("TR"===e.nodeType){const t=e?"task":"resource",a=i._getVCellById(t,e.getAttribute("row-id"));e=a?a[t]:void 0}else e=e._cellObj.task;if(!e||e.isGroup)return;const n=t?"confirm":"string"==typeof e.type?"task":"connection",s=i._createPopupWindow(n);!t&&i.$.fireEvent("opening",{target:s,type:n}).defaultPrevented||(i._closeTooltip(),s._target=e,i._popupWindow||(i._popupWindow={}),s.parentElement||i.getShadowRootOrBody().appendChild(s),s.isCompleted?a():s.whenReady((()=>a())))}_createPopupWindow(e){const t=this,i=e+"PopupWindow";if(t.$[i])return t.$[i];const a=document.createElement("smart-window");return a.classList.add("smart-"+e+"-popup-window"),a.classList.add("smart-gantt-chart-popup-window"),a.setAttribute("smart-id",i),t.$[i]=a,t["$"+i]=Smart.Utilities.Extend(a),a.rightToLeft=t.rightToLeft,a.theme=t.theme,a.animation=t.animation,a.disableSnap=!0,a.headerButtons=["close"],a}_popupWindowOpenHandler(e){const t=this,i=t["$"+e.target.getAttribute("smart-id")];if(i){const a=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";t._handleModal(!0),t.$.fireEvent(e.type,Object.assign({type:a,target:e.target},e.detail)),i.unlisten("open")}}_popupWindowClosingHandler(e){const t=this["$"+e.target.getAttribute("smart-id")];if(!t)return;const i=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";this.$.fireEvent(e.type,{target:e.target,type:i}).defaultPrevented?e.preventDefault():t.unlisten(e.type)}_popupWindowCloseHandler(e){const t=this,i=e.target.getAttribute("smart-id"),a=t["$"+i];if(a){const n=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";if(t._handleModal(),t.$.fireEvent(e.type,Object.assign({type:n,target:e.target},e.detail)),a.unlisten("close"),a.unlisten("click"),t.hasAttribute("aria-owns")){const e=t.getAttribute("aria-owns").replace(t._popupWindow[i].id,"").trim();e?t.setAttribute("aria-owns",e):t.removeAttribute("aria-owns")}delete t._popupWindow[i];const s=Object.keys(t._popupWindow);1===s.length&&t._popupWindow.confirmPopupWindow&&(delete t._popupWindow.confirmPopupWindow._target,t._popupWindow.confirmPopupWindow.close()),s.length?requestAnimationFrame((()=>{const e=t._popupWindow[s[s.length-1]];e&&e.focus()})):t.keyboardNavigation&&t.$.taskTable.focus({preventScroll:!0})}}_popupWindowTransitionendHandler(e){const t=this,i=e.target;i instanceof Smart.Window&&!i.opened&&"visibility"===e.propertyName&&(t["$"+i.getAttribute("smart-id")].unlisten("transitionend"),i.parentElement&&i.parentElement.removeChild(i))}_handleModal(e){const t=this;let i=(t.shadowRoot||t).querySelector(".smart-popup-window-modal");e?(i||(i=document.createElement("div"),i.classList.add("smart-popup-window-modal")),i.parentElement||(t.$.container.appendChild(i),t.setAttribute("modal",""))):i&&i.parentElement&&Object.keys(t._popupWindow).length<2&&(i.parentElement.removeChild(i),t.removeAttribute("modal"))}_findTaskEditor(e,t){if(!e||!t)return;const i=t.children;for(let t=0,a=i.length;t<a;t+=1){const a=i[t];if(a.getAttribute("value")===e)return a}}_createTaskEditor(e,t,i){const a=this,n=e.value,s=t[e.value];let r,o,l=i.find((e=>e._label===n));if(l)r=l.querySelector(".smart-gantt-chart-label-container"),o=l.lastElementChild;else{const t="editorLabel"+Math.floor(65536*(1+Math.random())).toString(16).substring(1);if(r=document.createElement("div"),r.classList.add("smart-gantt-chart-label-container"),r.innerHTML=`<label id="${t}"></label>`,"deadline"===n){const e=document.createElement("span");e.classList.add("smart-popup-window-editor-toggle"),r.appendChild(e)}if(l=document.createElement("div"),l.classList.add("smart-gantt-chart-popup-window-editor"),l.setAttribute("value",n||""),l._label=n,e.customEditor)return l.appendChild(e.customEditor(n,s)),l;if("number"==typeof s||"string"==typeof s)o=document.createElement("input"),o.classList.add("smart-input");else if(s instanceof Date||"deadline"===n)Smart.DateTimePicker?(o=document.createElement("smart-date-time-picker"),o.locale=a.locale,o.dropDownAppendTo="body",o.calendarButton=!0,o.dropDownDisplayMode="auto",o.enableMouseWheelAction=!0,o.formatString="yyyy-MMM-dd HH:mm:ss"):(o=document.createElement("input"),o.type="datetime-local");else if(Array.isArray(s))if(Smart.DropDownList)o=document.createElement("smart-drop-down-list"),o.virtualized=!0,o.dropDownAppendTo="body",o.selectionMode="zeroOrMany";else{o=document.createElement("input"),o.classList.add("smart-input");const e=document.createElement("datalist");e.id="resourceList",o.setAttribute("list",e.id),l.appendChild(e)}o&&o.setAttribute("aria-labelledby",t)}if(!l.parentElement)return r&&l.appendChild(r),o&&l.appendChild(o),l;a._setPopupWindowEditors(e,t,l)}_setAriaControls(){this.setAttribute("role","treegrid")}_setPopupWindowEditors(e,t,i){const a=this,n=i.querySelector("label"),s=i.querySelector(".smart-popup-window-editor-toggle"),r=i.lastElementChild,o=e.value+"",l=o.split(/(?=[A-Z])/).join(" "),d=t[o];if(e.customEditor)e.setCustomEditorValue&&e.setCustomEditorValue(i,l,d);else{if(n.innerHTML=a.localize(e.value)||l.charAt(0).toUpperCase()+l.slice(1),s)if("deadline"===o){const e=null==d?"add":"remove";r.classList[e]("smart-hidden"),s.textContent=a.localize(e)}else s.remove();if("number"==typeof d)r.value=parseFloat(d);else if("string"==typeof d)r.value=d;else if(d instanceof Date)r.value=new Date(d);else if(Array.isArray(d)){const e=a._resources;if(r.placeholder=a.localize("unassigned"),Smart.DropDownList&&r instanceof Smart.DropDownList)r.dataSource=e.map((e=>({label:e.label,value:e.id}))),r.selectedValues=t.disableResources?[]:t.resources.map((e=>e.toString()));else{let a=i.querySelector("datalist"),n=document.createDocumentFragment();a.innerHTML="";for(let t=0;t<e.length;t++){const i=e[t],a=document.createElement("option");a.value=i.id,a.innerHTML=i.label,n.appendChild(a)}r.value=t.resources.toString(),a.appendChild(n)}}"project"===t.type&&t.synchronized&&["duration","date"].indexOf(l.toLowerCase())>-1||"resources"===l&&t.disableResources?r.disabled=!0:r.disabled=!!e.disableEdit,r.rightToLeft=a.rightToLeft,r.animation=a.animation,r.theme=a.theme}}_setupPopupWindowTabs(e,t){const i=this,a=i.popupWindowTabs,n="milestone"===t.type,s=[{label:i.localize("generalTab"),value:"general"},{label:i.localize("dependencyTab"),value:"dependency"},{label:i.localize("segmentsTab"),value:"segments"}];let r=e.querySelector(".smart-gantt-chart-popup-window-tabs");r||(r=document.createElement("smart-tabs"),r.classList.add("smart-gantt-chart-popup-window-tabs"),e.clear(),e.appendChild(r)),r.animation=i.animation,r.rightToLeft=i.rightToLeft,r.theme=i.theme;const o=r.getTabs().slice(0);for(let e=0,t=s.length;e<t;e+=1){const t=s[e],i=t.value;let l=o[e];a.indexOf(i)<0?l&&r.removeChild(l):(l||(l=document.createElement("smart-tab-item"),r.appendChild(l)),l.label=t.label,l.setAttribute("value",i||""),l.disabled=n&&"segments"===i)}return r}_setPopupWindowContent(e,t){const i=this,a=i.$[e+"PopupWindow"],n=[].slice.call(a.querySelectorAll(".smart-gantt-chart-popup-window-editor"));if(a.content&&(!a.content.innerHTML||n.length))if("task"===e&&t){const e=i.taskColumns;let s=[];const r=i._setupPopupWindowTabs(a,t);0!==r.selectedIndex&&(r.selectedIndex=0);const o=r.getTabs()[0];if("general"!==o.getAttribute("value"))return void i._handleTabsContent(o,a);"string"==typeof o.content?o.content="":o.content.innerHTML="";for(let a=0;a<e.length;a++){const r=e[a],l=r.value;if(void 0===t[l]&&"deadline"!==l||"overdue"===l)continue;let d=i._findTaskEditor(l,o);d||(d=i._createTaskEditor(r,t,n),d&&o.appendChild(d)),d&&(i._setPopupWindowEditors(r,t,d),s.push(d))}for(let e=0,t=n.length;e<t;e+=1){const t=n[e];s.indexOf(t)<0&&t.remove()}t.id&&a.setAttribute("aria-controls",t.id)}else if("confirm"===e){if(a.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("confirm",{componentName:"The task"})+"</div >",i._popupWindow){const e=Object.keys(i._popupWindow);e.length&&a.setAttribute("aria-controls",i._popupWindow[e[e.length-1]].id)}}else{const e=t.startTask,n=t.endTask;a.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("deleteLink")+"<b> "+e.label+" - "+n.label+"?</b></div>"}}_setPopupWindowTemplate(e,t,i){const a=this,n=a.$[t+"PopupWindow"];if("content"!==e){if(n[e+"Template"]||(n[e+"Template"]=a._createPopupWindowTemplate(e,t)),"header"===e&&i&&"string"==typeof i.type){const e=(n.shadowRoot||n).querySelector(".smart-popup-window-label");e&&(e.innerHTML=i.label)}else if("footer"===e){const e=(n.shadowRoot||n).querySelectorAll(".smart-popup-window-button");for(let i=0;i<e.length;i++){const n=e[i];n.innerHTML="task"===t?'<span class="smart-icon"></span>':"",n.theme=a.theme,n.rightToLeft=a.rightToLeft,n.animation=a.animation,n.disabled=!1,n.classList.contains("ok")?(n.innerHTML+=a.localize("ok"),n.setAttribute("aria-label","ok")):n.classList.contains("cancel")?(n.innerHTML+=a.localize("cancel"),n.setAttribute("aria-label","cancel")):n.classList.contains("delete")&&(n.innerHTML+=a.localize("delete"),n.setAttribute("aria-label","delete"));const s=n.querySelector(".smart-ripple");s&&s.parentElement.removeChild(s)}}}else a._setPopupWindowContent(t,i)}_createPopupWindowTemplate(e,t){const i=this,a=document.createElement("template");if("footer"===e)switch(t){case"task":a.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button delete secondary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`;break;case"connection":case"confirm":a.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`}else"header"!==e||"task"!==t&&"confirm"!==t||(a.innerHTML='<span class="smart-popup-window-label"></span>');return a}_handleTabsContent(e,t){const i=this,a=t._target;if(!e|!a)return;const n=e.getAttribute("value");if("general"===n)return;let s=e.querySelector(".smart-gantt-popup-window-table"),r=e.querySelector(".smart-gantt-window-table-buttons"),o=e.querySelector(".smart-gantt-window-validation-message");r||(r=document.createElement("div"),r.classList.add("smart-gantt-window-table-buttons"),r.innerHTML=`<smart-button class="smart-gantt-chart-button" action="add">${i.localize("add")}</smart-button>\n <smart-button class="smart-gantt-chart-button" disabled action="delete">${i.localize("delete")}</smart-button>`,e.insertBefore(r,s)),s||(s=document.createElement("smart-table"),s.classList.add("smart-gantt-popup-window-table"),s.editing=!0,s.editMode="row",s.keyboardNavigation=!0,s.wait=!0,s.hideSelectionColumn=!0,s.selection=!0,s.selectionMode="one",s.columnMinWidth="10px",s.addEventListener("rowEndEdit",(r=>{const o=r.detail.row;switch(n){case"dependency":{const e=i._tasks,t=o.name,n=e.indexOf(a),r=e.findIndex((e=>e.$.id===t));r>-1&&s.updateRow(o.$.id,{id:`${r}-${n}-${o.type}`});break}case"segments":{const e=o.dateStart,t=o.dateEnd;e.getTime&&t.getTime&&s.updateRow(o.$.id,{duration:parseFloat(i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e,t):t.getTime()-e.getTime(),!0).toFixed(2))});break}}i._applyTableValidation(e,s,t),i._isPopupWindowTableModified=!0})),e.innerHTML&&(e.innerHTML=""),e.appendChild(s));const l=i._getTabsTableData(n,a);s.selected.length&&(s.selected=[]),s.dataSource=l.source,s.columns=l.columns,s.wait=!1,delete i._isPopupWindowTableModified,o||(o=document.createElement("label"),o.classList.add("smart-gantt-window-validation-message"),e.appendChild(o)),o.textContent=""}_applyTableValidation(e,t,i){const a=this,n=e.getAttribute("value"),s=e.querySelector(".smart-gantt-window-validation-message"),r=i.querySelector(".smart-popup-window-button.ok"),o=t.dataSource,l=o.length;if(!s)return void(r&&(r.disabled=!1));if(!l)return s.textContent="",void(r&&(r.disabled=!1));let d="";if("segments"===n)if(l<2)d=a.localize("segmentsCountValidation");else{const e=i._target,t=e.dateStart.getTime(),n=e.dateEnd.getTime();let s={};for(let e=0;e<l;e+=1){const i=o[e],r=i.label,l=i.dateStart.getTime(),c=i.dateEnd.getTime();for(let e in s){const t=s[e],n=t.timeStart,r=t.timeEnd,o=l<=n&&c>=n,m=l<=r&&c>=r;(o||m)&&(d+=a.localize("segmentConflictError",{dateConflict:o?"dateStart":"dateEnd",label:i.label,conflictLabel:t.label})+"\r\n")}l>c?d+=a.localize("segmentStartError",{label:i.label})+"\r\n":l===c&&(d+=a.localize("segmentEndError",{label:i.label})+"\r\n"),(l<t||c>n)&&(d+=a.localize("segmentRangeError",{label:i.label})+"\r\n"),void 0===s[e]&&(s[e]={label:r,timeStart:l,timeEnd:c})}}else if("dependency"===n)for(let e=0;e<l;e+=1){const t=o[e].id.split("-");t[0]===t[1]&&(d+=a.localize("dependencyValidation")+"\r\n")}s.textContent=d,r&&(r.disabled=d.length>0)}_getTabsTableData(e,t){const i=this;if("dependency"===e){const e=i._getTaskConnections(t).connectedTasks,a={connectionTypes:[{label:i.localize("startToStart"),value:0},{label:i.localize("endToStart"),value:1},{label:i.localize("endToEnd"),value:2},{label:i.localize("startToEnd"),value:3}],tasks:(()=>{const e=i._tasks;let a=[];for(let i=0,n=e.length;i<n;i+=1){const n=e[i];n!==t&&a.push({value:n.$.id,label:n.label})}return a})()};return{source:new window.Smart.DataAdapter({dataSource:e&&e.length?e.map((e=>({id:e.startIndex+"-"+e.endIndex+"-"+e.type,name:e.startTask.$.id||"",type:e.type,lag:e.lag||0}))):[],dataFields:["id: any","name: any","type: number","lag: number"]}),columns:[{label:i.localize("id"),dataField:"id",dataType:"any",autoWidth:!1,allowEdit:!1},{label:i.localize("name"),dataField:"name",dataType:"any",width:"35%",autoWidth:!1,editor:i._getColumnEditorSetup("name",a),formatFunction:e=>{const t=a.tasks.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("type"),dataField:"type",dataType:"number",width:"25%",autoWidth:!1,editor:i._getColumnEditorSetup("type",a),formatFunction:e=>{const t=a.connectionTypes.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("lag"),dataField:"lag",dataType:"number",autoWidth:!1}]}}if("segments"===e){const e={task:t};return{source:new window.Smart.DataAdapter({dataSource:t.segments,dataFields:["label: string","dateStart: date","dateEnd: date","duration: number"]}),columns:[{label:i.localize("name"),dataField:"label",dataType:"string",autoWidth:!1,width:"20%"},{label:i.localize("dateStart"),dataField:"dateStart",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateStart",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateStart)}},{label:i.localize("dateEnd"),dataField:"dateEnd",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateEnd",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateEnd)}},{label:i.localize("duration"),dataField:"duration",dataType:"number",autoWidth:!1,width:"15%",allowEdit:!1}]}}return{source:[],columns:[]}}_getColumnEditorSetup(e,t){const i=this;switch(e){case"dateStart":case"dateEnd":return{template:'<smart-date-time-picker drop-down-append-to="body" wait></smart-date-time-picker>',onInit:(e,a,n,s)=>{const r=t.task;s||(s=new Date(r.dateStart)),n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.min=r.dateStart,n.max=r.dateEnd,n.locale=i.locale,n.calendarButton=!0,n.dropDownDisplayMode="auto",n.enableMouseWheelAction=!0,n.formatString="yyyy-MMM-dd HH:mm:ss",n.value=new Date(Math.max(r.dateStart.getTime(),Math.min(r.dateEnd.getTime(),s.getTime()))),n.removeAttribute("wait")},getValue:e=>e.value.toDate()};case"name":return{template:'<smart-drop-down-list virtualized drop-down-append-to="body" wait></smart-drop-down-list>',onInit:(e,a,n,s)=>{n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dataSource=t.tasks,n.selectedValues=[s],n.removeAttribute("wait")},getValue:e=>e.selectedValues[0]};case"type":return{template:"<smart-input wait></smart-input>",onInit:(e,a,n,s)=>{const r=t.connectionTypes,o=r.find((e=>e.value===s));n.readonly=!0,n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dropDownButtonPosition="right",n.dataSource=r,n.value=(o||r[0]).label+"",n.removeAttribute("wait")},getValue:e=>{if(e.selectedValues.length)return e.selectedValues[0];const i=t.connectionTypes.find((t=>t.label===e.value));return i?i.value:void 0}}}}_popupWindowChangeHandler(e){const t=this,i=e.target,a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0);if(a._target)if(i.classList.contains("smart-gantt-chart-popup-window-tabs")){const n=a.querySelector(".smart-popup-window-button.ok");n&&(n.disabled=!1),t._handleTabsContent(i.getTabs()[e.detail.index],a)}else if(i.classList.contains("smart-gantt-popup-window-table")){const e=i.closest("smart-tab-item").querySelector('.smart-gantt-chart-button[action="delete"]');e&&(e.disabled=0===i.selected.length)}}_popupWindowClickHandler(e){const t=this;let i=(e.originalEvent||e).target;i.shadowRoot&&(i=(e.originalEvent||e).composedPath()[0]);const a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0),n=a._target;if(i.closest(".smart-popup-window-button.cancel"))return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target;if(i.closest(".smart-popup-window-button.ok")){if(a===t.$.connectionPopupWindow&&"number"==typeof n.type)t._removeConnection(n.startIndex+"-"+n.endIndex+"-"+n.type);else if(a===t.$.confirmPopupWindow){const e=n;void 0!==e.$._resourceId?t._removeResource(e):t._removeTask(e),a.close(),t.$.taskPopupWindow&&t.$.taskPopupWindow.close(),delete a._target}else{const e=a.shadowRoot||a,i=e.querySelectorAll(".smart-gantt-chart-popup-window-editor"),s=n;let r={};for(let e=0;e<i.length;e++){const a=i[e]._label,n=t.taskColumns.find((e=>e.value===a));if(n.customEditor&&n.getCustomEditorValue)r[a]=n.getCustomEditorValue(i[e]);else{const t=i[e].lastElementChild;let n;if(!t)continue;if(t.classList.contains("smart-hidden")){r[a]=void 0;continue}n=Smart.DateTimePicker&&t instanceof Smart.DateTimePicker?t.value.toDate?t.value.toDate():t.value:t instanceof HTMLInputElement&&"datetime-local"===t.type?new Date(t.value):Smart.DropDownList&&t instanceof Smart.DropDownList?t.selectedValues.slice(0):t.hasAttribute("list")?t.value.split(",").map((e=>e.trim())):t.value,n instanceof Date&&isNaN(n.getTime())&&(n=void 0),null!=n&&(r[a]=n)}}if(void 0!==s.$._resourceId)t._updateResource(s,r);else{const i=r.dateStart?r.dateStart:void 0,a=r.dateEnd?r.dateEnd:void 0;if((i&&i.getTime&&i.getTime()!==s.dateStart.getTime()||a&&a.getTime&&a.getTime()!==s.dateEnd.getTime())&&(r.duration=void 0),t._isPopupWindowTableModified){const i=e.querySelectorAll(".smart-gantt-popup-window-table");for(let e=0,a=i.length;e<a;e+=1){const a=i[e];a.closest('.smart-tab-item[value="dependency"]')?t._updateTaskDependencies(a,s):a.closest('.smart-tab-item[value="segments"]')&&t._updateTaskSegments(a,s)}}t._updateTask(s,r)}}return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target}if(i.closest(".smart-popup-window-button.delete"))return void t._openPopupWindow(a._target,!0);if(i.closest(".smart-popup-window-editor-toggle")){const e=i.closest('.smart-gantt-chart-popup-window-editor[value="deadline"]'),a=e?e.lastElementChild:void 0;if(a){const e=a.classList.contains("smart-hidden")?"remove":"add";a.classList[e]("smart-hidden"),i.textContent=t.localize(e)}return}const s=i.closest(".smart-gantt-chart-button");if(s){const e=i.closest("smart-tab-item"),r=e.querySelector(".smart-gantt-popup-window-table");if(!r)return;const o=s.getAttribute("action"),l=e.getAttribute("value"),d=n;switch(o){case"add":{let e;e="segments"===l?{label:`${t.localize("segment")} ${r.dataSource.length+1}`,dateStart:new Date(d.dateStart),dateEnd:new Date(d.dateEnd),duration:parseFloat((d.duration||0).toFixed(2))}:{id:"",name:"",type:0,lag:0},r.addRow(e),r.beginEdit(r.rows.length-1),t._isPopupWindowTableModified=!0;break}case"delete":{const e=r.selected;r.beginUpdate();for(let t=0,i=e.length;t<i;t+=1)r.removeRow(e[t]);r.endUpdate(),t._isPopupWindowTableModified=!0;break}}t._applyTableValidation(e,r,a)}}_updateTaskDependencies(e,t){const i=this,a=i._tasks.indexOf(t),n=i._getTaskConnections(t).connectedTasks,s=e.rows;for(let e=0,t=n.length;e<t;e+=1){const t=n[e];i._removeConnection(`${t.startIndex}-${t.endIndex}-${t.type}`)}for(let e=0,t=s.length;e<t;e+=1){const t=s[e].data,n=t.name,r=t.type;if(!i._getValidConnectionId(n,a,r,"_"))continue;const o=parseInt(t.lag);i._connectTask([n,a,r,isNaN(o)?0:o])}i._recycleConnections()}_updateTaskSegments(e,t){const i=e.rows;let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e].data,n=t.label,s=new Date(t.dateStart),r=new Date(t.dateEnd);isNaN(s)||isNaN(r)||a.push({label:"string"==typeof n?n:"",dateStart:s,dateEnd:r})}t.segments=a,this._validateTaskSegments(t)}_createTasks(e,t){const i=this,a={},n=[];e||(e=i.dataSource),i.dataSource instanceof Smart.DataAdapter&&(e=i._parseAdapterData(i.dataSource.toArray())),t||i.clearTasks();let s=[];if(function e(r,o){let l=[];if(!r||0===r.length)return[];for(let d=0;d<r.length;d++){let c,m=r[d];if("object"!=typeof m)continue;if(m=i._validateTaskProperties(m,o),!m)continue;const u=m.tasks,h=m.id;m.$.project=o,m.$.id=o?o.$.id+"."+d:d+"","string"!=typeof h&&"number"!=typeof h||(a[h]?n.push(h):a[h]=1),u instanceof Array&&u.length>0&&(m.synchronized&&(m.dateStart=m.minDateStart=m.maxDateStart=void 0,m.dateEnd=m.minDateEnd=m.maxDateEnd=void 0),m.type="project",c=e(u,m),c.length&&(m.hidden=!c.some((e=>!e.hidden)),m.hidden?c.forEach((e=>e.hidden=m.hidden)):i._synchronizeProjectVisibility(o,m))),(!m.type||["project","task","milestone"].indexOf(m.type)<0)&&(m.type="task"),o&&"project"===m.type&&c&&c.length>0?(l.push(m),l=l.concat(c)):(o||((t&&"project"===m.type&&m.synchronized||m.dateStart&&m.dateEnd&&!isNaN(m.dateStart.getTime())&&!isNaN(m.dateEnd.getTime()))&&s.push(m),c&&(s=s.concat(c))),l.push(m))}return o&&i._synchronizeProjectDates(o,l),l}(e),t)return s.slice(0);n.length&&console.warn(i.localize("duplicateIds",{elementType:i.nodeName.toLowerCase(),duplicates:n.toString()})),i._tasks=s.slice(0),i._handleResources()}_createTimeline(){const e=this;e._tasks&&0!==e._tasks.length?(delete e.__tasks,e._createConnections(),e._autoSchedule(),e._createTimelineCells(),e._insertTimelineTasks(),e.$.taskSplitter.refresh()):e._clearTasks()}_createConnections(){const e=this,t=e._tasks;e._connections=[];for(let i=0,a=t.length;i<a;i+=1)t[i].connections&&e._handleTaskConnections(i)}_createTooltip(){const e=this,t=e.tooltip;let i=e.$.tooltip;if(t.enabled)return i||(e.$.tooltip=i=document.createElement("smart-tooltip"),i.classList.add("smart-gantt-chart-tooltip"),i.setAttribute("smart-id","tooltip")),e.$tooltip||e._handleTooltipEvents(!0),i.rightToLeft=e.rightToLeft,i.theme=e.theme,i.openMode="manual",i.arrow=t.arrow,i.delay=t.delay,i.parentElement||e.$.container.appendChild(i),i;i&&(i.close(),i.remove())}_handleTooltipEvents(e){const t=this,i=t.$.tooltip;if(!i)return;let a=t.$tooltip;e?(a=t.$tooltip=Smart.Utilities.Extend(i),a.listen("close",t._tooltipVisibilityHandler.bind(t)),a.listen("closing",t._tooltipVisibilityHandler.bind(t)),a.listen("open",t._tooltipVisibilityHandler.bind(t)),a.listen("opening",t._tooltipVisibilityHandler.bind(t))):a&&(a.unlisten("close"),a.unlisten("closing"),a.unlisten("open"),a.unlisten("opening"),delete t.$tooltip)}_toggleTooltip(e){const t=this;if(t._dragDetails||!t.tooltip.enabled||!t.$.container.contains(e.target))return void t._closeTooltip();const i=t.getRootNode(),a={"smart-task-segment":null,"smart-timeline-task":null,"smart-gantt-chart-task-indicator":null,"smart-resource-timeline-view-cell":null,"smart-task-connection":null},n=(i.host?i.host.shadowRoot:i).elementsFromPoint(e.clientX,e.clientY);let s;for(let e=0,t=n.length;e<t;e+=1){const t=n[e],i=t.classList;if(i.contains("smart-task-container"))a["smart-timeline-task"]=t.closest(".smart-timeline-task");else for(let e in a)i.contains(e)&&(a[e]=t)}if(a["smart-task-segment"]){const e=a["smart-timeline-task"],t=e?e._cellObj.task:void 0;s=t&&t.segments&&t.segments.length?a["smart-task-segment"]:e}else if(a["smart-gantt-chart-task-indicator"])s=a["smart-gantt-chart-task-indicator"];else for(let e in a)if(a[e]){s=a[e];break}s?t._openTooltip(s,e):t._closeTooltip()}_getConnectionTypeName(e){const t=this;switch(e){case 0:return t.localize("startToStart");case 1:return t.localize("endToStart");case 2:return t.localize("endToEnd");case 3:return t.localize("startToEnd");default:return""}}_getSegmentTask(e){const t=this._tasks;for(let i=0,a=t.length;i<a;i+=1){const a=t[i];if(Array.isArray(a.segments)&&a.segments.indexOf(e)>-1)return a}}_getTooltipContent(e){const t=this;if(!e)return;const i=e.classList;let a,n;if(i.contains("smart-task-segment")){if(n=e._segmentObj,n){let e=n.label;if(void 0===e){const i=t._getSegmentTask(n);i&&(e=i.label)}a=`<label><b>${t.localize("segment")}</b>: ${e||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`}}else if(i.contains("smart-timeline-task"))n=e._cellObj.task,n&&!n.segments&&(a=`<label><b>${t.localize("task")}</b>: ${n.label||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`);else if(i.contains("smart-gantt-chart-task-indicator"))n=e._indicatorObj,n&&(a=n.label||"");else if(i.contains("smart-resource-timeline-view-cell")){if(!e.hasAttribute("load"))return;const i=e.closest(".smart-timeline-cell");if((e=e.closest(".smart-timeline-row"))&&e._cellObj&&(n=e._cellObj.resource),n){const s=t._getResourceTasks(n),r="hours"===t.resourceTimelineView?"h":"",o=t._tasks,l=t.$.resourceTimelineViewCells.children,d=Array.from(e.children).findIndex((e=>e===i));a=`<label><b>${t.localize("resource")}</b>: ${n.label||""}</label>\n <label><b>${t.localize("assignments")}</b>:</label>`;for(let e=0,i=s.length;e<i;e+=1){const i=s[e],c=o.indexOf(i),m=t._getResourceCellCapacity({cellDateRange:t._getCellDateRange(l[d]),cellTaskIndexAssigned:[c],index:d,resource:n,task:i,cellIndex:d});void 0!==m&&(a+=`<label>${t.localize("task")} #${c}: (${parseFloat(m.capacity.toFixed(1))}${r}) ${i.label||""}</label>`)}}}else i.contains("smart-task-connection")&&(n=t.getConnectionDetails(e.getAttribute("connection-id")),void 0!==n&&(a=`<label><b>${t.localize("startTask")}</b>: ${n.startTask.label||""}</label>\n <label><b>${t.localize("endTask")}</b>: ${n.endTask.label||""}</label>\n <label><b>${t.localize("type")}</b>: ${t._getConnectionTypeName(n.type)||""}</label>`,n.lag&&(a+=`<label><b>${t.localize("lag")}</b>: ${parseFloat(n.lag.toFixed(1))}</label>`)));return n?n.tooltip?n.tooltip+"":a||"":void 0}_openTooltip(e,t,i){const a=this,n=a.tooltip;if(i="string"==typeof i?i:a._getTooltipContent(e),!(n.enabled&&i&&e&&e.nodeName))return void a._closeTooltip();const s=a.$.tooltip||a._createTooltip();let r,o;if(i&&s.value!==i&&(s.value=i),s.selector=e,t&&t.pageX){const i=document.body.getBoundingClientRect(),a=e.getBoundingClientRect(),l=n,d=l.offset[0]||0,c=l.offset[1]||0,m=s.offsetWidth,u=s.offsetHeight;let h="bottom";"absolute"!==s.position&&(s.position="absolute",s.offset=[]),o=Math.min(i.left+i.width-m,t.pageX-m/2-d),r=a.top-u-c,r<i.top&&(r=a.bottom+c,h="top"),o<i.left&&(o=i.left+d,h="left"),h!==s.arrowDirection&&(s.arrowDirection=h),s.style.left=o+"px",s.style.top=r+"px"}else"auto"!==s.position&&(s.position="auto",s.offset=n.offset);s.visible||(a.getShadowRootOrBody().appendChild(s),s.open())}_closeTooltip(){const e=this.$.tooltip;e&&e.visible&&e.close()}_tooltipVisibilityHandler(e){const t=this,i=e.type,a=t.$.tooltip;e.target===a&&(e.stopPropagation(),t._fireTooltipVisibilityEvent(e)?e.preventDefault():"opening"===i?a.classList.remove("smart-visibility-hidden"):"closing"===i&&(a.hasAnimation?a.addEventListener("transitionend",(()=>{a.visible||(a.classList.add("smart-visibility-hidden"),a.style.top=a.style.left=0,t.$.container.appendChild(a))}),{once:!0}):t.$.container.appendChild(a)))}_fireTooltipVisibilityEvent(e){const t=this,i=e.type,a=t.$.tooltip,n=e.detail.owner;let s={target:a,owner:n};if(n)if(n.classList.contains("smart-task-connection")){s.type="connection";const e=t.getConnectionDetails(n.getAttribute("connection-id"));e&&(s.item=e)}else if(n.classList.contains("smart-gantt-chart-task-indicator"))s.type="indicator",n._indicatorObj&&(s.item=t._cloneObject(n._indicatorObj));else if(n.classList.contains("smart-task-segment"))s.type="segment",n._segmentObj&&(s.item=t._cloneObject(n._segmentObj));else if(n.classList.contains("smart-timeline-task"))s.type="task",n._cellObj&&n._cellObj.task&&(s.item=t._cloneObject(n._cellObj.task));else if(n.classList.contains("smart-resource-timeline-view-cell")){s.type="resource";const e=n.closest(".smart-timeline-row");e._cellObj&&(s.item=t._cloneObject(e._cellObj.resource))}let r=t.getAttribute("aria-owns")||"";switch(i){case"open":t.setAttribute("aria-owns",(r+" "+a.id).trim()),t.$.fireEvent(i,s);break;case"close":r=r.replace(a.id,"").trim(),r?t.setAttribute("aria-owns",r):t.removeAttribute("aria-owns"),t.$.fireEvent(i,s);break;case"closing":case"opening":if(t.$.fireEvent(i,s).defaultPrevented)return!0}}_parseAdapterData(e){let t={};for(let i=0,a=e.length;i<a;i+=1){const a=e[i],n=Object.assign({},a),s=a.parent,r=a.$.id;if(s&&s!==a){const e=s.$.id;t[e]||(t[e]=Object.assign({},s));const i=t[e];i.tasks||(i.tasks=[]),i.tasks.push(n)}else t[r]=n;delete n.parent,delete n.children,delete n.$}return Object.values(t)}_handleTaskConnections(e){const t=this,i=t._tasks;let a;if("number"==typeof e&&(a=e,e=i[e]),!e)return;void 0===a&&(a=i.indexOf(e));const n=e.connections,s=i.length;for(let e=0;e<n.length;e++){const i=n[e],r=t._getTaskIndexById(i.target);null==r||isNaN(r)||r<0||r>=s||r===a||t._connectTask([a,r,i.type,i.lag])}delete e.connections}_insertTasks(e,t,i){const a=this,n=a._tasks;if(t){const s=a._getProjectTasks(t,!0);if(s.length){const t=s[s.length-1];let r,o;"number"==typeof i&&i<s.length?r=s[i=Math.max(0,i)]:(r=t,o=!0);const l=a._getProjectTasks(r);i=o&&l.length?n.indexOf(l[l.length-1]):n.indexOf(r),n.splice.apply(n,[i+(o?1:0),0].concat(e))}else n.splice.apply(n,[n.indexOf(t)+1,0].concat(e))}else"number"==typeof i?(i+="",(i=n.findIndex((e=>e.$.id===i)))<0&&(i=n.length)):i=n.length,n.splice.apply(n,[i,0].concat(e))}_insertTimelineTasks(){const e=this,t=e._timelineVCells;t&&t.length?(e._recycleTimelineTasks(),e._refresh()):e._resetTimeline()}_recycleTimelineTasks(e){const t=this,i=t.$.taskIndicatorsContainer,a=i.children,n=t.$.taskTimelineCellsContainer.childElementCount,s=t._timelineVCells;for(;i.childElementCount>n;)i.firstElementChild.remove();if(t._closeTooltip(),!s||!s.length)return;const r=s.indexOf(t._getFirstContentCellInView()),o=t._getSelection("task",t.selectedTaskIds),l={timelineStart:t.dateStart.getTime(),timelineEnd:t.dateEnd.getTime()};for(let i=0,d=n;i<d;i++){const n=a[i],d=s[r+i];if(!d){n&&n.remove();continue}const c=d.task;t._snapToNearestDates(c),t._recycleTaskBars(d,i,o),t._setTimelineTaskBar(d,i),t._setTimelineTaskBaseline(d,i),t._setTaskBarProgress(c,i),t._setTaskBarLabel(c,i),t._setTaskIndicators(d,i,l),t._setTaskDeadline(d,i,l),e&&t._refreshTableColumnsData(c)}t._recycleConnections()}_ensureVisible(e,t="task"){const i=this;if(null==e)return;let a,n="task"===t?i._timelineVCells:i._timelineResourceVCells;a||(a=i.$[`${t}Table`]);const s=n.find((i=>i[t]===e));if(!s)return;let r,o;if("task"===t){const t=i._getTimelineTaskCellByDate(e.dateStart);if(r=i.$.taskTimelineContainer.offsetHeight,o=i,t){const e=i.scrollLeft,a=i.$.taskTimelineContainer.offsetWidth;t.left+t.width>e+a?i.scrollLeft=Math.max(0,t.left+t.width-a):t.left<e&&(i.scrollLeft=Math.max(0,t.left))}}else r=i.$.resourceTimelineContent.offsetHeight,o=i._resourceScrollView;const l=o.scrollTop;s.top+s.height>l+r?o.scrollTop=Math.max(0,s.top+s.height-r):s.top<l&&(o.scrollTop=Math.max(0,s.top))}_isTaskExpanded(e,t){if(!e||!e.$)return;let i,a=e.$[this.groupByResources?"group":"project"];if(!a)return!0;for(;a;){if(i=a.expanded,!i)return!1;if(a=a.$.project,a===t)break}return i}_getItemByTreeIndex(e,t,i){if(!t)return;const a=t.split(".");let n=this[`_${e}s`].filter((e=>!e.$.project))[t.split(".")[0]];if(n){if(!n[`${e}s`]||!n[`${e}s`].length)return i?null:n;for(let t=1;t<a.length;t++){const s=n[`${e}s`].filter((e=>!e.hidden&&e.$.project===n))[a[t]];if(!s||i&&"project"!==s.type)break;if(n=s,"project"!==n.type)break}return i?n&&"project"===n.type?n:void 0:n}}_getItemByTableId(e,t,i){if(null==t)return;const a=this[`_${e}s`];let n;for(let e=0,i=a.length;e<i;e+=1){const i=a[e];if(i.$.id===t){n=i;break}}return n?i?"project"===n.type?n:void 0:n:void 0}_tableChangeHandler(e){const t=e.target;(t.classList.contains("smart-task-table")||t.classList.contains("smart-resource-table"))&&(e.stopPropagation(),this._handleTableSelection(t===this.$.taskTable?"task":"resource",t.selected))}_tableColumnResizeHandler(e){const t=e.target,i=e.detail,a=t.classList.contains("smart-task-table");if(!a&&!t.classList.contains("smart-resource-table"))return;e.stopPropagation();const n=i.dataField,s=this[(a?"task":"resource")+"Columns"].find((e=>e.value===n));s&&(s.size=i.width),this.$.fireEvent("columnResize",i)}_tableSortFilterHandler(e){const t=this,i=e.target;let a;i.classList.contains("smart-task-table")?(a="task",t._createTimelineContent(),t._recycleTimelineTasks()):i.classList.contains("smart-resource-table")&&(a="resource",t._createResourceTimelineContent(),t._recycleResourceContent()),a&&(t._refresh(),e.stopPropagation(),t.$.fireEvent(e.type,Object.assign({type:a},e.detail)))}_taskTableExpandHandler(e){const t=this,i=e.target;if(!i.classList.contains("smart-task-table")&&!i.classList.contains("smart-resource-table"))return;const a=i===t.$.taskTable?"task":"resource";if(e.stopPropagation(),!t[`${a}s`]||!t[`${a}s`].length)return;const n=e.detail.record.itemId,s=t._getItemByTableId(a,n,!0);s&&(delete t._hoveredItem,s.expanded="collapse"!==e.type,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(e.type,{item:t._cloneObject(s),id:s.id||s.$.id,index:t._tasks.indexOf(s),label:s.label,value:s.value}))}_taskTableKeyDownHandler(e){const t=this,i=e.key;if(t.keyboardNavigation&&!t.disabled&&!t.readonly)switch(i){case"Delete":case"Enter":{const e=t.$.taskTable._focusedCell;if(!e||!e.closest)return;const a=e.closest("tbody tr");if(!a)return;const n=t._getVCellById("task",a.getAttribute("row-id"));n&&t._openPopupWindow(n.task,"Delete"===i);break}}}_getVCellById(e="task",t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_getGroupVCellByPath(e,t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_taskTableGroupEventHandler(e){const t=this,i=e.detail.action,a=e.target;if(["collapse","expand"].indexOf(i)<0||!a.classList.contains("smart-task-table")&&!a.classList.contains("smart-resource-table"))return;const n=a===t.$.taskTable?"task":"resource",s=t.$.taskTable._getGroupByIndex(e.detail.path),r=t._getGroupVCellByPath(n,s.$.id);if(!r||!r[n].isGroup)return;const o=r[n];e.stopPropagation(),o.expanded="collapse"!==i,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(i,{isGroup:!0,item:t._cloneObject(o),id:o.$.id,label:o.label})}_resetTimeline(){const e=this,t=e.$.taskTimelineContainer;if(e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineContent.style.height="",e.$.taskIndicatorsContainer.innerHTML="",e.rightToLeft&&e.scrollLeft!==t.scrollLeft){const i=e._getScrollLeft(e.scrollLeft);t.scrollLeft=i,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=i)}e._closeTooltip(),e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height")}_refreshTimeline(e){const t=this;e||(e=t.view);const i=t._getDateFromCell(t.scrollLeft,t._getFirstCellObjInView(),e),a=t.scrollTop;t._refreshing=!0,t.scrollLeft=0,t.scrollTop=0,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&t._resourceScrollView&&(t._resourceScrollView.scrollLeft=0),t._resetTimeline(),t._createTimelineCells(),t._recycleTimelineTasks(!0),t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshResourceTimeline(),t._refresh(),t._refreshing=!1,t._scrollTo(i),t.scrollTop=a}_scrollTo(e,t){const i=this,a=i._timelineCells;let n;if(void 0!==e&&!isNaN(new Date(e).getTime()))for(let s=0;s<a.length;s++){const r=a[s],o=r.date;switch(i.view){case"quarter":case"year":if(o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()){if(t){n=r.left;break}let i=new Date(e);i.setMonth(e.getMonth()+1),i.setDate(0),i=i.getDate(),n=r.left+(e.getDate()-1)/i*r.width}break;case"month":{let i=new Date(o),a=new Date(o);i.setDate(i.getDate()-i.getDay()),a.setDate(a.getDate()+(6-a.getDay())+1),a.setMilliseconds(a.getMilliseconds()-1),e.getTime()>=i.getTime()&&e.getTime()<=a.getTime()&&(n=r.left+(t||t?0:e.getDay()/7*r.width));break}case"week":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&(n=r.left+parseFloat(e.getHours()+"."+e.getMinutes()+e.getSeconds())/24*r.width);break;case"day":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&o.getHours()===e.getHours()&&(n=r.left+(t?0:parseFloat(e.getMinutes()+e.getSeconds())/60*r.width))}if(void 0!==n)return i.scrollLeft=n,void(i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=i.$.resourceTimelineContent.scrollLeft=n,i._refreshResourceTimeline()))}}_updateConnection(e,t){const i=this,a=i._tasks,[n,s,r,o]=e,l=a[n],d=a[s];if(!l||!d||"number"!=typeof r)return;let c=i._connections,m=-1;c||(c=i._connections=[]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=t.startIndex,a=t.endIndex;if(i===n&&a===s||i===s&&a===n){m=e;break}}if(!t){if(m<0)c.push({startTask:a[n],endTask:a[s],startIndex:n,endIndex:s,type:r,lag:o});else{const e=c[m];if(!e)return;if(e.startIndex=n,e.startTask=a[n],e.endIndex=s,e.endTask=a[s],e.type=r,o!==e.lag){const t=parseInt(o);isNaN(t)||(e.lag=t)}}return!0}m>-1&&c.splice(m,1)}_createTimelineCells(){const e=this,t=e._tasks,i=new Date(e.properties.dateStart.value),a=new Date(e.properties.dateEnd.value);let n,s;if(isNaN(i.getTime())||(n=i),isNaN(a.getTime())||(s=a),t.length>0){let e=t[0].dateStart,i=t[0].dateEnd;for(let a=0;a<t.length;a++)t[a].dateStart&&t[a].dateEnd&&(e||(e=t[a].dateStart),i||(i=t[a].dateEnd),e.getTime()>t[a].dateStart.getTime()&&(e=t[a].dateStart),i.getTime()<t[a].dateEnd.getTime()&&(i=t[a].dateEnd));(!n||n.getTime()>e.getTime())&&(n=e),(!s||s.getTime()<i.getTime())&&(s=i)}if(n&&s){if(n=e._minMaxDateValidator(n),s=e._minMaxDateValidator(s),-1!==e.firstDayOfWeek){const t=n.getDay()-e.firstDayOfWeek,i=new Date(n.getTime());i.setDate(n.getDate()-n.getDay()+e.firstDayOfWeek-(t>=0?0:7)),n=i}e._createTimelineHeader(n,e._getCellsCount(n,s)),e._createTimelineContent(),e._createDateMarkers(),e._refresh()}}_getCellsCount(e,t,i){let a,n,s,r,o,l,d=new Date(e),c=new Date(t);const m=this,u=t.getFullYear()-e.getFullYear();if(n=a=Math.round(u)+1,"year"===i)return{year:n};if(d.setHours(d.getHours(),0,0,0),c.setHours(c.getHours(),0,0,0),l=Math.floor((t.getTime()-e.getTime())/36e5),l>0){let e=new Date(d);if(l=1,d.getFullYear()!==c.getFullYear()){let t=new Date(d.getFullYear()+1,0,1,0,0,0,0);for(;e.getTime()!==t.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}const i=c.getFullYear()-t.getFullYear();for(let t=0;t<i;t++){const t=e.getFullYear();l+=24*((t%100==0?t%400==0:t%4==0)?366:365)-1,e.setFullYear(t+1)}}for(;e.getTime()<c.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}}if("hour"===i)return{hour:l};if(d.setHours(0,0,0,0),c.setHours(23,59,59,999),o=a=Math.round((c.getTime()-d.getTime())/864e5),"day"===i)return{day:o};if(d.setDate(d.getDate()-d.getDay()),c.setDate(c.getDate()+6-c.getDay()),r=a=Math.round((c.getTime()-d.getTime())/6048e5),"week"===i){if(-1!==m.firstDayOfWeek){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}return{week:r}}if("month"===this.view&&"day"!==m.monthScale&&(0!==e.getDay()&&(e=new Date(e.setDate(e.getDate()-e.getDay()))),6!==t.getDay()&&(t=new Date(t.setDate(t.getDate()+6-t.getDay()))),-1!==m.firstDayOfWeek)){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}if(e.getFullYear()!==t.getFullYear()){a=12-e.getMonth();const i=t.getFullYear();for(let n=e.getFullYear()+1;n<=i;n++)a+=n===t.getFullYear()?t.getMonth()+1:12}else a=t.getMonth()-e.getMonth()+1;return s=Math.ceil(a),"months"===i?{month:s}:("day"===this.view&&0===l&&(l=1),{year:n,month:s,week:r,day:o,hour:l})}_recycleTaskBars(e,t,i){const a=this,n=e.task,s=a.$.timelineTasksContainer,r=a.$.taskTimelineCellsContainer,o="project"===n.type&&n.synchronized,l=n.type,d=n.$.id,c=s.children[t],m=r.children[t];m._cellObj=e,m.setAttribute("row-id",d),m.style.top=e.top+"px",m.removeAttribute("hover"),c.removeAttribute("hover"),c.classList.contains(l)||(c.innerHTML="milestone"===l?'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-task-connection-point end"></div>\n </div>':'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-timeline-task-progress-thumb"></div>\n <div class="smart-task-connection-point end"></div>\n </div>'),n.connectionType&&(n.connectionType.includes("start")||c.querySelector(".start").classList.add("smart-hidden"),n.connectionType.includes("end")||c.querySelector(".end").classList.add("smart-hidden")),a._recycleSegments(n,c),delete c._cellStart,delete c._cellEnd,n.disableDrag||o&&!n.dragProject?c.setAttribute("disable-drag",""):c.removeAttribute("disable-drag"),n.disableResize||o?c.setAttribute("disable-resize",""):c.removeAttribute("disable-resize"),n.isGroup?c.setAttribute("resource-group",""):c.removeAttribute("resource-group"),i&&(i.indexOf(d)>-1?(c.setAttribute("selected",""),m.setAttribute("selected","")):(c.removeAttribute("selected"),m.removeAttribute("selected"))),n.id?c.id=n.id:c.id="ganttTask"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),c._cellObj=e,c.className="smart-timeline-task "+l,c.setAttribute("row-id",d),n.class&&c.classList.add(n.class),c.setAttribute("aria-label",n.label+" Start date: "+a._toISODate(n.dateStart)+", End date: "+a._toISODate(n.dateEnd)),c.setAttribute("aria-selected","false")}_toISODate(e){const t=e.getFullYear(),i=e.getMonth()+1,a=e.getDate();return t+"-"+(i<10?"0"+i:i)+"-"+(a<10?"0"+a:a)}_recycleSegments(e,t){const i=this,a=t.querySelector(".smart-task-segments");let n,s=e.segments;if(!a)return;for(Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);a.childElementCount>s.length;)a.children[0].remove();const r=document.createDocumentFragment(),o=a.children,l="milestone"===e.type?'<div class="smart-timeline-task-fill"></div>':'<div class="smart-timeline-task-fill">\n <div class="smart-timeline-task-progress"></div>\n </div>\n <div class="smart-timeline-task-label"></div>';for(let t=0,a=s.length;t<a;t+=1){const a=s[t];let d=o[t];a.dateStart=new Date(Math.max(e.dateStart.getTime(),a.dateStart.getTime())),a.dateEnd=new Date(Math.min(e.dateEnd.getTime(),a.dateEnd.getTime())),d?(delete d._cellStart,delete d._cellEnd):(d=document.createElement("div"),d.classList.add("smart-task-segment"),d.innerHTML=l,r.appendChild(d)),a.disableDrag?d.setAttribute("disable-drag",""):d.removeAttribute("disable-drag"),a.disableResize?d.setAttribute("disable-resize",""):d.removeAttribute("disable-resize"),d._segmentObj=a,d.setAttribute("aria-label",(a.label||"")+" Start date: "+i._toISODate(a.dateStart)+", End date: "+i._toISODate(a.dateEnd)),n=d}r.childElementCount&&a.appendChild(r),i._setTaskBarDeadline(e,n)}_createCells(e){let t,i=document.createDocumentFragment();for(let a=0;a<e;a++)t=document.createElement("div"),t.classList.add("smart-timeline-view-cell"),t.setAttribute("role","columnheader"),i.appendChild(t);return i}_getTimelineVisibleCellsCount(){const e=this,t=e._timelineCells;if(!t)return;const i=e._getFirstCellObjInView();if(!i)return t.length;const a=1-(i.left+i.width-e.scrollLeft)/t[0].width;return Math.min(t.length,Math.ceil(parseFloat((e.$.timeline.offsetWidth/i.width).toFixed(2))+a))}_getHeaderVisibleCellsCount(){const e=this;if(!e._timelineHeaderCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_getHeaderSubVisibleCellsCount(){const e=this;if(!e._timelineHeaderSubCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderSubCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_refreshHeaderDate(e){const t=this,i=t._getCellsViewType(),a=t.$.timelineHeader.scrollLeft,n=t.$.timelineViewCells.children,s=t._timelineCells;let r;t._refreshHeaderSubDetailsDate(e),t._refreshHeaderDetailsDate(e);for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=n[a],l=s[r];if(!l)break;r++;const d=l.date;o.innerHTML=`<div>${t._getDateString(new Date(d),i)}</div>`,e||(o._date=new Date(d),o.setAttribute("date",d.toLocaleDateString()),o.style.width=l.width+"px",o.style[t.rightToLeft?"right":"left"]=l.left+"px",l.weekend?o.setAttribute("weekend",""):o.removeAttribute("weekend"),l.nonworking?o.setAttribute("nonworking",""):o.removeAttribute("nonworking"))}}_getDateString(e,t,i){const a=this,n=["2-digit","numeric"][a.dayFormat]||"numeric";let s;if("year"===t||"quarter"===t)s=e.toLocaleDateString(a.locale,{year:a.yearFormat});else if("month"===t)s=e.toLocaleDateString(a.locale,{month:a.monthFormat}),"month"===a.view&&(s+=" "+e.toLocaleDateString(a.locale,{year:a.yearFormat}));else if("week"===t)s="numeric"!==a.weekFormat&&i?e.toLocaleDateString(a.locale,{day:n,month:a.monthFormat,year:a.yearFormat}):a._getWeekNumber(e);else if("day"===t)s="month"===a.view?"numeric"!==a.dayFormat&&"2-digit"!==a.dayFormat?e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:a.dayFormat}):e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:"short"}):e.toLocaleDateString(a.locale,"day"===a.view?{day:n,month:a.monthFormat,year:a.yearFormat}:["long","short","narrow"].indexOf(a.dayFormat)>-1?{weekday:a.dayFormat}:{day:a.dayFormat});else if("hour"===t)if(s="default"===a.hourFormat?e.toLocaleTimeString(a.locale,{hour12:!1}):e.toLocaleDateString(a.locale,{hour:a.hourFormat}),"default"!==a.hourFormat)s.indexOf(",")>=0&&(s=s.substring(s.indexOf(",")+1).trim());else if(s.indexOf(":")!==s.lastIndexOf(":")&&s.indexOf(":")>=0){let e=s.toLowerCase().indexOf("am")>=0?" AM":"";e=s.toLowerCase().indexOf("pm")>=0?" PM":e,s=s.substring(0,s.lastIndexOf(":"))+e}return a.timelineHeaderFormatFunction?a.timelineHeaderFormatFunction(new Date(e),t,i,s):s}_refreshHeaderSubDetailsDate(e){const t=this,i=(t.view,t.scrollLeft),a=t.$.timelineViewSubDetails.children,n=t._timelineHeaderSubCells;let s;if(t.$.timelineViewSubDetails.classList.contains("smart-hidden"))return;for(let e=0;e<n.length;e++){const t=n[e];if(i<=t.left+t.width){s=e;break}}let r=[],o=0;for(let i=0;i<a.length;i++){const l=n[s],d=a[i];if(!l)continue;let c=new Date(l.date);"week"===t.view&&c.setDate(c.getDate()-c.getDay()),s++,c=new Date(Math.max(l.date.getTime(),c.getTime()));const m=e=>{var i,a=e.getMonth();return i=a>=9?4:a>=6?3:a>=3?2:1,"long"===t.quarterFormat?t.localize("quarter")+" "+i:"numeric"===t.quarterFormat?i:t.localize("quarterShort")+i};let u="";"quarter"===t.view||"year"===t.view?(u=m(c),"quarter"===t.view&&t.hideTimelineSecondHeaderDetails&&(u+=" "+c.getFullYear())):"month"===t.view&&(-1===t.firstDayOfWeek?u=t._getWeekNumber(c):((c.getDay()-t.firstDayOfWeek)%7==0&&i>0&&o++,u=o));const h=u+"_"+c.getFullYear();r[h]||(r[h]=[]),d.classList.remove("smart-visibility-hidden"),r[h].push({element:d,cell:l}),d.innerHTML=`<div>${u}</div>`,d.classList.add("middle"),e||(d._date=c,d.style[t.rightToLeft?"right":"left"]=l.left+"px",d.style.width=l.width+"px")}for(let e in r){const i=r[e];let a=0;for(let e=0;e<i.length;e++)a+=i[e].cell.width;if(i[0].element.style.width=a+"px","year"===t.view){const e=i[0].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat}),a=i[i.length-1].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat});i.length>1?i[0].element.innerHTML=`<div>${e}-${a}</div>`:i[0].element.innerHTML=`<div>${e}</div>`}else if("month"===t.view){const e="numeric"!==t.dayFormat&&"2-digit"!==t.dayFormat?t.dayFormat:"short",a=i[0].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[0].cell.date.toLocaleDateString(t.locale,{weekday:e}),n=i[i.length-1].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[i.length-1].cell.date.toLocaleDateString(t.locale,{weekday:e});i.length>1?i[0].element.innerHTML=`<div>${a}-${n}</div>`:i[0].element.innerHTML=`<div>${a}</div>`,"numeric"===t.weekFormat&&(i[0].element.innerHTML=t._getWeekNumber(i[0].cell.date))}if(t.timelineHeaderFormatFunction){const e=t.timelineHeaderFormatFunction(new Date(i[0].cell.date),t.view,!0,i[0].element.innerHTML);i[0].element.innerHTML!==e&&(i[0].element.innerHTML=e)}for(let e=1;e<i.length;e++)i[e].element.classList.add("smart-visibility-hidden")}}_refreshHeaderDetailsDate(e){const t=this,i=t.view,a=t.scrollLeft,n=t.$.timelineViewDetails.children,s=t._timelineHeaderCells;let r;for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=s[r],l=n[a];let d=new Date(o.date);if("week"===t.view)if(-1!==t.firstDayOfWeek){const e=d.getDay()-t.firstDayOfWeek;d.setDate(d.getDate()-d.getDay()+t.firstDayOfWeek-(e>=0?0:7))}else d.setDate(d.getDate()-d.getDay());r++,d=new Date(Math.max(o.date.getTime(),d.getTime())),l.innerHTML=`<div>${t._getDateString(d,i,!0)}</div>`,e||(l._date=d,l.style[t.rightToLeft?"right":"left"]=o.left+"px",l.style.width=o.width+"px")}}_getWeekNumber(e){let t,i=new Date(e.getFullYear(),0,1),a=Math.round((e.getTime()-i.getTime()-6e4*(e.getTimezoneOffset()-i.getTimezoneOffset()))/864e5)+1,n=i.getDay();return n=n>=0?n:n+7,n<4?(t=Math.floor((a+n-1)/7)+1,t>52&&(i=new Date(e.getFullYear()+1,0,1),n=i.getDay(),n=n>=0?n:n+7,t=n<4?1:53)):t="week"===this.view?function(e){var t=new Date(e.valueOf()),i=(e.getDay()+6)%7;t.setDate(t.getDate()-i+3);var a=t.valueOf();return t.setMonth(0,1),4!==t.getDay()&&t.setMonth(0,1+(4-t.getDay()+7)%7),1+Math.ceil((a-t)/6048e5)}(e):Math.round((a+n-1)/7),t}_convertDuration(e,t){if(!e)return 0;let i;switch(this.durationUnit){case"day":i=864e5;break;case"hour":i=36e5;break;case"minute":i=6e4;break;case"second":i=1e3;break;case"milisecond":return e;case"week":i=6048e5}return Math.max(0,t?e/i:e*i)}_createTimelineHeader(e,t){const i=this,a=i._getCellsViewType();if(!e){const t=i.$.timelineViewCells.children;if(0===t.length)return;e=t[0]._date}if("day"!==i.view&&e.setHours(0,0,0,0),i.$.timelineContent.offsetWidth===i.$.timeline.offsetWidth&&i._timelineCells&&i._timelineCells[0]&&i._timelineCells[0].date.getTime()===e.getTime()&&i._timelineCells.length===t[i._getCellsViewType()])return void i._refresh();i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width="",i._createTimelineCellsObj(e,t),i._createTimelineHeaderCellsObj(e,t),i._createTimelineHeaderSubCellsObj(e,t),i.$.timelineViewDetails.innerHTML="",i.$.timelineViewDetails.appendChild(i._createCells(i._getHeaderVisibleCellsCount())),i.$.timelineViewSubDetails.innerHTML="",i.$.timelineViewCells.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.classList.add("smart-hidden");let n=2;"quarter"===i.view?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(i._getTimelineVisibleCellsCount()))):"month"===i.view&&"day"===i.monthScale?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.day))):"year"===i.view&&(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.month))),i.hideTimelineHeader&&(i.$.timelineViewCells.classList.add("smart-hidden"),n--),i.hideTimelineHeaderDetails&&(i.$.timelineViewDetails.classList.add("smart-hidden"),n--),i.hideTimelineSecondHeaderDetails&&("quarter"===i.view?i.$.timelineViewDetails.classList.add("smart-hidden"):i.$.timelineViewSubDetails.classList.add("smart-hidden"),("year"===i.view||"month"===i.view&&"day"===i.monthScale||"quarter"===i.view)&&n--),i.$.taskTable.style.setProperty("--smart-table-column-header-height","calc("+n+" * var(--smart-gantt-chart-task-default-height) - calc("+n+" * var(--smart-border-width) / "+n+"))"),i.$.timelineViewCells.innerHTML="",i.$.timelineViewCells.appendChild(i._createCells(i._getTimelineVisibleCellsCount()));let s=t[a];if("hour"===a&&("halfHour"===i.dayScale?s*=2:"quarterHour"===i.dayScale&&(s*=4)),i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width=Math.max(s*i._timelineCells[0].width,i.$.timeline.parentElement.offsetWidth)+"px",i.scrollLeft){const e=i._getScrollLeft(i.scrollLeft);i.$.timelineHeader.scrollLeft=e,i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=e)}i._refreshHeaderDate(),i._setCurrentTimeIndicators()}_createTimelineContent(){const e=this,t=e.$.container,i=e.$.timelineContent,a=e._taskDefaultHeight,n=e.$.taskTimelineContainer,s=e.scrollLeft;if(i.style.height="",t.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e._createTimelineVCells(a),i.style.height=e._timelineVCells.length*a+"px",t.style.setProperty("--smart-gantt-chart-task-timeline-content-height",e.$.timeline.offsetHeight+"px"),s||s!==n.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);n.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=t)}e.scrollTop&&(n.scrollTop=e.scrollTop),e._recycleContentCells()}_createDateMarkers(){const e=this,t=e.dateMarkers;let i=[];delete e._markers;for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e._dateValidator(void 0,n.date);if(s){const e={date:s},t=n.label,a=n.className;("string"==typeof t||"number"==typeof t&&!isNaN(t))&&(e.label=t),"string"==typeof a&&(e.className=a),i.push(e)}}i.length&&(e._markers=i),e._recycleDateMarkers()}_createTimelineRowCells(e,t){const i=this,a=e.children,n=e.querySelectorAll(".smart-task-bar-limiter"),s=document.createDocumentFragment(),[r,o]=i.rightToLeft?["right","left"]:["left","right"];t||(t=i.$.timelineViewCells.children);for(let e=0,t=n.length;e<t;e+=1)n[e].remove();const l=t.length;for(;e.childElementCount>l;)e.lastElementChild.remove();for(let t=e.childElementCount;t<l;t+=1){const e=document.createElement("div");e.classList.add("smart-timeline-cell"),s.appendChild(e)}s.childElementCount&&e.appendChild(s);for(let e=0;e<l;e+=1){const i=t[e],n=a[e];i.hasAttribute("weekend")?n.setAttribute("weekend",""):n.removeAttribute("weekend"),i.hasAttribute("nonworking")?n.setAttribute("nonworking",""):n.removeAttribute("nonworking"),n.style[o]=i.style[o],n.style[r]=i.style[r],n.style.width=i.style.width}for(let t=0,i=n.length;t<i;t+=1)e.appendChild(n[t])}_recycleTimelineRowCells(){const e=this,t=e.$.timelineViewCells.children,i=e.$.taskTimelineCellsContainer.children;for(let a=0,n=i.length;a<n;a+=1)e._createTimelineRowCells(i[a],t)}_createTimelineVCells(e){const t=this,i=t._tasks,a=t.$.taskTable.rows,n=t.groupByResources;let s=0,r={};t._timelineVCells=[];for(let o=0,l=a.length;o<l;o++){const l=a[o].data;let d=i[l.itemIndex];if(n)if(!d&&l.groupDataField){const e=l.$.id;d={$:{id:e,project:void 0},label:t._formatResourceGroupLabel(l.label),value:l.label,expanded:l.expanded,synchronized:!0,isGroup:!0,type:"project"},r[e]=d}else l.parent?(d.$.group=r[l.parent.$.id],t._synchronizeProjectDates(d.$.group,[d])):delete d.$.group;else delete d.$.group;!d.hidden&&t._isTaskExpanded(d)&&(t._timelineVCells.push({top:s,height:e,task:d}),s=parseFloat((s+e).toFixed(2)))}}_getCellsViewType(){const e=this;switch(e.view){case"quarter":case"year":return"month";case"month":return"day"===e.monthScale?"day":"week";case"week":return"day";case"day":return"hour"}}_dateAdd(e,t,i){if(e instanceof Date){var a=new Date(e),n=function(){a.getDate()!==e.getDate()&&a.setDate(0)};switch(String(t).toLowerCase()){case"year":a.setFullYear(a.getFullYear()+i),n();break;case"quarter":a.setMonth(a.getMonth()+3*i),n();break;case"month":a.setMonth(a.getMonth()+i),n();break;case"week":a.setDate(a.getDate()+7*i);break;case"day":a.setDate(a.getDate()+i);break;case"hour":a.setTime(a.getTime()+36e5*i);break;case"minute":a.setTime(a.getTime()+6e4*i);break;case"second":a.setTime(a.getTime()+1e3*i);break;default:a=void 0}return a}}_createTimelineCellsObj(e,t){const i=this,a=i._getCellsViewType();t=t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderSubCellsObj(e,t){const i=this,a=i._getCellsViewType();t="month"===i.view&&"day"===i.monthScale?t.day:t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineHeaderSubCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineHeaderSubCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderCellsObj(e,t){const i=this;let a=i.view,n=0,s=new Date(e);"quarter"===a&&(a="year"),t=t[a],i._timelineHeaderCells=[];for(let e=0;e<t;e++){const t={};switch(t.date=new Date(s),a){case"quarter":case"year":s.setFullYear(s.getFullYear()+1);break;case"month":s.setDate(1),s.setMonth(s.getMonth()+1);break;case"week":s.setDate(s.getDate()+7);break;case"day":s.setDate(s.getDate()+1)}n=i._refreshViewDetailCell(t,n,e),i._timelineHeaderCells.push(t)}}_minMaxDateValidator(e){if(!e||isNaN(e.getTime()))return e;const t=new Date(this.min),i=new Date(this.max);return t&&(e=new Date(Math.max(t.getTime(),e.getTime()))),i&&(e=new Date(Math.min(i.getTime(),e.getTime()))),e}_dateValidator(e,t){const i=this;let a;if(t instanceof Date)return i._minMaxDateValidator(t);if(Smart.Utilities.DateTime&&t instanceof Smart.Utilities.DateTime)return i._minMaxDateValidator(t.toDate());if("string"!=typeof t)return i._minMaxDateValidator(e);{const e=/\d+:\d+:\d+/;if("new Date()"===t.trim()||"new Smart.Utilities.DateTime()"===t.trim())return i._minMaxDateValidator(new Date);if(isNaN(Date.parse(t))){const i=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;if(i.test(t)){const n=i.exec(t)[0].replace(/[,-.\/]/g,",").split(",");if(3===n.length){const[i,s]=parseInt(n[0])<parseInt(n[2])?[n[0],n[2]]:[n[2],n[0]];if(a=new Date(parseInt(s),parseInt(n[1])-1,parseInt(i)),e.test(t)){const i=e.exec(t)[0].split(":");a.setHours(i[0]||0,i[1]||0,i[2]||0)}t=a}}}else a=new Date(Date.parse(t)),e.test(t)||a.setHours(0,0,0,0),t=a}return i._minMaxDateValidator(new Date(t))}_currentTimeIndicatorIntervalValidator(e,t){return Math.max(1,t)}_getTaskBarPositionLimits(e,t){const i=this;function a(e){const t=i._getTimelineTaskCellByDate(e);if(t)return t.left+i._getTimelineTaskOffset(t,e)||0}return{min:a(e["min"+t]),max:a(e["max"+t])}}_getTimelineTaskOffset(e,t){if(!e)return;let i,a;switch(this.view){case"quarter":case"year":{const n=t.getHours()/24+t.getMinutes()/1440+t.getSeconds()/86400;i=new Date(e.date.getFullYear(),e.date.getMonth()+1,0),a=(t.getDate()-1+n)/i.getDate()*e.width;break}case"month":a=t.getDay()/7*e.width;break;case"week":a=parseFloat(t.getHours()+t.getMinutes()/60+t.getSeconds()/3600)/24*e.width;break;case"day":a=parseFloat(t.getMinutes()+t.getSeconds()/60)/60*e.width}return a}_getTaskBarSizeLimits(e,t){const i=this,a=i._getTaskBarDateRange(e);let n,s=0,r=i._convertDuration(e._cellObj.task.minDuration)||i._getMinDuration(e,t),o=i._convertDuration(e._cellObj.task.maxDuration);function l(n,s){if(!n)return;let r,o;"left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft?(n*=-1,o=a.dateEnd):o=a.dateStart,s&&Math.abs(r)===Math.abs(n)&&(r=0);let l=i._getTaskWorkingDateEnd({dateStart:o},n);const d=l.getTime()+60*(l.getTimezoneOffset()-o.getTimezoneOffset())*1e3,c=i._getTimelineTaskCellByDate(new Date(d));if(!c)return;const m=i._getTimelineTaskOffset(c,new Date(d));return i.rightToLeft?"left"===t?m-(i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth-c.left):i.$.timelineContent.offsetWidth-e.offsetLeft-c.left-m:"left"===t?e.offsetLeft+e.offsetWidth-c.left-m:c.left-e.offsetLeft+m}if("left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft){const t=e._cellObj.task.maxDateStart,i=e._cellObj.task.minDateStart;i&&(s=60*(i.getTimezoneOffset()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateEnd.getTime())+s,o=o?Math.min(n,o):n),t&&(s=60*(t.getTimezoneOffset()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateEnd.getTime())+s,r=r?Math.max(n,r):n)}else{const t=e._cellObj.task.maxDateEnd,i=e._cellObj.task.minDateEnd;i&&(s=60*(i.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateStart.getTime())+s,r=r?Math.max(n,r):n),t&&(s=60*(t.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateStart.getTime())+s,o=o?Math.min(n,o):n)}return o&&(r=Math.min(r,o)),{min:l(r,!0),max:l(o)}}_getMinDuration(e,t){const i=this,a=i._taskBarMinWidth;if(!a||!i._timelineCells||0===i._timelineCells.length)return;const n=e._cellObj.task;let s,r,o=1;r=i.rightToLeft?parseFloat(e.style.right)||i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth:parseFloat(e.style.left)||e.offsetLeft,"left"===t?(s=n.dateEnd,r+=parseFloat(e.style.width)||e.offsetWidth,o=-1):s=n.dateStart;const l=r+o*a;let d;for(let e=0;e<i._timelineCells.length;e++){const t=i._timelineCells[e];if(l<t.left)break;d=t}const c=i._getDateFromCell(l,d);return c?Math.abs(s.getTime()-c.getTime()):void 0}_createDelimiter(e,t){const i=this,a=i._dragDetails,n=a.segment,s=e.slice(0,3),r=document.createElement("div");if(r.classList.add("smart-task-bar-limiter",e),e.indexOf("date")>-1){if(!a[s]||!a[s].left)return;const[e,t]=n?[n.element,n.originalPosition.x]:[a.timelineTask,0],o=i.$.taskTimelineCellsContainer.children[i._getTaskDOMIndex(a.task)];s.indexOf("max")>-1?r.style.width=o.offsetWidth-a[s].left-t-e.offsetWidth+"px":r.style.width=a[s].left+t+"px"}else{if(!a[s].width)return;r.style["left"===t?"right":"left"]=a[s].width+"px"}return r}_doubleClickHandler(e){const t=this;let i=e.target;if(t.disabled||t.disableWindowEditor)return;t.shadowRoot&&i===t&&(i=e.composedPath()[0]);let a=i.closest?i.closest(".smart-task-connection"):void 0;if(a)t._openPopupWindow(a);else if(a=i.closest(".smart-timeline-task")||i.closest(".smart-table tbody tr[row-id]"),a&&t.$.taskSplitter.contains(a))if(a.classList.contains("smart-timeline-task"))t._openPopupWindow(a._cellObj.task);else{const e=t._getVCellById("task",a.getAttribute("row-id"));e&&t._openPopupWindow(e.task)}}_checkDoubleClick(e){const t=this;let i=e.target;if(t.shadowRoot&&i===t&&(i=e.composedPath()[0]),void 0===t._dblClickDetails&&(t._dblClickDetails={clicks:0}),clearTimeout(t._dblClickDetails.timeOut),i!==t._dblClickDetails.target&&(t._dblClickDetails.clicks=0),t._dblClickDetails.target=i,t._dblClickDetails.clicks++,t._dblClickDetails.timeOut=setTimeout((function(){t._dblClickDetails&&(t._dblClickDetails.clicks=0)}),250),2===t._dblClickDetails.clicks)return t._doubleClickHandler(e),t._dblClickDetails.clicks=0,!0}_downHandler(e){const t=this,i=e.originalEvent,a=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target,n=a.closest?a.closest(".smart-timeline-row")||a.closest(".smart-timeline-task"):null;if(e.stopPropagation(),delete t._itemClickDetails,t._dragDetails)return delete t._dragDetails,void t._setConnectionFeedback();const s=t.$.taskSplitter.contains(a)?"task":"resource";if((a.closest(".smart-timeline-content")||a.closest(`.smart-${s}-table`))&&requestAnimationFrame((()=>t.$[`${s}Table`].focus({preventScroll:!0}))),t._itemClickDetails={target:a},!t._isMobile&&0!==e.button)return;if(!n){if(a.classList.contains("smart-popup-window-modal")){if(t._popupWindow){const e=Object.keys(t._popupWindow);requestAnimationFrame((()=>t._popupWindow[e[e.length-1]].focus()))}return}return void((a.closest(".smart-table tbody tr[row-id]")&&!a.classList.contains("smart-arrow")||a.closest(".smart-task-connection"))&&t._checkDoubleClick(i))}if(a.closest(".smart-resource-timeline-view-cell")||t.disabled)return;const r=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===n._cellObj.task));if(!r)return;const o=r._cellObj.task;if(!o)return;const l=t.$.timeline.getAttribute("task-bar-hovered");if(r.getElementsByClassName("smart-timeline-task-fill")[0]||l){if((a.closest(".smart-timeline-task-fill")||r.classList.contains("milestone")&&a.closest(".smart-task-container"))&&t._checkDoubleClick(i))return;const n=a.closest(".smart-timeline-task-progress-thumb"),s=e.pageX-window.pageXOffset,d=e.pageY-window.pageYOffset,c=t._dragDetails={},m=t.rightToLeft;let u,h=a.closest(".smart-task-segment");if(l&&!h){const e=r.querySelectorAll(".smart-task-segment");c.segments=e,h="left"===l&&!m||"right"===l&&m?e[0]:e[e.length-1]}if(c.target=(n||a).className,c.timelineTask=r,c.task=r._cellObj.task,c.taskDimensions={width:r.offsetWidth,height:r.offsetHeight,left:r.offsetLeft,top:r.offsetTop},c.coordinates={x:s,y:d},!e.ctrlKey&&h&&o.segments&&o.segments.length>1&&!t.disableSegmentDrag){const e=h.getBoundingClientRect(),t=h._segmentObj,i=c.task.segments,a=i.indexOf(t);c.segment={element:h,dimensions:{width:e.width,left:h.offsetLeft},offset:{x:s-e.left},originalSize:{width:e.width},isFirstSegment:0===a,isLastSegment:a===i.length-1,min:{},max:{}},u=c.segment.dimensions}const g=c.taskDimensions;t.rightToLeft?(g.right=t.$.timelineContent.offsetWidth-(g.left+g.width),c.originalPosition={x:g.right,y:g.top},c.segment&&(u.right=g.width-(u.left+u.width),c.segment.originalPosition={x:u.right})):(c.originalPosition={x:g.left,y:g.top},c.segment&&(c.segment.originalPosition={x:u.left}));const f=(n||r).getBoundingClientRect();if(c.offset={x:s-f.left,y:d-f.top},c.originalSize={width:g.width,height:g.height},n||!n&&"project"===o.type&&o.synchronized&&!o.dragProject)return void(a.closest(".smart-task-connection-point")&&(c.timelineTask=void 0,c.relatedConnections={}));("visible"===t.resizeHandlesVisibility||t._isMobile&&"auto"===t.resizeHandlesVisibility)&&(a.closest(".smart-timeline-task-fill")?t._checkTaskBarResizability(e):t.$.timeline.removeAttribute("task-bar-hovered")),c.min={},c.max={},t._setDragLimits(a)}}_documentMoveHandler(e){const t=this;if(!t._dragDetails||!t._dragDetails.target){let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const a=i.closest&&i.closest(".smart-table tbody tr[row-id]");return a&&a.data?t._handleTableItemHover(a.data.itemId,i):t._handleTimelineHover(e),t._checkTaskBarResizability(e),void t._toggleTooltip(e.originalEvent)}if(t._dragDetails.target.includes("smart-task-connection-point"))return t._setConnectionFeedback(e),t._handleTimelineHover(e),void t._autoScroll(e);if(t._dragDetails.target.includes("smart-timeline-task-progress-thumb"))t._handleTaskProgressChange(e);else if(t._autoScroll(e),!t._autoScrolling)if(t.$.timeline.hasAttribute("task-bar-hovered"))t._handleTaskBarResize(e);else if(t._dragDetails.target.includes("smart-timeline-task-fill")){const i=t._dragDetails.task;if(!i||i.disableDrag||"project"===i.type&&i.synchronized&&!i.dragProject)return;t._handleTaskBarDrag(e)}}_documentUpHandler(e){const t=this,i=e.originalEvent;let a=i.target;if(t._upHandler(),!t._dragDetails)return void t._handleItemClick(i);if(t._scrollView.disableSwipeScroll=t._touchmoveInside=!1,t.shadowRoot&&a===t&&(a=i.composedPath()[0]),t.hasAttribute("connecting-task")){const i=t._connectTask(e),a=t._tasks;if(t._setConnectionFeedback(),i){const e=i.taskStart,n=i.taskEnd,[s,r,o]=[a.indexOf(i.taskStart),a.indexOf(i.taskEnd),i.type];t.$.fireEvent("connectionEnd",{id:`${s}-${r}-${o}`,startIndex:s,startTaskId:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,endIndex:r,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,type:o}),t._autoSchedule(i.taskStart)}return t._isMobile&&t._handleTimelineHover(e,!0),void delete t._dragDetails}const n=t._dragDetails.task;if(!n)return void delete t._dragDetails;let s;const r=t._dragDetails.segment?t._dragDetails.segment.element:void 0;if(s||(s=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===n))),t.hasAttribute("dragged")){t._snapToNearest(s,r),r||t._checkWorkingDays(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._autoSchedule(n),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n)):(t.snapToNearest||t.nonworkingDays.length>0||t.nonworkingHours.length>0)&&t._refreshAssignedResources(n),t.removeAttribute("dragged");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:new Date(n.dateStart),dateEnd:new Date(n.dateEnd)};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("dragEnd",e)}else if(t.hasAttribute("progress-change"))t._resourceTreeRefreshTimeout&&(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n,["progress"])),t.removeAttribute("progress-change"),t.$.fireEvent("progressChangeEnd",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),progress:n.progress||0});else if(t.hasAttribute("resized")){t._snapToNearest(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n,["workload"])):t.snapToNearest&&t._refreshAssignedResources(n,["workload"]),t.removeAttribute("resized");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("resizeEnd",e),t._autoSchedule(n)}else a.closest(".smart-timeline-task")===s&&(t._select("task",n.$.id,!0),delete t._dragDetails,t._handleItemClick(i));const o=t.$.timelineContent.querySelectorAll(".smart-task-bar-limiter");for(let e=0,t=o.length;e<t;e+=1)o[e].remove();delete t._dragDetails}_handleItemClick(e){const t=this,i=e.target;if(t._dragDetails||!t._itemClickDetails||t._itemClickDetails.target!==i)return void delete t._itemClickDetails;let a,n,s;if(i.closest(".smart-timeline-task-fill"))n=i.closest(".smart-timeline-task")._cellObj.task,s="task";else if(a=i.closest(".smart-task-connection"),a)n=a.getAttribute("connection-id").split("-"),n={source:n[0],target:n[1],type:n[2]},s="connection";else if(i.closest(".milestone"))n=i.closest(".milestone")._cellObj.task,s="milestone";else if(a=i.closest(".smart-table tbody tr"),a){const e=t._getVCellById(s,a.getAttribute("row-id"));s=t.$.taskTable.contains(a)?"task":"resource",n=e?e[s]:void 0}if(!n)return;const r={originalEvent:e,type:s,item:t._cloneObject(n)};r.id="connection"===s?`${n.source}-${n.target}-${n.type}`:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,delete t._itemClickDetails,t.$.fireEvent("itemClick",r)}_moveHandler(e){const t=this;t._isMobile||e.stopPropagation(),(t.hasAttribute("dragged")||t.hasAttribute("progress-change"))&&"touchmove"===e.originalEvent.type&&e.originalEvent.preventDefault()}_handleTableItemHover(e,t){const i=this,a=i._hoveredItem;let n,s;if(t&&([n,s]=i.$.taskSplitter.contains(t)?[i.$.taskTable,"task"]:[i.$.resourceTable,"resource"]),a&&"itemType"===a.type&&a.id===e)return;const r=i.$.mainSplitter.querySelectorAll("table tbody tr[hover]");for(let e=0;e<r.length;e++)r[e].removeAttribute("hover");if(void 0===e)return void i._handleTimelineHover({target:i});if(!n)return;i._setTableHoverState(n,e);const o=i.$["task"===s?"taskTimelineCellsContainer":"resourceTimelineCellsContainer"].children;for(let t=0,a=o.length;t<a;t+=1){const a=o[t];if(a._cellObj[s].$.id===e){i._handleTimelineHover({target:a});break}}}_setTableHoverState(e,t){const i=this;e||(e=i.$.taskTable);const a=e===i.$.taskTable?"task":"resource",n=e.querySelectorAll("table tbody tr");if(!i._isMobile&&i[a+"Columns"].length)for(let e=0;e<n.length;e++){let i=n[e];const a=i.data;a&&a.itemId===t&&i.setAttribute("hover","")}}_checkWorkingDays(e){const t=this,i=t._dragDetails;if(!(i&&i._taskDuration||t._timelineCells.length))return;if(!e.classList||!e.classList.contains("smart-timeline-task")||!t.hasAttribute("dragged")||0===t.nonworkingDays.length&&0===t.nonworkingHours.length||!i||!i._taskDuration)return;const a=e._cellObj,n=a.task,s=t._getTaskWorkingDateEnd(n),r=n.segments;let o=new Date(t._timelineCells[t._timelineCells.length-1].date);if("year"===t.view||"quarter"===t.view?(o.setMonth(o.getMonth()+1),o.setDate(0),o.setHours(23,59,59,999)):"month"===t.view?(o.setDate(o.getDate()+6-o.getDay()),o.setHours(23,59,59,999)):"week"===t.view?o.setHours(23,59,59,999):o.setHours(o.getHours(),59,59,999),s&&(n.dateEnd=n.maxDateEnd?new Date(Math.min(s.getTime(),n.maxDateEnd.getTime())):s),n.dateEnd=new Date(Math.min(o.getTime(),n.dateEnd.getTime())),n.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n.dateStart,n.dateEnd):n.dateEnd.getTime()-n.dateStart.getTime(),!0),r&&r.length>1){for(let e=0,i=r.length;e<i;e+=1)t._snapToNearestDates(r[e],!0);t._validateTaskSegments(n),n.segments.length!==r.length&&t._recycleSegments(n,e),t._setTaskBarSegments(a,e,!0),t._setTaskBarProgress(n)}t._setTimelineTaskBar(a,void 0,!0),t._refreshTaskConnections(a.task),t._refreshTableColumnsData(n,["dateEnd","duration","overdue"])}_getTaskWorkingDateEnd(e,t){const i=this;if(!e||!e.dateStart)return;let a,n,s=new Date(e.dateStart);if(t||(t=i._dragDetails?i._dragDetails._taskDuration:i._getWorkingTime(e.dateStart,e.dateEnd)),!i.adjustToNonworkingTime)return new Date(e.dateStart.getTime()+t);const r=t<0?-1:1,o=i.nonworkingDays,l=i.nonworkingHours;for(t=Math.abs(t);t>0;){const e=Math.min(t,36e5-(60*s.getMinutes()*1e3+1e3*s.getSeconds()+s.getMilliseconds()));if(o.indexOf(s.getDay())>-1)n=new Date(s),n.setHours(0,0,0,0),n.setDate(s.getDate()+1*r),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a);else if("day"===i.view&&l.indexOf(s.getHours())>-1){n=new Date(s);const t=n.getTime();n.setHours(s.getHours()+1*r,0,0,0),t===n.getTime()&&n.setHours(s.getHours()+2*r,0,0,0),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a)}else t-=e,s=new Date(s.getTime()+r*e)}return s}_createConnectingElement(e,t,i,a,n){const s=this;if(!s._connectionDetails||!s._connectionDetails.start)return;const r=s._connectionDetails,o=r.type,l=s.$.timelineConnectionsContainer;let d=r.connections.shift();d||(d=document.createElement("div"),d.classList.add("smart-task-connection")),d.style.width=d.style.width="","horizontal"===a?(d.style.width=Math.abs(i)+"px",d.style.height=""):(d.style.width="",d.style.height=Math.abs(i)+"px"),d.style[s.rightToLeft?"left":"right"]="",d.style[s.rightToLeft?"right":"left"]=e+"px",d.style.top=t+"px",d.setAttribute("connection-id",r.id);const c=r.start.task.label,m=0===o||3===o?"start":"end",u=r.end.task.label,h=0===o||1===o?"start":"end";if(d.setAttribute("aria-label","Connection between "+c+" ("+m+") and "+u+" ("+h+")"),n){let e=0===o||1===o?"right":"left";s.rightToLeft&&(e="left"===e?"right":"left"),d.setAttribute("arrow-direction",e)}else d.removeAttribute("arrow-direction");d.parentElement||l.appendChild(d)}_getConnectionType(e,t){if(!e||!t)return;let i,a;return"string"==typeof e?i=!e.includes("end"):e instanceof HTMLElement&&(i=!e.classList.contains("end")),"string"==typeof t?a=t.includes("end"):t instanceof HTMLElement&&(a=t.classList.contains("end")),i&&!a?0:i||a?!i&&a?2:i&&a?3:void 0:1}_setConnectionFeedback(e){const t=this,i=t._dragDetails;if(!i||!i.target||!e){const e=t._connectionFeedback;return e&&e.parentElement&&e.remove(),t.removeAttribute("connecting-task"),void delete t._connectionFeedback}if(!i.target||!i.target.includes("smart-task-connection-point"))return;const a=i.task,n=i.taskDimensions;if(!a)return;if(!t.hasAttribute("connecting-task")){if(t.$.fireEvent("connectionStart",{startIndex:t._tasks.indexOf(a)}).defaultPrevented)return void delete t._dragDetails.target;t.setAttribute("connecting-task",""),t._isMobile&&(t._scrollView.disableSwipeScroll=t._touchmoveInside=!0)}const s="milestone"===a.type,r=t.rightToLeft;let o=s?-1*n.height/2:0;t._dragDetails.target.includes("end")&&(o=s?-1*o:n.width),t._connectionFeedback||(t._connectionFeedback=document.createElement("div"),t._connectionFeedback.classList.add("smart-task-connection-feedback"));const l=t._dragDetails.coordinates.x+(r?-1:1)*o,d=t._dragDetails.coordinates.y,c=t._dragDetails.offset.x-(r?n.width:0),m=t._dragDetails.offset.y,u=e.pageX-window.pageXOffset+c,h=e.pageY-window.pageYOffset+m-n.height/2;r?(t._connectionFeedback.style.left="",t._connectionFeedback.style.right=n.right+o+"px"):(t._connectionFeedback.style.left=n.left+o+"px",t._connectionFeedback.style.right=""),t._connectionFeedback.style.top=n.top+n.height/2+"px",t._connectionFeedback.style.width=Math.sqrt(Math.pow(Math.abs(u-l),2)+Math.pow(Math.abs(h-d),2))+"px",t._connectionFeedback.style.transform=t.rightToLeft?"rotate("+180*(Math.atan2(d-h,l-u)||0)/Math.PI+"deg)":"rotate("+180*(Math.atan2(h-d,u-l)||0)/Math.PI+"deg)",t._connectionFeedback.parentElement||t.$.timelineContent.appendChild(t._connectionFeedback)}_connectTask(e){const t=this,i=t._tasks;let a,n,s,r,o,l,d,c,m;if(e.originalEvent){const r=e.originalEvent;let o=t._isMobile?document.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.target;if(!(t._dragDetails&&t._dragDetails.target&&o&&o.classList))return;if(t.shadowRoot&&o===t&&(o=t._isMobile?t.shadowRoot.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.composedPath()[0]),a=t._dragDetails.target.includes("smart-task-connection-point")?t._dragDetails.target:void 0,n=o.classList.contains("smart-task-connection-point")?o:void 0,a&&(l=t._dragDetails.task),n)s=n.closest(".smart-timeline-task");else if(t._isMobile&&o.classList.contains("smart-timeline-task-fill")&&(s=o.closest(".smart-timeline-task"),s)){const e=r.pageX-window.pageXOffset-s.getBoundingClientRect().left;n=s.querySelector(".smart-task-connection-point."+(e>=s.offsetWidth/2?"end":"start"))}if(!l||!s)return;d=s._cellObj.task;for(let e=0,t=i.length;e<t;e+=1){const t=i[e];if(t!==l)if(t!==d){if(void 0!==c&&void 0!==m)break}else m=e;else c=e}}else{if(!e||e.length<3)return;const a=t._getValidConnectionId(e[0],e[1],e[2],"_connectTask");if(void 0===a)return;[c,m]=[parseInt(a[0]),parseInt(a[1])],[l,d]=[i[c],i[m]],r=parseInt(e[2]),o=e[4]||0}if(!l||!d||l===d||l.isGroup||d.isGroup||t._isAutoScheduled(l,d)||t.hasAttribute("dragged")||t.hasAttribute("resized"))return;void 0===r&&(r=t._getConnectionType(a,n));let u=t._connections;return u||(t._connections=u=[]),t._updateConnection([c,m,r,o])?(e.originalEvent&&t._recycleConnections([{startIndex:c,endIndex:m,type:r}]),e.originalEvent&&t.$.fireEvent("itemInsert",{type:"connection",item:{source:c,target:m,type:r}}),{taskStart:l,taskEnd:d,type:r}):void 0}_recycleConnections(e){const t=this,i=t._tasks;if(e?Array.isArray(e)||(e=[e]):e=t._connections,!i||!i.length||!e)return;const a=t.$.timelineTasksContainer.children,n=t.$.timelineConnectionsContainer;let s,r=[];if(a.length){const n=a[0],o=(()=>{let e=[];for(let t=0,n=a.length;t<n;t+=1)e.push(i.indexOf(a[t]._cellObj.task));return e})(),l=n.querySelector(".smart-task-connection-point."+(t.rightToLeft?"end":"start")),d=t._baselineProportion,c=t.showBaseline?t._taskDefaultHeight/d:0;s={top:l.offsetTop,width:l.offsetWidth},s.offset=Math.abs(l.offsetLeft)-s.width;for(let a=0,n=e.length;a<n;a+=1){const n=e[a],l=n.startIndex,d=n.endIndex;if(o.indexOf(l)<0&&o.indexOf(d)<0)continue;const m=i[l],u=i[d],{vCellStart:h,vCellEnd:g}=t._getTasksVCell(m,u);if(!h||!g)continue;const f=n.type,p={start:{width:s.width,top:s.top,index:l,task:m},end:{width:s.width,top:s.top,index:d,task:u},type:f},_=t._getTaskBarDetails(h,t._getTimelineCellByDate(m.dateStart),t._getTimelineCellByDate(m.dateEnd)),T=t._getTaskBarDetails(g,t._getTimelineCellByDate(u.dateStart),t._getTimelineCellByDate(u.dateEnd));"milestone"===m.type&&(_.width=h.height-c),"milestone"===u.type&&(T.width=h.height-c),p.start.left=0===f||3===f?-1*(s.width+s.offset):_.width+s.offset,p.end.left=0===f||1===f?-1*(s.width+s.offset):T.width+s.offset,t._connectionDetails=p,_.height=T.height=h.height-c,_.type=m.type,T.type=u.type,t._setConnectionDetails(_,T),t._createTaskConnection(),r.push(t._connectionDetails.id),delete t._connectionDetails}}if(arguments.length)return;const o=Array.from(n.children);for(let e=0,t=o.length;e<t;e+=1){const t=o[e];r.indexOf(t.getAttribute("connection-id"))<0&&t.remove()}}_getTasksVCell(e,t){const i=this._timelineVCells;let a,n;for(let s=0,r=i.length;s<r;s+=1){const r=i[s];if(r.task===e&&(a=r),r.task===t&&(n=r),a&&n)break}return{vCellStart:a,vCellEnd:n}}_isAutoScheduled(e,t,i){const a=this,n=a._tasks;let s={};if(a.autoSchedule)return e instanceof HTMLElement&&(e=e._cellObj.task),t instanceof HTMLElement&&(t=t._cellObj.task),function e(t,r){const o=a._getTaskConnections().taskConnections,l=n.indexOf(t);s[l]=!0;for(let t=0;t<o.length;t++){const d=o[t],c=d.endIndex;if(c===r)return i&&a._removeConnection(l+"-"+c+"-"+d.type,!0),!0;if(!s[c]&&e(n[c],r))return!0}}(t,n.indexOf(e))}_setConnectionDetails(e,t){const i=this;if(!i._connectionDetails)return;const a=i._connectionDetails,n=a.start,s=a.end,r=a.type;if(!n||!s)return;let o,l=e.width,d=t.width,c=e.left,m=t.left,u=e.top,h=t.top,g=n.left,f=s.left;const p=n.index,_=s.index;if("milestone"===e.type&&(l=e.height,c-=l/2),"milestone"===t.type&&(d=t.height,m-=d/2),a.id=p+"-"+_+"-"+r,!a.connectionStartOffset||!a.connectionEndOffset){switch(r){case 0:g=Math.abs(g)-n.width,f=Math.abs(f)-s.width;break;case 1:g-=l,f=Math.abs(f)-s.width;break;case 2:g-=l,f-=d;break;default:g=Math.abs(g)-n.width,f-=d}a.start.offset=g+=n.width/2,a.end.offset=f+=s.width/2}if(0===r&&c>m||1===r&&c+l+g>m-f&&h>u||2===r&&m+d>c+l||3===r&&(c-g<m+d+f&&h>u||c-g>m+d+f&&u>h)){o=!0;let i=e;e=t,t=i,i=g,g=f,f=i,i=l,l=d,d=i,i=c,c=m,m=i,i=u,u=h,h=i}let T=c,b=m;!o&&1===r||o&&3===r?T+=l:!o&&3===r||o&&1===r?b+=d:2===r&&(T+=l,b+=d);let k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+p+"-"+_+'-"]');0===k.length&&(k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+_+"-"+p+'"]')),a.connections=[].slice.call(k),a.start.x=T,a.start.y=u+n.top,a.end.x=b,a.end.y=h+s.top,a.type=r,a.inverted=o}_createTaskConnection(){const e=this,t=e._connectionDetails;if(!t)return;const i=2*e._taskConnectionWidth,a=t.start.x,n=t.start.y,s=t.start.offset,r=t.start.top,o=t.end.x,l=t.end.y,d=t.end.offset,c=t.type,m=t.inverted,u=!m&&3===c||m&&1===c,h=!m&&1===c||m&&3===c;let g,f,p,_=a,T=o;u?(_=a-d,T=o+d):h&&(_=a+s,T=o-d);const b=_<=T&&u,k=_>=T&&h,y=2===c||h;!function d(u){g!==o&&(u?"horizontal"===u?(p=g-o+(b?-1:1)*s,g=_>T?g-Math.abs(p):g,e._createConnectingElement(g,f,(_===T?0:Math.abs(p))+(y?i:0),"horizontal"),g=_<T?g-p:g,d("vertical")):(p=Math.abs(f-l),f+=n<l?0:-1*p,g-=m&&1===c||!m&&3===c&&n>l?i:0,e._createConnectingElement(g,f,p,"vertical"),d()):(g?(p=Math.abs(g-o),g>=o&&(g+=-1*p,p+=i),e._createConnectingElement(g,f+(n<l?Math.abs(f-l):0),p,"horizontal",!t.inverted),g=o):(g=a,f=n,(0===c||!m&&3===c||m&&1===c)&&(g-=s),e._createConnectingElement(g,f,s,"horizontal",t.inverted),y&&(g+=s-i),b||k?(e._createConnectingElement(g,f-=n>l?r:0,r,"vertical"),f+=n<l?r:0):d("vertical")),d("horizontal")))}(),t.connections.map((e=>e.parentElement.removeChild(e)))}_getTaskIndexById(e,t){const i=this;if(t||(t=i._tasks),"number"==typeof e)return isNaN(parseInt(e))?-1:parseInt(e);if("object"==typeof e)return i._getItemIndex(e,"task");for(let i=0,a=t.length;i<a;i+=1)if(t[i].id===e)return i;return-1}_refreshTaskConnections(e){const t=this,i=e instanceof HTMLElement?e._cellObj.task:e,a=t._tasks.indexOf(i);if(void 0===a||e.classList&&e.classList.contains("smart-visibility-hidden"))return;let n;if(t._dragDetails&&(n=t._dragDetails.relatedConnections[a]),!n){n=[];const e=t._connections;if(!e||!e.length)return;for(let t=0,i=e.length;t<i;t+=1){const i=e[t];i.startIndex!==a&&i.endIndex!==a||n.push(i)}t._dragDetails&&(t._dragDetails.relatedConnections[a]=n)}t._recycleConnections(n)}_dragStartHandler(e){const t=this,i=e.target.closest;(t._dragDetails||i&&i.call(t,"smart-gantt-chart")===t)&&e.preventDefault()}_getFirstCellObjInView(e){const t=this;if(e||(e=t._timelineCells),!e)return;const i=Math.abs(t.scrollLeft);let a,n;for(let t=0;t<e.length;t++){const s=e[t];if(s.left+s.width>i){a=s;break}n=s}return!a&&n&&(a=i>n.left?n:e[0]),a}_getFirstContentCellInView(e="task"){const t=this;let i,a,n,s;if("task"===e?(i=t._timelineVCells,a=t.scrollTop):(i=t._timelineResourceVCells,a=t.$.resourceVerticalScrollBar.value),!i)return 0;for(let e=0;e<i.length;e++){const t=i[e];if(t.top+t.height>a){n=t;break}s=t}return!n&&s&&(n=a>s.left?s:i[0]),n}_getProjectTasks(e,t){const i=this,a=i.groupByResources&&e.isGroup?"group":"project",n=i._tasks;if(!e||"project"!==e.type)return[];let s=[];for(let r=0,o=n.length;r<o;r+=1){const o=n[r];o.$[a]===e&&(s.push(o),"project"!==o.type||t||(s=s.concat(i._getProjectTasks(o,t))))}return s}_getSubTaskLimits(e){const t=this;if(!e)return;const i=e._cellObj.task,a=t._getProjectTasks(i);let n,s;if(!a.length)return;let r=a[0],o=a[0];for(let e=0;e<a.length;e++){const t=a[e];a[e].dateEnd&&a[e].dateStart&&(r.dateStart||(r=t[e]),o.dateEnd||(o=t[e]),a[e].dateEnd.getTime()>o.dateEnd.getTime()&&(o=a[e]),a[e].dateStart.getTime()<r.dateStart.getTime()&&(r=a[e]))}const l=t.$.timelineContent.offsetWidth;let d,c,m;if(r&&(d=t._getTimelineSubTaskOffset(r),d&&(c=d.left,m=d.width,n=Math.max(0,t.rightToLeft?l-e.offsetLeft-e.offsetWidth-(l-c-m):e.offsetLeft-c))),o&&(d=t._getTimelineSubTaskOffset(o),d))if(c=d.left,m=d.width,t.rightToLeft){const t=l-e.offsetLeft-e.offsetWidth;s=Math.max(t,t+l-(l-c))}else s=Math.max(e.offsetLeft,e.offsetLeft+l-(c+m));return{min:n,max:s}}_getTimelineSubTaskOffset(e){const t=this,i=t.$.timelineTasksContainer.children[t._tasks.filter((e=>!e.hidden)).indexOf(e)];let a,n,s;if(i)a=i.offsetLeft,s=i.offsetWidth;else{const i=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);i&&(a=i.left+t._getTimelineTaskOffset(i,e.dateStart)||0),r&&(n=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0),s=n-a}return{left:a,width:s}}_getTaskDragLimits(e){const t=this,i=t._dragDetails,a=i.segment?i.segment.element:void 0,n=a&&a.previousElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateStart"),s=a&&a.nextElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateEnd"),r=t._dragDetails.taskDimensions;let o={};return(n.min||s.min)&&(o.min=Math.max(n.min||0,Math.max(0,(s.min||0)-r.width))),s.max&&(o.max=Math.max(0,s.max-r.width)),n.max&&(o.max=o.max?Math.min(n.max,o.max):n.max),o}_getTaskBarDateRange(e){if(!e)return;const t=this,i=e.classList.contains("milestone"),a=parseFloat(e.style.width)||e.offsetWidth,n=i?a/2:a,s=t.rightToLeft?parseFloat(e.style.right)||t.$.timelineContent.offsetWidth-e.offsetLeft-n:parseFloat(e.style.left)||e.offsetLeft,r=e._cellStart,o=e._cellEnd,l=e._cellObj.task,d=l.minDateStart,c=l.maxDateEnd;let m,u;return m=t._getDateFromCell(s,r),!d||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(m=new Date(Math.max(d.getTime(),m.getTime()))),u=i?new Date(m):t._getDateFromCell(s+n,o),!c||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(u=new Date(Math.min(c.getTime(),u.getTime()))),{dateStart:m,dateEnd:u}}_getTaskBarDetails(e,t,i){const a=this,n=e.task;if(!e)return;let s=new Date(n.dateStart);const r=new Date(n.dateEnd);if(!a._dragDetails&&a.snapToNearest){let s,r,o=n.dateStart,l=n.dateEnd;const d=new Date(t.date),c=a._getDateFromCell(t.left+t.width,t),m=new Date(i.date),u=a._getDateFromCell(i.left+i.width,i);return s=c.getTime()-o.getTime()>=c.getTime()-d.getTime()?t.left:t.left+t.width,"milestone"!==n.type&&(r=u.getTime()-l.getTime()>=l.getTime()-m.getTime()?i.left-s:i.left-s+i.width),{left:s,width:r,top:e.top}}let o,l,d,c,m,u;switch(a.view){case"quarter":case"year":{d=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),c=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();const e=s.getHours()/24+s.getMinutes()/1440+s.getSeconds()/86400,a=r.getHours()/24+r.getMinutes()/1440+r.getSeconds()/86400;o=t.left+(s.getDate()-1+e)/d*t.width,l=i.left+(r.getDate()-1+a)/c*i.width-o;break}case"month":"day"===a.monthScale?(m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*t.width,u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*t.width,o=t.left+m,l=i.left+(u-m)-t.left):(m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*(t.width/7),u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*(t.width/7),o=t.left+s.getDay()/7*t.width+m,l=i.left+r.getDay()/7*i.width-o+u);break;case"week":m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*t.width,u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*t.width,o=t.left+m,l=i.left+(u-m)-t.left;break;case"day":m=parseFloat(s.getMinutes()+s.getSeconds()/60)/60*t.width,u=parseFloat(r.getMinutes()+r.getSeconds()/60)/60*t.width,o=t.left+m,l=i.left+(u-m)-t.left}return{width:"milestone"===n.type?"":l,left:o,top:e.top}}_snapToNearestDates(e,t){const i=this;if(!i.snapToNearest)return;if(e.classList&&e._cellObj&&(e=e._cellObj.task),!e)return;let a=e.dateStart,n=e.dateEnd;const{cellStart:s,cellEnd:r}={cellStart:i._getTimelineCellByDate(a),cellEnd:i._getTimelineCellByDate(n)},o=new Date(s.date),l=i._getDateFromCell(s.left+s.width,s),d=new Date(r.date),c=i._getDateFromCell(r.left+r.width,r);if(a=l.getTime()-a.getTime()>=l.getTime()-o.getTime()?o:l,"milestone"!==e.type&&(n=c.getTime()-n.getTime()>=c.getTime()-d.getTime()?d:c),e.dateEnd=n,n.getTime()<a.getTime()&&(a=new Date(n)),e.dateStart=a,e.duration=e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0),!t&&e.segments&&e.segments.length>1){const t=e.segments;for(let e=0,a=t.length;e<a;e+=1)i._snapToNearestDates(t[e],!0);i._validateTaskSegments(e)}}_getTimelineTaskCellByDate(e){if(!e)return;let t=this,i=t.view,a=t._timelineCells;"month"===i&&"day"===t.monthScale&&(i="day");for(let n=0;n<a.length;n++){const s=a[n];if(t._isDateInCell(s.date,e,i))return s}}_isDateInCell(e,t,i){const a=this;switch(i){case"quarter":case"year":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth())return!0;break;case"month":{let i=new Date(e);if(i.setDate(i.getDate()+(6-i.getDay())+1),i.setMilliseconds(i.getMilliseconds()-1),t.getTime()>=e.getTime()&&t.getTime()<=i.getTime())return!0;break}case"week":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())return!0;break;case"day":if("hour"!==a.dayScale){if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours()&&e.getMinutes()===t.getMinutes())return!0}else if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours())return!0}}_handleInverted(e){const t=this;function i(e){e||(e="task");const i=t.$[`${e}Splitter`];if(!t.$.mainSplitter.contains(i))return;const[a,n,s,r,o]="task"===e?[t.$.tableSplitterItem,t.$.timelineSplitterItem,t,t.$.taskTimelineContainer,"scrollTop"]:[t.$.resourceTableItem,t.$.resourceTimelineSplitterItem,t.$.resourceVerticalScrollBar,t.$.resourceTimelineContent,"value"],l=t.treeSize!==a.size?a.style[i._measurements.dimension]:t.treeSize;a.size="",i.removeChild(n),t.inverted&&!t.rightToLeft||!t.inverted&&t.rightToLeft?i.insertBefore(n,a):i.appendChild(n),a.size=l,r.scrollTop=s[o]}(!e||t.inverted||t.rightToLeft)&&(i("task"),i("resource"))}_createResourceTimeline(){const e=this;if(e._handleResourcePanelVisibility(),e.$.taskSplitterItem._setSize("size",e.taskPanelSize),!e._resources||!e.$.mainSplitter.contains(e.$.resourceTable))return;const t=e.$.resourceSplitterItemHeader.innerHTML;(e.resourcePanelHeaderTemplate&&!t||!e.resourcePanelHeaderTemplate&&t)&&e._handleHeaderTemplate("resource"),e._setTable(e.$.resourceTable),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter),e.$.resourceTimelineContent.scrollLeft=e.$.resourceTimelineHeader.scrollLeft=e.$.timelineHeader.scrollLeft,e.$.resourceSplitter.refresh(),e._refresh(),e._highlightAssignedItem("task",e._getSelection("task",e.selectedTaskIds))}_createResourceTimelineContent(){const e=this,t=e._timelineVCells,i=t.length?t[0].height:e._taskDefaultHeight;e._createResourceTimelineVCells(i);const a=e._timelineResourceVCells.length*i;e.$.resourceTimelineCellsContainer.style.height=a+"px",e.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",a+"px"),e._recycleResourceContent()}_recycleResourceContent(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e._timelineResourceVCells,i=e.$.resourceTimelineCellsContainer,a=e._getFirstContentCellInView("resource"),n=e.$.tooltip;if(n&&i.contains(n.selector)&&e._closeTooltip(),!a)return void(i.innerHTML="");const s=t.indexOf(a),r=a.height,o=1-(a.top+r-Math.abs(e.$.resourceVerticalScrollBar.value))/r,l=t?t.length:0,d=!e.$.resourceSplitter.offsetHeight,c=e.$.resourceTimelineContent.offsetHeight,m=!d&&c?Math.min(l,Math.ceil((parseFloat((c/r).toFixed(2))+o).toFixed(2))):l,u=i.children,h=e.$.timelineViewCells.children,g=document.createDocumentFragment();for(;i.childElementCount>m;)i.lastElementChild.remove();for(let t=0;t<m;t+=1){let i=u[t];i||(i=document.createElement("div"),i.classList.add("smart-timeline-row"),g.appendChild(i)),e._createTimelineRowCells(i,h)}g.childElementCount&&i.appendChild(g);const f=i.children,p=e._getSelection("resource",e.selectedResourceIds);for(let i=0;i<m;i+=1){const a=t[s+i],n=f[i];if(!a){n&&n.remove();continue}const r=a.resource,o=r.$.id;p.indexOf(o)>-1?n.setAttribute("selected",""):n.removeAttribute("selected"),n._cellObj=a,n.setAttribute("row-id",o),n.style.top=a.top+"px",e._refreshResourceTimelineContent(r,n)}}_createResourceTimelineVCells(e){const t=this,i=t._resources,a=t.$.resourceTable.rows,n=t._timelineResourceVCells=[];let s=0;if(void 0===e){const i=t._timelineVCells;e=i.length?i[0].height:t._taskDefaultHeight}for(let t=0,r=a.length;t<r;t+=1){const r=i[a[t].data.itemIndex];r.hidden||(n.push({top:s,height:e,resource:r}),s=parseFloat((s+e).toFixed(2)))}}_handleResourcePanelVisibility(){const e=this,t=e.$.container,i=e._resources.filter((e=>!e.hidden)),a=e.$.mainSplitter,n=e.$.resourceSplitterItem,s=e.$.taskSplitterItem;if(!i||!i.length||e.hideResourcePanel)return n&&!n.size&&(n._size=n.style[a._measurements.dimension]),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView),s.size="",s.min="",e.$.resourceTable&&e.$.resourceTable.clearSelection(),a.contains(n)&&(a.removeChild(n),e._refresh()),e._highlightAssignedItem("resource"),void t.removeAttribute("show-resource-panel");a.contains(n)||(s.min=e.taskPanelMin,e._createResourcePanel(),e._setupResourcePanel(),e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),t.setAttribute("show-resource-panel",""),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter)}_createResourcePanel(){const e=this,t=e.$.mainSplitter;let i=e.$.resourceSplitterItem;if(!i){i=document.createElement("smart-splitter-item"),i.classList.add("smart-resource-splitter-item"),i.innerHTML=`<div smart-id="resourceSplitterItemHeader" class="smart-resource-panel-header"></div>\n <smart-splitter smart-id="resourceSplitter" wait class="smart-resource-splitter" auto-fit-mode="end">\n <smart-splitter-item smart-id="resourceTableItem" class="smart-resource-table-item">\n <smart-table wait smart-id="resourceTable" class="smart-resource-table" virtualization deferred-scroll-delay="0"></smart-table>\n </smart-splitter-item>\n <smart-splitter-item smart-id="resourceTimelineSplitterItem" class="smart-timeline-splitter-item">\n <div class="smart-timeline" smart-id="resourceTimeline">\n <div class="smart-timeline-container" role="presentation">\n <div class="smart-timeline-header" smart-id="resourceTimelineHeader" role="rowgroup">\n <div class="smart-timeline-view-cells" smart-id="resourceTimelineViewCells" role="row"></div>\n </div>\n <div smart-id="resourceTimelineContent" class="smart-timeline-content" role="rowgroup">\n <div smart-id="resourceTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar wait smart-id="resourceVerticalScrollBar" class="smart-timeline-scroll-bar smart-resource-scroll-bar" \n orientation="vertical" aria-controls="[[${e.id||""}]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>`,t.contains(i)||t.appendChild(i);const a=Smart.Utilities,n=i.querySelectorAll(".smart-resource-panel-header, .smart-resource-splitter, .smart-resource-table-item, \n .smart-resource-table, .smart-timeline-splitter-item, .smart-timeline, .smart-timeline-header, .smart-timeline-view-cells, .smart-timeline-content,\n .smart-timeline-cells-container, .smart-timeline-scroll-bar"),[s,r,o,l,d,c,m,u,h,g,f]=n;e.$.resourceSplitterItem=i,e.$resourceSplitterItem=a.Extend(i),e.$.resourceSplitterItemHeader=s,e.$resourceSplitterItemHeader=a.Extend(s),e.$.resourceSplitter=r,r.hasResizeObserver=!1,r.wait=!1,e.$resourceSplitter=a.Extend(r),e.$.resourceTableItem=o,e.$resourceTableItem=a.Extend(o),e.$.resourceTable=l,l.hasResizeObserver=!1,e.$resourceTable=a.Extend(l),e.$.resourceTimelineSplitterItem=d,e.$resourceTimelineSplitterItem=a.Extend(d),e.$.resourceTimelineViewCells=u,e.$resourceTimelineViewCells=a.Extend(u),e.$.resourceTimeline=c,e.$resourceTimeline=a.Extend(c),e.$.resourceTimelineContent=h,e.$resourceTimelineContent=a.Extend(h),e.$.resourceTimelineHeader=m,e.$resourceTimelineHeader=a.Extend(m),e.$.resourceTimelineCellsContainer=g,e.$resourceTimelineCellsContainer=a.Extend(g),e.$.resourceVerticalScrollBar=f,e.$resourceVerticalScrollBar=a.Extend(f)}}_setupResourcePanel(){const e=this,t=e.rightToLeft,i=e.$.resourceSplitterItem,a=e.$.resourceTableItem,n=e.$.resourceTable,s=e.$.resourceTimelineSplitterItem,r=e.$.resourceVerticalScrollBar;e.$.mainSplitter.contains(i)?([e.$.resourceSplitter,n,e.$.resourceVerticalScrollBar].forEach((e=>e.rightToLeft=t)),n.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,n.$.virtualizationContainer.verticalScrollBarVisibility="hidden",n.$.virtualizationContainer.disabled=!0,a.size=e.treeSize,a.min=e.treeMin,s.min=e.timelineMin,i.min=e.resourcePanelMin,i.size=i._size||e.resourcePanelSize,r.hasStyleObserver=!1,r.hasResizeObserver=!1,r.wait=!1):e.$.mainSplitter.appendChild(i)}_refreshResourceTimeline(){const e=this;e._resources&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._recycleResourceHeaderCells(),e._recycleResourceContent())}_getResourceCellWorkTime(e,t){const i=e.dateStart,a=e.dateEnd,n=t.dateStart,s=t.dateEnd,r=e.dateStart.getTime()<n.getTime()?n:i,o=a.getTime()>s.getTime()?s:a,l=Math.round(this._getWorkingTime(r,o)/36e5);return{value:Math.max(0,l),max:r.getTime()===n.getTime()&&o.getTime()===s.getTime()?l:Math.round(this._getWorkingTime(n,s)/36e5)}}_refreshResourceTimelineContent(e,t){const i=this,a=i._resources.indexOf(e),n=i._getResourceTasks(e);if(t||(t=(()=>{const t=i.$.resourceTimelineCellsContainer.children;for(let i=0,a=t.length;i<a;i+=1){const a=t[i];if(a._cellObj&&a._cellObj.resource===e)return a}})()),a<0||!t||!t.childElementCount)return;let s=t.children;const r=i.$.resourceTimelineViewCells.children,o=i._tasks.filter((e=>!e.hidden));for(let t=0,l=s.length;t<l;t+=1){const l=s[t];let d,c=l.firstElementChild;n.length&&!e.hidden?(c?(c.classList.remove("hide-left-border","hide-right-border"),c.removeAttribute("load"),c.innerHTML=c.style.height=""):(c=document.createElement("div"),c.classList.add("smart-resource-timeline-view-cell"),d=!0),e.class&&c.classList.add(e.class),i._setResourceCellLoad({cell:c,cellIndex:t,resource:e,resourceCell:l,resourceIndex:a,resourceTasks:n,tasks:o,viewCells:r}),c.hasAttribute("load")?d&&l.appendChild(c):c.remove()):c&&c.remove()}}_setResourceCellLoad(e){const t=this,i=t.resourceTimelineFormatFunction,{cell:a,cellIndex:n,resource:s,resourceCell:r,resourceIndex:o,resourceTasks:l,tasks:d,viewCells:c}=e;let m={};for(let e=0,u=l.length;e<u;e+=1){const u=l[e];if(u.hidden)continue;const h=d.indexOf(u),g=t._getCellDateRange(c[n]),{dateStart:f,dateEnd:p}=g;if(!f||f.getTime()>=u.dateEnd.getTime()||p.getTime()<=u.dateStart.getTime())continue;if(m[n]&&m[n].indexOf(h)<0?m[n].push(h):m[a]||(m[n]=[h]),"custom"===t.resourceTimelineMode){i&&(a.innerHTML=i.call(t,m[n]||[],o,new Date(f))||"");continue}const _=t._getResourceCellCapacity({cell:a,cellDateRange:g,cellTaskIndexAssigned:m,index:o,resource:s,task:u,cellIndex:n});if(!_)continue;const{capacity:T,maxCapacity:b}=_,k=parseFloat(((parseFloat(a.getAttribute("load"))||0)+(T||0)).toFixed(1));k>b?a.classList.add("warning"):a.classList.remove("warning"),"histogram"!==t.resourceTimelineMode?k&&a.setAttribute("load",k):t._setCellHistogram({cell:a,load:k,maxCapacity:b,previousViewCell:r.previousElementSibling})}}_getResourceCellCapacity(e){const t=this,i=t.resourceTimelineView,{cell:a,cellDateRange:n,cellTaskIndexAssigned:s,index:r,resource:o,task:l,cellIndex:d}=e;let c,m;if("tasks"===i)c=1,m=o.maxCapacity;else if("hours"===i){const e=t._getResourceCellWorkTime(l,n),i=e.max/24;c=parseFloat((e.value/e.max*o.capacity*i).toFixed(1)),m=Math.min(e.max,parseFloat((o.maxCapacity*i).toFixed(1)))}else{const e=t.resourceTimelineFormatFunction;if(!e)return;let i=e.call(t,s[d]||[],r,new Date(n.dateStart));if(null!=i)if(i="object"!=typeof i?[i]:Object.values(i),2===i.length)c=parseFloat(i[0])||0,m=parseFloat(i[1])||0;else if(1===i.length)return void(a&&a.setAttribute("load",i[0]))}return{capacity:c,maxCapacity:m}}_setCellHistogram(e){const{load:t,cell:i,maxCapacity:a,previousViewCell:n}=e,s=Math.min(100,100*parseFloat((t/a).toFixed(2))),r=n?n.firstElementChild:void 0;if(r){const e=parseFloat(r.style.height)||0;s?e===s?(i.classList.add("hide-left-border"),r.classList.add("hide-right-border")):e>s?(i.classList.add("hide-left-border"),r.classList.remove("hide-right-border")):e<s&&(i.classList.remove("hide-left-border"),r.classList.add("hide-right-border")):(i.classList.remove("hide-left-border"),r.classList.remove("hide-right-border"))}i.style.height=s+"%",t&&i.setAttribute("load",t+"/"+a)}_recycleResourceHeaderCells(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e.$.resourceTimelineViewCells,i=t.children,a=e.$.timelineViewCells.children;let n=document.createDocumentFragment();for(;i.length>a.length;)i[0].remove();for(let e=0;e<a.length;e++){const t=a[e];let s=i[e];s||(s=t.cloneNode(!0),n.appendChild(s)),s.style.left=t.style.left,s.style.right=t.style.right,s.style.width=t.style.width,s.innerHTML=t.innerHTML,s._date=t._date,t.hasAttribute("weekend")?s.setAttribute("weekend",""):s.removeAttribute("weekend"),t.hasAttribute("nonworking")?s.setAttribute("nonworking",""):s.removeAttribute("nonworking")}n.childElementCount&&t.appendChild(n),e.$.resourceTimelineCellsContainer.style.width=e.$.resourceTimelineViewCells.style.width=e.$.timelineContent.style.width}_refreshResourceScrollBar(){const e=this,t=e.$.resourceVerticalScrollBar;if(!e.$.mainSplitter.contains(e.$.resourceSplitter))return;const i=Math.max(0,e.$.resourceTimelineCellsContainer.offsetHeight-e.$.resourceTimelineContent.offsetHeight);0===i&&"visible"===e.verticalScrollBarVisibility?(t.max=1,e.scrollHeight||e.$container.removeClass("vscroll")):i&&e.$container.addClass("vscroll"),t.max=i,t.disabled="disabled"===e.verticalScrollBarVisibility||e.disabled||i<=0,!e.$.container.classList.contains("vscroll")&&t.disabled?t.classList.add("smart-hidden"):(t.classList.remove("smart-hidden"),t.refresh(),e.$.container.classList.contains("hscroll")?e.$.horizontalScrollBar.classList.add("bottom-corner"):e.$.container.classList.contains("vscroll")||e.$.horizontalScrollBar.classList.remove("bottom-corner"))}_handleResources(e){const t=this,i=e?[e]:t._tasks;t._resources||(t._resources=[]);for(let e=0;e<i.length;e++){let a=i[e].resources;Array.isArray(a)||(a=[a].reduce(((e,t)=>e.concat(t)),[]));for(let n=0;n<a.length;n++){let s=a[n];if("object"!=typeof s||!s||void 0===s.id||null===s.id){"number"==typeof s&&(a[n]=s+"");continue}let r=t._resources.find((e=>e.id&&e.id.toString()===s.id.toString()))||{};t._setResource(r,s,i[e]),a[n]=r.id,Object.values(r).length&&!t._resources.includes(r)&&t._resources.push(r)}}t._refreshItemIds("resource");const a=t._resources;for(let e=0,i=a.length;e<i;e+=1)t._refreshResource(a[e])}_refreshAssignedResources(e,t=[]){const i=this;if(!e.$.id||i._tasks.indexOf(e)<0)return;const a=i._getTaskResources(e);for(let e=0;e<a.length;e++){const n=a[e];let s=[];i.resourceColumns.forEach((e=>{void 0!==e.formatFunction&&s.push(e.value)})),s.concat(t),i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(n),t.includes("workload")?i._refreshResource(n,"workload"):t.includes("progress")&&i._refreshResource(n,"progress"),s.length&&i._refreshTableColumnsData(n,s,"resource")}}_refreshResource(e,t){const i=this;if(!i._resources.length)return;const a=i._getResourceTasks(e),n=864e5;switch(t){case"progress":e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2));break;case"workload":e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*e.maxCapacity).toFixed(2));break;default:e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2)),e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*e.maxCapacity).toFixed(2))}i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(e)}_setResource(e,t){if(t&&"object"==typeof t)return e.id?e.id=e.id.trim():e.id=(t.id+"").trim(),e.$||(e.$={}),e.class=t.class||e.class,e.minCapacity=t.minCapacity||e.minCapacity||0,e.maxCapacity=t.maxCapacity||e.maxCapacity||24,e.progress=t.progress||e.progress||0,e.capacity=t.capacity||e.capacity||8,e.type=t.type||e.type,e.hidden=!!("boolean"==typeof t.hidden?t.hidden:e.hidden),e.workload=e.workload||0,t.label?e.label=t.label:void 0===e.label&&(e.label=""),t.value&&(e.value=t.value),e}insertResource(e,t){const i=this,a=Array.from(arguments).filter((e=>void 0!==e));let n,s=i._resources;if(1===a.length&&(t=a[0]),"object"!=typeof t)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"insertResources",argumentName:"resource"}));if(t.id&&s.find((e=>e.id&&e.id.toString()===t.id.toString())))return void i.updateResource(t.id,t);if(t.assignedTo&&(n=[t.assignedTo].reduce(((e,t)=>e.concat(t,[])))),!(t=i._setResource({},t)))return;i._refreshItemIds("resource"),s=i._resources;const r=i._getValidItemAndIndex(e,"resource").index;if(r<0?s.push(t):s.splice(r,0,t),i._tasks.length){if(void 0!==n){Array.isArray(n)||(n=[n]);for(let e=0,a=n.length;e<a;e+=1){const a=i._getValidItemAndIndex(n[e],"task");if(a){const e=a.item;!e||e.disableResources||e.resources.includes(t.id.toString())||e.resources.push(t.id)}}if(i._isUpdating)return void(i._isUpdating.type.resource=!0);i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i._refreshResource(t)}if(i._isUpdating)return i._isUpdating.type.resource=!0,void(i._isUpdating.type.task=!0);if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const e=i._tasks.filter((e=>e.resources.includes(t.id)));for(let t=0;t<e.length;t++)i._refreshTableColumnsData(e[t],["resources"])}}i._isUpdating?i._isUpdating.type.resource=!0:(i._createResourceTimeline(),i.$.fireEvent("itemInsert",{type:"resource",item:i._cloneObject(t)}))}_insertTimelineResource(e,t,i){const a=this,n=a.$.resourceTimelineCellsContainer,s=document.createElement("div");s.classList.add("smart-timeline-row"),s._resource=t,a._refreshResourceTimelineContent(t,s),a.$.resourceTimelineCellsContainer.insertBefore(s,e>-1?n.children[e]:void 0),a.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",n.offsetHeight+"px"),a._refreshResourceScrollBar(),a._insertNewTreeItem(e,t,i,"resource"),a.$.resourceTree.refresh(),a._highlightAssignedItem("task",a._getSelection("task",a.selectedTaskIds))}updateResource(e,t){if(void 0===e)return;const i=this._getValidItemAndIndex(e,"resource");i&&i.item&&this._updateResource(i.item,t)}removeResource(e){if(void 0===e)return;const t=this._getValidItemAndIndex(e,"resource");t&&t.item&&this._removeResource(t.item)}_getResourceTasks(e){const t=this._resources,i=this._tasks;if(!e||!t.length||!i.length)return;let a=[];for(let t=0;t<i.length;t++)i[t].resources.includes(e.id)&&a.push(i[t]);return a}_getTaskResources(e){const t=this;if(!e)return[];const i=[e.resources].reduce(((e,t)=>e.concat(t)),[]);let a=[];for(let e=0;e<i.length;e++){const n=t._resources.find((t=>t.id&&t.id.toString()===i[e].toString()));n&&a.push(n)}return a}_resourceValidator(e,t){const i=this;return Array.isArray(t)||t instanceof Smart.ObservableArray||"number"==typeof t||"string"==typeof t||null==t?t:(i.error(i.localize("invalidValue",{elementType:i.nodeName.toLowerCase(),property:"resources",typeOne:"array",typeTwo:"number"})),null)}_handleTaskProgressChange(e){const t=this,i=t._dragDetails.task,a=t._dragDetails.timelineTask;if(t.disableTaskProgressChange)return;if(!t.hasAttribute("progress-change")){if(t.$.fireEvent("progressChangeStart",{id:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,item:t._cloneObject(i),progress:i.progress||0}).defaultPrevented)return void delete t._dragDetails.target;t._closeTooltip(),t.setAttribute("progress-change",""),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const{left:n,width:s}=a.getBoundingClientRect(),r=e.pageX-window.pageXOffset;t._dragDetails.progress||(t._dragDetails.progress=i.progress/100*s),t._dragDetails.progress=Math.max(0,Math.min(s,t._dragDetails.progress+(t.rightToLeft?-1:1)*(r-t._dragDetails.coordinates.x))),t._dragDetails.coordinates.x=Math.max(n+t._dragDetails.offset.x,Math.min(n+s+t._dragDetails.offset.x,r));const o=t._dragDetails.task.progress=t._dragDetails.progress/s*100;i.progress=parseFloat(o.toFixed(2)),t._setTaskBarProgress(i,a),t._refreshTableColumnsData(i,["progress"]),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(i,["progress"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskSegmentDrag(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableDrag)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===r)));const u=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void delete i.timelineTask;if(t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0,l||d){const e=t._createDelimiter("min-date"),i=t._createDelimiter("max-date");e&&u.appendChild(e),i&&u.appendChild(i)}}if(l){const a=i.size?i.size.width:i.originalSize.width;t._handleTaskResize(e,c?"right":"left"),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const n=i.size.width-a,s=i.segments;for(let e=0,t=s.length;e<t;e+=1){const t=s[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+n+"px")}}else{if(!d)return void t._handleSegmentDrag(e);{const s=a.dimensions;t._handleTaskResize(e,c?"left":"right"),n.style[m]=i.size.width-s.width+"px"}}t._refreshTask(o,[n]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentDrag(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=i.task,r=t._dragDetails.timelineTask,o=t.rightToLeft,l=o?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===s)));const d=i.timelineRow,{left:c}=d.getBoundingClientRect(),m=i.taskDimensions.left;a.position||(a.position={x:a.originalPosition.x});const u=r.offsetWidth,h=e.pageX-window.pageXOffset;let g=0,f=a.min.left||0,p=a.max.left;o&&(f=u-(f+a.dimensions.width),p=u-p),a.position.x=Math.max(f,Math.min(p,a.position.x+(o?-1:1)*(h-i.coordinates.x))),void 0!==p&&(g=o?m+a.min.left:m+a.max.left,a.position.x=Math.min(p,a.position.x)),f=m+(o?a.max.left-a.dimensions.width:f),i.coordinates.x=Math.max(c+a.offset.x+f,Math.min(c+a.offset.x+g,h)),n.style[l]=a.position.x+"px",t._refreshTaskSegments(r,[n])}_handleTaskBarDrag(e){const t=this;if(t.disableTaskDrag)return;const i=t._dragDetails;if(Math.abs(e.pageX-i.coordinates.x)<=5)return void(t._scrollView.disableSwipeScroll=!0);if(i.segment)return void t._handleTaskSegmentDrag(e);const a=i.task,n=i.timelineTask;i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const s=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:a.dateStart,dateEnd:a.dateEnd}).defaultPrevented)return void delete i.timelineTask;t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0;const e=t._createDelimiter("min-date"),n=t._createDelimiter("max-date");e&&s.appendChild(e),n&&s.appendChild(n)}i.position||(i.position={x:i.originalPosition.x,y:i.originalPosition.y});const r=s.getBoundingClientRect().left,o=s.offsetWidth,l=n.offsetWidth,d=i.min.left||0,c=i.max.left,m=e.pageX-window.pageXOffset,u=t.rightToLeft;let h=0;i.position.x=Math.max(d,Math.min(o-l,i.position.x+(u?-1:1)*(m-i.coordinates.x))),void 0!==c&&(i.position.x=Math.min(c,i.position.x),h=o-l-c),i.coordinates.x=u?Math.max(r+i.offset.x+h,Math.min(r+o-(l-i.offset.x+d),m)):Math.max(r+i.offset.x+d,Math.min(r+o-(l-i.offset.x+h),m));const g=a.dateStart.getTime(),f=a.dateEnd.getTime();n.style[u?"right":"left"]=i.position.x+"px",t._refreshTask(n),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),"project"===a.type&&a.dragProject&&t._refreshProjectTasks(a,{startTime:a.dateStart.getTime()-g,endTime:a.dateEnd.getTime()-f}),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(n._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskBarResize(e){const t=this;if(t.disableTaskResize)return;const i=t._dragDetails;if(i.segment)return void t._handleTaskSegmentResize(e);const a=i.timelineTask,n=i.task;if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}t._handleTaskResize(e,t.$.timeline.getAttribute("task-bar-hovered")),t._updateSegmentsOnTaskResize(),t._refreshTask(a),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(a._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_updateSegmentsOnTaskResize(){const e=this,t=e._dragDetails,i=t.task,a=t.timelineTask;if(!i||!i.segments)return;let n;t&&t.segments?n=t.segments:t.segments=n=a.querySelectorAll(".smart-task-segment");const s=n.length,r=t.size.width,o=e.rightToLeft?"right":"left";for(let t=0;t<s;t+=1){const i=n[t],a=i.style.width?parseFloat(i.style.width):i.offsetWidth,l=i.style[o]?parseFloat(i.style[o]):0;if(l+a>r){const t=r-(l+a),n=a+t;n<e._taskBarMinWidth&&(i.style[o]=l+t+"px"),i.style.width=n+"px"}else t===s-1&&(i.style.width=r-l+"px")}}_handleTaskSegmentResize(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableResize)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"right":"left";if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const u=t.$.timeline.getAttribute("task-bar-hovered");if(l&&("left"===u&&!c||"right"===u&&c)){const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.originalSize.width}),t._handleTaskResize(e,u),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const r=i.size.width-s,l=i.segments;for(let e=0,t=l.length;e<t;e+=1){const t=l[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+r+"px")}n.style.width=(a.size.width+=r)+"px"}else{if(!d||!("right"===u&&!c||"left"===u&&c))return t._handleSegmentResize(e,u),void t._refreshTaskSegments(o,[n]);{const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.originalSize.width}),t._handleTaskResize(e,u),n.style.width=(a.size.width+=i.size.width-s)+"px"}}t._refreshTask(o,[n]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentResize(e,t){const i=this,a=i._dragDetails,n=a.task,s=a.segment,r=s.element,o=i.rightToLeft,l=a.taskDimensions.left;a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const d=a.timelineRow;s.position||(s.position={x:s.originalPosition.x}),s.size||(s.size={width:s.originalSize.width});const c=e.pageX-window.pageXOffset;let m=s.size.width,u=s.min.width||0,h=s.max.width,g=s.min.left||0,f=s.max.left,p=r.offsetLeft,{left:_}=d.getBoundingClientRect(),T="object"==typeof e?c-a.coordinates.x:e;if(_+=l,"left"===t&&!o||"right"===t&&o)if(o){const e=a.taskDimensions.width;T=T<0?-1*Math.min(Math.abs(T),m-u):Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(h,m+T)),r.style.left="",r.style.right=(p=Math.max(e-g,(parseFloat(r.style.right)||d.offsetWidth-p-m)-T))+"px",a.coordinates.x=Math.max(_+e-p+u,Math.min(_+e-p,c))}else T=T>0?Math.min(T,m-(u||0)):-1*Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(p+m,m-T)),r.style.right="",r.style.left=(p=Math.max(g,(parseFloat(r.style.left)||p)+T))+"px",a.coordinates.x=Math.max(_+g+u,Math.min(_+p+m-u,c));else o?(T<0&&(T=-1*Math.min(h-m,Math.abs(T))),m=Math.max(u,Math.min(p+m,m-T)),f-=s.dimensions.width,a.coordinates.x=Math.max(_+f,Math.min(_+f+h,c))):(T>0&&(T=Math.min(h-m,T)),m=Math.max(u,Math.min(h,m+T)),a.coordinates.x=Math.max(_+p+u,Math.min(_+p+h,c)));r.style.width=(s.size.width=m)+"px"}_handleTaskResize(e,t){const i=this,a=i._dragDetails,n=a.task;a.position||(a.position={x:a.originalPosition.x,y:a.originalPosition.y}),a.size||(a.size={width:a.originalSize.width}),a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const s=a.timelineRow,r=a.timelineTask,o=a.segment,l=e.pageX-window.pageXOffset;let d=a.size.width,c=a.min.width||0,m=a.max.width,u=s.getBoundingClientRect().left,h=i.rightToLeft,g="object"==typeof e?l-a.coordinates.x:e;if("left"===t&&!h||"right"===t&&h)if(o&&(h?(u-=o.dimensions.width-o.offset.x,c=Math.max(o.max.left+o.min.width,c)):(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.max.left+o.min.width,c))),h){g<0?g=-1*Math.min(Math.abs(g),d-(c||0)):void 0!==m&&(g=Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g));const e=r.offsetLeft;r.style.left="",r.style.right=(a.position.x=Math.max(0,(parseFloat(r.style.right)||s.offsetWidth-r.offsetLeft-r.offsetWidth)-g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+e+d,l))}else g>0?g=Math.min(g,d-(c||0)):void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+d,d-g)),r.style.right="",r.style.left=(a.position.x=Math.max(0,(parseFloat(r.style.left)||r.offsetLeft)+g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l));else h?(o&&(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.min.left+o.min.width,c)),g<0&&void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+r.offsetWidth,d-g)),r.style.width=a.size.width+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l))):(o&&(u-=o.dimensions.width-o.offset.x,c=Math.max(o.min.left+o.min.width,c)),g>0&&void 0!==m&&(g=Math.min(m-d,g)),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g)),a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+r.offsetLeft+(m||d),l)));r.style.width=a.size.width+"px"}_handleTimelineConnectionHover(e){const t=this;if(!(t.shadowRoot||t).contains(e))return;const i=t.$.timelineConnectionsContainer.children,a=e.closest(".smart-task-connection");if(a||!t.$.timelineConnectionsContainer.querySelector(".smart-task-connection[hover]")){if(a){const e=a.getAttribute("connection-id");for(let t=0;t<i.length;t++){const a=i[t];a.getAttribute("connection-id")===e?a.setAttribute("hover",""):a.removeAttribute("hover")}t._hoveredConnectionTasks=a.tasks}}else for(let e=0;e<i.length;e++)i[e].removeAttribute("hover")}_resetItemHover(){const e=this;if(e._hoveredItem){const t=e.$.mainSplitter.querySelectorAll(".smart-timeline-task[hover], .smart-timeline-row[hover], tr[hover]");for(let e=0;e<t.length;e++)t[e].removeAttribute("hover");e.$.timeline.removeAttribute("task-bar-hovered"),delete e._hoveredItem}}_handleTimelineHover(e,t){const i=this,a=i._isMobile;if(!e||a)return void i._resetItemHover();const n=e.originalEvent||e;let s="task",r=n.pageX&&a?document.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.target;if(n.pageX&&i.shadowRoot&&r===i&&(r=n.pageX&&a?i.shadowRoot.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.composedPath()[0]),!r||!r.closest||r===i||t)return void i._resetItemHover();i.$.resourceSplitter&&i.$.resourceSplitter.contains(r)?s="resource":i._handleTimelineConnectionHover(r);let o=r.closest(".smart-timeline-row")||r.closest(".smart-timeline-task");if(!o||!(i.shadowRoot||i).contains(o))return void i._resetItemHover();const l=o._cellObj[s],d=l.$.id,c=i._hoveredItem;if(!(c&&c.type===s&&c.id===d||(i._resetItemHover(),l.isGroup||("task"===s&&o.classList.contains("smart-timeline-row")&&(o=i.$.timelineTasksContainer.querySelector(`.smart-timeline-task[row-id="${d}"]`)),!o||i._connectionFeedback&&o.contains(i._connectionFeedback)||(o.setAttribute("hover",""),i._hoveredItem={id:d,type:s},a))))){const e=("task"===s?i.$.taskTimelineCellsContainer:i.$.resourceTimelineCellsContainer).querySelector(`.smart-timeline-row[row-id="${d}"]`);e&&(e.setAttribute("hover",""),i._handleTableItemHover(d,r))}}_getScrollLeft(e){return this.rightToLeft?e*=-1:e}_synchronizeSplitters(e,t){if(this.$.mainSplitter.contains(this.$.resourceSplitter)){const i=e._measurements,a=e.items,n=t.items,[s,r,o]=[i.dimension,i.minDimension,i.maxDimension],[l,d]=[n[0],a[0]],[c,m]=[n[1],a[1]];t.keepProportionsOnResize=!0,t.setAttribute("orientation-change",""),[r,o,s].forEach((e=>{const t=e===s?"size":e===r?"min":"max";l.set(t,""),c.set(t,""),l[t]=d.style[e],c[t]=m.style[e]})),t.removeAttribute("orientation-change"),t.keepProportionsOnResize=!1}}_resizeEventHandler(e){const t=this,i=t.$.taskSplitter;function a(e){e.refresh(),e===i&&t._synchronizeSplitters(i,t.$.resourceSplitter)}if(e&&"resizeEnd"===e.type){if(e.target===t.$.taskTreeSplitter||e.target===t.$.resourceTreeSplitter)return void a(e.target);e.target===t.$.resourceSplitter&&t._synchronizeSplitters(t.$.resourceSplitter,i)}if(!t._timelineCells)return void t._refresh();t.$.mainSplitter.refresh(),a(i);const n=t._getScrollLeft(t.scrollLeft);t._autoSchedule(),t._createTimelineCells(),t._recycleTimelineTasks(),t._recycleTimelineRowCells(),t._refreshResourceTimeline(),t._refresh(),t.$.taskTable.refresh(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=n,t.$.taskTable.scrollTop=t.$.taskTimelineContainer.scrollTop=t.scrollTop,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=n,t.$.resourceTable.refresh(),t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=t.$.resourceVerticalScrollBar.value),t._positionWindow()}_recycle(e){const t=this,i=e&&"horizontal"===e.context.orientation;if(e&&!i||(t._recycleHeaderCells(t.$.timelineViewCells),t._recycleHeaderCells(t.$.timelineViewDetails),t.$.timelineViewSubDetails.classList.contains("smart-hidden")||t._recycleHeaderSubCells(t.$.timelineViewSubDetails),t._recycleResourceContent()),i)return;if(t._recycleResourceContent(),t._recycleContentCells(),t._recycleTimelineTasks(),!e)return;const a=Math.round(e.detail.value);e.target!==t.$.resourceVerticalScrollBar?t._refreshTableScrollTop(t.$.taskTable,a):t._refreshTableScrollTop(t.$.resourceTable,a)}_recycleContentCells(){const e=this,t=e._getFirstContentCellInView(),i=e.$.taskTimelineCellsContainer,a=e.$.timelineTasksContainer;if(!t)return void(i.innerHTML=a.innerHTML="");const n=t.height,s=1-(t.top+n-Math.abs(e.scrollTop))/n,r=e._timelineVCells?e._timelineVCells.length:0,o=!e.$.taskSplitter.offsetHeight,l=e.$.taskTimelineContainer.offsetHeight,d=!o&&l?Math.min(r,Math.ceil((parseFloat((l/n).toFixed(2))+s).toFixed(2))):r,c=e.$.timelineViewCells.children,m=document.createDocumentFragment();for(;i.childElementCount>d;)i.lastElementChild.remove();for(;a.childElementCount>d;)a.lastElementChild.remove();for(let t=i.childElementCount;t<d;t+=1){const t=document.createElement("div");t.classList.add("smart-timeline-row"),e._createTimelineRowCells(t,c),m.appendChild(t)}m.childElementCount&&i.appendChild(m);for(let e=a.childElementCount;e<d;e+=1){const e=document.createElement("div");e.classList.add("smart-timeline-task"),m.appendChild(e)}m.childElementCount&&a.appendChild(m)}_getCellIndexByDate(e){const t=this._timelineCells;let i=[];if(e&&e.length&&t){Array.isArray(e)||(e=[e]);for(let t=0,a=e.length;t<a;t+=1){const a=e[t];e[t]=a.getTime?a.getTime():a,i[t]=-1}for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e.indexOf(n.date.getTime());if(s>-1&&(i[s]=a,i.every((e=>-1!==e))))break}return 1===i.length?i[0]:i}}_recycleDateMarkers(){const e=this,t=e.$.timelineMarkers,i=e._markers;if(!i||e.hideDateMarkers)return void(t.childElementCount&&(t.innerHTML=""));const a=e.$.timelineViewCells.children,n=a[0]._date,s=a[a.length-1]._date,[r,o]=e._getCellIndexByDate([n,s]);if(!n||!s)return;const l=n.getTime(),d=e._getCellDateRange({_date:s}).dateEnd.getTime(),c=t.children,[m,u]=e.rightToLeft?["right","left"]:["left","right"],h=document.createDocumentFragment();let g=0;for(let t=0,a=i.length;t<a;t+=1){const a=i[t],n=i[t].date,s=n.getTime();if(s<l||s>d)continue;const f=e._getTimelineCellByDate(n,r,o);if(f){const t=f.left+e._getTimelineTaskOffset(f,n),i=a.label,s=a.className;let r=c[g];r||(r=document.createElement("div"),h.appendChild(r)),r.className="smart-gantt-chart-date-marker",void 0!==i&&(r.firstElementChild||(r.innerHTML='<div class="smart-gantt-chart-marker-label"></div>'),r.firstElementChild.textContent=i+""),void 0!==s&&r.classList.add(s),r.style[u]="",r.style[m]=t+"px",g++}}for(h.childElementCount&&t.insertBefore(h,t.firstElementChild);c.length>g;)c[c.length-1].remove()}_refreshTableScrollTop(e,t){this.$.mainSplitter.contains(e)&&void 0!==t&&(e.scrollTop=t)}_recycleHeaderCells(e){let t=this,i=e.children,a=t.scrollLeft,n=e===t.$.timelineViewCells,s=n?t._timelineCells:t._timelineHeaderCells;if(e===t.$.timelineViewSubDetails&&(n=!1,s=t._timelineHeaderSubCells),!s.length)return;let r=document.createDocumentFragment();for(;i.length;)r.appendChild(e.firstElementChild);let o=t._getFirstCellObjInView(s),l=1-(o.left+o.width-Math.abs(a))/s[0].width,d=r.children.length,c=n?Math.ceil((parseFloat((t.$.timeline.offsetWidth/o.width).toFixed(2))+l).toFixed(2)):t._getHeaderVisibleCellsCount();if(e===t.$.timelineViewSubDetails&&(c=t._getHeaderSubVisibleCellsCount()),d>c)for(;r.children.length&&r.children.length!==c;)r.removeChild(r.firstElementChild);else if(d<c){const e=t._createCells(c-d);for(;e.children.length;)r.appendChild(e.firstElementChild)}const m=[t.rightToLeft?"right":"left"],u=n?t._getCellsViewType():t.view;let h=s.indexOf(o);for(let e=0;e<r.children.length;e++){const i=r.children[e],a=s[h];if(!a)break;let o=new Date(a.date);n||"week"!==t.view||(o.setDate(o.getDate()-o.getDay()),o=new Date(Math.max(a.date.getTime(),o.getTime()))),i.style[m]=a.left+"px",i.style.width=a.width+"px",i._date=o,i.innerHTML=`<div>${t._getDateString(o,u,!n)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),h++}e.appendChild(r),n&&(t._recycleTimelineRowCells(),t._recycleResourceHeaderCells(),t._recycleDateMarkers(),t._setTodayCell())}_recycleHeaderSubCells(e){let t=this,i=e.children,a=t.scrollLeft,n=t._timelineHeaderSubCells;if(!n.length)return;let s=document.createDocumentFragment();for(;i.length;)s.appendChild(e.firstElementChild);let r=t._getFirstCellObjInView(n),o=(r.left,r.width,Math.abs(a),n[0].width,s.children.length),l=t._getHeaderSubVisibleCellsCount();if(o>l)for(;s.children.length&&s.children.length!==l;)s.removeChild(s.firstElementChild);else if(o<l){const e=t._createCells(l-o);for(;e.children.length;)s.appendChild(e.firstElementChild)}const d=[t.rightToLeft?"right":"left"],c=t.view;let m=n.indexOf(r);for(let e=0;e<s.children.length;e++){const i=s.children[e],a=n[m];if(!a)break;let r=new Date(a.date);"week"===t.view&&(r.setDate(r.getDate()-r.getDay()),r=new Date(Math.max(a.date.getTime(),r.getTime()))),i.style[d]=a.left+"px",i.style.width=a.width+"px",i._date=r,i.innerHTML=`<div>${t._getDateString(r,c,!0)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),m++}e.appendChild(s),t._refreshHeaderSubDetailsDate()}_refresh(){const e=this;let t="disabled"===e.verticalScrollBarVisibility;function i(){const t=e.$.timelineHeader,i=t.scrollWidth-t.offsetWidth;return i>0&&"hidden"!==e.horizontalScrollBarVisibility||"visible"===e.horizontalScrollBarVisibility?e.$container.addClass("hscroll"):e.$container.removeClass("hscroll"),i}function a(){let i=Math.max(0,e.$.timelineContent.offsetHeight-e.$.taskTimelineContainer.offsetHeight);return i>0&&"hidden"!==e.verticalScrollBarVisibility||"visible"===e.verticalScrollBarVisibility?e.$container.addClass("vscroll"):e.$.mainSplitter.contains(e.$.resourceSplitter)?(i=1,t=!0,e.$.resourceVerticalScrollBar.max||e.$container.removeClass("vscroll")):e.$container.removeClass("vscroll"),i}const n=e.scrollWidth,s=e.scrollHeight;let r=i(),o=a();o&&s===o||(r=i()),r&&n===r||(o=a()),e.scrollWidth=r,e.scrollHeight=o,e.$.verticalScrollBar.disabled=t,e.$.horizontalScrollBar.refresh(),e.$.verticalScrollBar.refresh(),e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._refreshResourceScrollBar(),e._refreshTableScrollTop(e.$.resourceTable))}_refreshProjectTasks(e,t){const i=this,a=i._getProjectTasks(e);if(!a.length)return;const n=i.nonworkingDays,s=i.nonworkingHours,r=i._timelineVCells;for(let e=0,o=a.length;e<o;e++){const o=a[e];if(o){const e=i._getTaskDOMIndex(o),a=r[e],l=o.segments;if(o.dateStart=new Date(Math.max(i.dateStart.getTime(),o.dateStart.getTime()+t.startTime)),o.dateEnd=new Date(Math.min(i.dateEnd.getTime(),o.dateEnd.getTime()+t.endTime)),o.duration=i._convertDuration(n.length>0||s.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),l&&l.length>1){for(let e=0,i=l.length;e<i;e+=1){const i=l[e];i.dateStart=new Date(i.dateStart.getTime()+t.startTime),i.dateEnd=new Date(i.dateEnd.getTime()+t.endTime)}i._validateTaskSegments(o)}a&&(i._recycleTaskBars(a,e),i._setTimelineTaskBar(a,e),l&&l.length>1&&i._setTaskBarProgress(o),i._refreshTaskConnections(o),i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"]))}}}_refreshProject(e){const t=this;function i(e){let i,a,n;if(e instanceof HTMLElement)i=e.offsetLeft,n=e.offsetWidth;else if(e){const s=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);s&&r&&(i=s.left+t._getTimelineTaskOffset(s,e.dateStart)||0,a=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0,n=a-i)}return[i,n]}if(!e)return;const a=t.groupByResources&&e.isGroup?"group":"project";if(e.synchronized)for(;e&&e.synchronized;){const n=t._getProjectTasks(e);let s=n[0],r=n[0];for(let e=0;e<n.length;e++)s.dateStart.getTime()>=n[e].dateStart.getTime()&&(s=n[e]),r.dateEnd.getTime()<=n[e].dateEnd.getTime()&&(r=n[e]);const o=t.$.timelineTasksContainer.children,l=t.$.timelineContent.offsetWidth;let d,c,m;for(let t=0,i=o.length;t<i;t+=1){const i=o[t],a=i._cellObj?i._cellObj.task:void 0;a&&(a===e?d=i:a===s?c=i:a===e&&(m=i))}if(!d){s&&(e.dateStart=s.dateStart),r&&(e.dateEnd=r.dateEnd),e=e.$[a];continue}s&&(e.dateStart=s.dateStart);let[u,h]=i(c||s);void 0!==u&&void 0!==h&&(t.rightToLeft?(d.style.width=d.offsetWidth-(l-u-h-(l-d.offsetLeft-d.offsetWidth))+"px",d.style.right=c?c.style.right:u+"px"):(d.style.width=d.offsetWidth-(u-d.offsetLeft)+"px",d.style.left=c?c.style.left:u+"px")),r&&(e.dateEnd=r.dateEnd),[u,h]=i(m||r),void 0!==u&&void 0!==h&&(t.rightToLeft?d.style.width=Math.max(0,d.offsetWidth-(l-d.offsetLeft-(l-u)))+"px":d.style.width=Math.max(0,d.offsetWidth-(d.offsetLeft+d.offsetWidth-(u+h)))+"px"),t._refreshTask(d),e=e.$[a]}else t._refreshProject(e.$[a])}_refreshTask(e,t){const i=this,a=i._getTaskBarCellRange(e),n=a.cellStart,s=a.cellEnd;if(!a||!n||!s)return;e._cellStart=n,e._cellEnd=s;const r=i._getTaskBarDateRange(e);if(!r)return;const o=e._cellObj.task;if(Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===o))){if(o.dateStart=r.dateStart,o.dateEnd=r.dateEnd,o.duration=o.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),e.setAttribute("aria-label",o.label+" Start date: "+i._toISODate(o.dateStart)+", End date: "+i._toISODate(o.dateEnd)),i._refreshTaskConnections(e),t)Array.isArray(t)&&i._refreshTaskSegments(e,t);else{const t=i._dragDetails;let a;e.classList.contains("task")?t&&t.segments?a=t.segments:t.segments=a=e.querySelectorAll(".smart-task-segment"):a=e.querySelectorAll(".smart-task-segment"),i._refreshTaskSegments(e,a)}i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"])}}_refreshTaskSegments(e,t){const i=this,a=e._cellObj.task;if(!a||!a.segments||!a.segments.length)return void i._setTaskBarDeadline(a,t?t[0]:void 0);const n=i.nonworkingDays.length>0||i.nonworkingHours.length>0,s=i.rightToLeft,r=s?"right":"left",o=parseFloat(e.style[r])||e.offsetLeft;let l;for(let a=0,d=t.length;a<d;a+=1){const d=t[a],c=d._segmentObj,m=i._getSegmentCellRange(d),u=m.cellStart,h=m.cellEnd;if(!m||!u||!h)continue;const g=parseFloat(d.style.width)||d.offsetWidth,f=o+parseFloat(d.style[r])||(s?(parseFloat(e.style.width)||e.offsetWidth)-(d.offsetLeft+d.offsetWidth):d.offsetLeft);d._cellStart=u,d._cellEnd=h,l=d;let p=i._getDateFromCell(f,u),_=i._getDateFromCell(f+g,h);c.dateStart=p,c.dateEnd=_,c.duration=i._convertDuration(n?i._getWorkingTime(p,_):_.getTime()-p.getTime(),!0),e.setAttribute("aria-label",(c.label||"")+" Start date: "+i._toISODate(p)+", End date: "+i._toISODate(_))}i._setTaskBarProgress(a,e),i._setTaskBarDeadline(a,l)}_refreshTaskResources(e,t=[]){const i=this;if(e&&(t||(t=i._getTaskResources(e)),t.length))for(let e=0;e<t.length;e++){const a=t[e];i._refreshResource(a),i._refreshTableColumnsData(a,void 0,"resource")}}_refreshTableColumnsData(e,t,i){const a=this;if(i||(i="task"),!e)return;const n=a[`${i}Columns`],s=a.$[`${i}Table`];if(!a.$.mainSplitter.contains(s))return;const r=e.$.id;t=t?t.map((e=>n.find((t=>t.value===e)))):n;for(let i=0;i<t.length;i++){const n=t[i];n&&s.setValue(r,n.value,a._formatColumnData(e,n))}a.$[`${i}Splitter`].refresh()}_removeConnection(e,t){const i=this,a=i.$.connectionPopupWindow,n=i.$.timelineConnectionsContainer;if(e.classList&&e.classList.contains("smart-task-connection")?e=e.getAttribute("connection-id"):e+="",void 0===e)return;const s=n.querySelectorAll('.smart-task-connection[connection-id^="'+e+(e.indexOf("-")<0?"-":"")+'"]'),r=i._tasks,o=e.split("-"),l=parseInt(o[1]);for(let e=0;e<s.length;e++)n.removeChild(s[e]);let d;const c=parseInt(o[0]),m=parseInt(o[1]),u=parseInt(o[2]);if(a&&void 0!==a._target&&"number"==typeof a._target.type){const t=a._target;d=t.startIndex+"-"+t.endIndex+"-"+t.type===e}i._updateConnection([c,m,u],!0),!t&&i.autoSchedule&&(i._autoScheduleRestore(r[l],parseInt(o[2])),i._autoSchedule(r[l])),d&&i.$.fireEvent("itemRemove",{type:"connection",id:`${c}-${m}-${u}`,item:{source:c,target:m,type:u}})}_removeTaskConnections(e,t){const i=this,a=i._connections;if(a&&a.length){for(let t=0,i=a.length;t<i;t+=1)a[t].startTask===e&&(a.splice(t,1),i--);e.connections=[],t&&i._recycleConnections()}}_removeTask(e){const t=this,i=t._tasks;if(!e||!i||!i.length)return;const a=t._getSelection("task",t.selectedTaskIds),n=t.$.taskPopupWindow;let s;if(t._highlightAssignedItem("task",[e]),n&&n._target===e&&n.close(),"project"===e.type){const a=t._getProjectTasks(e);for(let e=0,t=a.length;e<t;e+=1)i.splice(i.indexOf(a[e]),1)}if(i.splice(i.indexOf(e),1),t._refreshItemIds(),t._refreshConnectionIds(),t._isUpdating)return t._isUpdating.type.task=!0,void(t._isUpdating.type.resource=!0);t._refreshSelectedItems(),t._refreshTableDataSource(),t._refreshTimeline(),t._selected&&t._selected.task&&(s=t._selected.task.map((e=>e.$.id)),a.toString()!==s.toString()&&(t.$.taskTable.selected=t._getSelection("task",t.selectedTaskIds))),t.$.fireEvent("itemRemove",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}_removeResource(e){const t=this,i=t._resources,a=i.indexOf(e);if(e&&!(a<0)){if(t._isUpdating)return i.splice(a,1),t._isUpdating.type.resource=!0,void(t._isUpdating.type.task=!0);if(i.splice(a,1),t.groupByResources)t._refreshTableDataSource(),t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks();else if(t.taskColumns.find((e=>"resources"===e.value))){const i=t._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<i.length;e++)t._refreshTableColumnsData(i[e],["resources"])}if(!i.filter((e=>!e.hidden)).length)return t._createResourceTimeline(),t._resizeEventHandler(),void n();t._refreshResourceTimeline(),t._refreshTableDataSource("resource"),t.$.mainSplitter.contains(t.$.resourceSplitter)?(t._refreshResourceScrollBar(),t._resizeEventHandler(),n()):n()}function n(){t.$.fireEvent("itemRemove",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}}_updateTask(e,t){const i=this,a=i._tasks;if(!e||!a||!a.length)return;const n=i.$.taskPopupWindow,s=i._getSelection("task",i.selectedTaskIds);n&&n._target===e&&n.close();let r,o=i._getTaskResources(e);for(let n in t){let s=e[n],l=t[n];if("type"===n&&s!==l&&["task","project","milestone"].indexOf(l)>-1&&"project"===s){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)a.splice(a.indexOf(t[e]),1);delete e.tasks}if("project"!==e.type||!e.synchronized||!(n.toLowerCase().indexOf("date")>-1||n.toLowerCase().indexOf("duration")>-1))if("dateEnd"===n&&new Date(s).getTime()!==new Date(l).getTime()&&(r=!0),"tasks"!==n)"connections"===n&&(i._removeTaskConnections(e),i._handleTaskConnections(e)),e[n]=l,"resources"===n&&(i._handleResources(e),e.disableResources||(o=o.concat(i._getTaskResources(e)),o=o.filter(((e,t)=>o.indexOf(e)===t)))),"milestone"!==e.type||"dateStart"!==n&&"dateEnd"!==n||(e.dateEnd=e.dateStart=l);else if("project"===e.type){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)a.splice(a.indexOf(t[e]),1);const n=i._createTasks(l,!0);for(let t=0,i=n.length;t<i;t+=1)n[t].$.project=e;i._insertTasks(n,e,a.indexOf(e))}}r&&delete e.duration;const l=e.$,d=e.$.project;if(i._validateTaskProperties(e,d),e.$=l,d&&i._synchronizeProjectDates(d),"project"===e.type&&e.hidden&&i._getProjectTasks(e).forEach((t=>t.hidden=e.hidden)),i._synchronizeProjectVisibility(e.$.project,e),i._refreshItemIds(),i._refreshConnectionIds(),i._isUpdating)return void(i._isUpdating.type.task=!0);let c;i._selected&&i._selected.task&&i._setSelection("task",c=i._selected.task.map((e=>e.$.id))),i._refreshTableDataSource(),i._refreshTimeline(),i._ensureVisible(e),c&&s.toString()!==c.toString()&&(i.$.taskTable.selected=c.slice(0)),i._refreshTaskResources(e,o),i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i.$.fireEvent("itemUpdate",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}_updateResource(e,t){const i=this;if(!e)return;const a=e.hidden;if(i._setResource(e,t),i._isUpdating)i._isUpdating.type.resource=!0;else{if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const t=i._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<t.length;e++)i._refreshTableColumnsData(t[e],["resources"])}if(a!==e.hidden)return i._createResourceTimeline(),void i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)});if(i._refreshTableColumnsData(e,void 0,"resource"),i.$.mainSplitter.contains(i.$.resourceTimelineCellsContainer)){const t=i.$.resourceTimelineCellsContainer.children;for(let a=0;a<t.length;a++){const n=t[a];n._resource===e&&i._refreshResourceTimelineContent(e,n)}}i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}}_select(e="task",t){const i=this;if(i.disableSelection||!t)return void i._unselectAll(e);let a,n;"task"===e?(a="selectedTaskIds",n=i._tasks):(a="selectedResourceIds",n=i._resources);const s=n.findIndex((e=>e.$.id===t)),r=i._getSelection(e,i[a]);s<0||(r.indexOf(t)>-1?i.$[`${e}Table`].unselect(t):i.$[`${e}Table`].select(t))}_handleTableSelection(e="task",t){const i=this;if(i.disableSelection||!t.length)return void i._unselectAll(e);let a,n,s,r,o,l=i._selected;l||(l=i._selected={});const d=t[t.length-1],c=l[e]=[];"task"===e?(o=i._tasks,a="selectedTaskIds",n=i.$.taskTimelineCellsContainer.children,s=i.$.timelineTasksContainer.children):(o=i._resources,a="selectedResourceIds",n=i.$.resourceTimelineCellsContainer.children,s=[]);for(let e=0,i=o.length;e<i;e+=1){const i=o[e];t.indexOf(i.$.id)>-1&&c.push(i)}for(let i=0,a=n.length;i<a;i+=1){const a=n[i],o=s[i],l=a._cellObj[e].$.id;d===l&&(r=s[i]),t.indexOf(l)>-1?(a.setAttribute("selected",""),a.setAttribute("aria-selected","true"),o&&o.setAttribute("selected","")):(a.removeAttribute("selected"),a.setAttribute("aria-selected","false"),o&&o.removeAttribute("selected"))}const m=i[a].slice(0);if(i._setSelection(e,t),!i._tableChangeEventFired){const a=document.scrollingElement||document.documentElement,n=a.scrollLeft,s=a.scrollTop;i._highlightAssignedItem(e,t),i.$[`${e}Table`].focus({preventScroll:!0}),window.scrollTo(n,s)}if("task"===e&&r){const e=r._cellStart;if(i.scrollLeft>e.left||e.left+r.offsetWidth>i.scrollLeft+i.$.timeline.offsetWidth){const t=i._timelineCells.indexOf(e);i._scrollTo((i._timelineCells[t-1]?i._timelineCells[t-1]:e).date)}}i._noChangeEvent||i.$.fireEvent("change",{type:e,value:i[a].slice(0),oldValue:m})}_setSelection(e="task",t){const i=this;let[a,n]="task"===e?[i._tasks,"selectedTaskIds"]:[i._resources,"selectedResourceIds"],s=[];for(let e=0,i=t.length;e<i;e+=1){const i=t[e],n=a.find((e=>e.$.id===i));n&&s.push(void 0!==n.id?n.id:i)}i.set(n,s)}_getSelection(e="task",t){const i="task"===e?this._tasks:this._resources;let a=t.slice(0);if(!t||!t.length)return a;for(let e=0,n=i.length;e<n;e+=1){const n=i[e],s=t.indexOf(n.id);s>-1&&(a[s]=n.$.id)}return a}_highlightAssignedItem(e,t){const i=this,[a,n]="task"===e?["resource","_getTaskResources"]:["task","_getResourceTasks"],s=i.$[`${a}Table`],r=i[`_${a}s`];if(!s||!i.$.mainSplitter.contains(s)||!r.length)return;t&&Array.isArray(t)||(t=[]);let o=[];for(let a=0,s=t.length;a<s;a+=1){const s=i._getValidItemAndIndex(t[a],e);s&&(o=o.concat(i[n](s.item).filter((e=>!e.hidden))))}i._tableChangeEventFired=!0,s.selected=o.map((e=>e.$.id)),o.length&&i._ensureVisible(o[0],a),delete i._tableChangeEventFired}_selectResource(e){const t=this,i=t._resources.indexOf(e);if(i<0)return void t._unselectAll("resource");const a=t.$.resourceTimelineCellsContainer.children[i];a&&a.hasAttribute("selected")?t._unselectAllTasks():t.$.resourceTree.focus({preventScroll:!0})}_snapToNearest(e,t){const i=this;if(!(i.snapToNearest&&e&&e.classList&&e.classList.contains("smart-timeline-task")&&e._cellObj))return;const a=e._cellObj.task,n=a.segments;if(t&&t.classList.contains("smart-task-segment")){const a=n.indexOf(t._segmentObj),s=0===a,r=a===n.length-1;if(i._handleSnapToNearestSegment(e,t,s?"first":r?"last":void 0),i._refreshTaskSegments(e,[t]),!s&&!r)return;i._refreshTask(e,!0)}else i._handleSnapToNearest(i._getTaskBarCellRange(e),e),i._refreshTask(e);if(n&&n.length>1){for(let e=0,t=n.length;e<t;e+=1)i._snapToNearestDates(n[e],!0);i._validateTaskSegments(a),a.segments.length!==n.length&&i._recycleSegments(a,e),i._setTaskBarSegments(e._cellObj,e,!0),i._setTaskBarProgress(a)}if("project"!==a.type||!a.dragProject)return;const s=i._getProjectTasks(a);if(s&&Array.isArray(s))for(let e=0;e<s.length;e++){const t=i.$.timelineTasksContainer.children[i._tasks.indexOf(s[e])];t&&i._snapToNearest(t)}}_handleSnapToNearestSegment(e,t,i){const a=this,n=a.rightToLeft,s=n?"right":"left",r=parseFloat(e.style[s])||0,o=t,l=a._getSegmentCellRange(t),d=l.cellStart,c=l.cellEnd,m="first"===i,u="last"===i;let h=parseFloat(o.style.width)||o.offsetWidth,g=parseFloat(o.style[s])||0,f=r+g;if(a.hasAttribute("dragged")){const t=c.width-(f+h-c.left);let a;if(f-d.left<=t?(a=d.left-r,o.style[s]=Math.max(0,m?0:a)+"px"):(a=g+t,o.style[s]=Math.max(0,m?0:a)+"px"),i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&(e.style[s]=r+(a-g)+"px"),e.style.width=t+(m?-1:1)*(a-g)+"px"}}else if(a.hasAttribute("resized")){const t=d===c?a._taskBarMinWidth:0;let l;if("left"===a.$.timeline.getAttribute("task-bar-hovered")){if(l=f-d.left,l-=l>=d.width/2?d.width-t:0,f-=l,o.style[s]=Math.max(0,m?0:f-r)+"px",l=f+h>c.left+c.width/2?c.left+c.width-(f+h):c.left-(f+h),o.style.width=Math.max(t,h+l)+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&!n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&n&&(e.style.width=t+l+"px")}}else if(f>d.left+d.width/2?(f=d.left+d.width,o.style[s]=Math.max(0,m?0:f-r)+"px"):(f=d.left,o.style[s]=Math.max(0,m?0:f-r)+"px"),l=f+h-c.left,l=-1*(l-(l>=d.width/2?c.width:t)),o.style.width=h+l+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&!n&&(e.style.width=t+l+"px")}}}_handleSnapToNearest(e,t){const i=this;if(!e)return;const a=i.rightToLeft?"right":"left",n=e.cellStart,s=e.cellEnd;let r=parseFloat(t.style.width)||t.offsetWidth,o=parseFloat(t.style[a])||0;if(i.hasAttribute("dragged")){const e=s.width-(o+r-s.left);o-n.left<=e?t.style[a]=n.left+"px":t.style[a]=o+e+"px"}else if(i.hasAttribute("resized")){const e=n===s?i._taskBarMinWidth:0;let l;"left"===i.$.timeline.getAttribute("task-bar-hovered")?(l=o-n.left,l-=l>=n.width/2?n.width-e:0,t.style[a]=(o-=l)+"px",l=o+r>s.left+s.width/2?s.left+s.width-(o+r):s.left-(o+r),t.style.width=Math.max(e,r+l)+"px"):(o>n.left+n.width/2?t.style[a]=n.left+n.width+"px":t.style[a]=n.left+"px",o=parseFloat(t.style[a])||0,l=o+r-s.left,l=-1*(l-(l>=n.width/2?s.width:e)),t.style.width=r+l+"px")}}_setDragLimits(e){const t=this,i=t._dragDetails;if(!i)return;const a=i.timelineTask;if(!a||!e)return;const n=t.$.timeline.getAttribute("task-bar-hovered"),s=a._cellObj.task;if(n){if(s.disableResize)return void delete t._dragDetails;const e=t._getTaskBarSizeLimits(a,n);i.min.width=e.min,i.max.width=e.max,t._setSegmentLimits(n);const r=t._createDelimiter("min",n),o=t._createDelimiter("max",n);r&&a.appendChild(r),o&&a.appendChild(o)}else if(e.closest(".smart-task-connection-point"))i.timelineTask=void 0;else if(e.closest(".smart-timeline-task")===a){let e;if(t._connections){const i=t._tasks.indexOf(a._cellObj.task);e=t._connections.some((e=>e.startIndex===i||e.endIndex===i))}if(s.disableDrag||e&&t.autoSchedule&&t.autoScheduleStrictMode)return void delete i.target;i._taskDuration=t._getWorkingTime(s.dateStart,s.dateEnd),a.classList.contains("milestone")&&(i.target="smart-timeline-task-fill");const n=t._getTaskDragLimits(a),r=t.rightToLeft?t.$.timelineContent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft;if(void 0!==n.min&&(i.min.left=n.min,"project"===a._cellObj.task.type&&n.min>r&&(i.min.left=r)),void 0!==n.max&&(i.max.left=n.max,"project"===a._cellObj.task.type&&n.max<r&&(i.max.left=r)),"project"===s.type&&s.dragProject&&!t.synchronized){const e=t._getSubTaskLimits(a);void 0!==e.min&&(i.min.left=i.min.left?Math.max(i.min.left,e.min):e.min),void 0!==e.max&&(i.max.left=i.max.left?Math.min(i.max.left,e.max):e.max)}else"milestone"===s.type&&(i.target="smart-timeline-task-fill");t._setSegmentLimits()}else i.timelineTask=void 0;i.relatedConnections={}}_setSegmentLimits(e){const t=this,i=t._dragDetails;if(!i||!i.segment)return;const a=i.segment;if(a){const n=a.element,s=a.dimensions,r=n.previousElementSibling,o=n.nextElementSibling;if(a.min.width=e?t._taskBarMinWidth:0,t.rightToLeft){if(r)a.min.left="left"===e?s.left+s.width:r.offsetLeft-(e?0:s.width),"right"===e&&(a.max.width=r.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}if(o)a.max.left="right"===e?a.dimensions.left:o.offsetLeft+o.offsetWidth+s.width,e&&"left"!==e||(a.max.width=s.left+s.width-(o.offsetLeft+o.offsetWidth));else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}}else{if(r)a.min.left="right"===e?s.left:r.offsetLeft+r.offsetWidth+(e||o?0:s.width),"left"===e&&(a.max.width=s.left+s.width-a.min.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}if(o)a.max.left="left"===e?s.left+s.width:o.offsetLeft-s.width,e&&"right"!==e||(a.max.width=o.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}}}}_setScrollBars(){const e=this;e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;i.$.addClass("smart-hidden"),t.$.addClass("smart-hidden"),t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.rightToLeft=i.rightToLeft=e.rightToLeft,i.wait=!1,e._refresh()}_getWorkingTime(e,t){const i=this;if(!e||!t)return;if(!i.adjustToNonworkingTime)return t.getTime()-e.getTime();const a=i.nonworkingHours,n=i.nonworkingDays;function s(e,t){let s,r,o=t.getTime()-e.getTime(),l=new Date(e),d=0;for(;o>0;){const e=Math.min(o,36e5-(60*l.getMinutes()*1e3+1e3*l.getSeconds()+l.getMilliseconds()));if(n.indexOf(l.getDay())>-1)r=new Date(l),r.setHours(0,0,0,0),r.setDate(l.getDate()+1),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s;else if("day"===i.view&&a.indexOf(l.getHours())>-1){r=new Date(l);const t=r.getTime();r.setHours(l.getHours()+1,0,0,0),t===r.getTime()&&r.setHours(l.getHours()+2,0,0,0),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s}else d+=e,o-=e,l=new Date(l.getTime()+e)}return d}if(e.getFullYear()===t.getFullYear())return s(e,t);let r=new Date(e.getFullYear()+1,0,1,0,0,0,0),o=s(e,r);if(t.getFullYear()>r.getFullYear()){const e=Math.max(0,t.getFullYear()-r.getFullYear());for(let t=0;t<e;t++){let e=i._getWorkingDaysBetweenDays(r);o+=60*(24*e-e*i.nonworkingHours.length)*60*1e3,r.setFullYear(r.getFullYear()+1)}}return o+=s(r,t),o}_getWorkingDaysBetweenDays(e){const t=this,i=e.getFullYear(),a=(i%100==0?i%400==0:i%4==0)?366:365;let n=new Date(e),s=0;for(let e=0;e<a;e++)t.nonworkingDays.indexOf(n.getDay())<0&&s++,n.setDate(n.getDate()+1);return s}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.tabIndex=-1:e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setTaskBarLabel(e,t){const i=this;void 0===t&&(t=i._getTaskDOMIndex(e));const a=i.$.timelineTasksContainer.children[t];if(!a)return;const n=a.querySelector(".smart-task-segments").children;let s=e.segments;Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);for(let r=0,o=s.length;r<o;r+=1){const o=s[r],l=n[r],d=l?l.getElementsByClassName("smart-timeline-task-label")[0]:void 0;if(!d)continue;d.firstElementChild||(d.innerHTML="<div></div>");let c=d.firstElementChild;"string"==typeof o.label||"number"==typeof o.label?c.textContent=o.formatFunction?o.formatFunction(o.label||"",t)||"":o.label||"":c.textContent=e.formatFunction?o.formatFunction(e.label||"",t)||"":e.label||"",i.onTaskRender&&i.onTaskRender(e,o,a,l,c),e.onRender&&e.onRender(e,o,a,l,c)}}_setTaskBarProgress(e,t){const i=this;if("number"==typeof t?t=i.$.timelineTasksContainer.children[t]:void 0===t&&(t=i.$.timelineTasksContainer.children[i._getTaskDOMIndex(e)]),!t||!e)return;let a=e.progress;const n=t.querySelector(".smart-timeline-task-progress-thumb");if(!n)return;a=Math.min(100,Math.max(0,a))||0;const s=e.dateStart.getTime(),r=e.dateEnd.getTime(),o=t.querySelector(".smart-task-segments").children;let l,d,c=e.segments,m=0;c&&c.length||(c=[e]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=o[e],n=i?i.querySelector(".smart-timeline-task-progress"):void 0;if(!n)continue;const u=(t.dateStart.getTime()-s)/(r-s)*100,h=(t.dateEnd.getTime()-s)/(r-s)*100,g=Math.max(0,Math.min(100,(a-u)/(h-u)*100));n.style.width=g+"%",n.removeAttribute("value"),i.removeAttribute("show-progress-label"),a>=u?(m=Math.max(u,Math.min(a,h)),l=n,d=i):l||(l=n,d=i)}if(n.style[i.rightToLeft?"left":"right"]="",n.style[i.rightToLeft?"right":"left"]=m+"%",!l||!i.showProgressLabel)return;const u=i.progressLabelFormatFunction;d.setAttribute("show-progress-label",""),l.setAttribute("value",u?u(a)+"":parseFloat(a.toFixed(2))+"%")}_setTaskDeadline(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,o=n.deadline,l=a.$.timelineDeadlines,d=l.children,c=o&&o.getTime&&!isNaN(o.getTime())?o.getTime():void 0;let m;for(let e=0,i=d.length;e<i;e+=1){const i=d[e];if(parseInt(i.getAttribute("task-index"))===t){m=i;break}}if(!c||c<s||c>r)return void(m&&m.remove());const u=a._getTimelineCellByDate(o),[h,g]=a.rightToLeft?["right","left"]:["left","right"];m||(m=document.createElement("div"),m.classList.add("smart-gantt-chart-task-deadline"),m.setAttribute("task-index",t),l.appendChild(m)),m.setAttribute("date",o.toString()),m.setAttribute("title",a._formatDate(o)),m.style.top=e.top+"px",m.style[g]="",m.style[h]=u.left+(a._getTimelineTaskOffset(u,o)||0)+"px"}_setTaskBarDeadline(e,t){const i=this,a=e.deadline;if(!a||!a.getTime||isNaN(a)||!t)return;const n=e.deadline.getTime()-e.dateEnd.getTime();if(!e.deadline||n>0)return t.removeAttribute("deadline"),void(e.overdue=!1);e.overdue=!0,t.setAttribute("deadline",`${i.localize("overdue")}: ${Math.round(i._convertDuration(Math.abs(n),!0))} ${i.durationUnit+"s"}`)}_setTaskIndicators(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,[o,l]=a.rightToLeft?["right","left"]:["left","right"],d=a.$.taskIndicatorsContainer,c=d.children,m=n.indicators;let u;for(let e=0,i=c.length;e<i;e+=1){const i=c[e];if(parseInt(i.getAttribute("task-index"))===t){u=i;break}}if(!Array.isArray(m))return void(u&&u.remove());const h=document.createDocumentFragment(),g=document.createDocumentFragment();u||(u=document.createElement("div"),u.classList.add("smart-gantt-chart-indicator"),u.setAttribute("task-index",t),h.appendChild(u));const f=u.children;for(;f.childElementCount>m.length;)f.firstElementChild.remove();for(let t=0,i=m.length;t<i;t+=1){let i=f[t];const n=m[t],d=n.date;if(!d||!d.getTime){i&&i.remove();continue}const c=d.getTime();if(c<s||c>r){i&&i.remove();continue}const u=a._getTimelineCellByDate(d),h=n.label,p=n.className,_=n.icon;i||(i=document.createElement("div"),g.appendChild(i)),i.className="smart-gantt-chart-task-indicator",i._indicatorObj=n;const T=i.classList;"string"==typeof p&&T.add(p),_?(T.add("icon"),i.style.setProperty("--smart-gantt-chart-indicator-icon",`'${_}'`)):T.contains("icon")&&(T.remove("icon"),i.style.removeProperty("--smart-gantt-chart-indicator-icon")),i.textContent=h||"",i.style.top=e.top+"px",i.style[l]="",i.style[o]=u.left+(a._getTimelineTaskOffset(u,d)||0)+"px"}g.childElementCount&&u.appendChild(g),h.childElementCount&&d.appendChild(h)}_setTimelineTaskBar(e,t,i){const a=this,n=e.task,s=void 0===t?a._getTaskDOMIndex(n):t,r=a.$.timelineTasksContainer.children,o=r[s];let l,d;if(0===r.length||!o||!o.classList||!o.classList.contains("smart-timeline-task"))return;const c=n.dateStart instanceof Date?n.dateStart:new Date(n.dateStart),m=n.dateEnd instanceof Date?n.dateEnd:new Date(n.dateEnd);if(l=!i&&o._cellStart||a._getTimelineCellByDate(c),d=!i&&o._cellEnd||a._getTimelineCellByDate(m),!l||!d)return void o.classList.add("smart-visibility-hidden");o._cellStart=l,o._cellEnd=d,o.classList.remove("smart-visibility-hidden");const u=a._getTaskBarDetails(e,l,d);u&&(o.style[a.rightToLeft?"left":"right"]="",o.style[a.rightToLeft?"right":"left"]=u.left+"px",o.style.width=u.width?u.width+"px":"",o.style.top=u.top+"px"),a._setTaskBarSegments(e,o,i)}_setTimelineTaskBaseline(e,t){const i=this,a=e.task,n=i.$.timelineBaselinesContainer;if(!i.showBaseline)return void(n.innerHTML&&(n.innerHTML=""));const s=a.planned,r=n.children;let o;for(let e=0,i=r.length;e<i;e+=1){const i=r[e];if(parseInt(i.getAttribute("task-index"))===t){o=i;break}}if(!s||"milestone"===a.type||!s.dateStart||!s.dateEnd)return void(o&&o.remove());const l=s.dateStart,d=s.dateEnd,c=i._getTimelineCellByDate(l),m=i._getTimelineCellByDate(d);if(!c||!m)return;o||(o=document.createElement("div"),o.classList.add("smart-gantt-chart-task-baseline"),o.setAttribute("task-index",t),n.appendChild(o));const[u,h]=i.rightToLeft?["right","left"]:["left","right"],g=i._getTaskBarDetails(e,c,m);if(g){const e=o.style;e.width=g.width?g.width+"px":"",e.top=g.top+"px",e[u]=g.left+"px",e[h]=""}o.setAttribute("aria-label",a.label+" Start date: "+i._toISODate(l)+", End date: "+i._toISODate(d))}_setTaskBarSegments(e,t,i){const a=this,n=e.task,s=t.querySelector(".smart-task-segments").children;let r,o,l=n.segments;if(Array.isArray(l)&&l&&l.length&&"task"===n.type||(l=[n]),1===l.length){const e=s[0].style;return void(e.right=e.left=e.width="")}const d=a.rightToLeft,c=parseFloat(t.style[d?"right":"left"]);let m;for(let e=0,t=l.length;e<t;e+=1){const t=l[e],n=s[e];if(!n)continue;const u=t.dateStart instanceof Date?t.dateStart:new Date(t.dateStart),h=t.dateEnd instanceof Date?t.dateEnd:new Date(t.dateEnd);r=!i&&n._cellStart||a._getTimelineCellByDate(u),o=!i&&n._cellEnd||a._getTimelineCellByDate(h),n._cellStart=r,n._cellEnd=o;const g=a._getTaskBarDetails({task:t},r,o);g&&(n.style[d?"left":"right"]="",n.style[d?"right":"left"]=Math.max(0,g.left-c)+"px",n.style.width=g.width+"px"),m=n}a._setTaskBarDeadline(n,m)}_setCurrentTimeIndicators(){const e=this;if(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval,e.currentTimeIndicator||e.shadeUntilCurrentTime)e._refreshTimeIndicators(),e._currentTimeIndicatorInterval=setInterval(e._refreshTimeIndicators.bind(e),1e3*e.currentTimeIndicatorInterval);else{const t=e.$.timelineIndicatorsContainer;t&&t.remove()}}_refreshTimeIndicators(){const e=this,t=e.currentTime,i=e.view,a=e._getTodayCellObj(t);let n=e.$.timelineIndicatorsContainer;if(!a)return n&&n.remove(),clearInterval(e._currentTimeIndicatorInterval),void delete e._currentTimeIndicatorInterval;n||(e.$.timelineIndicatorsContainer=n=document.createElement("div"),n.classList.add("smart-gantt-chart-time-indicators-container"),n.setAttribute("role","presentation")),new Date(a.date);let s,r,o=t.getMinutes();switch(i){case"quarter":case"year":{const e=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0,0);e.setDate(0),o+=24*t.getDate()*60,s=24*e.getDate()*60;break}case"month":o+=24*(t.getDay()+1)*60,s=10080;break;case"week":o+=60*t.getHours(),s=1440;break;case"day":s=60}r={cellObj:a,minutes:o,max:s,today:t},e._refreshCurrentTimeShader(r),e._refreshCurrentTimeIndicator(r),n.childElementCount||(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval),n.parentElement||e.$.timelineContent.appendChild(n)}_refreshCurrentTimeIndicator(e){const t=this,i=t.$.timelineIndicatorsContainer;let a=i.querySelector(".smart-gantt-chart-current-time-indicator");if(!t.currentTimeIndicator||!e)return void(a&&a.remove());const{cellObj:n,minutes:s,max:r}=e;a||(a=document.createElement("div"),a.classList.add("smart-gantt-chart-current-time-indicator")),t.rightToLeft?a.style.right=n.left+n.width*(s/r)+"px":a.style.left=n.left+n.width*(s/r)+"px",a.setAttribute("aria-label","Current Time Indicator"),a.parentElement||i.appendChild(a),t._setTodayCell(n.date)}_refreshCurrentTimeShader(e){const t=this.$.timelineIndicatorsContainer;let i=t.querySelector(".smart-gantt-chart-current-time-shader");if(!this.shadeUntilCurrentTime||!e)return void(i&&i.remove());const{cellObj:a,minutes:n,max:s}=e;i||(i=document.createElement("div"),i.classList.add("smart-gantt-chart-current-time-shader")),i.style.width=a.left+a.width*(n/s)+"px",i.setAttribute("aria-label","Current Time Shader"),i.parentElement||t.appendChild(i)}_setTodayCell(e){const t=this;if(e)e instanceof Date&&(e=e.getTime());else{let i=0;e=t.currentTime,"day"===t.view&&(i=e.getHours()),e.setHours(i,0,0,0),e=e.getTime()}if("number"!=typeof e)return;const i=t.$.timelineViewCells.children;for(let t=0;t<i.length;t++){const a=i[t],n=new Date(a._date);n&&(n.getTime()===e?a.setAttribute("current",""):a.removeAttribute("current"))}}_getTodayCellObj(e){const t=this,i=t.view,a=t._timelineCells;e&&e.getTime||(e=t.currentTime);for(let t=0,n=a.length;t<n;t+=1){const n=a[t],s=n.date;switch(i){case"quarter":case"year":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth())return n;break;case"month":{const t=new Date(e);if(t.setDate(e.getDate()-e.getDay()),e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&t.getDate()===s.getDate())return n;break}case"week":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate())return n;break;case"day":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()&&s.getHours()===e.getHours())return n}}}_getTaskDOMIndex(e){const t=this.$.timelineTasksContainer.children;if(!e||void 0===e.$.id)return-1;for(let i=0,a=t.length;i<a;i+=1)if(t[i]._cellObj.task===e)return i;return-1}_getTimelineCellByDate(e,t,i){const a=this,n=a._timelineCells;if(!n||0===n.length)return;const s=n.length-1;i=Math.min(s,"number"==typeof i?i:s);for(let s=t=Math.min(i,Math.max(0,"number"==typeof t?t:0));s<=i;s++){const t=n[s];if(!t)continue;const i=t.date;switch(a.view){case"quarter":case"year":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth())return t;break;case"month":if("day"===a.monthScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t}else{const a=new Date(i);let n=new Date(i);if(n.setDate(n.getDate()+(6-n.getDay())+1),n.setMilliseconds(n.getMilliseconds()-1),e.getTime()>=a.getTime()&&e.getTime()<=n.getTime())return t}break;case"week":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t;break;case"day":if("hour"!==a.dayScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours()&&i.getMinutes()<=e.getMinutes())return t}else if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours())return t}}const r=n[0],o=n[n.length-1];return e.getTime()<r.date.getTime()?r:e.getTime()>o.date.getTime()?o:void 0}_refreshViewDetailCell(e,t,i){const a=this,n=a._timelineCells,s=e.date;let r=0,o=0===i?0:void 0;for(void 0===t&&(t=0);t<n.length;t++){const e=n[t],i=a._getCellWidth(e,s);if(i){if("month"===a.view&&"day"===a.monthScale&&s.getMonth()!==e.date.getMonth())break;void 0===o&&(o=e.left+e.width-i),r+=i}else if(e.date.getTime()>s.getTime())break}return a._isLastWeekCellNotFull&&(delete a._isLastWeekCellNotFull,t--),e.width=r,e.left=o,t}_getCellWidth(e,t){const i=this,a=e.date,n=(e,t)=>e.getFullYear()===t.getFullYear(),s=(e,t)=>e.getMonth()===t.getMonth(),r=e.width;switch(i.view){case"month":{if("day"===i.monthScale)return r;let e=new Date(a),o=new Date(e),l=0;for(o.setDate(o.getDate()+(6-e.getDay())+1),o.setMilliseconds(o.getMilliseconds()-1);e.getTime()<=o.getTime();)n(e,t)&&s(e,t)&&l++,e.setDate(e.getDate()+1);if(0===l)return;"day"!==i.monthScale&&(i._isLastWeekCellNotFull=l/7!=1);let d=r*l/7;return d<70?70:d}case"quarter":case"year":if(n(a,t))return r;break;case"week":{const e=new Date(t),n=new Date(t);if(-1!==i.firstDayOfWeek){const t=e.getDay()-i.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+i.firstDayOfWeek-(t>=0?0:7)),n.setDate(e.getDate()+6)}else e.setDate(t.getDate()-t.getDay()),n.setDate(t.getDate()+(6-t.getDay()));if(a.getTime()>=e.getTime()&&a.getTime()<=n.getTime())return r;break}case"day":if(n(a,t)&&s(a,t)&&a.getDate()===t.getDate())return r}}_getCellByOffsetLeft(e){const t=this._timelineCells;if(!e)return;let i;for(let a=0;a<t.length&&!(t[a].left>=e);a++)i=t[a];return i}_unselectAll(e,t){const i=this,a=i.$[`${e}TimelineCellsContainer`];let n;delete i._selected;const s=a.querySelectorAll(".smart-timeline-row[selected]");for(let e=0;e<s.length;e++)s[e].removeAttribute("selected");if("task"===e){n="selectedTaskIds";const e=i.$.timelineTasksContainer.querySelectorAll(".smart-timeline-task[selected]");for(let t=0;t<e.length;t++)e[t].removeAttribute("selected"),e[t].setAttribute("aria-selected","false")}else n="selectedResourceIds";if(i[`_${e}TreeChangeEventFired`]||i.$[e+"Table"].clearSelection(),i._highlightAssignedItem(e),t)return;const r=i[n].slice(0);r.length&&(i[n]=[],i._noChangeEvent||i.$.fireEvent("change",{value:[],oldValue:r,type:e}))}_getSegmentCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-task-segment"))return;const i=e.closest(".smart-timeline-task");if(!i)return;let a,n,s=i._cellStart,r=i._cellEnd;s&&r||({cellStart:s,cellEnd:r}=t._getTaskBarCellRange(i));const o=t.rightToLeft,l=parseFloat(e.style.width)||e.offsetWidth,d=t._timelineCells;let c=parseFloat(i.style[o?"right":"left"]);c&&!isNaN(c)||(c=i.offsetLeft,o&&(c=t.$.timelineContent.offsetWidth-c));const m=c+parseFloat(e.style[o?"right":"left"])||(o?(parseFloat(i.style.width)||i.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft),u=parseFloat((m+l).toFixed(2));for(let e=d.indexOf(s),t=d.indexOf(r);e<=t;e++){const t=d[e],i=t.left,s=t.width,r=parseFloat((i+s).toFixed(2));if(m>=i&&m<=r&&(a=t),!n&&u>i&&u<=r&&(n=t),a&&n)break}return a||(a=n||d[0]),n||(n=d[d.length-1]),{cellStart:a,cellEnd:n}}_getTaskBarCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-timeline-task"))return;let i=parseFloat(e.style.width)||e.offsetWidth;const a=t._timelineCells,n=t.$.timelineContent,s=parseFloat(e.style[t.rightToLeft?"right":"left"])||(t.rightToLeft?(parseFloat(n.style.width)||n.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft);let r,o;e.classList.contains("milestone")&&(i/=2);const l=parseFloat((s+i).toFixed(2));for(let e=0;e<a.length;e++){const t=a[e],i=t.left,n=t.width,d=parseFloat((i+n).toFixed(2));if(s>=i&&s<=d&&(r=t),!o&&l>i&&l<=d&&(o=t),r&&o)break}return r||(r=e.classList.contains("milestone")&&o?o:a[0]),o||(o=a[a.length-1]),{cellStart:r,cellEnd:o}}_getDateFromCell(e,t,i){if(!t)return new Date;const a=this,n=new Date(t.date);let s,r=0,o=0,l=new Date(n);switch(l.setHours(0,0,0,0),i||(i=a.view),i){case"quarter":case"year":s=new Date(n.getFullYear(),n.getMonth()+1,0).getDate(),r=1,l.setDate(s);break;case"month":"day"===a.monthScale?(r=n.getDate(),s=1):(r=n.getDate(),s=7,l.setDate(l.getDate()+6));break;case"week":s=1,r=n.getDate();break;case"day":s=1/24,r=n.getDate(),o=n.getHours()}l.setHours(23,59,59,999);const d=parseFloat(((e-t.left)/t.width*s).toFixed(12)),c=Math.min(s,Math.floor(d)),m=d%1*24,u=Math.floor(m),h=60*Math.abs(m-u),g=Math.floor(h),f=60*Math.abs(h-g),p=Math.floor(f),_=1e3*Math.abs(f-p),T=Math.floor(_),b=new Date(n.getFullYear(),n.getMonth(),r+c,o+u,g,p,T);return b.getTime()>l?l:b}_getCellDateRange(e){if(!e||!e._date)return;const t=new Date(e._date);let i=new Date(t);switch(i.setHours(0,0,0,0),this.view){case"quarter":case"year":i.setDate(1),i.setMonth(i.getMonth()+1),i.setDate(0);break;case"month":i.setDate(i.getDate()+6);break;case"day":return i.setHours(t.getHours(),59,59,999),{dateStart:t,dateEnd:i}}return i.setHours(23,59,59,999),{dateStart:t,dateEnd:i}}_getTasksJSON(){const e=this;let t=e._tasks;return function t(i,a){if(!i)return;let n=[];for(let s=0;s<i.length;s++){const r=i[s];let o;if(!r.$.project&&!a||r.$.project===a){const i=e._getTaskConnections(r).taskConnections;o=e._cloneObject(r,!0),i.length&&(o.connections=i.map((e=>{const t={target:e.endIndex,type:e.type};return e.lag&&(t.lag=e.lag),t}))),o.tasks=t(e._getProjectTasks(r),r),delete o.$,n.push(o)}}return n}(t)}_cloneObject(e,t){let i={};for(let a in e){let n=e[a];"tasks"!==a&&("connections"!==a?n instanceof Date?i[a]=t?n.toISOString():new Date(n):i[a]=n:i[a]=JSON.parse(JSON.stringify(n)))}return t||delete i.$,i}_setTable(e){const t=this;e||(e=t.$.taskTable);const[i,a]=e===t.$.taskTable?[t.taskColumns,"task"]:[t.resourceColumns,"resource"];if(!t.contains(e))return;if(!i.length)return void(t.$[a+"Table"].dataSource=[]);const n=t._getTableColumns(a);"task"===a&&(e.filterRow=t.filterRow,[e.grouping,e.groupFormatFunction]=t.groupByResources?[!0,t._formatResourceGroups.bind(t)]:[!1,null]),e.isRendered&&e.resetState("expanded"),e.style.setProperty("--smart-table-row-height",""),e.columns=n,e.dataSource=t._getTableDataSource(a,n),e.wait&&(t.$.taskTable.hasResizeObserver=!1,e.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,e.$.virtualizationContainer.verticalScrollBarVisibility="hidden",e.$.virtualizationContainer.disabled=!0,e.columnMinWidth=t.columnMinWidth,e.columnResize=t.columnResize,e.columnResizeFeedback=t.columnResizeFeedback,e.filtering=t[`${a}Filtering`],e.sort=t.sortFunction,e.sortMode=t.sortMode,e.keyboardNavigation=t.keyboardNavigation,e.selectionByHierarchy=!1,e.selection=!t.disableSelection,e.hideSelectionColumn=!t.showSelectionColumn,e.selectionMode=t.selectionMode,e.onKeyboardScroll=(i,a)=>{const n=e===t.$.taskTable?t:t._resourceScrollView;a!==n.scrollTop&&(n.scrollTop=a)},e.wait=!1),e.$.virtualizationContainer.scrollTop="task"===a?t.scrollTop:t.$.resourceVerticalScrollBar.value,t._refresh()}_formatResourceGroups(e){const t=this,i=t._resources,a=e.data.data.resources.split(",");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}t.resourceGroupFormatFunction?e.template=t.resourceGroupFormatFunction(a):e.template="<strong>"+(n.length?n.join(", "):t.localize("unassigned"))+"</strong>"}_formatResourceGroupLabel(e){const t=this,i=t._resources,a=e.split(",");if(!e)return t.localize("unassigned");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}return n.length?n.join(", "):t.localize("unassigned")}_getTableColumns(e="task"){const t=this,i=["dateStart","dateEnd","minDateStart","maxDateStart","minDateEnd","maxDateEnd"],a=["progress","capacity","workload","maxCapacity","minCapacity"];let n="task"===e?t.taskColumns:t.resourceColumns,s=[];"task"===e&&t.groupByResources&&!n.find((e=>"resources"===e.value))&&(n=n.slice(0),n.push({label:"",value:"resources",hidden:!0}));for(let r=0,o=n.length;r<o;r++){const o=n[r],l=o.value,d={};d.label=t.localize(o.label)||o.label,d.dataField=l,l.startsWith("date")||i.indexOf(l)>-1?d.dataType="date":d.dataType="overdue"===l?"boolean":l.startsWith("duration")||a.indexOf(l)>-1?"number":"string",o.hidden&&(d.visible=!1),"function"==typeof o.formatFunction?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=i.column.toLowerCase();let s=i.value;n.indexOf("date")>-1?s=new Date(s):"resources"===n&&(s=s?s.split(","):[]),i.template=o.formatFunction.call(t,s,a?t._cloneObject(a):void 0)}:["date","number"].indexOf(d.dataType)>-1?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=t._formatColumnData(t._cloneObject(a),o);i.template=n}:"overdue"===l&&(d.formatFunction=e=>{const t=e.cell;e.value+""=="true"?t.setAttribute("overdue",""):t.removeAttribute("overdue"),e.value=""},d.width=t._taskDefaultHeight),o.size&&(d.width=o.size),s.push(d)}return s}_getTableDataSource(e="task",t){const i=this,a="task"===e?i._getTableData(i._tasks,i.taskColumns,e):i._getTableData(i._resources,i.resourceColumns,e),n=i.groupByResources,s=(()=>{let e=[];e.push("itemId: string"),e.push("projectId: string"),e.push("itemIndex: number"),n&&e.push("resources: string");for(let i=0,a=t.length;i<a;i+=1){const a=t[i];e.push(`${a.dataField}: ${a.dataType}`)}return e})();return i.groupByResources?new window.Smart.DataAdapter({dataFields:s,dataSource:a,groupBy:["resources"],id:"itemId"}):new window.Smart.DataAdapter({dataFields:s,dataSource:a,keyDataField:"itemId",parentDataField:"projectId",id:"itemId"})}_refreshTableDataSource(e="task"){const t=this,i="task"===e?t.$.taskTable:t.$.resourceTable;t.contains(i)&&(i.resetState("expanded"),i.dataSource=t._getTableDataSource(e,t._getTableColumns(e)))}_refreshColumnsHeaders(e){const t=this;e||(e="task");const i=t.$[`${e}Table`].columns,a=t[`${e}Columns`];for(let e=0,n=i.length;e<n;e++)i[e].label=t.localize(a[e].label)||a[e].label;!arguments.length&&t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshColumnsHeaders("resource")}_getTaskResourceIds(e){const t=e.resources,i=this._resources.map((e=>e.id));let a=[];if(Array.isArray(t))for(let e=0,n=t.length;e<n;e+=1){const n=t[e].id||t[e];i.indexOf(n)>-1&&a.push(n)}return a.sort()}_getTableData(e,t,i){const a=this,n=a.groupByResources;i||(i="task");const s=t.map((e=>e.value));let r=[],o=[];for(let l=0,d=e.length;l<d;l+=1){const d=e[l];if(d.hidden||n&&d.disableResources)continue;const c={},m=d.$.project,u=a._getTaskResourceIds(d);for(let e=0,n=s.length;e<n;e+=1)c[s[e]]=a._formatColumnData(d,t[e],i);c.expanded=n||d.expanded,c.itemId=d.$.id||d.id||"",c.itemIndex=l,u&&u.length?c.resources=u.toString():delete c.resources,d.$&&m&&(m.$.id?c.projectId=d.$.project.$.id:o.push(((e,t)=>{e.projectId=t.$.id}).bind(null,d,m))),r.push(c)}for(let e=0,t=o.length;e<t;e+=1)o[e]();return r}_formatColumnData(e,t){const i=this,a=t.value;let n=e[a];if(a){const e=(a+"").toLowerCase();if(e.indexOf("date")>-1||t.dateFormat)return i._formatDate(n,t);if(e.indexOf("duration")>-1||t.numberFormat){const e=parseFloat(n.toFixed(1));return t.numberFormat?i._formatNumber(e,t.numberFormat):e}}return null!=n?n.toString():i.localize("unassigned")}_formatDate(e,t){const i=this;if(e=Date.parse(e),!isNaN(e)){let a=t?t.dateFormat:void 0;if("string"==typeof a)return new Smart.Utilities.DateTime(new Date(e)).toString(a);if("object"==typeof a)a=t.dateFormat;else{const e=i.view;a={year:"numeric",month:"2-digit",day:"numeric"},["day","week"].indexOf(e)>-1&&(a.hour="numeric",a.minute="numeric",a.second="numeric")}return new Intl.DateTimeFormat(i.locale,a).format(new Date(e))}}_formatNumber(e,t,i){const a=this;if("object"==typeof t)return new Intl.NumberFormat(a.locale,t).format(""+e);i||(i={percentSymbol:"%",currencySymbol:"$",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","});const n=e=>"number"==typeof e&&isFinite(e);if(""===t||null===t)return e;let s;n(e)||(e*=1),t.length>1&&(s=parseInt(t.slice(1),10));let r={},o=t.charAt(0).toUpperCase();switch(r.thousandsSeparator=i.thousandsSeparator,r.decimalSeparator=i.decimalSeparator,o){case"D":case"d":case"F":case"f":r.decimalPlaces=s;break;case"N":case"n":r.decimalPlaces=0;break;case"C":case"c":r.decimalPlaces=s,"before"===i.currencySymbolPosition?r.prefix=i.currencySymbol:r.suffix=i.currencySymbol;break;case"P":case"p":r.suffix=i.percentSymbol,r.decimalPlaces=s;break;default:throw"Bad number format specifier: "+o}if(n(e)){const t=e<0;let i=e+"";const a=r.decimalSeparator?r.decimalSeparator:".";let s;if(n(r.decimalPlaces)){var l=r.decimalPlaces,d=Math.pow(10,l);if(i=(e*d).toFixed(0)/d+"",s=i.lastIndexOf("."),l>0)for(s<0?(i+=a,s=i.length-1):"."!==a&&(i=i.replace(".",a));i.length-1-s<l;)i+="0"}else{let t=e+"";s=t.lastIndexOf("."),s>0&&void 0===l&&"."!==a&&(t=t.replace(".",a))}if(r.thousandsSeparator){const e=r.thousandsSeparator;s=i.lastIndexOf(a),s=s>-1?s:i.length;let n=i.substring(s),o=-1;for(var c=s;c>0;c--)o++,o%3==0&&c!==s&&(!t||c>1)&&(n=e+n),n=i.charAt(c-1)+n;i=n}return i=r.prefix?r.prefix+i:i,i=r.suffix?i+r.suffix:i,i}return e}_validateDate(e,t){return e[t]=this._dateValidator(void 0,e[t]),e[t]&&!isNaN(e[t].getTime())||(e[t]=void 0),e[t]}_validateTaskProperties(e,t){const i=this;if(e.$={},e.tasks instanceof Array&&e.tasks.length>0?e.type="project":(!e.type||["project","task","milestone"].indexOf(e.type)<0)&&(e.type="task"),i._validateTaskDuration(e),void 0===e.hidden&&t&&(e.hidden=t.hidden),e.hidden=!!e.hidden,void 0===e.resources?e.resources=[]:e.resources=[e.resources].reduce(((e,t)=>e.concat(t)),[]),"project"===e.type?e.expanded=!!e.expanded:delete e.expanded,e.progress=Math.min(Math.max(0,parseFloat(e.progress)||0),100),i._validateTaskDates(e,t),i._validateTaskSegments(e),i._validateTaskIndicators(e),i._validateTaskPlannedDates(e),e.deadline){const t=i._validateDate(e,"deadline");!t||isNaN(t.getTime())?delete e.deadline:e.dateEnd&&(e.overdue=e.deadline.getTime()-e.dateEnd.getTime()<0)}else e.overdue=!1,delete e.deadline;if(!e.dateStart&&!e.dateEnd&&"project"===e.type&&!e.synchronized)return;const a=e.connections;if(a instanceof Array){for(let e=0;e<a.length;e++){const t=a[e],i=t.target="string"==typeof t.target?t.target:parseInt(t.target),n=t.type=parseInt(t.type);null==i||"number"==typeof i&&isNaN(i)||isNaN(n)?(a.splice(a.indexOf(t),1),e--):t.lag=parseInt(t.lag)||0}e.connections=e.connections.map((e=>Object.assign({},e)))}else e.connections=[];return e.class=e.class?e.class+"":"",e.class=void 0!==e.class&&null!==e.class?e.class:"",e}_validateTaskIndicators(e){const t=this,i=e.indicators;if(!i||!Array.isArray(i)||!i.length)return void delete e.indicators;let a=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if("object"!=typeof n)continue;const s=t._validateDate(n,"date");s&&s.getTime&&!isNaN(s.getTime())&&a.push(n)}e.indicators=a}_validateTaskSegments(e){const t=this,i=e.segments;if(!i||!Array.isArray(i)||i.length<2||"task"!==e.type)return void delete e.segments;const a=t.nonworkingDays.length>0||t.nonworkingHours.length>0;let n,s=[],r=[];for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("object"!=typeof a)continue;let n=parseFloat(a.duration);isNaN(n)&&delete a.duration,t._validateTaskDates(a),a.dateStart&&a.dateEnd&&s.push(a)}s.sort(((e,t)=>e.dateStart.getTime()-t.dateStart.getTime()));for(let i=0,o=s.length;i<o;i+=1){const o=s[i];let l=o.dateStart,d=o.dateEnd;o.dateStart=l=new Date(Math.max(e.dateStart.getTime(),l.getTime())),o.dateEnd=d=new Date(Math.min(e.dateEnd.getTime(),d.getTime())),n&&n.dateEnd.getTime()>l.getTime()&&(o.dateStart=l=new Date(n.dateEnd.getTime()+1e3),l.getTime()>=d.getTime())||l.getTime()>d.getTime()||(o.duration=t._convertDuration(a?t._getWorkingTime(l,d):d.getTime()-l.getTime(),!0),n=o,r.push(o))}r.length<2?delete e.segments:(r[0].dateStart=new Date(e.dateStart),r[r.length-1].dateEnd=new Date(e.dateEnd),e.segments=r)}_validateTaskDuration(e){const t=this;let i=t._convertDuration(parseFloat(e.duration))||0,a=t._convertDuration(parseFloat(e.minDuration))||0,n=t._convertDuration(parseFloat(e.maxDuration))||0;a&&n&&(n=Math.max(a,n)),i&&(a?i=Math.max(a,i):n&&(i=Math.min(i,n))),e.duration=t._convertDuration(i,!0),e.minDuration=t._convertDuration(a,!0),e.maxDuration=t._convertDuration(n,!0)}_validateTaskDates(e,t){const i=this,a=i._convertDuration(e.minDuration),n=i._convertDuration(e.maxDuration);let s=i._convertDuration(e.duration);if(void 0!==e.minDateStart&&(e.minDateStart=i._validateDate(e,"minDateStart")),void 0!==e.maxDateStart&&(e.maxDateStart=i._validateDate(e,"maxDateStart")),e.minDateStart&&e.maxDateStart&&(e.maxDateStart=new Date(Math.max(e.minDateStart.getTime(),e.maxDateStart.getTime()))),void 0!==e.minDateEnd&&(e.minDateEnd=i._validateDate(e,"minDateEnd")),void 0!==e.maxDateEnd&&(e.maxDateEnd=i._validateDate(e,"maxDateEnd")),e.minDateEnd&&e.maxDateEnd&&(e.maxDateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.maxDateEnd.getTime()))),e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart||(e.minDateStart?e.dateStart=e.minDateStart:e.maxDateStart?e.dateStart=e.maxDateStart:e.dateStart=i.dateStart),e.dateEnd||(e.minDateEnd?e.dateEnd=e.minDateEnd:e.maxDateEnd&&(e.dateEnd=e.maxDateEnd)),e.minDateStart&&(e.dateStart=new Date(Math.max(e.minDateStart.getTime(),e.dateStart.getTime()))),e.maxDateStart&&(e.dateStart=new Date(Math.min(e.maxDateStart.getTime(),e.dateStart.getTime()))),e.minDateEnd&&(e.dateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.dateEnd.getTime()))),e.maxDateEnd&&(e.dateEnd=new Date(Math.min(e.maxDateEnd.getTime(),e.dateEnd.getTime()))),e.dateStart&&(i.min&&(s=Math.min(e.dateStart.getTime()-i.min.getTime(),s),e.duration=i._convertDuration(s,!0)),i.max&&(s=Math.min(i.max.getTime()-e.dateStart.getTime(),s),e.duration=i._convertDuration(s,!0))),!e.dateStart&&s&&e.dateEnd&&(e.dateStart=new Date(e.dateEnd.getTime()-s)),"task"!==e.type||e.dateStart&&!isNaN(e.dateStart.getTime())||!t||(e.dateStart=new Date(t.dateStart)),a&&e.dateStart)if(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)){const t=i._getTaskWorkingDateEnd(e,a);e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,t.getTime()))}else e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,e.dateStart.getTime()+a));if(s&&e.dateStart&&(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?e.dateEnd=i._getTaskWorkingDateEnd(e,s):e.dateEnd=new Date(e.dateStart.getTime()+s)),s||n){let t;t=i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?i._getTaskWorkingDateEnd(e,Math.max(s,n)):new Date(e.dateStart.getTime()+Math.max(s,n)),e.dateEnd.getTime()>t.getTime()&&(e.dateEnd=t)}"task"===e.type&&!e.dateEnd&&t&&(e.dateEnd=new Date(t.dateEnd)),e.dateStart=i._minMaxDateValidator(e.dateStart),e.dateEnd=i._minMaxDateValidator(e.dateEnd),"milestone"===e.type&&(e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart=e.dateEnd=new Date(Math.max(e.dateStart?e.dateStart.getTime():0,e.dateEnd?e.dateEnd.getTime():0))),(e.dateStart||e.dateEnd||"project"!==e.type||e.synchronized)&&("milestone"!==e.type&&e.dateStart&&(e.dateEnd&&e.dateStart.getTime()>e.dateEnd.getTime()||!e.dateEnd)&&(e.dateEnd=new Date(e.dateStart.getTime()+36e5*("day"===i.view?1:24))),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}_validateTaskPlannedDates(e){const t=this;if(!e)return;const i=e.type,a=e.planned;if("milestone"===i||!a)return;const n=t._validateDate(a,"dateStart"),s=t._validateDate(a,"dateEnd");n&&s&&(a.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n,s):s.getTime()-n.getTime(),!0))}_synchronizeProjectDates(e,t){const i=this;if(e){void 0===t&&(t=i._getProjectTasks(e));for(let n=0,s=t.length;n<s;n+=1){const s=t[n];e.synchronized&&(s.dateStart&&(e.dateStart=a(s,"dateStart","min")),s.dateEnd&&(e.dateEnd=a(s,"dateEnd","max")),s.minDateStart&&(e.minDateStart=a(s,"minDateStart","max")),s.maxDateStart&&(e.maxDateStart=a(s,"maxDateStart","min")),s.minDateEnd&&(e.minDateEnd=a(s,"minDateEnd","max")),s.maxDateEnd&&(e.maxDateEnd=a(s,"maxDateEnd","min")),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}e.$&&i._synchronizeProjectDates(e.$.project,t)}function a(t,i,a){const n=e[i];let s=t[i];return void 0===n?new Date(s):s instanceof Date?new Date(Math[a](n.getTime(),s.getTime())):void 0}}_synchronizeProjectVisibility(e,t){const i=this;e&&e.hidden&&!t.hidden&&(e.hidden=t.hidden,e.$&&i._synchronizeProjectVisibility(e.$.project,e))}_mouseWheelHandler(e){const t=this,i=(t.shadowRoot||t).querySelector(".smart-task-popup-window");if(i&&i.modal&&i.opened)return void e.stopPropagation();if(t.disabled||!t.computedHorizontalScrollBarVisibility&&!t.computedVerticalScrollBarVisibility)return;if(e.shiftKey)return void t._handleHorizontalScroll(e);const a=t.$.resourceSplitterItem;t.$.mainSplitter.contains(a)&&a.contains(e.target)?t._handleVerticalScroll(e,!0):t.$.taskSplitterItem.contains(e.target)&&t._handleVerticalScroll(e)}_handleVerticalScroll(e,t){const i=this;let a,n,s,r;if(t){if(a=i.$.resourceVerticalScrollBar,a.classList.contains("smart-hidden")||a.disabled)return!0;n=a.value,s=a.max,r=i._resourceScrollView}else{if(!i.computedVerticalScrollBarVisibility||i.$.verticalScrollBar.disabled)return!0;n=i.scrollTop,s=i.scrollHeight,r=i}if(0===n&&e.deltaY<0||n===s&&e.deltaY>0)return void e.stopPropagation();const o=i.$[t?"resourceTable":"taskTable"];if(e.stopPropagation(),e.preventDefault(),n+=i._getScrollCoefficient(e,i.offsetHeight),r){const e=o.$.virtualizationContainer;e.scrollHeight!==r.scrollHeight&&(e.scrollHeight=r.scrollHeight),r.scrollTo(n,void 0)}o.scrollTop=n,i._hoveredItem&&i._handleTableItemHover()}_handleHorizontalScroll(e){const t=this;if(!t.computedHorizontalScrollBarVisibility)return!0;const i=t.scrollLeft;(0===i&&e.deltaX<0||i===t.scrollHeight&&e.deltaX>0)&&e.stopPropagation(),e.stopPropagation(),e.preventDefault(),t.scrollWidth>0&&t.scrollTo(void 0,t.scrollLeft+t._getScrollCoefficient(e,t.offsetWidth))}_handleHeaderTemplate(e="task"){const t=this;if(!("content"in document.createElement("template")))return void t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()}));const i=t.$[`${e}SplitterItemHeader`],a=t.$[`${e}SplitterItem`],n="task"===e?"headerTemplate":"resourcePanelHeaderTemplate";let s=t[n];if(a.removeAttribute("show-header"),i.innerHTML="",!s)return;if("function"==typeof s)return s(i,{}),void(i.innerHTML?a.setAttribute("show-header",""):a.removeAttribute("show-header"));if("string"==typeof s&&(s=document.getElementById(s)),null===s||!("content"in s))return void t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:n}));let r=document.importNode(s.content,!0);if(a.setAttribute("show-header",""),t.shadowRoot)return i.innerHTML="<slot></slot>",void t.appendChild(r);i.appendChild(r)}_handleCollapseExpandMethods(e,t){const i=this,a=i._tasks;if(null==e||!a||!a.length)return;const n=i._getValidItemAndIndex(e);if(!n||!n.item)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"collapse",argumentName:"task"}));let s=n.item;"project"!==s.type&&(s=s.$.project),s&&(s.hidden?s.expanded="expand"===t:i.$.taskTable["expand"===t?"expandRow":"collapseRow"](s.$.id))}_getValidItemAndIndex(e,t="task"){const i=this,a="task"===t?i._tasks:i._resources;let n;if(null==e||!a||!a.length)return{};if("string"==typeof e||"number"==typeof e){const t=e.toString();let i,s;for(let n=0,r=a.length;n<r;n+=1){const r=a[n];if(!i){const a=r.id;if(null!=a&&a.toString&&a.toString()===t){i=r,e=n;break}}r.$.id===t&&(s=r,e=n)}n=i||s}else"object"==typeof e&&(n=a[i._getItemIndex(e,t)],e=a.indexOf(n));return{item:n,index:e}}_horizontalScrollbarHandler(e){const t=this,i=t._getScrollLeft(e.detail.value);e.stopPropagation&&e.stopPropagation(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=i,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=i),t._recycle(e),e.context.min!==e.context.value?e.context.max===e.context.value&&(t._handleInfiniteTimeline(),t.$.fireEvent("scrollRightReached")):t.$.fireEvent("scrollLeftReached")}_verticalScrollbarHandler(e){const t=this,i=e.target,a=Math.round(e.detail.value);e.stopPropagation&&e.stopPropagation(),t._refreshing||(i&&i===t.$.resourceVerticalScrollBar?t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=a:(t.$.taskTimelineContainer.scrollTop=a,t.$.taskTable.scrollTop=a),t._recycle(e),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached"))}_handleInfiniteTimeline(){const e=this,t=e._timelineCells;if(!e.infiniteTimeline||!t||!t.length)return;const i=e.infiniteTimelineStep,a=t[t.length-1].date;switch(e.view){case"quarter":case"year":a.setMonth(a.getMonth()+i);break;case"month":a.setDate(a.getDate()+7*i);break;case"week":a.setDate(a.getDate()+i);break;case"day":a.setHours(a.getHours()+i)}e.set("dateEnd",a),e._createTimelineCells(),e._recycleTimelineTasks(!0),e.$.mainSplitter.contains(e.$.resourceSplitter)&&e._refreshResourceTimeline(),e._refresh()}_nonworkingDayValidator(e,t){return this._nonworkingDateTimeValidator(e,t)}_nonworkingTimeValidator(e,t){return this._nonworkingDateTimeValidator(e,t,!0)}_nonworkingDateTimeValidator(e,t,i){const a=this,[n,s,r]=i?[0,23,24]:[0,6,7];let o=[];function l(e){let t=Math.max(n,Math.min(s,parseInt(e[0]))),i=Math.max(n,Math.min(s,parseInt(e[1])));if(!isNaN(t)&&!isNaN(i)){for(;t!==i;)o.push(t),t=t===s?n:++t;o.push(t)}return o}for(let e=0;e<t.length;e++){const i=t[e];"number"!=typeof i||isNaN(i)?"string"==typeof i?o=l(i.split("-").map((e=>parseInt(e)))):Array.isArray(i)&&(o=l(i)):o.push(Math.max(n,Math.min(s,parseInt(i))))}return o.length===r&&(o.pop(),a.warn(a.localize("invalidNonworkingRange",{elementType:a.nodeName.toLowerCase(),property:i?"nonworkingHours":"nonworkingDays"}))),o}});
83
+ Smart("smart-gantt-chart",class extends Smart.ScrollViewer{static get properties(){return{adjustToNonworkingTime:{value:!1,type:"boolean"},autoSchedule:{value:!1,type:"boolean"},autoScheduleStrictMode:{value:!1,type:"boolean"},autoScrollStep:{value:5,type:"number"},columnMenu:{value:!1,type:"boolean"},columnMinWidth:{value:"50px",type:"any"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},currentTime:{value:new Date,type:"any",validator:"_dateValidator"},currentTimeIndicator:{value:!1,type:"boolean"},currentTimeIndicatorInterval:{value:1,validator:"_currentTimeIndicatorIntervalValidator",type:"number"},dataExport:{value:{exportFiltered:{value:!1,type:"boolean"},itemType:{value:"task",type:"string"},fileName:{value:"smartGanttChart",type:"string?"}},type:"object"},dataSource:{value:[],type:"any",reflectToAttribute:!1},dateEnd:{value:"",type:"any",validator:"_dateValidator"},dateStart:{value:"",type:"any",validator:"_dateValidator"},dateMarkers:{value:[],reflectToAttribute:!1,type:"array"},dayFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},dayScale:{value:"hour",allowedValues:["hour","halfHour","quarterHour"],type:"string"},disableAutoScroll:{value:!1,type:"boolean"},disableTaskDrag:{value:!1,type:"boolean"},disableTaskProgressChange:{value:!1,type:"boolean"},disableTaskResize:{value:!1,type:"boolean"},disableSelection:{value:!1,type:"boolean"},disableSegmentDrag:{value:!1,type:"boolean"},disableSegmentResize:{value:!1,type:"boolean"},disableWindowEditor:{value:!1,type:"boolean"},durationUnit:{value:"milisecond",allowedValues:["day","week","hour","minute","second","milisecond"],type:"string"},filterRow:{value:!1,type:"boolean"},firstDayOfWeek:{value:-1,type:"number"},groupByResources:{value:!1,type:"boolean"},headerTemplate:{value:null,type:"any"},hourFormat:{value:"default",allowedValues:["default","2-digit","numeric"],type:"string"},hideDateMarkers:{value:!1,type:"boolean"},hideTimelineHeaderDetails:{value:!1,type:"boolean"},hideTimelineSecondHeaderDetails:{value:!0,type:"boolean"},hideTimelineHeader:{value:!1,type:"boolean"},hideResourcePanel:{value:!1,type:"boolean"},showSelectionColumn:{value:!1,type:"boolean"},infiniteTimeline:{value:!1,type:"boolean"},infiniteTimelineStep:{value:5,type:"number"},inverted:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},messages:{extend:!0,value:{en:{duplicateIds:"{{elementType}}: DataSource contains duplicate ids. Tasks should have unique ids. The following ids are duplicating: {{duplicates}}.",invalidNonworkingRange:"{{elementType}}: Invalid {{property}} value. {{property}} should not contain all possible days/hours because it will result in an endless timeline. The value has been validated by removing the last item from the new value range.",invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",outOfBounds:"{{elementType}}: Out of bounds argument {{argumentName}} in method {{methodName}}.",missingReference:"{{elementType}}: Missing reference to {{file}} in method {{methodName}}.",alreadyExists:"{{elementType}}: The item already exists when calling the {{methodName}} method.",notExisting:"{{elementType}}: The item does not exists when calling the {{methodName}} method.",notAProject:"{{elementType}}: The {{argumentName}} argument in {{methodName}} method does not reference an item of type 'project'.",noId:"smartGanttChart requires an id in order to save/load/clear a state.",ok:"Ok",add:"Add",remove:"Remove",cancel:"Cancel",delete:"Delete",confirm:"{{componentName}} will be deleted permanently, <b>are you sure? </b>",taskColumnLabel:"Task Name",resourceColumnLabel:"Resource Name",deleteLink:"Delete link",unassigned:"Unassigned",generalTab:"General",dependencyTab:"Dependency",segmentsTab:"Segments",segment:"Segment",dependencyValidation:"*The Task cannot be connected to itself.",segmentsCountValidation:"*Segmented Tasks must have at least 2 segments. ",segmentConflictError:'*The Segment "{{label}}" is in conflict, because it starts on/before and ends on/after the {{dateConflict}} of Segment "{{conflictLabel}}." ',segmentStartError:'*The Segment "{{label}}" cannot start before it ends and cannot end before it starts.',segmentEndError:'*The Segment "{{label}}" cannot start when it ends.',segmentRangeError:'*The Segment "{{label}}" is out of Task date range. The first segment must start when the task starts and the last segment must end when the task ends.',label:"Label",duration:"Duration",dateStart:"Date Start",dateEnd:"Date End",id:"Id",name:"Name",type:"Type",lag:"Lag",startToStart:"Start-To-Start",endToStart:"End-To-Start",endToEnd:"End-To-End",startToEnd:"Start-To-End",overdue:"Overdue",weeks:"week(s)",days:"day(s)",hours:"hour(s)",minutes:"minute(s)",seconds:"second(s)",miliseconds:"milisecond(s)",task:"Task",resource:"Resource",assignments:"Assignments",startTask:"Task Start",endTask:"Task End",deadline:"Deadline",quarter:"Quarter",quarterShort:"Q"}},type:"object"},monthFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},monthScale:{value:"week",allowedValues:["day","week"],type:"string"},max:{value:new Date(2100,0,1),type:"any",validator:"_dateValidator"},min:{value:new Date(1900,0,1),type:"any",validator:"_dateValidator"},nonworkingDays:{value:[],type:"array",validator:"_nonworkingDayValidator"},nonworkingHours:{value:[],type:"array",validator:"_nonworkingTimeValidator"},onTaskRender:{value:null,reflectToAttribute:!1,type:"function?"},popupWindowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"},popupWindowTabs:{value:["general","dependency","segments"],reflectToAttribute:!1,type:"array"},progressLabelFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resizeHandlesVisibility:{allowedValues:["auto","hidden","visible"],value:"auto",type:"string"},quarterFormat:{value:"short",allowedValues:["long","short","numeric"],type:"string"},resourceColumns:{value:[{label:"resourceColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},resourceFiltering:{value:!1,type:"boolean"},resourceGroupFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourcePanelHeaderTemplate:{value:null,type:"any"},resourcePanelMin:{value:100,type:"any"},resourcePanelSize:{value:"",type:"any"},resourcePanelRefreshRate:{value:0,reflectToAttribute:!1,type:"number"},resourceTimelineFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourceTimelineMode:{allowedValues:["diagram","histogram","custom"],value:"diagram",type:"string"},resourceTimelineView:{allowedValues:["hours","tasks","custom"],value:"hours",type:"string"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},selectedTaskIds:{value:[],type:"array"},selectedResourceIds:{value:[],type:"array"},shadeUntilCurrentTime:{value:!1,type:"boolean"},showBaseline:{value:!1,type:"boolean"},showProgressLabel:{value:!1,type:"boolean"},snapToNearest:{value:!1,type:"boolean"},sortFunction:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",allowedValues:["none","one","many"],type:"string"},taskColumns:{value:[{label:"taskColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},taskFiltering:{value:!1,type:"boolean"},taskPanelMin:{value:200,type:"any"},taskPanelSize:{value:"",type:"any"},timelineHeaderFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},timelineMin:{value:200,type:"any"},treeMin:{value:100,type:"any"},treeSize:{value:"20%",type:"any"},tooltip:{value:{enabled:{value:!1,type:"boolean"},arrow:{value:!1,type:"boolean"},delay:{value:50,type:"number"},offset:{value:[0,5],type:"array"}},type:"object"},verticalScrollBarVisibility:{type:"string",value:"auto",allowedValues:["auto","disabled","hidden","visible"]},view:{value:"year",allowedValues:["day","week","month","quarter","year"],type:"any"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"},weekFormat:{value:"long",allowedValues:["long","numeric"],type:"string"}}}template(){return'<div id="container" role="presentation">\n <smart-splitter id="mainSplitter" auto-fit-mode="end" keep-proportions-on-resize right-to-left="[[rightToLeft]]" animation="[[animation]]" orientation="horizontal">\n <smart-splitter-item id="taskSplitterItem" class="smart-task-splitter-item">\n <div id="taskSplitterItemHeader" class="smart-task-panel-header"></div>\n <smart-splitter id="taskSplitter" class="smart-task-splitter" auto-fit-mode="end">\n <smart-splitter-item id="tableSplitterItem">\n <smart-table right-to-left="[[rightToLeft]]" wait id="taskTable" class="smart-task-table" virtualization animation="none" deferred-scroll-delay="0" ></smart-table>\n </smart-splitter-item>\n <smart-splitter-item id="timelineSplitterItem" class="smart-timeline-splitter-item">\n <div id="timeline" class="smart-timeline">\n <div id="timelineHeader" class="smart-timeline-header" role="rowgroup">\n <div id="timelineHeaderContent" class="smart-timeline-header-content">\n <div class="smart-timeline-view-details" id="timelineViewDetails" role="row"></div>\n <div class="smart-timeline-view-details smart-hidden" id="timelineViewSubDetails" role="row"></div>\n <div class="smart-timeline-view-cells" id="timelineViewCells" role="row"></div>\n </div>\n </div>\n <div id="taskTimelineContainer" class="smart-timeline-content-container">\n <div id="timelineContent" class="smart-timeline-content">\n <div id="taskTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n <div id="taskIndicatorsContainer" class="smart-timeline-indicators-container" role="group"></div>\n <div id="timelineConnectionsContainer" class="smart-timeline-connections-container" role="group"></div>\n <div id="timelineBaselinesContainer" class="smart-timeline-baselines-container" role="group"></div>\n <div id="timelineTasksContainer" class="smart-timeline-tasks-container" role="group"></div>\n <div id="timelineMarkers" class="smart-timeline-markers-container" role="group"></div>\n <div id="timelineDeadlines" class="smart-timeline-deadlines-container" role="group"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar id="verticalScrollBar" class="smart-timeline-scroll-bar" orientation="vertical"\n right-to-left="[[rightToLeft]]" aria-controls="[[id]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>\n </smart-splitter-item>\n </smart-splitter>\n <smart-scroll-bar wait id="horizontalScrollBar" class="smart-timeline-scroll-bar"></smart-scroll-bar>\n </div>'}static get listeners(){return{down:"_downHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","container.wheel":"_mouseWheelHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","verticalScrollBar.change":"_verticalScrollbarHandler","resourceVerticalScrollBar.change":"_verticalScrollbarHandler","mainSplitter.resizeEnd":"_resizeEventHandler","mainSplitter.resize":"_resizeEventHandler",move:"_moveHandler","mainSplitter.change":"_tableChangeHandler","mainSplitter.filter":"_tableSortFilterHandler","mainSplitter.sort":"_tableSortFilterHandler","mainSplitter.columnResize":"_tableColumnResizeHandler","taskTable.group":"_taskTableGroupEventHandler","taskTable.collapse":"_taskTableExpandHandler","taskTable.expand":"_taskTableExpandHandler","taskTable.keydown":"_taskTableKeyDownHandler"}}static get styleUrls(){return["smart.ganttchart.css"]}attached(){const e=this;if(super.attached(),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar)),!e._resourceScrollView&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),e.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);e.$.timelineHeader.scrollLeft=e.$.taskTimelineContainer.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineHeader.scrollLeft=e.$.resourceTimelineContent.scrollLeft=t)}if(e.scrollTop){const t=e.scrollTop;e.$.taskTimelineContainer.scrollTop=t,e.$.timelineContent.scrollTop=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollTop=t)}const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];for(let i=0;i<t.length;i++){const a=t[i];if(e.$[a]&&e.$[a].opened){const t=e["$"+a];e._handleModal(!0),t.listen("close",e._popupWindowCloseHandler.bind(e)),t.listen("closing",e._popupWindowClosingHandler.bind(e)),t.listen("open",e._popupWindowOpenHandler.bind(e)),t.listen("click",e._popupWindowClickHandler.bind(e)),t.listen("change",e._popupWindowChangeHandler.bind(e)),t.listen("transitionend",e._popupWindowTransitionendHandler.bind(e)),e.getShadowRootOrBody().appendChild(e.$[a])}}e._handleTooltipEvents(!0),e._currentTimeIndicatorInterval||!e.currentTimeIndicator&&!e.shadeUntilCurrentTime||e._setCurrentTimeIndicators()}detached(){const e=this;super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView);const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];e._handleModal();for(let i=0;i<t.length;i++){const a=t[i],n=e["$"+a];e.$[a]&&e.$[a].remove(),n&&(n.unlisten("open"),n.unlisten("close"),n.unlisten("closing"),n.unlisten("click"),n.unlisten("change"),n.unlisten("transitionend"))}e._handleTooltipEvents(),clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval}propertyChangedHandler(e,t,i){const a=this;switch(e){case"adjustToNonworkingTime":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline();break;case"animation":break;case"autoSchedule":i?a._autoSchedule():a._autoScheduleRestore();break;case"autoScheduleStrictMode":i&&(a._autoSchedule(),a._refreshTimeline());break;case"columnMinWidth":case"columnResizeFeedback":case"columnResize":{const t=a.$.taskTable,n=a.$.resourceTable;t[e]=i,n&&(n[e]=i);break}case"currentTimeIndicator":case"shadeUntilCurrentTime":a._setCurrentTimeIndicators();break;case"dataSource":if(a.scrollLeft=a.scrollTop=0,a._createTasks(),a._refreshTableDataSource(),a._createTimeline(),a._createResourceTimeline(),a._setAriaControls(),a.snapToNearest){for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline()}break;case"dateMarkers":a._createDateMarkers();break;case"hideDateMarkers":a._recycleDateMarkers();break;case"selectionMode":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selectionMode=a.selectionMode),t&&(t.selectionMode=a.selectionMode);break}case"disableSelection":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selection=!a.disableSelection),t&&(t.selection=!a.disableSelection);break}case"durationUnit":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDuration(t),a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i)}a._createTimelineCells(),a._insertTimelineTasks(),a.taskColumns.some((e=>(e.value+"").toLowerCase().indexOf("duration")>-1))&&a._refreshTableDataSource();break;case"filterRow":a.$.taskTable[e]=i;break;case"groupByResources":a._setTable(a.$.taskTable),a._createTimelineContent(),a._recycleTimelineTasks(),a._refresh();break;case"infiniteTimeline":i?a._scrollView.hScrollBar.value===a._scrollView.hScrollBar.max&&a._handleInfiniteTimeline():a.set("dateEnd","");break;case"keyboardNavigation":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"popupWindowTabs":case"popupWindowCustomizationFunction":{const e=a.$.taskPopupWindow;e&&(e.opened&&(e.close(),delete e._target),e.clear());break}case"taskFiltering":a.$.taskTable.filtering=i,a._refresh();break;case"resourceFiltering":{const e=a.$.resourceTable;e&&(e.filtering=i,a._refresh());break}case"tooltip_enabled":{const e=a.$.tooltip;e&&(i||e.remove(),a._handleTooltipEvents(i));break}case"tooltip_arrow":case"tooltip_delay":case"tooltip_offset":{const t=a.$.tooltip;t&&(t[e.replace("tooltip_","")]=i);break}case"headerTemplate":a._handleHeaderTemplate();break;case"inverted":if(a._handleInverted(),a.scrollLeft){const e=a._getScrollLeft(a.scrollLeft);a.$.timelineHeader.scrollLeft=a.$.taskTimelineContainer.scrollLeft=e,a.$.mainSplitter.contains(a.$.resourceTimelineHeader)&&(a.$.resourceTimelineHeader.scrollLeft=a.$.resourceTimelineContent.scrollLeft=e)}break;case"rightToLeft":Array.from(a.querySelectorAll("smart-splitter, smart-table, smart-scroll-bar")).forEach((t=>t[e]=i)),a.closeWindow(),a._handleInverted(),a._refreshTimeline();break;case"firstDayOfWeek":case"dateStart":case"dateEnd":a._refreshTimeline();break;case"messages":case"locale":case"dayFormat":case"hourFormat":case"timelineHeaderFormatFunction":case"monthFormat":case"yearFormat":a._refreshHeaderDate(!0),a._refreshColumnsHeaders(),a._recycleResourceHeaderCells();break;case"hideResourcePanel":a._createResourceTimeline(),a._refreshTimeline();break;case"nonworkingDays":case"nonworkingHours":a._refreshAfterWorkingTimeChange();break;case"selectedTaskIds":a.$.taskTable.selected=a._getSelection("task",i);break;case"selectedResourceIds":a.$.resourceTable&&(a.$.resourceTable.selected=a._getSelection("resource",i));break;case"resourceColumns":a._setTable(a.$.resourceTable),a._highlightAssignedItem("task",a._getSelection("task",a.selectedTaskIds));break;case"resourcePanelHeaderTemplate":a._handleHeaderTemplate("resource");break;case"resourceTimelineView":case"resourceTimelineMode":case"resourceTimelineFormatFunction":a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._resources.forEach((e=>a._refreshResourceTimelineContent(e)));break;case"showProgressLabel":case"progressLabelFormatFunction":a._tasks.forEach((e=>a._setTaskBarProgress(e)));break;case"sortFunction":a.$.taskTable.sort=i,a.$.resourceTable&&(a.$.resourceTable.sort=i);break;case"showSelectionColumn":a.$.taskTable.hideSelectionColumn=!i,a.$.resourceTable&&(a.$.resourceTable.hideSelectionColumn=!i);break;case"columnMenu":case"hideSelectionColumn":case"sortMode":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"taskColumns":a._setTable(a.$.taskTable);break;case"timelineMin":a.$.timelineSplitterItem.min=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break;case"treeMin":case"treeSize":{const t=e.toLowerCase().indexOf("size")>-1?"size":"min";a.$.tableSplitterItem[t]=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break}case"taskPanelMin":case"taskPanelSize":case"resourcePanelSize":case"resourcePanelMin":{const t=e.indexOf("Min")>-1?"min":"size",n=e.indexOf("resource")>-1?"resource":"task";a.$.mainSplitter.contains(a.$.resourceSplitter)&&(a.$[`${n}SplitterItem`][t]=i,a.$.taskSplitterItem._setSize("size",a.taskPanelSize),a.refresh());break}case"unfocusable":a._setFocusable();break;case"monthScale":case"dayScale":case"view":a._refreshTimeline(t);break;default:super.propertyChangedHandler(e,t,i)}}_predefPropertyGetter(e){const t=this;Object.defineProperty(t,e,{get:function(){switch(e){case"dataSource":{if(t.context===t)return t.properties[e].value;const i=function(e){if(!e.length)return e;for(let a=0;a<e.length;a++){const n=e[a];let s=t._getProjectTasks(n);s&&Array.isArray(s)&&(s=i(s.filter((e=>e.$&&e.$.project===n)))),e[a]=t._cloneObject(n),s&&s.length?e[a].tasks=s:delete e[a].tasks}return e},a=t.properties[e].value;return a instanceof Smart.DataAdapter?a:i(a.slice(0))}case"dateStart":case"dateEnd":{const i=t._timelineCells;if(i.length){const a=t._getCellDateRange({_date:i["dateStart"===e?0:i.length-1].date});return new Date(a[e])}return t.properties[e].value}default:return t.properties[e].value}},set(i){t.updateProperty(t,t._properties[e],i)}})}ready(){this._customScrollView=!0,super.ready()}render(){const e=this,t=window.getComputedStyle(e),i=Smart.Utilities.Core;e._isMobile=i.isMobile,e._isFirefox=i.Firefox,e._taskBarMinWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-min-width"))||0,e._taskDefaultHeight=parseFloat(t.getPropertyValue("--smart-gantt-chart-task-default-height"))||30,e._timelineCellSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-size"))||0,e._timelineCellMinSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-min-size"))||0,e._taskConnectionWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-connection-width"))||1,e._baselineProportion=parseFloat(t.getPropertyValue("--smart-gantt-chart-baseline-proportion"))||0,e._predefPropertyGetter("dataSource"),e._predefPropertyGetter("dateStart"),e._predefPropertyGetter("dateEnd"),e.$.tableSplitterItem.size=e.treeSize,e.$.tableSplitterItem.min=e.treeMin,e.$.timelineSplitterItem.min=e.timelineMin,e._setScrollBars(),e._handleHeaderTemplate(),e._handleInverted(!0),e._createTasks(),e._setTable(),e._createTimeline(),e._createResourceTimeline(),e._setAriaControls(),e._setFocusable(),e.checkLicense(),(e.shadowRoot||e._isFirefox)&&requestAnimationFrame((()=>e.refresh())),super.render()}refresh(e){const t=this;if(e)return t._refreshTimeline(),t._setTable(t.$.taskTable),void t._createResourceTimeline();t.isRendered&&t._resizeEventHandler()}addFilter(e,t){const i=this;if(!i.taskFiltering&&!i.resourceFiltering||!(t instanceof Smart.Utilities.FilterGroup))return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const a=i.taskColumns,n=i.resourceColumns,s=i.$.taskTable,r=i.$.resourceTable;for(let i=0;i<e.length;i++){const o=e[i],l=o.type,[d,c]="resource"===l||n.includes(o)?[r,n]:[s,a],m=c.find((e=>o.value&&e.value===o.value));m&&d.addFilter(m.value,t)}}clearSelection(){this._unselectAll("task"),this._unselectAll("resource")}static get requires(){return{"Smart.Splitter":"smart.splitter.js","Smart.Tree":"smart.tree.js","Smart.Window":"smart.window.js"}}ensureVisible(e,t="task"){const i=this,a=i._getValidItemAndIndex(e,t);(e=a?a.item:void 0)&&(i._ensureVisible(e,t),i._scrollTo(e.dateStart,!0))}removeAllConnections(){const e=this;e.isCompleted&&(e.$.timelineConnectionsContainer.innerHTML="",e._connections=[],e._tasks.map((e=>e.connections=[])))}removeConnection(){const e=this,t=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted)return;let i;if(1===t.length){if("string"==typeof t[0]){const e=document.getElementById(t[0]);e&&(i=e.getAttribute("connection-id"))}i||(i=(t[0]+"").split("-"),i=e._getValidConnectionId(i[0],i[1],i[2],"removeConnection"))}else 3===t.length&&(i=e._getValidConnectionId(t[0],t[1],t[2],"removeConnection"));i&&(e._removeConnection(i),e.$.fireEvent("itemRemove",{type:"connection",id:`${i[0]}-${i[1]}-${i[2]}`,item:{source:i[0],target:i[1],type:i[2]}}))}removeTaskConnection(e,t){const i=this;if(!i.isCompleted)return;if((e+="").indexOf("-")>-1&&!t){const i=e.split("-");t=i[1],e=i[0]}const a=i._getValidItemAndIndex(e),n=i._getValidItemAndIndex(t);e=a?a.index:void 0,t=n?n.index:void 0,isNaN(e)?i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"removeTaskConnection",argumentName:"taskEndIndex"})):i._removeConnection(""+e+(isNaN(t)?"":t))}beginUpdate(){this._isUpdating={started:!0,type:{}},this.$.fireEvent("beginUpdate")}endUpdate(){const e=this;function t(){e._refreshTableDataSource(),e._createTimelineContent(),e._recycleTimelineTasks(),e._setAriaControls();const t=e._resources;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i],void 0,"resource")}function i(){if(e.hideResourcePanel)return;e._refreshTableDataSource("resource"),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._refresh();const t=e._tasks;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i])}if(!e._isUpdating)return;const a=1===Object.keys(e._isUpdating.type).length?Object.keys(e._isUpdating.type)[0]:void 0;let n,s;switch(e._selected&&({task:n,resource:s}=e._selected),delete e._isUpdating,a){case"task":t();break;case"resource":i();break;default:t(),i()}n&&(e._refreshSelectedItems("task",n),e.$.taskTable.selected=e._getSelection("task",e.selectedTaskIds)),s&&(e._refreshSelectedItems("resource",s),e.$.resourceTable.selected=e._getSelection("resource",e.selectedResourceIds)),e.$.fireEvent("endUpdate")}clearFilters(e){this._resetFromAction(e,"clearFilters")}clearSort(e){const t=this;"task"!==e&&"resource"!==e?(t._resetFromAction("task","clearSort"),t._resetFromAction("resource","clearSort")):t._resetFromAction(e,"clearSort")}clearTasks(){this._clearTasks()}_clearTasks(){const e=this;e._selected&&delete e._selected.task,e.set("selectedTaskIds",[]),e._tasks=[],e._timelineCells=[],e._timelineVCells=[],e._timelineHeaderCells=[],e.$.timelineContent.style.width="",e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e.$.timelineViewDetails.innerHTML="",e.$.timelineViewCells.innerHTML="",e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.taskIndicatorsContainer.innerHTML="",e.$.timelineContent.style.height="",delete e._hoveredItem,e.$.taskTable.dataSource=[],e._closeTooltip(),e.closeWindow(),e._refresh()}clearResources(){const e=this;e._unselectAll("resource"),e._resources=[],e.$.resourceTable&&(e.$.resourceTable.dataSource=[]),e.$.resourceTimelineCellsContainer.innerHTML="",e._tasks.forEach((t=>{t.resources=[],e._refreshTableColumnsData(t,["resources"])})),e._refreshTimeline(),e._createResourceTimeline()}createConnection(){const e=this,t=e._tasks;let i,a=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted||0===t.length)return;if(i=1===a.length?(a[0]+"").split("-"):a,!e._getValidConnectionId(i[0],i[1],i[2],"createConnection"))return;const n=parseInt(i[3]);e._connectTask([i[0],i[1],i[2],isNaN(n)?0:n]),e._recycleConnections(),e.$.fireEvent("itemInsert",{type:"connection",item:{source:i[0],target:i[1],type:i[2],lag:n}})}collapse(e){this._handleCollapseExpandMethods(e,"collapse")}expand(e){this._handleCollapseExpandMethods(e,"expand")}exportData(e,t){const i=this;if(!Smart.Utilities.DataExporter)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"smart.export.js"}));try{new JSZip}catch(e){return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"jszip.min.js"}))}if("pdf"===e&!window.pdfMake)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"pdfMake.min.js"}));const a="task"===i.dataExport.itemType?i.$.taskTable:i.$.resourceTable;return a?a.exportData(e,i.dataExport.fileName,i.dataExport.exportFiltered,t):void 0}print(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const i=e.exportData("html"),a=window.open("","","width=800,height=500"),n=a.document.open(),s='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+i+"</body></html>";try{n.write(s),n.close(),setTimeout((function(){a.print(),a.close()}),100)}catch(e){}e.dataExport.fileName=t}getConnectionDetails(e){const t=this;if("string"!=typeof e)return;const i=t._getConnectionObjById(e);if(!i)return;const a=i.startTask,n=i.endTask,s={startTask:t._cloneObject(i.startTask),endTask:t._cloneObject(i.endTask),startTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,type:i.type};return void 0!==i.lag&&(s.lag=i.lag),s}getConnections(){const e=this;return e._connections.map((t=>{const i=t.startTask,a=t.endTask;return{id:t.startIndex+"-"+t.endIndex+"-"+t.type,startTask:e._cloneObject(i),endTask:e._cloneObject(a),startIndex:t.startIndex,startTaskId:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,endIndex:t.endIndex,type:t.type,lag:t.lag}}))}getState(){const e=this,t=e._getTasksJSON(!0)||[];return{tasks:JSON.parse(JSON.stringify(t)),selectedTaskIds:e.selectedTaskIds.slice(0),resources:JSON.parse(JSON.stringify(e._resources.slice(0))),scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}get tasks(){return this.isReady?this.getTasks():[]}get resources(){return this.isReady?this.getResources():[]}getTask(e){const t=this,i=t._getValidItemAndIndex(e);if(i.item)return t._cloneObject(i.item)}getTasks(){const e=this,t=e._tasks;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getResource(e){const t=this,i=t._getValidItemAndIndex(e,"resource");if(i.item)return t._cloneObject(i.item)}getResources(){const e=this,t=e._resources;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getItemPath(e){if(!e||void 0===e.type)return;const t="string"==typeof e.type?"task":"resource",i=this._getValidItemAndIndex(e,t);return i.item?i.item.$.id:void 0}getTaskIndex(e){const t=this;return"string"==typeof e?t._getTaskIndexById(e):t._getItemIndex(e,"task")}getTaskProject(e){const t=this;if((e=t._tasks[t._getItemIndex(e,"task")])&&e.$&&e.$.project)return t._cloneObject(e.$.project)}getTaskConnections(e){const t=this._getValidItemAndIndex(e,"task");return t&&t.item?this._getTaskConnections(t.item).taskConnections.map((e=>({target:e.endIndex,type:e.type,lag:e.lag}))):[]}getResourceIndex(e){return this._getItemIndex(e,"resource")}getResourceTasks(e){const t=this._getValidItemAndIndex(e,"resource");if(e=t?t.item:void 0)return this._getTasksAssigned(e)}getSelectedIds(){const e=this,t=e.selectedTaskIds,i=e.selectedResourceIds;return e.disableSelection||!t.length&&!i.length?null:{task:t.slice(),resources:i.slice()}}getSelectedTasks(){return this._getSelectedItems("task")}getSelectedResources(){return this._getSelectedItems("resource")}getWorkingHours(){const e=this.nonworkingHours;let t=[];for(let i=0,a=23;i<a;i+=1)e.indexOf(i)<0&&t.push(i);return t}isWorkingDay(e){return e=new Date(e),!isNaN(e.getTime())&&this.nonworkingDays.indexOf(e.getDay())<0}clearState(){const e=this;e.id?window.localStorage.removeItem("smartGanttChart"+e.id):e.warn(e.localize("noId"))}loadState(e){const t=this;if(!e){if(!t.id)return;e=JSON.parse(window.localStorage.getItem("smartGanttChart"+t.id))}if(!e)return;let i=JSON.stringify(e.tasks),a=JSON.stringify(e.selectedTaskIds),n=JSON.stringify(e.resources);if(i&&(i=JSON.parse(i)),a&&(a=JSON.parse(a)),n&&(n=JSON.parse(n)),t._noChangeEvent=!0,Array.isArray(i)&&(t._createTasks(i),t.set("dataSource",i)),Array.isArray(n)){let e=n;for(let i=0;i<e.length;i++){const e=n[i];let a=t._resources.find((t=>t.id&&t.id.toString()===e.id.toString()))||{};t._setResource(a,e),Object.values(a).length&&!t._resources.includes(a)&&t._resources.push(a)}t._refreshItemIds("resource")}"number"==typeof e.scrollLeft&&(t.scrollLeft=e.scrollLeft),"number"==typeof e.scrollTop&&(t.scrollTop=e.scrollTop),t._setTable(t.$.taskTable),t._createTimeline(),t._createResourceTimeline(),Array.isArray(a)&&(t.$.taskTable.selected=t._getSelection("task",a)),delete t._noChangeEvent}saveState(){const e=this;e.id?window.localStorage.setItem("smartGanttChart"+e.id,JSON.stringify(e.getState())):e.warn(e.localize("noId"))}insertTask(e,t,i){const a=this;if("object"!=typeof e)return void a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask",argumentName:"newTask"}));const n=a._tasks;if(n.indexOf(e)>-1)return void a.error(a.localize("alreadyExists",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask"}));const s=a._createTasks([e],!0);if(!n)return;let r,o,l;const d=a._getSelection("task",a.selectedTaskIds);if("string"==typeof i&&i.indexOf(!1)){const e=i.split(".");i=parseInt(e.slice(-1)),null==t&&(t=e.slice(0,-1).join("."))}if("string"==typeof t?(r=n.find((e=>e.id&&e.id.toString()===t)),r||(r=a._getItemByTableId("task",t))):"number"==typeof t&&(r=n[t]),r){if("project"!==r.type)return void a.error(a.localize("notAProject",{elementType:a.nodeName.toLowerCase(),argumentName:"project",methodName:"insertTask"}));s[0].$.project=r}return a._synchronizeProjectVisibility(s[0].$.project,s[0]),a._insertTasks(s,r,i),a._refreshItemIds(),a._refreshConnectionIds(),a._isUpdating?(a._isUpdating.type.task=!0,void(a._isUpdating.type.resource=!0)):(a._selected&&a._selected.task&&a._setSelection("task",l=a._selected.task.map((e=>e.$.id))),a._refreshTableDataSource(),a._refreshTimeline(),l&&d.toString()!==l.toString()&&(a.$.taskTable.selected=l.slice(0)),a._refreshTaskResources(o),a._ensureVisible(o),a.$.fireEvent("itemInsert",{type:"task",item:a._cloneObject(s[0])}),s[0].id||s[0].$.id+"")}openWindow(e){const t=this;if(t.disableWindowEditor)return;if("string"==typeof e){if(e.indexOf(".")>-1){const i=t._getVCellById("task",e),a=i?i.task:void 0;return void(a&&t._openPopupWindow(a))}if(e.indexOf("-")>-1){let e=(arguments[0]+"").split("-");if(e=t._getValidConnectionId(e[0],e[1],e[2],"openEditor"),e)return void t._openPopupWindow(e)}}const i=t._getValidItemAndIndex(e);i&&t._openPopupWindow(i.item)}closeWindow(){const e=this,t=["confirm","task","connection"];for(let i=0;i<t.length;i++){const a=e.$[t[i]+"PopupWindow"];a&&(a.close(),delete a._target)}}updateTask(e,t){const i=this,a=i._getValidItemAndIndex(e),n=a?a.item:void 0;"object"==typeof n?"object"==typeof t?i._updateTask(n,t):i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"taskDetails"})):i.error(i.localize("notExisting",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"newTask"}))}removeTask(e){const t=this,i=t._tasks,a=t._getValidItemAndIndex(e),n=a?a.item:void 0;i&&i.length&&("object"==typeof n?t._removeTask(n):t.error(t.localize("notExisting",{elementType:t.nodeName.toLowerCase(),methodName:"removeTask",argumentName:"index"})))}setWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,a=e.length;i<a;i+=1){const a=parseInt(e[i]),n=t.indexOf(a);n>-1&&t.splice(n,1)}return t}))}selectTask(e){this._handleItemSelection(e,"task")}selectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource")}sort(e){const t=this;if("none"===t.sortMode)return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const i=t.taskColumns,a=t.resourceColumns,n=t.$.taskTable,s=t.$.resourceTable;for(let t=0;t<e.length;t++){const r=e[t],o="desc"===r.sortOrder?"desc":"asc",[l,d]="resource"===r.type||a.includes(r)?[s,a]:[n,i],c=d.find((e=>r.value&&e.value===r.value));c&&l.sortBy(c.value,o)}}unselectTask(e){this._handleItemSelection(e,"task",!0)}unselectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource",!0)}unsetWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,a=e.length;i<a;i+=1){const a=parseInt(e[i]);t.indexOf(a)<0&&t.push(a)}return t}),!0)}hideTooltip(){this._closeTooltip()}showTooltip(e,t){this._openTooltip(e,void 0,t)}_getSelectedItems(e="task"){const t=this,i=t[`_${e}s`],a=t._getSelection(e,"task"===e?t.selectedTaskIds:t.selectedResourceIds);if(!a.length)return[];let n=[];for(let e=0,s=i.length;e<s;e+=1){const s=i[e];a.indexOf(s.$.id)>-1&&n.push(t._cloneObject(s))}return n}_getTasksAssigned(e){const t=this,i=t._tasks||[];let a=[];for(let n=0;n<i.length;n++){const s=i[n];!s.disableResources&&s.resources.find((t=>t===e.id))&&a.push(t._cloneObject(s))}return a}_getItemIndex(e,t){t||(t="task");const i=this[`_${t}s`];if(e instanceof HTMLElement&&e.classList.contains("smart-timeline-task"))return i.indexOf(e._cellObj[`_${t}`]);const a="resource"===t?["id","label","value","progress"]:["id","label","type","class","dateStart","dateEnd","resources","connections"];if("object"==typeof e)for(let t=0;t<i.length;t++)if(a.every((a=>Array.isArray(e[a])?JSON.stringify(e[a])===JSON.stringify(i[t][a]):a.indexOf("date")>-1?new Date(e[a]).getTime()===new Date(i[t][a]).getTime():e[a]===i[t][a])))return i.indexOf(i[t]);return-1}_handleItemSelection(e,t="task",i){const a=this,n=a._getValidItemAndIndex(e,t);if(n.item){const s=n.item,r=a._getSelection(t,"task"===t?a.selectedTaskIds:a.selectedResourceIds);if(e=s.$.id,i){const i=r.indexOf(e);i>-1&&(r.splice(i,1),a.$[`${t}Table`].selected=r)}else r.indexOf(e)<0&&(r.push(e),a.$[`${t}Table`].selected=r);return"string"==typeof s.id||"number"==typeof s.id?s.id:s.$.id}}_refreshAfterWorkingTimeChange(){const e=this;if(e.adjustToNonworkingTime)for(let t=0;t<e._tasks.length;t++){const i=e._tasks[t],a=i.$.project;e._validateTaskDates(i,a),e._synchronizeProjectDates(i,a),e._refreshTableColumnsData(i,["dateEnd","duration"])}e._refreshTimeline()}_refreshItemIds(e="task"){const t=this[`_${e}s`];if(!t)return;let i={},a=0;for(let e=0,n=t.length;e<n;e+=1){const n=t[e],s=n.$.project;if(void 0!==s){const e=s.$.id;i[e]||(i[e]=0),n.$.id=e+"."+i[e],i[e]++}else n.$.id=a+"",a++}}_refreshConnectionIds(){const e=this._tasks,t=this._connections;if(t&&t.length)for(let i=0,a=t.length;i<a;i+=1){const n=t[i],s=e.indexOf(n.startTask),r=e.indexOf(n.endTask);(s<0||r<0)&&(t.splice(i,1),a--),n.startIndex=s,n.endIndex=r}}_refreshSelectedItems(e="task",t){const i=this,a=i[`_${e}s`];if(a&&(!t&&i._selected&&i._selected[e]&&(t=i._selected[e]),t)){for(let e=0,i=t.length;e<i;e+=1){const n=t[e];(a.indexOf(n)<0||n.hidden)&&(t.splice(e,1),e-=1,i--)}i._setSelection(e,t.map((e=>e.$.id)))}}_resetFromAction(e="task",t="clearSort"){const i=this;function a(){i.$.taskTable[t](),i._createTimelineContent(),i._recycleTimelineTasks()}function n(){const e=i.$.resourceTable;e&&(e[t](),i._createResourceTimelineVCells(),i._recycleResourceContent())}"resource"===e?n():"task"===e?a():(a(),n())}_setWorkTime(e,t,i){const a=this;if("object"!=typeof e)return;let n,s=e.days,r=e.hours;null!=s&&(Array.isArray(s)||(s=[s]),s=a._nonworkingDayValidator(void 0,s),n=t(s,i?a.nonworkingDays:[0,1,2,3,4,5,6]),a.set("nonworkingDays",7===n.length?[]:n),a._refreshAfterWorkingTimeChange()),null!=r&&(Array.isArray(r)||(r=[r]),r=a._nonworkingTimeValidator(void 0,r),n=t(r,i?a.nonworkingHours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),a.set("nonworkingHours",24===n.length?[]:n),a._refreshAfterWorkingTimeChange())}_getValidConnectionId(e,t,i,a){const n=this,s=n._tasks,r=0===a.indexOf("_");let o;if("string"==typeof e&&(o=n._getTaskIndexById(e),o>=0&&(e=o)),"string"==typeof t&&(o=n._getTaskIndexById(t),o>=0&&(t=o)),e=parseInt(e),t=parseInt(t),i=parseInt(i),isNaN(e)||isNaN(t)||e===t)r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else if(e>=s.length||e<0||t>=s.length||t<0)r||n.error(n.localize("outOfBounds",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else{if(!(isNaN(i)||i<0||i>3))return r?[e,t,i]:e+"-"+t+"-"+i;r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"connectionType"}))}}_autoSchedule(e){const t=this,i=t._tasks;if(t.autoSchedule){e?Array.isArray(e)||(e=[e]):e=i;for(let i=0;i<e.length;i++){const a=e[i];"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}t._isUpdateRequired&&(t._createTimelineCells(),t._recycleTimelineTasks(!0),delete t._isUpdateRequired)}}_getTaskConnections(e){const t=this._tasks,i=this._connections;let a=[],n=[];if(t&&t.length&&i&&i.length){const s=t.indexOf(e);for(let e=0;e<i.length;e+=1){const t=i[e];t.startIndex===s?a.push(t):t.endIndex===s&&n.push(t)}}return{taskConnections:a,connectedTasks:n}}_autoScheduleTasks(e){const t=this,i=t._tasks,a=t._getTaskConnections(e),n=a.taskConnections,s=a.connectedTasks;let r,o,l;for(let a=0;a<n.length;a++)t._isAutoScheduled(e,i[n[a].endIndex],!0);for(let a=0;a<s.length;a++){const n=s[a],d=i[n.startIndex],c=n.type,m=n.lag,u=e.$.project;d&&"project"===d.type&&d.synchronized||(0===c||1===c?(l=new Date((0===c?d.dateStart:d.dateEnd).getTime()+m),e.minDateStart=new Date(e.minDateStart?Math.max(e.minDateStart.getTime(),l.getTime()):l),o=e.minDateStart.getTime()-e.dateStart.getTime(),r=new Date(e.dateEnd.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateStart.getTime()!==e.dateStart.getTime()&&(e.dateStart=e.minDateStart,t._isUpdateRequired=!0)):(l=new Date((2===c?d.dateEnd:d.dateStart).getTime()+m),e.minDateEnd=new Date(e.minDateEnd?Math.min(e.minDateEnd.getTime(),l.getTime()):l),o=e.minDateEnd.getTime()-e.dateEnd.getTime(),r=new Date(e.dateStart.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateStart.getTime()&&(e.dateStart=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateEnd.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=e.minDateEnd,t._isUpdateRequired=!0)),t._validateTaskDates(e,u),t._synchronizeProjectDates(e,u))}for(let e=0;e<n.length;e++){const a=i[n[e].endIndex];!a||"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}}_autoScheduleRestore(e,t){const i=this._tasks;e||(e=i),Array.isArray(e)||(e=[e]);for(let a=0;a<e.length;a++){const n=e[a];i.indexOf(e[a])>-1&&(t?0===t||1===t?n.minDateStart=void 0:n.minDateEnd=void 0:n.minDateStart=n.minDateEnd=void 0)}}_autoScroll(e){const t=this,i=t.hasAttribute("dragged"),a=t.hasAttribute("resized");function n(n,s){if(!t._dragDetails)return clearInterval(t._scrollInterval),t._scrollInterval=void 0,void delete t._autoScrolling;t._autoScrolling=!0,s?i||(t.scrollTop-=t.autoScrollStep*n,t._dragDetails.coordinates.y+=t.autoScrollStep*n):(t.scrollLeft-=(t.rightToLeft?-1:1)*t.autoScrollStep*n,t._dragDetails.coordinates.x+=t.autoScrollStep*n),i?t._handleTaskBarDrag(e):a&&t._handleTaskBarResize(e)}if(t.disableAutoScroll||!e||!i&&!a&&!t.hasAttribute("connecting-task"))return;const s=t.$.timeline.getBoundingClientRect();t._scrollInterval&&clearInterval(t._scrollInterval),t._scrollInterval=setInterval((function(){(t.scrollLeft||t.rightToLeft)&&e.clientX<=s.left+20?n(1):t.scrollLeft!==(t.rightToLeft?0:t.scrollWidth)&&e.clientX>=s.left+s.width-20?n(-1):t.scrollTop&&e.clientY<=s.top+20?n(1,!0):t.scrollTop!==t.scrollHeight&&e.clientY>=s.top+s.height-20?n(-1,!0):(clearInterval(t._scrollInterval),t._scrollInterval=void 0,delete t._autoScrolling)}),1)}_checkTaskBarResizability(e){const t=this;let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const a=t.$.timeline;if(!i.closest)return void a.removeAttribute("task-bar-hovered");let n,s=i.closest(".smart-timeline-row")||i.closest(".smart-timeline-task");if(t.disabled||t.disableTaskResize||!s||!a.contains(s))return void a.removeAttribute("task-bar-hovered");const r=s._cellObj.task,o=t._getTaskDOMIndex(r);if(s.classList.contains("smart-timeline-row")?n=t.$.timelineTasksContainer.children[o]:s.classList.contains("smart-timeline-task")&&(n=s,s=t.$.taskTimelineCellsContainer.children[o]),!n||n.classList.contains("milestone")||r.synchronized||r.disableResize)return;const l=i.closest(".smart-task-segment"),d=r.segments?r.segments.length:1;if(i.classList&&i.classList.contains("smart-task-connection-point")||l&&(d>1&&t.disableSegmentResize||l._segmentObj&&l._segmentObj.disableResize))return void a.removeAttribute("task-bar-hovered");const c=e.pageX-window.pageXOffset,m="visible"===t.resizeHandlesVisibility||t._isMobile?20:5,u=(l||n).getBoundingClientRect(),h=s.getBoundingClientRect(),g=Math.min(m,c-h.left),f=Math.min(m,h.left+h.width-c);Math.round(u.left)+g>=c&&Math.round(u.left)-g<=c?a.setAttribute("task-bar-hovered","left"):Math.round(u.left+u.width)+f>=c&&Math.round(u.left+u.width)-f<=c?a.setAttribute("task-bar-hovered","right"):a.removeAttribute("task-bar-hovered")}_onShadowDomLoaded(e,t,i){requestAnimationFrame((function a(){const n=(e.shadowRoot||e.getRootNode()).querySelectorAll("link");for(let e=0;e<n.length;e++)if(-1!==n[e].href.indexOf(t))return void i();requestAnimationFrame(a)}))}_getConnectionObjById(e){const t=this._connections;if(!e||!t||!t.length)return;const i=e.split("-"),a=parseInt(i[0]),n=parseInt(i[1]),s=parseInt(i[2]);for(let e=0,i=t.length;e<i;e+=1){const i=t[e];if(i.startIndex===a&&i.endIndex===n&&i.type===s)return i}}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),i=[e.$.taskPopupWindow,e.$.connectionPopupWindow,e.$.confirmPopupWindow];for(let a=0;a<i.length;a++){const n=i[a];if(!n||!t.contains(n))continue;const s=e.getBoundingClientRect();n.opened||(n.style.left=n.style.top=""),e._isMobile?(n.setAttribute("mobile",""),n.style.left=s.left+window.pageXOffset+"px",n.style.top=s.top+window.pageYOffset+"px",n.style.width=s.width+"px",n.style.height=s.height+"px"):(n.style.left=Math.max(s.left+window.pageXOffset,s.left+window.pageXOffset+s.width/2-n.offsetWidth/2)+"px",n.style.top=Math.max(s.top+window.pageYOffset,s.top+window.pageYOffset+s.height/2-n.offsetHeight/2)+"px")}}_openPopupWindow(e,t){const i=this;function a(){function t(){i._positionWindow(),s.opened?(s.bringToFront(),s._onOpenCallback?s._onOpenCallback():s._handleActiveState()):s.open()}if(i.popupWindowCustomizationFunction?i.popupWindowCustomizationFunction(s,n,"connection"===n?e.startIndex+"-"+e.endIndex+"-"+e.type:i._cloneObject(e)):s._onOpenCallback=()=>{const e=(s.shadowRoot||s).querySelectorAll(".smart-gantt-chart-popup-window-editor .smart-input, .smart-popup-window-button");(e[0]||e[1]||s).focus({preventScroll:!0}),s._handleActiveState()},i._setPopupWindowTemplate("header",n,e),i._setPopupWindowTemplate("footer",n,e),i._setPopupWindowTemplate("content",n,e),!i._popupWindow[n+"PopupWindow"]){const e=i["$"+n+"PopupWindow"];e.unlisten("transitionend"),e.unlisten("open"),e.unlisten("close"),e.unlisten("closing"),e.unlisten("click"),e.unlisten("change"),e.listen("transitionend",i._popupWindowTransitionendHandler.bind(i)),e.listen("open",i._popupWindowOpenHandler.bind(i)),e.listen("close",i._popupWindowCloseHandler.bind(i)),e.listen("closing",i._popupWindowClosingHandler.bind(i)),e.listen("click",i._popupWindowClickHandler.bind(i)),e.listen("change",i._popupWindowChangeHandler.bind(i))}s.shadowRoot?(s.importStyle(Smart.Utilities.Core.getScriptLocation()+Smart.StyleBaseUrl.replace("/scoped/","/smart.textbox.css")),i._onShadowDomLoaded(s,"smart.window.css",t)):t();const a=(i.getAttribute("aria-owns")||"")+" "+s.id;i.setAttribute("aria-owns",a.trim()),i._popupWindow[n+"PopupWindow"]=s}if(e&&e.classList)if(e.classList.contains("smart-task-connection"))e=i._getConnectionObjById(e.getAttribute("connection-id"));else if("TR"===e.nodeType){const t=e?"task":"resource",a=i._getVCellById(t,e.getAttribute("row-id"));e=a?a[t]:void 0}else e=e._cellObj.task;if(!e||e.isGroup)return;const n=t?"confirm":"string"==typeof e.type?"task":"connection",s=i._createPopupWindow(n);!t&&i.$.fireEvent("opening",{target:s,type:n}).defaultPrevented||(i._closeTooltip(),s._target=e,i._popupWindow||(i._popupWindow={}),s.parentElement||i.getShadowRootOrBody().appendChild(s),s.isCompleted?a():s.whenReady((()=>a())))}_createPopupWindow(e){const t=this,i=e+"PopupWindow";if(t.$[i])return t.$[i];const a=document.createElement("smart-window");return a.classList.add("smart-"+e+"-popup-window"),a.classList.add("smart-gantt-chart-popup-window"),a.setAttribute("smart-id",i),t.$[i]=a,t["$"+i]=Smart.Utilities.Extend(a),a.rightToLeft=t.rightToLeft,a.theme=t.theme,a.animation=t.animation,a.disableSnap=!0,a.headerButtons=["close"],a}_popupWindowOpenHandler(e){const t=this,i=t["$"+e.target.getAttribute("smart-id")];if(i){const a=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";t._handleModal(!0),t.$.fireEvent(e.type,Object.assign({type:a,target:e.target},e.detail)),i.unlisten("open")}}_popupWindowClosingHandler(e){const t=this["$"+e.target.getAttribute("smart-id")];if(!t)return;const i=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";this.$.fireEvent(e.type,{target:e.target,type:i}).defaultPrevented?e.preventDefault():t.unlisten(e.type)}_popupWindowCloseHandler(e){const t=this,i=e.target.getAttribute("smart-id"),a=t["$"+i];if(a){const n=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";if(t._handleModal(),t.$.fireEvent(e.type,Object.assign({type:n,target:e.target},e.detail)),a.unlisten("close"),a.unlisten("click"),t.hasAttribute("aria-owns")){const e=t.getAttribute("aria-owns").replace(t._popupWindow[i].id,"").trim();e?t.setAttribute("aria-owns",e):t.removeAttribute("aria-owns")}delete t._popupWindow[i];const s=Object.keys(t._popupWindow);1===s.length&&t._popupWindow.confirmPopupWindow&&(delete t._popupWindow.confirmPopupWindow._target,t._popupWindow.confirmPopupWindow.close()),s.length?requestAnimationFrame((()=>{const e=t._popupWindow[s[s.length-1]];e&&e.focus()})):t.keyboardNavigation&&t.$.taskTable.focus({preventScroll:!0})}}_popupWindowTransitionendHandler(e){const t=this,i=e.target;i instanceof Smart.Window&&!i.opened&&"visibility"===e.propertyName&&(t["$"+i.getAttribute("smart-id")].unlisten("transitionend"),i.parentElement&&i.parentElement.removeChild(i))}_handleModal(e){const t=this;let i=(t.shadowRoot||t).querySelector(".smart-popup-window-modal");e?(i||(i=document.createElement("div"),i.classList.add("smart-popup-window-modal")),i.parentElement||(t.$.container.appendChild(i),t.setAttribute("modal",""))):i&&i.parentElement&&Object.keys(t._popupWindow).length<2&&(i.parentElement.removeChild(i),t.removeAttribute("modal"))}_findTaskEditor(e,t){if(!e||!t)return;const i=t.children;for(let t=0,a=i.length;t<a;t+=1){const a=i[t];if(a.getAttribute("value")===e)return a}}_createTaskEditor(e,t,i){const a=this,n=e.value,s=t[e.value];let r,o,l=i.find((e=>e._label===n));if(l)r=l.querySelector(".smart-gantt-chart-label-container"),o=l.lastElementChild;else{const t="editorLabel"+Math.floor(65536*(1+Math.random())).toString(16).substring(1);if(r=document.createElement("div"),r.classList.add("smart-gantt-chart-label-container"),r.innerHTML=`<label id="${t}"></label>`,"deadline"===n){const e=document.createElement("span");e.classList.add("smart-popup-window-editor-toggle"),r.appendChild(e)}if(l=document.createElement("div"),l.classList.add("smart-gantt-chart-popup-window-editor"),l.setAttribute("value",n||""),l._label=n,e.customEditor)return l.appendChild(e.customEditor(n,s)),l;if("number"==typeof s||"string"==typeof s)o=document.createElement("input"),o.classList.add("smart-input");else if(s instanceof Date||"deadline"===n)Smart.DateTimePicker?(o=document.createElement("smart-date-time-picker"),o.locale=a.locale,o.dropDownAppendTo="body",o.calendarButton=!0,o.dropDownDisplayMode="auto",o.enableMouseWheelAction=!0,o.formatString="yyyy-MMM-dd HH:mm:ss"):(o=document.createElement("input"),o.type="datetime-local");else if(Array.isArray(s))if(Smart.DropDownList)o=document.createElement("smart-drop-down-list"),o.virtualized=!0,o.dropDownAppendTo="body",o.selectionMode="zeroOrMany";else{o=document.createElement("input"),o.classList.add("smart-input");const e=document.createElement("datalist");e.id="resourceList",o.setAttribute("list",e.id),l.appendChild(e)}o&&o.setAttribute("aria-labelledby",t)}if(!l.parentElement)return r&&l.appendChild(r),o&&l.appendChild(o),l;a._setPopupWindowEditors(e,t,l)}_setAriaControls(){this.setAttribute("role","treegrid")}_setPopupWindowEditors(e,t,i){const a=this,n=i.querySelector("label"),s=i.querySelector(".smart-popup-window-editor-toggle"),r=i.lastElementChild,o=e.value+"",l=o.split(/(?=[A-Z])/).join(" "),d=t[o];if(e.customEditor)e.setCustomEditorValue&&e.setCustomEditorValue(i,l,d);else{if(n.innerHTML=a.localize(e.value)||l.charAt(0).toUpperCase()+l.slice(1),s)if("deadline"===o){const e=null==d?"add":"remove";r.classList[e]("smart-hidden"),s.textContent=a.localize(e)}else s.remove();if("number"==typeof d)r.value=parseFloat(d);else if("string"==typeof d)r.value=d;else if(d instanceof Date)r.value=new Date(d);else if(Array.isArray(d)){const e=a._resources;if(r.placeholder=a.localize("unassigned"),Smart.DropDownList&&r instanceof Smart.DropDownList)r.dataSource=e.map((e=>({label:e.label,value:e.id}))),r.selectedValues=t.disableResources?[]:t.resources.map((e=>e.toString()));else{let a=i.querySelector("datalist"),n=document.createDocumentFragment();a.innerHTML="";for(let t=0;t<e.length;t++){const i=e[t],a=document.createElement("option");a.value=i.id,a.innerHTML=i.label,n.appendChild(a)}r.value=t.resources.toString(),a.appendChild(n)}}"project"===t.type&&t.synchronized&&["duration","date"].indexOf(l.toLowerCase())>-1||"resources"===l&&t.disableResources?r.disabled=!0:r.disabled=!!e.disableEdit,r.rightToLeft=a.rightToLeft,r.animation=a.animation,r.theme=a.theme}}_setupPopupWindowTabs(e,t){const i=this,a=i.popupWindowTabs,n="milestone"===t.type,s=[{label:i.localize("generalTab"),value:"general"},{label:i.localize("dependencyTab"),value:"dependency"},{label:i.localize("segmentsTab"),value:"segments"}];let r=e.querySelector(".smart-gantt-chart-popup-window-tabs");r||(r=document.createElement("smart-tabs"),r.classList.add("smart-gantt-chart-popup-window-tabs"),e.clear(),e.appendChild(r)),r.animation=i.animation,r.rightToLeft=i.rightToLeft,r.theme=i.theme;const o=r.getTabs().slice(0);for(let e=0,t=s.length;e<t;e+=1){const t=s[e],i=t.value;let l=o[e];a.indexOf(i)<0?l&&r.removeChild(l):(l||(l=document.createElement("smart-tab-item"),r.appendChild(l)),l.label=t.label,l.setAttribute("value",i||""),l.disabled=n&&"segments"===i)}return r}_setPopupWindowContent(e,t){const i=this,a=i.$[e+"PopupWindow"],n=[].slice.call(a.querySelectorAll(".smart-gantt-chart-popup-window-editor"));if(a.content&&(!a.content.innerHTML||n.length))if("task"===e&&t){const e=i.taskColumns;let s=[];const r=i._setupPopupWindowTabs(a,t);0!==r.selectedIndex&&(r.selectedIndex=0);const o=r.getTabs()[0];if("general"!==o.getAttribute("value"))return void i._handleTabsContent(o,a);"string"==typeof o.content?o.content="":o.content.innerHTML="";for(let a=0;a<e.length;a++){const r=e[a],l=r.value;if(void 0===t[l]&&"deadline"!==l||"overdue"===l)continue;let d=i._findTaskEditor(l,o);d||(d=i._createTaskEditor(r,t,n),d&&o.appendChild(d)),d&&(i._setPopupWindowEditors(r,t,d),s.push(d))}for(let e=0,t=n.length;e<t;e+=1){const t=n[e];s.indexOf(t)<0&&t.remove()}t.id&&a.setAttribute("aria-controls",t.id)}else if("confirm"===e){if(a.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("confirm",{componentName:"The task"})+"</div >",i._popupWindow){const e=Object.keys(i._popupWindow);e.length&&a.setAttribute("aria-controls",i._popupWindow[e[e.length-1]].id)}}else{const e=t.startTask,n=t.endTask;a.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("deleteLink")+"<b> "+e.label+" - "+n.label+"?</b></div>"}}_setPopupWindowTemplate(e,t,i){const a=this,n=a.$[t+"PopupWindow"];if("content"!==e){if(n[e+"Template"]||(n[e+"Template"]=a._createPopupWindowTemplate(e,t)),"header"===e&&i&&"string"==typeof i.type){const e=(n.shadowRoot||n).querySelector(".smart-popup-window-label");e&&(e.innerHTML=i.label)}else if("footer"===e){const e=(n.shadowRoot||n).querySelectorAll(".smart-popup-window-button");for(let i=0;i<e.length;i++){const n=e[i];n.innerHTML="task"===t?'<span class="smart-icon"></span>':"",n.theme=a.theme,n.rightToLeft=a.rightToLeft,n.animation=a.animation,n.disabled=!1,n.classList.contains("ok")?(n.innerHTML+=a.localize("ok"),n.setAttribute("aria-label","ok")):n.classList.contains("cancel")?(n.innerHTML+=a.localize("cancel"),n.setAttribute("aria-label","cancel")):n.classList.contains("delete")&&(n.innerHTML+=a.localize("delete"),n.setAttribute("aria-label","delete"));const s=n.querySelector(".smart-ripple");s&&s.parentElement.removeChild(s)}}}else a._setPopupWindowContent(t,i)}_createPopupWindowTemplate(e,t){const i=this,a=document.createElement("template");if("footer"===e)switch(t){case"task":a.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button delete secondary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`;break;case"connection":case"confirm":a.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`}else"header"!==e||"task"!==t&&"confirm"!==t||(a.innerHTML='<span class="smart-popup-window-label"></span>');return a}_handleTabsContent(e,t){const i=this,a=t._target;if(!e|!a)return;const n=e.getAttribute("value");if("general"===n)return;let s=e.querySelector(".smart-gantt-popup-window-table"),r=e.querySelector(".smart-gantt-window-table-buttons"),o=e.querySelector(".smart-gantt-window-validation-message");r||(r=document.createElement("div"),r.classList.add("smart-gantt-window-table-buttons"),r.innerHTML=`<smart-button class="smart-gantt-chart-button" action="add">${i.localize("add")}</smart-button>\n <smart-button class="smart-gantt-chart-button" disabled action="delete">${i.localize("delete")}</smart-button>`,e.insertBefore(r,s)),s||(s=document.createElement("smart-table"),s.classList.add("smart-gantt-popup-window-table"),s.editing=!0,s.editMode="row",s.keyboardNavigation=!0,s.wait=!0,s.hideSelectionColumn=!0,s.selection=!0,s.selectionMode="one",s.columnMinWidth="10px",s.addEventListener("rowEndEdit",(r=>{const o=r.detail.row;switch(n){case"dependency":{const e=i._tasks,t=o.name,n=e.indexOf(a),r=e.findIndex((e=>e.$.id===t));r>-1&&s.updateRow(o.$.id,{id:`${r}-${n}-${o.type}`});break}case"segments":{const e=o.dateStart,t=o.dateEnd;e.getTime&&t.getTime&&s.updateRow(o.$.id,{duration:parseFloat(i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e,t):t.getTime()-e.getTime(),!0).toFixed(2))});break}}i._applyTableValidation(e,s,t),i._isPopupWindowTableModified=!0})),e.innerHTML&&(e.innerHTML=""),e.appendChild(s));const l=i._getTabsTableData(n,a);s.selected.length&&(s.selected=[]),s.dataSource=l.source,s.columns=l.columns,s.wait=!1,delete i._isPopupWindowTableModified,o||(o=document.createElement("label"),o.classList.add("smart-gantt-window-validation-message"),e.appendChild(o)),o.textContent=""}_applyTableValidation(e,t,i){const a=this,n=e.getAttribute("value"),s=e.querySelector(".smart-gantt-window-validation-message"),r=i.querySelector(".smart-popup-window-button.ok"),o=t.dataSource,l=o.length;if(!s)return void(r&&(r.disabled=!1));if(!l)return s.textContent="",void(r&&(r.disabled=!1));let d="";if("segments"===n)if(l<2)d=a.localize("segmentsCountValidation");else{const e=i._target,t=e.dateStart.getTime(),n=e.dateEnd.getTime();let s={};for(let e=0;e<l;e+=1){const i=o[e],r=i.label,l=i.dateStart.getTime(),c=i.dateEnd.getTime();for(let e in s){const t=s[e],n=t.timeStart,r=t.timeEnd,o=l<=n&&c>=n,m=l<=r&&c>=r;(o||m)&&(d+=a.localize("segmentConflictError",{dateConflict:o?"dateStart":"dateEnd",label:i.label,conflictLabel:t.label})+"\r\n")}l>c?d+=a.localize("segmentStartError",{label:i.label})+"\r\n":l===c&&(d+=a.localize("segmentEndError",{label:i.label})+"\r\n"),(l<t||c>n)&&(d+=a.localize("segmentRangeError",{label:i.label})+"\r\n"),void 0===s[e]&&(s[e]={label:r,timeStart:l,timeEnd:c})}}else if("dependency"===n)for(let e=0;e<l;e+=1){const t=o[e].id.split("-");t[0]===t[1]&&(d+=a.localize("dependencyValidation")+"\r\n")}s.textContent=d,r&&(r.disabled=d.length>0)}_getTabsTableData(e,t){const i=this;if("dependency"===e){const e=i._getTaskConnections(t).connectedTasks,a={connectionTypes:[{label:i.localize("startToStart"),value:0},{label:i.localize("endToStart"),value:1},{label:i.localize("endToEnd"),value:2},{label:i.localize("startToEnd"),value:3}],tasks:(()=>{const e=i._tasks;let a=[];for(let i=0,n=e.length;i<n;i+=1){const n=e[i];n!==t&&a.push({value:n.$.id,label:n.label})}return a})()};return{source:new window.Smart.DataAdapter({dataSource:e&&e.length?e.map((e=>({id:e.startIndex+"-"+e.endIndex+"-"+e.type,name:e.startTask.$.id||"",type:e.type,lag:e.lag||0}))):[],dataFields:["id: any","name: any","type: number","lag: number"]}),columns:[{label:i.localize("id"),dataField:"id",dataType:"any",autoWidth:!1,allowEdit:!1},{label:i.localize("name"),dataField:"name",dataType:"any",width:"35%",autoWidth:!1,editor:i._getColumnEditorSetup("name",a),formatFunction:e=>{const t=a.tasks.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("type"),dataField:"type",dataType:"number",width:"25%",autoWidth:!1,editor:i._getColumnEditorSetup("type",a),formatFunction:e=>{const t=a.connectionTypes.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("lag"),dataField:"lag",dataType:"number",autoWidth:!1}]}}if("segments"===e){const e={task:t};return{source:new window.Smart.DataAdapter({dataSource:t.segments,dataFields:["label: string","dateStart: date","dateEnd: date","duration: number"]}),columns:[{label:i.localize("name"),dataField:"label",dataType:"string",autoWidth:!1,width:"20%"},{label:i.localize("dateStart"),dataField:"dateStart",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateStart",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateStart)}},{label:i.localize("dateEnd"),dataField:"dateEnd",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateEnd",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateEnd)}},{label:i.localize("duration"),dataField:"duration",dataType:"number",autoWidth:!1,width:"15%",allowEdit:!1}]}}return{source:[],columns:[]}}_getColumnEditorSetup(e,t){const i=this;switch(e){case"dateStart":case"dateEnd":return{template:'<smart-date-time-picker drop-down-append-to="body" wait></smart-date-time-picker>',onInit:(e,a,n,s)=>{const r=t.task;s||(s=new Date(r.dateStart)),n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.min=r.dateStart,n.max=r.dateEnd,n.locale=i.locale,n.calendarButton=!0,n.dropDownDisplayMode="auto",n.enableMouseWheelAction=!0,n.formatString="yyyy-MMM-dd HH:mm:ss",n.value=new Date(Math.max(r.dateStart.getTime(),Math.min(r.dateEnd.getTime(),s.getTime()))),n.removeAttribute("wait")},getValue:e=>e.value.toDate()};case"name":return{template:'<smart-drop-down-list virtualized drop-down-append-to="body" wait></smart-drop-down-list>',onInit:(e,a,n,s)=>{n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dataSource=t.tasks,n.selectedValues=[s],n.removeAttribute("wait")},getValue:e=>e.selectedValues[0]};case"type":return{template:"<smart-input wait></smart-input>",onInit:(e,a,n,s)=>{const r=t.connectionTypes,o=r.find((e=>e.value===s));n.readonly=!0,n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dropDownButtonPosition="right",n.dataSource=r,n.value=(o||r[0]).label+"",n.removeAttribute("wait")},getValue:e=>{if(e.selectedValues.length)return e.selectedValues[0];const i=t.connectionTypes.find((t=>t.label===e.value));return i?i.value:void 0}}}}_popupWindowChangeHandler(e){const t=this,i=e.target,a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0);if(a._target)if(i.classList.contains("smart-gantt-chart-popup-window-tabs")){const n=a.querySelector(".smart-popup-window-button.ok");n&&(n.disabled=!1),t._handleTabsContent(i.getTabs()[e.detail.index],a)}else if(i.classList.contains("smart-gantt-popup-window-table")){const e=i.closest("smart-tab-item").querySelector('.smart-gantt-chart-button[action="delete"]');e&&(e.disabled=0===i.selected.length)}}_popupWindowClickHandler(e){const t=this;let i=(e.originalEvent||e).target;i.shadowRoot&&(i=(e.originalEvent||e).composedPath()[0]);const a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0),n=a._target;if(i.closest(".smart-popup-window-button.cancel"))return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target;if(i.closest(".smart-popup-window-button.ok")){if(a===t.$.connectionPopupWindow&&"number"==typeof n.type)t._removeConnection(n.startIndex+"-"+n.endIndex+"-"+n.type);else if(a===t.$.confirmPopupWindow){const e=n;void 0!==e.$._resourceId?t._removeResource(e):t._removeTask(e),a.close(),t.$.taskPopupWindow&&t.$.taskPopupWindow.close(),delete a._target}else{const e=a.shadowRoot||a,i=e.querySelectorAll(".smart-gantt-chart-popup-window-editor"),s=n;let r={};for(let e=0;e<i.length;e++){const a=i[e]._label,n=t.taskColumns.find((e=>e.value===a));if(n.customEditor&&n.getCustomEditorValue)r[a]=n.getCustomEditorValue(i[e]);else{const t=i[e].lastElementChild;let n;if(!t)continue;if(t.classList.contains("smart-hidden")){r[a]=void 0;continue}n=Smart.DateTimePicker&&t instanceof Smart.DateTimePicker?t.value.toDate?t.value.toDate():t.value:t instanceof HTMLInputElement&&"datetime-local"===t.type?new Date(t.value):Smart.DropDownList&&t instanceof Smart.DropDownList?t.selectedValues.slice(0):t.hasAttribute("list")?t.value.split(",").map((e=>e.trim())):t.value,n instanceof Date&&isNaN(n.getTime())&&(n=void 0),null!=n&&(r[a]=n)}}if(void 0!==s.$._resourceId)t._updateResource(s,r);else{const i=r.dateStart?r.dateStart:void 0,a=r.dateEnd?r.dateEnd:void 0;if((i&&i.getTime&&i.getTime()!==s.dateStart.getTime()||a&&a.getTime&&a.getTime()!==s.dateEnd.getTime())&&(r.duration=void 0),t._isPopupWindowTableModified){const i=e.querySelectorAll(".smart-gantt-popup-window-table");for(let e=0,a=i.length;e<a;e+=1){const a=i[e];a.closest('.smart-tab-item[value="dependency"]')?t._updateTaskDependencies(a,s):a.closest('.smart-tab-item[value="segments"]')&&t._updateTaskSegments(a,s)}}t._updateTask(s,r)}}return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target}if(i.closest(".smart-popup-window-button.delete"))return void t._openPopupWindow(a._target,!0);if(i.closest(".smart-popup-window-editor-toggle")){const e=i.closest('.smart-gantt-chart-popup-window-editor[value="deadline"]'),a=e?e.lastElementChild:void 0;if(a){const e=a.classList.contains("smart-hidden")?"remove":"add";a.classList[e]("smart-hidden"),i.textContent=t.localize(e)}return}const s=i.closest(".smart-gantt-chart-button");if(s){const e=i.closest("smart-tab-item"),r=e.querySelector(".smart-gantt-popup-window-table");if(!r)return;const o=s.getAttribute("action"),l=e.getAttribute("value"),d=n;switch(o){case"add":{let e;e="segments"===l?{label:`${t.localize("segment")} ${r.dataSource.length+1}`,dateStart:new Date(d.dateStart),dateEnd:new Date(d.dateEnd),duration:parseFloat((d.duration||0).toFixed(2))}:{id:"",name:"",type:0,lag:0},r.addRow(e),r.beginEdit(r.rows.length-1),t._isPopupWindowTableModified=!0;break}case"delete":{const e=r.selected;r.beginUpdate();for(let t=0,i=e.length;t<i;t+=1)r.removeRow(e[t]);r.endUpdate(),t._isPopupWindowTableModified=!0;break}}t._applyTableValidation(e,r,a)}}_updateTaskDependencies(e,t){const i=this,a=i._tasks.indexOf(t),n=i._getTaskConnections(t).connectedTasks,s=e.rows;for(let e=0,t=n.length;e<t;e+=1){const t=n[e];i._removeConnection(`${t.startIndex}-${t.endIndex}-${t.type}`)}for(let e=0,t=s.length;e<t;e+=1){const t=s[e].data,n=t.name,r=t.type;if(!i._getValidConnectionId(n,a,r,"_"))continue;const o=parseInt(t.lag);i._connectTask([n,a,r,isNaN(o)?0:o])}i._recycleConnections()}_updateTaskSegments(e,t){const i=e.rows;let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e].data,n=t.label,s=new Date(t.dateStart),r=new Date(t.dateEnd);isNaN(s)||isNaN(r)||a.push({label:"string"==typeof n?n:"",dateStart:s,dateEnd:r})}t.segments=a,this._validateTaskSegments(t)}_createTasks(e,t){const i=this,a={},n=[];e||(e=i.dataSource),i.dataSource instanceof Smart.DataAdapter&&(e=i._parseAdapterData(i.dataSource.toArray())),t||i.clearTasks();let s=[];if(function e(r,o){let l=[];if(!r||0===r.length)return[];for(let d=0;d<r.length;d++){let c,m=r[d];if("object"!=typeof m)continue;if(m=i._validateTaskProperties(m,o),!m)continue;const u=m.tasks,h=m.id;m.$.project=o,m.$.id=o?o.$.id+"."+d:d+"","string"!=typeof h&&"number"!=typeof h||(a[h]?n.push(h):a[h]=1),u instanceof Array&&u.length>0&&(m.synchronized&&(m.dateStart=m.minDateStart=m.maxDateStart=void 0,m.dateEnd=m.minDateEnd=m.maxDateEnd=void 0),m.type="project",c=e(u,m),c.length&&(m.hidden=!c.some((e=>!e.hidden)),m.hidden?c.forEach((e=>e.hidden=m.hidden)):i._synchronizeProjectVisibility(o,m))),(!m.type||["project","task","milestone"].indexOf(m.type)<0)&&(m.type="task"),o&&"project"===m.type&&c&&c.length>0?(l.push(m),l=l.concat(c)):(o||((t&&"project"===m.type&&m.synchronized||m.dateStart&&m.dateEnd&&!isNaN(m.dateStart.getTime())&&!isNaN(m.dateEnd.getTime()))&&s.push(m),c&&(s=s.concat(c))),l.push(m))}return o&&i._synchronizeProjectDates(o,l),l}(e),t)return s.slice(0);n.length&&console.warn(i.localize("duplicateIds",{elementType:i.nodeName.toLowerCase(),duplicates:n.toString()})),i._tasks=s.slice(0),i._handleResources()}_createTimeline(){const e=this;e._tasks&&0!==e._tasks.length?(delete e.__tasks,e._createConnections(),e._autoSchedule(),e._createTimelineCells(),e._insertTimelineTasks(),e.$.taskSplitter.refresh()):e._clearTasks()}_createConnections(){const e=this,t=e._tasks;e._connections=[];for(let i=0,a=t.length;i<a;i+=1)t[i].connections&&e._handleTaskConnections(i)}_createTooltip(){const e=this,t=e.tooltip;let i=e.$.tooltip;if(t.enabled)return i||(e.$.tooltip=i=document.createElement("smart-tooltip"),i.classList.add("smart-gantt-chart-tooltip"),i.setAttribute("smart-id","tooltip")),e.$tooltip||e._handleTooltipEvents(!0),i.rightToLeft=e.rightToLeft,i.theme=e.theme,i.openMode="manual",i.arrow=t.arrow,i.delay=t.delay,i.parentElement||e.$.container.appendChild(i),i;i&&(i.close(),i.remove())}_handleTooltipEvents(e){const t=this,i=t.$.tooltip;if(!i)return;let a=t.$tooltip;e?(a=t.$tooltip=Smart.Utilities.Extend(i),a.listen("close",t._tooltipVisibilityHandler.bind(t)),a.listen("closing",t._tooltipVisibilityHandler.bind(t)),a.listen("open",t._tooltipVisibilityHandler.bind(t)),a.listen("opening",t._tooltipVisibilityHandler.bind(t))):a&&(a.unlisten("close"),a.unlisten("closing"),a.unlisten("open"),a.unlisten("opening"),delete t.$tooltip)}_toggleTooltip(e){const t=this;if(t._dragDetails||!t.tooltip.enabled||!t.$.container.contains(e.target))return void t._closeTooltip();const i=t.getRootNode(),a={"smart-task-segment":null,"smart-timeline-task":null,"smart-gantt-chart-task-indicator":null,"smart-resource-timeline-view-cell":null,"smart-task-connection":null},n=(i.host?i.host.shadowRoot:i).elementsFromPoint(e.clientX,e.clientY);let s;for(let e=0,t=n.length;e<t;e+=1){const t=n[e],i=t.classList;if(i.contains("smart-task-container"))a["smart-timeline-task"]=t.closest(".smart-timeline-task");else for(let e in a)i.contains(e)&&(a[e]=t)}if(a["smart-task-segment"]){const e=a["smart-timeline-task"],t=e?e._cellObj.task:void 0;s=t&&t.segments&&t.segments.length?a["smart-task-segment"]:e}else if(a["smart-gantt-chart-task-indicator"])s=a["smart-gantt-chart-task-indicator"];else for(let e in a)if(a[e]){s=a[e];break}s?t._openTooltip(s,e):t._closeTooltip()}_getConnectionTypeName(e){const t=this;switch(e){case 0:return t.localize("startToStart");case 1:return t.localize("endToStart");case 2:return t.localize("endToEnd");case 3:return t.localize("startToEnd");default:return""}}_getSegmentTask(e){const t=this._tasks;for(let i=0,a=t.length;i<a;i+=1){const a=t[i];if(Array.isArray(a.segments)&&a.segments.indexOf(e)>-1)return a}}_getTooltipContent(e){const t=this;if(!e)return;const i=e.classList;let a,n;if(i.contains("smart-task-segment")){if(n=e._segmentObj,n){let e=n.label;if(void 0===e){const i=t._getSegmentTask(n);i&&(e=i.label)}a=`<label><b>${t.localize("segment")}</b>: ${e||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`}}else if(i.contains("smart-timeline-task"))n=e._cellObj.task,n&&!n.segments&&(a=`<label><b>${t.localize("task")}</b>: ${n.label||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`);else if(i.contains("smart-gantt-chart-task-indicator"))n=e._indicatorObj,n&&(a=n.label||"");else if(i.contains("smart-resource-timeline-view-cell")){if(!e.hasAttribute("load"))return;const i=e.closest(".smart-timeline-cell");if((e=e.closest(".smart-timeline-row"))&&e._cellObj&&(n=e._cellObj.resource),n){const s=t._getResourceTasks(n),r="hours"===t.resourceTimelineView?"h":"",o=t._tasks,l=t.$.resourceTimelineViewCells.children,d=Array.from(e.children).findIndex((e=>e===i));a=`<label><b>${t.localize("resource")}</b>: ${n.label||""}</label>\n <label><b>${t.localize("assignments")}</b>:</label>`;for(let e=0,i=s.length;e<i;e+=1){const i=s[e],c=o.indexOf(i),m=t._getResourceCellCapacity({cellDateRange:t._getCellDateRange(l[d]),cellTaskIndexAssigned:[c],index:d,resource:n,task:i,cellIndex:d});void 0!==m&&(a+=`<label>${t.localize("task")} #${c}: (${parseFloat(m.capacity.toFixed(1))}${r}) ${i.label||""}</label>`)}}}else i.contains("smart-task-connection")&&(n=t.getConnectionDetails(e.getAttribute("connection-id")),void 0!==n&&(a=`<label><b>${t.localize("startTask")}</b>: ${n.startTask.label||""}</label>\n <label><b>${t.localize("endTask")}</b>: ${n.endTask.label||""}</label>\n <label><b>${t.localize("type")}</b>: ${t._getConnectionTypeName(n.type)||""}</label>`,n.lag&&(a+=`<label><b>${t.localize("lag")}</b>: ${parseFloat(n.lag.toFixed(1))}</label>`)));return n?n.tooltip?n.tooltip+"":a||"":void 0}_openTooltip(e,t,i){const a=this,n=a.tooltip;if(i="string"==typeof i?i:a._getTooltipContent(e),!(n.enabled&&i&&e&&e.nodeName))return void a._closeTooltip();const s=a.$.tooltip||a._createTooltip();let r,o;if(i&&s.value!==i&&(s.value=i),s.selector=e,t&&t.pageX){const i=document.body.getBoundingClientRect(),a=e.getBoundingClientRect(),l=n,d=l.offset[0]||0,c=l.offset[1]||0,m=s.offsetWidth,u=s.offsetHeight;let h="bottom";"absolute"!==s.position&&(s.position="absolute",s.offset=[]),o=Math.min(i.left+i.width-m,t.pageX-m/2-d),r=a.top-u-c,r<i.top&&(r=a.bottom+c,h="top"),o<i.left&&(o=i.left+d,h="left"),h!==s.arrowDirection&&(s.arrowDirection=h),s.style.left=o+"px",s.style.top=r+"px"}else"auto"!==s.position&&(s.position="auto",s.offset=n.offset);s.visible||(a.getShadowRootOrBody().appendChild(s),s.open())}_closeTooltip(){const e=this.$.tooltip;e&&e.visible&&e.close()}_tooltipVisibilityHandler(e){const t=this,i=e.type,a=t.$.tooltip;e.target===a&&(e.stopPropagation(),t._fireTooltipVisibilityEvent(e)?e.preventDefault():"opening"===i?a.classList.remove("smart-visibility-hidden"):"closing"===i&&(a.hasAnimation?a.addEventListener("transitionend",(()=>{a.visible||(a.classList.add("smart-visibility-hidden"),a.style.top=a.style.left=0,t.$.container.appendChild(a))}),{once:!0}):t.$.container.appendChild(a)))}_fireTooltipVisibilityEvent(e){const t=this,i=e.type,a=t.$.tooltip,n=e.detail.owner;let s={target:a,owner:n};if(n)if(n.classList.contains("smart-task-connection")){s.type="connection";const e=t.getConnectionDetails(n.getAttribute("connection-id"));e&&(s.item=e)}else if(n.classList.contains("smart-gantt-chart-task-indicator"))s.type="indicator",n._indicatorObj&&(s.item=t._cloneObject(n._indicatorObj));else if(n.classList.contains("smart-task-segment"))s.type="segment",n._segmentObj&&(s.item=t._cloneObject(n._segmentObj));else if(n.classList.contains("smart-timeline-task"))s.type="task",n._cellObj&&n._cellObj.task&&(s.item=t._cloneObject(n._cellObj.task));else if(n.classList.contains("smart-resource-timeline-view-cell")){s.type="resource";const e=n.closest(".smart-timeline-row");e._cellObj&&(s.item=t._cloneObject(e._cellObj.resource))}let r=t.getAttribute("aria-owns")||"";switch(i){case"open":t.setAttribute("aria-owns",(r+" "+a.id).trim()),t.$.fireEvent(i,s);break;case"close":r=r.replace(a.id,"").trim(),r?t.setAttribute("aria-owns",r):t.removeAttribute("aria-owns"),t.$.fireEvent(i,s);break;case"closing":case"opening":if(t.$.fireEvent(i,s).defaultPrevented)return!0}}_parseAdapterData(e){let t={};for(let i=0,a=e.length;i<a;i+=1){const a=e[i],n=Object.assign({},a),s=a.parent,r=a.$.id;if(s&&s!==a){const e=s.$.id;t[e]||(t[e]=Object.assign({},s));const i=t[e];i.tasks||(i.tasks=[]),i.tasks.push(n)}else t[r]=n;delete n.parent,delete n.children,delete n.$}return Object.values(t)}_handleTaskConnections(e){const t=this,i=t._tasks;let a;if("number"==typeof e&&(a=e,e=i[e]),!e)return;void 0===a&&(a=i.indexOf(e));const n=e.connections,s=i.length;for(let e=0;e<n.length;e++){const i=n[e],r=t._getTaskIndexById(i.target);null==r||isNaN(r)||r<0||r>=s||r===a||t._connectTask([a,r,i.type,i.lag])}delete e.connections}_insertTasks(e,t,i){const a=this,n=a._tasks;if(t){const s=a._getProjectTasks(t,!0);if(s.length){const t=s[s.length-1];let r,o;"number"==typeof i&&i<s.length?r=s[i=Math.max(0,i)]:(r=t,o=!0);const l=a._getProjectTasks(r);i=o&&l.length?n.indexOf(l[l.length-1]):n.indexOf(r),n.splice.apply(n,[i+(o?1:0),0].concat(e))}else n.splice.apply(n,[n.indexOf(t)+1,0].concat(e))}else"number"==typeof i?(i+="",(i=n.findIndex((e=>e.$.id===i)))<0&&(i=n.length)):i=n.length,n.splice.apply(n,[i,0].concat(e))}_insertTimelineTasks(){const e=this,t=e._timelineVCells;t&&t.length?(e._recycleTimelineTasks(),e._refresh()):e._resetTimeline()}_recycleTimelineTasks(e){const t=this,i=t.$.taskIndicatorsContainer,a=i.children,n=t.$.taskTimelineCellsContainer.childElementCount,s=t._timelineVCells;for(;i.childElementCount>n;)i.firstElementChild.remove();if(t._closeTooltip(),!s||!s.length)return;const r=s.indexOf(t._getFirstContentCellInView()),o=t._getSelection("task",t.selectedTaskIds),l={timelineStart:t.dateStart.getTime(),timelineEnd:t.dateEnd.getTime()};for(let i=0,d=n;i<d;i++){const n=a[i],d=s[r+i];if(!d){n&&n.remove();continue}const c=d.task;t._snapToNearestDates(c),t._recycleTaskBars(d,i,o),t._setTimelineTaskBar(d,i),t._setTimelineTaskBaseline(d,i),t._setTaskBarProgress(c,i),t._setTaskBarLabel(c,i),t._setTaskIndicators(d,i,l),t._setTaskDeadline(d,i,l),e&&t._refreshTableColumnsData(c)}t._recycleConnections()}_ensureVisible(e,t="task"){const i=this;if(null==e)return;let a,n="task"===t?i._timelineVCells:i._timelineResourceVCells;a||(a=i.$[`${t}Table`]);const s=n.find((i=>i[t]===e));if(!s)return;let r,o;if("task"===t){const t=i._getTimelineTaskCellByDate(e.dateStart);if(r=i.$.taskTimelineContainer.offsetHeight,o=i,t){const e=i.scrollLeft,a=i.$.taskTimelineContainer.offsetWidth;t.left+t.width>e+a?i.scrollLeft=Math.max(0,t.left+t.width-a):t.left<e&&(i.scrollLeft=Math.max(0,t.left))}}else r=i.$.resourceTimelineContent.offsetHeight,o=i._resourceScrollView;const l=o.scrollTop;s.top+s.height>l+r?o.scrollTop=Math.max(0,s.top+s.height-r):s.top<l&&(o.scrollTop=Math.max(0,s.top))}_isTaskExpanded(e,t){if(!e||!e.$)return;let i,a=e.$[this.groupByResources?"group":"project"];if(!a)return!0;for(;a;){if(i=a.expanded,!i)return!1;if(a=a.$.project,a===t)break}return i}_getItemByTreeIndex(e,t,i){if(!t)return;const a=t.split(".");let n=this[`_${e}s`].filter((e=>!e.$.project))[t.split(".")[0]];if(n){if(!n[`${e}s`]||!n[`${e}s`].length)return i?null:n;for(let t=1;t<a.length;t++){const s=n[`${e}s`].filter((e=>!e.hidden&&e.$.project===n))[a[t]];if(!s||i&&"project"!==s.type)break;if(n=s,"project"!==n.type)break}return i?n&&"project"===n.type?n:void 0:n}}_getItemByTableId(e,t,i){if(null==t)return;const a=this[`_${e}s`];let n;for(let e=0,i=a.length;e<i;e+=1){const i=a[e];if(i.$.id===t){n=i;break}}return n?i?"project"===n.type?n:void 0:n:void 0}_tableChangeHandler(e){const t=e.target;(t.classList.contains("smart-task-table")||t.classList.contains("smart-resource-table"))&&(e.stopPropagation(),this._handleTableSelection(t===this.$.taskTable?"task":"resource",t.selected))}_tableColumnResizeHandler(e){const t=e.target,i=e.detail,a=t.classList.contains("smart-task-table");if(!a&&!t.classList.contains("smart-resource-table"))return;e.stopPropagation();const n=i.dataField,s=this[(a?"task":"resource")+"Columns"].find((e=>e.value===n));s&&(s.size=i.width),this.$.fireEvent("columnResize",i)}_tableSortFilterHandler(e){const t=this,i=e.target;let a;i.classList.contains("smart-task-table")?(a="task",t._createTimelineContent(),t._recycleTimelineTasks()):i.classList.contains("smart-resource-table")&&(a="resource",t._createResourceTimelineContent(),t._recycleResourceContent()),a&&(t._refresh(),e.stopPropagation(),t.$.fireEvent(e.type,Object.assign({type:a},e.detail)))}_taskTableExpandHandler(e){const t=this,i=e.target;if(!i.classList.contains("smart-task-table")&&!i.classList.contains("smart-resource-table"))return;const a=i===t.$.taskTable?"task":"resource";if(e.stopPropagation(),!t[`${a}s`]||!t[`${a}s`].length)return;const n=e.detail.record.itemId,s=t._getItemByTableId(a,n,!0);s&&(delete t._hoveredItem,s.expanded="collapse"!==e.type,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(e.type,{item:t._cloneObject(s),id:s.id||s.$.id,index:t._tasks.indexOf(s),label:s.label,value:s.value}))}_taskTableKeyDownHandler(e){const t=this,i=e.key;if(t.keyboardNavigation&&!t.disabled&&!t.readonly)switch(i){case"Delete":case"Enter":{const e=t.$.taskTable._focusedCell;if(!e||!e.closest)return;const a=e.closest("tbody tr");if(!a)return;const n=t._getVCellById("task",a.getAttribute("row-id"));n&&t._openPopupWindow(n.task,"Delete"===i);break}}}_getVCellById(e="task",t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_getGroupVCellByPath(e,t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_taskTableGroupEventHandler(e){const t=this,i=e.detail.action,a=e.target;if(["collapse","expand"].indexOf(i)<0||!a.classList.contains("smart-task-table")&&!a.classList.contains("smart-resource-table"))return;const n=a===t.$.taskTable?"task":"resource",s=t.$.taskTable._getGroupByIndex(e.detail.path),r=t._getGroupVCellByPath(n,s.$.id);if(!r||!r[n].isGroup)return;const o=r[n];e.stopPropagation(),o.expanded="collapse"!==i,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(i,{isGroup:!0,item:t._cloneObject(o),id:o.$.id,label:o.label})}_resetTimeline(){const e=this,t=e.$.taskTimelineContainer;if(e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineContent.style.height="",e.$.taskIndicatorsContainer.innerHTML="",e.rightToLeft&&e.scrollLeft!==t.scrollLeft){const i=e._getScrollLeft(e.scrollLeft);t.scrollLeft=i,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=i)}e._closeTooltip(),e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height")}_refreshTimeline(e){const t=this;e||(e=t.view);const i=t._getDateFromCell(t.scrollLeft,t._getFirstCellObjInView(),e),a=t.scrollTop;t._refreshing=!0,t.scrollLeft=0,t.scrollTop=0,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&t._resourceScrollView&&(t._resourceScrollView.scrollLeft=0),t._resetTimeline(),t._createTimelineCells(),t._recycleTimelineTasks(!0),t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshResourceTimeline(),t._refresh(),t._refreshing=!1,t._scrollTo(i),t.scrollTop=a}_scrollTo(e,t){const i=this,a=i._timelineCells;let n;if(void 0!==e&&!isNaN(new Date(e).getTime()))for(let s=0;s<a.length;s++){const r=a[s],o=r.date;switch(i.view){case"quarter":case"year":if(o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()){if(t){n=r.left;break}let i=new Date(e);i.setMonth(e.getMonth()+1),i.setDate(0),i=i.getDate(),n=r.left+(e.getDate()-1)/i*r.width}break;case"month":{let i=new Date(o),a=new Date(o);i.setDate(i.getDate()-i.getDay()),a.setDate(a.getDate()+(6-a.getDay())+1),a.setMilliseconds(a.getMilliseconds()-1),e.getTime()>=i.getTime()&&e.getTime()<=a.getTime()&&(n=r.left+(t||t?0:e.getDay()/7*r.width));break}case"week":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&(n=r.left+parseFloat(e.getHours()+"."+e.getMinutes()+e.getSeconds())/24*r.width);break;case"day":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&o.getHours()===e.getHours()&&(n=r.left+(t?0:parseFloat(e.getMinutes()+e.getSeconds())/60*r.width))}if(void 0!==n)return i.scrollLeft=n,void(i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=i.$.resourceTimelineContent.scrollLeft=n,i._refreshResourceTimeline()))}}_updateConnection(e,t){const i=this,a=i._tasks,[n,s,r,o]=e,l=a[n],d=a[s];if(!l||!d||"number"!=typeof r)return;let c=i._connections,m=-1;c||(c=i._connections=[]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=t.startIndex,a=t.endIndex;if(i===n&&a===s||i===s&&a===n){m=e;break}}if(!t){if(m<0)c.push({startTask:a[n],endTask:a[s],startIndex:n,endIndex:s,type:r,lag:o});else{const e=c[m];if(!e)return;if(e.startIndex=n,e.startTask=a[n],e.endIndex=s,e.endTask=a[s],e.type=r,o!==e.lag){const t=parseInt(o);isNaN(t)||(e.lag=t)}}return!0}m>-1&&c.splice(m,1)}_createTimelineCells(){const e=this,t=e._tasks,i=new Date(e.properties.dateStart.value),a=new Date(e.properties.dateEnd.value);let n,s;if(isNaN(i.getTime())||(n=i),isNaN(a.getTime())||(s=a),t.length>0){let e=t[0].dateStart,i=t[0].dateEnd;for(let a=0;a<t.length;a++)t[a].dateStart&&t[a].dateEnd&&(e||(e=t[a].dateStart),i||(i=t[a].dateEnd),e.getTime()>t[a].dateStart.getTime()&&(e=t[a].dateStart),i.getTime()<t[a].dateEnd.getTime()&&(i=t[a].dateEnd));(!n||n.getTime()>e.getTime())&&(n=e),(!s||s.getTime()<i.getTime())&&(s=i)}if(n&&s){if(n=e._minMaxDateValidator(n),s=e._minMaxDateValidator(s),-1!==e.firstDayOfWeek){const t=n.getDay()-e.firstDayOfWeek,i=new Date(n.getTime());i.setDate(n.getDate()-n.getDay()+e.firstDayOfWeek-(t>=0?0:7)),n=i}e._createTimelineHeader(n,e._getCellsCount(n,s)),e._createTimelineContent(),e._createDateMarkers(),e._refresh()}}_getCellsCount(e,t,i){let a,n,s,r,o,l,d=new Date(e),c=new Date(t);const m=this,u=t.getFullYear()-e.getFullYear();if(n=a=Math.round(u)+1,"year"===i)return{year:n};if(d.setHours(d.getHours(),0,0,0),c.setHours(c.getHours(),0,0,0),l=Math.floor((t.getTime()-e.getTime())/36e5),l>0){let e=new Date(d);if(l=1,d.getFullYear()!==c.getFullYear()){let t=new Date(d.getFullYear()+1,0,1,0,0,0,0);for(;e.getTime()!==t.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}const i=c.getFullYear()-t.getFullYear();for(let t=0;t<i;t++){const t=e.getFullYear();l+=24*((t%100==0?t%400==0:t%4==0)?366:365)-1,e.setFullYear(t+1)}}for(;e.getTime()<c.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}}if("hour"===i)return{hour:l};if(d.setHours(0,0,0,0),c.setHours(23,59,59,999),o=a=Math.round((c.getTime()-d.getTime())/864e5),"day"===i)return{day:o};if(d.setDate(d.getDate()-d.getDay()),c.setDate(c.getDate()+6-c.getDay()),r=a=Math.round((c.getTime()-d.getTime())/6048e5),"week"===i){if(-1!==m.firstDayOfWeek){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}return{week:r}}if("month"===this.view&&"day"!==m.monthScale&&(0!==e.getDay()&&(e=new Date(e.setDate(e.getDate()-e.getDay()))),6!==t.getDay()&&(t=new Date(t.setDate(t.getDate()+6-t.getDay()))),-1!==m.firstDayOfWeek)){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}if(e.getFullYear()!==t.getFullYear()){a=12-e.getMonth();const i=t.getFullYear();for(let n=e.getFullYear()+1;n<=i;n++)a+=n===t.getFullYear()?t.getMonth()+1:12}else a=t.getMonth()-e.getMonth()+1;return s=Math.ceil(a),"months"===i?{month:s}:("day"===this.view&&0===l&&(l=1),{year:n,month:s,week:r,day:o,hour:l})}_recycleTaskBars(e,t,i){const a=this,n=e.task,s=a.$.timelineTasksContainer,r=a.$.taskTimelineCellsContainer,o="project"===n.type&&n.synchronized,l=n.type,d=n.$.id,c=s.children[t],m=r.children[t];m._cellObj=e,m.setAttribute("row-id",d),m.style.top=e.top+"px",m.removeAttribute("hover"),c.removeAttribute("hover"),c.classList.contains(l)||(c.innerHTML="milestone"===l?'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-task-connection-point end"></div>\n </div>':'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-timeline-task-progress-thumb"></div>\n <div class="smart-task-connection-point end"></div>\n </div>'),n.connectionType&&(n.connectionType.includes("start")||c.querySelector(".start").classList.add("smart-hidden"),n.connectionType.includes("end")||c.querySelector(".end").classList.add("smart-hidden")),a._recycleSegments(n,c),delete c._cellStart,delete c._cellEnd,n.disableDrag||o&&!n.dragProject?c.setAttribute("disable-drag",""):c.removeAttribute("disable-drag"),n.disableResize||o?c.setAttribute("disable-resize",""):c.removeAttribute("disable-resize"),n.isGroup?c.setAttribute("resource-group",""):c.removeAttribute("resource-group"),i&&(i.indexOf(d)>-1?(c.setAttribute("selected",""),m.setAttribute("selected","")):(c.removeAttribute("selected"),m.removeAttribute("selected"))),n.id?c.id=n.id:c.id="ganttTask"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),c._cellObj=e,c.className="smart-timeline-task "+l,c.setAttribute("row-id",d),n.class&&c.classList.add(n.class),c.setAttribute("aria-label",n.label+" Start date: "+a._toISODate(n.dateStart)+", End date: "+a._toISODate(n.dateEnd)),c.setAttribute("aria-selected","false")}_toISODate(e){const t=e.getFullYear(),i=e.getMonth()+1,a=e.getDate();return t+"-"+(i<10?"0"+i:i)+"-"+(a<10?"0"+a:a)}_recycleSegments(e,t){const i=this,a=t.querySelector(".smart-task-segments");let n,s=e.segments;if(!a)return;for(Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);a.childElementCount>s.length;)a.children[0].remove();const r=document.createDocumentFragment(),o=a.children,l="milestone"===e.type?'<div class="smart-timeline-task-fill"></div>':'<div class="smart-timeline-task-fill">\n <div class="smart-timeline-task-progress"></div>\n </div>\n <div class="smart-timeline-task-label"></div>';for(let t=0,a=s.length;t<a;t+=1){const a=s[t];let d=o[t];a.dateStart=new Date(Math.max(e.dateStart.getTime(),a.dateStart.getTime())),a.dateEnd=new Date(Math.min(e.dateEnd.getTime(),a.dateEnd.getTime())),d?(delete d._cellStart,delete d._cellEnd):(d=document.createElement("div"),d.classList.add("smart-task-segment"),d.innerHTML=l,r.appendChild(d)),a.disableDrag?d.setAttribute("disable-drag",""):d.removeAttribute("disable-drag"),a.disableResize?d.setAttribute("disable-resize",""):d.removeAttribute("disable-resize"),d._segmentObj=a,d.setAttribute("aria-label",(a.label||"")+" Start date: "+i._toISODate(a.dateStart)+", End date: "+i._toISODate(a.dateEnd)),n=d}r.childElementCount&&a.appendChild(r),i._setTaskBarDeadline(e,n)}_createCells(e){let t,i=document.createDocumentFragment();for(let a=0;a<e;a++)t=document.createElement("div"),t.classList.add("smart-timeline-view-cell"),t.setAttribute("role","columnheader"),i.appendChild(t);return i}_getTimelineVisibleCellsCount(){const e=this,t=e._timelineCells;if(!t)return;const i=e._getFirstCellObjInView();if(!i)return t.length;const a=1-(i.left+i.width-e.scrollLeft)/t[0].width;return Math.min(t.length,Math.ceil(parseFloat((e.$.timeline.offsetWidth/i.width).toFixed(2))+a))}_getHeaderVisibleCellsCount(){const e=this;if(!e._timelineHeaderCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_getHeaderSubVisibleCellsCount(){const e=this;if(!e._timelineHeaderSubCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderSubCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_refreshHeaderDate(e){const t=this,i=t._getCellsViewType(),a=t.$.timelineHeader.scrollLeft,n=t.$.timelineViewCells.children,s=t._timelineCells;let r;t._refreshHeaderSubDetailsDate(e),t._refreshHeaderDetailsDate(e);for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=n[a],l=s[r];if(!l)break;r++;const d=l.date;o.innerHTML=`<div>${t._getDateString(new Date(d),i)}</div>`,e||(o._date=new Date(d),o.setAttribute("date",d.toLocaleDateString()),o.style.width=l.width+"px",o.style[t.rightToLeft?"right":"left"]=l.left+"px",l.weekend?o.setAttribute("weekend",""):o.removeAttribute("weekend"),l.nonworking?o.setAttribute("nonworking",""):o.removeAttribute("nonworking"))}}_getDateString(e,t,i){const a=this,n=["2-digit","numeric"][a.dayFormat]||"numeric";let s;if("year"===t||"quarter"===t)s=e.toLocaleDateString(a.locale,{year:a.yearFormat});else if("month"===t)s=e.toLocaleDateString(a.locale,{month:a.monthFormat}),"month"===a.view&&(s+=" "+e.toLocaleDateString(a.locale,{year:a.yearFormat}));else if("week"===t)s="numeric"!==a.weekFormat&&i?e.toLocaleDateString(a.locale,{day:n,month:a.monthFormat,year:a.yearFormat}):a._getWeekNumber(e);else if("day"===t)s="month"===a.view?"numeric"!==a.dayFormat&&"2-digit"!==a.dayFormat?e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:a.dayFormat}):e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:"short"}):e.toLocaleDateString(a.locale,"day"===a.view?{day:n,month:a.monthFormat,year:a.yearFormat}:["long","short","narrow"].indexOf(a.dayFormat)>-1?{weekday:a.dayFormat}:{day:a.dayFormat});else if("hour"===t)if(s="default"===a.hourFormat?e.toLocaleTimeString(a.locale,{hour12:!1}):e.toLocaleDateString(a.locale,{hour:a.hourFormat}),"default"!==a.hourFormat)s.indexOf(",")>=0&&(s=s.substring(s.indexOf(",")+1).trim());else if(s.indexOf(":")!==s.lastIndexOf(":")&&s.indexOf(":")>=0){let e=s.toLowerCase().indexOf("am")>=0?" AM":"";e=s.toLowerCase().indexOf("pm")>=0?" PM":e,s=s.substring(0,s.lastIndexOf(":"))+e}return a.timelineHeaderFormatFunction?a.timelineHeaderFormatFunction(new Date(e),t,i,s):s}_refreshHeaderSubDetailsDate(e){const t=this,i=(t.view,t.scrollLeft),a=t.$.timelineViewSubDetails.children,n=t._timelineHeaderSubCells;let s;if(t.$.timelineViewSubDetails.classList.contains("smart-hidden"))return;for(let e=0;e<n.length;e++){const t=n[e];if(i<=t.left+t.width){s=e;break}}let r=[],o=0;for(let i=0;i<a.length;i++){const l=n[s],d=a[i];if(!l)continue;let c=new Date(l.date);"week"===t.view&&c.setDate(c.getDate()-c.getDay()),s++,c=new Date(Math.max(l.date.getTime(),c.getTime()));const m=e=>{var i,a=e.getMonth();return i=a>=9?4:a>=6?3:a>=3?2:1,"long"===t.quarterFormat?t.localize("quarter")+" "+i:"numeric"===t.quarterFormat?i:t.localize("quarterShort")+i};let u="";"quarter"===t.view||"year"===t.view?(u=m(c),"quarter"===t.view&&t.hideTimelineSecondHeaderDetails&&(u+=" "+c.getFullYear())):"month"===t.view&&(-1===t.firstDayOfWeek?u=t._getWeekNumber(c):((c.getDay()-t.firstDayOfWeek)%7==0&&i>0&&o++,u=o));const h=u+"_"+c.getFullYear();r[h]||(r[h]=[]),d.classList.remove("smart-visibility-hidden"),r[h].push({element:d,cell:l}),d.innerHTML=`<div>${u}</div>`,d.classList.add("middle"),e||(d._date=c,d.style[t.rightToLeft?"right":"left"]=l.left+"px",d.style.width=l.width+"px")}for(let e in r){const i=r[e];let a=0;for(let e=0;e<i.length;e++)a+=i[e].cell.width;if(i[0].element.style.width=a+"px","year"===t.view){const e=i[0].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat}),a=i[i.length-1].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat});i.length>1?i[0].element.innerHTML=`<div>${e}-${a}</div>`:i[0].element.innerHTML=`<div>${e}</div>`}else if("month"===t.view){const e="numeric"!==t.dayFormat&&"2-digit"!==t.dayFormat?t.dayFormat:"short",a=i[0].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[0].cell.date.toLocaleDateString(t.locale,{weekday:e}),n=i[i.length-1].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[i.length-1].cell.date.toLocaleDateString(t.locale,{weekday:e});i.length>1?i[0].element.innerHTML=`<div>${a}-${n}</div>`:i[0].element.innerHTML=`<div>${a}</div>`,"numeric"===t.weekFormat&&(i[0].element.innerHTML=t._getWeekNumber(i[0].cell.date))}if(t.timelineHeaderFormatFunction){const e=t.timelineHeaderFormatFunction(new Date(i[0].cell.date),t.view,!0,i[0].element.innerHTML);i[0].element.innerHTML!==e&&(i[0].element.innerHTML=e)}for(let e=1;e<i.length;e++)i[e].element.classList.add("smart-visibility-hidden")}}_refreshHeaderDetailsDate(e){const t=this,i=t.view,a=t.scrollLeft,n=t.$.timelineViewDetails.children,s=t._timelineHeaderCells;let r;for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=s[r],l=n[a];let d=new Date(o.date);if("week"===t.view)if(-1!==t.firstDayOfWeek){const e=d.getDay()-t.firstDayOfWeek;d.setDate(d.getDate()-d.getDay()+t.firstDayOfWeek-(e>=0?0:7))}else d.setDate(d.getDate()-d.getDay());r++,d=new Date(Math.max(o.date.getTime(),d.getTime())),l.innerHTML=`<div>${t._getDateString(d,i,!0)}</div>`,e||(l._date=d,l.style[t.rightToLeft?"right":"left"]=o.left+"px",l.style.width=o.width+"px")}}_getWeekNumber(e){let t,i=new Date(e.getFullYear(),0,1),a=Math.round((e.getTime()-i.getTime()-6e4*(e.getTimezoneOffset()-i.getTimezoneOffset()))/864e5)+1,n=i.getDay();return n=n>=0?n:n+7,n<4?(t=Math.floor((a+n-1)/7)+1,t>52&&(i=new Date(e.getFullYear()+1,0,1),n=i.getDay(),n=n>=0?n:n+7,t=n<4?1:53)):t="week"===this.view?function(e){var t=new Date(e.valueOf()),i=(e.getDay()+6)%7;t.setDate(t.getDate()-i+3);var a=t.valueOf();return t.setMonth(0,1),4!==t.getDay()&&t.setMonth(0,1+(4-t.getDay()+7)%7),1+Math.ceil((a-t)/6048e5)}(e):Math.round((a+n-1)/7),t}_convertDuration(e,t){if(!e)return 0;let i;switch(this.durationUnit){case"day":i=864e5;break;case"hour":i=36e5;break;case"minute":i=6e4;break;case"second":i=1e3;break;case"milisecond":return e;case"week":i=6048e5}return Math.max(0,t?e/i:e*i)}_createTimelineHeader(e,t){const i=this,a=i._getCellsViewType();if(!e){const t=i.$.timelineViewCells.children;if(0===t.length)return;e=t[0]._date}if("day"!==i.view&&e.setHours(0,0,0,0),i.$.timelineContent.offsetWidth===i.$.timeline.offsetWidth&&i._timelineCells&&i._timelineCells[0]&&i._timelineCells[0].date.getTime()===e.getTime()&&i._timelineCells.length===t[i._getCellsViewType()])return void i._refresh();i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width="",i._createTimelineCellsObj(e,t),i._createTimelineHeaderCellsObj(e,t),i._createTimelineHeaderSubCellsObj(e,t),i.$.timelineViewDetails.innerHTML="",i.$.timelineViewDetails.appendChild(i._createCells(i._getHeaderVisibleCellsCount())),i.$.timelineViewSubDetails.innerHTML="",i.$.timelineViewCells.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.classList.add("smart-hidden");let n=2;"quarter"===i.view?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(i._getTimelineVisibleCellsCount()))):"month"===i.view&&"day"===i.monthScale?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.day))):"year"===i.view&&(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.month))),i.hideTimelineHeader&&(i.$.timelineViewCells.classList.add("smart-hidden"),n--),i.hideTimelineHeaderDetails&&(i.$.timelineViewDetails.classList.add("smart-hidden"),n--),i.hideTimelineSecondHeaderDetails&&("quarter"===i.view?i.$.timelineViewDetails.classList.add("smart-hidden"):i.$.timelineViewSubDetails.classList.add("smart-hidden"),("year"===i.view||"month"===i.view&&"day"===i.monthScale||"quarter"===i.view)&&n--),i.$.taskTable.style.setProperty("--smart-table-column-header-height","calc("+n+" * var(--smart-gantt-chart-task-default-height) - calc("+n+" * var(--smart-border-width) / "+n+"))"),i.$.timelineViewCells.innerHTML="",i.$.timelineViewCells.appendChild(i._createCells(i._getTimelineVisibleCellsCount()));let s=t[a];if("hour"===a&&("halfHour"===i.dayScale?s*=2:"quarterHour"===i.dayScale&&(s*=4)),i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width=Math.max(s*i._timelineCells[0].width,i.$.timeline.parentElement.offsetWidth)+"px",i.scrollLeft){const e=i._getScrollLeft(i.scrollLeft);i.$.timelineHeader.scrollLeft=e,i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=e)}i._refreshHeaderDate(),i._setCurrentTimeIndicators()}_createTimelineContent(){const e=this,t=e.$.container,i=e.$.timelineContent,a=e._taskDefaultHeight,n=e.$.taskTimelineContainer,s=e.scrollLeft;if(i.style.height="",t.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e._createTimelineVCells(a),i.style.height=e._timelineVCells.length*a+"px",t.style.setProperty("--smart-gantt-chart-task-timeline-content-height",e.$.timeline.offsetHeight+"px"),s||s!==n.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);n.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=t)}e.scrollTop&&(n.scrollTop=e.scrollTop),e._recycleContentCells()}_createDateMarkers(){const e=this,t=e.dateMarkers;let i=[];delete e._markers;for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e._dateValidator(void 0,n.date);if(s){const e={date:s},t=n.label,a=n.className;("string"==typeof t||"number"==typeof t&&!isNaN(t))&&(e.label=t),"string"==typeof a&&(e.className=a),i.push(e)}}i.length&&(e._markers=i),e._recycleDateMarkers()}_createTimelineRowCells(e,t){const i=this,a=e.children,n=e.querySelectorAll(".smart-task-bar-limiter"),s=document.createDocumentFragment(),[r,o]=i.rightToLeft?["right","left"]:["left","right"];t||(t=i.$.timelineViewCells.children);for(let e=0,t=n.length;e<t;e+=1)n[e].remove();const l=t.length;for(;e.childElementCount>l;)e.lastElementChild.remove();for(let t=e.childElementCount;t<l;t+=1){const e=document.createElement("div");e.classList.add("smart-timeline-cell"),s.appendChild(e)}s.childElementCount&&e.appendChild(s);for(let e=0;e<l;e+=1){const i=t[e],n=a[e];i.hasAttribute("weekend")?n.setAttribute("weekend",""):n.removeAttribute("weekend"),i.hasAttribute("nonworking")?n.setAttribute("nonworking",""):n.removeAttribute("nonworking"),n.style[o]=i.style[o],n.style[r]=i.style[r],n.style.width=i.style.width}for(let t=0,i=n.length;t<i;t+=1)e.appendChild(n[t])}_recycleTimelineRowCells(){const e=this,t=e.$.timelineViewCells.children,i=e.$.taskTimelineCellsContainer.children;for(let a=0,n=i.length;a<n;a+=1)e._createTimelineRowCells(i[a],t)}_createTimelineVCells(e){const t=this,i=t._tasks,a=t.$.taskTable.rows,n=t.groupByResources;let s=0,r={};t._timelineVCells=[];for(let o=0,l=a.length;o<l;o++){const l=a[o].data;let d=i[l.itemIndex];if(n)if(!d&&l.groupDataField){const e=l.$.id;d={$:{id:e,project:void 0},label:t._formatResourceGroupLabel(l.label),value:l.label,expanded:l.expanded,synchronized:!0,isGroup:!0,type:"project"},r[e]=d}else l.parent?(d.$.group=r[l.parent.$.id],t._synchronizeProjectDates(d.$.group,[d])):delete d.$.group;else delete d.$.group;!d.hidden&&t._isTaskExpanded(d)&&(t._timelineVCells.push({top:s,height:e,task:d}),s=parseFloat((s+e).toFixed(2)))}}_getCellsViewType(){const e=this;switch(e.view){case"quarter":case"year":return"month";case"month":return"day"===e.monthScale?"day":"week";case"week":return"day";case"day":return"hour"}}_dateAdd(e,t,i){if(e instanceof Date){var a=new Date(e),n=function(){a.getDate()!==e.getDate()&&a.setDate(0)};switch(String(t).toLowerCase()){case"year":a.setFullYear(a.getFullYear()+i),n();break;case"quarter":a.setMonth(a.getMonth()+3*i),n();break;case"month":a.setMonth(a.getMonth()+i),n();break;case"week":a.setDate(a.getDate()+7*i);break;case"day":a.setDate(a.getDate()+i);break;case"hour":a.setTime(a.getTime()+36e5*i);break;case"minute":a.setTime(a.getTime()+6e4*i);break;case"second":a.setTime(a.getTime()+1e3*i);break;default:a=void 0}return a}}_createTimelineCellsObj(e,t){const i=this,a=i._getCellsViewType();t=t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderSubCellsObj(e,t){const i=this,a=i._getCellsViewType();t="month"===i.view&&"day"===i.monthScale?t.day:t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineHeaderSubCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineHeaderSubCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderCellsObj(e,t){const i=this;let a=i.view,n=0,s=new Date(e);"quarter"===a&&(a="year"),t=t[a],i._timelineHeaderCells=[];for(let e=0;e<t;e++){const t={};switch(t.date=new Date(s),a){case"quarter":case"year":s.setFullYear(s.getFullYear()+1);break;case"month":s.setDate(1),s.setMonth(s.getMonth()+1);break;case"week":s.setDate(s.getDate()+7);break;case"day":s.setDate(s.getDate()+1)}n=i._refreshViewDetailCell(t,n,e),i._timelineHeaderCells.push(t)}}_minMaxDateValidator(e){if(!e||isNaN(e.getTime()))return e;const t=new Date(this.min),i=new Date(this.max);return t&&(e=new Date(Math.max(t.getTime(),e.getTime()))),i&&(e=new Date(Math.min(i.getTime(),e.getTime()))),e}_dateValidator(e,t){const i=this;let a;if(t instanceof Date)return i._minMaxDateValidator(t);if(Smart.Utilities.DateTime&&t instanceof Smart.Utilities.DateTime)return i._minMaxDateValidator(t.toDate());if("string"!=typeof t)return i._minMaxDateValidator(e);{const e=/\d+:\d+:\d+/;if("new Date()"===t.trim()||"new Smart.Utilities.DateTime()"===t.trim())return i._minMaxDateValidator(new Date);if(isNaN(Date.parse(t))){const i=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;if(i.test(t)){const n=i.exec(t)[0].replace(/[,-.\/]/g,",").split(",");if(3===n.length){const[i,s]=parseInt(n[0])<parseInt(n[2])?[n[0],n[2]]:[n[2],n[0]];if(a=new Date(parseInt(s),parseInt(n[1])-1,parseInt(i)),e.test(t)){const i=e.exec(t)[0].split(":");a.setHours(i[0]||0,i[1]||0,i[2]||0)}t=a}}}else a=new Date(Date.parse(t)),e.test(t)||a.setHours(0,0,0,0),t=a}return i._minMaxDateValidator(new Date(t))}_currentTimeIndicatorIntervalValidator(e,t){return Math.max(1,t)}_getTaskBarPositionLimits(e,t){const i=this;function a(e){const t=i._getTimelineTaskCellByDate(e);if(t)return t.left+i._getTimelineTaskOffset(t,e)||0}return{min:a(e["min"+t]),max:a(e["max"+t])}}_getTimelineTaskOffset(e,t){if(!e)return;let i,a;switch(this.view){case"quarter":case"year":{const n=t.getHours()/24+t.getMinutes()/1440+t.getSeconds()/86400;i=new Date(e.date.getFullYear(),e.date.getMonth()+1,0),a=(t.getDate()-1+n)/i.getDate()*e.width;break}case"month":a=t.getDay()/7*e.width;break;case"week":a=parseFloat(t.getHours()+t.getMinutes()/60+t.getSeconds()/3600)/24*e.width;break;case"day":a=parseFloat(t.getMinutes()+t.getSeconds()/60)/60*e.width}return a}_getTaskBarSizeLimits(e,t){const i=this,a=i._getTaskBarDateRange(e);let n,s=0,r=i._convertDuration(e._cellObj.task.minDuration)||i._getMinDuration(e,t),o=i._convertDuration(e._cellObj.task.maxDuration);function l(n,s){if(!n)return;let r,o;"left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft?(n*=-1,o=a.dateEnd):o=a.dateStart,s&&Math.abs(r)===Math.abs(n)&&(r=0);let l=i._getTaskWorkingDateEnd({dateStart:o},n);const d=l.getTime()+60*(l.getTimezoneOffset()-o.getTimezoneOffset())*1e3,c=i._getTimelineTaskCellByDate(new Date(d));if(!c)return;const m=i._getTimelineTaskOffset(c,new Date(d));return i.rightToLeft?"left"===t?m-(i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth-c.left):i.$.timelineContent.offsetWidth-e.offsetLeft-c.left-m:"left"===t?e.offsetLeft+e.offsetWidth-c.left-m:c.left-e.offsetLeft+m}if("left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft){const t=e._cellObj.task.maxDateStart,i=e._cellObj.task.minDateStart;i&&(s=60*(i.getTimezoneOffset()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateEnd.getTime())+s,o=o?Math.min(n,o):n),t&&(s=60*(t.getTimezoneOffset()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateEnd.getTime())+s,r=r?Math.max(n,r):n)}else{const t=e._cellObj.task.maxDateEnd,i=e._cellObj.task.minDateEnd;i&&(s=60*(i.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateStart.getTime())+s,r=r?Math.max(n,r):n),t&&(s=60*(t.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateStart.getTime())+s,o=o?Math.min(n,o):n)}return o&&(r=Math.min(r,o)),{min:l(r,!0),max:l(o)}}_getMinDuration(e,t){const i=this,a=i._taskBarMinWidth;if(!a||!i._timelineCells||0===i._timelineCells.length)return;const n=e._cellObj.task;let s,r,o=1;r=i.rightToLeft?parseFloat(e.style.right)||i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth:parseFloat(e.style.left)||e.offsetLeft,"left"===t?(s=n.dateEnd,r+=parseFloat(e.style.width)||e.offsetWidth,o=-1):s=n.dateStart;const l=r+o*a;let d;for(let e=0;e<i._timelineCells.length;e++){const t=i._timelineCells[e];if(l<t.left)break;d=t}const c=i._getDateFromCell(l,d);return c?Math.abs(s.getTime()-c.getTime()):void 0}_createDelimiter(e,t){const i=this,a=i._dragDetails,n=a.segment,s=e.slice(0,3),r=document.createElement("div");if(r.classList.add("smart-task-bar-limiter",e),e.indexOf("date")>-1){if(!a[s]||!a[s].left)return;const[e,t]=n?[n.element,n.originalPosition.x]:[a.timelineTask,0],o=i.$.taskTimelineCellsContainer.children[i._getTaskDOMIndex(a.task)];s.indexOf("max")>-1?r.style.width=o.offsetWidth-a[s].left-t-e.offsetWidth+"px":r.style.width=a[s].left+t+"px"}else{if(!a[s].width)return;r.style["left"===t?"right":"left"]=a[s].width+"px"}return r}_doubleClickHandler(e){const t=this;let i=e.target;if(t.disabled||t.disableWindowEditor)return;t.shadowRoot&&i===t&&(i=e.composedPath()[0]);let a=i.closest?i.closest(".smart-task-connection"):void 0;if(a)t._openPopupWindow(a);else if(a=i.closest(".smart-timeline-task")||i.closest(".smart-table tbody tr[row-id]"),a&&t.$.taskSplitter.contains(a))if(a.classList.contains("smart-timeline-task"))t._openPopupWindow(a._cellObj.task);else{const e=t._getVCellById("task",a.getAttribute("row-id"));e&&t._openPopupWindow(e.task)}}_checkDoubleClick(e){const t=this;let i=e.target;if(t.shadowRoot&&i===t&&(i=e.composedPath()[0]),void 0===t._dblClickDetails&&(t._dblClickDetails={clicks:0}),clearTimeout(t._dblClickDetails.timeOut),i!==t._dblClickDetails.target&&(t._dblClickDetails.clicks=0),t._dblClickDetails.target=i,t._dblClickDetails.clicks++,t._dblClickDetails.timeOut=setTimeout((function(){t._dblClickDetails&&(t._dblClickDetails.clicks=0)}),250),2===t._dblClickDetails.clicks)return t._doubleClickHandler(e),t._dblClickDetails.clicks=0,!0}_downHandler(e){const t=this,i=e.originalEvent,a=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target,n=a.closest?a.closest(".smart-timeline-row")||a.closest(".smart-timeline-task"):null;if(e.stopPropagation(),delete t._itemClickDetails,t._dragDetails)return delete t._dragDetails,void t._setConnectionFeedback();const s=t.$.taskSplitter.contains(a)?"task":"resource";if((a.closest(".smart-timeline-content")||a.closest(`.smart-${s}-table`))&&requestAnimationFrame((()=>t.$[`${s}Table`].focus({preventScroll:!0}))),t._itemClickDetails={target:a},!t._isMobile&&0!==e.button)return;if(!n){if(a.classList.contains("smart-popup-window-modal")){if(t._popupWindow){const e=Object.keys(t._popupWindow);requestAnimationFrame((()=>t._popupWindow[e[e.length-1]].focus()))}return}return void((a.closest(".smart-table tbody tr[row-id]")&&!a.classList.contains("smart-arrow")||a.closest(".smart-task-connection"))&&t._checkDoubleClick(i))}if(a.closest(".smart-resource-timeline-view-cell")||t.disabled)return;const r=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===n._cellObj.task));if(!r)return;const o=r._cellObj.task;if(!o)return;const l=t.$.timeline.getAttribute("task-bar-hovered");if(r.getElementsByClassName("smart-timeline-task-fill")[0]||l){if((a.closest(".smart-timeline-task-fill")||r.classList.contains("milestone")&&a.closest(".smart-task-container"))&&t._checkDoubleClick(i))return;const n=a.closest(".smart-timeline-task-progress-thumb"),s=e.pageX-window.pageXOffset,d=e.pageY-window.pageYOffset,c=t._dragDetails={},m=t.rightToLeft;let u,h=a.closest(".smart-task-segment");if(l&&!h){const e=r.querySelectorAll(".smart-task-segment");c.segments=e,h="left"===l&&!m||"right"===l&&m?e[0]:e[e.length-1]}if(c.target=(n||a).className,c.timelineTask=r,c.task=r._cellObj.task,c.taskDimensions={width:r.offsetWidth,height:r.offsetHeight,left:r.offsetLeft,top:r.offsetTop},c.coordinates={x:s,y:d},!e.ctrlKey&&h&&o.segments&&o.segments.length>1&&!t.disableSegmentDrag){const e=h.getBoundingClientRect(),t=h._segmentObj,i=c.task.segments,a=i.indexOf(t);c.segment={element:h,dimensions:{width:e.width,left:h.offsetLeft},offset:{x:s-e.left},originalSize:{width:e.width},isFirstSegment:0===a,isLastSegment:a===i.length-1,min:{},max:{}},u=c.segment.dimensions}const g=c.taskDimensions;t.rightToLeft?(g.right=t.$.timelineContent.offsetWidth-(g.left+g.width),c.originalPosition={x:g.right,y:g.top},c.segment&&(u.right=g.width-(u.left+u.width),c.segment.originalPosition={x:u.right})):(c.originalPosition={x:g.left,y:g.top},c.segment&&(c.segment.originalPosition={x:u.left}));const f=(n||r).getBoundingClientRect();if(c.offset={x:s-f.left,y:d-f.top},c.originalSize={width:g.width,height:g.height},n||!n&&"project"===o.type&&o.synchronized&&!o.dragProject)return void(a.closest(".smart-task-connection-point")&&(c.timelineTask=void 0,c.relatedConnections={}));("visible"===t.resizeHandlesVisibility||t._isMobile&&"auto"===t.resizeHandlesVisibility)&&(a.closest(".smart-timeline-task-fill")?t._checkTaskBarResizability(e):t.$.timeline.removeAttribute("task-bar-hovered")),c.min={},c.max={},t._setDragLimits(a)}}_documentMoveHandler(e){const t=this;if(!t._dragDetails||!t._dragDetails.target){let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const a=i.closest&&i.closest(".smart-table tbody tr[row-id]");return a&&a.data?t._handleTableItemHover(a.data.itemId,i):t._handleTimelineHover(e),t._checkTaskBarResizability(e),void t._toggleTooltip(e.originalEvent)}if(t._dragDetails.target.includes("smart-task-connection-point"))return t._setConnectionFeedback(e),t._handleTimelineHover(e),void t._autoScroll(e);if(t._dragDetails.target.includes("smart-timeline-task-progress-thumb"))t._handleTaskProgressChange(e);else if(t._autoScroll(e),!t._autoScrolling)if(t.$.timeline.hasAttribute("task-bar-hovered"))t._handleTaskBarResize(e);else if(t._dragDetails.target.includes("smart-timeline-task-fill")){const i=t._dragDetails.task;if(!i||i.disableDrag||"project"===i.type&&i.synchronized&&!i.dragProject)return;t._handleTaskBarDrag(e)}}_documentUpHandler(e){const t=this,i=e.originalEvent;let a=i.target;if(t._upHandler(),!t._dragDetails)return void t._handleItemClick(i);if(t._scrollView.disableSwipeScroll=t._touchmoveInside=!1,t.shadowRoot&&a===t&&(a=i.composedPath()[0]),t.hasAttribute("connecting-task")){const i=t._connectTask(e),a=t._tasks;if(t._setConnectionFeedback(),i){const e=i.taskStart,n=i.taskEnd,[s,r,o]=[a.indexOf(i.taskStart),a.indexOf(i.taskEnd),i.type];t.$.fireEvent("connectionEnd",{id:`${s}-${r}-${o}`,startIndex:s,startTaskId:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,endIndex:r,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,type:o}),t._autoSchedule(i.taskStart)}return t._isMobile&&t._handleTimelineHover(e,!0),void delete t._dragDetails}const n=t._dragDetails.task;if(!n)return void delete t._dragDetails;let s;const r=t._dragDetails.segment?t._dragDetails.segment.element:void 0;if(s||(s=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===n))),t.hasAttribute("dragged")){t._snapToNearest(s,r),r||t._checkWorkingDays(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._autoSchedule(n),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n)):(t.snapToNearest||t.nonworkingDays.length>0||t.nonworkingHours.length>0)&&t._refreshAssignedResources(n),t.removeAttribute("dragged");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:new Date(n.dateStart),dateEnd:new Date(n.dateEnd)};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("dragEnd",e)}else if(t.hasAttribute("progress-change"))t._resourceTreeRefreshTimeout&&(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n,["progress"])),t.removeAttribute("progress-change"),t.$.fireEvent("progressChangeEnd",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),progress:n.progress||0});else if(t.hasAttribute("resized")){t._snapToNearest(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n,["workload"])):t.snapToNearest&&t._refreshAssignedResources(n,["workload"]),t.removeAttribute("resized");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("resizeEnd",e),t._autoSchedule(n)}else a.closest(".smart-timeline-task")===s&&(t._select("task",n.$.id,!0),delete t._dragDetails,t._handleItemClick(i));const o=t.$.timelineContent.querySelectorAll(".smart-task-bar-limiter");for(let e=0,t=o.length;e<t;e+=1)o[e].remove();delete t._dragDetails}_handleItemClick(e){const t=this,i=e.target;if(t._dragDetails||!t._itemClickDetails||t._itemClickDetails.target!==i)return void delete t._itemClickDetails;let a,n,s;if(i.closest(".smart-timeline-task-fill"))n=i.closest(".smart-timeline-task")._cellObj.task,s="task";else if(a=i.closest(".smart-task-connection"),a)n=a.getAttribute("connection-id").split("-"),n={source:n[0],target:n[1],type:n[2]},s="connection";else if(i.closest(".milestone"))n=i.closest(".milestone")._cellObj.task,s="milestone";else if(a=i.closest(".smart-table tbody tr"),a){const e=t._getVCellById(s,a.getAttribute("row-id"));s=t.$.taskTable.contains(a)?"task":"resource",n=e?e[s]:void 0}if(!n)return;const r={originalEvent:e,type:s,item:t._cloneObject(n)};r.id="connection"===s?`${n.source}-${n.target}-${n.type}`:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,delete t._itemClickDetails,t.$.fireEvent("itemClick",r)}_moveHandler(e){const t=this;t._isMobile||e.stopPropagation(),(t.hasAttribute("dragged")||t.hasAttribute("progress-change"))&&"touchmove"===e.originalEvent.type&&e.originalEvent.preventDefault()}_handleTableItemHover(e,t){const i=this,a=i._hoveredItem;let n,s;if(t&&([n,s]=i.$.taskSplitter.contains(t)?[i.$.taskTable,"task"]:[i.$.resourceTable,"resource"]),a&&"itemType"===a.type&&a.id===e)return;const r=i.$.mainSplitter.querySelectorAll("table tbody tr[hover]");for(let e=0;e<r.length;e++)r[e].removeAttribute("hover");if(void 0===e)return void i._handleTimelineHover({target:i});if(!n)return;i._setTableHoverState(n,e);const o=i.$["task"===s?"taskTimelineCellsContainer":"resourceTimelineCellsContainer"].children;for(let t=0,a=o.length;t<a;t+=1){const a=o[t];if(a._cellObj[s].$.id===e){i._handleTimelineHover({target:a});break}}}_setTableHoverState(e,t){const i=this;e||(e=i.$.taskTable);const a=e===i.$.taskTable?"task":"resource",n=e.querySelectorAll("table tbody tr");if(!i._isMobile&&i[a+"Columns"].length)for(let e=0;e<n.length;e++){let i=n[e];const a=i.data;a&&a.itemId===t&&i.setAttribute("hover","")}}_checkWorkingDays(e){const t=this,i=t._dragDetails;if(!(i&&i._taskDuration||t._timelineCells.length))return;if(!e.classList||!e.classList.contains("smart-timeline-task")||!t.hasAttribute("dragged")||0===t.nonworkingDays.length&&0===t.nonworkingHours.length||!i||!i._taskDuration)return;const a=e._cellObj,n=a.task,s=t._getTaskWorkingDateEnd(n),r=n.segments;let o=new Date(t._timelineCells[t._timelineCells.length-1].date);if("year"===t.view||"quarter"===t.view?(o.setMonth(o.getMonth()+1),o.setDate(0),o.setHours(23,59,59,999)):"month"===t.view?(o.setDate(o.getDate()+6-o.getDay()),o.setHours(23,59,59,999)):"week"===t.view?o.setHours(23,59,59,999):o.setHours(o.getHours(),59,59,999),s&&(n.dateEnd=n.maxDateEnd?new Date(Math.min(s.getTime(),n.maxDateEnd.getTime())):s),n.dateEnd=new Date(Math.min(o.getTime(),n.dateEnd.getTime())),n.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n.dateStart,n.dateEnd):n.dateEnd.getTime()-n.dateStart.getTime(),!0),r&&r.length>1){for(let e=0,i=r.length;e<i;e+=1)t._snapToNearestDates(r[e],!0);t._validateTaskSegments(n),n.segments.length!==r.length&&t._recycleSegments(n,e),t._setTaskBarSegments(a,e,!0),t._setTaskBarProgress(n)}t._setTimelineTaskBar(a,void 0,!0),t._refreshTaskConnections(a.task),t._refreshTableColumnsData(n,["dateEnd","duration","overdue"])}_getTaskWorkingDateEnd(e,t){const i=this;if(!e||!e.dateStart)return;let a,n,s=new Date(e.dateStart);if(t||(t=i._dragDetails?i._dragDetails._taskDuration:i._getWorkingTime(e.dateStart,e.dateEnd)),!i.adjustToNonworkingTime)return new Date(e.dateStart.getTime()+t);const r=t<0?-1:1,o=i.nonworkingDays,l=i.nonworkingHours;for(t=Math.abs(t);t>0;){const e=Math.min(t,36e5-(60*s.getMinutes()*1e3+1e3*s.getSeconds()+s.getMilliseconds()));if(o.indexOf(s.getDay())>-1)n=new Date(s),n.setHours(0,0,0,0),n.setDate(s.getDate()+1*r),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a);else if("day"===i.view&&l.indexOf(s.getHours())>-1){n=new Date(s);const t=n.getTime();n.setHours(s.getHours()+1*r,0,0,0),t===n.getTime()&&n.setHours(s.getHours()+2*r,0,0,0),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a)}else t-=e,s=new Date(s.getTime()+r*e)}return s}_createConnectingElement(e,t,i,a,n){const s=this;if(!s._connectionDetails||!s._connectionDetails.start)return;const r=s._connectionDetails,o=r.type,l=s.$.timelineConnectionsContainer;let d=r.connections.shift();d||(d=document.createElement("div"),d.classList.add("smart-task-connection")),d.style.width=d.style.width="","horizontal"===a?(d.style.width=Math.abs(i)+"px",d.style.height=""):(d.style.width="",d.style.height=Math.abs(i)+"px"),d.style[s.rightToLeft?"left":"right"]="",d.style[s.rightToLeft?"right":"left"]=e+"px",d.style.top=t+"px",d.setAttribute("connection-id",r.id);const c=r.start.task.label,m=0===o||3===o?"start":"end",u=r.end.task.label,h=0===o||1===o?"start":"end";if(d.setAttribute("aria-label","Connection between "+c+" ("+m+") and "+u+" ("+h+")"),n){let e=0===o||1===o?"right":"left";s.rightToLeft&&(e="left"===e?"right":"left"),d.setAttribute("arrow-direction",e)}else d.removeAttribute("arrow-direction");d.parentElement||l.appendChild(d)}_getConnectionType(e,t){if(!e||!t)return;let i,a;return"string"==typeof e?i=!e.includes("end"):e instanceof HTMLElement&&(i=!e.classList.contains("end")),"string"==typeof t?a=t.includes("end"):t instanceof HTMLElement&&(a=t.classList.contains("end")),i&&!a?0:i||a?!i&&a?2:i&&a?3:void 0:1}_setConnectionFeedback(e){const t=this,i=t._dragDetails;if(!i||!i.target||!e){const e=t._connectionFeedback;return e&&e.parentElement&&e.remove(),t.removeAttribute("connecting-task"),void delete t._connectionFeedback}if(!i.target||!i.target.includes("smart-task-connection-point"))return;const a=i.task,n=i.taskDimensions;if(!a)return;if(!t.hasAttribute("connecting-task")){if(t.$.fireEvent("connectionStart",{startIndex:t._tasks.indexOf(a)}).defaultPrevented)return void delete t._dragDetails.target;t.setAttribute("connecting-task",""),t._isMobile&&(t._scrollView.disableSwipeScroll=t._touchmoveInside=!0)}const s="milestone"===a.type,r=t.rightToLeft;let o=s?-1*n.height/2:0;t._dragDetails.target.includes("end")&&(o=s?-1*o:n.width),t._connectionFeedback||(t._connectionFeedback=document.createElement("div"),t._connectionFeedback.classList.add("smart-task-connection-feedback"));const l=t._dragDetails.coordinates.x+(r?-1:1)*o,d=t._dragDetails.coordinates.y,c=t._dragDetails.offset.x-(r?n.width:0),m=t._dragDetails.offset.y,u=e.pageX-window.pageXOffset+c,h=e.pageY-window.pageYOffset+m-n.height/2;r?(t._connectionFeedback.style.left="",t._connectionFeedback.style.right=n.right+o+"px"):(t._connectionFeedback.style.left=n.left+o+"px",t._connectionFeedback.style.right=""),t._connectionFeedback.style.top=n.top+n.height/2+"px",t._connectionFeedback.style.width=Math.sqrt(Math.pow(Math.abs(u-l),2)+Math.pow(Math.abs(h-d),2))+"px",t._connectionFeedback.style.transform=t.rightToLeft?"rotate("+180*(Math.atan2(d-h,l-u)||0)/Math.PI+"deg)":"rotate("+180*(Math.atan2(h-d,u-l)||0)/Math.PI+"deg)",t._connectionFeedback.parentElement||t.$.timelineContent.appendChild(t._connectionFeedback)}_connectTask(e){const t=this,i=t._tasks;let a,n,s,r,o,l,d,c,m;if(e.originalEvent){const r=e.originalEvent;let o=t._isMobile?document.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.target;if(!(t._dragDetails&&t._dragDetails.target&&o&&o.classList))return;if(t.shadowRoot&&o===t&&(o=t._isMobile?t.shadowRoot.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.composedPath()[0]),a=t._dragDetails.target.includes("smart-task-connection-point")?t._dragDetails.target:void 0,n=o.classList.contains("smart-task-connection-point")?o:void 0,a&&(l=t._dragDetails.task),n)s=n.closest(".smart-timeline-task");else if(t._isMobile&&o.classList.contains("smart-timeline-task-fill")&&(s=o.closest(".smart-timeline-task"),s)){const e=r.pageX-window.pageXOffset-s.getBoundingClientRect().left;n=s.querySelector(".smart-task-connection-point."+(e>=s.offsetWidth/2?"end":"start"))}if(!l||!s)return;d=s._cellObj.task;for(let e=0,t=i.length;e<t;e+=1){const t=i[e];if(t!==l)if(t!==d){if(void 0!==c&&void 0!==m)break}else m=e;else c=e}}else{if(!e||e.length<3)return;const a=t._getValidConnectionId(e[0],e[1],e[2],"_connectTask");if(void 0===a)return;[c,m]=[parseInt(a[0]),parseInt(a[1])],[l,d]=[i[c],i[m]],r=parseInt(e[2]),o=e[4]||0}if(!l||!d||l===d||l.isGroup||d.isGroup||t._isAutoScheduled(l,d)||t.hasAttribute("dragged")||t.hasAttribute("resized"))return;void 0===r&&(r=t._getConnectionType(a,n));let u=t._connections;return u||(t._connections=u=[]),t._updateConnection([c,m,r,o])?(e.originalEvent&&t._recycleConnections([{startIndex:c,endIndex:m,type:r}]),e.originalEvent&&t.$.fireEvent("itemInsert",{type:"connection",item:{source:c,target:m,type:r}}),{taskStart:l,taskEnd:d,type:r}):void 0}_recycleConnections(e){const t=this,i=t._tasks;if(e?Array.isArray(e)||(e=[e]):e=t._connections,!i||!i.length||!e)return;const a=t.$.timelineTasksContainer.children,n=t.$.timelineConnectionsContainer;let s,r=[];if(a.length){const n=a[0],o=(()=>{let e=[];for(let t=0,n=a.length;t<n;t+=1)e.push(i.indexOf(a[t]._cellObj.task));return e})(),l=n.querySelector(".smart-task-connection-point."+(t.rightToLeft?"end":"start")),d=t._baselineProportion,c=t.showBaseline?t._taskDefaultHeight/d:0;s={top:l.offsetTop,width:l.offsetWidth},s.offset=Math.abs(l.offsetLeft)-s.width;for(let a=0,n=e.length;a<n;a+=1){const n=e[a],l=n.startIndex,d=n.endIndex;if(o.indexOf(l)<0&&o.indexOf(d)<0)continue;const m=i[l],u=i[d],{vCellStart:h,vCellEnd:g}=t._getTasksVCell(m,u);if(!h||!g)continue;const f=n.type,p={start:{width:s.width,top:s.top,index:l,task:m},end:{width:s.width,top:s.top,index:d,task:u},type:f},_=t._getTaskBarDetails(h,t._getTimelineCellByDate(m.dateStart),t._getTimelineCellByDate(m.dateEnd)),T=t._getTaskBarDetails(g,t._getTimelineCellByDate(u.dateStart),t._getTimelineCellByDate(u.dateEnd));"milestone"===m.type&&(_.width=h.height-c),"milestone"===u.type&&(T.width=h.height-c),p.start.left=0===f||3===f?-1*(s.width+s.offset):_.width+s.offset,p.end.left=0===f||1===f?-1*(s.width+s.offset):T.width+s.offset,t._connectionDetails=p,_.height=T.height=h.height-c,_.type=m.type,T.type=u.type,t._setConnectionDetails(_,T),t._createTaskConnection(),r.push(t._connectionDetails.id),delete t._connectionDetails}}if(arguments.length)return;const o=Array.from(n.children);for(let e=0,t=o.length;e<t;e+=1){const t=o[e];r.indexOf(t.getAttribute("connection-id"))<0&&t.remove()}}_getTasksVCell(e,t){const i=this._timelineVCells;let a,n;for(let s=0,r=i.length;s<r;s+=1){const r=i[s];if(r.task===e&&(a=r),r.task===t&&(n=r),a&&n)break}return{vCellStart:a,vCellEnd:n}}_isAutoScheduled(e,t,i){const a=this,n=a._tasks;let s={};if(a.autoSchedule)return e instanceof HTMLElement&&(e=e._cellObj.task),t instanceof HTMLElement&&(t=t._cellObj.task),function e(t,r){const o=a._getTaskConnections().taskConnections,l=n.indexOf(t);s[l]=!0;for(let t=0;t<o.length;t++){const d=o[t],c=d.endIndex;if(c===r)return i&&a._removeConnection(l+"-"+c+"-"+d.type,!0),!0;if(!s[c]&&e(n[c],r))return!0}}(t,n.indexOf(e))}_setConnectionDetails(e,t){const i=this;if(!i._connectionDetails)return;const a=i._connectionDetails,n=a.start,s=a.end,r=a.type;if(!n||!s)return;let o,l=e.width,d=t.width,c=e.left,m=t.left,u=e.top,h=t.top,g=n.left,f=s.left;const p=n.index,_=s.index;if("milestone"===e.type&&(l=e.height,c-=l/2),"milestone"===t.type&&(d=t.height,m-=d/2),a.id=p+"-"+_+"-"+r,!a.connectionStartOffset||!a.connectionEndOffset){switch(r){case 0:g=Math.abs(g)-n.width,f=Math.abs(f)-s.width;break;case 1:g-=l,f=Math.abs(f)-s.width;break;case 2:g-=l,f-=d;break;default:g=Math.abs(g)-n.width,f-=d}a.start.offset=g+=n.width/2,a.end.offset=f+=s.width/2}if(0===r&&c>m||1===r&&c+l+g>m-f&&h>u||2===r&&m+d>c+l||3===r&&(c-g<m+d+f&&h>u||c-g>m+d+f&&u>h)){o=!0;let i=e;e=t,t=i,i=g,g=f,f=i,i=l,l=d,d=i,i=c,c=m,m=i,i=u,u=h,h=i}let T=c,b=m;!o&&1===r||o&&3===r?T+=l:!o&&3===r||o&&1===r?b+=d:2===r&&(T+=l,b+=d);let k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+p+"-"+_+'-"]');0===k.length&&(k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+_+"-"+p+'"]')),a.connections=[].slice.call(k),a.start.x=T,a.start.y=u+n.top,a.end.x=b,a.end.y=h+s.top,a.type=r,a.inverted=o}_createTaskConnection(){const e=this,t=e._connectionDetails;if(!t)return;const i=2*e._taskConnectionWidth,a=t.start.x,n=t.start.y,s=t.start.offset,r=t.start.top,o=t.end.x,l=t.end.y,d=t.end.offset,c=t.type,m=t.inverted,u=!m&&3===c||m&&1===c,h=!m&&1===c||m&&3===c;let g,f,p,_=a,T=o;u?(_=a-d,T=o+d):h&&(_=a+s,T=o-d);const b=_<=T&&u,k=_>=T&&h,y=2===c||h;!function d(u){g!==o&&(u?"horizontal"===u?(p=g-o+(b?-1:1)*s,g=_>T?g-Math.abs(p):g,e._createConnectingElement(g,f,(_===T?0:Math.abs(p))+(y?i:0),"horizontal"),g=_<T?g-p:g,d("vertical")):(p=Math.abs(f-l),f+=n<l?0:-1*p,g-=m&&1===c||!m&&3===c&&n>l?i:0,e._createConnectingElement(g,f,p,"vertical"),d()):(g?(p=Math.abs(g-o),g>=o&&(g+=-1*p,p+=i),e._createConnectingElement(g,f+(n<l?Math.abs(f-l):0),p,"horizontal",!t.inverted),g=o):(g=a,f=n,(0===c||!m&&3===c||m&&1===c)&&(g-=s),e._createConnectingElement(g,f,s,"horizontal",t.inverted),y&&(g+=s-i),b||k?(e._createConnectingElement(g,f-=n>l?r:0,r,"vertical"),f+=n<l?r:0):d("vertical")),d("horizontal")))}(),t.connections.map((e=>e.parentElement.removeChild(e)))}_getTaskIndexById(e,t){const i=this;if(t||(t=i._tasks),"number"==typeof e)return isNaN(parseInt(e))?-1:parseInt(e);if("object"==typeof e)return i._getItemIndex(e,"task");for(let i=0,a=t.length;i<a;i+=1)if(t[i].id===e)return i;return-1}_refreshTaskConnections(e){const t=this,i=e instanceof HTMLElement?e._cellObj.task:e,a=t._tasks.indexOf(i);if(void 0===a||e.classList&&e.classList.contains("smart-visibility-hidden"))return;let n;if(t._dragDetails&&(n=t._dragDetails.relatedConnections[a]),!n){n=[];const e=t._connections;if(!e||!e.length)return;for(let t=0,i=e.length;t<i;t+=1){const i=e[t];i.startIndex!==a&&i.endIndex!==a||n.push(i)}t._dragDetails&&(t._dragDetails.relatedConnections[a]=n)}t._recycleConnections(n)}_dragStartHandler(e){const t=this,i=e.target.closest;(t._dragDetails||i&&i.call(t,"smart-gantt-chart")===t)&&e.preventDefault()}_getFirstCellObjInView(e){const t=this;if(e||(e=t._timelineCells),!e)return;const i=Math.abs(t.scrollLeft);let a,n;for(let t=0;t<e.length;t++){const s=e[t];if(s.left+s.width>i){a=s;break}n=s}return!a&&n&&(a=i>n.left?n:e[0]),a}_getFirstContentCellInView(e="task"){const t=this;let i,a,n,s;if("task"===e?(i=t._timelineVCells,a=t.scrollTop):(i=t._timelineResourceVCells,a=t.$.resourceVerticalScrollBar.value),!i)return 0;for(let e=0;e<i.length;e++){const t=i[e];if(t.top+t.height>a){n=t;break}s=t}return!n&&s&&(n=a>s.left?s:i[0]),n}_getProjectTasks(e,t){const i=this,a=i.groupByResources&&e.isGroup?"group":"project",n=i._tasks;if(!e||"project"!==e.type)return[];let s=[];for(let r=0,o=n.length;r<o;r+=1){const o=n[r];o.$[a]===e&&(s.push(o),"project"!==o.type||t||(s=s.concat(i._getProjectTasks(o,t))))}return s}_getSubTaskLimits(e){const t=this;if(!e)return;const i=e._cellObj.task,a=t._getProjectTasks(i);let n,s;if(!a.length)return;let r=a[0],o=a[0];for(let e=0;e<a.length;e++){const t=a[e];a[e].dateEnd&&a[e].dateStart&&(r.dateStart||(r=t[e]),o.dateEnd||(o=t[e]),a[e].dateEnd.getTime()>o.dateEnd.getTime()&&(o=a[e]),a[e].dateStart.getTime()<r.dateStart.getTime()&&(r=a[e]))}const l=t.$.timelineContent.offsetWidth;let d,c,m;if(r&&(d=t._getTimelineSubTaskOffset(r),d&&(c=d.left,m=d.width,n=Math.max(0,t.rightToLeft?l-e.offsetLeft-e.offsetWidth-(l-c-m):e.offsetLeft-c))),o&&(d=t._getTimelineSubTaskOffset(o),d))if(c=d.left,m=d.width,t.rightToLeft){const t=l-e.offsetLeft-e.offsetWidth;s=Math.max(t,t+l-(l-c))}else s=Math.max(e.offsetLeft,e.offsetLeft+l-(c+m));return{min:n,max:s}}_getTimelineSubTaskOffset(e){const t=this,i=t.$.timelineTasksContainer.children[t._tasks.filter((e=>!e.hidden)).indexOf(e)];let a,n,s;if(i)a=i.offsetLeft,s=i.offsetWidth;else{const i=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);i&&(a=i.left+t._getTimelineTaskOffset(i,e.dateStart)||0),r&&(n=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0),s=n-a}return{left:a,width:s}}_getTaskDragLimits(e){const t=this,i=t._dragDetails,a=i.segment?i.segment.element:void 0,n=a&&a.previousElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateStart"),s=a&&a.nextElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateEnd"),r=t._dragDetails.taskDimensions;let o={};return(n.min||s.min)&&(o.min=Math.max(n.min||0,Math.max(0,(s.min||0)-r.width))),s.max&&(o.max=Math.max(0,s.max-r.width)),n.max&&(o.max=o.max?Math.min(n.max,o.max):n.max),o}_getTaskBarDateRange(e){if(!e)return;const t=this,i=e.classList.contains("milestone"),a=parseFloat(e.style.width)||e.offsetWidth,n=i?a/2:a,s=t.rightToLeft?parseFloat(e.style.right)||t.$.timelineContent.offsetWidth-e.offsetLeft-n:parseFloat(e.style.left)||e.offsetLeft,r=e._cellStart,o=e._cellEnd,l=e._cellObj.task,d=l.minDateStart,c=l.maxDateEnd;let m,u;return m=t._getDateFromCell(s,r),!d||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(m=new Date(Math.max(d.getTime(),m.getTime()))),u=i?new Date(m):t._getDateFromCell(s+n,o),!c||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(u=new Date(Math.min(c.getTime(),u.getTime()))),{dateStart:m,dateEnd:u}}_getTaskBarDetails(e,t,i){const a=this,n=e.task;if(!e)return;let s=new Date(n.dateStart);const r=new Date(n.dateEnd);if(!a._dragDetails&&a.snapToNearest){let s,r,o=n.dateStart,l=n.dateEnd;const d=new Date(t.date),c=a._getDateFromCell(t.left+t.width,t),m=new Date(i.date),u=a._getDateFromCell(i.left+i.width,i);return s=c.getTime()-o.getTime()>=c.getTime()-d.getTime()?t.left:t.left+t.width,"milestone"!==n.type&&(r=u.getTime()-l.getTime()>=l.getTime()-m.getTime()?i.left-s:i.left-s+i.width),{left:s,width:r,top:e.top}}let o,l,d,c,m,u;switch(a.view){case"quarter":case"year":{d=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),c=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();const e=s.getHours()/24+s.getMinutes()/1440+s.getSeconds()/86400,a=r.getHours()/24+r.getMinutes()/1440+r.getSeconds()/86400;o=t.left+(s.getDate()-1+e)/d*t.width,l=i.left+(r.getDate()-1+a)/c*i.width-o;break}case"month":"day"===a.monthScale?(m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*t.width,u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*t.width,o=t.left+m,l=i.left+(u-m)-t.left):(m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*(t.width/7),u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*(t.width/7),o=t.left+s.getDay()/7*t.width+m,l=i.left+r.getDay()/7*i.width-o+u);break;case"week":m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*t.width,u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*t.width,o=t.left+m,l=i.left+(u-m)-t.left;break;case"day":m=parseFloat(s.getMinutes()+s.getSeconds()/60)/60*t.width,u=parseFloat(r.getMinutes()+r.getSeconds()/60)/60*t.width,o=t.left+m,l=i.left+(u-m)-t.left}return{width:"milestone"===n.type?"":l,left:o,top:e.top}}_snapToNearestDates(e,t){const i=this;if(!i.snapToNearest)return;if(e.classList&&e._cellObj&&(e=e._cellObj.task),!e)return;let a=e.dateStart,n=e.dateEnd;const{cellStart:s,cellEnd:r}={cellStart:i._getTimelineCellByDate(a),cellEnd:i._getTimelineCellByDate(n)},o=new Date(s.date),l=i._getDateFromCell(s.left+s.width,s),d=new Date(r.date),c=i._getDateFromCell(r.left+r.width,r);if(a=l.getTime()-a.getTime()>=l.getTime()-o.getTime()?o:l,"milestone"!==e.type&&(n=c.getTime()-n.getTime()>=c.getTime()-d.getTime()?d:c),e.dateEnd=n,n.getTime()<a.getTime()&&(a=new Date(n)),e.dateStart=a,e.duration=e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0),!t&&e.segments&&e.segments.length>1){const t=e.segments;for(let e=0,a=t.length;e<a;e+=1)i._snapToNearestDates(t[e],!0);i._validateTaskSegments(e)}}_getTimelineTaskCellByDate(e){if(!e)return;let t=this,i=t.view,a=t._timelineCells;"month"===i&&"day"===t.monthScale&&(i="day");for(let n=0;n<a.length;n++){const s=a[n];if(t._isDateInCell(s.date,e,i))return s}}_isDateInCell(e,t,i){const a=this;switch(i){case"quarter":case"year":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth())return!0;break;case"month":{let i=new Date(e);if(i.setDate(i.getDate()+(6-i.getDay())+1),i.setMilliseconds(i.getMilliseconds()-1),t.getTime()>=e.getTime()&&t.getTime()<=i.getTime())return!0;break}case"week":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())return!0;break;case"day":if("hour"!==a.dayScale){if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours()&&e.getMinutes()===t.getMinutes())return!0}else if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours())return!0}}_handleInverted(e){const t=this;function i(e){e||(e="task");const i=t.$[`${e}Splitter`];if(!t.$.mainSplitter.contains(i))return;const[a,n,s,r,o]="task"===e?[t.$.tableSplitterItem,t.$.timelineSplitterItem,t,t.$.taskTimelineContainer,"scrollTop"]:[t.$.resourceTableItem,t.$.resourceTimelineSplitterItem,t.$.resourceVerticalScrollBar,t.$.resourceTimelineContent,"value"],l=t.treeSize!==a.size?a.style[i._measurements.dimension]:t.treeSize;a.size="",i.removeChild(n),t.inverted&&!t.rightToLeft||!t.inverted&&t.rightToLeft?i.insertBefore(n,a):i.appendChild(n),a.size=l,r.scrollTop=s[o]}(!e||t.inverted||t.rightToLeft)&&(i("task"),i("resource"))}_createResourceTimeline(){const e=this;if(e._handleResourcePanelVisibility(),e.$.taskSplitterItem._setSize("size",e.taskPanelSize),!e._resources||!e.$.mainSplitter.contains(e.$.resourceTable))return;const t=e.$.resourceSplitterItemHeader.innerHTML;(e.resourcePanelHeaderTemplate&&!t||!e.resourcePanelHeaderTemplate&&t)&&e._handleHeaderTemplate("resource"),e._setTable(e.$.resourceTable),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter),e.$.resourceTimelineContent.scrollLeft=e.$.resourceTimelineHeader.scrollLeft=e.$.timelineHeader.scrollLeft,e.$.resourceSplitter.refresh(),e._refresh(),e._highlightAssignedItem("task",e._getSelection("task",e.selectedTaskIds))}_createResourceTimelineContent(){const e=this,t=e._timelineVCells,i=t.length?t[0].height:e._taskDefaultHeight;e._createResourceTimelineVCells(i);const a=e._timelineResourceVCells.length*i;e.$.resourceTimelineCellsContainer.style.height=a+"px",e.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",a+"px"),e._recycleResourceContent()}_recycleResourceContent(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e._timelineResourceVCells,i=e.$.resourceTimelineCellsContainer,a=e._getFirstContentCellInView("resource"),n=e.$.tooltip;if(n&&i.contains(n.selector)&&e._closeTooltip(),!a)return void(i.innerHTML="");const s=t.indexOf(a),r=a.height,o=1-(a.top+r-Math.abs(e.$.resourceVerticalScrollBar.value))/r,l=t?t.length:0,d=!e.$.resourceSplitter.offsetHeight,c=e.$.resourceTimelineContent.offsetHeight,m=!d&&c?Math.min(l,Math.ceil((parseFloat((c/r).toFixed(2))+o).toFixed(2))):l,u=i.children,h=e.$.timelineViewCells.children,g=document.createDocumentFragment();for(;i.childElementCount>m;)i.lastElementChild.remove();for(let t=0;t<m;t+=1){let i=u[t];i||(i=document.createElement("div"),i.classList.add("smart-timeline-row"),g.appendChild(i)),e._createTimelineRowCells(i,h)}g.childElementCount&&i.appendChild(g);const f=i.children,p=e._getSelection("resource",e.selectedResourceIds);for(let i=0;i<m;i+=1){const a=t[s+i],n=f[i];if(!a){n&&n.remove();continue}const r=a.resource,o=r.$.id;p.indexOf(o)>-1?n.setAttribute("selected",""):n.removeAttribute("selected"),n._cellObj=a,n.setAttribute("row-id",o),n.style.top=a.top+"px",e._refreshResourceTimelineContent(r,n)}}_createResourceTimelineVCells(e){const t=this,i=t._resources,a=t.$.resourceTable.rows,n=t._timelineResourceVCells=[];let s=0;if(void 0===e){const i=t._timelineVCells;e=i.length?i[0].height:t._taskDefaultHeight}for(let t=0,r=a.length;t<r;t+=1){const r=i[a[t].data.itemIndex];r.hidden||(n.push({top:s,height:e,resource:r}),s=parseFloat((s+e).toFixed(2)))}}_handleResourcePanelVisibility(){const e=this,t=e.$.container,i=e._resources.filter((e=>!e.hidden)),a=e.$.mainSplitter,n=e.$.resourceSplitterItem,s=e.$.taskSplitterItem;if(!i||!i.length||e.hideResourcePanel)return n&&!n.size&&(n._size=n.style[a._measurements.dimension]),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView),s.size="",s.min="",e.$.resourceTable&&e.$.resourceTable.clearSelection(),a.contains(n)&&(a.removeChild(n),e._refresh()),e._highlightAssignedItem("resource"),void t.removeAttribute("show-resource-panel");a.contains(n)||(s.min=e.taskPanelMin,e._createResourcePanel(),e._setupResourcePanel(),e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),t.setAttribute("show-resource-panel",""),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter)}_createResourcePanel(){const e=this,t=e.$.mainSplitter;let i=e.$.resourceSplitterItem;if(!i){i=document.createElement("smart-splitter-item"),i.classList.add("smart-resource-splitter-item"),i.innerHTML=`<div smart-id="resourceSplitterItemHeader" class="smart-resource-panel-header"></div>\n <smart-splitter smart-id="resourceSplitter" wait class="smart-resource-splitter" auto-fit-mode="end">\n <smart-splitter-item smart-id="resourceTableItem" class="smart-resource-table-item">\n <smart-table wait smart-id="resourceTable" class="smart-resource-table" virtualization deferred-scroll-delay="0"></smart-table>\n </smart-splitter-item>\n <smart-splitter-item smart-id="resourceTimelineSplitterItem" class="smart-timeline-splitter-item">\n <div class="smart-timeline" smart-id="resourceTimeline">\n <div class="smart-timeline-container" role="presentation">\n <div class="smart-timeline-header" smart-id="resourceTimelineHeader" role="rowgroup">\n <div class="smart-timeline-view-cells" smart-id="resourceTimelineViewCells" role="row"></div>\n </div>\n <div smart-id="resourceTimelineContent" class="smart-timeline-content" role="rowgroup">\n <div smart-id="resourceTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar wait smart-id="resourceVerticalScrollBar" class="smart-timeline-scroll-bar smart-resource-scroll-bar" \n orientation="vertical" aria-controls="[[${e.id||""}]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>`,t.contains(i)||t.appendChild(i);const a=Smart.Utilities,n=i.querySelectorAll(".smart-resource-panel-header, .smart-resource-splitter, .smart-resource-table-item, \n .smart-resource-table, .smart-timeline-splitter-item, .smart-timeline, .smart-timeline-header, .smart-timeline-view-cells, .smart-timeline-content,\n .smart-timeline-cells-container, .smart-timeline-scroll-bar"),[s,r,o,l,d,c,m,u,h,g,f]=n;e.$.resourceSplitterItem=i,e.$resourceSplitterItem=a.Extend(i),e.$.resourceSplitterItemHeader=s,e.$resourceSplitterItemHeader=a.Extend(s),e.$.resourceSplitter=r,r.hasResizeObserver=!1,r.wait=!1,e.$resourceSplitter=a.Extend(r),e.$.resourceTableItem=o,e.$resourceTableItem=a.Extend(o),e.$.resourceTable=l,l.hasResizeObserver=!1,e.$resourceTable=a.Extend(l),e.$.resourceTimelineSplitterItem=d,e.$resourceTimelineSplitterItem=a.Extend(d),e.$.resourceTimelineViewCells=u,e.$resourceTimelineViewCells=a.Extend(u),e.$.resourceTimeline=c,e.$resourceTimeline=a.Extend(c),e.$.resourceTimelineContent=h,e.$resourceTimelineContent=a.Extend(h),e.$.resourceTimelineHeader=m,e.$resourceTimelineHeader=a.Extend(m),e.$.resourceTimelineCellsContainer=g,e.$resourceTimelineCellsContainer=a.Extend(g),e.$.resourceVerticalScrollBar=f,e.$resourceVerticalScrollBar=a.Extend(f)}}_setupResourcePanel(){const e=this,t=e.rightToLeft,i=e.$.resourceSplitterItem,a=e.$.resourceTableItem,n=e.$.resourceTable,s=e.$.resourceTimelineSplitterItem,r=e.$.resourceVerticalScrollBar;e.$.mainSplitter.contains(i)?([e.$.resourceSplitter,n,e.$.resourceVerticalScrollBar].forEach((e=>e.rightToLeft=t)),n.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,n.$.virtualizationContainer.verticalScrollBarVisibility="hidden",n.$.virtualizationContainer.disabled=!0,a.size=e.treeSize,a.min=e.treeMin,s.min=e.timelineMin,i.min=e.resourcePanelMin,i.size=i._size||e.resourcePanelSize,r.hasStyleObserver=!1,r.hasResizeObserver=!1,r.wait=!1):e.$.mainSplitter.appendChild(i)}_refreshResourceTimeline(){const e=this;e._resources&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._recycleResourceHeaderCells(),e._recycleResourceContent())}_getResourceCellWorkTime(e,t){const i=e.dateStart,a=e.dateEnd,n=t.dateStart,s=t.dateEnd,r=e.dateStart.getTime()<n.getTime()?n:i,o=a.getTime()>s.getTime()?s:a,l=Math.round(this._getWorkingTime(r,o)/36e5);return{value:Math.max(0,l),max:r.getTime()===n.getTime()&&o.getTime()===s.getTime()?l:Math.round(this._getWorkingTime(n,s)/36e5)}}_refreshResourceTimelineContent(e,t){const i=this,a=i._resources.indexOf(e),n=i._getResourceTasks(e);if(t||(t=(()=>{const t=i.$.resourceTimelineCellsContainer.children;for(let i=0,a=t.length;i<a;i+=1){const a=t[i];if(a._cellObj&&a._cellObj.resource===e)return a}})()),a<0||!t||!t.childElementCount)return;let s=t.children;const r=i.$.resourceTimelineViewCells.children,o=i._tasks.filter((e=>!e.hidden));for(let t=0,l=s.length;t<l;t+=1){const l=s[t];let d,c=l.firstElementChild;n.length&&!e.hidden?(c?(c.classList.remove("hide-left-border","hide-right-border"),c.removeAttribute("load"),c.innerHTML=c.style.height=""):(c=document.createElement("div"),c.classList.add("smart-resource-timeline-view-cell"),d=!0),e.class&&c.classList.add(e.class),i._setResourceCellLoad({cell:c,cellIndex:t,resource:e,resourceCell:l,resourceIndex:a,resourceTasks:n,tasks:o,viewCells:r}),c.hasAttribute("load")?d&&l.appendChild(c):c.remove()):c&&c.remove()}}_setResourceCellLoad(e){const t=this,i=t.resourceTimelineFormatFunction,{cell:a,cellIndex:n,resource:s,resourceCell:r,resourceIndex:o,resourceTasks:l,tasks:d,viewCells:c}=e;let m={};for(let e=0,u=l.length;e<u;e+=1){const u=l[e];if(u.hidden)continue;const h=d.indexOf(u),g=t._getCellDateRange(c[n]),{dateStart:f,dateEnd:p}=g;if(!f||f.getTime()>=u.dateEnd.getTime()||p.getTime()<=u.dateStart.getTime())continue;if(m[n]&&m[n].indexOf(h)<0?m[n].push(h):m[a]||(m[n]=[h]),"custom"===t.resourceTimelineMode){i&&(a.innerHTML=i.call(t,m[n]||[],o,new Date(f))||"");continue}const _=t._getResourceCellCapacity({cell:a,cellDateRange:g,cellTaskIndexAssigned:m,index:o,resource:s,task:u,cellIndex:n});if(!_)continue;const{capacity:T,maxCapacity:b}=_,k=parseFloat(((parseFloat(a.getAttribute("load"))||0)+(T||0)).toFixed(1));k>b?a.classList.add("warning"):a.classList.remove("warning"),"histogram"!==t.resourceTimelineMode?k&&a.setAttribute("load",k):t._setCellHistogram({cell:a,load:k,maxCapacity:b,previousViewCell:r.previousElementSibling})}}_getResourceCellCapacity(e){const t=this,i=t.resourceTimelineView,{cell:a,cellDateRange:n,cellTaskIndexAssigned:s,index:r,resource:o,task:l,cellIndex:d}=e;let c,m;if("tasks"===i)c=1,m=o.maxCapacity;else if("hours"===i){const e=t._getResourceCellWorkTime(l,n),i=e.max/24;c=parseFloat((e.value/e.max*o.capacity*i).toFixed(1)),m=Math.min(e.max,parseFloat((o.maxCapacity*i).toFixed(1)))}else{const e=t.resourceTimelineFormatFunction;if(!e)return;let i=e.call(t,s[d]||[],r,new Date(n.dateStart));if(null!=i)if(i="object"!=typeof i?[i]:Object.values(i),2===i.length)c=parseFloat(i[0])||0,m=parseFloat(i[1])||0;else if(1===i.length)return void(a&&a.setAttribute("load",i[0]))}return{capacity:c,maxCapacity:m}}_setCellHistogram(e){const{load:t,cell:i,maxCapacity:a,previousViewCell:n}=e,s=Math.min(100,100*parseFloat((t/a).toFixed(2))),r=n?n.firstElementChild:void 0;if(r){const e=parseFloat(r.style.height)||0;s?e===s?(i.classList.add("hide-left-border"),r.classList.add("hide-right-border")):e>s?(i.classList.add("hide-left-border"),r.classList.remove("hide-right-border")):e<s&&(i.classList.remove("hide-left-border"),r.classList.add("hide-right-border")):(i.classList.remove("hide-left-border"),r.classList.remove("hide-right-border"))}i.style.height=s+"%",t&&i.setAttribute("load",t+"/"+a)}_recycleResourceHeaderCells(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e.$.resourceTimelineViewCells,i=t.children,a=e.$.timelineViewCells.children;let n=document.createDocumentFragment();for(;i.length>a.length;)i[0].remove();for(let e=0;e<a.length;e++){const t=a[e];let s=i[e];s||(s=t.cloneNode(!0),n.appendChild(s)),s.style.left=t.style.left,s.style.right=t.style.right,s.style.width=t.style.width,s.innerHTML=t.innerHTML,s._date=t._date,t.hasAttribute("weekend")?s.setAttribute("weekend",""):s.removeAttribute("weekend"),t.hasAttribute("nonworking")?s.setAttribute("nonworking",""):s.removeAttribute("nonworking")}n.childElementCount&&t.appendChild(n),e.$.resourceTimelineCellsContainer.style.width=e.$.resourceTimelineViewCells.style.width=e.$.timelineContent.style.width}_refreshResourceScrollBar(){const e=this,t=e.$.resourceVerticalScrollBar;if(!e.$.mainSplitter.contains(e.$.resourceSplitter))return;const i=Math.max(0,e.$.resourceTimelineCellsContainer.offsetHeight-e.$.resourceTimelineContent.offsetHeight);0===i&&"visible"===e.verticalScrollBarVisibility?(t.max=1,e.scrollHeight||e.$container.removeClass("vscroll")):i&&e.$container.addClass("vscroll"),t.max=i,t.disabled="disabled"===e.verticalScrollBarVisibility||e.disabled||i<=0,!e.$.container.classList.contains("vscroll")&&t.disabled?t.classList.add("smart-hidden"):(t.classList.remove("smart-hidden"),t.refresh(),e.$.container.classList.contains("hscroll")?e.$.horizontalScrollBar.classList.add("bottom-corner"):e.$.container.classList.contains("vscroll")||e.$.horizontalScrollBar.classList.remove("bottom-corner"))}_handleResources(e){const t=this,i=e?[e]:t._tasks;t._resources||(t._resources=[]);for(let e=0;e<i.length;e++){let a=i[e].resources;Array.isArray(a)||(a=[a].reduce(((e,t)=>e.concat(t)),[]));for(let n=0;n<a.length;n++){let s=a[n];if("object"!=typeof s||!s||void 0===s.id||null===s.id){"number"==typeof s&&(a[n]=s+"");continue}let r=t._resources.find((e=>e.id&&e.id.toString()===s.id.toString()))||{};t._setResource(r,s,i[e]),a[n]=r.id,Object.values(r).length&&!t._resources.includes(r)&&t._resources.push(r)}}t._refreshItemIds("resource");const a=t._resources;for(let e=0,i=a.length;e<i;e+=1)t._refreshResource(a[e])}_refreshAssignedResources(e,t=[]){const i=this;if(!e.$.id||i._tasks.indexOf(e)<0)return;const a=i._getTaskResources(e);for(let e=0;e<a.length;e++){const n=a[e];let s=[];i.resourceColumns.forEach((e=>{void 0!==e.formatFunction&&s.push(e.value)})),s.concat(t),i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(n),t.includes("workload")?i._refreshResource(n,"workload"):t.includes("progress")&&i._refreshResource(n,"progress"),s.length&&i._refreshTableColumnsData(n,s,"resource")}}_refreshResource(e,t){const i=this;if(!i._resources.length)return;const a=i._getResourceTasks(e),n=864e5;switch(t){case"progress":e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2));break;case"workload":e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*e.maxCapacity).toFixed(2));break;default:e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2)),e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*e.maxCapacity).toFixed(2))}i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(e)}_setResource(e,t){if(t&&"object"==typeof t)return e.id?e.id=e.id.trim():e.id=(t.id+"").trim(),e.$||(e.$={}),e.class=t.class||e.class,e.minCapacity=t.minCapacity||e.minCapacity||0,e.maxCapacity=t.maxCapacity||e.maxCapacity||24,e.progress=t.progress||e.progress||0,e.capacity=t.capacity||e.capacity||8,e.type=t.type||e.type,e.hidden=!!("boolean"==typeof t.hidden?t.hidden:e.hidden),e.workload=e.workload||0,t.label?e.label=t.label:void 0===e.label&&(e.label=""),t.value&&(e.value=t.value),e}insertResource(e,t){const i=this,a=Array.from(arguments).filter((e=>void 0!==e));let n,s=i._resources;if(1===a.length&&(t=a[0]),"object"!=typeof t)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"insertResources",argumentName:"resource"}));if(t.id&&s.find((e=>e.id&&e.id.toString()===t.id.toString())))return void i.updateResource(t.id,t);if(t.assignedTo&&(n=[t.assignedTo].reduce(((e,t)=>e.concat(t,[])))),!(t=i._setResource({},t)))return;i._refreshItemIds("resource"),s=i._resources;const r=i._getValidItemAndIndex(e,"resource").index;if(r<0?s.push(t):s.splice(r,0,t),i._tasks.length){if(void 0!==n){Array.isArray(n)||(n=[n]);for(let e=0,a=n.length;e<a;e+=1){const a=i._getValidItemAndIndex(n[e],"task");if(a){const e=a.item;!e||e.disableResources||e.resources.includes(t.id.toString())||e.resources.push(t.id)}}if(i._isUpdating)return void(i._isUpdating.type.resource=!0);i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i._refreshResource(t)}if(i._isUpdating)return i._isUpdating.type.resource=!0,void(i._isUpdating.type.task=!0);if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const e=i._tasks.filter((e=>e.resources.includes(t.id)));for(let t=0;t<e.length;t++)i._refreshTableColumnsData(e[t],["resources"])}}i._isUpdating?i._isUpdating.type.resource=!0:(i._createResourceTimeline(),i.$.fireEvent("itemInsert",{type:"resource",item:i._cloneObject(t)}))}_insertTimelineResource(e,t,i){const a=this,n=a.$.resourceTimelineCellsContainer,s=document.createElement("div");s.classList.add("smart-timeline-row"),s._resource=t,a._refreshResourceTimelineContent(t,s),a.$.resourceTimelineCellsContainer.insertBefore(s,e>-1?n.children[e]:void 0),a.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",n.offsetHeight+"px"),a._refreshResourceScrollBar(),a._insertNewTreeItem(e,t,i,"resource"),a.$.resourceTree.refresh(),a._highlightAssignedItem("task",a._getSelection("task",a.selectedTaskIds))}updateResource(e,t){if(void 0===e)return;const i=this._getValidItemAndIndex(e,"resource");i&&i.item&&this._updateResource(i.item,t)}removeResource(e){if(void 0===e)return;const t=this._getValidItemAndIndex(e,"resource");t&&t.item&&this._removeResource(t.item)}_getResourceTasks(e){const t=this._resources,i=this._tasks;if(!e||!t.length||!i.length)return;let a=[];for(let t=0;t<i.length;t++)i[t].resources.includes(e.id)&&a.push(i[t]);return a}_getTaskResources(e){const t=this;if(!e)return[];const i=[e.resources].reduce(((e,t)=>e.concat(t)),[]);let a=[];for(let e=0;e<i.length;e++){const n=t._resources.find((t=>t.id&&t.id.toString()===i[e].toString()));n&&a.push(n)}return a}_resourceValidator(e,t){const i=this;return Array.isArray(t)||t instanceof Smart.ObservableArray||"number"==typeof t||"string"==typeof t||null==t?t:(i.error(i.localize("invalidValue",{elementType:i.nodeName.toLowerCase(),property:"resources",typeOne:"array",typeTwo:"number"})),null)}_handleTaskProgressChange(e){const t=this,i=t._dragDetails.task,a=t._dragDetails.timelineTask;if(t.disableTaskProgressChange)return;if(!t.hasAttribute("progress-change")){if(t.$.fireEvent("progressChangeStart",{id:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,item:t._cloneObject(i),progress:i.progress||0}).defaultPrevented)return void delete t._dragDetails.target;t._closeTooltip(),t.setAttribute("progress-change",""),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const{left:n,width:s}=a.getBoundingClientRect(),r=e.pageX-window.pageXOffset;t._dragDetails.progress||(t._dragDetails.progress=i.progress/100*s),t._dragDetails.progress=Math.max(0,Math.min(s,t._dragDetails.progress+(t.rightToLeft?-1:1)*(r-t._dragDetails.coordinates.x))),t._dragDetails.coordinates.x=Math.max(n+t._dragDetails.offset.x,Math.min(n+s+t._dragDetails.offset.x,r));const o=t._dragDetails.task.progress=t._dragDetails.progress/s*100;i.progress=parseFloat(o.toFixed(2)),t._setTaskBarProgress(i,a),t._refreshTableColumnsData(i,["progress"]),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(i,["progress"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskSegmentDrag(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableDrag)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===r)));const u=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void delete i.timelineTask;if(t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0,l||d){const e=t._createDelimiter("min-date"),i=t._createDelimiter("max-date");e&&u.appendChild(e),i&&u.appendChild(i)}}if(l){const a=i.size?i.size.width:i.originalSize.width;t._handleTaskResize(e,c?"right":"left"),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const n=i.size.width-a,s=i.segments;for(let e=0,t=s.length;e<t;e+=1){const t=s[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+n+"px")}}else{if(!d)return void t._handleSegmentDrag(e);{const s=a.dimensions;t._handleTaskResize(e,c?"left":"right"),n.style[m]=i.size.width-s.width+"px"}}t._refreshTask(o,[n]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentDrag(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=i.task,r=t._dragDetails.timelineTask,o=t.rightToLeft,l=o?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===s)));const d=i.timelineRow,{left:c}=d.getBoundingClientRect(),m=i.taskDimensions.left;a.position||(a.position={x:a.originalPosition.x});const u=r.offsetWidth,h=e.pageX-window.pageXOffset;let g=0,f=a.min.left||0,p=a.max.left;o&&(f=u-(f+a.dimensions.width),p=u-p),a.position.x=Math.max(f,Math.min(p,a.position.x+(o?-1:1)*(h-i.coordinates.x))),void 0!==p&&(g=o?m+a.min.left:m+a.max.left,a.position.x=Math.min(p,a.position.x)),f=m+(o?a.max.left-a.dimensions.width:f),i.coordinates.x=Math.max(c+a.offset.x+f,Math.min(c+a.offset.x+g,h)),n.style[l]=a.position.x+"px",t._refreshTaskSegments(r,[n])}_handleTaskBarDrag(e){const t=this;if(t.disableTaskDrag)return;const i=t._dragDetails;if(Math.abs(e.pageX-i.coordinates.x)<=5)return void(t._scrollView.disableSwipeScroll=!0);if(i.segment)return void t._handleTaskSegmentDrag(e);const a=i.task,n=i.timelineTask;i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const s=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:a.dateStart,dateEnd:a.dateEnd}).defaultPrevented)return void delete i.timelineTask;t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0;const e=t._createDelimiter("min-date"),n=t._createDelimiter("max-date");e&&s.appendChild(e),n&&s.appendChild(n)}i.position||(i.position={x:i.originalPosition.x,y:i.originalPosition.y});const r=s.getBoundingClientRect().left,o=s.offsetWidth,l=n.offsetWidth,d=i.min.left||0,c=i.max.left,m=e.pageX-window.pageXOffset,u=t.rightToLeft;let h=0;i.position.x=Math.max(d,Math.min(o-l,i.position.x+(u?-1:1)*(m-i.coordinates.x))),void 0!==c&&(i.position.x=Math.min(c,i.position.x),h=o-l-c),i.coordinates.x=u?Math.max(r+i.offset.x+h,Math.min(r+o-(l-i.offset.x+d),m)):Math.max(r+i.offset.x+d,Math.min(r+o-(l-i.offset.x+h),m));const g=a.dateStart.getTime(),f=a.dateEnd.getTime();n.style[u?"right":"left"]=i.position.x+"px",t._refreshTask(n),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),"project"===a.type&&a.dragProject&&t._refreshProjectTasks(a,{startTime:a.dateStart.getTime()-g,endTime:a.dateEnd.getTime()-f}),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(n._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskBarResize(e){const t=this;if(t.disableTaskResize)return;const i=t._dragDetails;if(i.segment)return void t._handleTaskSegmentResize(e);const a=i.timelineTask,n=i.task;if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}t._handleTaskResize(e,t.$.timeline.getAttribute("task-bar-hovered")),t._updateSegmentsOnTaskResize(),t._refreshTask(a),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(a._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_updateSegmentsOnTaskResize(){const e=this,t=e._dragDetails,i=t.task,a=t.timelineTask;if(!i||!i.segments)return;let n;t&&t.segments?n=t.segments:t.segments=n=a.querySelectorAll(".smart-task-segment");const s=n.length,r=t.size.width,o=e.rightToLeft?"right":"left";for(let t=0;t<s;t+=1){const i=n[t],a=i.style.width?parseFloat(i.style.width):i.offsetWidth,l=i.style[o]?parseFloat(i.style[o]):0;if(l+a>r){const t=r-(l+a),n=a+t;n<e._taskBarMinWidth&&(i.style[o]=l+t+"px"),i.style.width=n+"px"}else t===s-1&&(i.style.width=r-l+"px")}}_handleTaskSegmentResize(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableResize)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"right":"left";if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const u=t.$.timeline.getAttribute("task-bar-hovered");if(l&&("left"===u&&!c||"right"===u&&c)){const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.originalSize.width}),t._handleTaskResize(e,u),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const r=i.size.width-s,l=i.segments;for(let e=0,t=l.length;e<t;e+=1){const t=l[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+r+"px")}n.style.width=(a.size.width+=r)+"px"}else{if(!d||!("right"===u&&!c||"left"===u&&c))return t._handleSegmentResize(e,u),void t._refreshTaskSegments(o,[n]);{const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.originalSize.width}),t._handleTaskResize(e,u),n.style.width=(a.size.width+=i.size.width-s)+"px"}}t._refreshTask(o,[n]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentResize(e,t){const i=this,a=i._dragDetails,n=a.task,s=a.segment,r=s.element,o=i.rightToLeft,l=a.taskDimensions.left;a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const d=a.timelineRow;s.position||(s.position={x:s.originalPosition.x}),s.size||(s.size={width:s.originalSize.width});const c=e.pageX-window.pageXOffset;let m=s.size.width,u=s.min.width||0,h=s.max.width,g=s.min.left||0,f=s.max.left,p=r.offsetLeft,{left:_}=d.getBoundingClientRect(),T="object"==typeof e?c-a.coordinates.x:e;if(_+=l,"left"===t&&!o||"right"===t&&o)if(o){const e=a.taskDimensions.width;T=T<0?-1*Math.min(Math.abs(T),m-u):Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(h,m+T)),r.style.left="",r.style.right=(p=Math.max(e-g,(parseFloat(r.style.right)||d.offsetWidth-p-m)-T))+"px",a.coordinates.x=Math.max(_+e-p+u,Math.min(_+e-p,c))}else T=T>0?Math.min(T,m-(u||0)):-1*Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(p+m,m-T)),r.style.right="",r.style.left=(p=Math.max(g,(parseFloat(r.style.left)||p)+T))+"px",a.coordinates.x=Math.max(_+g+u,Math.min(_+p+m-u,c));else o?(T<0&&(T=-1*Math.min(h-m,Math.abs(T))),m=Math.max(u,Math.min(p+m,m-T)),f-=s.dimensions.width,a.coordinates.x=Math.max(_+f,Math.min(_+f+h,c))):(T>0&&(T=Math.min(h-m,T)),m=Math.max(u,Math.min(h,m+T)),a.coordinates.x=Math.max(_+p+u,Math.min(_+p+h,c)));r.style.width=(s.size.width=m)+"px"}_handleTaskResize(e,t){const i=this,a=i._dragDetails,n=a.task;a.position||(a.position={x:a.originalPosition.x,y:a.originalPosition.y}),a.size||(a.size={width:a.originalSize.width}),a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const s=a.timelineRow,r=a.timelineTask,o=a.segment,l=e.pageX-window.pageXOffset;let d=a.size.width,c=a.min.width||0,m=a.max.width,u=s.getBoundingClientRect().left,h=i.rightToLeft,g="object"==typeof e?l-a.coordinates.x:e;if("left"===t&&!h||"right"===t&&h)if(o&&(h?(u-=o.dimensions.width-o.offset.x,c=Math.max(o.max.left+o.min.width,c)):(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.max.left+o.min.width,c))),h){g<0?g=-1*Math.min(Math.abs(g),d-(c||0)):void 0!==m&&(g=Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g));const e=r.offsetLeft;r.style.left="",r.style.right=(a.position.x=Math.max(0,(parseFloat(r.style.right)||s.offsetWidth-r.offsetLeft-r.offsetWidth)-g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+e+d,l))}else g>0?g=Math.min(g,d-(c||0)):void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+d,d-g)),r.style.right="",r.style.left=(a.position.x=Math.max(0,(parseFloat(r.style.left)||r.offsetLeft)+g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l));else h?(o&&(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.min.left+o.min.width,c)),g<0&&void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+r.offsetWidth,d-g)),r.style.width=a.size.width+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l))):(o&&(u-=o.dimensions.width-o.offset.x,c=Math.max(o.min.left+o.min.width,c)),g>0&&void 0!==m&&(g=Math.min(m-d,g)),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g)),a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+r.offsetLeft+(m||d),l)));r.style.width=a.size.width+"px"}_handleTimelineConnectionHover(e){const t=this;if(!(t.shadowRoot||t).contains(e))return;const i=t.$.timelineConnectionsContainer.children,a=e.closest(".smart-task-connection");if(a||!t.$.timelineConnectionsContainer.querySelector(".smart-task-connection[hover]")){if(a){const e=a.getAttribute("connection-id");for(let t=0;t<i.length;t++){const a=i[t];a.getAttribute("connection-id")===e?a.setAttribute("hover",""):a.removeAttribute("hover")}t._hoveredConnectionTasks=a.tasks}}else for(let e=0;e<i.length;e++)i[e].removeAttribute("hover")}_resetItemHover(){const e=this;if(e._hoveredItem){const t=e.$.mainSplitter.querySelectorAll(".smart-timeline-task[hover], .smart-timeline-row[hover], tr[hover]");for(let e=0;e<t.length;e++)t[e].removeAttribute("hover");e.$.timeline.removeAttribute("task-bar-hovered"),delete e._hoveredItem}}_handleTimelineHover(e,t){const i=this,a=i._isMobile;if(!e||a)return void i._resetItemHover();const n=e.originalEvent||e;let s="task",r=n.pageX&&a?document.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.target;if(n.pageX&&i.shadowRoot&&r===i&&(r=n.pageX&&a?i.shadowRoot.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.composedPath()[0]),!r||!r.closest||r===i||t)return void i._resetItemHover();i.$.resourceSplitter&&i.$.resourceSplitter.contains(r)?s="resource":i._handleTimelineConnectionHover(r);let o=r.closest(".smart-timeline-row")||r.closest(".smart-timeline-task");if(!o||!(i.shadowRoot||i).contains(o))return void i._resetItemHover();const l=o._cellObj[s],d=l.$.id,c=i._hoveredItem;if(!(c&&c.type===s&&c.id===d||(i._resetItemHover(),l.isGroup||("task"===s&&o.classList.contains("smart-timeline-row")&&(o=i.$.timelineTasksContainer.querySelector(`.smart-timeline-task[row-id="${d}"]`)),!o||i._connectionFeedback&&o.contains(i._connectionFeedback)||(o.setAttribute("hover",""),i._hoveredItem={id:d,type:s},a))))){const e=("task"===s?i.$.taskTimelineCellsContainer:i.$.resourceTimelineCellsContainer).querySelector(`.smart-timeline-row[row-id="${d}"]`);e&&(e.setAttribute("hover",""),i._handleTableItemHover(d,r))}}_getScrollLeft(e){return this.rightToLeft?e*=-1:e}_synchronizeSplitters(e,t){if(this.$.mainSplitter.contains(this.$.resourceSplitter)){const i=e._measurements,a=e.items,n=t.items,[s,r,o]=[i.dimension,i.minDimension,i.maxDimension],[l,d]=[n[0],a[0]],[c,m]=[n[1],a[1]];t.keepProportionsOnResize=!0,t.setAttribute("orientation-change",""),[r,o,s].forEach((e=>{const t=e===s?"size":e===r?"min":"max";l.set(t,""),c.set(t,""),l[t]=d.style[e],c[t]=m.style[e]})),t.removeAttribute("orientation-change"),t.keepProportionsOnResize=!1}}_resizeEventHandler(e){const t=this,i=t.$.taskSplitter;function a(e){e.refresh(),e===i&&t._synchronizeSplitters(i,t.$.resourceSplitter)}if(e&&"resizeEnd"===e.type){if(e.target===t.$.taskTreeSplitter||e.target===t.$.resourceTreeSplitter)return void a(e.target);e.target===t.$.resourceSplitter&&t._synchronizeSplitters(t.$.resourceSplitter,i)}if(!t._timelineCells)return void t._refresh();t.$.mainSplitter.refresh(),a(i);const n=t._getScrollLeft(t.scrollLeft);t._autoSchedule(),t._createTimelineCells(),t._recycleTimelineTasks(),t._recycleTimelineRowCells(),t._refreshResourceTimeline(),t._refresh(),t.$.taskTable.refresh(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=n,t.$.taskTable.scrollTop=t.$.taskTimelineContainer.scrollTop=t.scrollTop,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=n,t.$.resourceTable.refresh(),t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=t.$.resourceVerticalScrollBar.value),t._positionWindow()}_recycle(e){const t=this,i=e&&"horizontal"===e.context.orientation;if(e&&!i||(t._recycleHeaderCells(t.$.timelineViewCells),t._recycleHeaderCells(t.$.timelineViewDetails),t.$.timelineViewSubDetails.classList.contains("smart-hidden")||t._recycleHeaderSubCells(t.$.timelineViewSubDetails),t._recycleResourceContent()),i)return;if(t._recycleResourceContent(),t._recycleContentCells(),t._recycleTimelineTasks(),!e)return;const a=Math.round(e.detail.value);e.target!==t.$.resourceVerticalScrollBar?t._refreshTableScrollTop(t.$.taskTable,a):t._refreshTableScrollTop(t.$.resourceTable,a)}_recycleContentCells(){const e=this,t=e._getFirstContentCellInView(),i=e.$.taskTimelineCellsContainer,a=e.$.timelineTasksContainer;if(!t)return void(i.innerHTML=a.innerHTML="");const n=t.height,s=1-(t.top+n-Math.abs(e.scrollTop))/n,r=e._timelineVCells?e._timelineVCells.length:0,o=!e.$.taskSplitter.offsetHeight,l=e.$.taskTimelineContainer.offsetHeight,d=!o&&l?Math.min(r,Math.ceil((parseFloat((l/n).toFixed(2))+s).toFixed(2))):r,c=e.$.timelineViewCells.children,m=document.createDocumentFragment();for(;i.childElementCount>d;)i.lastElementChild.remove();for(;a.childElementCount>d;)a.lastElementChild.remove();for(let t=i.childElementCount;t<d;t+=1){const t=document.createElement("div");t.classList.add("smart-timeline-row"),e._createTimelineRowCells(t,c),m.appendChild(t)}m.childElementCount&&i.appendChild(m);for(let e=a.childElementCount;e<d;e+=1){const e=document.createElement("div");e.classList.add("smart-timeline-task"),m.appendChild(e)}m.childElementCount&&a.appendChild(m)}_getCellIndexByDate(e){const t=this._timelineCells;let i=[];if(e&&e.length&&t){Array.isArray(e)||(e=[e]);for(let t=0,a=e.length;t<a;t+=1){const a=e[t];e[t]=a.getTime?a.getTime():a,i[t]=-1}for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e.indexOf(n.date.getTime());if(s>-1&&(i[s]=a,i.every((e=>-1!==e))))break}return 1===i.length?i[0]:i}}_recycleDateMarkers(){const e=this,t=e.$.timelineMarkers,i=e._markers;if(!i||e.hideDateMarkers)return void(t.childElementCount&&(t.innerHTML=""));const a=e.$.timelineViewCells.children,n=a[0]._date,s=a[a.length-1]._date,[r,o]=e._getCellIndexByDate([n,s]);if(!n||!s)return;const l=n.getTime(),d=e._getCellDateRange({_date:s}).dateEnd.getTime(),c=t.children,[m,u]=e.rightToLeft?["right","left"]:["left","right"],h=document.createDocumentFragment();let g=0;for(let t=0,a=i.length;t<a;t+=1){const a=i[t],n=i[t].date,s=n.getTime();if(s<l||s>d)continue;const f=e._getTimelineCellByDate(n,r,o);if(f){const t=f.left+e._getTimelineTaskOffset(f,n),i=a.label,s=a.className;let r=c[g];r||(r=document.createElement("div"),h.appendChild(r)),r.className="smart-gantt-chart-date-marker",void 0!==i&&(r.firstElementChild||(r.innerHTML='<div class="smart-gantt-chart-marker-label"></div>'),r.firstElementChild.textContent=i+""),void 0!==s&&r.classList.add(s),r.style[u]="",r.style[m]=t+"px",g++}}for(h.childElementCount&&t.insertBefore(h,t.firstElementChild);c.length>g;)c[c.length-1].remove()}_refreshTableScrollTop(e,t){this.$.mainSplitter.contains(e)&&void 0!==t&&(e.scrollTop=t)}_recycleHeaderCells(e){let t=this,i=e.children,a=t.scrollLeft,n=e===t.$.timelineViewCells,s=n?t._timelineCells:t._timelineHeaderCells;if(e===t.$.timelineViewSubDetails&&(n=!1,s=t._timelineHeaderSubCells),!s.length)return;let r=document.createDocumentFragment();for(;i.length;)r.appendChild(e.firstElementChild);let o=t._getFirstCellObjInView(s),l=1-(o.left+o.width-Math.abs(a))/s[0].width,d=r.children.length,c=n?Math.ceil((parseFloat((t.$.timeline.offsetWidth/o.width).toFixed(2))+l).toFixed(2)):t._getHeaderVisibleCellsCount();if(e===t.$.timelineViewSubDetails&&(c=t._getHeaderSubVisibleCellsCount()),d>c)for(;r.children.length&&r.children.length!==c;)r.removeChild(r.firstElementChild);else if(d<c){const e=t._createCells(c-d);for(;e.children.length;)r.appendChild(e.firstElementChild)}const m=[t.rightToLeft?"right":"left"],u=n?t._getCellsViewType():t.view;let h=s.indexOf(o);for(let e=0;e<r.children.length;e++){const i=r.children[e],a=s[h];if(!a)break;let o=new Date(a.date);n||"week"!==t.view||(o.setDate(o.getDate()-o.getDay()),o=new Date(Math.max(a.date.getTime(),o.getTime()))),i.style[m]=a.left+"px",i.style.width=a.width+"px",i._date=o,i.innerHTML=`<div>${t._getDateString(o,u,!n)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),h++}e.appendChild(r),n&&(t._recycleTimelineRowCells(),t._recycleResourceHeaderCells(),t._recycleDateMarkers(),t._setTodayCell())}_recycleHeaderSubCells(e){let t=this,i=e.children,a=t.scrollLeft,n=t._timelineHeaderSubCells;if(!n.length)return;let s=document.createDocumentFragment();for(;i.length;)s.appendChild(e.firstElementChild);let r=t._getFirstCellObjInView(n),o=(r.left,r.width,Math.abs(a),n[0].width,s.children.length),l=t._getHeaderSubVisibleCellsCount();if(o>l)for(;s.children.length&&s.children.length!==l;)s.removeChild(s.firstElementChild);else if(o<l){const e=t._createCells(l-o);for(;e.children.length;)s.appendChild(e.firstElementChild)}const d=[t.rightToLeft?"right":"left"],c=t.view;let m=n.indexOf(r);for(let e=0;e<s.children.length;e++){const i=s.children[e],a=n[m];if(!a)break;let r=new Date(a.date);"week"===t.view&&(r.setDate(r.getDate()-r.getDay()),r=new Date(Math.max(a.date.getTime(),r.getTime()))),i.style[d]=a.left+"px",i.style.width=a.width+"px",i._date=r,i.innerHTML=`<div>${t._getDateString(r,c,!0)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),m++}e.appendChild(s),t._refreshHeaderSubDetailsDate()}_refresh(){const e=this;let t="disabled"===e.verticalScrollBarVisibility;function i(){const t=e.$.timelineHeader,i=t.scrollWidth-t.offsetWidth;return i>0&&"hidden"!==e.horizontalScrollBarVisibility||"visible"===e.horizontalScrollBarVisibility?e.$container.addClass("hscroll"):e.$container.removeClass("hscroll"),i}function a(){let i=Math.max(0,e.$.timelineContent.offsetHeight-e.$.taskTimelineContainer.offsetHeight);return i>0&&"hidden"!==e.verticalScrollBarVisibility||"visible"===e.verticalScrollBarVisibility?e.$container.addClass("vscroll"):e.$.mainSplitter.contains(e.$.resourceSplitter)?(i=1,t=!0,e.$.resourceVerticalScrollBar.max||e.$container.removeClass("vscroll")):e.$container.removeClass("vscroll"),i}const n=e.scrollWidth,s=e.scrollHeight;let r=i(),o=a();o&&s===o||(r=i()),r&&n===r||(o=a()),e.scrollWidth=r,e.scrollHeight=o,e.$.verticalScrollBar.disabled=t,e.$.horizontalScrollBar.refresh(),e.$.verticalScrollBar.refresh(),e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._refreshResourceScrollBar(),e._refreshTableScrollTop(e.$.resourceTable))}_refreshProjectTasks(e,t){const i=this,a=i._getProjectTasks(e);if(!a.length)return;const n=i.nonworkingDays,s=i.nonworkingHours,r=i._timelineVCells;for(let e=0,o=a.length;e<o;e++){const o=a[e];if(o){const e=i._getTaskDOMIndex(o),a=r[e],l=o.segments;if(o.dateStart=new Date(Math.max(i.dateStart.getTime(),o.dateStart.getTime()+t.startTime)),o.dateEnd=new Date(Math.min(i.dateEnd.getTime(),o.dateEnd.getTime()+t.endTime)),o.duration=i._convertDuration(n.length>0||s.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),l&&l.length>1){for(let e=0,i=l.length;e<i;e+=1){const i=l[e];i.dateStart=new Date(i.dateStart.getTime()+t.startTime),i.dateEnd=new Date(i.dateEnd.getTime()+t.endTime)}i._validateTaskSegments(o)}a&&(i._recycleTaskBars(a,e),i._setTimelineTaskBar(a,e),l&&l.length>1&&i._setTaskBarProgress(o),i._refreshTaskConnections(o),i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"]))}}}_refreshProject(e){const t=this;function i(e){let i,a,n;if(e instanceof HTMLElement)i=e.offsetLeft,n=e.offsetWidth;else if(e){const s=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);s&&r&&(i=s.left+t._getTimelineTaskOffset(s,e.dateStart)||0,a=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0,n=a-i)}return[i,n]}if(!e)return;const a=t.groupByResources&&e.isGroup?"group":"project";if(e.synchronized)for(;e&&e.synchronized;){const n=t._getProjectTasks(e);let s=n[0],r=n[0];for(let e=0;e<n.length;e++)s.dateStart.getTime()>=n[e].dateStart.getTime()&&(s=n[e]),r.dateEnd.getTime()<=n[e].dateEnd.getTime()&&(r=n[e]);const o=t.$.timelineTasksContainer.children,l=t.$.timelineContent.offsetWidth;let d,c,m;for(let t=0,i=o.length;t<i;t+=1){const i=o[t],a=i._cellObj?i._cellObj.task:void 0;a&&(a===e?d=i:a===s?c=i:a===e&&(m=i))}if(!d){s&&(e.dateStart=s.dateStart),r&&(e.dateEnd=r.dateEnd),e=e.$[a];continue}s&&(e.dateStart=s.dateStart);let[u,h]=i(c||s);void 0!==u&&void 0!==h&&(t.rightToLeft?(d.style.width=d.offsetWidth-(l-u-h-(l-d.offsetLeft-d.offsetWidth))+"px",d.style.right=c?c.style.right:u+"px"):(d.style.width=d.offsetWidth-(u-d.offsetLeft)+"px",d.style.left=c?c.style.left:u+"px")),r&&(e.dateEnd=r.dateEnd),[u,h]=i(m||r),void 0!==u&&void 0!==h&&(t.rightToLeft?d.style.width=Math.max(0,d.offsetWidth-(l-d.offsetLeft-(l-u)))+"px":d.style.width=Math.max(0,d.offsetWidth-(d.offsetLeft+d.offsetWidth-(u+h)))+"px"),t._refreshTask(d),e=e.$[a]}else t._refreshProject(e.$[a])}_refreshTask(e,t){const i=this,a=i._getTaskBarCellRange(e),n=a.cellStart,s=a.cellEnd;if(!a||!n||!s)return;e._cellStart=n,e._cellEnd=s;const r=i._getTaskBarDateRange(e);if(!r)return;const o=e._cellObj.task;if(Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===o))){if(o.dateStart=r.dateStart,o.dateEnd=r.dateEnd,o.duration=o.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),e.setAttribute("aria-label",o.label+" Start date: "+i._toISODate(o.dateStart)+", End date: "+i._toISODate(o.dateEnd)),i._refreshTaskConnections(e),t)Array.isArray(t)&&i._refreshTaskSegments(e,t);else{const t=i._dragDetails;let a;e.classList.contains("task")?t&&t.segments?a=t.segments:t.segments=a=e.querySelectorAll(".smart-task-segment"):a=e.querySelectorAll(".smart-task-segment"),i._refreshTaskSegments(e,a)}i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"])}}_refreshTaskSegments(e,t){const i=this,a=e._cellObj.task;if(!a||!a.segments||!a.segments.length)return void i._setTaskBarDeadline(a,t?t[0]:void 0);const n=i.nonworkingDays.length>0||i.nonworkingHours.length>0,s=i.rightToLeft,r=s?"right":"left",o=parseFloat(e.style[r])||e.offsetLeft;let l;for(let a=0,d=t.length;a<d;a+=1){const d=t[a],c=d._segmentObj,m=i._getSegmentCellRange(d),u=m.cellStart,h=m.cellEnd;if(!m||!u||!h)continue;const g=parseFloat(d.style.width)||d.offsetWidth,f=o+parseFloat(d.style[r])||(s?(parseFloat(e.style.width)||e.offsetWidth)-(d.offsetLeft+d.offsetWidth):d.offsetLeft);d._cellStart=u,d._cellEnd=h,l=d;let p=i._getDateFromCell(f,u),_=i._getDateFromCell(f+g,h);c.dateStart=p,c.dateEnd=_,c.duration=i._convertDuration(n?i._getWorkingTime(p,_):_.getTime()-p.getTime(),!0),e.setAttribute("aria-label",(c.label||"")+" Start date: "+i._toISODate(p)+", End date: "+i._toISODate(_))}i._setTaskBarProgress(a,e),i._setTaskBarDeadline(a,l)}_refreshTaskResources(e,t=[]){const i=this;if(e&&(t||(t=i._getTaskResources(e)),t.length))for(let e=0;e<t.length;e++){const a=t[e];i._refreshResource(a),i._refreshTableColumnsData(a,void 0,"resource")}}_refreshTableColumnsData(e,t,i){const a=this;if(i||(i="task"),!e)return;const n=a[`${i}Columns`],s=a.$[`${i}Table`];if(!a.$.mainSplitter.contains(s))return;const r=e.$.id;t=t?t.map((e=>n.find((t=>t.value===e)))):n;for(let i=0;i<t.length;i++){const n=t[i];n&&s.setValue(r,n.value,a._formatColumnData(e,n))}a.$[`${i}Splitter`].refresh()}_removeConnection(e,t){const i=this,a=i.$.connectionPopupWindow,n=i.$.timelineConnectionsContainer;if(e.classList&&e.classList.contains("smart-task-connection")?e=e.getAttribute("connection-id"):e+="",void 0===e)return;const s=n.querySelectorAll('.smart-task-connection[connection-id^="'+e+(e.indexOf("-")<0?"-":"")+'"]'),r=i._tasks,o=e.split("-"),l=parseInt(o[1]);for(let e=0;e<s.length;e++)n.removeChild(s[e]);let d;const c=parseInt(o[0]),m=parseInt(o[1]),u=parseInt(o[2]);if(a&&void 0!==a._target&&"number"==typeof a._target.type){const t=a._target;d=t.startIndex+"-"+t.endIndex+"-"+t.type===e}i._updateConnection([c,m,u],!0),!t&&i.autoSchedule&&(i._autoScheduleRestore(r[l],parseInt(o[2])),i._autoSchedule(r[l])),d&&i.$.fireEvent("itemRemove",{type:"connection",id:`${c}-${m}-${u}`,item:{source:c,target:m,type:u}})}_removeTaskConnections(e,t){const i=this,a=i._connections;if(a&&a.length){for(let t=0,i=a.length;t<i;t+=1)a[t].startTask===e&&(a.splice(t,1),i--);e.connections=[],t&&i._recycleConnections()}}_removeTask(e){const t=this,i=t._tasks;if(!e||!i||!i.length)return;const a=t._getSelection("task",t.selectedTaskIds),n=t.$.taskPopupWindow;let s;if(t._highlightAssignedItem("task",[e]),n&&n._target===e&&n.close(),"project"===e.type){const a=t._getProjectTasks(e);for(let e=0,t=a.length;e<t;e+=1)i.splice(i.indexOf(a[e]),1)}if(i.splice(i.indexOf(e),1),t._refreshItemIds(),t._refreshConnectionIds(),t._isUpdating)return t._isUpdating.type.task=!0,void(t._isUpdating.type.resource=!0);t._refreshSelectedItems(),t._refreshTableDataSource(),t._refreshTimeline(),t._selected&&t._selected.task&&(s=t._selected.task.map((e=>e.$.id)),a.toString()!==s.toString()&&(t.$.taskTable.selected=t._getSelection("task",t.selectedTaskIds))),t.$.fireEvent("itemRemove",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}_removeResource(e){const t=this,i=t._resources,a=i.indexOf(e);if(e&&!(a<0)){if(t._isUpdating)return i.splice(a,1),t._isUpdating.type.resource=!0,void(t._isUpdating.type.task=!0);if(i.splice(a,1),t.groupByResources)t._refreshTableDataSource(),t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks();else if(t.taskColumns.find((e=>"resources"===e.value))){const i=t._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<i.length;e++)t._refreshTableColumnsData(i[e],["resources"])}if(!i.filter((e=>!e.hidden)).length)return t._createResourceTimeline(),t._resizeEventHandler(),void n();t._refreshResourceTimeline(),t._refreshTableDataSource("resource"),t.$.mainSplitter.contains(t.$.resourceSplitter)?(t._refreshResourceScrollBar(),t._resizeEventHandler(),n()):n()}function n(){t.$.fireEvent("itemRemove",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}}_updateTask(e,t){const i=this,a=i._tasks;if(!e||!a||!a.length)return;const n=i.$.taskPopupWindow,s=i._getSelection("task",i.selectedTaskIds);n&&n._target===e&&n.close();let r,o=i._getTaskResources(e);for(let n in t){let s=e[n],l=t[n];if("type"===n&&s!==l&&["task","project","milestone"].indexOf(l)>-1&&"project"===s){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)a.splice(a.indexOf(t[e]),1);delete e.tasks}if("project"!==e.type||!e.synchronized||!(n.toLowerCase().indexOf("date")>-1||n.toLowerCase().indexOf("duration")>-1))if("dateEnd"===n&&new Date(s).getTime()!==new Date(l).getTime()&&(r=!0),"tasks"!==n)"connections"===n&&(i._removeTaskConnections(e),i._handleTaskConnections(e)),e[n]=l,"resources"===n&&(i._handleResources(e),e.disableResources||(o=o.concat(i._getTaskResources(e)),o=o.filter(((e,t)=>o.indexOf(e)===t)))),"milestone"!==e.type||"dateStart"!==n&&"dateEnd"!==n||(e.dateEnd=e.dateStart=l);else if("project"===e.type){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)a.splice(a.indexOf(t[e]),1);const n=i._createTasks(l,!0);for(let t=0,i=n.length;t<i;t+=1)n[t].$.project=e;i._insertTasks(n,e,a.indexOf(e))}}r&&delete e.duration;const l=e.$,d=e.$.project;if(i._validateTaskProperties(e,d),e.$=l,d&&i._synchronizeProjectDates(d),"project"===e.type&&e.hidden&&i._getProjectTasks(e).forEach((t=>t.hidden=e.hidden)),i._synchronizeProjectVisibility(e.$.project,e),i._refreshItemIds(),i._refreshConnectionIds(),i._isUpdating)return void(i._isUpdating.type.task=!0);let c;i._selected&&i._selected.task&&i._setSelection("task",c=i._selected.task.map((e=>e.$.id))),i._refreshTableDataSource(),i._refreshTimeline(),i._ensureVisible(e),c&&s.toString()!==c.toString()&&(i.$.taskTable.selected=c.slice(0)),i._refreshTaskResources(e,o),i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i.$.fireEvent("itemUpdate",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}_updateResource(e,t){const i=this;if(!e)return;const a=e.hidden;if(i._setResource(e,t),i._isUpdating)i._isUpdating.type.resource=!0;else{if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const t=i._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<t.length;e++)i._refreshTableColumnsData(t[e],["resources"])}if(a!==e.hidden)return i._createResourceTimeline(),void i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)});if(i._refreshTableColumnsData(e,void 0,"resource"),i.$.mainSplitter.contains(i.$.resourceTimelineCellsContainer)){const t=i.$.resourceTimelineCellsContainer.children;for(let a=0;a<t.length;a++){const n=t[a];n._resource===e&&i._refreshResourceTimelineContent(e,n)}}i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}}_select(e="task",t){const i=this;if(i.disableSelection||!t)return void i._unselectAll(e);let a,n;"task"===e?(a="selectedTaskIds",n=i._tasks):(a="selectedResourceIds",n=i._resources);const s=n.findIndex((e=>e.$.id===t)),r=i._getSelection(e,i[a]);s<0||(r.indexOf(t)>-1?i.$[`${e}Table`].unselect(t):i.$[`${e}Table`].select(t))}_handleTableSelection(e="task",t){const i=this;if(i.disableSelection||!t.length)return void i._unselectAll(e);let a,n,s,r,o,l=i._selected;l||(l=i._selected={});const d=t[t.length-1],c=l[e]=[];"task"===e?(o=i._tasks,a="selectedTaskIds",n=i.$.taskTimelineCellsContainer.children,s=i.$.timelineTasksContainer.children):(o=i._resources,a="selectedResourceIds",n=i.$.resourceTimelineCellsContainer.children,s=[]);for(let e=0,i=o.length;e<i;e+=1){const i=o[e];t.indexOf(i.$.id)>-1&&c.push(i)}for(let i=0,a=n.length;i<a;i+=1){const a=n[i],o=s[i],l=a._cellObj[e].$.id;d===l&&(r=s[i]),t.indexOf(l)>-1?(a.setAttribute("selected",""),a.setAttribute("aria-selected","true"),o&&o.setAttribute("selected","")):(a.removeAttribute("selected"),a.setAttribute("aria-selected","false"),o&&o.removeAttribute("selected"))}const m=i[a].slice(0);if(i._setSelection(e,t),!i._tableChangeEventFired){const a=document.scrollingElement||document.documentElement,n=a.scrollLeft,s=a.scrollTop;i._highlightAssignedItem(e,t),i.$[`${e}Table`].focus({preventScroll:!0}),window.scrollTo(n,s)}if("task"===e&&r){const e=r._cellStart;if(i.scrollLeft>e.left||e.left+r.offsetWidth>i.scrollLeft+i.$.timeline.offsetWidth){const t=i._timelineCells.indexOf(e);i._scrollTo((i._timelineCells[t-1]?i._timelineCells[t-1]:e).date)}}i._noChangeEvent||i.$.fireEvent("change",{type:e,value:i[a].slice(0),oldValue:m})}_setSelection(e="task",t){const i=this;let[a,n]="task"===e?[i._tasks,"selectedTaskIds"]:[i._resources,"selectedResourceIds"],s=[];for(let e=0,i=t.length;e<i;e+=1){const i=t[e],n=a.find((e=>e.$.id===i));n&&s.push(void 0!==n.id?n.id:i)}i.set(n,s)}_getSelection(e="task",t){const i="task"===e?this._tasks:this._resources;let a=t.slice(0);if(!t||!t.length)return a;for(let e=0,n=i.length;e<n;e+=1){const n=i[e],s=t.indexOf(n.id);s>-1&&(a[s]=n.$.id)}return a}_highlightAssignedItem(e,t){const i=this,[a,n]="task"===e?["resource","_getTaskResources"]:["task","_getResourceTasks"],s=i.$[`${a}Table`],r=i[`_${a}s`];if(!s||!i.$.mainSplitter.contains(s)||!r.length)return;t&&Array.isArray(t)||(t=[]);let o=[];for(let a=0,s=t.length;a<s;a+=1){const s=i._getValidItemAndIndex(t[a],e);s&&(o=o.concat(i[n](s.item).filter((e=>!e.hidden))))}i._tableChangeEventFired=!0,s.selected=o.map((e=>e.$.id)),o.length&&i._ensureVisible(o[0],a),delete i._tableChangeEventFired}_selectResource(e){const t=this,i=t._resources.indexOf(e);if(i<0)return void t._unselectAll("resource");const a=t.$.resourceTimelineCellsContainer.children[i];a&&a.hasAttribute("selected")?t._unselectAllTasks():t.$.resourceTree.focus({preventScroll:!0})}_snapToNearest(e,t){const i=this;if(!(i.snapToNearest&&e&&e.classList&&e.classList.contains("smart-timeline-task")&&e._cellObj))return;const a=e._cellObj.task,n=a.segments;if(t&&t.classList.contains("smart-task-segment")){const a=n.indexOf(t._segmentObj),s=0===a,r=a===n.length-1;if(i._handleSnapToNearestSegment(e,t,s?"first":r?"last":void 0),i._refreshTaskSegments(e,[t]),!s&&!r)return;i._refreshTask(e,!0)}else i._handleSnapToNearest(i._getTaskBarCellRange(e),e),i._refreshTask(e);if(n&&n.length>1){for(let e=0,t=n.length;e<t;e+=1)i._snapToNearestDates(n[e],!0);i._validateTaskSegments(a),a.segments.length!==n.length&&i._recycleSegments(a,e),i._setTaskBarSegments(e._cellObj,e,!0),i._setTaskBarProgress(a)}if("project"!==a.type||!a.dragProject)return;const s=i._getProjectTasks(a);if(s&&Array.isArray(s))for(let e=0;e<s.length;e++){const t=i.$.timelineTasksContainer.children[i._tasks.indexOf(s[e])];t&&i._snapToNearest(t)}}_handleSnapToNearestSegment(e,t,i){const a=this,n=a.rightToLeft,s=n?"right":"left",r=parseFloat(e.style[s])||0,o=t,l=a._getSegmentCellRange(t),d=l.cellStart,c=l.cellEnd,m="first"===i,u="last"===i;let h=parseFloat(o.style.width)||o.offsetWidth,g=parseFloat(o.style[s])||0,f=r+g;if(a.hasAttribute("dragged")){const t=c.width-(f+h-c.left);let a;if(f-d.left<=t?(a=d.left-r,o.style[s]=Math.max(0,m?0:a)+"px"):(a=g+t,o.style[s]=Math.max(0,m?0:a)+"px"),i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&(e.style[s]=r+(a-g)+"px"),e.style.width=t+(m?-1:1)*(a-g)+"px"}}else if(a.hasAttribute("resized")){const t=d===c?a._taskBarMinWidth:0;let l;if("left"===a.$.timeline.getAttribute("task-bar-hovered")){if(l=f-d.left,l-=l>=d.width/2?d.width-t:0,f-=l,o.style[s]=Math.max(0,m?0:f-r)+"px",l=f+h>c.left+c.width/2?c.left+c.width-(f+h):c.left-(f+h),o.style.width=Math.max(t,h+l)+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&!n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&n&&(e.style.width=t+l+"px")}}else if(f>d.left+d.width/2?(f=d.left+d.width,o.style[s]=Math.max(0,m?0:f-r)+"px"):(f=d.left,o.style[s]=Math.max(0,m?0:f-r)+"px"),l=f+h-c.left,l=-1*(l-(l>=d.width/2?c.width:t)),o.style.width=h+l+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&!n&&(e.style.width=t+l+"px")}}}_handleSnapToNearest(e,t){const i=this;if(!e)return;const a=i.rightToLeft?"right":"left",n=e.cellStart,s=e.cellEnd;let r=parseFloat(t.style.width)||t.offsetWidth,o=parseFloat(t.style[a])||0;if(i.hasAttribute("dragged")){const e=s.width-(o+r-s.left);o-n.left<=e?t.style[a]=n.left+"px":t.style[a]=o+e+"px"}else if(i.hasAttribute("resized")){const e=n===s?i._taskBarMinWidth:0;let l;"left"===i.$.timeline.getAttribute("task-bar-hovered")?(l=o-n.left,l-=l>=n.width/2?n.width-e:0,t.style[a]=(o-=l)+"px",l=o+r>s.left+s.width/2?s.left+s.width-(o+r):s.left-(o+r),t.style.width=Math.max(e,r+l)+"px"):(o>n.left+n.width/2?t.style[a]=n.left+n.width+"px":t.style[a]=n.left+"px",o=parseFloat(t.style[a])||0,l=o+r-s.left,l=-1*(l-(l>=n.width/2?s.width:e)),t.style.width=r+l+"px")}}_setDragLimits(e){const t=this,i=t._dragDetails;if(!i)return;const a=i.timelineTask;if(!a||!e)return;const n=t.$.timeline.getAttribute("task-bar-hovered"),s=a._cellObj.task;if(n){if(s.disableResize)return void delete t._dragDetails;const e=t._getTaskBarSizeLimits(a,n);i.min.width=e.min,i.max.width=e.max,t._setSegmentLimits(n);const r=t._createDelimiter("min",n),o=t._createDelimiter("max",n);r&&a.appendChild(r),o&&a.appendChild(o)}else if(e.closest(".smart-task-connection-point"))i.timelineTask=void 0;else if(e.closest(".smart-timeline-task")===a){let e;if(t._connections){const i=t._tasks.indexOf(a._cellObj.task);e=t._connections.some((e=>e.startIndex===i||e.endIndex===i))}if(s.disableDrag||e&&t.autoSchedule&&t.autoScheduleStrictMode)return void delete i.target;i._taskDuration=t._getWorkingTime(s.dateStart,s.dateEnd),a.classList.contains("milestone")&&(i.target="smart-timeline-task-fill");const n=t._getTaskDragLimits(a),r=t.rightToLeft?t.$.timelineContent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft;if(void 0!==n.min&&(i.min.left=n.min,"project"===a._cellObj.task.type&&n.min>r&&(i.min.left=r)),void 0!==n.max&&(i.max.left=n.max,"project"===a._cellObj.task.type&&n.max<r&&(i.max.left=r)),"project"===s.type&&s.dragProject&&!t.synchronized){const e=t._getSubTaskLimits(a);void 0!==e.min&&(i.min.left=i.min.left?Math.max(i.min.left,e.min):e.min),void 0!==e.max&&(i.max.left=i.max.left?Math.min(i.max.left,e.max):e.max)}else"milestone"===s.type&&(i.target="smart-timeline-task-fill");t._setSegmentLimits()}else i.timelineTask=void 0;i.relatedConnections={}}_setSegmentLimits(e){const t=this,i=t._dragDetails;if(!i||!i.segment)return;const a=i.segment;if(a){const n=a.element,s=a.dimensions,r=n.previousElementSibling,o=n.nextElementSibling;if(a.min.width=e?t._taskBarMinWidth:0,t.rightToLeft){if(r)a.min.left="left"===e?s.left+s.width:r.offsetLeft-(e?0:s.width),"right"===e&&(a.max.width=r.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}if(o)a.max.left="right"===e?a.dimensions.left:o.offsetLeft+o.offsetWidth+s.width,e&&"left"!==e||(a.max.width=s.left+s.width-(o.offsetLeft+o.offsetWidth));else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}}else{if(r)a.min.left="right"===e?s.left:r.offsetLeft+r.offsetWidth+(e||o?0:s.width),"left"===e&&(a.max.width=s.left+s.width-a.min.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}if(o)a.max.left="left"===e?s.left+s.width:o.offsetLeft-s.width,e&&"right"!==e||(a.max.width=o.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}}}}_setScrollBars(){const e=this;e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;i.$.addClass("smart-hidden"),t.$.addClass("smart-hidden"),t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.rightToLeft=i.rightToLeft=e.rightToLeft,i.wait=!1,e._refresh()}_getWorkingTime(e,t){const i=this;if(!e||!t)return;if(!i.adjustToNonworkingTime)return t.getTime()-e.getTime();const a=i.nonworkingHours,n=i.nonworkingDays;function s(e,t){let s,r,o=t.getTime()-e.getTime(),l=new Date(e),d=0;for(;o>0;){const e=Math.min(o,36e5-(60*l.getMinutes()*1e3+1e3*l.getSeconds()+l.getMilliseconds()));if(n.indexOf(l.getDay())>-1)r=new Date(l),r.setHours(0,0,0,0),r.setDate(l.getDate()+1),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s;else if("day"===i.view&&a.indexOf(l.getHours())>-1){r=new Date(l);const t=r.getTime();r.setHours(l.getHours()+1,0,0,0),t===r.getTime()&&r.setHours(l.getHours()+2,0,0,0),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s}else d+=e,o-=e,l=new Date(l.getTime()+e)}return d}if(e.getFullYear()===t.getFullYear())return s(e,t);let r=new Date(e.getFullYear()+1,0,1,0,0,0,0),o=s(e,r);if(t.getFullYear()>r.getFullYear()){const e=Math.max(0,t.getFullYear()-r.getFullYear());for(let t=0;t<e;t++){let e=i._getWorkingDaysBetweenDays(r);o+=60*(24*e-e*i.nonworkingHours.length)*60*1e3,r.setFullYear(r.getFullYear()+1)}}return o+=s(r,t),o}_getWorkingDaysBetweenDays(e){const t=this,i=e.getFullYear(),a=(i%100==0?i%400==0:i%4==0)?366:365;let n=new Date(e),s=0;for(let e=0;e<a;e++)t.nonworkingDays.indexOf(n.getDay())<0&&s++,n.setDate(n.getDate()+1);return s}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.tabIndex=-1:e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setTaskBarLabel(e,t){const i=this;void 0===t&&(t=i._getTaskDOMIndex(e));const a=i.$.timelineTasksContainer.children[t];if(!a)return;const n=a.querySelector(".smart-task-segments").children;let s=e.segments;Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);for(let r=0,o=s.length;r<o;r+=1){const o=s[r],l=n[r],d=l?l.getElementsByClassName("smart-timeline-task-label")[0]:void 0;if(!d)continue;d.firstElementChild||(d.innerHTML="<div></div>");let c=d.firstElementChild;"string"==typeof o.label||"number"==typeof o.label?c.textContent=o.formatFunction?o.formatFunction(o.label||"",t)||"":o.label||"":c.textContent=e.formatFunction?o.formatFunction(e.label||"",t)||"":e.label||"",i.onTaskRender&&i.onTaskRender(e,o,a,l,c),e.onRender&&e.onRender(e,o,a,l,c)}}_setTaskBarProgress(e,t){const i=this;if("number"==typeof t?t=i.$.timelineTasksContainer.children[t]:void 0===t&&(t=i.$.timelineTasksContainer.children[i._getTaskDOMIndex(e)]),!t||!e)return;let a=e.progress;const n=t.querySelector(".smart-timeline-task-progress-thumb");if(!n)return;a=Math.min(100,Math.max(0,a))||0;const s=e.dateStart.getTime(),r=e.dateEnd.getTime(),o=t.querySelector(".smart-task-segments").children;let l,d,c=e.segments,m=0;c&&c.length||(c=[e]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=o[e],n=i?i.querySelector(".smart-timeline-task-progress"):void 0;if(!n)continue;const u=(t.dateStart.getTime()-s)/(r-s)*100,h=(t.dateEnd.getTime()-s)/(r-s)*100,g=Math.max(0,Math.min(100,(a-u)/(h-u)*100));n.style.width=g+"%",n.removeAttribute("value"),i.removeAttribute("show-progress-label"),a>=u?(m=Math.max(u,Math.min(a,h)),l=n,d=i):l||(l=n,d=i)}if(n.style[i.rightToLeft?"left":"right"]="",n.style[i.rightToLeft?"right":"left"]=m+"%",!l||!i.showProgressLabel)return;const u=i.progressLabelFormatFunction;d.setAttribute("show-progress-label",""),l.setAttribute("value",u?u(a)+"":parseFloat(a.toFixed(2))+"%")}_setTaskDeadline(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,o=n.deadline,l=a.$.timelineDeadlines,d=l.children,c=o&&o.getTime&&!isNaN(o.getTime())?o.getTime():void 0;let m;for(let e=0,i=d.length;e<i;e+=1){const i=d[e];if(parseInt(i.getAttribute("task-index"))===t){m=i;break}}if(!c||c<s||c>r)return void(m&&m.remove());const u=a._getTimelineCellByDate(o),[h,g]=a.rightToLeft?["right","left"]:["left","right"];m||(m=document.createElement("div"),m.classList.add("smart-gantt-chart-task-deadline"),m.setAttribute("task-index",t),l.appendChild(m)),m.setAttribute("date",o.toString()),m.setAttribute("title",a._formatDate(o)),m.style.top=e.top+"px",m.style[g]="",m.style[h]=u.left+(a._getTimelineTaskOffset(u,o)||0)+"px"}_setTaskBarDeadline(e,t){const i=this,a=e.deadline;if(!a||!a.getTime||isNaN(a)||!t)return;const n=e.deadline.getTime()-e.dateEnd.getTime();if(!e.deadline||n>0)return t.removeAttribute("deadline"),void(e.overdue=!1);e.overdue=!0,t.setAttribute("deadline",`${i.localize("overdue")}: ${Math.round(i._convertDuration(Math.abs(n),!0))} ${i.durationUnit+"s"}`)}_setTaskIndicators(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,[o,l]=a.rightToLeft?["right","left"]:["left","right"],d=a.$.taskIndicatorsContainer,c=d.children,m=n.indicators;let u;for(let e=0,i=c.length;e<i;e+=1){const i=c[e];if(parseInt(i.getAttribute("task-index"))===t){u=i;break}}if(!Array.isArray(m))return void(u&&u.remove());const h=document.createDocumentFragment(),g=document.createDocumentFragment();u||(u=document.createElement("div"),u.classList.add("smart-gantt-chart-indicator"),u.setAttribute("task-index",t),h.appendChild(u));const f=u.children;for(;f.childElementCount>m.length;)f.firstElementChild.remove();for(let t=0,i=m.length;t<i;t+=1){let i=f[t];const n=m[t],d=n.date;if(!d||!d.getTime){i&&i.remove();continue}const c=d.getTime();if(c<s||c>r){i&&i.remove();continue}const u=a._getTimelineCellByDate(d),h=n.label,p=n.className,_=n.icon;i||(i=document.createElement("div"),g.appendChild(i)),i.className="smart-gantt-chart-task-indicator",i._indicatorObj=n;const T=i.classList;"string"==typeof p&&T.add(p),_?(T.add("icon"),i.style.setProperty("--smart-gantt-chart-indicator-icon",`'${_}'`)):T.contains("icon")&&(T.remove("icon"),i.style.removeProperty("--smart-gantt-chart-indicator-icon")),i.textContent=h||"",i.style.top=e.top+"px",i.style[l]="",i.style[o]=u.left+(a._getTimelineTaskOffset(u,d)||0)+"px"}g.childElementCount&&u.appendChild(g),h.childElementCount&&d.appendChild(h)}_setTimelineTaskBar(e,t,i){const a=this,n=e.task,s=void 0===t?a._getTaskDOMIndex(n):t,r=a.$.timelineTasksContainer.children,o=r[s];let l,d;if(0===r.length||!o||!o.classList||!o.classList.contains("smart-timeline-task"))return;const c=n.dateStart instanceof Date?n.dateStart:new Date(n.dateStart),m=n.dateEnd instanceof Date?n.dateEnd:new Date(n.dateEnd);if(l=!i&&o._cellStart||a._getTimelineCellByDate(c),d=!i&&o._cellEnd||a._getTimelineCellByDate(m),!l||!d)return void o.classList.add("smart-visibility-hidden");o._cellStart=l,o._cellEnd=d,o.classList.remove("smart-visibility-hidden");const u=a._getTaskBarDetails(e,l,d);u&&(o.style[a.rightToLeft?"left":"right"]="",o.style[a.rightToLeft?"right":"left"]=u.left+"px",o.style.width=u.width?u.width+"px":"",o.style.top=u.top+"px"),a._setTaskBarSegments(e,o,i)}_setTimelineTaskBaseline(e,t){const i=this,a=e.task,n=i.$.timelineBaselinesContainer;if(!i.showBaseline)return void(n.innerHTML&&(n.innerHTML=""));const s=a.planned,r=n.children;let o;for(let e=0,i=r.length;e<i;e+=1){const i=r[e];if(parseInt(i.getAttribute("task-index"))===t){o=i;break}}if(!s||"milestone"===a.type||!s.dateStart||!s.dateEnd)return void(o&&o.remove());const l=s.dateStart,d=s.dateEnd,c=i._getTimelineCellByDate(l),m=i._getTimelineCellByDate(d);if(!c||!m)return;o||(o=document.createElement("div"),o.classList.add("smart-gantt-chart-task-baseline"),o.setAttribute("task-index",t),n.appendChild(o));const[u,h]=i.rightToLeft?["right","left"]:["left","right"];(e=JSON.parse(JSON.stringify(e))).dateStart=l,e.dateEnd=d,e.task.dateStart=l,e.task.dateEnd=d;const g=i._getTaskBarDetails(e,c,m);if(g){const e=o.style;e.width=g.width?g.width+"px":"",e.top=g.top+"px",e[u]=g.left+"px",e[h]=""}o.setAttribute("aria-label",a.label+" Start date: "+i._toISODate(l)+", End date: "+i._toISODate(d))}_setTaskBarSegments(e,t,i){const a=this,n=e.task,s=t.querySelector(".smart-task-segments").children;let r,o,l=n.segments;if(Array.isArray(l)&&l&&l.length&&"task"===n.type||(l=[n]),1===l.length){const e=s[0].style;return void(e.right=e.left=e.width="")}const d=a.rightToLeft,c=parseFloat(t.style[d?"right":"left"]);let m;for(let e=0,t=l.length;e<t;e+=1){const t=l[e],n=s[e];if(!n)continue;const u=t.dateStart instanceof Date?t.dateStart:new Date(t.dateStart),h=t.dateEnd instanceof Date?t.dateEnd:new Date(t.dateEnd);r=!i&&n._cellStart||a._getTimelineCellByDate(u),o=!i&&n._cellEnd||a._getTimelineCellByDate(h),n._cellStart=r,n._cellEnd=o;const g=a._getTaskBarDetails({task:t},r,o);g&&(n.style[d?"left":"right"]="",n.style[d?"right":"left"]=Math.max(0,g.left-c)+"px",n.style.width=g.width+"px"),m=n}a._setTaskBarDeadline(n,m)}_setCurrentTimeIndicators(){const e=this;if(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval,e.currentTimeIndicator||e.shadeUntilCurrentTime)e._refreshTimeIndicators(),e._currentTimeIndicatorInterval=setInterval(e._refreshTimeIndicators.bind(e),1e3*e.currentTimeIndicatorInterval);else{const t=e.$.timelineIndicatorsContainer;t&&t.remove()}}_refreshTimeIndicators(){const e=this,t=e.currentTime,i=e.view,a=e._getTodayCellObj(t);let n=e.$.timelineIndicatorsContainer;if(!a)return n&&n.remove(),clearInterval(e._currentTimeIndicatorInterval),void delete e._currentTimeIndicatorInterval;n||(e.$.timelineIndicatorsContainer=n=document.createElement("div"),n.classList.add("smart-gantt-chart-time-indicators-container"),n.setAttribute("role","presentation")),new Date(a.date);let s,r,o=t.getMinutes();switch(i){case"quarter":case"year":{const e=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0,0);e.setDate(0),o+=24*t.getDate()*60,s=24*e.getDate()*60;break}case"month":o+=24*(t.getDay()+1)*60,s=10080;break;case"week":o+=60*t.getHours(),s=1440;break;case"day":s=60}r={cellObj:a,minutes:o,max:s,today:t},e._refreshCurrentTimeShader(r),e._refreshCurrentTimeIndicator(r),n.childElementCount||(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval),n.parentElement||e.$.timelineContent.appendChild(n)}_refreshCurrentTimeIndicator(e){const t=this,i=t.$.timelineIndicatorsContainer;let a=i.querySelector(".smart-gantt-chart-current-time-indicator");if(!t.currentTimeIndicator||!e)return void(a&&a.remove());const{cellObj:n,minutes:s,max:r}=e;a||(a=document.createElement("div"),a.classList.add("smart-gantt-chart-current-time-indicator")),t.rightToLeft?a.style.right=n.left+n.width*(s/r)+"px":a.style.left=n.left+n.width*(s/r)+"px",a.setAttribute("aria-label","Current Time Indicator"),a.parentElement||i.appendChild(a),t._setTodayCell(n.date)}_refreshCurrentTimeShader(e){const t=this.$.timelineIndicatorsContainer;let i=t.querySelector(".smart-gantt-chart-current-time-shader");if(!this.shadeUntilCurrentTime||!e)return void(i&&i.remove());const{cellObj:a,minutes:n,max:s}=e;i||(i=document.createElement("div"),i.classList.add("smart-gantt-chart-current-time-shader")),i.style.width=a.left+a.width*(n/s)+"px",i.setAttribute("aria-label","Current Time Shader"),i.parentElement||t.appendChild(i)}_setTodayCell(e){const t=this;if(e)e instanceof Date&&(e=e.getTime());else{let i=0;e=t.currentTime,"day"===t.view&&(i=e.getHours()),e.setHours(i,0,0,0),e=e.getTime()}if("number"!=typeof e)return;const i=t.$.timelineViewCells.children;for(let t=0;t<i.length;t++){const a=i[t],n=new Date(a._date);n&&(n.getTime()===e?a.setAttribute("current",""):a.removeAttribute("current"))}}_getTodayCellObj(e){const t=this,i=t.view,a=t._timelineCells;e&&e.getTime||(e=t.currentTime);for(let t=0,n=a.length;t<n;t+=1){const n=a[t],s=n.date;switch(i){case"quarter":case"year":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth())return n;break;case"month":{const t=new Date(e);if(t.setDate(e.getDate()-e.getDay()),e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&t.getDate()===s.getDate())return n;break}case"week":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate())return n;break;case"day":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()&&s.getHours()===e.getHours())return n}}}_getTaskDOMIndex(e){const t=this.$.timelineTasksContainer.children;if(!e||void 0===e.$.id)return-1;for(let i=0,a=t.length;i<a;i+=1)if(t[i]._cellObj.task===e)return i;return-1}_getTimelineCellByDate(e,t,i){const a=this,n=a._timelineCells;if(!n||0===n.length)return;const s=n.length-1;i=Math.min(s,"number"==typeof i?i:s);for(let s=t=Math.min(i,Math.max(0,"number"==typeof t?t:0));s<=i;s++){const t=n[s];if(!t)continue;const i=t.date;switch(a.view){case"quarter":case"year":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth())return t;break;case"month":if("day"===a.monthScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t}else{const a=new Date(i);let n=new Date(i);if(n.setDate(n.getDate()+(6-n.getDay())+1),n.setMilliseconds(n.getMilliseconds()-1),e.getTime()>=a.getTime()&&e.getTime()<=n.getTime())return t}break;case"week":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t;break;case"day":if("hour"!==a.dayScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours()&&i.getMinutes()<=e.getMinutes())return t}else if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours())return t}}const r=n[0],o=n[n.length-1];return e.getTime()<r.date.getTime()?r:e.getTime()>o.date.getTime()?o:void 0}_refreshViewDetailCell(e,t,i){const a=this,n=a._timelineCells,s=e.date;let r=0,o=0===i?0:void 0;for(void 0===t&&(t=0);t<n.length;t++){const e=n[t],i=a._getCellWidth(e,s);if(i){if("month"===a.view&&"day"===a.monthScale&&s.getMonth()!==e.date.getMonth())break;void 0===o&&(o=e.left+e.width-i),r+=i}else if(e.date.getTime()>s.getTime())break}return a._isLastWeekCellNotFull&&(delete a._isLastWeekCellNotFull,t--),e.width=r,e.left=o,t}_getCellWidth(e,t){const i=this,a=e.date,n=(e,t)=>e.getFullYear()===t.getFullYear(),s=(e,t)=>e.getMonth()===t.getMonth(),r=e.width;switch(i.view){case"month":{if("day"===i.monthScale)return r;let e=new Date(a),o=new Date(e),l=0;for(o.setDate(o.getDate()+(6-e.getDay())+1),o.setMilliseconds(o.getMilliseconds()-1);e.getTime()<=o.getTime();)n(e,t)&&s(e,t)&&l++,e.setDate(e.getDate()+1);if(0===l)return;"day"!==i.monthScale&&(i._isLastWeekCellNotFull=l/7!=1);let d=r*l/7;return d<70?70:d}case"quarter":case"year":if(n(a,t))return r;break;case"week":{const e=new Date(t),n=new Date(t);if(-1!==i.firstDayOfWeek){const t=e.getDay()-i.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+i.firstDayOfWeek-(t>=0?0:7)),n.setDate(e.getDate()+6)}else e.setDate(t.getDate()-t.getDay()),n.setDate(t.getDate()+(6-t.getDay()));if(a.getTime()>=e.getTime()&&a.getTime()<=n.getTime())return r;break}case"day":if(n(a,t)&&s(a,t)&&a.getDate()===t.getDate())return r}}_getCellByOffsetLeft(e){const t=this._timelineCells;if(!e)return;let i;for(let a=0;a<t.length&&!(t[a].left>=e);a++)i=t[a];return i}_unselectAll(e,t){const i=this,a=i.$[`${e}TimelineCellsContainer`];let n;delete i._selected;const s=a.querySelectorAll(".smart-timeline-row[selected]");for(let e=0;e<s.length;e++)s[e].removeAttribute("selected");if("task"===e){n="selectedTaskIds";const e=i.$.timelineTasksContainer.querySelectorAll(".smart-timeline-task[selected]");for(let t=0;t<e.length;t++)e[t].removeAttribute("selected"),e[t].setAttribute("aria-selected","false")}else n="selectedResourceIds";if(i[`_${e}TreeChangeEventFired`]||i.$[e+"Table"].clearSelection(),i._highlightAssignedItem(e),t)return;const r=i[n].slice(0);r.length&&(i[n]=[],i._noChangeEvent||i.$.fireEvent("change",{value:[],oldValue:r,type:e}))}_getSegmentCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-task-segment"))return;const i=e.closest(".smart-timeline-task");if(!i)return;let a,n,s=i._cellStart,r=i._cellEnd;s&&r||({cellStart:s,cellEnd:r}=t._getTaskBarCellRange(i));const o=t.rightToLeft,l=parseFloat(e.style.width)||e.offsetWidth,d=t._timelineCells;let c=parseFloat(i.style[o?"right":"left"]);c&&!isNaN(c)||(c=i.offsetLeft,o&&(c=t.$.timelineContent.offsetWidth-c));const m=c+parseFloat(e.style[o?"right":"left"])||(o?(parseFloat(i.style.width)||i.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft),u=parseFloat((m+l).toFixed(2));for(let e=d.indexOf(s),t=d.indexOf(r);e<=t;e++){const t=d[e],i=t.left,s=t.width,r=parseFloat((i+s).toFixed(2));if(m>=i&&m<=r&&(a=t),!n&&u>i&&u<=r&&(n=t),a&&n)break}return a||(a=n||d[0]),n||(n=d[d.length-1]),{cellStart:a,cellEnd:n}}_getTaskBarCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-timeline-task"))return;let i=parseFloat(e.style.width)||e.offsetWidth;const a=t._timelineCells,n=t.$.timelineContent,s=parseFloat(e.style[t.rightToLeft?"right":"left"])||(t.rightToLeft?(parseFloat(n.style.width)||n.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft);let r,o;e.classList.contains("milestone")&&(i/=2);const l=parseFloat((s+i).toFixed(2));for(let e=0;e<a.length;e++){const t=a[e],i=t.left,n=t.width,d=parseFloat((i+n).toFixed(2));if(s>=i&&s<=d&&(r=t),!o&&l>i&&l<=d&&(o=t),r&&o)break}return r||(r=e.classList.contains("milestone")&&o?o:a[0]),o||(o=a[a.length-1]),{cellStart:r,cellEnd:o}}_getDateFromCell(e,t,i){if(!t)return new Date;const a=this,n=new Date(t.date);let s,r=0,o=0,l=new Date(n);switch(l.setHours(0,0,0,0),i||(i=a.view),i){case"quarter":case"year":s=new Date(n.getFullYear(),n.getMonth()+1,0).getDate(),r=1,l.setDate(s);break;case"month":"day"===a.monthScale?(r=n.getDate(),s=1):(r=n.getDate(),s=7,l.setDate(l.getDate()+6));break;case"week":s=1,r=n.getDate();break;case"day":s=1/24,r=n.getDate(),o=n.getHours()}l.setHours(23,59,59,999);const d=parseFloat(((e-t.left)/t.width*s).toFixed(12)),c=Math.min(s,Math.floor(d)),m=d%1*24,u=Math.floor(m),h=60*Math.abs(m-u),g=Math.floor(h),f=60*Math.abs(h-g),p=Math.floor(f),_=1e3*Math.abs(f-p),T=Math.floor(_),b=new Date(n.getFullYear(),n.getMonth(),r+c,o+u,g,p,T);return b.getTime()>l?l:b}_getCellDateRange(e){if(!e||!e._date)return;const t=new Date(e._date);let i=new Date(t);switch(i.setHours(0,0,0,0),this.view){case"quarter":case"year":i.setDate(1),i.setMonth(i.getMonth()+1),i.setDate(0);break;case"month":i.setDate(i.getDate()+6);break;case"day":return i.setHours(t.getHours(),59,59,999),{dateStart:t,dateEnd:i}}return i.setHours(23,59,59,999),{dateStart:t,dateEnd:i}}_getTasksJSON(){const e=this;let t=e._tasks;return function t(i,a){if(!i)return;let n=[];for(let s=0;s<i.length;s++){const r=i[s];let o;if(!r.$.project&&!a||r.$.project===a){const i=e._getTaskConnections(r).taskConnections;o=e._cloneObject(r,!0),i.length&&(o.connections=i.map((e=>{const t={target:e.endIndex,type:e.type};return e.lag&&(t.lag=e.lag),t}))),o.tasks=t(e._getProjectTasks(r),r),delete o.$,n.push(o)}}return n}(t)}_cloneObject(e,t){let i={};for(let a in e){let n=e[a];"tasks"!==a&&("connections"!==a?n instanceof Date?i[a]=t?n.toISOString():new Date(n):i[a]=n:i[a]=JSON.parse(JSON.stringify(n)))}return t||delete i.$,i}_setTable(e){const t=this;e||(e=t.$.taskTable);const[i,a]=e===t.$.taskTable?[t.taskColumns,"task"]:[t.resourceColumns,"resource"];if(!t.contains(e))return;if(!i.length)return void(t.$[a+"Table"].dataSource=[]);const n=t._getTableColumns(a);"task"===a&&(e.filterRow=t.filterRow,[e.grouping,e.groupFormatFunction]=t.groupByResources?[!0,t._formatResourceGroups.bind(t)]:[!1,null]),e.isRendered&&e.resetState("expanded"),e.style.setProperty("--smart-table-row-height",""),e.columns=n,e.dataSource=t._getTableDataSource(a,n),e.wait&&(t.$.taskTable.hasResizeObserver=!1,e.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,e.$.virtualizationContainer.verticalScrollBarVisibility="hidden",e.$.virtualizationContainer.disabled=!0,e.columnMinWidth=t.columnMinWidth,e.columnResize=t.columnResize,e.columnResizeFeedback=t.columnResizeFeedback,e.filtering=t[`${a}Filtering`],e.sort=t.sortFunction,e.sortMode=t.sortMode,e.keyboardNavigation=t.keyboardNavigation,e.selectionByHierarchy=!1,e.selection=!t.disableSelection,e.hideSelectionColumn=!t.showSelectionColumn,e.selectionMode=t.selectionMode,e.onKeyboardScroll=(i,a)=>{const n=e===t.$.taskTable?t:t._resourceScrollView;a!==n.scrollTop&&(n.scrollTop=a)},e.wait=!1),e.$.virtualizationContainer.scrollTop="task"===a?t.scrollTop:t.$.resourceVerticalScrollBar.value,t._refresh()}_formatResourceGroups(e){const t=this,i=t._resources,a=e.data.data.resources.split(",");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}t.resourceGroupFormatFunction?e.template=t.resourceGroupFormatFunction(a):e.template="<strong>"+(n.length?n.join(", "):t.localize("unassigned"))+"</strong>"}_formatResourceGroupLabel(e){const t=this,i=t._resources,a=e.split(",");if(!e)return t.localize("unassigned");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}return n.length?n.join(", "):t.localize("unassigned")}_getTableColumns(e="task"){const t=this,i=["dateStart","dateEnd","minDateStart","maxDateStart","minDateEnd","maxDateEnd"],a=["progress","capacity","workload","maxCapacity","minCapacity"];let n="task"===e?t.taskColumns:t.resourceColumns,s=[];"task"===e&&t.groupByResources&&!n.find((e=>"resources"===e.value))&&(n=n.slice(0),n.push({label:"",value:"resources",hidden:!0}));for(let r=0,o=n.length;r<o;r++){const o=n[r],l=o.value,d={};d.label=t.localize(o.label)||o.label,d.dataField=l,l.startsWith("date")||i.indexOf(l)>-1?d.dataType="date":d.dataType="overdue"===l?"boolean":l.startsWith("duration")||a.indexOf(l)>-1?"number":"string",o.hidden&&(d.visible=!1),"function"==typeof o.formatFunction?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=i.column.toLowerCase();let s=i.value;n.indexOf("date")>-1?s=new Date(s):"resources"===n&&(s=s?s.split(","):[]),i.template=o.formatFunction.call(t,s,a?t._cloneObject(a):void 0)}:["date","number"].indexOf(d.dataType)>-1?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=t._formatColumnData(t._cloneObject(a),o);i.template=n}:"overdue"===l&&(d.formatFunction=e=>{const t=e.cell;e.value+""=="true"?t.setAttribute("overdue",""):t.removeAttribute("overdue"),e.value=""},d.width=t._taskDefaultHeight),o.size&&(d.width=o.size),s.push(d)}return s}_getTableDataSource(e="task",t){const i=this,a="task"===e?i._getTableData(i._tasks,i.taskColumns,e):i._getTableData(i._resources,i.resourceColumns,e),n=i.groupByResources,s=(()=>{let e=[];e.push("itemId: string"),e.push("projectId: string"),e.push("itemIndex: number"),n&&e.push("resources: string");for(let i=0,a=t.length;i<a;i+=1){const a=t[i];e.push(`${a.dataField}: ${a.dataType}`)}return e})();return i.groupByResources?new window.Smart.DataAdapter({dataFields:s,dataSource:a,groupBy:["resources"],id:"itemId"}):new window.Smart.DataAdapter({dataFields:s,dataSource:a,keyDataField:"itemId",parentDataField:"projectId",id:"itemId"})}_refreshTableDataSource(e="task"){const t=this,i="task"===e?t.$.taskTable:t.$.resourceTable;t.contains(i)&&(i.resetState("expanded"),i.dataSource=t._getTableDataSource(e,t._getTableColumns(e)))}_refreshColumnsHeaders(e){const t=this;e||(e="task");const i=t.$[`${e}Table`].columns,a=t[`${e}Columns`];for(let e=0,n=i.length;e<n;e++)i[e].label=t.localize(a[e].label)||a[e].label;!arguments.length&&t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshColumnsHeaders("resource")}_getTaskResourceIds(e){const t=e.resources,i=this._resources.map((e=>e.id));let a=[];if(Array.isArray(t))for(let e=0,n=t.length;e<n;e+=1){const n=t[e].id||t[e];i.indexOf(n)>-1&&a.push(n)}return a.sort()}_getTableData(e,t,i){const a=this,n=a.groupByResources;i||(i="task");const s=t.map((e=>e.value));let r=[],o=[];for(let l=0,d=e.length;l<d;l+=1){const d=e[l];if(d.hidden||n&&d.disableResources)continue;const c={},m=d.$.project,u=a._getTaskResourceIds(d);for(let e=0,n=s.length;e<n;e+=1)c[s[e]]=a._formatColumnData(d,t[e],i);c.expanded=n||d.expanded,c.itemId=d.$.id||d.id||"",c.itemIndex=l,u&&u.length?c.resources=u.toString():delete c.resources,d.$&&m&&(m.$.id?c.projectId=d.$.project.$.id:o.push(((e,t)=>{e.projectId=t.$.id}).bind(null,d,m))),r.push(c)}for(let e=0,t=o.length;e<t;e+=1)o[e]();return r}_formatColumnData(e,t){const i=this,a=t.value;let n=e[a];if(a){const e=(a+"").toLowerCase();if(e.indexOf("date")>-1||t.dateFormat)return i._formatDate(n,t);if(e.indexOf("duration")>-1||t.numberFormat){const e=parseFloat(n.toFixed(1));return t.numberFormat?i._formatNumber(e,t.numberFormat):e}}return null!=n?n.toString():i.localize("unassigned")}_formatDate(e,t){const i=this;if(e=Date.parse(e),!isNaN(e)){let a=t?t.dateFormat:void 0;if("string"==typeof a)return new Smart.Utilities.DateTime(new Date(e)).toString(a);if("object"==typeof a)a=t.dateFormat;else{const e=i.view;a={year:"numeric",month:"2-digit",day:"numeric"},["day","week"].indexOf(e)>-1&&(a.hour="numeric",a.minute="numeric",a.second="numeric")}return new Intl.DateTimeFormat(i.locale,a).format(new Date(e))}}_formatNumber(e,t,i){const a=this;if("object"==typeof t)return new Intl.NumberFormat(a.locale,t).format(""+e);i||(i={percentSymbol:"%",currencySymbol:"$",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","});const n=e=>"number"==typeof e&&isFinite(e);if(""===t||null===t)return e;let s;n(e)||(e*=1),t.length>1&&(s=parseInt(t.slice(1),10));let r={},o=t.charAt(0).toUpperCase();switch(r.thousandsSeparator=i.thousandsSeparator,r.decimalSeparator=i.decimalSeparator,o){case"D":case"d":case"F":case"f":r.decimalPlaces=s;break;case"N":case"n":r.decimalPlaces=0;break;case"C":case"c":r.decimalPlaces=s,"before"===i.currencySymbolPosition?r.prefix=i.currencySymbol:r.suffix=i.currencySymbol;break;case"P":case"p":r.suffix=i.percentSymbol,r.decimalPlaces=s;break;default:throw"Bad number format specifier: "+o}if(n(e)){const t=e<0;let i=e+"";const a=r.decimalSeparator?r.decimalSeparator:".";let s;if(n(r.decimalPlaces)){var l=r.decimalPlaces,d=Math.pow(10,l);if(i=(e*d).toFixed(0)/d+"",s=i.lastIndexOf("."),l>0)for(s<0?(i+=a,s=i.length-1):"."!==a&&(i=i.replace(".",a));i.length-1-s<l;)i+="0"}else{let t=e+"";s=t.lastIndexOf("."),s>0&&void 0===l&&"."!==a&&(t=t.replace(".",a))}if(r.thousandsSeparator){const e=r.thousandsSeparator;s=i.lastIndexOf(a),s=s>-1?s:i.length;let n=i.substring(s),o=-1;for(var c=s;c>0;c--)o++,o%3==0&&c!==s&&(!t||c>1)&&(n=e+n),n=i.charAt(c-1)+n;i=n}return i=r.prefix?r.prefix+i:i,i=r.suffix?i+r.suffix:i,i}return e}_validateDate(e,t){return e[t]=this._dateValidator(void 0,e[t]),e[t]&&!isNaN(e[t].getTime())||(e[t]=void 0),e[t]}_validateTaskProperties(e,t){const i=this;if(e.$={},e.tasks instanceof Array&&e.tasks.length>0?e.type="project":(!e.type||["project","task","milestone"].indexOf(e.type)<0)&&(e.type="task"),i._validateTaskDuration(e),void 0===e.hidden&&t&&(e.hidden=t.hidden),e.hidden=!!e.hidden,void 0===e.resources?e.resources=[]:e.resources=[e.resources].reduce(((e,t)=>e.concat(t)),[]),"project"===e.type?e.expanded=!!e.expanded:delete e.expanded,e.progress=Math.min(Math.max(0,parseFloat(e.progress)||0),100),i._validateTaskDates(e,t),i._validateTaskSegments(e),i._validateTaskIndicators(e),i._validateTaskPlannedDates(e),e.deadline){const t=i._validateDate(e,"deadline");!t||isNaN(t.getTime())?delete e.deadline:e.dateEnd&&(e.overdue=e.deadline.getTime()-e.dateEnd.getTime()<0)}else e.overdue=!1,delete e.deadline;if(!e.dateStart&&!e.dateEnd&&"project"===e.type&&!e.synchronized)return;const a=e.connections;if(a instanceof Array){for(let e=0;e<a.length;e++){const t=a[e],i=t.target="string"==typeof t.target?t.target:parseInt(t.target),n=t.type=parseInt(t.type);null==i||"number"==typeof i&&isNaN(i)||isNaN(n)?(a.splice(a.indexOf(t),1),e--):t.lag=parseInt(t.lag)||0}e.connections=e.connections.map((e=>Object.assign({},e)))}else e.connections=[];return e.class=e.class?e.class+"":"",e.class=void 0!==e.class&&null!==e.class?e.class:"",e}_validateTaskIndicators(e){const t=this,i=e.indicators;if(!i||!Array.isArray(i)||!i.length)return void delete e.indicators;let a=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if("object"!=typeof n)continue;const s=t._validateDate(n,"date");s&&s.getTime&&!isNaN(s.getTime())&&a.push(n)}e.indicators=a}_validateTaskSegments(e){const t=this,i=e.segments;if(!i||!Array.isArray(i)||i.length<2||"task"!==e.type)return void delete e.segments;const a=t.nonworkingDays.length>0||t.nonworkingHours.length>0;let n,s=[],r=[];for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("object"!=typeof a)continue;let n=parseFloat(a.duration);isNaN(n)&&delete a.duration,t._validateTaskDates(a),a.dateStart&&a.dateEnd&&s.push(a)}s.sort(((e,t)=>e.dateStart.getTime()-t.dateStart.getTime()));for(let i=0,o=s.length;i<o;i+=1){const o=s[i];let l=o.dateStart,d=o.dateEnd;o.dateStart=l=new Date(Math.max(e.dateStart.getTime(),l.getTime())),o.dateEnd=d=new Date(Math.min(e.dateEnd.getTime(),d.getTime())),n&&n.dateEnd.getTime()>l.getTime()&&(o.dateStart=l=new Date(n.dateEnd.getTime()+1e3),l.getTime()>=d.getTime())||l.getTime()>d.getTime()||(o.duration=t._convertDuration(a?t._getWorkingTime(l,d):d.getTime()-l.getTime(),!0),n=o,r.push(o))}r.length<2?delete e.segments:(r[0].dateStart=new Date(e.dateStart),r[r.length-1].dateEnd=new Date(e.dateEnd),e.segments=r)}_validateTaskDuration(e){const t=this;let i=t._convertDuration(parseFloat(e.duration))||0,a=t._convertDuration(parseFloat(e.minDuration))||0,n=t._convertDuration(parseFloat(e.maxDuration))||0;a&&n&&(n=Math.max(a,n)),i&&(a?i=Math.max(a,i):n&&(i=Math.min(i,n))),e.duration=t._convertDuration(i,!0),e.minDuration=t._convertDuration(a,!0),e.maxDuration=t._convertDuration(n,!0)}_validateTaskDates(e,t){const i=this,a=i._convertDuration(e.minDuration),n=i._convertDuration(e.maxDuration);let s=i._convertDuration(e.duration);if(void 0!==e.minDateStart&&(e.minDateStart=i._validateDate(e,"minDateStart")),void 0!==e.maxDateStart&&(e.maxDateStart=i._validateDate(e,"maxDateStart")),e.minDateStart&&e.maxDateStart&&(e.maxDateStart=new Date(Math.max(e.minDateStart.getTime(),e.maxDateStart.getTime()))),void 0!==e.minDateEnd&&(e.minDateEnd=i._validateDate(e,"minDateEnd")),void 0!==e.maxDateEnd&&(e.maxDateEnd=i._validateDate(e,"maxDateEnd")),e.minDateEnd&&e.maxDateEnd&&(e.maxDateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.maxDateEnd.getTime()))),e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart||(e.minDateStart?e.dateStart=e.minDateStart:e.maxDateStart?e.dateStart=e.maxDateStart:e.dateStart=i.dateStart),e.dateEnd||(e.minDateEnd?e.dateEnd=e.minDateEnd:e.maxDateEnd&&(e.dateEnd=e.maxDateEnd)),e.minDateStart&&(e.dateStart=new Date(Math.max(e.minDateStart.getTime(),e.dateStart.getTime()))),e.maxDateStart&&(e.dateStart=new Date(Math.min(e.maxDateStart.getTime(),e.dateStart.getTime()))),e.minDateEnd&&(e.dateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.dateEnd.getTime()))),e.maxDateEnd&&(e.dateEnd=new Date(Math.min(e.maxDateEnd.getTime(),e.dateEnd.getTime()))),e.dateStart&&(i.min&&(s=Math.min(e.dateStart.getTime()-i.min.getTime(),s),e.duration=i._convertDuration(s,!0)),i.max&&(s=Math.min(i.max.getTime()-e.dateStart.getTime(),s),e.duration=i._convertDuration(s,!0))),!e.dateStart&&s&&e.dateEnd&&(e.dateStart=new Date(e.dateEnd.getTime()-s)),"task"!==e.type||e.dateStart&&!isNaN(e.dateStart.getTime())||!t||(e.dateStart=new Date(t.dateStart)),a&&e.dateStart)if(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)){const t=i._getTaskWorkingDateEnd(e,a);e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,t.getTime()))}else e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,e.dateStart.getTime()+a));if(s&&e.dateStart&&(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?e.dateEnd=i._getTaskWorkingDateEnd(e,s):e.dateEnd=new Date(e.dateStart.getTime()+s)),s||n){let t;t=i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?i._getTaskWorkingDateEnd(e,Math.max(s,n)):new Date(e.dateStart.getTime()+Math.max(s,n)),e.dateEnd.getTime()>t.getTime()&&(e.dateEnd=t)}"task"===e.type&&!e.dateEnd&&t&&(e.dateEnd=new Date(t.dateEnd)),e.dateStart=i._minMaxDateValidator(e.dateStart),e.dateEnd=i._minMaxDateValidator(e.dateEnd),"milestone"===e.type&&(e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart=e.dateEnd=new Date(Math.max(e.dateStart?e.dateStart.getTime():0,e.dateEnd?e.dateEnd.getTime():0))),(e.dateStart||e.dateEnd||"project"!==e.type||e.synchronized)&&("milestone"!==e.type&&e.dateStart&&(e.dateEnd&&e.dateStart.getTime()>e.dateEnd.getTime()||!e.dateEnd)&&(e.dateEnd=new Date(e.dateStart.getTime()+36e5*("day"===i.view?1:24))),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}_validateTaskPlannedDates(e){const t=this;if(!e)return;const i=e.type,a=e.planned;if("milestone"===i||!a)return;const n=t._validateDate(a,"dateStart"),s=t._validateDate(a,"dateEnd");n&&s&&(a.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n,s):s.getTime()-n.getTime(),!0))}_synchronizeProjectDates(e,t){const i=this;if(e){void 0===t&&(t=i._getProjectTasks(e));for(let n=0,s=t.length;n<s;n+=1){const s=t[n];e.synchronized&&(s.dateStart&&(e.dateStart=a(s,"dateStart","min")),s.dateEnd&&(e.dateEnd=a(s,"dateEnd","max")),s.minDateStart&&(e.minDateStart=a(s,"minDateStart","max")),s.maxDateStart&&(e.maxDateStart=a(s,"maxDateStart","min")),s.minDateEnd&&(e.minDateEnd=a(s,"minDateEnd","max")),s.maxDateEnd&&(e.maxDateEnd=a(s,"maxDateEnd","min")),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}e.$&&i._synchronizeProjectDates(e.$.project,t)}function a(t,i,a){const n=e[i];let s=t[i];return void 0===n?new Date(s):s instanceof Date?new Date(Math[a](n.getTime(),s.getTime())):void 0}}_synchronizeProjectVisibility(e,t){const i=this;e&&e.hidden&&!t.hidden&&(e.hidden=t.hidden,e.$&&i._synchronizeProjectVisibility(e.$.project,e))}_mouseWheelHandler(e){const t=this,i=(t.shadowRoot||t).querySelector(".smart-task-popup-window");if(i&&i.modal&&i.opened)return void e.stopPropagation();if(t.disabled||!t.computedHorizontalScrollBarVisibility&&!t.computedVerticalScrollBarVisibility)return;if(e.shiftKey)return void t._handleHorizontalScroll(e);const a=t.$.resourceSplitterItem;t.$.mainSplitter.contains(a)&&a.contains(e.target)?t._handleVerticalScroll(e,!0):t.$.taskSplitterItem.contains(e.target)&&t._handleVerticalScroll(e)}_handleVerticalScroll(e,t){const i=this;let a,n,s,r;if(t){if(a=i.$.resourceVerticalScrollBar,a.classList.contains("smart-hidden")||a.disabled)return!0;n=a.value,s=a.max,r=i._resourceScrollView}else{if(!i.computedVerticalScrollBarVisibility||i.$.verticalScrollBar.disabled)return!0;n=i.scrollTop,s=i.scrollHeight,r=i}if(0===n&&e.deltaY<0||n===s&&e.deltaY>0)return void e.stopPropagation();const o=i.$[t?"resourceTable":"taskTable"];if(e.stopPropagation(),e.preventDefault(),n+=i._getScrollCoefficient(e,i.offsetHeight),r){const e=o.$.virtualizationContainer;e.scrollHeight!==r.scrollHeight&&(e.scrollHeight=r.scrollHeight),r.scrollTo(n,void 0)}o.scrollTop=n,i._hoveredItem&&i._handleTableItemHover()}_handleHorizontalScroll(e){const t=this;if(!t.computedHorizontalScrollBarVisibility)return!0;const i=t.scrollLeft;(0===i&&e.deltaX<0||i===t.scrollHeight&&e.deltaX>0)&&e.stopPropagation(),e.stopPropagation(),e.preventDefault(),t.scrollWidth>0&&t.scrollTo(void 0,t.scrollLeft+t._getScrollCoefficient(e,t.offsetWidth))}_handleHeaderTemplate(e="task"){const t=this;if(!("content"in document.createElement("template")))return void t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()}));const i=t.$[`${e}SplitterItemHeader`],a=t.$[`${e}SplitterItem`],n="task"===e?"headerTemplate":"resourcePanelHeaderTemplate";let s=t[n];if(a.removeAttribute("show-header"),i.innerHTML="",!s)return;if("function"==typeof s)return s(i,{}),void(i.innerHTML?a.setAttribute("show-header",""):a.removeAttribute("show-header"));if("string"==typeof s&&(s=document.getElementById(s)),null===s||!("content"in s))return void t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:n}));let r=document.importNode(s.content,!0);if(a.setAttribute("show-header",""),t.shadowRoot)return i.innerHTML="<slot></slot>",void t.appendChild(r);i.appendChild(r)}_handleCollapseExpandMethods(e,t){const i=this,a=i._tasks;if(null==e||!a||!a.length)return;const n=i._getValidItemAndIndex(e);if(!n||!n.item)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"collapse",argumentName:"task"}));let s=n.item;"project"!==s.type&&(s=s.$.project),s&&(s.hidden?s.expanded="expand"===t:i.$.taskTable["expand"===t?"expandRow":"collapseRow"](s.$.id))}_getValidItemAndIndex(e,t="task"){const i=this,a="task"===t?i._tasks:i._resources;let n;if(null==e||!a||!a.length)return{};if("string"==typeof e||"number"==typeof e){const t=e.toString();let i,s;for(let n=0,r=a.length;n<r;n+=1){const r=a[n];if(!i){const a=r.id;if(null!=a&&a.toString&&a.toString()===t){i=r,e=n;break}}r.$.id===t&&(s=r,e=n)}n=i||s}else"object"==typeof e&&(n=a[i._getItemIndex(e,t)],e=a.indexOf(n));return{item:n,index:e}}_horizontalScrollbarHandler(e){const t=this,i=t._getScrollLeft(e.detail.value);e.stopPropagation&&e.stopPropagation(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=i,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=i),t._recycle(e),e.context.min!==e.context.value?e.context.max===e.context.value&&(t._handleInfiniteTimeline(),t.$.fireEvent("scrollRightReached")):t.$.fireEvent("scrollLeftReached")}_verticalScrollbarHandler(e){const t=this,i=e.target,a=Math.round(e.detail.value);e.stopPropagation&&e.stopPropagation(),t._refreshing||(i&&i===t.$.resourceVerticalScrollBar?t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=a:(t.$.taskTimelineContainer.scrollTop=a,t.$.taskTable.scrollTop=a),t._recycle(e),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached"))}_handleInfiniteTimeline(){const e=this,t=e._timelineCells;if(!e.infiniteTimeline||!t||!t.length)return;const i=e.infiniteTimelineStep,a=t[t.length-1].date;switch(e.view){case"quarter":case"year":a.setMonth(a.getMonth()+i);break;case"month":a.setDate(a.getDate()+7*i);break;case"week":a.setDate(a.getDate()+i);break;case"day":a.setHours(a.getHours()+i)}e.set("dateEnd",a),e._createTimelineCells(),e._recycleTimelineTasks(!0),e.$.mainSplitter.contains(e.$.resourceSplitter)&&e._refreshResourceTimeline(),e._refresh()}_nonworkingDayValidator(e,t){return this._nonworkingDateTimeValidator(e,t)}_nonworkingTimeValidator(e,t){return this._nonworkingDateTimeValidator(e,t,!0)}_nonworkingDateTimeValidator(e,t,i){const a=this,[n,s,r]=i?[0,23,24]:[0,6,7];let o=[];function l(e){let t=Math.max(n,Math.min(s,parseInt(e[0]))),i=Math.max(n,Math.min(s,parseInt(e[1])));if(!isNaN(t)&&!isNaN(i)){for(;t!==i;)o.push(t),t=t===s?n:++t;o.push(t)}return o}for(let e=0;e<t.length;e++){const i=t[e];"number"!=typeof i||isNaN(i)?"string"==typeof i?o=l(i.split("-").map((e=>parseInt(e)))):Array.isArray(i)&&(o=l(i)):o.push(Math.max(n,Math.min(s,parseInt(i))))}return o.length===r&&(o.pop(),a.warn(a.localize("invalidNonworkingRange",{elementType:a.nodeName.toLowerCase(),property:i?"nonworkingHours":"nonworkingDays"}))),o}});
84
84
  Smart("smart-list-item",class extends Smart.ContentElement{static get properties(){return{alternationIndex:{value:-1,type:"int"},color:{value:"",type:"string"},displayMode:{allowedValues:["plain","checkBox","radioButton"],value:"plain",type:"string"},grouped:{value:!1,type:"boolean"},selected:{value:!1,type:"boolean"},value:{value:"",type:"string"},label:{value:"",type:"string"},details:{value:"",type:"string"},group:{value:"",type:"string"},hidden:{value:!1,type:"boolean"},readonly:{value:!1,type:"boolean"}}}get hasStyleObserver(){return!1}get enableShadowDOM(){return!1}get _focused(){const e=this;return void 0===e.__focused&&(e.__focused=!1),e.__focused}set _focused(e){const t=this;t.__focused=e,e?(t.setAttribute("focus",""),t.ownerListBox&&t.ownerListBox.ownerElement&&Smart.ComboBox&&t.ownerListBox.ownerElement instanceof Smart.ComboBox&&t.ownerListBox.ownerElement.$.input.setAttribute("aria-activedescendant",t.id)):t.removeAttribute("focus")}template(){return'<div id="container">\n <span id=\'itemInput\' class=\'smart-input smart-hidden\'></span>\n <span class="smart-overlay" id="overlay"></span>\n <div id="itemContainer" class="smart-content smart-list-item-container"><span class="smart-content-label" inner-h-t-m-l=\'[[innerHTML]]\' role="presentation"><content></content></span><span inner-h-t-m-l=\'[[details]]\' id="details" class="smart-content-details"></span></div>\n </div>'}appendChild(e){const t=this;if(!t.isCompleted||e.classList&&e.classList.contains("smart-ripple")){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}window.smartBlazor?t.$.itemContainer.appendChild(e):(t.$.itemContainer.innerHTML="",e instanceof HTMLElement&&t.$.itemContainer.appendChild(e))}insertBefore(e,t){const i=this;if(!i.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.insertBefore.apply(i,e.concat(Array.prototype.slice.call(arguments)))}t.parentNode.insertBefore(e,t)}removeChild(e){const t=this;if(!t.isCompleted||e.classList.contains("smart-ripple")){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.itemContainer.removeChild(e)}attached(){super.attached(),this.ownerListBox=this.getListBox()}static get listeners(){return{mouseenter:"_itemOnMouseEnter",mouseleave:"_itemOnMouseLeave"}}ready(){super.ready();const e=this;if(e.setAttribute("role","option"),""!==e.label){let t=e.label;t&&"string"==typeof t&&(t=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")),e.innerHTML=t}else""!==e.innerHTML&&(e.label=e.innerHTML);e._setDisplayMode(e.displayMode),e._setItemColor(),e.$.container.noRipple=!0;const t=e.closest("smart-list-box");if(t&&t.isRendered){if(cancelAnimationFrame(Smart.ListBox.processTimer),t._inLazyInit||t._isUpdating)return;Smart.ListBox.processTimer=requestAnimationFrame((()=>{t._lazyInitItems()}))}}propertyChangedHandler(e,t,i){const r=this;if(super.propertyChangedHandler(e,t,i),"hidden"===e)i?r.$.addClass("smart-hidden"):r.$.removeClass("smart-hidden");else if("color"===e)r._setItemColor();else if("displayMode"===e)r._setDisplayMode(i);else if("label"===e||"value"===e){const t=r.context;r.context=document,"label"===e&&(r.innerHTML=i);const o=r.getListBox();o&&(o._applyTemplate(r),o.onItemUpdated(r)),r.context=t}else if("details"===e){const e=r.context;r.context=document,r.$.details.innerHTML=i;const t=r.getListBox();t&&t.onItemUpdated(r),r.context=e}else if("innerHTML"===e){const e=r.getListBox();e&&e.onItemUpdated(r)}else if("selected"===e)if(i)r.setAttribute("aria-selected",!0);else{const e=r.getListBox();r.readonly||r.disabled||!e||-1===["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox"].indexOf(e.selectionMode)?r.removeAttribute("aria-selected"):r.setAttribute("aria-selected",!1)}}getListBox(){const e=this;if(!Smart.ListBox)return e.getRootNode().host;let t=e.parentNode;for(;t instanceof Smart.ListBox==0&&null!==t;)t=t.parentNode;return!t&&Smart.EnableShadowDOM?e.getRootNode().host:t}_itemOnMouseEnter(){const e=this;!e.disabled&&e.ownerListBox&&(Smart.ListBox.DragDrop.Dragging&&e.ownerListBox.allowDrop&&(Smart.ListBox.DragDrop.DropDetails={item:e,position:"bottom"}),e.ownerListBox.$.verticalScrollBar.thumbCapture||e.ownerListBox.$.horizontalScrollBar.thumbCapture||e.setAttribute("hover",""))}_itemOnMouseMove(e){const t=this;if(t.ownerListBox&&Smart.ListBox.DragDrop.Dragging&&t.ownerListBox.allowDrop&&!Smart.Utilities.Core.isMobile){const i=[].slice.call(t.ownerListBox.getElementsByClassName("smart-list-item-bottom-line-feedback"));for(let e=0;e<i.length;e++)i[e].$.removeClass("smart-list-item-line-feedback"),i[e].$.removeClass("smart-list-item-bottom-line-feedback");if(Smart.ListBox.DragDrop.DropDetails={item:t,position:"top"},!t.ownerListBox._areCSSVarsSupported){if(t.ownerListBox._indexOf(t)===t.ownerListBox._items.length-1||t.parentNode.lastElementChild===t){const i=t.getBoundingClientRect();e.pageY-window.pageYOffset>i.top+i.height/2-1&&(Smart.ListBox.DragDrop.DropDetails={item:t,position:"bottom"})}return}if(t.$.removeClass("smart-list-item-line-feedback"),t.$.removeClass("smart-list-item-bottom-line-feedback"),t.ownerListBox.sorted&&t.ownerListBox.autoSort)return;const r=t.ownerListBox._items.filter((e=>!e.hidden));if(r.indexOf(t)===r.length-1||t.parentNode.lastElementChild===t){const i=t.getBoundingClientRect();e.pageY-window.pageYOffset>i.top+i.height/2-1?(t.$.addClass("smart-list-item-bottom-line-feedback"),Smart.ListBox.DragDrop.DropDetails={item:t,position:"bottom"}):arguments[1]||t.$.addClass("smart-list-item-line-feedback")}else arguments[1]||t.$.addClass("smart-list-item-line-feedback")}}_itemOnMouseLeave(){const e=this;e.ownerListBox&&(Smart.ListBox.DragDrop.Dragging&&(e.$.removeClass("smart-list-item-line-feedback"),e.$.removeClass("smart-list-item-bottom-line-feedback")),e.removeAttribute("hover"))}_setDisplayMode(e){const t=this,i=t.getListBox();if(i){const r="checkBox"===i.selectionMode||"radioButton"===i.selectionMode?i.selectionMode:"plain";t.displayMode=e=r}"plain"!==e?t.$itemInput.removeClass("smart-hidden"):t.$itemInput.addClass("smart-hidden")}_setItemColor(){const e=this,t=e.querySelector(".smart-content-label"),i=/(^#[0-9A-F]{3}$)|(^#[0-9A-F]{6}$)|(^#[0-9A-F]{8}$)/i.test(e.color)?e.color:"";t.style.backgroundColor=i,t.style.color=e._getContrastColor(i)}_getContrastColor(e){if(!e)return"";let t=(i=e.slice(1,3),r=e.slice(3,5),o=e.slice(5,7),[parseInt(i,16),parseInt(r,16),parseInt(o,16)]);var i,r,o;return parseFloat(((.299*t[0]+.61*t[1]+.114*t[2])/255).toFixed(2))>.65?"#000000":"#FFFFFF"}}),Smart("smart-list-items-group",class extends Smart.ContentElement{static get properties(){return{label:{value:"",type:"string"}}}get enableShadowDOM(){return!1}template(){return'<div id="container" role="presentation">\n <span id="itemsLabel" class="smart-list-items-group-label">[[label]]</span>\n <div id="listItemsGroupContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-list-items-group-container" role="presentation">\n <content></content>\n </div>\n </div>'}appendChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.listItemsGroupContainer.appendChild(e)}removeChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.listItemsGroupContainer.removeChild(e)}getListBox(){let e=this.parentNode;for(;e instanceof Smart.ListBox==0&&null!==e;)e=e.parentNode;return e}attached(){const e=this;super.attached(),e.ownerListBox||(e.ownerListBox=e.getListBox()),e.setAttribute("role","group"),e.$.itemsLabel.id||(e.$.itemsLabel.id=e.id+"Label"),e.setAttribute("aria-labelledby",e.$.itemsLabel.id)}}),Smart("smart-list-box",class extends Smart.ScrollViewer{static get properties(){return{allowDrag:{value:!1,type:"boolean"},allowDrop:{value:!1,type:"boolean"},alternationStart:{value:0,type:"int"},alternationEnd:{value:0,type:"int"},alternationCount:{value:0,type:"int"},autoSort:{value:!0,type:"boolean"},dataSource:{value:null,type:"any?",reflectToAttribute:!1},dragFeedbackFormatFunction:{value:null,type:"function?"},dragOffset:{value:[10,10],type:"array"},displayLoadingIndicator:{value:!1,type:"boolean"},displayMember:{value:"",type:"string"},shadowDomMode:{allowedValues:["light","shadow"],value:"shadow",type:"string"},dropAction:{value:"move",type:"string",allowedValues:["copy","move","none"]},editable:{value:!1,type:"boolean"},filterable:{value:!1,type:"boolean"},filterCallback:{value:null,type:"function?"},filterMode:{value:"containsIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase","custom"],type:"string"},filterInputPlaceholder:{value:"",type:"string"},grouped:{value:!1,type:"boolean"},groupMember:{value:"",type:"string"},itemTemplate:{value:null,type:"any"},itemHeight:{value:null,type:"number?"},incrementalSearchDelay:{value:700,type:"number?"},incrementalSearchMode:{value:"startsWithIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string"},itemMeasureMode:{value:"auto",allowedValues:["auto","precise"],type:"string"},loadingIndicatorPlaceholder:{value:"Loading...",type:"string"},loadingIndicatorPosition:{value:"center",allowedValues:["bottom","center","top"],type:"string"},messages:{extend:!0,value:{en:{overridingProperties:'{{elementType}}: Overriding properties {{property1}} and {{property2}} applied. The "{{property1}}" property is used by default.',invalidIndex:'{{elementType}}: "{{method}}" method accepts an index of type number or an Array of numbers.',indexOutOfBound:'{{elementType}}: Out of bound index/indexes in "{{method}}" method.',invalidItem:'{{elementType}}: "{{method}}" method accepts an object or an array of objects as it\'s second parameter.',invalidSettings:'{{elementType}}: "{{method}}" method accepts a string or an object as it\'s second parameter.'}},type:"object"},name:{value:"",type:"string"},placeholder:{value:"No Items",type:"string"},selectedIndexes:{value:[],type:"array"},selectedValues:{value:[],type:"array"},selectionMode:{value:"oneOrManyExtended",allowedValues:["none","oneOrManyExtended","zeroOrMany","oneOrMany","zeroOrOne","zeroAndOne","one","checkBox","radioButton"],type:"string"},selectionChangeAction:{value:"release",allowedValues:["press","release"],type:"string"},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},topVisibleIndex:{value:-1,type:"int"},type:{value:"list",type:"string",defaultReflectToAttribute:!0,readonly:!0},valueMember:{value:"",type:"string"},virtualized:{value:!1,type:"boolean"}}}static get requires(){return{"Smart.ScrollBar":"smart.scrollbar.js"}}static get styleUrls(){return["smart.listbox.css","smart.dropdown.css","smart.scrollbar.css"]}static get listeners(){return{focus:"_focusHandler",blur:"_blurHandler","container.wheel":"_mouseWheelHandler","editInput.change":"_editInputEventHandler","editInput.blur":"_editInputEventHandler","editInput.keydown":"_editInputEventHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","itemsInnerContainer.down":"_downHandler","itemsInnerContainer.dblclick":"_dblclickEventHandler","itemsInnerContainer.move":"_itemsContainerMoveHandler","itemsContainer.mouseleave":"_mouseLeaveHandler","itemsInnerContainer.touchmove":"_touchmoveHandler","itemsInnerContainer.touchstart":"_touchstartHandler","document.move":"_moveHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",resize:"_resizeHandler",selectstart:"_selectStartHandler",styleChanged:"_styleChangedHandler",swipeleft:"_swipeLeftHandler",swiperight:"_swipeRightHandler",touchmove:"_overriddenHandler",touchstart:"_overriddenHandler","verticalScrollBar.change":"_verticalScrollbarHandler"}}template(){return'<div id="container" class="smart-container" role="presentation">\n <div class="smart-list-box-filter-input-container smart-hidden" id="filterInputContainer" role="presentation"><input id="filterInput" disabled="[[disabled]]" placeholder=\'[[filterInputPlaceholder]]\' role="searchbox" aria-label="[[filterInputPlaceholder]]"></div>\n <div id="itemsContainer" class="smart-list-items-container" role="presentation">\n <div id="placeholder" class="smart-placeholder" role="presentation" aria-hidden="true">[[placeholder]]</div>\n <div id="itemsInnerContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-list-items-inner-container" role="presentation">\n <content></content>\n </div>\n <input type="text" id="editInput" class= "smart-hidden"/>\n </div>\n <smart-scroll-bar wait theme="[[theme]]" right-to-left="[[rightToLeft]]" id="verticalScrollBar" disabled="[[disabled]]" orientation="vertical"></smart-scroll-bar>\n <smart-scroll-bar wait theme="[[theme]]" right-to-left="[[rightToLeft]]" id="horizontalScrollBar" disabled="[[disabled]]"></smart-scroll-bar>\n <div id="loadingIndicatorContainer" class="smart-loader-container" role="presentation">\n <span id="loadingIndicator" class="smart-loader" role="img" aria-label="[[loadingIndicatorPlaceholder]]"></span>\n <span id="loadingIndicatorPlaceHolder" class="smart-loader-label smart-hidden">[[loadingIndicatorPlaceholder]]</span>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>'}get value(){const e=this;return e.isRendered&&e._selectedItems.length>0?e._selectedItems.map((e=>({label:e.label,value:e.value}))):null}set value(e){const t=this;if(Array.isArray(e)){const i=t.context;t.context=t,t._isUpdating++,t.selectedValues=[],t.clearSelection();for(let i=0;i<e.length;i++){const r=e[i],o=t.getItem(r);o&&("oneOrManyExtended"===t.selectionMode?t._select(o):t.select(o))}return t.context=i,void t._isUpdating--}const i=t.getItem(e);i&&t.select(i)}get _selectedItems(){const e=this,t=[];if(e.isRendered)for(let i=0;i<e._items.length;i++){const r=e._items[i];r.selected&&t.push(r)}return t}_mouseLeaveHandler(){const e=[].slice.call(this.getElementsByClassName("smart-list-item-bottom-line-feedback"));for(let t=0;t<e.length;t++)e[t].$.removeClass("smart-list-item-line-feedback"),e[t].$.removeClass("smart-list-item-bottom-line-feedback")}_downHandler(e){const t=this;if(t.disabled||t.displayLoadingIndicator||t.readonly)return;let i=e.originalEvent.target,r=null;if(!(i instanceof Smart.ListItem)||i.disabled||i.hidden||i instanceof Smart.ListItemsGroup)for(;i.parentElement;){if(i instanceof Smart.ListItem&&!i.disabled&&!i.hidden&&!(i instanceof Smart.ListItemsGroup)){r=i.dataItem;break}i=i.parentElement}else r=i.dataItem;Smart.ListBox.DragDrop.StartTime=new Date,Smart.ListBox.DragDrop.StartPosition={left:e.pageX,top:e.pageY},r&&(e.stopPropagation(),t.hasRippleAnimation&&(r.readonly||r.disabled||Smart.Utilities.Animation.Ripple.animate(i.$.overlay,e.pageX,e.pageY)),Smart.Utilities.Core.isMobile||"press"!==t.selectionChangeAction||(t._focus(r),t.select(r)),!Smart.ListBox.DragDrop.Feedback&&t.allowDrag&&(Smart.ListBox.DragDrop.DraggedFrom=t,Smart.ListBox.DragDrop.Feedback=document.createElement("span"),t.rightToLeft?Smart.ListBox.DragDrop.Feedback.setAttribute("right-to-left",!0):Smart.ListBox.DragDrop.Feedback.removeAttribute("right-to-left"),t.dragFeedbackFormatFunction?Smart.ListBox.DragDrop.Feedback.innerHTML=t.dragFeedbackFormatFunction(r):Smart.ListBox.DragDrop.Feedback.appendChild(r.offsetHeight?r.cloneNode(!0):t._createItem(r)),Smart.ListBox.DragDrop.Item=r,Smart.Utilities.Extend(Smart.ListBox.DragDrop.Feedback).addClass("smart-popup smart-list-item smart-list-item-feedback")))}_dblclickEventHandler(e){const t=this;if(!t.editable)return;const i=e.target.closest("smart-list-item");i instanceof Smart.ListItem&&!i.disabled&&!i.readonly?(t.$.editInput.dir=t.rightToLeft?"rtl":"ltr",t.$.editInput.style.width=t.$.itemsInnerContainer.offsetWidth+"px",t.$.editInput.owner=i,t.$.editInput.value=i.label,t.$.editInput.style.height=i.offsetHeight+"px",t.$.editInput.style.top=i.offsetTop+t.$.itemsInnerContainer.offsetTop+"px",t.$.editInput.setAttribute("aria-label","Edit item "+i.label),t.$editInput.hasClass("smart-hidden")&&t.$editInput.removeClass("smart-hidden"),t.$.editInput.focus({preventScroll:!0})):t.$editInput.addClass("smart-hidden")}_editInputEventHandler(e){const t=this;if("blur"===e.type||"keydown"===e.type&&"Escape"===e.key)return t.$editInput.hasClass("smart-hidden")||t.$editInput.addClass("smart-hidden"),void t.focus();if("keydown"===e.type||t.$editInput.hasClass("smart-hidden"))return;const i=e.target;if(e.stopPropagation(),i.owner.label!==i.value&&(i.owner.label=i.value,t.itemTemplate&&t._applyTemplate(i.owner),t.dataSource)){const e=i.owner.dataIndex,r=t.dataSource[e];r&&(t.displayMember?r[t.displayMember]=i.value:r.label=i.value)}t.$editInput.addClass("smart-hidden"),t.$.fireEvent("itemLabelChange",{selected:i.owner.selected,disabled:i.owner.disabled,index:t._indexOf(i.owner),label:i.owner.label,value:i.owner.value})}_pointerUpHandler(e){const t=this;let i=e.originalEvent,r=i.target;(t.shadowRoot||t.isInShadowDOM)&&(r=i.originalEvent?i.originalEvent.composedPath()[0]:i.composedPath()[0]);const o=e=>{const i=e.ownerListBox;i.disabled||i!==t||i.displayLoadingIndicator||"none"===i.selectionMode||e.grouped||e.readonly||(i._focus(e),i.select(e),Smart.ListBox.DragDrop.StartPosition=null,t.$.fireEvent("itemClick",{selected:r.selected,disabled:r.disabled,index:t._indexOf(r),label:r.label,value:r.value}))};if(!(i.target instanceof Smart.ListItem)||i.target.disabled||i.target instanceof Smart.ListItemsGroup){for(;r&&r.parentElement;){if(r instanceof Smart.ListItem&&!r.disabled&&!(r instanceof Smart.ListItemsGroup))return void o(r.dataItem);r=r.parentElement}if(this.shadowRoot&&"shadow"===this.shadowDomMode){const e=i.composedPath();for(let t=0;t<e.length;t++){const i=e[t];i instanceof Smart.ListItem&&!i.disabled&&o(i.dataItem)}}}else o(r.dataItem)}_upHandler(e){const t=this;if(super._upHandler(),!t.disabled&&!t.readonly&&Smart.ListBox.DragDrop.StartPosition){if(Smart.Utilities.Core.isMobile&&!Smart.ListBox.DragDrop.Dragging){const i=Math.abs(e.pageX-Smart.ListBox.DragDrop.StartPosition.left),r=Math.abs(e.pageY-Smart.ListBox.DragDrop.StartPosition.top);let o=i>=0&&i<=3&&r>=0&&r<=3;if(Smart.Utilities.Core.isMobile&&new Date-Smart.ListBox.DragDrop.StartTime>=300&&(o=!1,Smart.ListBox.DragDrop.StartTime=null),o){const i=e.originalEvent.target.closest("smart-list-box");i?i._pointerUpHandler(e):t._pointerUpHandler(e),Smart.ListBox.DragDrop.StartPosition=null}else{let t=e.originalEvent.target;if(!(e.target instanceof Smart.ListItem)||t.readonly||e.target.disabled||e.target instanceof Smart.ListItemsGroup)for(;t.parentElement;){if(t instanceof Smart.ListItem&&!t.readonly&&!t.disabled&&!(t instanceof Smart.ListItemsGroup)){e.stopPropagation();break}t=t.parentElement}else e.stopPropagation()}}else if(!Smart.Utilities.Core.isMobile&&!Smart.ListBox.DragDrop.Dragging&&"release"===t.selectionChangeAction){const i=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-box");i&&(i.upTimer&&clearTimeout(i.upTimer),t.isInShadowDOM?i?i._pointerUpHandler(e):t._pointerUpHandler(e):i.upTimer=setTimeout((()=>{i?i._pointerUpHandler(e):t._pointerUpHandler(e)})))}if(Smart.ListBox.DragDrop.Feedback){let i;if(Smart.ListBox.DragDrop.Feedback.parentNode&&Smart.ListBox.DragDrop.Feedback.parentNode.removeChild(Smart.ListBox.DragDrop.Feedback),Smart.ListBox.DragDrop.Feedback=null,Smart.Utilities.Core.isMobile&&Smart.ListBox.DragDrop.Dragging)for(let t=0;t<Smart.ListBox.DragDrop.ListBoxes.length;t++){const r=Smart.ListBox.DragDrop.ListBoxes[t],o=r.getBoundingClientRect();if(r.allowDrop&&!r.closest(".smart-visibility-hidden")&&o.left<=e.clientX&&e.clientX<=o.left+o.width&&o.top<=e.clientY&&e.clientY<=o.top+o.height){i=r;const t=r._items.filter((e=>!e.hidden));for(let i=0;i<t.length;i++){const s=t[i],n=s.getBoundingClientRect();if((t.indexOf(s)===t.length-1||s.parentNode.lastElementChild===s)&&e.clientY>=o.top+s.offsetTop-r.scrollTop+n.height/2&&e.clientY<=o.top-r.scrollTop+s.offsetTop+n.height){Smart.ListBox.DragDrop.DropDetails={item:s,position:"bottom"};break}if(e.clientY>=o.top+s.offsetTop-r.scrollTop&&e.clientY<=o.top+s.offsetTop+n.height-r.scrollTop){Smart.ListBox.DragDrop.DropDetails={item:s,position:"top"};break}}}}if(Smart.ListBox.DragDrop.Dragging){if(Smart.ListBox.DragDrop.DropDetails){let r=Smart.ListBox.DragDrop.DropDetails.item,o=Smart.ListBox.DragDrop.Item;const s=o.ownerListBox;let n=e.originalEvent.target;if(t.isInShadowDOM&&(n=e.originalEvent?e.originalEvent.composedPath()[0]:e.composedPath()[0]),i=!i&&n.closest?n.closest("smart-list-box"):i,document.body.classList.remove("smart-dragging"),r.$.removeClass("smart-list-item-line-feedback"),r.$.removeClass("smart-list-item-bottom-line-feedback"),i&&r.ownerListBox!==i&&i.items.length>0&&(r=i.items[i.items.length-1]),Smart.ListBox.DragDrop.Item===r||i!==r.ownerListBox&&!Smart.Utilities.Core.isMobile)i&&0===i._items.length&&"none"!==i.dropAction&&("move"===i.dropAction?Smart.ListBox.DragDrop.Item.ownerListBox.removeChild(Smart.ListBox.DragDrop.Item):"copy"===i.dropAction&&(o=o.cloneNode(!0)),i.appendChild(o));else if("none"!==o.ownerListBox.dropAction){r.ownerListBox!==o.ownerListBox&&"move"===o.ownerListBox.dropAction&&Smart.ListBox.DragDrop.Item.ownerListBox.removeChild(Smart.ListBox.DragDrop.Item),"copy"===o.ownerListBox.dropAction&&(o=o.cloneNode(!0)),Smart.ListBox.DragDrop.Item.group=r.group;const e=r.ownerListBox;"checkBox"!==e.selectionMode&&"radioButton"!==e.selectionMode&&e.clearSelection(),"top"===Smart.ListBox.DragDrop.DropDetails.position?e.insertBefore(o,r):r.parentNode.lastElementChild===r?e.appendChild(o):e.appendChild(o,r),e.ensureVisible(o),"checkBox"===e.selectionMode||"radioButton"===e.selectionMode?(e._focus(o),e._refreshSelection()):(e.clearSelection(),e.select(o))}o.selected&&i!==s&&s._refreshSelection();const l=Smart.ListBox.DragDrop.Item,a=l.ownerListBox;l.displayMode="checkBox"===a.selectionMode||"radioButton"===a.selectionMode?a.selectionMode:"plain",a.$.fireEvent("dragEnd",{item:l,target:r,data:Smart.ListBox.DragDrop,previousContainer:s,container:i,originalEvent:e}),a._focus(l)}else{const t=Smart.ListBox.DragDrop.Item,i=t.ownerListBox;t.displayMode="checkBox"===i.selectionMode||"radioButton"===i.selectionMode?i.selectionMode:"plain",document.body.classList.remove("smart-dragging"),i.$.fireEvent("dragEnd",{item:t,target:null,data:Smart.ListBox.DragDrop,previousContainer:i,container:i,originalEvent:e}),i._focus(t)}e.preventDefault()}delete Smart.ListBox.DragDrop.DraggedFrom,Smart.ListBox.DragDrop.Dragging=!1,Smart.ListBox.DragDrop.Item=null,Smart.ListBox.DragDrop.DropDetails=null}for(let e=0;e<Smart.ListBox.DragDrop.ListBoxes.length;e++){const t=Smart.ListBox.DragDrop.ListBoxes[e];t._dragInterval&&clearInterval(t._dragInterval)}}}_itemsContainerMoveHandler(e){const t=this;if(Smart.ListBox.DragDrop.Dragging)return t._applyItemFeedback(e),t._moveHandler(e),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),!1}_touchmoveHandler(e){if(Smart.ListBox.DragDrop.Dragging&&e.cancelable)return e.preventDefault(),void e.stopPropagation();super._touchmoveHandler(e)}_applyItemFeedback(e){const t=this,i=e.originalEvent.target,r=i.closest?i.closest("smart-list-item"):i;Smart.Utilities.Core.isMobile?Smart.ListBox.DragDrop.DropDetails={item:Smart.ListBox.DragDrop.Item,position:"bottom"}:0!==t.items.length&&(r?r._itemOnMouseMove(e):t.items[t.items.length-1]._itemOnMouseMove(e,!0))}_moveHandler(e){const t=this;if(!Smart.ListBox.DragDrop.Feedback||Smart.ListBox.DragDrop.DraggedFrom!==t)return;const i=t.dragOffset;if(Smart.ListBox.DragDrop.Dragging){Smart.ListBox.DragDrop.Feedback.style.left=i[0]+e.pageX+"px",Smart.ListBox.DragDrop.Feedback.style.top=i[1]+e.pageY+"px",t.$.fireEvent("dragging",{item:Smart.ListBox.DragDrop.Item,data:Smart.ListBox.DragDrop,originalEvent:e.originalEvent});for(let t=0;t<Smart.ListBox.DragDrop.ListBoxes.length;t++){const i=Smart.ListBox.DragDrop.ListBoxes[t];i._dragInterval&&clearInterval(i._dragInterval),i._dragInterval=setInterval((function(){const t=i.getBoundingClientRect();t.left<=e.clientX&&t.left+t.width>=e.clientX&&(e.clientY>=t.top&&e.clientY<=t.top+20?i.scrollTop-=2:e.clientY>=t.top+t.height-20&&e.clientY<=t.top+t.height&&(i.scrollTop+=2))}),1)}return e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),!1}{const r=Math.abs(e.pageX-Smart.ListBox.DragDrop.StartPosition.left),o=Math.abs(e.pageY-Smart.ListBox.DragDrop.StartPosition.top),s=new Date-Smart.ListBox.DragDrop.StartTime;let n=r>=5&&r<=15||o>=5&&o<=15;if(Smart.Utilities.Core.isMobile&&(s<300||s>1e3)&&(n=!1),n){Smart.ListBox.DragDrop.Dragging=!0,Smart.ListBox.DragDrop.Feedback.style.left=i[0]+e.pageX+"px",Smart.ListBox.DragDrop.Feedback.style.top=i[1]+e.pageY+"px",t.getShadowRootOrBody().appendChild(Smart.ListBox.DragDrop.Feedback),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation();const r=Smart.ListBox.DragDrop.Item,o=r.ownerListBox;o.$.fireEvent("dragStart",{item:r,data:Smart.ListBox.DragDrop,container:o,previousContainer:o,originalEvent:e.originalEvent}),document.body.classList.add("smart-dragging")}}}_focusHandler(){this._focused=!0,this.setAttribute("focus","")}_blurHandler(){this._focused=!1,this.removeAttribute("focus")}appendChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}t.isVirtualized?(t._items.indexOf(e)>-1&&t._items.splice(t._items.indexOf(e),1),t._items.push(e)):(e.dataItem=e,t.shadowRoot&&"light"===t.shadowDomMode?t.appendChild(e):t.$.itemsInnerContainer.appendChild(e),t._items.indexOf(e)>-1&&t._items.splice(t._items.indexOf(e),1),t._items.push(e)),t._isUpdating||(t._refreshItems(),t._refreshSelection())}insertBefore(e,t){const i=this;if(!i.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.insertBefore.apply(i,e.concat(Array.prototype.slice.call(arguments)))}i.isVirtualized?(i._items.indexOf(e)>-1&&i._items.splice(i._items.indexOf(e),1),i._items.splice(i._indexOf(t),0,e)):(e.dataItem=e,t.parentNode.insertBefore(e,t),i._items.indexOf(e)>-1&&i._items.splice(i._items.indexOf(e),1),i._items.splice(i._indexOf(t),0,e)),i._refreshItems(),i._refreshSelection()}removeChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}if(t.isVirtualized)t._items.splice(t._indexOf(e),1);else if(e.parentNode){const i=t.selectedIndexes.slice(0),r=t.selectedValues.slice(0),o=i.indexOf(e.dataIndex);e.parentNode.removeChild(e),o>-1&&(i.splice(o,1),r.splice(o,1),t.selectedIndexes=i,t.selectedValues=r)}t._refreshItems()}propertyChangedHandler(e,t,i){if("dataSource"===e&&(!i||i&&Array.isArray(i)&&0===i.length))return void this.clearItems();super.propertyChangedHandler(e,t,i);const r=this;switch(e){case"innerHTML":r.clearSelection(),r._dataBind(),r.innerHTML=r.content=Smart.Utilities.Core.html(r.$.content);break;case"dataSource":case"valueMember":case"groupMember":case"displayMember":r.clearSelection(),r._dataBind(),r._applyDefaultSelection();break;case"disabled":case"unfocusable":r._setFocusable();break;case"displayLoadingIndicator":r._setLoadingIndicatorVisibility();break;case"filterable":r._refreshFilter(),r._refreshLayout();break;case"grouped":if(i?r._group():r._ungroup(),"radioButton"===r.selectionMode){if(r.selectedValues.length>0){const e=r.selectedValues;r.clearSelection(),r.select(e[0])}}else r._refreshSelection();r._refreshLayout();break;case"itemTemplate":{if(null===i||""===i)return r._items.map((e=>e.innerHTML=e.label)),delete r._bindingDetails,void r._refreshLayout();const e=r.querySelectorAll("smart-list-item"),t=function(){r._handleItemTemplate(i)&&(r._items.map((e=>r._applyTemplate(e))),r._refreshLayout()),r.ownerElement&&r.ownerElement._setDropDownSize&&r.ownerElement._setDropDownSize(),r.$.fireEvent("bindingComplete")};0===e.length?t():r._ensureItemsReady(e,t);break}case"selectedIndexes":case"selectedValues":{let o=r.selectedIndexes.slice(0),s=r.selectedValues.slice(0);if(!r._items||0===r._items.length)return r.selectedIndexes=[],r.selectedValues=[],void(r.$.hiddenInput.value=r.selectedValues.toString());if(r._propertyChanging=!0,"selectedIndexes"===e){o=t.slice(0),r.clearSelection();for(let e=0;e<i.length;e++){const t=i[e],o=r._items[t];o&&("oneOrManyExtended"===r.selectionMode||"oneOrMany"===r.selectionMode?(r.selectedIndexes.length>0&&0===e&&r.clearSelection(),r._select(o)):r.select(o))}}else{s=t.slice(0),r.selectedValues=[],r.clearSelection();for(let e=0;e<i.length;e++){const t=i[e],o=r.getItem(t);o&&("oneOrManyExtended"===r.selectionMode?r._select(o):r.select(o))}}if(r.selectedIndexes.length>0&&r._focus(r._items[r.selectedIndexes[0]]),r._propertyChanging=!1,JSON.stringify(s)!==JSON.stringify(r.selectedValues.slice(0))){let e=[],t=[];for(let e=0;e<o.length;e++)r.selectedIndexes.indexOf(o[e])<0&&t.push(r._items[o[e]]);for(let t=0;t<r.selectedIndexes.length;t++)o.indexOf(r.selectedIndexes[t])<0&&e.push(r._items[r.selectedIndexes[t]]);let i={addedItems:e,removedItems:t};if(r.selectedIndexes.length>0){const e=r._items[r.selectedIndexes[r.selectedIndexes.length-1]];void 0!==e&&(i.selected=e.selected,i.disabled=e.disabled,i.index=r._indexOf(e),i.label=e.label,i.value=e.value)}else i.selected=!1,i.disabled=!1,i.index=-1,i.label="",i.value="";r.$.fireEvent("change",i),r._updateTargetValue()}break}case"selectionMode":{const e="checkBox"===r.selectionMode||"radioButton"===r.selectionMode?r.selectionMode:"plain",o=r.selectedIndexes.slice(0),s=r.selectedValues.slice(0);r._propertyChanging=!0;const n=r.selectedValues;r.setAttribute("aria-multiselectable",-1!==["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox","radioButton"].indexOf(i)),r.selectedValues=[],r.clearSelection();for(let e=0;e<n.length;e++){const t=n[e],i=r.getItem(t);i&&("oneOrManyExtended"===r.selectionMode?r._select(i):r.select(i))}if(r._items.forEach((t=>t.displayMode=e)),r._recycle(),r._propertyChanging=!1,JSON.stringify(s)!==JSON.stringify(r.selectedValues.slice(0))){let e=[],t=[];for(let e=0;e<o.length;e++)r.selectedIndexes.indexOf(o[e])<0&&t.push(r._items[o[e]]);for(let t=0;t<r.selectedIndexes.length;t++)o.indexOf(r.selectedIndexes[t])<0&&e.push(r._items[r.selectedIndexes[t]]);let i={addedItems:e,removedItems:t};if(o.length>0){const e=r._items[o[o.length-1]];e&&(i.selected=e.selected,i.disabled=e.disabled,i.index=r._indexOf(e),i.label=e.label,i.value=e.value)}r.$.fireEvent("change",i),r._updateTargetValue()}r._applyAriaSelected(),"checkBox"!==i&&"radioButton"!==i&&"checkBox"!==t&&"radioButton"!==t||r._refreshLayout();break}case"topVisibleIndex":r._setTopVisibleIndex(i);break;case"autoSort":r._canSort=i;break;case"alternationStart":case"alternationEnd":case"alternationCount":r._refreshItems(),r._refreshLayout();break;case"sortDirection":case"sorted":{r._canSort=!0,i?r._sort():r._unsort();const e=r.selectedValues;r.selectedValues=[],r._refreshSelection();for(let t=0;t<e.length;t++){const i=e[t],o=r.getItem(i);o&&("oneOrManyExtended"===r.selectionMode?r._select(o):r.select(o))}r._refreshLayout(),r._canSort=r.autoSort;break}}}_refreshSelection(){const e=this;if(!e._items||0===e._items.length)return;const t=e.selectedValues;e.selectedIndexes=[],e.selectedValues=[];for(let i=0;i<e._items.length;i++){const r=e._items[i];r.selected=!1,t.indexOf(r.value)>-1&&e.select(r)}e._recycle()}clearSelection(){const e=this;if(!e._items||0===e._items.length)return;let t=[];for(let i=0;i<e._items.length;i++)e._items[i].selected&&t.push(e._items[i]);e._items.map((e=>e.selected=!1)),e.selectedValues.slice(0);const i=e.selectedIndexes.slice(0);if(e.selectedIndexes=[],e.selectedValues=[],e.$.hiddenInput.value=e.selectedValues.toString(),e._recycle(),e.context!==e){let r={addedItems:[],removedItems:t};if(i.length>0){const t=e._items[i[i.length-1]];t&&(r.selected=t.selected,r.disabled=t.disabled,r.index=e._indexOf(t),r.label=t.label,r.value=t.value)}e.$.fireEvent("change",r),e._updateTargetValue()}}ensureVisible(e){const t=this;if(e)return!("string"==typeof e&&!(e=t.getItem(e))||(t.isVirtualized||t.$.itemsContainer.scrollTop===t.scrollTop||(t.scrollTop=t.$.itemsContainer.scrollTop),e.top+e.height>=t.scrollTop+t.offsetHeight&&(t.scrollTop=t.scrollTop+e.height,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),(e.top<=t.scrollTop||e.top>=t.scrollTop+t.$.itemsContainer.offsetHeight)&&(t.scrollTop=e.top,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),0===t._indexOf(e)||1===t._indexOf(e)&&t._items.length>1&&t._items[0].grouped?(t.scrollTop=0,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)):t._indexOf(e)===t._items.length-1&&(t.scrollTop=t.scrollHeight,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),0))}get items(){const e=this;if(!window.__karma__&&!window.karma&&e instanceof Element&&e.isRendered&&e.hasAttribute&&e.hasAttribute("smart-blazor")){let t=[];for(let i=0;i<e._items.length;i++){const r=e._items[i];t.push({label:r.label,value:r.value})}return t}return e._filteredItems?e._filteredItems:e._items}getItems(){const e=this,t=e._filteredItems?e._filteredItems:e._items;let i=[];if(t&&t.length>0)for(let e=0;e<t.length;e++){const r=t[e];i.push({label:r.label,value:r.value})}return i}ready(){super.ready();const e=this;if(e.shadowRoot&&"light"===e.shadowDomMode){const t=document.createDocumentFragment();[].slice.call(e.$.itemsInnerContainer.children).map((e=>t.appendChild(e))),e.appendChild(t),e.$.itemsInnerContainer.appendChild(document.createElement("slot"))}e._areCSSVarsSupported=Smart.Utilities.Core.CSSVariablesSupport(),e.isUpdating=0,e._scrollView&&(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar),e._scrollView.hScrollBar.$.addClass("smart-hidden"),e._scrollView.vScrollBar.$.addClass("smart-hidden"));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.wait=!1,i.wait=!1,e._setFocusable()}render(){const e=this;e.setAttribute("role","listbox"),e.setAttribute("aria-orientation","vertical"),e.$.verticalScrollBar.setAttribute("aria-controls",e.id),e.$.horizontalScrollBar.setAttribute("aria-controls",e.id),e._keysPressed={},e._incrementalSearchQuery="",e._incrementalSearchItems=[],e._canSort=!0,e._previousEntry="",e._setLoadingIndicatorVisibility(),e._refreshFilter(),e._initializeInnerHTML(),e._dataBind(),e._applyDefaultSelection(),e.enableShadowDOM&&HTMLElement.prototype.appendChild.apply(e,[e.$.hiddenInput]),e.setAttribute("aria-multiselectable",-1!==["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox","radioButton"].indexOf(e.selectionMode)),super.render()}_lazyInitItems(){const e=this;if(e._inLazyInit)return cancelAnimationFrame(Smart.ListBox.processTimer),void delete Smart.ListBox.processTimer;e._inLazyInit=!0,e.dataSource||(e.clearSelection(),e._dataBind(),e._applyDefaultSelection()),cancelAnimationFrame(Smart.ListBox.processTimer),delete Smart.ListBox.processTimer,e._inLazyInit=!1}_applyDefaultSelection(){const e=this;!e._focusedItem&&e._items&&e._items.length>0&&0===e.selectedIndexes.length&&("one"!==e.selectionMode&&"oneOrMany"!==e.selectionMode&&"oneOrManyExtended"!==e.selectionMode||e.select(e._items[0]))}attached(){const e=this;super.attached(),Smart.ListBox.DragDrop||(Smart.ListBox.DragDrop={ListBoxes:[]}),Smart.ListBox.DragDrop.ListBoxes.push(e),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),e.selectedIndexes.length>0&&e._items&&e.ensureVisible(e._items[e.selectedIndexes[0]])}detached(){const e=this;if(super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),Smart.ListBox.DragDrop&&Smart.ListBox.DragDrop.ListBoxes){const t=Smart.ListBox.DragDrop.ListBoxes.indexOf(e);Smart.ListBox.DragDrop.ListBoxes.splice(t,1)}}_createItem(e,t,i){const r=this,o="checkBox"===r.selectionMode||"radioButton"===r.selectionMode?r.selectionMode:"plain",s=i?{}:document.createElement("smart-list-item");s.ownerListBox=r,"number"==typeof e&&(e=""+e);const n=function(t,i){return void 0!==e[t]?""+e[t]:e[i]};let l="string"==typeof e?e:n(r.displayMember,"label"),a="string"==typeof e?e:n(r.valueMember,"value"),d=n(r.groupMember,"group");return void 0===l&&(l=void 0!==t?""+t:""),s.label=s.innerHTML=""+l,void 0===a&&(a=void 0!==t?""+t:l),e.color&&(s.color=e.color),s.value=""+a,s.displayMode=o,s.selected=!!e.selected&&e.selected,s.disabled=!!e.disabled&&e.disabled,s.dataItem=s,void 0!==t&&(s.dataIndex=t),r._alternateItem(s),e.title&&(s.title=e.title),d&&(s.group=""+d),s}_alternateItem(e){const t=this,i=t.alternationStart,r=t.alternationEnd>0?t.alternationEnd:1/0;t.alternationCount<=0||(void 0===t._alternationIndexCounter&&(t._alternationIndexCounter=0),e.dataIndex>=i&&e.dataIndex<=r&&(e.alternationIndex=t._alternationIndexCounter++,t._alternationIndexCounter===t.alternationCount&&(t._alternationIndexCounter=0)))}_beginUpdate(){this.isUpdating++}_isUpdating(){return this.isUpdating>0}_endUpdate(){this.isUpdating--}get _scrollHeight(){const e=this;if(0===e._items.length||e._items.filter((e=>!e.hidden)).length<1)return 0;let t=0;if(e.isVirtualized){if(e.__scrollHeight)return e.__scrollHeight;if(0===e._items.length)return 0;e.isUpdating++;const i=e._createItem(e._items[0]);e.$.itemsInnerContainer.appendChild(i);for(let r=0;r<e._items.length;r++){const o=e._items[r];o.hidden?(o.height=0,o.top=t):(e.itemHeight?(e.itemHeight<32&&(e.itemHeight=32),o.height=e.itemHeight):(i.$&&i.$.itemContainer?i.$.itemContainer.firstElementChild.innerHTML=o.label:i.label=o.label,o.height=i.offsetHeight),o.top=t,t+=o.height)}e.$.itemsInnerContainer.removeChild(i),e.__scrollHeight=t-e.$.itemsInnerContainer.offsetHeight,e.filterable&&(e.__scrollHeight+=e.$.filterInput.offsetHeight),t=e.__scrollHeight,e.isUpdating--}else{for(let i=0;i<e._items.length;i++){const r=e._items[i];r.hidden?(r.height=0,r.top=t):(e.itemHeight?"auto"!==e.itemHeight&&(r.height=e.itemHeight,r.style.height=r.height+"px"):r.height=r.offsetHeight,r.top=r.offsetTop,t+=r.height)}t=e.$.itemsInnerContainer.scrollHeight-e.$.itemsInnerContainer.offsetHeight,e.filterable&&t>0&&(t+=e.$.filterInput.offsetHeight),e.__scrollHeight=t}return t}_initializeRecyclingItems(){const e=this;if(!e.dataSource||e.dataSource&&0===e.dataSource.length||!e.isVirtualized)return;let t=0,i=e.offsetHeight||400;e.$.itemsInnerContainer.innerHTML="",e._recyclingItems=[];const r=function(r){for(let o=0;o<r.length;o++){const s=r[o],n=e._createItem(s);if(e.itemHeight&&"auto"!==e.itemHeight&&(n.style.height=e.itemHeight+"px"),e.$.itemsInnerContainer.appendChild(n),t+=n.offsetHeight,n.dataItem=e._items[o],e._recyclingItems.push(n),t>1.5*i)break}};if("function"==typeof e.dataSource){let e=[];for(let t=0;t<100;t++)e.push("");r(e)}else{r(e.dataSource);let o=0;for(;t<1.5*i&&++o<5;)r(e.dataSource)}}dataBind(){const e=this;e.clearSelection(),e._dataBind(),e._applyDefaultSelection()}_dataBind(){const e=this;if(e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),"function"==typeof e.dataSource){e._items=[],delete e._filteredItems;const t=e.dataSource("",(t=>{e.clearItems(),e.insert(0,t)}));t&&Array.isArray(t)&&(e.clearItems(),e.insert(0,t))}if("string"==typeof e.dataSource&&(e.dataSource=JSON.parse(e.dataSource)),null!==e.dataSource&&Array.isArray(e.dataSource)){e.isUpdating++;const t=t=>{e._items=[],e._groups=[],delete e._filteredItems;const i=e.dataSource;for(let r=0;r<i.length;r++){const o=i[r],s=e._createItem(o,r,!t);e._items[r]=s,t&&t.appendChild(s)}};if(e.isVirtualized)t(),e._initializeRecyclingItems();else{const i=document.createDocumentFragment();e.$.itemsInnerContainer.innerHTML="",t(i),e.$.itemsInnerContainer.appendChild(i)}e.isUpdating--}const t=e.shadowRoot?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item"),i=function(){e.isUpdating++,e.dataSource||(e._initializeHtmlListItems(),e._initializeHtmlListGroups()),e.grouped&&e._group(),e.sorted&&e._sort(),e._refreshLayout(),e._initializeSelection(),e.isInitialized=!0,e._canSort=e.autoSort,e.isUpdating--,e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&(e._items.map((t=>e._applyTemplate(t))),e._refreshLayout()),e.__onCompleted&&(e._onCompleted=e.__onCompleted,e.__onCompleted=null,e._onCompleted()),e.topVisibleIndex>-1&&e._setTopVisibleIndex(e.topVisibleIndex),e.$.fireEvent("bindingComplete"),e._updateTopVisibleIndex(),0===e._items.length&&e.clearItems(),e._applyAriaSelected()};0===t.length?i():(e._onCompleted&&(e.__onCompleted=e._onCompleted,e._onCompleted=null),e._ensureItemsReady(t,i))}_ensureItemsReady(e,t){const i=this,r=function(){const i=function(t){for(let i=0;i<e.length;i++)e[i].context="node"===t?e[i]:document};i("node"),t(),i()};if(0===e.length)r();else{i._nodesReadyListeners=0;for(let t=0;t<e.length;t++){const o=e[t],s=function(){i._nodesReadyListeners--,0===i._nodesReadyListeners&&(r(),delete i._nodesReadyListeners)}.bind(i);o.isCompleted||(i._nodesReadyListeners++,o._onCompleted=s)}0===i._nodesReadyListeners&&r()}}_initializeInnerHTML(){const e=this;e.$.itemsInnerContainer.innerHTML.indexOf("<option")>=0?e.$.itemsInnerContainer.innerHTML=e.$.itemsInnerContainer.innerHTML.replace(/<optgroup/gi,"<smart-list-items-group").replace(/<\/optgroup/gi,"</smart-list-items-group").replace(/<option/gi,"<smart-list-item").replace(/<\/option/gi,"</smart-list-item"):e.$.itemsInnerContainer.innerHTML.indexOf("<ul")>=0&&(e.$.itemsInnerContainer.innerHTML=e.$.itemsInnerContainer.innerHTML.replace(/<ul/gi,"<smart-list-items-group").replace(/<\/ul/gi,"</smart-list-items-group").replace(/<li/gi,"<smart-list-item").replace(/<\/li/gi,"</smart-list-item"))}_initializeHtmlListItems(){const e=this,t=e.shadowRoot&&"shadow"===e.shadowDomMode?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item"),i="checkBox"===e.selectionMode||"radioButton"===e.selectionMode?e.selectionMode:"plain",r=function(e,t,i){return void 0!==e[t]?""+e[t]:e[i]};e._items=[];let o=0;for(let s=0;s<t.length;s++){const n=t[s];n.dataIndex=s,n.label=n.innerHTML,n.dataItem=n,n.top||(n.top=o),n.height||(n.height=n.offsetHeight),o+=n.height,n.value||(n.value=""+s);const l=r(n,e.displayMember,"label"),a=r(n,e.valueMember,"value"),d=r(n,e.groupMember,"group");n.label!==l&&(n.label=l),n.value!==a&&(n.value=a),n.group!==d&&(n.group=d);const c=n.context;n.context=document,n.displayMode=i,n.context=c,e._alternateItem(n),n.selected&&(e.selectedIndexes.push(s),e.selectedValues.push(n.value)),e._items.push(n)}e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&e._items.map((t=>e._applyTemplate(t)))}_group(){const e=this;e.isUpdating++;let t=[],i=[];e._canSort&&e._unsort();for(let i=0;i<e._items.length;i++){const r=e._items[i];let o=r.group?r.group.trim():r.innerHTML.charAt(0)||r.label.charAt(0);o+=" ",t[o]?t[o].items.push(r):t[t.length++]=t[o]={items:[r],label:o}}if(e.isVirtualized){e._groups=[];for(let e=0;e<t.length;e++){const r=t[e];r.dataIndex=e,r.grouped=!0,r.hidden=!1,r.displayMode="plain",i.push(r);for(let o=0;o<t[e].items.length;o++){const e=r.items[o];e.group=r,i.push(e)}}e._groups=t,e._items=i}else{for(;e.$.itemsInnerContainer.firstChild;)e.$.itemsInnerContainer.removeChild(e.$.itemsInnerContainer.firstChild);const r=document.createDocumentFragment();e._groups=[];for(let o=0;o<t.length;o++){const s=t[o],n=document.createElement("smart-list-items-group");n.label=s.label,n.dataIndex=o;for(let e=0;e<t[o].items.length;e++){const t=s.items[e];i.push(t),t.group=s.label,n.appendChild(t)}e._groups.push(n),r.appendChild(n)}e._items=i,/Trident|Edge/.test(navigator.userAgent)?setTimeout((function(){e.$.itemsInnerContainer.appendChild(r)}),50):e.$.itemsInnerContainer.appendChild(r)}e.sorted&&e._sort(),e.isUpdating--}_ungroup(){const e=this;e.isUpdating++,e._groups=[],e._canSort&&e._unsort();let t=[];if(e.isVirtualized)for(let i=0;i<e._items.length;i++){const r=e._items[i];r.grouped||t.push(r)}else{const i=document.createDocumentFragment();for(let r=0;r<e._items.length;r++){const o=e._items[r];i.appendChild(o),t.push(o)}t.length>0&&(e.$.itemsInnerContainer.innerHTML="",e.$.itemsInnerContainer.appendChild(i))}e._items=t,e.sorted&&e._sort(),e.isUpdating--}_initializeHtmlListGroups(){const e=this,t=e.$.itemsInnerContainer.querySelectorAll("smart-list-items-group");e._groups=[];for(let i=0;i<t.length;i++){const r=t[i];r.dataIndex=i,e._groups.push(r)}}_initializeSelection(){const e=this,t=e.selectedIndexes.slice(0),i=e.selectedValues.slice(0);e.clearSelection(),"oneOrManyExtended"===e.selectionMode&&(e._keysPressed.Control=!0);for(let r=0;r<e._items.length;r++){const o=e._items[r];(t.indexOf(r)>=0||i.indexOf(o.value||o.label)>=0)&&(e._focusedItem&&(e._focusedItem._focused=!1),e._focusedItem=null,e.select(o))}"oneOrManyExtended"===e.selectionMode&&(e._keysPressed.Control=!1)}onItemUpdated(){const e=this;e.isInitialized&&!e._isUpdating()&&(e.isUpdating++,e._refreshLayout(),e.isUpdating--)}_refreshItems(){const e=this;if(e.isInitialized&&!e._isUpdating()){if(e.isUpdating++,e.grouped?e._ungroup():e.sorted&&e._canSort&&e._unsort(),!e.isVirtualized){e._items=[];const t=e.shadowRoot?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item");for(let i=0;i<t.length;i++)t[i].dataIndex=i,e._alternateItem(t[i]),e._items.push(t[i])}e.grouped?e._group():e.sorted&&e._sort(),e._refreshLayout(),e.isUpdating--}}_applyIncrementalSearch(e){const t=this;null===t.incrementalSearchDelay||isNaN(t.incrementalSearchDelay)||["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control","Home","End","PageUp","PageDown"].indexOf(e)>-1||(0!==t._incrementalSearchQuery.indexOf(e)&&(t._incrementalSearchQuery+=e),t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t._incrementalSearch(),t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),t.incrementalSearchDelay))}select(e){const t=this;if(("string"!=typeof e||(e=t.getItem(e)))&&("number"!=typeof e||(e=t.getItem(e)))&&!(e.grouped||e.readonly||!t._items.length||e instanceof HTMLElement&&!t.contains(e)&&!t.virtualized)){if("none"===t.selectionMode)return t.selectedIndexes=[],void(t.selectedValues=[]);switch(!t._focusedItem!==e&&"none"!==t.selectionMode&&(t._focusedItem&&(t._focusedItem._focused=!1),t._focusedItem=e,e._focused=!0),t.selectionMode){case"one":case"zeroAndOne":return(1!==t.selectedIndexes.length||t.selectedIndexes[0]!==t._indexOf(e))&&(t._previouslySelectedIndexes=t.selectedIndexes,t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e),delete t._previouslySelectedIndexes,!0);case"zeroOrOne":return 1===t.selectedIndexes.length&&t.selectedIndexes[0]===t._indexOf(e)?(t.unselect(e),!0):(t._previouslySelectedIndexes=t.selectedIndexes,t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e),delete t._previouslySelectedIndexes,!0);case"radioButton":if(t._previouslySelectedIndexes=t.selectedIndexes,t.$.itemsInnerContainer.querySelectorAll("smart-list-items-group").length>0){const i=e.parentNode;if(!e.selected){for(let e in i.children){const r=i.children[e];r.selected&&t.unselect(r)}t._select(e)}return delete t._previouslySelectedIndexes,!0}if(t.isVirtualized&&t._groups.length>0){const i=e.group;if(!e.selected){for(let e in i.items){const r=i.items[e];r.selected&&t.unselect(r)}t._select(e)}return delete t._previouslySelectedIndexes,!0}return e.selected||(t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e)),delete t._previouslySelectedIndexes,!0;case"oneOrMany":return e.selected?t.selectedIndexes.length>1&&t.unselect(e):t._select(e),!0;case"zeroOrMany":case"checkBox":return e.selected?t.unselect(e):t._select(e),!0;case"oneOrManyExtended":{const i=t.selectedValues;if(t._keysPressed.Control)return t.selectedIndexes.length>1&&e.selected?(t.unselect(e),t._focus(t._items[t.selectedIndexes[0]])):t._select(e),!0;if(t._keysPressed.Shift){const r=t._items[t.selectedIndexes[0]];let o;t.clearSelection();const s=i.indexOf(r.value)>=0||r.selected;if(t._select(r,s),t._indexOf(r)>t._indexOf(e))for(o=t._indexOf(r)-1;o>=t._indexOf(e);){const e=t._items[o],r=i.indexOf(e.value)>=0||e.selected;t._select(e,r),o--}else for(o=t._indexOf(r)+1;o<=t._indexOf(e);){const e=t._items[o],r=i.indexOf(e.value)>=0||e.selected;t._select(e,r),o++}const n=[];for(let e=0;e<i.length;e++)n.push(t.getItem(i[e]));if(n.length>0&&!t._propertyChanging){let r=[];for(let e=0;e<t.selectedValues.length;e++){const o=t.selectedValues[e];i.indexOf(o)<0&&r.push(t.getItem(o))}t.$.fireEvent("change",{addedItems:r,removedItems:n,selected:e.selected,disabled:e.disabled,index:t._indexOf(e),label:e.label,value:e.value}),t._updateTargetValue()}return!0}for(let r=0;r<i.length;r++){const o=i[r],s=t.getItem(o);e!==s&&t.unselect(s)}return t.clearSelection(),t._select(e,i.indexOf(e.value)>=0),!0}}return!1}}_applyTemplate(e,t){const i=this;if(null===i.itemTemplate)return;if("function"==typeof i.itemTemplate)return void i.itemTemplate(e,{label:e.label,value:e.value,index:i._items.indexOf(e)});if(!i._bindingDetails||0===i._bindingDetails.length)return;const r=i._bindingDetails.length;let o,s,n=document.importNode(i._template.content,!0);for(let t=0;t<r;t++){o=n.childNodes[i._bindingDetails[t].childNodeIndex],s=i._bindingDetails[t].bindingString.length;for(let r=0;r<s;r++){const s=i._bindingDetails[t].bindingString[r],n=s.indexOf("label")>=0?e.label:e.value;o.innerHTML=o.innerHTML.replace(s,n)}}e.innerHTML="";for(let t=0;t<n.childNodes.length;t++)n.childNodes[t].outerHTML&&(e.innerHTML+=n.childNodes[t].outerHTML);!1!==t&&(i._scrollHeightTimer&&(clearInterval(i._scrollHeightTimer),i._scrollHeightCounter=0),i._scrollHeightTimer=setInterval((function(){i._lastScrollHeight===i.$.itemsInnerContainer.scrollHeight&&10!==i._scrollHeightCounter||(i._refreshLayout(),clearInterval(i._scrollHeightTimer)),i._lastScrollHeight=i.$.itemsInnerContainer.scrollHeight,i._scrollHeightCounter++}),50))}_filterItems(e,t,i){const r=this,o=r.$.filterInput.value;let s,n;const l=function(){if(0===n.length)return r._filteredItems=[],void(t&&t());s=r._queryItems(o,r.filterMode);for(let e=0;e<n.length;e++)n[e].hidden=!0,n[e].$&&n[e].$.addClass("smart-hidden");for(let e=0;e<s.length;e++){const t=s[e];t.hidden=!1,n[e].$&&t.$.removeClass("smart-hidden")}if(r.grouped&&r.isVirtualized)for(let e=0;e<r._groups.length;e++){const t=r._groups[e],i=t.items;let o=!0;for(let e=0;e<i.length;e++)i[e].hidden||(o=!1);o&&(t.hidden=!0)}if(r.grouped&&!r.isVirtualized)for(let e=0;e<r._groups.length;e++){const t=r._groups[e],i=[].concat(...t.querySelectorAll("smart-list-item"));let o=!0;for(let e=0;e<i.length;e++)i[e].$.hasClass("smart-hidden")||(o=!1);o?t.$.addClass("smart-hidden"):t.$.removeClass("smart-hidden")}if(r._filteredItems=s,r._refreshLayout(),t&&t(),e)return;const i=r._propertyChanging;r._propertyChanging=!0,r._refreshSelection(),r._propertyChanging=i};if("function"==typeof r.dataSource)if(o||i){const e=function(e){(o||i)&&r.isAttached&&(r._updateListBoxAfterQuery=function(){s=n=r._items,l()},r.clearItems(),r.insert(0,e))},t=r.dataSource(o,e);if(t){if(!o&&!i)return;r._updateListBoxAfterQuery=function(){s=n=r._items,l()},r.clearItems(),r.insert(0,t)}}else r.clearItems(),s=n=r._items,l(),r.$.fireEvent("bindingComplete");else{if(n=r._items,0===n.length)return;l()}}_getNextItem(e){const t=this._items,i=this._items.length;let r=Math.max(e+1,0);for(;r<i;){const e=t[r];if(!(e.disabled||e.hidden||e.grouped||e.readonly))return e;r++}return t[e]}_getPreviousItem(e){const t=this._items;let i=Math.max(e-1,0);for(;i>-1;){const e=t[i];if(!(e.disabled||e.hidden||e.grouped||e.readonly))return e;i--}return t[e]}get _scrollWidth(){const e=this,t=e._items;return e.__scrollWidth||(e.__scrollWidth=(()=>{const e=this,i=e.virtualized,r=e.itemMeasureMode;let o=0,s="";function n(t){const i=e._createItem({label:t});i.style.position="absolute",e.$.itemsContainer.appendChild(i),i.label=t,i.style.width="auto",i.isCompleted&&(i.$.itemContainer.style.width="auto");const r=getComputedStyle(i),o=parseInt(r.paddingLeft)+parseInt(r.paddingRight),s=i.$.itemContainer||i,n=s.offsetWidth+s.offsetLeft+o;return i.parentNode.removeChild(i),n}for(let e=0;e<t.length;e++){const l=t[e];if(!l.hidden)if("auto"===r){const e=i?l.label:l.textContent.trim();e.length>s.length&&(s=e)}else o=Math.max(o,n(l.label))}return"auto"===r?n(s):o})()),e.__scrollWidth}update(e,t){const i=this,r=i._items[e];if(r){if("string"==typeof t)r.label=t,void 0===r.value&&(r.value=t);else for(let e in t)"selected"===e&&r[e]!==t[e]?i.select(r):r[e]=t[e],"group"===e&&i._refreshItems();(i.sorted||i.grouped||i.isVirtualized)&&(i._refreshItems(),i._refreshSelection())}else i.error(i.localize("indexOutOfBound",{elementType:i.nodeName.toLowerCase(),method:"update"}))}insert(e,t){const i=this;let r=[];if((!e||e<0)&&(e=0),Array.isArray(t)){i.isUpdating++;const o=0===i._items.length;for(let s=0;s<t.length;s++){const n=t[s],l=i._createItem(n);r.push(l),e>=i._items.length||0===i._items.length||o?i.appendChild(l):i.insertBefore(l,i._items[e])}i.isUpdating--}else{const o=i._createItem(t);r.push(o),e>=i._items.length||0===i._items.length?i.appendChild(o):i.insertBefore(o,i._items[e])}if(r.length>0?(r.map((e=>i._applyTemplate(e))),i._ensureItemsReady(r,(function(){i._refreshItems(),0!==i._items.length&&(i._updateListBoxAfterQuery&&(i._updateListBoxAfterQuery(),delete i._updateListBoxAfterQuery),i._refreshSelection(),i.$.fireEvent("bindingComplete"))}))):i._updateListBoxAfterQuery&&(i._updateListBoxAfterQuery(),delete i._updateListBoxAfterQuery),i.virtualized&&i.filterable){const e=i.context;i.context=i,i.filterable&&(i.$.filterInput.value="",i._filterItems()),i.scrollTop=i.$.itemsContainer.scrollTop=0,i.scrollLeft=i.$.itemsContainer.scrollLeft=i._getScrollLeft(0),i.context=e}}add(e){const t=this;let i=[];if(e&&(!e||0!==e.length)){if(Array.isArray(e)){t.isUpdating++;for(let r=0;r<e.length;r++){const o=e[r],s=t._createItem(o);i.push(s),t.appendChild(s)}t.isUpdating--}else{const r=t._createItem(e);i.push(r),t.appendChild(r)}if(i.length>0?(i.map((e=>t._applyTemplate(e))),t._ensureItemsReady(i,(function(){t._refreshItems(),0!==t._items.length&&(t._updateListBoxAfterQuery&&(t._updateListBoxAfterQuery(),delete t._updateListBoxAfterQuery),t._refreshSelection(),t.$.fireEvent("bindingComplete"))}))):t._updateListBoxAfterQuery&&(t._updateListBoxAfterQuery(),delete t._updateListBoxAfterQuery),t.virtualized&&t.filterable){const e=t.context;t.context=t,t.filterable&&(t.$.filterInput.value="",t._filterItems()),t.scrollTop=t.$.itemsContainer.scrollTop=0,t.scrollLeft=t.$.itemsContainer.scrollLeft=t._getScrollLeft(0),t.context=e}else t.virtualized&&t._refreshLayout()}}removeAt(e){const t=this,i=t._items[e];i?(i.selected&&t.unselect(i),t.isVirtualized?t._items.splice(e,1):i.parentNode.removeChild(i),t._refreshItems(),t._refreshSelection(),0===t.selectedIndexes.length&&t._items.length>0&&("oneOrMany"!==t.selectionMode&&"one"!==t.selectionMode&&"oneOrManyExtended"!==t.selectionMode||t.select(t._items[0]))):t.error(t.localize("indexOutOfBound",{elementType:t.nodeName.toLowerCase(),method:"remove"}))}_queryItems(e,t){const i=this,r=[],o=function(r,o){if(r.grouped)return r;switch(t){case"startsWith":if(0===r.label.indexOf(o))return r;break;case"startsWithIgnoreCase":if(0===r.label.toLowerCase().indexOf(o.toLowerCase()))return r;break;case"doesNotContain":if(r.label.indexOf(o)<0)return r;break;case"doesNotContainIgnoreCase":if(r.label.toLowerCase().indexOf(o.toLowerCase())<0)return r;break;case"contains":if(r.label.indexOf(o)>-1)return r;break;case"containsIgnoreCase":if(r.label.toLowerCase().indexOf(o.toLowerCase())>-1)return r;break;case"equals":if(0===r.label.localeCompare(o))return r;break;case"equalsIgnoreCase":if(0===r.label.toLowerCase().localeCompare(o.toLowerCase()))return r;break;case"endsWith":if(r.label.endsWith(o))return r;break;case"endsWithIgnoreCase":if(r.label.toLowerCase().endsWith(o.toLowerCase()))return r;break;case"custom":if(i.filterCallback(r,e))return r}return null};if(0===e.length)return i._items;for(let t=0;t<i._items.length;t++){const s=o(i._items[t],e);s&&r.push(s)}return r}_select(e,t){const i=this,r=i.selectedIndexes.indexOf(i._indexOf(e)),o=i.selectedIndexes.slice(0),s=i.selectedValues.slice(0);if(e.selected=!0,-1!==r)return i._recycle(),!1;if(o.push(i._indexOf(e)),s.push(e.value||e.label),i.selectedIndexes=o,i.selectedValues=s,i._recycle(),i.$.hiddenInput.value=s.toString(),!i.isCompleted||t||!i.isInitialized||i._propertyChanging)return;let n=[];if(i._previouslySelectedIndexes){for(let e=0;e<i._previouslySelectedIndexes.length;e++)i.selectedIndexes.indexOf(i._previouslySelectedIndexes[e])<0&&n.push(i._items[i._previouslySelectedIndexes[e]]);delete i._previouslySelectedIndexes}return i.$.fireEvent("change",{addedItems:[e],removedItems:n,selected:e.selected,disabled:e.disabled,index:i._indexOf(e),label:e.label,value:e.value}),i._updateTargetValue(),!0}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const i=e.dataset.property,r=e.value;i&&void 0!==t[i]&&(t[i]=r)}}}_setTopVisibleIndex(e){const t=this;if("number"==typeof e&&(t.topVisibleIndex=Math.max(0,e),e=t._items[t.topVisibleIndex]),!e)return!1;e.top!==t.scrollTop&&(t.scrollTop=e.top,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop),t.scrollHeight===t.scrollTop&&t._updateTopVisibleIndex())}_updateTopVisibleIndex(){const e=this,t=e.scrollTop+e._scrollView.verticalScrollBar.offsetHeight-e.offsetHeight;let i;if(e.scrollTop<e.scrollHeight/2){for(let r=0;r<e._items.length;r++)if(e._items[r].top>=t){i=e._items[r];break}}else for(let r=e._items.length-1;r>=0&&!(e._items[r].top<t);r--)i=e._items[r];if(i){const t=e.context;e.context=e,e.topVisibleIndex=i.dataIndex,e.context=t}}unselect(e){const t=this;if(!e)return;if("string"==typeof e&&!(e=t.getItem(e)))return;if("none"===t.selectionMode)return void t.clearSelection();const i=t.selectedIndexes.indexOf(t._indexOf(e)),r=t.selectedIndexes.slice(0),o=t.selectedValues.slice(0);return e.selected=!1,i>=0&&(r.splice(i,1),o.splice(i,1),t.selectedIndexes=r,t.selectedValues=o,t.$.hiddenInput.value=o.toString(),t.isCompleted&&!t._propertyChanging?(t.$.fireEvent("change",{addedItems:[],removedItems:[e],selected:e.selected,disabled:e.disabled,index:t._indexOf(e),label:e.label,value:e.value}),t._updateTargetValue(),t._recycle(),!0):void 0)}_handleItemTemplate(e){if(null===e||!e)return;if("function"==typeof e)return e;const t=this;if(!("content"in document.createElement("template")))return t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()})),void(t.itemTemplate=null);if(null===(e=document.getElementById(e))||!("content"in e))return t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:"itemTemplate"})),void(t.itemTemplate=null);const i=e.content,r=i.childNodes.length,o=/{{\w+}}/g;let s,n;t._bindingDetails=[],t._template=e;for(let e=0;e<r;e++){for(n=[];s=o.exec(i.childNodes[e].innerHTML);)n.push(s[0]);n.length>0&&t._bindingDetails.push({childNodeIndex:e,bindingString:n})}return!0}_handleKeyStrokes(e){const t=this,i="radioButton"===t.selectionMode||"checkBox"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode;let r=t._items;if(t.filterable&&t.$.filterInput.value.length>0&&(r=t._filteredItems),!t.disabled&&!t.readonly&&r.length){switch(e){case"ArrowLeft":case"ArrowUp":t._handleArrowKeys(!0);break;case"ArrowRight":case"ArrowDown":t._handleArrowKeys(!1);break;case" ":{if(t.selectedIndexes.length<1&&!t._focusedItem)return;const e=t._focusedItem?t._focusedItem:t._items[t.selectedIndexes[t.selectedIndexes.length-1]],i=e=>{e.selected&&"radioButton"!==t.selectionMode?t.unselect(e):t.select(e)};if("oneOrMany"===t.selectionMode)return void(e.selected&&t.selectedIndexes.length>1?i(e):e.selected||i(e));i(e);break}case"Home":if(0===r.length)return;i||(t._keysPressed.Shift||t.clearSelection(),t.select(r[0])),t._focus(r[0]),t.scrollTop=0;break;case"End":if(0===r.length)return;i||(t._keysPressed.Shift||t.clearSelection(),t.select(r[r.length-1])),t._focus(r[r.length-1]),t.scrollTop=t.scrollHeight;break;case"PageUp":t._pageUpKeyHandler(r);break;case"PageDown":t._pageDownKeyHandler(r)}t._recycle()}}_horizontalScrollbarHandler(e){const t=this;e&&e.stopPropagation&&e.stopPropagation(),t.isVirtualized?t._recycle():t.$.itemsContainer.scrollLeft=t._getScrollLeft(e.detail.value)}_getScrollLeft(e,t){const i=this;if(!i.rightToLeft)return e;if(Smart.Utilities.Core.Browser.Chrome){if(!t){const e=2*(parseInt(getComputedStyle(i.$.itemsInnerContainer).getPropertyValue("--smart-list-item-horizontal-offset"))||0);t=i._scrollWidth-i.$.itemsContainer.offsetWidth-e}e=t-e}else e*=-1;return e}_unsort(){const e=this;e.isUpdating++;const t=function(e,t){let i=e.dataIndex,r=t.dataIndex;return i<r?-1:i>r?1:0};if(e.isVirtualized)if(e._groups.length>0){e._groups.sort(t);let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.items);s.sort(t),i.push(o),i=i.concat(s)}e._items=i}else e._items.sort(t);else{if(e._groups.length>0){e._groups.sort(t);let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.querySelectorAll("smart-list-item"));s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);e._applySortOrder()}e.isUpdating--}_applySortOrder(){const e=function(e){for(let t=0;t<e.length;t++){const i=e[t],r=i.parentNode;r&&r.appendChild(i)}};e(this._items),e(this._groups)}_sort(){const e=this;if(!e._canSort)return;e.isUpdating++;const t=function(t,i){let r=t.label,o=i.label;if("asc"===e.sortDirection){if(r<o)return-1;if(r>o)return 1}else{if(r<o)return 1;if(r>o)return-1}return 0};if(e._groups.sort(t),e.isVirtualized)if(e._groups.length>0){let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.items);i.push(o),s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);else{if(e._groups.length>0){let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.querySelectorAll("smart-list-item"));s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);e._applySortOrder()}e.isUpdating--}getItem(e){const t=this;for(let i=0;i<t._items.length;i++)if(t._items[i].value===e)return t._items[i];return null}_focus(e){const t=this;!e||"none"===t.selectionMode||t.disabled||t.readonly||(t._focusedItem&&(t._focusedItem._focused=!1),t._focusedItem=e,t._focusedItem._focused=!0)}_keyDownHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;let r=e.key;if(e.metaKey&&(r="Control"),!t.disabled&&!t.readonly&&(!t.filterable||t.$.filterInput!==i)&&t._focused&&0!==t._items.length&&!t.disabled&&!t.displayLoadingIndicator){if(t.editable){if("F2"===r)return void t._dblclickEventHandler({target:t._focusedItem});if(t.$.editInput===i)return}if("none"!==t.selectionMode){switch(e.stopPropagation(),r){case"Down":case"Right":case"Left":case"Up":r="Arrow"+r}if(t.filterable)switch(r){case"ArrowLeft":case"ArrowRight":return;case"ArrowUp":case"ArrowDown":e.preventDefault()}if(t._applyIncrementalSearch(r),!(["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control"," ","Home","End","PageUp","PageDown"].indexOf(r)<0))if(e.preventDefault(),!t._focusedItem&&t._items.length>0)"one"===t.selectionMode||"oneOrMany"===t.selectionMode||"oneOrManyExtended"===t.selectionMode?t.select(t._items[0]):t._focus(t._items[0]);else switch(t.selectionMode){case"one":case"zeroAndOne":if("Shift"===r||"Control"===r||" "===r)return;t._handleKeyStrokes(r);break;case"oneOrMany":case"zeroOrOne":case"zeroOrMany":case"radioButton":case"checkBox":if("Shift"===r||"Control"===r)return;t._handleKeyStrokes(r);break;case"oneOrManyExtended":if(" "===r)return;t._keysPressed[r]="keydown"===e.type,t._handleKeyStrokes(r)}}}}_keyUpHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;if(!t.editable||t.$.editInput!==i){if(t.filterable&&t.$.filterInput===i)return t._filterTimer&&clearTimeout(t._filterTimer),void(t._filterTimer=setTimeout((function(){const e=t.context;t.context=t,t._filterItems(void 0,void 0,!0),t.scrollTop=t.$.itemsContainer.scrollTop=0,t.scrollLeft=t.$.itemsContainer.scrollLeft=t._getScrollLeft(0),t.context=e}),300));if(t._focused){if(t._focusedItem&&t._focusedItem.hidden&&t._filteredItems.length>0){let e=t._filteredItems[0];e.grouped&&t._filteredItems.length>1&&(e=t._filteredItems[1]),t._focus(e),t._recycle()}e.stopPropagation(),e.preventDefault(),t.disabled||("Escape"===e.key&&Smart.ListBox.DragDrop.Dragging&&t._cancelDrag(),["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control"," ","PageUp","PageDown"].indexOf(e.key)<0||(t._keysPressed[e.key]=!1))}}}_cancelDrag(){if(!Smart.ListBox.DragDrop.Dragging)return;Smart.ListBox.DragDrop.Feedback.parentNode&&Smart.ListBox.DragDrop.Feedback.parentNode.removeChild(Smart.ListBox.DragDrop.Feedback);const e=Smart.ListBox.DragDrop.Item,t=e.ownerListBox;if(t.$.fireEvent("dragCancel",{item:e,data:Smart.ListBox.DragDrop,container:t,previousContainer:t}),Smart.ListBox.DragDrop.Feedback=null,Smart.ListBox.DragDrop.DropDetails){let e=Smart.ListBox.DragDrop.DropDetails.item;e&&(e.$.removeClass("smart-list-item-line-feedback"),e.$.removeClass("smart-list-item-bottom-line-feedback"))}document.body.classList.remove("smart-dragging"),delete Smart.ListBox.DragDrop.DraggedFrom,Smart.ListBox.DragDrop.Dragging=!1,Smart.ListBox.DragDrop.Item=null,Smart.ListBox.DragDrop.DropDetails=null}_mouseWheelHandler(e){const t=this;if((t.computedHorizontalScrollBarVisibility||t.computedVerticalScrollBarVisibility)&&!t.disabled&&t.computedVerticalScrollBarVisibility){const i=t.scrollTop;if(0===i&&e.deltaY<0||i===t.scrollHeight&&e.deltaY>0)return;e.stopPropagation(),e.preventDefault(),t.scrollTo(i+t._getScrollCoefficient(e,t.offsetHeight))}}_pageDownKeyHandler(e){const t=this;if(0===e.length)return;let i,r=t._items[t.selectedIndexes[t.selectedIndexes.length-1]];if("checkBox"!==t.selectionMode&&"radioButton"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._focusedItem&&(r=t._focusedItem),!r)return;const o=t._indexOf(r);let s=r.top+t.$.itemsContainer.offsetHeight-r.height;for(let t=o;t<e.length;t++)if(e[t].top>=s){i=e[t];break}i||(i=e[e.length-1]),"checkBox"===t.selectionMode||"radioButton"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode?t._focus(i):i.selected||(t._keysPressed.Shift||t.clearSelection(),t.select(i),t._focus(i)),(i.height+i.top>t.$.itemsContainer.scrollTop+t.$.itemsContainer.offsetHeight||i.top<t.$.itemsContainer.scrollTop)&&(t.scrollTop=i.top-t.$.itemsContainer.offsetHeight+i.height)}_pageUpKeyHandler(e){const t=this;if(0===e.length)return;let i=t._items[t.selectedIndexes[t.selectedIndexes.length-1]];if("checkBox"!==t.selectionMode&&"radioButton"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._focusedItem&&(i=t._focusedItem),!i)return;const r=i.top-t.$.itemsContainer.offsetHeight;let o;for(let s=t._indexOf(i);s>0;s--)if(e[s].top<=r){o=e[s];break}o||(o=e[0]),"checkBox"===t.selectionMode||"radioButton"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode?t._focus(o):o.selected||(t._keysPressed.Shift||t.clearSelection(),t.select(o),t._focus(o)),t.scrollTop=o.top,0===t._indexOf(o)&&(t.scrollTop=0)}clearItems(){const e=this;e.clearSelection(),e.$.itemsInnerContainer.innerHTML="",e._items=[],delete e._focusedItem,e.$placeholder.removeClass("smart-hidden"),e.refresh()}_resizeHandler(e){this.refresh(e)}refresh(e){const t=this;if(!e&&!t._isUpdatingScrollBars&&t.isInitialized)return t._isUpdatingScrollBars=!0,t._initializeRecyclingItems(),t._refreshLayout(),void(t._isUpdatingScrollBars=!1);e&&e.target===t&&!t._isUpdatingScrollBars&&(t._isUpdatingScrollBars=!0,t._initializeRecyclingItems(),t._refreshLayout(),t._isUpdatingScrollBars=!1)}_indexOf(e){const t=this;if(!e)return-1;let i=t._items.indexOf(e);return-1===i&&(i=t._items.indexOf(t.getItem(e.value))),i}_incrementalSearch(){const e=this,t="radioButton"!==e.selectionMode&&"checkBox"!==e.selectionMode&&"zeroOrMany"!==e.selectionMode&&"oneOrMany"!==e.selectionMode&&"zeroOrOne"!==e.selectionMode;let i,r=0;switch(e.incrementalSearchMode){case"containsIgnoreCase":case"equalsIgnoreCase":case"startsWithIgnoreCase":case"endsWithIgnoreCase":i=e._incrementalSearchQuery.toLowerCase();break;default:i=e._incrementalSearchQuery}const o=function(i){i.grouped||i.readonly||(t?(e.selectedIndexes.length>0&&e.clearSelection(),e._focus(i),e.select(i)):e._focus(i),(i.height+i.top>e.$.itemsContainer.scrollTop+e.$.itemsContainer.offsetHeight||i.top<e.scrollTop)&&(e.scrollTop=i.top),0===e._indexOf(i)&&(e.scrollTop=0),e._indexOf(i)===e._items.length-1&&(e.scrollTop=e.scrollHeight))};0!==e._previousEntry.localeCompare(i)&&(e._incrementalSearchItems=e._queryItems(e._incrementalSearchQuery,e.incrementalSearchMode),delete e._itemPosition),e._previousEntry=i;const s=e._incrementalSearchItems.length;if(0!==s)if(1!==s)for(void 0!==e._itemPosition?e._itemPosition<s-1?r=e._itemPosition:(r=0,t?(e._incrementalSearchItems[e._itemPosition].selected=!1,e.selectedIndexes=[],e.selectedValues=[]):e._incrementalSearchItems[e._itemPosition]._focused=!1):t&&e.clearSelection();r<s;r++)if(e._incrementalSearchItems[r].selected&&t)e._incrementalSearchItems[r].selected=!1,e.selectedIndexes=[],e.selectedValues=[];else{if(t||!e._incrementalSearchItems[r]._focused)return o(e._incrementalSearchItems[r]),void(e._itemPosition=r);e._incrementalSearchItems[r]._focused=!1}else o(e._incrementalSearchItems[0])}_selectStartHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement;t.$.filterInput!==i&&t.$.editInput!==i&&e.preventDefault()}_handleArrowKeys(e){const t=this,i="radioButton"!==t.selectionMode&&"checkBox"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode;if(t.disabled||t.readonly)return;let r;if(t._focusedItem&&!t._keysPressed.Shift)r=t._indexOf(t._focusedItem),t._focusedItem._focused=!1;else{if(0===t.selectedIndexes.length)return;r=t.selectedIndexes[t.selectedIndexes.length-1]}const o=e?t._getPreviousItem(r):t._getNextItem(r);t._focus(o),i&&(t._keysPressed.Shift?t.select(o):t._items[r]!==o&&(t.clearSelection(),t.select(o))),t.ensureVisible(o)}_refreshFilter(){const e=this;if(e.filterable)return e.$.filterInput.disabled=!(!e.disabled&&!e.displayLoadingIndicator),e.$filterInputContainer.removeClass("smart-hidden"),void e.$itemsContainer.addClass("filter");e.$.filterInput.disabled=!0,e.$filterInputContainer.addClass("smart-hidden"),e.$itemsContainer.removeClass("filter")}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setLoadingIndicatorVisibility(){const e=this;e.displayLoadingIndicator?e.$loadingIndicatorContainer.hasClass("smart-visibility-hidden")?e.$loadingIndicatorContainer.removeClass("smart-visibility-hidden"):e.$loadingIndicatorContainer.removeClass("smart-hidden"):e._areCSSVarsSupported?e.$loadingIndicatorContainer.addClass("smart-hidden"):e.$loadingIndicatorContainer.addClass("smart-visibility-hidden")}_refreshLayout(){const e=this,t=e._filteredItems||e._items;if(e.__scrollHeight=null,e.__scrollWidth=null,e._height=null,e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),e.$itemsContainer.removeClass("hscroll"),e.$itemsContainer.removeClass("vscroll"),!t||null===t||0===t.length)return e.scrollWidth=0,e.scrollHeight=0,e.$filterInputContainer.removeClass("vscroll"),e.$placeholder.removeClass("smart-hidden"),e.isVirtualized&&e._recycle(),void(e.$.itemsInnerContainer.style.width="");e.$placeholder.addClass("smart-hidden");const i=2*(parseInt(getComputedStyle(e.$.itemsContainer).getPropertyValue("--smart-list-item-horizontal-offset"))||0);let r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,o=e._scrollHeight;if(e._refreshHorizontalScrollBarVisibility(r),e._refreshVerticalScrollBarVisibility(o),e.$.itemsInnerContainer.style.width="","hidden"===e.horizontalScrollBarVisibility?e.$.itemsInnerContainer.style.width=e.$.itemsContainer.offsetWidth-i:e.$.itemsInnerContainer.style.width=Math.max(e.$.itemsContainer.offsetWidth-i,-i+e.__scrollWidth)+"px",e.computedVerticalScrollBarVisibility)return r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,e._refreshHorizontalScrollBarVisibility(r),"hidden"!==e.horizontalScrollBarVisibility&&(e.$.itemsInnerContainer.style.width="",e.$.itemsInnerContainer.style.width=Math.max(e.$.itemsContainer.offsetWidth-i,-i+e.__scrollWidth)+"px"),e.computedHorizontalScrollBarVisibility&&(("visible"!==e.horizontalScrollBarVisibility||0!==e.scrollWidth||"visible"===e.horizontalScrollBarVisibility)&&(e.__scrollHeight+=e._scrollView.hScrollBar.offsetHeight),e.scrollHeight=e.__scrollHeight,e._scrollView.hScrollBar.$.hasClass("bottom-corner")&&e._scrollView.hScrollBar.refresh()),void(e.isVirtualized&&e._recycle());r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,e._refreshHorizontalScrollBarVisibility(r),e.computedHorizontalScrollBarVisibility&&(e.scrollHeight=e._scrollHeight,e._refreshVerticalScrollBarVisibility(e.scrollHeight),e.computedVerticalScrollBarVisibility&&(r=e._scrollWidth-e.$.itemsContainer.offsetWidth-e._scrollView.vScrollBar.offsetWidth,e._refreshHorizontalScrollBarVisibility(r)),e._scrollView.vScrollBar.$.hasClass("bottom-corner")&&e._scrollView.vScrollBar.refresh(),e._scrollView.hScrollBar.$.hasClass("bottom-corner")&&e._scrollView.hScrollBar.refresh()),e.isVirtualized&&e._recycle();const s=/Trident|Edge/.test(navigator.userAgent);!e.isRefreshing&&s&&setTimeout((function(){e.isRefreshing=!0,e._refreshLayout(),e.isRefreshing=!1}),50)}_styleChangedHandler(){this._refreshLayout()}_swipeLeftHandler(){}_swipeRightHandler(){}_refreshHorizontalScrollBarVisibility(e){const t=this;t.scrollWidth=e,t.$.horizontalScrollBar.refresh(),t.computedHorizontalScrollBarVisibility?(t.scrollLeft=t._getScrollLeft(t.$.itemsContainer.scrollLeft,e),t.$itemsContainer.addClass("hscroll")):t.$itemsContainer.removeClass("hscroll")}_refreshVerticalScrollBarVisibility(e){const t=this;t.scrollHeight=e,t.$.verticalScrollBar.refresh(),t.computedVerticalScrollBarVisibility?(t.$itemsContainer.addClass("vscroll"),t.$filterInputContainer.addClass("vscroll")):(t.$itemsContainer.removeClass("vscroll"),t.$filterInputContainer.removeClass("vscroll"))}_validateTemplate(e,t){if(null===t||!t)return;const i=this;return"content"in document.createElement("template")?null!==(t=document.getElementById(t))&&"content"in t?t:(i.error(i.localize("invalidTemplate",{elementType:i.nodeName.toLowerCase(),property:e})),void(i[e]=null)):(i.error(i.localize("htmlTemplateNotSuported",{elementType:i.nodeName.toLowerCase()})),void(i[e]=null))}_getItemIndexByPosition(e){const t=this;return(i=>{let r=0,o=i.length-1;if(e<=0)return 0;if(i[i.length-1].top<=e)return i.length-1;for(;;){const s=Math.floor((r+o)/2),n=i[s];if(t._isItemInPosition(n,e))return s;n.top<e?r=s+1:n.top>e&&(o=s-1)}})(t.$.filterInput.value.length>0?t._filteredItems:t._items)}_isItemInPosition(e,t){const i=e.top,r=e.top+e.height;return i<=t&&r>t}get isVirtualized(){const e=this;return e.virtualized&&e.dataSource&&e.dataSource.length>0}_recycle(){const e=this;if(!e._recyclingItems)return;let t=e._height;e._height||(t=e._height=e.$.itemsContainer.offsetHeight);let i=0;const r=e.scrollTop,o=e._getItemIndexByPosition(r),s=e.filterable&&e.$.filterInput.value.length>0?e._filteredItems:e._items,n=s[o];let l=n?n.top:0;if(e.$.itemsInnerContainer.style.left=-e.scrollLeft+"px",e.$.itemsInnerContainer.style.top=-r+l+"px",e.isUpdating++,o>=0){const n=s.length;for(let a=o;a<n;a++){const o=s[a];if(0!==o.height){if(!(l+o.height>=r&&l<=r+t))break;{const t=e._recyclingItems[i++];if(!t)break;t.setAttribute("aria-setsize",n),t.setAttribute("aria-posinset",a),t.context=document,t.dataItem=o,t.label=o.label,t.value=o.value,t.selected=o.selected,t._focused=o._focused,t.hidden=o.hidden,t.grouped=o.grouped,t.readonly=o.readonly,t.style.height=o.height+"px",e._alternateItem(t),o.title?t.title=o.title:t.title="",o.grouped?t.displayMode="plain":t.displayMode=o.displayMode,e.scrollWidth>0&&(t.style.width=e.$.itemsInnerContainer.offsetWidth+e.scrollWidth+"px"),e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&e._applyTemplate(t,!1)}l+=o.height}}}if(i<e._recyclingItems.length)for(let t=i;t<e._recyclingItems.length;t++){const t=e._recyclingItems[i++],r=t.context;t.context=document,t.hidden=!0,t.context=r}e.isUpdating--}_verticalScrollbarHandler(e){const t=this,i=e.detail.value;e&&e.stopPropagation&&e.stopPropagation(),t.isVirtualized?t._recycle():t.$.itemsContainer.scrollTop=i,t._updateTopVisibleIndex(),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached")}_applyAriaSelected(){const e=this,t=e.isVirtualized?e._recyclingItems:e._items,i=e.selectionMode;for(let e=0;e<t.length;e++){const r=t[e];r.selected?r.setAttribute("aria-selected",!0):r.readonly||r.disabled||-1===["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox"].indexOf(i)?r.removeAttribute("aria-selected"):r.setAttribute("aria-selected",!1)}}});
85
85
  Smart("smart-map",class extends Smart.BaseElement{static get properties(){return{apiKey:{type:"string",value:""},query:{type:"string",value:"sofia"},mode:{allowedTypes:["place","search","view","directions","streetview"],type:"string",value:"place"},mapType:{allowedTypes:["roadmap","satellite","hybrid","terrain"],value:"",type:"string"},heading:{type:"string",value:"210"},pitch:{type:"string",value:"10"},terrain:{type:"string",value:"terrain"},zoom:{type:"string",value:"12"}}}static get styleUrls(){return["smart.map.css"]}template(){return'<div id=mapId><iframe width="100%" height="100%" id="map" mode=\'[[mode]]\' class="smart-map-container" api-key=\'apiKey\' map-type=\'[[mapType]]\' query=\'[[query]]\' frameborder="0" alllowfullscreen aria-hidden="false" tabindex="0"> </iframe></div>'}render(){const e=this;if("roadmap"===e.$.map.mapType||"satellite"===e.mapType)return e.$.map.src="https://www.google.com/maps/embed/v1/"+e.mode+"?key="+e.apiKey+"&maptype="+e.mapType+"&q="+e.query,void super.render();if("streetview"===e.$.map.mode){const a=e.query;let t,r;window.initMap=function(){(new window.google.maps.Geocoder).geocode({address:a},(function(a,o){return o===window.google.maps.GeocoderStatus.OK?(t=a[0].geometry.location.lat(),r=a[0].geometry.location.lng()):console.error("Loading the map was not successful for the following reason: "+o),e.$.map.src="https://www.google.com/maps/embed/v1/"+e.mode+"?key="+e.apiKey+"&location="+t+","+r+"&heading="+e.heading+"&pitch="+e.pitch+"&fov=35"}))};const o=document.createElement("script");o.type="text/javascript",o.src="https://maps.googleapis.com/maps/api/js?key="+e.apiKey+"&callback=initMap&libraries=&v=weekly",o.defer=!0,document.body.appendChild(o)}if("terrain"===e.$.map.mapType){const o=e.query;var a,t,r;if(window.initTerrainMap=function(){(new window.google.maps.Geocoder).geocode({address:o},(function(o,n){if(n===window.google.maps.GeocoderStatus.OK){a=o[0].geometry.location.lat(),t=o[0].geometry.location.lng(),r=new window.google.maps.LatLng(a,t),e.querySelectorAll(".smart-container").length;const n=new window.google.maps.Map(e.querySelectorAll(".smart-container")[0],{zoom:parseInt(e.zoom),center:r,mapTypeId:"terrain"});new window.google.maps.Marker({position:r,map:n})}else console.error("Loading the map was not successful for the following reason: "+n)}))},e.querySelectorAll(".smart-container").length<2){const a=document.createElement("script");a.type="text/javascript",a.src="https://maps.googleapis.com/maps/api/js?key="+e.apiKey+"&callback=initTerrainMap",a.defer=!0,document.head.appendChild(a)}}super.render()}propertyChangedHandler(e,a,t){super.propertyChangedHandler(e,a,t),this.render()}});
86
86
  Smart("smart-numeric-text-box",class extends Smart.BaseElement{static get properties(){return{decimalSeparator:{value:".",type:"string"},dropDownAppendTo:{value:null,type:"any"},enableMouseWheelAction:{value:!1,type:"boolean"},inputFormat:{value:"integer",allowedValues:["integer","floatingPoint","complex"],type:"string"},hint:{value:"",type:"string"},label:{value:"",type:"string"},leadingZeros:{value:!1,type:"boolean"},max:{value:null,type:"any"},messages:{value:{en:{binary:"BIN",octal:"OCT",decimal:"DEC",hexadecimal:"HEX",integerOnly:"smartNumericTextBox: The property {{property}} can only be set when inputFormat is integer.",noInteger:"smartNumericTextBox: the property {{property}} cannot be set when inputFormat is integer.",significantPrecisionDigits:"smartNumericTextBox: the properties significantDigits and precisionDigits cannot be set at the same time."}},type:"object",extend:!0},min:{value:null,type:"any"},name:{value:"",type:"string"},nullable:{value:!1,type:"boolean"},opened:{value:!1,type:"boolean"},outputFormatString:{value:null,type:"string?"},placeholder:{value:"",type:"string"},dropDownEnabled:{value:!1,type:"boolean"},precisionDigits:{value:null,type:"number?"},radix:{value:10,allowedValues:["2","8","10","16",2,8,10,16,"binary","octal","decimal","hexadecimal"],type:"any"},radixDisplay:{value:!1,type:"boolean"},radixDisplayPosition:{value:"left",allowedValues:["left","right"],type:"string"},scientificNotation:{value:!1,type:"boolean"},showDropDownValues:{value:!1,type:"boolean"},showUnit:{value:!1,type:"boolean"},significantDigits:{value:null,type:"number?"},spinButtons:{value:!1,type:"boolean"},spinButtonsDelay:{value:75,type:"number"},spinButtonsInitialDelay:{value:0,type:"number"},spinButtonsPosition:{value:"right",allowedValues:["left","right"],type:"string"},spinButtonsStep:{value:"1",type:"any"},type:{value:"numeric",type:"string",defaultReflectToAttribute:!0,readonly:!0},unit:{value:"kg",type:"string"},validation:{value:"strict",allowedValues:["strict","interaction"],type:"string"},value:{value:"0",type:"any?"},wordLength:{value:"int32",allowedValues:["int8","uint8","int16","uint16","int32","uint32","int64","uint64"],type:"string"}}}static get listeners(){return{mouseenter:"_mouseenterMouseleaveHandler",mouseleave:"_mouseenterMouseleaveHandler",resize:"_resizeHandler","downButton.click":"_downButtonClickHandler","downButton.mouseenter":"_mouseenterMouseleaveHandler","downButton.mouseleave":"_mouseenterMouseleaveHandler","dropDown.click":"_dropDownItemClickHandler","dropDown.mouseout":"_mouseenterMouseleaveHandler","dropDown.mouseover":"_mouseenterMouseleaveHandler","input.blur":"_inputBlurHandler","input.change":"_inputChangeHandler","input.focus":"_inputFocusHandler","input.keydown":"_inputKeydownHandler","input.keyup":"_inputKeyupHandler","input.paste":"_inputPasteHandler","input.wheel":"_inputWheelHandler","radixDisplayButton.click":"_radixDisplayButtonClickHandler","radixDisplayButton.mouseenter":"_mouseenterMouseleaveHandler","radixDisplayButton.mouseleave":"_mouseenterMouseleaveHandler","upButton.click":"_upButtonClickHandler","upButton.mouseenter":"_mouseenterMouseleaveHandler","upButton.mouseleave":"_mouseenterMouseleaveHandler","document.down":"_documentMousedownHandler","document.up":"_documentMouseupHandler"}}static get requires(){return window.NIComplex?{"Smart.Button":"smart.button.js","Smart.Utilities.BigNumber":"smart.math.js","Smart.Utilities.NumericProcessor":"smart.numeric.js"}:{"Smart.Button":"smart.button.js","Smart.Utilities.Complex":"smart.complex.js","Smart.Utilities.BigNumber":"smart.math.js","Smart.Utilities.NumericProcessor":"smart.numeric.js"}}static get styleUrls(){return["smart.button.css","smart.numerictextbox.css"]}template(){return'<div id="container" class="smart-container" role="presentation">\n <span id="label" inner-h-t-m-l="[[label]]" class="smart-label"></span>\n <div id="radixDisplayButton" class="smart-unselectable smart-input-addon smart-drop-down-button smart-numeric-text-box-component smart-numeric-text-box-radix-display" role="button" aria-haspopup="listbox"></div>\n <input id="input" type="text" spellcheck="false" class="smart-input smart-numeric-text-box-component" placeholder="[[placeholder]]" readonly="[[readonly]]" disabled="[[disabled]]" name="[[name]]" aria-label="[[placeholder]]" />\n <div id="unitDisplay" class="smart-unselectable smart-input-addon smart-drop-down-button smart-numeric-text-box-component smart-numeric-text-box-unit-display" role="presentation"></div>\n <div id="spinButtonsContainer" class="smart-input-addon smart-numeric-text-box-component smart-spin-buttons-container" role="presentation">\n <smart-repeat-button initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" animation="[[animation]]" unfocusable id="upButton" class="smart-spin-button" aria-label="Increment" right-to-left="[[rightToLeft]]">\n <div class="smart-arrow smart-arrow-up" role="presentation" aria-hidden="true"></div>\n </smart-repeat-button>\n <smart-repeat-button initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" animation="[[animation]]" unfocusable id="downButton" class="smart-spin-button" aria-label="Decrement" right-to-left="[[rightToLeft]]">\n <div class="smart-arrow smart-arrow-down" role="presentation" aria-hidden="true"></div>\n </smart-repeat-button>\n </div>\n <ul id="dropDown" class="smart-visibility-hidden smart-drop-down smart-numeric-text-box-drop-down" role="listbox">\n <li id="dropDownItem2" class="smart-list-item" data-value="2" role="option"></li>\n <li id="dropDownItem8" class="smart-list-item" data-value="8" role="option"></li>\n <li id="dropDownItem10" class="smart-list-item" data-value="10" role="option"></li>\n <li id="dropDownItem16" class="smart-list-item" data-value="16" role="option"></li>\n </ul>\n <span id="hint" class="smart-hint smart-hidden" inner-h-t-m-l="[[hint]]"></span>\n </div>'}attached(){const e=this;super.attached(),e.isCompleted&&(e._positionDetection.dropDownAttached(),e._positionDetection.checkBrowserBounds())}detached(){const e=this;super.detached(),e.opened&&e._closeRadix(!0),e._positionDetection&&e._positionDetection.dropDownDetached()}ready(){super.ready()}render(){const e=this;e._numericProcessor=new Smart.Utilities.NumericProcessor(e,"inputFormat"),e._numberRenderer=new Smart.Utilities.NumberRenderer,e._numberRenderer.localizationObject.decimalseparator=e.decimalSeparator,e._positionDetection=new Smart.Utilities.PositionDetection(e,e.$.dropDown,e.$.container,"_closeRadix"),e._positionDetection.getDropDownParent(!0),e._dropDownListPosition="bottom",e.rightToLeft&&(e.spinButtonsPosition="right"===e.spinButtonsPosition?"left":"right"),e._setIds(),e.setAttribute("aria-describedby",e.$.unitDisplay.id+" "+e.$.hint.id),e.getAttribute("aria-labelledby")||e.setAttribute("aria-labelledby",e.$.label.id),e.$.radixDisplayButton.setAttribute("aria-owns",e.$.dropDown.id),e.rightToLeft&&null!==e.dropDownAppendTo&&e.$.dropDown.setAttribute("right-to-left",""),e._radixPrefixes={10:"d",2:"b",8:"o",16:"x"},e._regex={2:new RegExp(/^[0-1]+$/),8:new RegExp(/^[0-7]+$/),10:new RegExp(/^[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?$/),16:new RegExp(/^[0-9a-f]+$/i)},e._regexSpecial={nan:new RegExp(/^(nan)$/i),inf:new RegExp(/^((-?inf(inity)?)|([+\-]?∞))$/i),nonNumericValue:new RegExp(/^$|(^((nan)|((-?inf(inity)?)|([+\-]?∞))|(null))$)/i),exaValue:new RegExp(/^[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[E])([+\-]\d*)?i$/)},e._initialDropDownOptionsSet=!1,"left"===e.spinButtonsPosition&&e.$.container.insertBefore(e.$.spinButtonsContainer,e.$.label.nextElementSibling),"right"===e.radixDisplayPosition&&e.$.container.insertBefore(e.$.radixDisplayButton,e.$.unitDisplay.nextElementSibling),e._setInitialComponentDisplay(),e._initialAdjustments(),e._refreshShape(),e._initialized=!0,super.render()}_setIds(){const e=this;e.$.label.id||(e.$.label.id=e.id+"Label"),e.$.radixDisplayButton.id||(e.$.radixDisplayButton.id=e.id+"RadixDisplayButton"),e.$.unitDisplay.id||(e.$.unitDisplay.id=e.id+"UnitDisplay"),e.$.dropDown.id||(e.$.dropDown.id=e.id+"DropDown"),e.$.hint.id||(e.$.hint.id=e.id+"Hint")}_refreshShape(){const e=this.$.container.querySelectorAll(".smart-numeric-text-box-component:not(.smart-hidden)");Array.from(this.$.container.getElementsByClassName("smart-numeric-text-box-component")).forEach((e=>e.classList.remove("smart-numeric-text-box-component-border-left","smart-numeric-text-box-component-border-right"))),e.length>0&&(e[0].classList.add("smart-numeric-text-box-component-border-left"),e[e.length-1].classList.add("smart-numeric-text-box-component-border-right"))}val(e,t){const n=this,i=null!==e&&"object"==typeof e&&0===Object.keys(e).length;if(void 0===e||!1!==i)return n.value;{const i=n.value;if((""===e||null===e)&&null===i)return null;if(null===e)return n._triggerChangeEvent="strict"===n.validation,n._validate(!1,null),n._triggerChangeEvent=!1,void(n._programmaticValueIsSet=!0);if((e=e.toString()).toUpperCase()===i.toString().toUpperCase())return e;void 0===t?(n._triggerChangeEvent="strict"===n.validation,n._validate(!1,e),n._triggerChangeEvent=!1):n._setValue(e),n._programmaticValueIsSet=!0}}focus(){this.$.input.focus()}select(){this.$.input.select()}_updateSpinButtonsStepObject(){const e=this;e._spinButtonsStepObject=e._numericProcessor.createDescriptor(e.spinButtonsStep,!0)}_setInitialComponentDisplay(){const e=this;!1===e.spinButtons&&e.$spinButtonsContainer.addClass("smart-hidden"),!1===e.radixDisplay&&e.$radixDisplayButton.addClass("smart-hidden"),!1===e.showUnit&&e.$unitDisplay.addClass("smart-hidden")}_initialAdjustments(){const e=this;e._radixNumber=e._getRadix(e.radix),e._wordLengthNumber=e._numericProcessor.getWordLength(e.wordLength),e._validatePropertyCompatibility(),e._numericProcessor.validateMinMax(!0,!0),e._updateSpinButtonsStepObject(),e._validate(!0),e._programmaticValueIsSet=!0,e._cachedInputValue=e.$.input.value,void 0===e._editableValue&&(e._editableValue=e._cachedInputValue),e.$.radixDisplayButton.innerHTML=e._radixPrefixes[e._radixNumber],e.$.unitDisplay.innerHTML=e.unit,e.disabled&&(e.$.upButton.disabled=!0,e.$.downButton.disabled=!0),e.opened&&(e.dropDownEnabled&&!e.disabled&&null!==e.value?e._openRadix():e.opened=!1),e.$.radixDisplayButton.setAttribute("aria-expanded",e.opened),e._setFocusable()}_validatePropertyCompatibility(){const e=this;"integer"!==e.inputFormat?(10!==e._radixNumber&&e.error(e.localize("integerOnly",{property:"radix"})),e.radixDisplay&&e.error(e.localize("integerOnly",{property:"radixDisplay"})),e.dropDownEnabled&&e.error(e.localize("integerOnly",{property:"dropDownEnabled"})),"int32"!==e.wordLength&&e.error(e.localize("integerOnly",{property:"wordLength"}))):null!==e.precisionDigits&&e.error(e.localize("noInteger",{property:"precisionDigits"})),null===e.significantDigits&&null===e.precisionDigits?e.significantDigits=8:null!==e.significantDigits&&null!==e.precisionDigits&&e.error(e.localize("significantPrecisionDigits"))}_validate(e,t){const n=this;let i;if(e)i=n.value,void 0===i&&(i=n.nullable?null:"0");else if(void 0===t||null===t&&!n.nullable){if(i=n.$.input.value,i===n.value&&!0!==n._programmaticValueIsSet)return void(n.$.input.value=n._cachedInputValue)}else i=t;if(n.nullable&&(null===i||""===i))return n.value=null,n._number=null,n.$.input.value="",n._cachedInputValue="",n._editableValue="",void n._disableComponents();const a=n._numericProcessor.prepareForValidation(e,t,i);if(void 0===a)return void n._disableComponents();const r=n._numericProcessor.createDescriptor(a.value,!0,!0,!e&&void 0===t||"strict"===n.validation,e||void 0!==t,a.enteredComplexNumber);if(e){n._number=r;let e=n._renderValue(r);n.value=r.toString(),n.$.input.value=e}else n._updateValue(r);n._programmaticValueIsSet=!1,n._disableComponents()}_handleNonNumericValue(e,t,n){const i=this;if("integer"!==i.inputFormat){if(i._regexSpecial.nan.test(n))return void i._handleNaN(e);if(i._regexSpecial.inf.test(n))return void i._handleInfinity(e,t,n)}if(e){let e=i._numericProcessor.createDescriptor(0);i._number=i._validateRange(e);const t=i._renderValue(i._number);i.value=i._number.toString(),i.$.input.value=t}else if(void 0===t)i.$.input.value=i._cachedInputValue;else{const e=i._number.toString();i.value!==e&&(i.value=e)}}_handleNaN(e){const t=this;if(t.$.input.value="NaN",e)t.value=NaN,t._number=NaN;else{const e=t.value;null!==e&&"NaN"===e.toString()||(t.value=NaN,t._number=NaN,t._cachedInputValue="NaN",t._editableValue="NaN",t._triggerChangeEvent&&(t.$.fireEvent("change",{value:NaN,oldValue:e,radix:t._radixNumber}),t._updateTargetValue()))}}_handleInfinity(e,t,n){const i=this;let a,r;if("-"===n.charAt(0)?(a="∞"===n.charAt(1)?"-∞":"-Inf",r=-1/0):(a=-1!==n.indexOf("∞")?"∞":"Inf",r=1/0),r===-1/0&&i.min===-1/0||r===1/0&&i.max===1/0||void 0!==t)if(e)i.value=r,i._number=r,i.$.input.value=a;else{const e=i.value;n!==a&&(i.$.input.value=a),e!==r&&(i.value=r,i._number=r,i._cachedInputValue=a,i._editableValue=a,i._triggerChangeEvent&&(i.$.fireEvent("change",{value:r,oldValue:e,radix:i._radixNumber}),i._updateTargetValue()))}else r===-1/0?i._validate(!1,i.min):i._validate(!1,i.max)}_updateTargetValue(e){const t=this;if(t.dataset.target){const n=document.querySelector(t.dataset.target);if(n){const i=t.dataset.property,a=t.value;i&&void 0!==n[i]&&(n[i]=void 0!==e?e:a)}}}_validateRange(e){const t=this;return e=t._numericProcessor.validate(e,t._minObject,t._maxObject)}propertyChangedHandler(e,t,n){super.propertyChangedHandler(e,t,n);const i=this,a=i.$.input;function r(){!0===i._initialDropDownOptionsSet&&i._setDropDownOptions(!0),2!==i._radixNumber&&16!==i._radixNumber||(i._cachedInputValue=i._number.toString(i._radixNumber,i._wordLengthNumber,i.leadingZeros),i._editableValue=i._cachedInputValue,i.$.input.value=i._cachedInputValue)}if(n!=t)switch(e){case"disabled":i._setFocusable(),!0===n?(i.$.upButton.disabled=!0,i.$.downButton.disabled=!0):i._disableComponents();break;case"dropDownAppendTo":i._positionDetection.dropDownAppendToChangedHandler(),i.$.dropDown.removeAttribute("right-to-left"),i.rightToLeft&&null!==n&&i.$.dropDown.setAttribute("right-to-left","");break;case"unfocusable":i._setFocusable();break;case"enableMouseWheelAction":case"placeholder":case"readonly":case"spinButtonsDelay":case"spinButtonsInitialDelay":break;case"value":{if(""===n&&null===t)return;if(null===n||""===n||null===t)return i.value=t,i._triggerChangeEvent="strict"===i.validation,i._validate(!1,n),i._triggerChangeEvent=!1,void(i._programmaticValueIsSet=!0);const e=n.toString(),a=t.toString();a!==e&&(a.toUpperCase()===e.toUpperCase()&&(i.value=t),i._triggerChangeEvent="strict"===i.validation,i._validate(!1,e),i._triggerChangeEvent=!1,i._programmaticValueIsSet=!0);break}case"radix":"integer"===i.inputFormat?i._changeRadix(n):i.error(i.localize("integerOnly",{property:"radix"}));break;case"rightToLeft":null!==i.dropDownAppendTo&&(n?i.$.dropDown.setAttribute("right-to-left",""):i.$.dropDown.removeAttribute("right-to-left")),i.spinButtonsPosition=i.rightToLeft?"left":"right","left"===i.spinButtonsPosition?i.$.container.insertBefore(i.$.spinButtonsContainer,i.$.label.nextElementSibling):i.$.container.insertBefore(i.$.spinButtonsContainer,i.$.dropDown),i._refreshShape();break;case"leadingZeros":"integer"===i.inputFormat&&null!==i._number&&r();break;case"min":case"max":if(null!==n&&(i[`_${e}IsNull`]=!1),i._numericProcessor.validateMinMax("min"===e,"max"===e),"strict"===i.validation)i._triggerChangeEvent=!0,i._validate(!1,i.value),i._triggerChangeEvent=!1;else if(!1===i._regexSpecial.nonNumericValue.test(i.value)){const e=i._numericProcessor.createDescriptor(i._number),t=i._validateRange(e);!0===i._numericProcessor.compare(i.value,t)&&(i._programmaticValueIsSet=!0)}break;case"opened":n?i.dropDownEnabled&&!i.disabled&&null!==i.value?i._openRadix():(i.opened=!1,i.$.radixDisplayButton.setAttribute("aria-expanded",!1)):i._closeRadix(!1,!0);break;case"outputFormatString":n?(i._cachedInputValue=i._numberRenderer.formatNumber(i._number,n),i.$.input.value=i._cachedInputValue):(i._cachedInputValue=i._editableValue,i.$.input.value=i._editableValue);break;case"dropDownEnabled":n?("integer"!==i.inputFormat&&i.error(i.localize("integerOnly",{property:"dropDownEnabled"})),!0===i._initialDropDownOptionsSet&&i._setDropDownOptions(!0)):i.opened&&i._closeRadix(!0);break;case"spinButtons":n?i.$spinButtonsContainer.removeClass("smart-hidden"):i.$spinButtonsContainer.addClass("smart-hidden"),i._refreshShape();break;case"spinButtonsStep":i._updateSpinButtonsStepObject();break;case"significantDigits":case"precisionDigits":if("precisionDigits"===e&&"integer"===i.inputFormat&&i.error(i.localize("noInteger",{property:e})),"significantDigits"===e&&null!==i.precisionDigits?i.precisionDigits=null:"precisionDigits"===e&&null!==i.significantDigits&&(i.significantDigits=null),!1===i._regexSpecial.nonNumericValue.test(i.value)){const e=i._renderValue(i._number);a.value=e}break;case"decimalSeparator":{i._numberRenderer.localizationObject.decimalseparator=i.decimalSeparator;const e=i._discardDecimalSeparator(a.value,t),n=i._applyDecimalSeparator(e),r=i._applyDecimalSeparator(i._discardDecimalSeparator(i._editableValue,t));a.value=n,i._editableValue=r;break}case"spinButtonsPosition":"left"===n?i.$.container.insertBefore(i.$.spinButtonsContainer,i.$.label.nextElementSibling):i.$.container.insertBefore(i.$.spinButtonsContainer,i.$.dropDown),i._refreshShape();break;case"wordLength":if(i._wordLengthNumber=i._numericProcessor.getWordLength(n),"integer"===i.inputFormat&&(i._numericProcessor.validateMinMax(!0,!0),null!==i._number)){let e=i._validateRange(new Smart.Utilities.BigNumber(i._number));i._updateValue(e),i.leadingZeros&&r()}break;case"radixDisplay":n?("integer"!==i.inputFormat&&i.error(i.localize("integerOnly",{property:"radixDisplay"})),i.$radixDisplayButton.removeClass("smart-hidden")):i.$radixDisplayButton.addClass("smart-hidden"),i._refreshShape();break;case"radixDisplayPosition":"left"===n?i.$.container.insertBefore(i.$.radixDisplayButton,i.$.input):i.$.container.insertBefore(i.$.radixDisplayButton,i.$.unitDisplay.nextElementSibling),i._refreshShape();break;case"inputFormat":i._changeInputFormat(t,n);break;case"showUnit":n?i.$unitDisplay.removeClass("smart-hidden"):i.$unitDisplay.addClass("smart-hidden"),i._refreshShape();break;case"unit":i.$.unitDisplay.innerHTML=n;break;case"scientificNotation":if(!1===i._regexSpecial.nonNumericValue.test(i.value)){const e=i._renderValue(i._number);a.value=e}break;case"locale":case"messages":case"showDropDownValues":i.opened?i._setDropDownOptions():i._initialDropDownOptionsSet=!1;break;case"nullable":!0===t&&null===i.value&&i._validate(!1,"0");break;case"validation":"strict"===n&&(i._triggerChangeEvent=!0,i._validate(!1,i.value),i._triggerChangeEvent=!1)}else"string"!=typeof n&&"string"==typeof t&&(i[e]=t);i._cachedInputValue=a.value}_changeInputFormat(e,t){const n=this;n._numericProcessor=new Smart.Utilities.NumericProcessor(n,"inputFormat"),"complex"!==e?("integer"===t&&"floatingPoint"===e&&n._changeFromFloatingPointToIntegerInputFormat(),"floatingPoint"===t&&"integer"===e&&n._changeFromIntegerToFloatingPointInputFormat(),"complex"===t&&n._changeToComplexInputFormat(e),n._updateSpinButtonsStepObject(),null!==n.value&&(n._inputFormatChangedFlag=!0,n._validate(void 0,n._number.toString()),n._inputFormatChangedFlag=!1)):n._changeFromComplexInputFormat(t)}_changeFromComplexInputFormat(e){const t=this;if(t.spinButtonsStep=t._spinButtonsStepObject.realPart,t._updateSpinButtonsStepObject(),"integer"===e?(t.min===-1/0?t.min=null:t.min=t._minObject.realPart,t.max===1/0?t.max=null:t.max=t._maxObject.realPart):(t.min!==-1/0&&(t.min=t._minObject.realPart),t.max!==1/0&&(t.max=t._maxObject.realPart)),t._numericProcessor.validateMinMax(!0,!0),null!==t.value){const e=t._number;t._inputFormatChangedFlag=!0,t._validate(void 0,(void 0!==e.realPart?e.realPart:e).toString()),t._inputFormatChangedFlag=!1}}_changeFromFloatingPointToIntegerInputFormat(){const e=this;e.min===-1/0&&(e.min=null),e.max===1/0&&(e.max=null),e._numericProcessor.validateMinMax(!0,!0)}_changeFromIntegerToFloatingPointInputFormat(){const e=this;e.radixDisplay&&(e.radixDisplay=!1,e.$radixDisplayButton.addClass("smart-hidden")),10!==e._radixNumber&&(e.radix=10,e._radixNumber=10),e._minIsNull?(e.min=-1/0,e._minObject=-1/0):e._minObject=parseFloat(e._minObject.toString()),e._maxIsNull?(e.max=1/0,e._maxObject=1/0):e._maxObject=parseFloat(e._maxObject.toString()),e.dropDownEnabled&&(e.dropDownEnabled=!1)}_changeToComplexInputFormat(e){const t=this;"integer"===e&&(t.radixDisplay&&(t.radixDisplay=!1,t.$radixDisplayButton.addClass("smart-hidden")),t._minIsNull&&(t.min=null),t._maxIsNull&&(t.max=null),t.dropDownEnabled&&(t.dropDownEnabled=!1)),t._numericProcessor.validateMinMax(t.min!==-1/0,t.max!==1/0)}_updateValue(e){const t=this,n=t.$.input.value,i=e.toString(t._radixNumber,t._wordLengthNumber,t.leadingZeros),a=t._renderValue(e),r=t.value,o=t._regexSpecial.nonNumericValue.test(i);if(n===i&&n===t._cachedInputValue||(t.$.input.value=a,t._cachedInputValue=a),t._inputFormatChangedFlag||o&&a!==r||!1===o&&t._numericProcessor.compare(e,t._number)){t._number=t._numericProcessor.createDescriptor(e);const n=t._number.toString();t.value=n,t._setDropDownOptions(!0),t._triggerChangeEvent&&(t.$.fireEvent("change",{value:n,oldValue:r,radix:t._radixNumber}),t._updateTargetValue())}else t.value=t._number.toString()}_setValue(e){const t=this;t.value=e,t.$.input.value=e,t._number=t._numericProcessor.createDescriptor(e,!0),t._setDropDownOptions(!0)}_changeRadix(e){const t=this,n=t._getRadix(e),i=t.radix;if(n===t._radixNumber)return;t.radix=e,t._radixNumber=n;const a=t.$.input,r=a.value;let o,l;null!==t.value?(o=t._number.toString(n,t._wordLengthNumber,t.leadingZeros),l=t._renderValue(o)):l="",a.value=l,t._cachedInputValue=l,t.$.radixDisplayButton.innerHTML=t._radixPrefixes[n],t.$.fireEvent("radixChange",{radix:e,oldRadix:i,displayedValue:l,oldDisplayedValue:r})}_openRadix(){const e=this;if(e.$.fireEvent("opening").defaultPrevented)return void(e.opened=!1);!1===e._initialDropDownOptionsSet&&(e._setDropDownOptions(),e._initialDropDownOptionsSet=!0),null!==e._dropDownParent&&(e.$.dropDown.style.width=e.offsetWidth+"px"),e.$radixDisplayButton.addClass("smart-numeric-text-box-pressed-component"),e.$dropDown.removeClass("smart-visibility-hidden"),e.$.dropDown.style.marginTop=null,e.opened=!0,e._positionDetection.positionDropDown();const t=(1===window.devicePixelRatio?document.documentElement.clientHeight:window.innerHeight)-e.$.dropDown.getBoundingClientRect().top-e.$.dropDown.offsetHeight-parseFloat(getComputedStyle(e.$.dropDown).marginBottom);t<0&&(e.$.dropDown.style.marginTop=t+"px"),e.$.fireEvent("open",{dropDown:e.$.dropDown}),e.$.radixDisplayButton.setAttribute("aria-expanded",!0)}_closeRadix(e,t){const n=this;(n.opened||t)&&(!n.$.fireEvent("closing").defaultPrevented||e?(n.$radixDisplayButton.removeClass("smart-numeric-text-box-pressed-component"),n.$dropDown.addClass("smart-visibility-hidden"),n.opened=!1,n.$.fireEvent("close",{dropDown:n.$.dropDown}),n.$.radixDisplayButton.setAttribute("aria-expanded",!1)):n.opened=!0)}_isLeftButtonPressed(e){const t=0===e.buttons||1===e.which;return 1===e.detail.buttons||t}_isIncrementOrDecrementAllowed(){const e=this;return!e.disabled&&!e.readonly&&!1===e._regexSpecial.nonNumericValue.test(e.$.input.value)}_upButtonClickHandler(e){const t=this;t._isLeftButtonPressed(e)&&t._isIncrementOrDecrementAllowed()&&(t._up||t.$upButton.addClass("smart-numeric-text-box-pressed-component"),t._incrementOrDecrement("add"))}_downButtonClickHandler(e){const t=this;t._isLeftButtonPressed(e)&&t._isIncrementOrDecrementAllowed()&&(t._up||t.$downButton.addClass("smart-numeric-text-box-pressed-component"),t._incrementOrDecrement("subtract"))}_documentMousedownHandler(e){const t=this;if(t._up=!1,!t.opened)return;let n=e.originalEvent.target;(t.shadowRoot||t.isInShadowDOM)&&(n=e.originalEvent.composedPath()[0]),(t.shadowRoot||t).contains(n)||t.$.dropDown.contains(n)||t._closeRadix()}_documentMouseupHandler(){const e=this;e._up=!0,e.$upButton.removeClass("smart-numeric-text-box-pressed-component"),e.$downButton.removeClass("smart-numeric-text-box-pressed-component")}_radixDisplayButtonClickHandler(){const e=this;e.dropDownEnabled&&!e.disabled&&null!==e.value&&(e.opened?e._closeRadix():e._openRadix())}_dropDownItemClickHandler(e){if(e.target.$.hasClass("smart-list-item")){const t=this;let n=e.target.getAttribute("data-value");t._changeRadix(parseInt(n,10)),t._closeRadix()}}_mouseenterMouseleaveHandler(e){const t=this;e.target===t.$.dropDown||t.disabled||t.readonly||("mouseenter"===e.type?e.target.setAttribute("hover",""):e.target.removeAttribute("hover"))}_inputKeydownHandler(e){const t=this,n=e.charCode?e.charCode:e.which;40===n&&t._isIncrementOrDecrementAllowed()?t._incrementOrDecrement("subtract"):38===n&&t._isIncrementOrDecrementAllowed()&&t._incrementOrDecrement("add"),t._keydownInfo={value:t.$.input.value,specialKey:e.altKey||e.ctrlKey||e.shiftKey}}_inputKeyupHandler(e){const t=this;if(13===e.keyCode)t._suppressBlurEvent=!0,t.$.input.value!==t._cachedInputValue&&(t._triggerChangeEvent=!0,t._validate(),t._triggerChangeEvent=!1,t.$.input.blur());else if(27===e.keyCode)t.$.input.value=t._editableValue;else{const n=t.$.input.value;""!==n&&t._regex[t._radixNumber].test(n)?(t.$.upButton.disabled=!1,t.$.downButton.disabled=!1):""===n&&(t.$.upButton.disabled=!0,t.$.downButton.disabled=!0),!t._keydownInfo||t._keydownInfo.value===n||t._keydownInfo.specialKey||e.altKey||e.ctrlKey||e.shiftKey||"Control"===e.key||(t.$.fireEvent("changing",{currentValue:n,validValue:t.value,radix:t._radixNumber}),t._updateTargetValue(n))}e.preventDefault()}_inputBlurHandler(){const e=this;!0===e._suppressBlurEvent?(e._suppressBlurEvent=!1,e._formattedValue&&(e._cachedInputValue=e._formattedValue,e.$.input.value=e._formattedValue,delete e._formattedValue)):e.$.input.value!==e._editableValue?(e._triggerChangeEvent=!0,e._validate(),e._triggerChangeEvent=!1):e.$.input.value=e._cachedInputValue,e.radixDisplay&&e.$.radixDisplayButton.removeAttribute("focus"),e.opened&&e._closeRadix(),e.spinButtons&&e.$.spinButtonsContainer.removeAttribute("focus"),e.showUnit&&e.$.unitDisplay.removeAttribute("focus"),e.removeAttribute("focus"),e.$.fireEvent("blur")}_inputFocusHandler(){const e=this;e.spinButtons&&e.$.spinButtonsContainer.setAttribute("focus",""),e.radixDisplay&&e.$.radixDisplayButton.setAttribute("focus",""),e.showUnit&&e.$.unitDisplay.setAttribute("focus",""),e.opened&&e._closeRadix(),e.setAttribute("focus",""),e.outputFormatString&&(e.$.input.value=e._editableValue),e.$.fireEvent("focus")}_inputChangeHandler(e){e.stopPropagation(),e.preventDefault()}_inputPasteHandler(){const e=this;requestAnimationFrame((()=>e.$.fireEvent("changing",{currentValue:e.$.input.value,validValue:e.value,radix:e._radixNumber})))}_inputWheelHandler(e){const t=this,n=t.shadowRoot&&t.shadowRoot.activeElement||document.activeElement;t.$.input===n&&t.enableMouseWheelAction&&t._isIncrementOrDecrementAllowed()&&(e.stopPropagation(),e.preventDefault(),e.wheelDelta>0?t._incrementOrDecrement("add"):t._incrementOrDecrement("subtract"))}_getRadix(e){switch(e.toString()){case"10":case"decimal":return 10;case"2":case"binary":return 2;case"8":case"octal":return 8;case"16":case"hexadecimal":return 16}}_setDropDownOptions(e){const t=this;if(!1===t.dropDownEnabled||null===t._number)return;if(!t.showDropDownValues){if(e)return;return t.$.dropDownItem2.innerHTML=t.localize("binary"),t.$.dropDownItem8.innerHTML=t.localize("octal"),t.$.dropDownItem10.innerHTML=t.localize("decimal"),void(t.$.dropDownItem16.innerHTML=t.localize("hexadecimal"))}const n=t._wordLengthNumber,i=t.leadingZeros;t.$.dropDownItem2.innerHTML=`${t._number.toString(2,n,i)} (${t.localize("binary")})`,t.$.dropDownItem8.innerHTML=`${t._number.toString(8,n)} (${t.localize("octal")})`,t.$.dropDownItem10.innerHTML=`${t._renderValue(t._number.toString(10,n),!0)} (${t.localize("decimal")})`,t.$.dropDownItem16.innerHTML=`${t._number.toString(16,n,i)} (${t.localize("hexadecimal")})`}_incrementOrDecrement(e){const t=this,n=t.shadowRoot&&t.shadowRoot.activeElement||document.activeElement;let i=t._cachedInputValue;if(t.$.input===n&&(i=t._editableValue,t._suppressBlurEvent=!0),(t.$.input.value!==i||t._programmaticValueIsSet&&"interaction"===t.validation)&&(t._triggerChangeEvent=!0,t._validate(),t._triggerChangeEvent=!1,!1===t._isIncrementOrDecrementAllowed()))return;const a=t._numericProcessor.incrementDecrement(t._number,e,t._spinButtonsStepObject),r=t._validateRange(a);t._triggerChangeEvent=!0,t._updateValue(r),t._triggerChangeEvent=!1}_toBigNumberDecimal(e,t){const n=this;let i;return 10===t?i=new Smart.Utilities.BigNumber(e):n._unsigned||!1===n._isNegative(e,t)?n._wordLengthNumber<64?(i=parseInt(e,t),i=new Smart.Utilities.BigNumber(i)):i=n._getBigNumberFrom64BitBinOctHex(e,t):(i=n._getNegativeDecimal(e,t),i=new Smart.Utilities.BigNumber(i)),i}_isNegative(e,t){const n=this,i=e.length,a=e.charAt(0).toLowerCase();if(2===t)return i===n._wordLengthNumber&&"1"===a;if(8!==t)return i===n._wordLengthNumber/4&&-1!==["8","9","a","b","c","d","e","f"].indexOf(a);switch(n._wordLengthNumber){case 8:return 3===i&&("2"===a||"3"===a);case 16:return 5===i&&"1"===a;case 32:return 11===i&&("2"===a||"3"===a);case 64:return 22===i&&"1"===a}}_getBigNumberFrom64BitBinOctHex(e,t){let n=new Smart.Utilities.BigNumber(0);for(let i=e.length-1;i>=0;i--){let a=new Smart.Utilities.BigNumber(parseInt(e.charAt(i),t));n=n.add(a.multiply(new Smart.Utilities.BigNumber(t).pow(e.length-1-i)))}return n}_getNegativeDecimal(e,t){const n=this;let i=e;if(8===t){let t=[];for(let n=0;n<e.length;n++){let i=parseInt(e.charAt(n),8).toString(2);for(;3!==i.length;)i=`0${i}`;t.push(i)}for(i=t.join("");"0"===i.charAt(0);)i=i.slice(1)}else if(16===t){let t=[];for(let n=0;n<e.length;n++){let i=parseInt(e.charAt(n),16).toString(2);for(;4!==i.length;)i=`0${i}`;t.push(i)}i=t.join("")}let a=i.replace(/0/g,"a");return a=a.replace(/1/g,"b"),a=a.replace(/a/g,"1"),a=a.replace(/b/g,"0"),this._wordLengthNumber<64?a=-1*(parseInt(a,2)+1):(a=n._getBigNumberFrom64BitBinOctHex(a,t),a=a.add(1).negate()),a}_discardDecimalSeparator(e,t){if(void 0===t&&(t=this.decimalSeparator),"."!==t&&e!==1/0&&e!==-1/0){let n=new RegExp(t,"g");return e.replace(n,".")}return e}_applyDecimalSeparator(e){const t=this;return"string"!=typeof e&&(e=e.toString()),"."!==t.decimalSeparator&&(e=e.replace(/\./g,t.decimalSeparator)),e}_renderValue(e,t){const n=this,i=e,a=10===n._radixNumber||!0===t;if(e=n._numericProcessor.render(e,a),"."!==n.decimalSeparator&&a&&(e=n._applyDecimalSeparator(e)),!0!==t&&(n._editableValue=e,n.outputFormatString&&10===n._radixNumber)){const e=(n.shadowRoot||n.getRootNode()).activeElement||document.activeElement,t=n._numberRenderer.formatNumber(i,n.outputFormatString);if(e!==n.$.input)return t;n._formattedValue=t}return e}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.$.input.tabIndex=-1:e.$.input.removeAttribute("tabindex")}_disableComponents(){const e=this;if(e.disabled)return;const t=e.value;null===t||"NaN"===t.toString()||Math.abs(t)===1/0?(e.$.upButton.disabled=!0,e.$.downButton.disabled=!0):(e.$.upButton.disabled=!1,e.$.downButton.disabled=!1)}_resizeHandler(){this.refresh()}refresh(){const e=this;e.opened&&e._closeRadix(!0)}});