smart-webcomponents-react 14.2.39 → 14.2.92

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 (399) hide show
  1. package/accordion/accordion.esm.js +2 -2
  2. package/accordion/accordion.umd.js +2 -2
  3. package/alertwindow/alertwindow.esm.js +1 -1
  4. package/alertwindow/alertwindow.umd.js +1 -1
  5. package/array/array.esm.js +1 -1
  6. package/array/array.umd.js +1 -1
  7. package/barcode/barcode.esm.js +1 -1
  8. package/barcode/barcode.umd.js +1 -1
  9. package/breadcrumb/breadcrumb.esm.js +1 -1
  10. package/breadcrumb/breadcrumb.umd.js +1 -1
  11. package/button/button.esm.js +4 -4
  12. package/button/button.umd.js +4 -4
  13. package/buttongroup/buttongroup.esm.js +1 -1
  14. package/buttongroup/buttongroup.umd.js +1 -1
  15. package/calendar/calendar.esm.js +1 -1
  16. package/calendar/calendar.umd.js +1 -1
  17. package/card/card.esm.js +1 -1
  18. package/card/card.umd.js +1 -1
  19. package/cardview/cardview.esm.js +1 -1
  20. package/cardview/cardview.umd.js +1 -1
  21. package/carousel/carousel.esm.js +1 -1
  22. package/carousel/carousel.umd.js +1 -1
  23. package/chart/chart.esm.js +1 -1
  24. package/chart/chart.umd.js +1 -1
  25. package/checkbox/checkbox.esm.js +1 -1
  26. package/checkbox/checkbox.umd.js +1 -1
  27. package/checkinput/checkinput.esm.js +1 -1
  28. package/checkinput/checkinput.umd.js +1 -1
  29. package/chip/chip.esm.js +1 -1
  30. package/chip/chip.umd.js +1 -1
  31. package/colorinput/colorinput.esm.js +1 -1
  32. package/colorinput/colorinput.umd.js +1 -1
  33. package/colorpanel/colorpanel.esm.js +1 -1
  34. package/colorpanel/colorpanel.umd.js +1 -1
  35. package/colorpicker/colorpicker.esm.js +1 -1
  36. package/colorpicker/colorpicker.umd.js +1 -1
  37. package/columnpanel/columnpanel.esm.js +1 -1
  38. package/columnpanel/columnpanel.umd.js +1 -1
  39. package/combobox/combobox.esm.js +3 -3
  40. package/combobox/combobox.umd.js +3 -3
  41. package/countryinput/countryinput.esm.js +1 -1
  42. package/countryinput/countryinput.umd.js +1 -1
  43. package/customizationdialog/customizationdialog.esm.js +1 -1
  44. package/customizationdialog/customizationdialog.umd.js +1 -1
  45. package/dateinput/dateinput.esm.js +1 -1
  46. package/dateinput/dateinput.umd.js +1 -1
  47. package/daterangeinput/daterangeinput.esm.js +1 -1
  48. package/daterangeinput/daterangeinput.umd.js +1 -1
  49. package/datetimepicker/datetimepicker.esm.js +1 -1
  50. package/datetimepicker/datetimepicker.umd.js +1 -1
  51. package/dialogwindow/dialogwindow.esm.js +1 -1
  52. package/dialogwindow/dialogwindow.umd.js +1 -1
  53. package/dockinglayout/dockinglayout.esm.js +1 -1
  54. package/dockinglayout/dockinglayout.umd.js +1 -1
  55. package/dropdownbutton/dropdownbutton.esm.js +1 -1
  56. package/dropdownbutton/dropdownbutton.umd.js +1 -1
  57. package/dropdownlist/dropdownlist.esm.js +3 -3
  58. package/dropdownlist/dropdownlist.umd.js +3 -3
  59. package/editor/editor.esm.js +1 -1
  60. package/editor/editor.umd.js +1 -1
  61. package/element/element.esm.js +1 -1
  62. package/element/element.umd.js +1 -1
  63. package/fileupload/fileupload.esm.js +1 -1
  64. package/fileupload/fileupload.umd.js +1 -1
  65. package/filterbuilder/filterbuilder.esm.js +1 -1
  66. package/filterbuilder/filterbuilder.umd.js +1 -1
  67. package/filterpanel/filterpanel.esm.js +1 -1
  68. package/filterpanel/filterpanel.umd.js +1 -1
  69. package/form/form.esm.js +3 -3
  70. package/form/form.umd.js +3 -3
  71. package/ganttchart/ganttchart.esm.js +1 -1
  72. package/ganttchart/ganttchart.umd.js +1 -1
  73. package/gauge/gauge.esm.js +1 -1
  74. package/gauge/gauge.umd.js +1 -1
  75. package/grid/grid.esm.js +1 -1
  76. package/grid/grid.umd.js +1 -1
  77. package/grouppanel/grouppanel.esm.js +1 -1
  78. package/grouppanel/grouppanel.umd.js +1 -1
  79. package/index.d.ts +12 -0
  80. package/input/input.esm.js +1 -1
  81. package/input/input.umd.js +1 -1
  82. package/kanban/kanban.esm.js +1 -1
  83. package/kanban/kanban.umd.js +1 -1
  84. package/layout/layout.esm.js +5 -5
  85. package/layout/layout.umd.js +5 -5
  86. package/led/led.esm.js +1 -1
  87. package/led/led.umd.js +1 -1
  88. package/listbox/listbox.esm.js +3 -3
  89. package/listbox/listbox.umd.js +3 -3
  90. package/listmenu/listmenu.esm.js +3 -3
  91. package/listmenu/listmenu.umd.js +3 -3
  92. package/map/map.esm.js +1 -1
  93. package/map/map.umd.js +1 -1
  94. package/maskedtextbox/maskedtextbox.esm.js +1 -1
  95. package/maskedtextbox/maskedtextbox.umd.js +1 -1
  96. package/menu/menu.esm.js +3 -3
  97. package/menu/menu.umd.js +3 -3
  98. package/multicolumnfilterpanel/multicolumnfilterpanel.esm.js +1 -1
  99. package/multicolumnfilterpanel/multicolumnfilterpanel.umd.js +1 -1
  100. package/multicomboinput/multicomboinput.esm.js +1 -1
  101. package/multicomboinput/multicomboinput.umd.js +1 -1
  102. package/multiinput/multiinput.esm.js +1 -1
  103. package/multiinput/multiinput.umd.js +1 -1
  104. package/multilinetextbox/multilinetextbox.esm.js +3 -3
  105. package/multilinetextbox/multilinetextbox.umd.js +3 -3
  106. package/multilinewindow/multilinewindow.esm.js +1 -1
  107. package/multilinewindow/multilinewindow.umd.js +1 -1
  108. package/multisplitbutton/multisplitbutton.esm.js +3 -3
  109. package/multisplitbutton/multisplitbutton.umd.js +3 -3
  110. package/numberinput/numberinput.esm.js +1 -1
  111. package/numberinput/numberinput.umd.js +1 -1
  112. package/numerictextbox/numerictextbox.esm.js +1 -1
  113. package/numerictextbox/numerictextbox.umd.js +1 -1
  114. package/package.json +1 -1
  115. package/pager/pager.esm.js +1 -1
  116. package/pager/pager.umd.js +1 -1
  117. package/passwordinput/passwordinput.esm.js +1 -1
  118. package/passwordinput/passwordinput.umd.js +1 -1
  119. package/passwordtextbox/passwordtextbox.esm.js +1 -1
  120. package/passwordtextbox/passwordtextbox.umd.js +1 -1
  121. package/path/path.esm.js +1 -1
  122. package/path/path.umd.js +1 -1
  123. package/phoneinput/phoneinput.esm.js +1 -1
  124. package/phoneinput/phoneinput.umd.js +1 -1
  125. package/pivottable/pivottable.esm.js +1 -1
  126. package/pivottable/pivottable.umd.js +1 -1
  127. package/progressbar/progressbar.esm.js +2 -2
  128. package/progressbar/progressbar.umd.js +2 -2
  129. package/progresswindow/progresswindow.esm.js +1 -1
  130. package/progresswindow/progresswindow.umd.js +1 -1
  131. package/promptwindow/promptwindow.esm.js +1 -1
  132. package/promptwindow/promptwindow.umd.js +1 -1
  133. package/qrcode/qrcode.esm.js +1 -1
  134. package/qrcode/qrcode.umd.js +1 -1
  135. package/querybuilder/querybuilder.d.ts +7 -0
  136. package/querybuilder/querybuilder.esm.js +2 -2
  137. package/querybuilder/querybuilder.umd.js +2 -2
  138. package/radiobutton/radiobutton.esm.js +1 -1
  139. package/radiobutton/radiobutton.umd.js +1 -1
  140. package/rating/rating.esm.js +1 -1
  141. package/rating/rating.umd.js +1 -1
  142. package/scheduler/scheduler.esm.js +1 -1
  143. package/scheduler/scheduler.umd.js +1 -1
  144. package/scrollbar/scrollbar.esm.js +1 -1
  145. package/scrollbar/scrollbar.umd.js +1 -1
  146. package/slider/slider.esm.js +1 -1
  147. package/slider/slider.umd.js +1 -1
  148. package/sortable/sortable.esm.js +1 -1
  149. package/sortable/sortable.umd.js +1 -1
  150. package/sortpanel/sortpanel.esm.js +1 -1
  151. package/sortpanel/sortpanel.umd.js +1 -1
  152. package/source/modules/smart.accordion.js +1 -1
  153. package/source/modules/smart.array.js +1 -1
  154. package/source/modules/smart.barcode.js +1 -1
  155. package/source/modules/smart.breadcrumb.js +1 -1
  156. package/source/modules/smart.button.js +1 -1
  157. package/source/modules/smart.buttongroup.js +1 -1
  158. package/source/modules/smart.calendar.js +2 -2
  159. package/source/modules/smart.card.js +1 -1
  160. package/source/modules/smart.cardview.js +2 -2
  161. package/source/modules/smart.carousel.js +1 -1
  162. package/source/modules/smart.chart.js +1 -1
  163. package/source/modules/smart.checkbox.js +1 -1
  164. package/source/modules/smart.checkinput.js +1 -1
  165. package/source/modules/smart.chip.js +1 -1
  166. package/source/modules/smart.colorinput.js +1 -1
  167. package/source/modules/smart.colorpanel.js +1 -1
  168. package/source/modules/smart.colorpicker.js +1 -1
  169. package/source/modules/smart.combobox.js +1 -1
  170. package/source/modules/smart.common.js +21 -21
  171. package/source/modules/smart.countryinput.js +1 -1
  172. package/source/modules/smart.dateinput.js +3 -3
  173. package/source/modules/smart.daterangeinput.js +3 -3
  174. package/source/modules/smart.datetimepicker.js +2 -2
  175. package/source/modules/smart.dockinglayout.js +1 -1
  176. package/source/modules/smart.dropdownbutton.js +1 -1
  177. package/source/modules/smart.dropdownlist.js +1 -1
  178. package/source/modules/smart.editor.js +1 -1
  179. package/source/modules/smart.element.js +1 -1
  180. package/source/modules/smart.fileupload.js +1 -1
  181. package/source/modules/smart.form.js +1 -1
  182. package/source/modules/smart.formulaparser.js +1 -1
  183. package/source/modules/smart.ganttchart.js +3 -3
  184. package/source/modules/smart.gauge.js +1 -1
  185. package/source/modules/smart.grid.js +16 -16
  186. package/source/modules/smart.gridpanel.js +3 -3
  187. package/source/modules/smart.input.js +1 -1
  188. package/source/modules/smart.kanban.js +4 -4
  189. package/source/modules/smart.layout.js +1 -1
  190. package/source/modules/smart.led.js +1 -1
  191. package/source/modules/smart.listbox.js +1 -1
  192. package/source/modules/smart.listmenu.js +1 -1
  193. package/source/modules/smart.map.js +1 -1
  194. package/source/modules/smart.maskedtextbox.js +1 -1
  195. package/source/modules/smart.menu.js +1 -1
  196. package/source/modules/smart.multicomboinput.js +2 -2
  197. package/source/modules/smart.multiinput.js +1 -1
  198. package/source/modules/smart.multilinetextbox.js +1 -1
  199. package/source/modules/smart.multisplitbutton.js +1 -1
  200. package/source/modules/smart.numberinput.js +1 -1
  201. package/source/modules/smart.numerictextbox.js +1 -1
  202. package/source/modules/smart.pager.js +1 -1
  203. package/source/modules/smart.passwordinput.js +1 -1
  204. package/source/modules/smart.passwordtextbox.js +1 -1
  205. package/source/modules/smart.path.js +1 -1
  206. package/source/modules/smart.phoneinput.js +1 -1
  207. package/source/modules/smart.pivottable.js +3 -3
  208. package/source/modules/smart.progressbar.js +1 -1
  209. package/source/modules/smart.qrcode.js +1 -1
  210. package/source/modules/smart.querybuilder.js +3 -3
  211. package/source/modules/smart.radiobutton.js +1 -1
  212. package/source/modules/smart.rating.js +1 -1
  213. package/source/modules/smart.router.js +1 -1
  214. package/source/modules/smart.scheduler.js +3 -3
  215. package/source/modules/smart.scrollbar.js +1 -1
  216. package/source/modules/smart.slider.js +1 -1
  217. package/source/modules/smart.sortable.js +1 -1
  218. package/source/modules/smart.splitter.js +1 -1
  219. package/source/modules/smart.switchbutton.js +1 -1
  220. package/source/modules/smart.table.js +2 -2
  221. package/source/modules/smart.tabs.js +1 -1
  222. package/source/modules/smart.tank.js +1 -1
  223. package/source/modules/smart.textarea.js +1 -1
  224. package/source/modules/smart.textbox.js +1 -1
  225. package/source/modules/smart.timeinput.js +1 -1
  226. package/source/modules/smart.timepicker.js +1 -1
  227. package/source/modules/smart.toast.js +1 -1
  228. package/source/modules/smart.tooltip.js +1 -1
  229. package/source/modules/smart.tree.js +1 -1
  230. package/source/modules/smart.validator.js +1 -1
  231. package/source/modules/smart.window.js +1 -1
  232. package/source/smart.accordion.js +1 -1
  233. package/source/smart.ajax.js +1 -1
  234. package/source/smart.array.js +1 -1
  235. package/source/smart.barcode.js +1 -1
  236. package/source/smart.bootstrap.js +1 -1
  237. package/source/smart.breadcrumb.js +1 -1
  238. package/source/smart.button.js +1 -1
  239. package/source/smart.buttongroup.js +1 -1
  240. package/source/smart.calendar.js +2 -2
  241. package/source/smart.card.js +1 -1
  242. package/source/smart.cardview.js +1 -1
  243. package/source/smart.carousel.js +1 -1
  244. package/source/smart.chart.annotations.js +1 -1
  245. package/source/smart.chart.api.js +1 -1
  246. package/source/smart.chart.core.js +1 -1
  247. package/source/smart.chart.js +1 -1
  248. package/source/smart.chart.rangeselector.js +1 -1
  249. package/source/smart.chart.waterfall.js +1 -1
  250. package/source/smart.checkbox.js +1 -1
  251. package/source/smart.checkinput.js +1 -1
  252. package/source/smart.chip.js +1 -1
  253. package/source/smart.colorinput.js +1 -1
  254. package/source/smart.colorpanel.js +1 -1
  255. package/source/smart.colorpicker.js +1 -1
  256. package/source/smart.combobox.js +1 -1
  257. package/source/smart.complex.js +1 -1
  258. package/source/smart.core.js +1 -1
  259. package/source/smart.countryinput.js +1 -1
  260. package/source/smart.data.js +1 -1
  261. package/source/smart.date.js +1 -1
  262. package/source/smart.dateformatpanel.js +1 -1
  263. package/source/smart.dateinput.js +2 -2
  264. package/source/smart.daterangeinput.js +1 -1
  265. package/source/smart.datetimepicker.js +1 -1
  266. package/source/smart.dockinglayout.js +1 -1
  267. package/source/smart.draw.js +1 -1
  268. package/source/smart.dropdownbutton.js +1 -1
  269. package/source/smart.dropdownlist.js +1 -1
  270. package/source/smart.editor.js +1 -1
  271. package/source/smart.element.js +1 -1
  272. package/source/smart.elements.js +18 -18
  273. package/source/smart.export.js +1 -1
  274. package/source/smart.fileupload.js +1 -1
  275. package/source/smart.filter.js +1 -1
  276. package/source/smart.filterbuilder.js +2 -2
  277. package/source/smart.filterpanel.js +2 -2
  278. package/source/smart.form.js +1 -1
  279. package/source/smart.format.js +1 -1
  280. package/source/smart.formulaparser.js +1 -1
  281. package/source/smart.ganttchart.js +1 -1
  282. package/source/smart.gauge.js +1 -1
  283. package/source/smart.grid.cell.js +2 -2
  284. package/source/smart.grid.chart.js +1 -1
  285. package/source/smart.grid.column.js +1 -1
  286. package/source/smart.grid.core.js +2 -2
  287. package/source/smart.grid.dialog.js +2 -2
  288. package/source/smart.grid.edit.js +2 -2
  289. package/source/smart.grid.export.js +1 -1
  290. package/source/smart.grid.filter.js +1 -1
  291. package/source/smart.grid.group.js +1 -1
  292. package/source/smart.grid.js +1 -1
  293. package/source/smart.grid.menu.js +2 -2
  294. package/source/smart.grid.pager.js +1 -1
  295. package/source/smart.grid.reorder.js +1 -1
  296. package/source/smart.grid.resize.js +2 -2
  297. package/source/smart.grid.row.js +2 -2
  298. package/source/smart.grid.select.js +2 -2
  299. package/source/smart.grid.sort.js +1 -1
  300. package/source/smart.grid.toolbar.js +2 -2
  301. package/source/smart.grid.tree.js +1 -1
  302. package/source/smart.grid.view.js +2 -2
  303. package/source/smart.gridpanel.js +1 -1
  304. package/source/smart.input.js +1 -1
  305. package/source/smart.kanban.js +2 -2
  306. package/source/smart.layout.js +1 -1
  307. package/source/smart.led.js +1 -1
  308. package/source/smart.listbox.js +1 -1
  309. package/source/smart.listmenu.js +1 -1
  310. package/source/smart.map.js +1 -1
  311. package/source/smart.maskedtextbox.js +1 -1
  312. package/source/smart.math.js +1 -1
  313. package/source/smart.menu.js +1 -1
  314. package/source/smart.multicomboinput.js +2 -2
  315. package/source/smart.multiinput.js +1 -1
  316. package/source/smart.multilinetextbox.js +1 -1
  317. package/source/smart.multisplitbutton.js +1 -1
  318. package/source/smart.numberformatpanel.js +1 -1
  319. package/source/smart.numberinput.js +1 -1
  320. package/source/smart.numeric.js +1 -1
  321. package/source/smart.numerictextbox.js +1 -1
  322. package/source/smart.pager.js +1 -1
  323. package/source/smart.passwordinput.js +1 -1
  324. package/source/smart.passwordtextbox.js +1 -1
  325. package/source/smart.path.js +1 -1
  326. package/source/smart.phoneinput.js +1 -1
  327. package/source/smart.pivottable.js +1 -1
  328. package/source/smart.powerbutton.js +1 -1
  329. package/source/smart.progressbar.js +1 -1
  330. package/source/smart.qrcode.js +1 -1
  331. package/source/smart.radiobutton.js +1 -1
  332. package/source/smart.rating.js +1 -1
  333. package/source/smart.router.js +1 -1
  334. package/source/smart.scheduler.js +2 -2
  335. package/source/smart.scrollbar.js +1 -1
  336. package/source/smart.slider.js +1 -1
  337. package/source/smart.sortable.js +1 -1
  338. package/source/smart.splitter.js +1 -1
  339. package/source/smart.switchbutton.js +1 -1
  340. package/source/smart.table.js +2 -2
  341. package/source/smart.tabs.js +1 -1
  342. package/source/smart.tank.js +1 -1
  343. package/source/smart.textarea.js +1 -1
  344. package/source/smart.textbox.js +1 -1
  345. package/source/smart.tickintervalhandler.js +1 -1
  346. package/source/smart.timeinput.js +1 -1
  347. package/source/smart.timepicker.js +1 -1
  348. package/source/smart.toast.js +1 -1
  349. package/source/smart.tooltip.js +1 -1
  350. package/source/smart.tree.js +1 -1
  351. package/source/smart.validationpanel.js +1 -1
  352. package/source/smart.validator.js +1 -1
  353. package/source/smart.window.js +1 -1
  354. package/source/styles/components/smart.base.css +1 -1
  355. package/source/styles/components/smart.grid.css +1 -1
  356. package/source/styles/default/scss/smart.grid.scss +57 -3
  357. package/source/styles/default/smart.grid.css +41 -3
  358. package/source/styles/default/smart.variables.css +8 -0
  359. package/source/styles/font/smart-icons.eot +0 -0
  360. package/source/styles/font/smart-icons.svg +296 -286
  361. package/source/styles/font/smart-icons.ttf +0 -0
  362. package/source/styles/font/smart-icons.woff +0 -0
  363. package/source/styles/font/smart-icons.woff2 +0 -0
  364. package/source/styles/smart.default.css +2 -2
  365. package/source/typescript/smart.elements.d.ts +12 -0
  366. package/source/typescript/smart.grid.d.ts +5 -0
  367. package/source/typescript/smart.querybuilder.d.ts +7 -0
  368. package/splitter/splitter.esm.js +3 -3
  369. package/splitter/splitter.umd.js +3 -3
  370. package/switchbutton/switchbutton.esm.js +1 -1
  371. package/switchbutton/switchbutton.umd.js +1 -1
  372. package/table/table.esm.js +1 -1
  373. package/table/table.umd.js +1 -1
  374. package/tabs/tabs.esm.js +3 -3
  375. package/tabs/tabs.umd.js +3 -3
  376. package/tabswindow/tabswindow.esm.js +1 -1
  377. package/tabswindow/tabswindow.umd.js +1 -1
  378. package/tank/tank.esm.js +1 -1
  379. package/tank/tank.umd.js +1 -1
  380. package/textarea/textarea.esm.js +1 -1
  381. package/textarea/textarea.umd.js +1 -1
  382. package/textbox/textbox.esm.js +3 -3
  383. package/textbox/textbox.umd.js +3 -3
  384. package/timeinput/timeinput.esm.js +1 -1
  385. package/timeinput/timeinput.umd.js +1 -1
  386. package/timepicker/timepicker.esm.js +1 -1
  387. package/timepicker/timepicker.umd.js +1 -1
  388. package/toast/toast.esm.js +1 -1
  389. package/toast/toast.umd.js +1 -1
  390. package/tooltip/tooltip.esm.js +1 -1
  391. package/tooltip/tooltip.umd.js +1 -1
  392. package/tree/tree.esm.js +3 -3
  393. package/tree/tree.umd.js +3 -3
  394. package/validator/validator.esm.js +1 -1
  395. package/validator/validator.umd.js +1 -1
  396. package/waitwindow/waitwindow.esm.js +1 -1
  397. package/waitwindow/waitwindow.umd.js +1 -1
  398. package/window/window.esm.js +1 -1
  399. package/window/window.umd.js +1 -1
