smart-webcomponents-react 18.0.2 → 18.0.11
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.
- package/accordion/accordion.d.ts +2 -0
- package/accordion/accordion.esm.js +1 -1
- package/accordion/accordion.umd.js +2 -3
- package/accordion/accordionitem.d.ts +2 -0
- package/alertwindow/alertwindow.d.ts +2 -0
- package/alertwindow/alertwindow.esm.js +1 -1
- package/alertwindow/alertwindow.umd.js +2 -3
- package/array/array.d.ts +2 -0
- package/array/array.esm.js +1 -1
- package/array/array.umd.js +2 -3
- package/barcode/barcode.d.ts +2 -0
- package/barcode/barcode.esm.js +1 -1
- package/barcode/barcode.umd.js +2 -3
- package/breadcrumb/breadcrumb.d.ts +2 -0
- package/breadcrumb/breadcrumb.esm.js +1 -1
- package/breadcrumb/breadcrumb.umd.js +2 -3
- package/button/button.d.ts +2 -0
- package/button/button.esm.js +1 -1
- package/button/button.umd.js +2 -3
- package/button/buttongroup.d.ts +2 -0
- package/button/dropdownbutton.d.ts +2 -0
- package/button/multisplitbutton.d.ts +2 -0
- package/button/powerbutton.d.ts +2 -0
- package/button/radiobutton.d.ts +2 -0
- package/button/repeatbutton.d.ts +2 -0
- package/button/switchbutton.d.ts +2 -0
- package/button/togglebutton.d.ts +2 -0
- package/buttongroup/buttongroup.d.ts +2 -0
- package/buttongroup/buttongroup.esm.js +1 -1
- package/buttongroup/buttongroup.umd.js +2 -3
- package/calendar/calendar.d.ts +7 -0
- package/calendar/calendar.esm.js +13 -2
- package/calendar/calendar.umd.js +14 -4
- package/card/card.d.ts +2 -0
- package/card/card.esm.js +1 -1
- package/card/card.umd.js +2 -3
- package/card/cardview.d.ts +2 -0
- package/cardview/cardview.d.ts +2 -0
- package/cardview/cardview.esm.js +1 -1
- package/cardview/cardview.umd.js +2 -3
- package/carousel/carousel.d.ts +2 -0
- package/carousel/carousel.esm.js +1 -1
- package/carousel/carousel.umd.js +2 -3
- package/chart/chart.d.ts +2 -0
- package/chart/chart.esm.js +1 -1
- package/chart/chart.umd.js +2 -3
- package/chart/ganttchart.d.ts +2 -0
- package/chart/threedchart.d.ts +2 -0
- package/checkbox/checkbox.d.ts +2 -0
- package/checkbox/checkbox.esm.js +1 -1
- package/checkbox/checkbox.umd.js +2 -3
- package/checkinput/checkinput.d.ts +2 -0
- package/checkinput/checkinput.esm.js +1 -1
- package/checkinput/checkinput.umd.js +2 -3
- package/chip/chip.d.ts +2 -0
- package/chip/chip.esm.js +1 -1
- package/chip/chip.umd.js +2 -3
- package/colorinput/colorinput.d.ts +2 -0
- package/colorinput/colorinput.esm.js +1 -1
- package/colorinput/colorinput.umd.js +2 -3
- package/colorpanel/colorpanel.d.ts +2 -0
- package/colorpanel/colorpanel.esm.js +1 -1
- package/colorpanel/colorpanel.umd.js +2 -3
- package/colorpicker/colorpicker.d.ts +2 -0
- package/colorpicker/colorpicker.esm.js +1 -1
- package/colorpicker/colorpicker.umd.js +2 -3
- package/columnpanel/columnpanel.d.ts +2 -0
- package/columnpanel/columnpanel.esm.js +1 -1
- package/columnpanel/columnpanel.umd.js +2 -3
- package/combobox/combobox.d.ts +2 -0
- package/combobox/combobox.esm.js +1 -1
- package/combobox/combobox.umd.js +2 -3
- package/countryinput/countryinput.d.ts +2 -0
- package/countryinput/countryinput.esm.js +1 -1
- package/countryinput/countryinput.umd.js +2 -3
- package/customizationdialog/customizationdialog.d.ts +2 -0
- package/customizationdialog/customizationdialog.esm.js +1 -1
- package/customizationdialog/customizationdialog.umd.js +2 -3
- package/dateinput/dateinput.d.ts +2 -0
- package/dateinput/dateinput.esm.js +1 -1
- package/dateinput/dateinput.umd.js +2 -3
- package/daterangeinput/daterangeinput.d.ts +2 -0
- package/daterangeinput/daterangeinput.esm.js +1 -1
- package/daterangeinput/daterangeinput.umd.js +2 -3
- package/datetimepicker/datetimepicker.d.ts +2 -0
- package/datetimepicker/datetimepicker.esm.js +1 -1
- package/datetimepicker/datetimepicker.umd.js +2 -3
- package/dialogwindow/dialogwindow.d.ts +2 -0
- package/dialogwindow/dialogwindow.esm.js +1 -1
- package/dialogwindow/dialogwindow.umd.js +2 -3
- package/dockinglayout/dockinglayout.d.ts +2 -0
- package/dockinglayout/dockinglayout.esm.js +1 -1
- package/dockinglayout/dockinglayout.umd.js +2 -3
- package/dropdownbutton/dropdownbutton.d.ts +2 -0
- package/dropdownbutton/dropdownbutton.esm.js +1 -1
- package/dropdownbutton/dropdownbutton.umd.js +2 -3
- package/dropdownlist/dropdownlist.d.ts +2 -0
- package/dropdownlist/dropdownlist.esm.js +1 -1
- package/dropdownlist/dropdownlist.umd.js +2 -3
- package/editor/editor.d.ts +2 -0
- package/editor/editor.esm.js +1 -1
- package/editor/editor.umd.js +2 -3
- package/element/element.d.ts +2 -0
- package/element/element.esm.js +1 -1
- package/element/element.umd.js +2 -3
- package/fileupload/fileupload.d.ts +2 -0
- package/fileupload/fileupload.esm.js +1 -1
- package/fileupload/fileupload.umd.js +2 -3
- package/filterbuilder/filterbuilder.d.ts +2 -0
- package/filterbuilder/filterbuilder.esm.js +1 -1
- package/filterbuilder/filterbuilder.umd.js +2 -3
- package/filterpanel/filterpanel.d.ts +2 -0
- package/filterpanel/filterpanel.esm.js +1 -1
- package/filterpanel/filterpanel.umd.js +2 -3
- package/filterpanel/multicolumnfilterpanel.d.ts +2 -0
- package/form/form.d.ts +2 -0
- package/form/form.esm.js +1 -1
- package/form/form.umd.js +2 -3
- package/form/formcontrol.d.ts +2 -0
- package/form/formgroup.d.ts +2 -0
- package/ganttchart/ganttchart.d.ts +2 -0
- package/ganttchart/ganttchart.esm.js +1 -1
- package/ganttchart/ganttchart.umd.js +2 -3
- package/gauge/gauge.d.ts +2 -0
- package/gauge/gauge.esm.js +1 -1
- package/gauge/gauge.umd.js +2 -3
- package/grid/grid.d.ts +23 -12
- package/grid/grid.esm.js +25 -14
- package/grid/grid.umd.js +26 -16
- package/grouppanel/grouppanel.d.ts +2 -0
- package/grouppanel/grouppanel.esm.js +1 -1
- package/grouppanel/grouppanel.umd.js +2 -3
- package/index.d.ts +54 -3
- package/input/checkinput.d.ts +2 -0
- package/input/colorinput.d.ts +2 -0
- package/input/countryinput.d.ts +2 -0
- package/input/dateinput.d.ts +2 -0
- package/input/daterangeinput.d.ts +2 -0
- package/input/input.d.ts +2 -0
- package/input/input.esm.js +1 -1
- package/input/input.umd.js +2 -3
- package/input/multicomboinput.d.ts +2 -0
- package/input/multiinput.d.ts +2 -0
- package/input/numberinput.d.ts +2 -0
- package/input/passwordinput.d.ts +2 -0
- package/input/phoneinput.d.ts +2 -0
- package/input/timeinput.d.ts +2 -0
- package/kanban/kanban.d.ts +2 -0
- package/kanban/kanban.esm.js +1 -1
- package/kanban/kanban.umd.js +2 -3
- package/layout/dockinglayout.d.ts +2 -0
- package/layout/layout.d.ts +2 -0
- package/layout/layout.esm.js +1 -1
- package/layout/layout.umd.js +2 -3
- package/layout/layoutgroup.d.ts +2 -0
- package/layout/layoutitem.d.ts +2 -0
- package/layout/tablayoutgroup.d.ts +2 -0
- package/layout/tablayoutitem.d.ts +2 -0
- package/led/led.d.ts +2 -0
- package/led/led.esm.js +1 -1
- package/led/led.umd.js +2 -3
- package/listbox/listbox.d.ts +2 -0
- package/listbox/listbox.esm.js +1 -1
- package/listbox/listbox.umd.js +2 -3
- package/listmenu/listmenu.d.ts +2 -0
- package/listmenu/listmenu.esm.js +1 -1
- package/listmenu/listmenu.umd.js +2 -3
- package/map/map.d.ts +2 -0
- package/map/map.esm.js +1 -1
- package/map/map.umd.js +2 -3
- package/maskedtextbox/maskedtextbox.d.ts +2 -0
- package/maskedtextbox/maskedtextbox.esm.js +1 -1
- package/maskedtextbox/maskedtextbox.umd.js +2 -3
- package/menu/listmenu.d.ts +2 -0
- package/menu/menu.d.ts +2 -0
- package/menu/menu.esm.js +1 -1
- package/menu/menu.umd.js +2 -3
- package/menu/menuitem.d.ts +2 -0
- package/menu/menuitemsgroup.d.ts +2 -0
- package/multicolumnfilterpanel/multicolumnfilterpanel.d.ts +2 -0
- package/multicolumnfilterpanel/multicolumnfilterpanel.esm.js +1 -1
- package/multicolumnfilterpanel/multicolumnfilterpanel.umd.js +2 -3
- package/multicomboinput/multicomboinput.d.ts +2 -0
- package/multicomboinput/multicomboinput.esm.js +1 -1
- package/multicomboinput/multicomboinput.umd.js +2 -3
- package/multiinput/multiinput.d.ts +2 -0
- package/multiinput/multiinput.esm.js +1 -1
- package/multiinput/multiinput.umd.js +2 -3
- package/multilinetextbox/multilinetextbox.d.ts +2 -0
- package/multilinetextbox/multilinetextbox.esm.js +1 -1
- package/multilinetextbox/multilinetextbox.umd.js +2 -3
- package/multilinewindow/multilinewindow.d.ts +2 -0
- package/multilinewindow/multilinewindow.esm.js +1 -1
- package/multilinewindow/multilinewindow.umd.js +2 -3
- package/multisplitbutton/multisplitbutton.d.ts +2 -0
- package/multisplitbutton/multisplitbutton.esm.js +1 -1
- package/multisplitbutton/multisplitbutton.umd.js +2 -3
- package/numberinput/numberinput.d.ts +2 -0
- package/numberinput/numberinput.esm.js +1 -1
- package/numberinput/numberinput.umd.js +2 -3
- package/numerictextbox/numerictextbox.d.ts +2 -0
- package/numerictextbox/numerictextbox.esm.js +1 -1
- package/numerictextbox/numerictextbox.umd.js +2 -3
- package/package.json +1 -1
- package/pager/pager.d.ts +2 -0
- package/pager/pager.esm.js +1 -1
- package/pager/pager.umd.js +2 -3
- package/passwordinput/passwordinput.d.ts +2 -0
- package/passwordinput/passwordinput.esm.js +1 -1
- package/passwordinput/passwordinput.umd.js +2 -3
- package/passwordtextbox/passwordtextbox.d.ts +2 -0
- package/passwordtextbox/passwordtextbox.esm.js +1 -1
- package/passwordtextbox/passwordtextbox.umd.js +2 -3
- package/path/path.d.ts +2 -0
- package/path/path.esm.js +1 -1
- package/path/path.umd.js +2 -3
- package/phoneinput/phoneinput.d.ts +2 -0
- package/phoneinput/phoneinput.esm.js +1 -1
- package/phoneinput/phoneinput.umd.js +2 -3
- package/pivottable/pivottable.d.ts +2 -0
- package/pivottable/pivottable.esm.js +1 -1
- package/pivottable/pivottable.umd.js +2 -3
- package/progressbar/circularprogressbar.d.ts +2 -0
- package/progressbar/progressbar.d.ts +2 -0
- package/progressbar/progressbar.esm.js +1 -1
- package/progressbar/progressbar.umd.js +2 -3
- package/progresswindow/progresswindow.d.ts +2 -0
- package/progresswindow/progresswindow.esm.js +1 -1
- package/progresswindow/progresswindow.umd.js +2 -3
- package/promptwindow/promptwindow.d.ts +2 -0
- package/promptwindow/promptwindow.esm.js +1 -1
- package/promptwindow/promptwindow.umd.js +2 -3
- package/qrcode/qrcode.d.ts +2 -0
- package/qrcode/qrcode.esm.js +1 -1
- package/qrcode/qrcode.umd.js +2 -3
- package/querybuilder/querybuilder.d.ts +2 -0
- package/querybuilder/querybuilder.esm.js +1 -1
- package/querybuilder/querybuilder.umd.js +2 -3
- package/radiobutton/radiobutton.d.ts +2 -0
- package/radiobutton/radiobutton.esm.js +1 -1
- package/radiobutton/radiobutton.umd.js +2 -3
- package/rating/rating.d.ts +2 -0
- package/rating/rating.esm.js +1 -1
- package/rating/rating.umd.js +2 -3
- package/ribbon/ribbon.d.ts +2 -0
- package/ribbon/ribbon.esm.js +1 -1
- package/ribbon/ribbon.umd.js +2 -3
- package/ribbon/ribbongroup.d.ts +2 -0
- package/ribbon/ribbonitem.d.ts +2 -0
- package/ribbon/ribbontab.d.ts +2 -0
- package/scheduler/scheduler.d.ts +2 -0
- package/scheduler/scheduler.esm.js +1 -1
- package/scheduler/scheduler.umd.js +2 -3
- package/scrollbar/scrollbar.d.ts +2 -0
- package/scrollbar/scrollbar.esm.js +1 -1
- package/scrollbar/scrollbar.umd.js +2 -3
- package/slider/slider.d.ts +2 -0
- package/slider/slider.esm.js +1 -1
- package/slider/slider.umd.js +2 -3
- package/sortable/sortable.d.ts +2 -0
- package/sortable/sortable.esm.js +1 -1
- package/sortable/sortable.umd.js +2 -3
- package/sortpanel/sortpanel.d.ts +2 -0
- package/sortpanel/sortpanel.esm.js +1 -1
- package/sortpanel/sortpanel.umd.js +2 -3
- package/source/modules/smart.3dchart.js +1 -1
- package/source/modules/smart.accordion.js +1 -1
- package/source/modules/smart.array.js +1 -1
- package/source/modules/smart.barcode.js +1 -1
- package/source/modules/smart.breadcrumb.js +1 -1
- package/source/modules/smart.button.js +1 -1
- package/source/modules/smart.buttongroup.js +1 -1
- package/source/modules/smart.calendar.js +3 -3
- package/source/modules/smart.card.js +1 -1
- package/source/modules/smart.cardview.js +5 -5
- package/source/modules/smart.carousel.js +1 -1
- package/source/modules/smart.chart.js +2 -2
- package/source/modules/smart.checkbox.js +1 -1
- package/source/modules/smart.checkinput.js +2 -2
- package/source/modules/smart.chip.js +1 -1
- package/source/modules/smart.colorinput.js +2 -2
- package/source/modules/smart.colorpanel.js +1 -1
- package/source/modules/smart.colorpicker.js +1 -1
- package/source/modules/smart.combobox.js +1 -1
- package/source/modules/smart.common.js +3 -3
- package/source/modules/smart.countryinput.js +2 -2
- package/source/modules/smart.dateinput.js +3 -3
- package/source/modules/smart.daterangeinput.js +3 -3
- package/source/modules/smart.datetimepicker.js +3 -3
- package/source/modules/smart.dockinglayout.js +1 -1
- package/source/modules/smart.dropdownbutton.js +1 -1
- package/source/modules/smart.dropdownlist.js +1 -1
- package/source/modules/smart.editor.js +2 -2
- package/source/modules/smart.element.js +1 -1
- package/source/modules/smart.fileupload.js +1 -1
- package/source/modules/smart.form.js +3 -3
- package/source/modules/smart.formulaparser.js +1 -1
- package/source/modules/smart.ganttchart.js +6 -6
- package/source/modules/smart.gauge.js +1 -1
- package/source/modules/smart.grid.js +15 -15
- package/source/modules/smart.gridpanel.js +5 -5
- package/source/modules/smart.input.js +2 -2
- package/source/modules/smart.kanban.js +5 -5
- package/source/modules/smart.layout.js +1 -1
- package/source/modules/smart.led.js +1 -1
- package/source/modules/smart.listbox.js +1 -1
- package/source/modules/smart.listmenu.js +1 -1
- package/source/modules/smart.map.js +1 -1
- package/source/modules/smart.maskedtextbox.js +2 -2
- package/source/modules/smart.menu.js +1 -1
- package/source/modules/smart.multicomboinput.js +2 -2
- package/source/modules/smart.multiinput.js +2 -2
- package/source/modules/smart.multilinetextbox.js +1 -1
- package/source/modules/smart.multisplitbutton.js +1 -1
- package/source/modules/smart.numberinput.js +2 -2
- package/source/modules/smart.numerictextbox.js +1 -1
- package/source/modules/smart.pager.js +2 -2
- package/source/modules/smart.passwordinput.js +2 -2
- package/source/modules/smart.passwordtextbox.js +2 -2
- package/source/modules/smart.path.js +1 -1
- package/source/modules/smart.phoneinput.js +2 -2
- package/source/modules/smart.pivottable.js +6 -6
- package/source/modules/smart.progressbar.js +1 -1
- package/source/modules/smart.qrcode.js +1 -1
- package/source/modules/smart.querybuilder.js +3 -3
- package/source/modules/smart.radiobutton.js +1 -1
- package/source/modules/smart.rating.js +1 -1
- package/source/modules/smart.ribbon.js +2 -2
- package/source/modules/smart.router.js +2 -2
- package/source/modules/smart.scheduler.js +5 -5
- package/source/modules/smart.scrollbar.js +1 -1
- package/source/modules/smart.slider.js +1 -1
- package/source/modules/smart.sortable.js +1 -1
- package/source/modules/smart.splitter.js +1 -1
- package/source/modules/smart.switchbutton.js +1 -1
- package/source/modules/smart.table.js +4 -4
- package/source/modules/smart.tabs.js +1 -1
- package/source/modules/smart.tank.js +1 -1
- package/source/modules/smart.textarea.js +3 -3
- package/source/modules/smart.textbox.js +1 -1
- package/source/modules/smart.timeinput.js +2 -2
- package/source/modules/smart.timepicker.js +1 -1
- package/source/modules/smart.toast.js +1 -1
- package/source/modules/smart.tooltip.js +1 -1
- package/source/modules/smart.tree.js +2 -2
- package/source/modules/smart.validator.js +1 -1
- package/source/modules/smart.window.js +1 -1
- package/source/smart.3dchart.js +1 -1
- package/source/smart.accordion.js +1 -1
- package/source/smart.ajax.js +1 -1
- package/source/smart.array.js +1 -1
- package/source/smart.barcode.js +1 -1
- package/source/smart.bootstrap.js +1 -1
- package/source/smart.breadcrumb.js +1 -1
- package/source/smart.button.js +1 -1
- package/source/smart.buttongroup.js +1 -1
- package/source/smart.calendar.js +2 -2
- package/source/smart.card.js +1 -1
- package/source/smart.cardview.js +1 -1
- package/source/smart.carousel.js +1 -1
- package/source/smart.chart.annotations.js +1 -1
- package/source/smart.chart.api.js +1 -1
- package/source/smart.chart.core.js +1 -1
- package/source/smart.chart.js +1 -1
- package/source/smart.chart.rangeselector.js +1 -1
- package/source/smart.chart.waterfall.js +1 -1
- package/source/smart.checkbox.js +1 -1
- package/source/smart.checkinput.js +1 -1
- package/source/smart.chip.js +1 -1
- package/source/smart.colorinput.js +1 -1
- package/source/smart.colorpanel.js +1 -1
- package/source/smart.colorpicker.js +1 -1
- package/source/smart.combobox.js +1 -1
- package/source/smart.complex.js +1 -1
- package/source/smart.core.js +1 -1
- package/source/smart.countryinput.js +1 -1
- package/source/smart.data.js +2 -2
- package/source/smart.date.js +1 -1
- package/source/smart.dateformatpanel.js +1 -1
- package/source/smart.dateinput.js +1 -1
- package/source/smart.daterangeinput.js +1 -1
- package/source/smart.datetimepicker.js +1 -1
- package/source/smart.dockinglayout.js +1 -1
- package/source/smart.draw.js +1 -1
- package/source/smart.dropdownbutton.js +1 -1
- package/source/smart.dropdownlist.js +1 -1
- package/source/smart.editor.js +1 -1
- package/source/smart.element.js +1 -1
- package/source/smart.elements.js +16 -16
- package/source/smart.export.js +1 -1
- package/source/smart.fileupload.js +1 -1
- package/source/smart.filter.js +2 -2
- package/source/smart.filterbuilder.js +1 -1
- package/source/smart.filterpanel.js +2 -2
- package/source/smart.form.js +1 -1
- package/source/smart.format.js +1 -1
- package/source/smart.formulaparser.js +1 -1
- package/source/smart.ganttchart.js +2 -2
- package/source/smart.gauge.js +1 -1
- package/source/smart.grid.cell.js +2 -2
- package/source/smart.grid.chart.js +1 -1
- package/source/smart.grid.column.js +2 -2
- package/source/smart.grid.core.js +2 -2
- package/source/smart.grid.dialog.js +2 -2
- package/source/smart.grid.edit.js +2 -2
- package/source/smart.grid.export.js +1 -1
- package/source/smart.grid.filter.js +1 -1
- package/source/smart.grid.group.js +1 -1
- package/source/smart.grid.js +1 -1
- package/source/smart.grid.menu.js +1 -1
- package/source/smart.grid.pager.js +1 -1
- package/source/smart.grid.reorder.js +1 -1
- package/source/smart.grid.resize.js +1 -1
- package/source/smart.grid.row.js +2 -2
- package/source/smart.grid.select.js +2 -2
- package/source/smart.grid.sort.js +1 -1
- package/source/smart.grid.toolbar.js +1 -1
- package/source/smart.grid.tree.js +1 -1
- package/source/smart.grid.view.js +1 -1
- package/source/smart.gridpanel.js +1 -1
- package/source/smart.input.js +2 -2
- package/source/smart.kanban.js +1 -1
- package/source/smart.layout.js +1 -1
- package/source/smart.led.js +1 -1
- package/source/smart.listbox.js +1 -1
- package/source/smart.listmenu.js +1 -1
- package/source/smart.map.js +1 -1
- package/source/smart.maskedtextbox.js +1 -1
- package/source/smart.math.js +1 -1
- package/source/smart.menu.js +1 -1
- package/source/smart.multicomboinput.js +1 -1
- package/source/smart.multiinput.js +1 -1
- package/source/smart.multilinetextbox.js +1 -1
- package/source/smart.multisplitbutton.js +1 -1
- package/source/smart.numberformatpanel.js +1 -1
- package/source/smart.numberinput.js +1 -1
- package/source/smart.numeric.js +1 -1
- package/source/smart.numerictextbox.js +1 -1
- package/source/smart.pager.js +1 -1
- package/source/smart.passwordinput.js +1 -1
- package/source/smart.passwordtextbox.js +1 -1
- package/source/smart.path.js +1 -1
- package/source/smart.phoneinput.js +1 -1
- package/source/smart.pivottable.js +1 -1
- package/source/smart.powerbutton.js +1 -1
- package/source/smart.progressbar.js +1 -1
- package/source/smart.qrcode.js +1 -1
- package/source/smart.radiobutton.js +1 -1
- package/source/smart.rating.js +1 -1
- package/source/smart.ribbon.js +1 -1
- package/source/smart.router.js +1 -1
- package/source/smart.scheduler.js +1 -1
- package/source/smart.scrollbar.js +1 -1
- package/source/smart.slider.js +1 -1
- package/source/smart.sortable.js +1 -1
- package/source/smart.sparkline.js +6 -0
- package/source/smart.splitter.js +1 -1
- package/source/smart.switchbutton.js +1 -1
- package/source/smart.table.js +1 -1
- package/source/smart.tabs.js +1 -1
- package/source/smart.tank.js +1 -1
- package/source/smart.textarea.js +2 -2
- package/source/smart.textbox.js +1 -1
- package/source/smart.tickintervalhandler.js +1 -1
- package/source/smart.timeinput.js +1 -1
- package/source/smart.timepicker.js +1 -1
- package/source/smart.toast.js +1 -1
- package/source/smart.tooltip.js +1 -1
- package/source/smart.tree.js +2 -2
- package/source/smart.validationpanel.js +1 -1
- package/source/smart.validator.js +1 -1
- package/source/smart.window.js +1 -1
- package/source/styles/components/smart.grid.css +1 -1
- package/source/styles/components/smart.validator.css +1 -1
- package/source/styles/default/scss/smart.grid.scss +230 -168
- package/source/styles/default/scss/smart.validator.scss +1 -0
- package/source/styles/default/smart.grid.css +48 -9
- package/source/styles/default/smart.validator.css +123 -121
- package/source/styles/smart.default.css +2 -2
- package/source/typescript/smart.calendar.d.ts +5 -0
- package/source/typescript/smart.elements.d.ts +54 -3
- package/source/typescript/smart.grid.d.ts +33 -3
- package/source/typescript/smart.textarea.d.ts +5 -0
- package/source/typescript/smart.tree.d.ts +11 -0
- package/splitter/splitter.d.ts +2 -0
- package/splitter/splitter.esm.js +1 -1
- package/splitter/splitter.umd.js +2 -3
- package/splitter/splitterbar.d.ts +2 -0
- package/splitter/splitteritem.d.ts +2 -0
- package/switchbutton/switchbutton.d.ts +2 -0
- package/switchbutton/switchbutton.esm.js +1 -1
- package/switchbutton/switchbutton.umd.js +2 -3
- package/table/pivottable.d.ts +2 -0
- package/table/sortable.d.ts +2 -0
- package/table/table.d.ts +2 -0
- package/table/table.esm.js +1 -1
- package/table/table.umd.js +2 -3
- package/tabs/tabs.d.ts +2 -0
- package/tabs/tabs.esm.js +1 -1
- package/tabs/tabs.umd.js +2 -3
- package/tabs/tabswindow.d.ts +2 -0
- package/tabswindow/tabswindow.d.ts +2 -0
- package/tabswindow/tabswindow.esm.js +1 -1
- package/tabswindow/tabswindow.umd.js +2 -3
- package/tank/tank.d.ts +2 -0
- package/tank/tank.esm.js +1 -1
- package/tank/tank.umd.js +2 -3
- package/textarea/textarea.d.ts +7 -0
- package/textarea/textarea.esm.js +13 -2
- package/textarea/textarea.umd.js +14 -4
- package/textbox/maskedtextbox.d.ts +2 -0
- package/textbox/multilinetextbox.d.ts +2 -0
- package/textbox/numerictextbox.d.ts +2 -0
- package/textbox/passwordtextbox.d.ts +2 -0
- package/textbox/textbox.d.ts +2 -0
- package/textbox/textbox.esm.js +1 -1
- package/textbox/textbox.umd.js +2 -3
- package/threedchart/threedchart.d.ts +2 -0
- package/threedchart/threedchart.esm.js +1 -1
- package/threedchart/threedchart.umd.js +2 -3
- package/timeinput/timeinput.d.ts +2 -0
- package/timeinput/timeinput.esm.js +1 -1
- package/timeinput/timeinput.umd.js +2 -3
- package/timepicker/datetimepicker.d.ts +2 -0
- package/timepicker/timepicker.d.ts +2 -0
- package/timepicker/timepicker.esm.js +1 -1
- package/timepicker/timepicker.umd.js +2 -3
- package/toast/toast.d.ts +2 -0
- package/toast/toast.esm.js +1 -1
- package/toast/toast.umd.js +2 -3
- package/tooltip/tooltip.d.ts +2 -0
- package/tooltip/tooltip.esm.js +1 -1
- package/tooltip/tooltip.umd.js +2 -3
- package/tree/tree.d.ts +12 -0
- package/tree/tree.esm.js +9 -2
- package/tree/tree.umd.js +10 -4
- package/tree/treeitem.d.ts +2 -0
- package/tree/treeitemsgroup.d.ts +2 -0
- package/validator/validator.d.ts +2 -0
- package/validator/validator.esm.js +1 -1
- package/validator/validator.umd.js +2 -3
- package/waitwindow/waitwindow.d.ts +2 -0
- package/waitwindow/waitwindow.esm.js +1 -1
- package/waitwindow/waitwindow.umd.js +2 -3
- package/window/alertwindow.d.ts +2 -0
- package/window/dialogwindow.d.ts +2 -0
- package/window/multilinewindow.d.ts +2 -0
- package/window/progresswindow.d.ts +2 -0
- package/window/promptwindow.d.ts +2 -0
- package/window/tabswindow.d.ts +2 -0
- package/window/waitwindow.d.ts +2 -0
- package/window/window.d.ts +2 -0
- package/window/window.esm.js +1 -1
- package/window/window.umd.js +2 -3
|
@@ -70,7 +70,7 @@ Smart("smart-button-group",class extends Smart.ContentElement{static get propert
|
|
|
70
70
|
/***/ 5810:
|
|
71
71
|
/***/ (() => {
|
|
72
72
|
|
|
73
|
-
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")&&t._dragStartDetails&&(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)}});
|
|
73
|
+
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"},disableMouseWheel:{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;if(t.disableMouseWheel)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")&&t._dragStartDetails&&(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)}});
|
|
74
74
|
|
|
75
75
|
/***/ }),
|
|
76
76
|
|
|
@@ -98,7 +98,7 @@ Smart("smart-color-input",class extends Smart.Input{static get properties(){retu
|
|
|
98
98
|
/***/ 6057:
|
|
99
99
|
/***/ (() => {
|
|
100
100
|
|
|
101
|
-
(()=>{Smart.DataAdapter=window.smartDataAdapter=class{constructor(e){e||(e={});const t=Object.assign(this,e);t.key=(65536*(1+Math.random())|0).toString(16).substring(1),t.$document=Smart.Utilities.Extend(document),t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],void 0===t.allowAdd&&(t.allowAdd=!0),void 0===t.allowRemove&&(t.allowRemove=!0),void 0===t.allowUpdate&&(t.allowUpdate=!0),void 0===t.mapChar&&(t.mapChar="."),void 0!==e.observable||t.virtualDataSource?t.observable=!1:t.observable=!0,void 0===t.sanitizeHTML&&(t.sanitizeHTML="blackList"),t._expandedRowIds=[],e.dataSource||(t.dataSource=[]),e.dataFields||(t.dataFields=[]),e.dataSourceType||(t.dataSourceType="array"),e.id||(t.id=null),e.autoFetch||(t.autoFetch=!0),void 0===e.skipFirstRow&&(t.skipFirstRow=!1),e.dataFields&&(t.dataFields=e.dataFields),Object.defineProperty(t,"groupBy",{configurable:!1,enumerable:!0,get:()=>t._groupBy?t._groupBy:[],set(e){const a=()=>{t.boundHierarchy=null,t.refreshHierarchy(),t.onGroup&&t.onGroup()};t._groupBy=new Smart.ObservableArray(e),t._groupBy.notify((function(){a()})),t.isInitialized&&a()}}),e.groupBy?e.groupBy.toArray?t.groupBy=e.groupBy.toArray():t.groupBy=e.groupBy:t.groupBy=[],e&&!1!==e.autoBind&&t.dataBind(),t.isInitialized=!0}beginUpdate(){this.isUpdating=!0}endUpdate(){const e=this;e.isUpdating=!1,e.refreshIndexes(),e.refreshHierarchy()}get expandHierarchy(){return void 0===this._expandHierarchy&&(this._expandHierarchy=!1),this._expandHierarchy}set expandHierarchy(e){const t=this;t._expandHierarchy=e,t.isInitialized&&t.refreshHierarchy()}_getDataField(e){switch(e.name){case"leaf":case"parent":case"expanded":case"checked":case"selected":case"level":case"icon":case"data":case"group":case"children":case"items":e.map?e.map=e.map.replace(e.name,"$"+e.name):e.map=e.name,e.name="$"+e.name}}get dataFields(){return this._dataFields}set dataFields(e){const t=this;return t._dataFields=t._getDataFieldObjects(e),t._dataFields}_getDataFieldObjects(e){const t=this;let a=[];if("number"==typeof e){const t="A".charCodeAt(0);let n="",r=0;for(let i=0;i<e;i++){const e=String.fromCharCode(t+r);r++;const i=n+e;a.push({name:i,dataType:"string"}),r>=26&&(r=0,n+="A")}}else if(Array.isArray(e)&&e.length>0)for(let n=0;n<e.length;n++){const r=e[n];if("string"==typeof r){const e=r.split(":"),t=e[0].trim(),n=e.length>1?e[1].trim():"string";a.push({name:t,dataType:n})}else a.push(r);t._getDataField(a[a.length-1])}return a}get dataSource(){const e=this;return e._dataSource||(e._dataSource=[]),e._dataSource}set dataSource(e){const t=this;t._dataSource=e,t.isInitialized&&(t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],t.bindingCompleted=!1,t.dataBind(),t.refreshIndexes())}get canNotify(){const e=this;return void 0===e._canNotify&&(e._canNotify=!0),e._canNotify}set canNotify(e){this._canNotify=e}_notify(e){const t=this;t.canNotify&&t.notifyFn&&t.notifyFn(e)}notify(e){e&&(this.notifyFn=e)}toArray(){const e=this;return!1===e.observable?e.boundSource:e.boundSource.toArray()}forEach(e){const t=this;if(e)if(t.boundHierarchy&&t.boundHierarchy.length>0){const a=(e=>{let t=[];for(;e;){t=t.concat(e);for(let a=0;a<e.length;a++)e[a].children&&(t=t.concat(e[a].children));e=e.children}return t})(t.boundHierarchy);for(let t=0;t<a.length;t++){e(a[t],t)}}else for(let a=0;a<t.boundSource.length;a++){e(t.boundSource[a],a)}}dataBind(){const t=this;t.bindingCompleted=!1,t.clear();const a=()=>{t.observable&&(t.boundSource.notify||(t.boundSource=new Smart.ObservableArray),t.boundSource.notify((function(e){if("update"===e.action&&e.path&&e.path.indexOf(".")>=0&&-1===e.path.indexOf("children")&&-1===e.path.indexOf("parent")&&-1===e.path.indexOf("loaded")&&-1===e.path.indexOf("level")&&-1===e.path.indexOf("leaf")&&-1===e.path.indexOf("expanded")){let a=!1;for(let n=0;n<t.dataFields.length;n++){const r=t.dataFields[n].name;e.path.indexOf(r)>=0&&(a=!0)}t._notify&&a&&t._notify({action:"update",data:e.target,index:e.index})}}))),t._onBindingComplete()};if("string"==typeof t.dataSource&&(t.dataSource.indexOf(".json")>=0||"json"===t.dataSourceType))t.url=t.dataSource,t.dataSourceType="json",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".xml")>=0)t.url=t.dataSource,t.dataSourceType="xml",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".xlsx")>=0)t.url=t.dataSource,t.dataSourceType="xlsx",new e(t,(e=>{if(!e[0])return e=[],t._bindToArray(),void a();const n=Object.keys(e[0]),r={},i=[];if(!1!==t.exportHeader){let a=0;for(let e in n){r[n[e]]=t.dataFields[a++].name}for(let t=1;t<e.length;t++){const a=e[t],o={};for(let e in n){const t=n[e];o[r[t]]=a[t]}i.push(o)}t.dataSource=i}t._bindToArray(),a()}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".csv")>=0)t.url=t.dataSource,t.dataSourceType="csv",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".tsv")>=0)t.url=t.dataSource,t.dataSourceType="tsv",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&(t.dataSource.indexOf(".ics")>=0||t.dataSource.indexOf(".php")>=0&&"ics"===t.dataSourceType||t.dataSource.indexOf(".txt")>=0&&"ics"===t.dataSourceType))t.url=t.dataSource,t.dataSourceType="ics",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("BEGIN:VCALENDAR")>=0||"ics"===t.dataSourceType))t._bindToICS(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("<?xml")>=0||"xml"===t.dataSourceType))t._bindToXML(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf(" ")>=0||t.dataSource.indexOf(",")>=0||"tsv"===t.dataSourceType||"csv"===t.dataSourceType||"tab"===t.dataSourceType))t._bindToCSV(),a();else if("array"===t.dataSourceType)t._bindToArray(),a();else if("json"===t.dataSourceType){if(t.dataSource&&t.dataSource.url)return t.url=t.dataSource.url,t.dataSource.method&&(t.type=t.dataSource.method),t.dataSource.type&&(t.type=t.dataSource.type),t.dataSource.data&&(t.data=t.dataSource.data),void new e(t,(e=>{t.dataSource=e}));t._bindToJSON(),a()}}_bindToXML(){const e=this;let t=null,a=null;window.DOMParser&&(t=new DOMParser,a=t.parseFromString(e.dataSource,"text/xml")),void 0===e.root&&(e.root=""),void 0===e.record&&(e.record="");const n=a.querySelectorAll(e.root+" "+e.record),r=n.length,i=[];let o=e.dataFields?e.dataFields.length:0;if(0===o){const t=n[0],a=new Array;for(let e in t){const t=e;a[a.length]={name:t}}e.dataFields=a,o=a.length}for(let t=0;t<r;t++){const a=n[t],r={};if(void 0===a)break;if(e.id){const t=a.querySelector(e.id);r[e.id]=t.textContent}for(let t=0;t<o;t++){const n=e.dataFields[t],i=a.querySelector(n.map||n.name);r[n.name]=i.textContent}i[t]=r}e.canNotify=!1,e.dataSource=i,e.canNotify=!0,e._bindToArray()}static BindToCSV(e,t=!1){const a=""+e,n=-1===a.indexOf(",")?"\t":",",r=a.split("\r"),i=new Array,o=[];let d=a.split("\n"),l=d.length;1===l&&r.length>1&&(d=r,l=d.length);const s=!0===t;for(let e=0;e<l;e++){const t={},a=d[e].split(n);for(let n=0;n<a.length;n++){let r=o[n],i=a[n];if(r||(o.push({name:i.trim()}),r=o[o.length-1]),i=i.trim(),1!==e||s)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}t[r.name]=i}(s||e>0)&&i.push(t)}return i}_bindToCSV(){const e=this,t=""+e.dataSource,a=-1===t.indexOf(",")?"\t":",",n=t.split("\r"),r=new Array;let i=t.split("\n"),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=e.dataFields.length>0;for(let t=0;t<o;t++){const n=i[t],o={};let l=i[t].split(a);if(t>0){let e=[],a=0,n=!1,r=i[t];for(let t=0;t<r.length;t++)if('"'===r.charAt(t))n=!n;else if(","===r.charAt(t)&&!n){let n=r.substring(a,t);n=n.trim(),n=n.replaceAll('"',""),e.push(n),a=t+1}let o=r.substring(a);o=o.trim(),o=o.replaceAll('"',""),","===o?e.push('""'):e.push(o),l=e}for(let a=0;a<l.length;a++){let r=e.dataFields[a],i=l[a];if(r||(e.dataFields.push({name:i.trim()}),r=e.dataFields[e.dataFields.length-1]),r.map&&(i=n[r.map]),i=i.trim(),1!==t||d)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/")&&-1===i.indexOf("-"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):i.indexOf(".")>=0&&i.lastIndexOf(".")!==i.indexOf(".")?-1===i.indexOf(",")&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}o[r.map||r.name||a.toString()]=i}0===t&&e.skipFirstRow||(d||t>0)&&r.push(o)}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_onBindingComplete(){const e=this;e._buildHierarchy(),e.onBindingComplete&&e.onBindingComplete({data:e.boundSource}),e._notify&&e._notify({action:"bindingComplete",data:e.boundSource}),e.bindingCompleted=!0}refreshHierarchy(){this.isUpdating||this._buildHierarchy()}find(){return this.boundSource.find.apply(this.boundSource,arguments)}onVirtualDataSourceRequested(e,t){const a=this;let n=t?t.first:1/0,r=t?t.last:1/0,i=t?t.row:null;if(void 0===n&&(n=1/0),void 0===r&&(r=1/0),a.virtualFirstIndex=n,a.virtualLastIndex=r,a.virtualDataSource){const o=function(r){void 0!==r.virtualDataSourceLength&&(a.virtualDataSourceLength=r.virtualDataSourceLength),new Smart.DataAdapter({dataSource:r.dataSource,dataFields:r.dataFields||a.dataFields,data:t,keyDataField:r.keyDataField,parentDataField:r.parentDataField,observable:!1,id:r.id||a.id,onBindingComplete(r){if(void 0===t.result&&(t.result=!0),t.data=r.data,a.virtualDataSourceOnExpand&&i)return a.groupBy.length>0?r.data&&r.data.length>0&&a.add(r.data):r.data&&r.data.length>0?a.add(r.data,i.$.id):i.leaf=!0,a.onFilter&&a.onFilter(),void e(t);n===1/0&&"scroll"===t.action?r.data&&r.data.length&&a.add(r.data):"filter"===t.action||"group"===t.action?(a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0):("add"===t.action||"update"===t.action||t.action,a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0),a.onFilter&&a.onFilter(),e(t)}})};let d={};if(t.sorting&&t.sorting.length>0){let e=[];for(let a in t.sorting)e.push(a+" "+t.sorting[a].sortOrder.toUpperCase());const a=" ORDER BY "+e.join(", ");d.orderBy=a}else d.orderBy="";if(void 0===n||void 0===r||0===n&&0===r)d.limit="";else{const e=r-n,t=" LIMIT "+e+" OFFSET "+n;d.limit=t,isNaN(e)&&(d.limit="")}if(t.grouping&&t.grouping.length>0){const e=" GROUP BY "+t.grouping[0];d.groupBy=e}else d.groupBy="";if(t.filtering&&t.filtering.length>0){const e=(e,t)=>{switch(t.condition){case"EMPTY":return e+" = ''";case"NOT_EMPTY":return e+" != ''";case"EQUAL":return e+" = '"+t.value+"'";case"NOT_EQUAL":return e+" != '"+t.value+"'";case"CONTAINS_CASE_SENSITIVE":case"CONTAINS":return e+" LIKE '%"+t.value+"%'";case"DOES_NOT_CONTAIN_CASE_SENSITIVE":case"DOES_NOT_CONTAIN":return e+" NOT LIKE '%"+t.value+"%'";case"STARTS_WITH_CASE_SENSITIVE":case"STARTS_WITH":return e+" LIKE '"+t.value+"%'";case"ENDS_WITH_CASE_SENSITIVE":case"ENDS_WITH":return e+" LIKE '%"+t.value+"'";case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL"}},a=(e,t)=>{let a=t.value,n=t.valueTo;if(a&&a instanceof Date){a=`'${new Smart.Utilities.DateTime(a).toString("yyyy-MM-dd")}'`}if(t.valueTo&&t.valueTo instanceof Date){n=`'${new Smart.Utilities.DateTime(n).toString("yyyy-MM-dd")}'`}switch(t.condition){case"EQUAL":return e+" = "+a;case"NOT_EQUAL":return e+" != "+a;case"GREATER_THAN":return e+" > "+a;case"GREATER_THAN_OR_EQUAL":return e+" >= "+a;case"LESS_THAN":return e+" < "+a;case"LESS_THAN_OR_EQUAL":return e+" <= "+a;case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL";case"RANGE":return"("+e+" >= "+a+" and "+e+" <= "+n+")"}},n=(e,t,a)=>{if(a.operator){var n=e(t,a.condition1),r=e(t,a.condition2);return"("+n+" "+a.operator+" "+r+")"}return e(t,a)};let r=[];for(let i in t.filtering){const o=t.filtering[i];let d=o.filters,l=[],s=" AND ";for(let t=0;t<d.length;t++){const r=d[t];switch(r.type){case"stringFilter":l.push(n(e,i,r));break;case"numericFilter":case"dateFilter":case"booleanFilter":l.push(n(a,i,r))}1!==o.logicalOperators[t]&&"or"!==o.logicalOperators[t]||(s=" OR ")}l.length&&r.push("("+l.join(s)+")")}if(r.length>0){let e=" AND ";t.filterOperator&&"or"===t.filterOperator.toLowerCase()&&(e=" OR "),d.where=" WHERE "+r.join(e).replace(/</g,"<").replace(/>/g,">")}else d.where=""}else d.where="";if("dataBind"===t.action&&a.virtualDataSourceOnExpand&&a.keyDataField&&a.parentDataField&&(d.where?d.where+=" AND "+a.parentDataField+" IS NULL":d.where=" WHERE "+a.parentDataField+" IS NULL"),"update"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+"='"+t.edit.row[n].replace(/</g,"<").replace(/>/g,">")+"'");null===a.id?d.update=" SET "+e.join(", "):d.update=" SET "+e.join(", ")+" WHERE "+a.id+"="+t.edit.row[a.id]}if("remove"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+" = '"+t.edit.row[n]+"'");d.remove=" WHERE "+a.id+"="+t.edit.row[a.id]}if("add"===t.action){const e=[],a=[];for(let n in t.edit.row)"$"!==n&&(a.push(n),null!==t.edit.row[n]?e.push("'"+t.edit.row[n]+"'"):e.push("null"));d.add=" ("+a.join(", ")+") VALUES ("+e.join(", ")+")"}"expand"===t.action?(a.groupDataField?d.where?d.where+=" AND "+a.groupDataField+" = '"+i[a.groupDataField]+"'":d.where=" WHERE "+a.groupDataField+" = '"+i[a.groupDataField]+"'":a.keyDataField&&a.parentDataField?d.where?d.where+=" AND "+a.parentDataField+" = "+i[a.keyDataField]:d.where=" WHERE "+a.parentDataField+" = "+i[a.keyDataField]:d.where?d.where+=" AND "+i.groupDataField+" = '"+i.label+"'":d.where=" WHERE "+i.groupDataField+" = '"+i.label+"'",d.where.indexOf("undefined")>=0&&(d.where=""),d.limit="",d.groupBy="",a.virtualDataSourceOnExpand(o,{first:n,last:r,row:t.row,sorting:t.sorting,filtering:t.filtering,grouping:t.grouping,action:t.action,query:d})):a.virtualDataSource(o,{first:n,last:r,sorting:t.sorting,edit:t.edit,filtering:t.filtering,filterOperator:t.filterOperator||"and",grouping:t.grouping,action:t.action,query:d})}else e()}add(e,t){const a=this;if(!e)return;let n=!0;const r=function(e){const r=a._getDataItem(e,a.boundSource.length);if(a.dataItemById[r.$.id])return void 0!==t&&(r.$.parentId=t),null;a[a.boundSource.length]=r,a.dataItemById[r.$.id]=r;const i=a.boundSource.push(r);return void 0!==t&&(r.$.parentId=t),i||(n=!1),r};if(e.length){let t=[];for(let a=0;a<e.length;a++){const n=r(e[a]);n&&t.push(n)}a._notify({action:"add",data:t})}else{const t=r(e);a._notify({action:"add",data:t})}return a.refreshHierarchy(),n}refreshIndexes(){const e=this;for(let t=0;t<e.boundSource.length;t++)e[t]=e.boundSource[t],e[t].$.index=t,e.dataItemById[e[t].$.id]=e[t];let t=e.boundSource.length;for(;e[t];)delete e[t],t++}removeLast(){const e=this;delete e[e.boundSource.length-1];const t=e.boundSource.pop();return delete e.dataItemById[t.$.id],e._notify({action:"removeLast",data:t}),e.refreshHierarchy(),t}removeById(e){const t=this,a=t.indexOf(t.dataItemById[e]);t.boundSource[a]&&t.removeAt(a)}remove(e){const t=this;let a=t.indexOf(e);-1===a&&e&&e.$&&(a=t.indexOf(t.dataItemById[e.$.id]));t.boundSource[a]&&t.removeAt(a)}removeAt(e){const t=this,a=t.boundSource[e];if(!a)throw new Error("Invalid Item Index");t.boundSource.splice(e,1),delete t.dataItemById[a.$.id],t.refreshIndexes(),t._notify({action:"remove",index:e,data:a}),t.refreshHierarchy()}update(e,t){const a=this;if(Smart.Utilities.Types.isArray(e)&&Smart.Utilities.Types.isArray(t)&&0===e.length&&0===t.length)return void a.refreshHierarchy();if(t.length&&e.length){let n=[];for(let r=0;r<e.length;r++){const i=a._getDataItem(t[r],e[r]),o=e[r];n.push(i),a.boundSource[o]=i,a[o]=a.boundSource[o],a.dataItemById[i.$.id]=a[o]}return a._notify({action:"update",index:e,data:n}),void a.refreshHierarchy()}const n=a._getDataItem(t,e),r=a.boundSource[e].$.id;return n.$.id=r,a.boundSource[e]=n,a[e]=a.boundSource[e],a.dataItemById[n.$.id]=a[e],a._notify({action:"update",index:e,data:n}),a.refreshHierarchy(),n}insert(e,t){const a=this;if(t.length){const n=[];for(let r=0;r<t.length;r++){const i=a._getDataItem(t[r],e+r);n.push(i)}t=n}else t=a._getDataItem(t,e);const n=a.boundSource.splice(e,0,t);return a.refreshIndexes(),a._notify({action:"insert",index:e,data:t}),a.refreshHierarchy(),n}move(e,t){if(t>e&&t-e==1||e===t)return;const a=this,n=a.boundSource.splice(e,1)[0];t>e?(t--,a.boundSource.splice(t,0,n)):a.boundSource.splice(t,0,n),a.refreshIndexes(),a._notify({action:"move",index:t,data:a.boundSource[t]}),a.refreshHierarchy()}indexOf(e){return this.boundSource.indexOf(e)}get length(){const e=this;return void 0!==e.virtualDataSourceLength?e.virtualDataSourceLength:e.dataSourceLength?e.dataSourceLength:"number"==typeof e.dataSource?e.dataSource:e.bindingCompleted?e.boundSource.length:e.dataSource&&"string"!=typeof e.dataSource&&e.dataSource.length?e.dataSource.length:e.boundSource.length}clear(){const e=this;if(!e.isInitialized)return e._cachedValues=[],void(e.dataItemById=[]);for(let t=0;t<e.boundSource.length;t++)delete e[t];e._expandedRowIds=[],e._cachedValues=[],e.boundSource=e.observable?new Smart.ObservableArray:[],e.dataItemById=[],e.refreshHierarchy()}_getId(e,t,a){if(null===e||void 0===e.name||!e.name||!t.getAttribute){if(e&&e.toString().length>0&&t.getAttribute){let a=t.getAttribute(e);if(null!==a&&a.toString().length>0)return a.trim().split(" ").join("").replace(/([ #;?%&,.+*~\':'!^$[\]()=>|\/@])/g,"");{let a=e.split(this.mapChar);if(a.length>1){let e=t;for(let t=0;t<a.length;t++)void 0!==e&&(e=e[a[t]]);if(void 0!==e)return e}else if(void 0!==t[e])return t[e]}}return a}{let n=t.getAttribute(e.name);if(null!==n&&n.toString().length>0)return n;if(e.map)try{let a=t.getAttribute(e.map);if(null!==a&&a.toString().length>0)return a}catch(e){return a}}}_buildHierarchy(){const e=this;if(e.reservedNames){const t=e.reservedNames;t.leaf||(t.leaf="leaf"),t.parent||(t.parent="parent"),t.expanded||(t.expanded="expanded"),t.checked||(t.checked="checked"),t.selected||(t.selected="selected"),t.level||(t.level="level"),t.data||(t.data="data")}else e.reservedNames={leaf:"leaf",parent:"parent",expanded:"expanded",checked:"checked",selected:"selected",level:"level",icon:"icon",data:"data"};const t=e.reservedNames;if(e.childrenDataField){const a=[];for(let n=0;n<e.boundSource.length;n++){const r=JSON.parse(JSON.stringify(e.boundSource[n]));if(!r)continue;a.push(r);const i=function(a){const n=e.childrenDataField.split(e.mapChar);let r=null;if(n.length>1){let e=a;for(let t=0;t<n.length;t++)void 0!==e&&(e=e[n[t]]);r=e}else r=a.children;a.children=r,(null===a.children||void 0===a.children||a.children&&0===a.children.length)&&(a[t.leaf]=!0)};i(r),r[t.level]=0,r.$||(r.$={}),r[t.parent]=null,r[t.data]=r,void 0===r[t.expanded]&&(r[t.expanded]=!1,e.expandHierarchy&&(r[t.expanded]=!0));const o=function(a,n){if(n)for(let r=0;r<n.length;r++){let d=e._getDataItem(n[r],r);if(d){if(i(d),!e.id){const e=function(){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()};d.$.id=e()}d[t.level]=a[t.level]+1,d[t.parent]=a,d[t.data]=Object.assign({},d),a&&(a.children[r]=d),void 0===d[t.expanded]&&(d[t.expanded]=!1,e.expandHierarchy&&(d[t.expanded]=!0)),o(d,d.children)}}else a.children=new Array};o(r,r.children)}if(e.boundHierarchy=a,!e._boundSourceUpdate){for(let t=0;t<e.boundHierarchy.length;t++){const a=e.boundHierarchy[t];if(a.children){const t=function(a){if(e.dataItemById[a.$.id]||(e.boundSource.canNotify=!1,e.dataItemById[a.$.id]=a,e.boundSource.canNotify=!0),a.children)for(let e=0;e<a.children.length;e++){const n=a.children[e];n.children&&t(n)}};t(a)}}e._boundSourceUpdate=!0}}if(e.xmlRoot&&"xml"===e.dataSourceType&&(e.boundHierarchy=this._getHierarchy("uid","_parentuid","children",null,e.boundSource)),e.keyDataField&&e.parentDataField)return["keyDataField","parentDataField"].forEach((t=>{switch(e[t]){case"parent":e[t]="$"+e[t]}})),void(e.boundHierarchy=this._getHierarchy(e.keyDataField,e.parentDataField,"children",null,e.boundSource));e.groupBy&&e.groupBy.length>0?e.boundHierarchy=this._getGroupHierarchy(e.groupBy,"children","label",null,"data",null,"parent",e.boundSource):e.virtualDataSourceOnExpand&&(e.boundHierarchy=this._getHierarchy("id","parentId","children",null,e.boundSource))}_getGroupHierarchy(e,t,a,n,r,i,o,d,l){let s=this;l||(l=0);let c=s.reservedNames;const u=s.boundSource.canNotify;s.boundSource.canNotify=!1;const f=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()};let h=new Array;for(let t=0;t<e.length;t++)h[t]=f();t||(t="children"),a||(a="group"),r||(r="item"),o||(o="parent"),void 0===i&&(i="value");const p=new Array,g=new Array;let S=0;const y=function(t){let a=t;for(let n=0;n<e.length;n++){if(void 0===t[e[n]]){a=s._getDataItem(t,t.$.index);break}}if(n)for(let e in n){const t=n[e];t.name&&t.map&&(a[t.map]=a[t.name])}return a};let m=!1;for(let n=0;n<d.length;n++){let u=y(d[n]);u[c.leaf]=!1;let T=new Array,b=0;for(let t=0;t<e.length;t++){const a=e[t],n=u[a];null!=n?((""===n||void 0===n&&0===t)&&(m=!0),T[b++]={value:n,group:a,hash:h[t]}):(T[b++]={value:null,group:a,hash:h[t]},0===t&&(m=!0))}if(T.length!==e.length)break;let x=null,v="";for(let e=0;e<T.length;e++){const n=T[e].value,d=T[e].group;if(v=v+"_"+T[e].hash+"_"+n,void 0===g[v]||null===g[v]){if(null===x){x={$:{}},x[c.level]=0,x[c.leaf]=!1,x[o]=null,x[a]=n,x[r]=u,x.groupDataField=d,x[d]||(x[d]=x.data[d]),void 0!==u[c.expanded]?x[c.expanded]=u[c.expanded]:(x[c.expanded]=!1,s.expandHierarchy&&(x[c.expanded]=!0)),i&&(x[i]=u[i]),x[t]=new Array;let e=p.length+l;this.id&&"number"!=typeof u.$.id&&!isFinite(u.$.id)||(e="Item"+e),void 0===x.$.id&&(x.$.id=e),s._expandedRowIds[x.$.id]&&(x[c.expanded]=!0),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[x.$.id]&&(x[c.expanded]=!1),p[S++]=x}else{const e={$:{}};e[c.level]=x[c.level]+1,e[o]=x,e[a]=n,e[t]=new Array,e[r]=u,e.groupDataField=d,e[c.leaf]=!1,e[d]||(e[d]=e.data[d]),void 0!==u[c.expanded]?e[c.expanded]=u[c.expanded]:(e[c.expanded]=!1,s.expandHierarchy&&(e[c.expanded]=!0)),i&&(e[i]=u[i]),void 0===e.$.id&&(e.$.id=x.$.id+"_"+x[t].length),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[e.$.id]&&(e[c.expanded]=!1),s._expandedRowIds[e.$.id]&&(e[c.expanded]=!0),x[t][x[t].length]=e,x=e}g[v]=x}else x=g[v]}u&&(u[c.leaf]=!0),null!==x?(null===this.id?void 0===u.$.id&&(u.$.id=x.$.id+"_"+x[t].length):void 0===u.$.id&&-1===u.$.id.toString().indexOf(x.$.id)&&(u.$.id=x.$.id+"_"+u.$.id),u[o]=x,u[c.level]=x[c.level]+1,x[t][x[t].length]=u):void 0===u.$.id&&(u.$.id=f())}if(m){let e=null,t=!1;for(let a=0;a<p.length;a++){const n=p[a];if(!n[n.groupDataField]){e=n,e.$.id.toString().startsWith("Item")&&(t=!0),p.splice(a,1);break}}if(e&&(p.push(e),t))for(let e=0;e<p.length;e++){const t=p[e];t.$.id="Item"+e,Object.keys(s._expandedRowIds).length>0&&(s._expandedRowIds[t.$.id]?t[c.expanded]=!0:t[c.expanded]=!1,s.expandHierarchy&&(t[c.expanded]=!0,s._collapsedIds&&s._collapsedIds[t.$.id]&&(t[c.expanded]=!1)))}}return s.boundSource.canNotify=u,p}_getHierarchy(e,t,a,n,r){const i=this,o=new Array;let d=this.boundSource;if(r&&(d=r),0===this.boundSource.length)return null;const l=null!==a?a:"children";let s=new Array,c=d,u=c.length,f=i.reservedNames;const h=function(e){let t=e;if(n)for(let e in n){const a=n[e];a.name&&a.map&&(t[a.map]=t[a.name])}return t};for(let a=0;a<u;a++){let n=c[a],r=n[t],o=n[e];"parentId"===t&&(r=n.$.parentId),"id"===e&&(o=n.$.id),null===o&&(o=n[e]=n.$.id),n[l]=new Array,i.expandHierarchy&&void 0===n[f.expanded]&&(n[f.expanded]=i.expandHierarchy),s[o]={parentId:r,item:n}}for(let a=0;a<u;a++){const n=c[a];let r=n[t],i=n[e];if("parentId"===t&&(r=n.$.parentId),"id"===e&&(i=n.$.id),void 0!==s[r]){let e={parentId:r,item:s[i].item},t=s[r].item;t[l]||(t[l]=new Array);let a=t[l].length;e=e.item,f?e[f.parent]=t:e.parent=t;const n=h(e);t[l][a]=n,s[r].item=t,s[i].item=e}else{let e=s[i].item;f?void 0===e[f.parent]&&(e[f.parent]=null):void 0===e.parent&&(e.parent=null);const t=h(e);f?t[f.level]=0:t.level=0,o[o.length]=t}}if(0!==o.length){let e=function(t,a){for(let n=0;n<a.length;n++){const r=a[n];f?r[f.level]=t:r.level=t;const o=r[l];o&&o.length>0?(r.leaf=!1,e(t+1,o)):i.virtualDataSourceOnExpand?void 0===r.leaf&&(r.leaf=!1):f?r[f.leaf]=!0:r.leaf=!0}};e(0,o)}return o}summarize(e,t){const a=this;Array.isArray(e)||(e=[e]);let n=[];for(let t=0;t<e.length;t++){const a=e[t];for(let e in a){const t=a[e];n.push({dataField:e,functions:t})}}e=n;let r={},i=new Array;t||(t=a.boundSource);let o=t.length,d=0;if(0!==o&&void 0!==o){for(let a=0;a<o;a++){let n=t[a];if((!n||!n.$||!1!==n.$.filtered)&&n){d++;for(let t=0;t<e.length;t++){const o=e[t];let d=n[o.dataField];if(void 0!==d&&"uncategorized"!==d||(d=""),o.functions&&o.functions.length>0){r[o.dataField]=r[o.dataField]||{},i[o.dataField]=i[o.dataField]||0,i[o.dataField]++;const e=function(e){for(let t in e){let a=r[o.dataField][t];null==a&&(r[o.dataField][t]=0,a=0),"function"==typeof e[t]&&(a=e[t](a,d,o.dataField,n)),r[o.dataField][t]=a}},t=d;let l=parseFloat(d);l=!isNaN(l),t&&t.toDate&&(l=!1),"string"==typeof d&&d.startsWith("+")&&(l=!1),l&&(d=parseFloat(d)),"number"==typeof d&&isFinite(d)?o.functions.forEach((function(t){let n=r[o.dataField][t];if(null==n&&(n=0,"min"===t&&(n=9999999999999),"max"===t&&(n=-9999999999999),"median"===t&&(n=[])),"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t)n+=parseFloat(d);else if("product"===t)0===a?n=parseFloat(d):n*=parseFloat(d);else if("min"===t)n=Math.min(n,parseFloat(d));else if("max"===t)n=Math.max(n,parseFloat(d));else if("count"===t)n++;else if("median"===t)n.push(parseFloat(d));else if("blank"===t)n=r[o.dataField][t],null==n&&(n=0),d||n++;else if("filled"===t)n=r[o.dataField][t],null==n&&(n=0),void 0!==d&&n++;else if("unique"===t)n=r[o.dataField][t],null==n&&(n=[]),-1===n.indexOf(d)&&n.push(d);else if("status"===t)n=r[o.dataField][t],null==n&&(n=[]),n[d]||(n[d]=[]),n[d].push(d);else if("object"==typeof t)return void e(t);r[o.dataField][t]=n})):o.functions.forEach((function(t){if("min"===t||"max"===t||"count"===t||"product"===t||"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t){if(null===d&&"count"!==t)return!0;let e=r[o.dataField][t];return null==e&&(e=0),r[o.dataField][t]=e,!0}if("blank"===t){let e=r[o.dataField][t];null==e&&(e=0),d||e++,r[o.dataField][t]=e}else if("filled"===t){let e=r[o.dataField][t];null==e&&(e=0),d&&e++,r[o.dataField][t]=e}else if("unique"===t){let e=r[o.dataField][t];null==e&&(e=[]),-1===e.indexOf(d)&&e.push(d),r[o.dataField][t]=e}else if("status"===t){let e=r[o.dataField][t];null==e&&(e=[]),e[d]||(e[d]=[]),e[d].push(d),r[o.dataField][t]=e}"object"==typeof t&&e(t)}))}}}}for(let a=0;a<e.length;a++){const n=e[a];if(n.functions&&(!n.functions||0!==n.functions.length)){if(r[n.dataField]||(r[n.dataField]={},n.functions.forEach((function(e){r[n.dataField][e]=0}))),void 0!==r[n.dataField].avg){const e=r[n.dataField].avg,t=i[n.dataField];r[n.dataField].avg=0===t||void 0===t?0:e/t}else void 0!==r[n.dataField].count&&(r[n.dataField].count=d);if(void 0!==r[n.dataField].unique){const e=r[n.dataField].unique;r[n.dataField].unique=e.length}if(void 0!==r[n.dataField].status){const e=r[n.dataField].status;r[n.dataField].status=e}if(void 0!==r[n.dataField].median){let e=r[n.dataField].median;e.sort((function(e,t){return e-t})),r[n.dataField].median=.5*(e[Math.floor((e.length+1)/2)-1]+e[Math.ceil((e.length+1)/2)-1])}(r[n.dataField].stdev||r[n.dataField].stdevp||r[n.dataField].var||r[n.dataField].varp)&&n.functions.forEach((function(e){if("stdev"===e||"var"===e||"varp"===e||"stdevp"===e){const a=r[n.dataField][e],i=o,d=a/o;let l=0;for(let e=0;e<o;e++){let a=t[e][n.dataField];l+=(a-d)*(a-d)}let s="stdevp"===e||"varp"===e?i:i-1;0===s&&(s=1),"var"===e||"varp"===e?r[n.dataField][e]=l/s:"stdevp"!==e&&"stdev"!==e||(r[n.dataField][e]=Math.sqrt(l/s))}}))}}return r}}_getDataItem(e,t){const a=this,n={},r="number"==typeof a.dataSource||a.dataSourceLength;if(!e)return{$:{id:t,isEmpty:!0,index:t}};if("string"==typeof e&&(e={"":e}),r){for(let e=0;e<a.dataFields.length;e++){n[(a.dataFields?a.dataFields[e]:{}).name]=""}return n.$={},n.$.id=t,n.$.index=t,n}const i=e;if(void 0!==i.expanded&&(n.expanded=i.expanded,"true"===i.expanded||!0===i.expanded||1===i.expanded?n.expanded=!0:n.expanded=!1),a.childrenDataField?void 0!==i[a.childrenDataField]&&(n.children=i[a.childrenDataField]):void 0!==i.children?n.children=i.children:void 0!==i.items&&(n.children=i.items),void 0!==i.leaf&&(n.leaf=i.leaf),void 0!==i.level&&(n.level=i.level),a.keyDataField&&void 0!==i[a.keyDataField]&&(n[a.keyDataField]=i[a.keyDataField]),a.parentDataField&&void 0!==i[a.parentDataField]&&(n[a.parentDataField]=i[a.parentDataField]),0===a.dataFields.length){const t=Object.getOwnPropertyNames(e);for(let e=0;e<t.length;e++)"$"!==t[e]&&a.dataFields.push({name:t[e],dataType:"string"})}for(let t=0;t<a.dataFields.length;t++){const r=a.dataFields?a.dataFields[t]:{};let o="";if(null==r)continue;if(e.length&&(o=e[t]),r.map){let e=r.map.split(a.mapChar);if(e.length>0){let t=i;for(let a=0;a<e.length;a++)i&&t&&(t=t[e[a]]);o=t}else o=i[r.map]}null!=o?o=o.toString():void 0===o&&null!==o&&(o="");let d=!1;if(""===o&&(d=!0,o=e[r.name],void 0===r.dataType&&(r.dataType="any"),null!=o?"array"!==r.dataType&&("any"===r.dataType?o=Array.isArray(e[r.name])?[...e[r.name]]:"object"==typeof e[r.name]?Object.assign({},e[r.name]):e[r.name]:"date"!==r.dataType&&(o=o.toString())):o=void 0===o&&"any"===r.dataType?null:""),"[object Object]"===o&&r.map&&d&&(o=""),a._cachedValues[o+"_"+r.dataType])o=a._cachedValues[o+"_"+r.dataType];else{if("bool"===r.dataType||"boolean"===r.dataType)"true"===o||"1"===o?o=!0:"false"!==o&&"0"!==o||(o=!1);else if("number"===r.dataType)-1===o.indexOf(".")&&o.indexOf(",")>=0&&o.substring(1+o.indexOf(",")).length<3&&(o=o.replace(",",".")),o=a.$document.deserialize(""+o,r.dataType,!0);else if("date"===r.dataType){if(o&&"string"==typeof o&&o.indexOf("[")>=0){const e=JSON.parse(o);if(r.formatString&&Smart.Utilities.DateTime){const t=Smart.Utilities.DateTime.ParseDate(e[0],r.formatString),a=Smart.Utilities.DateTime.ParseDate(e[1],r.formatString);e[0]=t,e[1]=a}else{const t=a.$document.deserialize(""+e[0],r.dataType,!0),n=a.$document.deserialize(""+e[1],r.dataType,!0);e[0]=t,e[1]=n}o=e,n[r.name]=o;continue}if(r.formatString&&Smart.Utilities.DateTime){o=Smart.Utilities.DateTime.ParseDate(o,r.formatString)}else o=a.$document.deserialize(""+o,r.dataType,!0)}else"any"!==r.dataType&&(o="string"===r.dataType&&"null"===o?"null":a.$document.deserialize(""+o,r.dataType,!0));"any"!==r.dataType&&(a._cachedValues[o+"_"+r.dataType]=o)}"string"!==r.dataType&&"boolean"!==r.dataType&&"bool"!==r.dataType&&"any"!==r.dataType&&(isNaN(o)||o===-1/0||o===1/0)&&(o="date"===r.dataType||"number"===r.dataType?null:0),"parent"!==r.name&&"group"!==r.name&&"leaf"!==r.name&&"level"!==r.name?("string"===r.dataType&&/<.+?>/.test(o)&&o.replace&&("all"===a.sanitizeHTML?o=o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):"blackList"===a.sanitizeHTML&&(o=window.Smart.Utilities.Core.sanitizeHTML(o),o.indexOf("<br")>=0&&(o=o.replaceAll("<br/>","\n\r"),o=o.replaceAll("<br>","\n\r")))),n[r.name]=o):n.$[r.name]=o}let o=t;if(a.id){if(o=i[a.id],void 0===o){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};o=e()+e()}"object"==typeof o&&(o=t),i.$&&void 0!==i.$.id&&(o=i.$.id)}else if(!a.virtualDataSource&&a.dataItemById&&a.dataItemById[o])for(o=a.length;a.dataItemById[o];)o++;return n.$||(n.$={}),n.$.id=o,n.$.index=t,new Object(n)}_bindToArray(){const e=this,t="number"==typeof e.dataSource||e.dataSourceLength,a=[];e.boundSource.canNotify=!1;const n=t?"number"==typeof e.dataSource?e.dataSource:e.dataSource.length:e.observable?e.length:e.dataSource.length;for(let r=0;r<n;r++){const n=t?{}:e.dataSource[r],i=e._getDataItem(n,r);a.push(i)}if(t&&e.dataSourceLength&&e.dataSource.length>0)for(let t=0;t<e.dataSource.length;t++){const n=e.dataSource[t].cell,r=e.dataSource[t].value,i=n.replace(/[^0-9]/g,""),o=n.replace(/[0-9]/g,"");a[i-1][o]=r}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(a),e.observable&&(e.boundSource=new Smart.ObservableArray(a));for(let t=0;t<n;t++)e.observable?e[t]=e.boundSource[t]:e[t]=a[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=a),e.boundSource.canNotify=!0}_bindToICS(){const e=this,t=""+e.dataSource,a=e.rowDelimiter||"\n",n=t.split("\r"),r=[];let i=t.split(a),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=function(e,t){var a=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z)?$/.exec(e);if(!a)throw new Error("Invalid UNTIL value: "+e);return t?new Date(a[1],a[2]-1,a[3],0,0,0,0):new Date(Date.UTC(a[1],a[2]-1,a[3],a[5]||0,a[6]||0,a[7]||0))};for(let e=0;e<o;e++){const t=i[e].trim();if(t.indexOf("BEGIN:VEVENT")>=0)var l={};else if(l)if(t.indexOf("BEGIN:VALARM")>=0)var s={};else{if(s){if(t.indexOf("ACTION")>=0){s.ACTION=t.substring(t.indexOf("ACTION")+7);continue}if(t.indexOf("DESCRIPTION")>=0){s.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);continue}if(t.indexOf("TRIGGER")>=0){s.TRIGGER=t.substring(t.indexOf("TRIGGER")+8);continue}if(t.indexOf("END:VALARM")>=0){l.ALARM||(l.ALARM=[]),l.ALARM.push(s),s=void 0;continue}}if(t.indexOf("SUMMARY")>=0)l.SUMMARY=t.substring(t.indexOf("SUMMARY")+8);else if(t.indexOf("LOCATION")>=0)l.LOCATION=t.substring(t.indexOf("LOCATION")+9);else if(t.indexOf("DESCRIPTION")>=0)l.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);else if(t.indexOf("RRULE")>=0)l.RRULE=t.substring(t.indexOf("RRULE")+6);else if(t.indexOf("RECURRENCE-ID")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID")+14);else if(t.indexOf("RECURRENCE-ID;VALUE=DATE")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID;VALUE=DATE")+25);else if(t.indexOf("EXDATE;VALUE=DATE")>=0){const e=t.substring(t.indexOf("EXDATE;VALUE=DATE")+20);l.EXDATE=e}else if(t.indexOf("EXDATE")>=0){const e=t.substring(t.indexOf("EXDATE")+7);l.EXDATE=e}else t.indexOf("DTEND;VALUE=DATE")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND;VALUE=DATE")+17),!0):t.indexOf("DTEND")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND")+6)):t.indexOf("DTSTART;VALUE=DATE")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART;VALUE=DATE")+19),!0):t.indexOf("DTSTART")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART")+8)):t.indexOf("UID")>=0?l.uid=l.UID=t.substring(t.indexOf("UID")+4):t.indexOf("STATUS")>=0?l.STATUS=t.substring(t.indexOf("STATUS")+7):t.indexOf("TITLE")>=0?l.TITLE=t.substring(t.indexOf("TITLE")+6):t.indexOf("CATEGORIES")>=0?l.CATEGORIES=t.substring(t.indexOf("CATEGORIES")+11):t.indexOf("END:VEVENT")>=0&&(r.push(l),l.ALARM&&(l.ALARM=JSON.stringify(l.ALARM)),s=void 0)}}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_bindToJSON(){const e=this,t=[],a=e.dataSource.length?e.dataSource:Object.entries(e.dataSource);e.boundSource.canNotify=!1;for(let n=0;n<a.length;n++){const r=a[n],i=e._getDataItem(r,n);t.push(i)}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(t);for(let t=0;t<e.length;t++)e[t]=e.boundSource[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=t),e.boundSource.canNotify=!0}sortBy(e,t,a){const n=this;if(!t)for(let a=0;a<n.dataFields.length;a++){const r=n.dataFields[a];if(r.name===e){t=r.dataType;break}}if(n.boundHierarchy){if((!e||0===e.length)&&n.groupBy.length>0)return void n.refreshHierarchy();const r=(e=>{let t=[];for(;e;){t=t.concat(e);for(let a=0;a<e.length;a++)e[a].children&&(t=t.concat(e[a].children));e=e.children}return t})(n.boundHierarchy);if(r){r.find((e=>{if(e.summaryRow)return e}))&&n.refreshHierarchy()}const i=function(r){n._sort(r,e,a,t);for(let n=0;n<r.length;n++){const o=r[n];o.children&&i(o.children,e,a,t)}};i(n.boundHierarchy)}else n._sort(n.boundSource,e,a,t)}_createFilter(e,t){const a={"=":"EQUAL","<>":"NOT_EQUAL","!=":"NOT_EQUAL",not_like:"DOES_NOT_CONTAIN",like:"CONTAINS","<":"LESS_THAN",">":"GREATER_THAN","<=":"LESS_THAN_OR_EQUAL",">=":"GREATER_THAN_OR_EQUAL",equal:"EQUAL","not equal":"NOT_EQUAL","less than":"LESS_THAN","greater than":"GREATER_THAN","greater than or equal":"GREATER_THAN_OR_EQUAL","less than or equal":"LESS_THAN_OR_EQUAL","starts with":"STARTS_WITH","ends with":"ENDS_WITH",notEqual:"NOT_EQUAL",not_equal:"NOT_EQUAL",lessThan:"LESS_THAN",greaterThan:"GREATER_THAN",greaterThanOrEqual:"GREATER_THAN_OR_EQUAL",lessThanOrEqual:"LESS_THAN_OR_EQUAL",less_than:"LESS_THAN",greater_than:"GREATER_THAN",greater_than_or_equal:"GREATER_THAN_OR_EQUAL",less_than_or_equal:"LESS_THAN_OR_EQUAL",null:"null","":"EMPTY",isblank:"EMPTY",isnotblank:"NOT_EMPTY",isBlank:"EMPTY",isNotBlank:"NOT_EMPTY",CONTAINS:"CONTAINS",DOES_NOT_CONTAIN:"DOES_NOT_CONTAIN",contains:"CONTAINS",does_not_contain:"DOES_NOT_CONTAIN","not contains":"DOES_NOT_CONTAIN",notcontains:"DOES_NOT_CONTAIN",notContains:"DOES_NOT_CONTAIN",startswith:"STARTS_WITH",endswith:"ENDS_WITH",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH",startsWith:"STARTS_WITH",endsWith:"ENDS_WITH",NULL:"NULL",NOT_NULL:"NOT_NULL"};let n=[];"string"==typeof t&&(t=[t]);for(let e=0;e<t.length;e++){const a=t[e],r=-1===a.indexOf('"')?a.split(" "):a.split('"');let i=[];for(let e=0;e<r.length;e++){const t=r[e];if(""!==t&&" "!==t){if("true"===t.trim()){i.push(!0);continue}if("false"===t.trim()){i.push(!1);continue}if(t.indexOf("or ")>=0||t.indexOf("and ")>=0||t.indexOf("1 ")>=0||t.indexOf("0 ")>=0||t.indexOf("| ")>=0||t.indexOf("& ")>=0){const e=t.trim().split(" ");if(e.length>1){const t=e[0].trim(),a=e[1].trim();"1"===t?i.push("or"):"0"===t?i.push("and"):i.push(t),i.push(a)}else i.push(t.trim())}else i.push(t.trim())}}n.push(i)}const r=new Smart.FilterGroup,i=[],o=[];for(let t=0;t<n.length;t++){const r=n[t];if(r.length>1){const t=new Smart.FilterGroup;let n=r.length>2?"":"and",i=0,d=[];for(let o=0;o<r.length;o++){let l=r[o];if("and"!==l&&"or"!==l){if(i++,2===i){let s=a[r[o-1]];s||(s=r[o-1]),"number"===e&&(l=parseFloat(l)),"date"===e&&(l=new Date(l));const c=t.createFilter(e,l,s);if(i=0,d.push(c),n){for(let e=0;e<d.length;e++)t.addFilter(n,d[e]);d=[]}}}else n=l}o.push(t)}else{let e=r[0];if(e&&a[e]&&(e="and"),"and"!==e&&"or"!==e)throw new Error('Filter Exprresion expects "AND" or "OR", but the token is: '+e);i.push(e)}}let d=0;if(1===o.length)return o[0];for(let e=0;e<o.length;e++){let t=i[d];(e+1)%2==0&&d++,t||(t="and"),r.addFilter(t,o[e])}return r}filterBy(e,...t){const a=this,n=(()=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}})(),r=a._createFilter(n,t);return a.boundSource.filter((t=>r.evaluate(t[e])))}_filter(e,t="and"){const a=this,n=[],r=[];if(0===e.length)return void a.clearFilter();const i=e=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}};let o,d;"and"===t?(o=!0,d=function(e,t,a){return e&&t.evaluate(a[t.dataField])}):(o=!1,d=function(e,t,a){return e||t.evaluate(a[t.dataField])});for(let t=0;t<e.length;t++){const o=e[t],d=o[0];let l=null;l=o[1]instanceof Smart.FilterGroup?o[1]:a._createFilter(i(d),o.splice(1)),l&&(r.push(d),l.dataField=d,n.push(l))}if(a.boundHierarchy){const e=function(e){let t=o;for(let a=0;a<n.length;a++){const r=n[a];t=d(t,r,e)}return e.$.filtered=t,t},t=function(n,r,i){let o=0;for(let a=0;a<n.length;a++){const i=n[a];e(i),i.$.filtered&&o++,i.children&&t(i.children,i,r)}o>0&&a.groupBy.length>0&&r?(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0)):o>0&&o!==n.length&&r?(r.$.filtered=null,i&&!i.$.filtered&&(i.$.filtered=null)):o>0&&o===n.length&&r&&(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0))};t(a.boundHierarchy,null,null)}else for(let e=0;e<a.boundSource.length;e++){const t=a.boundSource[e];let r=o;for(let e=0;e<n.length;e++){const a=n[e];r=d(r,a,t)}t.$.filtered=r}a.onFilter&&a.onFilter()}clearGroup(){const e=this;e.groupBy=[],e.boundHierarchy=null,e.refreshHierarchy(),e.onGroup&&e.onGroup()}clearFilter(){const e=this;for(let t=0;t<e.boundSource.length;t++){e.boundSource[t].$.filtered=!0}if(e.boundHierarchy){const t=function(e,a,n){for(let n=0;n<e.length;n++){const r=e[n];r.$.filtered=!0,r.$.filtered,r.children&&t(r.children,r,a)}a&&(a.$.filtered=!0,n&&!n.$.filtered&&(n.$.filtered=!0))};t(e.boundHierarchy,null,null)}e.onFilter&&e.onFilter()}clearSort(){this._sort(this.boundSource,[],[],[])}_sort(e,t,a,n,r,i){const o=this;let d=!1;if(0===e.length)return;if(e&&e.constructor&&e instanceof Smart.ObservableArray&&(d=!0),(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)&&!d&&!o.boundHierarchy){if(o.virtualDataSource)return;throw new Error("sort: Missing or Invalid arguments!")}"string"==typeof t&&(t=[t]);const l=[],s=[];void 0===a&&(a=[]);const c=function(e,t){let a;switch(t||typeof e){case"string":a=(new Intl.Collator).compare;break;case"number":case"int":case"bigInt":case"float":case"double":a=function(e,t){return e-t};break;case"boolean":case"bool":a=function(e,t){return e===t?0:!1===e?-1:1};break;case"date":case"time":case"dateTime":a=e instanceof Date?function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0}:e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber?function(e,t){return e.compare(t)}:function(e,t){return e-t};break;case"object":if(e instanceof Date)a=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)a=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;a=function(t,a){return e.compareComplexNumbers(t,a)}}}return a};for(let r=0;r<t.length;r++){void 0===a[r]||"asc"===a[r]||"ascending"===a[r]?l[r]=1:l[r]=-1;let d=e[0][t[r]];if(void 0===d&&e[0]&&e[0].children&&e[0].data&&(d=e[0].data[t[r]]),i&&i){const e=t[r];if(i[e]){s[r]=i[e];continue}}o.sortComparators&&o.sortComparators[t[r]]?s[r]=o.sortComparators[t[r]]:s[r]=c(d,n[r])}t.length>0&&r?r(e,t,a,s):e.sort((function(e,a){for(let n=0;n<t.length;n++){const r=s[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e.$.index?(e.$.index-a.$.index)*l[n]:0}return r*l[n]}if(0===t.length)return e.$.index<a.$.index?-1:e.$.index>a.$.index?1:0}));for(let t=0;t<e.length;t++)o[t]=e[t]}static Filter(e,t,a,n,r="and"){let i,o;"and"===r?(i=!0,o=function(e,t,a,r){return n?e&&n(t,a,r):e&&r.evaluate(t[a])}):(i=!1,o=function(e,t,a,r){return n?e||n(t,a,r):e||r.evaluate(t[a])});return e.filter((e=>{let n=i;for(let r=0;r<a.length;r++){const i=a[r],d=t[r];n=o(n,e,d,i)}return n}))}filter(e,t,a){Smart.DataAdapter.Filter(this.boundSource,e,t,a)}sort(e,t,a){Smart.DataAdapter.Sort(this.boundSource,e,t,a)}static Sort(e,t,a,n){const r=function(e){let t;switch(typeof e){case"string":if(e.indexOf("-")>=0||e.indexOf("/")>=0){const t=new Date(e);if(t&&"Invalid Date"!==t.toString()){return function(e,t){const a=new Date(e),n=new Date(t);return a||n?a?n?a.getTime()-n.getTime():1:-1:0}}}t=(new Intl.Collator).compare;break;case"number":t=function(e,t){return e-t};break;case"boolean":t=function(e,t){return e===t?0:!1===e?-1:1};break;case"object":if(e instanceof Date)t=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)t=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;t=function(t,a){return e.compareComplexNumbers(t,a)}}else t=function(e,t){return e-t}}return t};if(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)return;"string"==typeof t&&(t=[t]);const i=[],o=[];void 0===a&&(a=[]);for(let n=0;n<t.length;n++)void 0===a[n]||"asc"===a[n]||"ascending"===a[n]?i[n]=1:i[n]=-1,o[n]=r(e[0][t[n]]);if(n)return void n(e,t,a,o);const d=e.slice(0);return d.sort((function(e,a){for(let n=0;n<t.length;n++){const r=o[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e._index?(e._index-a._index)*i[n]:0}return r*i[n]}})),d}};class e{constructor(e,t){const a=this;a.config=e,a.callback=t,!1!==e.autoFetch&&a.call(e)}call(e){const t=this;e||(e=t.config);let a="GET",n=e.url,r=null,i=!0;if(e.type&&(a=e.type),e.data)if("GET"===a){n+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(n+=encodeURI(t+"="+e.data[t]+"&"));"&"===n.charAt(n.length-1)&&(n=n.slice(0,n.length-1))}else"POST"===a&&(r=JSON.stringify(e.data));e&&!1===e.async&&"xlsx"!==e.dataSourceType&&(i=!1),void 0!==window.fetch&&i?t.ajaxFetch(e,a,n,r):t.ajaxXMLHttpRequest(e,a,n,r,i)}ajaxFetch(e,t,a,n){const r=this,i={method:t};let o,d,l,s;switch(e.dataSourceType){case"json":o="json";break;case"xlsx":o="arrayBuffer";break;default:o="text"}if(e&&e.contentType&&(i.headers=new Headers({"Content-Type":e.contentType})),null!==n&&(i.body=n),e.timeout&&(l=setTimeout((function(){s=!0}),e.timeout)),e.beforeSend){if(!1===e.beforeSend(i,e))return}fetch(a,i).then((function(e){if(s)throw d=408,new Error("timeout");if(l&&clearTimeout(l),d=e.status,!e.ok)throw new Error(e.statusText);return e[o]()})).then((function(t){if("arrayBuffer"===o)return JSZip.loadAsync(t).then((function(t){return t.files["xl/worksheets/sheet1.xml"].async("text").then((function(a){return t.files["xl/sharedStrings.xml"].async("text").then((function(t){const n=r.parseXLSXData(a,t);r.ajaxComplete(e,n,d)}))}))}));r.ajaxComplete(e,t,d)})).catch((function(t){"JSZip is not defined"===t.message&&(t.message="JSZip is not defined. Please include a reference to JSZip to be able to load data from XLSX files."),e&&e.loadError&&e.loadError(d,t),r.callback&&r.callback(t,d)}))}ajaxXMLHttpRequest(e,t,a,n,r){const i=new XMLHttpRequest,o=this;if(i.open(t,a,r),i.ontimeout=function(){e&&e.loadError&&e.loadError(408,"timeout")},i.onload=function(){if(4===i.readyState){const t=i.status;let a=i.response;t>=200&&t<=299?("json"===e.dataSourceType&&(a=JSON.parse(a)),o.ajaxComplete(e,a,t)):e&&e.loadError&&e.loadError(t,a)}},i.onerror=function(){e&&e.loadError&&e.loadError(i.status,i.response)},e&&e.contentType&&i.setRequestHeader("Content-Type",e.contentType),r&&e.timeout&&(i.timeout=e.timeout),e.beforeSend){if(!1===e.beforeSend(i,e))return}i.send(n)}ajaxComplete(e,t,a){if(e){if(e.beforeLoadComplete){const a=e.beforeLoadComplete(t);a&&(t=a)}e.loadComplete&&e.loadComplete(t,a),this.callback&&this.callback(t,a)}}parseXLSXData(e,t){const a=new DOMParser,n=a.parseFromString(t,"text/xml"),r=Array.from(n.getElementsByTagName("si")),i=[],o=a.parseFromString(e,"text/xml"),d=Array.from(o.getElementsByTagName("row")),l=[];return r.forEach((function(e){let t=e.getElementsByTagName("t");if(1===t.length)i.push(t[0].innerHTML);else{let e="";t=Array.from(t),t.forEach((function(t){e+=t.innerHTML})),i.push(e)}})),d.forEach((function(e){const t={};Array.from(e.getElementsByTagName("c")).forEach((function(e){const a=e.getAttribute("r").match(/\D+/)[0],n=e.getAttribute("t"),r=e.getElementsByTagName("v")[0].innerHTML;let o;switch(n){case"s":o=i[parseFloat(r)];break;case"b":o=1===parseFloat(r);break;default:o=parseFloat(r)}t[a]=o})),l.push(t)})),l}}Smart.Ajax=window.Ajax=e})();
|
|
101
|
+
(()=>{Smart.DataAdapter=window.smartDataAdapter=class{constructor(e){e||(e={});const t=Object.assign(this,e);t.key=(65536*(1+Math.random())|0).toString(16).substring(1),t.$document=Smart.Utilities.Extend(document),t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],void 0===t.allowAdd&&(t.allowAdd=!0),void 0===t.allowRemove&&(t.allowRemove=!0),void 0===t.allowUpdate&&(t.allowUpdate=!0),void 0===t.mapChar&&(t.mapChar="."),void 0!==e.observable||t.virtualDataSource?t.observable=!1:t.observable=!0,void 0===t.sanitizeHTML&&(t.sanitizeHTML="blackList"),t._expandedRowIds=[],e.dataSource||(t.dataSource=[]),e.dataFields||(t.dataFields=[]),e.dataSourceType||(t.dataSourceType="array"),e.id||(t.id=null),e.autoFetch||(t.autoFetch=!0),void 0===e.skipFirstRow&&(t.skipFirstRow=!1),e.dataFields&&(t.dataFields=e.dataFields),Object.defineProperty(t,"groupBy",{configurable:!1,enumerable:!0,get:()=>t._groupBy?t._groupBy:[],set(e){const a=()=>{t.boundHierarchy=null,t.refreshHierarchy(),t.onGroup&&t.onGroup()};t._groupBy=new Smart.ObservableArray(e),t._groupBy.notify((function(){a()})),t.isInitialized&&a()}}),e.groupBy?e.groupBy.toArray?t.groupBy=e.groupBy.toArray():t.groupBy=e.groupBy:t.groupBy=[],e&&!1!==e.autoBind&&t.dataBind(),t.isInitialized=!0}beginUpdate(){this.isUpdating=!0}endUpdate(){const e=this;e.isUpdating=!1,e.refreshIndexes(),e.refreshHierarchy()}get expandHierarchy(){return void 0===this._expandHierarchy&&(this._expandHierarchy=!1),this._expandHierarchy}set expandHierarchy(e){const t=this;t._expandHierarchy=e,t.isInitialized&&t.refreshHierarchy()}_getDataField(e){switch(e.name){case"leaf":case"parent":case"expanded":case"checked":case"selected":case"level":case"icon":case"data":case"group":case"children":case"items":e.map?e.map=e.map.replace(e.name,"$"+e.name):e.map=e.name,e.name="$"+e.name}}get dataFields(){return this._dataFields}set dataFields(e){const t=this;return t._dataFields=t._getDataFieldObjects(e),t._dataFields}_getDataFieldObjects(e){const t=this;let a=[];if("number"==typeof e){const t="A".charCodeAt(0);let n="",r=0;for(let i=0;i<e;i++){const e=String.fromCharCode(t+r);r++;const i=n+e;a.push({name:i,dataType:"string"}),r>=26&&(r=0,n+="A")}}else if(Array.isArray(e)&&e.length>0)for(let n=0;n<e.length;n++){const r=e[n];if("string"==typeof r){const e=r.split(":"),t=e[0].trim(),n=e.length>1?e[1].trim():"string";a.push({name:t,dataType:n})}else a.push(r);t._getDataField(a[a.length-1])}return a}get dataSource(){const e=this;return e._dataSource||(e._dataSource=[]),e._dataSource}set dataSource(e){const t=this;t._dataSource=e,t.isInitialized&&(t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],t.bindingCompleted=!1,t.dataBind(),t.refreshIndexes())}get canNotify(){const e=this;return void 0===e._canNotify&&(e._canNotify=!0),e._canNotify}set canNotify(e){this._canNotify=e}_notify(e){const t=this;t.canNotify&&t.notifyFn&&t.notifyFn(e)}notify(e){e&&(this.notifyFn=e)}toArray(){const e=this;return!1===e.observable?e.boundSource:e.boundSource.toArray()}forEach(e){const t=this;if(e)if(t.boundHierarchy&&t.boundHierarchy.length>0){const a=(e=>{let t=[];for(;e;){t=t.concat(e);for(let a=0;a<e.length;a++)e[a].children&&(t=t.concat(e[a].children));e=e.children}return t})(t.boundHierarchy);for(let t=0;t<a.length;t++){e(a[t],t)}}else for(let a=0;a<t.boundSource.length;a++){e(t.boundSource[a],a)}}dataBind(){const t=this;t.bindingCompleted=!1,t.clear();const a=()=>{t.observable&&(t.boundSource.notify||(t.boundSource=new Smart.ObservableArray),t.boundSource.notify((function(e){if("update"===e.action&&e.path&&e.path.indexOf(".")>=0&&-1===e.path.indexOf("children")&&-1===e.path.indexOf("parent")&&-1===e.path.indexOf("loaded")&&-1===e.path.indexOf("level")&&-1===e.path.indexOf("leaf")&&-1===e.path.indexOf("expanded")){let a=!1;for(let n=0;n<t.dataFields.length;n++){const r=t.dataFields[n].name;e.path.indexOf(r)>=0&&(a=!0)}t._notify&&a&&t._notify({action:"update",data:e.target,index:e.index})}}))),t._onBindingComplete()};if("string"==typeof t.dataSource&&(t.dataSource.indexOf(".json")>=0||"json"===t.dataSourceType))t.url=t.dataSource,t.dataSourceType="json",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".xml")>=0)t.url=t.dataSource,t.dataSourceType="xml",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".xlsx")>=0)t.url=t.dataSource,t.dataSourceType="xlsx",new e(t,(e=>{if(!e[0])return e=[],t._bindToArray(),void a();const n=Object.keys(e[0]),r={},i=[];if(!1!==t.exportHeader){let a=0;for(let e in n){r[n[e]]=t.dataFields[a++].name}for(let t=1;t<e.length;t++){const a=e[t],o={};for(let e in n){const t=n[e];o[r[t]]=a[t]}i.push(o)}t.dataSource=i}t._bindToArray(),a()}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".csv")>=0)t.url=t.dataSource,t.dataSourceType="csv",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".tsv")>=0)t.url=t.dataSource,t.dataSourceType="tsv",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&(t.dataSource.indexOf(".ics")>=0||t.dataSource.indexOf(".php")>=0&&"ics"===t.dataSourceType||t.dataSource.indexOf(".txt")>=0&&"ics"===t.dataSourceType))t.url=t.dataSource,t.dataSourceType="ics",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("BEGIN:VCALENDAR")>=0||"ics"===t.dataSourceType))t._bindToICS(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("<?xml")>=0||"xml"===t.dataSourceType))t._bindToXML(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf(" ")>=0||t.dataSource.indexOf(",")>=0||"tsv"===t.dataSourceType||"csv"===t.dataSourceType||"tab"===t.dataSourceType))t._bindToCSV(),a();else if("array"===t.dataSourceType)t._bindToArray(),a();else if("json"===t.dataSourceType){if(t.dataSource&&t.dataSource.url)return t.url=t.dataSource.url,t.dataSource.method&&(t.type=t.dataSource.method),t.dataSource.type&&(t.type=t.dataSource.type),t.dataSource.data&&(t.data=t.dataSource.data),void new e(t,(e=>{t.dataSource=e}));t._bindToJSON(),a()}}_bindToXML(){const e=this;let t=null,a=null;window.DOMParser&&(t=new DOMParser,a=t.parseFromString(e.dataSource,"text/xml")),void 0===e.root&&(e.root=""),void 0===e.record&&(e.record="");const n=a.querySelectorAll(e.root+" "+e.record),r=n.length,i=[];let o=e.dataFields?e.dataFields.length:0;if(0===o){const t=n[0],a=new Array;for(let e in t){const t=e;a[a.length]={name:t}}e.dataFields=a,o=a.length}for(let t=0;t<r;t++){const a=n[t],r={};if(void 0===a)break;if(e.id){const t=a.querySelector(e.id);r[e.id]=t.textContent}for(let t=0;t<o;t++){const n=e.dataFields[t],i=a.querySelector(n.map||n.name);r[n.name]=i.textContent}i[t]=r}e.canNotify=!1,e.dataSource=i,e.canNotify=!0,e._bindToArray()}static BindToCSV(e,t=!1){const a=""+e,n=-1===a.indexOf(",")?"\t":",",r=a.split("\r"),i=new Array,o=[];let d=a.split("\n"),l=d.length;1===l&&r.length>1&&(d=r,l=d.length);const s=!0===t;for(let e=0;e<l;e++){const t={},a=d[e].split(n);for(let n=0;n<a.length;n++){let r=o[n],i=a[n];if(r||(o.push({name:i.trim()}),r=o[o.length-1]),i=i.trim(),1!==e||s)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}t[r.name]=i}(s||e>0)&&i.push(t)}return i}_bindToCSV(){const e=this,t=""+e.dataSource,a=-1===t.indexOf(",")?"\t":",",n=t.split("\r"),r=new Array;let i=t.split("\n"),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=e.dataFields.length>0;for(let t=0;t<o;t++){const n=i[t],o={};let l=i[t].split(a);if(t>0){let e=[],a=0,n=!1,r=i[t];for(let t=0;t<r.length;t++)if('"'===r.charAt(t))n=!n;else if(","===r.charAt(t)&&!n){let n=r.substring(a,t);n=n.trim(),n=n.replaceAll('"',""),e.push(n),a=t+1}let o=r.substring(a);o=o.trim(),o=o.replaceAll('"',""),","===o?e.push('""'):e.push(o),l=e}for(let a=0;a<l.length;a++){let r=e.dataFields[a],i=l[a];if(r||(e.dataFields.push({name:i.trim()}),r=e.dataFields[e.dataFields.length-1]),r.map&&(i=n[r.map]),i=i.trim(),1!==t||d)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/")&&-1===i.indexOf("-"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):i.indexOf(".")>=0&&i.lastIndexOf(".")!==i.indexOf(".")?-1===i.indexOf(",")&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}o[r.map||r.name||a.toString()]=i}0===t&&e.skipFirstRow||(d||t>0)&&r.push(o)}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_onBindingComplete(){const e=this;e._buildHierarchy(),e.onBindingComplete&&e.onBindingComplete({data:e.boundSource}),e._notify&&e._notify({action:"bindingComplete",data:e.boundSource}),e.bindingCompleted=!0}refreshHierarchy(){this.isUpdating||this._buildHierarchy()}find(){return this.boundSource.find.apply(this.boundSource,arguments)}onVirtualDataSourceRequested(e,t){const a=this;let n=t?t.first:1/0,r=t?t.last:1/0,i=t?t.row:null;if(void 0===n&&(n=1/0),void 0===r&&(r=1/0),a.virtualFirstIndex=n,a.virtualLastIndex=r,a.virtualDataSource){const o=function(r){void 0!==r.virtualDataSourceLength&&(a.virtualDataSourceLength=r.virtualDataSourceLength),new Smart.DataAdapter({dataSource:r.dataSource,dataFields:r.dataFields||a.dataFields,data:t,keyDataField:r.keyDataField,parentDataField:r.parentDataField,observable:!1,id:r.id||a.id,onBindingComplete(r){if(void 0===t.result&&(t.result=!0),t.data=r.data,a.virtualDataSourceOnExpand&&i)return a.groupBy.length>0?r.data&&r.data.length>0&&a.add(r.data):r.data&&r.data.length>0?a.add(r.data,i.$.id):i.leaf=!0,a.onFilter&&a.onFilter(),void e(t);n===1/0&&"scroll"===t.action?r.data&&r.data.length&&a.add(r.data):"filter"===t.action||"group"===t.action?(a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0):("add"===t.action||"update"===t.action||t.action,a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0),a.onFilter&&a.onFilter(),e(t)}})};let d={};if(t.sorting&&t.sorting.length>0){let e=[];for(let a in t.sorting)e.push(a+" "+t.sorting[a].sortOrder.toUpperCase());const a=" ORDER BY "+e.join(", ");d.orderBy=a}else d.orderBy="";if(void 0===n||void 0===r||0===n&&0===r)d.limit="";else{const e=r-n,t=" LIMIT "+e+" OFFSET "+n;d.limit=t,isNaN(e)&&(d.limit="")}if(t.grouping&&t.grouping.length>0){const e=" GROUP BY "+t.grouping[0];d.groupBy=e}else d.groupBy="";if(t.filtering&&t.filtering.length>0){const e=(e,t)=>{switch(t.condition){case"EMPTY":return e+" = ''";case"NOT_EMPTY":return e+" != ''";case"EQUAL":return e+" = '"+t.value+"'";case"NOT_EQUAL":return e+" != '"+t.value+"'";case"CONTAINS_CASE_SENSITIVE":case"CONTAINS":return e+" LIKE '%"+t.value+"%'";case"DOES_NOT_CONTAIN_CASE_SENSITIVE":case"DOES_NOT_CONTAIN":return e+" NOT LIKE '%"+t.value+"%'";case"STARTS_WITH_CASE_SENSITIVE":case"STARTS_WITH":return e+" LIKE '"+t.value+"%'";case"ENDS_WITH_CASE_SENSITIVE":case"ENDS_WITH":return e+" LIKE '%"+t.value+"'";case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL"}},a=(e,t)=>{let a=t.value,n=t.valueTo;if(a&&a instanceof Date){a=`'${new Smart.Utilities.DateTime(a).toString("yyyy-MM-dd")}'`}if(t.valueTo&&t.valueTo instanceof Date){n=`'${new Smart.Utilities.DateTime(n).toString("yyyy-MM-dd")}'`}switch(t.condition){case"EQUAL":return e+" = "+a;case"NOT_EQUAL":return e+" != "+a;case"GREATER_THAN":return e+" > "+a;case"GREATER_THAN_OR_EQUAL":return e+" >= "+a;case"LESS_THAN":return e+" < "+a;case"LESS_THAN_OR_EQUAL":return e+" <= "+a;case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL";case"RANGE":return"("+e+" >= "+a+" and "+e+" <= "+n+")"}},n=(e,t,a)=>{if(a.operator){var n=e(t,a.condition1),r=e(t,a.condition2);return"("+n+" "+a.operator+" "+r+")"}return e(t,a)};let r=[];for(let i in t.filtering){const o=t.filtering[i];let d=o.filters,l=[],s=" AND ";for(let t=0;t<d.length;t++){const r=d[t];switch(r.type){case"stringFilter":l.push(n(e,i,r));break;case"numericFilter":case"dateFilter":case"booleanFilter":l.push(n(a,i,r))}1!==o.logicalOperators[t]&&"or"!==o.logicalOperators[t]||(s=" OR ")}l.length&&r.push("("+l.join(s)+")")}if(r.length>0){let e=" AND ";t.filterOperator&&"or"===t.filterOperator.toLowerCase()&&(e=" OR "),d.where=" WHERE "+r.join(e).replace(/</g,"<").replace(/>/g,">")}else d.where=""}else d.where="";if("dataBind"===t.action&&a.virtualDataSourceOnExpand&&a.keyDataField&&a.parentDataField&&(d.where?d.where+=" AND "+a.parentDataField+" IS NULL":d.where=" WHERE "+a.parentDataField+" IS NULL"),"update"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+"='"+t.edit.row[n].replace(/</g,"<").replace(/>/g,">")+"'");null===a.id?d.update=" SET "+e.join(", "):d.update=" SET "+e.join(", ")+" WHERE "+a.id+"="+t.edit.row[a.id]}if("remove"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+" = '"+t.edit.row[n]+"'");d.remove=" WHERE "+a.id+"="+t.edit.row[a.id]}if("add"===t.action){const e=[],a=[];for(let n in t.edit.row)"$"!==n&&(a.push(n),null!==t.edit.row[n]?e.push("'"+t.edit.row[n]+"'"):e.push("null"));d.add=" ("+a.join(", ")+") VALUES ("+e.join(", ")+")"}"expand"===t.action?(a.groupDataField?d.where?d.where+=" AND "+a.groupDataField+" = '"+i[a.groupDataField]+"'":d.where=" WHERE "+a.groupDataField+" = '"+i[a.groupDataField]+"'":a.keyDataField&&a.parentDataField?d.where?d.where+=" AND "+a.parentDataField+" = "+i[a.keyDataField]:d.where=" WHERE "+a.parentDataField+" = "+i[a.keyDataField]:d.where?d.where+=" AND "+i.groupDataField+" = '"+i.label+"'":d.where=" WHERE "+i.groupDataField+" = '"+i.label+"'",d.where.indexOf("undefined")>=0&&(d.where=""),d.limit="",d.groupBy="",a.virtualDataSourceOnExpand(o,{first:n,last:r,row:t.row,sorting:t.sorting,filtering:t.filtering,grouping:t.grouping,action:t.action,query:d})):a.virtualDataSource(o,{first:n,last:r,sorting:t.sorting,edit:t.edit,filtering:t.filtering,filterOperator:t.filterOperator||"and",grouping:t.grouping,action:t.action,query:d})}else e()}add(e,t){const a=this;if(!e)return;let n=!0;const r=function(e){const r=a._getDataItem(e,a.boundSource.length);if(a.dataItemById[r.$.id])return void 0!==t&&(r.$.parentId=t),null;a[a.boundSource.length]=r,a.dataItemById[r.$.id]=r;const i=a.boundSource.push(r);return void 0!==t&&(r.$.parentId=t),i||(n=!1),r};if(e.length){let t=[];for(let a=0;a<e.length;a++){const n=r(e[a]);n&&t.push(n)}a._notify({action:"add",data:t})}else{const t=r(e);a._notify({action:"add",data:t})}return a.refreshHierarchy(),n}refreshIndexes(){const e=this;for(let t=0;t<e.boundSource.length;t++)e[t]=e.boundSource[t],e[t].$.index=t,e.dataItemById[e[t].$.id]=e[t];let t=e.boundSource.length;for(;e[t];)delete e[t],t++}removeLast(){const e=this;delete e[e.boundSource.length-1];const t=e.boundSource.pop();return delete e.dataItemById[t.$.id],e._notify({action:"removeLast",data:t}),e.refreshHierarchy(),t}removeById(e){const t=this,a=t.indexOf(t.dataItemById[e]);t.boundSource[a]&&t.removeAt(a)}remove(e){const t=this;let a=t.indexOf(e);-1===a&&e&&e.$&&(a=t.indexOf(t.dataItemById[e.$.id]));t.boundSource[a]&&t.removeAt(a)}removeAt(e){const t=this,a=t.boundSource[e];if(!a)throw new Error("Invalid Item Index");t.boundSource.splice(e,1),delete t.dataItemById[a.$.id],t.refreshIndexes(),t._notify({action:"remove",index:e,data:a}),t.refreshHierarchy()}update(e,t){const a=this;if(Smart.Utilities.Types.isArray(e)&&Smart.Utilities.Types.isArray(t)&&0===e.length&&0===t.length)return void a.refreshHierarchy();if(t.length&&e.length){let n=[];for(let r=0;r<e.length;r++){const i=a._getDataItem(t[r],e[r]),o=e[r];n.push(i),a.boundSource[o]=i,a[o]=a.boundSource[o],a.dataItemById[i.$.id]=a[o]}return a._notify({action:"update",index:e,data:n}),void a.refreshHierarchy()}const n=a._getDataItem(t,e),r=a.boundSource[e].$.id;return n.$.id=r,a.boundSource[e]=n,a[e]=a.boundSource[e],a.dataItemById[n.$.id]=a[e],a._notify({action:"update",index:e,data:n}),a.refreshHierarchy(),n}insert(e,t){const a=this;if(t.length){const n=[];for(let r=0;r<t.length;r++){const i=a._getDataItem(t[r],e+r);n.push(i)}t=n}else t=a._getDataItem(t,e);const n=a.boundSource.splice(e,0,t);return a.refreshIndexes(),a._notify({action:"insert",index:e,data:t}),a.refreshHierarchy(),n}move(e,t){if(t>e&&t-e==1||e===t)return;const a=this,n=a.boundSource.splice(e,1)[0];t>e?(t--,a.boundSource.splice(t,0,n)):a.boundSource.splice(t,0,n),a.refreshIndexes(),a._notify({action:"move",index:t,data:a.boundSource[t]}),a.refreshHierarchy()}indexOf(e){return this.boundSource.indexOf(e)}get length(){const e=this;return void 0!==e.virtualDataSourceLength?e.virtualDataSourceLength:e.dataSourceLength?e.dataSourceLength:"number"==typeof e.dataSource?e.dataSource:e.bindingCompleted?e.boundSource.length:e.dataSource&&"string"!=typeof e.dataSource&&e.dataSource.length?e.dataSource.length:e.boundSource.length}clear(){const e=this;if(!e.isInitialized)return e._cachedValues=[],void(e.dataItemById=[]);for(let t=0;t<e.boundSource.length;t++)delete e[t];e._expandedRowIds=[],e._cachedValues=[],e.boundSource=e.observable?new Smart.ObservableArray:[],e.dataItemById=[],e.refreshHierarchy()}_getId(e,t,a){if(null===e||void 0===e.name||!e.name||!t.getAttribute){if(e&&e.toString().length>0&&t.getAttribute){let a=t.getAttribute(e);if(null!==a&&a.toString().length>0)return a.trim().split(" ").join("").replace(/([ #;?%&,.+*~\':'!^$[\]()=>|\/@])/g,"");{let a=e.split(this.mapChar);if(a.length>1){let e=t;for(let t=0;t<a.length;t++)void 0!==e&&(e=e[a[t]]);if(void 0!==e)return e}else if(void 0!==t[e])return t[e]}}return a}{let n=t.getAttribute(e.name);if(null!==n&&n.toString().length>0)return n;if(e.map)try{let a=t.getAttribute(e.map);if(null!==a&&a.toString().length>0)return a}catch(e){return a}}}_buildHierarchy(){const e=this;if(e.reservedNames){const t=e.reservedNames;t.leaf||(t.leaf="leaf"),t.parent||(t.parent="parent"),t.expanded||(t.expanded="expanded"),t.checked||(t.checked="checked"),t.selected||(t.selected="selected"),t.level||(t.level="level"),t.data||(t.data="data")}else e.reservedNames={leaf:"leaf",parent:"parent",expanded:"expanded",checked:"checked",selected:"selected",level:"level",icon:"icon",data:"data"};const t=e.reservedNames;if(e.childrenDataField){const a=[];for(let n=0;n<e.boundSource.length;n++){const r=JSON.parse(JSON.stringify(e.boundSource[n]));if(!r)continue;a.push(r);const i=function(a){const n=e.childrenDataField.split(e.mapChar);let r=null;if(n.length>1){let e=a;for(let t=0;t<n.length;t++)void 0!==e&&(e=e[n[t]]);r=e}else r=a.children;a.children=r,(null===a.children||void 0===a.children||a.children&&0===a.children.length)&&(a[t.leaf]=!0)};i(r),r[t.level]=0,r.$||(r.$={}),r[t.parent]=null,r[t.data]=r,void 0===r[t.expanded]&&(r[t.expanded]=!1,e.expandHierarchy&&(r[t.expanded]=!0));const o=function(a,n){if(n)for(let r=0;r<n.length;r++){let d=e._getDataItem(n[r],r);if(d){if(i(d),!e.id){const e=function(){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()};d.$.id=e()}d[t.level]=a[t.level]+1,d[t.parent]=a,d[t.data]=Object.assign({},d),a&&(a.children[r]=d),void 0===d[t.expanded]&&(d[t.expanded]=!1,e.expandHierarchy&&(d[t.expanded]=!0)),o(d,d.children)}}else a.children=new Array};o(r,r.children)}if(e.boundHierarchy=a,!e._boundSourceUpdate){for(let t=0;t<e.boundHierarchy.length;t++){const a=e.boundHierarchy[t];if(a.children){const t=function(a){if(e.dataItemById[a.$.id]||(e.boundSource.canNotify=!1,e.dataItemById[a.$.id]=a,e.boundSource.canNotify=!0),a.children)for(let e=0;e<a.children.length;e++){const n=a.children[e];n.children&&t(n)}};t(a)}}e._boundSourceUpdate=!0}}if(e.xmlRoot&&"xml"===e.dataSourceType&&(e.boundHierarchy=this._getHierarchy("uid","_parentuid","children",null,e.boundSource)),e.keyDataField&&e.parentDataField)return["keyDataField","parentDataField"].forEach((t=>{switch(e[t]){case"parent":e[t]="$"+e[t]}})),void(e.boundHierarchy=this._getHierarchy(e.keyDataField,e.parentDataField,"children",null,e.boundSource));e.groupBy&&e.groupBy.length>0?e.boundHierarchy=this._getGroupHierarchy(e.groupBy,"children","label",null,"data",null,"parent",e.boundSource):e.virtualDataSourceOnExpand&&(e.boundHierarchy=this._getHierarchy("id","parentId","children",null,e.boundSource))}_getGroupHierarchy(e,t,a,n,r,i,o,d,l){let s=this;l||(l=0);let c=s.reservedNames;const u=s.boundSource.canNotify;s.boundSource.canNotify=!1;const f=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()};let h=new Array;for(let t=0;t<e.length;t++)h[t]=f();t||(t="children"),a||(a="group"),r||(r="item"),o||(o="parent"),void 0===i&&(i="value");const p=new Array,g=new Array;let S=0;const y=function(t){let a=t;for(let n=0;n<e.length;n++){if(void 0===t[e[n]]){a=s._getDataItem(t,t.$.index);break}}if(n)for(let e in n){const t=n[e];t.name&&t.map&&(a[t.map]=a[t.name])}return a};let m=!1;for(let n=0;n<d.length;n++){let u=y(d[n]);u[c.leaf]=!1;let T=new Array,b=0;for(let t=0;t<e.length;t++){const a=e[t],n=u[a];null!=n?((""===n||void 0===n&&0===t)&&(m=!0),T[b++]={value:n,group:a,hash:h[t]}):(T[b++]={value:null,group:a,hash:h[t]},0===t&&(m=!0))}if(T.length!==e.length)break;let x=null,v="";for(let e=0;e<T.length;e++){const n=T[e].value,d=T[e].group;if(v=v+"_"+T[e].hash+"_"+n,void 0===g[v]||null===g[v]){if(null===x){x={$:{}},x[c.level]=0,x[c.leaf]=!1,x[o]=null,x[a]=n,x[r]=u,x.groupDataField=d,x[d]||(x[d]=x.data[d]),void 0!==u[c.expanded]?x[c.expanded]=u[c.expanded]:(x[c.expanded]=!1,s.expandHierarchy&&(x[c.expanded]=!0)),i&&(x[i]=u[i]),x[t]=new Array;let e=p.length+l;this.id&&"number"!=typeof u.$.id&&!isFinite(u.$.id)||(e="Item"+e),void 0===x.$.id&&(x.$.id=e),s._expandedRowIds[x.$.id]&&(x[c.expanded]=!0),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[x.$.id]&&(x[c.expanded]=!1),p[S++]=x}else{const e={$:{}};e[c.level]=x[c.level]+1,e[o]=x,e[a]=n,e[t]=new Array,e[r]=u,e.groupDataField=d,e[c.leaf]=!1,e[d]||(e[d]=e.data[d]),void 0!==u[c.expanded]?e[c.expanded]=u[c.expanded]:(e[c.expanded]=!1,s.expandHierarchy&&(e[c.expanded]=!0)),i&&(e[i]=u[i]),void 0===e.$.id&&(e.$.id=x.$.id+"_"+x[t].length),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[e.$.id]&&(e[c.expanded]=!1),s._expandedRowIds[e.$.id]&&(e[c.expanded]=!0),x[t][x[t].length]=e,x=e}g[v]=x}else x=g[v]}u&&(u[c.leaf]=!0),null!==x?(null===this.id?void 0===u.$.id&&(u.$.id=x.$.id+"_"+x[t].length):void 0===u.$.id&&-1===u.$.id.toString().indexOf(x.$.id)&&(u.$.id=x.$.id+"_"+u.$.id),u[o]=x,u[c.level]=x[c.level]+1,x[t][x[t].length]=u):void 0===u.$.id&&(u.$.id=f())}if(m){let e=null,t=!1;for(let a=0;a<p.length;a++){const n=p[a];if(!n[n.groupDataField]){e=n,e.$.id.toString().startsWith("Item")&&(t=!0),p.splice(a,1);break}}if(e&&(p.push(e),t))for(let e=0;e<p.length;e++){const t=p[e];t.$.id="Item"+e,Object.keys(s._expandedRowIds).length>0&&(s._expandedRowIds[t.$.id]?t[c.expanded]=!0:t[c.expanded]=!1,s.expandHierarchy&&(t[c.expanded]=!0,s._collapsedIds&&s._collapsedIds[t.$.id]&&(t[c.expanded]=!1)))}}return s.boundSource.canNotify=u,p}_getHierarchy(e,t,a,n,r){const i=this,o=new Array;let d=this.boundSource;if(r&&(d=r),0===this.boundSource.length)return null;const l=null!==a?a:"children";let s=new Array,c=d,u=c.length,f=i.reservedNames;const h=function(e){let t=e;if(n)for(let e in n){const a=n[e];a.name&&a.map&&(t[a.map]=t[a.name])}return t};for(let a=0;a<u;a++){let n=c[a],r=n[t],o=n[e];"parentId"===t&&(r=n.$.parentId),"id"===e&&(o=n.$.id),null===o&&(o=n[e]=n.$.id),n[l]=new Array,i.expandHierarchy&&void 0===n[f.expanded]&&(n[f.expanded]=i.expandHierarchy),s[o]={parentId:r,item:n}}for(let a=0;a<u;a++){const n=c[a];let r=n[t],i=n[e];if("parentId"===t&&(r=n.$.parentId),"id"===e&&(i=n.$.id),void 0!==s[r]){let e={parentId:r,item:s[i].item},t=s[r].item;t[l]||(t[l]=new Array);let a=t[l].length;e=e.item,f?e[f.parent]=t:e.parent=t;const n=h(e);t[l][a]=n,s[r].item=t,s[i].item=e}else{let e=s[i].item;f?void 0===e[f.parent]&&(e[f.parent]=null):void 0===e.parent&&(e.parent=null);const t=h(e);f?t[f.level]=0:t.level=0,o[o.length]=t}}if(0!==o.length){let e=function(t,a){for(let n=0;n<a.length;n++){const r=a[n];f?r[f.level]=t:r.level=t;const o=r[l];o&&o.length>0?(r.leaf=!1,e(t+1,o)):i.virtualDataSourceOnExpand?void 0===r.leaf&&(r.leaf=!1):f?r[f.leaf]=!0:r.leaf=!0}};e(0,o)}return o}summarize(e,t){const a=this;Array.isArray(e)||(e=[e]);let n=[];for(let t=0;t<e.length;t++){const a=e[t];for(let e in a){const t=a[e];n.push({dataField:e,functions:t})}}e=n;let r={},i=new Array;t||(t=a.boundSource);let o=t.length,d=0;if(0!==o&&void 0!==o){for(let a=0;a<o;a++){let n=t[a];if((!n||!n.$||!1!==n.$.filtered)&&n){d++;for(let t=0;t<e.length;t++){const o=e[t];let d=n[o.dataField];if(void 0!==d&&"uncategorized"!==d||(d=""),o.functions&&o.functions.length>0){r[o.dataField]=r[o.dataField]||{},i[o.dataField]=i[o.dataField]||0,i[o.dataField]++;const e=function(e){for(let t in e){let a=r[o.dataField][t];null==a&&(r[o.dataField][t]=0,a=0),"function"==typeof e[t]&&(a=e[t](a,d,o.dataField,n)),r[o.dataField][t]=a}},t=d;let l=parseFloat(d);l=!isNaN(l),t&&t.toDate&&(l=!1),"string"==typeof d&&d.startsWith("+")&&(l=!1),l&&(d=parseFloat(d)),"number"==typeof d&&isFinite(d)?o.functions.forEach((function(t){let n=r[o.dataField][t];if(null==n&&(n=0,"min"===t&&(n=9999999999999),"max"===t&&(n=-9999999999999),"median"===t&&(n=[])),"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t)n+=parseFloat(d);else if("product"===t)0===a?n=parseFloat(d):n*=parseFloat(d);else if("min"===t)n=Math.min(n,parseFloat(d));else if("max"===t)n=Math.max(n,parseFloat(d));else if("count"===t)n++;else if("median"===t)n.push(parseFloat(d));else if("blank"===t)n=r[o.dataField][t],null==n&&(n=0),d||n++;else if("filled"===t)n=r[o.dataField][t],null==n&&(n=0),void 0!==d&&n++;else if("unique"===t)n=r[o.dataField][t],null==n&&(n=[]),-1===n.indexOf(d)&&n.push(d);else if("status"===t)n=r[o.dataField][t],null==n&&(n=[]),n[d]||(n[d]=[]),n[d].push(d);else if("object"==typeof t)return void e(t);r[o.dataField][t]=n})):o.functions.forEach((function(t){if("min"===t||"max"===t||"count"===t||"product"===t||"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t){if(null===d&&"count"!==t)return!0;let e=r[o.dataField][t];return null==e&&(e=0),r[o.dataField][t]=e,!0}if("blank"===t){let e=r[o.dataField][t];null==e&&(e=0),d||e++,r[o.dataField][t]=e}else if("filled"===t){let e=r[o.dataField][t];null==e&&(e=0),d&&e++,r[o.dataField][t]=e}else if("unique"===t){let e=r[o.dataField][t];null==e&&(e=[]),-1===e.indexOf(d)&&e.push(d),r[o.dataField][t]=e}else if("status"===t){let e=r[o.dataField][t];null==e&&(e=[]),e[d]||(e[d]=[]),e[d].push(d),r[o.dataField][t]=e}"object"==typeof t&&e(t)}))}}}}for(let a=0;a<e.length;a++){const n=e[a];if(n.functions&&(!n.functions||0!==n.functions.length)){if(r[n.dataField]||(r[n.dataField]={},n.functions.forEach((function(e){r[n.dataField][e]=0}))),void 0!==r[n.dataField].avg){const e=r[n.dataField].avg,t=i[n.dataField];r[n.dataField].avg=0===t||void 0===t?0:e/t}else void 0!==r[n.dataField].count&&(r[n.dataField].count=d);if(void 0!==r[n.dataField].unique){const e=r[n.dataField].unique;r[n.dataField].unique=e.length}if(void 0!==r[n.dataField].status){const e=r[n.dataField].status;r[n.dataField].status=e}if(void 0!==r[n.dataField].median){let e=r[n.dataField].median;e.sort((function(e,t){return e-t})),r[n.dataField].median=.5*(e[Math.floor((e.length+1)/2)-1]+e[Math.ceil((e.length+1)/2)-1])}(r[n.dataField].stdev||r[n.dataField].stdevp||r[n.dataField].var||r[n.dataField].varp)&&n.functions.forEach((function(e){if("stdev"===e||"var"===e||"varp"===e||"stdevp"===e){const a=r[n.dataField][e],i=o,d=a/o;let l=0;for(let e=0;e<o;e++){let a=t[e][n.dataField];l+=(a-d)*(a-d)}let s="stdevp"===e||"varp"===e?i:i-1;0===s&&(s=1),"var"===e||"varp"===e?r[n.dataField][e]=l/s:"stdevp"!==e&&"stdev"!==e||(r[n.dataField][e]=Math.sqrt(l/s))}}))}}return r}}_getDataItem(e,t){const a=this,n={},r="number"==typeof a.dataSource||a.dataSourceLength;if(!e)return{$:{id:t,isEmpty:!0,index:t}};if("string"==typeof e&&(e={"":e}),r){for(let e=0;e<a.dataFields.length;e++){n[(a.dataFields?a.dataFields[e]:{}).name]=""}return n.$={},n.$.id=t,n.$.index=t,n}const i=e;if(void 0!==i.expanded&&(n.expanded=i.expanded,"true"===i.expanded||!0===i.expanded||1===i.expanded?n.expanded=!0:n.expanded=!1),a.childrenDataField?void 0!==i[a.childrenDataField]&&(n.children=i[a.childrenDataField]):void 0!==i.children?n.children=i.children:void 0!==i.items&&(n.children=i.items),void 0!==i.leaf&&(n.leaf=i.leaf),void 0!==i.level&&(n.level=i.level),a.keyDataField&&void 0!==i[a.keyDataField]&&(n[a.keyDataField]=i[a.keyDataField]),a.parentDataField&&void 0!==i[a.parentDataField]&&(n[a.parentDataField]=i[a.parentDataField]),0===a.dataFields.length){const t=Object.getOwnPropertyNames(e);for(let e=0;e<t.length;e++)"$"!==t[e]&&a.dataFields.push({name:t[e],dataType:"string"})}for(let t=0;t<a.dataFields.length;t++){const r=a.dataFields?a.dataFields[t]:{};let o="";if(null==r)continue;if(e.length&&(o=e[t]),r.map){let e=r.map.split(a.mapChar);if(e.length>0){let t=i;for(let a=0;a<e.length;a++)i&&t&&(t=t[e[a]]);o=t}else o=i[r.map]}null!=o?o=o.toString():void 0===o&&null!==o&&(o="");let d=!1;if(""===o&&(d=!0,o=e[r.name],void 0===r.dataType&&(r.dataType="any"),null!=o?"array"!==r.dataType&&("any"===r.dataType?o=Array.isArray(e[r.name])?[...e[r.name]]:"object"==typeof e[r.name]?Object.assign({},e[r.name]):e[r.name]:"date"!==r.dataType&&(o=o.toString())):o=void 0===o&&"any"===r.dataType?null:""),"[object Object]"===o&&r.map&&d&&(o=""),a._cachedValues[o+"_"+r.dataType])o=a._cachedValues[o+"_"+r.dataType];else{if("bool"===r.dataType||"boolean"===r.dataType)"true"===o||"1"===o?o=!0:"false"!==o&&"0"!==o||(o=!1);else if("number"===r.dataType)-1===o.indexOf(".")&&o.indexOf(",")>=0&&o.substring(1+o.indexOf(",")).length<3&&(o=o.replace(",",".")),o=a.$document.deserialize(""+o,r.dataType,!0);else if("date"===r.dataType){if(o&&"string"==typeof o&&o.indexOf("[")>=0){const e=JSON.parse(o);if(r.formatString&&Smart.Utilities.DateTime){const t=Smart.Utilities.DateTime.ParseDate(e[0],r.formatString),a=Smart.Utilities.DateTime.ParseDate(e[1],r.formatString);e[0]=t,e[1]=a}else{const t=a.$document.deserialize(""+e[0],r.dataType,!0),n=a.$document.deserialize(""+e[1],r.dataType,!0);e[0]=t,e[1]=n}o=e,n[r.name]=o;continue}if(r.formatString&&Smart.Utilities.DateTime){o=Smart.Utilities.DateTime.ParseDate(o,r.formatString)}else o=a.$document.deserialize(""+o,r.dataType,!0)}else"any"!==r.dataType&&(o="string"===r.dataType&&"null"===o?"null":a.$document.deserialize(""+o,r.dataType,!0));"any"!==r.dataType&&(a._cachedValues[o+"_"+r.dataType]=o)}"string"!==r.dataType&&"boolean"!==r.dataType&&"bool"!==r.dataType&&"any"!==r.dataType&&(isNaN(o)||o===-1/0||o===1/0)&&(o="date"===r.dataType||"number"===r.dataType?null:0),"parent"!==r.name&&"group"!==r.name&&"leaf"!==r.name&&"level"!==r.name?("string"===r.dataType&&/<.+?>/.test(o)&&o.replace&&("all"===a.sanitizeHTML?o=o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):"blackList"===a.sanitizeHTML&&(o=window.Smart.Utilities.Core.sanitizeHTML(o),o.indexOf("<br")>=0&&(o=o.replaceAll("<br/>","\n\r"),o=o.replaceAll("<br>","\n\r")))),n[r.name]=o):n.$[r.name]=o}let o=t;if(a.id){if(o=i[a.id],void 0===o){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};o=e()+e()}"object"==typeof o&&(o=t),i.$&&void 0!==i.$.id&&(o=i.$.id)}else if(!a.virtualDataSource&&a.dataItemById&&a.dataItemById[o])for(o=a.length;a.dataItemById[o];)o++;return n.$||(n.$={}),n.$.id=o,n.$.index=t,new Object(n)}_bindToArray(){const e=this,t="number"==typeof e.dataSource||e.dataSourceLength,a=[];e.boundSource.canNotify=!1;const n=t?"number"==typeof e.dataSource?e.dataSource:e.dataSource.length:e.observable?e.length:e.dataSource.length;for(let r=0;r<n;r++){const n=t?{}:e.dataSource[r],i=e._getDataItem(n,r);a.push(i)}if(t&&e.dataSourceLength&&e.dataSource.length>0)for(let t=0;t<e.dataSource.length;t++){const n=e.dataSource[t].cell,r=e.dataSource[t].value,i=n.replace(/[^0-9]/g,""),o=n.replace(/[0-9]/g,"");a[i-1][o]=r}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(a),e.observable&&(e.boundSource=new Smart.ObservableArray(a));for(let t=0;t<n;t++)e.observable?e[t]=e.boundSource[t]:e[t]=a[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=a),e.boundSource.canNotify=!0}_bindToICS(){const e=this,t=""+e.dataSource,a=e.rowDelimiter||"\n",n=t.split("\r"),r=[];let i=t.split(a),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=function(e,t){var a=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z)?$/.exec(e);if(!a)throw new Error("Invalid UNTIL value: "+e);return t?new Date(a[1],a[2]-1,a[3],0,0,0,0):new Date(Date.UTC(a[1],a[2]-1,a[3],a[5]||0,a[6]||0,a[7]||0))};for(let e=0;e<o;e++){const t=i[e].trim();if(t.indexOf("BEGIN:VEVENT")>=0)var l={};else if(l)if(t.indexOf("BEGIN:VALARM")>=0)var s={};else{if(s){if(t.indexOf("ACTION")>=0){s.ACTION=t.substring(t.indexOf("ACTION")+7);continue}if(t.indexOf("DESCRIPTION")>=0){s.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);continue}if(t.indexOf("TRIGGER")>=0){s.TRIGGER=t.substring(t.indexOf("TRIGGER")+8);continue}if(t.indexOf("END:VALARM")>=0){l.ALARM||(l.ALARM=[]),l.ALARM.push(s),s=void 0;continue}}if(t.indexOf("SUMMARY")>=0)l.SUMMARY=t.substring(t.indexOf("SUMMARY")+8);else if(t.indexOf("LOCATION")>=0)l.LOCATION=t.substring(t.indexOf("LOCATION")+9);else if(t.indexOf("DESCRIPTION")>=0)l.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);else if(t.indexOf("RRULE")>=0)l.RRULE=t.substring(t.indexOf("RRULE")+6);else if(t.indexOf("RECURRENCE-ID")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID")+14);else if(t.indexOf("RECURRENCE-ID;VALUE=DATE")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID;VALUE=DATE")+25);else if(t.indexOf("EXDATE;VALUE=DATE")>=0){const e=t.substring(t.indexOf("EXDATE;VALUE=DATE")+20);l.EXDATE=e}else if(t.indexOf("EXDATE")>=0){const e=t.substring(t.indexOf("EXDATE")+7);l.EXDATE=e}else t.indexOf("DTEND;VALUE=DATE")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND;VALUE=DATE")+17),!0):t.indexOf("DTEND")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND")+6)):t.indexOf("DTSTART;VALUE=DATE")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART;VALUE=DATE")+19),!0):t.indexOf("DTSTART")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART")+8)):t.indexOf("UID")>=0?l.uid=l.UID=t.substring(t.indexOf("UID")+4):t.indexOf("STATUS")>=0?l.STATUS=t.substring(t.indexOf("STATUS")+7):t.indexOf("TITLE")>=0?l.TITLE=t.substring(t.indexOf("TITLE")+6):t.indexOf("CATEGORIES")>=0?l.CATEGORIES=t.substring(t.indexOf("CATEGORIES")+11):t.indexOf("END:VEVENT")>=0&&(r.push(l),l.ALARM&&(l.ALARM=JSON.stringify(l.ALARM)),s=void 0)}}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_bindToJSON(){const e=this,t=[],a=e.dataSource.length?e.dataSource:Object.entries(e.dataSource);e.boundSource.canNotify=!1;for(let n=0;n<a.length;n++){const r=a[n],i=e._getDataItem(r,n);t.push(i)}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(t);for(let t=0;t<e.length;t++)e[t]=e.boundSource[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=t),e.boundSource.canNotify=!0}sortBy(e,t,a){const n=this;if(!t)for(let a=0;a<n.dataFields.length;a++){const r=n.dataFields[a];if(r.name===e){t=r.dataType;break}}if(n.boundHierarchy){if((!e||0===e.length)&&n.groupBy.length>0)return void n.refreshHierarchy();const r=(e=>{let t=[];for(;e;){t=t.concat(e);for(let a=0;a<e.length;a++)e[a].children&&(t=t.concat(e[a].children));e=e.children}return t})(n.boundHierarchy);if(r){r.find((e=>{if(e.summaryRow)return e}))&&n.refreshHierarchy()}const i=function(r){n._sort(r,e,a,t);for(let n=0;n<r.length;n++){const o=r[n];o.children&&i(o.children,e,a,t)}};i(n.boundHierarchy)}else n._sort(n.boundSource,e,a,t)}_createFilter(e,t){const a={"=":"EQUAL","<>":"NOT_EQUAL","!=":"NOT_EQUAL",not_like:"DOES_NOT_CONTAIN",like:"CONTAINS","<":"LESS_THAN",">":"GREATER_THAN","<=":"LESS_THAN_OR_EQUAL",">=":"GREATER_THAN_OR_EQUAL",equal:"EQUAL","not equal":"NOT_EQUAL","less than":"LESS_THAN","greater than":"GREATER_THAN","greater than or equal":"GREATER_THAN_OR_EQUAL","less than or equal":"LESS_THAN_OR_EQUAL","starts with":"STARTS_WITH","ends with":"ENDS_WITH",notEqual:"NOT_EQUAL",not_equal:"NOT_EQUAL",lessThan:"LESS_THAN",greaterThan:"GREATER_THAN",greaterThanOrEqual:"GREATER_THAN_OR_EQUAL",lessThanOrEqual:"LESS_THAN_OR_EQUAL",less_than:"LESS_THAN",greater_than:"GREATER_THAN",greater_than_or_equal:"GREATER_THAN_OR_EQUAL",less_than_or_equal:"LESS_THAN_OR_EQUAL",null:"null","":"EMPTY",isblank:"EMPTY",isnotblank:"NOT_EMPTY",isBlank:"EMPTY",isNotBlank:"NOT_EMPTY",CONTAINS:"CONTAINS",DOES_NOT_CONTAIN:"DOES_NOT_CONTAIN",contains:"CONTAINS",does_not_contain:"DOES_NOT_CONTAIN","not contains":"DOES_NOT_CONTAIN",notcontains:"DOES_NOT_CONTAIN",notContains:"DOES_NOT_CONTAIN",startswith:"STARTS_WITH",endswith:"ENDS_WITH",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH",startsWith:"STARTS_WITH",endsWith:"ENDS_WITH",NULL:"NULL",NOT_NULL:"NOT_NULL"};let n=[];"string"==typeof t&&(t=[t]);for(let e=0;e<t.length;e++){const a=t[e],r=-1===a.indexOf('"')?a.split(" "):a.split('"');let i=[];for(let e=0;e<r.length;e++){const t=r[e];if(""!==t&&" "!==t){if("true"===t.trim()){i.push(!0);continue}if("false"===t.trim()){i.push(!1);continue}if(t.indexOf(" GMT")>=0)i.push(t.trim());else if(t.indexOf("or ")>=0||t.indexOf("and ")>=0||t.indexOf("1 ")>=0||t.indexOf("0 ")>=0||t.indexOf("| ")>=0||t.indexOf("& ")>=0){const e=t.trim().split(" ");if(e.length>1){const t=e[0].trim(),a=e[1].trim();"1"===t?i.push("or"):"0"===t?i.push("and"):i.push(t),i.push(a)}else i.push(t.trim())}else i.push(t.trim())}}n.push(i)}const r=new Smart.FilterGroup,i=[],o=[];for(let t=0;t<n.length;t++){const r=n[t];if(r.length>1){const t=new Smart.FilterGroup;let n=r.length>2?"":"and",i=0,d=[];for(let o=0;o<r.length;o++){let l=r[o];if("and"!==l&&"or"!==l){if(i++,2===i){let s=a[r[o-1]];s||(s=r[o-1]),"number"===e&&(l=parseFloat(l)),"date"===e&&(l=new Date(l));const c=t.createFilter(e,l,s);if(i=0,d.push(c),n){for(let e=0;e<d.length;e++)t.addFilter(n,d[e]);d=[]}}}else n=l}o.push(t)}else{let e=r[0];if(e&&a[e]&&(e="and"),"and"!==e&&"or"!==e)throw new Error('Filter Exprresion expects "AND" or "OR", but the token is: '+e);i.push(e)}}let d=0;if(1===o.length)return o[0];for(let e=0;e<o.length;e++){let t=i[d];(e+1)%2==0&&d++,t||(t="and"),r.addFilter(t,o[e])}return r}filterBy(e,...t){const a=this,n=(()=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}})(),r=a._createFilter(n,t);return a.boundSource.filter((t=>r.evaluate(t[e])))}_filter(e,t="and"){const a=this,n=[],r=[];if(0===e.length)return void a.clearFilter();const i=e=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}};let o,d;"and"===t?(o=!0,d=function(e,t,a){return e&&t.evaluate(a[t.dataField])}):(o=!1,d=function(e,t,a){return e||t.evaluate(a[t.dataField])});for(let t=0;t<e.length;t++){const o=e[t],d=o[0];let l=null;l=o[1]instanceof Smart.FilterGroup?o[1]:a._createFilter(i(d),o.splice(1)),l&&(r.push(d),l.dataField=d,n.push(l))}if(a.boundHierarchy){const e=function(e){let t=o;for(let a=0;a<n.length;a++){const r=n[a];t=d(t,r,e)}return e.$.filtered=t,t},t=function(n,r,i){let o=0;for(let a=0;a<n.length;a++){const i=n[a];e(i),i.$.filtered&&o++,i.children&&t(i.children,i,r)}o>0&&a.groupBy.length>0&&r?(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0)):o>0&&o!==n.length&&r?(r.$.filtered=null,i&&!i.$.filtered&&(i.$.filtered=null)):o>0&&o===n.length&&r&&(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0))};t(a.boundHierarchy,null,null)}else for(let e=0;e<a.boundSource.length;e++){const t=a.boundSource[e];let r=o;for(let e=0;e<n.length;e++){const a=n[e];r=d(r,a,t)}t.$.filtered=r}a.onFilter&&a.onFilter()}clearGroup(){const e=this;e.groupBy=[],e.boundHierarchy=null,e.refreshHierarchy(),e.onGroup&&e.onGroup()}clearFilter(){const e=this;for(let t=0;t<e.boundSource.length;t++){e.boundSource[t].$.filtered=!0}if(e.boundHierarchy){const t=function(e,a,n){for(let n=0;n<e.length;n++){const r=e[n];r.$.filtered=!0,r.$.filtered,r.children&&t(r.children,r,a)}a&&(a.$.filtered=!0,n&&!n.$.filtered&&(n.$.filtered=!0))};t(e.boundHierarchy,null,null)}e.onFilter&&e.onFilter()}clearSort(){this._sort(this.boundSource,[],[],[])}_sort(e,t,a,n,r,i){const o=this;let d=!1;if(0===e.length)return;if(e&&e.constructor&&e instanceof Smart.ObservableArray&&(d=!0),(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)&&!d&&!o.boundHierarchy){if(o.virtualDataSource)return;throw new Error("sort: Missing or Invalid arguments!")}"string"==typeof t&&(t=[t]);const l=[],s=[];void 0===a&&(a=[]);const c=function(e,t){let a;switch(t||typeof e){case"string":a=(new Intl.Collator).compare;break;case"number":case"int":case"bigInt":case"float":case"double":a=function(e,t){return e-t};break;case"boolean":case"bool":a=function(e,t){return e===t?0:!1===e?-1:1};break;case"date":case"time":case"dateTime":a=e instanceof Date?function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0}:e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber?function(e,t){return e.compare(t)}:function(e,t){return e-t};break;case"object":if(e instanceof Date)a=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)a=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;a=function(t,a){return e.compareComplexNumbers(t,a)}}}return a};for(let r=0;r<t.length;r++){void 0===a[r]||"asc"===a[r]||"ascending"===a[r]?l[r]=1:l[r]=-1;let d=e[0][t[r]];if(void 0===d&&e[0]&&e[0].children&&e[0].data&&(d=e[0].data[t[r]]),i&&i){const e=t[r];if(i[e]){s[r]=i[e];continue}}o.sortComparators&&o.sortComparators[t[r]]?s[r]=o.sortComparators[t[r]]:s[r]=c(d,n[r])}t.length>0&&r?r(e,t,a,s):e.sort((function(e,a){for(let n=0;n<t.length;n++){const r=s[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e.$.index?(e.$.index-a.$.index)*l[n]:0}return r*l[n]}if(0===t.length)return e.$.index<a.$.index?-1:e.$.index>a.$.index?1:0}));for(let t=0;t<e.length;t++)o[t]=e[t]}static Filter(e,t,a,n,r="and"){let i,o;"and"===r?(i=!0,o=function(e,t,a,r){return n?e&&n(t,a,r):e&&r.evaluate(t[a])}):(i=!1,o=function(e,t,a,r){return n?e||n(t,a,r):e||r.evaluate(t[a])});return e.filter((e=>{let n=i;for(let r=0;r<a.length;r++){const i=a[r],d=t[r];n=o(n,e,d,i)}return n}))}filter(e,t,a){Smart.DataAdapter.Filter(this.boundSource,e,t,a)}sort(e,t,a){Smart.DataAdapter.Sort(this.boundSource,e,t,a)}static Sort(e,t,a,n){const r=function(e){let t;switch(typeof e){case"string":if(e.indexOf("-")>=0||e.indexOf("/")>=0){const t=new Date(e);if(t&&"Invalid Date"!==t.toString()){return function(e,t){const a=new Date(e),n=new Date(t);return a||n?a?n?a.getTime()-n.getTime():1:-1:0}}}t=(new Intl.Collator).compare;break;case"number":t=function(e,t){return e-t};break;case"boolean":t=function(e,t){return e===t?0:!1===e?-1:1};break;case"object":if(e instanceof Date)t=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)t=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;t=function(t,a){return e.compareComplexNumbers(t,a)}}else t=function(e,t){return e-t}}return t};if(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)return;"string"==typeof t&&(t=[t]);const i=[],o=[];void 0===a&&(a=[]);for(let n=0;n<t.length;n++)void 0===a[n]||"asc"===a[n]||"ascending"===a[n]?i[n]=1:i[n]=-1,o[n]=r(e[0][t[n]]);if(n)return void n(e,t,a,o);const d=e.slice(0);return d.sort((function(e,a){for(let n=0;n<t.length;n++){const r=o[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e._index?(e._index-a._index)*i[n]:0}return r*i[n]}})),d}};class e{constructor(e,t){const a=this;a.config=e,a.callback=t,!1!==e.autoFetch&&a.call(e)}call(e){const t=this;e||(e=t.config);let a="GET",n=e.url,r=null,i=!0;if(e.type&&(a=e.type),e.data)if("GET"===a){n+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(n+=encodeURI(t+"="+e.data[t]+"&"));"&"===n.charAt(n.length-1)&&(n=n.slice(0,n.length-1))}else"POST"===a&&(r=JSON.stringify(e.data));e&&!1===e.async&&"xlsx"!==e.dataSourceType&&(i=!1),void 0!==window.fetch&&i?t.ajaxFetch(e,a,n,r):t.ajaxXMLHttpRequest(e,a,n,r,i)}ajaxFetch(e,t,a,n){const r=this,i={method:t};let o,d,l,s;switch(e.dataSourceType){case"json":o="json";break;case"xlsx":o="arrayBuffer";break;default:o="text"}if(e&&e.contentType&&(i.headers=new Headers({"Content-Type":e.contentType})),null!==n&&(i.body=n),e.timeout&&(l=setTimeout((function(){s=!0}),e.timeout)),e.beforeSend){if(!1===e.beforeSend(i,e))return}fetch(a,i).then((function(e){if(s)throw d=408,new Error("timeout");if(l&&clearTimeout(l),d=e.status,!e.ok)throw new Error(e.statusText);return e[o]()})).then((function(t){if("arrayBuffer"===o)return JSZip.loadAsync(t).then((function(t){return t.files["xl/worksheets/sheet1.xml"].async("text").then((function(a){return t.files["xl/sharedStrings.xml"].async("text").then((function(t){const n=r.parseXLSXData(a,t);r.ajaxComplete(e,n,d)}))}))}));r.ajaxComplete(e,t,d)})).catch((function(t){"JSZip is not defined"===t.message&&(t.message="JSZip is not defined. Please include a reference to JSZip to be able to load data from XLSX files."),e&&e.loadError&&e.loadError(d,t),r.callback&&r.callback(t,d)}))}ajaxXMLHttpRequest(e,t,a,n,r){const i=new XMLHttpRequest,o=this;if(i.open(t,a,r),i.ontimeout=function(){e&&e.loadError&&e.loadError(408,"timeout")},i.onload=function(){if(4===i.readyState){const t=i.status;let a=i.response;t>=200&&t<=299?("json"===e.dataSourceType&&(a=JSON.parse(a)),o.ajaxComplete(e,a,t)):e&&e.loadError&&e.loadError(t,a)}},i.onerror=function(){e&&e.loadError&&e.loadError(i.status,i.response)},e&&e.contentType&&i.setRequestHeader("Content-Type",e.contentType),r&&e.timeout&&(i.timeout=e.timeout),e.beforeSend){if(!1===e.beforeSend(i,e))return}i.send(n)}ajaxComplete(e,t,a){if(e){if(e.beforeLoadComplete){const a=e.beforeLoadComplete(t);a&&(t=a)}e.loadComplete&&e.loadComplete(t,a),this.callback&&this.callback(t,a)}}parseXLSXData(e,t){const a=new DOMParser,n=a.parseFromString(t,"text/xml"),r=Array.from(n.getElementsByTagName("si")),i=[],o=a.parseFromString(e,"text/xml"),d=Array.from(o.getElementsByTagName("row")),l=[];return r.forEach((function(e){let t=e.getElementsByTagName("t");if(1===t.length)i.push(t[0].innerHTML);else{let e="";t=Array.from(t),t.forEach((function(t){e+=t.innerHTML})),i.push(e)}})),d.forEach((function(e){const t={};Array.from(e.getElementsByTagName("c")).forEach((function(e){const a=e.getAttribute("r").match(/\D+/)[0],n=e.getAttribute("t"),r=e.getElementsByTagName("v")[0].innerHTML;let o;switch(n){case"s":o=i[parseFloat(r)];break;case"b":o=1===parseFloat(r);break;default:o=parseFloat(r)}t[a]=o})),l.push(t)})),l}}Smart.Ajax=window.Ajax=e})();
|
|
102
102
|
|
|
103
103
|
/***/ }),
|
|
104
104
|
|
|
@@ -147,7 +147,7 @@ Smart.Utilities.Assign("DataExporter",class{constructor(e,t,a,o){const l=this;e|
|
|
|
147
147
|
/***/ 8588:
|
|
148
148
|
/***/ (() => {
|
|
149
149
|
|
|
150
|
-
Smart("smart-input",class extends Smart.BaseElement{static get properties(){return{autoCompleteDelay:{value:100,type:"number"},dataSource:{type:"any",value:[],reflectToAttribute:!1},dropDownClassList:{value:[],type:"array",reflectToAttribute:!1},dropDownDataSource:{type:"any",reflectToAttribute:!1,value:[]},dropDownHeight:{type:"any",value:200},dropDownOpenMode:{allowedValues:["default","manual"],value:"default",type:"string"},dropDownAppendTo:{value:null,type:"any"},dropDownWidth:{type:"any",value:null},dropDownButtonPosition:{allowedValues:["none","left","right"],value:"none",type:"string"},dropDownOpenPosition:{allowedValues:["bottom","top","auto"],value:"bottom",type:"string"},dropDownPlaceholder:{type:"string",value:""},hint:{type:"string",value:""},inputPurpose:{type:"string",value:"off"},items:{type:"number",value:8},minLength:{type:"number",value:1},maxLength:{type:"number",value:99999999},name:{value:"",type:"string"},prefix:{value:"",type:"string",reflectToAttribute:!1},suffix:{value:"",type:"string",reflectToAttribute:!1},onAffixClick:{value:null,type:"any",reflectToAttribute:!1},opened:{value:!1,type:"boolean"},query:{type:"string",value:""},queryMode:{allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string",value:"containsIgnoreCase"},placeholder:{value:"",type:"string"},readonly:{type:"boolean",value:!1},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},selectedIndex:{type:"number",value:-1},selectedValue:{type:"any",value:""},selectedValues:{value:[],type:"array"},type:{type:"string"},value:{type:"string",value:""},innerHTML:{type:"string",reflectToAttribute:!1}}}static get styleUrls(){return["smart.textbox.css"]}template(){return'<div id="inputContainer" role="presentation"><div id="optionsContainer" inner-h-t-m-l=\'{{innerHTML}}\' class="smart-hidden"></div><span class="smart-input-prefix" id="prefix" inner-h-t-m-l=\'{{prefix}}\'></span><input maxlength=\'[[maxLength]]\' class="smart-input" id=\'input\' readonly=\'[[readonly]]\' placeholder=\'[[placeholder]]\' type=\'[[type]]\' name=\'[[name]]\' value=\'{{value::keyup}}\' disabled=\'[[disabled]]\' aria-label="[[placeholder]]" /><span class="smart-hidden smart-hint" id="span">[[hint]]</span><span id="suffix" class="smart-input-suffix" inner-h-t-m-l=\'{{suffix}}\'></span><div id="dropDownButton" tabindex=-1 class="smart-drop-down-button" role="button" aria-label="Toggle popup"><div id="arrow" class="arrow" aria-hidden="true"></div></div></div>'}static get listeners(){return{"input.focus":"_focusHandler","input.blur":"_blurHandler","input.keydown":"_keyDownHandler","input.keyup":"_keyUpHandler","input.keypress":"_keyPressHandler","input.paste":"_pasteHandler","prefix.click":"_prefixClick","suffix.click":"_suffixClick","dropDownButton.down":"_dropDownButtonDownHandler","inputContainer.down":"_downHandler","document.up":"_documentUpHandler"}}_prefixClick(e){const t=this;if(t.onAffixClick)if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}_suffixClick(e){const t=this;if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}get selectedIndexes(){return this.isCompleted?[this.selectedIndex]:[]}set selectedIndexes(e){if(!this.isCompleted)return;const t=this;if(e&&void 0!==e[0]){if(this.selectedIndex=e[0],null===this.dataSource)return;const o=this.dataSource[this.selectedIndex];if(!o)return;const a=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="string"==typeof o?o:o.value,this.setAttribute("data-value",this.$.input.dataValue);let l=t.dataSource;"string"==typeof l&&(l=t.$.deserialize(l,"array"));for(let e=0;e<l.length;e++){let o=l[e];"string"!=typeof o&&"number"!=typeof o&&(o.value===t.$.input.dataValue?o.selected=!0:o.selected=!1)}this.context=a}else{const e=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="",this.setAttribute("data-value",this.$.input.dataValue),this.selectedIndex=-1;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o&&Array.isArray(o))for(let e=0;e<o.length;e++){let a=o[e];"string"!=typeof a&&(a.value===t.$.input.dataValue?a.selected=!0:a.selected=!1)}this.context=e}}focus(){this.$.input.focus()}select(){const e=this;e.readonly?e.$.input.focus():e.$.input.select()}_documentUpHandler(e){const t=this,o=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;o!==t&&o!==t.$.dropDownButton&&o!==t.$.input&&o!==t.$.arrow?t.$.scrollView.contains(o.shadowParent||o)?t._isPointerDown&&(t._isPointerDown=!1,t.opened&&(t._preventLookup=!0),t.$.input.focus()):(t.opened&&(t._preventLookup=!0),"manual"===t.dropDownOpenMode||t._isPointerDown||t.close(),t._isPointerDown=!1):t._isPointerDown=!1}_focusHandler(){const e=this;e.setAttribute("focus",""),e.readonly||0!==e.minLength||0!==e.$.input.value.length||e._preventLookup?(e.$.fireEvent("focus"),delete e._preventLookup):e._lookup()}_blurHandler(){const e=this;e.opened||e.removeAttribute("focus"),e.opened||e.$.fireEvent("blur"),e._refreshSelectedIndex(),delete e._preventLookup}_pasteHandler(e){const t=this,o=t.$.input,a=o.value,l=o.selectionStart,r=o.selectionEnd;if(!e.clipboardData&&!window.clipboardData)return;if(t.disabled)return;const i=(e.clipboardData||window.clipboardData).getData("text");let n=a.slice(0,l)+i;n.length,n+=a.slice(r),t.setAttribute("data-value",n),t._refreshSelectedIndex()}_refreshSelectedIndex(){const e=this;let t=e.dataSource;if(t){let o=-1,a=null;if(e.dataSource instanceof Promise)return;if("function"==typeof e.dataSource)return;"string"==typeof t&&(t=e.$.deserialize(t,"array"));for(let l=0;l<t.length;l++){let r=t[l];if("number"!=typeof r&&"boolean"!=typeof r||(r=""+r),"string"==typeof r){if(r===e.value){o=l,a=e.value;break}}else r&&(delete r.selected,r.label===e.value&&(o=l,a=r.value,r.selected=!0))}e.set("selectedIndex",o,!1),e.set("selectedValue",a,!1),-1===e.selectedIndex&&(e.$.input.dataValue=null)}}selectItem(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o)for(let a=0;a<o.length;a++){const l=o[a];if(t.set("selectedIndex",-1),t.set("value",""),t.$.input.dataValue=null,"string"==typeof l){if(l===e)return t.set("selectedIndex",a,!1),t.set("value",t.$.input.dataValue=e),void t.setAttribute("data-value",t.$.input.dataValue)}else if(l.value===e)return t.set("selectedIndex",a,!1),t.set("value",l.label),t.$.input.dataValue=e,void t.setAttribute("data-value",t.$.input.dataValue)}else t.set("value",t.$.input.dataValue=e),t.setAttribute("data-value",t.$.input.dataValue),t.set("selectedIndex",-1,!1)}getItem(e){const t=this;if(t.dataSource)for(let o=0;o<t.dataSource.length;o++){const a=t.dataSource[o];if(a.value===e)return a}return null}getPrevItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o-1];return null}getNextItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o+1];return null}getSelectedItem(){const e=this;return e.dataSource&&0===e.dataSource.length?{label:e.value,value:e.$.input.dataValue?e.$.input.dataValue:e.value}:{label:e.value,value:void 0!==e.$.input.dataValue?e.$.input.dataValue:e.value}}_refreshMenu(){const e=this;e.$.menu.classList.remove("scroll"),e.$.scrollView.computedVerticalScrollBarVisibility&&e.$.menu.classList.add("scroll")}_fromHTMLEntities(e){const t=this,o=t._textArea?t._textArea:document.createElement("textarea");return o.innerHTML=e,t._textArea=o,o.value}_performSelect(){const e=this,t=e.$.menu.querySelector(".active");let o="",a="";t&&(o=t.getAttribute("data-label"),o=e._fromHTMLEntities(o),a=t.dataValue);let l=e.value,r=e.$.input.dataValue;e.set("value",o),e.$.input.dataValue=a,e.setAttribute("data-value",a),t&&e.set("selectedIndex",t.index),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue);let i=e.dataSource;if("string"==typeof i&&(i=e.$.deserialize(i,"array")),i&&Array.isArray(i))for(let t=0;t<i.length;t++){let o=i[t];"string"!=typeof o&&"number"!=typeof o&&(o.value===e.$.input.dataValue?o.selected=!0:o.selected=!1)}e.close(),o===l&&a===r||(e.$.fireEvent("change",{value:a,label:o,oldValue:r,oldLabel:l}),e._updateTargetValue())}_open(){const e=this;if(e.opened)return;const t=window.scrollX,o=window.scrollY;let a=e.getBoundingClientRect(),l=0,r=0;if(e.timer&&clearTimeout(e.timer),e.getRootNode()&&e.getRootNode().host)e.getRootNode().host.shadowRoot.appendChild(e.$.scrollView);else if(e.dropDownAppendTo){if("body"===e.dropDownAppendTo||e.dropDownAppendTo===document.body)document.body.appendChild(e.$.scrollView);else if(e.dropDownAppendTo instanceof HTMLElement)e.dropDownAppendTo.appendChild(e.$.scrollView);else if("string"==typeof dropDownAppendTo){let t=document.getElementById(e.dropDownAppendTo);t instanceof HTMLElement?t.appendChild(e.$.scrollView):document.body.appendChild(e.$.scrollView)}}else document.body.appendChild(e.$.scrollView);if(e.setAttribute("aria-owns",e.$.scrollView.id),e.readonly||e.$.input.setAttribute("aria-controls",e.$.scrollView.id),e.$.scrollView.enableShadowDOM&&!e._importedStyle&&(e.$.scrollView.importStyle(e._getStyleUrl("smart.textbox.css")),e._importedStyle=!0),"static"!==getComputedStyle(document.body).position){const e=document.body.getBoundingClientRect();l=e.left,r=e.top}if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.style.left=-3+a.left+t-l+"px",e.$.scrollView.classList.remove("open"),e.$.scrollView.removeAttribute("top"),"bottom"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.bottom+o-r+1+"px";else if("top"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.top-e.$.scrollView.offsetHeight+o-r-2+"px",e.$.scrollView.setAttribute("top","");else if("auto"===e.dropDownOpenPosition){e.$.scrollView.style.top=a.bottom+o-r+1+"px";const t=a.top-e.$.scrollView.offsetHeight+o-r-2;window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-o?t>=0&&(e.$.scrollView.style.top=t+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=a.bottom+o-r+1+"px"}if(e.dropDownAppendTo&&"body"!==e.dropDownAppendTo){e.$.scrollView.style.position="absolute",e.$.scrollView.style.width="auto",e.$.scrollView.style.height="auto";const t=e.$.scrollView.parentNode.getBoundingClientRect();e.$.scrollView.style.top=a.bottom-t.top+"px","top"===e.dropDownOpenPosition&&(e.$.scrollView.style.top=a.top-t.top-e.$.scrollView.offsetHeight+"px"),e.$.scrollView.style.left=-3+a.left-t.left+"px",e.dropDownHeight&&(e.$.scrollView.style.height=e.dropDownHeight),e.dropDownWidth&&(e.$.scrollView.style.width=e.dropDownWidth)}e.opening=!0,e._positionTimer&&clearInterval(e._positionTimer),e.dropDownAppendTo||(e._positionTimer=setInterval((()=>{const t=e.getBoundingClientRect();if(e.opening)e.opening=!1,a=t;else if(Math.abs(parseInt(t.top)-parseInt(a.top))>=10||Math.abs(parseInt(t.left)-parseInt(a.left))>=10){const o=window.scrollX,a=window.scrollY;return e.$.scrollView.style.left=-3+t.left+o-l+"px",void("bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.bottom+a-r+1+"px":"top"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px":"auto"===e.dropDownOpenPosition&&(e.$.scrollView.removeAttribute("top"),e.$.scrollView.style.top=t.bottom+a-r+1+"px",window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-a?(e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=t.bottom+a-r+1+"px"))}}),50)),e.$.scrollView.onpointerdown=function(t){e._isPointerDown=!0,t.stopPropagation(),t.preventDefault()},requestAnimationFrame((function(){const t=e.dropDownWidth;if(e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.$.scrollView.setAttribute("open",""),e.setAttribute("open",""),e.$.dropDownButton.setAttribute("open",""),e.$.input.setAttribute("open",""),t&&"string"==typeof t&&-1!==t.indexOf("%")){const o=parseFloat(t)/100;e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",e.offsetWidth*o+"px")}else if("auto"!==t&&t)e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",parseFloat(t)+"px");else if("auto"===t){if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.$.scrollViewerContainer.classList.contains("vscroll")){const t=e.$.scrollView.offsetWidth+parseFloat(getComputedStyle(e.$.scrollView).getPropertyValue("--smart-scroll-bar-size"));e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",t+"px")}}else{e.$.menu.style.width="auto";let t=e.$.menu.offsetWidth;const o=e.$.menu.querySelectorAll("li");for(let t=0;t<o.length;t++)e._maxDropDownWidth=Math.max((o[t].firstElementChild||o[t]).offsetWidth,e._maxDropDownWidth);e.$.scrollView.computedVerticalScrollBarVisibility&&(t+=e.$.scrollView.$&&e.$.scrollView.$.verticalScrollBar?e.$.scrollView.$.verticalScrollBar.offsetWidth:30),e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",Math.max(t,e.offsetWidth-8)+"px"),e.$.menu.style.width=""}(e.shadowRoot||e.isInShadowDOM)&&e.$.scrollView._scrollView&&Smart.ScrollBar&&requestAnimationFrame((()=>{e.$.scrollView._scrollView&&e.$.scrollView._scrollView.vScrollBar.refresh()}))})),e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.set("opened",!0),e.setAttribute("aria-expanded",!0),e.$.fireEvent("open")}close(){const e=this;return!!e.opened&&(e.timer&&clearTimeout(e.timer),e.timer=setTimeout((function(){e.$.scrollView.parentNode&&!e.opened&&(e.$.scrollView.remove(),e.removeAttribute("aria-owns"),e.readonly||e.$.input.removeAttribute("aria-controls"))}),1e3),e._positionTimer&&clearInterval(e._positionTimer),e.$.scrollView.removeAttribute("open"),e.$.dropDownButton.removeAttribute("open"),e.$.input.removeAttribute("open"),e.removeAttribute("open"),e.set("opened",!1),e.setAttribute("aria-expanded",!1),e.$.input.focus(),e.$.fireEvent("close"),!0)}refresh(){const e=this;e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._getDataSourceFromOption(),e.close()}_lookup(e){const t=this;t.query=t.$.input.value;const o=t.context;if(t.context=t,t.selectedIndex=-1,t.selectedValue=null,t.context=o,t.$.input.readonly&&(t._incrementalSearchQuery||(t._incrementalSearchQuery=""),t._incrementalSearchQuery+=e.key,t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t.query=t._incrementalSearchQuery,t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),700)),t.query.length<t.minLength)return void t.close();const a=function(e){clearTimeout(t._autoCompleteTimeout),t._autoCompleteTimeout=setTimeout((()=>{const o=t.context;t.context=t,t._process(e),t.context=o}),t.autoCompleteDelay)};"function"==typeof t.dataSource?t.dataSource(t.query,a):a(t.dataSource)}_downHandler(e){const t=this;t.readonly&&t._dropDownButtonDownHandler(e)}_dropDownButtonDownHandler(e){const t=this;return"manual"!==t.dropDownOpenMode&&(t._toggle(),t.focus()),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),t._isPointerDown=!0,!1}_toggle(){const e=this;e.opened?e.close():e.open()}open(){const e=this;function t(t){e._process(t);const o=e.$.menu.querySelector(".active");if(o){const t=e.$.input.dataValue;for(let a=0;a<e.$.menu.children.length;a++){const l=e.$.menu.children[a],r=l.getAttribute("data-label"),i=l.dataValue;if(void 0!==t&&i===t||void 0===t&&r===e.$.input.value){o.classList.remove("active"),l.classList.add("active"),e._setActiveDescendant(l),e.$.input.dataValue=i,e.setAttribute("data-value",i);break}}}e.ensureVisible(),e.$.input.focus(),setTimeout((function(){e.$.input.focus()}),25)}e.dropDownDataSource&&(Array.isArray(e.dropDownDataSource)&&e.dropDownDataSource.length>0||"function"==typeof e.dropDownDataSource)?(e.query="","function"==typeof e.dropDownDataSource?e.dropDownDataSource(e.query,t):t(e.dropDownDataSource)):(e.query="","function"==typeof e.dataSource?e.dataSource(e.query,t):t(e.dataSource))}_process(e){const t=this;"string"==typeof e&&(e=t.$.deserialize(e,"array")),e=t.readonly?e.filter((function(){return!0})):e.filter((function(e){return""===e||(t.matcher?t.matcher(e):t._matcher(e))})),e=t._sorter(e),t.sorted&&(e.sort(((e,t)=>void 0!==e.label?e.label.localeCompare(t.label):e.localeCompare(t))),"desc"===t.sortDirection&&e.reverse()),!e.length&&t.opened&&t.close(),0===e.length&&!0!==t.allowItemsAdd&&""===t.dropDownPlaceholder||(t.query.length>0?t._render(e.slice(0,t.items)):t._render(e),t._open(),t.$.scrollView.refresh&&t.$.scrollView.refresh(),t._refreshMenu(),t.ensureVisible())}_matcher(e){const t=this.query;switch(null===e&&(e="null"),e=""+(e=e.label||e),this.queryMode){case"startsWith":return e.startsWith(t);case"startsWithIgnoreCase":return e.toLowerCase().startsWith(t.toLowerCase());case"doesNotContain":return e.indexOf(t)<0;case"doesNotContainIgnoreCase":return e.toLowerCase().indexOf(t.toLowerCase())<0;case"contains":return e.indexOf(t)>-1;default:case"containsIgnoreCase":return~e.toLowerCase().indexOf(t.toLowerCase());case"equals":return 0===e.localeCompare(t);case"equalsIgnoreCase":return 0===e.toLowerCase().localeCompare(t.toLowerCase());case"endsWith":return e.endsWith(t);case"endsWithIgnoreCase":return e.toLowerCase().endsWith(t.toLowerCase())}}_sorter(e){const t=this;let o,a=[],l=[],r=[];if(e&&""===e[0])return e;for(;o=e.shift();){let e=o.label||o;e=""+e,e.toLowerCase().indexOf(t.query.toLowerCase())?~e.indexOf(t.query)?l.push(o):r.push(o):a.push(o)}return a.concat(l,r)}_highlighter(e){const t=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return this.query?e.replace(new RegExp("("+t+")","ig"),(function(e,t){return"<strong>"+t+"</strong>"})):e}_render(e){const t=this;let o=0,a=-1,l=null;const r=e.map((function(e){let r=e,i=e;"object"==typeof e&&(r=e.label,i=void 0!==e.value?e.value:r),r=""+r,r=r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");const n=document.createElement("li"),s=document.createElement("a");if(s.href="javascript:void(0)",n.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),n.setAttribute("data-label",r),n.index=o++,n.dataValue=i,"string"==typeof i?n.setAttribute("value",i):n.setAttribute("value",JSON.stringify(i)),n.setAttribute("role","option"),n.setAttribute("aria-label",r),void 0!==e.menuLabel?(r=e.menuLabel,s.innerHTML=r):s.innerHTML=t.highlighter?t.highlighter(r):t._highlighter(r),s.setAttribute("aria-hidden",!0),e.disabled&&n.classList.add("smart-disabled"),e.icon&&(s.classList.add("icon"),s.classList.add(e.icon)),e.prefix){const t=document.createElement("span");t.innerHTML=e.prefix,s.classList.add("has-prefix"),s.innerHTML=t.innerHTML+s.innerHTML}if(e.suffix){const t=document.createElement("span");t.innerHTML=e.suffix,s.classList.add("has-suffix"),s.innerHTML=s.innerHTML+t.innerHTML}if(e.dataset)for(let t in e.dataset)n.setAttribute("data-"+t,e.dataset[t]);if(e.className){const t=e.className.split(" ");for(let e=0;e<t.length;e++)n.classList.add(t[e].trim())}return void 0!==t.selectedValue&&void 0!==e.value&&""!==t.selectedValue&&t.selectedValue===e.value&&(e.selected=!0,l=e,a=n.index,n.classList.add("active")),n.appendChild(s),n}));function i(){const e=t.$.menu.getElementsByClassName("active");e[0]&&e[0].classList.remove("active"),this.classList.add("active"),t._setActiveDescendant(this)}-1===a&&r.length>0&&(r[0].classList.add("active"),t._setActiveDescendant(r[0])),l&&(t.$.input.value=l.label,t.$.input.dataValue=l.value,t.setAttribute("data-value",t.$.input.dataValue)),t.$.menu.innerHTML="",0===r.length&&t.dropDownPlaceholder&&(t.$.menu.innerHTML='<div class="smart-flex smart-truncate smart-quiet" style="padding:10px; align-items: center;">'+t.dropDownPlaceholder+"</div>");for(let e=0;e<r.length;e++){const o=r[e];t.$.menu.appendChild(o),o.onmouseenter=i,o.onmouseleave=function(){this.classList.remove("active"),t._setActiveDescendant(null)},o.onclick=i}}ensureVisible(){const e=this,t=e.$.menu.querySelector(".active");t&&(t.offsetTop+t.offsetHeight>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight&&(e.$.scrollView.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.$.scrollView.scrollTop||t.offsetTop>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight)&&(e.$.scrollView.scrollTop=t.offsetTop),0===[...e.$.menu.children].indexOf(t)?e.$.scrollView.scrollTop=0:[...e.$.menu.children].indexOf(t)===e.$.menu.children.length-1&&(e.$.scrollView.scrollTop=e.$.scrollView.scrollHeight))}_next(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.nextElementSibling;o||(o=e.$.menu.firstElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_prev(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.previousElementSibling;o||(o=e.$.menu.lastElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_move(e){const t=this;if(t.readonly&&!t.opened){if("ArrowUp"===e.key){const o=t.getPrevItem();o&&t.selectItem(o.value),e.preventDefault()}if("ArrowDown"===e.key){const o=t.getNextItem();o&&t.selectItem(o.value),e.preventDefault()}}if(t.opened){switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),t._prev();break;case 40:e.preventDefault(),t._next()}e.stopPropagation()}}_keyDownHandler(e){const t=this;if(t._suppressKeyPressRepeat=![40,38,9,13,27,16,17,18].includes(e.keyCode),t._oldValue=t.$.input.value,!(e.shiftKey||e.altKey||e.ctrlKey))return t.opened&&"Escape"===e.key?(t.close(),e.stopPropagation(),void e.preventDefault()):void t._move(e)}_keyPressHandler(e){this._suppressKeyPressRepeat||e.shiftKey||e.altKey||e.ctrlKey||this._move(e)}_keyUpHandler(e){const t=this;if(!(e.shiftKey||"F2"===e.key||"a"===e.key&&e.ctrlKey))switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:40===e.keyCode&&e.altKey&&t.open(),38===e.keyCode&&e.altKey&&t.close();break;case 9:case 13:if(!t.opened)return;t._performSelect(),e.stopPropagation(),e.preventDefault();break;case 27:if(!t.opened)return;t.close(),e.stopPropagation(),e.preventDefault();break;default:if(t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.$.fireEvent("changing",{value:t.$.input.value,oldValue:t._oldValue}),t.dataSource&&t.dataSource.length)for(let e=0;e<t.dataSource.length;e++){const o=t.dataSource[e];if("string"==typeof o){if(o===t.$.input.value){t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);break}}else if(void 0!==o.label&&o.label===t.$.input.value){t.$.input.dataValue=o.value,t.setAttribute("data-value",o.value);break}}else t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);t._updateTargetValue()}}clearValue(){const e=this;e.$.input.value="",e.$.input.dataValue="",e.removeAttribute("data-value"),e.set("value",""),e.set("selectedIndex",-1),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue)}propertyChangedHandler(e,t,o){super.propertyChangedHandler(e,t,o);const a=this;if("innerHTML"===e&&(a._getDataSourceFromOption(),a._setSelection(!1)),"selectedValue"===e){let e=-1;if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((t,a)=>{"string"==typeof t?t===o&&(e=a):t&&t.value===o&&(e=a)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}a._setSelection()}if("selectedIndex"===e){let e=a.dataSource;if(a.selectedValue=null,e&&Array.isArray(e))for(let t=0;t<e.length;t++){let o=e[t];"string"!=typeof o&&"number"!=typeof o&&(o.selected=!1)}a._setSelection()}else if("dataSource"===e){if(a.dataSource&&Array.isArray(a.dataSource)){let e=-1;if(a.dataSource.forEach(((t,o)=>{t.selected&&(e=o)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(!1)}else if("dropDownClassList"===e){const e=a.$.scrollView;for(let o=0,a=t.length;o<a;o+=1)e.classList.remove(t[o]);for(let t=0,a=o.length;t<a;t+=1)e.classList.add(o[t])}else if("dropDownHeight"===e)"auto"!==a.dropDownHeight?a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height",a.dropDownHeight+"px"):a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height","auto");else if("opened"===e)a.opened=t,o?a.open():a.close();else if("placeholder"===e){if(a.readonly){const e=a.getAttribute("aria-label");if(e&&e!==t)return;o?a.setAttribute("aria-label",o):a.removeAttribute("aria-label")}}else if("selectedValues"===e)if(null===o)a.$.input.value="",a.$.input.dataValue=o,a.setAttribute("data-value",o),a._refreshSelectedIndex();else{const e=o.join(","),t=a.value;if(a.$.input.dataValue=e,e&&-1===e.indexOf(",")){let e=-1,t=o[0];if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((a,l)=>{"string"==typeof a?a!==o&&a!==t||(e=l):a&&a.value===t&&(e=l)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(),a.propertyChangedHandler("value",t,a.value)}else"value"===e?(a.displayMember!==a.valueMember&&"string"!=typeof o?(a.set("value",o[a.displayMember]),a.$.input.dataValue=o[a.valueMember],a.setAttribute("data-value",a.$.input.dataValue)):(a.$.input.value=a.$.input.dataValue=o,a.setAttribute("data-value",o)),a._refreshSelectedIndex()):"readonly"===e?(a._setAriaRelations(),a._setInputPurpose()):"theme"===e||"rightToLeft"===e?a.$.scrollView[e]=o:"inputPurpose"===e?a._setInputPurpose():"inverted"===e?o?a.$.scrollView.setAttribute("inverted",""):a.$.scrollView.removeAttribute("inverted"):"disabled"!==e&&"unfocusable"!==e||a._setFocusable()}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const o=e.dataset.property,a=e.value;o&&void 0!==t[o]&&(t[o]=a)}}}detached(){super.detached(),this.close(),this.removeAttribute("focus")}_getDataSourceFromOption(){const e=this;if(e.innerHTML.indexOf("<option")>=0){e.$.optionsContainer.innerHTML=e.innerHTML.trim();const t=e.querySelectorAll("option");let o=[];for(let e=0;e<t.length;e++){const a=t[e],l=a.hasAttribute("selected")||a.hasAttribute("is-selected")&&"false"!==a.getAttribute("is-selected");let r=(""+a.textContent).trim();const i=(""+a.innerHTML).trim(),n=a.hasAttribute("value")?a.getAttribute("value"):r,s=a.hasAttribute("disabled"),u=a.hasAttribute("label")?a.getAttribute("label"):null;u&&(r=u),o.push({label:r,menuLabel:i,value:n,disabled:s,selected:l,className:a.className,dataset:a.dataset}),a.classList.add("smart-hidden")}e.dataSource=o}}render(){const e=this,t=e.dropDownClassList;if(e._getDataSourceFromOption(),e.selectedValues&&e.selectedValues.length){const t=e.selectedValues.join(",");e.value=t}e._createElement&&e._createElement();const o=e.$.scrollView;for(let e=0,a=t.length;e<a;e+=1)o.classList.add(t[e]);e.opened&&(e.opened=!1,e.open());const a=e.$.menu;a&&(a.setAttribute("role","presentation"),o.appendChild(a)),"auto"!==e.dropDownHeight?o.style.setProperty("--smart-input-drop-down-menu-height",e.dropDownHeight+"px"):o.style.setProperty("--smart-input-drop-down-menu-height","auto"),o.classList.add("smart-input-drop-down-menu");for(let t=0;t<e.classList.length;t++){const a=e.classList[t];"smart-element"!==a&&"smart-input"!==a&&o.classList.add(a+"-drop-down-menu")}o.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),o.ownerElement=e;let l=e.dataSource;if("string"==typeof l&&(l=e.$.deserialize(l,"array")),l&&l.length&&Array.isArray(l)){let t=-1;if(l.forEach(((e,o)=>{e.selected&&(t=o)})),t>=0){e.selectedIndex=t;const o=l[t];e.selectedValue="string"==typeof o?l[t]:l[t].value}}e._setAriaRelations(),e._setInputPurpose(),e._setSelection(),e.isInitialized=!0,e.hasAttribute("tabindex")&&(e.readonly||(e.$.input.setAttribute("tabindex",e.getAttribute("tabindex")),e.removeAttribute("tabindex"))),super.render()}_setSelection(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),t.selectedIndex>=0&&o&&o.length>0){let a=o[t.selectedIndex];if("number"!=typeof a&&"boolean"!=typeof a||(a=""+a),"string"==typeof a){let o=t.$.input.dataValue,l=t.value;t.set("value",a),t.$.input.dataValue=a,t.$.input.setAttribute("data-value",a),t.selectedValues=[t.$.input.dataValue],t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.value,label:t.label,oldValue:o,oldLabel:l}),t._updateTargetValue())}else{let o=t.$.input.dataValue,l=t.value;a&&(void 0!==a.value?(t.set("value",void 0!==a.value?a.value+"":""),t.$.input.dataValue=a.value,t.$.input.setAttribute("data-value",a.value),t.selectedValues=[t.$.input.dataValue]):a.label&&(t.selectedValues=[a.value]),a.label&&t.set("value",a.label)),t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.$.input.dataValue,label:a.value,oldValue:o,oldLabel:l}),t._updateTargetValue())}}}_createElement(){const e=this,t=document.createElement("ul"),o=document.createElement("smart-scroll-viewer");o.rightToLeft=e.rightToLeft,o.theme=e.theme,o.horizontalScrollBarVisibility="hidden",e.inverted?o.setAttribute("inverted",""):o.removeAttribute("inverted"),e.$.scrollView=o,e.$.menu=t,e._setFocusable();const a=e.$.input;e.$.menu.onpointerdown=function(t){const o=t.target.closest("li"),l=e.$.menu.querySelector(".active");l&&o&&(l.classList.remove("active"),o.classList.add("active")),t.stopPropagation(),t.preventDefault(),setTimeout((()=>{e._performSelect(),o&&o.parentNode&&e.$.fireEvent("itemClick",{index:[...o.parentNode.children].indexOf(o),item:o,label:o.getAttribute("aria-label"),value:o.dataValue}),a.focus()}),50)},e.$.menu.onpointerup=function(t){t.stopPropagation(),t.preventDefault(),e.$.scrollView.$.verticalScrollBar.thumbCapture&&(e.$.scrollView.$.verticalScrollBar.thumbCapture=!1)}}_setAriaRelations(){const e=this,t=e.getAttribute("aria-label");e.readonly?(e.setAttribute("role","button"),!t&&e.placeholder&&e.setAttribute("aria-label",e.placeholder),e.removeAttribute("aria-readonly"),e.$.input.setAttribute("aria-hidden",!0),e.$.input.removeAttribute("aria-activedescendant"),e.$.input.removeAttribute("aria-controls"),e.$.dropDownButton.setAttribute("aria-hidden",!0)):(e.setAttribute("role","combobox"),t&&t===e.placeholder&&e.removeAttribute("aria-label"),e.$.input.setAttribute("role","searchbox"),e.$.input.removeAttribute("aria-hidden",!0),e.$.dropDownButton.removeAttribute("aria-hidden")),e.setAttribute("aria-expanded",e.opened),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-owns",e.$.scrollView.id),e.$.scrollView.setAttribute("role","listbox")}_setActiveDescendant(e){const t=this;t.readonly||(e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant"))}_setInputPurpose(){const e=this;e.readonly?e.$.input.removeAttribute("autocomplete"):e.$.input.setAttribute("autocomplete",e.inputPurpose)}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.$.input.setAttribute("tabindex",-1):e.$.input.removeAttribute("tabindex")}});
|
|
150
|
+
Smart("smart-input",class extends Smart.BaseElement{static get properties(){return{autoCompleteDelay:{value:100,type:"number"},dataSource:{type:"any",value:[],reflectToAttribute:!1},dropDownClassList:{value:[],type:"array",reflectToAttribute:!1},dropDownDataSource:{type:"any",reflectToAttribute:!1,value:[]},dropDownHeight:{type:"any",value:200},dropDownOpenMode:{allowedValues:["default","manual"],value:"default",type:"string"},dropDownAppendTo:{value:null,type:"any"},dropDownWidth:{type:"any",value:null},dropDownButtonPosition:{allowedValues:["none","left","right"],value:"none",type:"string"},dropDownOpenPosition:{allowedValues:["bottom","top","auto"],value:"bottom",type:"string"},dropDownPlaceholder:{type:"string",value:""},hint:{type:"string",value:""},inputPurpose:{type:"string",value:"off"},items:{type:"number",value:8},minLength:{type:"number",value:1},maxLength:{type:"number",value:99999999},name:{value:"",type:"string"},prefix:{value:"",type:"string",reflectToAttribute:!1},suffix:{value:"",type:"string",reflectToAttribute:!1},onAffixClick:{value:null,type:"any",reflectToAttribute:!1},opened:{value:!1,type:"boolean"},query:{type:"string",value:""},queryMode:{allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string",value:"containsIgnoreCase"},placeholder:{value:"",type:"string"},readonly:{type:"boolean",value:!1},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},selectedIndex:{type:"number",value:-1},selectedValue:{type:"any",value:""},selectedValues:{value:[],type:"array"},type:{type:"string"},value:{type:"string",value:""},innerHTML:{type:"string",reflectToAttribute:!1}}}static get styleUrls(){return["smart.textbox.css"]}template(){return'<div id="inputContainer" role="presentation"><div id="optionsContainer" inner-h-t-m-l=\'{{innerHTML}}\' class="smart-hidden"></div><span class="smart-input-prefix" id="prefix" inner-h-t-m-l=\'{{prefix}}\'></span><input maxlength=\'[[maxLength]]\' class="smart-input" id=\'input\' readonly=\'[[readonly]]\' placeholder=\'[[placeholder]]\' type=\'[[type]]\' name=\'[[name]]\' value=\'{{value::keyup}}\' disabled=\'[[disabled]]\' aria-label="[[placeholder]]" /><span class="smart-hidden smart-hint" id="span">[[hint]]</span><span id="suffix" class="smart-input-suffix" inner-h-t-m-l=\'{{suffix}}\'></span><div id="dropDownButton" tabindex=-1 class="smart-drop-down-button" role="button" aria-label="Toggle popup"><div id="arrow" class="arrow" aria-hidden="true"></div></div></div>'}static get listeners(){return{"input.focus":"_focusHandler","input.blur":"_blurHandler","input.keydown":"_keyDownHandler","input.keyup":"_keyUpHandler","input.keypress":"_keyPressHandler","input.paste":"_pasteHandler","prefix.click":"_prefixClick","suffix.click":"_suffixClick","dropDownButton.down":"_dropDownButtonDownHandler","inputContainer.down":"_downHandler","document.up":"_documentUpHandler"}}_prefixClick(e){const t=this;if(t.onAffixClick)if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}_suffixClick(e){const t=this;if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}get selectedIndexes(){return this.isCompleted?[this.selectedIndex]:[]}set selectedIndexes(e){if(!this.isCompleted)return;const t=this;if(e&&void 0!==e[0]){if(this.selectedIndex=e[0],null===this.dataSource)return;const o=this.dataSource[this.selectedIndex];if(!o)return;const a=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="string"==typeof o?o:o.value,this.setAttribute("data-value",this.$.input.dataValue);let l=t.dataSource;"string"==typeof l&&(l=t.$.deserialize(l,"array"));for(let e=0;e<l.length;e++){let o=l[e];"string"!=typeof o&&"number"!=typeof o&&(o.value===t.$.input.dataValue?o.selected=!0:o.selected=!1)}this.context=a}else{const e=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="",this.setAttribute("data-value",this.$.input.dataValue),this.selectedIndex=-1;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o&&Array.isArray(o))for(let e=0;e<o.length;e++){let a=o[e];"string"!=typeof a&&(a.value===t.$.input.dataValue?a.selected=!0:a.selected=!1)}this.context=e}}focus(){this.$.input.focus()}select(){const e=this;e.readonly?e.$.input.focus():e.$.input.select()}_documentUpHandler(e){const t=this,o=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;o!==t&&o!==t.$.dropDownButton&&o!==t.$.input&&o!==t.$.arrow?t.$.scrollView.contains(o.shadowParent||o)?t._isPointerDown&&(t._isPointerDown=!1,t.opened&&(t._preventLookup=!0),t.$.input.focus()):(t.opened&&(t._preventLookup=!0),"manual"===t.dropDownOpenMode||t._isPointerDown||t.close(),t._isPointerDown=!1):t._isPointerDown=!1}_focusHandler(){const e=this;e.setAttribute("focus",""),e.readonly||0!==e.minLength||0!==e.$.input.value.length||e._preventLookup?(e.$.fireEvent("focus"),delete e._preventLookup):e._lookup()}_blurHandler(){const e=this;e.opened||e.removeAttribute("focus"),e.opened||e.$.fireEvent("blur"),e._refreshSelectedIndex(),delete e._preventLookup}_pasteHandler(e){const t=this,o=t.$.input,a=o.value,l=o.selectionStart,r=o.selectionEnd;if(!e.clipboardData&&!window.clipboardData)return;if(t.disabled)return;const i=(e.clipboardData||window.clipboardData).getData("text");let n=a.slice(0,l)+i;n.length,n+=a.slice(r),t.setAttribute("data-value",n),t._refreshSelectedIndex()}_refreshSelectedIndex(){const e=this;let t=e.dataSource;if(t){let o=-1,a=null;if(e.dataSource instanceof Promise)return;if("function"==typeof e.dataSource)return;"string"==typeof t&&(t=e.$.deserialize(t,"array"));for(let l=0;l<t.length;l++){let r=t[l];if("number"!=typeof r&&"boolean"!=typeof r||(r=""+r),"string"==typeof r){if(r===e.value){o=l,a=e.value;break}}else r&&(delete r.selected,r.label===e.value&&(o=l,a=r.value,r.selected=!0))}e.set("selectedIndex",o,!1),e.set("selectedValue",a,!1),-1===e.selectedIndex&&(e.$.input.dataValue=null)}}selectItem(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o)for(let a=0;a<o.length;a++){const l=o[a];if(t.set("selectedIndex",-1),t.set("value",""),t.$.input.dataValue=null,"string"==typeof l){if(l===e)return t.set("selectedIndex",a,!1),t.set("value",t.$.input.dataValue=e),void t.setAttribute("data-value",t.$.input.dataValue)}else if(l.value===e)return t.set("selectedIndex",a,!1),t.set("value",l.label),t.$.input.dataValue=e,void t.setAttribute("data-value",t.$.input.dataValue)}else t.set("value",t.$.input.dataValue=e),t.setAttribute("data-value",t.$.input.dataValue),t.set("selectedIndex",-1,!1)}getItem(e){const t=this;if(t.dataSource)for(let o=0;o<t.dataSource.length;o++){const a=t.dataSource[o];if(a.value===e)return a}return null}getPrevItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o-1];return null}getNextItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o+1];return null}getSelectedItem(){const e=this;return e.dataSource&&0===e.dataSource.length?{label:e.value,value:e.$.input.dataValue?e.$.input.dataValue:e.value}:{label:e.value,value:void 0!==e.$.input.dataValue?e.$.input.dataValue:e.value}}_refreshMenu(){const e=this;e.$.menu.classList.remove("scroll"),e.$.scrollView.computedVerticalScrollBarVisibility&&e.$.menu.classList.add("scroll")}_fromHTMLEntities(e){const t=this,o=t._textArea?t._textArea:document.createElement("textarea");return o.innerHTML=e,t._textArea=o,o.value}_performSelect(){const e=this,t=e.$.menu.querySelector(".active");let o="",a="";t&&(o=t.getAttribute("data-label"),o=e._fromHTMLEntities(o),a=t.dataValue);let l=e.value,r=e.$.input.dataValue;e.set("value",o),e.$.input.dataValue=a,e.setAttribute("data-value",a),t&&e.set("selectedIndex",t.index),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue);let i=e.dataSource;if("string"==typeof i&&(i=e.$.deserialize(i,"array")),i&&Array.isArray(i))for(let t=0;t<i.length;t++){let o=i[t];"string"!=typeof o&&"number"!=typeof o&&(o.value===e.$.input.dataValue?o.selected=!0:o.selected=!1)}e.close(),o===l&&a===r||(e.$.fireEvent("change",{value:a,label:o,oldValue:r,oldLabel:l}),e._updateTargetValue())}_open(){const e=this;if(e.opened)return;const t=window.scrollX,o=window.scrollY;let a=e.getBoundingClientRect(),l=0,r=0;if(e.timer&&clearTimeout(e.timer),e.getRootNode()&&e.getRootNode().host)e.getRootNode().host.shadowRoot.appendChild(e.$.scrollView);else if(e.dropDownAppendTo){if("body"===e.dropDownAppendTo||e.dropDownAppendTo===document.body)document.body.appendChild(e.$.scrollView);else if(e.dropDownAppendTo instanceof HTMLElement)e.dropDownAppendTo.appendChild(e.$.scrollView);else if("string"==typeof dropDownAppendTo){let t=document.getElementById(e.dropDownAppendTo);t instanceof HTMLElement?t.appendChild(e.$.scrollView):document.body.appendChild(e.$.scrollView)}}else document.body.appendChild(e.$.scrollView);if(e.setAttribute("aria-owns",e.$.scrollView.id),e.readonly||e.$.input.setAttribute("aria-controls",e.$.scrollView.id),e.$.scrollView.enableShadowDOM&&!e._importedStyle&&(e.$.scrollView.importStyle(e._getStyleUrl("smart.textbox.css")),e._importedStyle=!0),"static"!==getComputedStyle(document.body).position){const e=document.body.getBoundingClientRect();l=e.left,r=e.top}if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.style.left=-3+a.left+t-l+"px",e.$.scrollView.classList.remove("open"),e.$.scrollView.removeAttribute("top"),"bottom"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.bottom+o-r+1+"px";else if("top"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.top-e.$.scrollView.offsetHeight+o-r-2+"px",e.$.scrollView.setAttribute("top","");else if("auto"===e.dropDownOpenPosition){e.$.scrollView.style.top=a.bottom+o-r+1+"px";const t=a.top-e.$.scrollView.offsetHeight+o-r-2;window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-o?t>=0&&(e.$.scrollView.style.top=t+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=a.bottom+o-r+1+"px"}if(e.dropDownAppendTo&&"body"!==e.dropDownAppendTo){e.$.scrollView.style.position="absolute",e.$.scrollView.style.width="auto",e.$.scrollView.style.height="auto";const t=e.$.scrollView.parentNode.getBoundingClientRect();e.$.scrollView.style.top=a.bottom-t.top+"px","top"===e.dropDownOpenPosition&&(e.$.scrollView.style.top=a.top-t.top-e.$.scrollView.offsetHeight+"px"),e.$.scrollView.style.left=-3+a.left-t.left+"px",e.dropDownHeight&&(e.$.scrollView.style.height=e.dropDownHeight),e.dropDownWidth&&(e.$.scrollView.style.width=e.dropDownWidth)}e.opening=!0,e._positionTimer&&clearInterval(e._positionTimer),e.dropDownAppendTo||(e._positionTimer=setInterval((()=>{const t=e.getBoundingClientRect();if(e.opening)e.opening=!1,a=t;else if(Math.abs(parseInt(t.top)-parseInt(a.top))>=10||Math.abs(parseInt(t.left)-parseInt(a.left))>=10){const o=window.scrollX,a=window.scrollY;return e.$.scrollView.style.left=-3+t.left+o-l+"px",void("bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.bottom+a-r+1+"px":"top"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px":"auto"===e.dropDownOpenPosition&&(e.$.scrollView.removeAttribute("top"),e.$.scrollView.style.top=t.bottom+a-r+1+"px",window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-a?(e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=t.bottom+a-r+1+"px"))}}),50)),e.$.scrollView.onpointerdown=function(t){e._isPointerDown=!0,t.stopPropagation(),t.preventDefault()},requestAnimationFrame((function(){const t=e.dropDownWidth;if(e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.$.scrollView.setAttribute("open",""),e.setAttribute("open",""),e.$.dropDownButton.setAttribute("open",""),e.$.input.setAttribute("open",""),t&&"string"==typeof t&&-1!==t.indexOf("%")){const o=parseFloat(t)/100;e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",e.offsetWidth*o+"px")}else if("auto"!==t&&t)e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",parseFloat(t)+"px");else if("auto"===t){if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.$.scrollViewerContainer.classList.contains("vscroll")){const t=e.$.scrollView.offsetWidth+parseFloat(getComputedStyle(e.$.scrollView).getPropertyValue("--smart-scroll-bar-size"));e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",t+"px")}}else{e.$.menu.style.width="auto";let t=e.$.menu.offsetWidth;const o=e.$.menu.querySelectorAll("li");for(let t=0;t<o.length;t++)e._maxDropDownWidth=Math.max((o[t].firstElementChild||o[t]).offsetWidth,e._maxDropDownWidth);e.$.scrollView.computedVerticalScrollBarVisibility&&(t+=e.$.scrollView.$&&e.$.scrollView.$.verticalScrollBar?e.$.scrollView.$.verticalScrollBar.offsetWidth:30),e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",Math.max(t,e.offsetWidth-8)+"px"),e.$.menu.style.width=""}(e.shadowRoot||e.isInShadowDOM)&&e.$.scrollView._scrollView&&Smart.ScrollBar&&requestAnimationFrame((()=>{e.$.scrollView._scrollView&&e.$.scrollView._scrollView.vScrollBar.refresh()}))})),e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.set("opened",!0),e.setAttribute("aria-expanded",!0),e.$.fireEvent("open")}close(){const e=this;return!!e.opened&&(e.timer&&clearTimeout(e.timer),e.timer=setTimeout((function(){e.$.scrollView.parentNode&&!e.opened&&(e.$.scrollView.remove(),e.removeAttribute("aria-owns"),e.readonly||e.$.input.removeAttribute("aria-controls"))}),1e3),e._positionTimer&&clearInterval(e._positionTimer),e.$.scrollView.removeAttribute("open"),e.$.dropDownButton.removeAttribute("open"),e.$.input.removeAttribute("open"),e.removeAttribute("open"),e.set("opened",!1),e.setAttribute("aria-expanded",!1),e.$.input.focus(),e.$.fireEvent("close"),!0)}refresh(){const e=this;e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._getDataSourceFromOption(),e.close()}_lookup(e){const t=this;t.query=t.$.input.value;const o=t.context;if(t.context=t,t.selectedIndex=-1,t.selectedValue=null,t.context=o,t.$.input.readonly&&(t._incrementalSearchQuery||(t._incrementalSearchQuery=""),t._incrementalSearchQuery+=e.key,t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t.query=t._incrementalSearchQuery,t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),700)),t.query.length<t.minLength)return void t.close();const a=function(e){clearTimeout(t._autoCompleteTimeout),t._autoCompleteTimeout=setTimeout((()=>{const o=t.context;t.context=t,t._process(e),t.context=o}),t.autoCompleteDelay)};"function"==typeof t.dataSource?t.dataSource(t.query,a):a(t.dataSource)}_downHandler(e){const t=this;t.readonly&&t._dropDownButtonDownHandler(e)}_dropDownButtonDownHandler(e){const t=this;return"manual"!==t.dropDownOpenMode&&(t._toggle(),t.focus()),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),t._isPointerDown=!0,!1}_toggle(){const e=this;e.opened?e.close():e.open()}open(){const e=this;function t(t){e._process(t);const o=e.$.menu.querySelector(".active");if(o){const t=e.$.input.dataValue;for(let a=0;a<e.$.menu.children.length;a++){const l=e.$.menu.children[a],r=l.getAttribute("data-label"),i=l.dataValue;if(void 0!==t&&i===t||void 0===t&&r===e.$.input.value){o.classList.remove("active"),l.classList.add("active"),e._setActiveDescendant(l),e.$.input.dataValue=i,e.setAttribute("data-value",i);break}}}e.ensureVisible(),e.$.input.focus(),setTimeout((function(){e.$.input.focus()}),25)}e.dropDownDataSource&&(Array.isArray(e.dropDownDataSource)&&e.dropDownDataSource.length>0||"function"==typeof e.dropDownDataSource)?(e.query="","function"==typeof e.dropDownDataSource?e.dropDownDataSource(e.query,t):t(e.dropDownDataSource)):(e.query="","function"==typeof e.dataSource?e.dataSource(e.query,t):t(e.dataSource))}_process(e){const t=this;"string"==typeof e&&(e=t.$.deserialize(e,"array")),e=t.readonly?e.filter((function(){return!0})):e.filter((function(e){return""===e||(t.matcher?t.matcher(e):t._matcher(e))})),e=t._sorter(e),t.sorted&&(e.sort(((e,t)=>void 0!==e.label?e.label.localeCompare(t.label):e.localeCompare(t))),"desc"===t.sortDirection&&e.reverse()),!e.length&&t.opened&&""===t.dropDownPlaceholder&&t.close(),0===e.length&&!0!==t.allowItemsAdd&&""===t.dropDownPlaceholder||(t.query.length>0?t._render(e.slice(0,t.items)):t._render(e),t._open(),t.$.scrollView.refresh&&t.$.scrollView.refresh(),t._refreshMenu(),t.ensureVisible())}_matcher(e){const t=this.query;switch(null===e&&(e="null"),e=""+(e=e.label||e),this.queryMode){case"startsWith":return e.startsWith(t);case"startsWithIgnoreCase":return e.toLowerCase().startsWith(t.toLowerCase());case"doesNotContain":return e.indexOf(t)<0;case"doesNotContainIgnoreCase":return e.toLowerCase().indexOf(t.toLowerCase())<0;case"contains":return e.indexOf(t)>-1;default:case"containsIgnoreCase":return~e.toLowerCase().indexOf(t.toLowerCase());case"equals":return 0===e.localeCompare(t);case"equalsIgnoreCase":return 0===e.toLowerCase().localeCompare(t.toLowerCase());case"endsWith":return e.endsWith(t);case"endsWithIgnoreCase":return e.toLowerCase().endsWith(t.toLowerCase())}}_sorter(e){const t=this;let o,a=[],l=[],r=[];if(e&&""===e[0])return e;for(;o=e.shift();){let e=o.label||o;e=""+e,e.toLowerCase().indexOf(t.query.toLowerCase())?~e.indexOf(t.query)?l.push(o):r.push(o):a.push(o)}return a.concat(l,r)}_highlighter(e){const t=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return this.query?e.replace(new RegExp("("+t+")","ig"),(function(e,t){return"<strong>"+t+"</strong>"})):e}_render(e){const t=this;let o=0,a=-1,l=null;const r=e.map((function(e){let r=e,i=e;"object"==typeof e&&(r=e.label,i=void 0!==e.value?e.value:r),r=""+r,r=r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");const n=document.createElement("li"),s=document.createElement("a");if(s.href="javascript:void(0)",n.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),n.setAttribute("data-label",r),n.index=o++,n.dataValue=i,"string"==typeof i?n.setAttribute("value",i):n.setAttribute("value",JSON.stringify(i)),n.setAttribute("role","option"),n.setAttribute("aria-label",r),void 0!==e.menuLabel?(r=e.menuLabel,s.innerHTML=r):s.innerHTML=t.highlighter?t.highlighter(r):t._highlighter(r),s.setAttribute("aria-hidden",!0),e.disabled&&n.classList.add("smart-disabled"),e.icon&&(s.classList.add("icon"),s.classList.add(e.icon)),e.prefix){const t=document.createElement("span");t.innerHTML=e.prefix,s.classList.add("has-prefix"),s.innerHTML=t.innerHTML+s.innerHTML}if(e.suffix){const t=document.createElement("span");t.innerHTML=e.suffix,s.classList.add("has-suffix"),s.innerHTML=s.innerHTML+t.innerHTML}if(e.dataset)for(let t in e.dataset)n.setAttribute("data-"+t,e.dataset[t]);if(e.className){const t=e.className.split(" ");for(let e=0;e<t.length;e++)n.classList.add(t[e].trim())}return void 0!==t.selectedValue&&void 0!==e.value&&""!==t.selectedValue&&t.selectedValue===e.value&&(e.selected=!0,l=e,a=n.index,n.classList.add("active")),n.appendChild(s),n}));function i(){const e=t.$.menu.getElementsByClassName("active");e[0]&&e[0].classList.remove("active"),this.classList.add("active"),t._setActiveDescendant(this)}-1===a&&r.length>0&&(r[0].classList.add("active"),t._setActiveDescendant(r[0])),l&&(t.$.input.value=l.label,t.$.input.dataValue=l.value,t.setAttribute("data-value",t.$.input.dataValue)),t.$.menu.innerHTML="",0===r.length&&t.dropDownPlaceholder&&(t.$.menu.innerHTML='<div class="smart-flex smart-truncate smart-quiet" style="padding:10px; align-items: center;">'+t.dropDownPlaceholder+"</div>");for(let e=0;e<r.length;e++){const o=r[e];t.$.menu.appendChild(o),o.onmouseenter=i,o.onmouseleave=function(){this.classList.remove("active"),t._setActiveDescendant(null)},o.onclick=i}}ensureVisible(){const e=this,t=e.$.menu.querySelector(".active");t&&(t.offsetTop+t.offsetHeight>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight&&(e.$.scrollView.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.$.scrollView.scrollTop||t.offsetTop>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight)&&(e.$.scrollView.scrollTop=t.offsetTop),0===[...e.$.menu.children].indexOf(t)?e.$.scrollView.scrollTop=0:[...e.$.menu.children].indexOf(t)===e.$.menu.children.length-1&&(e.$.scrollView.scrollTop=e.$.scrollView.scrollHeight))}_next(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.nextElementSibling;o||(o=e.$.menu.firstElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_prev(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.previousElementSibling;o||(o=e.$.menu.lastElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_move(e){const t=this;if(t.readonly&&!t.opened){if("ArrowUp"===e.key){const o=t.getPrevItem();o&&t.selectItem(o.value),e.preventDefault()}if("ArrowDown"===e.key){const o=t.getNextItem();o&&t.selectItem(o.value),e.preventDefault()}}if(t.opened){switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),t._prev();break;case 40:e.preventDefault(),t._next()}e.stopPropagation()}}_keyDownHandler(e){const t=this;if(t._suppressKeyPressRepeat=![40,38,9,13,27,16,17,18].includes(e.keyCode),t._oldValue=t.$.input.value,!(e.shiftKey||e.altKey||e.ctrlKey))return t.opened&&"Escape"===e.key?(t.close(),e.stopPropagation(),void e.preventDefault()):void t._move(e)}_keyPressHandler(e){this._suppressKeyPressRepeat||e.shiftKey||e.altKey||e.ctrlKey||this._move(e)}_keyUpHandler(e){const t=this;if(!(e.shiftKey||"F2"===e.key||"a"===e.key&&e.ctrlKey))switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:40===e.keyCode&&e.altKey&&t.open(),38===e.keyCode&&e.altKey&&t.close();break;case 9:case 13:if(!t.opened)return;if(!t.readonly&&!t.$.menu.querySelector(".active")){const o=t.$.input.value;return t._performSelect(),t.value=t.$.input.value=o,e.stopPropagation(),void e.preventDefault()}t._performSelect(),e.stopPropagation(),e.preventDefault();break;case 27:if(!t.opened)return;t.close(),e.stopPropagation(),e.preventDefault();break;default:t._lookupTimer&&clearTimeout(t._lookupTimer),t._lookupTimer=setTimeout((()=>{if(t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.$.fireEvent("changing",{value:t.$.input.value,oldValue:t._oldValue}),t.dataSource&&t.dataSource.length)for(let e=0;e<t.dataSource.length;e++){const o=t.dataSource[e];if("string"==typeof o){if(o===t.$.input.value){t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);break}}else if(void 0!==o.label&&o.label===t.$.input.value){t.$.input.dataValue=o.value,t.setAttribute("data-value",o.value);break}}else t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);t._updateTargetValue()}),300)}}clearValue(){const e=this;e.$.input.value="",e.$.input.dataValue="",e.removeAttribute("data-value"),e.set("value",""),e.set("selectedIndex",-1),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue)}propertyChangedHandler(e,t,o){super.propertyChangedHandler(e,t,o);const a=this;if("innerHTML"===e&&(a._getDataSourceFromOption(),a._setSelection(!1)),"selectedValue"===e){let e=-1;if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((t,a)=>{"string"==typeof t?t===o&&(e=a):t&&t.value===o&&(e=a)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}a._setSelection()}if("selectedIndex"===e){let e=a.dataSource;if(a.selectedValue=null,e&&Array.isArray(e))for(let t=0;t<e.length;t++){let o=e[t];"string"!=typeof o&&"number"!=typeof o&&(o.selected=!1)}a._setSelection()}else if("dataSource"===e){if(a.dataSource&&Array.isArray(a.dataSource)){let e=-1;if(a.dataSource.forEach(((t,o)=>{t.selected&&(e=o)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(!1)}else if("dropDownClassList"===e){const e=a.$.scrollView;for(let o=0,a=t.length;o<a;o+=1)e.classList.remove(t[o]);for(let t=0,a=o.length;t<a;t+=1)e.classList.add(o[t])}else if("dropDownHeight"===e)"auto"!==a.dropDownHeight?a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height",a.dropDownHeight+"px"):a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height","auto");else if("opened"===e)a.opened=t,o?a.open():a.close();else if("placeholder"===e){if(a.readonly){const e=a.getAttribute("aria-label");if(e&&e!==t)return;o?a.setAttribute("aria-label",o):a.removeAttribute("aria-label")}}else if("selectedValues"===e)if(null===o)a.$.input.value="",a.$.input.dataValue=o,a.setAttribute("data-value",o),a._refreshSelectedIndex();else{const e=o.join(","),t=a.value;if(a.$.input.dataValue=e,e&&-1===e.indexOf(",")){let e=-1,t=o[0];if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((a,l)=>{"string"==typeof a?a!==o&&a!==t||(e=l):a&&a.value===t&&(e=l)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(),a.propertyChangedHandler("value",t,a.value)}else"value"===e?(a.displayMember!==a.valueMember&&"string"!=typeof o?(a.set("value",o[a.displayMember]),a.$.input.dataValue=o[a.valueMember],a.setAttribute("data-value",a.$.input.dataValue)):(a.$.input.value=a.$.input.dataValue=o,a.setAttribute("data-value",o)),a._refreshSelectedIndex()):"readonly"===e?(a._setAriaRelations(),a._setInputPurpose()):"theme"===e||"rightToLeft"===e?a.$.scrollView[e]=o:"inputPurpose"===e?a._setInputPurpose():"inverted"===e?o?a.$.scrollView.setAttribute("inverted",""):a.$.scrollView.removeAttribute("inverted"):"disabled"!==e&&"unfocusable"!==e||a._setFocusable()}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const o=e.dataset.property,a=e.value;o&&void 0!==t[o]&&(t[o]=a)}}}detached(){super.detached(),this.close(),this.removeAttribute("focus")}_getDataSourceFromOption(){const e=this;if(e.innerHTML.indexOf("<option")>=0){e.$.optionsContainer.innerHTML=e.innerHTML.trim();const t=e.querySelectorAll("option");let o=[];for(let e=0;e<t.length;e++){const a=t[e],l=a.hasAttribute("selected")||a.hasAttribute("is-selected")&&"false"!==a.getAttribute("is-selected");let r=(""+a.textContent).trim();const i=(""+a.innerHTML).trim(),n=a.hasAttribute("value")?a.getAttribute("value"):r,s=a.hasAttribute("disabled"),u=a.hasAttribute("label")?a.getAttribute("label"):null;u&&(r=u),o.push({label:r,menuLabel:i,value:n,disabled:s,selected:l,className:a.className,dataset:a.dataset}),a.classList.add("smart-hidden")}e.dataSource=o}}render(){const e=this,t=e.dropDownClassList;if(e._getDataSourceFromOption(),e.selectedValues&&e.selectedValues.length){const t=e.selectedValues.join(",");e.value=t}e._createElement&&e._createElement();const o=e.$.scrollView;for(let e=0,a=t.length;e<a;e+=1)o.classList.add(t[e]);e.opened&&(e.opened=!1,e.open());const a=e.$.menu;a&&(a.setAttribute("role","presentation"),o.appendChild(a)),"auto"!==e.dropDownHeight?o.style.setProperty("--smart-input-drop-down-menu-height",e.dropDownHeight+"px"):o.style.setProperty("--smart-input-drop-down-menu-height","auto"),o.classList.add("smart-input-drop-down-menu");for(let t=0;t<e.classList.length;t++){const a=e.classList[t];"smart-element"!==a&&"smart-input"!==a&&o.classList.add(a+"-drop-down-menu")}o.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),o.ownerElement=e;let l=e.dataSource;if("string"==typeof l&&(l=e.$.deserialize(l,"array")),l&&l.length&&Array.isArray(l)){let t=-1;if(l.forEach(((e,o)=>{e.selected&&(t=o)})),t>=0){e.selectedIndex=t;const o=l[t];e.selectedValue="string"==typeof o?l[t]:l[t].value}}e._setAriaRelations(),e._setInputPurpose(),e._setSelection(),e.isInitialized=!0,e.hasAttribute("tabindex")&&(e.readonly||(e.$.input.setAttribute("tabindex",e.getAttribute("tabindex")),e.removeAttribute("tabindex"))),super.render()}_setSelection(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),t.selectedIndex>=0&&o&&o.length>0){let a=o[t.selectedIndex];if("number"!=typeof a&&"boolean"!=typeof a||(a=""+a),"string"==typeof a){let o=t.$.input.dataValue,l=t.value;t.set("value",a),t.$.input.dataValue=a,t.$.input.setAttribute("data-value",a),t.selectedValues=[t.$.input.dataValue],t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.value,label:t.label,oldValue:o,oldLabel:l}),t._updateTargetValue())}else{let o=t.$.input.dataValue,l=t.value;a&&(void 0!==a.value?(t.set("value",void 0!==a.value?a.value+"":""),t.$.input.dataValue=a.value,t.$.input.setAttribute("data-value",a.value),t.selectedValues=[t.$.input.dataValue]):a.label&&(t.selectedValues=[a.value]),a.label&&t.set("value",a.label)),t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.$.input.dataValue,label:a.value,oldValue:o,oldLabel:l}),t._updateTargetValue())}}}_createElement(){const e=this,t=document.createElement("ul"),o=document.createElement("smart-scroll-viewer");o.rightToLeft=e.rightToLeft,o.theme=e.theme,o.horizontalScrollBarVisibility="hidden",e.inverted?o.setAttribute("inverted",""):o.removeAttribute("inverted"),e.$.scrollView=o,e.$.menu=t,e._setFocusable();const a=e.$.input;e.$.menu.onpointerdown=function(t){const o=t.target.closest("li"),l=e.$.menu.querySelector(".active");l&&o&&(l.classList.remove("active"),o.classList.add("active")),t.stopPropagation(),t.preventDefault(),setTimeout((()=>{e._performSelect(),o&&o.parentNode&&e.$.fireEvent("itemClick",{index:[...o.parentNode.children].indexOf(o),item:o,label:o.getAttribute("aria-label"),value:o.dataValue}),a.focus()}),50)},e.$.menu.onpointerup=function(t){t.stopPropagation(),t.preventDefault(),e.$.scrollView.$.verticalScrollBar.thumbCapture&&(e.$.scrollView.$.verticalScrollBar.thumbCapture=!1)}}_setAriaRelations(){const e=this,t=e.getAttribute("aria-label");e.readonly?(e.setAttribute("role","button"),!t&&e.placeholder&&e.setAttribute("aria-label",e.placeholder),e.removeAttribute("aria-readonly"),e.$.input.setAttribute("aria-hidden",!0),e.$.input.removeAttribute("aria-activedescendant"),e.$.input.removeAttribute("aria-controls"),e.$.dropDownButton.setAttribute("aria-hidden",!0)):(e.setAttribute("role","combobox"),t&&t===e.placeholder&&e.removeAttribute("aria-label"),e.$.input.setAttribute("role","searchbox"),e.$.input.removeAttribute("aria-hidden",!0),e.$.dropDownButton.removeAttribute("aria-hidden")),e.setAttribute("aria-expanded",e.opened),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-owns",e.$.scrollView.id),e.$.scrollView.setAttribute("role","listbox")}_setActiveDescendant(e){const t=this;t.readonly||(e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant"))}_setInputPurpose(){const e=this;e.readonly?e.$.input.removeAttribute("autocomplete"):e.$.input.setAttribute("autocomplete",e.inputPurpose)}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.$.input.setAttribute("tabindex",-1):e.$.input.removeAttribute("tabindex")}});
|
|
151
151
|
|
|
152
152
|
/***/ }),
|
|
153
153
|
|
|
@@ -217,7 +217,7 @@ Smart("smart-switch-button",class extends Smart.ToggleButton{static get properti
|
|
|
217
217
|
/***/ 7341:
|
|
218
218
|
/***/ (() => {
|
|
219
219
|
|
|
220
|
-
(()=>{Smart("smart-text-area",class extends Smart.Input{static get properties(){return{users:{value:[],type:"array",reflectToAttribute:!1},resize:{value:"none",type:"string"},richText:{value:!1,type:"boolean"},enableHTMLEncode:{value:!0,type:"boolean"},minWidth:{value:0,type:"number"},minHeight:{value:0,type:"number"},toolbarOnFocus:{value:!1,type:"boolean"}}}template(){return'<div id="inputContainer" role="presentation"><textarea class="smart-input" id=\'input\' readonly=\'[[readonly]]\' placeholder=\'[[placeholder]]\' name=\'[[name]]\' value=\'{{value::keyup}}\' disabled=\'[[disabled]]\' aria-label="[[placeholder]]"></textarea><div id="editor"></div><span class="smart-hidden smart-hint" inner-h-t-m-l="[[hint]]" id="span"></span><div id="dropDownButton" tabindex=-1 class="smart-drop-down-button" role="button" aria-label="Toggle popup"><div id="arrow" class="arrow" aria-hidden="true"></div></div></div>'}_blurHandler(){const e=this;e.richText?e.removeAttribute("focus"):super._blurHandler()}_focusHandler(){const e=this;e.richText&&(e.$.editor.component.focus(),setTimeout((()=>{const t=e.$.editor.value;e.$.editor.selectionStart=t.length}))),super._focusHandler()}setHTML(e){const t=this;if(t.richText)return t.$.editor.value=e;this.value=e.replaceAll("<","<").replaceAll(">",">")}getHTML(){const e=this;return e.richText?e.$.editor.component.getHTML():e.value}propertyChangedHandler(e,t,o){const n=this;"value"===e&&n.richText&&(n.$.editor.value=o),"users"===e?(delete n._initMenu,n._mentionMenu&&(n._mentionPlugin&&n._mentionPlugin.destroy(),n._mentionMenu.remove(),n._initUsersMention()),n._renderMentionTrigger()):"resize"===e&&(n.richText?n.$.editor.querySelector(".smart-editor-editable").style.resize=o:n.$.input.style.resize=o,n._mentionTrigger&&("none"!==n.resize?n._mentionTrigger.style.right="10px":n._mentionTrigger.style.right="5px"))}detached(){const e=this;delete e._initMenu,e._mentionMenu&&e._mentionMenu.remove()}findMatches(){const e=this.$.input.value.split("").concat([" "]),t=[];let o="";for(let n in e){let i=e[n],r=e[n-1]||" ",s=[" ","\\n"].indexOf(r)>-1||10===r.charCodeAt(0);("@"===i&&s||o.length)&&" "!==i&&(o+=i),o.length&&" "===i&&(t.push({word:o,index:Math.max(n-o.length,0)}),o="")}return t}getMentions(){const e=this,t=this.findMatches(),o=[];return t.forEach((t=>{e.users.forEach((e=>{const n=t.word.replace("@","");e.name===n&&o.push(e)}))})),o}_initUsersMention(){const e=this;if(e._initMenu)return;e._initMenu=!0;const t=document.createElement("div");t.id=e.id+"_mention_menu",t.classList.add("smart-text-area-mention-menu","smart-hidden"),e._mentionMenu=t,document.body.appendChild(t),e._mentionPlugin=new Smart.Mention(e.richText?e.$.editor:e.$.input,t,(t=>""===t?e.users:e.users.filter((e=>e.name.startsWith(t)))),((e,t)=>e?`${t}${e.name} `:""),((e,t,o)=>{const n=document.createElement("div");return n.setAttribute("role","option"),n.className="smart-text-area-mention-menu-item",o&&(n.classList.add("selected"),n.setAttribute("aria-selected","")),n.textContent=e.name,n.onpointerdown=e=>{e.preventDefault(),t()},n}))}_initRichText(e,t,o){const n=this,i=n,r={};if(!e)return;o||(o={bold:"Bold",italic:"Italic",underline:"Underline",striketrhough:"Strikethrough",unorderedlist:"Bulleted list",orderedlist:"Numbered list",checklist:"Checklist",paragraph:"Paragraph",format:"Format",h1:"Large Heading",h2:"Medium Heading",h3:"Small Heading",link:"Create link",code:"Code",openLink:"Ctrl + Click to open the link"});const s=`\n <div class="smart-container">\n <div class="smart-editor-toolbar"> \n <div style="height: auto;" class="smart-editor-toolbar-items-primary">\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.bold}" command="bold" item-name="bold"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.italic}" command="italic" item-name="italic"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.underline}" command="underline" item-name="underline"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.striketrhough}" command="strikethrough" item-name="strikethrough"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.unorderedlist}" command="insertUnorderedList" item-name="unorderedlist"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.orderedlist}" command="insertOrderedList" item-name="orderedlist"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.checklist}" command="insertUnorderedList" item-name="checklist"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.link}" command="hyperlink" item-name="hyperlink"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center smart-arrow-down" item-type="button" item-name="tableheader" tooltip="${o.format}"></div>\n </div>\n </div>\n <div class="smart-editor-content-container">\n <div class="smart-editor-editable" contenteditable="true"></div>\n </div>\n </div>\n `,a=e;a.className="smart-editor smart-rich-textarea",a.style.borderLeftWidth=a.style.borderTopWidth=a.style.borderRightWidth=a.style.borderBottomWidth="0px",a.innerHTML=s;const l=a.querySelector(".smart-editor-editable");l.style.resize=n.resize,n.style.minHeight=n.minHeight+"px",l.style.minHeight=n.minHeight+"px",l.style.minWidth=n.minWidth+"px",e.style.minHeight=n.minHeight+"px",e.style.minWidth=n.minWidth+"px";const d=a.querySelectorAll(".smart-editor-toolbar-item");if(r.textarea=t,r.tools=[],r.toolbar=a.querySelector(".smart-editor-toolbar"),n.toolbarOnFocus){r.toolbar.id=n.id+"_toolbar";const e=document.createElement("div");e.classList.add("smart-editor"),e.classList.add("smart-editor-toolbar-float"),e.setAttribute("focus",""),e.appendChild(r.toolbar),a.querySelector(".smart-container").setAttribute("toolbar-on-focus",""),n.appendChild(e)}r.contentContainer=a.querySelector(".smart-editor-content-container");const c=document.createElement("div");c.className="smart-editor-tooltip",c.setAttribute("tooltip-position","bottom"),document.body.appendChild(c),r.tooltip=document.querySelector(".smart-editor-tooltip");new ResizeObserver((()=>{if("none"!==n.resize){if(n.style.width=parseInt(l.offsetWidth)+2+"px",n.toolbarOnFocus)return void(n.style.height=parseInt(l.offsetHeight)+2+"px");n.style.height=parseInt(l.offsetHeight)+r.toolbar.offsetHeight+2+"px"}})).observe(l),d.forEach((e=>{const t=e.getAttribute("item-name");r.tools[t]={element:e,type:"button"},e.onmouseenter=e=>{setTimeout((()=>{const t=e.target.getAttribute("tooltip"),o=e.target.getBoundingClientRect(),i=(r.toolbar.getBoundingClientRect(),e=>e?e.offsetTop+i(e.offsetParent):0),s=e=>e?e.offsetLeft+s(e.offsetParent):0,a=(l=e.target,{left:s(l),top:i(l)});var l;r.tooltip.style.top=5+a.top+o.height+"px",r.tooltip.setAttribute("hover-tooltip",t),r.tooltip.classList.add("open"),r.tooltip.style.left=a.left+o.width/2-r.tooltip.offsetWidth/2+"px",n._tooltipTimer&&clearTimeout(n._tooltipTimer),n._tooltipTimer=setTimeout((()=>{r.tooltip.classList.remove("open")}),1e3)}),150)},e.onmouseleave=()=>{r.tooltip.classList.remove("open")},e.onpointerdown=e=>{const t=e.target.getAttribute("item-name"),i=(e.target.getAttribute("item-value"),e.target.getAttribute("command")),s=e.target.getAttribute("command-value"),l=a.querySelector(".smart-editor-editable");if("tableheader"===t){e.preventDefault();const t=n.toolbarOnFocus?document.querySelector("#"+n.id+'_toolbar [item-name="tableheader"]'):a.querySelector('[item-name="tableheader"]');if(t._popup)t._popup.remove(),delete t._popup;else{t._popup=document.createElement("div");const e=t._popup;document.body.appendChild(e),e.style.position="absolute",e.style.height="auto",e.style.width="70px",e.style.background="var(--smart-background)",e.style.borderStyle="solid",e.style.borderWidth="1px",e.style.borderColor="var(--smart-border)",e.style.boxShadow="var(--smart-elevation-8)",e.style.zIndex=99999;const n=t.getBoundingClientRect();e.style.top=n.bottom+"px",e.style.left=n.left-20+"px",e.innerHTML=`\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.paragraph}" command="insertParagraph" command-value="p" item-name="p">P</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.h1}" command="formatBlock" command-value="H1" item-name="h1">H1</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.h2}" command="formatBlock" command-value="H2" item-name="h2">H2</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.h3}" command="formatBlock" command-value="H3" item-name="h3">H3</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.code}" command="formatBlock" command-value="pre" item-name="pre">Code</div> \n `,e.querySelectorAll(".smart-button").forEach((e=>{e.onpointerdown=e=>{t._popup.remove(),delete t._popup;const o=e.target.getAttribute("command"),n=e.target.getAttribute("command-value");a.querySelector(".smart-editor-editable").getRootNode().execCommand(o,!1,n),e.preventDefault()}}))}return}e.target.hasAttribute("checked")?e.target.removeAttribute("checked"):e.target.setAttribute("checked","");const d=n.toolbarOnFocus?document.querySelector("#"+n.id+'_toolbar [item-name="tableheader"]'):a.querySelector('[item-name="tableheader"]');switch(d._popup&&(d._popup.remove(),delete d._popup),t){case"bold":case"italic":case"underline":case"strikethrough":case"unorderedlist":case"checklist":case"orderedlist":l.getRootNode().execCommand(i,!1,null);break;case"hyperlink":{const e=r._getSelectionRange();let t,n=e.startContainer;n&&"a"!==n.nodeName.toLowerCase()&&(n=n.parentElement);let i=!1;n&&"a"===n.nodeName.toLowerCase()?(t=n.textContent,i=!0):t=e.toString(),i?(n.remove(),l.getRootNode().execCommand("insertHTML",!1,t)):t&&(l.getRootNode().execCommand("insertHTML",!1,'<a title="'+o.openLink+'" href="https://'+t.trim()+'">'+t+"</a>"),setTimeout((()=>{let e=r._getSelectionRange().startContainer;e&&"a"!==e.nodeName.toLowerCase()&&(e=e.parentElement),e&&"a"===e.nodeName.toLowerCase()&&(e.onmouseenter=t=>{t.ctrlKey&&e.classList.add("ctrl")},e.onmousemove=t=>{t.ctrlKey&&e.classList.add("ctrl")},e.onmouseleave=()=>{e.classList.remove("ctrl")})}),50));break}case"h1":case"h2":case"h3":case"p":case"pre":case"formats":l.getRootNode().execCommand(i,!1,s)}if("checklist"===t){const e=window.getSelection();if(e.focusNode){const t=e.focusNode.parentElement.closest("ul");t&&t.setAttribute("checklist","")}}e.preventDefault()}}));const m=a.querySelector(".smart-editor-editable");r.content=m,r.content.innerHTML="<div>"+t.value+"​</div>";const u=(e,o)=>{const n=r;return void 0===e&&(e=t.value),e=!o&&n.enableHtmlEncode?e.replaceAll("<","<").replaceAll(">",">"):e.replaceAll("<","<").replaceAll(">",">")};e.component=r;const h=(e,t)=>{var o=t(e);for(e=e.firstChild;!1!==o&&e;e=e.nextSibling)o=h(e,t);return o};r.getCaretPosition=e=>{var t=window.getSelection(),o=[0,0];if(t.anchorNode===e)o=[t.anchorOffset,t.extentOffset];else{var n=[t.anchorNode,t.extentNode];if(!e.contains(t.anchorNode)||!e.contains(t.extentNode))return;var i,r=[0,0];h(e,(function(e){for(i=0;i<2;i++)if(e==n[i]&&(r[i]=!0,r[0==i?1:0]))return!1;if(e.textContent&&!e.firstChild)for(i=0;i<2;i++)r[i]||(o[i]+=e.textContent.length)})),o[0]+=t.anchorOffset,o[1]+=t.extentOffset}return o[0]<=o[1]?o:[o[1],o[0]]},r.setCaretPosition=e=>{if(e>=0){const t=window.getSelection(),o=(e,t,n)=>{if(n||((n=document.createRange()).selectNode(e),n.setStart(e,0)),0===t.count)n.setEnd(e,t.count);else if(e&&t.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length<t.count?t.count-=e.textContent.length:(n.setEnd(e,t.count),t.count=0);else for(var i=0;i<e.childNodes.length&&(n=o(e.childNodes[i],t,n),0!==t.count);i++);return n},n=o(a.querySelector(".smart-editor-editable"),{count:e});n&&(n.collapse(!1),t.removeAllRanges(),t.addRange(n))}},r.execCommand=(e,t)=>{const o=m.getRootNode();o&&o.execCommand(e,!1,t)},Object.defineProperty(e,"selectionStart",{configurable:!1,enumerable:!0,get(){t.value=r.content.textContent;const e=r.getCaretPosition(r.content);return void 0!==e?e[1]:0},set(e){r.setCaretPosition(e)}}),Object.defineProperty(e,"value",{configurable:!1,enumerable:!0,get:()=>(t.value=r.content.textContent,r._getInputValue()),set(e){r.content.innerHTML="<div>"+e+"​</div>",t.value=e,i.set("value",t.value,!1)}});return r._getSelectionRange=()=>{const e=r;return e._selectionRange||e._setSelectionRange(),e._selectionRange},r._setSelectionRange=(e,t,o)=>{const n=r;let i=a.querySelector(".smart-editor-editable");const s=window.getSelection();let l;if(e){if(l=document.createRange(),"number"==typeof t&&"number"==typeof o)try{l.setStart(e,parseInt(t)),l.setEnd(e,parseInt(o))}catch(t){l.selectNodeContents(e)}else"img"===e.nodeName.toLowerCase()||e.classList.contains("smart-editor-video-container")?(l.setStartBefore(e),l.setEndAfter(e),l.selectNode(e)):l.selectNodeContents(e);s.removeAllRanges(),s.addRange(l)}else s.rangeCount&&(l=s.getRangeAt(0));try{l&&l.startContainer&&i.contains(l.startContainer)&&(r._selectionRange=l)}catch(e){}n._selectionRange||(l=document.createRange(),l.selectNodeContents(i),l.collapse(!0),r._selectionRange=l)},r._getNodeFromList=(e,t)=>{const o=r.content;if(e&&t)for(;e&&e!==o;){const o=e.nodeName.toLocaleLowerCase();if(t.indexOf(o)>-1)return o;e=e.parentElement}},r._setItemValue=(e,t)=>{const o=r;let n=t.value;e&&t&&("button"===t.type?n?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)):(n||"color-input"!==t.type?["fontname","formats"].indexOf(t.name)>-1&&(n=o.localize(t.value)||t.label||t.value):n="transparent",n?(e.setAttribute("item-value",n),e.style.setProperty("--item-value",n)):(e.removeAttribute("item-value"),e.style.removeProperty("--item-value"))))},r._getInputValue=u,r._updateToolbarItems=e=>{const t=r,o=t._getSelectionRange();if(!o)return;const n=t.content;let i,s=o.startOffset>o.endOffset?o.endContainer:o.startContainer;if(s&&(s.closest||(s=s.parentElement),s&&s.closest)){e||(e=["alignment","bold","hyperlink","italic","strikethrough","underline","fontsize","fontname","formats","fontcolor","backgroundcolor","orderedlist","unorderedlist","checklist","subscript","superscript","h1","h2","h3","code","pre"]);for(let o=0,r=e.length;o<r;o+=1){const r=e[o],a=t.tools[r];if(a){let e;if("alignment"===r)e=s.style.textAlign;else if("bold"===r)e=!!t._getNodeFromList(s,["b","strong","h4","h5","h6"]);else if("hyperlink"===r)e=!!t._getNodeFromList(s,["a"]);else if("h1"===r)e=!!t._getNodeFromList(s,["h1"]);else if("h2"===r)e=!!t._getNodeFromList(s,["h2"]);else if("h3"===r)e=!!t._getNodeFromList(s,["h3"]);else if("pre"===r)e=!!t._getNodeFromList(s,["pre"]);else if("p"===r)e=!!t._getNodeFromList(s,["p"]);else if("italic"===r)e=!!t._getNodeFromList(s,["i"]);else if("underline"===r)e=!!t._getNodeFromList(s,["u"]);else if("strikethrough"===r)e=!!t._getNodeFromList(s,["strike"]);else if("fontsize"===r){const t=s.closest(".smart-editor-editable font");t&&(e=t.style.fontSize),e||(i||(i=window.getComputedStyle(s)),e=i.fontSize),e=parseInt(e),isNaN(e)&&(e="")}else if("fontname"===r){const t=s.closest(".smart-editor-editable font");t&&t.hasAttribute("face")?e=t.getAttribute("face"):(i||(i=window.getComputedStyle(s)),e=i.fontFamily.split(",")[0])}else if("formats"===r&&s!==n){const o=["h1","h2","h3","p","pre"];if(e="",o){const n=o;e=t._getNodeFromList(s,n)||""}}else if("fontcolor"===r){const t=s.closest(".smart-editor-editable font");t?e=t.color:(i||(i=window.getComputedStyle(s)),e=i.color)}else if("backgroundcolor"===r)e=t._getNodeBackgroundColor(s),e||(i||(i=window.getComputedStyle(s)),e=i.backgroundColor);else if("orderedlist"===r||"unorderedlist"===r){e=!!s.closest(`.smart-editor-editable ${"orderedlist"===r?"ol":"ul"} li`);const t=s.closest(`.smart-editor-editable ${"orderedlist"===r?"ol":"ul"} li`);t&&t.parentElement&&t.parentElement.hasAttribute("checklist")&&(e=!1)}else if("checklist"===r){const t=s.closest(`.smart-editor-editable ${"orderedlist"===r?"ol":"ul"} li`);t&&t.parentElement.hasAttribute("checklist")&&(e=!0)}else"subscript"===r?e=!!s.closest(".smart-editor-editable sub"):"superscript"===r&&(e=!!s.closest(".smart-editor-editable sup"));if(!e&&a.dataSource){const t=a.dataSource[0];t&&(e=t.value||t)}null!==e&&(a.value=e,t._setItemValue(t.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${r}]`),a))}}}},r._getTextFromCarret=()=>{const e=r._getSelectionRange(),t=e.startContainer,o=t.textContent;let n,i;if(!e.toString()&&o.length>0&&o.indexOf(" ")>-1){const t=o.slice(0,e.startOffset).lastIndexOf(" ")+1;let r=o.slice(e.endOffset).indexOf(" ");r<0&&(r=o.length-1),n=t>-1?t:e.startOffset,i=Math.max(e.endOffset,e.endOffset+r)}else n=0,i=t.length;return{selectionStartIndex:n,selectionEndIndex:i}},r.focus=()=>{m.focus()},r.blur=()=>{m.blur()},r.getHTML=()=>u(r.content.innerHTML),m.onpointerup=e=>{const t=r,o=e.target;if(t._setSelectionRange(),t._updateToolbarItems(),e.ctrlKey){let e=t._getSelectionRange().startContainer;e&&"a"!==e.nodeName.toLowerCase()&&(e=e.parentElement),e&&"a"===e.nodeName.toLowerCase()&&window.open(e.href,"_blank")}if(o&&"LI"===o.nodeName&&o.closest("UL[checklist]")){const e=t._getSelectionRange();e&&0===e.startOffset&&0===e.endOffset&&(o.hasAttribute("checked")?o.removeAttribute("checked"):o.setAttribute("checked",""))}},m.onpaste=()=>{const e=r;e._setSelectionRange(),e._updateToolbarItems(),t.value=e.content.textContent,i.set("value",t.value,!1)},m.oninput=()=>{const e=r;e._setSelectionRange(),e._updateToolbarItems(),t.value=e.content.textContent,i.set("value",t.value,!1)},m.onkeydown=e=>{const t=r;t._setSelectionRange(),t._updateToolbarItems();let o=r._getSelectionRange().startContainer;o&&"a"!==o.nodeName.toLowerCase()&&(o=o.parentElement),o&&"a"===o.nodeName.toLowerCase()&&e.ctrlKey&&o.classList.add("ctrl")},m.onkeyup=()=>{const e=r;e._setSelectionRange(),e._updateToolbarItems(),t.value=e.content.textContent,i.set("value",t.value,!1)},m.onfocus=()=>{a.setAttribute("focus",""),i.toolbarOnFocus&&r.toolbar.parentElement.classList.add("show")},m.onblur=()=>{const e=r;a.removeAttribute("focus"),t.value=e.content.textContent,i.set("value",t.value,!1),i.toolbarOnFocus&&r.toolbar.parentElement.classList.remove("show"),r.tooltip.classList.remove("open")},document.addEventListener("selectionchange",(e=>{const t=r;if(!e.target.getSelection)return;const o=e.target.getSelection().focusNode;t.contentContainer.contains(o)&&(t._setSelectionRange(),t._updateToolbarItems())})),r}render(){const e=this;if(super.render(),e.richText)e._initRichText(e.$.editor,e.$.input);else{new ResizeObserver((()=>{"none"!==e.resize&&(e.style.width=parseInt(e.$.input.offsetWidth)+2+"px",e.style.height=parseInt(e.$.input.offsetHeight)+2+"px")})).observe(e.$.input),e.$.input.style.resize=e.resize}e._initUsersMention(),e._renderMentionTrigger(),e.classList.add("smart-input")}_renderMentionTrigger(){const e=this;if(!this.richText&&e.users&&e.users.length){e.setAttribute("has-users","");const t=document.createElement("span");t.innerHTML="@",t.style.position="absolute",t.classList.add("smart-hidden"),t.classList.add("smart-mention-trigger"),t.style.bottom="3px","none"!==e.resize?t.style.right="10px":t.style.right="5px",t.style.cursor="pointer",t.onpointerdown=t=>{const o=this.$.input.selectionEnd,n=this.$.input.value.slice(0,o),i=this.$.input.value.substring(o);return e.richText?(e.$.editor.component.execCommand("insertHTML","@"),this.$.editor.dispatchEvent(new Event("input")),void t.preventDefault()):n.length>1&&n.substring(n.length-2).indexOf("@")>=0?(this.$.input.dispatchEvent(new Event("input")),void t.preventDefault()):(n.length>0?(this.$.input.value=n+" @"+i,this.$.input.selectionStart=this.$.input.selectionEnd=o+2):0===e.$.input.selectionStart&&(this.$.input.value=n+"@ "+i,this.$.input.selectionStart=this.$.input.selectionEnd=1),this.$.input.dispatchEvent(new Event("input")),void t.preventDefault())},e._mentionTrigger=t,e.addEventListener("focus",(()=>{t.classList.remove("smart-hidden"),e._mentionPlugin&&e._mentionPlugin.refreshMenu()})),e.addEventListener("blur",(()=>{t.classList.add("smart-hidden"),e._mentionPlugin&&e._mentionPlugin.refreshMenu()})),e.onmouseenter=()=>{t.classList.remove("smart-hidden")},e.onmouseleave=()=>{t.classList.add("smart-hidden")},e.$.inputContainer.appendChild(t)}}});const e=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"];function t(t,o){const n=document.createElement("div");document.body.appendChild(n);const i=n.style;let r=getComputedStyle(t);if(t.className.indexOf("smart-editor")>=0){const e=t.querySelector(".smart-editor-editable");r=getComputedStyle(e)}i.whiteSpace="pre-wrap",i.wordWrap="break-word",i.position="absolute",i.visibility="hidden",e.forEach((e=>{i[e]=r[e]})),i.overflow="hidden",n.textContent=t.value.substring(0,o);const s=document.createElement("span");s.textContent=t.value.substring(o)||".",n.appendChild(s);const a={top:s.offsetTop+parseInt(r.borderTopWidth),left:s.offsetLeft+parseInt(r.borderLeftWidth),height:s.offsetHeight};if(t.className.indexOf("smart-editor")>=0){const e=t.getBoundingClientRect(),o=window.getSelection().getRangeAt(0).getClientRects()[0];o&&e&&(a.left=o.left-e.left,a.top=o.top-e.top)}return n.remove(),a}Smart.Mention=class{constructor(e,t,o,n,i){this.ref=e,this.menuRef=t,this.resolveFn=o,this.replaceFn=n,this.menuItemFn=i,this.options=[],this.makeOptions=this.makeOptions.bind(this),this.closeMenu=this.closeMenu.bind(this),this.selectItem=this.selectItem.bind(this),this.onInput=this.onInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.renderMenu=this.renderMenu.bind(this),this.ref.addEventListener("input",this.onInput),this.ref.addEventListener("keydown",this.onKeyDown)}destroy(){this.ref.removeEventListener("input",this.onInput),this.ref.removeEventListener("keydown",this.onKeyDown)}async makeOptions(e){const t=await this.resolveFn(e);0!==t.lenght?(this.options=t,this.renderMenu()):this.closeMenu()}closeMenu(){setTimeout((()=>{this.options=[],this.left=void 0,this.top=void 0,this.triggerIdx=void 0,this.renderMenu()}),0)}selectItem(e){return()=>{const t=this.ref.value.substr(0,this.triggerIdx),o=this.options[e],n=this.replaceFn(o,this.ref.value[this.triggerIdx]),i=this.ref.value.substr(this.ref.selectionStart),r=`${t}${n}${i}`;-1!==this.ref.className.indexOf("smart-editor")?this.ref.component.execCommand("insertHTML",o.name):(this.ref.value=r,this.ref.ownerElement&&(this.ref.ownerElement.value=r));const s=this.ref.value.length-i.length;-1===this.ref.className.indexOf("smart-editor")?this.ref.setSelectionRange(s,s):this.ref.selectionStart=s,this.ref.dispatchEvent(new Event("input")),this.closeMenu(),this.ref.focus()}}onInput(e){const o=this.ref.selectionStart,n=this.ref.value.slice(0,o),i=n.split(/\s/),r=i[i.length-1],s=n.endsWith(r)?n.length-r.length:-1;if(!("@"===n[s]))return void this.closeMenu();const a=n.slice(s+1);this.makeOptions(a);const l=t(this.ref,o),{top:d,left:c}=this.ref.getBoundingClientRect();setTimeout((()=>{this.active=0,this.left=window.scrollX+l.left+c+this.ref.scrollLeft,this.top=window.scrollY+l.top+d+l.height-this.ref.scrollTop,this.triggerIdx=s,this.renderMenu()}),0)}refreshMenu(){void 0!==this.triggerIdx&&null!==this.triggerIdx&&(this.ref===document.activeElement?this.triggerIdx&&this.menuRef.classList.remove("smart-hidden"):this.menuRef.classList.add("smart-hidden"),setTimeout((()=>{const e=this.ref.selectionStart,o=t(this.ref,e),{top:n,left:i}=this.ref.getBoundingClientRect();this.left=window.scrollX+o.left+i+this.ref.scrollLeft,this.top=window.scrollY+o.top+n+o.height-this.ref.scrollTop,this.menuRef.style.left=this.left+"px",this.menuRef.style.top=this.top+"px"})))}onKeyDown(e){let t=!1;if(void 0!==this.triggerIdx)switch(e.key){case"ArrowDown":this.active=Math.min(this.active+1,this.options.length-1),this.renderMenu(),t=!0;break;case"ArrowUp":this.active=Math.max(this.active-1,0),this.renderMenu(),t=!0;break;case"Enter":case"Tab":this.selectItem(this.active)(),t=!0}t&&e.preventDefault()}renderMenu(){return void 0===this.top?(this.menuRef.hidden=!0,void this.menuRef.classList.add("smart-hidden")):this.options.length?(this.menuRef.style.left=this.left+"px",this.menuRef.style.top=this.top+"px",this.menuRef.innerHTML="",this.ref===document.activeElement&&this.menuRef.classList.remove("smart-hidden"),this.options.forEach(((e,t)=>{this.menuRef.appendChild(this.menuItemFn(e,this.selectItem(t),this.active===t))})),this.menuRef.hidden=!1,void this.menuRef.classList.remove("smart-hidden")):(this.menuRef.hidden=!0,void this.menuRef.classList.add("smart-hidden"))}}})();
|
|
220
|
+
(()=>{Smart("smart-text-area",class extends Smart.Input{static get properties(){return{users:{value:[],type:"array",reflectToAttribute:!1},resize:{value:"none",type:"string"},richText:{value:!1,type:"boolean"},enableHTMLEncode:{value:!0,type:"boolean"},minWidth:{value:0,type:"number"},minHeight:{value:0,type:"number"},toolbarOnFocus:{value:!1,type:"boolean"},uploadSettings:{value:{url:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1},existsUrl:{value:"",type:"string",reflectToAttribute:!1},name:{value:"userfile[]",type:"string",reflectToAttribute:!1},uploadMaxCount:{value:5,type:"number",reflectToAttribute:!1},uploadMaxSize:{value:2097152,type:"number",reflectToAttribute:!1},data:{value:null,type:"object",reflectToAttribute:!1},onUploadStarted:{value:null,type:"any",reflectToAttribute:!1},onUploadCompleted:{value:null,type:"any",reflectToAttribute:!1},onUploadRemove:{value:null,type:"any",reflectToAttribute:!1},onUploadError:{value:null,type:"any",reflectToAttribute:!1},onChange:{value:null,type:"any",reflectToAttribute:!1},onProgress:{value:null,type:"any",reflectToAttribute:!1},onAbort:{value:null,type:"any",reflectToAttribute:!1},onError:{value:null,type:"any",reflectToAttribute:!1},onSetHeaders:{value:null,type:"any",reflectToAttribute:!1}},reflectToAttribute:!1,type:"object"},toolbarItems:{value:["bold","italic","underline","strikethrough","alignment","orderedlist","unorderedlist","checklist","hyperlink","image","tableheader"],reflectToAttribute:!1,type:"array"}}}template(){return'<div id="inputContainer" role="presentation"><textarea class="smart-input" id=\'input\' readonly=\'[[readonly]]\' placeholder=\'[[placeholder]]\' name=\'[[name]]\' value=\'{{value::keyup}}\' disabled=\'[[disabled]]\' aria-label="[[placeholder]]"></textarea><div id="editor"></div><span class="smart-hidden smart-hint" inner-h-t-m-l="[[hint]]" id="span"></span><div id="dropDownButton" tabindex=-1 class="smart-drop-down-button" role="button" aria-label="Toggle popup"><div id="arrow" class="arrow" aria-hidden="true"></div></div></div>'}_blurHandler(){const e=this;e.richText?e.removeAttribute("focus"):super._blurHandler()}_focusHandler(){const e=this;e.richText&&(e.$.editor.component.focus(),setTimeout((()=>{const t=e.$.editor.value;e.$.editor.selectionStart=t.length}))),super._focusHandler()}setHTML(e){const t=this;if(t.richText)return t.$.editor.value=e;this.value=e.replaceAll("<","<").replaceAll(">",">")}getHTML(){const e=this;return e.richText?e.$.editor.component.getHTML():e.value}propertyChangedHandler(e,t,o){const n=this;"value"===e&&n.richText&&(n.$.editor.value=o),"users"===e?(delete n._initMenu,n._mentionMenu&&(n._mentionPlugin&&n._mentionPlugin.destroy(),n._mentionMenu.remove(),n._initUsersMention()),n._renderMentionTrigger()):"resize"===e&&(n.richText?n.$.editor.querySelector(".smart-editor-editable").style.resize=o:n.$.input.style.resize=o,n._mentionTrigger&&("none"!==n.resize?n._mentionTrigger.style.right="10px":n._mentionTrigger.style.right="5px"))}detached(){const e=this;delete e._initMenu,e._mentionMenu&&e._mentionMenu.remove()}findMatches(){const e=this.$.input.value.split("").concat([" "]),t=[];let o="";for(let n in e){let i=e[n],r=e[n-1]||" ",s=[" ","\\n"].indexOf(r)>-1||10===r.charCodeAt(0);("@"===i&&s||o.length)&&" "!==i&&(o+=i),o.length&&" "===i&&(t.push({word:o,index:Math.max(n-o.length,0)}),o="")}return t}getMentions(){const e=this,t=this.findMatches(),o=[];return t.forEach((t=>{e.users.forEach((e=>{const n=t.word.replace("@","");e.name===n&&o.push(e)}))})),o}_initUsersMention(){const e=this;if(e._initMenu)return;e._initMenu=!0;const t=document.createElement("div");t.id=e.id+"_mention_menu",t.classList.add("smart-text-area-mention-menu","smart-hidden"),e._mentionMenu=t,document.body.appendChild(t),e._mentionPlugin=new Smart.Mention(e.richText?e.$.editor:e.$.input,t,(t=>""===t?e.users:e.users.filter((e=>e.name.startsWith(t)))),((e,t)=>e?`${t}${e.name} `:""),((e,t,o)=>{const n=document.createElement("div");return n.setAttribute("role","option"),n.className="smart-text-area-mention-menu-item",o&&(n.classList.add("selected"),n.setAttribute("aria-selected","")),n.textContent=e.name,n.onpointerdown=e=>{e.preventDefault(),t()},n}))}_initRichText(e,t,o){const n=this,i=n,r={};if(!e)return;o||(o={bold:"Bold",italic:"Italic",underline:"Underline",striketrhough:"Strikethrough",alignment:"Alignment",unorderedlist:"Bulleted list",orderedlist:"Numbered list",checklist:"Checklist",paragraph:"Paragraph",format:"Format",image:"Image",h1:"Large Heading",h2:"Medium Heading",h3:"Small Heading",link:"Create link",code:"Code",openLink:"Ctrl + Click to open the link"});const s=`\n <div class="smart-container">\n <div class="smart-editor-toolbar"> \n <div style="height: auto;" class="smart-editor-toolbar-items-primary">\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.bold}" command="bold" item-name="bold"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.italic}" command="italic" item-name="italic"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.underline}" command="underline" item-name="underline"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.striketrhough}" command="strikethrough" item-name="strikethrough"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center smart-arrow-down" item-type="button" item-value="left" item-name="alignment" command="justify" tooltip="${o.alignment}"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.unorderedlist}" command="insertUnorderedList" item-name="unorderedlist"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.orderedlist}" command="insertOrderedList" item-name="orderedlist"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.checklist}" command="insertUnorderedList" item-name="checklist"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.link}" command="hyperlink" item-name="hyperlink"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.image}" command="image" item-name="image"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center smart-arrow-down" item-type="button" item-name="tableheader" tooltip="${o.format}"></div>\n </div>\n </div>\n <div class="smart-editor-content-container">\n <div class="smart-editor-editable" contenteditable="true"></div>\n </div>\n </div>\n `,a=e;a.className="smart-editor smart-rich-textarea",a.style.borderLeftWidth=a.style.borderTopWidth=a.style.borderRightWidth=a.style.borderBottomWidth="0px",a.innerHTML=s;const l=a.querySelector(".smart-editor-editable");l.style.resize=n.resize,n.style.minHeight=n.minHeight+"px",l.style.minHeight=n.minHeight+"px",l.style.minWidth=n.minWidth+"px",e.style.minHeight=n.minHeight+"px",e.style.minWidth=n.minWidth+"px";const d=a.querySelectorAll(".smart-editor-toolbar-item");for(let e=0;e<d.length;e++){const t=d[e],o=t.getAttribute("item-name");-1===n.toolbarItems.indexOf(o)&&t.classList.add("smart-hidden")}if(r.textarea=t,r.tools=[],r.toolbar=a.querySelector(".smart-editor-toolbar"),n.toolbarOnFocus){r.toolbar.id=n.id+"_toolbar";const e=document.createElement("div");e.classList.add("smart-editor"),e.classList.add("smart-editor-toolbar-float"),e.setAttribute("focus",""),e.appendChild(r.toolbar),a.querySelector(".smart-container").setAttribute("toolbar-on-focus",""),n.appendChild(e)}r.contentContainer=a.querySelector(".smart-editor-content-container");const m=document.createElement("div");m.className="smart-editor-tooltip",m.setAttribute("tooltip-position","bottom"),document.body.appendChild(m),r.tooltip=document.querySelector(".smart-editor-tooltip");new ResizeObserver((()=>{if("none"!==n.resize){if(n.style.width=parseInt(l.offsetWidth)+2+"px",n.toolbarOnFocus)return void(n.style.height=parseInt(l.offsetHeight)+2+"px");n.style.height=parseInt(l.offsetHeight)+r.toolbar.offsetHeight+2+"px"}})).observe(l);const c=[],u=(e,t)=>{const o=this,n=new FormData,i=o.uploadSettings.url;let r=!1;const s=files[0],a=o.uploadSettings.data;a&&""!==a&&("string"==typeof a?n.append("postData",a):n.append("postData",JSON.stringify(a))),n.append("fileType",fileType);for(let e=0;e<files.length;e++)n.append(o.uploadSettings.name,files[e]),r=!0;let l=new XMLHttpRequest;l.open("POST",i),o.uploadSettings.onSetHeaders&&"function"==typeof o.uploadSettings.onSetHeaders&&o.uploadSettings.onSetHeaders(l,s),o.uploadSettings.onUploadStarted&&o.uploadSettings.onUploadStarted({files,status:l.status}),l.upload.onprogress=function(e){o.uploadSettings.onProgress&&o.uploadSettings.onProgress(e)},l.onabort=function(e){o.uploadSettings.onAbort&&o.uploadSettings.onAbort(e)},l.onerror=function(e){o.uploadSettings.onError&&o.uploadSettings.onError(e)},l.onload=function(){let e=!1;if(l.response&&("string"==typeof l.response?(e=l.response,e.indexOf("[{")>=0&&(e=JSON.parse(l.response))):e=JSON.parse(l.response)),l.status>=200&&l.status<=299){const n=(e,t)=>{if(e.response&&e.response.response&&"success"!==e.response.response)return null;let o=!1;l.fileURL&&(o=l.file_url);let n={};e&&e.file_url?o=e.file_url:e&&e[0]&&e[0].file_url&&(o=e[0].file_url);let i=!1;e&&e.file_url_small?i=e.file_url_small:e&&e[0]&&e[0].file_url_small&&(i=e[0].file_url_small);let r=!1;e&&e.file_url_medium?r=e.file_url_medium:e&&e[0]&&e[0].file_url_medium&&(r=e[0].file_url_medium);let s=!1;return e&&e.file_url_large?s=e.file_url_large:e&&e[0]&&e[0].file_url_large&&(s=e[0].file_url_large),o&&(n.value=o),i&&(n.small=i),r&&(n.medium=r),s&&(n.large=s),n.label=t,n};for(let t=0;t<files.length;t++){const i=files[t].name?[]:files[t].split("/"),r="url"===fileType?i[i.length-1]:files[t].name;o.uploadSettings.url;const s=n((e.files||e[0]&&e[0].files||[e[0]])[t],r);s&&c.push(s)}t(c,e)}else t(c,e)},l.onreadystatechange=function(){},r&&l.send(n)};d.forEach((t=>{const i=t.getAttribute("item-name");r.tools[i]={element:t,type:"button"},t.onmouseenter=e=>{setTimeout((()=>{const t=e.target.getAttribute("tooltip"),o=e.target.getBoundingClientRect(),i=(r.toolbar.getBoundingClientRect(),e=>e?e.offsetTop+i(e.offsetParent):0),s=e=>e?e.offsetLeft+s(e.offsetParent):0,a=(l=e.target,{left:s(l),top:i(l)});var l;r.tooltip.style.top=5+a.top+o.height+"px",r.tooltip.setAttribute("hover-tooltip",t),r.tooltip.classList.add("open"),r.tooltip.style.left=a.left+o.width/2-r.tooltip.offsetWidth/2+"px",n._tooltipTimer&&clearTimeout(n._tooltipTimer),n._tooltipTimer=setTimeout((()=>{r.tooltip.classList.remove("open")}),1e3)}),150)},t.onmouseleave=()=>{r.tooltip.classList.remove("open")},t.onpointerdown=t=>{const i=t.target.getAttribute("item-name"),s=(t.target.getAttribute("item-value"),t.target.getAttribute("command")),l=t.target.getAttribute("command-value"),d=a.querySelector(".smart-editor-editable"),m=e=>{if(!e||"tableheader"===e){const e=n.toolbarOnFocus?document.querySelector("#"+n.id+'_toolbar [item-name="tableheader"]'):a.querySelector('[item-name="tableheader"]');e._popup&&(e._popup.remove(),delete e._popup)}if(!e||"alignment"===e){const e=n.toolbarOnFocus?document.querySelector("#"+n.id+'_toolbar [item-name="alignment"]'):a.querySelector('[item-name="alignment"]');e._popup&&(e._popup.remove(),delete e._popup)}};if("tableheader"!==i)if("alignment"!==i){switch(m(),t.target.hasAttribute("checked")?t.target.removeAttribute("checked"):t.target.setAttribute("checked",""),i){case"bold":case"italic":case"underline":case"strikethrough":case"unorderedlist":case"checklist":case"orderedlist":d.getRootNode().execCommand(s,!1,null);break;case"image":{const t=document.createElement("input");t.type="file",t.accept="image/jpeg, image/png, image/gif",t.hidden=!0,document.body.appendChild(t);r._getSelectionRange();d.getRootNode().execCommand("insertHTML",!1,'<img style="max-width: 100%;" class="smart-hidden" id="targetImage"/>'),t.click(),t.onchange=()=>{const o=d.getRootNode().getElementById("targetImage"),i=t.files[0];o.id="",o.classList.add("smart-hidden");const r=new FileReader;r.addEventListener("load",(function(){o.src=r.result,o.classList.remove("smart-hidden")})),i&&r.readAsDataURL(i),n.uploadSettings.uploadUrl&&u(0,(t=>{t&&t.length&&(o.src=t[0].medium||t[0].value,o.classList.remove("smart-hidden"),e.imgArray||(e.imgArray=[]),e.imgArrayId||(e.imgArrayId=[]),e.imgArray.push(o.src),e.imgArrayId[o.src]=t[0])}))};break}case"hyperlink":{const e=r._getSelectionRange();let t,n=e.startContainer;n&&"a"!==n.nodeName.toLowerCase()&&(n=n.parentElement);let i=!1;n&&"a"===n.nodeName.toLowerCase()?(t=n.textContent,i=!0):t=e.toString(),i?(n.remove(),d.getRootNode().execCommand("insertHTML",!1,t)):t&&(d.getRootNode().execCommand("insertHTML",!1,'<a title="'+o.openLink+'" href="https://'+t.trim()+'">'+t+"</a>"),setTimeout((()=>{let e=r._getSelectionRange().startContainer;e&&"a"!==e.nodeName.toLowerCase()&&(e=e.parentElement),e&&"a"===e.nodeName.toLowerCase()&&(e.onmouseenter=t=>{t.ctrlKey&&e.classList.add("ctrl")},e.onmousemove=t=>{t.ctrlKey&&e.classList.add("ctrl")},e.onmouseleave=()=>{e.classList.remove("ctrl")})}),50));break}case"h1":case"h2":case"h3":case"p":case"pre":case"justify":case"formats":d.getRootNode().execCommand(s,!1,l)}if("checklist"===i){const e=window.getSelection();if(e.focusNode){const t=e.focusNode.parentElement.closest("ul");t&&t.setAttribute("checklist","")}}t.preventDefault()}else{t.preventDefault(),m("tableheader");const e=n.toolbarOnFocus?document.querySelector("#"+n.id+'_toolbar [item-name="alignment"]'):a.querySelector('[item-name="alignment"]');if(e._popup)e._popup.remove(),delete e._popup;else{e._popup=document.createElement("div");const t=e._popup;document.body.appendChild(t),t.style.position="absolute",t.style.height="auto",t.style.width="30px",t.style.background="var(--smart-background)",t.style.borderStyle="solid",t.style.borderWidth="1px",t.style.borderColor="var(--smart-border)",t.style.boxShadow="var(--smart-elevation-8)",t.style.zIndex=99999;const n=e.getBoundingClientRect();t.style.top=n.bottom+"px",t.style.left=n.left+"px",t.innerHTML=`\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.alignLeft}" command="justify" command-value="Left" item-name="alignment" item-value="left"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.alignCenter}" command="justify" command-value="Center" item-name="alignment" item-value="center"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.alignRight}" command="justify" command-value="Right" item-name="alignment" item-value="right"></div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.alignJustify}" command="justify" command-value="Full" item-name="alignment" item-value="justify"></div>\n `,t.querySelectorAll(".smart-button").forEach((t=>{t.onpointerdown=t=>{e._popup.remove(),delete e._popup;const o=t.target.getAttribute("command"),n=t.target.getAttribute("command-value");a.querySelector(".smart-editor-editable").getRootNode().execCommand(o+n,!1,null),t.preventDefault()}}))}}else{t.preventDefault(),m("alignment");const e=n.toolbarOnFocus?document.querySelector("#"+n.id+'_toolbar [item-name="tableheader"]'):a.querySelector('[item-name="tableheader"]');if(e._popup)e._popup.remove(),delete e._popup;else{e._popup=document.createElement("div");const t=e._popup;document.body.appendChild(t),t.style.position="absolute",t.style.height="auto",t.style.width="70px",t.style.background="var(--smart-background)",t.style.borderStyle="solid",t.style.borderWidth="1px",t.style.borderColor="var(--smart-border)",t.style.boxShadow="var(--smart-elevation-8)",t.style.zIndex=99999;const n=e.getBoundingClientRect();t.style.top=n.bottom+"px",t.style.left=n.left-20+"px",t.innerHTML=`\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.paragraph}" command="insertParagraph" command-value="p" item-name="p">P</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.h1}" command="formatBlock" command-value="H1" item-name="h1">H1</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.h2}" command="formatBlock" command-value="H2" item-name="h2">H2</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.h3}" command="formatBlock" command-value="H3" item-name="h3">H3</div>\n <div class="smart-button smart-editor-toolbar-item smart-editor-toolbar-item-center" item-type="button" tooltip="${o.code}" command="formatBlock" command-value="pre" item-name="pre">Code</div> \n `,t.querySelectorAll(".smart-button").forEach((t=>{t.onpointerdown=t=>{e._popup.remove(),delete e._popup;const o=t.target.getAttribute("command"),n=t.target.getAttribute("command-value");a.querySelector(".smart-editor-editable").getRootNode().execCommand(o,!1,n),t.preventDefault()}}))}}}}));const p=a.querySelector(".smart-editor-editable");r.content=p,r.content.innerHTML="<div>"+t.value+"​</div>";const h=(e,o)=>{const n=r;return void 0===e&&(e=t.value),e=!o&&n.enableHtmlEncode?e.replaceAll("<","<").replaceAll(">",">"):e.replaceAll("<","<").replaceAll(">",">")};e.component=r;const g=(e,t)=>{var o=t(e);for(e=e.firstChild;!1!==o&&e;e=e.nextSibling)o=g(e,t);return o};r.getCaretPosition=e=>{var t=window.getSelection(),o=[0,0];if(t.anchorNode===e)o=[t.anchorOffset,t.extentOffset];else{var n=[t.anchorNode,t.extentNode];if(!e.contains(t.anchorNode)||!e.contains(t.extentNode))return;var i,r=[0,0];g(e,(function(e){for(i=0;i<2;i++)if(e==n[i]&&(r[i]=!0,r[0==i?1:0]))return!1;if(e.textContent&&!e.firstChild)for(i=0;i<2;i++)r[i]||(o[i]+=e.textContent.length)})),o[0]+=t.anchorOffset,o[1]+=t.extentOffset}return o[0]<=o[1]?o:[o[1],o[0]]},r.setCaretPosition=e=>{if(e>=0){const t=window.getSelection(),o=(e,t,n)=>{if(n||((n=document.createRange()).selectNode(e),n.setStart(e,0)),0===t.count)n.setEnd(e,t.count);else if(e&&t.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length<t.count?t.count-=e.textContent.length:(n.setEnd(e,t.count),t.count=0);else for(var i=0;i<e.childNodes.length&&(n=o(e.childNodes[i],t,n),0!==t.count);i++);return n},n=o(a.querySelector(".smart-editor-editable"),{count:e});n&&(n.collapse(!1),t.removeAllRanges(),t.addRange(n))}},r.execCommand=(e,t)=>{const o=p.getRootNode();o&&o.execCommand(e,!1,t)},Object.defineProperty(e,"selectionStart",{configurable:!1,enumerable:!0,get(){t.value=r.content.textContent;const e=r.getCaretPosition(r.content);return void 0!==e?e[1]:0},set(e){r.setCaretPosition(e)}}),Object.defineProperty(e,"value",{configurable:!1,enumerable:!0,get:()=>(t.value=r.content.textContent,r._getInputValue()),set(e){r.content.innerHTML!==e&&(r.content.innerHTML="<div>"+e+"​</div>",t.value=e,i.set("value",t.value,!1),r.setCaretPosition(r.content.textContent.length-1))}});return r._getSelectionRange=()=>{const e=r;return e._selectionRange||e._setSelectionRange(),e._selectionRange},r._setSelectionRange=(e,t,o)=>{const n=r;let i=a.querySelector(".smart-editor-editable");const s=window.getSelection();let l;if(e){if(l=document.createRange(),"number"==typeof t&&"number"==typeof o)try{l.setStart(e,parseInt(t)),l.setEnd(e,parseInt(o))}catch(t){l.selectNodeContents(e)}else"img"===e.nodeName.toLowerCase()||e.classList.contains("smart-editor-video-container")?(l.setStartBefore(e),l.setEndAfter(e),l.selectNode(e)):l.selectNodeContents(e);s.removeAllRanges(),s.addRange(l)}else s.rangeCount&&(l=s.getRangeAt(0));try{l&&l.startContainer&&i.contains(l.startContainer)&&(r._selectionRange=l)}catch(e){}n._selectionRange||(l=document.createRange(),l.selectNodeContents(i),l.collapse(!0),r._selectionRange=l)},r._getNodeFromList=(e,t)=>{const o=r.content;if(e&&t)for(;e&&e!==o;){const o=e.nodeName.toLocaleLowerCase();if(t.indexOf(o)>-1)return o;e=e.parentElement}},r._setItemValue=(e,t)=>{const o=r;let n=t.value;e&&t&&("button"===t.type?n?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)):(n||"color-input"!==t.type?["fontname","formats"].indexOf(t.name)>-1&&(n=o.localize(t.value)||t.label||t.value):n="transparent",n?(e.setAttribute("item-value",n),e.style.setProperty("--item-value",n)):(e.removeAttribute("item-value"),e.style.removeProperty("--item-value"))))},r._getInputValue=h,r._updateToolbarItems=e=>{const t=r,o=t._getSelectionRange();if(!o)return;const n=t.content;let i,s=o.startOffset>o.endOffset?o.endContainer:o.startContainer;if(s&&(s.closest||(s=s.parentElement),s&&s.closest)){e||(e=["alignment","bold","hyperlink","italic","strikethrough","underline","fontsize","fontname","formats","fontcolor","backgroundcolor","orderedlist","unorderedlist","image","checklist","subscript","superscript","h1","h2","h3","code","pre"]);for(let o=0,r=e.length;o<r;o+=1){const r=e[o],a=t.tools[r];if(a){let e;if("alignment"===r)e=s.style.textAlign;else if("bold"===r)e=!!t._getNodeFromList(s,["b","strong","h4","h5","h6"]);else if("hyperlink"===r)e=!!t._getNodeFromList(s,["a"]);else if("h1"===r)e=!!t._getNodeFromList(s,["h1"]);else if("h2"===r)e=!!t._getNodeFromList(s,["h2"]);else if("h3"===r)e=!!t._getNodeFromList(s,["h3"]);else if("pre"===r)e=!!t._getNodeFromList(s,["pre"]);else if("p"===r)e=!!t._getNodeFromList(s,["p"]);else if("italic"===r)e=!!t._getNodeFromList(s,["i"]);else if("underline"===r)e=!!t._getNodeFromList(s,["u"]);else if("strikethrough"===r)e=!!t._getNodeFromList(s,["strike"]);else if("fontsize"===r){const t=s.closest(".smart-editor-editable font");t&&(e=t.style.fontSize),e||(i||(i=window.getComputedStyle(s)),e=i.fontSize),e=parseInt(e),isNaN(e)&&(e="")}else if("fontname"===r){const t=s.closest(".smart-editor-editable font");t&&t.hasAttribute("face")?e=t.getAttribute("face"):(i||(i=window.getComputedStyle(s)),e=i.fontFamily.split(",")[0])}else if("formats"===r&&s!==n){const o=["h1","h2","h3","p","pre"];if(e="",o){const n=o;e=t._getNodeFromList(s,n)||""}}else if("fontcolor"===r){const t=s.closest(".smart-editor-editable font");t?e=t.color:(i||(i=window.getComputedStyle(s)),e=i.color)}else if("backgroundcolor"===r)e=t._getNodeBackgroundColor(s),e||(i||(i=window.getComputedStyle(s)),e=i.backgroundColor);else if("orderedlist"===r||"unorderedlist"===r){e=!!s.closest(`.smart-editor-editable ${"orderedlist"===r?"ol":"ul"} li`);const t=s.closest(`.smart-editor-editable ${"orderedlist"===r?"ol":"ul"} li`);t&&t.parentElement&&t.parentElement.hasAttribute("checklist")&&(e=!1)}else if("checklist"===r){const t=s.closest(`.smart-editor-editable ${"orderedlist"===r?"ol":"ul"} li`);t&&t.parentElement.hasAttribute("checklist")&&(e=!0)}else"subscript"===r?e=!!s.closest(".smart-editor-editable sub"):"superscript"===r&&(e=!!s.closest(".smart-editor-editable sup"));if(!e&&a.dataSource){const t=a.dataSource[0];t&&(e=t.value||t)}null!==e&&(a.value=e,t._setItemValue(t.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${r}]`),a))}}}},r._getTextFromCarret=()=>{const e=r._getSelectionRange(),t=e.startContainer,o=t.textContent;let n,i;if(!e.toString()&&o.length>0&&o.indexOf(" ")>-1){const t=o.slice(0,e.startOffset).lastIndexOf(" ")+1;let r=o.slice(e.endOffset).indexOf(" ");r<0&&(r=o.length-1),n=t>-1?t:e.startOffset,i=Math.max(e.endOffset,e.endOffset+r)}else n=0,i=t.length;return{selectionStartIndex:n,selectionEndIndex:i}},r.focus=()=>{p.focus()},r.blur=()=>{p.blur()},r.getHTML=()=>h(r.content.innerHTML),p.onpointerup=e=>{const t=r,o=e.target;if(t._setSelectionRange(),t._updateToolbarItems(),e.ctrlKey){let e=t._getSelectionRange().startContainer;e&&"a"!==e.nodeName.toLowerCase()&&(e=e.parentElement),e&&"a"===e.nodeName.toLowerCase()&&window.open(e.href,"_blank")}if(o&&"LI"===o.nodeName&&o.closest("UL[checklist]")){const e=t._getSelectionRange();e&&0===e.startOffset&&0===e.endOffset&&(o.hasAttribute("checked")?o.removeAttribute("checked"):o.setAttribute("checked",""))}},p.onpaste=()=>{const e=r;e._setSelectionRange(),e._updateToolbarItems(),t.value=e.content.textContent,i.set("value",t.value,!1)},p.oninput=e=>{const o=r;o._setSelectionRange(),o._updateToolbarItems();const n=t.value;t.value=o.content.textContent,i.set("value",t.value,!1),i.$.fireEvent("input",{value:t.value,oldValue:n,html:r.getHTML()}),e.stopPropagation()},p.onkeydown=e=>{const t=r;t._setSelectionRange(),t._updateToolbarItems();let o=r._getSelectionRange().startContainer;o&&"a"!==o.nodeName.toLowerCase()&&(o=o.parentElement),o&&"a"===o.nodeName.toLowerCase()&&e.ctrlKey&&o.classList.add("ctrl")},p.onkeyup=()=>{const e=r;e._setSelectionRange(),e._updateToolbarItems(),t.value=e.content.textContent,i.set("value",t.value,!1)},p.onfocus=()=>{a.setAttribute("focus",""),i.toolbarOnFocus&&r.toolbar.parentElement.classList.add("show")},p.onblur=()=>{const o=r;a.removeAttribute("focus");const n=t.value;t.value=o.content.textContent,i.set("value",t.value,!1),i.toolbarOnFocus&&r.toolbar.parentElement.classList.remove("show"),r.tooltip.classList.remove("open"),i.$.fireEvent("change",{value:t.value,oldValue:n,html:r.getHTML()}),o.content.querySelector("img")&&i.uploadSettings.uploadUrl&&i.uploadSettings.removeUrl&&o.content.querySelectorAll("img").forEach((t=>{if(e.imgArray&&-1===e.imgArray.indexOf(t.src)&&e.uploadSettings.removeUrl){let o=new FormData,n=new XMLHttpRequest;if(o.append(e.uploadSettings.name,t.src),e.imgArrayId[t.src]){const n=e.imgArrayId[t.src].small,i=e.imgArrayId[t.src].medium,r=e.imgArrayId[t.src].large,s=e.imgArrayId[t.src].value;n&&o.append(e.uploadSettings.name+"_small",n),i&&o.append(e.uploadSettings.name+"_medium",i),r&&o.append(e.uploadSettings.name+"_large",r),s&&o.append(e.uploadSettings.name+"_value",s)}n.open("POST",e.uploadSettings.removeUrl),n.send(o)}}))},document.addEventListener("selectionchange",(e=>{const t=r;if(!e.target.getSelection)return;const o=e.target.getSelection().focusNode;t.contentContainer.contains(o)&&(t._setSelectionRange(),t._updateToolbarItems())})),r}render(){const e=this;if(super.render(),e.richText)e._initRichText(e.$.editor,e.$.input);else{new ResizeObserver((()=>{"none"!==e.resize&&(e.style.width=parseInt(e.$.input.offsetWidth)+2+"px",e.style.height=parseInt(e.$.input.offsetHeight)+2+"px")})).observe(e.$.input),e.$.input.style.resize=e.resize}e._initUsersMention(),e._renderMentionTrigger(),e.classList.add("smart-input")}_renderMentionTrigger(){const e=this;if(!this.richText&&e.users&&e.users.length){e.setAttribute("has-users","");const t=document.createElement("span");t.innerHTML="@",t.style.position="absolute",t.classList.add("smart-hidden"),t.classList.add("smart-mention-trigger"),t.style.bottom="3px","none"!==e.resize?t.style.right="10px":t.style.right="5px",t.style.cursor="pointer",t.onpointerdown=t=>{const o=this.$.input.selectionEnd,n=this.$.input.value.slice(0,o),i=this.$.input.value.substring(o);return e.richText?(e.$.editor.component.execCommand("insertHTML","@"),this.$.editor.dispatchEvent(new Event("input")),void t.preventDefault()):n.length>1&&n.substring(n.length-2).indexOf("@")>=0?(this.$.input.dispatchEvent(new Event("input")),void t.preventDefault()):(n.length>0?(this.$.input.value=n+" @"+i,this.$.input.selectionStart=this.$.input.selectionEnd=o+2):0===e.$.input.selectionStart&&(this.$.input.value=n+"@ "+i,this.$.input.selectionStart=this.$.input.selectionEnd=1),this.$.input.dispatchEvent(new Event("input")),void t.preventDefault())},e._mentionTrigger=t,e.addEventListener("focus",(()=>{t.classList.remove("smart-hidden"),e._mentionPlugin&&e._mentionPlugin.refreshMenu()})),e.addEventListener("blur",(()=>{t.classList.add("smart-hidden"),e._mentionPlugin&&e._mentionPlugin.refreshMenu()})),e.onmouseenter=()=>{t.classList.remove("smart-hidden")},e.onmouseleave=()=>{t.classList.add("smart-hidden")},e.$.inputContainer.appendChild(t)}}});const e=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"];function t(t,o){const n=document.createElement("div");document.body.appendChild(n);const i=n.style;let r=getComputedStyle(t);if(t.className.indexOf("smart-editor")>=0){const e=t.querySelector(".smart-editor-editable");r=getComputedStyle(e)}i.whiteSpace="pre-wrap",i.wordWrap="break-word",i.position="absolute",i.visibility="hidden",e.forEach((e=>{i[e]=r[e]})),i.overflow="hidden",n.textContent=t.value.substring(0,o);const s=document.createElement("span");s.textContent=t.value.substring(o)||".",n.appendChild(s);const a={top:s.offsetTop+parseInt(r.borderTopWidth),left:s.offsetLeft+parseInt(r.borderLeftWidth),height:s.offsetHeight};if(t.className.indexOf("smart-editor")>=0){const e=t.getBoundingClientRect(),o=window.getSelection().getRangeAt(0).getClientRects()[0];o&&e&&(a.left=o.left-e.left,a.top=o.top-e.top)}return n.remove(),a}Smart.Mention=class{constructor(e,t,o,n,i){this.ref=e,this.menuRef=t,this.resolveFn=o,this.replaceFn=n,this.menuItemFn=i,this.options=[],this.makeOptions=this.makeOptions.bind(this),this.closeMenu=this.closeMenu.bind(this),this.selectItem=this.selectItem.bind(this),this.onInput=this.onInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.renderMenu=this.renderMenu.bind(this),this.ref.addEventListener("input",this.onInput),this.ref.addEventListener("keydown",this.onKeyDown)}destroy(){this.ref.removeEventListener("input",this.onInput),this.ref.removeEventListener("keydown",this.onKeyDown)}async makeOptions(e){const t=await this.resolveFn(e);0!==t.lenght?(this.options=t,this.renderMenu()):this.closeMenu()}closeMenu(){setTimeout((()=>{this.options=[],this.left=void 0,this.top=void 0,this.triggerIdx=void 0,this.renderMenu()}),0)}selectItem(e){return()=>{const t=this.ref.value.substr(0,this.triggerIdx),o=this.options[e],n=this.replaceFn(o,this.ref.value[this.triggerIdx]),i=this.ref.value.substr(this.ref.selectionStart),r=`${t}${n}${i}`;-1!==this.ref.className.indexOf("smart-editor")?this.ref.component.execCommand("insertHTML",o.name):(this.ref.value=r,this.ref.ownerElement&&(this.ref.ownerElement.value=r));const s=this.ref.value.length-i.length;-1===this.ref.className.indexOf("smart-editor")?this.ref.setSelectionRange(s,s):this.ref.selectionStart=s,this.ref.dispatchEvent(new Event("input")),this.closeMenu(),this.ref.focus()}}onInput(e){const o=this.ref.selectionStart,n=this.ref.value.slice(0,o),i=n.split(/\s/),r=i[i.length-1],s=n.endsWith(r)?n.length-r.length:-1;if(!("@"===n[s]))return void this.closeMenu();const a=n.slice(s+1);this.makeOptions(a);const l=t(this.ref,o),{top:d,left:m}=this.ref.getBoundingClientRect();setTimeout((()=>{this.active=0,this.left=window.scrollX+l.left+m+this.ref.scrollLeft,this.top=window.scrollY+l.top+d+l.height-this.ref.scrollTop,this.triggerIdx=s,this.renderMenu()}),0)}refreshMenu(){void 0!==this.triggerIdx&&null!==this.triggerIdx&&(this.ref===document.activeElement?this.triggerIdx&&this.menuRef.classList.remove("smart-hidden"):this.menuRef.classList.add("smart-hidden"),setTimeout((()=>{const e=this.ref.selectionStart,o=t(this.ref,e),{top:n,left:i}=this.ref.getBoundingClientRect();this.left=window.scrollX+o.left+i+this.ref.scrollLeft,this.top=window.scrollY+o.top+n+o.height-this.ref.scrollTop,this.menuRef.style.left=this.left+"px",this.menuRef.style.top=this.top+"px"})))}onKeyDown(e){let t=!1;if(void 0!==this.triggerIdx)switch(e.key){case"ArrowDown":this.active=Math.min(this.active+1,this.options.length-1),this.renderMenu(),t=!0;break;case"ArrowUp":this.active=Math.max(this.active-1,0),this.renderMenu(),t=!0;break;case"Enter":case"Tab":this.selectItem(this.active)(),t=!0}t&&e.preventDefault()}renderMenu(){return void 0===this.top?(this.menuRef.hidden=!0,void this.menuRef.classList.add("smart-hidden")):this.options.length?(this.menuRef.style.left=this.left+"px",this.menuRef.style.top=this.top+"px",this.menuRef.innerHTML="",this.ref===document.activeElement&&this.menuRef.classList.remove("smart-hidden"),this.options.forEach(((e,t)=>{this.menuRef.appendChild(this.menuItemFn(e,this.selectItem(t),this.active===t))})),this.menuRef.hidden=!1,void this.menuRef.classList.remove("smart-hidden")):(this.menuRef.hidden=!0,void this.menuRef.classList.add("smart-hidden"))}}})();
|
|
221
221
|
|
|
222
222
|
/***/ }),
|
|
223
223
|
|
|
@@ -379,7 +379,7 @@ var __webpack_exports__ = {};
|
|
|
379
379
|
/* harmony import */ var _scripts_rrule_min_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(5453);
|
|
380
380
|
/* harmony import */ var _scripts_rrule_min_js__WEBPACK_IMPORTED_MODULE_29___default = /*#__PURE__*/__webpack_require__.n(_scripts_rrule_min_js__WEBPACK_IMPORTED_MODULE_29__);
|
|
381
381
|
|
|
382
|
-
/* Smart UI v18.0.
|
|
382
|
+
/* Smart UI v18.0.11 (2024-02-10)
|
|
383
383
|
Copyright (c) 2011-2024 jQWidgets.
|
|
384
384
|
License: https://htmlelements.com/license/ */ //
|
|
385
385
|
|