@@ -17,7 +17,7 @@ Smart("smart-button",class extends Smart.ContentElement{static get properties(){
17
17
  /***/ 5810:
18
18
  /***/ (() => {
19
19
 
20
- Smart("smart-calendar",class extends Smart.BaseElement{static get properties(){return{animationSettings:{value:null,type:"object"},calendarMode:{value:"default",allowedValues:["default","classic"],type:"string"},dayNameFormat:{value:"firstTwoLetters",allowedValues:["narrow","firstTwoLetters","long","short"],type:"string"},dateFormatFunction:{value:null,type:"function"},disableAutoNavigation:{value:!1,type:"boolean"},displayMode:{value:"month",allowedValues:["month","year","decade"],type:"string"},displayModeView:{value:"table",allowedValues:["table","list"],type:"string"},dropDownHeight:{value:"200",type:"string"},dropDownWidth:{value:"",type:"string"},firstDayOfWeek:{value:0,type:"number",defaultValue:0,validator:"_firstDayOfWeekValidator"},footerTemplate:{value:null,type:"any"},headerTemplate:{value:null,type:"any"},hideDayNames:{value:!1,type:"boolean"},hideOtherMonthDays:{value:!1,type:"boolean"},hideTooltipArrow:{value:!1,type:"boolean"},importantDates:{value:[],type:"array",defaultValue:[]},importantDatesTemplate:{value:null,type:"any"},max:{value:new Date(2100,1,1),type:"any",defaultValue:new Date(2100,1,1)},min:{value:new Date(1900,1,1),type:"any",defaultValue:new Date(1900,1,1)},months:{value:1,type:"number",defaultValue:1,validator:"_monthsValidator"},monthNameFormat:{value:"long",allowedValues:["narrow","firstTwoLetters","long","short","2-digit","numeric"],type:"string"},name:{value:"",type:"string"},restrictedDates:{value:[],type:"array",defaultValue:[]},scrollButtonsNavigationMode:{value:"landscape",allowedValues:["portrait","landscape"],type:"string"},scrollButtonsPosition:{value:"both",allowedValues:["near","far","both"],type:"string"},selectedDates:{value:[],reflectToAttribute:!1,type:"array"},selectionMode:{value:"default",allowedValues:["none","default","one","oneExtended","many","zeroOrMany","oneOrMany","zeroOrOne","week","range"],type:"string"},spinButtonsDelay:{value:80,type:"number"},spinButtonsInitialDelay:{value:0,type:"number"},titleTemplate:{value:null,type:"any"},tooltip:{value:!1,type:"boolean"},tooltipArrow:{value:!0,type:"boolean"},tooltipArrowDirection:{allowedValues:["bottom","top","left","right","none"],value:"bottom",type:"string"},tooltipDelay:{value:100,type:"number"},tooltipOffset:{value:[],type:"array"},tooltipPosition:{value:"auto",allowedValues:["auto","bottom","top","left","right","absolute"],type:"string"},tooltipTemplate:{value:null,type:"any"},view:{value:"portrait",allowedValues:["landscape","portrait"],type:"string"},viewSections:{value:["header"],type:"array"},weekNumbers:{value:!1,type:"boolean"},weeks:{value:6,type:"number",defaultValue:6,validator:"_weeksValidator"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"}}}static get listeners(){return{"container.down":"_downHandler","document.up":"_documentUpHandler","body.move":"_moveHandler","container.wheel":"_containerWheelHandler","body.focus":"_bodyFocusStateHandler","body.blur":"_bodyBlurStateHandler","header.click":"_headerClickHandler","header.change":"_headerChangeHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",mouseenter:"_mouseEventsHandler",mouseleave:"_mouseEventsHandler","container.mouseover":"_mouseEventsHandler","container.mouseout":"_mouseEventsHandler","container.open":"_popupEventHandler","container.close":"_popupEventHandler"}}static get methods(){return{select:"select(date=new Date(): date|string): void",clearSelection:"clearSelection(): void",today:"today(): date",navigate:"navigate(step: date|string|int): bool"}}static get styleUrls(){return["smart.calendar.css"]}template(){return'<div id="container" role="presentation">\n <div id="title" class="smart-calendar-title" role="heading" aria-level="1">\n <div id="yearContainer" class="smart-calendar-year-container" role="button"></div>\n <div id="dateContainer" class="smart-calendar-date-container smart-calendar-selected" role="button"></div>\n </div>\n <div id="calendarContainer" class="smart-calendar-container">\n <div id="header" class="smart-calendar-header">\n <smart-repeat-button prev-month class="smart-calendar-button" id="previousMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <div id="dateElement" class="smart-calendar-date-element" role="presentation">\n <div id="defaultHeaderDate" role="button"></div>\n <div id="classicHeaderDate">\n <div id="monthElement" class="smart-calendar-month-element" disabled="[[disabled]]" role="presentation">\n </div>\n <input class="smart-calendar-year-element" id="yearElement" disabled="[[disabled]]" readonly="[[readonly]]" aria-label="Year" />\n <span class="smart-calendar-year-elements">\n <smart-repeat-button next-year class="smart-calendar-button" id="nextYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <smart-repeat-button prev-year class="smart-calendar-button" id="previousYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </span>\n </div>\n </div>\n <smart-repeat-button next-month class="smart-calendar-button" id="nextMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </div>\n <div id="body" class="smart-content smart-calendar-body" role="presentation">\n <div id="monthsContainer" class="smart-calendar-months-container" role="presentation">\n <div id="month" class="smart-calendar-month" role="grid">\n <div id="monthName" class="smart-calendar-month-name"></div>\n <div id="weekTitles" class="smart-calendar-week-titles" role="row">\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n </div>\n <div id="weeks" class="smart-calendar-weeks" role="rowgroup">\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n </div>\n </div>\n </div>\n <div id="dateViewContainer" class="smart-calendar-date-view-container smart-hidden">\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n </div>\n <div id="monthsSeparator" class="smart-calendar-month-separator"></div>\n <div id="nextMonthsContainer" class="smart-calendar-next-months-container" aria-hidden="true"></div>\n <div id="animationPanel" class="smart-calendar-animation-panel smart-hidden"></div>\n </div>\n <div id="footer" class="smart-calendar-footer smart-hidden">\n <div id="selectedDatesRange"></div>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>\n </div>'}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const a=e.dataset.property,n=e.selectedDates.toString();a&&void 0!==t[a]&&(t[a]=n)}}}propertyChangedHandler(e,t,a){super.propertyChangedHandler(e,t,a);const n=this;switch(e){case"animationSettings":n._applyAnimationSettings();break;case"disabled":case"unfocusable":n._setFocusable();break;case"calendarMode":case"dropDownWidth":case"dropDownHeight":n.displayMode="month",n._refreshHeaderElements(),n._refreshCalendarMode(),n._setDisplayModeContent();break;case"dayNameFormat":n._refreshDayOfWeekTitles(n.$.month);break;case"dateFormatFunction":{let e=n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=a?a(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:n.yearFormat});n._refreshHeaderTitle();break}case"displayMode":if("classic"===n.calendarMode&&"month"!==a){n[e]="month";break}n._setDisplayMode(t,a);break;case"displayModeView":n._applyAnimationSettings(!0),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"firstDayOfWeek":n._handleMonths(),n._refreshDayOfWeekTitles();break;case"hideTooltipArrow":n.$.tooltip&&(n.$.tooltip.arrow=!a);break;case"titleTemplate":case"headerTemplate":case"footerTemplate":n._handleLayoutTemplate(n.$[e.split(/[T]/)[0]],a),"titleTemplate"===e?n._refreshTitle():"headerTemplate"===e?n._refreshHeaderTitle():n._refreshFooter();break;case"importantDates":n.importantDates=n._getValidDates(a),n._refreshImportantDates();break;case"importantDatesTemplate":n._handleImportantDateTemplate(),n._refreshImportantDates();break;case"locale":n._refreshMonthNames(),n._refreshDayOfWeekTitles(),n._refreshHeaderTitle(),n._refreshTitle(),n._refreshFooter(),n.displayMode&&"month"!==n.displayMode&&n._setDisplayModeContent();break;case"max":case"min":n._validateMinMax(e,a,t),n._validateSelectedDates(),n._noFocusingRequired=!1,n._refreshHeaderElements();break;case"months":n._handleMonths();break;case"monthNameFormat":n._refreshCalendarMode(),n._refreshHeaderTitle();break;case"restrictedDates":n._setRestrictedDates(n.restrictedDates=n._getValidDates(a));break;case"rightToLeft":n._refreshDayOfWeekTitles(),n._handleMonths();break;case"scrollButtonsNavigationMode":n._setScrollButtonsNavigationMode();break;case"selectedDates":if(n._clearSelection(!0),n._validateSelectedDates(n._getValidDates(a)),n._applySelectionMode(!0),n._viewDates){let e=n.selectedDates[n.selectedDates.length-1];n._isDateInView(e)?n.selectedDates.map((e=>n._selectDate(e,!0,!0))):n._handleMonths(e)}n._refreshFooter(),n._setWeeksVisibility(n.$.monthsContainer),n.$.hiddenInput.value=n.selectedDates.toString(),n.isInitialized&&(n.$.fireEvent("change",{value:n.selectedDates}),n._updateTargetValue()),n._refreshTitle(),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"selectionMode":n._applySelectionMode(!1,t),n._refreshTitle();break;case"tooltip":n._handleTooltip();break;case"tooltipArrow":case"tooltipArrowDirection":case"tooltipDelay":case"tooltipOffset":case"tooltipPosition":case"tooltipTemplate":if(n.$.tooltip){const t=e.replace("tooltip","");n.$.tooltip[t.charAt(0).toLowerCase()+t.slice(1)]=a}break;case"view":n._refreshTitle();break;case"viewSections":a.indexOf("title")>-1?n.$title.removeClass("smart-hidden"):n.$title.addClass("smart-hidden"),n._refreshTitle(),a.indexOf("header")>-1?n.$header.removeClass("smart-hidden"):n.$header.addClass("smart-hidden"),n._refreshHeaderTitle(),a.indexOf("footer")>-1?n.$footer.removeClass("smart-hidden"):n.$footer.addClass("smart-hidden"),n._refreshFooter(),n._setFocusable();break;case"weeks":n._setWeeksVisibility(n.$.monthsContainer);break;case"yearFormat":if(n._refreshCalendarMode(),n._refreshFooter(),n.months>1&&"month"===n.displayMode){let e=n._animationStarted?n.$.nextMonthsContainer.children:n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:a})}n._refreshTitle(),n._refreshHeaderTitle()}}ready(){super.ready();const e=this;e._keysPressed={},e._applyAnimationSettings(),e.importantDates=e._getValidDates(e.importantDates),e.restrictedDates=e._getValidDates(e.restrictedDates)}render(){const e=this;e.setAttribute("role","dialog"),e._refreshMonthNames(),e._validateMinMax(),e._validateSelectedDates(e._getValidDates(e.selectedDates)),e._handleLayoutTemplate(e.$.title,e.titleTemplate),e._handleLayoutTemplate(e.$.header,e.headerTemplate),e._handleLayoutTemplate(e.$.footer,e.footerTemplate),e._handleImportantDateTemplate(),e._setFocusable(),e._refreshDayOfWeekTitles(),e._applySelectionMode(!0),e._handleMonths(0===e.selectedDates.length?new Date((new Date).setHours(0,0,0,0)):e.selectedDates[e.selectedDates.length-1]),e._handleTooltip(),e._updateViewSectionsVisibility(),e._setScrollButtonsNavigationMode(),e._refreshCalendarMode(),e._setDisplayMode(),e._refreshTitle(),e._refreshFooter(),e._refreshImportantDates(),e.$.monthElement&&e.$.monthElement._setDropDownSize&&e.$.monthElement._setDropDownSize(),e._changeEventFired=0,e.$.hiddenInput.value=e.selectedDates.toString(),e.shadowRoot&&e.appendChild(e.$.hiddenInput),e.isInitialized=!0,super.render()}refresh(){this.isInitialized&&this.render()}_updateViewSectionsVisibility(){const e=this;e.viewSections.indexOf("title")>-1?e.$title.removeClass("smart-hidden"):e.$title.addClass("smart-hidden"),e.viewSections.indexOf("header")>-1?e.$header.removeClass("smart-hidden"):e.$header.addClass("smart-hidden"),e.viewSections.indexOf("footer")>-1?e.$footer.removeClass("smart-hidden"):e.$footer.addClass("smart-hidden")}clearSelection(){this._clearSelection()}_setFocusable(){const e=this;let t=e.tabIndex>0?e.tabIndex:0;function a(e,a){if(a)return e&&e instanceof a?("function"==typeof e._setFocusable&&e.isCompleted?e.unfocusable=t<=-1:e.setAttribute("tabindex",t),e):e||void 0}(e.disabled||e.unfocusable)&&(t=-1),e.$.previousMonthButton=a(e.$.previousMonthButton,Smart.Button),e.$.nextMonthButton=a(e.$.nextMonthButton,Smart.Button),e.$.nextYearButton=a(e.$.nextYearButton,Smart.Button),e.$.previousYearButton=a(e.$.previousYearButton,Smart.Button),e.$.monthElement=a(e.$.monthElement,Smart.Input),e.$.yearElement=a(e.$.yearElement,HTMLInputElement),e.viewSections.indexOf("title")>-1&&(e.$.dateContainer.setAttribute("tabindex",t),e.$.yearContainer.setAttribute("tabindex",t)),e.$.body.setAttribute("tabindex",t),"default"===e.calendarMode?e.$.dateElement.setAttribute("tabindex",t):e.$.dateElement.removeAttribute("tabindex"),e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.readonly&&!e.disabled?e.tabIndex>0?e.tabIndex:0:t}static get requires(){return{"Smart.DropDownList":"smart.dropdownlist.js","Smart.ListBox":"smart.listbox.js","Smart.RepeatButton":"smart.button.js","Smart.Tooltip":"smart.tooltip.js"}}navigate(e){const t=this;let a,n,l;if(e){if("number"==typeof e){if(e=parseInt(e),isNaN(e)||0===e)return!1;if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let l,i;t._focusedCell||t._focusCell();const s=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));e<0?(i=s[0].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[i.length-1]:i[0]):(i=s[s.length-1].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[0]:i[i.length-1]),n=new Date(l.value),n.setDate(n.getDate()+e),a=n}else a=t._getNextDate(e)}else{if(a=e=t._getValidDate(e),l=!0,isNaN(a.getTime()))return!1;const i=t._viewDates[0];if(i&&a.getMonth()===i.getMonth()&&a.getFullYear()===i.getFullYear())return!1;6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&(n=a)}return!(!a||t.$.fireEvent("navigationChanging",{value:new Date(a),type:t.displayMode}).defaultPrevented||("month"!==t.displayMode?(!l&&t.hasAnimation?(t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),"list"===t.displayModeView?t._setDisplayModeContent(a):t._navigationDate&&t._navigationDate.getTime()===a.getTime()||t._animateNavigation(a,e)):t._setDisplayModeContent(a),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0):(t.hasAnimation?(t._animateNavigation(a,e),t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container")):(t._handleMonths(a),t._refreshHeaderElements(),t._refreshHeaderTitle()),n&&(t._focusCell(t._getCellByDate(n,t._animationStarted?t.$.nextMonthsContainer:void 0),!0),t._updateWeeksVisibility(e)),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0)))}}set value(e){this.select(e)}get value(){return this.selectedDates&&this.selectedDates.length>0?this.selectedDates[0]:null}select(e){const t=this;t._viewDates&&void 0!==t._viewDates[0]&&"none"!==t.selectionMode&&e&&(e=t._getValidDate(e))instanceof Date&&("one"===t.selectionMode&&t.selectedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<t.min.getTime()||e.getTime()>t.max.getTime()||("one"!==t.selectionMode&&"default"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._clearSelection(!0),t._selectDate(e),1!==t.selectedDates.length||t._isDateInView(t.selectedDates[0])||t._handleMonths(t.selectedDates[0])))}today(){const e=this;let t=new Date;return t.setHours(0,0,0,0),t.getTime()<e.min.getTime()||t.getTime()>e.max.getTime()?t=new Date(e.max):e._selectDate(t),e._handleMonths(t),t}_animateNavigation(e,t,a){const n=this;n._navigationDate=e,n._animationSettings||n._applyAnimationSettings(),n.$animationPanel.addClass("smart-hidden"),n.$.dateViewContainer.style.transform="",n.$.dateViewContainer.style.opacity="",n.$.monthsContainer.style.transform="",n.$.monthsContainer.style.opacity="";const l="month"!==n.displayMode?n.$.dateViewContainer:n.$.monthsContainer,i=n.$.body[n._animationSettings.scrollMax]-n.$.body[n._animationSettings.size];n._scrollStep=n.$.body[n._animationSettings.size]*n._animationSettings.startSpeed,n._animationStarted&&n._getMonthCells(n.$.monthsContainer,n.rightToLeft).map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)})),n._animationStarted=!0,"month"!==n.displayMode?(n._setCellState(n._focusedCell,"focus",!1),n._setDisplayModeContent(e,n.$.nextMonthsContainer)):n._handleMonths(e,n.$.nextMonthsContainer),n.rightToLeft&&(t*=-1),a||(t>0?(l.style.order=1,n.$.nextMonthsContainer.style.order=3,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]>n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold*2)&&(n.$.body[n._animationSettings.scrollSize]=0)):(l.style.order=3,n.$.nextMonthsContainer.style.order=1,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]<n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold)&&(n.$.body[n._animationSettings.scrollSize]=n.$.body[n._animationSettings.scrollMax]))),cancelAnimationFrame(n._animationId),n._animationId=requestAnimationFrame((function e(){let a=t>0?n.$.body[n._animationSettings.scrollSize]>=i:0===n.$.body[n._animationSettings.scrollSize],l=n._scrollStep/2;a?n._animateNavigationCompleted():(t>0&&n.$.body[n._animationSettings.scrollSize]>i*n._animationSettings.easeThreshold?(l=Math.max(n.$.body[n._animationSettings.scrollSize]/n._animationSettings.stepEaseSize,Math.abs(l-(i-n.$.body[n._animationSettings.scrollSize])*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l):t<0&&n.$.body[n._animationSettings.scrollSize]<i*n._animationSettings.easeThreshold&&(l=Math.max(n.$.body[n._animationSettings.scrollMax]/n._animationSettings.stepEaseSize,Math.abs(l-n.$.body[n._animationSettings.scrollSize]*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l),n.$.body[n._animationSettings.scrollSize]+=t>0?n._scrollStep:-n._scrollStep,n._animationId=requestAnimationFrame(e))}))}_animateNavigationCompleted(){const e=this;let t,a,n,l="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;if(cancelAnimationFrame(e._animationId),"month"!==e.displayMode){let i=[].slice.call(l.children).indexOf(e._focusedCell);l.innerHTML=e.$.nextMonthsContainer.innerHTML;let s,o=l.children[i];a=l.children,n=e.$.nextMonthsContainer.children;for(let t=0;t<a.length;t++)a[t].value=n[t].value,a[t].restricted=n[t].restricted,a[t].important=n[t].important,a[t].otherMonth=n[t].otherMonth,a[t].value.getTime()<=e.max.getTime()&&(s=a[t]);t=o&&o.value.getTime()>=e.max.getTime()?s.value:e._focusedCell?e._focusedCell.value:void 0}else{let i=l.children,s=e.$.nextMonthsContainer.children;e._focusedCell&&e.$.nextMonthsContainer.contains(e._focusedCell)&&(t=e._focusedCell.value);for(let t=0;t<i.length&&s[t]._date;t++){i[t]._date=s[t]._date,i[t].innerHTML=s[t].innerHTML,a=e._getMonthCells(i[t]),n=e._getMonthCells(s[t]);for(let e=0;e<a.length;e++)a[e].value=n[e].value,a[e].restricted=n[e].restricted,a[e].important=n[e].important,a[e].otherMonth=n[e].otherMonth,a[e].removeAttribute("focus")}e._selectedCells.length>0&&(e._selectedCells=e._selectedCells.map((t=>e._getCellByDate(t.value))).filter((e=>void 0!==e)))}e._focusCell(e._getCellByDate(t)),l.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationStarted=!1,delete e._navigationDate}_applyAnimationSettings(e){const t=this;t._animationSettings=t.animationSettings?t.animationSettings:t._animationSettings||{},"portrait"===t.scrollButtonsNavigationMode?(t._animationSettings.scrollMax="scrollHeight",t._animationSettings.size="offsetHeight",t._animationSettings.scrollSize="scrollTop"):(t._animationSettings.scrollMax="scrollWidth",t._animationSettings.size="offsetWidth",t._animationSettings.scrollSize="scrollLeft"),e||(t._animationSettings.startSpeed=t._animationSettings.startSpeed?t._animationSettings.startSpeed:.2,t._animationSettings.easeThreshold=t._animationSettings.easeThreshold?t._animationSettings.easeThreshold:.5,t._animationSettings.step=t._animationSettings.step?t._animationSettings.step:.25,t._animationSettings.stepEaseSize=t._animationSettings.stepEaseSize?t._animationSettings.stepEaseSize:200,t._animationSettings.resetThreshold=t._animationSettings.resetThreshold?t._animationSettings.resetThreshold:.2)}_applySelectionMode(e,t){const a=this;let n=[],l=!!e,i=a.selectionMode;function s(e,t){const n=a.$.monthsContainer.children;for(let l=0;l<n.length;l++)a._getMonthCells(n[l]).map((n=>{a._setCellState(n,e,t)}))}switch("many"===i&&"range"===i||s("hover",!1),a._newRangeSelectionStarted=a.selectedDates.length>0&&"range"===i,-1!==["default","many","zeroOrMany","oneOrMany","week","range"].indexOf(i)?Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.setAttribute("aria-multiselectable",!0))):Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.removeAttribute("aria-multiselectable"))),"none"!==i&&"none"!==t||s("selected",!1),i){case"none":return void a._clearSelection(l);case"range":return void(a.selectedDates.length>1&&a._selectMultipleDates(a.selectedDates[0],a.selectedDates[a.selectedDates.length-1]));case"many":case"default":case"oneOrMany":if(0===a.selectedDates.length){n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break}return;case"oneExtended":case"one":if(1===a.selectedDates.length)return;a.selectedDates.length>1?(n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l)):n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break;case"zeroOrOne":if(a.selectedDates.length>1){n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l);break}return;case"zeroOrMany":return;case"week":if(a.selectedDates.length>=1){let e=a.selectedDates[a.selectedDates.length-1];for(let t=0;t<7;t++)n.push(new Date(e)),e.setDate(e.getDate()+1);a._clearSelection(l)}}if(a.selectedDates=[],e)return void(a.selectedDates=n);const o=n.length;for(let e=0;e<o;e++)a._selectDate(n[e],e<o-1)}_clearSelection(e){const t=this,a=t.selectedDates.slice(0),n=t.selectionMode;if(t.isRendered){if(t._selectedCells&&t._selectedCells.map((e=>{t._setCellState(e,"selected",!1)})),t.selectedDates=[],t._selectedCells=[],"many"===n||"range"===n){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}t.$.footer&&t._refreshFooter(),t.$.hiddenInput.value=t.selectedDates.toString(),!e&&t.isInitialized&&a.length&&(t.$.fireEvent("change",{value:[]}),t._updateTargetValue()),t.$.title&&t._refreshTitle()}else t.set("selectedDates",[])}_bodyBlurStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("blur")}_bodyFocusStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("focus")}_bodyStateHandler(e){const t=this;if(t._focusedCell){if("blur"===e.type||"focus"===e.type&&t._noFocusingRequired)return t._noFocusingRequired=!1,void t._setCellState(t._focusedCell,"focus",!1);if("month"!==t.displayMode)return void("focus"!==e.type||t.$.dateViewContainer.querySelector("smart-calendar-cell[focus]")||t._setCellState(t._focusedCell||t.$.dateViewContainer.querySelector(".smart-calendar-cell"),"focus",!0))}"focus"===e.type&&t._focusCell()}_containerWheelHandler(e){const t=this;if(t.disabled||t.readonly||"month"!==t.displayMode&&"list"===t.displayModeView)return;let a,n;n=document.activeElement,t.shadowRoot?n=t.shadowRoot.activeElement:t.isInShadowDOM&&(n=t.getRootNode().activeElement),t.$.yearElement===n&&(a=12),(n&&t.shadowRoot||n.closest("smart-calendar")===t)&&(a=e.target===t.$.yearElement?12:1),a&&(e.preventDefault(),a=12===a?a:a*t.months,e.deltaY>0?t.navigate(-a):t.navigate(a))}_downHandler(e){const t=this;let a=e.originalEvent.target;if(t._dragStartDetails=void 0,t.disabled||t.readonly)return;if(t.hasRippleAnimation&&(a.value instanceof Date||a.parentElement&&a.parentElement.classList.contains("smart-calendar-title")||a.parentElement===t.$.dateElement)&&Smart.Utilities.Animation.Ripple.animate(a,e.pageX,e.pageY),a=e.originalEvent.target.closest(".smart-calendar-header"),e.originalEvent.target.closest(".smart-calendar-year-container")&&"decade"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._showDateView("year")}if(e.originalEvent.target.closest(".smart-calendar-date-container")&&"month"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")}if(t._animationStarted&&t._animateNavigationCompleted(),Smart.Utilities.Core.isMobile&&e.originalEvent.target.closest(".smart-calendar-body")===t.$.body)return void(t._dragStartDetails={x:e.pageX,y:e.pageY,startTime:Date.now(),target:e.originalEvent.target});if(a=e.originalEvent.target,a.closest(".smart-calendar-week")||a.parentElement===t.$.dateViewContainer){for(;a&&!(a.value instanceof Date);)a=a.parentElement;return void(a&&("month"!==t.displayMode?t._displayModeHandler(a):t._weeksDownHandler(e,a)))}if(a.closest(".smart-calendar-month-element"))return;if(e.originalEvent.stopPropagation(),"list"===t.displayModeView&&"month"!==t.displayMode)return a=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-item"),void(a&&t._displayModeHandler(a));const n=document.scrollingElement||document.documentElement,l=n.scrollLeft,i=n.scrollTop;t.unfocusable||t.focus(),window.scrollTo(l,i)}_displayModeHandler(e,t){const a=this;if(a._animationStarted&&a._animateNavigationCompleted(),e instanceof HTMLElement&&e.closest(".smart-calendar-week")&&e.otherMonth){if("decade"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()>a.max.getFullYear()))return;if("year"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()===a.min.getFullYear()&&e.value.getMonth()<a.min.getMonth()||e.value.getFullYear()>a.max.getFullYear()||e.value.getFullYear()===a.max.getFullYear()&&e.value.getMonth()>a.max.getMonth()))return}switch(t=t||a.displayMode){case"year":t="month";break;case"decade":t="year"}if(a.displayMode===t)return;const n=a.$.listViewContainer,l=n&&n.contains(e);a.$.fireEvent("displayModeChanging",{oldDisplayMode:a.displayMode,newDisplayMode:t}).defaultPrevented||(a.set("displayMode",t),a.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),e.parentElement!==a.$.dateViewContainer||e.disabled||e.restricted||a._focusCell(e),a.hasAnimation?(l&&e instanceof HTMLLIElement?e.offsetHeight?a.$.animationPanel.style.transformOrigin=e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px":a.$.animationPanel.style.transformOrigin=n.offsetLeft+n.offsetWidth/2+"px "+(n.offsetTop+n.offsetHeight/2)+"px":(a.$.dateViewContainer.style.order=1,a.$.nextMonthsContainer.style.order=3,e=a._focusedCell,a.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),a._animateView(1,e)):a._setDisplayModeContent(e.value instanceof Date?e.value:new Date(e.getAttribute("value")||e.value)))}_animateView(e,t){const a=this;let n,l,i=t instanceof Date?t:new Date(t.getAttribute("value")||t.value),s=!1,o=1,r=1;const d=a.$.listViewContainer;"list"===a.displayModeView?n=d.contains(t)?d:l="month"!==a.displayMode?a.$.monthsContainer:d:t.value instanceof Date||(t=a._focusedCell?a._focusedCell:a._selectedCells.length>0?a._selectedCells[a._selectedCells.length-1]:a._getCellByDate(new Date)),n||(n=t.parentElement===a.$.dateViewContainer?a.$.dateViewContainer:a.$.monthsContainer),l||(l="month"===a.displayMode?a.$.monthsContainer:"list"===a.displayModeView?d:a.$.dateViewContainer),l.style.transformOrigin=a.$.animationPanel.style.transformOrigin,n===d?(a.$.animationPanel.innerHTML="",a.$.animationPanel.appendChild(n.cloneNode(!0))):a.$.animationPanel.innerHTML=n.innerHTML,a._setDisplayModeContent(i),n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,a.$.animationPanel.style.width=a.$.body.offsetWidth+"px",a.$.animationPanel.style.height=a.$.body.offsetHeight+"px",a.$.animationPanel.style.transform="scale(1)",a.$.animationPanel.style.opacity=1,a.$animationPanel.removeClass("smart-hidden"),l.style.opacity="0",l.style.transform="scale(3.5)",n.$.hasClass("smart-calendar-date-view-container")?a.$animationPanel.addClass("smart-calendar-date-view-container"):a.$animationPanel.removeClass("smart-calendar-date-view-container"),cancelAnimationFrame(a._animationId),a._animationId=requestAnimationFrame((function t(){if((e>0&&o>=3.5||e<0&&o<=0)&&(s=!0),s){if(cancelAnimationFrame(a._animationId),a.$animationPanel.addClass("smart-hidden"),a.$.animationPanel.style.transform="",a.$.animationPanel.style.opacity="",n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,l.style.transform="",l.style.opacity="",a.unfocusable)return;"month"===a.displayMode?a.$.body.focus():"list"===a.displayModeView&&a.focus()}else a.$.animationPanel.style.opacity=r,l.style.opacity=1-r,r-=.05,e>0?(a.$.animationPanel.style.transform="scale("+o+")",l.style.transform="scale("+Math.min((o-1)/2,1)+")",o+=.125):(a.$.animationPanel.style.transform="scale("+Math.max(o,0)+")",l.style.transform="scale("+Math.max(1+o,1)+")",o-=.06),a._animationId=requestAnimationFrame(t)}))}_documentUpHandler(e){const t=this;let a=e.originalEvent.target;if((t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),t._newRangeSelectionStarted&&!t.$.container.contains(a)&&delete t._newRangeSelectionStarted,a&&a.classList&&a.classList.contains("smart-calendar-cell")&&(e.originalEvent.stopPropagation(),e.originalEvent.preventDefault(),e.preventDefault()),!Smart.Utilities.Core.isMobile||!t._dragStartDetails||e.originalEvent.target.closest(".smart-calendar-list-view"))return;delete t._previousIteration;const n=Date.now();let l={};(t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),"portrait"===t.scrollButtonsNavigationMode?(l.coordinate="y",l.direction="pageY"):(l.coordinate="x",l.direction="pageX");const i=t._dragStartDetails.step*(t.rightToLeft?-1:1);if(Math.abs(t._dragStartDetails[l.coordinate]-e[l.direction])<=10){if(a="list"===t.displayModeView&&"month"!==t.displayMode?a.closest("smart-list-item"):a,!a)return void(t._dragStartDetails=void 0);if("month"!==t.displayMode)return t._displayModeHandler(a),"portrait"===t.scrollButtonsNavigationMode?t.$.body.scrollTop=0:t.$.body.scrollLeft=0,void(t._dragStartDetails=void 0);if(t._weeksDownHandler(e,a),!t.disableAutoNavigation&&a.otherMonth)return}else{const a=Math.abs((e[l.direction]-t._dragStartDetails[l.coordinate])/(n-t._dragStartDetails.startTime));if(a>1){const e=parseInt(a);for(let a=0;a<e;a++)if(!t.navigate(i)){t._cancelAnimation();break}return void(t._dragStartDetails=void 0)}}if(!t.hasAnimation)return t.navigate(t._dragStartDetails.step),void(t._dragStartDetails=void 0);let s=("month"!==t.displayMode?t.$.dateViewContainer[t._animationSettings.scrollMax]:t.$.monthsContainer[t._animationSettings.scrollMax])+t.$.monthsSeparator[t._animationSettings.size];if(t._dragStartDetails.step>0&&t.$.body[t._animationSettings.scrollSize]>s*t._animationSettings.easeThreshold||t._dragStartDetails.step<0&&t.$.body[t._animationSettings.scrollSize]<s*t._animationSettings.easeThreshold)return t._animateNavigation(t._dragStartDetails.navigationDate,i,!0),6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(i,t._getCellByDate(t._dragStartDetails.navigationDate,t.$.nextMonthsContainer)),t.$.fireEvent("navigationChange",{value:new Date(t._dragStartDetails.navigationDate),type:t.displayMode}),void(t._dragStartDetails=void 0);t._cancelAnimation(),t._dragStartDetails=void 0}_cancelAnimation(){const e=this,t="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;let a=e.$.animationPanel.style.transform,n=e.$.animationPanel.style.opacity;a&&(a=parseFloat(a.substring(a.indexOf("(")+1||0,a.indexOf(")")))),t.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationId=requestAnimationFrame((function t(){if(!a||a>=3.5){cancelAnimationFrame(e._animationId),e.$animationPanel.addClass("smart-hidden"),e.$.animationPanel.style.transform="",e.$.animationPanel.style.opacity="";const t="month"===e.displayMode?e.$.monthsContainer:e.$.listViewContainer;return t.style.transform="",t.style.opacity="",e.unfocusable||("month"===e.displayMode?e.$.body.focus():"list"===e.displayModeView&&e.focus()),void(e._animationStarted=!1)}e.$.animationPanel.style.opacity=n-=.25,e.$.animationPanel.style.transform="scale("+(a+=.5)+")",e._animationId=requestAnimationFrame(t)}))}_focusCell(e,t){const a=this;if(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a.disabled||a.readonly)return;if(e){if("month"!==a.displayMode)return a._setCellState(e,"focus",!0),void(a._focusedCell=e);if(e.disabled||e.restricted)return;return t||a._setCellState(e,"focus",!0),void(a._focusedCell=e)}if("month"!==a.displayMode&&0===a.$.monthsContainer.offsetHeight)return;const n=a._selectedCells[a._selectedCells.length-1];if(n&&n.offsetHeight)a._setCellState(n,"focus",!0),a._focusedCell=n;else{const e=a.$.monthsContainer.children;if(!e[0]._date||a.min.getTime<e[0]._date.getTime())return;const t=a._getMonthCells(e[0],a.rightToLeft);for(let e=0;e<t.length;e++){const n=t[e];if(!n.otherMonth){if(n.disabled||n.restricted||!n.offsetHeight)continue;a._focusedCell=n;break}}}a._focusedCell&&a._setCellState(a._focusedCell,"focus",!0)}_getDays(e,t){const a=t.length;let n=[];if(a>0)for(let l=0;l<a;l++)t[l].getFullYear()===e.getFullYear()&&t[l].getMonth()===e.getMonth()&&n.push(t[l].getDate());return n}_getCellByDate(e,t){const a=this;if(!(e instanceof Date))return;if(t||(t=a.$.monthsContainer),"month"!==a.displayMode){if("list"===a.displayModeView)return;let t=arguments[1]?a.$.nextMonthsContainer.children:a.$.dateViewContainer.children;for(let n=0;n<t.length;n++)if("year"!==a.displayMode){if(t[n].value.getFullYear()===e.getFullYear())return t[n]}else if(t[n].value.getMonth()===e.getMonth())return t[n];return}let n,l,i=t.children;for(let t=0;t<i.length;t++)if(e.getFullYear()===i[t]._date.getFullYear()&&e.getMonth()===i[t]._date.getMonth()){n=i[t];break}if(n){l=a._getMonthCells(n);for(let t=0;t<l.length;t++)if((!l[t].otherMonth||l[t].hover)&&l[t].value.getMonth()===e.getMonth()&&l[t].value.getDate()===e.getDate())return l[t]}}_getMonthCells(e,t){const a=e.getElementsByClassName("smart-calendar-week");let n=[];if(t)for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=t.length-1;e>0;e--)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}else for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=1;e<t.length;e++)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}return n}_getWeekNumber(e){const t=this;let a,n=new Date(e.getFullYear(),0,1),l=Math.round((e.getTime()-n.getTime()-6e4*(e.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)+1,i=n.getDay()-t.firstDayOfWeek;return i=i>=0?i:i+7,i<4?(a=Math.floor((l+i-1)/7)+1,a>52&&(n=new Date(e.getFullYear()+1,0,1),i=n.getDay()-t.firstDayOfWeek,i=i>=0?i:i+7,a=i<4?1:53)):a=Math.round((l+i-1)/7),a}_handleDateSelection(e){const t=this;if(void 0!==e&&!e.disabled&&!e.restricted)switch(t.selectionMode){case"none":t._focusCell(e);break;case"oneExtended":case"one":case"default":if(t._keysPressed.Control)return t.selectedDates.length>1||1===t.selectedDates.length&&!e.selected?void t._selectDate(e.value):void t._focusCell(e);if(t._keysPressed.Shift)return void t._selectMultipleDates(new Date(t.selectedDates[0]),e);t._clearSelection(!0),t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break;case"many":{if(0===t.selectedDates.length)return void t._selectDate(e.value);const a=t.selectedDates[t.selectedDates.length-1];let n=new Date(t.selectedDates[0]);if(e.value.getTime()===n.getTime()||e.value.getTime()===a.getTime())return t._clearSelection(),void t._focusCell(e);t.selectedDates.length>0&&t._selectMultipleDates(n,e);break}case"range":{if(t.selectedDates.length>1&&!t._keysPressed.Control&&!t._newRangeSelectionStarted&&t._clearSelection(!0),0===t.selectedDates.length||t._keysPressed.Control&&t.selectedDates.length>1&&!t._newRangeSelectionStarted){if(e.value&&t.selectedDates.find((t=>t.getTime()===e.value.getTime())))return;return t._newRangeSelectionStarted=!0,void t._selectDate(e.value)}const a=t.selectedDates[t.selectedDates.length-1];let n=t._keysPressed.Control||t._newRangeSelectionStarted?a:new Date(t.selectedDates[0]);t.selectedDates.length>0&&t._selectMultipleDates(n,e),delete t._newRangeSelectionStarted;break}case"zeroOrMany":t._selectDate(e.value);break;case"oneOrMany":if(1===t.selectedDates.length&&e.selected)return void t._focusCell(e);t._selectDate(e.value);break;case"zeroOrOne":if(1===t.selectedDates.length&&e.selected)return void t._selectDate(e.value);t._clearSelection(!0),t._selectDate(e.value);break;case"week":{if(e.selected&&(e.value.getTime()===t.selectedDates[0].getTime()||e.value.getTime()===t.selectedDates[t.selectedDates.length-1].getTime()))return t._clearSelection(),void t._focusCell(e);t._clearSelection(!0);let a=new Date(e.value);t._selectDate(a);for(let e=1;e<7;e++)a.setDate(a.getDate()+1),t._selectDate(a);t._isDateInView(a)||t.navigate(1);break}}}_handleImportantDateTemplate(){const e=this;if(e._importantDatesTemplate=e._validateTemplate("importantDatesTemplate",e.importantDatesTemplate),!e._importantDatesTemplate||!e._importantDatesTemplate.content)return;let t=e._importantDatesTemplate.content;const a=t.childNodes.length,n=/{{\w+}}/g;let l;e._bindingDetails=[];for(let i=0;i<a;i++)if(l=n.exec(t.childNodes[i].innerHTML),l)return void e._bindingDetails.push({childNodeIndex:i,bindingString:l[0]})}_handleLayoutTemplate(e,t){const a=this,n=a._validateTemplate(e.$.hasClass("smart-header")?"headerTemplate":e.$.hasClass("smart-calendar-footer")?"footerTemplate":"titleTemplate",t);if(!n||!n.content)return void("function"==typeof t&&t(e,{}));a._layoutTemplates||(a._layoutTemplates=[]);let l=document.importNode(n.content,!0);e.innerHTML="";const i=l.childNodes.length,s=/{{\w+}}/g;let o,r=[];for(let e=0;e<i;e++)o=s.exec(l.childNodes[e].innerHTML),o&&r.push({childNodeIndex:e,bindingString:o[0]});if(a._layoutTemplates=a._layoutTemplates.filter((t=>t.selector!==e)),a._layoutTemplates.push({selector:e,template:n,bindings:r}),a.shadowRoot)return e.innerHTML="<slot></slot>",void a.appendChild(l);e.appendChild(l)}_handleCalendarCellHover(e,t){const a=this;if(!a._animationStarted){if("month"===a.displayMode)if("mouseover"===e.type&&("many"===a.selectionMode||"range"===a.selectionMode&&a._newRangeSelectionStarted)&&a.selectedDates.length>0){const e=a.$.monthsContainer.children;for(let t=0;t<e.length;t++)a._getMonthCells(e[t]).map((e=>{a._setCellState(e,"hover",!1)}));let n=new Date("range"===a.selectionMode?a.selectedDates[a.selectedDates.length-1]:a.selectedDates[0]),l=new Date(t.value),i=t;const s=n.getTime()>l.getTime()?-1:1,o=function(){i=a._getCellByDate(n),!i||i.selected||i.restricted||a._setCellState(i,"hover",!0)};if(n.getTime()!==l.getTime()){for(n.setDate(n.getDate()+s);n.getTime()!==l.getTime();)o(),n.setDate(n.getDate()+s);o()}}else a._setCellState(t,"hover",!1);"mouseover"!==e.type||t.otherMonth?a._setCellState(t,"hover",!1):a._setCellState(t,"hover",!0)}}_handleMonths(e,t){const a=this;let n;function l(e){let t,n=e.children.length,l=document.createDocumentFragment();for(;n<a.months;n++)t=a.$.month.cloneNode(!1),t.innerHTML=a.$.month.innerHTML,l.appendChild(t);return l}function i(t){let n=t.children;for(let t=0;t<n.length;t++)a._setMonth(e,n[t]),e.setMonth(e.getMonth()+1);a._setWeeksVisibility(t),a._refreshHeaderElements(),a._refreshHeaderTitle(),a.tooltip&&a.$.tooltip&&a.$.tooltip.close(),a.$.body===document.activeElement&&a._focusCell()}if(e||(e=a._viewDates&&a._viewDates.length>0?a._viewDates[0]:new Date),e=new Date(Math.min(Math.max(a.min.getTime(),e.getTime()),a.max.getTime())),t||(t=a.$.monthsContainer),a._selectedCells=[],a.hasAnimation){for(n=a.$.nextMonthsContainer.children,n.length>0&&n[0].value instanceof Date&&(a.$.nextMonthsContainer.innerHTML="");a.$.nextMonthsContainer.childElementCount<a.months;)a.$.nextMonthsContainer.appendChild(l(a.$.nextMonthsContainer));for(;a.$.nextMonthsContainer.childElementCount>a.months;)a.$.nextMonthsContainer.removeChild(n[a.$.nextMonthsContainer.childElementCount-1]);if(arguments[1]===a.$.nextMonthsContainer)return void i(a.$.nextMonthsContainer)}if(n=a.$.monthsContainer.children,n.length>a.months){for(;a.$.monthsContainer.childElementCount>a.months;)a.$.monthsContainer.removeChild(n[a.$.monthsContainer.childElementCount-1]),a._viewDates.pop();i(a.$.monthsContainer)}else a.$.monthsContainer.children.length!==a.months?(a._viewDates=[],a.$.monthsContainer.appendChild(l(a.$.monthsContainer)),i(a.$.monthsContainer)):i(a.$.monthsContainer)}_headerChangeHandler(e){const t=this;if(e.stopPropagation(),t.disabled||t.readonly)return;if(e.target.ownerElement===t.$.monthElement&&0!==t._changeEventFired)return void t._changeEventFired--;const a=t.displayMode;e.target===t.$.yearElement&&(t._viewDates[0].setFullYear(Math.min(Math.max(t.min.getFullYear(),isNaN(parseInt(t.$.yearElement.value))?0:parseInt(t.$.yearElement.value)),t.max.getFullYear())),t._handleMonths(t._viewDates[0])),!t.$.monthElement||e.target!==t.$.monthElement&&e.target.ownerElement!==t.$.monthElement||(t._handleMonths(new Date(t.$.monthsContainer.children[0]._date.getFullYear(),t.$.monthElement.selectedIndex,1)),"month"!==a&&t._setDisplayMode(t.displayMode,t.displayMode="month"))}_headerClickHandler(e){const t=this;if(t.disabled||t.readonly)return;let a=e.target.closest("smart-repeat-button");if(!a||!a.disabled){switch(a){case t.$.previousMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(-1*t.months*(t.rightToLeft?-1:1));case t.$.nextMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(1*t.months*(t.rightToLeft?-1:1));case t.$.previousYearButton:return void t.navigate(-12);case t.$.nextYearButton:return void t.navigate(12)}"classic"!==t.calendarMode&&e.target.closest(".smart-calendar-date-element")&&(t._animationStarted&&t._animateNavigationCompleted(),t._isInteractiveNavigation=!0,t._showDateView())}}_selectMultipleDates(e,t){const a=this;if(t instanceof HTMLElement&&(t=t.value),a._newRangeSelectionStarted?a._selectDate(e,!0):a._clearSelection(!0),"range"!==a.selectionMode||t.getTime()!==e.getTime()){if((e=new Date(e)).getTime()<t.getTime())for(;e.getTime()<=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()+1);else if(e.getTime()>t.getTime())for(;e.getTime()>=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()-1);else a._selectDate(t,!0);a.$.hiddenInput.value=a.selectedDates.toString(),a._refreshFooter(),a.isInitialized&&(a.$.fireEvent("change",{value:a.selectedDates}),a._updateTargetValue()),a._refreshTitle()}}_setDisplayMode(e,t,a){const n=this;if(n.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),0!==arguments.length&&n.hasAnimation)if(n._animationStarted&&(n.displayMode=e,n._animateNavigationCompleted(),n.displayMode=t),"month"===e&&"year"===t||"year"===e&&"decade"===t)n.displayMode=e,n._showDateView(a?void 0:n.displayMode);else if("month"===e&&"decade"===t)n._showDateView(n.displayMode="year");else{let e;"list"===n.displayModeView?(e=n.$.listViewContainer.querySelector("li.active"),n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop>0?e.offsetTop-e.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"):(n.$.dateViewContainer.style.order=1,n.$.nextMonthsContainer.style.order=3,e=n._focusedCell,n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),n._animateView(1,e)}else{if("classic"===n.calendarMode)return void(n.displayMode="month");if("month"!==n.displayMode&&(n.$monthsContainer.addClass("smart-hidden"),n.$dateViewContainer.hasClass("smart-hidden")&&n.$dateViewContainer.removeClass("smart-hidden")),!n.isCompleted&&"month"===n.displayMode)return;n._setDisplayModeContent()}}_setDisplayModeContent(e,t){const a=this;let n=e&&"Invalid Date"!==e.toString()?e:a.selectedDates.length>0?a.selectedDates[a.selectedDates.length-1]:new Date;n.setTime(Math.min(Math.max(n.getTime(),a.min.getTime()),a.max.getTime())),n.setHours(0,0,0,0);const l=a._prepareView(n);if(!l)return;let i;t?(a.$.nextMonthsContainer.innerHTML=a.$.dateViewContainer.innerHTML,i=a.$.nextMonthsContainer):i=a.$.dateViewContainer;const s=i.children;let o;for(let e=0;e<s.length;e++){const t=s[e];t.innerHTML=l.viewContent[e],t.value=l.dates[e],"year"===a.displayMode?(t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()===a.min.getFullYear()&&t.value.getMonth()<a.min.getMonth()||t.value.getFullYear()>a.max.getFullYear()||t.value.getFullYear()===a.max.getFullYear()&&t.value.getMonth()>a.max.getMonth()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&n.getMonth()===t.value.getMonth()&&(o=t)):"decade"===a.displayMode&&(0===e||e===s.length-1||t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()>a.max.getFullYear()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&(o=t)),a._setCellState(t,"hover",!1),a._setCellState(t,"focus",!1)}if(o.otherMonth)for(let e=0;e<s.length;e++)if(!s[e].otherMonth){o=s[e];break}a._mobileScrolling||(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a._focusedCell=o,a._focusCell(a._focusedCell),a._refreshHeaderTitle(),a._refreshHeaderElements(),a.$.fireEvent("displayModeChange"),a._isInteractiveNavigation?a._isInteractiveNavigation=void 0:(a._setCellState(o,"focus",!0),setTimeout((function(){a.unfocusable||(a.$.body.focus(),a._focusCell(a._focusedCell))}),0)))}_prepareView(e){const t=this,a=t.$.listViewContainer;let n,l,i=[],s=[];function o(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if("month"===t.displayMode)return t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container"),a&&a.classList.add("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),t._isDateInView(e)||t._handleMonths(e),t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$body.hasClass("smart-calendar-list-view")&&t.$body.removeClass("smart-calendar-list-view"),t.$dateContainer.addClass("smart-calendar-selected"),t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateViewContainer.addClass("smart-hidden"),t.$monthsContainer.removeClass("smart-hidden"),t._refreshHeaderTitle(),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),t._refreshHeaderElements(),t.unfocusable||t.$.body.focus(),t._focusCell(t._getCellByDate(e)),void t.$.fireEvent("displayModeChange");if("list"===t.displayModeView)return t._setDisplayModeListContent(e),void t.$.fireEvent("displayModeChange");if(t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),a&&a.classList.add("smart-hidden"),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),"year"===t.displayMode){let a=new Date;for(let n=0;n<12;n++)a=o(a.getFullYear(),n,a.getDate()),i.push(a.toLocaleDateString(t.locale,{month:"short"})),s.push(o(e.getFullYear(),n,e.getDate()))}else{n=e?e.getFullYear():t._viewDates[0].getFullYear(),l=n%10,0!==l&&(n-=l),n-=1;for(let t=0;t<12;t++)i.push(n+""),s.push(new Date(n,e.getMonth(),e.getDate())),++n}return{viewContent:i,dates:s}}_setDisplayModeListContent(e){const t=this;let a=[];function n(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if(t.$dateViewContainer.addClass("smart-visibility-hidden"),"year"===t.displayMode){let l=new Date;for(let i=0;i<12;i++)l=n(l.getFullYear(),i,l.getDate()),a.push({label:l.toLocaleDateString(t.locale,{month:"short"}),value:n(e.getFullYear(),i,e.getDate()).toDateString()});t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateContainer.addClass("smart-calendar-selected")}else{let n=t.min.getFullYear(),l=t.max.getFullYear();l=Math.min(t.max.getFullYear(),e.getFullYear()+10),n=Math.max(t.min.getFullYear(),l-10);for(let t=n;t<l;t++)a.push({label:t.toString(),value:new Date(t,e.getMonth(),e.getDate()).toDateString()});t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")}t._prepareListViewer(a,e.toDateString()),t._refreshHeaderTitle(),t._refreshHeaderElements(),t.unfocusable||t.focus()}_prepareListViewer(e=[],t){const a=this,n=a.$.body;let l=a.$.listViewContainer;l||(a.$.listViewContainer=l=document.createElement("smart-scroll-viewer"),l.classList.add("smart-input-drop-down-menu","smart-calendar-list-view"),l.ensureVisible=a._listViewerEnsureVisible.bind(a),l._handleKeyStrokes=a._listViewerKeyStrokesHandler.bind(a),l._setActiveDescendant=a._listViewerSetActiveDescendant.bind(a));let i=l.querySelector("ul");i||(i=document.createElement("ul"),i.onclick=a._listViewContainerItemClickHandler.bind(a),l.appendChild(i)),n.contains(l)&&n.removeChild(l),i.innerHTML="";for(let a=0;a<e.length;a++){const n=e[a],s=n.label,o=n.value,r=document.createElement("li"),d=document.createElement("a");t===o?(r.setAttribute("aria-selected",!0),r.classList.add("active"),t=r):r.setAttribute("aria-selected",!1),r.id=l.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),r.setAttribute("value",o),r.setAttribute("role","option"),r.setAttribute("aria-label",s),d.innerHTML=s,d.setAttribute("aria-hidden",!0),r.appendChild(d),i.appendChild(r)}l.classList.remove("smart-hidden"),n.classList.add("smart-calendar-list-view"),n.removeAttribute("tabindex"),n.insertBefore(l,a.$.animationPanel),l.refresh(),l.ensureVisible()}_listViewerEnsureVisible(){const e=this.$.listViewContainer,t=e.querySelector(".active");if(!t)return;const a=Array.from(e.querySelectorAll("li"));t.offsetTop+t.offsetHeight>=e.scrollTop+e.offsetHeight&&(e.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.scrollTop||t.offsetTop>=e.scrollTop+e.offsetHeight)&&(e.scrollTop=t.offsetTop),0===a.indexOf(t)?e.scrollTop=0:a.indexOf(t)===a.length-1&&(e.scrollTop=e.scrollHeight)}_listViewerKeyStrokesHandler(e){if(["ArrowUp","ArrowDown"].indexOf(e)<0)return;event.preventDefault();const t=this.$.listViewContainer,a=t.querySelector(".active");if(!a){const e=t.querySelector("li");return e.classList.add("active"),void t._setActiveDescendant(e)}const n=a["ArrowDown"===e?"nextElementSibling":"previousElementSibling"];n&&(a.classList.remove("active"),n.classList.add("active"),t._setActiveDescendant(n),t.ensureVisible())}_listViewerSetActiveDescendant(e){const t=this.$.listViewContainer;e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant")}_listViewContainerItemClickHandler(e){const t=this,a=e.target.closest("li");a&&"list"===t.displayModeView&&"month"!==t.displayMode&&t._displayModeHandler(a)}_isDateInView(e){const t=this;if(!e)return!1;for(let a=0;a<t._viewDates.length;a++)if(e.getFullYear()===t._viewDates[a].getFullYear()&&e.getMonth()===t._viewDates[a].getMonth()){let a=t._getCellByDate(e,t._animationStarted?t.$.nextMonthsContainer:void 0);if(!a)return;return!(a.otherMonth||!a.offsetHeight||a.classList.contains("smart-visibility-hidden"))}return!1}_keyDownHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;switch(a){case t.$.yearElement:"Escape"===e.key&&t._refreshHeaderElements();break;case t.$.dateElement:if("default"===t.calendarMode&&" "===e.key||"Enter"===e.key)return e.preventDefault(),t._isInteractiveNavigation=!0,void t._showDateView();t._focusedCell||t._focusCell(),e.key.indexOf("Arrow")>-1&&t.$.dateElement===a&&!t.unfocusable&&t.$.body.focus(),t._navigateDays(e);break;case t.$.body:" "===e.key&&e.preventDefault(),t._navigateDays(e);break;case t.$.yearContainer:if(" "!==e.key&&"Enter"!==e.key||"decade"===t.displayMode||(e.preventDefault(),t._isInteractiveNavigation=!0,t._showDateView("year")),e.key.indexOf("Arrow")>-1){if(e.preventDefault(),t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;case t.$.dateContainer:if(" "!==e.key&&"Enter"!==e.key||"month"===t.displayMode||(e.preventDefault(),t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")),e.key.indexOf("Arrow")>-1){if(t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;default:if("month"!==t.displayMode&&"list"===t.displayModeView)return["Arrow","End","Home","Page"].indexOf(e.key)&&e.preventDefault()," "===e.key||"Enter"===e.key||e.ctrlKey&&("ArrowUp"===e.key||"ArrowDown"===e.key)?void t._navigateDays(e):void t.$.listViewContainer._handleKeyStrokes(e.key);e.key.indexOf("Arrow")>-1&&(t._focusedCell||t._focusCell(),t._navigateDays(e))}}_showDateView(e){const t=this;switch(e=e||t.displayMode){case"month":e="year";break;case"year":e="decade"}if(t.displayMode===e)return;if(t.$.fireEvent("displayModeChanging",{oldDisplayMode:t.displayMode,newDisplayMode:e}).defaultPrevented)return;let a;if(t.displayMode=e,"list"===t.displayModeView&&"month"!==t.displayMode){t._setDisplayModeListContent(t._focusedCell?t._focusedCell.value:t._viewDates[0]);const e=t.$.listViewContainer;e.classList.remove("smart-hidden"),a=e.querySelector("li.active"),a.offsetHeight?t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:a.offsetTop+a.offsetHeight/2)+"px":t.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"}else t._focusedCell||t._focusCell(),a=t._focusedCell,t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop+a.offsetHeight/2)+"px";t.$monthsContainer.addClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-hidden")&&t.$dateViewContainer.removeClass("smart-hidden"),"decade"===t.displayMode&&(t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")),t.hasAnimation?t._animateView(-1,a):t._setDisplayModeContent(t._focusedCell?t._focusedCell.value:t._viewDates[0])}_keyUpHandler(e){const t=this;t.disabled||t.readonly||"default"!==t.selectionMode&&"range"!==t.selectionMode||"Shift"!==e.key&&"Control"!==e.key||(t._keysPressed[e.key]=!1)}_handleTooltip(){const e=this,t=e.tooltip;let a=e.$.tooltip;t?(a||(a=document.createElement("smart-tooltip"),a.tooltipTemplate=e.tooltipTemplate,a.arrow=e.tooltipArrow,a.arrowDirection=e.tooltipArrowDirection,a.offset=e.tooltipOffset,a.position=e.tooltipPosition,a.delay=e.tooltipDelay,a.rightToLeft=e.rightToLeft,a.openMode="manual",e.$.tooltip=a),a.parentElement||e.$.calendarContainer.appendChild(a)):a&&a.remove()}_mouseEventsHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=t.$.tooltip;if("mouseenter"===e.type)return void t.$.setAttributeValue("hover",!0);if("mouseleave"===e.type){if(t.$.setAttributeValue("hover",!1),t._newRangeSelectionStarted&&"range"===t.selectionMode){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}return void(t.tooltip&&a&&a.close())}const n=t.shadowRoot||t.isInShadowDOM?e.composedPath()[0]:e.target;if(!n.closest(".smart-calendar-week"))return void(t.tooltip&&a&&(clearTimeout(t._tooltipAutoCloseTimeout),a[a.contains(n)?"open":"close"]()));const l=n.closest(".smart-calendar-cell");if(!l)return;if(Smart.Utilities.Core.isMobile||t._handleCalendarCellHover(e,l),!t.tooltip&&a)return void a.close();const i=l.hasAttribute("important");if(clearTimeout(t._tooltipAutoCloseTimeout),i&&a&&"mouseover"===e.type)return a.selector=l,void(a.selector!==l?a.close():(t.tooltipTemplate||(a.innerHTML=0===a.innerHTML.trim().length?"Important day!":a.innerHTML),a.open(),t.$.fireEvent("open",{target:a,value:new Date(l.value)})));t._tooltipAutoCloseTimeout=setTimeout(function(){!a||"mouseout"!==e.type&&l&&i||a.close(),clearTimeout(t._tooltipAutoCloseTimeout)}.bind(t),t.tooltipDelay)}_popupEventHandler(e){const t=this,a=t.$.tooltip;if(e.stopPropagation(),e.target!==t.$.monthElement)if(e.target===a)if("close"!==e.type);else{const e=a.selector;t.$.fireEvent("close",{target:a,value:e?new Date(e.value):null})}else t.$.fireEvent(e.type,{target:e.target})}_moveHandler(e){const t=this;if(!Smart.Utilities.Core.isMobile||!t._dragStartDetails||"list"===t.displayModeView&&"month"!==t.displayMode)return;e.originalEvent.preventDefault(),e.preventDefault(),e.stopPropagation();const a={x:Math.round(e.pageX),y:Math.round(e.pageY)};let n,l,i;if(n="portrait"===t.scrollButtonsNavigationMode?a.y>t._dragStartDetails.y?-1*t.months:1*t.months:a.x<t._dragStartDetails.x?1*t.months:-1*t.months,t._previousIteration&&n===t._previousIteration.step)l=t._previousIteration.date;else if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let e,a;t._focusedCell||t._focusCell();const i=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));if(i.length){let s;!t.rightToLeft&&n<0||t.rightToLeft&&n>0?(s=i[0].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[s.length-1]:s[0]):(s=i[i.length-1].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[0]:s[s.length-1]),e=new Date(a.value),e.setDate(e.getDate()+n*(t.rightToLeft?-1:1)),l=e}else l=t._getNextDate(n*(t.rightToLeft?-1:1))}else l=t._getNextDate(n*(t.rightToLeft?-1:1));if(!l)return;if(!t._dragStartDetails.navigationDate&&t.$.fireEvent("navigationChanging",{value:new Date(l),type:t.displayMode}).defaultPrevented)return t._cancelAnimation(),void(t._dragStartDetails=void 0);if(t._dragStartDetails.step=n,t._dragStartDetails.navigationDate=new Date(l),!t.hasAnimation)return;if(t._previousIteration={step:n,date:l},t._mobileScrolling=!0,"month"!==t.displayMode)t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),i=t.$.dateViewContainer,t.$.nextMonthsContainer.children[0].value instanceof Date&&t.$.nextMonthsContainer.children[1].value.getFullYear()===l.getFullYear()||t._setDisplayModeContent(l,t.$.nextMonthsContainer);else if(t.$nextMonthsContainer.hasClass("smart-calendar-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),i=t.$.monthsContainer,!t.$.nextMonthsContainer.children[0]._date||t.$.nextMonthsContainer.children[0]._date.getTime()!==l.getTime()){let e=t.$.nextMonthsContainer.children;for(let a=0;a<e.length;a++)l.setMonth(t._dragStartDetails.navigationDate.getMonth()+a*(t.rightToLeft?-1:1)),t._setMonth(new Date(l),e[a],!0)}6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(n*(t.rightToLeft?-1:1),t._getCellByDate(l,t.$.nextMonthsContainer)),delete t._mobileScrolling,n<0?(i.style.order=3,t.$.nextMonthsContainer.style.order=1,t.$.body[t._animationSettings.scrollSize]=t.$.body[t._animationSettings.scrollMax]):(i.style.order=1,t.$.nextMonthsContainer.style.order=3,t.$.body[t._animationSettings.scrollSize]=0);const s="portrait"===t.scrollButtonsNavigationMode?"y":"x";Math.abs(t._dragStartDetails[s]-a[s])>5&&(t.$.body[t._animationSettings.scrollSize]+=2*-(a[s]-t._dragStartDetails[s]))}_getNextDate(e){const t=this;let a;if("month"!==t.displayMode){let n;const l=t._focusedCell&&t._focusedCell.value.getFullYear();if("list"===t.displayModeView)a=new Date(t.$.listViewContainer.querySelector("li").getAttribute("value"));else{let e=t._animationStarted?t.$.nextMonthsContainer:t.$.dateViewContainer;a=new Date("year"===t.displayMode?e.children[0].value:e.children[1].value)}n="year"===t.displayMode?1:0!==e?10:1,a.setFullYear(a.getFullYear()+(e>0?n:-n)),a.getTime()<t.min.getTime()&&(a=t.min),a.getTime()>t.max.getTime()&&(a=t.max);const i="month"!==t.displayMode&&"list"===t.displayModeView;if(a.getFullYear()<t.min.getFullYear()||a.getFullYear()>t.max.getFullYear()||!i&&l===a.getFullYear())return}else{let n=t._viewDates[0];if(a=new Date(n),a.setDate(1),a.setMonth(a.getMonth()+e),a.setTime(Math.min(Math.max(a.getTime(),t.min.getTime()),t.max.getTime())),n.getMonth()===a.getMonth()&&n.getFullYear()===a.getFullYear())return}return a}_navigateDays(e){const t=this;let a="ArrowUp"===e.key||"ArrowDown"===e.key?7:1,n="ArrowUp"===e.key||"ArrowLeft"===e.key||"PageUp"===e.key?-1:1;switch(e.key){case"ArrowUp":case"ArrowLeft":case"ArrowDown":case"ArrowRight":if(!t._handleArrowKeys(e,a,n))return;break;case" ":case"Enter":{if("month"!==t.displayMode)return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell);const e=t._focusedCell;if("oneExtended"===t.selectionMode&&e)return t._clearSelection(!0),void t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break}case"Control":case"Shift":return"default"===t.selectionMode&&(t._keysPressed[e.key]=!0),void("range"===t.selectionMode&&(t._keysPressed[e.key]="Control"===e.key));case"Home":case"End":{e.preventDefault();let a,n=function(t){if("Home"===e.key){for(let e=0;e<t.length;e++)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]}else for(let e=t.length-1;e>=0;e--)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]};if(a="month"!==t.displayMode?n(t.$.dateViewContainer.children):n(t._getMonthCells(t._focusedCell.closest(".smart-calendar-month"),t.rightToLeft)),!a)return;if(t._focusCell(a),"month"!==t.displayMode)return;break}case"PageUp":case"PageDown":if(!t._handlePageUpDownKeys(e,n))return;break;default:return}"oneExtended"!==t.selectionMode&&t._focusedCell&&t._handleDateSelection(t._focusedCell)}_handleArrowKeys(e,t,a){const n=this;let l;if("month"!==n.displayMode||n._animationStarted||n.unfocusable||n.$.body.focus(),n._focusedCell||n._focusCell(n._getCellByDate(new Date)),e.altKey)return;if(e.ctrlKey){if("ArrowDown"===e.key||"ArrowUp"===e.key){if("classic"===n.calendarMode)return;let t;switch(n.displayMode){case"month":t="ArrowDown"===e.key?"month":"year";break;case"year":t="ArrowDown"===e.key?"month":"decade";break;case"decade":t="ArrowDown"===e.key?"year":"decade"}if(t!==n.displayMode){const e=n.displayMode;n.displayMode=t,n._setDisplayMode(e,t,"month"===e),n._keysPressed&&delete n._keysPressed.Control}}return}if(e.preventDefault(),!n.rightToLeft||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(a*=-1),"month"!==n.displayMode&&"list"!==n.displayModeView){const i=n._animationStarted?n.$.nextMonthsContainer.children:n.$.dateViewContainer.children;if(t="ArrowUp"===e.key||"ArrowDown"===e.key?4:1,"year"===n.displayMode){const e=n._focusedCell.value.getMonth()+a*t;let i=new Date(n._focusedCell.value.getFullYear(),e+1,0);n._focusedCell.value.getDate()<=i.getDate()&&(i=n._focusedCell.value),l=new Date(n._focusedCell.value.getFullYear(),e,i.getDate())}else l=new Date(n._focusedCell.value.getFullYear()+a*t,n._focusedCell.value.getMonth(),n._focusedCell.value.getDate());if("year"===n.displayMode){if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()===n.min.getFullYear()&&l.getMonth()<n.min.getMonth()||l.getFullYear()>n.max.getFullYear()||l.getFullYear()===n.max.getFullYear()&&l.getMonth()>n.max.getMonth())return;l.getTime()>i[i.length-1].value.getTime()?n.navigate(1):l.getTime()<i[0].value.getTime()&&n.navigate(-1)}else{if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()>n.max.getFullYear())return;if(l.getFullYear()<i[1].value.getFullYear()||l.getFullYear()>i[10].value.getFullYear()){let t=n._focusedCell;n.navigate(a),"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(t===i[3]||t===i[4]||t===i[7]||t===i[8]?l.setFullYear(l.getFullYear()+2*a):l.setFullYear(l.getFullYear()-2*a))}}return void n._focusCell(n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0))}if(!n._focusedCell)return;const i=n.restrictedDates.map(Number);for(l=new Date(n._focusedCell.value.getFullYear(),n._focusedCell.value.getMonth(),n._focusedCell.value.getDate()+a*t,0,0,0,0);i.indexOf(l.getTime())>-1;)l.setDate(l.getDate()+a);if(l.getTime()<n.min.getTime()||l.getTime()>n.max.getTime())return;n._isDateInView(l)||n.navigate(a*n.months);let s=n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0);return n._focusCell(s),n._updateWeeksVisibility(a),!(["zeroOrMany","oneOrMany","none","many","week","range"].indexOf(n.selectionMode)>-1)||void 0}_handlePageUpDownKeys(e,t){const a=this;let n;if(e.preventDefault(),"month"!==a.displayMode){if(n=a._focusedCell,!a.navigate(t))return;for(;n&&n.classList.contains("smart-visibility-hidden");)n=null===n.previousElementSibling?n.nextElementSibling:n.previousElementSibling;return a._focusCell(n),void(a.hasAnimation&&"decade"===a.displayMode&&a._focusedCell.value.setFullYear(a._focusedCell.value.getFullYear()+10*t))}n=new Date(a._focusedCell.value.getFullYear(),a._focusedCell.value.getMonth()+t,1,0,0,0,0);let l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return a._focusedCell.value.getDate()>l?n.setDate(l):n.setDate(a._focusedCell.value.getDate()),a._isDateInView(n)||a.navigate(n),a._animationStarted?a._focusCell(a._getCellByDate(n,a.$.nextMonthsContainer)):a._focusCell(a._getCellByDate(n)),!0}_selectDate(e,t,a){const n=this;if(void 0===n._viewDates||"none"===n.selectionMode)return;let l,i=n.selectedDates.slice(0),s=n._getCellByDate(e,n._animationStarted?n.$.nextMonthsContainer:void 0);s&&n._selectCell(s),(e=new Date(e)).setHours(0,0,0,0),l=i.map(Number).indexOf(e.getTime()),n.restrictedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<n.min.getTime()||e.getTime()>n.max.getTime()||(l>-1?i.splice(l,1):i.push(e),a||(n.selectedDates=i),n._refreshFooter(),n.$.hiddenInput.value=n.selectedDates.toString(),!t&&n.isInitialized&&(n.$.fireEvent("change",{value:[e]}),n._updateTargetValue()),n._refreshTitle())}_selectCell(e){const t=this;if(!e||t.restrictedDates.map(Number).indexOf(e.value.getTime())>-1||t.disableAutoNavigation&&!1===e.otherMonth||e.value.getTime()<t.min.getTime()||e.value.getTime()>t.max.getTime())return;const a=t._selectedCells.indexOf(e);a>-1?(t._setCellState(e,"selected",!1),t._selectedCells.splice(a,1)):(t._setCellState(e,"selected",!0),t._selectedCells.push(e)),t._focusCell(e)}_refreshDayOfWeekTitles(){const e=this;let t,a=[],n=new Date;function l(t){let a;return"firstTwoLetters"===e.dayNameFormat?(a=new Intl.DateTimeFormat(e.locale,{weekday:"long"}).format(t),a=8206===a.charCodeAt(0)?a.substring(1,3):a.substring(0,2)):a=new Intl.DateTimeFormat(e.locale,{weekday:e.dayNameFormat}).format(t),a}for(let e=1;e<8;e++)n.setDate(e),t={number:n.getDay(),name:l(n)},a.push(t);a.sort(((e,t)=>e.number>t.number?1:-1));const i=e.$.monthsContainer.children;let s,o;for(let t=0;t<i.length;t++)if(s=i[t].getElementsByClassName("smart-calendar-week-titles")[0].children,o=e.firstDayOfWeek>6?0:e.firstDayOfWeek,e.rightToLeft)for(let e=s.length-1;e>=1;e--)s[e].textContent=a[o++].name,o=o>6?0:o;else for(let e=1;e<s.length;e++)s[e].textContent=a[o++].name,o=o>6?0:o;if(e.hasAnimation){const t=e.$.monthsContainer.getElementsByClassName("smart-calendar-week-titles")[0].innerHTML,a=e.$.nextMonthsContainer.getElementsByClassName("smart-calendar-week-titles");for(let e=0;e<a.length;e++)a[e].innerHTML=t}}_refreshCalendarMode(){const e=this;if(!e.headerTemplate)if(e._refreshMonthNames(),"default"===e.calendarMode){e.$classicHeaderDate.addClass("smart-hidden"),e.$defaultHeaderDate.removeClass("smart-hidden");const t=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),a=t[0],n=t[t.length-1];a.setDate(2);let l=e.monthNameFormat;"firstTwoLetters"===l&&(l="long");let i=a.toLocaleDateString(e.locale,{year:e.yearFormat,month:l});e.months>1&&(n.setDate(2),i+=" - "+n.toLocaleDateString(e.locale,{year:e.yearFormat,month:l})),e.$.defaultHeaderDate.innerHTML=i,e.unfocusable||e.$.dateElement.setAttribute("tabindex",e.tabIndex>0?e.tabIndex:0)}else e.$defaultHeaderDate.addClass("smart-hidden"),e.$classicHeaderDate.removeClass("smart-hidden"),e.$.dateElement.removeAttribute("tabindex")}_refreshFooter(){const e=this;if(!(e.viewSections.indexOf("footer")<0||0===e.$.footer.offsetHeight))if(e.footerTemplate){if("function"==typeof e.footerTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.footer))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let e=n.childNodes[a.bindings[0].childNodeIndex];a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=e.innerHTML.replace(a.bindings[0].bindingString,t())}}else e.$.selectedDatesRange.innerHTML=t();function t(){if(0===e.selectedDates.length)return"";if(1===e.selectedDates.length)return e.selectedDates[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"});{let t=e.selectedDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime()));return t[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})+" - "+t[t.length-1].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})}}}_refreshImportantDates(){const e=this;if("month"===e.displayMode){e._clearImportantDates();for(let t=0;t<e.importantDates.length;t++)e._setImportantDate(e.importantDates[t])}}_clearImportantDates(){const e=this,t=e.$.monthsContainer.children;for(let a=0;a<t.length;a++)e._getMonthCells(t[a]).map((t=>{e._setCellState(t,"important",!1)}))}_setImportantDate(e,t){const a=this,n=a._getCellByDate(e);t||(t=n),t&&(a._setCellState(t,"important",!0),a._applyImportantDateTemplate(t))}_applyImportantDateTemplate(e){const t=this;if(!t._importantDatesTemplate)return"function"==typeof t.importantDatesTemplate?void t.importantDatesTemplate(e,{value:e.value}):void(e.innerHTML=e.value.getDate()+"");let a=document.importNode(t._importantDatesTemplate.content,!0);if(t._bindingDetails&&t._bindingDetails.length>0){let n=a.childNodes[t._bindingDetails[0].childNodeIndex];n.innerHTML=n.innerHTML.replace(t._bindingDetails[0].bindingString,e.value.getDate())}e.innerHTML="";for(let t=0;t<a.childNodes.length;t++)a.childNodes[t].outerHTML&&(e.innerHTML+=a.childNodes[t].outerHTML)}_setMonth(e,t,a){const n=this,l=n._getDays(e,n.selectedDates),i=n._getDays(e,n.importantDates),s=n._getDays(e,n.restrictedDates);e.setDate(1),t||(t=n.$.month),t._date=new Date(e),a||((!n._viewDates||n._viewDates.length>=n.months)&&(n._viewDates=[]),n._viewDates.push(new Date(e)));let o=((e=new Date(e)).getDay()-n.firstDayOfWeek+7)%7;e.setDate(0);let r=e.getDate();if(e.setDate(32),e.setDate(1),e.setDate(32),n._selectedCells)for(let e=0;e<n._selectedCells.length;e++)n._selectedCells[e].closest(".smart-calendar-month")===t&&n._setCellState(n._selectedCells[e],"selected",!1);n._setMonthContent(e,t,{previusMonthDays:r,firstDayOfWeek:o,selectedDates:l,importantDates:i,restrictedDates:s})}_setMonthContent(e,t,a){const n=this,l=32-e.getDate(),i=n._getMonthCells(t,n.rightToLeft),s=t._date.getMonth(),o=t._date.getFullYear(),r=new Date;let d,c=1,m=1;r.setHours(0,0,0,0),i.map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)}));for(let e=0;e<i.length;e++){const h=i[e];e===a.firstDayOfWeek&&m<=l?(h.className="smart-calendar-cell",h.value=new Date(o,s,m),h.innerHTML=h.value.getDate().toString(),a.restrictedDates.indexOf(m)>-1||h.value.getTime()<n.min.getTime()||h.value.getTime()>n.max.getTime()?n._setCellState(h,"restricted",!0):a.selectedDates.indexOf(m)>-1&&(n._setCellState(h,"selected",!0),n._selectedCells.indexOf(h)<0&&n._selectedCells.push(h)),a.importantDates.indexOf(m)>-1&&(n._setImportantDate(h.value,h),a.importantDates.splice(a.importantDates.indexOf(m),1)),h.value.getTime()===r.getTime()&&n._setCellState(h,"today",!0),a.firstDayOfWeek++,m++):(1===m?(h.value=new Date(o,s-1,++a.previusMonthDays-a.firstDayOfWeek),d=!!(h.value.getTime()<n.min.getTime()||t.previousElementSibling)):(h.value=new Date(o,s+1,c++),d=!!(h.value.getTime()>n.max.getTime()||t.nextElementSibling)),h.innerHTML=h.value.getDate().toString(),n._setCellState(h,"otherMonth",!0),d?h.classList.add("smart-visibility-hidden"):h.classList.remove("smart-visibility-hidden"))}n.months>1&&(t.firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(t._date):n._monthsNames[s]+" "+t._date.toLocaleDateString(n.locale,{year:n.yearFormat})),n._setMonthWeekNumbers(t)}_refreshMonthNames(){const e=this;let t,a=new Date;function n(t){let a=e.monthNameFormat;"firstTwoLetters"===a&&(a="long");let n=new Intl.DateTimeFormat(e.locale,{month:a}).format(t);return"firstTwoLetters"===e.monthNameFormat&&(n=8206===n.charCodeAt(0)?n.substring(0,2):n.substring(1,3)),n}a.setDate(1),e._monthsNames=[];for(let l=0;l<12;l++)a.setMonth(l),t=n(a),e._monthsNames.push(t);if("classic"===e.calendarMode&&e.$.monthElement){let t=e.$.monthsContainer.children;if(e.$.monthElement.dataSource&&(e._changeEventFired=1),e.shadowRoot?e._setMonthElementPropertyInShadowDOM("dataSource",e._monthsNames):e.$.monthElement.dataSource=e._monthsNames,e._viewDates){for(let a=0;a<t.length;a++)t[a].firstElementChild.textContent=e._monthsNames[t[a]._date.getMonth()]+" "+t[a]._date.getFullYear();e._changeEventFired=1,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates.map((e=>e.getMonth()))[0]):e.$.monthElement.selectedIndex=e._viewDates.map((e=>e.getMonth()))[0]}}}_setMonthWeekNumbers(e){const t=this,a=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!0};let n=e.getElementsByClassName("smart-calendar-week");n=[].slice.call(n);for(let l=0;l<n.length;l++){if(!a(n[l])){n[l].children[0].innerHTML="";continue}const i=n[l].children[1],s=i.otherMonth?i.value.getTime()>e._date.getTime()?1:-1:0;n[l].children[0].innerHTML=t._getWeekNumber(new Date(e._date.getFullYear(),e._date.getMonth()+s,i.value.getDate()))}}_setRestrictedDates(e){const t=this,a=t.$.monthsContainer.children;for(let e=0;e<a.length;e++)t._getMonthCells(a[e]).map((e=>{t._setCellState(e,"restricted",!1)}));if(t._viewDates){const a=function(e){for(let a=0;a<t._viewDates.length;a++)if(t._viewDates[a].getFullYear()===e.getFullYear()&&t._viewDates[a].getMonth()===e.getMonth())return!0};for(let n=0;n<e.length;n++)if(a(e[n])){const a=t._getCellByDate(e[n]);t._setCellState(a,"restricted",!0)}}}_setScrollButtonsNavigationMode(){const e=this;"landscape"!==e.scrollButtonsNavigationMode?(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-down smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-up smart-arrow")):(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-left smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-right smart-arrow")),e._applyAnimationSettings(!0)}_refreshTitle(){const e=this;let t=e.selectedDates.length>0?e.selectedDates[e.selectedDates.length-1]:new Date;if(e.titleTemplate){if("function"==typeof e.titleTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.title))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let l=n.childNodes[a.bindings[0].childNodeIndex];return t=t.toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"}),void(a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=l.innerHTML.replace(a.bindings[0].bindingString,t))}}e.$.title.children[0].innerHTML=t.toLocaleDateString(e.locale,{year:e.yearFormat}),e.$.title.children[1].innerHTML="landscape"===e.view?t.toLocaleDateString(e.locale,{weekday:"short"})+",</br>"+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"}):t.toLocaleDateString(e.locale,{weekday:"short"})+", "+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"})}_setWeeksVisibility(e){const t=this,a=e.children;let n;function l(e){(function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0})(e)||n>=t.weeks?e.classList.add("smart-hidden"):n<t.weeks&&(e.classList.remove("smart-hidden"),n++)}for(let e=0;e<a.length;e++){let i=a[e].getElementsByClassName("smart-calendar-week");i=[].slice.call(i);let s=t._selectedCells.filter((t=>t.closest(".smart-calendar-month")===a[e]));if(6!==t.weeks)if(n=0,s.length>0){let e=s[s.length-1],t=i.indexOf(e.parentElement);for(let e=t;e<i.length;e++)l(i[e]);for(let e=t-1;e>=0;e--)l(i[e])}else for(let e=0;e<i.length;e++)l(i[e]);else i.map((e=>e.classList.remove("smart-hidden")))}}_refreshHeaderElements(){const e=this,t=document.activeElement.closest("smart-calendar")===e,a=e._animationStarted?e.$.nextMonthsContainer:e.$.dateViewContainer;let n,l,i=e._viewDates[e._viewDates.length-1],s=e._viewDates.map((e=>e.getFullYear()));if("month"===e.displayMode||"list"!==e.displayModeView){if("classic"===e.calendarMode&&e.$.monthElement&&e.$.monthElement instanceof HTMLDivElement){const t=document.createElement("smart-input");t.setAttribute("smart-id","monthElement"),t.classList.add("smart-calendar-month-element"),t.dropDownPosition="bottom",t.selectionMode="one",t.disabled=e.disabled,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.dropDownWidth=e.dropDownWidth,t.dropDownHeight=e.dropDownHeight,t.readonly=!0,t.dropDownButtonPosition="right";const a=e.$.monthElement;e.$.monthElement.parentNode.insertBefore(t,e.$.monthElement),e.$.monthElement=t,a.remove()}if(e.$.previousMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()-1:a.children[1].value.getFullYear()-1:e._viewDates[0].getMonth()-1<0?(n=11,l=e._viewDates[0].getFullYear()-1):(n=e._viewDates[0].getMonth()-1,l=e._viewDates[0].getFullYear()),e.$.previousMonthButton.disabled=l<e.min.getFullYear()||l===e.min.getFullYear()&&n<e.min.getMonth(),e.$.previousMonthButton.disabled&&t&&e.$.body.focus()),e.$.nextMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()+1:a.children[1].value.getFullYear()+11:i.getMonth()+1>11?(n=0,l=i.getFullYear()+1):(n=i.getMonth()+1,l=i.getFullYear()),e.$.nextMonthButton.disabled=l>e.max.getFullYear()||l===e.max.getFullYear()&&n>e.max.getMonth(),e.$.nextMonthButton.disabled&&t&&e.$.body.focus()),"classic"===e.calendarMode&&e.$.monthElement){let t=[...e._monthsNames];if(s.indexOf(e.min.getFullYear())>-1)for(let a=0;a<e.min.getMonth();a++)t[a]="";if(s.indexOf(e.max.getFullYear())>-1)for(let a=e.max.getMonth()+1;a<t.length;a++)t[a]="";t=t.filter((e=>""!==e));const a=Math.max(0,e.$.monthElement.selectedIndex);e.$.monthElement.dataSource=t,e._changeEventFired=0!==e.$.monthElement.selectedIndex,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates[0].getMonth()):e.$.monthElement.selectedIndex=a,e._changeEventFired=0}e.$.previousYearButton&&!e.disabled&&(l=e._viewDates[0].getFullYear()-1,e.$.previousYearButton.disabled=l<e.min.getFullYear(),e.$.previousYearButton.disabled&&t&&e.$.body.focus()),e.$.nextYearButton&&!e.disabled&&(l=i.getFullYear()+1,e.$.nextYearButton.disabled=l>e.max.getFullYear(),e.$.nextYearButton.disabled&&t&&e.$.body.focus()),e.$.yearElement&&(e.$.yearElement.value=s[0],e.$.yearElement.disabled=i.getFullYear()+1>e.max.getFullYear()&&e._viewDates[0].getFullYear()-1<e.min.getFullYear())}}_setMonthElementPropertyInShadowDOM(e,t){const a=this.$.monthElement,n=a.context;a.context=document,this.$.monthElement[e]=t,a.context=n}_refreshHeaderTitle(){const e=this;let t;function a(){if("month"!==e.displayMode){if("list"===e.displayModeView){const a=e.$.listViewContainer;if(!a)return;const n=a.querySelectorAll("li");if(!n.length)return"";let l;a.querySelector("li.active")&&(l=a.querySelector("li.active").getAttribute("value")),t="year"===e.displayMode?new Date(l||n[0].getAttribute("value")).getFullYear():new Date(n[0].getAttribute("value")).getFullYear()+" - "+new Date(n[n.length-1].getAttribute("value")).getFullYear()}else if(e.$.dateViewContainer.children[0].value){let a=e._animationStarted?e.$.nextMonthsContainer.children:e.$.dateViewContainer.children;t="year"===e.displayMode?a[0].value.getFullYear():a[1].value.getFullYear()+" - "+a[a.length-2].value.getFullYear()}if(t)return t}const a=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),n=a[0],l=a[a.length-1];n.setDate(2);let i=e.monthNameFormat;return"firstTwoLetters"===i&&(i="long"),t=n.toLocaleDateString(e.locale,{year:e.yearFormat,month:i}),e.months>1&&(l.setDate(2),t+=" - "+l.toLocaleDateString(e.locale,{year:e.yearFormat,month:i})),t}if("default"===e.calendarMode&&(e.$.defaultHeaderDate.innerHTML=a()),"function"==typeof e.headerTemplate||!e._layoutTemplates)return;let n=e._layoutTemplates.filter((t=>t.selector===e.$.header))[0];if(!n)return;let l=document.importNode(n.template.content,!0);if(n.bindings.length>0){const t=l.childNodes[n.bindings[0].childNodeIndex];(e.shadowRoot?e:n.selector).childNodes[n.bindings[0].childNodeIndex].innerHTML=t.innerHTML.replace(n.bindings[0].bindingString,e.dateFormatFunction?e.dateFormatFunction(e._viewDates):a())}}_updateWeeksVisibility(e,t){const a=this;let n=(t||a._focusedCell).parentElement;function l(){for(let e=o;e<s.length;e++)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}function i(){for(let e=o;e>=0;--e)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}if(!t&&!n.classList.contains("smart-hidden"))return;const s=[].slice.call(n.parentElement.children),o=s.indexOf(n),r=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0};let d=0;if(s.map((e=>e.classList.add("smart-hidden"))),e>0){if(l())return;i()}else{if(i())return;l()}}_getValidDates(e){let t=[];function a(e){if(e instanceof Date)return e;if(Smart.Utilities.DateTime&&e instanceof Smart.Utilities.DateTime)return e.toDate();if("string"==typeof e){if("new Date()"===e.trim()||"new Smart.Utilities.DateTime()"===e.trim())return new Date;let t=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;const a=()=>(e=e.replace(/[,-.\/]/g,",").split(",")).length>2?e=new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):new Date;return t.test(e)&&(e=t.exec(e)[0].replace(/[,-.\/]/g,",").split(","))?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):a()}}if(void 0===e)return null;if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(a(e[n]));else t.push(a(e));return t=t.filter((e=>e&&"Invalid Date"!==e.toDateString())),t.map((e=>e.setHours(0,0,0,0))),t}_getValidDate(e){const t=this._getValidDates(e);return t.length>0?t[0]:null}_validateSelectedDates(e){const t=this;let a=[];e||(e=t.selectedDates);let n=e.slice(0),l=function(e){for(let a=0;a<t.restrictedDates.length;a++)if(t.restrictedDates[a].getTime()===e.getTime())return!0};t.selectedDates=n.filter((function(e){if(e.getTime()>=t.min.getTime()&&e.getTime()<=t.max.getTime()&&!l(e))return!0;a.push(e)})),t._viewDates&&(a.map((e=>t._selectDate(e))),t._focusCell())}_validateMinMax(e,t,a){const n=this;switch(e){case"min":t=n._getValidDate(n[e]),n.min=t||a||n.properties.min.defaultValue;break;case"max":t=n._getValidDate(n[e]),n.max=t||a||n.properties.max.defaultValue;break;default:t=n._getValidDate(n.min),n.min=t||a||n.properties.min.defaultValue,t=n._getValidDate(n.max),n.max=t||a||n.properties.max.defaultValue}n.min=n.min.getTime()>n.max.getTime()?n.max:n.min,n.min.setHours(0,0,0,0),n.max.setHours(0,0,0,0);let l,i=n.$.monthsContainer.children;if(n._viewDates){if(n._viewDates[0].getTime()>n.max.getTime()||n._viewDates[0].getTime()<n.min.getTime())return void n._handleMonths();for(let e=0;e<i.length;e++){l=n._getMonthCells(i[e]);for(let t=0;t<l.length;t++){const a=l[t];if(a.value.getTime()>=n.min.getTime()&&a.value.getTime()<=n.max.getTime())n._setCellState(a,"restricted",!1),a.value.getMonth()===i[e]._date.getMonth()?a.classList.remove("smart-visibility-hidden"):n.hideOtherMonthDays||(n._setCellState(a,"otherMonth",!0),a.classList.remove("smart-visibility-hidden")),"month"!==n.displayMode&&n._setCellState(a,"otherMonth",!1);else{if(a.otherMonth){if(a.classList.contains("smart-visibility-hidden")){n._setCellState(a,"restricted",!1);continue}}else n._setCellState(a,"restricted",!0);"month"!==n.displayMode&&(a.classList.remove("smart-visibility-hidden"),n._setCellState(a,"otherMonth",!0))}}}}}_setCellState(e,t,a){e[t]=a;const n=Smart.Utilities.Core.toDash(t);a?(e.setAttribute(n,""),"selected"===t?e.setAttribute("aria-selected",!0):"today"===t?e.setAttribute("aria-current","date"):"restricted"===t?e.removeAttribute("aria-selected"):"disabled"===t&&(e.removeAttribute("aria-selected"),e.setAttribute("aria-disabled",!0))):(e.removeAttribute(n),"selected"===t?"none"===this.selectionMode||e.restricted||e.disabled?e.removeAttribute("aria-selected"):e.setAttribute("aria-selected",!1):"today"===t?e.removeAttribute("aria-current"):"restricted"!==t||e.disabled?"disabled"===t&&(e.removeAttribute("aria-disabled"),e.restricted||e.setAttribute("aria-selected",!1)):e.setAttribute("aria-selected",!1))}_validateTemplate(e,t){if(null===t||!t)return;if("function"==typeof t)return;const a=this;if("content"in document.createElement("template")){if("string"==typeof t&&(t=document.getElementById(t)),null!==t&&"content"in t)return t;a.error(a.localize("invalidTemplate",{elementType:a.nodeName.toLowerCase(),property:e}))}else a.error(a.localize("htmlTemplateNotSuported",{elementType:a.nodeName.toLowerCase()}))}_weeksDownHandler(e,t){const a=this,n=t.value;let l;if(a.$.body.contains(t))if(t.otherMonth&&(l=t.value.getTime()>t.closest(".smart-calendar-month")._date.getTime()?1:-1),n&&a.hasRippleAnimation&&Smart.Utilities.Animation.Ripple.animate(t,e.pageX,e.pageY),l){if(a._isDateInView(n))return;a.disableAutoNavigation||a.navigate(l*a.months)}else(t=a._getCellByDate(n))&&(t.disabled||t.restricted)||a._handleDateSelection(t)}_firstDayOfWeekValidator(e,t){return Math.min(Math.max(0,isNaN(t)?6:t),6)}_weeksValidator(e,t){return Math.min(Math.max(1,isNaN(t)?6:t),6)}_monthsValidator(e,t){return Math.min(Math.max(1,isNaN(t)?1:t),12)}});
20
+ Smart("smart-calendar",class extends Smart.BaseElement{static get properties(){return{animationSettings:{value:null,type:"object"},calendarMode:{value:"default",allowedValues:["default","classic"],type:"string"},dayNameFormat:{value:"firstTwoLetters",allowedValues:["narrow","firstTwoLetters","long","short"],type:"string"},dateFormatFunction:{value:null,type:"function"},disableAutoNavigation:{value:!1,type:"boolean"},displayMode:{value:"month",allowedValues:["month","year","decade"],type:"string"},displayModeView:{value:"table",allowedValues:["table","list"],type:"string"},dropDownHeight:{value:"200",type:"string"},dropDownWidth:{value:"",type:"string"},firstDayOfWeek:{value:0,type:"number",defaultValue:0,validator:"_firstDayOfWeekValidator"},footerTemplate:{value:null,type:"any"},headerTemplate:{value:null,type:"any"},hideDayNames:{value:!1,type:"boolean"},hideOtherMonthDays:{value:!1,type:"boolean"},hideTooltipArrow:{value:!1,type:"boolean"},importantDates:{value:[],type:"array",defaultValue:[]},importantDatesTemplate:{value:null,type:"any"},max:{value:new Date(2100,0,1),type:"any",defaultValue:new Date(2100,0,1)},min:{value:new Date(1900,0,1),type:"any",defaultValue:new Date(1900,0,1)},months:{value:1,type:"number",defaultValue:1,validator:"_monthsValidator"},monthNameFormat:{value:"long",allowedValues:["narrow","firstTwoLetters","long","short","2-digit","numeric"],type:"string"},name:{value:"",type:"string"},restrictedDates:{value:[],type:"array",defaultValue:[]},scrollButtonsNavigationMode:{value:"landscape",allowedValues:["portrait","landscape"],type:"string"},scrollButtonsPosition:{value:"both",allowedValues:["near","far","both"],type:"string"},selectedDates:{value:[],reflectToAttribute:!1,type:"array"},selectionMode:{value:"default",allowedValues:["none","default","one","oneExtended","many","zeroOrMany","oneOrMany","zeroOrOne","week","range"],type:"string"},spinButtonsDelay:{value:80,type:"number"},spinButtonsInitialDelay:{value:0,type:"number"},titleTemplate:{value:null,type:"any"},tooltip:{value:!1,type:"boolean"},tooltipArrow:{value:!0,type:"boolean"},tooltipArrowDirection:{allowedValues:["bottom","top","left","right","none"],value:"bottom",type:"string"},tooltipDelay:{value:100,type:"number"},tooltipOffset:{value:[],type:"array"},tooltipPosition:{value:"auto",allowedValues:["auto","bottom","top","left","right","absolute"],type:"string"},tooltipTemplate:{value:null,type:"any"},view:{value:"portrait",allowedValues:["landscape","portrait"],type:"string"},viewSections:{value:["header"],type:"array"},weekNumbers:{value:!1,type:"boolean"},weeks:{value:6,type:"number",defaultValue:6,validator:"_weeksValidator"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"}}}static get listeners(){return{"container.down":"_downHandler","document.up":"_documentUpHandler","body.move":"_moveHandler","container.wheel":"_containerWheelHandler","body.focus":"_bodyFocusStateHandler","body.blur":"_bodyBlurStateHandler","header.click":"_headerClickHandler","header.change":"_headerChangeHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",mouseenter:"_mouseEventsHandler",mouseleave:"_mouseEventsHandler","container.mouseover":"_mouseEventsHandler","container.mouseout":"_mouseEventsHandler","container.open":"_popupEventHandler","container.close":"_popupEventHandler"}}static get methods(){return{select:"select(date=new Date(): date|string): void",clearSelection:"clearSelection(): void",today:"today(): date",navigate:"navigate(step: date|string|int): bool"}}static get styleUrls(){return["smart.calendar.css"]}template(){return'<div id="container" role="presentation">\n <div id="title" class="smart-calendar-title" role="heading" aria-level="1">\n <div id="yearContainer" class="smart-calendar-year-container" role="button"></div>\n <div id="dateContainer" class="smart-calendar-date-container smart-calendar-selected" role="button"></div>\n </div>\n <div id="calendarContainer" class="smart-calendar-container">\n <div id="header" class="smart-calendar-header">\n <smart-repeat-button prev-month class="smart-calendar-button" id="previousMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <div id="dateElement" class="smart-calendar-date-element" role="presentation">\n <div id="defaultHeaderDate" role="button"></div>\n <div id="classicHeaderDate">\n <div id="monthElement" class="smart-calendar-month-element" disabled="[[disabled]]" role="presentation">\n </div>\n <input class="smart-calendar-year-element" id="yearElement" disabled="[[disabled]]" readonly="[[readonly]]" aria-label="Year" />\n <span class="smart-calendar-year-elements">\n <smart-repeat-button next-year class="smart-calendar-button" id="nextYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <smart-repeat-button prev-year class="smart-calendar-button" id="previousYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </span>\n </div>\n </div>\n <smart-repeat-button next-month class="smart-calendar-button" id="nextMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </div>\n <div id="body" class="smart-content smart-calendar-body" role="presentation">\n <div id="monthsContainer" class="smart-calendar-months-container" role="presentation">\n <div id="month" class="smart-calendar-month" role="grid">\n <div id="monthName" class="smart-calendar-month-name"></div>\n <div id="weekTitles" class="smart-calendar-week-titles" role="row">\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n </div>\n <div id="weeks" class="smart-calendar-weeks" role="rowgroup">\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n </div>\n </div>\n </div>\n <div id="dateViewContainer" class="smart-calendar-date-view-container smart-hidden">\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n </div>\n <div id="monthsSeparator" class="smart-calendar-month-separator"></div>\n <div id="nextMonthsContainer" class="smart-calendar-next-months-container" aria-hidden="true"></div>\n <div id="animationPanel" class="smart-calendar-animation-panel smart-hidden"></div>\n </div>\n <div id="footer" class="smart-calendar-footer smart-hidden">\n <div id="selectedDatesRange"></div>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>\n </div>'}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const a=e.dataset.property,n=e.selectedDates.toString();a&&void 0!==t[a]&&(t[a]=n)}}}propertyChangedHandler(e,t,a){super.propertyChangedHandler(e,t,a);const n=this;switch(e){case"animationSettings":n._applyAnimationSettings();break;case"disabled":case"unfocusable":n._setFocusable();break;case"calendarMode":case"dropDownWidth":case"dropDownHeight":n.displayMode="month",n._refreshHeaderElements(),n._refreshCalendarMode(),n._setDisplayModeContent();break;case"dayNameFormat":n._refreshDayOfWeekTitles(n.$.month);break;case"dateFormatFunction":{let e=n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=a?a(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:n.yearFormat});n._refreshHeaderTitle();break}case"displayMode":if("classic"===n.calendarMode&&"month"!==a){n[e]="month";break}n._setDisplayMode(t,a);break;case"displayModeView":n._applyAnimationSettings(!0),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"firstDayOfWeek":n._handleMonths(),n._refreshDayOfWeekTitles();break;case"hideTooltipArrow":n.$.tooltip&&(n.$.tooltip.arrow=!a);break;case"titleTemplate":case"headerTemplate":case"footerTemplate":n._handleLayoutTemplate(n.$[e.split(/[T]/)[0]],a),"titleTemplate"===e?n._refreshTitle():"headerTemplate"===e?n._refreshHeaderTitle():n._refreshFooter();break;case"importantDates":n.importantDates=n._getValidDates(a),n._refreshImportantDates();break;case"importantDatesTemplate":n._handleImportantDateTemplate(),n._refreshImportantDates();break;case"locale":n._refreshMonthNames(),n._refreshDayOfWeekTitles(),n._refreshHeaderTitle(),n._refreshTitle(),n._refreshFooter(),n.displayMode&&"month"!==n.displayMode&&n._setDisplayModeContent();break;case"max":case"min":n._validateMinMax(e,a,t),n._validateSelectedDates(),n._noFocusingRequired=!1,n._refreshHeaderElements();break;case"months":n._handleMonths();break;case"monthNameFormat":n._refreshCalendarMode(),n._refreshHeaderTitle();break;case"restrictedDates":n._setRestrictedDates(n.restrictedDates=n._getValidDates(a));break;case"rightToLeft":n._refreshDayOfWeekTitles(),n._handleMonths();break;case"scrollButtonsNavigationMode":n._setScrollButtonsNavigationMode();break;case"selectedDates":if(n._clearSelection(!0),n._validateSelectedDates(n._getValidDates(a)),n._applySelectionMode(!0),n._viewDates){let e=n.selectedDates[n.selectedDates.length-1];n._isDateInView(e)?n.selectedDates.map((e=>n._selectDate(e,!0,!0))):n._handleMonths(e)}n._refreshFooter(),n._setWeeksVisibility(n.$.monthsContainer),n.$.hiddenInput.value=n.selectedDates.toString(),n.isInitialized&&(n.$.fireEvent("change",{value:n.selectedDates}),n._updateTargetValue()),n._refreshTitle(),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"selectionMode":n._applySelectionMode(!1,t),n._refreshTitle();break;case"tooltip":n._handleTooltip();break;case"tooltipArrow":case"tooltipArrowDirection":case"tooltipDelay":case"tooltipOffset":case"tooltipPosition":case"tooltipTemplate":if(n.$.tooltip){const t=e.replace("tooltip","");n.$.tooltip[t.charAt(0).toLowerCase()+t.slice(1)]=a}break;case"view":n._refreshTitle();break;case"viewSections":a.indexOf("title")>-1?n.$title.removeClass("smart-hidden"):n.$title.addClass("smart-hidden"),n._refreshTitle(),a.indexOf("header")>-1?n.$header.removeClass("smart-hidden"):n.$header.addClass("smart-hidden"),n._refreshHeaderTitle(),a.indexOf("footer")>-1?n.$footer.removeClass("smart-hidden"):n.$footer.addClass("smart-hidden"),n._refreshFooter(),n._setFocusable();break;case"weeks":n._setWeeksVisibility(n.$.monthsContainer);break;case"yearFormat":if(n._refreshCalendarMode(),n._refreshFooter(),n.months>1&&"month"===n.displayMode){let e=n._animationStarted?n.$.nextMonthsContainer.children:n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:a})}n._refreshTitle(),n._refreshHeaderTitle()}}ready(){super.ready();const e=this;e._keysPressed={},e._applyAnimationSettings(),e.importantDates=e._getValidDates(e.importantDates),e.restrictedDates=e._getValidDates(e.restrictedDates)}render(){const e=this;e.setAttribute("role","dialog"),e._refreshMonthNames(),e._validateMinMax(),e._validateSelectedDates(e._getValidDates(e.selectedDates)),e._handleLayoutTemplate(e.$.title,e.titleTemplate),e._handleLayoutTemplate(e.$.header,e.headerTemplate),e._handleLayoutTemplate(e.$.footer,e.footerTemplate),e._handleImportantDateTemplate(),e._setFocusable(),e._refreshDayOfWeekTitles(),e._applySelectionMode(!0),e._handleMonths(0===e.selectedDates.length?new Date((new Date).setHours(0,0,0,0)):e.selectedDates[e.selectedDates.length-1]),e._handleTooltip(),e._updateViewSectionsVisibility(),e._setScrollButtonsNavigationMode(),e._refreshCalendarMode(),e._setDisplayMode(),e._refreshTitle(),e._refreshFooter(),e._refreshImportantDates(),e.$.monthElement&&e.$.monthElement._setDropDownSize&&e.$.monthElement._setDropDownSize(),e._changeEventFired=0,e.$.hiddenInput.value=e.selectedDates.toString(),e.shadowRoot&&e.appendChild(e.$.hiddenInput),e.isInitialized=!0,super.render()}refresh(){this.isInitialized&&this.render()}_updateViewSectionsVisibility(){const e=this;e.viewSections.indexOf("title")>-1?e.$title.removeClass("smart-hidden"):e.$title.addClass("smart-hidden"),e.viewSections.indexOf("header")>-1?e.$header.removeClass("smart-hidden"):e.$header.addClass("smart-hidden"),e.viewSections.indexOf("footer")>-1?e.$footer.removeClass("smart-hidden"):e.$footer.addClass("smart-hidden")}clearSelection(){this._clearSelection()}_setFocusable(){const e=this;let t=e.tabIndex>0?e.tabIndex:0;function a(e,a){if(a)return e&&e instanceof a?("function"==typeof e._setFocusable&&e.isCompleted?e.unfocusable=t<=-1:e.setAttribute("tabindex",t),e):e||void 0}(e.disabled||e.unfocusable)&&(t=-1),e.$.previousMonthButton=a(e.$.previousMonthButton,Smart.Button),e.$.nextMonthButton=a(e.$.nextMonthButton,Smart.Button),e.$.nextYearButton=a(e.$.nextYearButton,Smart.Button),e.$.previousYearButton=a(e.$.previousYearButton,Smart.Button),e.$.monthElement=a(e.$.monthElement,Smart.Input),e.$.yearElement=a(e.$.yearElement,HTMLInputElement),e.viewSections.indexOf("title")>-1&&(e.$.dateContainer.setAttribute("tabindex",t),e.$.yearContainer.setAttribute("tabindex",t)),e.$.body.setAttribute("tabindex",t),"default"===e.calendarMode?e.$.dateElement.setAttribute("tabindex",t):e.$.dateElement.removeAttribute("tabindex"),e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.readonly&&!e.disabled?e.tabIndex>0?e.tabIndex:0:t}static get requires(){return{"Smart.DropDownList":"smart.dropdownlist.js","Smart.ListBox":"smart.listbox.js","Smart.RepeatButton":"smart.button.js","Smart.Tooltip":"smart.tooltip.js"}}navigate(e){const t=this;let a,n,l;if(e){if("number"==typeof e){if(e=parseInt(e),isNaN(e)||0===e)return!1;if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let l,i;t._focusedCell||t._focusCell();const s=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));e<0?(i=s[0].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[i.length-1]:i[0]):(i=s[s.length-1].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[0]:i[i.length-1]),n=new Date(l.value),n.setDate(n.getDate()+e),a=n}else a=t._getNextDate(e)}else{if(a=e=t._getValidDate(e),l=!0,isNaN(a.getTime()))return!1;const i=t._viewDates[0];if(i&&a.getMonth()===i.getMonth()&&a.getFullYear()===i.getFullYear())return!1;6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&(n=a)}return!(!a||t.$.fireEvent("navigationChanging",{value:new Date(a),type:t.displayMode}).defaultPrevented||("month"!==t.displayMode?(!l&&t.hasAnimation?(t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),"list"===t.displayModeView?t._setDisplayModeContent(a):t._navigationDate&&t._navigationDate.getTime()===a.getTime()||t._animateNavigation(a,e)):t._setDisplayModeContent(a),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0):(t.hasAnimation?(t._animateNavigation(a,e),t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container")):(t._handleMonths(a),t._refreshHeaderElements(),t._refreshHeaderTitle()),n&&(t._focusCell(t._getCellByDate(n,t._animationStarted?t.$.nextMonthsContainer:void 0),!0),t._updateWeeksVisibility(e)),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0)))}}set value(e){this._select(e)}get value(){return this.selectedDates&&this.selectedDates.length>0?this.selectedDates[0]:null}select(e){this._select(e)}_select(e){const t=this;t._viewDates&&void 0!==t._viewDates[0]&&"none"!==t.selectionMode&&e&&(e=t._getValidDate(e))instanceof Date&&("one"===t.selectionMode&&t.selectedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<t.min.getTime()||e.getTime()>t.max.getTime()||("one"!==t.selectionMode&&"default"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._clearSelection(!0),t._selectDate(e),1!==t.selectedDates.length||t._isDateInView(t.selectedDates[0])||t._handleMonths(t.selectedDates[0])))}today(){const e=this;let t=new Date;return t.setHours(0,0,0,0),t.getTime()<e.min.getTime()||t.getTime()>e.max.getTime()?t=new Date(e.max):e._selectDate(t),e._handleMonths(t),t}_animateNavigation(e,t,a){const n=this;n._navigationDate=e,n._animationSettings||n._applyAnimationSettings(),n.$animationPanel.addClass("smart-hidden"),n.$.dateViewContainer.style.transform="",n.$.dateViewContainer.style.opacity="",n.$.monthsContainer.style.transform="",n.$.monthsContainer.style.opacity="";const l="month"!==n.displayMode?n.$.dateViewContainer:n.$.monthsContainer,i=n.$.body[n._animationSettings.scrollMax]-n.$.body[n._animationSettings.size];n._scrollStep=n.$.body[n._animationSettings.size]*n._animationSettings.startSpeed,n._animationStarted&&n._getMonthCells(n.$.monthsContainer,n.rightToLeft).map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)})),n._animationStarted=!0,"month"!==n.displayMode?(n._setCellState(n._focusedCell,"focus",!1),n._setDisplayModeContent(e,n.$.nextMonthsContainer)):n._handleMonths(e,n.$.nextMonthsContainer),n.rightToLeft&&(t*=-1),a||(t>0?(l.style.order=1,n.$.nextMonthsContainer.style.order=3,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]>n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold*2)&&(n.$.body[n._animationSettings.scrollSize]=0)):(l.style.order=3,n.$.nextMonthsContainer.style.order=1,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]<n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold)&&(n.$.body[n._animationSettings.scrollSize]=n.$.body[n._animationSettings.scrollMax]))),cancelAnimationFrame(n._animationId),n._animationId=requestAnimationFrame((function e(){let a=t>0?n.$.body[n._animationSettings.scrollSize]>=i:0===n.$.body[n._animationSettings.scrollSize],l=n._scrollStep/2;a?n._animateNavigationCompleted():(t>0&&n.$.body[n._animationSettings.scrollSize]>i*n._animationSettings.easeThreshold?(l=Math.max(n.$.body[n._animationSettings.scrollSize]/n._animationSettings.stepEaseSize,Math.abs(l-(i-n.$.body[n._animationSettings.scrollSize])*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l):t<0&&n.$.body[n._animationSettings.scrollSize]<i*n._animationSettings.easeThreshold&&(l=Math.max(n.$.body[n._animationSettings.scrollMax]/n._animationSettings.stepEaseSize,Math.abs(l-n.$.body[n._animationSettings.scrollSize]*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l),n.$.body[n._animationSettings.scrollSize]+=t>0?n._scrollStep:-n._scrollStep,n._animationId=requestAnimationFrame(e))}))}_animateNavigationCompleted(){const e=this;let t,a,n,l="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;if(cancelAnimationFrame(e._animationId),"month"!==e.displayMode){let i=[].slice.call(l.children).indexOf(e._focusedCell);l.innerHTML=e.$.nextMonthsContainer.innerHTML;let s,o=l.children[i];a=l.children,n=e.$.nextMonthsContainer.children;for(let t=0;t<a.length;t++)a[t].value=n[t].value,a[t].restricted=n[t].restricted,a[t].important=n[t].important,a[t].otherMonth=n[t].otherMonth,a[t].value.getTime()<=e.max.getTime()&&(s=a[t]);t=o&&o.value.getTime()>=e.max.getTime()?s.value:e._focusedCell?e._focusedCell.value:void 0}else{let i=l.children,s=e.$.nextMonthsContainer.children;e._focusedCell&&e.$.nextMonthsContainer.contains(e._focusedCell)&&(t=e._focusedCell.value);for(let t=0;t<i.length&&s[t]._date;t++){i[t]._date=s[t]._date,i[t].innerHTML=s[t].innerHTML,a=e._getMonthCells(i[t]),n=e._getMonthCells(s[t]);for(let e=0;e<a.length;e++)a[e].value=n[e].value,a[e].restricted=n[e].restricted,a[e].important=n[e].important,a[e].otherMonth=n[e].otherMonth,a[e].removeAttribute("focus")}e._selectedCells.length>0&&(e._selectedCells=e._selectedCells.map((t=>e._getCellByDate(t.value))).filter((e=>void 0!==e)))}e._focusCell(e._getCellByDate(t)),l.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationStarted=!1,delete e._navigationDate}_applyAnimationSettings(e){const t=this;t._animationSettings=t.animationSettings?t.animationSettings:t._animationSettings||{},"portrait"===t.scrollButtonsNavigationMode?(t._animationSettings.scrollMax="scrollHeight",t._animationSettings.size="offsetHeight",t._animationSettings.scrollSize="scrollTop"):(t._animationSettings.scrollMax="scrollWidth",t._animationSettings.size="offsetWidth",t._animationSettings.scrollSize="scrollLeft"),e||(t._animationSettings.startSpeed=t._animationSettings.startSpeed?t._animationSettings.startSpeed:.2,t._animationSettings.easeThreshold=t._animationSettings.easeThreshold?t._animationSettings.easeThreshold:.5,t._animationSettings.step=t._animationSettings.step?t._animationSettings.step:.25,t._animationSettings.stepEaseSize=t._animationSettings.stepEaseSize?t._animationSettings.stepEaseSize:200,t._animationSettings.resetThreshold=t._animationSettings.resetThreshold?t._animationSettings.resetThreshold:.2)}_applySelectionMode(e,t){const a=this;let n=[],l=!!e,i=a.selectionMode;function s(e,t){const n=a.$.monthsContainer.children;for(let l=0;l<n.length;l++)a._getMonthCells(n[l]).map((n=>{a._setCellState(n,e,t)}))}switch("many"===i&&"range"===i||s("hover",!1),a._newRangeSelectionStarted=a.selectedDates.length>0&&"range"===i,-1!==["default","many","zeroOrMany","oneOrMany","week","range"].indexOf(i)?Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.setAttribute("aria-multiselectable",!0))):Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.removeAttribute("aria-multiselectable"))),"none"!==i&&"none"!==t||s("selected",!1),i){case"none":return void a._clearSelection(l);case"range":return void(a.selectedDates.length>1&&a._selectMultipleDates(a.selectedDates[0],a.selectedDates[a.selectedDates.length-1]));case"many":case"default":case"oneOrMany":if(0===a.selectedDates.length){n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break}return;case"oneExtended":case"one":if(1===a.selectedDates.length)return;a.selectedDates.length>1?(n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l)):n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break;case"zeroOrOne":if(a.selectedDates.length>1){n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l);break}return;case"zeroOrMany":return;case"week":if(a.selectedDates.length>=1){let e=a.selectedDates[a.selectedDates.length-1];for(let t=0;t<7;t++)n.push(new Date(e)),e.setDate(e.getDate()+1);a._clearSelection(l)}}if(a.selectedDates=[],e)return void(a.selectedDates=n);const o=n.length;for(let e=0;e<o;e++)a._selectDate(n[e],e<o-1)}_clearSelection(e){const t=this,a=t.selectedDates.slice(0),n=t.selectionMode;if(t.isRendered){if(t._selectedCells&&t._selectedCells.map((e=>{t._setCellState(e,"selected",!1)})),t.selectedDates=[],t._selectedCells=[],"many"===n||"range"===n){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}t.$.footer&&t._refreshFooter(),t.$.hiddenInput.value=t.selectedDates.toString(),!e&&t.isInitialized&&a.length&&(t.$.fireEvent("change",{value:[]}),t._updateTargetValue()),t.$.title&&t._refreshTitle()}else t.set("selectedDates",[])}_bodyBlurStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("blur")}_bodyFocusStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("focus")}_bodyStateHandler(e){const t=this;if(t._focusedCell){if("blur"===e.type||"focus"===e.type&&t._noFocusingRequired)return t._noFocusingRequired=!1,void t._setCellState(t._focusedCell,"focus",!1);if("month"!==t.displayMode)return void("focus"!==e.type||t.$.dateViewContainer.querySelector("smart-calendar-cell[focus]")||t._setCellState(t._focusedCell||t.$.dateViewContainer.querySelector(".smart-calendar-cell"),"focus",!0))}"focus"===e.type&&t._focusCell()}_containerWheelHandler(e){const t=this;if(t.disabled||t.readonly||"month"!==t.displayMode&&"list"===t.displayModeView)return;let a,n;n=document.activeElement,t.shadowRoot?n=t.shadowRoot.activeElement:t.isInShadowDOM&&(n=t.getRootNode().activeElement),t.$.yearElement===n&&(a=12),(n&&t.shadowRoot||n.closest("smart-calendar")===t)&&(a=e.target===t.$.yearElement?12:1),a&&(e.preventDefault(),a=12===a?a:a*t.months,e.deltaY>0?t.navigate(-a):t.navigate(a))}_downHandler(e){const t=this;let a=e.originalEvent.target;if(t._dragStartDetails=void 0,t.disabled||t.readonly)return;if(t.hasRippleAnimation&&(a.value instanceof Date||a.parentElement&&a.parentElement.classList.contains("smart-calendar-title")||a.parentElement===t.$.dateElement)&&Smart.Utilities.Animation.Ripple.animate(a,e.pageX,e.pageY),a=e.originalEvent.target.closest(".smart-calendar-header"),e.originalEvent.target.closest(".smart-calendar-year-container")&&"decade"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._showDateView("year")}if(e.originalEvent.target.closest(".smart-calendar-date-container")&&"month"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")}if(t._animationStarted&&t._animateNavigationCompleted(),Smart.Utilities.Core.isMobile&&e.originalEvent.target.closest(".smart-calendar-body")===t.$.body)return void(t._dragStartDetails={x:e.pageX,y:e.pageY,startTime:Date.now(),target:e.originalEvent.target});if(a=e.originalEvent.target,a.closest(".smart-calendar-week")||a.parentElement===t.$.dateViewContainer){for(;a&&!(a.value instanceof Date);)a=a.parentElement;return void(a&&("month"!==t.displayMode?t._displayModeHandler(a):t._weeksDownHandler(e,a)))}if(a.closest(".smart-calendar-month-element"))return;if(e.originalEvent.stopPropagation(),"list"===t.displayModeView&&"month"!==t.displayMode)return a=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-item"),void(a&&t._displayModeHandler(a));const n=document.scrollingElement||document.documentElement,l=n.scrollLeft,i=n.scrollTop;t.unfocusable||t.focus(),window.scrollTo(l,i)}_displayModeHandler(e,t){const a=this;if(a._animationStarted&&a._animateNavigationCompleted(),e instanceof HTMLElement&&e.closest(".smart-calendar-week")&&e.otherMonth){if("decade"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()>a.max.getFullYear()))return;if("year"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()===a.min.getFullYear()&&e.value.getMonth()<a.min.getMonth()||e.value.getFullYear()>a.max.getFullYear()||e.value.getFullYear()===a.max.getFullYear()&&e.value.getMonth()>a.max.getMonth()))return}switch(t=t||a.displayMode){case"year":t="month";break;case"decade":t="year"}if(a.displayMode===t)return;const n=a.$.listViewContainer,l=n&&n.contains(e);a.$.fireEvent("displayModeChanging",{oldDisplayMode:a.displayMode,newDisplayMode:t}).defaultPrevented||(a.set("displayMode",t),a.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),e.parentElement!==a.$.dateViewContainer||e.disabled||e.restricted||a._focusCell(e),a.hasAnimation?(l&&e instanceof HTMLLIElement?e.offsetHeight?a.$.animationPanel.style.transformOrigin=e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px":a.$.animationPanel.style.transformOrigin=n.offsetLeft+n.offsetWidth/2+"px "+(n.offsetTop+n.offsetHeight/2)+"px":(a.$.dateViewContainer.style.order=1,a.$.nextMonthsContainer.style.order=3,e=a._focusedCell,a.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),a._animateView(1,e)):a._setDisplayModeContent(e.value instanceof Date?e.value:new Date(e.getAttribute("value")||e.value)))}_animateView(e,t){const a=this;let n,l,i=t instanceof Date?t:new Date(t.getAttribute("value")||t.value),s=!1,o=1,r=1;const d=a.$.listViewContainer;"list"===a.displayModeView?n=d.contains(t)?d:l="month"!==a.displayMode?a.$.monthsContainer:d:t.value instanceof Date||(t=a._focusedCell?a._focusedCell:a._selectedCells.length>0?a._selectedCells[a._selectedCells.length-1]:a._getCellByDate(new Date)),n||(n=t.parentElement===a.$.dateViewContainer?a.$.dateViewContainer:a.$.monthsContainer),l||(l="month"===a.displayMode?a.$.monthsContainer:"list"===a.displayModeView?d:a.$.dateViewContainer),l.style.transformOrigin=a.$.animationPanel.style.transformOrigin,n===d?(a.$.animationPanel.innerHTML="",a.$.animationPanel.appendChild(n.cloneNode(!0))):a.$.animationPanel.innerHTML=n.innerHTML,a._setDisplayModeContent(i),n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,a.$.animationPanel.style.width=a.$.body.offsetWidth+"px",a.$.animationPanel.style.height=a.$.body.offsetHeight+"px",a.$.animationPanel.style.transform="scale(1)",a.$.animationPanel.style.opacity=1,a.$animationPanel.removeClass("smart-hidden"),l.style.opacity="0",l.style.transform="scale(3.5)",n.$.hasClass("smart-calendar-date-view-container")?a.$animationPanel.addClass("smart-calendar-date-view-container"):a.$animationPanel.removeClass("smart-calendar-date-view-container"),cancelAnimationFrame(a._animationId),a._animationId=requestAnimationFrame((function t(){if((e>0&&o>=3.5||e<0&&o<=0)&&(s=!0),s){if(cancelAnimationFrame(a._animationId),a.$animationPanel.addClass("smart-hidden"),a.$.animationPanel.style.transform="",a.$.animationPanel.style.opacity="",n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,l.style.transform="",l.style.opacity="",a.unfocusable)return;"month"===a.displayMode?a.$.body.focus():"list"===a.displayModeView&&a.focus()}else a.$.animationPanel.style.opacity=r,l.style.opacity=1-r,r-=.05,e>0?(a.$.animationPanel.style.transform="scale("+o+")",l.style.transform="scale("+Math.min((o-1)/2,1)+")",o+=.125):(a.$.animationPanel.style.transform="scale("+Math.max(o,0)+")",l.style.transform="scale("+Math.max(1+o,1)+")",o-=.06),a._animationId=requestAnimationFrame(t)}))}_documentUpHandler(e){const t=this;let a=e.originalEvent.target;if((t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),t._newRangeSelectionStarted&&!t.$.container.contains(a)&&delete t._newRangeSelectionStarted,a&&a.classList&&a.classList.contains("smart-calendar-cell")&&(e.originalEvent.stopPropagation(),e.originalEvent.preventDefault(),e.preventDefault()),!Smart.Utilities.Core.isMobile||!t._dragStartDetails||e.originalEvent.target.closest(".smart-calendar-list-view"))return;delete t._previousIteration;const n=Date.now();let l={};(t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),"portrait"===t.scrollButtonsNavigationMode?(l.coordinate="y",l.direction="pageY"):(l.coordinate="x",l.direction="pageX");const i=t._dragStartDetails.step*(t.rightToLeft?-1:1);if(Math.abs(t._dragStartDetails[l.coordinate]-e[l.direction])<=10){if(a="list"===t.displayModeView&&"month"!==t.displayMode?a.closest("smart-list-item"):a,!a)return void(t._dragStartDetails=void 0);if("month"!==t.displayMode)return t._displayModeHandler(a),"portrait"===t.scrollButtonsNavigationMode?t.$.body.scrollTop=0:t.$.body.scrollLeft=0,void(t._dragStartDetails=void 0);if(t._weeksDownHandler(e,a),!t.disableAutoNavigation&&a.otherMonth)return}else{const a=Math.abs((e[l.direction]-t._dragStartDetails[l.coordinate])/(n-t._dragStartDetails.startTime));if(a>1){const e=parseInt(a);for(let a=0;a<e;a++)if(!t.navigate(i)){t._cancelAnimation();break}return void(t._dragStartDetails=void 0)}}if(!t.hasAnimation)return t.navigate(t._dragStartDetails.step),void(t._dragStartDetails=void 0);let s=("month"!==t.displayMode?t.$.dateViewContainer[t._animationSettings.scrollMax]:t.$.monthsContainer[t._animationSettings.scrollMax])+t.$.monthsSeparator[t._animationSettings.size];if(t._dragStartDetails.step>0&&t.$.body[t._animationSettings.scrollSize]>s*t._animationSettings.easeThreshold||t._dragStartDetails.step<0&&t.$.body[t._animationSettings.scrollSize]<s*t._animationSettings.easeThreshold)return t._animateNavigation(t._dragStartDetails.navigationDate,i,!0),6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(i,t._getCellByDate(t._dragStartDetails.navigationDate,t.$.nextMonthsContainer)),t.$.fireEvent("navigationChange",{value:new Date(t._dragStartDetails.navigationDate),type:t.displayMode}),void(t._dragStartDetails=void 0);t._cancelAnimation(),t._dragStartDetails=void 0}_cancelAnimation(){const e=this,t="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;let a=e.$.animationPanel.style.transform,n=e.$.animationPanel.style.opacity;a&&(a=parseFloat(a.substring(a.indexOf("(")+1||0,a.indexOf(")")))),t.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationId=requestAnimationFrame((function t(){if(!a||a>=3.5){cancelAnimationFrame(e._animationId),e.$animationPanel.addClass("smart-hidden"),e.$.animationPanel.style.transform="",e.$.animationPanel.style.opacity="";const t="month"===e.displayMode?e.$.monthsContainer:e.$.listViewContainer;return t.style.transform="",t.style.opacity="",e.unfocusable||("month"===e.displayMode?e.$.body.focus():"list"===e.displayModeView&&e.focus()),void(e._animationStarted=!1)}e.$.animationPanel.style.opacity=n-=.25,e.$.animationPanel.style.transform="scale("+(a+=.5)+")",e._animationId=requestAnimationFrame(t)}))}_focusCell(e,t){const a=this;if(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a.disabled||a.readonly)return;if(e){if("month"!==a.displayMode)return a._setCellState(e,"focus",!0),void(a._focusedCell=e);if(e.disabled||e.restricted)return;return t||a._setCellState(e,"focus",!0),void(a._focusedCell=e)}if("month"!==a.displayMode&&0===a.$.monthsContainer.offsetHeight)return;const n=a._selectedCells[a._selectedCells.length-1];if(n&&n.offsetHeight)a._setCellState(n,"focus",!0),a._focusedCell=n;else{const e=a.$.monthsContainer.children;if(!e[0]._date||a.min.getTime<e[0]._date.getTime())return;const t=a._getMonthCells(e[0],a.rightToLeft);for(let e=0;e<t.length;e++){const n=t[e];if(!n.otherMonth){if(n.disabled||n.restricted||!n.offsetHeight)continue;a._focusedCell=n;break}}}a._focusedCell&&a._setCellState(a._focusedCell,"focus",!0)}_getDays(e,t){const a=t.length;let n=[];if(a>0)for(let l=0;l<a;l++)t[l].getFullYear()===e.getFullYear()&&t[l].getMonth()===e.getMonth()&&n.push(t[l].getDate());return n}_getCellByDate(e,t){const a=this;if(!(e instanceof Date))return;if(t||(t=a.$.monthsContainer),"month"!==a.displayMode){if("list"===a.displayModeView)return;let t=arguments[1]?a.$.nextMonthsContainer.children:a.$.dateViewContainer.children;for(let n=0;n<t.length;n++)if("year"!==a.displayMode){if(t[n].value.getFullYear()===e.getFullYear())return t[n]}else if(t[n].value.getMonth()===e.getMonth())return t[n];return}let n,l,i=t.children;for(let t=0;t<i.length;t++)if(e.getFullYear()===i[t]._date.getFullYear()&&e.getMonth()===i[t]._date.getMonth()){n=i[t];break}if(n){l=a._getMonthCells(n);for(let t=0;t<l.length;t++)if((!l[t].otherMonth||l[t].hover)&&l[t].value.getMonth()===e.getMonth()&&l[t].value.getDate()===e.getDate())return l[t]}}_getMonthCells(e,t){const a=e.getElementsByClassName("smart-calendar-week");let n=[];if(t)for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=t.length-1;e>0;e--)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}else for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=1;e<t.length;e++)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}return n}_getWeekNumber(e){const t=this;let a,n=new Date(e.getFullYear(),0,1),l=Math.round((e.getTime()-n.getTime()-6e4*(e.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)+1,i=n.getDay()-t.firstDayOfWeek;return i=i>=0?i:i+7,i<4?(a=Math.floor((l+i-1)/7)+1,a>52&&(n=new Date(e.getFullYear()+1,0,1),i=n.getDay()-t.firstDayOfWeek,i=i>=0?i:i+7,a=i<4?1:53)):a=Math.round((l+i-1)/7),a}_handleDateSelection(e){const t=this;if(void 0!==e&&!e.disabled&&!e.restricted)switch(t.selectionMode){case"none":t._focusCell(e);break;case"oneExtended":case"one":case"default":if(t._keysPressed.Control)return t.selectedDates.length>1||1===t.selectedDates.length&&!e.selected?void t._selectDate(e.value):void t._focusCell(e);if(t._keysPressed.Shift)return void t._selectMultipleDates(new Date(t.selectedDates[0]),e);t._clearSelection(!0),t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break;case"many":{if(0===t.selectedDates.length)return void t._selectDate(e.value);const a=t.selectedDates[t.selectedDates.length-1];let n=new Date(t.selectedDates[0]);if(e.value.getTime()===n.getTime()||e.value.getTime()===a.getTime())return t._clearSelection(),void t._focusCell(e);t.selectedDates.length>0&&t._selectMultipleDates(n,e);break}case"range":{if(t.selectedDates.length>1&&!t._keysPressed.Control&&!t._newRangeSelectionStarted&&t._clearSelection(!0),0===t.selectedDates.length||t._keysPressed.Control&&t.selectedDates.length>1&&!t._newRangeSelectionStarted){if(e.value&&t.selectedDates.find((t=>t.getTime()===e.value.getTime())))return;return t._newRangeSelectionStarted=!0,void t._selectDate(e.value)}const a=t.selectedDates[t.selectedDates.length-1];let n=t._keysPressed.Control||t._newRangeSelectionStarted?a:new Date(t.selectedDates[0]);t.selectedDates.length>0&&t._selectMultipleDates(n,e),delete t._newRangeSelectionStarted;break}case"zeroOrMany":t._selectDate(e.value);break;case"oneOrMany":if(1===t.selectedDates.length&&e.selected)return void t._focusCell(e);t._selectDate(e.value);break;case"zeroOrOne":if(1===t.selectedDates.length&&e.selected)return void t._selectDate(e.value);t._clearSelection(!0),t._selectDate(e.value);break;case"week":{if(e.selected&&(e.value.getTime()===t.selectedDates[0].getTime()||e.value.getTime()===t.selectedDates[t.selectedDates.length-1].getTime()))return t._clearSelection(),void t._focusCell(e);t._clearSelection(!0);let a=new Date(e.value);t._selectDate(a);for(let e=1;e<7;e++)a.setDate(a.getDate()+1),t._selectDate(a);t._isDateInView(a)||t.navigate(1);break}}}_handleImportantDateTemplate(){const e=this;if(e._importantDatesTemplate=e._validateTemplate("importantDatesTemplate",e.importantDatesTemplate),!e._importantDatesTemplate||!e._importantDatesTemplate.content)return;let t=e._importantDatesTemplate.content;const a=t.childNodes.length,n=/{{\w+}}/g;let l;e._bindingDetails=[];for(let i=0;i<a;i++)if(l=n.exec(t.childNodes[i].innerHTML),l)return void e._bindingDetails.push({childNodeIndex:i,bindingString:l[0]})}_handleLayoutTemplate(e,t){const a=this,n=a._validateTemplate(e.$.hasClass("smart-header")?"headerTemplate":e.$.hasClass("smart-calendar-footer")?"footerTemplate":"titleTemplate",t);if(!n||!n.content)return void("function"==typeof t&&t(e,{}));a._layoutTemplates||(a._layoutTemplates=[]);let l=document.importNode(n.content,!0);e.innerHTML="";const i=l.childNodes.length,s=/{{\w+}}/g;let o,r=[];for(let e=0;e<i;e++)o=s.exec(l.childNodes[e].innerHTML),o&&r.push({childNodeIndex:e,bindingString:o[0]});if(a._layoutTemplates=a._layoutTemplates.filter((t=>t.selector!==e)),a._layoutTemplates.push({selector:e,template:n,bindings:r}),a.shadowRoot)return e.innerHTML="<slot></slot>",void a.appendChild(l);e.appendChild(l)}_handleCalendarCellHover(e,t){const a=this;if(!a._animationStarted){if("month"===a.displayMode)if("mouseover"===e.type&&("many"===a.selectionMode||"range"===a.selectionMode&&a._newRangeSelectionStarted)&&a.selectedDates.length>0){const e=a.$.monthsContainer.children;for(let t=0;t<e.length;t++)a._getMonthCells(e[t]).map((e=>{a._setCellState(e,"hover",!1)}));let n=new Date("range"===a.selectionMode?a.selectedDates[a.selectedDates.length-1]:a.selectedDates[0]),l=new Date(t.value),i=t;const s=n.getTime()>l.getTime()?-1:1,o=function(){i=a._getCellByDate(n),!i||i.selected||i.restricted||a._setCellState(i,"hover",!0)};if(n.getTime()!==l.getTime()){for(n.setDate(n.getDate()+s);n.getTime()!==l.getTime();)o(),n.setDate(n.getDate()+s);o()}}else a._setCellState(t,"hover",!1);"mouseover"!==e.type||t.otherMonth?a._setCellState(t,"hover",!1):a._setCellState(t,"hover",!0)}}_handleMonths(e,t){const a=this;let n;function l(e){let t,n=e.children.length,l=document.createDocumentFragment();for(;n<a.months;n++)t=a.$.month.cloneNode(!1),t.innerHTML=a.$.month.innerHTML,l.appendChild(t);return l}function i(t){let n=t.children;for(let t=0;t<n.length;t++)a._setMonth(e,n[t]),e.setMonth(e.getMonth()+1);a._setWeeksVisibility(t),a._refreshHeaderElements(),a._refreshHeaderTitle(),a.tooltip&&a.$.tooltip&&a.$.tooltip.close(),a.$.body===document.activeElement&&a._focusCell()}if(e||(e=a._viewDates&&a._viewDates.length>0?a._viewDates[0]:new Date),e=new Date(Math.min(Math.max(a.min.getTime(),e.getTime()),a.max.getTime())),t||(t=a.$.monthsContainer),a._selectedCells=[],a.hasAnimation){for(n=a.$.nextMonthsContainer.children,n.length>0&&n[0].value instanceof Date&&(a.$.nextMonthsContainer.innerHTML="");a.$.nextMonthsContainer.childElementCount<a.months;)a.$.nextMonthsContainer.appendChild(l(a.$.nextMonthsContainer));for(;a.$.nextMonthsContainer.childElementCount>a.months;)a.$.nextMonthsContainer.removeChild(n[a.$.nextMonthsContainer.childElementCount-1]);if(arguments[1]===a.$.nextMonthsContainer)return void i(a.$.nextMonthsContainer)}if(n=a.$.monthsContainer.children,n.length>a.months){for(;a.$.monthsContainer.childElementCount>a.months;)a.$.monthsContainer.removeChild(n[a.$.monthsContainer.childElementCount-1]),a._viewDates.pop();i(a.$.monthsContainer)}else a.$.monthsContainer.children.length!==a.months?(a._viewDates=[],a.$.monthsContainer.appendChild(l(a.$.monthsContainer)),i(a.$.monthsContainer)):i(a.$.monthsContainer)}_headerChangeHandler(e){const t=this;if(e.stopPropagation(),t.disabled||t.readonly)return;if(e.target.ownerElement===t.$.monthElement&&0!==t._changeEventFired)return void t._changeEventFired--;const a=t.displayMode;e.target===t.$.yearElement&&(t._viewDates[0].setFullYear(Math.min(Math.max(t.min.getFullYear(),isNaN(parseInt(t.$.yearElement.value))?0:parseInt(t.$.yearElement.value)),t.max.getFullYear())),t._handleMonths(t._viewDates[0])),!t.$.monthElement||e.target!==t.$.monthElement&&e.target.ownerElement!==t.$.monthElement||(t._handleMonths(new Date(t.$.monthsContainer.children[0]._date.getFullYear(),t.$.monthElement.selectedIndex,1)),"month"!==a&&t._setDisplayMode(t.displayMode,t.displayMode="month"))}_headerClickHandler(e){const t=this;if(t.disabled||t.readonly)return;let a=e.target.closest("smart-repeat-button");if(!a||!a.disabled){switch(a){case t.$.previousMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(-1*t.months*(t.rightToLeft?-1:1));case t.$.nextMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(1*t.months*(t.rightToLeft?-1:1));case t.$.previousYearButton:return void t.navigate(-12);case t.$.nextYearButton:return void t.navigate(12)}"classic"!==t.calendarMode&&e.target.closest(".smart-calendar-date-element")&&(t._animationStarted&&t._animateNavigationCompleted(),t._isInteractiveNavigation=!0,t._showDateView())}}_selectMultipleDates(e,t){const a=this;if(t instanceof HTMLElement&&(t=t.value),a._newRangeSelectionStarted?a._selectDate(e,!0):a._clearSelection(!0),"range"!==a.selectionMode||t.getTime()!==e.getTime()){if((e=new Date(e)).getTime()<t.getTime())for(;e.getTime()<=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()+1);else if(e.getTime()>t.getTime())for(;e.getTime()>=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()-1);else a._selectDate(t,!0);a.$.hiddenInput.value=a.selectedDates.toString(),a._refreshFooter(),a.isInitialized&&(a.$.fireEvent("change",{value:a.selectedDates}),a._updateTargetValue()),a._refreshTitle()}}_setDisplayMode(e,t,a){const n=this;if(n.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),0!==arguments.length&&n.hasAnimation)if(n._animationStarted&&(n.displayMode=e,n._animateNavigationCompleted(),n.displayMode=t),"month"===e&&"year"===t||"year"===e&&"decade"===t)n.displayMode=e,n._showDateView(a?void 0:n.displayMode);else if("month"===e&&"decade"===t)n._showDateView(n.displayMode="year");else{let e;"list"===n.displayModeView?(e=n.$.listViewContainer.querySelector("li.active"),n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop>0?e.offsetTop-e.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"):(n.$.dateViewContainer.style.order=1,n.$.nextMonthsContainer.style.order=3,e=n._focusedCell,n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),n._animateView(1,e)}else{if("classic"===n.calendarMode)return void(n.displayMode="month");if("month"!==n.displayMode&&(n.$monthsContainer.addClass("smart-hidden"),n.$dateViewContainer.hasClass("smart-hidden")&&n.$dateViewContainer.removeClass("smart-hidden")),!n.isCompleted&&"month"===n.displayMode)return;n._setDisplayModeContent()}}_setDisplayModeContent(e,t){const a=this;let n=e&&"Invalid Date"!==e.toString()?e:a.selectedDates.length>0?a.selectedDates[a.selectedDates.length-1]:new Date;n.setTime(Math.min(Math.max(n.getTime(),a.min.getTime()),a.max.getTime())),n.setHours(0,0,0,0);const l=a._prepareView(n);if(!l)return;let i;t?(a.$.nextMonthsContainer.innerHTML=a.$.dateViewContainer.innerHTML,i=a.$.nextMonthsContainer):i=a.$.dateViewContainer;const s=i.children;let o;for(let e=0;e<s.length;e++){const t=s[e];t.innerHTML=l.viewContent[e],t.value=l.dates[e],"year"===a.displayMode?(t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()===a.min.getFullYear()&&t.value.getMonth()<a.min.getMonth()||t.value.getFullYear()>a.max.getFullYear()||t.value.getFullYear()===a.max.getFullYear()&&t.value.getMonth()>a.max.getMonth()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&n.getMonth()===t.value.getMonth()&&(o=t)):"decade"===a.displayMode&&(0===e||e===s.length-1||t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()>a.max.getFullYear()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&(o=t)),a._setCellState(t,"hover",!1),a._setCellState(t,"focus",!1)}if(o.otherMonth)for(let e=0;e<s.length;e++)if(!s[e].otherMonth){o=s[e];break}a._mobileScrolling||(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a._focusedCell=o,a._focusCell(a._focusedCell),a._refreshHeaderTitle(),a._refreshHeaderElements(),a.$.fireEvent("displayModeChange"),a._isInteractiveNavigation?a._isInteractiveNavigation=void 0:(a._setCellState(o,"focus",!0),setTimeout((function(){a.unfocusable||(a.$.body.focus(),a._focusCell(a._focusedCell))}),0)))}_prepareView(e){const t=this,a=t.$.listViewContainer;let n,l,i=[],s=[];function o(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if("month"===t.displayMode)return t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container"),a&&a.classList.add("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),t._isDateInView(e)||t._handleMonths(e),t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$body.hasClass("smart-calendar-list-view")&&t.$body.removeClass("smart-calendar-list-view"),t.$dateContainer.addClass("smart-calendar-selected"),t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateViewContainer.addClass("smart-hidden"),t.$monthsContainer.removeClass("smart-hidden"),t._refreshHeaderTitle(),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),t._refreshHeaderElements(),t.unfocusable||t.$.body.focus(),t._focusCell(t._getCellByDate(e)),void t.$.fireEvent("displayModeChange");if("list"===t.displayModeView)return t._setDisplayModeListContent(e),void t.$.fireEvent("displayModeChange");if(t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),a&&a.classList.add("smart-hidden"),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),"year"===t.displayMode){let a=new Date;for(let n=0;n<12;n++)a=o(a.getFullYear(),n,a.getDate()),i.push(a.toLocaleDateString(t.locale,{month:"short"})),s.push(o(e.getFullYear(),n,e.getDate()))}else{n=e?e.getFullYear():t._viewDates[0].getFullYear(),l=n%10,0!==l&&(n-=l),n-=1;for(let t=0;t<12;t++)i.push(n+""),s.push(new Date(n,e.getMonth(),e.getDate())),++n}return{viewContent:i,dates:s}}_setDisplayModeListContent(e){const t=this;let a=[];function n(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if(t.$dateViewContainer.addClass("smart-visibility-hidden"),"year"===t.displayMode){let l=new Date;for(let i=0;i<12;i++)l=n(l.getFullYear(),i,l.getDate()),a.push({label:l.toLocaleDateString(t.locale,{month:"short"}),value:n(e.getFullYear(),i,e.getDate()).toDateString()});t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateContainer.addClass("smart-calendar-selected")}else{let n=t.min.getFullYear(),l=t.max.getFullYear();l=Math.min(t.max.getFullYear(),e.getFullYear()+10),n=Math.max(t.min.getFullYear(),l-10);for(let t=n;t<l;t++)a.push({label:t.toString(),value:new Date(t,e.getMonth(),e.getDate()).toDateString()});t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")}t._prepareListViewer(a,e.toDateString()),t._refreshHeaderTitle(),t._refreshHeaderElements(),t.unfocusable||t.focus()}_prepareListViewer(e=[],t){const a=this,n=a.$.body;let l=a.$.listViewContainer;l||(a.$.listViewContainer=l=document.createElement("smart-scroll-viewer"),l.classList.add("smart-input-drop-down-menu","smart-calendar-list-view"),l.ensureVisible=a._listViewerEnsureVisible.bind(a),l._handleKeyStrokes=a._listViewerKeyStrokesHandler.bind(a),l._setActiveDescendant=a._listViewerSetActiveDescendant.bind(a));let i=l.querySelector("ul");i||(i=document.createElement("ul"),i.onclick=a._listViewContainerItemClickHandler.bind(a),l.appendChild(i)),n.contains(l)&&n.removeChild(l),i.innerHTML="";for(let a=0;a<e.length;a++){const n=e[a],s=n.label,o=n.value,r=document.createElement("li"),d=document.createElement("a");t===o?(r.setAttribute("aria-selected",!0),r.classList.add("active"),t=r):r.setAttribute("aria-selected",!1),r.id=l.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),r.setAttribute("value",o),r.setAttribute("role","option"),r.setAttribute("aria-label",s),d.innerHTML=s,d.setAttribute("aria-hidden",!0),r.appendChild(d),i.appendChild(r)}l.classList.remove("smart-hidden"),n.classList.add("smart-calendar-list-view"),n.removeAttribute("tabindex"),n.insertBefore(l,a.$.animationPanel),l.refresh(),l.ensureVisible()}_listViewerEnsureVisible(){const e=this.$.listViewContainer,t=e.querySelector(".active");if(!t)return;const a=Array.from(e.querySelectorAll("li"));t.offsetTop+t.offsetHeight>=e.scrollTop+e.offsetHeight&&(e.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.scrollTop||t.offsetTop>=e.scrollTop+e.offsetHeight)&&(e.scrollTop=t.offsetTop),0===a.indexOf(t)?e.scrollTop=0:a.indexOf(t)===a.length-1&&(e.scrollTop=e.scrollHeight)}_listViewerKeyStrokesHandler(e){if(["ArrowUp","ArrowDown"].indexOf(e)<0)return;event.preventDefault();const t=this.$.listViewContainer,a=t.querySelector(".active");if(!a){const e=t.querySelector("li");return e.classList.add("active"),void t._setActiveDescendant(e)}const n=a["ArrowDown"===e?"nextElementSibling":"previousElementSibling"];n&&(a.classList.remove("active"),n.classList.add("active"),t._setActiveDescendant(n),t.ensureVisible())}_listViewerSetActiveDescendant(e){const t=this.$.listViewContainer;e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant")}_listViewContainerItemClickHandler(e){const t=this,a=e.target.closest("li");a&&"list"===t.displayModeView&&"month"!==t.displayMode&&t._displayModeHandler(a)}_isDateInView(e){const t=this;if(!e)return!1;for(let a=0;a<t._viewDates.length;a++)if(e.getFullYear()===t._viewDates[a].getFullYear()&&e.getMonth()===t._viewDates[a].getMonth()){let a=t._getCellByDate(e,t._animationStarted?t.$.nextMonthsContainer:void 0);if(!a)return;return!(a.otherMonth||!a.offsetHeight||a.classList.contains("smart-visibility-hidden"))}return!1}_keyDownHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;switch(a){case t.$.yearElement:"Escape"===e.key&&t._refreshHeaderElements();break;case t.$.dateElement:if("default"===t.calendarMode&&" "===e.key||"Enter"===e.key)return e.preventDefault(),t._isInteractiveNavigation=!0,void t._showDateView();t._focusedCell||t._focusCell(),e.key.indexOf("Arrow")>-1&&t.$.dateElement===a&&!t.unfocusable&&t.$.body.focus(),t._navigateDays(e);break;case t.$.body:" "===e.key&&e.preventDefault(),t._navigateDays(e);break;case t.$.yearContainer:if(" "!==e.key&&"Enter"!==e.key||"decade"===t.displayMode||(e.preventDefault(),t._isInteractiveNavigation=!0,t._showDateView("year")),e.key.indexOf("Arrow")>-1){if(e.preventDefault(),t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;case t.$.dateContainer:if(" "!==e.key&&"Enter"!==e.key||"month"===t.displayMode||(e.preventDefault(),t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")),e.key.indexOf("Arrow")>-1){if(t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;default:if("month"!==t.displayMode&&"list"===t.displayModeView)return["Arrow","End","Home","Page"].indexOf(e.key)&&e.preventDefault()," "===e.key||"Enter"===e.key||e.ctrlKey&&("ArrowUp"===e.key||"ArrowDown"===e.key)?void t._navigateDays(e):void t.$.listViewContainer._handleKeyStrokes(e.key);e.key.indexOf("Arrow")>-1&&(t._focusedCell||t._focusCell(),t._navigateDays(e))}}_showDateView(e){const t=this;switch(e=e||t.displayMode){case"month":e="year";break;case"year":e="decade"}if(t.displayMode===e)return;if(t.$.fireEvent("displayModeChanging",{oldDisplayMode:t.displayMode,newDisplayMode:e}).defaultPrevented)return;let a;if(t.displayMode=e,"list"===t.displayModeView&&"month"!==t.displayMode){t._setDisplayModeListContent(t._focusedCell?t._focusedCell.value:t._viewDates[0]);const e=t.$.listViewContainer;e.classList.remove("smart-hidden"),a=e.querySelector("li.active"),a.offsetHeight?t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:a.offsetTop+a.offsetHeight/2)+"px":t.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"}else t._focusedCell||t._focusCell(),a=t._focusedCell,t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop+a.offsetHeight/2)+"px";t.$monthsContainer.addClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-hidden")&&t.$dateViewContainer.removeClass("smart-hidden"),"decade"===t.displayMode&&(t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")),t.hasAnimation?t._animateView(-1,a):t._setDisplayModeContent(t._focusedCell?t._focusedCell.value:t._viewDates[0])}_keyUpHandler(e){const t=this;t.disabled||t.readonly||"default"!==t.selectionMode&&"range"!==t.selectionMode||"Shift"!==e.key&&"Control"!==e.key||(t._keysPressed[e.key]=!1)}_handleTooltip(){const e=this,t=e.tooltip;let a=e.$.tooltip;t?(a||(a=document.createElement("smart-tooltip"),a.tooltipTemplate=e.tooltipTemplate,a.arrow=e.tooltipArrow,a.arrowDirection=e.tooltipArrowDirection,a.offset=e.tooltipOffset,a.position=e.tooltipPosition,a.delay=e.tooltipDelay,a.rightToLeft=e.rightToLeft,a.openMode="manual",e.$.tooltip=a),a.parentElement||e.$.calendarContainer.appendChild(a)):a&&a.remove()}_mouseEventsHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=t.$.tooltip;if("mouseenter"===e.type)return void t.$.setAttributeValue("hover",!0);if("mouseleave"===e.type){if(t.$.setAttributeValue("hover",!1),t._newRangeSelectionStarted&&"range"===t.selectionMode){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}return void(t.tooltip&&a&&a.close())}const n=t.shadowRoot||t.isInShadowDOM?e.composedPath()[0]:e.target;if(!n.closest(".smart-calendar-week"))return void(t.tooltip&&a&&(clearTimeout(t._tooltipAutoCloseTimeout),a[a.contains(n)?"open":"close"]()));const l=n.closest(".smart-calendar-cell");if(!l)return;if(Smart.Utilities.Core.isMobile||t._handleCalendarCellHover(e,l),!t.tooltip&&a)return void a.close();const i=l.hasAttribute("important");if(clearTimeout(t._tooltipAutoCloseTimeout),i&&a&&"mouseover"===e.type)return a.selector=l,void(a.selector!==l?a.close():(t.tooltipTemplate||(a.innerHTML=0===a.innerHTML.trim().length?"Important day!":a.innerHTML),a.open(),t.$.fireEvent("open",{target:a,value:new Date(l.value)})));t._tooltipAutoCloseTimeout=setTimeout(function(){!a||"mouseout"!==e.type&&l&&i||a.close(),clearTimeout(t._tooltipAutoCloseTimeout)}.bind(t),t.tooltipDelay)}_popupEventHandler(e){const t=this,a=t.$.tooltip;if(e.stopPropagation(),e.target!==t.$.monthElement)if(e.target===a)if("close"!==e.type);else{const e=a.selector;t.$.fireEvent("close",{target:a,value:e?new Date(e.value):null})}else t.$.fireEvent(e.type,{target:e.target})}_moveHandler(e){const t=this;if(!Smart.Utilities.Core.isMobile||!t._dragStartDetails||"list"===t.displayModeView&&"month"!==t.displayMode)return;e.originalEvent.preventDefault(),e.preventDefault(),e.stopPropagation();const a={x:Math.round(e.pageX),y:Math.round(e.pageY)};let n,l,i;if(n="portrait"===t.scrollButtonsNavigationMode?a.y>t._dragStartDetails.y?-1*t.months:1*t.months:a.x<t._dragStartDetails.x?1*t.months:-1*t.months,t._previousIteration&&n===t._previousIteration.step)l=t._previousIteration.date;else if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let e,a;t._focusedCell||t._focusCell();const i=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));if(i.length){let s;!t.rightToLeft&&n<0||t.rightToLeft&&n>0?(s=i[0].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[s.length-1]:s[0]):(s=i[i.length-1].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[0]:s[s.length-1]),e=new Date(a.value),e.setDate(e.getDate()+n*(t.rightToLeft?-1:1)),l=e}else l=t._getNextDate(n*(t.rightToLeft?-1:1))}else l=t._getNextDate(n*(t.rightToLeft?-1:1));if(!l)return;if(!t._dragStartDetails.navigationDate&&t.$.fireEvent("navigationChanging",{value:new Date(l),type:t.displayMode}).defaultPrevented)return t._cancelAnimation(),void(t._dragStartDetails=void 0);if(t._dragStartDetails.step=n,t._dragStartDetails.navigationDate=new Date(l),!t.hasAnimation)return;if(t._previousIteration={step:n,date:l},t._mobileScrolling=!0,"month"!==t.displayMode)t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),i=t.$.dateViewContainer,t.$.nextMonthsContainer.children[0].value instanceof Date&&t.$.nextMonthsContainer.children[1].value.getFullYear()===l.getFullYear()||t._setDisplayModeContent(l,t.$.nextMonthsContainer);else if(t.$nextMonthsContainer.hasClass("smart-calendar-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),i=t.$.monthsContainer,!t.$.nextMonthsContainer.children[0]._date||t.$.nextMonthsContainer.children[0]._date.getTime()!==l.getTime()){let e=t.$.nextMonthsContainer.children;for(let a=0;a<e.length;a++)l.setMonth(t._dragStartDetails.navigationDate.getMonth()+a*(t.rightToLeft?-1:1)),t._setMonth(new Date(l),e[a],!0)}6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(n*(t.rightToLeft?-1:1),t._getCellByDate(l,t.$.nextMonthsContainer)),delete t._mobileScrolling,n<0?(i.style.order=3,t.$.nextMonthsContainer.style.order=1,t.$.body[t._animationSettings.scrollSize]=t.$.body[t._animationSettings.scrollMax]):(i.style.order=1,t.$.nextMonthsContainer.style.order=3,t.$.body[t._animationSettings.scrollSize]=0);const s="portrait"===t.scrollButtonsNavigationMode?"y":"x";Math.abs(t._dragStartDetails[s]-a[s])>5&&(t.$.body[t._animationSettings.scrollSize]+=2*-(a[s]-t._dragStartDetails[s]))}_getNextDate(e){const t=this;let a;if("month"!==t.displayMode){let n;const l=t._focusedCell&&t._focusedCell.value.getFullYear();if("list"===t.displayModeView)a=new Date(t.$.listViewContainer.querySelector("li").getAttribute("value"));else{let e=t._animationStarted?t.$.nextMonthsContainer:t.$.dateViewContainer;a=new Date("year"===t.displayMode?e.children[0].value:e.children[1].value)}n="year"===t.displayMode?1:0!==e?10:1,a.setFullYear(a.getFullYear()+(e>0?n:-n)),a.getTime()<t.min.getTime()&&(a=t.min),a.getTime()>t.max.getTime()&&(a=t.max);const i="month"!==t.displayMode&&"list"===t.displayModeView;if(a.getFullYear()<t.min.getFullYear()||a.getFullYear()>t.max.getFullYear()||!i&&l===a.getFullYear())return}else{let n=t._viewDates[0];if(a=new Date(n),a.setDate(1),a.setMonth(a.getMonth()+e),a.setTime(Math.min(Math.max(a.getTime(),t.min.getTime()),t.max.getTime())),n.getMonth()===a.getMonth()&&n.getFullYear()===a.getFullYear())return}return a}_navigateDays(e){const t=this;let a="ArrowUp"===e.key||"ArrowDown"===e.key?7:1,n="ArrowUp"===e.key||"ArrowLeft"===e.key||"PageUp"===e.key?-1:1;switch(e.key){case"ArrowUp":case"ArrowLeft":case"ArrowDown":case"ArrowRight":if(!t._handleArrowKeys(e,a,n))return;break;case" ":case"Enter":{if("month"!==t.displayMode)return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell);const e=t._focusedCell;if("oneExtended"===t.selectionMode&&e)return t._clearSelection(!0),void t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break}case"Control":case"Shift":return"default"===t.selectionMode&&(t._keysPressed[e.key]=!0),void("range"===t.selectionMode&&(t._keysPressed[e.key]="Control"===e.key));case"Home":case"End":{e.preventDefault();let a,n=function(t){if("Home"===e.key){for(let e=0;e<t.length;e++)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]}else for(let e=t.length-1;e>=0;e--)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]};if(a="month"!==t.displayMode?n(t.$.dateViewContainer.children):n(t._getMonthCells(t._focusedCell.closest(".smart-calendar-month"),t.rightToLeft)),!a)return;if(t._focusCell(a),"month"!==t.displayMode)return;break}case"PageUp":case"PageDown":if(!t._handlePageUpDownKeys(e,n))return;break;default:return}"oneExtended"!==t.selectionMode&&t._focusedCell&&t._handleDateSelection(t._focusedCell)}_handleArrowKeys(e,t,a){const n=this;let l;if("month"!==n.displayMode||n._animationStarted||n.unfocusable||n.$.body.focus(),n._focusedCell||n._focusCell(n._getCellByDate(new Date)),e.altKey)return;if(e.ctrlKey){if("ArrowDown"===e.key||"ArrowUp"===e.key){if("classic"===n.calendarMode)return;let t;switch(n.displayMode){case"month":t="ArrowDown"===e.key?"month":"year";break;case"year":t="ArrowDown"===e.key?"month":"decade";break;case"decade":t="ArrowDown"===e.key?"year":"decade"}if(t!==n.displayMode){const e=n.displayMode;n.displayMode=t,n._setDisplayMode(e,t,"month"===e),n._keysPressed&&delete n._keysPressed.Control}}return}if(e.preventDefault(),!n.rightToLeft||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(a*=-1),"month"!==n.displayMode&&"list"!==n.displayModeView){const i=n._animationStarted?n.$.nextMonthsContainer.children:n.$.dateViewContainer.children;if(t="ArrowUp"===e.key||"ArrowDown"===e.key?4:1,"year"===n.displayMode){const e=n._focusedCell.value.getMonth()+a*t;let i=new Date(n._focusedCell.value.getFullYear(),e+1,0);n._focusedCell.value.getDate()<=i.getDate()&&(i=n._focusedCell.value),l=new Date(n._focusedCell.value.getFullYear(),e,i.getDate())}else l=new Date(n._focusedCell.value.getFullYear()+a*t,n._focusedCell.value.getMonth(),n._focusedCell.value.getDate());if("year"===n.displayMode){if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()===n.min.getFullYear()&&l.getMonth()<n.min.getMonth()||l.getFullYear()>n.max.getFullYear()||l.getFullYear()===n.max.getFullYear()&&l.getMonth()>n.max.getMonth())return;l.getTime()>i[i.length-1].value.getTime()?n.navigate(1):l.getTime()<i[0].value.getTime()&&n.navigate(-1)}else{if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()>n.max.getFullYear())return;if(l.getFullYear()<i[1].value.getFullYear()||l.getFullYear()>i[10].value.getFullYear()){let t=n._focusedCell;n.navigate(a),"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(t===i[3]||t===i[4]||t===i[7]||t===i[8]?l.setFullYear(l.getFullYear()+2*a):l.setFullYear(l.getFullYear()-2*a))}}return void n._focusCell(n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0))}if(!n._focusedCell)return;const i=n.restrictedDates.map(Number);for(l=new Date(n._focusedCell.value.getFullYear(),n._focusedCell.value.getMonth(),n._focusedCell.value.getDate()+a*t,0,0,0,0);i.indexOf(l.getTime())>-1;)l.setDate(l.getDate()+a);if(l.getTime()<n.min.getTime()||l.getTime()>n.max.getTime())return;n._isDateInView(l)||n.navigate(a*n.months);let s=n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0);return n._focusCell(s),n._updateWeeksVisibility(a),!(["zeroOrMany","oneOrMany","none","many","week","range"].indexOf(n.selectionMode)>-1)||void 0}_handlePageUpDownKeys(e,t){const a=this;let n;if(e.preventDefault(),"month"!==a.displayMode){if(n=a._focusedCell,!a.navigate(t))return;for(;n&&n.classList.contains("smart-visibility-hidden");)n=null===n.previousElementSibling?n.nextElementSibling:n.previousElementSibling;return a._focusCell(n),void(a.hasAnimation&&"decade"===a.displayMode&&a._focusedCell.value.setFullYear(a._focusedCell.value.getFullYear()+10*t))}n=new Date(a._focusedCell.value.getFullYear(),a._focusedCell.value.getMonth()+t,1,0,0,0,0);let l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return a._focusedCell.value.getDate()>l?n.setDate(l):n.setDate(a._focusedCell.value.getDate()),a._isDateInView(n)||a.navigate(n),a._animationStarted?a._focusCell(a._getCellByDate(n,a.$.nextMonthsContainer)):a._focusCell(a._getCellByDate(n)),!0}_selectDate(e,t,a){const n=this;if(void 0===n._viewDates||"none"===n.selectionMode)return;let l,i=n.selectedDates.slice(0),s=n._getCellByDate(e,n._animationStarted?n.$.nextMonthsContainer:void 0);s&&n._selectCell(s),(e=new Date(e)).setHours(0,0,0,0),l=i.map(Number).indexOf(e.getTime()),n.restrictedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<n.min.getTime()||e.getTime()>n.max.getTime()||(l>-1?i.splice(l,1):i.push(e),a||(n.selectedDates=i),n._refreshFooter(),n.$.hiddenInput.value=n.selectedDates.toString(),!t&&n.isInitialized&&(n.$.fireEvent("change",{value:[e]}),n._updateTargetValue()),n._refreshTitle())}_selectCell(e){const t=this;if(!e||t.restrictedDates.map(Number).indexOf(e.value.getTime())>-1||t.disableAutoNavigation&&!1===e.otherMonth||e.value.getTime()<t.min.getTime()||e.value.getTime()>t.max.getTime())return;const a=t._selectedCells.indexOf(e);a>-1?(t._setCellState(e,"selected",!1),t._selectedCells.splice(a,1)):(t._setCellState(e,"selected",!0),t._selectedCells.push(e)),t._focusCell(e)}_refreshDayOfWeekTitles(){const e=this;let t,a=[],n=new Date;function l(t){let a;return"firstTwoLetters"===e.dayNameFormat?(a=new Intl.DateTimeFormat(e.locale,{weekday:"long"}).format(t),a=8206===a.charCodeAt(0)?a.substring(1,3):a.substring(0,2)):a=new Intl.DateTimeFormat(e.locale,{weekday:e.dayNameFormat}).format(t),a}for(let e=1;e<8;e++)n.setDate(e),t={number:n.getDay(),name:l(n)},a.push(t);a.sort(((e,t)=>e.number>t.number?1:-1));const i=e.$.monthsContainer.children;let s,o;for(let t=0;t<i.length;t++)if(s=i[t].getElementsByClassName("smart-calendar-week-titles")[0].children,o=e.firstDayOfWeek>6?0:e.firstDayOfWeek,e.rightToLeft)for(let e=s.length-1;e>=1;e--)s[e].textContent=a[o++].name,o=o>6?0:o;else for(let e=1;e<s.length;e++)s[e].textContent=a[o++].name,o=o>6?0:o;if(e.hasAnimation){const t=e.$.monthsContainer.getElementsByClassName("smart-calendar-week-titles")[0].innerHTML,a=e.$.nextMonthsContainer.getElementsByClassName("smart-calendar-week-titles");for(let e=0;e<a.length;e++)a[e].innerHTML=t}}_refreshCalendarMode(){const e=this;if(!e.headerTemplate)if(e._refreshMonthNames(),"default"===e.calendarMode){e.$classicHeaderDate.addClass("smart-hidden"),e.$defaultHeaderDate.removeClass("smart-hidden");const t=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),a=t[0],n=t[t.length-1];a.setDate(2);let l=e.monthNameFormat;"firstTwoLetters"===l&&(l="long");let i=a.toLocaleDateString(e.locale,{year:e.yearFormat,month:l});e.months>1&&(n.setDate(2),i+=" - "+n.toLocaleDateString(e.locale,{year:e.yearFormat,month:l})),e.$.defaultHeaderDate.innerHTML=i,e.unfocusable||e.$.dateElement.setAttribute("tabindex",e.tabIndex>0?e.tabIndex:0)}else e.$defaultHeaderDate.addClass("smart-hidden"),e.$classicHeaderDate.removeClass("smart-hidden"),e.$.dateElement.removeAttribute("tabindex")}_refreshFooter(){const e=this;if(!(e.viewSections.indexOf("footer")<0||0===e.$.footer.offsetHeight))if(e.footerTemplate){if("function"==typeof e.footerTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.footer))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let e=n.childNodes[a.bindings[0].childNodeIndex];a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=e.innerHTML.replace(a.bindings[0].bindingString,t())}}else e.$.selectedDatesRange.innerHTML=t();function t(){if(0===e.selectedDates.length)return"";if(1===e.selectedDates.length)return e.selectedDates[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"});{let t=e.selectedDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime()));return t[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})+" - "+t[t.length-1].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})}}}_refreshImportantDates(){const e=this;if("month"===e.displayMode){e._clearImportantDates();for(let t=0;t<e.importantDates.length;t++)e._setImportantDate(e.importantDates[t])}}_clearImportantDates(){const e=this,t=e.$.monthsContainer.children;for(let a=0;a<t.length;a++)e._getMonthCells(t[a]).map((t=>{e._setCellState(t,"important",!1)}))}_setImportantDate(e,t){const a=this,n=a._getCellByDate(e);t||(t=n),t&&(a._setCellState(t,"important",!0),a._applyImportantDateTemplate(t))}_applyImportantDateTemplate(e){const t=this;if(!t._importantDatesTemplate)return"function"==typeof t.importantDatesTemplate?void t.importantDatesTemplate(e,{value:e.value}):void(e.innerHTML=e.value.getDate()+"");let a=document.importNode(t._importantDatesTemplate.content,!0);if(t._bindingDetails&&t._bindingDetails.length>0){let n=a.childNodes[t._bindingDetails[0].childNodeIndex];n.innerHTML=n.innerHTML.replace(t._bindingDetails[0].bindingString,e.value.getDate())}e.innerHTML="";for(let t=0;t<a.childNodes.length;t++)a.childNodes[t].outerHTML&&(e.innerHTML+=a.childNodes[t].outerHTML)}_setMonth(e,t,a){const n=this,l=n._getDays(e,n.selectedDates),i=n._getDays(e,n.importantDates),s=n._getDays(e,n.restrictedDates);e.setDate(1),t||(t=n.$.month),t._date=new Date(e),a||((!n._viewDates||n._viewDates.length>=n.months)&&(n._viewDates=[]),n._viewDates.push(new Date(e)));let o=((e=new Date(e)).getDay()-n.firstDayOfWeek+7)%7;e.setDate(0);let r=e.getDate();if(e.setDate(32),e.setDate(1),e.setDate(32),n._selectedCells)for(let e=0;e<n._selectedCells.length;e++)n._selectedCells[e].closest(".smart-calendar-month")===t&&n._setCellState(n._selectedCells[e],"selected",!1);n._setMonthContent(e,t,{previusMonthDays:r,firstDayOfWeek:o,selectedDates:l,importantDates:i,restrictedDates:s})}_setMonthContent(e,t,a){const n=this,l=32-e.getDate(),i=n._getMonthCells(t,n.rightToLeft),s=t._date.getMonth(),o=t._date.getFullYear(),r=new Date;let d,c=1,m=1;r.setHours(0,0,0,0),i.map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)}));for(let e=0;e<i.length;e++){const h=i[e];e===a.firstDayOfWeek&&m<=l?(h.className="smart-calendar-cell",h.value=new Date(o,s,m),h.innerHTML=h.value.getDate().toString(),a.restrictedDates.indexOf(m)>-1||h.value.getTime()<n.min.getTime()||h.value.getTime()>n.max.getTime()?n._setCellState(h,"restricted",!0):a.selectedDates.indexOf(m)>-1&&(n._setCellState(h,"selected",!0),n._selectedCells.indexOf(h)<0&&n._selectedCells.push(h)),a.importantDates.indexOf(m)>-1&&(n._setImportantDate(h.value,h),a.importantDates.splice(a.importantDates.indexOf(m),1)),h.value.getTime()===r.getTime()&&n._setCellState(h,"today",!0),a.firstDayOfWeek++,m++):(1===m?(h.value=new Date(o,s-1,++a.previusMonthDays-a.firstDayOfWeek),d=!!(h.value.getTime()<n.min.getTime()||t.previousElementSibling)):(h.value=new Date(o,s+1,c++),d=!!(h.value.getTime()>n.max.getTime()||t.nextElementSibling)),h.innerHTML=h.value.getDate().toString(),n._setCellState(h,"otherMonth",!0),d?h.classList.add("smart-visibility-hidden"):h.classList.remove("smart-visibility-hidden"))}n.months>1&&(t.firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(t._date):n._monthsNames[s]+" "+t._date.toLocaleDateString(n.locale,{year:n.yearFormat})),n._setMonthWeekNumbers(t)}_refreshMonthNames(){const e=this;let t,a=new Date;function n(t){let a=e.monthNameFormat;"firstTwoLetters"===a&&(a="long");let n=new Intl.DateTimeFormat(e.locale,{month:a}).format(t);return"firstTwoLetters"===e.monthNameFormat&&(n=8206===n.charCodeAt(0)?n.substring(0,2):n.substring(1,3)),n}a.setDate(1),e._monthsNames=[];for(let l=0;l<12;l++)a.setMonth(l),t=n(a),e._monthsNames.push(t);if("classic"===e.calendarMode&&e.$.monthElement){let t=e.$.monthsContainer.children;if(e.$.monthElement.dataSource&&(e._changeEventFired=1),e.shadowRoot?e._setMonthElementPropertyInShadowDOM("dataSource",e._monthsNames):e.$.monthElement.dataSource=e._monthsNames,e._viewDates){for(let a=0;a<t.length;a++)t[a].firstElementChild.textContent=e._monthsNames[t[a]._date.getMonth()]+" "+t[a]._date.getFullYear();e._changeEventFired=1,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates.map((e=>e.getMonth()))[0]):e.$.monthElement.selectedIndex=e._viewDates.map((e=>e.getMonth()))[0]}}}_setMonthWeekNumbers(e){const t=this,a=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!0};let n=e.getElementsByClassName("smart-calendar-week");n=[].slice.call(n);for(let l=0;l<n.length;l++){if(!a(n[l])){n[l].children[0].innerHTML="";continue}const i=n[l].children[1],s=i.otherMonth?i.value.getTime()>e._date.getTime()?1:-1:0;n[l].children[0].innerHTML=t._getWeekNumber(new Date(e._date.getFullYear(),e._date.getMonth()+s,i.value.getDate()))}}_setRestrictedDates(e){const t=this,a=t.$.monthsContainer.children;for(let e=0;e<a.length;e++)t._getMonthCells(a[e]).map((e=>{t._setCellState(e,"restricted",!1)}));if(t._viewDates){const a=function(e){for(let a=0;a<t._viewDates.length;a++)if(t._viewDates[a].getFullYear()===e.getFullYear()&&t._viewDates[a].getMonth()===e.getMonth())return!0};for(let n=0;n<e.length;n++)if(a(e[n])){const a=t._getCellByDate(e[n]);t._setCellState(a,"restricted",!0)}}}_setScrollButtonsNavigationMode(){const e=this;"landscape"!==e.scrollButtonsNavigationMode?(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-down smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-up smart-arrow")):(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-left smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-right smart-arrow")),e._applyAnimationSettings(!0)}_refreshTitle(){const e=this;let t=e.selectedDates.length>0?e.selectedDates[e.selectedDates.length-1]:new Date;if(e.titleTemplate){if("function"==typeof e.titleTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.title))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let l=n.childNodes[a.bindings[0].childNodeIndex];return t=t.toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"}),void(a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=l.innerHTML.replace(a.bindings[0].bindingString,t))}}e.$.title.children[0].innerHTML=t.toLocaleDateString(e.locale,{year:e.yearFormat}),e.$.title.children[1].innerHTML="landscape"===e.view?t.toLocaleDateString(e.locale,{weekday:"short"})+",</br>"+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"}):t.toLocaleDateString(e.locale,{weekday:"short"})+", "+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"})}_setWeeksVisibility(e){const t=this,a=e.children;let n;function l(e){(function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0})(e)||n>=t.weeks?e.classList.add("smart-hidden"):n<t.weeks&&(e.classList.remove("smart-hidden"),n++)}for(let e=0;e<a.length;e++){let i=a[e].getElementsByClassName("smart-calendar-week");i=[].slice.call(i);let s=t._selectedCells.filter((t=>t.closest(".smart-calendar-month")===a[e]));if(6!==t.weeks)if(n=0,s.length>0){let e=s[s.length-1],t=i.indexOf(e.parentElement);for(let e=t;e<i.length;e++)l(i[e]);for(let e=t-1;e>=0;e--)l(i[e])}else for(let e=0;e<i.length;e++)l(i[e]);else i.map((e=>e.classList.remove("smart-hidden")))}}_refreshHeaderElements(){const e=this,t=document.activeElement.closest("smart-calendar")===e,a=e._animationStarted?e.$.nextMonthsContainer:e.$.dateViewContainer;let n,l,i=e._viewDates[e._viewDates.length-1],s=e._viewDates.map((e=>e.getFullYear()));if("month"===e.displayMode||"list"!==e.displayModeView){if("classic"===e.calendarMode&&e.$.monthElement&&e.$.monthElement instanceof HTMLDivElement){const t=document.createElement("smart-input");t.setAttribute("smart-id","monthElement"),t.classList.add("smart-calendar-month-element"),t.dropDownPosition="bottom",t.selectionMode="one",t.disabled=e.disabled,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.dropDownWidth=e.dropDownWidth,t.dropDownHeight=e.dropDownHeight,t.readonly=!0,t.dropDownButtonPosition="right";const a=e.$.monthElement;e.$.monthElement.parentNode.insertBefore(t,e.$.monthElement),e.$.monthElement=t,a.remove()}if(e.$.previousMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()-1:a.children[1].value.getFullYear()-1:e._viewDates[0].getMonth()-1<0?(n=11,l=e._viewDates[0].getFullYear()-1):(n=e._viewDates[0].getMonth()-1,l=e._viewDates[0].getFullYear()),e.$.previousMonthButton.disabled=l<e.min.getFullYear()||l===e.min.getFullYear()&&n<e.min.getMonth(),e.$.previousMonthButton.disabled&&t&&e.$.body.focus()),e.$.nextMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()+1:a.children[1].value.getFullYear()+11:i.getMonth()+1>11?(n=0,l=i.getFullYear()+1):(n=i.getMonth()+1,l=i.getFullYear()),e.$.nextMonthButton.disabled=l>e.max.getFullYear()||l===e.max.getFullYear()&&n>e.max.getMonth(),e.$.nextMonthButton.disabled&&t&&e.$.body.focus()),"classic"===e.calendarMode&&e.$.monthElement){let t=[...e._monthsNames];if(s.indexOf(e.min.getFullYear())>-1)for(let a=0;a<e.min.getMonth();a++)t[a]="";if(s.indexOf(e.max.getFullYear())>-1)for(let a=e.max.getMonth()+1;a<t.length;a++)t[a]="";t=t.filter((e=>""!==e));const a=Math.max(0,e.$.monthElement.selectedIndex);e.$.monthElement.dataSource=t,e._changeEventFired=0!==e.$.monthElement.selectedIndex,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates[0].getMonth()):e.$.monthElement.selectedIndex=a,e._changeEventFired=0}e.$.previousYearButton&&!e.disabled&&(l=e._viewDates[0].getFullYear()-1,e.$.previousYearButton.disabled=l<e.min.getFullYear(),e.$.previousYearButton.disabled&&t&&e.$.body.focus()),e.$.nextYearButton&&!e.disabled&&(l=i.getFullYear()+1,e.$.nextYearButton.disabled=l>e.max.getFullYear(),e.$.nextYearButton.disabled&&t&&e.$.body.focus()),e.$.yearElement&&(e.$.yearElement.value=s[0],e.$.yearElement.disabled=i.getFullYear()+1>e.max.getFullYear()&&e._viewDates[0].getFullYear()-1<e.min.getFullYear())}}_setMonthElementPropertyInShadowDOM(e,t){const a=this.$.monthElement,n=a.context;a.context=document,this.$.monthElement[e]=t,a.context=n}_refreshHeaderTitle(){const e=this;let t;function a(){if("month"!==e.displayMode){if("list"===e.displayModeView){const a=e.$.listViewContainer;if(!a)return;const n=a.querySelectorAll("li");if(!n.length)return"";let l;a.querySelector("li.active")&&(l=a.querySelector("li.active").getAttribute("value")),t="year"===e.displayMode?new Date(l||n[0].getAttribute("value")).getFullYear():new Date(n[0].getAttribute("value")).getFullYear()+" - "+new Date(n[n.length-1].getAttribute("value")).getFullYear()}else if(e.$.dateViewContainer.children[0].value){let a=e._animationStarted?e.$.nextMonthsContainer.children:e.$.dateViewContainer.children;t="year"===e.displayMode?a[0].value.getFullYear():a[1].value.getFullYear()+" - "+a[a.length-2].value.getFullYear()}if(t)return t}const a=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),n=a[0],l=a[a.length-1];n.setDate(2);let i=e.monthNameFormat;return"firstTwoLetters"===i&&(i="long"),t=n.toLocaleDateString(e.locale,{year:e.yearFormat,month:i}),e.months>1&&(l.setDate(2),t+=" - "+l.toLocaleDateString(e.locale,{year:e.yearFormat,month:i})),t}if("default"===e.calendarMode&&(e.$.defaultHeaderDate.innerHTML=a()),"function"==typeof e.headerTemplate||!e._layoutTemplates)return;let n=e._layoutTemplates.filter((t=>t.selector===e.$.header))[0];if(!n)return;let l=document.importNode(n.template.content,!0);if(n.bindings.length>0){const t=l.childNodes[n.bindings[0].childNodeIndex];(e.shadowRoot?e:n.selector).childNodes[n.bindings[0].childNodeIndex].innerHTML=t.innerHTML.replace(n.bindings[0].bindingString,e.dateFormatFunction?e.dateFormatFunction(e._viewDates):a())}}_updateWeeksVisibility(e,t){const a=this;let n=(t||a._focusedCell).parentElement;function l(){for(let e=o;e<s.length;e++)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}function i(){for(let e=o;e>=0;--e)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}if(!t&&!n.classList.contains("smart-hidden"))return;const s=[].slice.call(n.parentElement.children),o=s.indexOf(n),r=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0};let d=0;if(s.map((e=>e.classList.add("smart-hidden"))),e>0){if(l())return;i()}else{if(i())return;l()}}_getValidDates(e){let t=[];function a(e){if(e instanceof Date)return e;if(Smart.Utilities.DateTime&&e instanceof Smart.Utilities.DateTime)return e.toDate();if("string"==typeof e){if("new Date()"===e.trim()||"new Smart.Utilities.DateTime()"===e.trim())return new Date;let t=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;const a=()=>(e=e.replace(/[,-.\/]/g,",").split(",")).length>2?e=new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):new Date;return t.test(e)&&(e=t.exec(e)[0].replace(/[,-.\/]/g,",").split(","))?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):a()}}if(void 0===e)return null;if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(a(e[n]));else t.push(a(e));return t=t.filter((e=>e&&"Invalid Date"!==e.toDateString())),t.map((e=>e.setHours(0,0,0,0))),t}_getValidDate(e){const t=this._getValidDates(e);return t.length>0?t[0]:null}_validateSelectedDates(e){const t=this;let a=[];e||(e=t.selectedDates);let n=e.slice(0),l=function(e){for(let a=0;a<t.restrictedDates.length;a++)if(t.restrictedDates[a].getTime()===e.getTime())return!0};t.selectedDates=n.filter((function(e){if(e.getTime()>=t.min.getTime()&&e.getTime()<=t.max.getTime()&&!l(e))return!0;a.push(e)})),t._viewDates&&(a.map((e=>t._selectDate(e))),t._focusCell())}_validateMinMax(e,t,a){const n=this;switch(e){case"min":t=n._getValidDate(n[e]),n.min=t||a||n.properties.min.defaultValue;break;case"max":t=n._getValidDate(n[e]),n.max=t||a||n.properties.max.defaultValue;break;default:t=n._getValidDate(n.min),n.min=t||a||n.properties.min.defaultValue,t=n._getValidDate(n.max),n.max=t||a||n.properties.max.defaultValue}n.min=n.min.getTime()>n.max.getTime()?n.max:n.min,n.min.setHours(0,0,0,0),n.max.setHours(0,0,0,0);let l,i=n.$.monthsContainer.children;if(n._viewDates){if(n._viewDates[0].getTime()>n.max.getTime()||n._viewDates[0].getTime()<n.min.getTime())return void n._handleMonths();for(let e=0;e<i.length;e++){l=n._getMonthCells(i[e]);for(let t=0;t<l.length;t++){const a=l[t];if(a.value.getTime()>=n.min.getTime()&&a.value.getTime()<=n.max.getTime())n._setCellState(a,"restricted",!1),a.value.getMonth()===i[e]._date.getMonth()?a.classList.remove("smart-visibility-hidden"):n.hideOtherMonthDays||(n._setCellState(a,"otherMonth",!0),a.classList.remove("smart-visibility-hidden")),"month"!==n.displayMode&&n._setCellState(a,"otherMonth",!1);else{if(a.otherMonth){if(a.classList.contains("smart-visibility-hidden")){n._setCellState(a,"restricted",!1);continue}}else n._setCellState(a,"restricted",!0);"month"!==n.displayMode&&(a.classList.remove("smart-visibility-hidden"),n._setCellState(a,"otherMonth",!0))}}}}}_setCellState(e,t,a){e[t]=a;const n=Smart.Utilities.Core.toDash(t);a?(e.setAttribute(n,""),"selected"===t?e.setAttribute("aria-selected",!0):"today"===t?e.setAttribute("aria-current","date"):"restricted"===t?e.removeAttribute("aria-selected"):"disabled"===t&&(e.removeAttribute("aria-selected"),e.setAttribute("aria-disabled",!0))):(e.removeAttribute(n),"selected"===t?"none"===this.selectionMode||e.restricted||e.disabled?e.removeAttribute("aria-selected"):e.setAttribute("aria-selected",!1):"today"===t?e.removeAttribute("aria-current"):"restricted"!==t||e.disabled?"disabled"===t&&(e.removeAttribute("aria-disabled"),e.restricted||e.setAttribute("aria-selected",!1)):e.setAttribute("aria-selected",!1))}_validateTemplate(e,t){if(null===t||!t)return;if("function"==typeof t)return;const a=this;if("content"in document.createElement("template")){if("string"==typeof t&&(t=document.getElementById(t)),null!==t&&"content"in t)return t;a.error(a.localize("invalidTemplate",{elementType:a.nodeName.toLowerCase(),property:e}))}else a.error(a.localize("htmlTemplateNotSuported",{elementType:a.nodeName.toLowerCase()}))}_weeksDownHandler(e,t){const a=this,n=t.value;let l;if(a.$.body.contains(t))if(t.otherMonth&&(l=t.value.getTime()>t.closest(".smart-calendar-month")._date.getTime()?1:-1),n&&a.hasRippleAnimation&&Smart.Utilities.Animation.Ripple.animate(t,e.pageX,e.pageY),l){if(a._isDateInView(n))return;a.disableAutoNavigation||a.navigate(l*a.months)}else(t=a._getCellByDate(n))&&(t.disabled||t.restricted)||a._handleDateSelection(t)}_firstDayOfWeekValidator(e,t){return Math.min(Math.max(0,isNaN(t)?6:t),6)}_weeksValidator(e,t){return Math.min(Math.max(1,isNaN(t)?6:t),6)}_monthsValidator(e,t){return Math.min(Math.max(1,isNaN(t)?1:t),12)}});
21
21
 
22
22
  /***/ }),
23
23
 
@@ -80,7 +80,7 @@ Smart("smart-drop-down-list",class extends Smart.ContentElement{static get prope
80
80
  /***/ 3131:
81
81
  /***/ (() => {
82
82
 
83
- 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"},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,i){super.propertyChangedHandler(e,t,i);const a=this;switch(e){case"animation":case"theme":["textBoxEditor","numericTextBoxEditor","comboBoxEditor","dateTimePickerEditor","checkBoxEditor"].forEach((t=>a.$[t]&&(a.$[t][e]=i)));break;case"formatStringDate":case"formatStringDateTime":case"valueFormatFunction":a._refresh();break;case"operatorPlaceholder":Array.from((a.shadowRoot||a).querySelectorAll(".smart-filter-operation[placeholder]")).forEach((e=>e.firstElementChild.innerHTML=i));break;case"propertyPlaceholder":Array.from((a.shadowRoot||a).querySelectorAll(".smart-filter-field-name[placeholder]")).forEach((e=>e.firstElementChild.innerHTML=i));break;case"showIcons":a._closeEditor(),i?a._filterOperationDescriptions.map((e=>e.icon=a.icons[e.value])):a._filterOperationDescriptions.map((e=>delete e.icon));break;case"customOperations":case"fields":case"value":{const t=JSON.stringify(a._validValue),o=a._queryParser;"customOperations"===e?a._handleCustomOperations():""===e&&a._mapFieldsToMenu(),a._applyValue(),"customOperations"!==e&&"fields"!==e||(o[e]=i),a._oldValueAsString!==t&&(a._oldValueAsString=JSON.stringify(a._validValue),a.$.fireEvent("change",{value:JSON.parse(a._oldValueAsString),linq:o.toLinq(a._validValue)}));break}case"valuePlaceholder":Array.from((a.shadowRoot||a).querySelectorAll(".smart-filter-value[placeholder]")).forEach((e=>e.firstElementChild.innerHTML=i));break;case"locale":case"messages":a._localizeInitialValues(),a._refresh(),a._handleCustomOperations(),a.$.dateTimePickerEditor&&(a.$.dateTimePickerEditor.messages[a.locale]||(a.$.dateTimePickerEditor.messages[a.locale]={}),a.$.dateTimePickerEditor.messages[a.locale].dateTabLabel=a.localize("dateTabLabel"),a.$.dateTimePickerEditor.messages[a.locale].timeTabLabel=a.localize("timeTabLabel"),"locale"===e?a.$.dateTimePickerEditor.locale=a.locale:"messages"===e&&(a.$.dateTimePickerEditor.$.selectDate.innerHTML=a.$.dateTimePickerEditor.messages[a.locale].dateTabLabel,a.$.dateTimePickerEditor.$.selectTime.innerHTML=a.$.dateTimePickerEditor.messages[a.locale].timeTabLabel));break;case"icons":a._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 i=0;i<t.length;i++){const a=t[i];if("condition"!==a.type)continue;const o=a.data[0];!o||a.data.length<3||(a.data[2]=e._validateStoredValue(a.data[2],o))}e._generateValue(!0)}_applyValidationOnInput(){const e=this,t=e._editor;if(!t||!e._editorIsOpen)return;const i=t.closest(".filter-builder-item"),a=t.closest(".smart-filter-group-condition");i&&i.classList.contains("smart-filter-value")&&(clearTimeout(e._valueValidationTimeout),e._valueValidationTimeout=setTimeout((()=>{const i=a.getAttribute("node-id"),o=e.value.toString();clearTimeout(e._valueValidationTimeout),e._closeEditor(),o===e.value.toString()&&e._generateValue();const r=e._getItemById(i);r&&(t.setAttribute("focus",""),e._openEditor(r.htmlNode.querySelector(".smart-filter-value"))),delete e._valueValidationTimeout}),e.validationTimeout))}_contentContainerChangeHandler(e){const t=this,i=e.type,a=e.target,o=t._editor,r=t._editorIsOpen,l=t.applyMode;if(e.stopPropagation(),"change"===i&&t.validateOnInput&&r&&a===o&&t._applyValidationOnInput(),"itemClick"===i&&a.value!==e.detail.label||"immediately"!==l||!r||!o||"immediately"===l&&a!==o)return;const n=t._editor.closest(".filter-builder-item");n.classList.contains("smart-filter-value")||(t._closeEditor(),t._handleAutoPrompt(n))}_handleAutoPrompt(e){const t=this;if(e&&t.autoPrompt&&"immediately"===t.applyMode&&!e.classList.contains("smart-filter-value")){const i=e.closest(".smart-filter-group-condition")||e.closest(".smart-filter-nested-operator")||e.closest(".smart-filter-group");if(!i)return;const a=t._getItemById(i.getAttribute("node-id")),o=i.querySelector(".smart-filter-value");if(!a||!o)return;t._clickHandlerFilterButton(e.classList,a.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 i=e.customOperations[t],a=e._filterOperationDescriptions.findIndex((e=>e.value===i.name)),o={label:i.label,value:i.name,custom:!0,index:t,editorTemplate:i.editorTemplate,valueTemplate:i.valueTemplate,handleValue:i.handleValue,hideValue:i.hideValue,validateValue:i.validateValue};a>-1?e._filterOperationDescriptions[a]=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,i=t._editor;i&&i.contains(e.target)&&t._editorIsOpen&&t.validateOnInput&&t._applyValidationOnInput()}_documentDownHandler(e){const t=this,i=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;if(i.shadowParent&&i.shadowParent.closest(".smart-input-drop-down-menu")||i.closest(".smart-input-drop-down-menu")||t.$.conditionsMenu.contains(i))return;const a=i.closest(".smart-drop-down");if(i.getRootNode().host===t||i.closest("smart-query-builder")===t||a&&t.contains(a.ownerElement))if(t._isMobile){const i=t.$.scrollableContainer.scrollTop,a=t.getBoundingClientRect().top;setTimeout((function(){if(t.$.scrollableContainer.scrollTop===i&&t.getBoundingClientRect().top===a){const i=t.context;t.context=t,t._clickHandler(e.originalEvent),t.context=i}}),250)}else t._clickHandler(e.originalEvent);else t._editorIsOpen&&!t._scrollBarDown&&t._closeEditor(),delete t._scrollBarDown}_emptyElementsStructure(e){const t=this,i=t.$.contentContainer;for(;i.firstChild;)i.removeChild(i.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,i=["and","or","notAnd","notOr"];if(!e)return;let a=0,o=0;t._valueFlat=[],function e(r,l){let n;for(let s=0;s<r.length;s++){const d=r[s];let c={htmlNode:null};if("string"==typeof d&&(i.indexOf(d)>-1||t.customOperators[d]))n=(t.customOperators[d]||d).trim();else if(n=n||"and",Array.isArray(d)){let i=t._valueFlat.filter((e=>e.parentId+""==l+"")).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&&a>=t.maxConditions||t.maxConditionsPerGroup&&i>=t.maxConditionsPerGroup)continue;0!==s&&(t._valueFlat.push({nodeId:l+"."+i,type:"operator",data:n,parentId:l+""}),n="",i++),c.nodeId=l+"."+i,c.parentId=l+"",c.type="condition",c.data=d,a++,t._valueFlat.push(c)}}}}(e,0),delete t._totalGroups}_getFieldsFromValue(){const e=this._valueFlat,t=[],i=[];for(let o=0;o<e.length;o++){const r=e[o];if("condition"===r.type){const e=r.data[0];if(e&&-1===t.indexOf(e)){const o={label:e,dataField:e,dataType:(a=r.data[2],"boolean"==typeof a?"boolean":a instanceof Date?a.getHours()>0||a.getMinutes()>0||a.getSeconds()>0?"dateTime":"date":isNaN(a)?"string":"number"),format:null};t.push(e),i.push(o)}}}var a;this._valueFields=i}_addElement(e,t,i,a){const o=this,r=o._valueFlat.filter((e=>e.parentId===t));let l=0,n="";if(i=i||("group"===e?"or":[]),r.length){let e=r.map((e=>{const t=e.nodeId.split(".");return parseInt(t[t.length-1])}));e=0===e.length?[0]:e,l=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:l),d=r[0];if(r.length)for(let e=0;e<r.length;e++){const t=r[e],i=t.nodeId.split(".").pop();parseInt(i)>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&&r.length>0&&(o._valueFlat.splice(c,0,{nodeId:s,parentId:t,type:"operator",data:["and"],htmlNode:null}),s=(t||"")+n+(l+1),c++);const u={nodeId:s,parentId:t,type:e,data:i,htmlNode:null},p=o.autoPrompt;if("condition"===e&&p&&o._fields.length){const e=o._fields[0];if(e){const t=o._getFilterOperations(e);i[0]=e.value||e.label||"",t.length&&(i[1]=t[0].value)}}if(o._valueFlat.splice(c,0,u),"group"===e&&o._addElement("condition",s,[],!0),!a&&(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 i=this,a="string"==typeof e?e:e.getAttribute("node-id");if(a&&1!==a.length&&("group"===t?l(a):r(a),!t||"condition"===t)){let e=a.split(".");if(e.pop(),e=e.join("."),!i._valueFlat.filter((t=>t.parentId===e)).length&&(i._valueFlat.filter((e=>"group"===e.type)).length>1&&l(e),"0"===e)){const e=i._valueFlat.find((e=>"group"===e.type)),t=e.nodeId;e.nodeId="0",e.htmlNode.setAttribute("node-id","0");const a=i._valueFlat.filter((e=>e.parentId===t));for(let e=0;e<a.length;e++){const t=a[e];t.parentId="0",t.nodeId="0."+e,t.htmlNode.setAttribute("node-id",t.nodeId)}}i._generateValue()}function o(e){const t=i._valueFlat[e];if(t&&"operator"===t.type)return i._valueFlat.splice(e,1),t.htmlNode.parentElement.removeChild(t.htmlNode),!0}function r(e){let t,a=0,r=e.split(".");r.pop(),r=r.join(".");for(let o=0;o<i._valueFlat.length;o++){const l=i._valueFlat[o];if("condition"===l.type){if(l.nodeId===e){t=l;break}l.parentId===r&&a++}}const l=i._valueFlat.indexOf(t);i._valueFlat.splice(l,1),t.htmlNode.parentElement.removeChild(t.htmlNode);const n=o(l-1);a||o(l-(n?1:0));const s=i._valueFlat.filter((e=>e.nodeId===r))[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 l(e){const t=i._valueFlat.filter((t=>e===t.nodeId&&"group"===t.type))[0];for(let t=0;t<i._valueFlat.length;t++){const a=i._valueFlat[t],o=a.nodeId;a.parentId===e&&("group"===a.type?l(o):r(o))}i._valueFlat.indexOf(t)>-1&&i._valueFlat.splice(i._valueFlat.indexOf(t),1),t.htmlNode.parentElement.removeChild(t.htmlNode)}}_generateHTMLStructureFromFlatValue(e){const t=this,i=document.createDocumentFragment();if(t._valueFlat&&0!==t._valueFlat.length){for(let e=0;e<t._valueFlat.length;e++){const a=t._valueFlat[e],o=!!t.customOperations&&t.customOperations.find((e=>e.name===a.data[1])),r=a.parentId?(t.shadowRoot||t).querySelector('[node-id="'+a.parentId+'"]').querySelector(".smart-filter-group-condition-container"):t.$.contentContainer;if("group"===a.type){const o=document.createElement("div"),r=t.localize(a.data)||"";o.className="smart-filter-group",o.innerHTML='<div class="smart-filter-group-operator" role="button" aria-expanded="false" aria-haspopup="menu">'+r+'</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=r,i.appendChild(o),o.setAttribute("node-id",a.nodeId),t._valueFlat[e].htmlNode=o}else if("condition"===a.type){const r=t._newFilterConditionRow(a.data);if(r.setAttribute("node-id",a.nodeId),i.appendChild(r),t._valueFlat[e].htmlNode=r,void 0!==a.data[0]&&void 0===a.data[1]){const e=t._getFilterOperations(t._fields.find((e=>e.value===a.data[0])));t._handleOnlyOperation(e,a.data,r)}else(-1!==["isblank","isnotblank"].indexOf(a.data[1])||o&&o.hideValue)&&(a.data.splice(2,1),r.children[2].classList.add("smart-visibility-hidden"))}else{const o=document.createElement("div");o.className="smart-filter-nested-operator",o.setAttribute("node-id",a.nodeId),o.setAttribute("role","button"),o.setAttribute("aria-expanded",!1),o.setAttribute("aria-haspopup","menu"),o.innerHTML=t.localize(a.data),i.appendChild(o),t._valueFlat[e].htmlNode=o}r.appendChild(i)}e&&t._validateValueAdvanced(),t.$.scrollableContainer.refresh()}}_validateValueAdvanced(){const e=this,t=e.value;let i=!1,a=!1,o=0;for(let e=0;e<t.length;e++){const r=t[e];if("string"!=typeof r)for(let e=r.length-1;e>=0;e--){let t=r[e];if(Array.isArray(t)&&0===t.length&&e!==r.length-1)r.splice(e,1),0===e&&r.splice(0,1),i=!0;else if("string"==typeof t){t=t.toLowerCase(),o++,(o>1||"and"!==t&&"or"!==t)&&(a=!0);continue}o=0}}i&&(e._emptyElementsStructure(!0),e._convertValueToFlat(e.value),e._generateHTMLStructureFromFlatValue()),a&&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,i=t.shadowRoot||t.isInShadowDOM?e.composedPath()[0]:e.target;if(t.disabled||!i||!i.closest||!t._isMobile&&0!==e.button)return;if(t._scrollBarDown)return void delete t._scrollBarDown;const a=i.closest(".smart-drop-down"),o=t._editor&&t._editor.contains(i)||a&&(t._editor.contains(a.ownerElement)||t._editor===a.ownerElement)||i.closest(".smart-custom-editor");t._editor&&t._editorIsOpen&&!o&&t._closeEditor();const r=i.closest(".smart-filter-group-condition")||i.closest(".smart-filter-nested-operator")||i.closest(".smart-filter-group");if(!r)return;const l=t._getItemById(r.getAttribute("node-id"));if(!l)return;if(t.$.fireEvent("itemClick",{id:l.nodeId,type:l.type,data:l.data}),i.closest(".smart-filter-delete-btn"))return void t._clickHandlerDeleteButton(l.htmlNode);const n=i.closest(".smart-filter-add-btn")||i.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,l.nodeId,i))}const s=i.closest(".filter-builder-item")||i.closest(".smart-filter-group-operator")||i.closest(".smart-filter-nested-operator");if(s){const e=s.classList;t._clickHandlerFilterButton(e,l.nodeId,i)}}_downHandler(e){const t=this;if(!e.originalEvent||!t._isMobile&&0!==e.button)return;const i=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target,a=t.rightToLeft?e.pageX>i.getBoundingClientRect().right:e.pageX<i.getBoundingClientRect().left;if(t.allowDrag&&i.classList.contains("smart-filter-group-condition")&&a){const a=t._valueFlat.filter((e=>"condition"===e.type));if(1===a.length||2===a.length&&a[0].parentId===a[1].parentId&&a[1].htmlNode.hasAttribute("limit-selection"))return;return t._dragDetails={coords:{x:e.pageX,y:e.pageY},item:i,originalEvent:e},t.$.scrollableContainer._scrollView.disableSwipeScroll=!0,t._hoveredCondition=i,void window.getSelection().removeAllRanges()}this._scrollBarDown=i.closest("smart-scroll-bar"),e.stopPropagation(),e.preventDefault()}_scrollableContainerTouchmoveHandler(e){this._dragDetails&&e.cancelable&&(e.preventDefault(),e.stopPropagation())}_documentMoveHandler(e){const t=this,i=t._dragDetails;if(!i)return;const a=i.item;if(!i.feedbackShown){if(!(Math.abs(i.coords.x-e.pageX)>5||Math.abs(i.coords.y-e.pageY)>5))return;{const o=t._valueFlat.filter((e=>e.htmlNode===a))[0];if(t.$.fireEvent("dragStart",{data:o.data,item:a,originalEvent:e}).defaultPrevented)return delete t._dragDetails,delete t._hoveredCondition,void(t.$.scrollableContainer._scrollView.disableSwipeScroll=!1);i.allConditions=Array.from((t.shadowRoot||t).querySelectorAll(".smart-filter-group-condition")),i.data=o,i.feedback=t._addDragFeedback(),i.feedbackShown=!0,a.classList.add("dragged")}}const o=e.clientY;let r,l=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;if(t.$.fireEvent("dragging",{data:i.data,item:a,originalEvent:e}),t.setAttribute("dragging",""),i.feedback.style.left=e.pageX+10+"px",i.feedback.style.top=e.pageY+10+"px",t._isMobile){const i=t._hoveredCondition;i&&(i.classList.remove("drop-target","top","bottom"),delete t._hoveredCondition);const a=document.elementFromPoint(e.clientX,o);a&&(l=a)}let n,s=l.closest(".smart-filter-group-condition");if(s){r=s;const e=r.getBoundingClientRect(),t=Math.abs(o-e.top),i=Math.abs(o-e.bottom);n=t<i?"top":"bottom"}else{let e,t;i.allConditions.forEach((i=>{const a=i.getBoundingClientRect(),r=Math.abs(o-a.top),l=Math.abs(o-a.bottom),s=Math.min(r,l);(void 0===t||s<t)&&(e=i,t=s,n=r<l?"top":"bottom")})),s=e}if(s===a||s.hasAttribute("limit-selection")&&"bottom"===n)s=void 0;else{const e=Array.from(s.parentElement.getElementsByClassName("smart-filter-group-condition")),t=e.indexOf(a);-1!==t&&("top"===n&&s===e[t+1]||"bottom"===n&&s===e[t-1])&&(s=void 0)}if(r=s,i.side=n,clearInterval(t._dragInterval),t._dragInterval=setInterval((function(){const i=t.getBoundingClientRect();t.$.scrollableContainer.scrollHeight>0&&i.left<=e.clientX&&i.left+i.width>=e.clientX?o>=i.top&&o<=i.top+36?t.$.scrollableContainer.scrollTop-=t._autoScrollCoefficient:o>=i.top+i.height-36&&o<=i.top+i.height?t.$.scrollableContainer.scrollTop+=t._autoScrollCoefficient:clearInterval(t._dragInterval):clearInterval(t._dragInterval)}),1),r){t._hoveredCondition&&r!==t._hoveredCondition&&t._hoveredCondition.classList.remove("drop-target","top","bottom");const e=r.closest(".smart-filter-group");if(e&&e.hasAttribute("restricted"))return void(t._hoveredCondition=void 0);t._hoveredCondition=r,r.classList.remove("top","bottom"),r.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,i=t._dragDetails;if(!i)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 a=i.item,o=i.data,r=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"),a.classList.remove("dragged"),i.feedback.remove(),!r)return void t.$.fireEvent("dragEnd",{data:o.data,item:a,originalEvent:e,target:null,targetData:null,targetSide:null});const l=t._valueFlat.filter((e=>e.htmlNode===r))[0],n=t.$.fireEvent("dragEnd",{data:o.data,item:a,originalEvent:e,target:r,targetData:l.data,targetSide:i.side});if(r.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=l.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"===i.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 i=this;if(e&&e.classList){if(i._closeEditor(),1===i.getElementsByClassName("smart-filter-group-condition").length){const e=i._valueFlat[1].htmlNode.children;i.value=[[[]]],i._validValue=i._getValidValue(),i._valueFlat[1].data=[],i._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=i.propertyPlaceholder,e[1].firstElementChild.innerHTML=i.operatorPlaceholder,e[2].firstElementChild.innerHTML=i.valuePlaceholder;const t=JSON.stringify(i._validValue);return i._oldValueAsString!==t&&(i._oldValueAsString=t,i.$.fireEvent("change",{value:JSON.parse(t),linq:i._queryParser.toLinq(i._validValue)})),void i._restrictNesting()}if(e.classList.contains("smart-filter-group")){if(t&&i._valueFlat.filter((t=>t.parentId===e.getAttribute("node-id"))).length>0)return;i._deleteElement(e,"group")}else i._deleteElement(e);i._generateValue(),i.$.scrollableContainer.refresh(),Array.from(i.$.contentContainer.children).forEach(((e,t)=>{const a=(t+1).toString();e.setAttribute("node-id",a),i._valueFlat.filter((t=>t.htmlNode===e))[0].nodeId=a,Array.from(e.children[1].children).forEach(((e,t)=>{const o=i._valueFlat.filter((t=>t.htmlNode===e))[0],r=a+"."+t;e.setAttribute("node-id",r),o.parentId=a,o.nodeId=r}))}))}}_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,i=t._selectedElement.closest(".smart-filter-group-operator, .smart-filter-nested-operator"),a=e.detail,o=a.value;let r;if(i){i.innerHTML=t.localize(o)||a.label,i.value=o,r=i.classList.contains("smart-filter-nested-operator")?i.getAttribute("node-id"):i.parentElement.getAttribute("node-id");for(let e=0;e<t._valueFlat.length;e++)if(t._valueFlat[e].nodeId===r){t._valueFlat[e].data=i.value;break}t._generateValue()}else r=t._selectedElement.parentElement.getAttribute("node-id"),t._addElement("group",null,o);t.$.scrollableContainer.refresh()}_newFilterConditionRow(e=[]){const t=this,i=e[0];let a,o=t._fields.find((e=>e.value===i)),r=o?o.label:void 0;void 0===i||!r&&"static"===t.fieldsMode?e.length=0:(r||(o=t._getDynamicFieldInfo(i),r=o.label,e[0]=o.dataField),a=t._getFilterOperations(o).find((t=>t.value===e[1])),a&&(a=a.label));const l=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" '+(r?'><div class="smart-value-container" role="presentation">'+r:'placeholder><div class="smart-value-container" role="presentation">'+t.propertyPlaceholder)+'</div></div><div class="filter-builder-item smart-filter-operation" id="'+d+'Operation" '+(a?'><div class="smart-value-container" role="presentation">'+a:'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">'+l:'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 i=0;i<e.children.length-1;i++){const a=e.children[i];a.classList.contains("smart-visibility-hidden")||a.hasAttribute("placeholder")||t.push(e.children[i].innerText)}0!==t.length?e.setAttribute("aria-label",t.join(" ")):e.setAttribute("aria-label","Empty condition row")}_formatValueStringRepresentation(e,t){const i=this,a=t[2],o=t[0],r=i._getFieldByFieldName(o);let l,n=t[1];if(!r||!r.dataType)return e;if(null==e)return i.valuePlaceholder;if(void 0!==n&&i.customOperations&&i.customOperations.length>0&&(n=i.customOperations.find((e=>e.name===n)),n&&n.valueTemplate))return"<span>"+n.valueTemplate(i._editor,e)+"</span>";switch(r.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=i._localizedDays,e.calendar.months=i._localizedMonths,e.calendar.locale=i.locale,l=e.toString("date"===r.dataType?i.formatStringDate:i.formatStringDateTime);break;case"array":l="string"==typeof e?e.split(","):e;break;case"object":l="string"==typeof e?e:JSON.stringify(e);break;case"number":l=e;break;case"boolean":l=!!e;break;default:l=e+""}if(!i.valueFormatFunction)return"<span>"+l+"</span>";const s={label:l,value:a,dataField:o,dataType:r.dataType||"string"};return"<span>"+i.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 i=[],a=t._valueFlat.slice(0),o=[];for(let e=0;e<a.length;e++){const t=a[e];let o={};"group"===t.type&&(o.nodeId=t.nodeId,o.parentId=t.parentId,o.data=t.data,o.structure=[],i.push(o))}for(let e=0;e<i.length;e++){const t=i[e];for(let e=0;e<a.length;e++){const i=a[e];if(i.parentId===t.nodeId&&"condition"===i.type){const o=a[e-1];o&&o.parentId===t.nodeId&&"operator"===o.type&&t.structure.push(o.data.toString()),t.structure.push(i.data)}}}i=i.filter((e=>e.structure.length>0)),i.sort((function(e,t){return t.nodeId.split(".").length-e.nodeId.split(".").length}));for(let e=0;e<i.length;e++){const t=i[e],a=i.filter((e=>e.nodeId===t.parentId))[0];a&&a.structure?a.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)),i=e._valueFlat,a=!!e._validationStatus;let o=!0;for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("condition"!==a.type)continue;const r=a.data[1],l=t.find((e=>e.name===r));if(l&&0==!!l.validateValue(a.data[2])){o=!1;break}}if(e._validationStatus!==o){const t=void 0!==e._validationStatus;e._validationStatus=o,t&&e.$.fireEvent("validationChange",{oldValue:a,newValue:o})}}_getItemById(e,t){const i=this._valueFlat.filter((i=>t?i.parentId===e:i.nodeId===e));return i.length>0?i[0]:null}_validateStoredValue(e,t){const i=this;if(!t&&!i._editedItem)return e;if(!t&&!(t=i._editedItem.data[0]))return e;const a=i._getFieldByFieldName(t).dataType;if(void 0===a)return e+"";switch(a.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){const t=this;let i;if(!t._editedItem||!t._editorIsOpen)return;const a=t._editedItem,o=t._editor.closest(".filter-builder-item"),r=o.querySelector(".smart-value-container"),l=o.parentElement,n=l.children[2];if(t._editor===t.$.dateTimePickerEditor)t._editor._inputChangeHandler(),i=t._editor.value,i&&(i=i.toDate());else if(t._editor===t.$.checkBoxEditor)i=t._editor.checked;else if(t._editor===t.$.customEditor)t._editor&&Array.from(t._editor.getElementsByTagName("smart-numeric-text-box")).forEach((e=>e._inputBlurHandler())),i=t._validateStoredValue(t._selectedCustomCondition.handleValue(t._editor));else if(t._editor===t.$.numericTextBoxEditor)t._editor._inputBlurHandler(),i=t._editor.value;else if(o.classList.contains("smart-filter-value")){const e=t._getFieldByFieldName(t._editedItem.data[0]);if("array"===e.dataType)i=t._editor.value.split(",");else if("object"===e.dataType)i=JSON.parse(t._editor.value);else{const a=t._editor.value;i=e.lookup&&e.lookup.dataSource?{label:a,value:t._editor.dataset.value||a}:a}}else i=t._editor.value;if(o.classList.contains("smart-filter-field-name")){if(""===i.trim())return void t._hideEditor(o,void 0===a.data[0]);l.hasAttribute("limit-selection")&&(l.removeAttribute("limit-selection"),l.parentElement.nextElementSibling.removeAttribute("limit-selection"));const e=t._fields.find((e=>e.label===i)),s=a.data[0];if(e)a.data[0]=e.value;else{if("dynamic"!==t.fieldsMode){const e=t._fields.find((e=>e.value===s));return e&&(r.innerHTML=e.label),void t._hideEditor(o)}{const e=t._getDynamicFieldInfo(i);i=e.label,a.data[0]=e.dataField}}r.innerHTML=i,t._handleFieldChange([s,a.data[0]],[n,a,l])}else if(o.classList.contains("smart-filter-operation"))t._handleOperationChange([a,i,t._editor.$.input.dataValue],[r,n]);else{let e,o;"object"==typeof i&&void 0!==i.value?(e=i.label,o=i.value,void 0===e&&(e=o)):e=o=i,a.data[2]=o,r.innerHTML=t._formatValueStringRepresentation(e,a.data)}t._validateValueField(n,a.data[1],a.data[2]),t._generateValue(e),t._hideEditor(o)}_validateValueField(e,t,i){const a=this.customOperations;let o=!0;if(e&&e.removeAttribute("invalid-value"),a&&a.length>0){const r=a.find((e=>e.name===t));r&&"function"==typeof r.validateValue&&(o=!!r.validateValue(i),!o&&e&&e.setAttribute("invalid-value",""))}return o}_getDynamicFieldInfo(e){const t=this,i={label:e,dataField:e,dataType:"string"};if(t.getDynamicField){const a=t.getDynamicField(e);a.label&&(i.label=a.label),a.dataField&&(i.dataField=a.dataField),a.dataType&&(i.dataType=a.dataType),a.filterOperations&&Array.isArray(a.filterOperations)&&a.filterOperations.length>0&&(i.filterOperations=a.filterOperations),a.lookup&&(i.lookup=a.lookup)}return t._manuallyAddedFields.push(i),t._mapFieldsToMenu(),i}_handleFieldChange(e,t){const i=this,a=e[0],o=t[1],r=t[2],l=t[0],n=i._fields.find((t=>t.value===e[1])),s=i._getFilterOperations(n),d=function(){n.value!==a&&i.$.fireEvent("propertySelected",{label:n.label,value:n.value})};if(!a||void 0===o.data[1])return i._handleOnlyOperation(s,o.data,r),void d();const c=i._fields.find((e=>e.value===a)),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?(l.firstElementChild.innerHTML=i._formatValueStringRepresentation(o.data),void d()):(o.data.splice(2,1),l.setAttribute("placeholder",""),l.firstElementChild.innerHTML=i.valuePlaceholder,void d())}o.data.splice(1,2),r.children[1].setAttribute("placeholder",""),r.children[1].firstElementChild.innerHTML=i.operatorPlaceholder,l.setAttribute("placeholder",""),l.firstElementChild.innerHTML=i.valuePlaceholder,l.classList.remove("smart-visibility-hidden"),i._handleOnlyOperation(s,o.data,r),d()}}_handleOnlyOperation(e,t,i){const a=this.autoPrompt;if(1===e.length||a&&"immediately"===this.applyMode&&e.length>1){const a=e[0];t[1]=a.value,i.children[1].removeAttribute("placeholder",""),i.children[1].firstElementChild.innerHTML=e[0].label,("isblank"===a.value||"isnotblank"===a.value||a.custom&&a.hideValue)&&(t.splice(2,1),i.children[2].classList.add("smart-visibility-hidden"))}}_handleOperationChange(e,t){const i=this,a=e[0],o=e[1],r=e[2],l=t[0],n=t[1],s=void 0!==a.data[1]?i._filterOperationDescriptions.find((e=>e.value===a.data[1])):void 0,d=i._filterOperationDescriptions.find((e=>e.value===r));if(!d||d===s)return;const c=d.value;a.data[1]=c;const u=a.data[0],p=a.data[1],m=a.data[2];if(l.innerHTML=o,"isblank"===c||"isnotblank"===c||d.custom&&d.hideValue)a.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=i.valuePlaceholder;else if(d.custom){const e=i._getFieldByFieldName(u);if(d.editorTemplate){const t=d.editorTemplate(e.dataType,p,e);t&&(i.$.customEditor.innerHTML="",i.$.customEditor.appendChild(t))}d.valueTemplate?n.firstElementChild.innerHTML=d.valueTemplate(i.$.customEditor,m):void 0===m?(n.setAttribute("placeholder",""),n.firstElementChild.innerHTML=i.valuePlaceholder):n.firstElementChild.innerHTML=m}else void 0===m?(a.data.splice(2,1),n.setAttribute("placeholder",""),n.firstElementChild.innerHTML=i.valuePlaceholder):d.custom||(n.firstElementChild.innerHTML=i._formatValueStringRepresentation(m,a.data))}_hideEditor(e,t){const i=this;t&&e.setAttribute("placeholder",""),e.removeAttribute("edited"),i.$.editorsContainer.removeAttribute("open"),i._editor.close&&i._editor.close(),i._editor.classList.add("smart-hidden"),i._editorIsOpen=i._enterIsPressedInEditor=!1,i.$.scrollableContainer.refresh(),i._setAriaLabel(e.parentElement)}_clickHandlerFilterButton(e,t,i){const a=this;function o(e,t,i){a._contextMenuOptions=0===t.length?a._defaultFilterOperationDescriptions:t,a._handleContextMenu(e),a.$.conditionsMenu.opened&&(a.$.conditionsMenu._discardKeyboardHover(),a.$.conditionsMenu._hoverViaKeyboard(a.$.conditionsMenu.querySelector('smart-menu-item[value="'+i+'"]')))}i.closest(".smart-editors-container")||(a._closeEditor(),a._editedItem=a._getItemById(t),e.contains("smart-filter-add-btn")?o(i,a._groupOperationDescriptions):(e.contains("smart-filter-field-name")||a._editedItem.data&&a._editedItem.data.length)&&(e.contains("smart-filter-group-operator")||e.contains("smart-filter-nested-operator")?o(i,a._groupOperationDescriptions,a._editedItem.data):(i.closest(".filter-builder-item").removeAttribute("placeholder"),a._openEditor(i))))}_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 i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=i.left+t.$.contentContainer.scrollLeft-a.left,r=i.top+t.$.contentContainer.scrollTop-a.top+i.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,r+3),t._selectedElement=e,t.$.scrollableContainer.refresh()}_openEditor(e){const t=this,i=e&&e.closest(".smart-filter-group-condition")?e.closest(".smart-filter-group-condition").getAttribute("node-id"):null,a=e.closest(".filter-builder-item"),o=t._getItemById(i);let r="";void 0!==o.data[0]?r=o.data[0]:t._fields.length&&(r=t._fields[0].value);let l,n,s=t._getFieldByFieldName(r),d="";if(a.classList.contains("smart-filter-field-name"))n=0,t._fields||t._mapFieldsToMenu(),s.lookup={dataSource:t._fields.slice(),readonly:!1},d=s.label||"",l=s.value;else if(a.classList.contains("smart-filter-operation")){n=1;let e=t._getFilterOperations(s);s.lookup={dataSource:e,readonly:!0};let i=e.find((e=>e.value===o.data[n]))||e[0];d=i.label,l=i.value}else n=2,d=o.data[n],void 0===d&&(d="");t._editorIsOpen&&t._closeEditor(),a.setAttribute("edited",""),t._editedItem=o;const c=t._fields.filter((e=>e.value===r)),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,l),a.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 requestAnimationFrame((()=>t._editor.focus()));s.lookup&&!t._valueValidationTimeout&&t._editor.open()}_getFilterOperations(e){const t=this;let i=t._filterOperationDescriptions.slice();if(e.filterOperations)i=t._filterOperationDescriptions.filter((t=>e.filterOperations.indexOf(t.value)>-1));else{let a;switch(e.dataType){case"date":case"dateTime":case"number":a=["=","<>","<",">","<=",">=","isblank","isnotblank"];break;case"boolean":a=["=","<>","isblank","isnotblank"];break;case"object":a=["isblank","isnotblank"];break;case"string":a=["contains","notcontains","startswith","endswith","=","<>","isblank","isnotblank"];break;default:a=["contains","notcontains","startswith","endswith","=","<>","<",">","<=",">=","isblank","isnotblank"]}i=t._filterOperationDescriptions.filter((e=>a.indexOf(e.value)>-1))}return t.showIcons&&i.map((e=>e.icon=t.icons[e.value])),i}_openCustomEditor(e,t,i){const a=this,o=a.customOperations[a._selectedCustomCondition.index].editorTemplate(e,t,i);a.$.customEditor.innerHTML="",o&&a.$.customEditor.appendChild(o),a._editor=a.$.customEditor}_openEditorByFieldType(e,t,i,a){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 a=i.lookup.minLength,r=i.lookup.dataSource;if(o._editor.autoCompleteDelay=i.lookup.autoCompleteDelay||100,o._editor.dropDownAppendTo=o.$.container,o._editor.dropDownButtonPosition=o.rightToLeft?"left":"right",o._editor.minLength=isNaN(a)||null===a?1:a,o._editor.readonly=!!i.lookup.readonly,"function"==typeof r?o._editor.dataSource=r:r instanceof Promise?r.then((e=>{if(!(o._editor instanceof Smart.Input))return;const i=o._editor.opened;o._editor.dataSource=e,e.length<12?o._editor.dropDownHeight="auto":o._editor.dropDownHeight=200,i&&(o._editor.open(),""===t&&o._editor.readonly&&e.length&&(o._editor.value=e[0].label||e[0]))})):(o._editor.dataSource=r,r.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 i=e[0];t=i&&(i.value||i.label)||""}else t=""}if(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+"":"";a&&"object"!==e&&o._editor.isRendered&&(o._editor.$.input.dataValue=a)}_initializeEditor(e){const t=this;if(t.$[e+"Editor"])return void(t._editor=t.$[e+"Editor"]);const i=document.createElement("smart-"+Smart.Utilities.Core.toDash(e));"numericTextBox"===e?(i.spinButtons=!0,i.inputFormat="floatingPoint"):"dateTimePicker"===e&&(i.dropDownAppendTo=t.$.container,i.calendarButton=!0,i.dropDownDisplayMode="auto",i.enableMouseWheelAction=!0,i.locale=t.locale,i.autoClose=!0,i.messages[t.locale]||(i.messages[t.locale]={}),i.messages[t.locale].dateTabLabel=t.localize("dateTabLabel"),i.messages[t.locale].timeTabLabel=t.localize("timeTabLabel")),i.rightToLeft=t.rightToLeft,i.theme=t.theme,i.animation=t.animation,i.$.addClass("smart-hidden underlined"),t.$.editorsContainer.appendChild(i),t._editor=t.$[e+"Editor"]=i}_getValidValue(){const e=this,t=e.properties.value.value,i=[];let a=!1;return t.forEach((t=>{if(Array.isArray(t)){let o=!1,r=!1;const l=[];t.forEach((t=>{if(Array.isArray(t)){const i=t[0],a=t[1],n=t[2];if(void 0===i||void 0===a)return void(r=!0);if(void 0!==n||"isblank"===a||"isnotblank"===a)return o=!0,void l.push(t);const s=e._filterOperationDescriptions.find((e=>e.value===a));s.custom&&s.hideValue?(o=!0,l.push(t)):r=!0}else r?r=!1:l.push(t)})),o?("string"==typeof l[l.length-1]&&l.pop(),i.push(l)):a=!0}else a?a=!1:i.push(t)})),"string"==typeof i[i.length-1]&&i.pop(),i}}),Smart.Utilities.Assign("QueryParser",class{constructor(e,t,i){const a=this;a.customOperations=t||[],a.fields=e||[],a.dynamicField=i}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,i={and:"&&",or:"||"};let a="";for(let o=0;o<e.length;o++){const r=e[o];if(Array.isArray(r))if(r.indexOf("and")>-1||r.indexOf("or")>-1||1===r.length&&Array.isArray(r[0])){const e=t._parseQueryToLinq(r);e?a+=r.length>1?"("+e+")":e:/\s(&|\|){2}\s$/gm.test(a)&&(a=a.replace(/\s(&|\|){2}\s$/gm,""))}else a+=t._getExpressionFromQuery(r)||"";else a&&(a+=" "+i[r]+" ")}return a}_getExpressionFromQuery(e){const t=e[0],i=e[1];let a=e[2];const o=this.customOperations.find((e=>e.name===i));return o&&o.expressionTemplate?("string"==typeof a&&a.includes('"')&&o.expressionTemplate.includes('"')&&(a=JSON.stringify(a).slice(1,-1)),o.expressionBuilderCallback?o.expressionBuilderCallback(t,i,a):o.expressionTemplate.replace("{0}",t).replace("{1}",a)):""}_parseLinqToValue(e){const t=this;let i,a=0,o=[];for(let t=0;t<e.length;t++)if("("===e[t])a++,void 0===i&&(i=t);else if(")"===e[t]&&a>0&&(a--,0===a)){let a=e.substring(i,t+1).trim();a.length&&(a.includes("&&")||a.includes("||"))&&o.push({expr:a}),i=void 0}let r,l=[];if(o.length)for(let i=0;i<o.length;i++){let a;o[i].query=t._getQueryFromExpression(o[i].expr),a=r?e.substring(e.indexOf(r)+r.length,e.indexOf(o[i].expr)).trim():e.substring(0,e.indexOf(o[i].expr)).trim(),a&&l.push(a),r=o[i].expr}r?l.push(e.substring(e.indexOf(r)+r.length).trim()):l.push(e.trim());for(let e=0;e<l.length;e++){const i=l[e].replace(/^&{2}|^\|{2}|&{2}$|\|{2}$/gm,"").trim();i.length&&o.push({expr:i,query:t._getQueryFromExpression(i),outher:!0})}return t._constructValueFromQueries(e,o)}_getQueryFromExpression(e){const t=this,i=t.fields,a=t.dynamicField;let o=[],r=e;const l=function(e){let r=[];const l=t.customOperations.filter((e=>e.expressionTemplate));l.sort(((e,t)=>t.expressionTemplate.length-e.expressionTemplate.length));for(let t=0;t<l.length;t++){const i=l[t],a=new RegExp(i.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(a.test(e)){a.lastIndex=0;let t,o,l=a.exec(e);if(l=l.filter(((e,t)=>l.indexOf(e)===t)),i.expressionReaderCallback){let e=i.expressionReaderCallback(l[0],l.slice(1));e&&(t=e.fieldName,o=e.value)}void 0===t&&(t=l[1]||""),void 0===o&&(o=l[2]||""),r.push({operator:i.name,field:t,value:o,query:l[0]})}}let n=r.find((e=>i.find((t=>t.filterOperations.indexOf(e.operator)>-1&&t.dataField===e.field))));if(!n&&a)for(let e=0;e<r.length;e++){const t=r[e],i=a(t.field);if(i&&Array.isArray(i.filterOperations)&&i.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(r){for(;r.length;){r&&(r=r.trim(),"("===r[0]&&")"===r[r.length-1]&&(r=r.trim().replace(/^\(|\)$/gm,"")),r=r.replace(/^&{2}|^\|{2}|&{2}$|\|{2}$/gm,"").trim());const e=l(r);if(!e)break;r=r.replace(e,"").trim()}return t._constructValueFromQueries(e,o)}}_constructValueFromQueries(e,t){let i=[];t.sort(((t,i)=>e.indexOf(t.expr)-e.indexOf(i.expr)));for(let a=0;a<t.length;a++){let o=t[a-1];if(o){const r=e.substring(e.indexOf(o.expr)+o.expr.length,e.indexOf(t[a].expr)).trim();i.push("||"===r?"or":"and")}t[a].outher?t[a].query.forEach((e=>i.push(Array.isArray(e)?[e]:e))):i.push(t[a].query)}return i}});
83
+ 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"},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;if(e.stopPropagation(),"change"===a&&t.validateOnInput&&l&&i===o&&t._applyValidationOnInput(),"itemClick"===a&&i.value!==e.detail.label||"immediately"!==r||!l||!o||"immediately"===r&&i!==o)return;const n=t._editor.closest(".filter-builder-item");n.classList.contains("smart-filter-value")||(t._closeEditor(),t._handleAutoPrompt(n))}_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;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){const t=this;let a;if(!t._editedItem||!t._editorIsOpen)return;const i=t._editedItem,o=t._editor.closest(".filter-builder-item"),l=o.querySelector(".smart-value-container"),r=o.parentElement,n=r.children[2];if(t._editor===t.$.dateTimePickerEditor)t._editor._inputChangeHandler(),a=t._editor.value,a&&(a=a.toDate());else if(t._editor===t.$.checkBoxEditor)a=t._editor.checked;else if(t._editor===t.$.customEditor)t._editor&&Array.from(t._editor.getElementsByTagName("smart-numeric-text-box")).forEach((e=>e._inputBlurHandler())),a=t._validateStoredValue(t._selectedCustomCondition.handleValue(t._editor));else if(t._editor===t.$.numericTextBoxEditor)t._editor._inputBlurHandler(),a=t._editor.value;else if(o.classList.contains("smart-filter-value")){const e=t._getFieldByFieldName(t._editedItem.data[0]);if("array"===e.dataType)a=t._editor.value.split(",");else if("object"===e.dataType)a=JSON.parse(t._editor.value);else{const i=t._editor.value;a=e.lookup&&e.lookup.dataSource?{label:i,value:t._editor.dataset.value||i}:i}}else a=t._editor.value;if(o.classList.contains("smart-filter-field-name")){if(""===a.trim())return void t._hideEditor(o,void 0===i.data[0]);r.hasAttribute("limit-selection")&&(r.removeAttribute("limit-selection"),r.parentElement.nextElementSibling.removeAttribute("limit-selection"));const e=t._fields.find((e=>e.label===a)),s=i.data[0];if(e)i.data[0]=e.value;else{if("dynamic"!==t.fieldsMode){const e=t._fields.find((e=>e.value===s));return e&&(l.innerHTML=e.label),void t._hideEditor(o)}{const e=t._getDynamicFieldInfo(a);a=e.label,i.data[0]=e.dataField}}l.innerHTML=a,t._handleFieldChange([s,i.data[0]],[n,i,r])}else if(o.classList.contains("smart-filter-operation"))t._handleOperationChange([i,a,t._editor.$.input.dataValue],[l,n]);else{let e,o;"object"==typeof a&&void 0!==a.value?(e=a.label,o=a.value,void 0===e&&(e=o)):e=o=a,i.data[2]=o,l.innerHTML=t._formatValueStringRepresentation(e,i.data)}t._validateValueField(n,i.data[1],i.data[2]),t._generateValue(e),t._hideEditor(o)}_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 requestAnimationFrame((()=>t._editor.focus()));s.lookup&&!t._valueValidationTimeout&&t._editor.open()}_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(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}});
84
84
 
85
85
  /***/ }),
86
86
 
@@ -295,7 +295,7 @@ var __webpack_exports__ = {};
295
295
  /* harmony import */ var _smart_filterbuilder_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(3131);
296
296
  /* harmony import */ var _smart_filterbuilder_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(_smart_filterbuilder_js__WEBPACK_IMPORTED_MODULE_24__);
297
297
 
298
- /* Smart UI v14.2.39 (2022-08-04)
298
+ /* Smart UI v14.2.89 (2022-09-14)
299
299
  Copyright (c) 2011-2022 jQWidgets.
300
300
  License: https://htmlelements.com/license/ */ //
301
301